{"version":3,"sources":["../../../src/lib/utils/index.ts","../../../src/types/index.ts","../../../src/lib/transforms/extensions.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\nconst idGenerator = require('@mojaloop/central-services-shared').Util.id;\nconst { CreateFSPIOPErrorFromErrorCode } = require('@mojaloop/central-services-error-handling')\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 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","/*****\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 { GenericObject } from '../../types';\nimport { deepMerge, unrollExtensions, rollUpUnmappedAsExtensions, setProp, deduplicateObjectsArray, getProp, hasProp } from '../utils';\n\n// Unrolls extensions from the source object and merges them with the target object\nexport const applyUnrollExtensions = (params: { source: GenericObject, target: GenericObject, options: GenericObject, logger: ContextLogger }) => {\n  const { source, target, options, logger } = params;\n  let extensionListProperty; \n  // determine the property path to the extension list\n  if (options.applyUnrollExtensions?.extensionListProperty) {\n    extensionListProperty = options.applyUnrollExtensions?.extensionListProperty;\n  } else if (source.body?.errorInformation) {\n    extensionListProperty = 'body.errorInformation.extensionList';\n  } else {\n    extensionListProperty = 'body.extensionList';\n  }\n  const extension = getProp(source, `${extensionListProperty}.extension`);\n  if (!options.unrollExtensions || !extension) {\n    logger.debug('Skipping unrollExtensions', { source, target, options });\n    return target;\n  }\n  \n  const unrolled = unrollExtensions(extension as any);\n  logger.debug('Unrolled extensions', { source, unrolled });\n  // we merge the unrolled extensions into the target's body only\n  target.body = deepMerge(target.body, unrolled);\n  return target;\n}\n\n// Rolls up unmapped properties from the source object into extensions and adds them to the target object's extensionList\nexport const applyRollUpUnmappedAsExtensions = (params: { source: GenericObject, target: GenericObject, options: GenericObject, logger: ContextLogger }) => {\n  const { source, target, options: { mapping },  options, logger } = params;\n  \n  if (!options.rollUpUnmappedAsExtensions) {\n    logger.debug('Skipping rollUpUnmappedAsExtensions', { source, target, mapping, options });\n    return target;\n  }\n  const extensions = rollUpUnmappedAsExtensions(source, mapping);\n  logger.debug('Rolled up unmapped properties into extensions', { source, mapping, extensions });\n\n  if (extensions.length === 0) {\n    logger.debug('No unmapped properties to roll up', { source, mapping });\n    return target;\n  }\n\n  // determine the property path for the extension list\n  let extensionListProperty; \n  if (options.applyRollUpUnmappedAsExtensions?.extensionListProperty) {\n    extensionListProperty = options.applyRollUpUnmappedAsExtensions?.extensionListProperty;\n  } else if (target.body?.errorInformation) {\n    extensionListProperty = 'body.errorInformation.extensionList';\n  } else {\n    extensionListProperty = 'body.extensionList';\n  }\n  const extensionProperty = `${extensionListProperty}.extension`;\n\n  if (!hasProp(target, extensionProperty)) {\n    setProp(target, extensionProperty, []);\n  }\n  \n  let allExtensions = getProp(target, extensionProperty) as GenericObject[];\n  allExtensions.push(...extensions);\n  allExtensions = deduplicateObjectsArray(allExtensions, 'key');\n  setProp(target, extensionProperty, allExtensions);\n\n  logger.debug('Rolled up unmapped properties into extensions', { source, target, mapping, extensions });\n\n  return target;\n}\n"],"mappings":";;;;;;;;AA8BA,YAAY,eAAe;;;ACmHpB,IAAM,eAAe;AAAA,EAC1B,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AAAA,EACP,MAAM;AACR;AAEO,IAAM,iBAAiB,OAAO,OAAO,YAAY;;;ADjIxD,IAAM,cAAc,UAAQ,mCAAmC,EAAE,KAAK;AACtE,IAAM,EAAE,+BAA+B,IAAI,UAAQ,2CAA2C;AAkCvF,IAAM,UAAU,CAAC,KAAc,MAAc,UAAmB;AACrE,QAAM,YAAY,KAAK,MAAM,GAAG;AAChC,MAAI,UAAU;AACd,WAAS,IAAI,GAAG,IAAI,UAAU,SAAS,GAAG,KAAK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