@ama-sdk/core 14.6.0-prerelease.9 → 15.1.0-prerelease.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/fwk/api-helpers.js +10 -19
- package/cjs/fwk/api-helpers.spec.js +79 -10
- package/cjs/fwk/core/api-client.js +1 -1
- package/cjs/fwk/date.js +20 -29
- package/cjs/fwk/errors.js +16 -27
- package/cjs/fwk/mocks/alf-mock-adapter.js +5 -11
- package/cjs/fwk/mocks/base-mock-adapter.js +4 -11
- package/cjs/fwk/mocks/random-mock-adapter.js +12 -20
- package/cjs/fwk/mocks/sequential-mock-adapter.js +12 -20
- package/cjs/fwk/param-deserialization.js +1 -1
- package/cjs/fwk/param-serialization.js +2 -4
- package/cjs/fwk/server.js +1 -1
- package/cjs/plugins/additional-params/additional-params-request.js +17 -24
- package/cjs/plugins/additional-params/additional-params-sync-request.js +3 -7
- package/cjs/plugins/additional-params/additional-params.spec.js +2 -5
- package/cjs/plugins/api-configuration-override/api-configuration-override-request.js +4 -11
- package/cjs/plugins/api-configuration-override/api-configuration-override.spec.js +4 -11
- package/cjs/plugins/api-key/api-key-request.js +4 -11
- package/cjs/plugins/api-key/api-key.spec.js +2 -5
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint-request.js +4 -11
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +2 -5
- package/cjs/plugins/client-facts/client-facts-request.js +4 -11
- package/cjs/plugins/client-facts/client-facts.spec.js +3 -8
- package/cjs/plugins/custom-info/custom-info-reply.js +2 -6
- package/cjs/plugins/custom-info/custom-info.spec.js +2 -5
- package/cjs/plugins/exception/exception-reply.js +2 -6
- package/cjs/plugins/exception/exception.spec.js +1 -3
- package/cjs/plugins/fetch-cache/fetch-cache-request.js +4 -9
- package/cjs/plugins/fetch-cache/fetch-cache.spec.js +2 -5
- package/cjs/plugins/fetch-credentials/fetch-credentials-request.js +2 -6
- package/cjs/plugins/fetch-credentials/fetch-credentials.spec.js +2 -5
- package/cjs/plugins/json-token/json-token-reply.js +2 -6
- package/cjs/plugins/json-token/json-token-request.js +2 -6
- package/cjs/plugins/json-token/json-token.spec.js +2 -5
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth-helpers.js +14 -15
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth-request.js +4 -11
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +4 -11
- package/cjs/plugins/mock-intercept/mock-intercept-request.js +6 -14
- package/cjs/plugins/mock-intercept/mock-intercept.spec.js +2 -5
- package/cjs/plugins/open-telemetry/traceparent/open-telemetry-traceparent-reply.js +5 -10
- package/cjs/plugins/open-telemetry/traceparent/open-telemetry-traceparent-reply.spec.js +2 -5
- package/cjs/plugins/open-telemetry/traceparent/open-telemetry-traceparent-request.js +4 -9
- package/cjs/plugins/open-telemetry/traceparent/open-telemetry-traceparent-request.spec.js +2 -5
- package/cjs/plugins/pii-tokenizer/pii-tokenizer-request.js +4 -11
- package/cjs/plugins/pii-tokenizer/pii-tokenizer.spec.js +13 -30
- package/cjs/plugins/raw-response-info/raw-response-info-reply.js +4 -9
- package/cjs/plugins/raw-response-info/raw-response-info.spec.js +2 -5
- package/cjs/plugins/reviver/reviver-reply.js +2 -6
- package/cjs/plugins/reviver/reviver.spec.js +2 -5
- package/cjs/plugins/session-id/session-id-request.js +2 -6
- package/cjs/plugins/session-id/session-id.spec.js +2 -5
- package/cjs/plugins/si-token/si-token-request.js +12 -20
- package/cjs/plugins/si-token/si-token.spec.js +2 -5
- package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication-request.js +4 -11
- package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +2 -5
- package/cjs/plugins/url-rewrite/url-rewrite-request.js +4 -11
- package/cjs/plugins/url-rewrite/url-rewrite.spec.js +2 -5
- package/cjs/utils/crypto.js +2 -5
- package/cjs/utils/encoder.js +6 -8
- package/cjs/utils/generic-api.js +4 -11
- package/cjs/utils/json-token.js +2 -5
- package/cjs/utils/json-token.spec.js +11 -14
- package/cjs/utils/perf/perf-metric.js +4 -9
- package/esm2015/fwk/api-helpers.js +11 -21
- package/esm2015/fwk/api-helpers.spec.js +80 -11
- package/esm2015/fwk/core/api-client.js +1 -1
- package/esm2015/fwk/date.js +20 -29
- package/esm2015/fwk/errors.js +16 -27
- package/esm2015/fwk/mocks/alf-mock-adapter.js +5 -11
- package/esm2015/fwk/mocks/base-mock-adapter.js +4 -11
- package/esm2015/fwk/mocks/random-mock-adapter.js +12 -20
- package/esm2015/fwk/mocks/sequential-mock-adapter.js +12 -20
- package/esm2015/fwk/param-deserialization.js +1 -1
- package/esm2015/fwk/param-serialization.js +2 -4
- package/esm2015/fwk/server.js +1 -1
- package/esm2015/plugins/additional-params/additional-params-request.js +17 -24
- package/esm2015/plugins/additional-params/additional-params-sync-request.js +3 -7
- package/esm2015/plugins/additional-params/additional-params.spec.js +2 -5
- package/esm2015/plugins/api-configuration-override/api-configuration-override-request.js +4 -11
- package/esm2015/plugins/api-configuration-override/api-configuration-override.spec.js +4 -11
- package/esm2015/plugins/api-key/api-key-request.js +4 -11
- package/esm2015/plugins/api-key/api-key.spec.js +2 -5
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint-request.js +4 -11
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +2 -5
- package/esm2015/plugins/client-facts/client-facts-request.js +4 -11
- package/esm2015/plugins/client-facts/client-facts.spec.js +3 -8
- package/esm2015/plugins/custom-info/custom-info-reply.js +2 -6
- package/esm2015/plugins/custom-info/custom-info.spec.js +2 -5
- package/esm2015/plugins/exception/exception-reply.js +2 -6
- package/esm2015/plugins/exception/exception.spec.js +1 -3
- package/esm2015/plugins/fetch-cache/fetch-cache-request.js +4 -9
- package/esm2015/plugins/fetch-cache/fetch-cache.spec.js +2 -5
- package/esm2015/plugins/fetch-credentials/fetch-credentials-request.js +2 -6
- package/esm2015/plugins/fetch-credentials/fetch-credentials.spec.js +2 -5
- package/esm2015/plugins/json-token/json-token-reply.js +2 -6
- package/esm2015/plugins/json-token/json-token-request.js +2 -6
- package/esm2015/plugins/json-token/json-token.spec.js +2 -5
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth-helpers.js +14 -15
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth-request.js +4 -11
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +4 -11
- package/esm2015/plugins/mock-intercept/mock-intercept-request.js +6 -14
- package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +2 -5
- package/esm2015/plugins/open-telemetry/traceparent/open-telemetry-traceparent-reply.js +5 -10
- package/esm2015/plugins/open-telemetry/traceparent/open-telemetry-traceparent-reply.spec.js +2 -5
- package/esm2015/plugins/open-telemetry/traceparent/open-telemetry-traceparent-request.js +4 -9
- package/esm2015/plugins/open-telemetry/traceparent/open-telemetry-traceparent-request.spec.js +2 -5
- package/esm2015/plugins/pii-tokenizer/pii-tokenizer-request.js +4 -11
- package/esm2015/plugins/pii-tokenizer/pii-tokenizer.spec.js +5 -11
- package/esm2015/plugins/raw-response-info/raw-response-info-reply.js +4 -9
- package/esm2015/plugins/raw-response-info/raw-response-info.spec.js +2 -5
- package/esm2015/plugins/reviver/reviver-reply.js +2 -6
- package/esm2015/plugins/reviver/reviver.spec.js +2 -5
- package/esm2015/plugins/session-id/session-id-request.js +2 -6
- package/esm2015/plugins/session-id/session-id.spec.js +2 -5
- package/esm2015/plugins/si-token/si-token-request.js +12 -20
- package/esm2015/plugins/si-token/si-token.spec.js +2 -5
- package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication-request.js +4 -11
- package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +2 -5
- package/esm2015/plugins/url-rewrite/url-rewrite-request.js +4 -11
- package/esm2015/plugins/url-rewrite/url-rewrite.spec.js +2 -5
- package/esm2015/utils/crypto.js +2 -5
- package/esm2015/utils/encoder.js +6 -8
- package/esm2015/utils/generic-api.js +4 -11
- package/esm2015/utils/json-token.js +2 -5
- package/esm2015/utils/json-token.spec.js +11 -14
- package/esm2015/utils/perf/perf-metric.js +4 -9
- package/package.json +25 -25
- package/schematics/ng-add/index.js +3 -2
- package/schematics/ng-add/index.js.map +1 -1
- package/src/fwk/api-helpers.d.ts +2 -10
- package/src/fwk/api-helpers.d.ts.map +1 -1
- package/src/fwk/api-helpers.js +8 -16
- package/src/fwk/api-helpers.js.map +1 -1
- package/src/fwk/core/api-client.d.ts +2 -10
- package/src/fwk/core/api-client.d.ts.map +1 -1
- package/src/fwk/core/api-client.js +1 -1
- package/src/fwk/core/api-client.js.map +1 -1
package/cjs/utils/crypto.js
CHANGED
|
@@ -37,11 +37,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
37
37
|
reject(error);
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
if (info.done)
|
|
41
|
-
|
|
42
|
-
} else {
|
|
43
|
-
Promise.resolve(value).then(_next, _throw);
|
|
44
|
-
}
|
|
40
|
+
if (info.done) resolve(value);
|
|
41
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
45
42
|
}
|
|
46
43
|
function _async_to_generator(fn) {
|
|
47
44
|
return function() {
|
package/cjs/utils/encoder.js
CHANGED
|
@@ -17,9 +17,7 @@ function _array_without_holes(arr) {
|
|
|
17
17
|
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
18
18
|
}
|
|
19
19
|
function _class_call_check(instance, Constructor) {
|
|
20
|
-
if (!(instance instanceof Constructor))
|
|
21
|
-
throw new TypeError("Cannot call a class as a function");
|
|
22
|
-
}
|
|
20
|
+
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
23
21
|
}
|
|
24
22
|
function _defineProperties(target, props) {
|
|
25
23
|
for(var i = 0; i < props.length; i++){
|
|
@@ -43,16 +41,16 @@ function _define_property(obj, key, value) {
|
|
|
43
41
|
configurable: true,
|
|
44
42
|
writable: true
|
|
45
43
|
});
|
|
46
|
-
} else
|
|
47
|
-
obj[key] = value;
|
|
48
|
-
}
|
|
44
|
+
} else obj[key] = value;
|
|
49
45
|
return obj;
|
|
50
46
|
}
|
|
51
47
|
function _iterable_to_array(iter) {
|
|
52
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
48
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
|
|
49
|
+
return Array.from(iter);
|
|
50
|
+
}
|
|
53
51
|
}
|
|
54
52
|
function _non_iterable_spread() {
|
|
55
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance
|
|
53
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
56
54
|
}
|
|
57
55
|
function _to_consumable_array(arr) {
|
|
58
56
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
package/cjs/utils/generic-api.js
CHANGED
|
@@ -17,11 +17,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
17
17
|
reject(error);
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
if (info.done)
|
|
21
|
-
|
|
22
|
-
} else {
|
|
23
|
-
Promise.resolve(value).then(_next, _throw);
|
|
24
|
-
}
|
|
20
|
+
if (info.done) resolve(value);
|
|
21
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
25
22
|
}
|
|
26
23
|
function _async_to_generator(fn) {
|
|
27
24
|
return function() {
|
|
@@ -39,9 +36,7 @@ function _async_to_generator(fn) {
|
|
|
39
36
|
};
|
|
40
37
|
}
|
|
41
38
|
function _class_call_check(instance, Constructor) {
|
|
42
|
-
if (!(instance instanceof Constructor))
|
|
43
|
-
throw new TypeError("Cannot call a class as a function");
|
|
44
|
-
}
|
|
39
|
+
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
45
40
|
}
|
|
46
41
|
function _defineProperties(target, props) {
|
|
47
42
|
for(var i = 0; i < props.length; i++){
|
|
@@ -65,9 +60,7 @@ function _define_property(obj, key, value) {
|
|
|
65
60
|
configurable: true,
|
|
66
61
|
writable: true
|
|
67
62
|
});
|
|
68
|
-
} else
|
|
69
|
-
obj[key] = value;
|
|
70
|
-
}
|
|
63
|
+
} else obj[key] = value;
|
|
71
64
|
return obj;
|
|
72
65
|
}
|
|
73
66
|
function _object_spread(target) {
|
package/cjs/utils/json-token.js
CHANGED
|
@@ -44,11 +44,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
44
44
|
reject(error);
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
if (info.done)
|
|
48
|
-
|
|
49
|
-
} else {
|
|
50
|
-
Promise.resolve(value).then(_next, _throw);
|
|
51
|
-
}
|
|
47
|
+
if (info.done) resolve(value);
|
|
48
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
52
49
|
}
|
|
53
50
|
function _async_to_generator(fn) {
|
|
54
51
|
return function() {
|
|
@@ -20,11 +20,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
20
20
|
reject(error);
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
|
-
if (info.done)
|
|
24
|
-
|
|
25
|
-
} else {
|
|
26
|
-
Promise.resolve(value).then(_next, _throw);
|
|
27
|
-
}
|
|
23
|
+
if (info.done) resolve(value);
|
|
24
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
28
25
|
}
|
|
29
26
|
function _async_to_generator(fn) {
|
|
30
27
|
return function() {
|
|
@@ -71,19 +68,11 @@ function _iterable_to_array_limit(arr, i) {
|
|
|
71
68
|
return _arr;
|
|
72
69
|
}
|
|
73
70
|
function _non_iterable_rest() {
|
|
74
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance
|
|
71
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
75
72
|
}
|
|
76
73
|
function _sliced_to_array(arr, i) {
|
|
77
74
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
78
75
|
}
|
|
79
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
80
|
-
if (!o) return;
|
|
81
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
82
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
83
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
84
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
85
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
86
|
-
}
|
|
87
76
|
function _ts_generator(thisArg, body) {
|
|
88
77
|
var f, y, t, _ = {
|
|
89
78
|
label: 0,
|
|
@@ -183,6 +172,14 @@ function _ts_generator(thisArg, body) {
|
|
|
183
172
|
};
|
|
184
173
|
}
|
|
185
174
|
}
|
|
175
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
176
|
+
if (!o) return;
|
|
177
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
178
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
179
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
180
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
181
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
182
|
+
}
|
|
186
183
|
describe('JSON token utils', function() {
|
|
187
184
|
it('should encode and decode in base64 properly a string that contains characters occupying more than 1 byte', function() {
|
|
188
185
|
var base64Encoder = (0, _jsontoken.createBase64Encoder)();
|
|
@@ -10,9 +10,7 @@ Object.defineProperty(exports, "PerformanceMetricService", {
|
|
|
10
10
|
});
|
|
11
11
|
var _uuid = require("uuid");
|
|
12
12
|
function _class_call_check(instance, Constructor) {
|
|
13
|
-
if (!(instance instanceof Constructor))
|
|
14
|
-
throw new TypeError("Cannot call a class as a function");
|
|
15
|
-
}
|
|
13
|
+
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
16
14
|
}
|
|
17
15
|
function _defineProperties(target, props) {
|
|
18
16
|
for(var i = 0; i < props.length; i++){
|
|
@@ -36,9 +34,7 @@ function _define_property(obj, key, value) {
|
|
|
36
34
|
configurable: true,
|
|
37
35
|
writable: true
|
|
38
36
|
});
|
|
39
|
-
} else
|
|
40
|
-
obj[key] = value;
|
|
41
|
-
}
|
|
37
|
+
} else obj[key] = value;
|
|
42
38
|
return obj;
|
|
43
39
|
}
|
|
44
40
|
function _object_spread(target) {
|
|
@@ -71,9 +67,8 @@ function ownKeys(object, enumerableOnly) {
|
|
|
71
67
|
}
|
|
72
68
|
function _object_spread_props(target, source) {
|
|
73
69
|
source = source != null ? source : {};
|
|
74
|
-
if (Object.getOwnPropertyDescriptors)
|
|
75
|
-
|
|
76
|
-
} else {
|
|
70
|
+
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
71
|
+
else {
|
|
77
72
|
ownKeys(Object(source)).forEach(function(key) {
|
|
78
73
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
79
74
|
});
|
|
@@ -14,9 +14,7 @@ function _define_property(obj, key, value) {
|
|
|
14
14
|
configurable: true,
|
|
15
15
|
writable: true
|
|
16
16
|
});
|
|
17
|
-
} else
|
|
18
|
-
obj[key] = value;
|
|
19
|
-
}
|
|
17
|
+
} else obj[key] = value;
|
|
20
18
|
return obj;
|
|
21
19
|
}
|
|
22
20
|
function _iterable_to_array_limit(arr, i) {
|
|
@@ -44,7 +42,7 @@ function _iterable_to_array_limit(arr, i) {
|
|
|
44
42
|
return _arr;
|
|
45
43
|
}
|
|
46
44
|
function _non_iterable_rest() {
|
|
47
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance
|
|
45
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
48
46
|
}
|
|
49
47
|
function _object_spread(target) {
|
|
50
48
|
for(var i = 1; i < arguments.length; i++){
|
|
@@ -77,29 +75,21 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
77
75
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
78
76
|
}
|
|
79
77
|
import { isDateType } from './param-serialization';
|
|
80
|
-
/**
|
|
81
|
-
* Prepares the url to be called
|
|
82
|
-
* @param url Base url to be used
|
|
83
|
-
* @param queryParameters Key value pair with the parameters. If the value is undefined, the key is dropped
|
|
84
|
-
* @deprecated use {@link prepareUrlWithQueryParams} with query parameter serialization, will be removed in v15.
|
|
85
|
-
*/ export function prepareUrl(url) {
|
|
86
|
-
var queryParameters = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
87
|
-
var queryPart = Object.keys(queryParameters).filter(function(name) {
|
|
88
|
-
return typeof queryParameters[name] !== 'undefined';
|
|
89
|
-
}).map(function(name) {
|
|
90
|
-
return "".concat(name, "=").concat(queryParameters[name]);
|
|
91
|
-
}).join('&');
|
|
92
|
-
var paramsPrefix = url.includes('?') ? '&' : '?';
|
|
93
|
-
return url + (queryPart ? paramsPrefix + queryPart : '');
|
|
94
|
-
}
|
|
95
78
|
/**
|
|
96
79
|
* Prepares the url to be called with the query parameters
|
|
97
80
|
* @param url Base url to be used
|
|
98
81
|
* @param serializedQueryParams Key value pairs of query parameter names and their serialized values
|
|
82
|
+
* @param enableParameterSerialization Enable parameter serialization
|
|
99
83
|
*/ export function prepareUrlWithQueryParams(url) {
|
|
100
|
-
var serializedQueryParams = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
84
|
+
var serializedQueryParams = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, enableParameterSerialization = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
101
85
|
var paramsPrefix = url.includes('?') ? '&' : '?';
|
|
102
|
-
var queryPart = Object.values(serializedQueryParams).join('&')
|
|
86
|
+
var queryPart = enableParameterSerialization ? Object.values(serializedQueryParams).join('&') : Object.entries(serializedQueryParams).filter(function(param) {
|
|
87
|
+
var _param = _sliced_to_array(param, 2), value = _param[1];
|
|
88
|
+
return typeof value !== 'undefined';
|
|
89
|
+
}).map(function(param) {
|
|
90
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
91
|
+
return "".concat(key, "=").concat(value);
|
|
92
|
+
}).join('&');
|
|
103
93
|
return url + (queryPart ? paramsPrefix + queryPart : '');
|
|
104
94
|
}
|
|
105
95
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* eslint-disable no-console -- only using the reference */ import { getResponseReviver,
|
|
1
|
+
/* eslint-disable no-console -- only using the reference */ import { getResponseReviver, prepareUrlWithQueryParams, stringifyQueryParams } from '@ama-sdk/core';
|
|
2
2
|
describe('getResponseReviver - revivers by status code', function() {
|
|
3
3
|
var revivers = {
|
|
4
4
|
202: jest.fn(),
|
|
@@ -83,16 +83,6 @@ describe('getResponseReviver - reviver as function', function() {
|
|
|
83
83
|
});
|
|
84
84
|
});
|
|
85
85
|
describe('Prepare URL', function() {
|
|
86
|
-
it('should correctly prepare url with query parameters of deprecated type', function() {
|
|
87
|
-
// primitive value
|
|
88
|
-
expect(prepareUrl('https://sampleUrl/samplePath/sampleOperation', {
|
|
89
|
-
id: '5'
|
|
90
|
-
})).toEqual('https://sampleUrl/samplePath/sampleOperation?id=5');
|
|
91
|
-
// array value
|
|
92
|
-
expect(prepareUrl('https://sampleUrl/samplePath/sampleOperation', {
|
|
93
|
-
id: '3,4,5'
|
|
94
|
-
})).toEqual('https://sampleUrl/samplePath/sampleOperation?id=3,4,5');
|
|
95
|
-
});
|
|
96
86
|
it('should correctly prepare url with serialized query parameters', function() {
|
|
97
87
|
// one parameter
|
|
98
88
|
expect(prepareUrlWithQueryParams('https://sampleUrl/samplePath/sampleOperation', {
|
|
@@ -106,4 +96,83 @@ describe('Prepare URL', function() {
|
|
|
106
96
|
id2: 'id2=5'
|
|
107
97
|
})).toEqual('https://sampleUrl/samplePath/sampleOperation?id1=3,4,5&id2=5');
|
|
108
98
|
});
|
|
99
|
+
it('should correctly prepare url with serialized query parameters when enableParameterSerialization is true', function() {
|
|
100
|
+
// Serialized values already contain "key=value" — Object.values is used
|
|
101
|
+
expect(prepareUrlWithQueryParams('https://sampleUrl/samplePath/sampleOperation', {
|
|
102
|
+
id: 'id=5'
|
|
103
|
+
}, true)).toEqual('https://sampleUrl/samplePath/sampleOperation?id=5');
|
|
104
|
+
expect(prepareUrlWithQueryParams('https://sampleUrl/samplePath/sampleOperation', {
|
|
105
|
+
id1: 'id1=3,4,5',
|
|
106
|
+
id2: 'id2=5'
|
|
107
|
+
}, true)).toEqual('https://sampleUrl/samplePath/sampleOperation?id1=3,4,5&id2=5');
|
|
108
|
+
});
|
|
109
|
+
it('should correctly prepare url with stringified query parameters when enableParameterSerialization is false', function() {
|
|
110
|
+
// Stringified values are bare — Object.entries is used to produce "key=value"
|
|
111
|
+
expect(prepareUrlWithQueryParams('https://sampleUrl/samplePath/sampleOperation', {
|
|
112
|
+
id: '5'
|
|
113
|
+
}, false)).toEqual('https://sampleUrl/samplePath/sampleOperation?id=5');
|
|
114
|
+
// no parameters
|
|
115
|
+
expect(prepareUrlWithQueryParams('https://sampleUrl/samplePath/sampleOperation', {}, false)).toEqual('https://sampleUrl/samplePath/sampleOperation');
|
|
116
|
+
// multiple parameters
|
|
117
|
+
expect(prepareUrlWithQueryParams('https://sampleUrl/samplePath/sampleOperation', {
|
|
118
|
+
id1: '3,4,5',
|
|
119
|
+
id2: '5'
|
|
120
|
+
}, false)).toEqual('https://sampleUrl/samplePath/sampleOperation?id1=3,4,5&id2=5');
|
|
121
|
+
// array-like values
|
|
122
|
+
expect(prepareUrlWithQueryParams('https://sampleUrl/samplePath/sampleOperation', {
|
|
123
|
+
tags: 'a,b,c'
|
|
124
|
+
}, false)).toEqual('https://sampleUrl/samplePath/sampleOperation?tags=a,b,c');
|
|
125
|
+
// undefined values should be filtered
|
|
126
|
+
expect(prepareUrlWithQueryParams('https://sampleUrl/samplePath/sampleOperation', {
|
|
127
|
+
id: '5',
|
|
128
|
+
filter: undefined
|
|
129
|
+
}, false)).toEqual('https://sampleUrl/samplePath/sampleOperation?id=5');
|
|
130
|
+
});
|
|
131
|
+
it('should use & as separator when url already contains ?', function() {
|
|
132
|
+
expect(prepareUrlWithQueryParams('https://sampleUrl/samplePath?existing=1', {
|
|
133
|
+
id: 'id=5'
|
|
134
|
+
}, true)).toEqual('https://sampleUrl/samplePath?existing=1&id=5');
|
|
135
|
+
expect(prepareUrlWithQueryParams('https://sampleUrl/samplePath?existing=1', {
|
|
136
|
+
id: '5'
|
|
137
|
+
}, false)).toEqual('https://sampleUrl/samplePath?existing=1&id=5');
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
describe('stringifyQueryParams', function() {
|
|
141
|
+
it('should exclude undefined values from the result', function() {
|
|
142
|
+
var queryParams = {
|
|
143
|
+
id: '5',
|
|
144
|
+
filter: undefined,
|
|
145
|
+
name: 'test'
|
|
146
|
+
};
|
|
147
|
+
var result = stringifyQueryParams(queryParams);
|
|
148
|
+
expect(result).toEqual({
|
|
149
|
+
id: '5',
|
|
150
|
+
name: 'test'
|
|
151
|
+
});
|
|
152
|
+
expect('filter' in result).toBe(false);
|
|
153
|
+
});
|
|
154
|
+
it('should exclude null values from the result', function() {
|
|
155
|
+
var queryParams = {
|
|
156
|
+
id: '5',
|
|
157
|
+
filter: null,
|
|
158
|
+
name: 'test'
|
|
159
|
+
};
|
|
160
|
+
var result = stringifyQueryParams(queryParams);
|
|
161
|
+
expect(result).toEqual({
|
|
162
|
+
id: '5',
|
|
163
|
+
name: 'test'
|
|
164
|
+
});
|
|
165
|
+
expect('filter' in result).toBe(false);
|
|
166
|
+
});
|
|
167
|
+
it('should produce correct URL when combined with prepareUrlWithQueryParams and enableParameterSerialization is false', function() {
|
|
168
|
+
// Simulates the template flow: stringifyQueryParams -> prepareUrlWithQueryParams(url, params, false)
|
|
169
|
+
var queryParams = {
|
|
170
|
+
id: '5',
|
|
171
|
+
filter: undefined,
|
|
172
|
+
page: '2'
|
|
173
|
+
};
|
|
174
|
+
var stringified = stringifyQueryParams(queryParams);
|
|
175
|
+
var url = prepareUrlWithQueryParams('https://api.example.com/resource', stringified, false);
|
|
176
|
+
expect(url).toEqual('https://api.example.com/resource?id=5&page=2');
|
|
177
|
+
});
|
|
109
178
|
});
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* @param client object to check
|
|
4
4
|
*/ export function isApiClient(client) {
|
|
5
5
|
var apiClient = client;
|
|
6
|
-
return !!apiClient && !!apiClient.options && typeof apiClient.stringifyQueryParams === 'function' && typeof apiClient.getRequestOptions === 'function' &&
|
|
6
|
+
return !!apiClient && !!apiClient.options && typeof apiClient.stringifyQueryParams === 'function' && typeof apiClient.getRequestOptions === 'function' && typeof apiClient.prepareUrlWithQueryParams === 'function' && typeof apiClient.processFormData === 'function' && typeof apiClient.processCall === 'function';
|
|
7
7
|
}
|
package/esm2015/fwk/date.js
CHANGED
|
@@ -8,9 +8,7 @@ function _array_without_holes(arr) {
|
|
|
8
8
|
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
9
9
|
}
|
|
10
10
|
function _assert_this_initialized(self) {
|
|
11
|
-
if (self === void 0)
|
|
12
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
13
|
-
}
|
|
11
|
+
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
14
12
|
return self;
|
|
15
13
|
}
|
|
16
14
|
function _call_super(_this, derived, args) {
|
|
@@ -18,14 +16,11 @@ function _call_super(_this, derived, args) {
|
|
|
18
16
|
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
19
17
|
}
|
|
20
18
|
function _class_call_check(instance, Constructor) {
|
|
21
|
-
if (!(instance instanceof Constructor))
|
|
22
|
-
throw new TypeError("Cannot call a class as a function");
|
|
23
|
-
}
|
|
19
|
+
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
24
20
|
}
|
|
25
21
|
function _construct(Parent, args, Class) {
|
|
26
|
-
if (_is_native_reflect_construct())
|
|
27
|
-
|
|
28
|
-
} else {
|
|
22
|
+
if (_is_native_reflect_construct()) _construct = Reflect.construct;
|
|
23
|
+
else {
|
|
29
24
|
_construct = function construct(Parent, args, Class) {
|
|
30
25
|
var a = [
|
|
31
26
|
null
|
|
@@ -76,23 +71,29 @@ function _instanceof(left, right) {
|
|
|
76
71
|
"@swc/helpers - instanceof";
|
|
77
72
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
78
73
|
return !!right[Symbol.hasInstance](left);
|
|
79
|
-
} else
|
|
80
|
-
return left instanceof right;
|
|
81
|
-
}
|
|
74
|
+
} else return left instanceof right;
|
|
82
75
|
}
|
|
83
76
|
function _is_native_function(fn) {
|
|
84
77
|
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
85
78
|
}
|
|
79
|
+
function _is_native_reflect_construct() {
|
|
80
|
+
try {
|
|
81
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
82
|
+
} catch (_) {}
|
|
83
|
+
return (_is_native_reflect_construct = function() {
|
|
84
|
+
return !!result;
|
|
85
|
+
})();
|
|
86
|
+
}
|
|
86
87
|
function _iterable_to_array(iter) {
|
|
87
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
88
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) {
|
|
89
|
+
return Array.from(iter);
|
|
90
|
+
}
|
|
88
91
|
}
|
|
89
92
|
function _non_iterable_spread() {
|
|
90
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance
|
|
93
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
91
94
|
}
|
|
92
95
|
function _possible_constructor_return(self, call) {
|
|
93
|
-
if (call && (_type_of(call) === "object" || typeof call === "function"))
|
|
94
|
-
return call;
|
|
95
|
-
}
|
|
96
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) return call;
|
|
96
97
|
return _assert_this_initialized(self);
|
|
97
98
|
}
|
|
98
99
|
function _set_prototype_of(o, p) {
|
|
@@ -119,11 +120,9 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
119
120
|
}
|
|
120
121
|
function _wrap_native_super(Class) {
|
|
121
122
|
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
122
|
-
_wrap_native_super = function
|
|
123
|
+
_wrap_native_super = function(Class) {
|
|
123
124
|
if (Class === null || !_is_native_function(Class)) return Class;
|
|
124
|
-
if (typeof Class !== "function")
|
|
125
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
126
|
-
}
|
|
125
|
+
if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
|
|
127
126
|
if (typeof _cache !== "undefined") {
|
|
128
127
|
if (_cache.has(Class)) return _cache.get(Class);
|
|
129
128
|
_cache.set(Class, Wrapper);
|
|
@@ -143,14 +142,6 @@ function _wrap_native_super(Class) {
|
|
|
143
142
|
};
|
|
144
143
|
return _wrap_native_super(Class);
|
|
145
144
|
}
|
|
146
|
-
function _is_native_reflect_construct() {
|
|
147
|
-
try {
|
|
148
|
-
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
149
|
-
} catch (_) {}
|
|
150
|
-
return (_is_native_reflect_construct = function() {
|
|
151
|
-
return !!result;
|
|
152
|
-
})();
|
|
153
|
-
}
|
|
154
145
|
// eslint-disable-next-line @typescript-eslint/naming-convention, no-underscore-dangle -- keep to not introduce breaking change
|
|
155
146
|
export var _NativeDateClass = Date;
|
|
156
147
|
/**
|
package/esm2015/fwk/errors.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generic error context
|
|
3
3
|
*/ function _assert_this_initialized(self) {
|
|
4
|
-
if (self === void 0)
|
|
5
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
6
|
-
}
|
|
4
|
+
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
7
5
|
return self;
|
|
8
6
|
}
|
|
9
7
|
function _call_super(_this, derived, args) {
|
|
@@ -11,14 +9,11 @@ function _call_super(_this, derived, args) {
|
|
|
11
9
|
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
12
10
|
}
|
|
13
11
|
function _class_call_check(instance, Constructor) {
|
|
14
|
-
if (!(instance instanceof Constructor))
|
|
15
|
-
throw new TypeError("Cannot call a class as a function");
|
|
16
|
-
}
|
|
12
|
+
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
17
13
|
}
|
|
18
14
|
function _construct(Parent, args, Class) {
|
|
19
|
-
if (_is_native_reflect_construct())
|
|
20
|
-
|
|
21
|
-
} else {
|
|
15
|
+
if (_is_native_reflect_construct()) _construct = Reflect.construct;
|
|
16
|
+
else {
|
|
22
17
|
_construct = function construct(Parent, args, Class) {
|
|
23
18
|
var a = [
|
|
24
19
|
null
|
|
@@ -40,9 +35,7 @@ function _define_property(obj, key, value) {
|
|
|
40
35
|
configurable: true,
|
|
41
36
|
writable: true
|
|
42
37
|
});
|
|
43
|
-
} else
|
|
44
|
-
obj[key] = value;
|
|
45
|
-
}
|
|
38
|
+
} else obj[key] = value;
|
|
46
39
|
return obj;
|
|
47
40
|
}
|
|
48
41
|
function _get_prototype_of(o) {
|
|
@@ -67,10 +60,16 @@ function _inherits(subClass, superClass) {
|
|
|
67
60
|
function _is_native_function(fn) {
|
|
68
61
|
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
69
62
|
}
|
|
63
|
+
function _is_native_reflect_construct() {
|
|
64
|
+
try {
|
|
65
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
66
|
+
} catch (_) {}
|
|
67
|
+
return (_is_native_reflect_construct = function() {
|
|
68
|
+
return !!result;
|
|
69
|
+
})();
|
|
70
|
+
}
|
|
70
71
|
function _possible_constructor_return(self, call) {
|
|
71
|
-
if (call && (_type_of(call) === "object" || typeof call === "function"))
|
|
72
|
-
return call;
|
|
73
|
-
}
|
|
72
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) return call;
|
|
74
73
|
return _assert_this_initialized(self);
|
|
75
74
|
}
|
|
76
75
|
function _set_prototype_of(o, p) {
|
|
@@ -86,11 +85,9 @@ function _type_of(obj) {
|
|
|
86
85
|
}
|
|
87
86
|
function _wrap_native_super(Class) {
|
|
88
87
|
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
89
|
-
_wrap_native_super = function
|
|
88
|
+
_wrap_native_super = function(Class) {
|
|
90
89
|
if (Class === null || !_is_native_function(Class)) return Class;
|
|
91
|
-
if (typeof Class !== "function")
|
|
92
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
93
|
-
}
|
|
90
|
+
if (typeof Class !== "function") throw new TypeError("Super expression must either be null or a function");
|
|
94
91
|
if (typeof _cache !== "undefined") {
|
|
95
92
|
if (_cache.has(Class)) return _cache.get(Class);
|
|
96
93
|
_cache.set(Class, Wrapper);
|
|
@@ -110,14 +107,6 @@ function _wrap_native_super(Class) {
|
|
|
110
107
|
};
|
|
111
108
|
return _wrap_native_super(Class);
|
|
112
109
|
}
|
|
113
|
-
function _is_native_reflect_construct() {
|
|
114
|
-
try {
|
|
115
|
-
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
116
|
-
} catch (_) {}
|
|
117
|
-
return (_is_native_reflect_construct = function() {
|
|
118
|
-
return !!result;
|
|
119
|
-
})();
|
|
120
|
-
}
|
|
121
110
|
/**
|
|
122
111
|
* Generic error class
|
|
123
112
|
*/ export var GenericError = /*#__PURE__*/ function(Error1) {
|
|
@@ -6,11 +6,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
6
6
|
reject(error);
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
|
-
if (info.done)
|
|
10
|
-
|
|
11
|
-
} else {
|
|
12
|
-
Promise.resolve(value).then(_next, _throw);
|
|
13
|
-
}
|
|
9
|
+
if (info.done) resolve(value);
|
|
10
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
14
11
|
}
|
|
15
12
|
function _async_to_generator(fn) {
|
|
16
13
|
return function() {
|
|
@@ -35,9 +32,7 @@ function _define_property(obj, key, value) {
|
|
|
35
32
|
configurable: true,
|
|
36
33
|
writable: true
|
|
37
34
|
});
|
|
38
|
-
} else
|
|
39
|
-
obj[key] = value;
|
|
40
|
-
}
|
|
35
|
+
} else obj[key] = value;
|
|
41
36
|
return obj;
|
|
42
37
|
}
|
|
43
38
|
function _object_spread(target) {
|
|
@@ -70,9 +65,8 @@ function ownKeys(object, enumerableOnly) {
|
|
|
70
65
|
}
|
|
71
66
|
function _object_spread_props(target, source) {
|
|
72
67
|
source = source != null ? source : {};
|
|
73
|
-
if (Object.getOwnPropertyDescriptors)
|
|
74
|
-
|
|
75
|
-
} else {
|
|
68
|
+
if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
69
|
+
else {
|
|
76
70
|
ownKeys(Object(source)).forEach(function(key) {
|
|
77
71
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
78
72
|
});
|
|
@@ -6,11 +6,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
6
6
|
reject(error);
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
|
-
if (info.done)
|
|
10
|
-
|
|
11
|
-
} else {
|
|
12
|
-
Promise.resolve(value).then(_next, _throw);
|
|
13
|
-
}
|
|
9
|
+
if (info.done) resolve(value);
|
|
10
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
14
11
|
}
|
|
15
12
|
function _async_to_generator(fn) {
|
|
16
13
|
return function() {
|
|
@@ -28,9 +25,7 @@ function _async_to_generator(fn) {
|
|
|
28
25
|
};
|
|
29
26
|
}
|
|
30
27
|
function _class_call_check(instance, Constructor) {
|
|
31
|
-
if (!(instance instanceof Constructor))
|
|
32
|
-
throw new TypeError("Cannot call a class as a function");
|
|
33
|
-
}
|
|
28
|
+
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
|
|
34
29
|
}
|
|
35
30
|
function _defineProperties(target, props) {
|
|
36
31
|
for(var i = 0; i < props.length; i++){
|
|
@@ -54,9 +49,7 @@ function _define_property(obj, key, value) {
|
|
|
54
49
|
configurable: true,
|
|
55
50
|
writable: true
|
|
56
51
|
});
|
|
57
|
-
} else
|
|
58
|
-
obj[key] = value;
|
|
59
|
-
}
|
|
52
|
+
} else obj[key] = value;
|
|
60
53
|
return obj;
|
|
61
54
|
}
|
|
62
55
|
function _ts_generator(thisArg, body) {
|