@ama-sdk/client-fetch 11.3.0-prerelease.33
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/LICENSE +26 -0
- package/README.md +33 -0
- package/cjs/api-fetch-client.js +581 -0
- package/cjs/fetch-plugin.js +4 -0
- package/cjs/plugins/abort/abort.fetch.js +84 -0
- package/cjs/plugins/abort/abort.spec.js +204 -0
- package/cjs/plugins/abort/index.js +18 -0
- package/cjs/plugins/concurrent/concurrent.fetch.js +263 -0
- package/cjs/plugins/concurrent/concurrent.spec.js +239 -0
- package/cjs/plugins/concurrent/index.js +18 -0
- package/cjs/plugins/index.js +25 -0
- package/cjs/plugins/keepalive/index.js +18 -0
- package/cjs/plugins/keepalive/keepalive.request.js +289 -0
- package/cjs/plugins/keepalive/keepalive.spec.js +162 -0
- package/cjs/plugins/mock-intercept/index.js +19 -0
- package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +288 -0
- package/cjs/plugins/mock-intercept/mock-intercept.interface.js +4 -0
- package/cjs/plugins/mock-intercept/mock-intercept.spec.js +445 -0
- package/cjs/plugins/perf-metric/index.js +18 -0
- package/cjs/plugins/perf-metric/perf-metric.fetch.js +371 -0
- package/cjs/plugins/perf-metric/perf-metric.probe.spec.js +60 -0
- package/cjs/plugins/retry/index.js +18 -0
- package/cjs/plugins/retry/retry.fetch.js +371 -0
- package/cjs/plugins/retry/retry.spec.js +348 -0
- package/cjs/plugins/timeout/index.js +18 -0
- package/cjs/plugins/timeout/timeout.fetch.js +320 -0
- package/cjs/plugins/timeout/timeout.spec.js +443 -0
- package/cjs/plugins/wait-for/index.js +18 -0
- package/cjs/plugins/wait-for/wait-for.fetch.js +350 -0
- package/cjs/plugins/wait-for/wait-for.spec.js +383 -0
- package/cjs/public_api.js +20 -0
- package/collection.json +11 -0
- package/esm2015/api-fetch-client.js +571 -0
- package/esm2015/fetch-plugin.js +4 -0
- package/esm2015/plugins/abort/abort.fetch.js +74 -0
- package/esm2015/plugins/abort/abort.spec.js +200 -0
- package/esm2015/plugins/abort/index.js +1 -0
- package/esm2015/plugins/concurrent/concurrent.fetch.js +255 -0
- package/esm2015/plugins/concurrent/concurrent.spec.js +235 -0
- package/esm2015/plugins/concurrent/index.js +1 -0
- package/esm2015/plugins/index.js +8 -0
- package/esm2015/plugins/keepalive/index.js +1 -0
- package/esm2015/plugins/keepalive/keepalive.request.js +281 -0
- package/esm2015/plugins/keepalive/keepalive.spec.js +158 -0
- package/esm2015/plugins/mock-intercept/index.js +2 -0
- package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +283 -0
- package/esm2015/plugins/mock-intercept/mock-intercept.interface.js +1 -0
- package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +441 -0
- package/esm2015/plugins/perf-metric/index.js +1 -0
- package/esm2015/plugins/perf-metric/perf-metric.fetch.js +363 -0
- package/esm2015/plugins/perf-metric/perf-metric.probe.spec.js +56 -0
- package/esm2015/plugins/retry/index.js +1 -0
- package/esm2015/plugins/retry/retry.fetch.js +363 -0
- package/esm2015/plugins/retry/retry.spec.js +344 -0
- package/esm2015/plugins/timeout/index.js +1 -0
- package/esm2015/plugins/timeout/timeout.fetch.js +310 -0
- package/esm2015/plugins/timeout/timeout.spec.js +439 -0
- package/esm2015/plugins/wait-for/index.js +1 -0
- package/esm2015/plugins/wait-for/wait-for.fetch.js +379 -0
- package/esm2015/plugins/wait-for/wait-for.spec.js +379 -0
- package/esm2015/public_api.js +3 -0
- package/package.json +196 -0
- package/schematics/ng-add/index.d.ts +8 -0
- package/schematics/ng-add/index.d.ts.map +1 -0
- package/schematics/ng-add/index.js +67 -0
- package/schematics/ng-add/migration/import-map.d.ts +6 -0
- package/schematics/ng-add/migration/import-map.d.ts.map +1 -0
- package/schematics/ng-add/migration/import-map.js +39 -0
- package/schematics/ng-add/schema.d.ts +6 -0
- package/schematics/ng-add/schema.d.ts.map +1 -0
- package/schematics/ng-add/schema.js +3 -0
- package/schematics/ng-add/schema.json +18 -0
- package/schematics/package.json +3 -0
- package/src/api-fetch-client.d.ts +46 -0
- package/src/api-fetch-client.d.ts.map +1 -0
- package/src/api-fetch-client.js +126 -0
- package/src/api-fetch-client.js.map +1 -0
- package/src/fetch-plugin.d.ts +38 -0
- package/src/fetch-plugin.d.ts.map +1 -0
- package/src/fetch-plugin.js +2 -0
- package/src/fetch-plugin.js.map +1 -0
- package/src/plugins/abort/abort.fetch.d.ts +66 -0
- package/src/plugins/abort/abort.fetch.d.ts.map +1 -0
- package/src/plugins/abort/abort.fetch.js +32 -0
- package/src/plugins/abort/abort.fetch.js.map +1 -0
- package/src/plugins/abort/index.d.ts +2 -0
- package/src/plugins/abort/index.d.ts.map +1 -0
- package/src/plugins/abort/index.js +2 -0
- package/src/plugins/abort/index.js.map +1 -0
- package/src/plugins/concurrent/concurrent.fetch.d.ts +33 -0
- package/src/plugins/concurrent/concurrent.fetch.d.ts.map +1 -0
- package/src/plugins/concurrent/concurrent.fetch.js +57 -0
- package/src/plugins/concurrent/concurrent.fetch.js.map +1 -0
- package/src/plugins/concurrent/index.d.ts +2 -0
- package/src/plugins/concurrent/index.d.ts.map +1 -0
- package/src/plugins/concurrent/index.js +2 -0
- package/src/plugins/concurrent/index.js.map +1 -0
- package/src/plugins/index.d.ts +9 -0
- package/src/plugins/index.d.ts.map +1 -0
- package/src/plugins/index.js +9 -0
- package/src/plugins/index.js.map +1 -0
- package/src/plugins/keepalive/index.d.ts +2 -0
- package/src/plugins/keepalive/index.d.ts.map +1 -0
- package/src/plugins/keepalive/index.js +2 -0
- package/src/plugins/keepalive/index.js.map +1 -0
- package/src/plugins/keepalive/keepalive.request.d.ts +18 -0
- package/src/plugins/keepalive/keepalive.request.d.ts.map +1 -0
- package/src/plugins/keepalive/keepalive.request.js +39 -0
- package/src/plugins/keepalive/keepalive.request.js.map +1 -0
- package/src/plugins/mock-intercept/index.d.ts +3 -0
- package/src/plugins/mock-intercept/index.d.ts.map +1 -0
- package/src/plugins/mock-intercept/index.js +3 -0
- package/src/plugins/mock-intercept/index.js.map +1 -0
- package/src/plugins/mock-intercept/mock-intercept.fetch.d.ts +15 -0
- package/src/plugins/mock-intercept/mock-intercept.fetch.d.ts.map +1 -0
- package/src/plugins/mock-intercept/mock-intercept.fetch.js +47 -0
- package/src/plugins/mock-intercept/mock-intercept.fetch.js.map +1 -0
- package/src/plugins/mock-intercept/mock-intercept.interface.d.ts +10 -0
- package/src/plugins/mock-intercept/mock-intercept.interface.d.ts.map +1 -0
- package/src/plugins/mock-intercept/mock-intercept.interface.js +2 -0
- package/src/plugins/mock-intercept/mock-intercept.interface.js.map +1 -0
- package/src/plugins/perf-metric/index.d.ts +2 -0
- package/src/plugins/perf-metric/index.d.ts.map +1 -0
- package/src/plugins/perf-metric/index.js +2 -0
- package/src/plugins/perf-metric/index.js.map +1 -0
- package/src/plugins/perf-metric/perf-metric.fetch.d.ts +133 -0
- package/src/plugins/perf-metric/perf-metric.fetch.d.ts.map +1 -0
- package/src/plugins/perf-metric/perf-metric.fetch.js +111 -0
- package/src/plugins/perf-metric/perf-metric.fetch.js.map +1 -0
- package/src/plugins/retry/index.d.ts +2 -0
- package/src/plugins/retry/index.d.ts.map +1 -0
- package/src/plugins/retry/index.js +2 -0
- package/src/plugins/retry/index.js.map +1 -0
- package/src/plugins/retry/retry.fetch.d.ts +53 -0
- package/src/plugins/retry/retry.fetch.d.ts.map +1 -0
- package/src/plugins/retry/retry.fetch.js +66 -0
- package/src/plugins/retry/retry.fetch.js.map +1 -0
- package/src/plugins/timeout/index.d.ts +2 -0
- package/src/plugins/timeout/index.d.ts.map +1 -0
- package/src/plugins/timeout/index.js +2 -0
- package/src/plugins/timeout/index.js.map +1 -0
- package/src/plugins/timeout/timeout.fetch.d.ts +47 -0
- package/src/plugins/timeout/timeout.fetch.d.ts.map +1 -0
- package/src/plugins/timeout/timeout.fetch.js +105 -0
- package/src/plugins/timeout/timeout.fetch.js.map +1 -0
- package/src/plugins/wait-for/index.d.ts +2 -0
- package/src/plugins/wait-for/index.d.ts.map +1 -0
- package/src/plugins/wait-for/index.js +2 -0
- package/src/plugins/wait-for/index.js.map +1 -0
- package/src/plugins/wait-for/wait-for.fetch.d.ts +78 -0
- package/src/plugins/wait-for/wait-for.fetch.d.ts.map +1 -0
- package/src/plugins/wait-for/wait-for.fetch.js +104 -0
- package/src/plugins/wait-for/wait-for.fetch.js.map +1 -0
- package/src/public_api.d.ts +4 -0
- package/src/public_api.d.ts.map +1 -0
- package/src/public_api.js +4 -0
- package/src/public_api.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Copyright Amadeus SAS
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
4
|
+
are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
7
|
+
list of conditions and the following disclaimer.
|
|
8
|
+
|
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
this list of conditions and the following disclaimer in the documentation and/or
|
|
11
|
+
other materials provided with the distribution.
|
|
12
|
+
|
|
13
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
|
14
|
+
may be used to endorse or promote products derived from this software without
|
|
15
|
+
specific prior written permission.
|
|
16
|
+
|
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
18
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
21
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
22
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
23
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
24
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
25
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Ama SDK Fetch Client
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@ama-sdk/client-fetch)
|
|
4
|
+
[](https://www.npmjs.com/package/@ama-sdk/client-fetch)
|
|
5
|
+
|
|
6
|
+
This package exposes the **Api Fetch Client** from an SDK based on [@ama-sdk/core](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/core).
|
|
7
|
+
|
|
8
|
+
This package contains all the [Fetch Plugins](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/client-fetch/src/plugins), helpers and object definitions to dialog with an API following the `ama-sdk` architecture.
|
|
9
|
+
|
|
10
|
+
> [!TIP]
|
|
11
|
+
> Please refer to the [SDK initializer](https://www.npmjs.com/package/@ama-sdk/create) package for getting started with an API client SDK based on `ama-sdk` architecture.
|
|
12
|
+
|
|
13
|
+
## Setup
|
|
14
|
+
|
|
15
|
+
The **Api Fetch Client** can be added to your project via the following command:
|
|
16
|
+
|
|
17
|
+
```shell
|
|
18
|
+
ng add @ama-sdk/client-fetch
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
> [!NOTE]
|
|
22
|
+
> In case of migration from deprecated `ApiFetchClient` imported from `@ama-sdk/core`, the `ng add` command will replace, in your existing code, the import from `@ama-sdk/core` to `@ama-sdk/client-fetch` for the deprecated dependencies.
|
|
23
|
+
|
|
24
|
+
## Available plugins
|
|
25
|
+
|
|
26
|
+
- [abort](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/client-fetch/src/plugins/abort)
|
|
27
|
+
- [concurrent](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/client-fetch/src/plugins/concurrent)
|
|
28
|
+
- [keepalive](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/client-fetch/src/plugins/keepalive)
|
|
29
|
+
- [mock-intercept](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/client-fetch/src/plugins/mock-intercept)
|
|
30
|
+
- [perf-metric](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/client-fetch/src/plugins/perf-metric)
|
|
31
|
+
- [retry](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/client-fetch/src/plugins/retry)
|
|
32
|
+
- [timeout](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/client-fetch/src/plugins/timeout)
|
|
33
|
+
- [wait-for](https://github.com/AmadeusITGroup/otter/tree/main/packages/%40ama-sdk/client-fetch/src/plugins/wait-for)
|
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "ApiFetchClient", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return ApiFetchClient;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _core = require("@ama-sdk/core");
|
|
12
|
+
function _array_like_to_array(arr, len) {
|
|
13
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
14
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
15
|
+
return arr2;
|
|
16
|
+
}
|
|
17
|
+
function _array_without_holes(arr) {
|
|
18
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
19
|
+
}
|
|
20
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
21
|
+
try {
|
|
22
|
+
var info = gen[key](arg);
|
|
23
|
+
var value = info.value;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
reject(error);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (info.done) {
|
|
29
|
+
resolve(value);
|
|
30
|
+
} else {
|
|
31
|
+
Promise.resolve(value).then(_next, _throw);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function _async_to_generator(fn) {
|
|
35
|
+
return function() {
|
|
36
|
+
var self = this, args = arguments;
|
|
37
|
+
return new Promise(function(resolve, reject) {
|
|
38
|
+
var gen = fn.apply(self, args);
|
|
39
|
+
function _next(value) {
|
|
40
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
41
|
+
}
|
|
42
|
+
function _throw(err) {
|
|
43
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
44
|
+
}
|
|
45
|
+
_next(undefined);
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function _class_call_check(instance, Constructor) {
|
|
50
|
+
if (!(instance instanceof Constructor)) {
|
|
51
|
+
throw new TypeError("Cannot call a class as a function");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function _defineProperties(target, props) {
|
|
55
|
+
for(var i = 0; i < props.length; i++){
|
|
56
|
+
var descriptor = props[i];
|
|
57
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
58
|
+
descriptor.configurable = true;
|
|
59
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
60
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
64
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
65
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
66
|
+
return Constructor;
|
|
67
|
+
}
|
|
68
|
+
function _define_property(obj, key, value) {
|
|
69
|
+
if (key in obj) {
|
|
70
|
+
Object.defineProperty(obj, key, {
|
|
71
|
+
value: value,
|
|
72
|
+
enumerable: true,
|
|
73
|
+
configurable: true,
|
|
74
|
+
writable: true
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
obj[key] = value;
|
|
78
|
+
}
|
|
79
|
+
return obj;
|
|
80
|
+
}
|
|
81
|
+
function _instanceof(left, right) {
|
|
82
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
83
|
+
return !!right[Symbol.hasInstance](left);
|
|
84
|
+
} else {
|
|
85
|
+
return left instanceof right;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function _iterable_to_array(iter) {
|
|
89
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
90
|
+
}
|
|
91
|
+
function _non_iterable_spread() {
|
|
92
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
93
|
+
}
|
|
94
|
+
function _object_spread(target) {
|
|
95
|
+
for(var i = 1; i < arguments.length; i++){
|
|
96
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
97
|
+
var ownKeys = Object.keys(source);
|
|
98
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
99
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
100
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
ownKeys.forEach(function(key) {
|
|
104
|
+
_define_property(target, key, source[key]);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return target;
|
|
108
|
+
}
|
|
109
|
+
function ownKeys(object, enumerableOnly) {
|
|
110
|
+
var keys = Object.keys(object);
|
|
111
|
+
if (Object.getOwnPropertySymbols) {
|
|
112
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
113
|
+
if (enumerableOnly) {
|
|
114
|
+
symbols = symbols.filter(function(sym) {
|
|
115
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
keys.push.apply(keys, symbols);
|
|
119
|
+
}
|
|
120
|
+
return keys;
|
|
121
|
+
}
|
|
122
|
+
function _object_spread_props(target, source) {
|
|
123
|
+
source = source != null ? source : {};
|
|
124
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
125
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
126
|
+
} else {
|
|
127
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
128
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return target;
|
|
132
|
+
}
|
|
133
|
+
function _to_consumable_array(arr) {
|
|
134
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
135
|
+
}
|
|
136
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
137
|
+
if (!o) return;
|
|
138
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
139
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
140
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
141
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
142
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
143
|
+
}
|
|
144
|
+
function _ts_generator(thisArg, body) {
|
|
145
|
+
var f, y, t, g, _ = {
|
|
146
|
+
label: 0,
|
|
147
|
+
sent: function() {
|
|
148
|
+
if (t[0] & 1) throw t[1];
|
|
149
|
+
return t[1];
|
|
150
|
+
},
|
|
151
|
+
trys: [],
|
|
152
|
+
ops: []
|
|
153
|
+
};
|
|
154
|
+
return g = {
|
|
155
|
+
next: verb(0),
|
|
156
|
+
"throw": verb(1),
|
|
157
|
+
"return": verb(2)
|
|
158
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
159
|
+
return this;
|
|
160
|
+
}), g;
|
|
161
|
+
function verb(n) {
|
|
162
|
+
return function(v) {
|
|
163
|
+
return step([
|
|
164
|
+
n,
|
|
165
|
+
v
|
|
166
|
+
]);
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function step(op) {
|
|
170
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
171
|
+
while(_)try {
|
|
172
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
173
|
+
if (y = 0, t) op = [
|
|
174
|
+
op[0] & 2,
|
|
175
|
+
t.value
|
|
176
|
+
];
|
|
177
|
+
switch(op[0]){
|
|
178
|
+
case 0:
|
|
179
|
+
case 1:
|
|
180
|
+
t = op;
|
|
181
|
+
break;
|
|
182
|
+
case 4:
|
|
183
|
+
_.label++;
|
|
184
|
+
return {
|
|
185
|
+
value: op[1],
|
|
186
|
+
done: false
|
|
187
|
+
};
|
|
188
|
+
case 5:
|
|
189
|
+
_.label++;
|
|
190
|
+
y = op[1];
|
|
191
|
+
op = [
|
|
192
|
+
0
|
|
193
|
+
];
|
|
194
|
+
continue;
|
|
195
|
+
case 7:
|
|
196
|
+
op = _.ops.pop();
|
|
197
|
+
_.trys.pop();
|
|
198
|
+
continue;
|
|
199
|
+
default:
|
|
200
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
201
|
+
_ = 0;
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
205
|
+
_.label = op[1];
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
209
|
+
_.label = t[1];
|
|
210
|
+
t = op;
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
if (t && _.label < t[2]) {
|
|
214
|
+
_.label = t[2];
|
|
215
|
+
_.ops.push(op);
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
if (t[2]) _.ops.pop();
|
|
219
|
+
_.trys.pop();
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
op = body.call(thisArg, _);
|
|
223
|
+
} catch (e) {
|
|
224
|
+
op = [
|
|
225
|
+
6,
|
|
226
|
+
e
|
|
227
|
+
];
|
|
228
|
+
y = 0;
|
|
229
|
+
} finally{
|
|
230
|
+
f = t = 0;
|
|
231
|
+
}
|
|
232
|
+
if (op[0] & 5) throw op[1];
|
|
233
|
+
return {
|
|
234
|
+
value: op[0] ? op[1] : void 0,
|
|
235
|
+
done: true
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
var DEFAULT_OPTIONS = {
|
|
240
|
+
replyPlugins: [
|
|
241
|
+
new _core.ReviverReply(),
|
|
242
|
+
new _core.ExceptionReply()
|
|
243
|
+
],
|
|
244
|
+
fetchPlugins: [],
|
|
245
|
+
requestPlugins: [],
|
|
246
|
+
enableTokenization: false,
|
|
247
|
+
disableFallback: false
|
|
248
|
+
};
|
|
249
|
+
var ApiFetchClient = /*#__PURE__*/ function() {
|
|
250
|
+
"use strict";
|
|
251
|
+
function ApiFetchClient(options) {
|
|
252
|
+
_class_call_check(this, ApiFetchClient);
|
|
253
|
+
/** @inheritdoc */ _define_property(this, "options", void 0);
|
|
254
|
+
this.options = _object_spread({}, DEFAULT_OPTIONS, options);
|
|
255
|
+
}
|
|
256
|
+
_create_class(ApiFetchClient, [
|
|
257
|
+
{
|
|
258
|
+
key: "extractQueryParams",
|
|
259
|
+
value: /** @inheritdoc */ function extractQueryParams(data, names) {
|
|
260
|
+
return (0, _core.extractQueryParams)(data, names);
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
key: "tokenizeRequestOptions",
|
|
265
|
+
value: /** @inheritdoc */ function tokenizeRequestOptions(url, queryParameters, piiParamTokens, data) {
|
|
266
|
+
return this.options.enableTokenization ? (0, _core.tokenizeRequestOptions)(url, queryParameters, piiParamTokens, data) : undefined;
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
key: "getRequestOptions",
|
|
271
|
+
value: /** @inheritdoc */ function getRequestOptions(requestOptionsParameters) {
|
|
272
|
+
var _this = this;
|
|
273
|
+
return _async_to_generator(function() {
|
|
274
|
+
var opts, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plugin, _requestOptionsParameters_api, err;
|
|
275
|
+
return _ts_generator(this, function(_state) {
|
|
276
|
+
switch(_state.label){
|
|
277
|
+
case 0:
|
|
278
|
+
opts = _object_spread_props(_object_spread({}, requestOptionsParameters), {
|
|
279
|
+
headers: new Headers((0, _core.filterUndefinedValues)(requestOptionsParameters.headers)),
|
|
280
|
+
queryParams: (0, _core.filterUndefinedValues)(requestOptionsParameters.queryParams)
|
|
281
|
+
});
|
|
282
|
+
if (!_this.options.requestPlugins) return [
|
|
283
|
+
3,
|
|
284
|
+
8
|
|
285
|
+
];
|
|
286
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
287
|
+
_state.label = 1;
|
|
288
|
+
case 1:
|
|
289
|
+
_state.trys.push([
|
|
290
|
+
1,
|
|
291
|
+
6,
|
|
292
|
+
7,
|
|
293
|
+
8
|
|
294
|
+
]);
|
|
295
|
+
_iterator = _this.options.requestPlugins[Symbol.iterator]();
|
|
296
|
+
_state.label = 2;
|
|
297
|
+
case 2:
|
|
298
|
+
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
|
|
299
|
+
3,
|
|
300
|
+
5
|
|
301
|
+
];
|
|
302
|
+
plugin = _step.value;
|
|
303
|
+
return [
|
|
304
|
+
4,
|
|
305
|
+
plugin.load({
|
|
306
|
+
logger: _this.options.logger,
|
|
307
|
+
apiName: (_requestOptionsParameters_api = requestOptionsParameters.api) === null || _requestOptionsParameters_api === void 0 ? void 0 : _requestOptionsParameters_api.apiName
|
|
308
|
+
}).transform(opts)
|
|
309
|
+
];
|
|
310
|
+
case 3:
|
|
311
|
+
opts = _state.sent();
|
|
312
|
+
_state.label = 4;
|
|
313
|
+
case 4:
|
|
314
|
+
_iteratorNormalCompletion = true;
|
|
315
|
+
return [
|
|
316
|
+
3,
|
|
317
|
+
2
|
|
318
|
+
];
|
|
319
|
+
case 5:
|
|
320
|
+
return [
|
|
321
|
+
3,
|
|
322
|
+
8
|
|
323
|
+
];
|
|
324
|
+
case 6:
|
|
325
|
+
err = _state.sent();
|
|
326
|
+
_didIteratorError = true;
|
|
327
|
+
_iteratorError = err;
|
|
328
|
+
return [
|
|
329
|
+
3,
|
|
330
|
+
8
|
|
331
|
+
];
|
|
332
|
+
case 7:
|
|
333
|
+
try {
|
|
334
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
335
|
+
_iterator.return();
|
|
336
|
+
}
|
|
337
|
+
} finally{
|
|
338
|
+
if (_didIteratorError) {
|
|
339
|
+
throw _iteratorError;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return [
|
|
343
|
+
7
|
|
344
|
+
];
|
|
345
|
+
case 8:
|
|
346
|
+
return [
|
|
347
|
+
2,
|
|
348
|
+
opts
|
|
349
|
+
];
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
})();
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
key: "prepareUrl",
|
|
357
|
+
value: /** @inheritdoc */ function prepareUrl(url) {
|
|
358
|
+
var queryParameters = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
359
|
+
return (0, _core.prepareUrl)(url, queryParameters);
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
key: "processFormData",
|
|
364
|
+
value: /** @inheritdoc */ function processFormData(data, type) {
|
|
365
|
+
return (0, _core.processFormData)(data, type);
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
key: "processCall",
|
|
370
|
+
value: function processCall(url, options, apiType, apiName, revivers, operationId) {
|
|
371
|
+
var _this = this;
|
|
372
|
+
return _async_to_generator(function() {
|
|
373
|
+
var response, asyncResponse, root, body, exception, origin, _options_metadata, metadataSignal, controller, loadedPlugins, _loadedPlugins, canStart, isCanceledBy, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, plugin, e, reviver, replyPlugins, parsedData, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, pluginRunner, err;
|
|
374
|
+
return _ts_generator(this, function(_state) {
|
|
375
|
+
switch(_state.label){
|
|
376
|
+
case 0:
|
|
377
|
+
origin = options.headers.get('Origin');
|
|
378
|
+
_state.label = 1;
|
|
379
|
+
case 1:
|
|
380
|
+
_state.trys.push([
|
|
381
|
+
1,
|
|
382
|
+
5,
|
|
383
|
+
,
|
|
384
|
+
6
|
|
385
|
+
]);
|
|
386
|
+
metadataSignal = (_options_metadata = options.metadata) === null || _options_metadata === void 0 ? void 0 : _options_metadata.signal;
|
|
387
|
+
metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.throwIfAborted();
|
|
388
|
+
controller = new AbortController();
|
|
389
|
+
options.signal = controller.signal;
|
|
390
|
+
metadataSignal === null || metadataSignal === void 0 ? void 0 : metadataSignal.addEventListener('abort', function() {
|
|
391
|
+
return controller.abort();
|
|
392
|
+
});
|
|
393
|
+
loadedPlugins = [];
|
|
394
|
+
if (_this.options.fetchPlugins) {
|
|
395
|
+
;
|
|
396
|
+
(_loadedPlugins = loadedPlugins).push.apply(_loadedPlugins, _to_consumable_array(_this.options.fetchPlugins.map(function(plugin) {
|
|
397
|
+
return plugin.load({
|
|
398
|
+
url: url,
|
|
399
|
+
options: options,
|
|
400
|
+
fetchPlugins: loadedPlugins,
|
|
401
|
+
controller: controller,
|
|
402
|
+
apiClient: _this,
|
|
403
|
+
logger: _this.options.logger
|
|
404
|
+
});
|
|
405
|
+
})));
|
|
406
|
+
}
|
|
407
|
+
return [
|
|
408
|
+
4,
|
|
409
|
+
Promise.all(loadedPlugins.map(function(plugin) {
|
|
410
|
+
return !plugin.canStart || plugin.canStart();
|
|
411
|
+
}))
|
|
412
|
+
];
|
|
413
|
+
case 2:
|
|
414
|
+
canStart = _state.sent();
|
|
415
|
+
isCanceledBy = canStart.indexOf(false);
|
|
416
|
+
if (isCanceledBy >= 0) {
|
|
417
|
+
// One of the fetch plugins cancelled the execution of the call
|
|
418
|
+
asyncResponse = Promise.reject(new _core.CanceledCallError("Is canceled by the plugin ".concat(isCanceledBy), isCanceledBy, _this.options.fetchPlugins[isCanceledBy], {
|
|
419
|
+
apiName: apiName,
|
|
420
|
+
operationId: operationId,
|
|
421
|
+
url: url,
|
|
422
|
+
origin: origin
|
|
423
|
+
}));
|
|
424
|
+
} else {
|
|
425
|
+
asyncResponse = fetch(url, options);
|
|
426
|
+
}
|
|
427
|
+
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
428
|
+
try {
|
|
429
|
+
for(_iterator = loadedPlugins[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
430
|
+
plugin = _step.value;
|
|
431
|
+
asyncResponse = plugin.transform(asyncResponse);
|
|
432
|
+
}
|
|
433
|
+
} catch (err) {
|
|
434
|
+
_didIteratorError = true;
|
|
435
|
+
_iteratorError = err;
|
|
436
|
+
} finally{
|
|
437
|
+
try {
|
|
438
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
439
|
+
_iterator.return();
|
|
440
|
+
}
|
|
441
|
+
} finally{
|
|
442
|
+
if (_didIteratorError) {
|
|
443
|
+
throw _iteratorError;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return [
|
|
448
|
+
4,
|
|
449
|
+
asyncResponse
|
|
450
|
+
];
|
|
451
|
+
case 3:
|
|
452
|
+
response = _state.sent();
|
|
453
|
+
return [
|
|
454
|
+
4,
|
|
455
|
+
response.text()
|
|
456
|
+
];
|
|
457
|
+
case 4:
|
|
458
|
+
body = _state.sent();
|
|
459
|
+
return [
|
|
460
|
+
3,
|
|
461
|
+
6
|
|
462
|
+
];
|
|
463
|
+
case 5:
|
|
464
|
+
e = _state.sent();
|
|
465
|
+
if (_instanceof(e, _core.CanceledCallError)) {
|
|
466
|
+
exception = e;
|
|
467
|
+
} else {
|
|
468
|
+
exception = new _core.EmptyResponseError(e.message || 'Fail to Fetch', undefined, {
|
|
469
|
+
apiName: apiName,
|
|
470
|
+
operationId: operationId,
|
|
471
|
+
url: url,
|
|
472
|
+
origin: origin
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
return [
|
|
476
|
+
3,
|
|
477
|
+
6
|
|
478
|
+
];
|
|
479
|
+
case 6:
|
|
480
|
+
try {
|
|
481
|
+
root = body ? JSON.parse(body) : undefined;
|
|
482
|
+
} catch (e) {
|
|
483
|
+
exception = new _core.ResponseJSONParseError(e.message || 'Fail to parse response body', response && response.status || 0, body, {
|
|
484
|
+
apiName: apiName,
|
|
485
|
+
operationId: operationId,
|
|
486
|
+
url: url,
|
|
487
|
+
origin: origin
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
// eslint-disable-next-line no-console
|
|
491
|
+
reviver = (0, _core.getResponseReviver)(revivers, response, operationId, {
|
|
492
|
+
disableFallback: _this.options.disableFallback,
|
|
493
|
+
log: console.error
|
|
494
|
+
});
|
|
495
|
+
replyPlugins = _this.options.replyPlugins ? _this.options.replyPlugins.map(function(plugin) {
|
|
496
|
+
return plugin.load({
|
|
497
|
+
dictionaries: root && root.dictionaries,
|
|
498
|
+
response: response,
|
|
499
|
+
reviver: reviver,
|
|
500
|
+
apiType: apiType,
|
|
501
|
+
apiName: apiName,
|
|
502
|
+
exception: exception,
|
|
503
|
+
operationId: operationId,
|
|
504
|
+
url: url,
|
|
505
|
+
origin: origin,
|
|
506
|
+
logger: _this.options.logger
|
|
507
|
+
});
|
|
508
|
+
}) : [];
|
|
509
|
+
parsedData = root;
|
|
510
|
+
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
511
|
+
_state.label = 7;
|
|
512
|
+
case 7:
|
|
513
|
+
_state.trys.push([
|
|
514
|
+
7,
|
|
515
|
+
12,
|
|
516
|
+
13,
|
|
517
|
+
14
|
|
518
|
+
]);
|
|
519
|
+
_iterator1 = replyPlugins[Symbol.iterator]();
|
|
520
|
+
_state.label = 8;
|
|
521
|
+
case 8:
|
|
522
|
+
if (!!(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done)) return [
|
|
523
|
+
3,
|
|
524
|
+
11
|
|
525
|
+
];
|
|
526
|
+
pluginRunner = _step1.value;
|
|
527
|
+
return [
|
|
528
|
+
4,
|
|
529
|
+
pluginRunner.transform(parsedData)
|
|
530
|
+
];
|
|
531
|
+
case 9:
|
|
532
|
+
parsedData = _state.sent();
|
|
533
|
+
_state.label = 10;
|
|
534
|
+
case 10:
|
|
535
|
+
_iteratorNormalCompletion1 = true;
|
|
536
|
+
return [
|
|
537
|
+
3,
|
|
538
|
+
8
|
|
539
|
+
];
|
|
540
|
+
case 11:
|
|
541
|
+
return [
|
|
542
|
+
3,
|
|
543
|
+
14
|
|
544
|
+
];
|
|
545
|
+
case 12:
|
|
546
|
+
err = _state.sent();
|
|
547
|
+
_didIteratorError1 = true;
|
|
548
|
+
_iteratorError1 = err;
|
|
549
|
+
return [
|
|
550
|
+
3,
|
|
551
|
+
14
|
|
552
|
+
];
|
|
553
|
+
case 13:
|
|
554
|
+
try {
|
|
555
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
556
|
+
_iterator1.return();
|
|
557
|
+
}
|
|
558
|
+
} finally{
|
|
559
|
+
if (_didIteratorError1) {
|
|
560
|
+
throw _iteratorError1;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
return [
|
|
564
|
+
7
|
|
565
|
+
];
|
|
566
|
+
case 14:
|
|
567
|
+
if (exception) {
|
|
568
|
+
throw exception;
|
|
569
|
+
}
|
|
570
|
+
return [
|
|
571
|
+
2,
|
|
572
|
+
parsedData
|
|
573
|
+
];
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
})();
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
]);
|
|
580
|
+
return ApiFetchClient;
|
|
581
|
+
}();
|