@ama-sdk/client-angular 11.3.0-prerelease.47
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 +26 -0
- package/cjs/angular-plugin.js +4 -0
- package/cjs/api-angular-client.js +562 -0
- package/cjs/index.spec.js +5 -0
- package/cjs/plugins/index.js +18 -0
- package/cjs/plugins/mock-intercept/index.js +19 -0
- package/cjs/plugins/mock-intercept/mock-intercept.angular.js +346 -0
- package/cjs/plugins/mock-intercept/mock-intercept.interface.js +4 -0
- package/cjs/public_api.js +20 -0
- package/collection.json +11 -0
- package/esm2015/angular-plugin.js +4 -0
- package/esm2015/api-angular-client.js +552 -0
- package/esm2015/index.spec.js +4 -0
- package/esm2015/plugins/index.js +1 -0
- package/esm2015/plugins/mock-intercept/index.js +2 -0
- package/esm2015/plugins/mock-intercept/mock-intercept.angular.js +341 -0
- package/esm2015/plugins/mock-intercept/mock-intercept.interface.js +3 -0
- package/esm2015/public_api.js +3 -0
- package/package.json +192 -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 +17 -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/angular-plugin.d.ts +38 -0
- package/src/angular-plugin.d.ts.map +1 -0
- package/src/angular-plugin.js +2 -0
- package/src/angular-plugin.js.map +1 -0
- package/src/api-angular-client.d.ts +49 -0
- package/src/api-angular-client.d.ts.map +1 -0
- package/src/api-angular-client.js +131 -0
- package/src/api-angular-client.js.map +1 -0
- package/src/plugins/index.d.ts +2 -0
- package/src/plugins/index.d.ts.map +1 -0
- package/src/plugins/index.js +2 -0
- package/src/plugins/index.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.angular.d.ts +15 -0
- package/src/plugins/mock-intercept/mock-intercept.angular.d.ts.map +1 -0
- package/src/plugins/mock-intercept/mock-intercept.angular.js +62 -0
- package/src/plugins/mock-intercept/mock-intercept.angular.js.map +1 -0
- package/src/plugins/mock-intercept/mock-intercept.interface.d.ts +12 -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/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
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "MockInterceptAngular", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return MockInterceptAngular;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _rxjs = require("rxjs");
|
|
12
|
+
var _core = require("@ama-sdk/core");
|
|
13
|
+
var _http = require("@angular/common/http");
|
|
14
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
15
|
+
try {
|
|
16
|
+
var info = gen[key](arg);
|
|
17
|
+
var value = info.value;
|
|
18
|
+
} catch (error) {
|
|
19
|
+
reject(error);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (info.done) {
|
|
23
|
+
resolve(value);
|
|
24
|
+
} else {
|
|
25
|
+
Promise.resolve(value).then(_next, _throw);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function _async_to_generator(fn) {
|
|
29
|
+
return function() {
|
|
30
|
+
var self = this, args = arguments;
|
|
31
|
+
return new Promise(function(resolve, reject) {
|
|
32
|
+
var gen = fn.apply(self, args);
|
|
33
|
+
function _next(value) {
|
|
34
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
35
|
+
}
|
|
36
|
+
function _throw(err) {
|
|
37
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
38
|
+
}
|
|
39
|
+
_next(undefined);
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function _class_call_check(instance, Constructor) {
|
|
44
|
+
if (!(instance instanceof Constructor)) {
|
|
45
|
+
throw new TypeError("Cannot call a class as a function");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function _defineProperties(target, props) {
|
|
49
|
+
for(var i = 0; i < props.length; i++){
|
|
50
|
+
var descriptor = props[i];
|
|
51
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
52
|
+
descriptor.configurable = true;
|
|
53
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
54
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
58
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
59
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
60
|
+
return Constructor;
|
|
61
|
+
}
|
|
62
|
+
function _define_property(obj, key, value) {
|
|
63
|
+
if (key in obj) {
|
|
64
|
+
Object.defineProperty(obj, key, {
|
|
65
|
+
value: value,
|
|
66
|
+
enumerable: true,
|
|
67
|
+
configurable: true,
|
|
68
|
+
writable: true
|
|
69
|
+
});
|
|
70
|
+
} else {
|
|
71
|
+
obj[key] = value;
|
|
72
|
+
}
|
|
73
|
+
return obj;
|
|
74
|
+
}
|
|
75
|
+
function _instanceof(left, right) {
|
|
76
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
77
|
+
return !!right[Symbol.hasInstance](left);
|
|
78
|
+
} else {
|
|
79
|
+
return left instanceof right;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function _object_spread(target) {
|
|
83
|
+
for(var i = 1; i < arguments.length; i++){
|
|
84
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
85
|
+
var ownKeys = Object.keys(source);
|
|
86
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
87
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
88
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
ownKeys.forEach(function(key) {
|
|
92
|
+
_define_property(target, key, source[key]);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return target;
|
|
96
|
+
}
|
|
97
|
+
function ownKeys(object, enumerableOnly) {
|
|
98
|
+
var keys = Object.keys(object);
|
|
99
|
+
if (Object.getOwnPropertySymbols) {
|
|
100
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
101
|
+
if (enumerableOnly) {
|
|
102
|
+
symbols = symbols.filter(function(sym) {
|
|
103
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
keys.push.apply(keys, symbols);
|
|
107
|
+
}
|
|
108
|
+
return keys;
|
|
109
|
+
}
|
|
110
|
+
function _object_spread_props(target, source) {
|
|
111
|
+
source = source != null ? source : {};
|
|
112
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
113
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
114
|
+
} else {
|
|
115
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
116
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return target;
|
|
120
|
+
}
|
|
121
|
+
function _ts_generator(thisArg, body) {
|
|
122
|
+
var f, y, t, g, _ = {
|
|
123
|
+
label: 0,
|
|
124
|
+
sent: function() {
|
|
125
|
+
if (t[0] & 1) throw t[1];
|
|
126
|
+
return t[1];
|
|
127
|
+
},
|
|
128
|
+
trys: [],
|
|
129
|
+
ops: []
|
|
130
|
+
};
|
|
131
|
+
return g = {
|
|
132
|
+
next: verb(0),
|
|
133
|
+
"throw": verb(1),
|
|
134
|
+
"return": verb(2)
|
|
135
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
136
|
+
return this;
|
|
137
|
+
}), g;
|
|
138
|
+
function verb(n) {
|
|
139
|
+
return function(v) {
|
|
140
|
+
return step([
|
|
141
|
+
n,
|
|
142
|
+
v
|
|
143
|
+
]);
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function step(op) {
|
|
147
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
148
|
+
while(_)try {
|
|
149
|
+
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;
|
|
150
|
+
if (y = 0, t) op = [
|
|
151
|
+
op[0] & 2,
|
|
152
|
+
t.value
|
|
153
|
+
];
|
|
154
|
+
switch(op[0]){
|
|
155
|
+
case 0:
|
|
156
|
+
case 1:
|
|
157
|
+
t = op;
|
|
158
|
+
break;
|
|
159
|
+
case 4:
|
|
160
|
+
_.label++;
|
|
161
|
+
return {
|
|
162
|
+
value: op[1],
|
|
163
|
+
done: false
|
|
164
|
+
};
|
|
165
|
+
case 5:
|
|
166
|
+
_.label++;
|
|
167
|
+
y = op[1];
|
|
168
|
+
op = [
|
|
169
|
+
0
|
|
170
|
+
];
|
|
171
|
+
continue;
|
|
172
|
+
case 7:
|
|
173
|
+
op = _.ops.pop();
|
|
174
|
+
_.trys.pop();
|
|
175
|
+
continue;
|
|
176
|
+
default:
|
|
177
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
178
|
+
_ = 0;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
182
|
+
_.label = op[1];
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
186
|
+
_.label = t[1];
|
|
187
|
+
t = op;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
if (t && _.label < t[2]) {
|
|
191
|
+
_.label = t[2];
|
|
192
|
+
_.ops.push(op);
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
if (t[2]) _.ops.pop();
|
|
196
|
+
_.trys.pop();
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
op = body.call(thisArg, _);
|
|
200
|
+
} catch (e) {
|
|
201
|
+
op = [
|
|
202
|
+
6,
|
|
203
|
+
e
|
|
204
|
+
];
|
|
205
|
+
y = 0;
|
|
206
|
+
} finally{
|
|
207
|
+
f = t = 0;
|
|
208
|
+
}
|
|
209
|
+
if (op[0] & 5) throw op[1];
|
|
210
|
+
return {
|
|
211
|
+
value: op[0] ? op[1] : void 0,
|
|
212
|
+
done: true
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
var MockInterceptAngular = /*#__PURE__*/ function() {
|
|
217
|
+
"use strict";
|
|
218
|
+
function MockInterceptAngular(options) {
|
|
219
|
+
_class_call_check(this, MockInterceptAngular);
|
|
220
|
+
_define_property(this, "options", void 0);
|
|
221
|
+
this.options = options;
|
|
222
|
+
}
|
|
223
|
+
_create_class(MockInterceptAngular, [
|
|
224
|
+
{
|
|
225
|
+
key: "load",
|
|
226
|
+
value: function load(context) {
|
|
227
|
+
var _this = this;
|
|
228
|
+
if (!context.apiClient.options.requestPlugins.some(function(plugin) {
|
|
229
|
+
return _instanceof(plugin, _core.MockInterceptRequest);
|
|
230
|
+
})) {
|
|
231
|
+
throw new Error('MockInterceptAngular plugin should be used only with the MockInterceptRequest plugin');
|
|
232
|
+
}
|
|
233
|
+
return {
|
|
234
|
+
transform: function(call) {
|
|
235
|
+
var _this1 = _this;
|
|
236
|
+
return (0, _rxjs.from)(_async_to_generator(function() {
|
|
237
|
+
var originalCall, delayTime, _tmp, operationId, mock, response;
|
|
238
|
+
return _ts_generator(this, function(_state) {
|
|
239
|
+
switch(_state.label){
|
|
240
|
+
case 0:
|
|
241
|
+
return [
|
|
242
|
+
4,
|
|
243
|
+
_this1.options.adapter.initialize()
|
|
244
|
+
];
|
|
245
|
+
case 1:
|
|
246
|
+
_state.sent();
|
|
247
|
+
originalCall = call;
|
|
248
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
249
|
+
if (!context.options.headers || !_instanceof(context.options.headers, Headers) || !context.options.headers.has(_core.CUSTOM_MOCK_OPERATION_ID_HEADER)) {
|
|
250
|
+
return [
|
|
251
|
+
2,
|
|
252
|
+
originalCall
|
|
253
|
+
];
|
|
254
|
+
}
|
|
255
|
+
if (!(typeof _this1.options.delayTiming !== 'undefined')) return [
|
|
256
|
+
3,
|
|
257
|
+
5
|
|
258
|
+
];
|
|
259
|
+
if (!(typeof _this1.options.delayTiming === 'number')) return [
|
|
260
|
+
3,
|
|
261
|
+
2
|
|
262
|
+
];
|
|
263
|
+
_tmp = _this1.options.delayTiming;
|
|
264
|
+
return [
|
|
265
|
+
3,
|
|
266
|
+
4
|
|
267
|
+
];
|
|
268
|
+
case 2:
|
|
269
|
+
return [
|
|
270
|
+
4,
|
|
271
|
+
_this1.options.delayTiming(_object_spread_props(_object_spread({}, context), {
|
|
272
|
+
fetchPlugins: [],
|
|
273
|
+
options: context.requestOptions
|
|
274
|
+
}))
|
|
275
|
+
];
|
|
276
|
+
case 3:
|
|
277
|
+
_tmp = _state.sent();
|
|
278
|
+
_state.label = 4;
|
|
279
|
+
case 4:
|
|
280
|
+
delayTime = _tmp;
|
|
281
|
+
originalCall = originalCall.pipe((0, _rxjs.delay)(delayTime));
|
|
282
|
+
_state.label = 5;
|
|
283
|
+
case 5:
|
|
284
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
285
|
+
operationId = context.options.headers.get(_core.CUSTOM_MOCK_OPERATION_ID_HEADER);
|
|
286
|
+
try {
|
|
287
|
+
mock = _this1.options.adapter.getLatestMock(operationId);
|
|
288
|
+
if (!mock.getResponse) {
|
|
289
|
+
return [
|
|
290
|
+
2,
|
|
291
|
+
originalCall
|
|
292
|
+
];
|
|
293
|
+
}
|
|
294
|
+
response = mock.getResponse();
|
|
295
|
+
return [
|
|
296
|
+
2,
|
|
297
|
+
originalCall.pipe((0, _rxjs.mergeMap)(/*#__PURE__*/ function() {
|
|
298
|
+
var _ref = _async_to_generator(function(res) {
|
|
299
|
+
var body, responseCloned;
|
|
300
|
+
return _ts_generator(this, function(_state) {
|
|
301
|
+
switch(_state.label){
|
|
302
|
+
case 0:
|
|
303
|
+
return [
|
|
304
|
+
4,
|
|
305
|
+
response.json()
|
|
306
|
+
];
|
|
307
|
+
case 1:
|
|
308
|
+
body = _state.sent();
|
|
309
|
+
responseCloned = res.clone();
|
|
310
|
+
return [
|
|
311
|
+
2,
|
|
312
|
+
new _http.HttpResponse(_object_spread_props(_object_spread({}, responseCloned), {
|
|
313
|
+
body: body,
|
|
314
|
+
url: responseCloned.url || undefined
|
|
315
|
+
}))
|
|
316
|
+
];
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
return function(res) {
|
|
321
|
+
return _ref.apply(this, arguments);
|
|
322
|
+
};
|
|
323
|
+
}()))
|
|
324
|
+
];
|
|
325
|
+
} catch (e) {
|
|
326
|
+
(context.logger || console).error("Failed to retrieve the latest mock for Operation ID ".concat(operationId, ", fallback to default mock"));
|
|
327
|
+
return [
|
|
328
|
+
2,
|
|
329
|
+
originalCall
|
|
330
|
+
];
|
|
331
|
+
}
|
|
332
|
+
return [
|
|
333
|
+
2
|
|
334
|
+
];
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
})()).pipe((0, _rxjs.mergeMap)(function(res) {
|
|
338
|
+
return res;
|
|
339
|
+
}));
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
]);
|
|
345
|
+
return MockInterceptAngular;
|
|
346
|
+
}();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./api-angular-client"), exports);
|
|
6
|
+
_export_star(require("./angular-plugin"), exports);
|
|
7
|
+
_export_star(require("./plugins/index"), exports);
|
|
8
|
+
function _export_star(from, to) {
|
|
9
|
+
Object.keys(from).forEach(function(k) {
|
|
10
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
11
|
+
Object.defineProperty(to, k, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function() {
|
|
14
|
+
return from[k];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return from;
|
|
20
|
+
}
|
package/collection.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/angular/angular-cli/main/packages/angular_devkit/schematics/collection-schema.json",
|
|
3
|
+
"schematics": {
|
|
4
|
+
"ng-add": {
|
|
5
|
+
"description": "Add the SDK Angular Client API to the project.",
|
|
6
|
+
"factory": "./schematics/ng-add/index#ngAdd",
|
|
7
|
+
"schema": "./schematics/ng-add/schema.json",
|
|
8
|
+
"aliases": ["install", "i"]
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|