@ama-sdk/core 11.6.0-prerelease.2 → 11.6.0-prerelease.21
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 +12 -4
- package/cjs/clients/api-beacon-client.js +1 -2
- package/cjs/clients/api-fetch-client.js +15 -24
- package/cjs/fwk/api.helper.spec.js +1 -1
- package/cjs/fwk/api.helpers.js +20 -24
- package/cjs/fwk/core/api-client.js +2 -1
- package/cjs/fwk/core/index.js +1 -1
- package/cjs/fwk/date.js +26 -27
- package/cjs/fwk/date.spec.js +4 -2
- package/cjs/fwk/ignore-enum.type.js +1 -2
- package/cjs/fwk/index.js +1 -1
- package/cjs/fwk/mocks/alf-mock-adapter.js +7 -6
- package/cjs/fwk/mocks/base-mock-adapter.js +3 -3
- package/cjs/fwk/mocks/helpers.js +15 -7
- package/cjs/fwk/mocks/index.js +3 -3
- package/cjs/fwk/{Reviver.js → reviver.js} +1 -2
- package/cjs/fwk/reviver.spec.js +9 -9
- package/cjs/plugins/additional-params/index.js +1 -1
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +3 -3
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +7 -10
- package/cjs/plugins/client-facts/client-facts.request.js +5 -5
- package/cjs/plugins/concurrent/concurrent.fetch.js +5 -9
- package/cjs/plugins/core/index.js +2 -2
- package/cjs/plugins/custom-info/custom-info.reply.js +2 -2
- package/cjs/plugins/exception/exception.spec.js +1 -1
- package/cjs/plugins/fetch-cache/fetch-cache.request.js +1 -1
- package/cjs/plugins/fetch-credentials/fetch-credentials.spec.js +4 -4
- package/cjs/plugins/json-token/json-token.reply.js +6 -6
- package/cjs/plugins/json-token/json-token.request.js +1 -1
- package/cjs/plugins/json-token/json-token.spec.js +7 -9
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +0 -2
- package/cjs/plugins/mock-intercept/index.js +1 -1
- package/cjs/plugins/mock-intercept/mock-intercept.angular.js +4 -4
- package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +0 -2
- package/cjs/plugins/mock-intercept/mock-intercept.spec.js +5 -4
- package/cjs/plugins/perf-metric/perf-metric.fetch.js +10 -2
- package/cjs/plugins/pii-tokenizer/pii-tokenizer.request.js +5 -11
- package/cjs/plugins/pii-tokenizer/pii-tokenizer.spec.js +5 -6
- package/cjs/plugins/retry/retry.fetch.js +17 -32
- package/cjs/plugins/retry/retry.spec.js +4 -4
- package/cjs/plugins/session-id/session-id.request.js +4 -4
- package/cjs/plugins/session-id/session-id.spec.js +2 -2
- package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +1 -1
- package/cjs/plugins/timeout/timeout.fetch.js +14 -6
- package/cjs/plugins/wait-for/wait-for.fetch.js +3 -3
- package/cjs/plugins/wait-for/wait-for.spec.js +1 -1
- package/cjs/utils/crypto.js +7 -7
- package/cjs/utils/encoder.js +9 -17
- package/cjs/utils/generic-api.js +1 -2
- package/cjs/utils/ie11.js +1 -0
- package/cjs/utils/index.js +1 -1
- package/cjs/utils/json-token.js +7 -7
- package/cjs/utils/json-token.spec.js +14 -11
- package/cjs/utils/mime-types.js +1 -1
- package/esm2015/clients/api-angular-client.js +12 -4
- package/esm2015/clients/api-beacon-client.js +1 -2
- package/esm2015/clients/api-fetch-client.js +15 -24
- package/esm2015/fwk/api.helper.spec.js +1 -1
- package/esm2015/fwk/api.helpers.js +24 -30
- package/esm2015/fwk/core/api-client.js +2 -1
- package/esm2015/fwk/core/index.js +1 -1
- package/esm2015/fwk/date.js +30 -29
- package/esm2015/fwk/date.spec.js +4 -2
- package/esm2015/fwk/ignore-enum.type.js +1 -2
- package/esm2015/fwk/index.js +1 -1
- package/esm2015/fwk/mocks/alf-mock-adapter.js +7 -6
- package/esm2015/fwk/mocks/base-mock-adapter.js +3 -3
- package/esm2015/fwk/mocks/helpers.js +15 -7
- package/esm2015/fwk/mocks/index.js +3 -3
- package/esm2015/fwk/{Reviver.js → reviver.js} +2 -2
- package/esm2015/fwk/reviver.spec.js +1 -1
- package/esm2015/plugins/additional-params/index.js +1 -1
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +3 -3
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +7 -10
- package/esm2015/plugins/client-facts/client-facts.request.js +5 -5
- package/esm2015/plugins/concurrent/concurrent.fetch.js +5 -9
- package/esm2015/plugins/core/index.js +2 -2
- package/esm2015/plugins/custom-info/custom-info.reply.js +2 -2
- package/esm2015/plugins/exception/exception.spec.js +1 -1
- package/esm2015/plugins/fetch-cache/fetch-cache.request.js +1 -1
- package/esm2015/plugins/fetch-credentials/fetch-credentials.spec.js +4 -4
- package/esm2015/plugins/json-token/json-token.reply.js +6 -6
- package/esm2015/plugins/json-token/json-token.request.js +1 -1
- package/esm2015/plugins/json-token/json-token.spec.js +7 -9
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +0 -2
- package/esm2015/plugins/mock-intercept/index.js +1 -1
- package/esm2015/plugins/mock-intercept/mock-intercept.angular.js +4 -4
- package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +0 -2
- package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +5 -4
- package/esm2015/plugins/perf-metric/perf-metric.fetch.js +10 -2
- package/esm2015/plugins/pii-tokenizer/pii-tokenizer.request.js +5 -11
- package/esm2015/plugins/pii-tokenizer/pii-tokenizer.spec.js +5 -6
- package/esm2015/plugins/retry/retry.fetch.js +17 -32
- package/esm2015/plugins/retry/retry.spec.js +4 -4
- package/esm2015/plugins/session-id/session-id.request.js +4 -4
- package/esm2015/plugins/session-id/session-id.spec.js +2 -2
- package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +1 -1
- package/esm2015/plugins/timeout/timeout.fetch.js +15 -8
- package/esm2015/plugins/wait-for/wait-for.fetch.js +3 -3
- package/esm2015/plugins/wait-for/wait-for.spec.js +1 -1
- package/esm2015/utils/crypto.js +7 -7
- package/esm2015/utils/encoder.js +9 -17
- package/esm2015/utils/generic-api.js +1 -2
- package/esm2015/utils/ie11.js +1 -0
- package/esm2015/utils/index.js +1 -1
- package/esm2015/utils/json-token.js +7 -7
- package/esm2015/utils/json-token.spec.js +8 -10
- package/esm2015/utils/mime-types.js +1 -1
- package/package.json +19 -13
- package/schematics/ng-add/index.d.ts.map +1 -1
- package/schematics/ng-add/index.js +24 -26
- package/schematics/ng-add/schema.d.ts.map +1 -1
- package/src/clients/api-angular-client.d.ts +2 -2
- package/src/clients/api-angular-client.d.ts.map +1 -1
- package/src/clients/api-angular-client.js +11 -9
- package/src/clients/api-angular-client.js.map +1 -1
- package/src/clients/api-beacon-client.d.ts +1 -1
- package/src/clients/api-beacon-client.d.ts.map +1 -1
- package/src/clients/api-beacon-client.js +2 -3
- package/src/clients/api-beacon-client.js.map +1 -1
- package/src/clients/api-fetch-client.d.ts +2 -2
- package/src/clients/api-fetch-client.d.ts.map +1 -1
- package/src/clients/api-fetch-client.js +14 -21
- package/src/clients/api-fetch-client.js.map +1 -1
- package/src/fwk/api.helpers.d.ts +6 -8
- package/src/fwk/api.helpers.d.ts.map +1 -1
- package/src/fwk/api.helpers.js +22 -31
- package/src/fwk/api.helpers.js.map +1 -1
- package/src/fwk/api.interface.d.ts.map +1 -1
- package/src/fwk/core/api-client.d.ts +3 -3
- package/src/fwk/core/api-client.d.ts.map +1 -1
- package/src/fwk/core/api-client.js +8 -7
- package/src/fwk/core/api-client.js.map +1 -1
- package/src/fwk/core/base-api-constructor.d.ts +1 -1
- package/src/fwk/core/base-api-constructor.d.ts.map +1 -1
- package/src/fwk/core/base-api-constructor.js.map +1 -1
- package/src/fwk/core/index.d.ts +1 -1
- package/src/fwk/core/index.d.ts.map +1 -1
- package/src/fwk/core/index.js +1 -1
- package/src/fwk/core/index.js.map +1 -1
- package/src/fwk/date.d.ts +6 -18
- package/src/fwk/date.d.ts.map +1 -1
- package/src/fwk/date.js +25 -28
- package/src/fwk/date.js.map +1 -1
- package/src/fwk/errors.d.ts.map +1 -1
- package/src/fwk/errors.js.map +1 -1
- package/src/fwk/ignore-enum.type.d.ts.map +1 -1
- package/src/fwk/index.d.ts +1 -1
- package/src/fwk/index.js +1 -1
- package/src/fwk/mocks/alf-mock-adapter.d.ts.map +1 -1
- package/src/fwk/mocks/alf-mock-adapter.js +11 -10
- package/src/fwk/mocks/alf-mock-adapter.js.map +1 -1
- package/src/fwk/mocks/base-mock-adapter.d.ts.map +1 -1
- package/src/fwk/mocks/base-mock-adapter.js +4 -4
- package/src/fwk/mocks/base-mock-adapter.js.map +1 -1
- package/src/fwk/mocks/encoded-api-request.d.ts +1 -1
- package/src/fwk/mocks/encoded-api-request.d.ts.map +1 -1
- package/src/fwk/mocks/helpers.d.ts.map +1 -1
- package/src/fwk/mocks/helpers.js +8 -7
- package/src/fwk/mocks/helpers.js.map +1 -1
- package/src/fwk/mocks/index.d.ts +3 -3
- package/src/fwk/mocks/index.d.ts.map +1 -1
- package/src/fwk/mocks/index.js +3 -3
- package/src/fwk/mocks/index.js.map +1 -1
- package/src/fwk/mocks/mock-adapter.d.ts +1 -1
- package/src/fwk/mocks/mock-adapter.d.ts.map +1 -1
- package/src/fwk/mocks/path-object.d.ts.map +1 -1
- package/src/fwk/mocks/random-mock-adapter.d.ts.map +1 -1
- package/src/fwk/mocks/random-mock-adapter.js +1 -1
- package/src/fwk/mocks/random-mock-adapter.js.map +1 -1
- package/src/fwk/mocks/sequential-mock-adapter.d.ts.map +1 -1
- package/src/fwk/mocks/sequential-mock-adapter.js +1 -1
- package/src/fwk/mocks/sequential-mock-adapter.js.map +1 -1
- package/src/fwk/{Reviver.d.ts → reviver.d.ts} +2 -1
- package/src/fwk/reviver.d.ts.map +1 -0
- package/src/fwk/{Reviver.js → reviver.js} +3 -3
- package/src/fwk/reviver.js.map +1 -0
- package/src/plugins/abort/abort.fetch.d.ts.map +1 -1
- package/src/plugins/abort/abort.fetch.js.map +1 -1
- package/src/plugins/additional-params/additional-params-sync.request.d.ts.map +1 -1
- package/src/plugins/additional-params/additional-params-sync.request.js +1 -1
- package/src/plugins/additional-params/additional-params-sync.request.js.map +1 -1
- package/src/plugins/additional-params/additional-params.request.d.ts.map +1 -1
- package/src/plugins/additional-params/additional-params.request.js.map +1 -1
- package/src/plugins/additional-params/index.d.ts +1 -1
- package/src/plugins/additional-params/index.d.ts.map +1 -1
- package/src/plugins/additional-params/index.js +1 -1
- package/src/plugins/additional-params/index.js.map +1 -1
- package/src/plugins/api-configuration-override/api-configuration-override.request.d.ts.map +1 -1
- package/src/plugins/api-configuration-override/api-configuration-override.request.js.map +1 -1
- package/src/plugins/api-key/api-key.request.d.ts.map +1 -1
- package/src/plugins/api-key/api-key.request.js.map +1 -1
- package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.d.ts +10 -10
- package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.d.ts.map +1 -1
- package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +5 -5
- package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js.map +1 -1
- package/src/plugins/client-facts/client-facts.request.d.ts +1 -1
- package/src/plugins/client-facts/client-facts.request.d.ts.map +1 -1
- package/src/plugins/client-facts/client-facts.request.js +5 -5
- package/src/plugins/client-facts/client-facts.request.js.map +1 -1
- package/src/plugins/concurrent/concurrent.fetch.d.ts.map +1 -1
- package/src/plugins/concurrent/concurrent.fetch.js +1 -6
- package/src/plugins/concurrent/concurrent.fetch.js.map +1 -1
- package/src/plugins/core/angular-plugin.d.ts +1 -1
- package/src/plugins/core/angular-plugin.d.ts.map +1 -1
- package/src/plugins/core/fetch-plugin.d.ts.map +1 -1
- package/src/plugins/core/index.d.ts +2 -2
- package/src/plugins/core/index.d.ts.map +1 -1
- package/src/plugins/core/index.js +2 -2
- package/src/plugins/core/index.js.map +1 -1
- package/src/plugins/core/plugin.d.ts.map +1 -1
- package/src/plugins/core/reply-plugin.d.ts +1 -1
- package/src/plugins/core/reply-plugin.d.ts.map +1 -1
- package/src/plugins/core/request-plugin.d.ts.map +1 -1
- package/src/plugins/custom-info/custom-info.reply.d.ts.map +1 -1
- package/src/plugins/custom-info/custom-info.reply.js +1 -1
- package/src/plugins/custom-info/custom-info.reply.js.map +1 -1
- package/src/plugins/exception/exception.reply.d.ts +1 -0
- package/src/plugins/exception/exception.reply.d.ts.map +1 -1
- package/src/plugins/exception/exception.reply.js +6 -5
- package/src/plugins/exception/exception.reply.js.map +1 -1
- package/src/plugins/fetch-cache/fetch-cache.request.d.ts.map +1 -1
- package/src/plugins/fetch-cache/fetch-cache.request.js +3 -3
- package/src/plugins/fetch-cache/fetch-cache.request.js.map +1 -1
- package/src/plugins/fetch-credentials/fetch-credentials.request.d.ts.map +1 -1
- package/src/plugins/fetch-credentials/fetch-credentials.request.js.map +1 -1
- package/src/plugins/json-token/json-token.reply.d.ts.map +1 -1
- package/src/plugins/json-token/json-token.reply.js +6 -6
- package/src/plugins/json-token/json-token.reply.js.map +1 -1
- package/src/plugins/json-token/json-token.request.d.ts.map +1 -1
- package/src/plugins/json-token/json-token.request.js +1 -1
- package/src/plugins/json-token/json-token.request.js.map +1 -1
- package/src/plugins/keepalive/keepalive.request.d.ts.map +1 -1
- package/src/plugins/keepalive/keepalive.request.js +1 -1
- package/src/plugins/keepalive/keepalive.request.js.map +1 -1
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.d.ts.map +1 -1
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +3 -3
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js.map +1 -1
- package/src/plugins/mock-intercept/index.d.ts +1 -1
- package/src/plugins/mock-intercept/index.d.ts.map +1 -1
- package/src/plugins/mock-intercept/index.js +1 -1
- package/src/plugins/mock-intercept/index.js.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.angular.d.ts +1 -1
- package/src/plugins/mock-intercept/mock-intercept.angular.d.ts.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.angular.js +15 -11
- package/src/plugins/mock-intercept/mock-intercept.angular.js.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.fetch.d.ts.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.fetch.js +4 -6
- package/src/plugins/mock-intercept/mock-intercept.fetch.js.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.interface.d.ts +1 -1
- package/src/plugins/mock-intercept/mock-intercept.interface.d.ts.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.interface.js.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.request.d.ts.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.request.js +4 -3
- package/src/plugins/mock-intercept/mock-intercept.request.js.map +1 -1
- package/src/plugins/perf-metric/perf-metric.fetch.d.ts.map +1 -1
- package/src/plugins/perf-metric/perf-metric.fetch.js +4 -3
- package/src/plugins/perf-metric/perf-metric.fetch.js.map +1 -1
- package/src/plugins/pii-tokenizer/pii-tokenizer.request.d.ts.map +1 -1
- package/src/plugins/pii-tokenizer/pii-tokenizer.request.js +5 -10
- package/src/plugins/pii-tokenizer/pii-tokenizer.request.js.map +1 -1
- package/src/plugins/raw-response-info/raw-response-info.reply.d.ts +0 -1
- package/src/plugins/raw-response-info/raw-response-info.reply.d.ts.map +1 -1
- package/src/plugins/raw-response-info/raw-response-info.reply.js +0 -1
- package/src/plugins/raw-response-info/raw-response-info.reply.js.map +1 -1
- package/src/plugins/retry/retry.fetch.d.ts.map +1 -1
- package/src/plugins/retry/retry.fetch.js +5 -4
- package/src/plugins/retry/retry.fetch.js.map +1 -1
- package/src/plugins/reviver/reviver.reply.d.ts +1 -1
- package/src/plugins/reviver/reviver.reply.d.ts.map +1 -1
- package/src/plugins/reviver/reviver.reply.js.map +1 -1
- package/src/plugins/session-id/session-id.request.d.ts +1 -1
- package/src/plugins/session-id/session-id.request.d.ts.map +1 -1
- package/src/plugins/session-id/session-id.request.js +5 -3
- package/src/plugins/session-id/session-id.request.js.map +1 -1
- package/src/plugins/si-token/si-token.request.d.ts.map +1 -1
- package/src/plugins/si-token/si-token.request.js +1 -1
- package/src/plugins/si-token/si-token.request.js.map +1 -1
- package/src/plugins/simple-api-key-authentication/simple-api-key-authentication.request.d.ts.map +1 -1
- package/src/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +1 -1
- package/src/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js.map +1 -1
- package/src/plugins/timeout/timeout.fetch.d.ts +1 -2
- package/src/plugins/timeout/timeout.fetch.d.ts.map +1 -1
- package/src/plugins/timeout/timeout.fetch.js +14 -12
- package/src/plugins/timeout/timeout.fetch.js.map +1 -1
- package/src/plugins/url-rewrite/url-rewrite.request.d.ts.map +1 -1
- package/src/plugins/url-rewrite/url-rewrite.request.js.map +1 -1
- package/src/plugins/wait-for/wait-for.fetch.d.ts.map +1 -1
- package/src/plugins/wait-for/wait-for.fetch.js +2 -2
- package/src/plugins/wait-for/wait-for.fetch.js.map +1 -1
- package/src/utils/crypto.d.ts.map +1 -1
- package/src/utils/crypto.js +7 -7
- package/src/utils/crypto.js.map +1 -1
- package/src/utils/encoder.d.ts +1 -1
- package/src/utils/encoder.d.ts.map +1 -1
- package/src/utils/encoder.js +22 -28
- package/src/utils/encoder.js.map +1 -1
- package/src/utils/generic-api.d.ts +1 -2
- package/src/utils/generic-api.d.ts.map +1 -1
- package/src/utils/generic-api.js +3 -6
- package/src/utils/generic-api.js.map +1 -1
- package/src/utils/ie11.d.ts.map +1 -1
- package/src/utils/ie11.js +1 -0
- package/src/utils/ie11.js.map +1 -1
- package/src/utils/index.d.ts +1 -1
- package/src/utils/index.d.ts.map +1 -1
- package/src/utils/index.js +1 -1
- package/src/utils/index.js.map +1 -1
- package/src/utils/json-token.d.ts.map +1 -1
- package/src/utils/json-token.js +12 -12
- package/src/utils/json-token.js.map +1 -1
- package/src/utils/mime-types.d.ts.map +1 -1
- package/src/utils/mime-types.js +1 -1
- package/src/utils/mime-types.js.map +1 -1
- package/src/fwk/Reviver.d.ts.map +0 -1
- package/src/fwk/Reviver.js.map +0 -1
|
@@ -225,10 +225,10 @@ function _ts_generator(thisArg, body) {
|
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
import { ExceptionReply } from '../plugins/exception';
|
|
229
|
-
import { ReviverReply } from '../plugins/reviver';
|
|
230
228
|
import { extractQueryParams, filterUndefinedValues, getResponseReviver, prepareUrl, processFormData, tokenizeRequestOptions } from '../fwk/api.helpers';
|
|
231
229
|
import { CanceledCallError, EmptyResponseError, ResponseJSONParseError } from '../fwk/errors';
|
|
230
|
+
import { ExceptionReply } from '../plugins/exception';
|
|
231
|
+
import { ReviverReply } from '../plugins/reviver';
|
|
232
232
|
var DEFAULT_OPTIONS = {
|
|
233
233
|
replyPlugins: [
|
|
234
234
|
new ReviverReply(),
|
|
@@ -410,17 +410,12 @@ var DEFAULT_OPTIONS = {
|
|
|
410
410
|
case 2:
|
|
411
411
|
canStart = _state.sent();
|
|
412
412
|
isCanceledBy = canStart.indexOf(false);
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
origin: origin
|
|
420
|
-
}));
|
|
421
|
-
} else {
|
|
422
|
-
asyncResponse = fetch(url, options);
|
|
423
|
-
}
|
|
413
|
+
asyncResponse = isCanceledBy === -1 ? fetch(url, options) : Promise.reject(new CanceledCallError("Is canceled by the plugin ".concat(isCanceledBy), isCanceledBy, _this.options.fetchPlugins[isCanceledBy], {
|
|
414
|
+
apiName: apiName,
|
|
415
|
+
operationId: operationId,
|
|
416
|
+
url: url,
|
|
417
|
+
origin: origin
|
|
418
|
+
}));
|
|
424
419
|
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
425
420
|
try {
|
|
426
421
|
for(_iterator = loadedPlugins[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
@@ -459,16 +454,12 @@ var DEFAULT_OPTIONS = {
|
|
|
459
454
|
];
|
|
460
455
|
case 5:
|
|
461
456
|
e = _state.sent();
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
url: url,
|
|
469
|
-
origin: origin
|
|
470
|
-
});
|
|
471
|
-
}
|
|
457
|
+
exception = _instanceof(e, CanceledCallError) ? e : new EmptyResponseError(e.message || 'Fail to Fetch', undefined, {
|
|
458
|
+
apiName: apiName,
|
|
459
|
+
operationId: operationId,
|
|
460
|
+
url: url,
|
|
461
|
+
origin: origin
|
|
462
|
+
});
|
|
472
463
|
return [
|
|
473
464
|
3,
|
|
474
465
|
6
|
|
@@ -484,7 +475,7 @@ var DEFAULT_OPTIONS = {
|
|
|
484
475
|
origin: origin
|
|
485
476
|
});
|
|
486
477
|
}
|
|
487
|
-
// eslint-disable-next-line no-console
|
|
478
|
+
// eslint-disable-next-line no-console -- `console.error` is supposed to be the default value if the `options` argument is not provided, can be removed in Otter v12.
|
|
488
479
|
reviver = getResponseReviver(revivers, response, operationId, {
|
|
489
480
|
disableFallback: _this.options.disableFallback,
|
|
490
481
|
log: console.error
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* eslint-disable
|
|
1
|
+
/* eslint-disable no-console -- only using the reference */ import { getResponseReviver } from '@ama-sdk/core';
|
|
2
2
|
describe('getResponseReviver - revivers by status code', function() {
|
|
3
3
|
var revivers = {
|
|
4
4
|
202: jest.fn(),
|
|
@@ -83,8 +83,8 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
83
83
|
}).map(function(name) {
|
|
84
84
|
return "".concat(name, "=").concat(queryParameters[name]);
|
|
85
85
|
}).join('&');
|
|
86
|
-
var paramsPrefix = url.
|
|
87
|
-
return url + (
|
|
86
|
+
var paramsPrefix = url.includes('?') ? '&' : '?';
|
|
87
|
+
return url + (queryPart ? paramsPrefix + queryPart : '');
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
* Returns a map containing the query parameters
|
|
@@ -104,36 +104,34 @@ 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
|
|
107
|
+
return object ? Object.keys(object).filter(function(objectKey) {
|
|
108
108
|
return typeof object[objectKey] !== 'undefined';
|
|
109
109
|
}).reduce(function(acc, objectKey) {
|
|
110
110
|
acc[objectKey] = object[objectKey];
|
|
111
111
|
return acc;
|
|
112
|
-
}, {});
|
|
112
|
+
}, {}) : {};
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
115
|
* Receives an object containing key/value pairs
|
|
116
116
|
* Encodes this object to match application/x-www-urlencoded or multipart/form-data
|
|
117
117
|
* @param data
|
|
118
118
|
* @param type
|
|
119
|
-
* @param data
|
|
120
|
-
* @param type
|
|
121
119
|
*/ export function processFormData(data, type) {
|
|
122
120
|
var encodedData;
|
|
123
|
-
|
|
121
|
+
if (type === 'multipart/form-data') {
|
|
124
122
|
var formData = new FormData();
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
Object.entries(data).forEach(function(param) {
|
|
124
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
125
|
+
return formData.append(key, value);
|
|
126
|
+
});
|
|
128
127
|
encodedData = formData;
|
|
129
128
|
} else {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
encodedData = formData1.join('&');
|
|
129
|
+
encodedData = Object.entries(data).map(function(param) {
|
|
130
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
131
|
+
return "".concat(key, "=").concat(encodeURIComponent(value));
|
|
132
|
+
}).join('&');
|
|
135
133
|
}
|
|
136
|
-
|
|
134
|
+
return encodedData;
|
|
137
135
|
}
|
|
138
136
|
/**
|
|
139
137
|
* Computes tokens based on the given list of PII parameter names.
|
|
@@ -177,29 +175,25 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
177
175
|
* Fallback to the lowest status code's reviver.
|
|
178
176
|
* Does not try to match non-successful responses as error are handled separately
|
|
179
177
|
* @param revivers
|
|
180
|
-
* @param endpoint
|
|
181
178
|
* @param response
|
|
182
|
-
* @param
|
|
183
|
-
* @param options.
|
|
184
|
-
* @param options.
|
|
185
|
-
|
|
186
|
-
endpoint) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
log: console.error
|
|
190
|
-
};
|
|
179
|
+
* @param endpoint
|
|
180
|
+
* @param options `{ disableFallback: false, log: console.error }` by default
|
|
181
|
+
* @param options.disableFallback `false` by default
|
|
182
|
+
* @param options.log `() => {}` by default -- warning: default value will change to `console.error` in Otter v12.
|
|
183
|
+
*/ export function getResponseReviver(revivers, response, endpoint, options) {
|
|
184
|
+
// eslint-disable-next-line no-console -- set as default value
|
|
185
|
+
var _ref = options !== null && options !== void 0 ? options : {}, _ref_disableFallback = _ref.disableFallback, disableFallback = _ref_disableFallback === void 0 ? false : _ref_disableFallback, tmp = _ref.log, logMsg = tmp === void 0 ? options ? function() {} : console.error : tmp;
|
|
191
186
|
var logPrefix = "API status code error for ".concat(endpoint || 'unknown', " endpoint");
|
|
192
|
-
var logMsg = options.log || function() {};
|
|
193
187
|
if (!response || !response.ok) {
|
|
194
188
|
return undefined;
|
|
195
189
|
}
|
|
196
190
|
if (typeof revivers === 'function' || typeof revivers === 'undefined') {
|
|
197
191
|
return revivers;
|
|
198
192
|
}
|
|
199
|
-
if (response.status && Object.keys(revivers).
|
|
193
|
+
if (response.status && Object.keys(revivers).includes("".concat(response.status))) {
|
|
200
194
|
return revivers[response.status];
|
|
201
195
|
}
|
|
202
|
-
if (
|
|
196
|
+
if (disableFallback) {
|
|
203
197
|
logMsg("".concat(logPrefix, " - Missing ").concat(response.status, " from API specification - fallback is deactivated, no revive will run on this response"));
|
|
204
198
|
return undefined;
|
|
205
199
|
}
|
|
@@ -219,7 +213,7 @@ endpoint) {
|
|
|
219
213
|
statusCode: Number.MAX_SAFE_INTEGER,
|
|
220
214
|
reviver: undefined
|
|
221
215
|
});
|
|
222
|
-
var fallbackLog = Number.MAX_SAFE_INTEGER
|
|
216
|
+
var fallbackLog = Number.MAX_SAFE_INTEGER === fallback.statusCode ? 'No fallback found' : "Fallback to ".concat(fallback.statusCode, "'s reviver");
|
|
223
217
|
logMsg("".concat(logPrefix, " - Unknown ").concat(response.status || 'undefined', " code returned by the API - ").concat(fallbackLog));
|
|
224
218
|
return fallback.reviver;
|
|
225
219
|
}
|
|
@@ -2,5 +2,6 @@
|
|
|
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
|
-
|
|
5
|
+
var apiClient = client;
|
|
6
|
+
return !!apiClient && !!apiClient.options && typeof apiClient.extractQueryParams === 'function' && typeof apiClient.getRequestOptions === 'function' && typeof apiClient.prepareUrl === 'function' && typeof apiClient.processFormData === 'function' && typeof apiClient.processCall === 'function';
|
|
6
7
|
}
|
package/esm2015/fwk/date.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- keep to not introduce breaking change
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
2
3
|
if (len == null || len > arr.length) len = arr.length;
|
|
3
4
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
5
|
return arr2;
|
|
@@ -149,10 +150,10 @@ function _is_native_reflect_construct() {
|
|
|
149
150
|
return !!result;
|
|
150
151
|
})();
|
|
151
152
|
}
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention, no-underscore-dangle -- keep to not introduce breaking change
|
|
152
154
|
export var _NativeDateClass = Date;
|
|
153
155
|
/**
|
|
154
156
|
* Specific padding for number
|
|
155
|
-
*
|
|
156
157
|
* @param val number
|
|
157
158
|
* @param digits minimal number of digits to display
|
|
158
159
|
*/ export function pad(val) {
|
|
@@ -160,7 +161,9 @@ export var _NativeDateClass = Date;
|
|
|
160
161
|
var str = "".concat(val);
|
|
161
162
|
return '0'.repeat(Math.max(0, digits - str.length)) + str;
|
|
162
163
|
}
|
|
163
|
-
|
|
164
|
+
/**
|
|
165
|
+
* Removes timezone information from ISO8601 strings
|
|
166
|
+
*/ export var CommonDate = /*#__PURE__*/ function(Date1) {
|
|
164
167
|
"use strict";
|
|
165
168
|
_inherits(CommonDate, Date1);
|
|
166
169
|
function CommonDate() {
|
|
@@ -168,27 +171,23 @@ export var CommonDate = /*#__PURE__*/ function(Date1) {
|
|
|
168
171
|
args[_key] = arguments[_key];
|
|
169
172
|
}
|
|
170
173
|
_class_call_check(this, CommonDate);
|
|
171
|
-
if (args) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
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)));
|
|
189
|
-
}
|
|
190
|
-
} else if (_instanceof(args[0], CommonDate)) {
|
|
191
|
-
args[0] = args[0];
|
|
174
|
+
if (args && typeof args[0] === 'string') {
|
|
175
|
+
var idxT = args[0].lastIndexOf('T');
|
|
176
|
+
// TZD = time zone designator (Z or +hh:mm or -hh:mm)
|
|
177
|
+
var idx = args[0].lastIndexOf('Z');
|
|
178
|
+
if (idx < 0) {
|
|
179
|
+
idx = args[0].lastIndexOf('+');
|
|
180
|
+
}
|
|
181
|
+
if (idx < 0 && idxT > 0) {
|
|
182
|
+
var relativeIdx = args[0].substring(idxT).lastIndexOf('-');
|
|
183
|
+
idx = relativeIdx > 0 ? relativeIdx + idxT : relativeIdx;
|
|
184
|
+
}
|
|
185
|
+
if (idx > 0) {
|
|
186
|
+
args[0] = args[0].substring(0, idx);
|
|
187
|
+
}
|
|
188
|
+
var TIME_ZONE_OFFSET = _construct(Date, _to_consumable_array(args)).getTimezoneOffset();
|
|
189
|
+
if (idxT > 0) {
|
|
190
|
+
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)));
|
|
192
191
|
}
|
|
193
192
|
}
|
|
194
193
|
return _call_super(this, CommonDate, _to_consumable_array(args));
|
|
@@ -214,7 +213,7 @@ export var CommonDate = /*#__PURE__*/ function(Date1) {
|
|
|
214
213
|
args[_key] = arguments[_key];
|
|
215
214
|
}
|
|
216
215
|
_class_call_check(this, Date1);
|
|
217
|
-
if (args && typeof args[0] === 'string' && args[0].
|
|
216
|
+
if (args && typeof args[0] === 'string' && !args[0].includes('T')) {
|
|
218
217
|
args[0] = "".concat(args[0], "T00:00:00Z");
|
|
219
218
|
} else if (_instanceof(args[0], _NativeDateClass)) {
|
|
220
219
|
args[0] = "".concat(args[0].getFullYear(), "-").concat(pad(args[0].getMonth() + 1), "-").concat(pad(args[0].getDate()), "T00:00:00Z");
|
|
@@ -226,7 +225,8 @@ export var CommonDate = /*#__PURE__*/ function(Date1) {
|
|
|
226
225
|
key: "_Date",
|
|
227
226
|
value: /**
|
|
228
227
|
* To ensure that users cannot use a standard Date instead of utils.Date
|
|
229
|
-
*/
|
|
228
|
+
*/ // eslint-disable-next-line @typescript-eslint/naming-convention -- keep to not introduce breaking change
|
|
229
|
+
function _Date() {}
|
|
230
230
|
},
|
|
231
231
|
{
|
|
232
232
|
key: "toJSON",
|
|
@@ -240,9 +240,8 @@ export var CommonDate = /*#__PURE__*/ function(Date1) {
|
|
|
240
240
|
key: "equals",
|
|
241
241
|
value: /**
|
|
242
242
|
* Compare if two dates are equals.
|
|
243
|
-
*
|
|
244
243
|
* @param {Date} date the date to compare
|
|
245
|
-
* @
|
|
244
|
+
* @returns {boolean} true if the dates are equals.
|
|
246
245
|
*/ function equals(date) {
|
|
247
246
|
if (!date) {
|
|
248
247
|
return false;
|
|
@@ -261,6 +260,7 @@ export var CommonDate = /*#__PURE__*/ function(Date1) {
|
|
|
261
260
|
args[_key] = arguments[_key];
|
|
262
261
|
}
|
|
263
262
|
_class_call_check(this, DateTime);
|
|
263
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- type is explicitly `any`
|
|
264
264
|
return _call_super(this, DateTime, _to_consumable_array(args));
|
|
265
265
|
}
|
|
266
266
|
_create_class(DateTime, [
|
|
@@ -268,7 +268,8 @@ export var CommonDate = /*#__PURE__*/ function(Date1) {
|
|
|
268
268
|
key: "_DateTime",
|
|
269
269
|
value: /**
|
|
270
270
|
* To ensure that users cannot use a standard Date instead of utils.DateTime
|
|
271
|
-
*/
|
|
271
|
+
*/ // eslint-disable-next-line @typescript-eslint/naming-convention -- keep to not introduce breaking change
|
|
272
|
+
function _DateTime() {}
|
|
272
273
|
}
|
|
273
274
|
]);
|
|
274
275
|
return DateTime;
|
package/esm2015/fwk/date.spec.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { utils } from './date';
|
|
2
2
|
describe('DateTime', function() {
|
|
3
3
|
it('should support timestamp', function() {
|
|
4
|
-
var ts =
|
|
4
|
+
var ts = Date.now();
|
|
5
5
|
var dateUtils = new utils.DateTime(ts);
|
|
6
6
|
expect(dateUtils.getTime()).toEqual(ts);
|
|
7
7
|
});
|
|
@@ -15,6 +15,7 @@ describe('DateTime', function() {
|
|
|
15
15
|
});
|
|
16
16
|
it('should support json conversions', function() {
|
|
17
17
|
var originalDate = new utils.DateTime(new Date());
|
|
18
|
+
// eslint-disable-next-line unicorn/prefer-structured-clone -- we test the JSON conversion
|
|
18
19
|
var jsonDate = JSON.parse(JSON.stringify(originalDate));
|
|
19
20
|
expect(new utils.DateTime(jsonDate)).toEqual(originalDate);
|
|
20
21
|
});
|
|
@@ -52,7 +53,7 @@ describe('DateTime', function() {
|
|
|
52
53
|
});
|
|
53
54
|
describe('Date', function() {
|
|
54
55
|
it('should support timestamp', function() {
|
|
55
|
-
var ts =
|
|
56
|
+
var ts = Date.now();
|
|
56
57
|
var dateUtils = new utils.Date(ts);
|
|
57
58
|
expect(dateUtils.getTime()).toEqual(ts);
|
|
58
59
|
});
|
|
@@ -66,6 +67,7 @@ describe('Date', function() {
|
|
|
66
67
|
});
|
|
67
68
|
it('should support json conversions', function() {
|
|
68
69
|
var originalDate = new utils.Date(new Date());
|
|
70
|
+
// eslint-disable-next-line unicorn/prefer-structured-clone -- we test the JSON conversion
|
|
69
71
|
var jsonDate = JSON.parse(JSON.stringify(originalDate));
|
|
70
72
|
expect(new utils.Date(jsonDate)).toEqual(originalDate);
|
|
71
73
|
});
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
/** Type helper to ignore the constraint on literal union type (enum) of an SDK model */
|
|
2
|
-
export { };
|
|
1
|
+
/** Type helper to ignore the constraint on literal union type (enum) of an SDK model */ export { };
|
package/esm2015/fwk/index.js
CHANGED
|
@@ -178,19 +178,19 @@ import { getOperationId, getPath } from './helpers';
|
|
|
178
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
|
-
*/ var logNewCallRegex = RegExp(/^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}\.\d{6}\b/gm);
|
|
181
|
+
*/ var logNewCallRegex = new RegExp(/^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}\.\d{6}\b/gm);
|
|
182
182
|
/**
|
|
183
183
|
* the correlation Id is printed this way by ALF, ex: CorrID=0001W37ZH480AJ,
|
|
184
|
-
*/ var correlationIdRegex = RegExp(/CorrID=([^,]*),/);
|
|
184
|
+
*/ var correlationIdRegex = new RegExp(/CorrID=([^,]*),/);
|
|
185
185
|
/**
|
|
186
186
|
* a request is logged with its HTTP method and the path targetted on a new line, ex: "GET /1ASIUAIRFAC/v2/shopping..."
|
|
187
|
-
*/ var requestRegex = RegExp(/^(POST|GET|PATCH|DELETE) \/(
|
|
187
|
+
*/ var requestRegex = new RegExp(/^(POST|GET|PATCH|DELETE) \/(\S*)/m);
|
|
188
188
|
/**
|
|
189
189
|
* a request is logged with its HTTP version and the HTTP status on a new line, ex: "HTTP/1.1 200 OK"
|
|
190
|
-
*/ var responseRegex = RegExp(/^(HTTP\/1.1 \d{3})/m);
|
|
190
|
+
*/ var responseRegex = new RegExp(/^(HTTP\/1.1 \d{3})/m);
|
|
191
191
|
/**
|
|
192
192
|
* the response data is logged with its JSON content on a new line
|
|
193
|
-
*/ var requestResponseJsonRegexp = RegExp(/(^{.*}$)/m);
|
|
193
|
+
*/ var requestResponseJsonRegexp = new RegExp(/(^{.*}$)/m);
|
|
194
194
|
/**
|
|
195
195
|
* Split the logs
|
|
196
196
|
* @param log alf log
|
|
@@ -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('/'), match[2].
|
|
213
|
+
var requestUrl = match[2].substring(match[2].indexOf('/'), match[2].includes('?') ? match[2].indexOf('?') : match[2].length);
|
|
214
214
|
var method = match[1];
|
|
215
215
|
var pathObject = getPath(requestUrl, operationAdapter, method);
|
|
216
216
|
if (pathObject) {
|
|
@@ -317,6 +317,7 @@ import { SequentialMockAdapter } from './sequential-mock-adapter';
|
|
|
317
317
|
mockMap[alfCall.operationId] = [];
|
|
318
318
|
}
|
|
319
319
|
mockMap[alfCall.operationId].push({
|
|
320
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- type is explicitly `any`
|
|
320
321
|
mockData: alfCall.response ? JSON.parse(alfCall.response) : ''
|
|
321
322
|
});
|
|
322
323
|
return mockMap;
|
|
@@ -166,10 +166,10 @@ 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
|
|
170
|
-
this.mocks = mockMap;
|
|
171
|
-
} else {
|
|
169
|
+
if (typeof mockMap === 'function') {
|
|
172
170
|
this.mockFactory = mockMap;
|
|
171
|
+
} else {
|
|
172
|
+
this.mocks = mockMap;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
_create_class(BaseMockAdapter, [
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
return newMatches;
|
|
37
37
|
}, []);
|
|
38
38
|
var lastIndex = -1;
|
|
39
|
-
var nextIndex = -1;
|
|
40
39
|
while(matches.length > 1){
|
|
41
|
-
|
|
40
|
+
var result = matches.reduce(function(param, match) {
|
|
41
|
+
var newMatches = param.matches, nextIndex = param.nextIndex;
|
|
42
42
|
var newIndex = match.segments.findIndex(function(segment) {
|
|
43
43
|
return segment.startsWith('{') && segment.endsWith('}');
|
|
44
|
-
}
|
|
44
|
+
});
|
|
45
45
|
// Complete static match so use some value that can't be exceeded
|
|
46
46
|
if (newIndex === -1) {
|
|
47
47
|
newIndex = Infinity;
|
|
@@ -54,11 +54,19 @@
|
|
|
54
54
|
} else if (newIndex === nextIndex) {
|
|
55
55
|
newMatches.push(match);
|
|
56
56
|
}
|
|
57
|
-
return
|
|
58
|
-
|
|
57
|
+
return {
|
|
58
|
+
matches: newMatches,
|
|
59
|
+
nextIndex: nextIndex
|
|
60
|
+
};
|
|
61
|
+
}, {
|
|
62
|
+
matches: [],
|
|
63
|
+
nextIndex: -1
|
|
64
|
+
});
|
|
65
|
+
var next = result.nextIndex;
|
|
66
|
+
matches = result.matches;
|
|
59
67
|
// At this point we have tried to filter the matches but there are multiple matches that are identical and cannot
|
|
60
68
|
// be filtered further. Trying to filter on the HTTP method if provided, then choose the first match.
|
|
61
|
-
if (lastIndex ===
|
|
69
|
+
if (lastIndex === next) {
|
|
62
70
|
if (method) {
|
|
63
71
|
// Try to filter the multiple matches based on the HTTP method
|
|
64
72
|
matches.splice(0, matches.findIndex(function(match) {
|
|
@@ -67,7 +75,7 @@
|
|
|
67
75
|
}
|
|
68
76
|
matches.splice(1);
|
|
69
77
|
}
|
|
70
|
-
lastIndex =
|
|
78
|
+
lastIndex = next;
|
|
71
79
|
}
|
|
72
80
|
return matches.length > 0 ? pathObjects[matches[0].index] : undefined;
|
|
73
81
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export * from './alf-mock-adapter';
|
|
2
|
+
export * from './base-mock-adapter';
|
|
2
3
|
export * from './encoded-api-request';
|
|
3
|
-
export * from './
|
|
4
|
+
export * from './helpers';
|
|
4
5
|
export * from './mock';
|
|
6
|
+
export * from './mock-adapter';
|
|
5
7
|
export * from './operation';
|
|
6
8
|
export * from './path-object';
|
|
7
|
-
export * from './base-mock-adapter';
|
|
8
|
-
export * from './helpers';
|
|
9
9
|
export * from './random-mock-adapter';
|
|
10
10
|
export * from './sequential-mock-adapter';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Used in case of maps (dictionaries): All values of the map must be of the same type. reviveWithType will be called
|
|
3
3
|
* for each of these elements.
|
|
4
|
+
* @param data
|
|
4
5
|
* @param dictionaries
|
|
5
6
|
* @param reviver
|
|
6
7
|
* @param options Reviver options
|
|
@@ -11,8 +12,7 @@
|
|
|
11
12
|
}
|
|
12
13
|
var revived = {};
|
|
13
14
|
for(var key in data){
|
|
14
|
-
|
|
15
|
-
if (data.hasOwnProperty(key)) {
|
|
15
|
+
if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
16
16
|
revived[key] = reviver(data[key], dictionaries, options);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -168,7 +168,7 @@ function _ts_generator(thisArg, body) {
|
|
|
168
168
|
var getProtection = function() {
|
|
169
169
|
return new Promise(function(resolve, reject) {
|
|
170
170
|
var timeout = setTimeout(function() {
|
|
171
|
-
return reject("[SDK][Plug-in][BotProtectionFingerprintRequest] Timeout: no Protection object was received in time.\nIf the application runs on a domain that is not protected by Imperva, this plugin should be disabled.");
|
|
171
|
+
return reject(new Error("[SDK][Plug-in][BotProtectionFingerprintRequest] Timeout: no Protection object was received in time.\nIf the application runs on a domain that is not protected by Imperva, this plugin should be disabled."));
|
|
172
172
|
}, protectionTimeout);
|
|
173
173
|
window.protectionLoaded = function(protectionObject) {
|
|
174
174
|
protection = protectionObject;
|
|
@@ -229,7 +229,7 @@ function _ts_generator(thisArg, body) {
|
|
|
229
229
|
];
|
|
230
230
|
case 6:
|
|
231
231
|
e1 = _state.sent();
|
|
232
|
-
(logger || console).error('[SDK][Plug-in][BotProtectionFingerprintRequest] Timeout: no Token was received in time.');
|
|
232
|
+
(logger || console).error('[SDK][Plug-in][BotProtectionFingerprintRequest] Timeout: no Token was received in time.', e1);
|
|
233
233
|
return [
|
|
234
234
|
2
|
|
235
235
|
];
|
|
@@ -250,7 +250,7 @@ function _ts_generator(thisArg, body) {
|
|
|
250
250
|
* Will return the telemetry, or undefined if bmak object is not found
|
|
251
251
|
* @param bmakOpt BMak object from Akamai. Default to `window.bmak` on browser if not provided.
|
|
252
252
|
*/ export function akamaiTelemetryRetrieverFactory(bmakOpt) {
|
|
253
|
-
var bmak = bmakOpt || (typeof window
|
|
253
|
+
var bmak = bmakOpt || (typeof window === 'undefined' ? undefined : window.bmak);
|
|
254
254
|
return function() {
|
|
255
255
|
if (!bmak || !(typeof bmak.get_telemetry === 'function')) {
|
|
256
256
|
return;
|
|
@@ -137,7 +137,7 @@ describe('BotProtectionFingerprint', function() {
|
|
|
137
137
|
};
|
|
138
138
|
var protectionReject = {
|
|
139
139
|
token: function() {
|
|
140
|
-
return Promise.reject('error');
|
|
140
|
+
return Promise.reject(new Error('error'));
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
143
|
var registerEvent = function(protection) {
|
|
@@ -154,13 +154,11 @@ describe('BotProtectionFingerprint', function() {
|
|
|
154
154
|
beforeEach(function() {
|
|
155
155
|
consoleMock = jest.spyOn(console, 'error').mockImplementation();
|
|
156
156
|
windowBackup = global.window;
|
|
157
|
-
// eslint-disable-next-line no-global-assign
|
|
158
157
|
global.window = {};
|
|
159
158
|
retriever = impervaProtectionRetrieverFactory(50, 50);
|
|
160
159
|
tokenValue = 'dummyToken';
|
|
161
160
|
});
|
|
162
161
|
afterEach(function() {
|
|
163
|
-
// eslint-disable-next-line no-global-assign
|
|
164
162
|
global.window = windowBackup;
|
|
165
163
|
consoleMock.mockReset();
|
|
166
164
|
});
|
|
@@ -184,7 +182,7 @@ describe('BotProtectionFingerprint', function() {
|
|
|
184
182
|
expect.apply(void 0, [
|
|
185
183
|
_state.sent()
|
|
186
184
|
]).toBeUndefined();
|
|
187
|
-
// eslint-disable-next-line no-console
|
|
185
|
+
// eslint-disable-next-line no-console -- console.error is not called here
|
|
188
186
|
expect(console.error).toHaveBeenCalledTimes(1);
|
|
189
187
|
return [
|
|
190
188
|
2
|
|
@@ -213,7 +211,7 @@ describe('BotProtectionFingerprint', function() {
|
|
|
213
211
|
expect.apply(void 0, [
|
|
214
212
|
_state.sent()
|
|
215
213
|
]).toBeUndefined();
|
|
216
|
-
// eslint-disable-next-line no-console
|
|
214
|
+
// eslint-disable-next-line no-console -- console.error is not called here
|
|
217
215
|
expect(console.error).toHaveBeenCalledTimes(1);
|
|
218
216
|
return [
|
|
219
217
|
2
|
|
@@ -242,7 +240,7 @@ describe('BotProtectionFingerprint', function() {
|
|
|
242
240
|
expect.apply(void 0, [
|
|
243
241
|
_state.sent()
|
|
244
242
|
]).toBeUndefined();
|
|
245
|
-
// eslint-disable-next-line no-console
|
|
243
|
+
// eslint-disable-next-line no-console -- console.error is not called here
|
|
246
244
|
expect(console.error).toHaveBeenCalledTimes(1);
|
|
247
245
|
return [
|
|
248
246
|
2
|
|
@@ -287,7 +285,7 @@ describe('BotProtectionFingerprint', function() {
|
|
|
287
285
|
expect.apply(void 0, [
|
|
288
286
|
_state.sent()
|
|
289
287
|
]).toBe(tokenValue);
|
|
290
|
-
// eslint-disable-next-line no-console
|
|
288
|
+
// eslint-disable-next-line no-console -- console.error is not called here
|
|
291
289
|
expect(console.error).not.toHaveBeenCalled();
|
|
292
290
|
return [
|
|
293
291
|
2
|
|
@@ -300,20 +298,19 @@ describe('BotProtectionFingerprint', function() {
|
|
|
300
298
|
it('Should return undefined if bmak object doesn\'t exist.', function() {
|
|
301
299
|
expect(akamaiTelemetryRetrieverFactory()()).toBeUndefined();
|
|
302
300
|
expect(akamaiTelemetryRetrieverFactory({})()).toBeUndefined();
|
|
303
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention,camelcase
|
|
304
301
|
expect(akamaiTelemetryRetrieverFactory({
|
|
305
302
|
get_telemetry: 'test'
|
|
306
303
|
})()).toBeUndefined();
|
|
307
304
|
});
|
|
308
305
|
it('Should return telemetry', function() {
|
|
309
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
306
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- naming convention imposed by Akamai
|
|
310
307
|
expect(akamaiTelemetryRetrieverFactory({
|
|
311
308
|
get_telemetry: function() {
|
|
312
309
|
return 'telemetryValue';
|
|
313
310
|
}
|
|
314
311
|
})()).toBe('telemetryValue');
|
|
315
312
|
global.window = {};
|
|
316
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
313
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- naming convention imposed by Akamai
|
|
317
314
|
global.window.bmak = {
|
|
318
315
|
get_telemetry: function() {
|
|
319
316
|
return 'telemetryValue2';
|