import { ServiceResponse , ServiceResult , ServiceException } from '@mds-core/mds-service-helpers' ; import logger from '@mds-core/mds-logger' ; import { RepositoryError } from '@mds-core/mds-repository' ; import { CreateJurisdictionDomainModel , JurisdictionDomainModel } from '../../@types' ; import { JurisdictionRepository } from '../repository' ; import { ValidateJurisdictionForCreate } from '../validators' ; export const createJurisdiction = async ( model ) : Promise < ServiceResponse < JurisdictionDomainModel > > => { try { const [ jurisdiction ] = await JurisdictionRepository . createJurisdictions ( [ model ] . map ( ValidateJurisdictionForCreate ) ) ; return ServiceResult ( jurisdiction ) ; } catch ( error ) { const exception = ServiceException ( 'Error Creating Jurisdiction' , RepositoryError ( error ) ) ; logger . error ( exception , error ) ; return exception ; } } ;