@mojaloop/ml-schema-transformer-lib
Version:
Shared component for ML schemas translation
1 lines • 8.6 kB
Source Map (JSON)
{"version":3,"sources":["../../src/lib/logger.ts","../../src/types/index.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 { loggerFactory } from '@mojaloop/central-services-logger/src/contextLogger';\nimport { LogContext, LogLevel, logLevelsMap } from '../types';\n\nexport const createLogger = (context: LogContext, logLevel: LogLevel) => {\n const log = loggerFactory(context);\n log.setLevel(logLevel);\n return log;\n};\n\nexport const logger = createLogger('MLST', process.env.MLST_LOG_LEVEL as LogLevel || logLevelsMap.warn);\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"],"mappings":";AA4BA,SAAS,qBAAqB;;;ACqHvB,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;;;AD9HjD,IAAM,eAAe,CAAC,SAAqB,aAAuB;AACvE,QAAM,MAAM,cAAc,OAAO;AACjC,MAAI,SAAS,QAAQ;AACrB,SAAO;AACT;AAEO,IAAM,SAAS,aAAa,QAAQ,QAAQ,IAAI,kBAA8B,aAAa,IAAI;","names":[]}