@mojaloop/central-services-shared 18.6.0-proxy.3 → 18.6.0-proxy.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,4 +9,3 @@ workflows:
9
9
  filters:
10
10
  tags:
11
11
  only: /v\d+(\.\d+){2}(-(snapshot|hotfix|perf)\.\d+)?/
12
-
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [18.5.2](https://github.com/mojaloop/central-services-shared/compare/v18.5.1...v18.5.2) (2024-07-04)
6
+
7
+
8
+ ### Chore
9
+
10
+ * **mojaloop/csi-190:** update enums for proxy transfer states ([#388](https://github.com/mojaloop/central-services-shared/issues/388)) ([735d30a](https://github.com/mojaloop/central-services-shared/commit/735d30a92416ec024d094affd69b41781c0e11e3))
11
+
5
12
  ### [18.5.1](https://github.com/mojaloop/central-services-shared/compare/v18.5.0...v18.5.1) (2024-06-28)
6
13
 
7
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mojaloop/central-services-shared",
3
- "version": "18.6.0-proxy.3",
3
+ "version": "18.6.0-proxy.5",
4
4
  "description": "Shared code for mojaloop central services",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
@@ -101,6 +101,7 @@ const Event = {
101
101
  POSITION_PREPARE: 'position-prepare',
102
102
  POSITION_FULFIL: 'position-fulfil',
103
103
  PREPARE: 'prepare',
104
+ FORWARDED: 'forwarded',
104
105
  PREPARE_DUPLICATE: 'prepare-duplicate',
105
106
  PROCESSING: 'processing',
106
107
  RECORD_FUNDS_IN: 'recordFundsIn',
@@ -38,6 +38,7 @@ const TransferInternalState = {
38
38
  RECEIVED_PREPARE: 'RECEIVED_PREPARE',
39
39
  RECEIVED_REJECT: 'RECEIVED_REJECT',
40
40
  RESERVED: 'RESERVED',
41
+ RESERVED_FORWARDED: 'RESERVED_FORWARDED',
41
42
  RESERVED_TIMEOUT: 'RESERVED_TIMEOUT'
42
43
  }
43
44
 
package/src/index.d.ts CHANGED
@@ -316,6 +316,7 @@ declare namespace CentralServicesShared {
316
316
  POSITION_PREPARE = 'position-prepare',
317
317
  POSITION_FULFIL = 'position-fulfil',
318
318
  PREPARE = 'prepare',
319
+ FORWARDED = 'forwarded',
319
320
  PREPARE_DUPLICATE = 'prepare-duplicate',
320
321
  PROCESSING = 'processing',
321
322
  RECORD_FUNDS_IN = 'recordFundsIn',
@@ -349,6 +350,7 @@ declare namespace CentralServicesShared {
349
350
  RECEIVED_PREPARE = 'RECEIVED_PREPARE',
350
351
  RECEIVED_REJECT = 'RECEIVED_REJECT',
351
352
  RESERVED = 'RESERVED',
353
+ RESERVED_FORWARDED = 'RESERVED_FORWARDED',
352
354
  RESERVED_TIMEOUT = 'RESERVED_TIMEOUT'
353
355
  }
354
356
 
@@ -147,6 +147,8 @@ exports.getEndpoint = async (switchUrl, fsp, endpointType, options = {}, renderO
147
147
  ).startTimer()
148
148
  switchEndpoint = switchUrl
149
149
  Logger.isDebugEnabled && Logger.debug(`participantEndpointCache::getEndpoint::endpointType - ${endpointType}`)
150
+ let proxyId
151
+ const result = url => proxyConfig ? { url, proxyId } : url
150
152
  try {
151
153
  // If a service passes in `getDecoratedValue` as true, then an object
152
154
  // { value, cached, report } is returned, where value is the cached value,
@@ -158,7 +160,7 @@ exports.getEndpoint = async (switchUrl, fsp, endpointType, options = {}, renderO
158
160
  proxy = proxyLib.createProxyCache(type, config)
159
161
  await proxy.connect()
160
162
  }
161
- const proxyId = await proxy.lookupProxyByDfspId(fsp)
163
+ proxyId = await proxy.lookupProxyByDfspId(fsp)
162
164
  endpoints = proxyId && await policy.get(proxyId)
163
165
  }
164
166
  if (!endpoints) throw ErrorHandler.CreateFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.PARTY_NOT_FOUND)
@@ -171,16 +173,16 @@ exports.getEndpoint = async (switchUrl, fsp, endpointType, options = {}, renderO
171
173
  const endpoint = new Map(endpoints.value).get(endpointType)
172
174
  if (renderOptions.path) {
173
175
  const renderedEndpoint = (endpoint === undefined) ? endpoint : endpoint + renderOptions.path
174
- return Mustache.render(renderedEndpoint, options)
176
+ return result(Mustache.render(renderedEndpoint, options))
175
177
  }
176
- return Mustache.render(endpoint, options)
178
+ return result(Mustache.render(endpoint, options))
177
179
  }
178
180
  let endpoint = new Map(endpoints).get(endpointType)
179
181
  if (renderOptions.path) {
180
182
  endpoint = (endpoint === undefined) ? endpoint : endpoint + renderOptions.path
181
183
  }
182
184
  histTimer({ success: true, hit: false })
183
- return Mustache.render(endpoint, options)
185
+ return result(Mustache.render(endpoint, options))
184
186
  } catch (err) {
185
187
  histTimer({ success: false, hit: false })
186
188
  Logger.isErrorEnabled && Logger.error(`participantEndpointCache::getEndpoint:: ERROR:'${err}'`)
@@ -122,8 +122,10 @@ Test('Cache Test', (cacheTest) => {
122
122
  { fsp: proxiedFsp }
123
123
  )
124
124
  const endpointType = FSPIOP_CALLBACK_URL_TRANSFER_PUT
125
- const expected =
126
- 'http://localhost:1080/transfers/97b01bd3-b223-415b-b37b-ab5bef9bdbed'
125
+ const expected = {
126
+ url: 'http://localhost:1080/transfers/97b01bd3-b223-415b-b37b-ab5bef9bdbed',
127
+ proxyId: 'fsp'
128
+ }
127
129
 
128
130
  await Cache.initializeCache(Config.ENDPOINT_CACHE_CONFIG, {
129
131
  hubName, hubNameRegex
@@ -144,7 +146,7 @@ Test('Cache Test', (cacheTest) => {
144
146
  undefined,
145
147
  {}
146
148
  )
147
- test.equal(result, expected, 'The results match')
149
+ test.deepEqual(result, expected, 'The results match')
148
150
 
149
151
  await Cache.stopCache()
150
152
  test.end()