UNPKG

@mojaloop/ml-schema-transformer-lib

Version:
1 lines 31.7 kB
{"version":3,"sources":["../../src/lib/transformer.ts","../../src/lib/utils/index.ts","../../src/types/index.ts","../../src/lib/transforms/index.ts","../../src/lib/createTransformer.ts"],"sourcesContent":["/*****\n License\n --------------\n Copyright © 2020-2025 Mojaloop Foundation\n The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the \"License\") and you may not use these files except in compliance with the License. You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\n Contributors\n --------------\n This is the official list of the Mojaloop project contributors for this file.\n Names of the original copyright holders (individuals or organizations)\n should be listed with a '*' in the first column. People who have\n contributed from an organization can be listed under the organization\n that actually holds the copyright for their contributions (see the\n Mojaloop Foundation for an example). Those individuals should have\n their names indented and be marked with a '-'. Email address can be added\n optionally within square brackets <email>.\n\n * Mojaloop Foundation\n - Name Surname <name.surname@mojaloop.io>\n \n * Steven Oderayi <steven.oderayi@infitx.com>\n --------------\n ******/\n\nimport { ITransformer, Source, Target, TransformFunctionOptions } from '../types';\nimport { DataMapper, State } from '../types/map-transform';\nimport { createTransformer } from './createTransformer';\n\nexport const transformFn = async (source: Partial<Source>, options: TransformFunctionOptions): Promise<Partial<Target>> => {\n const { mapping, mapTransformOptions, mapperOptions, logger } = options;\n try {\n const transformer = createTransformer(mapping, { mapTransformOptions });\n return transformer.transform(source, { mapperOptions });\n } catch (error) {\n logger.error('Error transforming payload with supplied mapping', { error, source, mapping });\n throw error;\n }\n};\n\nexport class Transformer implements ITransformer {\n mapper: DataMapper;\n \n constructor(mapper: DataMapper) {\n this.mapper = mapper;\n }\n\n async transform(source: Partial<Source>, { mapperOptions }: { mapperOptions?: State } = {}): Promise<Partial<Target>> {\n return this.mapper(source, mapperOptions) as Promise<Partial<Target>>;\n }\n}\n","/*****\n License\n --------------\n Copyright © 2020-2025 Mojaloop Foundation\n The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the \"License\") and you may not use these files except in compliance with the License. You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\n Contributors\n --------------\n This is the official list of the Mojaloop project contributors for this file.\n Names of the original copyright holders (individuals or organizations)\n should be listed with a '*' in the first column. People who have\n contributed from an organization can be listed under the organization\n that actually holds the copyright for their contributions (see the\n Mojaloop Foundation for an example). Those individuals should have\n their names indented and be marked with a '-'. Email address can be added\n optionally within square brackets <email>.\n\n * Mojaloop Foundation\n - Name Surname <name.surname@mojaloop.io>\n\n * Steven Oderayi <steven.oderayi@infitx.com>\n --------------\n ******/\n\nconst idGenerator = require('@mojaloop/central-services-shared').Util.id;\nconst { CreateFSPIOPErrorFromErrorCode } = require('@mojaloop/central-services-error-handling')\nimport {\n v2_0 as fspiopAPI,\n} from '@mojaloop/api-snippets'\nimport * as ilpPacket from 'ilp-packet';\nimport { ConfigOptions, GenericObject, ID_GENERATOR_TYPE, Primitive, isContextLogger } from '../../types';\nimport { TransformDefinition } from '../../types/map-transform';\nimport { ContextLogger } from '@mojaloop/central-services-logger/src/contextLogger';\n\n// improve: use enums from cs-shared\n// We only cover the states that are externally visible\nconst fspiopToIsoTransferStateMap: GenericObject = {\n COMMITTED: 'COMM',\n RESERVED: 'RESV',\n RECEIVED: 'RECV',\n ABORTED: 'ABOR'\n}\n\n// Generates a unique ID\nexport const generateID = (idGenType: ID_GENERATOR_TYPE = ID_GENERATOR_TYPE.ulid, config: GenericObject = {}): string => {\n switch (idGenType) {\n case ID_GENERATOR_TYPE.ulid:\n case ID_GENERATOR_TYPE.uuid:\n return idGenerator({ ...config, type: idGenType })();\n default:\n return idGenerator({ ...config, type: ID_GENERATOR_TYPE.ulid })();\n }\n}\n\n// improve: import enums from cs-shared\nexport const isPersonPartyIdType = (partyIdType: string) => partyIdType && !['BUSINESS', 'ALIAS', 'DEVICE'].includes(partyIdType);\n\nexport const isEmptyObject = (data: unknown) => {\n return typeof data === 'object' && data !== null && Object.keys(data as object).length === 0;\n}\n\n// Safely sets nested property in an object\nexport const setProp = (obj: unknown, path: string, value: unknown) => {\n const pathParts = path.split('.');\n let current = obj as GenericObject;\n for (let i = 0; i < pathParts.length - 1; i++) {\n const part = pathParts[i] as string;\n if (!current[part]) {\n current[part] = {};\n }\n current = current[part];\n }\n current[pathParts[pathParts.length - 1] as string] = value;\n}\n\n// Safely gets nested property from an object\nexport const getProp = (obj: unknown, path: string): unknown => {\n const pathParts = path.split('.');\n let current = obj;\n for (const part of pathParts) {\n if (typeof current === 'object' && current !== null && part in current) {\n current = (current as GenericObject)[part];\n } else {\n return undefined;\n }\n }\n return current;\n}\n\n// Safely checks if nested property exists in an object\nexport const hasProp = (obj: unknown, path: string): boolean => {\n const pathParts = path.split('.');\n let current = obj;\n for (const part of pathParts) {\n if (typeof current === 'object' && current !== null && part in current) {\n current = (current as GenericObject)[part];\n } else {\n return false;\n }\n }\n\n return true;\n}\n\n// Merges deeply nested objects\n// e.g { a: { b: 1 } } and { a: { c: 2 } } => { a: { b: 1, c: 2 } }\nexport const deepMerge = (target: GenericObject, source: GenericObject): GenericObject => {\n for (const key in source) {\n if (source[key] instanceof Object && key in target) {\n Object.assign(source[key], deepMerge(target[key], source[key]));\n }\n }\n Object.assign(target, source);\n return target;\n}\n\n// Gets the description for an error code\nexport const getDescrForErrCode = (code: string | number): string => {\n try {\n const errorCode = Number.parseInt(code as string);\n const errorCreated = CreateFSPIOPErrorFromErrorCode(errorCode);\n return errorCreated?.apiErrorCode?.type?.description;\n } catch (error) {\n return 'Unknown error';\n }\n}\n\n// Gets the ILP packet condition from an ILP packet\nexport const getIlpPacketCondition = (inputIlpPacket: string): string => {\n const binaryPacket = Buffer.from(inputIlpPacket, 'base64');\n const decoded = ilpPacket.deserializeIlpPrepare(binaryPacket);\n return decoded?.executionCondition?.toString('base64url');\n}\n\n// Converts FSPIOP transfer state to FSPIOP ISO20022 transfer state\nexport const toIsoTransferState = (fspiopState: string): string | undefined => {\n if (!fspiopState) return undefined;\n const isoState = fspiopToIsoTransferStateMap[fspiopState] as string;\n if (!isoState) throw new Error(`toIsoTransferState: Unknown FSPIOP transfer state: ${fspiopState}`);\n return isoState;\n}\n\n// Converts FSPIOP ISO20022 transfer state to FSPIOP transfer state\nexport const toFspiopTransferState = (isoState: string): string | undefined => {\n if (!isoState) return undefined;\n for (const [key, value] of Object.entries(fspiopToIsoTransferStateMap)) {\n if (value === isoState) return key;\n }\n throw new Error(`toFspiopTransferState: Unknown ISO20022 transfer state: ${isoState}`);\n}\n\n// Validates configuration options\nexport const validateConfig = (config: ConfigOptions): void => {\n if (hasProp(config, 'logger') && !isContextLogger(config.logger as ContextLogger)) {\n throw new Error('Invalid logger provided');\n }\n}\n\n// Unrolls extensions array into an object\n// e.g [ { key: 'key1', value: 'value1' }, { key: 'key2', value: 'value2' } ] => { key1: 'value1', key2: 'value2' }\nexport const unrollExtensions = (extensions: Array<{ key: string, value: unknown }>): GenericObject => {\n const unrolled: GenericObject = {};\n for (const { key, value } of extensions) {\n setProp(unrolled, key, value);\n }\n return unrolled;\n}\n\n// Rolls up unmapped properties (i.e properties in source object not found in the mapping values - r.h.s) into extensions array\n// e.g { a: 1, b: 2 } => [ { key: 'a', value: 1 }, { key: 'b', value: 2 } ]\nexport const rollUpUnmappedAsExtensions = (source: GenericObject, mapping: TransformDefinition): Array<{ key: string, value: unknown }> => {\n const extensions = [];\n const mappingObj = mapping = typeof mapping === 'string' ? JSON.parse(mapping) : mapping;\n // we are only interested in body and $context mappings\n const mappingValues = extractValues(mappingObj)\n .map((value) => String(value))\n .filter((value) => value.startsWith('body.') || value.startsWith('$context.'))\n .map((value) => value.replace('body.', ''))\n .map((value) => value.replace(/\\$context\\.[a-zA-Z0-9]+./, ''));\n // for the source, we are only interested in body\n const sourcePaths = getObjectPaths(source.body);\n\n for (const path of sourcePaths) {\n if (!mappingValues.includes(path)) {\n const value = getProp(source.body, path);\n extensions.push({ key: path, value });\n }\n }\n\n return extensions;\n}\n\n// Extracts all leaf values from an object including values nested in arrays and objects\n// e.g { a: { b: 1, c: { d: 2, e: [ 3, 4 ] } } } => [1, 2, 3, 4]\nexport const extractValues = (obj: GenericObject) => {\n const values: Primitive[] = [];\n\n function recurse(current: GenericObject | Primitive | null) {\n if (Array.isArray(current)) {\n current.forEach(item => recurse(item));\n } else if (typeof current === 'object' && current !== null) {\n Object.values(current).forEach(value => recurse(value));\n } else {\n values.push((current as Primitive));\n }\n }\n\n recurse(obj);\n return values;\n}\n\n// Gets all paths to leaf nodes in an object\n// e.g { a: { b: 1, c: { d: 2 } } } => ['a.b', 'a.c.d']\nexport const getObjectPaths = (obj: GenericObject, prefix = '') => {\n let paths: string[] = [];\n\n for (const key in obj) {\n if (obj.hasOwnProperty(key)) {\n const path = prefix ? `${prefix}.${key}` : key;\n if (typeof obj[key] === 'object' && obj[key] !== null && !Array.isArray(obj[key])) {\n paths = paths.concat(getObjectPaths(obj[key], path));\n } else {\n paths.push(path);\n }\n }\n }\n\n return paths;\n}\n\n// Removes duplicates from an array of objects based on a unique key\n// e.g [ { id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }, { id: 1, name: 'Alice' } ] => [ { id: 1, name: 'Alice' }, { id: 2, name: 'Bob' } ]\nexport const deduplicateObjectsArray = (arr: GenericObject[], uniqueKey: string): GenericObject[] => {\n const seen = new Set();\n return arr.reduce((acc: GenericObject[], obj) => {\n if (!seen.has(obj[uniqueKey])) {\n seen.add(obj[uniqueKey]);\n acc.push(obj);\n }\n return acc;\n }, []);\n}\n\n// Extracts the first value from a semicolon-delimited string\n// e.g 'First;Middle;Last;DisplayName' => 'First'\nexport const getFirstFromDelimitedName = (name: string | undefined): string | undefined => {\n if (!name) return undefined;\n const parts = name.split(';');\n return parts[0]?.trim() || undefined;\n}\n\n// Extracts the second value from a semicolon-delimited string\n// e.g 'First;Middle;Last;DisplayName' => 'Middle'\nexport const getMiddleFromDelimitedName = (name: string | undefined): string | undefined => {\n if (!name) return undefined;\n const parts = name.split(';');\n return parts[1]?.trim() || undefined;\n}\n\n// Extracts the third value from a semicolon-delimited string\n// e.g 'First;Middle;Last;DisplayName' => 'Last'\nexport const getLastFromDelimitedName = (name: string | undefined): string | undefined => {\n if (!name) return undefined;\n const parts = name.split(';');\n return parts[2]?.trim() || undefined;\n}\n\n// Extracts the fourth value from a semicolon-delimited string\n// e.g 'First;Middle;Last;DisplayName' => 'DisplayName'\nexport const getDisplayNameFromDelimitedName = (name: string | undefined): string | undefined => {\n if (!name) return undefined;\n const parts = name.split(';');\n return parts[3]?.trim() || undefined;\n}\n\n// Creates a semicolon-delimited name string from a Party object\n// e.g a Party with first, middle, last, and display names => 'First;Middle;Last;DisplayName'\nexport const makeDelimitedName = (party: fspiopAPI.Types.Party): string | undefined => {\n const first = party?.personalInfo?.complexName?.firstName || undefined;\n const second = party?.personalInfo?.complexName?.middleName || undefined;\n const third = party?.personalInfo?.complexName?.lastName || undefined;\n const displayName = party?.name || undefined;\n if (!first && !second && !third && !displayName) return undefined;\n const parts = [first, second, third, displayName];\n return parts.join(';');\n}\n","/*****\n License\n --------------\n Copyright © 2020-2025 Mojaloop Foundation\n The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the \"License\") and you may not use these files except in compliance with the License. You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\n Contributors\n --------------\n This is the official list of the Mojaloop project contributors for this file.\n Names of the original copyright holders (individuals or organizations)\n should be listed with a '*' in the first column. People who have\n contributed from an organization can be listed under the organization\n that actually holds the copyright for their contributions (see the\n Mojaloop Foundation for an example). Those individuals should have\n their names indented and be marked with a '-'. Email address can be added\n optionally within square brackets <email>.\n\n * Mojaloop Foundation\n - Name Surname <name.surname@mojaloop.io>\n\n * Steven Oderayi <steven.oderayi@infitx.com>\n --------------\n ******/\n\nimport { ContextLogger } from '@mojaloop/central-services-logger/src/contextLogger';\nimport { AsyncTransformer, Options, State, TransformDefinition, Transformer } from './map-transform';\n\nexport enum HTTP_METHOD {\n GET = 'GET',\n PUT = 'PUT',\n POST = 'POST',\n DELETE = 'DELETE',\n PATCH = 'PATCH'\n}\n\nexport enum API_NAME {\n FSPIOP = 'fspiop',\n ISO20022 = 'iso'\n}\n\nexport interface ITransformer {\n transform(source: Partial<Source>, { mapperOptions }: { mapperOptions?: State }): Promise<Partial<Target>>;\n}\n\nexport type FacadeOptions = { overrideMapping?: TransformDefinition, mapTransformOptions?: Options, mapperOptions?: State, validateTarget?: boolean };\n\nexport type FspiopFacadeOptions = FacadeOptions & { unrollExtensions?: boolean };\nexport type FspiopFacadeFunction = (source: Source, options: FacadeOptions) => Promise<IsoTarget>;\nexport type IsoFacadeOptions = FacadeOptions & { rollUpUnmappedAsExtensions?: boolean };\nexport type IsoFacadeFunction = (source: IsoSource, options: FacadeOptions) => Promise<Partial<Target>>;\n\nexport type TransformFunctionOptions = { mapping: TransformDefinition, mapperOptions?: State, mapTransformOptions?: Options, logger: ContextLogger };\nexport type CreateTransformerOptions = { mapTransformOptions?: Options };\n\nexport enum ID_GENERATOR_TYPE {\n ulid = 'ulid',\n uuid = 'uuid'\n}\n\nexport interface ICustomTransforms {\n [key: string | symbol]: Transformer | AsyncTransformer\n}\n\nexport type ConfigOptions = {\n logger?: ContextLogger;\n isTestingMode?: boolean;\n unrollExtensions?: boolean;\n rollUpUnmappedAsExtensions?: boolean;\n validateTarget?: boolean;\n}\n\nexport type Headers = {\n 'fspiop-source': string;\n 'fspiop-destination': string;\n}\n\nexport type Params = {\n Type?: string;\n ID?: string;\n SubId?: string;\n}\n\nexport type PartyIdParamsSource = {\n Type: string;\n ID: string;\n SubId?: string;\n IdPath?: string; // format: IdType/IdValue or IdType/IdValue/SubIdValue\n} | {\n Type?: string;\n ID?: string;\n SubId?: string;\n IdPath: string; // format: IdType/IdValue or IdType/IdValue/SubIdValue\n}\n\nexport type PartyIdParamsTarget = {\n Type: string;\n ID: string;\n SubId?: string;\n}\n\nexport type Source = {\n body: GenericObject;\n headers?: Headers;\n params?: Partial<Params>;\n}\n\nexport type Target = {\n body: GenericObject;\n headers: Headers;\n params: Params;\n};\n\nexport type FspiopSource = Pick<Source, 'body'>;\nexport type FspiopTarget = Pick<Target, 'body'>;\nexport type FspiopPutQuotesSource = { body: GenericObject, params: Pick<Params, 'ID'>, $context?: { isoPostQuote: GenericObject }, headers?: Headers } | {body: GenericObject, params: Pick<Params, 'ID'>, headers: Headers, $context?: { isoPostQuote: GenericObject } };\nexport type FspiopPutQuotesTarget = { body: GenericObject, headers: Headers, params: Pick<Params, 'ID'> };\nexport type FspiopPutPartiesSource = { body: GenericObject, headers: Headers, params: PartyIdParamsSource };\nexport type FspiopPutPartiesTarget = { body: GenericObject, headers: Headers, params: PartyIdParamsTarget };\nexport type FspiopPutPartiesErrorSource = { body: GenericObject, headers: Headers, params: PartyIdParamsSource };\nexport type FspiopPutPartiesErrorTarget = { body: GenericObject, headers: Headers, params: PartyIdParamsTarget };\nexport type FspiopPostTransfersSource = { body: GenericObject, $context?: { isoPostQuoteResponse: GenericObject }, headers?: Headers } | {body: GenericObject, params: Pick<Params, 'ID'>, headers: Headers, $context?: { isoPostQuoteResponse: GenericObject } };\n\nexport type IsoSource = Pick<Source, 'body'>;\nexport type IsoTarget = Pick<Target, 'body'>;\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport type GenericObject = Record<string, any>;\nexport type Primitive = string | number | boolean;\n\n// Pipeline types\nexport type PipelineStep = ({ source, target, options, logger }: { source: GenericObject, target: GenericObject, options: GenericObject, logger: ContextLogger }) => GenericObject;\nexport type PipelineStepsConfig = { [key: string]: GenericObject };\nexport type PipelineOptions = {\n pipelineSteps: PipelineStep[];\n logger: ContextLogger;\n [key: string]: any;\n}\n\n\nexport type Json = string | number | boolean | Json[] | { [key: string]: Json };\nexport type LogContext = Json | string | null;\nexport const logLevelsMap = {\n error: 'error',\n warn: 'warn',\n info: 'info',\n verbose: 'verbose',\n debug: 'debug',\n silly: 'silly',\n audit: 'audit',\n trace: 'trace',\n perf: 'perf',\n} as const;\n\nexport const logLevelValues = Object.values(logLevelsMap);\nexport type LogLevel = (typeof logLevelValues)[number];\nexport * from './type-guards';\n\nexport type Request = {\n path: string;\n method: HTTP_METHOD;\n headers: GenericObject;\n body: GenericObject;\n query: GenericObject;\n}\n","/*****\n License\n --------------\n Copyright © 2020-2025 Mojaloop Foundation\n The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the \"License\") and you may not use these files except in compliance with the License. You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\n Contributors\n --------------\n This is the official list of the Mojaloop project contributors for this file.\n Names of the original copyright holders (individuals or organizations)\n should be listed with a '*' in the first column. People who have\n contributed from an organization can be listed under the organization\n that actually holds the copyright for their contributions (see the\n Mojaloop Foundation for an example). Those individuals should have\n their names indented and be marked with a '-'. Email address can be added\n optionally within square brackets <email>.\n\n * Mojaloop Foundation\n - Name Surname <name.surname@mojaloop.io>\n\n * Steven Oderayi <steven.oderayi@infitx.com>\n --------------\n ******/\n\nimport {\n v2_0 as fspiopAPI,\n} from '@mojaloop/api-snippets'\nimport { ICustomTransforms } from '../../types';\nimport { Options, State } from '../../types/map-transform';\nimport {\n generateID as genID,\n getDescrForErrCode,\n getIlpPacketCondition,\n isEmptyObject,\n isPersonPartyIdType,\n toFspiopTransferState,\n toIsoTransferState,\n getFirstFromDelimitedName,\n getMiddleFromDelimitedName,\n getLastFromDelimitedName,\n makeDelimitedName,\n getDisplayNameFromDelimitedName\n} from '../utils';\n\nexport const CustomTransforms: ICustomTransforms = {\n generateID: (options: Options) => () => (data: unknown, state: State) => {\n return genID();\n },\n\n datetimeNow: (options: Options) => () => (data: unknown, state: State) => {\n return new Date().toISOString(); // Not sure if this is the correct format\n },\n\n isPersonParty: (options: Options) => () => (data: unknown, state: State) => {\n return isPersonPartyIdType(data as string);\n },\n\n isNotPersonParty: (options: Options) => () => (data: unknown, state: State) => {\n return !isPersonPartyIdType(data as string);\n },\n\n isNotEmpty: (options: Options) => () => (data: unknown, state: State) => {\n return data && !isEmptyObject(data);\n },\n\n fspiopErrorDescrForCode: (options: Options) => () => (data: unknown, state: State) => {\n return getDescrForErrCode(data as string);\n },\n\n ilpPacketToCondition: (options: Options) => () => (data: unknown, state: State) => {\n return getIlpPacketCondition(data as string);\n },\n\n toFspiopTransferState: (options: Options) => () => (data: unknown, state: State) => {\n return toFspiopTransferState(data as string);\n },\n\n toIsoTransferState: (options: Options) => () => (data: unknown, state: State) => {\n return toIsoTransferState(data as string);\n },\n\n toIsoErrorDescription: (options: Options) => () => (data: unknown, state: State) => {\n // In ISO20022, error descriptions are limited to 105 characters\n const dataStr = data as string;\n return dataStr.length > 105 ? dataStr.substring(0, 105) : dataStr;\n },\n\n supportedCurrenciesToString: (options: Options) => () => (data: unknown, state: State) => {\n return data && Array.isArray(data) && data.length > 0 ? data[0] : data;\n },\n\n toArray: (options: Options) => () => (data: unknown, state: State) => {\n if (data) {\n return Array.isArray(data) ? data : [data];\n }\n\n return undefined;\n },\n\n getFirstFromDelimitedName: (options: Options) => () => (data: unknown, state: State) => {\n return getFirstFromDelimitedName(data as string);\n },\n\n getMiddleFromDelimitedName: (options: Options) => () => (data: unknown, state: State) => {\n return getMiddleFromDelimitedName(data as string);\n },\n\n getLastFromDelimitedName: (options: Options) => () => (data: unknown, state: State) => {\n return getLastFromDelimitedName(data as string);\n },\n\n getDisplayNameFromDelimitedName: (options: Options) => () => (data: unknown, state: State) => {\n return getDisplayNameFromDelimitedName(data as string);\n },\n\n makeDelimitedName: (options: Options) => () => (data: unknown, state: State) => {\n const party = data as fspiopAPI.Types.Party;\n return makeDelimitedName(party);\n }\n}\n","/*****\n License\n --------------\n Copyright © 2020-2025 Mojaloop Foundation\n The Mojaloop files are made available by the Mojaloop Foundation under the Apache License, Version 2.0 (the \"License\") and you may not use these files except in compliance with the License. You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\n Contributors\n --------------\n This is the official list of the Mojaloop project contributors for this file.\n Names of the original copyright holders (individuals or organizations)\n should be listed with a '*' in the first column. People who have\n contributed from an organization can be listed under the organization\n that actually holds the copyright for their contributions (see the\n Mojaloop Foundation for an example). Those individuals should have\n their names indented and be marked with a '-'. Email address can be added\n optionally within square brackets <email>.\n\n * Mojaloop Foundation\n - Name Surname <name.surname@mojaloop.io>\n \n * Steven Oderayi <steven.oderayi@infitx.com>\n --------------\n ******/\n\n/* eslint-disable @typescript-eslint/no-require-imports */\nconst mapTransform = require('map-transform-cjs').default;\nimport { TransformDefinition } from '../types/map-transform';\nimport { CreateTransformerOptions, ITransformer } from '../types';\nimport { Transformer } from './transformer';\nimport { CustomTransforms } from './transforms';\n\nexport const createTransformer = (mapping: TransformDefinition, options: CreateTransformerOptions = {}): ITransformer => {\n const { mapTransformOptions } = options;\n const mergedOptions = { ...mapTransformOptions, transformers: { ...mapTransformOptions?.transformers, ...CustomTransforms } };\n mapping = typeof mapping === 'string' ? JSON.parse(mapping) : mapping;\n return new Transformer(mapTransform(mapping, mergedOptions));\n};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