import { VocabularyCategory } from '@ulangi/ulangi-common/interfaces' ; import { AbstractPreparer } from '@ulangi/ulangi-common/preparers' ; import * as Joi from 'joi' ; import { VocabularyCategoryRow , VocabularyCategoryRowForUpsert , } from '../interfaces/VocabularyCategoryRow' ; export class VocabularyCategoryRowPreparer extends AbstractPreparer < VocabularyCategoryRow > { protected upsertRules = { userId : Joi . string ( ) , vocabularyId : Joi . string ( ) , categoryName : Joi . string ( ) , createdAt : Joi . date ( ) , updatedAt : Joi . date ( ) , firstSyncedAt : Joi . forbidden ( ) . strip ( ) . optional ( ) , lastSyncedAt : Joi . forbidden ( ) . strip ( ) . optional ( ) , } ; public prepareUpsert ( userId , vocabularyCategory , vocabularyId ) ; public prepareUpsert ( userId , vocabularyCategory , vocabularyId ) { const vocabularyCategoryRow = this . convertToUpsertRow ( userId , vocabularyCategory , vocabularyId ) ; return this . validateData ( vocabularyCategoryRow , this . upsertRules ) as VocabularyCategoryRowForUpsert ; } public canPrepareUpsert ( userId , vocabularyCategory , vocabularyId ) ; public canPrepareUpsert ( userId , vocabularyCategory , vocabularyId ) { const vocabularyCategoryRow = this . convertToUpsertRow ( userId , vocabularyCategory , vocabularyId ) ; return this . isValidData ( vocabularyCategoryRow , this . upsertRules ) ; } private convertToUpsertRow ( userId , vocabularyCategory , vocabularyId ) { const vocabularyCategoryRow = { userId , vocabularyId , categoryName : vocabularyCategory . categoryName , createdAt : vocabularyCategory . createdAt , updatedAt : vocabularyCategory . updatedAt , } ; return vocabularyCategoryRow ; } }