@ama-sdk/core 10.3.0-prerelease.8 → 10.3.0-rc.0
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.
- package/cjs/clients/api-angular-client.js +36 -18
- package/cjs/clients/api-beacon-client.js +61 -19
- package/cjs/clients/api-fetch-client.js +60 -18
- package/cjs/fwk/api.helper.spec.js +20 -20
- package/cjs/fwk/api.helpers.js +14 -14
- package/cjs/fwk/core/api-client.js +1 -1
- package/cjs/fwk/core/base-api-constructor.js +1 -1
- package/cjs/fwk/date.js +9 -9
- package/cjs/fwk/date.spec.js +25 -25
- package/cjs/fwk/errors.js +3 -3
- package/cjs/fwk/mocks/alf-mock-adapter.js +4 -4
- package/cjs/fwk/mocks/base-mock-adapter.js +2 -2
- package/cjs/fwk/mocks/helpers.js +3 -3
- package/cjs/fwk/reviver.spec.js +19 -19
- package/cjs/plugins/additional-params/additional-params-sync.request.js +2 -2
- package/cjs/plugins/additional-params/additional-params.request.js +3 -3
- package/cjs/plugins/additional-params/additional-params.spec.js +30 -30
- package/cjs/plugins/api-configuration-override/api-configuration-override.request.js +2 -2
- package/cjs/plugins/api-configuration-override/api-configuration-override.spec.js +13 -13
- package/cjs/plugins/api-key/api-key.request.js +2 -2
- package/cjs/plugins/api-key/api-key.spec.js +11 -11
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +5 -5
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +33 -33
- package/cjs/plugins/client-facts/client-facts.request.js +3 -3
- package/cjs/plugins/client-facts/client-facts.spec.js +27 -27
- package/cjs/plugins/concurrent/concurrent.spec.js +4 -4
- package/cjs/plugins/custom-info/custom-info.spec.js +15 -15
- package/cjs/plugins/exception/exception.reply.js +2 -2
- package/cjs/plugins/exception/exception.spec.js +15 -15
- package/cjs/plugins/fetch-cache/fetch-cache.request.js +4 -4
- package/cjs/plugins/fetch-cache/fetch-cache.spec.js +20 -20
- package/cjs/plugins/fetch-credentials/fetch-credentials.request.js +1 -1
- package/cjs/plugins/fetch-credentials/fetch-credentials.spec.js +8 -8
- package/cjs/plugins/json-token/json-token.reply.js +5 -5
- package/cjs/plugins/json-token/json-token.request.js +4 -4
- package/cjs/plugins/json-token/json-token.spec.js +24 -24
- package/cjs/plugins/keepalive/keepalive.request.js +2 -2
- package/cjs/plugins/keepalive/keepalive.spec.js +4 -4
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +11 -11
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +25 -25
- package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +3 -3
- package/cjs/plugins/mock-intercept/mock-intercept.interface.js +2 -2
- package/cjs/plugins/mock-intercept/mock-intercept.request.js +3 -3
- package/cjs/plugins/mock-intercept/mock-intercept.spec.js +28 -28
- package/cjs/plugins/perf-metric/perf-metric.fetch.js +1 -1
- package/cjs/plugins/perf-metric/perf-metric.probe.spec.js +9 -9
- package/cjs/plugins/pii-tokenizer/pii-tokenizer.request.js +11 -11
- package/cjs/plugins/pii-tokenizer/pii-tokenizer.spec.js +94 -94
- package/cjs/plugins/raw-response-info/raw-response-info.spec.js +12 -12
- package/cjs/plugins/retry/retry.spec.js +20 -20
- package/cjs/plugins/reviver/reviver.spec.js +4 -4
- package/cjs/plugins/session-id/session-id.request.js +6 -6
- package/cjs/plugins/session-id/session-id.spec.js +13 -13
- package/cjs/plugins/si-token/si-token.spec.js +9 -9
- package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +4 -4
- package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +44 -44
- package/cjs/plugins/timeout/timeout.fetch.js +11 -11
- package/cjs/plugins/timeout/timeout.spec.js +13 -13
- package/cjs/plugins/url-rewrite/url-rewrite.spec.js +9 -9
- package/cjs/plugins/wait-for/wait-for.spec.js +9 -9
- package/cjs/utils/crypto.js +14 -14
- package/cjs/utils/generic-api.js +253 -0
- package/cjs/utils/index.js +1 -0
- package/cjs/utils/json-token.js +30 -30
- package/cjs/utils/json-token.spec.js +31 -31
- package/cli/clear-index.cjs.map +1 -0
- package/cli/files-pack.cjs.map +1 -0
- package/esm2015/clients/api-angular-client.js +40 -22
- package/esm2015/clients/api-beacon-client.js +62 -20
- package/esm2015/clients/api-fetch-client.js +64 -22
- package/esm2015/clients/index.js +2 -2
- package/esm2015/fwk/api.helper.spec.js +21 -21
- package/esm2015/fwk/api.helpers.js +14 -14
- package/esm2015/fwk/core/api-client.js +1 -1
- package/esm2015/fwk/core/base-api-constructor.js +1 -1
- package/esm2015/fwk/core/index.js +2 -2
- package/esm2015/fwk/date.js +9 -9
- package/esm2015/fwk/date.spec.js +26 -26
- package/esm2015/fwk/errors.js +3 -3
- package/esm2015/fwk/index.js +10 -10
- package/esm2015/fwk/mocks/alf-mock-adapter.js +6 -6
- package/esm2015/fwk/mocks/base-mock-adapter.js +3 -3
- package/esm2015/fwk/mocks/helpers.js +3 -3
- package/esm2015/fwk/mocks/index.js +10 -10
- package/esm2015/fwk/mocks/random-mock-adapter.js +1 -1
- package/esm2015/fwk/mocks/sequential-mock-adapter.js +1 -1
- package/esm2015/fwk/reviver.spec.js +20 -20
- package/esm2015/plugins/additional-params/additional-params-sync.request.js +3 -3
- package/esm2015/plugins/additional-params/additional-params.request.js +3 -3
- package/esm2015/plugins/additional-params/additional-params.spec.js +32 -32
- package/esm2015/plugins/additional-params/index.js +2 -2
- package/esm2015/plugins/api-configuration-override/api-configuration-override.request.js +2 -2
- package/esm2015/plugins/api-configuration-override/api-configuration-override.spec.js +14 -14
- package/esm2015/plugins/api-configuration-override/index.js +1 -1
- package/esm2015/plugins/api-key/api-key.request.js +2 -2
- package/esm2015/plugins/api-key/api-key.spec.js +12 -12
- package/esm2015/plugins/api-key/index.js +1 -1
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +5 -5
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +34 -34
- package/esm2015/plugins/bot-protection-fingerprint/index.js +1 -1
- package/esm2015/plugins/client-facts/client-facts.request.js +4 -4
- package/esm2015/plugins/client-facts/client-facts.spec.js +28 -28
- package/esm2015/plugins/client-facts/index.js +1 -1
- package/esm2015/plugins/concurrent/concurrent.spec.js +5 -5
- package/esm2015/plugins/concurrent/index.js +1 -1
- package/esm2015/plugins/core/index.js +4 -4
- package/esm2015/plugins/custom-info/custom-info.spec.js +17 -17
- package/esm2015/plugins/custom-info/index.js +1 -1
- package/esm2015/plugins/exception/exception.reply.js +4 -4
- package/esm2015/plugins/exception/exception.spec.js +18 -18
- package/esm2015/plugins/exception/index.js +1 -1
- package/esm2015/plugins/fetch-cache/fetch-cache.request.js +4 -4
- package/esm2015/plugins/fetch-cache/fetch-cache.spec.js +21 -21
- package/esm2015/plugins/fetch-cache/index.js +1 -1
- package/esm2015/plugins/fetch-credentials/fetch-credentials.request.js +1 -1
- package/esm2015/plugins/fetch-credentials/fetch-credentials.spec.js +9 -9
- package/esm2015/plugins/fetch-credentials/index.js +1 -1
- package/esm2015/plugins/index.js +25 -25
- package/esm2015/plugins/json-token/index.js +2 -2
- package/esm2015/plugins/json-token/json-token.reply.js +5 -5
- package/esm2015/plugins/json-token/json-token.request.js +4 -4
- package/esm2015/plugins/json-token/json-token.spec.js +27 -27
- package/esm2015/plugins/keepalive/index.js +1 -1
- package/esm2015/plugins/keepalive/keepalive.request.js +2 -2
- package/esm2015/plugins/keepalive/keepalive.spec.js +5 -5
- package/esm2015/plugins/mgw-mdw-auth/index.js +1 -1
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +13 -13
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +27 -27
- package/esm2015/plugins/mock-intercept/index.js +2 -2
- package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +5 -5
- package/esm2015/plugins/mock-intercept/mock-intercept.interface.js +2 -2
- package/esm2015/plugins/mock-intercept/mock-intercept.request.js +4 -4
- package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +32 -32
- package/esm2015/plugins/perf-metric/index.js +1 -1
- package/esm2015/plugins/perf-metric/perf-metric.fetch.js +2 -2
- package/esm2015/plugins/perf-metric/perf-metric.probe.spec.js +10 -10
- package/esm2015/plugins/pii-tokenizer/index.js +1 -1
- package/esm2015/plugins/pii-tokenizer/pii-tokenizer.request.js +12 -12
- package/esm2015/plugins/pii-tokenizer/pii-tokenizer.spec.js +96 -96
- package/esm2015/plugins/raw-response-info/index.js +1 -1
- package/esm2015/plugins/raw-response-info/raw-response-info.spec.js +14 -14
- package/esm2015/plugins/retry/index.js +1 -1
- package/esm2015/plugins/retry/retry.fetch.js +1 -1
- package/esm2015/plugins/retry/retry.spec.js +21 -21
- package/esm2015/plugins/reviver/index.js +1 -1
- package/esm2015/plugins/reviver/reviver.spec.js +6 -6
- package/esm2015/plugins/session-id/index.js +1 -1
- package/esm2015/plugins/session-id/session-id.request.js +7 -7
- package/esm2015/plugins/session-id/session-id.spec.js +14 -14
- package/esm2015/plugins/si-token/index.js +1 -1
- package/esm2015/plugins/si-token/si-token.request.js +1 -1
- package/esm2015/plugins/si-token/si-token.spec.js +10 -10
- package/esm2015/plugins/simple-api-key-authentication/index.js +1 -1
- package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +5 -5
- package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +46 -46
- package/esm2015/plugins/timeout/index.js +1 -1
- package/esm2015/plugins/timeout/timeout.fetch.js +12 -12
- package/esm2015/plugins/timeout/timeout.spec.js +15 -15
- package/esm2015/plugins/url-rewrite/index.js +1 -1
- package/esm2015/plugins/url-rewrite/url-rewrite.spec.js +10 -10
- package/esm2015/plugins/wait-for/index.js +1 -1
- package/esm2015/plugins/wait-for/wait-for.spec.js +10 -10
- package/esm2015/public_api.js +4 -4
- package/esm2015/utils/crypto.js +15 -15
- package/esm2015/utils/generic-api.js +245 -0
- package/esm2015/utils/index.js +6 -5
- package/esm2015/utils/json-token.js +32 -32
- package/esm2015/utils/json-token.spec.js +32 -32
- package/package.json +7 -7
- package/schematics/ng-add/index.js.map +1 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/src/clients/api-angular-client.d.ts +6 -3
- package/src/clients/api-angular-client.d.ts.map +1 -1
- package/src/clients/api-angular-client.js +23 -11
- package/src/clients/api-angular-client.js.map +1 -1
- package/src/clients/api-beacon-client.d.ts +7 -5
- package/src/clients/api-beacon-client.d.ts.map +1 -1
- package/src/clients/api-beacon-client.js +22 -14
- package/src/clients/api-beacon-client.js.map +1 -1
- package/src/clients/api-fetch-client.d.ts +5 -3
- package/src/clients/api-fetch-client.d.ts.map +1 -1
- package/src/clients/api-fetch-client.js +22 -11
- package/src/clients/api-fetch-client.js.map +1 -1
- package/src/fwk/api.helpers.d.ts +1 -1
- package/src/fwk/api.helpers.d.ts.map +1 -1
- package/src/fwk/api.helpers.js +1 -1
- package/src/fwk/api.helpers.js.map +1 -1
- package/src/fwk/core/api-client.d.ts +36 -1
- package/src/fwk/core/api-client.d.ts.map +1 -1
- package/src/fwk/core/api-client.js.map +1 -1
- package/src/plugins/core/plugin.d.ts +6 -1
- package/src/plugins/core/plugin.d.ts.map +1 -1
- package/src/plugins/core/reply-plugin.d.ts +0 -2
- package/src/plugins/core/reply-plugin.d.ts.map +1 -1
- package/src/utils/generic-api.d.ts +39 -0
- package/src/utils/generic-api.d.ts.map +1 -0
- package/src/utils/generic-api.js +43 -0
- package/src/utils/generic-api.js.map +1 -0
- package/src/utils/index.d.ts +1 -0
- package/src/utils/index.d.ts.map +1 -1
- package/src/utils/index.js +1 -0
- package/src/utils/index.js.map +1 -1
|
@@ -95,6 +95,30 @@ function _object_spread(target) {
|
|
|
95
95
|
}
|
|
96
96
|
return target;
|
|
97
97
|
}
|
|
98
|
+
function ownKeys(object, enumerableOnly) {
|
|
99
|
+
var keys = Object.keys(object);
|
|
100
|
+
if (Object.getOwnPropertySymbols) {
|
|
101
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
102
|
+
if (enumerableOnly) {
|
|
103
|
+
symbols = symbols.filter(function(sym) {
|
|
104
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
keys.push.apply(keys, symbols);
|
|
108
|
+
}
|
|
109
|
+
return keys;
|
|
110
|
+
}
|
|
111
|
+
function _object_spread_props(target, source) {
|
|
112
|
+
source = source != null ? source : {};
|
|
113
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
114
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
115
|
+
} else {
|
|
116
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
117
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return target;
|
|
121
|
+
}
|
|
98
122
|
function _to_consumable_array(arr) {
|
|
99
123
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
100
124
|
}
|
|
@@ -201,10 +225,10 @@ function _ts_generator(thisArg, body) {
|
|
|
201
225
|
};
|
|
202
226
|
}
|
|
203
227
|
}
|
|
204
|
-
import { ExceptionReply } from
|
|
205
|
-
import { ReviverReply } from
|
|
206
|
-
import { extractQueryParams, filterUndefinedValues, getResponseReviver, prepareUrl, processFormData, tokenizeRequestOptions } from
|
|
207
|
-
import { CanceledCallError, EmptyResponseError, ResponseJSONParseError } from
|
|
228
|
+
import { ExceptionReply } from '../plugins/exception';
|
|
229
|
+
import { ReviverReply } from '../plugins/reviver';
|
|
230
|
+
import { extractQueryParams, filterUndefinedValues, getResponseReviver, prepareUrl, processFormData, tokenizeRequestOptions } from '../fwk/api.helpers';
|
|
231
|
+
import { CanceledCallError, EmptyResponseError, ResponseJSONParseError } from '../fwk/errors';
|
|
208
232
|
var DEFAULT_OPTIONS = {
|
|
209
233
|
replyPlugins: [
|
|
210
234
|
new ReviverReply(),
|
|
@@ -236,24 +260,18 @@ var DEFAULT_OPTIONS = {
|
|
|
236
260
|
}
|
|
237
261
|
},
|
|
238
262
|
{
|
|
239
|
-
key: "
|
|
240
|
-
value: /** @inheritdoc */ function
|
|
263
|
+
key: "getRequestOptions",
|
|
264
|
+
value: /** @inheritdoc */ function getRequestOptions(requestOptionsParameters) {
|
|
241
265
|
var _this = this;
|
|
242
266
|
return _async_to_generator(function() {
|
|
243
|
-
var
|
|
267
|
+
var opts, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plugin, _requestOptionsParameters_api, err;
|
|
244
268
|
return _ts_generator(this, function(_state) {
|
|
245
269
|
switch(_state.label){
|
|
246
270
|
case 0:
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
queryParams: filterUndefinedValues(queryParams),
|
|
252
|
-
basePath: url,
|
|
253
|
-
tokenizedOptions: tokenizedOptions,
|
|
254
|
-
metadata: metadata
|
|
255
|
-
};
|
|
256
|
-
opts = options;
|
|
271
|
+
opts = _object_spread_props(_object_spread({}, requestOptionsParameters), {
|
|
272
|
+
headers: new Headers(filterUndefinedValues(requestOptionsParameters.headers)),
|
|
273
|
+
queryParams: filterUndefinedValues(requestOptionsParameters.queryParams)
|
|
274
|
+
});
|
|
257
275
|
if (!_this.options.requestPlugins) return [
|
|
258
276
|
3,
|
|
259
277
|
8
|
|
@@ -278,7 +296,8 @@ var DEFAULT_OPTIONS = {
|
|
|
278
296
|
return [
|
|
279
297
|
4,
|
|
280
298
|
plugin.load({
|
|
281
|
-
logger: _this.options.logger
|
|
299
|
+
logger: _this.options.logger,
|
|
300
|
+
apiName: (_requestOptionsParameters_api = requestOptionsParameters.api) === null || _requestOptionsParameters_api === void 0 ? void 0 : _requestOptionsParameters_api.apiName
|
|
282
301
|
}).transform(opts)
|
|
283
302
|
];
|
|
284
303
|
case 3:
|
|
@@ -326,6 +345,29 @@ var DEFAULT_OPTIONS = {
|
|
|
326
345
|
})();
|
|
327
346
|
}
|
|
328
347
|
},
|
|
348
|
+
{
|
|
349
|
+
key: "prepareOptions",
|
|
350
|
+
value: /** @inheritdoc */ function prepareOptions(url, method, queryParams, headers, body, tokenizedOptions, metadata, api) {
|
|
351
|
+
var _this = this;
|
|
352
|
+
return _async_to_generator(function() {
|
|
353
|
+
return _ts_generator(this, function(_state) {
|
|
354
|
+
return [
|
|
355
|
+
2,
|
|
356
|
+
_this.getRequestOptions({
|
|
357
|
+
headers: headers,
|
|
358
|
+
method: method,
|
|
359
|
+
basePath: url,
|
|
360
|
+
queryParams: queryParams,
|
|
361
|
+
body: body,
|
|
362
|
+
metadata: metadata,
|
|
363
|
+
tokenizedOptions: tokenizedOptions,
|
|
364
|
+
api: api
|
|
365
|
+
})
|
|
366
|
+
];
|
|
367
|
+
});
|
|
368
|
+
})();
|
|
369
|
+
}
|
|
370
|
+
},
|
|
329
371
|
{
|
|
330
372
|
key: "prepareUrl",
|
|
331
373
|
value: /** @inheritdoc */ function prepareUrl1(url) {
|
|
@@ -348,7 +390,7 @@ var DEFAULT_OPTIONS = {
|
|
|
348
390
|
return _ts_generator(this, function(_state) {
|
|
349
391
|
switch(_state.label){
|
|
350
392
|
case 0:
|
|
351
|
-
origin = options.headers.get(
|
|
393
|
+
origin = options.headers.get('Origin');
|
|
352
394
|
_state.label = 1;
|
|
353
395
|
case 1:
|
|
354
396
|
_state.trys.push([
|
|
@@ -361,7 +403,7 @@ var DEFAULT_OPTIONS = {
|
|
|
361
403
|
metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.throwIfAborted();
|
|
362
404
|
controller = new AbortController();
|
|
363
405
|
options.signal = controller.signal;
|
|
364
|
-
metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.addEventListener(
|
|
406
|
+
metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.addEventListener('abort', function() {
|
|
365
407
|
return controller.abort();
|
|
366
408
|
});
|
|
367
409
|
loadedPlugins = [];
|
|
@@ -439,7 +481,7 @@ var DEFAULT_OPTIONS = {
|
|
|
439
481
|
if (_instanceof(e, CanceledCallError)) {
|
|
440
482
|
exception = e;
|
|
441
483
|
} else {
|
|
442
|
-
exception = new EmptyResponseError(e.message ||
|
|
484
|
+
exception = new EmptyResponseError(e.message || 'Fail to Fetch', undefined, {
|
|
443
485
|
apiName: apiName,
|
|
444
486
|
operationId: operationId,
|
|
445
487
|
url: url,
|
|
@@ -454,7 +496,7 @@ var DEFAULT_OPTIONS = {
|
|
|
454
496
|
try {
|
|
455
497
|
root = body ? JSON.parse(body) : undefined;
|
|
456
498
|
} catch (e) {
|
|
457
|
-
exception = new ResponseJSONParseError(e.message ||
|
|
499
|
+
exception = new ResponseJSONParseError(e.message || 'Fail to parse response body', response && response.status || 0, body, {
|
|
458
500
|
apiName: apiName,
|
|
459
501
|
operationId: operationId,
|
|
460
502
|
url: url,
|
package/esm2015/clients/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './api-beacon-client';
|
|
2
|
+
export * from './api-fetch-client';
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable no-console */ import { getResponseReviver } from
|
|
2
|
-
describe(
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable no-console */ import { getResponseReviver } from '@ama-sdk/core';
|
|
2
|
+
describe('getResponseReviver - revivers by status code', function() {
|
|
3
3
|
var revivers = {
|
|
4
4
|
202: jest.fn(),
|
|
5
5
|
201: jest.fn()
|
|
6
6
|
};
|
|
7
7
|
beforeEach(function() {
|
|
8
|
-
jest.spyOn(console,
|
|
8
|
+
jest.spyOn(console, 'error');
|
|
9
9
|
});
|
|
10
10
|
afterEach(function() {
|
|
11
11
|
jest.clearAllMocks();
|
|
12
12
|
});
|
|
13
|
-
it(
|
|
13
|
+
it('should not return a reviver for a non ok response', function() {
|
|
14
14
|
expect(getResponseReviver(revivers, {
|
|
15
15
|
status: 300,
|
|
16
16
|
ok: false
|
|
17
17
|
})).toBe(undefined);
|
|
18
18
|
});
|
|
19
|
-
it(
|
|
19
|
+
it('should return a reason but not reviver for a 204 No Content Response', function() {
|
|
20
20
|
expect(getResponseReviver(revivers, {
|
|
21
21
|
status: 204,
|
|
22
22
|
ok: true
|
|
23
23
|
})).toBe(undefined);
|
|
24
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
24
|
+
expect(console.error).toHaveBeenCalledWith('API status code error for unknown endpoint - 204 response is not defined in the API specification');
|
|
25
25
|
});
|
|
26
|
-
it(
|
|
26
|
+
it('should return the status code\'s reviver', function() {
|
|
27
27
|
expect(getResponseReviver(revivers, {
|
|
28
28
|
status: 202,
|
|
29
29
|
ok: true
|
|
30
|
-
},
|
|
30
|
+
}, 'myEndpoint')).toBe(revivers[202]);
|
|
31
31
|
expect(console.error).not.toHaveBeenCalled();
|
|
32
32
|
});
|
|
33
|
-
it(
|
|
33
|
+
it('should fallback on the first defined status if the status code\'s reviver is not defined', function() {
|
|
34
34
|
expect(getResponseReviver(revivers, {
|
|
35
35
|
status: undefined,
|
|
36
36
|
ok: true
|
|
37
|
-
},
|
|
38
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
37
|
+
}, 'myEndpoint')).toBe(revivers[201]);
|
|
38
|
+
expect(console.error).toHaveBeenCalledWith('API status code error for myEndpoint endpoint - Unknown undefined code returned by the API - Fallback to 201\'s reviver');
|
|
39
39
|
});
|
|
40
|
-
it(
|
|
40
|
+
it('should not fallback on 204 (No Content)\'s reviver', function() {
|
|
41
41
|
var reviversWith204 = {
|
|
42
42
|
204: jest.fn(),
|
|
43
43
|
206: jest.fn()
|
|
@@ -45,33 +45,33 @@ describe("getResponseReviver - revivers by status code", function() {
|
|
|
45
45
|
var fallback = getResponseReviver(reviversWith204, {
|
|
46
46
|
status: 201,
|
|
47
47
|
ok: true
|
|
48
|
-
},
|
|
48
|
+
}, 'myEndpoint');
|
|
49
49
|
expect(fallback).toBe(reviversWith204[206]);
|
|
50
50
|
expect(fallback).not.toBe(reviversWith204[204]);
|
|
51
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
51
|
+
expect(console.error).toHaveBeenCalledWith('API status code error for myEndpoint endpoint - Unknown 201 code returned by the API - Fallback to 206\'s reviver');
|
|
52
52
|
});
|
|
53
|
-
it(
|
|
54
|
-
jest.spyOn(console,
|
|
53
|
+
it('should not fallback if the feature is deactivated', function() {
|
|
54
|
+
jest.spyOn(console, 'log');
|
|
55
55
|
expect(getResponseReviver(revivers, {
|
|
56
56
|
status: 206,
|
|
57
57
|
ok: true
|
|
58
|
-
},
|
|
58
|
+
}, 'myEndpoint', {
|
|
59
59
|
disableFallback: true,
|
|
60
60
|
log: console.log
|
|
61
61
|
})).toBe(undefined);
|
|
62
62
|
expect(console.error).not.toHaveBeenCalled();
|
|
63
|
-
expect(console.log).toHaveBeenCalledWith(
|
|
63
|
+
expect(console.log).toHaveBeenCalledWith('API status code error for myEndpoint endpoint - Missing 206 from API specification - fallback is deactivated, no revive will run on this response');
|
|
64
64
|
});
|
|
65
65
|
});
|
|
66
|
-
describe(
|
|
66
|
+
describe('getResponseReviver - reviver as function', function() {
|
|
67
67
|
var reviver = jest.fn();
|
|
68
|
-
it(
|
|
68
|
+
it('should not return a reviver for a non ok response', function() {
|
|
69
69
|
expect(getResponseReviver(reviver, {
|
|
70
70
|
status: 300,
|
|
71
71
|
ok: false
|
|
72
72
|
})).toBe(undefined);
|
|
73
73
|
});
|
|
74
|
-
it(
|
|
74
|
+
it('should only return the reviver if the endpoint reviver is a function or an undefined object', function() {
|
|
75
75
|
expect(getResponseReviver(reviver, {
|
|
76
76
|
status: 200,
|
|
77
77
|
ok: true
|
|
@@ -79,12 +79,12 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
79
79
|
*/ export function prepareUrl(url) {
|
|
80
80
|
var queryParameters = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
81
81
|
var queryPart = Object.keys(queryParameters).filter(function(name) {
|
|
82
|
-
return typeof queryParameters[name] !==
|
|
82
|
+
return typeof queryParameters[name] !== 'undefined';
|
|
83
83
|
}).map(function(name) {
|
|
84
84
|
return "".concat(name, "=").concat(queryParameters[name]);
|
|
85
|
-
}).join(
|
|
86
|
-
var paramsPrefix = url.indexOf(
|
|
87
|
-
return url + (!queryPart ?
|
|
85
|
+
}).join('&');
|
|
86
|
+
var paramsPrefix = url.indexOf('?') > -1 ? '&' : '?';
|
|
87
|
+
return url + (!queryPart ? '' : paramsPrefix + queryPart);
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
* Returns a map containing the query parameters
|
|
@@ -92,10 +92,10 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
92
92
|
* @param names
|
|
93
93
|
*/ export function extractQueryParams(data, names) {
|
|
94
94
|
return names.filter(function(name) {
|
|
95
|
-
return typeof data[name] !==
|
|
95
|
+
return typeof data[name] !== 'undefined' && data[name] !== null;
|
|
96
96
|
}).reduce(function(acc, name) {
|
|
97
97
|
var prop = data[name];
|
|
98
|
-
acc[name] = typeof prop.toJSON ===
|
|
98
|
+
acc[name] = typeof prop.toJSON === 'function' ? prop.toJSON() : prop.toString();
|
|
99
99
|
return acc;
|
|
100
100
|
}, {});
|
|
101
101
|
}
|
|
@@ -104,8 +104,8 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
104
104
|
* @param object JSON object to filter
|
|
105
105
|
* @returns an object without undefined values
|
|
106
106
|
*/ export function filterUndefinedValues(object) {
|
|
107
|
-
return Object.keys(object).filter(function(objectKey) {
|
|
108
|
-
return typeof object[objectKey] !==
|
|
107
|
+
return !object ? {} : Object.keys(object).filter(function(objectKey) {
|
|
108
|
+
return typeof object[objectKey] !== 'undefined';
|
|
109
109
|
}).reduce(function(acc, objectKey) {
|
|
110
110
|
acc[objectKey] = object[objectKey];
|
|
111
111
|
return acc;
|
|
@@ -120,7 +120,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
120
120
|
* @param type
|
|
121
121
|
*/ export function processFormData(data, type) {
|
|
122
122
|
var encodedData;
|
|
123
|
-
/* eslint-disable guard-for-in */ if (type ===
|
|
123
|
+
/* eslint-disable guard-for-in */ if (type === 'multipart/form-data') {
|
|
124
124
|
var formData = new FormData();
|
|
125
125
|
for(var i in data){
|
|
126
126
|
formData.append(i, data[i]);
|
|
@@ -131,7 +131,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
131
131
|
for(var i1 in data){
|
|
132
132
|
formData1.push("".concat(i1, "=").concat(encodeURIComponent(data[i1])));
|
|
133
133
|
}
|
|
134
|
-
encodedData = formData1.join(
|
|
134
|
+
encodedData = formData1.join('&');
|
|
135
135
|
}
|
|
136
136
|
/* eslint-enable guard-for-in */ return encodedData;
|
|
137
137
|
}
|
|
@@ -188,12 +188,12 @@ endpoint) {
|
|
|
188
188
|
disableFallback: false,
|
|
189
189
|
log: console.error
|
|
190
190
|
};
|
|
191
|
-
var logPrefix = "API status code error for ".concat(endpoint ||
|
|
191
|
+
var logPrefix = "API status code error for ".concat(endpoint || 'unknown', " endpoint");
|
|
192
192
|
var logMsg = options.log || function() {};
|
|
193
193
|
if (!response || !response.ok) {
|
|
194
194
|
return undefined;
|
|
195
195
|
}
|
|
196
|
-
if (typeof revivers ===
|
|
196
|
+
if (typeof revivers === 'function' || typeof revivers === 'undefined') {
|
|
197
197
|
return revivers;
|
|
198
198
|
}
|
|
199
199
|
if (response.status && revivers[response.status]) {
|
|
@@ -219,7 +219,7 @@ endpoint) {
|
|
|
219
219
|
statusCode: Number.MAX_SAFE_INTEGER,
|
|
220
220
|
reviver: undefined
|
|
221
221
|
});
|
|
222
|
-
var fallbackLog = Number.MAX_SAFE_INTEGER !== fallback.statusCode ? "Fallback to ".concat(fallback.statusCode, "'s reviver") :
|
|
223
|
-
logMsg("".concat(logPrefix, " - Unknown ").concat(response.status ||
|
|
222
|
+
var fallbackLog = Number.MAX_SAFE_INTEGER !== fallback.statusCode ? "Fallback to ".concat(fallback.statusCode, "'s reviver") : 'No fallback found';
|
|
223
|
+
logMsg("".concat(logPrefix, " - Unknown ").concat(response.status || 'undefined', " code returned by the API - ").concat(fallbackLog));
|
|
224
224
|
return fallback.reviver;
|
|
225
225
|
}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Check if the object is an Api Client object
|
|
3
3
|
* @param client object to check
|
|
4
4
|
*/ export function isApiClient(client) {
|
|
5
|
-
return client && !!client.options && typeof client.extractQueryParams ===
|
|
5
|
+
return client && !!client.options && typeof client.extractQueryParams === 'function' && typeof client.prepareOptions === 'function' && typeof client.prepareUrl === 'function' && typeof client.processFormData === 'function' && typeof client.processCall === 'function';
|
|
6
6
|
}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Determine if object passed to the constructor is valid
|
|
3
3
|
* @param args
|
|
4
4
|
*/ export function isConstructorObject(args) {
|
|
5
|
-
return !!args && args.length === 1 && !!args[0] && typeof args[0] ===
|
|
5
|
+
return !!args && args.length === 1 && !!args[0] && typeof args[0] === 'object';
|
|
6
6
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './base-api-constructor';
|
|
2
|
+
export * from './api-client';
|
package/esm2015/fwk/date.js
CHANGED
|
@@ -170,7 +170,7 @@ export var _NativeDateClass = Date;
|
|
|
170
170
|
*/ export function pad(val) {
|
|
171
171
|
var digits = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 2;
|
|
172
172
|
var str = "".concat(val);
|
|
173
|
-
return
|
|
173
|
+
return '0'.repeat(Math.max(0, digits - str.length)) + str;
|
|
174
174
|
}
|
|
175
175
|
export var CommonDate = /*#__PURE__*/ function(Date1) {
|
|
176
176
|
"use strict";
|
|
@@ -182,15 +182,15 @@ export var CommonDate = /*#__PURE__*/ function(Date1) {
|
|
|
182
182
|
}
|
|
183
183
|
_class_call_check(this, CommonDate);
|
|
184
184
|
if (args) {
|
|
185
|
-
if (typeof args[0] ===
|
|
186
|
-
var idxT = args[0].lastIndexOf(
|
|
185
|
+
if (typeof args[0] === 'string') {
|
|
186
|
+
var idxT = args[0].lastIndexOf('T');
|
|
187
187
|
// TZD = time zone designator (Z or +hh:mm or -hh:mm)
|
|
188
|
-
var idx = args[0].lastIndexOf(
|
|
188
|
+
var idx = args[0].lastIndexOf('Z');
|
|
189
189
|
if (idx < 0) {
|
|
190
|
-
idx = args[0].lastIndexOf(
|
|
190
|
+
idx = args[0].lastIndexOf('+');
|
|
191
191
|
}
|
|
192
192
|
if (idx < 0 && idxT > 0) {
|
|
193
|
-
var relativeIdx = args[0].substring(idxT).lastIndexOf(
|
|
193
|
+
var relativeIdx = args[0].substring(idxT).lastIndexOf('-');
|
|
194
194
|
idx = relativeIdx > 0 ? relativeIdx + idxT : relativeIdx;
|
|
195
195
|
}
|
|
196
196
|
if (idx > 0) {
|
|
@@ -198,7 +198,7 @@ export var CommonDate = /*#__PURE__*/ function(Date1) {
|
|
|
198
198
|
}
|
|
199
199
|
var TIME_ZONE_OFFSET = _construct(Date, _to_consumable_array(args)).getTimezoneOffset();
|
|
200
200
|
if (idxT > 0) {
|
|
201
|
-
args[0] += "".concat(TIME_ZONE_OFFSET < 0 ?
|
|
201
|
+
args[0] += "".concat(TIME_ZONE_OFFSET < 0 ? '+' : '-').concat(pad(Math.floor(Math.abs(TIME_ZONE_OFFSET / 60))), ":").concat(pad(Math.abs(TIME_ZONE_OFFSET % 60)));
|
|
202
202
|
}
|
|
203
203
|
} else if (_instanceof(args[0], CommonDate)) {
|
|
204
204
|
args[0] = args[0];
|
|
@@ -222,7 +222,7 @@ export var CommonDate = /*#__PURE__*/ function(Date1) {
|
|
|
222
222
|
}(_wrap_native_super(Date));
|
|
223
223
|
export var utils;
|
|
224
224
|
(function(utils) {
|
|
225
|
-
|
|
225
|
+
'use strict';
|
|
226
226
|
var _$Date = /*#__PURE__*/ function(CommonDate) {
|
|
227
227
|
_inherits(Date1, CommonDate);
|
|
228
228
|
var _super = _create_super(Date1);
|
|
@@ -231,7 +231,7 @@ export var utils;
|
|
|
231
231
|
args[_key] = arguments[_key];
|
|
232
232
|
}
|
|
233
233
|
_class_call_check(this, Date1);
|
|
234
|
-
if (args && typeof args[0] ===
|
|
234
|
+
if (args && typeof args[0] === 'string' && args[0].lastIndexOf('T') < 0) {
|
|
235
235
|
args[0] = "".concat(args[0], "T00:00:00Z");
|
|
236
236
|
} else if (_instanceof(args[0], _NativeDateClass)) {
|
|
237
237
|
args[0] = "".concat(args[0].getFullYear(), "-").concat(pad(args[0].getMonth() + 1), "-").concat(pad(args[0].getDate()), "T00:00:00Z");
|
package/esm2015/fwk/date.spec.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { utils } from
|
|
2
|
-
describe(
|
|
3
|
-
it(
|
|
1
|
+
import { utils } from './date';
|
|
2
|
+
describe('DateTime', function() {
|
|
3
|
+
it('should support timestamp', function() {
|
|
4
4
|
var ts = new Date().getTime();
|
|
5
5
|
var dateUtils = new utils.DateTime(ts);
|
|
6
6
|
expect(dateUtils.getTime()).toEqual(ts);
|
|
7
7
|
});
|
|
8
|
-
it(
|
|
8
|
+
it('should support DateTime Utils', function() {
|
|
9
9
|
var originalDate = new utils.DateTime(new Date());
|
|
10
10
|
expect(new utils.DateTime(originalDate)).toEqual(originalDate);
|
|
11
11
|
});
|
|
12
|
-
it(
|
|
12
|
+
it('should support a copy constructor', function() {
|
|
13
13
|
var originalDate = new utils.DateTime(new Date());
|
|
14
14
|
expect(new utils.DateTime(originalDate)).toEqual(originalDate);
|
|
15
15
|
});
|
|
16
|
-
it(
|
|
16
|
+
it('should support json conversions', function() {
|
|
17
17
|
var originalDate = new utils.DateTime(new Date());
|
|
18
18
|
var jsonDate = JSON.parse(JSON.stringify(originalDate));
|
|
19
19
|
expect(new utils.DateTime(jsonDate)).toEqual(originalDate);
|
|
20
20
|
});
|
|
21
|
-
it(
|
|
22
|
-
var date1 =
|
|
21
|
+
it('should support date without time', function() {
|
|
22
|
+
var date1 = '1988-06-07';
|
|
23
23
|
var dateCompare = new Date(date1);
|
|
24
24
|
expect(new utils.DateTime(date1)).toEqual(dateCompare);
|
|
25
25
|
});
|
|
26
|
-
it(
|
|
27
|
-
var date1 =
|
|
28
|
-
var dateCompare = new Date(
|
|
26
|
+
it('should support datetime without timezone', function() {
|
|
27
|
+
var date1 = '2015-03-25T12:00:00Z';
|
|
28
|
+
var dateCompare = new Date('2015-03-25');
|
|
29
29
|
dateCompare.setHours(12);
|
|
30
30
|
dateCompare.setMinutes(0);
|
|
31
31
|
var dateUtils = new utils.DateTime(date1);
|
|
32
32
|
expect(dateUtils).toEqual(dateCompare);
|
|
33
33
|
});
|
|
34
|
-
it(
|
|
35
|
-
var date1 =
|
|
36
|
-
var date2 =
|
|
37
|
-
var dateCompare = new Date(
|
|
34
|
+
it('should ignore timezone of datetime', function() {
|
|
35
|
+
var date1 = '2015-03-25T12:00:00-02:00';
|
|
36
|
+
var date2 = '2015-03-25T12:00:00+05:00';
|
|
37
|
+
var dateCompare = new Date('2015-03-25T12:00:00Z');
|
|
38
38
|
dateCompare.setHours(12);
|
|
39
39
|
dateCompare.setMinutes(0);
|
|
40
40
|
expect(new utils.DateTime(date1)).toEqual(dateCompare);
|
|
41
41
|
expect(new utils.DateTime(date2)).toEqual(dateCompare);
|
|
42
42
|
});
|
|
43
|
-
it(
|
|
44
|
-
var dateStr1 =
|
|
45
|
-
var dateStr2 =
|
|
43
|
+
it('should handle daylight change', function() {
|
|
44
|
+
var dateStr1 = '2017-03-23T12:00:00Z';
|
|
45
|
+
var dateStr2 = '2017-04-01T12:00:00Z';
|
|
46
46
|
var date1 = new utils.DateTime(dateStr1);
|
|
47
47
|
var date2 = new utils.DateTime(dateStr2);
|
|
48
48
|
var compareDate1 = new Date(dateStr1);
|
|
@@ -50,28 +50,28 @@ describe("DateTime", function() {
|
|
|
50
50
|
expect(date1.getTimezoneOffset() - date2.getTimezoneOffset()).toBe(compareDate1.getTimezoneOffset() - compareDate2.getTimezoneOffset());
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
|
-
describe(
|
|
54
|
-
it(
|
|
53
|
+
describe('Date', function() {
|
|
54
|
+
it('should support timestamp', function() {
|
|
55
55
|
var ts = new Date().getTime();
|
|
56
56
|
var dateUtils = new utils.Date(ts);
|
|
57
57
|
expect(dateUtils.getTime()).toEqual(ts);
|
|
58
58
|
});
|
|
59
|
-
it(
|
|
59
|
+
it('should support Date Utils', function() {
|
|
60
60
|
var originalDate = new utils.Date(new Date());
|
|
61
61
|
expect(new utils.Date(originalDate)).toEqual(originalDate);
|
|
62
62
|
});
|
|
63
|
-
it(
|
|
63
|
+
it('should support a copy constructor', function() {
|
|
64
64
|
var originalDate = new utils.Date(new Date());
|
|
65
65
|
expect(new utils.Date(originalDate)).toEqual(originalDate);
|
|
66
66
|
});
|
|
67
|
-
it(
|
|
67
|
+
it('should support json conversions', function() {
|
|
68
68
|
var originalDate = new utils.Date(new Date());
|
|
69
69
|
var jsonDate = JSON.parse(JSON.stringify(originalDate));
|
|
70
70
|
expect(new utils.Date(jsonDate)).toEqual(originalDate);
|
|
71
71
|
});
|
|
72
|
-
it(
|
|
73
|
-
var date1 =
|
|
74
|
-
var dateCompare = new utils.DateTime(
|
|
72
|
+
it('should be converted to a Js DateTime', function() {
|
|
73
|
+
var date1 = '1988-06-07';
|
|
74
|
+
var dateCompare = new utils.DateTime('1988-06-07T00:00:00Z');
|
|
75
75
|
expect(new utils.Date(date1)).toEqual(dateCompare);
|
|
76
76
|
});
|
|
77
77
|
});
|
package/esm2015/fwk/errors.js
CHANGED
|
@@ -139,9 +139,9 @@ function _create_super(Derived) {
|
|
|
139
139
|
function GenericError(message, context) {
|
|
140
140
|
_class_call_check(this, GenericError);
|
|
141
141
|
var httpRegexp = /^https?:\/\//;
|
|
142
|
-
var baseUrl = (context === null || context === void 0 ? void 0 : context.url) ? context.url.replace(httpRegexp,
|
|
143
|
-
var origin = (context === null || context === void 0 ? void 0 : context.origin) ? context.origin.replace(httpRegexp,
|
|
144
|
-
return _super.call(this, context ? "[SDK] [apiName: ".concat(context.apiName ||
|
|
142
|
+
var baseUrl = (context === null || context === void 0 ? void 0 : context.url) ? context.url.replace(httpRegexp, '') : 'unknown';
|
|
143
|
+
var origin = (context === null || context === void 0 ? void 0 : context.origin) ? context.origin.replace(httpRegexp, '') : 'unknown';
|
|
144
|
+
return _super.call(this, context ? "[SDK] [apiName: ".concat(context.apiName || 'unknown', "] [operationId: ").concat(context.operationId || 'unknown', "] [baseUrl: ").concat(baseUrl, "] [origin: ").concat(origin, "] [errorType: SDK] ").concat(message) : "[SDK] ".concat(message));
|
|
145
145
|
}
|
|
146
146
|
return GenericError;
|
|
147
147
|
}(_wrap_native_super(Error));
|
package/esm2015/fwk/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
1
|
+
export * from './api';
|
|
2
|
+
export * from './api.helpers';
|
|
3
|
+
export * from './api.interface';
|
|
4
|
+
export * from './core/index';
|
|
5
|
+
export * from './date';
|
|
6
|
+
export * from './errors';
|
|
7
|
+
export * from './ignore-enum.type';
|
|
8
|
+
export * from './logger';
|
|
9
|
+
export * from './mocks/index';
|
|
10
|
+
export * from './Reviver';
|
|
@@ -174,8 +174,8 @@ function _ts_generator(thisArg, body) {
|
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
import { getOperationId, getPath } from
|
|
178
|
-
import { SequentialMockAdapter } from
|
|
177
|
+
import { getOperationId, getPath } from './helpers';
|
|
178
|
+
import { SequentialMockAdapter } from './sequential-mock-adapter';
|
|
179
179
|
/**
|
|
180
180
|
* a new call is detected thanks to the timestamp printed by ALF on a new line, ex: "2021/12/16 18:21:28.312472 "
|
|
181
181
|
*/ var logNewCallRegex = RegExp(/^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}\.\d{6}\b/gm);
|
|
@@ -210,7 +210,7 @@ import { SequentialMockAdapter } from "./sequential-mock-adapter";
|
|
|
210
210
|
if (match && match[1] && match[2]) {
|
|
211
211
|
// the match looks like this 1ASIUAIRFAC/v2/shopping/carts/19DXNCKB931CYX3S?refresh=true
|
|
212
212
|
// so we remove the SAP information at the beginning and URL parameters at the end if any
|
|
213
|
-
var requestUrl = match[2].substring(match[2].indexOf(
|
|
213
|
+
var requestUrl = match[2].substring(match[2].indexOf('/'), match[2].indexOf('?') > -1 ? match[2].indexOf('?') : match[2].length);
|
|
214
214
|
var method = match[1];
|
|
215
215
|
var pathObject = getPath(requestUrl, operationAdapter, method);
|
|
216
216
|
if (pathObject) {
|
|
@@ -237,7 +237,7 @@ import { SequentialMockAdapter } from "./sequential-mock-adapter";
|
|
|
237
237
|
* @returns JSON data that can be either the request or the response
|
|
238
238
|
*/ function getData(log) {
|
|
239
239
|
var match = log.match(requestResponseJsonRegexp);
|
|
240
|
-
return match && match[1] ||
|
|
240
|
+
return match && match[1] || '';
|
|
241
241
|
}
|
|
242
242
|
/**
|
|
243
243
|
* Retrieve path from logPath and parse it to find all the calls.
|
|
@@ -317,7 +317,7 @@ import { SequentialMockAdapter } from "./sequential-mock-adapter";
|
|
|
317
317
|
mockMap[alfCall.operationId] = [];
|
|
318
318
|
}
|
|
319
319
|
mockMap[alfCall.operationId].push({
|
|
320
|
-
mockData: alfCall.response ? JSON.parse(alfCall.response) :
|
|
320
|
+
mockData: alfCall.response ? JSON.parse(alfCall.response) : ''
|
|
321
321
|
});
|
|
322
322
|
return mockMap;
|
|
323
323
|
}, {});
|
|
@@ -350,7 +350,7 @@ import { SequentialMockAdapter } from "./sequential-mock-adapter";
|
|
|
350
350
|
];
|
|
351
351
|
case 2:
|
|
352
352
|
content = _state.sent();
|
|
353
|
-
if (!(typeof operationAdapter ===
|
|
353
|
+
if (!(typeof operationAdapter === 'function')) return [
|
|
354
354
|
3,
|
|
355
355
|
4
|
|
356
356
|
];
|
|
@@ -154,7 +154,7 @@ function _ts_generator(thisArg, body) {
|
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
import { getOperationId, getPath } from
|
|
157
|
+
import { getOperationId, getPath } from './helpers';
|
|
158
158
|
/**
|
|
159
159
|
* Base implementation of a mock adapter
|
|
160
160
|
*/ export var BaseMockAdapter = /*#__PURE__*/ function() {
|
|
@@ -166,7 +166,7 @@ import { getOperationId, getPath } from "./helpers";
|
|
|
166
166
|
_define_property(this, "mockFactory", void 0);
|
|
167
167
|
this.pathObjects = pathObjects;
|
|
168
168
|
this.mocks = {};
|
|
169
|
-
if (typeof mockMap !==
|
|
169
|
+
if (typeof mockMap !== 'function') {
|
|
170
170
|
this.mocks = mockMap;
|
|
171
171
|
} else {
|
|
172
172
|
this.mockFactory = mockMap;
|
|
@@ -197,7 +197,7 @@ import { getOperationId, getPath } from "./helpers";
|
|
|
197
197
|
return _ts_generator(this, function(_state) {
|
|
198
198
|
switch(_state.label){
|
|
199
199
|
case 0:
|
|
200
|
-
if (!(typeof _this.pathObjects ===
|
|
200
|
+
if (!(typeof _this.pathObjects === 'function')) return [
|
|
201
201
|
3,
|
|
202
202
|
2
|
|
203
203
|
];
|