@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.
Files changed (59) hide show
  1. package/LICENSE +26 -0
  2. package/README.md +26 -0
  3. package/cjs/angular-plugin.js +4 -0
  4. package/cjs/api-angular-client.js +562 -0
  5. package/cjs/index.spec.js +5 -0
  6. package/cjs/plugins/index.js +18 -0
  7. package/cjs/plugins/mock-intercept/index.js +19 -0
  8. package/cjs/plugins/mock-intercept/mock-intercept.angular.js +346 -0
  9. package/cjs/plugins/mock-intercept/mock-intercept.interface.js +4 -0
  10. package/cjs/public_api.js +20 -0
  11. package/collection.json +11 -0
  12. package/esm2015/angular-plugin.js +4 -0
  13. package/esm2015/api-angular-client.js +552 -0
  14. package/esm2015/index.spec.js +4 -0
  15. package/esm2015/plugins/index.js +1 -0
  16. package/esm2015/plugins/mock-intercept/index.js +2 -0
  17. package/esm2015/plugins/mock-intercept/mock-intercept.angular.js +341 -0
  18. package/esm2015/plugins/mock-intercept/mock-intercept.interface.js +3 -0
  19. package/esm2015/public_api.js +3 -0
  20. package/package.json +192 -0
  21. package/schematics/ng-add/index.d.ts +8 -0
  22. package/schematics/ng-add/index.d.ts.map +1 -0
  23. package/schematics/ng-add/index.js +67 -0
  24. package/schematics/ng-add/migration/import-map.d.ts +6 -0
  25. package/schematics/ng-add/migration/import-map.d.ts.map +1 -0
  26. package/schematics/ng-add/migration/import-map.js +17 -0
  27. package/schematics/ng-add/schema.d.ts +6 -0
  28. package/schematics/ng-add/schema.d.ts.map +1 -0
  29. package/schematics/ng-add/schema.js +3 -0
  30. package/schematics/ng-add/schema.json +18 -0
  31. package/schematics/package.json +3 -0
  32. package/src/angular-plugin.d.ts +38 -0
  33. package/src/angular-plugin.d.ts.map +1 -0
  34. package/src/angular-plugin.js +2 -0
  35. package/src/angular-plugin.js.map +1 -0
  36. package/src/api-angular-client.d.ts +49 -0
  37. package/src/api-angular-client.d.ts.map +1 -0
  38. package/src/api-angular-client.js +131 -0
  39. package/src/api-angular-client.js.map +1 -0
  40. package/src/plugins/index.d.ts +2 -0
  41. package/src/plugins/index.d.ts.map +1 -0
  42. package/src/plugins/index.js +2 -0
  43. package/src/plugins/index.js.map +1 -0
  44. package/src/plugins/mock-intercept/index.d.ts +3 -0
  45. package/src/plugins/mock-intercept/index.d.ts.map +1 -0
  46. package/src/plugins/mock-intercept/index.js +3 -0
  47. package/src/plugins/mock-intercept/index.js.map +1 -0
  48. package/src/plugins/mock-intercept/mock-intercept.angular.d.ts +15 -0
  49. package/src/plugins/mock-intercept/mock-intercept.angular.d.ts.map +1 -0
  50. package/src/plugins/mock-intercept/mock-intercept.angular.js +62 -0
  51. package/src/plugins/mock-intercept/mock-intercept.angular.js.map +1 -0
  52. package/src/plugins/mock-intercept/mock-intercept.interface.d.ts +12 -0
  53. package/src/plugins/mock-intercept/mock-intercept.interface.d.ts.map +1 -0
  54. package/src/plugins/mock-intercept/mock-intercept.interface.js +2 -0
  55. package/src/plugins/mock-intercept/mock-intercept.interface.js.map +1 -0
  56. package/src/public_api.d.ts +4 -0
  57. package/src/public_api.d.ts.map +1 -0
  58. package/src/public_api.js +4 -0
  59. package/src/public_api.js.map +1 -0
@@ -0,0 +1,341 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ function _class_call_check(instance, Constructor) {
31
+ if (!(instance instanceof Constructor)) {
32
+ throw new TypeError("Cannot call a class as a function");
33
+ }
34
+ }
35
+ function _defineProperties(target, props) {
36
+ for(var i = 0; i < props.length; i++){
37
+ var descriptor = props[i];
38
+ descriptor.enumerable = descriptor.enumerable || false;
39
+ descriptor.configurable = true;
40
+ if ("value" in descriptor) descriptor.writable = true;
41
+ Object.defineProperty(target, descriptor.key, descriptor);
42
+ }
43
+ }
44
+ function _create_class(Constructor, protoProps, staticProps) {
45
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
46
+ if (staticProps) _defineProperties(Constructor, staticProps);
47
+ return Constructor;
48
+ }
49
+ function _define_property(obj, key, value) {
50
+ if (key in obj) {
51
+ Object.defineProperty(obj, key, {
52
+ value: value,
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true
56
+ });
57
+ } else {
58
+ obj[key] = value;
59
+ }
60
+ return obj;
61
+ }
62
+ function _instanceof(left, right) {
63
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
64
+ return !!right[Symbol.hasInstance](left);
65
+ } else {
66
+ return left instanceof right;
67
+ }
68
+ }
69
+ function _object_spread(target) {
70
+ for(var i = 1; i < arguments.length; i++){
71
+ var source = arguments[i] != null ? arguments[i] : {};
72
+ var ownKeys = Object.keys(source);
73
+ if (typeof Object.getOwnPropertySymbols === "function") {
74
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
75
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
76
+ }));
77
+ }
78
+ ownKeys.forEach(function(key) {
79
+ _define_property(target, key, source[key]);
80
+ });
81
+ }
82
+ return target;
83
+ }
84
+ function ownKeys(object, enumerableOnly) {
85
+ var keys = Object.keys(object);
86
+ if (Object.getOwnPropertySymbols) {
87
+ var symbols = Object.getOwnPropertySymbols(object);
88
+ if (enumerableOnly) {
89
+ symbols = symbols.filter(function(sym) {
90
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
91
+ });
92
+ }
93
+ keys.push.apply(keys, symbols);
94
+ }
95
+ return keys;
96
+ }
97
+ function _object_spread_props(target, source) {
98
+ source = source != null ? source : {};
99
+ if (Object.getOwnPropertyDescriptors) {
100
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
101
+ } else {
102
+ ownKeys(Object(source)).forEach(function(key) {
103
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
104
+ });
105
+ }
106
+ return target;
107
+ }
108
+ function _ts_generator(thisArg, body) {
109
+ var f, y, t, g, _ = {
110
+ label: 0,
111
+ sent: function() {
112
+ if (t[0] & 1) throw t[1];
113
+ return t[1];
114
+ },
115
+ trys: [],
116
+ ops: []
117
+ };
118
+ return g = {
119
+ next: verb(0),
120
+ "throw": verb(1),
121
+ "return": verb(2)
122
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
123
+ return this;
124
+ }), g;
125
+ function verb(n) {
126
+ return function(v) {
127
+ return step([
128
+ n,
129
+ v
130
+ ]);
131
+ };
132
+ }
133
+ function step(op) {
134
+ if (f) throw new TypeError("Generator is already executing.");
135
+ while(_)try {
136
+ 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;
137
+ if (y = 0, t) op = [
138
+ op[0] & 2,
139
+ t.value
140
+ ];
141
+ switch(op[0]){
142
+ case 0:
143
+ case 1:
144
+ t = op;
145
+ break;
146
+ case 4:
147
+ _.label++;
148
+ return {
149
+ value: op[1],
150
+ done: false
151
+ };
152
+ case 5:
153
+ _.label++;
154
+ y = op[1];
155
+ op = [
156
+ 0
157
+ ];
158
+ continue;
159
+ case 7:
160
+ op = _.ops.pop();
161
+ _.trys.pop();
162
+ continue;
163
+ default:
164
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
165
+ _ = 0;
166
+ continue;
167
+ }
168
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
169
+ _.label = op[1];
170
+ break;
171
+ }
172
+ if (op[0] === 6 && _.label < t[1]) {
173
+ _.label = t[1];
174
+ t = op;
175
+ break;
176
+ }
177
+ if (t && _.label < t[2]) {
178
+ _.label = t[2];
179
+ _.ops.push(op);
180
+ break;
181
+ }
182
+ if (t[2]) _.ops.pop();
183
+ _.trys.pop();
184
+ continue;
185
+ }
186
+ op = body.call(thisArg, _);
187
+ } catch (e) {
188
+ op = [
189
+ 6,
190
+ e
191
+ ];
192
+ y = 0;
193
+ } finally{
194
+ f = t = 0;
195
+ }
196
+ if (op[0] & 5) throw op[1];
197
+ return {
198
+ value: op[0] ? op[1] : void 0,
199
+ done: true
200
+ };
201
+ }
202
+ }
203
+ import { delay, from, mergeMap } from 'rxjs';
204
+ import { CUSTOM_MOCK_OPERATION_ID_HEADER, MockInterceptRequest } from '@ama-sdk/core';
205
+ import { HttpResponse } from '@angular/common/http';
206
+ /**
207
+ * Plugin to mock and intercept the call of SDK
208
+ *
209
+ * This plugin should be used only with the MockInterceptRequest Plugin.
210
+ * It will allow the user to delay the response or to handle the getResponse function provided with the mock (if present).
211
+ */ export var MockInterceptAngular = /*#__PURE__*/ function() {
212
+ "use strict";
213
+ function MockInterceptAngular(options) {
214
+ _class_call_check(this, MockInterceptAngular);
215
+ _define_property(this, "options", void 0);
216
+ this.options = options;
217
+ }
218
+ _create_class(MockInterceptAngular, [
219
+ {
220
+ key: "load",
221
+ value: function load(context) {
222
+ var _this = this;
223
+ if (!context.apiClient.options.requestPlugins.some(function(plugin) {
224
+ return _instanceof(plugin, MockInterceptRequest);
225
+ })) {
226
+ throw new Error('MockInterceptAngular plugin should be used only with the MockInterceptRequest plugin');
227
+ }
228
+ return {
229
+ transform: function(call) {
230
+ var _this1 = _this;
231
+ return from(_async_to_generator(function() {
232
+ var originalCall, delayTime, _tmp, operationId, mock, response;
233
+ return _ts_generator(this, function(_state) {
234
+ switch(_state.label){
235
+ case 0:
236
+ return [
237
+ 4,
238
+ _this1.options.adapter.initialize()
239
+ ];
240
+ case 1:
241
+ _state.sent();
242
+ originalCall = call;
243
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
244
+ if (!context.options.headers || !_instanceof(context.options.headers, Headers) || !context.options.headers.has(CUSTOM_MOCK_OPERATION_ID_HEADER)) {
245
+ return [
246
+ 2,
247
+ originalCall
248
+ ];
249
+ }
250
+ if (!(typeof _this1.options.delayTiming !== 'undefined')) return [
251
+ 3,
252
+ 5
253
+ ];
254
+ if (!(typeof _this1.options.delayTiming === 'number')) return [
255
+ 3,
256
+ 2
257
+ ];
258
+ _tmp = _this1.options.delayTiming;
259
+ return [
260
+ 3,
261
+ 4
262
+ ];
263
+ case 2:
264
+ return [
265
+ 4,
266
+ _this1.options.delayTiming(_object_spread_props(_object_spread({}, context), {
267
+ fetchPlugins: [],
268
+ options: context.requestOptions
269
+ }))
270
+ ];
271
+ case 3:
272
+ _tmp = _state.sent();
273
+ _state.label = 4;
274
+ case 4:
275
+ delayTime = _tmp;
276
+ originalCall = originalCall.pipe(delay(delayTime));
277
+ _state.label = 5;
278
+ case 5:
279
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
280
+ operationId = context.options.headers.get(CUSTOM_MOCK_OPERATION_ID_HEADER);
281
+ try {
282
+ mock = _this1.options.adapter.getLatestMock(operationId);
283
+ if (!mock.getResponse) {
284
+ return [
285
+ 2,
286
+ originalCall
287
+ ];
288
+ }
289
+ response = mock.getResponse();
290
+ return [
291
+ 2,
292
+ originalCall.pipe(mergeMap(/*#__PURE__*/ function() {
293
+ var _ref = _async_to_generator(function(res) {
294
+ var body, responseCloned;
295
+ return _ts_generator(this, function(_state) {
296
+ switch(_state.label){
297
+ case 0:
298
+ return [
299
+ 4,
300
+ response.json()
301
+ ];
302
+ case 1:
303
+ body = _state.sent();
304
+ responseCloned = res.clone();
305
+ return [
306
+ 2,
307
+ new HttpResponse(_object_spread_props(_object_spread({}, responseCloned), {
308
+ body: body,
309
+ url: responseCloned.url || undefined
310
+ }))
311
+ ];
312
+ }
313
+ });
314
+ });
315
+ return function(res) {
316
+ return _ref.apply(this, arguments);
317
+ };
318
+ }()))
319
+ ];
320
+ } catch (e) {
321
+ (context.logger || console).error("Failed to retrieve the latest mock for Operation ID ".concat(operationId, ", fallback to default mock"));
322
+ return [
323
+ 2,
324
+ originalCall
325
+ ];
326
+ }
327
+ return [
328
+ 2
329
+ ];
330
+ }
331
+ });
332
+ })()).pipe(mergeMap(function(res) {
333
+ return res;
334
+ }));
335
+ }
336
+ };
337
+ }
338
+ }
339
+ ]);
340
+ return MockInterceptAngular;
341
+ }();
@@ -0,0 +1,3 @@
1
+ /**
2
+ * Mock Angular Plugin options
3
+ */ export { };
@@ -0,0 +1,3 @@
1
+ export * from './api-angular-client';
2
+ export * from './angular-plugin';
3
+ export * from './plugins/index';
package/package.json ADDED
@@ -0,0 +1,192 @@
1
+ {
2
+ "name": "@ama-sdk/client-angular",
3
+ "version": "11.3.0-prerelease.47",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "Angular API Request client for @ama-sdk/core based SDK",
8
+ "module": "src/public_api.js",
9
+ "esm2015": "esm2015/public_api.js",
10
+ "esm2020": "src/public_api.js",
11
+ "typings": "src/public_api.d.ts",
12
+ "sideEffects": false,
13
+ "exports": {
14
+ "./package.json": {
15
+ "default": "./package.json"
16
+ },
17
+ ".": {
18
+ "module": "./src/public_api.js",
19
+ "esm2020": "./src/public_api.js",
20
+ "esm2015": "./esm2015/public_api.js",
21
+ "es2020": "./cjs/public_api.js",
22
+ "default": "./cjs/public_api.js",
23
+ "typings": "./src/public_api.d.ts",
24
+ "import": "./src/public_api.js",
25
+ "node": "./cjs/public_api.js",
26
+ "require": "./cjs/public_api.js"
27
+ }
28
+ },
29
+ "scripts": {
30
+ "nx": "nx",
31
+ "ng": "yarn nx",
32
+ "build": "yarn nx build ama-sdk-client-angular",
33
+ "build:cjs": "swc src -d dist/cjs -C module.type=commonjs -q --strip-leading-paths",
34
+ "build:esm2015": "swc src -d dist/esm2015 -C module.type=es6 -q --strip-leading-paths",
35
+ "build:esm2020": "tsc -b tsconfig.build.json",
36
+ "postbuild": "yarn cpy './package.json' dist && patch-package-json-main",
37
+ "prepare:build:builders": "yarn cpy 'schematics/**/*.json' dist/schematics && yarn cpy 'collection.json' dist",
38
+ "build:builders": "tsc -b tsconfig.builders.json --pretty && yarn generate-cjs-manifest",
39
+ "prepare:publish": "prepare-publish ./dist"
40
+ },
41
+ "dependencies": {
42
+ "@swc/helpers": "~0.5.0",
43
+ "tslib": "^2.6.2",
44
+ "uuid": "^10.0.0"
45
+ },
46
+ "peerDependencies": {
47
+ "@ama-sdk/core": "^11.3.0-prerelease.47",
48
+ "@angular-devkit/schematics": "~18.2.0",
49
+ "@angular/cli": "~18.2.0",
50
+ "@angular/common": "~18.2.0",
51
+ "@o3r/schematics": "^11.3.0-prerelease.47",
52
+ "@schematics/angular": "~18.2.0",
53
+ "rxjs": "^7.8.1",
54
+ "typescript": "~5.5.4"
55
+ },
56
+ "peerDependenciesMeta": {
57
+ "@angular-devkit/schematics": {
58
+ "optional": true
59
+ },
60
+ "@angular/cli": {
61
+ "optional": true
62
+ },
63
+ "@angular/common": {
64
+ "optional": true
65
+ },
66
+ "@o3r/schematics": {
67
+ "optional": true
68
+ },
69
+ "@schematics/angular": {
70
+ "optional": true
71
+ },
72
+ "typescript": {
73
+ "optional": true
74
+ }
75
+ },
76
+ "devDependencies": {
77
+ "@ama-sdk/core": "^11.3.0-prerelease.47",
78
+ "@angular-devkit/core": "~18.2.0",
79
+ "@angular-devkit/schematics": "~18.2.0",
80
+ "@angular-eslint/eslint-plugin": "~18.3.0",
81
+ "@angular/common": "~18.2.0",
82
+ "@angular/core": "~18.2.0",
83
+ "@nx/eslint-plugin": "~19.5.0",
84
+ "@nx/jest": "~19.5.0",
85
+ "@o3r/build-helpers": "^11.3.0-prerelease.47",
86
+ "@o3r/eslint-plugin": "^11.3.0-prerelease.47",
87
+ "@o3r/test-helpers": "^11.3.0-prerelease.47",
88
+ "@schematics/angular": "~18.2.0",
89
+ "@stylistic/eslint-plugin-ts": "~2.4.0",
90
+ "@swc/cli": "~0.4.0",
91
+ "@swc/core": "~1.7.0",
92
+ "@types/jest": "~29.5.2",
93
+ "@types/node": "^20.0.0",
94
+ "@types/uuid": "^9.0.0",
95
+ "@typescript-eslint/eslint-plugin": "^7.14.1",
96
+ "@typescript-eslint/parser": "^7.14.1",
97
+ "@typescript-eslint/utils": "^7.14.1",
98
+ "cpy-cli": "^5.0.0",
99
+ "eslint": "^8.57.0",
100
+ "eslint-import-resolver-node": "^0.3.9",
101
+ "eslint-plugin-jest": "~28.8.0",
102
+ "eslint-plugin-jsdoc": "~48.11.0",
103
+ "eslint-plugin-prefer-arrow": "~1.2.3",
104
+ "eslint-plugin-unicorn": "^54.0.0",
105
+ "jest": "~29.7.0",
106
+ "jest-junit": "~16.0.0",
107
+ "jsonc-eslint-parser": "~2.4.0",
108
+ "minimist": "^1.2.6",
109
+ "pid-from-port": "^1.1.3",
110
+ "rimraf": "^5.0.1",
111
+ "rxjs": "^7.8.1",
112
+ "semver": "^7.5.2",
113
+ "ts-jest": "~29.2.0",
114
+ "ts-node": "~10.9.2",
115
+ "type-fest": "^4.10.2",
116
+ "typescript": "~5.5.4",
117
+ "zone.js": "~0.14.2"
118
+ },
119
+ "engines": {
120
+ "node": "^18.19.1 || ^20.11.1 || >=22.0.0"
121
+ },
122
+ "schematics": "./collection.json",
123
+ "contributors": [
124
+ {
125
+ "name": "Yannick Adam",
126
+ "url": "https://github.com/yannickadam",
127
+ "email": "yannickadam@users.noreply.github.com"
128
+ },
129
+ {
130
+ "name": "Kilian Panot",
131
+ "url": "https://github.com/kpanot",
132
+ "email": "kpanot@users.noreply.github.com"
133
+ },
134
+ {
135
+ "name": "Jeremy Bourgeois",
136
+ "url": "https://github.com/jbourgeois-1A",
137
+ "email": "jbourgeois-1A@users.noreply.github.com"
138
+ },
139
+ {
140
+ "name": "Pierre Henri Ginoux",
141
+ "url": "https://github.com/pginoux-1A",
142
+ "email": "pginoux-1A@users.noreply.github.com"
143
+ },
144
+ {
145
+ "name": "Mircea Vasile Rednic",
146
+ "url": "https://github.com/mrednic-1A",
147
+ "email": "mrednic-1A@users.noreply.github.com"
148
+ },
149
+ {
150
+ "name": "Stephane Dalle",
151
+ "url": "https://github.com/sdalle-1A",
152
+ "email": "sdalle-1A@users.noreply.github.com"
153
+ },
154
+ {
155
+ "name": "Nicolas Hoffmann",
156
+ "url": "https://github.com/nhoffmann-1A",
157
+ "email": "nhoffmann-1A@users.noreply.github.com"
158
+ },
159
+ {
160
+ "name": "Victor Scaiceanu",
161
+ "url": "https://github.com/vscaiceanu-1a",
162
+ "email": "vscaiceanu-1A@users.noreply.github.com"
163
+ },
164
+ {
165
+ "name": "Florian Paul",
166
+ "url": "https://github.com/fpaul-1A",
167
+ "email": "fpaul-1A@users.noreply.github.com"
168
+ },
169
+ {
170
+ "name": "Corinne Paulve",
171
+ "url": "https://github.com/cpaulve-1A",
172
+ "email": "cpaulve-1A@users.noreply.github.com"
173
+ },
174
+ {
175
+ "name": "Matthieu Crouzet",
176
+ "url": "https://github.com/matthieu-crouzet",
177
+ "email": "matthieu-crouzet@users.noreply.github.com"
178
+ },
179
+ {
180
+ "name": "Salome Do",
181
+ "url": "https://github.com/sdo-1A",
182
+ "email": "sdo-1A@users.noreply.github.com"
183
+ }
184
+ ],
185
+ "bugs": "https://github.com/AmadeusITGroup/otter/issues",
186
+ "repository": {
187
+ "type": "git",
188
+ "url": "git+https://github.com/AmadeusITGroup/otter.git"
189
+ },
190
+ "license": "BSD-3-Clause",
191
+ "homepage": "https://amadeusitgroup.github.io/otter/"
192
+ }
@@ -0,0 +1,8 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ import type { NgAddSchematicsSchema } from './schema';
3
+ /**
4
+ * Add SDk Angular Client to an Otter Project
5
+ * @param options
6
+ */
7
+ export declare const ngAdd: (options: NgAddSchematicsSchema) => Rule;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AA0EtD;;;GAGG;AACH,eAAO,MAAM,KAAK,YAAa,qBAAqB,KAAG,IAGtD,CAAC"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ngAdd = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const path = require("node:path");
6
+ const dependencies_1 = require("@schematics/angular/utility/dependencies");
7
+ const import_map_1 = require("./migration/import-map");
8
+ const devDependenciesToInstall = [];
9
+ const reportMissingSchematicsDep = (logger) => (reason) => {
10
+ logger.error(`[ERROR]: Adding @ama-sdk/client-angular has failed.
11
+ If the error is related to missing @o3r dependencies you need to install '@o3r/schematics' as devDependency to be able to use this schematics. Please run 'ng add @o3r/schematics'.
12
+ Otherwise, use the error message as guidance.`);
13
+ throw reason;
14
+ };
15
+ /**
16
+ * Add SDk Angular Client to an Otter Project
17
+ * @param options
18
+ */
19
+ function ngAddFn(options) {
20
+ return async (tree, context) => {
21
+ // use dynamic import to properly raise an exception if it is not an Otter project.
22
+ const { getPackageInstallConfig, applyEsLintFix, setupDependencies, getO3rPeerDeps, getProjectNewDependenciesTypes, getWorkspaceConfig, getExternalDependenciesVersionRange, updateImports } = await Promise.resolve().then(() => require('@o3r/schematics'));
23
+ const workspaceProject = options.projectName ? getWorkspaceConfig(tree)?.projects[options.projectName] : undefined;
24
+ const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
25
+ const depsInfo = getO3rPeerDeps(packageJsonPath);
26
+ const dependencies = depsInfo.o3rPeerDeps.reduce((acc, dep) => {
27
+ acc[dep] = {
28
+ inManifest: [{
29
+ range: `${options.exactO3rVersion ? '' : '~'}${depsInfo.packageVersion}`,
30
+ types: getProjectNewDependenciesTypes(workspaceProject)
31
+ }],
32
+ ngAddOptions: { exactO3rVersion: options.exactO3rVersion }
33
+ };
34
+ return acc;
35
+ }, getPackageInstallConfig(packageJsonPath, tree, options.projectName, false, !!options.exactO3rVersion));
36
+ Object.entries(getExternalDependenciesVersionRange(devDependenciesToInstall, packageJsonPath, context.logger))
37
+ .forEach(([dep, range]) => {
38
+ dependencies[dep] = {
39
+ inManifest: [{
40
+ range,
41
+ types: [dependencies_1.NodeDependencyType.Dev]
42
+ }]
43
+ };
44
+ });
45
+ return (0, schematics_1.chain)([
46
+ // optional custom action dedicated to this module
47
+ options.skipLinter ? (0, schematics_1.noop)() : applyEsLintFix(),
48
+ // add the missing Otter modules in the current project
49
+ setupDependencies({
50
+ projectName: options.projectName,
51
+ dependencies,
52
+ ngAddToRun: depsInfo.o3rPeerDeps
53
+ }),
54
+ updateImports(import_map_1.mapMigrationFromCoreImports)
55
+ ]);
56
+ };
57
+ }
58
+ /**
59
+ * Add SDk Angular Client to an Otter Project
60
+ * @param options
61
+ */
62
+ const ngAdd = (options) => async (_, { logger }) => {
63
+ const { createSchematicWithMetricsIfInstalled } = await Promise.resolve().then(() => require('@o3r/schematics')).catch(reportMissingSchematicsDep(logger));
64
+ return createSchematicWithMetricsIfInstalled(ngAddFn)(options);
65
+ };
66
+ exports.ngAdd = ngAdd;
67
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ export declare const mapMigrationFromCoreImports: {
2
+ '@ama-sdk/core': Record<string, {
3
+ newPackage: string;
4
+ }>;
5
+ };
6
+ //# sourceMappingURL=import-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-map.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/migration/import-map.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,2BAA2B;;;;CAQvC,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapMigrationFromCoreImports = void 0;
4
+ /* eslint-disable @typescript-eslint/naming-convention */
5
+ const currentPackage = {
6
+ newPackage: '@ama-sdk/client-angular'
7
+ };
8
+ exports.mapMigrationFromCoreImports = {
9
+ '@ama-sdk/core': [
10
+ 'BaseApiAngularClientOptions',
11
+ 'BaseApiAngularClientConstructor',
12
+ 'ApiAngularClient',
13
+ 'MockInterceptAngular',
14
+ 'MockInterceptAngularParameters'
15
+ ].reduce((acc, name) => ({ ...acc, [name]: currentPackage }), {})
16
+ };
17
+ //# sourceMappingURL=import-map.js.map
@@ -0,0 +1,6 @@
1
+ import type { SchematicOptionObject } from '@o3r/schematics';
2
+ export interface NgAddSchematicsSchema extends SchematicOptionObject {
3
+ /** Project name */
4
+ projectName?: string | undefined;
5
+ }
6
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAClE,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schema.js.map