@ama-sdk/core 10.3.0-prerelease.9 → 11.0.0-next.1
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
|
@@ -232,24 +232,18 @@ var ApiAngularClient = /*#__PURE__*/ function() {
|
|
|
232
232
|
}
|
|
233
233
|
},
|
|
234
234
|
{
|
|
235
|
-
key: "
|
|
236
|
-
value:
|
|
235
|
+
key: "getRequestOptions",
|
|
236
|
+
value: /** @inheritdoc */ function getRequestOptions(requestOptionsParameters) {
|
|
237
237
|
var _this = this;
|
|
238
238
|
return _async_to_generator(function() {
|
|
239
|
-
var
|
|
239
|
+
var opts, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plugin, _requestOptionsParameters_api, err;
|
|
240
240
|
return _ts_generator(this, function(_state) {
|
|
241
241
|
switch(_state.label){
|
|
242
242
|
case 0:
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
queryParams: (0, _apihelpers.filterUndefinedValues)(queryParams),
|
|
248
|
-
basePath: url,
|
|
249
|
-
tokenizedOptions: tokenizedOptions,
|
|
250
|
-
metadata: metadata
|
|
251
|
-
};
|
|
252
|
-
opts = options;
|
|
243
|
+
opts = _object_spread_props(_object_spread({}, requestOptionsParameters), {
|
|
244
|
+
headers: new Headers((0, _apihelpers.filterUndefinedValues)(requestOptionsParameters.headers)),
|
|
245
|
+
queryParams: (0, _apihelpers.filterUndefinedValues)(requestOptionsParameters.queryParams)
|
|
246
|
+
});
|
|
253
247
|
if (!_this.options.requestPlugins) return [
|
|
254
248
|
3,
|
|
255
249
|
8
|
|
@@ -274,7 +268,8 @@ var ApiAngularClient = /*#__PURE__*/ function() {
|
|
|
274
268
|
return [
|
|
275
269
|
4,
|
|
276
270
|
plugin.load({
|
|
277
|
-
logger: _this.options.logger
|
|
271
|
+
logger: _this.options.logger,
|
|
272
|
+
apiName: (_requestOptionsParameters_api = requestOptionsParameters.api) === null || _requestOptionsParameters_api === void 0 ? void 0 : _requestOptionsParameters_api.apiName
|
|
278
273
|
}).transform(opts)
|
|
279
274
|
];
|
|
280
275
|
case 3:
|
|
@@ -322,6 +317,29 @@ var ApiAngularClient = /*#__PURE__*/ function() {
|
|
|
322
317
|
})();
|
|
323
318
|
}
|
|
324
319
|
},
|
|
320
|
+
{
|
|
321
|
+
key: "prepareOptions",
|
|
322
|
+
value: /** @inheritdoc */ function prepareOptions(url, method, queryParams, headers, body, tokenizedOptions, metadata, api) {
|
|
323
|
+
var _this = this;
|
|
324
|
+
return _async_to_generator(function() {
|
|
325
|
+
return _ts_generator(this, function(_state) {
|
|
326
|
+
return [
|
|
327
|
+
2,
|
|
328
|
+
_this.getRequestOptions({
|
|
329
|
+
headers: headers,
|
|
330
|
+
method: method,
|
|
331
|
+
basePath: url,
|
|
332
|
+
queryParams: queryParams,
|
|
333
|
+
body: body,
|
|
334
|
+
metadata: metadata,
|
|
335
|
+
tokenizedOptions: tokenizedOptions,
|
|
336
|
+
api: api
|
|
337
|
+
})
|
|
338
|
+
];
|
|
339
|
+
});
|
|
340
|
+
})();
|
|
341
|
+
}
|
|
342
|
+
},
|
|
325
343
|
{
|
|
326
344
|
key: "prepareUrl",
|
|
327
345
|
value: /** @inheritdoc */ function prepareUrl(url) {
|
|
@@ -350,7 +368,7 @@ var ApiAngularClient = /*#__PURE__*/ function() {
|
|
|
350
368
|
return _ts_generator(this, function(_state) {
|
|
351
369
|
switch(_state.label){
|
|
352
370
|
case 0:
|
|
353
|
-
origin = options.headers.get(
|
|
371
|
+
origin = options.headers.get('Origin');
|
|
354
372
|
_state.label = 1;
|
|
355
373
|
case 1:
|
|
356
374
|
_state.trys.push([
|
|
@@ -366,7 +384,7 @@ var ApiAngularClient = /*#__PURE__*/ function() {
|
|
|
366
384
|
var metadataSignal = (_options_metadata = options.metadata) === null || _options_metadata === void 0 ? void 0 : _options_metadata.signal;
|
|
367
385
|
metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.throwIfAborted();
|
|
368
386
|
var subscription = _this.options.httpClient.request(options.method, url, _object_spread_props(_object_spread({}, options), {
|
|
369
|
-
observe:
|
|
387
|
+
observe: 'response',
|
|
370
388
|
headers: headers
|
|
371
389
|
})).subscribe({
|
|
372
390
|
next: function(res) {
|
|
@@ -380,7 +398,7 @@ var ApiAngularClient = /*#__PURE__*/ function() {
|
|
|
380
398
|
}
|
|
381
399
|
});
|
|
382
400
|
metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.throwIfAborted();
|
|
383
|
-
metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.addEventListener(
|
|
401
|
+
metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.addEventListener('abort', function() {
|
|
384
402
|
subscription.unsubscribe();
|
|
385
403
|
reject(metadataSignal.reason);
|
|
386
404
|
});
|
|
@@ -398,7 +416,7 @@ var ApiAngularClient = /*#__PURE__*/ function() {
|
|
|
398
416
|
];
|
|
399
417
|
case 3:
|
|
400
418
|
e = _state.sent();
|
|
401
|
-
exception = new _errors.EmptyResponseError(e.message ||
|
|
419
|
+
exception = new _errors.EmptyResponseError(e.message || 'Fail to Fetch', undefined, {
|
|
402
420
|
apiName: apiName,
|
|
403
421
|
operationId: operationId,
|
|
404
422
|
url: url,
|
|
@@ -41,6 +41,13 @@ function _define_property(obj, key, value) {
|
|
|
41
41
|
}
|
|
42
42
|
return obj;
|
|
43
43
|
}
|
|
44
|
+
function _instanceof(left, right) {
|
|
45
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
46
|
+
return !!right[Symbol.hasInstance](left);
|
|
47
|
+
} else {
|
|
48
|
+
return left instanceof right;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
44
51
|
function _object_spread(target) {
|
|
45
52
|
for(var i = 1; i < arguments.length; i++){
|
|
46
53
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -56,6 +63,30 @@ function _object_spread(target) {
|
|
|
56
63
|
}
|
|
57
64
|
return target;
|
|
58
65
|
}
|
|
66
|
+
function ownKeys(object, enumerableOnly) {
|
|
67
|
+
var keys = Object.keys(object);
|
|
68
|
+
if (Object.getOwnPropertySymbols) {
|
|
69
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
70
|
+
if (enumerableOnly) {
|
|
71
|
+
symbols = symbols.filter(function(sym) {
|
|
72
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
keys.push.apply(keys, symbols);
|
|
76
|
+
}
|
|
77
|
+
return keys;
|
|
78
|
+
}
|
|
79
|
+
function _object_spread_props(target, source) {
|
|
80
|
+
source = source != null ? source : {};
|
|
81
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
82
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
83
|
+
} else {
|
|
84
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
85
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return target;
|
|
89
|
+
}
|
|
59
90
|
var DEFAULT_OPTIONS = {
|
|
60
91
|
replyPlugins: [],
|
|
61
92
|
requestPlugins: [],
|
|
@@ -67,15 +98,15 @@ var DEFAULT_OPTIONS = {
|
|
|
67
98
|
*/ // NOTE: the `extends unknown` is required for ESM build with TSC
|
|
68
99
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint
|
|
69
100
|
var isPromise = function(value) {
|
|
70
|
-
return value
|
|
101
|
+
return _instanceof(value, Promise);
|
|
71
102
|
};
|
|
72
103
|
var ApiBeaconClient = /*#__PURE__*/ function() {
|
|
73
104
|
"use strict";
|
|
74
105
|
function ApiBeaconClient(options) {
|
|
75
106
|
_class_call_check(this, ApiBeaconClient);
|
|
76
107
|
/** @inheritdoc */ _define_property(this, "options", void 0);
|
|
77
|
-
if (typeof navigator ===
|
|
78
|
-
throw new Error(
|
|
108
|
+
if (typeof navigator === 'undefined' || !navigator.sendBeacon) {
|
|
109
|
+
throw new Error('Beacon API is not supported in this context');
|
|
79
110
|
}
|
|
80
111
|
this.options = _object_spread({}, DEFAULT_OPTIONS, options);
|
|
81
112
|
}
|
|
@@ -87,28 +118,24 @@ var ApiBeaconClient = /*#__PURE__*/ function() {
|
|
|
87
118
|
}
|
|
88
119
|
},
|
|
89
120
|
{
|
|
90
|
-
key: "
|
|
91
|
-
value: /** @inheritdoc */ function
|
|
92
|
-
if (method.toUpperCase() !==
|
|
93
|
-
throw new Error("Unsupported method: ".concat(method, ". The beacon API only supports POST."));
|
|
121
|
+
key: "getRequestOptions",
|
|
122
|
+
value: /** @inheritdoc */ function getRequestOptions(options) {
|
|
123
|
+
if (options.method.toUpperCase() !== 'POST') {
|
|
124
|
+
throw new Error("Unsupported method: ".concat(options.method, ". The beacon API only supports POST."));
|
|
94
125
|
}
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
queryParams: (0, _apihelpers.filterUndefinedValues)(queryParams),
|
|
100
|
-
basePath: url,
|
|
101
|
-
tokenizedOptions: tokenizedOptions,
|
|
102
|
-
metadata: metadata
|
|
103
|
-
};
|
|
104
|
-
var opts = options;
|
|
126
|
+
var opts = _object_spread_props(_object_spread({}, options), {
|
|
127
|
+
headers: new Headers((0, _apihelpers.filterUndefinedValues)(options.headers)),
|
|
128
|
+
queryParams: (0, _apihelpers.filterUndefinedValues)(options.queryParams)
|
|
129
|
+
});
|
|
105
130
|
if (this.options.requestPlugins) {
|
|
106
131
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
107
132
|
try {
|
|
108
133
|
for(var _iterator = this.options.requestPlugins[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
109
134
|
var plugin = _step.value;
|
|
135
|
+
var _options_api;
|
|
110
136
|
var changedOpt = plugin.load({
|
|
111
|
-
logger: this.options.logger
|
|
137
|
+
logger: this.options.logger,
|
|
138
|
+
apiName: (_options_api = options.api) === null || _options_api === void 0 ? void 0 : _options_api.apiName
|
|
112
139
|
}).transform(opts);
|
|
113
140
|
if (isPromise(changedOpt)) {
|
|
114
141
|
throw new Error("Request plugin ".concat(plugin.constructor.name, " has async transform method. Only sync methods are supported with the Beacon client."));
|
|
@@ -134,6 +161,21 @@ var ApiBeaconClient = /*#__PURE__*/ function() {
|
|
|
134
161
|
return Promise.resolve(opts);
|
|
135
162
|
}
|
|
136
163
|
},
|
|
164
|
+
{
|
|
165
|
+
key: "prepareOptions",
|
|
166
|
+
value: /** @inheritdoc */ function prepareOptions(url, method, queryParams, headers, body, tokenizedOptions, metadata, api) {
|
|
167
|
+
return this.getRequestOptions({
|
|
168
|
+
headers: headers,
|
|
169
|
+
method: method,
|
|
170
|
+
basePath: url,
|
|
171
|
+
queryParams: queryParams,
|
|
172
|
+
body: body,
|
|
173
|
+
metadata: metadata,
|
|
174
|
+
tokenizedOptions: tokenizedOptions,
|
|
175
|
+
api: api
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
},
|
|
137
179
|
{
|
|
138
180
|
key: "prepareUrl",
|
|
139
181
|
value: /** @inheritdoc */ function prepareUrl(url, queryParameters) {
|
|
@@ -156,7 +198,7 @@ var ApiBeaconClient = /*#__PURE__*/ function() {
|
|
|
156
198
|
key: "processCall",
|
|
157
199
|
value: /** @inheritdoc */ function processCall(url, options, _apiType, _apiName, _revivers, _operationId) {
|
|
158
200
|
var headers = _object_spread({
|
|
159
|
-
type:
|
|
201
|
+
type: 'application/json'
|
|
160
202
|
}, options.headers.entries());
|
|
161
203
|
var blob = new Blob(options.body ? [
|
|
162
204
|
JSON.stringify(options.body)
|
|
@@ -109,6 +109,30 @@ function _object_spread(target) {
|
|
|
109
109
|
}
|
|
110
110
|
return target;
|
|
111
111
|
}
|
|
112
|
+
function ownKeys(object, enumerableOnly) {
|
|
113
|
+
var keys = Object.keys(object);
|
|
114
|
+
if (Object.getOwnPropertySymbols) {
|
|
115
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
116
|
+
if (enumerableOnly) {
|
|
117
|
+
symbols = symbols.filter(function(sym) {
|
|
118
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
keys.push.apply(keys, symbols);
|
|
122
|
+
}
|
|
123
|
+
return keys;
|
|
124
|
+
}
|
|
125
|
+
function _object_spread_props(target, source) {
|
|
126
|
+
source = source != null ? source : {};
|
|
127
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
128
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
129
|
+
} else {
|
|
130
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
131
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return target;
|
|
135
|
+
}
|
|
112
136
|
function _to_consumable_array(arr) {
|
|
113
137
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
114
138
|
}
|
|
@@ -246,24 +270,18 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
246
270
|
}
|
|
247
271
|
},
|
|
248
272
|
{
|
|
249
|
-
key: "
|
|
250
|
-
value: /** @inheritdoc */ function
|
|
273
|
+
key: "getRequestOptions",
|
|
274
|
+
value: /** @inheritdoc */ function getRequestOptions(requestOptionsParameters) {
|
|
251
275
|
var _this = this;
|
|
252
276
|
return _async_to_generator(function() {
|
|
253
|
-
var
|
|
277
|
+
var opts, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plugin, _requestOptionsParameters_api, err;
|
|
254
278
|
return _ts_generator(this, function(_state) {
|
|
255
279
|
switch(_state.label){
|
|
256
280
|
case 0:
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
queryParams: (0, _apihelpers.filterUndefinedValues)(queryParams),
|
|
262
|
-
basePath: url,
|
|
263
|
-
tokenizedOptions: tokenizedOptions,
|
|
264
|
-
metadata: metadata
|
|
265
|
-
};
|
|
266
|
-
opts = options;
|
|
281
|
+
opts = _object_spread_props(_object_spread({}, requestOptionsParameters), {
|
|
282
|
+
headers: new Headers((0, _apihelpers.filterUndefinedValues)(requestOptionsParameters.headers)),
|
|
283
|
+
queryParams: (0, _apihelpers.filterUndefinedValues)(requestOptionsParameters.queryParams)
|
|
284
|
+
});
|
|
267
285
|
if (!_this.options.requestPlugins) return [
|
|
268
286
|
3,
|
|
269
287
|
8
|
|
@@ -288,7 +306,8 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
288
306
|
return [
|
|
289
307
|
4,
|
|
290
308
|
plugin.load({
|
|
291
|
-
logger: _this.options.logger
|
|
309
|
+
logger: _this.options.logger,
|
|
310
|
+
apiName: (_requestOptionsParameters_api = requestOptionsParameters.api) === null || _requestOptionsParameters_api === void 0 ? void 0 : _requestOptionsParameters_api.apiName
|
|
292
311
|
}).transform(opts)
|
|
293
312
|
];
|
|
294
313
|
case 3:
|
|
@@ -336,6 +355,29 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
336
355
|
})();
|
|
337
356
|
}
|
|
338
357
|
},
|
|
358
|
+
{
|
|
359
|
+
key: "prepareOptions",
|
|
360
|
+
value: /** @inheritdoc */ function prepareOptions(url, method, queryParams, headers, body, tokenizedOptions, metadata, api) {
|
|
361
|
+
var _this = this;
|
|
362
|
+
return _async_to_generator(function() {
|
|
363
|
+
return _ts_generator(this, function(_state) {
|
|
364
|
+
return [
|
|
365
|
+
2,
|
|
366
|
+
_this.getRequestOptions({
|
|
367
|
+
headers: headers,
|
|
368
|
+
method: method,
|
|
369
|
+
basePath: url,
|
|
370
|
+
queryParams: queryParams,
|
|
371
|
+
body: body,
|
|
372
|
+
metadata: metadata,
|
|
373
|
+
tokenizedOptions: tokenizedOptions,
|
|
374
|
+
api: api
|
|
375
|
+
})
|
|
376
|
+
];
|
|
377
|
+
});
|
|
378
|
+
})();
|
|
379
|
+
}
|
|
380
|
+
},
|
|
339
381
|
{
|
|
340
382
|
key: "prepareUrl",
|
|
341
383
|
value: /** @inheritdoc */ function prepareUrl(url) {
|
|
@@ -358,7 +400,7 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
358
400
|
return _ts_generator(this, function(_state) {
|
|
359
401
|
switch(_state.label){
|
|
360
402
|
case 0:
|
|
361
|
-
origin = options.headers.get(
|
|
403
|
+
origin = options.headers.get('Origin');
|
|
362
404
|
_state.label = 1;
|
|
363
405
|
case 1:
|
|
364
406
|
_state.trys.push([
|
|
@@ -371,7 +413,7 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
371
413
|
metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.throwIfAborted();
|
|
372
414
|
controller = new AbortController();
|
|
373
415
|
options.signal = controller.signal;
|
|
374
|
-
metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.addEventListener(
|
|
416
|
+
metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.addEventListener('abort', function() {
|
|
375
417
|
return controller.abort();
|
|
376
418
|
});
|
|
377
419
|
loadedPlugins = [];
|
|
@@ -449,7 +491,7 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
449
491
|
if (_instanceof(e, _errors.CanceledCallError)) {
|
|
450
492
|
exception = e;
|
|
451
493
|
} else {
|
|
452
|
-
exception = new _errors.EmptyResponseError(e.message ||
|
|
494
|
+
exception = new _errors.EmptyResponseError(e.message || 'Fail to Fetch', undefined, {
|
|
453
495
|
apiName: apiName,
|
|
454
496
|
operationId: operationId,
|
|
455
497
|
url: url,
|
|
@@ -464,7 +506,7 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
464
506
|
try {
|
|
465
507
|
root = body ? JSON.parse(body) : undefined;
|
|
466
508
|
} catch (e) {
|
|
467
|
-
exception = new _errors.ResponseJSONParseError(e.message ||
|
|
509
|
+
exception = new _errors.ResponseJSONParseError(e.message || 'Fail to parse response body', response && response.status || 0, body, {
|
|
468
510
|
apiName: apiName,
|
|
469
511
|
operationId: operationId,
|
|
470
512
|
url: url,
|
|
@@ -3,45 +3,45 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
var _core = require("@ama-sdk/core");
|
|
6
|
-
describe(
|
|
6
|
+
describe('getResponseReviver - revivers by status code', function() {
|
|
7
7
|
var revivers = {
|
|
8
8
|
202: jest.fn(),
|
|
9
9
|
201: jest.fn()
|
|
10
10
|
};
|
|
11
11
|
beforeEach(function() {
|
|
12
|
-
jest.spyOn(console,
|
|
12
|
+
jest.spyOn(console, 'error');
|
|
13
13
|
});
|
|
14
14
|
afterEach(function() {
|
|
15
15
|
jest.clearAllMocks();
|
|
16
16
|
});
|
|
17
|
-
it(
|
|
17
|
+
it('should not return a reviver for a non ok response', function() {
|
|
18
18
|
expect((0, _core.getResponseReviver)(revivers, {
|
|
19
19
|
status: 300,
|
|
20
20
|
ok: false
|
|
21
21
|
})).toBe(undefined);
|
|
22
22
|
});
|
|
23
|
-
it(
|
|
23
|
+
it('should return a reason but not reviver for a 204 No Content Response', function() {
|
|
24
24
|
expect((0, _core.getResponseReviver)(revivers, {
|
|
25
25
|
status: 204,
|
|
26
26
|
ok: true
|
|
27
27
|
})).toBe(undefined);
|
|
28
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
28
|
+
expect(console.error).toHaveBeenCalledWith('API status code error for unknown endpoint - 204 response is not defined in the API specification');
|
|
29
29
|
});
|
|
30
|
-
it(
|
|
30
|
+
it('should return the status code\'s reviver', function() {
|
|
31
31
|
expect((0, _core.getResponseReviver)(revivers, {
|
|
32
32
|
status: 202,
|
|
33
33
|
ok: true
|
|
34
|
-
},
|
|
34
|
+
}, 'myEndpoint')).toBe(revivers[202]);
|
|
35
35
|
expect(console.error).not.toHaveBeenCalled();
|
|
36
36
|
});
|
|
37
|
-
it(
|
|
37
|
+
it('should fallback on the first defined status if the status code\'s reviver is not defined', function() {
|
|
38
38
|
expect((0, _core.getResponseReviver)(revivers, {
|
|
39
39
|
status: undefined,
|
|
40
40
|
ok: true
|
|
41
|
-
},
|
|
42
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
41
|
+
}, 'myEndpoint')).toBe(revivers[201]);
|
|
42
|
+
expect(console.error).toHaveBeenCalledWith('API status code error for myEndpoint endpoint - Unknown undefined code returned by the API - Fallback to 201\'s reviver');
|
|
43
43
|
});
|
|
44
|
-
it(
|
|
44
|
+
it('should not fallback on 204 (No Content)\'s reviver', function() {
|
|
45
45
|
var reviversWith204 = {
|
|
46
46
|
204: jest.fn(),
|
|
47
47
|
206: jest.fn()
|
|
@@ -49,33 +49,33 @@ describe("getResponseReviver - revivers by status code", function() {
|
|
|
49
49
|
var fallback = (0, _core.getResponseReviver)(reviversWith204, {
|
|
50
50
|
status: 201,
|
|
51
51
|
ok: true
|
|
52
|
-
},
|
|
52
|
+
}, 'myEndpoint');
|
|
53
53
|
expect(fallback).toBe(reviversWith204[206]);
|
|
54
54
|
expect(fallback).not.toBe(reviversWith204[204]);
|
|
55
|
-
expect(console.error).toHaveBeenCalledWith(
|
|
55
|
+
expect(console.error).toHaveBeenCalledWith('API status code error for myEndpoint endpoint - Unknown 201 code returned by the API - Fallback to 206\'s reviver');
|
|
56
56
|
});
|
|
57
|
-
it(
|
|
58
|
-
jest.spyOn(console,
|
|
57
|
+
it('should not fallback if the feature is deactivated', function() {
|
|
58
|
+
jest.spyOn(console, 'log');
|
|
59
59
|
expect((0, _core.getResponseReviver)(revivers, {
|
|
60
60
|
status: 206,
|
|
61
61
|
ok: true
|
|
62
|
-
},
|
|
62
|
+
}, 'myEndpoint', {
|
|
63
63
|
disableFallback: true,
|
|
64
64
|
log: console.log
|
|
65
65
|
})).toBe(undefined);
|
|
66
66
|
expect(console.error).not.toHaveBeenCalled();
|
|
67
|
-
expect(console.log).toHaveBeenCalledWith(
|
|
67
|
+
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');
|
|
68
68
|
});
|
|
69
69
|
});
|
|
70
|
-
describe(
|
|
70
|
+
describe('getResponseReviver - reviver as function', function() {
|
|
71
71
|
var reviver = jest.fn();
|
|
72
|
-
it(
|
|
72
|
+
it('should not return a reviver for a non ok response', function() {
|
|
73
73
|
expect((0, _core.getResponseReviver)(reviver, {
|
|
74
74
|
status: 300,
|
|
75
75
|
ok: false
|
|
76
76
|
})).toBe(undefined);
|
|
77
77
|
});
|
|
78
|
-
it(
|
|
78
|
+
it('should only return the reviver if the endpoint reviver is a function or an undefined object', function() {
|
|
79
79
|
expect((0, _core.getResponseReviver)(reviver, {
|
|
80
80
|
status: 200,
|
|
81
81
|
ok: true
|
package/cjs/fwk/api.helpers.js
CHANGED
|
@@ -108,25 +108,25 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
108
108
|
function prepareUrl(url) {
|
|
109
109
|
var queryParameters = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
110
110
|
var queryPart = Object.keys(queryParameters).filter(function(name) {
|
|
111
|
-
return typeof queryParameters[name] !==
|
|
111
|
+
return typeof queryParameters[name] !== 'undefined';
|
|
112
112
|
}).map(function(name) {
|
|
113
113
|
return "".concat(name, "=").concat(queryParameters[name]);
|
|
114
|
-
}).join(
|
|
115
|
-
var paramsPrefix = url.indexOf(
|
|
116
|
-
return url + (!queryPart ?
|
|
114
|
+
}).join('&');
|
|
115
|
+
var paramsPrefix = url.indexOf('?') > -1 ? '&' : '?';
|
|
116
|
+
return url + (!queryPart ? '' : paramsPrefix + queryPart);
|
|
117
117
|
}
|
|
118
118
|
function extractQueryParams(data, names) {
|
|
119
119
|
return names.filter(function(name) {
|
|
120
|
-
return typeof data[name] !==
|
|
120
|
+
return typeof data[name] !== 'undefined' && data[name] !== null;
|
|
121
121
|
}).reduce(function(acc, name) {
|
|
122
122
|
var prop = data[name];
|
|
123
|
-
acc[name] = typeof prop.toJSON ===
|
|
123
|
+
acc[name] = typeof prop.toJSON === 'function' ? prop.toJSON() : prop.toString();
|
|
124
124
|
return acc;
|
|
125
125
|
}, {});
|
|
126
126
|
}
|
|
127
127
|
function filterUndefinedValues(object) {
|
|
128
|
-
return Object.keys(object).filter(function(objectKey) {
|
|
129
|
-
return typeof object[objectKey] !==
|
|
128
|
+
return !object ? {} : Object.keys(object).filter(function(objectKey) {
|
|
129
|
+
return typeof object[objectKey] !== 'undefined';
|
|
130
130
|
}).reduce(function(acc, objectKey) {
|
|
131
131
|
acc[objectKey] = object[objectKey];
|
|
132
132
|
return acc;
|
|
@@ -134,7 +134,7 @@ function filterUndefinedValues(object) {
|
|
|
134
134
|
}
|
|
135
135
|
function processFormData(data, type) {
|
|
136
136
|
var encodedData;
|
|
137
|
-
/* eslint-disable guard-for-in */ if (type ===
|
|
137
|
+
/* eslint-disable guard-for-in */ if (type === 'multipart/form-data') {
|
|
138
138
|
var formData = new FormData();
|
|
139
139
|
for(var i in data){
|
|
140
140
|
formData.append(i, data[i]);
|
|
@@ -145,7 +145,7 @@ function processFormData(data, type) {
|
|
|
145
145
|
for(var i1 in data){
|
|
146
146
|
formData1.push("".concat(i1, "=").concat(encodeURIComponent(data[i1])));
|
|
147
147
|
}
|
|
148
|
-
encodedData = formData1.join(
|
|
148
|
+
encodedData = formData1.join('&');
|
|
149
149
|
}
|
|
150
150
|
/* eslint-enable guard-for-in */ return encodedData;
|
|
151
151
|
}
|
|
@@ -180,12 +180,12 @@ endpoint) {
|
|
|
180
180
|
disableFallback: false,
|
|
181
181
|
log: console.error
|
|
182
182
|
};
|
|
183
|
-
var logPrefix = "API status code error for ".concat(endpoint ||
|
|
183
|
+
var logPrefix = "API status code error for ".concat(endpoint || 'unknown', " endpoint");
|
|
184
184
|
var logMsg = options.log || function() {};
|
|
185
185
|
if (!response || !response.ok) {
|
|
186
186
|
return undefined;
|
|
187
187
|
}
|
|
188
|
-
if (typeof revivers ===
|
|
188
|
+
if (typeof revivers === 'function' || typeof revivers === 'undefined') {
|
|
189
189
|
return revivers;
|
|
190
190
|
}
|
|
191
191
|
if (response.status && revivers[response.status]) {
|
|
@@ -211,7 +211,7 @@ endpoint) {
|
|
|
211
211
|
statusCode: Number.MAX_SAFE_INTEGER,
|
|
212
212
|
reviver: undefined
|
|
213
213
|
});
|
|
214
|
-
var fallbackLog = Number.MAX_SAFE_INTEGER !== fallback.statusCode ? "Fallback to ".concat(fallback.statusCode, "'s reviver") :
|
|
215
|
-
logMsg("".concat(logPrefix, " - Unknown ").concat(response.status ||
|
|
214
|
+
var fallbackLog = Number.MAX_SAFE_INTEGER !== fallback.statusCode ? "Fallback to ".concat(fallback.statusCode, "'s reviver") : 'No fallback found';
|
|
215
|
+
logMsg("".concat(logPrefix, " - Unknown ").concat(response.status || 'undefined', " code returned by the API - ").concat(fallbackLog));
|
|
216
216
|
return fallback.reviver;
|
|
217
217
|
}
|
|
@@ -9,5 +9,5 @@ Object.defineProperty(exports, "isApiClient", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
function isApiClient(client) {
|
|
12
|
-
return client && !!client.options && typeof client.extractQueryParams ===
|
|
12
|
+
return client && !!client.options && typeof client.extractQueryParams === 'function' && typeof client.prepareOptions === 'function' && typeof client.prepareUrl === 'function' && typeof client.processFormData === 'function' && typeof client.processCall === 'function';
|
|
13
13
|
}
|
|
@@ -9,5 +9,5 @@ Object.defineProperty(exports, "isConstructorObject", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
function isConstructorObject(args) {
|
|
12
|
-
return !!args && args.length === 1 && !!args[0] && typeof args[0] ===
|
|
12
|
+
return !!args && args.length === 1 && !!args[0] && typeof args[0] === 'object';
|
|
13
13
|
}
|
package/cjs/fwk/date.js
CHANGED
|
@@ -189,7 +189,7 @@ var _NativeDateClass = Date;
|
|
|
189
189
|
function pad(val) {
|
|
190
190
|
var digits = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 2;
|
|
191
191
|
var str = "".concat(val);
|
|
192
|
-
return
|
|
192
|
+
return '0'.repeat(Math.max(0, digits - str.length)) + str;
|
|
193
193
|
}
|
|
194
194
|
var CommonDate = /*#__PURE__*/ function(Date1) {
|
|
195
195
|
"use strict";
|
|
@@ -201,15 +201,15 @@ var CommonDate = /*#__PURE__*/ function(Date1) {
|
|
|
201
201
|
}
|
|
202
202
|
_class_call_check(this, CommonDate);
|
|
203
203
|
if (args) {
|
|
204
|
-
if (typeof args[0] ===
|
|
205
|
-
var idxT = args[0].lastIndexOf(
|
|
204
|
+
if (typeof args[0] === 'string') {
|
|
205
|
+
var idxT = args[0].lastIndexOf('T');
|
|
206
206
|
// TZD = time zone designator (Z or +hh:mm or -hh:mm)
|
|
207
|
-
var idx = args[0].lastIndexOf(
|
|
207
|
+
var idx = args[0].lastIndexOf('Z');
|
|
208
208
|
if (idx < 0) {
|
|
209
|
-
idx = args[0].lastIndexOf(
|
|
209
|
+
idx = args[0].lastIndexOf('+');
|
|
210
210
|
}
|
|
211
211
|
if (idx < 0 && idxT > 0) {
|
|
212
|
-
var relativeIdx = args[0].substring(idxT).lastIndexOf(
|
|
212
|
+
var relativeIdx = args[0].substring(idxT).lastIndexOf('-');
|
|
213
213
|
idx = relativeIdx > 0 ? relativeIdx + idxT : relativeIdx;
|
|
214
214
|
}
|
|
215
215
|
if (idx > 0) {
|
|
@@ -217,7 +217,7 @@ var CommonDate = /*#__PURE__*/ function(Date1) {
|
|
|
217
217
|
}
|
|
218
218
|
var TIME_ZONE_OFFSET = _construct(Date, _to_consumable_array(args)).getTimezoneOffset();
|
|
219
219
|
if (idxT > 0) {
|
|
220
|
-
args[0] += "".concat(TIME_ZONE_OFFSET < 0 ?
|
|
220
|
+
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)));
|
|
221
221
|
}
|
|
222
222
|
} else if (_instanceof(args[0], CommonDate)) {
|
|
223
223
|
args[0] = args[0];
|
|
@@ -241,7 +241,7 @@ var CommonDate = /*#__PURE__*/ function(Date1) {
|
|
|
241
241
|
}(_wrap_native_super(Date));
|
|
242
242
|
var utils;
|
|
243
243
|
(function(utils) {
|
|
244
|
-
|
|
244
|
+
'use strict';
|
|
245
245
|
var _$Date = /*#__PURE__*/ function(CommonDate) {
|
|
246
246
|
_inherits(Date1, CommonDate);
|
|
247
247
|
var _super = _create_super(Date1);
|
|
@@ -250,7 +250,7 @@ var utils;
|
|
|
250
250
|
args[_key] = arguments[_key];
|
|
251
251
|
}
|
|
252
252
|
_class_call_check(this, Date1);
|
|
253
|
-
if (args && typeof args[0] ===
|
|
253
|
+
if (args && typeof args[0] === 'string' && args[0].lastIndexOf('T') < 0) {
|
|
254
254
|
args[0] = "".concat(args[0], "T00:00:00Z");
|
|
255
255
|
} else if (_instanceof(args[0], _NativeDateClass)) {
|
|
256
256
|
args[0] = "".concat(args[0].getFullYear(), "-").concat(pad(args[0].getMonth() + 1), "-").concat(pad(args[0].getDate()), "T00:00:00Z");
|