@o3r/apis-manager 10.0.0-next.8 → 11.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/apis-manager/api-factory.service.d.ts +1 -6
- package/apis-manager/api-factory.service.d.ts.map +1 -1
- package/apis-manager/api-manager.d.ts +0 -4
- package/apis-manager/api-manager.d.ts.map +1 -1
- package/apis-manager/api-manager.helpers.d.ts +0 -1
- package/apis-manager/api-manager.helpers.d.ts.map +1 -1
- package/apis-manager/api-manager.module.d.ts +0 -1
- package/apis-manager/api-manager.module.d.ts.map +1 -1
- package/esm2022/apis-manager/api-factory.service.mjs +6 -11
- package/esm2022/apis-manager/api-manager.helpers.mjs +1 -2
- package/esm2022/apis-manager/api-manager.mjs +1 -5
- package/esm2022/apis-manager/api-manager.module.mjs +5 -6
- package/fesm2022/o3r-apis-manager.mjs +9 -20
- package/fesm2022/o3r-apis-manager.mjs.map +1 -1
- package/package.json +11 -11
- package/schematics/helpers/update-api-deps/index.d.ts +2 -0
- package/schematics/helpers/update-api-deps/index.d.ts.map +1 -1
- package/schematics/helpers/update-api-deps/index.js +13 -10
- package/schematics/helpers/update-api-deps/index.js.map +1 -1
- package/schematics/ng-add/index.d.ts +0 -1
- package/schematics/ng-add/index.d.ts.map +1 -1
- package/schematics/ng-add/index.js +3 -5
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/schema.json +1 -1
- package/schematics/package.json +0 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<h1 align="center">Otter APIs-manager</h1>
|
|
2
2
|
<p align="center">
|
|
3
|
-
<img src="https://raw.githubusercontent.com/AmadeusITGroup/otter/main
|
|
3
|
+
<img src="https://raw.githubusercontent.com/AmadeusITGroup/otter/main/assets/logo/otter.png" alt="Super cute Otter!" width="40%"/>
|
|
4
4
|
</p>
|
|
5
5
|
|
|
6
6
|
This package is an [Otter Framework Module](https://github.com/AmadeusITGroup/otter/tree/main/docs/core/MODULE.md).
|
|
@@ -9,19 +9,17 @@ export type ApiClassType<T extends Api = Api> = (new (client: ApiClient) => T) &
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const INITIAL_APIS_TOKEN: InjectionToken<(Api | ApiClassType<Api>)[]>;
|
|
11
11
|
export declare class ApiFactoryService {
|
|
12
|
-
private apiManager;
|
|
12
|
+
private readonly apiManager;
|
|
13
13
|
/** Map of loaded APIs */
|
|
14
14
|
private loadedApis;
|
|
15
15
|
constructor(apiManager: ApiManager, apis?: (Api | ApiClassType)[]);
|
|
16
16
|
/**
|
|
17
17
|
* Determine if the given parameter is a API class
|
|
18
|
-
*
|
|
19
18
|
* @param apiClass object to check
|
|
20
19
|
*/
|
|
21
20
|
private isApiClass;
|
|
22
21
|
/**
|
|
23
22
|
* Retrieve a specific API with loaded configuration
|
|
24
|
-
*
|
|
25
23
|
* @param apiClass class of the API to retrieve
|
|
26
24
|
* @param refreshCache Ignore cached API instance and refresh it
|
|
27
25
|
*/
|
|
@@ -29,19 +27,16 @@ export declare class ApiFactoryService {
|
|
|
29
27
|
/**
|
|
30
28
|
* Update the Map of loaded APIs.
|
|
31
29
|
* Note: Can be used to override the a specific API
|
|
32
|
-
*
|
|
33
30
|
* @param map Map of loaded APIs to update
|
|
34
31
|
*/
|
|
35
32
|
updateApiMapping(map: (Api | ApiClassType)[] | Record<string, (Api | ApiClassType)>): void;
|
|
36
33
|
/**
|
|
37
34
|
* Clear the cache of loaded APIs
|
|
38
|
-
*
|
|
39
35
|
* @param apis Whitelist of APIs to clear from the cache, if specified only these apis will be removed from the cache
|
|
40
36
|
*/
|
|
41
37
|
clearCache(apis?: ApiName[]): void;
|
|
42
38
|
/**
|
|
43
39
|
* Retrieve the configuration for a specific API
|
|
44
|
-
*
|
|
45
40
|
* @param apiClass class of the API for which retrieving the configuration
|
|
46
41
|
*/
|
|
47
42
|
getConfigFor(apiClass: ApiName): ApiClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-factory.service.d.ts","sourceRoot":"","sources":["../../src/apis-manager/api-factory.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAsB,cAAc,EAAY,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;;AAG3C,sCAAsC;AACtC,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC,KAAK,MAAM,EAAE,SAAS,KAAK,CAAC,CAAC,GAAG,OAAO,CAAC;AAEzF;;GAEG;AACH,eAAO,MAAM,kBAAkB,6CAAmE,CAAC;AAEnG,qBACa,iBAAiB;IAKG,OAAO,CAAC,UAAU;
|
|
1
|
+
{"version":3,"file":"api-factory.service.d.ts","sourceRoot":"","sources":["../../src/apis-manager/api-factory.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAsB,cAAc,EAAY,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;;AAG3C,sCAAsC;AACtC,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC,KAAK,MAAM,EAAE,SAAS,KAAK,CAAC,CAAC,GAAG,OAAO,CAAC;AAEzF;;GAEG;AACH,eAAO,MAAM,kBAAkB,6CAAmE,CAAC;AAEnG,qBACa,iBAAiB;IAKG,OAAO,CAAC,QAAQ,CAAC,UAAU;IAH1D,yBAAyB;IACzB,OAAO,CAAC,UAAU,CAA2B;gBAEG,UAAU,EAAE,UAAU,EAA0C,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,YAAY,CAAC,EAAE;IAM7I;;;OAGG;IACH,OAAO,CAAC,UAAU;IAIlB;;;;OAIG;IACI,MAAM,CAAC,CAAC,SAAS,GAAG,EAAE,QAAQ,EAAE,CAAC,KAAK,MAAM,EAAE,SAAS,KAAK,CAAC,CAAC,GAAG,OAAO,EAAE,YAAY,UAAQ,GAAG,CAAC;IAYzG;;;;OAIG;IACI,gBAAgB,CAAC,GAAG,EAAE,CAAC,GAAG,GAAG,YAAY,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,YAAY,CAAC,CAAC;IAkB1F;;;OAGG;IACI,UAAU,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE;IAQlC;;;OAGG;IACI,YAAY,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS;yCA3EtC,iBAAiB;6CAAjB,iBAAiB;CA8E7B"}
|
|
@@ -10,7 +10,6 @@ export declare class ApiManager {
|
|
|
10
10
|
private apiConfigurations;
|
|
11
11
|
/**
|
|
12
12
|
* Map of registered Api Client associated to specific API
|
|
13
|
-
*
|
|
14
13
|
* @warning This should not be used to get the ApiClient for an API, the function getConfiguration() should be used instead
|
|
15
14
|
*/
|
|
16
15
|
get registeredApiConfigurations(): {
|
|
@@ -18,7 +17,6 @@ export declare class ApiManager {
|
|
|
18
17
|
};
|
|
19
18
|
/**
|
|
20
19
|
* Create an API manager using a custom ApiClient
|
|
21
|
-
*
|
|
22
20
|
* @param defaultConfiguration
|
|
23
21
|
*/
|
|
24
22
|
constructor(defaultConfiguration: ApiClient, apiConfigurations?: {
|
|
@@ -26,13 +24,11 @@ export declare class ApiManager {
|
|
|
26
24
|
});
|
|
27
25
|
/**
|
|
28
26
|
* Retrieve a configuration for a specific API
|
|
29
|
-
*
|
|
30
27
|
* @param api API to get the configuration for
|
|
31
28
|
*/
|
|
32
29
|
getConfiguration(api?: string): ApiClient;
|
|
33
30
|
/**
|
|
34
31
|
* Set or override API configuration
|
|
35
|
-
*
|
|
36
32
|
* @param apiClient API configuration to override to the given api
|
|
37
33
|
* @param api API name to override, the default configuration will be used if not specified
|
|
38
34
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-manager.d.ts","sourceRoot":"","sources":["../../src/apis-manager/api-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;;GAKG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,oBAAoB,CAAY;IACxC,OAAO,CAAC,iBAAiB,CAA+B;IAExD
|
|
1
|
+
{"version":3,"file":"api-manager.d.ts","sourceRoot":"","sources":["../../src/apis-manager/api-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;;GAKG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,oBAAoB,CAAY;IACxC,OAAO,CAAC,iBAAiB,CAA+B;IAExD;;;OAGG;IACH,IAAW,2BAA2B;;MAErC;IAED;;;OAGG;gBACS,oBAAoB,EAAE,SAAS,EAAE,iBAAiB,GAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;KAAO;IAKjG;;;OAGG;IACI,gBAAgB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS;IAIhD;;;;OAIG;IACI,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI;CAOlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-manager.helpers.d.ts","sourceRoot":"","sources":["../../src/apis-manager/api-manager.helpers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"api-manager.helpers.d.ts","sourceRoot":"","sources":["../../src/apis-manager/api-manager.helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,kBAAkB,UAAO,GAAG,IAAI,CAQjF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-manager.module.d.ts","sourceRoot":"","sources":["../../src/apis-manager/api-manager.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAY,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;;AAI3C,qBAKa,gBAAgB;IAC3B
|
|
1
|
+
{"version":3,"file":"api-manager.module.d.ts","sourceRoot":"","sources":["../../src/apis-manager/api-manager.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAY,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;;AAI3C,qBAKa,gBAAgB;IAC3B;;;;OAIG;WACW,OAAO,CAAC,UAAU,EAAE,UAAU,GAAG,mBAAmB,CAAC,gBAAgB,CAAC;yCANzE,gBAAgB;0CAAhB,gBAAgB;0CAAhB,gBAAgB;CAc5B"}
|
|
@@ -18,7 +18,6 @@ export class ApiFactoryService {
|
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Determine if the given parameter is a API class
|
|
21
|
-
*
|
|
22
21
|
* @param apiClass object to check
|
|
23
22
|
*/
|
|
24
23
|
isApiClass(apiClass) {
|
|
@@ -26,7 +25,6 @@ export class ApiFactoryService {
|
|
|
26
25
|
}
|
|
27
26
|
/**
|
|
28
27
|
* Retrieve a specific API with loaded configuration
|
|
29
|
-
*
|
|
30
28
|
* @param apiClass class of the API to retrieve
|
|
31
29
|
* @param refreshCache Ignore cached API instance and refresh it
|
|
32
30
|
*/
|
|
@@ -43,7 +41,6 @@ export class ApiFactoryService {
|
|
|
43
41
|
/**
|
|
44
42
|
* Update the Map of loaded APIs.
|
|
45
43
|
* Note: Can be used to override the a specific API
|
|
46
|
-
*
|
|
47
44
|
* @param map Map of loaded APIs to update
|
|
48
45
|
*/
|
|
49
46
|
updateApiMapping(map) {
|
|
@@ -64,7 +61,6 @@ export class ApiFactoryService {
|
|
|
64
61
|
}
|
|
65
62
|
/**
|
|
66
63
|
* Clear the cache of loaded APIs
|
|
67
|
-
*
|
|
68
64
|
* @param apis Whitelist of APIs to clear from the cache, if specified only these apis will be removed from the cache
|
|
69
65
|
*/
|
|
70
66
|
clearCache(apis) {
|
|
@@ -77,18 +73,17 @@ export class ApiFactoryService {
|
|
|
77
73
|
}
|
|
78
74
|
/**
|
|
79
75
|
* Retrieve the configuration for a specific API
|
|
80
|
-
*
|
|
81
76
|
* @param apiClass class of the API for which retrieving the configuration
|
|
82
77
|
*/
|
|
83
78
|
getConfigFor(apiClass) {
|
|
84
79
|
return this.apiManager.getConfiguration(apiClass.apiName);
|
|
85
80
|
}
|
|
86
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
87
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
81
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ApiFactoryService, deps: [{ token: API_TOKEN }, { token: INITIAL_APIS_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
82
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ApiFactoryService }); }
|
|
88
83
|
}
|
|
89
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
84
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ApiFactoryService, decorators: [{
|
|
90
85
|
type: Injectable
|
|
91
|
-
}], ctorParameters:
|
|
86
|
+
}], ctorParameters: () => [{ type: i1.ApiManager, decorators: [{
|
|
92
87
|
type: Inject,
|
|
93
88
|
args: [API_TOKEN]
|
|
94
89
|
}] }, { type: undefined, decorators: [{
|
|
@@ -96,5 +91,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImpor
|
|
|
96
91
|
}, {
|
|
97
92
|
type: Inject,
|
|
98
93
|
args: [INITIAL_APIS_TOKEN]
|
|
99
|
-
}] }]
|
|
100
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
94
|
+
}] }] });
|
|
95
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBpLWZhY3Rvcnkuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcGlzLW1hbmFnZXIvYXBpLWZhY3Rvcnkuc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsTUFBTSxFQUFFLFVBQVUsRUFBRSxjQUFjLEVBQUUsUUFBUSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQzdFLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDM0MsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLHFCQUFxQixDQUFDOzs7QUFLaEQ7O0dBRUc7QUFDSCxNQUFNLENBQUMsTUFBTSxrQkFBa0IsR0FBRyxJQUFJLGNBQWMsQ0FBeUIsb0JBQW9CLENBQUMsQ0FBQztBQUduRyxNQUFNLE9BQU8saUJBQWlCO0lBSzVCLFlBQWdELFVBQXNCLEVBQTBDLElBQTZCO1FBQTdGLGVBQVUsR0FBVixVQUFVLENBQVk7UUFIdEUseUJBQXlCO1FBQ2pCLGVBQVUsR0FBd0IsRUFBRSxDQUFDO1FBRzNDLElBQUksSUFBSSxFQUFFO1lBQ1IsSUFBSSxDQUFDLGdCQUFnQixDQUFDLElBQUksQ0FBQyxDQUFDO1NBQzdCO0lBQ0gsQ0FBQztJQUVEOzs7T0FHRztJQUNLLFVBQVUsQ0FBc0IsUUFBYTtRQUNuRCxPQUFPLENBQUMsQ0FBQyxRQ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,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Add a preconnect `<link>` element to the DOM
|
|
3
|
-
*
|
|
4
3
|
* @param baseUrl the origin href
|
|
5
4
|
* @param supportCrossOrigin add crossorigin attribute to the link element
|
|
6
5
|
*/
|
|
@@ -13,4 +12,4 @@ export function appendPreconnect(baseUrl, supportCrossOrigin = true) {
|
|
|
13
12
|
}
|
|
14
13
|
document.head.appendChild(preConnectLink);
|
|
15
14
|
}
|
|
16
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBpLW1hbmFnZXIuaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcGlzLW1hbmFnZXIvYXBpLW1hbmFnZXIuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7OztHQUlHO0FBQ0gsTUFBTSxVQUFVLGdCQUFnQixDQUFDLE9BQWUsRUFBRSxrQkFBa0IsR0FBRyxJQUFJO0lBQ3pFLE1BQU0sY0FBYyxHQUFHLFFBQVEsQ0FBQyxhQUFhLENBQUMsTUFBTSxDQUFDLENBQUM7SUFDdEQsY0FBYyxDQUFDLFlBQVksQ0FBQyxLQUFLLEVBQUUsWUFBWSxDQUFDLENBQUM7SUFDakQsY0FBYyxDQUFDLFlBQVksQ0FBQyxNQUFNLEVBQUUsT0FBTyxDQUFDLENBQUM7SUFDN0MsSUFBSSxrQkFBa0IsRUFBRTtRQUN0QixjQUFjLENBQUMsWUFBWSxDQUFDLGFBQWEsRUFBRSxFQUFFLENBQUMsQ0FBQztLQUNoRDtJQUNELFFBQVEsQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLGNBQWMsQ0FBQyxDQUFDO0FBQzVDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEFkZCBhIHByZWNvbm5lY3QgYDxsaW5rPmAgZWxlbWVudCB0byB0aGUgRE9NXG4gKiBAcGFyYW0gYmFzZVVybCB0aGUgb3JpZ2luIGhyZWZcbiAqIEBwYXJhbSBzdXBwb3J0Q3Jvc3NPcmlnaW4gYWRkIGNyb3Nzb3JpZ2luIGF0dHJpYnV0ZSB0byB0aGUgbGluayBlbGVtZW50XG4gKi9cbmV4cG9ydCBmdW5jdGlvbiBhcHBlbmRQcmVjb25uZWN0KGJhc2VVcmw6IHN0cmluZywgc3VwcG9ydENyb3NzT3JpZ2luID0gdHJ1ZSk6IHZvaWQge1xuICBjb25zdCBwcmVDb25uZWN0TGluayA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2xpbmsnKTtcbiAgcHJlQ29ubmVjdExpbmsuc2V0QXR0cmlidXRlKCdyZWwnLCAncHJlY29ubmVjdCcpO1xuICBwcmVDb25uZWN0TGluay5zZXRBdHRyaWJ1dGUoJ2hyZWYnLCBiYXNlVXJsKTtcbiAgaWYgKHN1cHBvcnRDcm9zc09yaWdpbikge1xuICAgIHByZUNvbm5lY3RMaW5rLnNldEF0dHJpYnV0ZSgnY3Jvc3NvcmlnaW4nLCAnJyk7XG4gIH1cbiAgZG9jdW1lbnQuaGVhZC5hcHBlbmRDaGlsZChwcmVDb25uZWN0TGluayk7XG59XG4iXX0=
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
export class ApiManager {
|
|
8
8
|
/**
|
|
9
9
|
* Map of registered Api Client associated to specific API
|
|
10
|
-
*
|
|
11
10
|
* @warning This should not be used to get the ApiClient for an API, the function getConfiguration() should be used instead
|
|
12
11
|
*/
|
|
13
12
|
get registeredApiConfigurations() {
|
|
@@ -15,7 +14,6 @@ export class ApiManager {
|
|
|
15
14
|
}
|
|
16
15
|
/**
|
|
17
16
|
* Create an API manager using a custom ApiClient
|
|
18
|
-
*
|
|
19
17
|
* @param defaultConfiguration
|
|
20
18
|
*/
|
|
21
19
|
constructor(defaultConfiguration, apiConfigurations = {}) {
|
|
@@ -24,7 +22,6 @@ export class ApiManager {
|
|
|
24
22
|
}
|
|
25
23
|
/**
|
|
26
24
|
* Retrieve a configuration for a specific API
|
|
27
|
-
*
|
|
28
25
|
* @param api API to get the configuration for
|
|
29
26
|
*/
|
|
30
27
|
getConfiguration(api) {
|
|
@@ -32,7 +29,6 @@ export class ApiManager {
|
|
|
32
29
|
}
|
|
33
30
|
/**
|
|
34
31
|
* Set or override API configuration
|
|
35
|
-
*
|
|
36
32
|
* @param apiClient API configuration to override to the given api
|
|
37
33
|
* @param api API name to override, the default configuration will be used if not specified
|
|
38
34
|
*/
|
|
@@ -45,4 +41,4 @@ export class ApiManager {
|
|
|
45
41
|
}
|
|
46
42
|
}
|
|
47
43
|
}
|
|
48
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
44
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBpLW1hbmFnZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYXBpcy1tYW5hZ2VyL2FwaS1tYW5hZ2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBOzs7OztHQUtHO0FBQ0gsTUFBTSxPQUFPLFVBQVU7SUFJckI7OztPQUdHO0lBQ0gsSUFBVywyQkFBMkI7UUFDcEMsT0FBTyxFQUFDLEdBQUcsSUFBSSxDQUFDLGlCQUFpQixFQUFVLENBQUM7SUFDOUMsQ0FBQztJQUVEOzs7T0FHRztJQUNILFlBQVksb0JBQStCLEVBQUUsb0JBQWtELEVBQUU7UUFDL0YsSUFBSSxDQUFDLG9CQUFvQixHQUFHLG9CQUFvQixDQUFDO1FBQ2pELElBQUksQ0FBQyxpQkFBaUIsR0FBRyxpQkFBaUIsQ0FBQztJQUM3QyxDQUFDO0lBRUQ7OztPQUdHO0lBQ0ksZ0JBQWdCLENBQUMsR0FBWTtRQUNsQyxPQUFPLEdBQUcsSUFB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XRpb24oYXBpPzogc3RyaW5nKTogQXBpQ2xpZW50IHtcbiAgICByZXR1cm4gYXBpICYmIHRoaXMuYXBpQ29uZmlndXJhdGlvbnNbYXBpXSB8fCB0aGlzLmRlZmF1bHRDb25maWd1cmF0aW9uO1xuICB9XG5cbiAgLyoqXG4gICAqIFNldCBvciBvdmVycmlkZSBBUEkgY29uZmlndXJhdGlvblxuICAgKiBAcGFyYW0gYXBpQ2xpZW50IEFQSSBjb25maWd1cmF0aW9uIHRvIG92ZXJyaWRlIHRvIHRoZSBnaXZlbiBhcGlcbiAgICogQHBhcmFtIGFwaSBBUEkgbmFtZSB0byBvdmVycmlkZSwgdGhlIGRlZmF1bHQgY29uZmlndXJhdGlvbiB3aWxsIGJlIHVzZWQgaWYgbm90IHNwZWNpZmllZFxuICAgKi9cbiAgcHVibGljIHNldENvbmZpZ3VyYXRpb24oYXBpQ2xpZW50OiBBcGlDbGllbnQsIGFwaT86IHN0cmluZyk6IHZvaWQge1xuICAgIGlmIChhcGkpIHtcbiAgICAgIHRoaXMuYXBpQ29uZmlndXJhdGlvbnNbYXBpXSA9IGFwaUNsaWVudDtcbiAgICB9IGVsc2Uge1xuICAgICAgdGhpcy5kZWZhdWx0Q29uZmlndXJhdGlvbiA9IGFwaUNsaWVudDtcbiAgICB9XG4gIH1cbn1cbiJdfQ==
|
|
@@ -7,7 +7,6 @@ export class ApiManagerModule {
|
|
|
7
7
|
/**
|
|
8
8
|
* Provide a custom apiManager
|
|
9
9
|
* A factory can be provided via injection to the token API_TOKEN
|
|
10
|
-
*
|
|
11
10
|
* @param apiManager
|
|
12
11
|
*/
|
|
13
12
|
static forRoot(apiManager) {
|
|
@@ -18,13 +17,13 @@ export class ApiManagerModule {
|
|
|
18
17
|
]
|
|
19
18
|
};
|
|
20
19
|
}
|
|
21
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
22
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
23
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
20
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ApiManagerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
21
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.8", ngImport: i0, type: ApiManagerModule }); }
|
|
22
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ApiManagerModule, providers: [
|
|
24
23
|
ApiFactoryService
|
|
25
24
|
] }); }
|
|
26
25
|
}
|
|
27
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
26
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ApiManagerModule, decorators: [{
|
|
28
27
|
type: NgModule,
|
|
29
28
|
args: [{
|
|
30
29
|
providers: [
|
|
@@ -32,4 +31,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImpor
|
|
|
32
31
|
]
|
|
33
32
|
}]
|
|
34
33
|
}] });
|
|
35
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
34
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBpLW1hbmFnZXIubW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2FwaXMtbWFuYWdlci9hcGktbWFuYWdlci5tb2R1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUF1QixRQUFRLEVBQUUsTUFBTSxlQUFlLENBQUM7Q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VsZSh7XG4gIHByb3ZpZGVyczogW1xuICAgIEFwaUZhY3RvcnlTZXJ2aWNlXG4gIF1cbn0pXG5leHBvcnQgY2xhc3MgQXBpTWFuYWdlck1vZHVsZSB7XG4gIC8qKlxuICAgKiBQcm92aWRlIGEgY3VzdG9tIGFwaU1hbmFnZXJcbiAgICogQSBmYWN0b3J5IGNhbiBiZSBwcm92aWRlZCB2aWEgaW5qZWN0aW9uIHRvIHRoZSB0b2tlbiBBUElfVE9LRU5cbiAgICogQHBhcmFtIGFwaU1hbmFnZXJcbiAgICovXG4gIHB1YmxpYyBzdGF0aWMgZm9yUm9vdChhcGlNYW5hZ2VyOiBBcGlNYW5hZ2VyKTogTW9kdWxlV2l0aFByb3ZpZGVyczxBcGlNYW5hZ2VyTW9kdWxlPiB7XG4gICAgcmV0dXJuIHtcbiAgICAgIG5nTW9kdWxlOiBBcGlNYW5hZ2VyTW9kdWxlLFxuICAgICAgcHJvdmlkZXJzOiBbXG4gICAgICAgIHsgcHJvdmlkZTogQVBJX1RPS0VOLCB1c2VWYWx1ZTogYXBpTWFuYWdlciB9XG4gICAgICBdXG4gICAgfTtcbiAgfVxufVxuIl19
|
|
@@ -10,7 +10,6 @@ import { InjectionToken, Injectable, Inject, Optional, NgModule } from '@angular
|
|
|
10
10
|
class ApiManager {
|
|
11
11
|
/**
|
|
12
12
|
* Map of registered Api Client associated to specific API
|
|
13
|
-
*
|
|
14
13
|
* @warning This should not be used to get the ApiClient for an API, the function getConfiguration() should be used instead
|
|
15
14
|
*/
|
|
16
15
|
get registeredApiConfigurations() {
|
|
@@ -18,7 +17,6 @@ class ApiManager {
|
|
|
18
17
|
}
|
|
19
18
|
/**
|
|
20
19
|
* Create an API manager using a custom ApiClient
|
|
21
|
-
*
|
|
22
20
|
* @param defaultConfiguration
|
|
23
21
|
*/
|
|
24
22
|
constructor(defaultConfiguration, apiConfigurations = {}) {
|
|
@@ -27,7 +25,6 @@ class ApiManager {
|
|
|
27
25
|
}
|
|
28
26
|
/**
|
|
29
27
|
* Retrieve a configuration for a specific API
|
|
30
|
-
*
|
|
31
28
|
* @param api API to get the configuration for
|
|
32
29
|
*/
|
|
33
30
|
getConfiguration(api) {
|
|
@@ -35,7 +32,6 @@ class ApiManager {
|
|
|
35
32
|
}
|
|
36
33
|
/**
|
|
37
34
|
* Set or override API configuration
|
|
38
|
-
*
|
|
39
35
|
* @param apiClient API configuration to override to the given api
|
|
40
36
|
* @param api API name to override, the default configuration will be used if not specified
|
|
41
37
|
*/
|
|
@@ -69,7 +65,6 @@ class ApiFactoryService {
|
|
|
69
65
|
}
|
|
70
66
|
/**
|
|
71
67
|
* Determine if the given parameter is a API class
|
|
72
|
-
*
|
|
73
68
|
* @param apiClass object to check
|
|
74
69
|
*/
|
|
75
70
|
isApiClass(apiClass) {
|
|
@@ -77,7 +72,6 @@ class ApiFactoryService {
|
|
|
77
72
|
}
|
|
78
73
|
/**
|
|
79
74
|
* Retrieve a specific API with loaded configuration
|
|
80
|
-
*
|
|
81
75
|
* @param apiClass class of the API to retrieve
|
|
82
76
|
* @param refreshCache Ignore cached API instance and refresh it
|
|
83
77
|
*/
|
|
@@ -94,7 +88,6 @@ class ApiFactoryService {
|
|
|
94
88
|
/**
|
|
95
89
|
* Update the Map of loaded APIs.
|
|
96
90
|
* Note: Can be used to override the a specific API
|
|
97
|
-
*
|
|
98
91
|
* @param map Map of loaded APIs to update
|
|
99
92
|
*/
|
|
100
93
|
updateApiMapping(map) {
|
|
@@ -115,7 +108,6 @@ class ApiFactoryService {
|
|
|
115
108
|
}
|
|
116
109
|
/**
|
|
117
110
|
* Clear the cache of loaded APIs
|
|
118
|
-
*
|
|
119
111
|
* @param apis Whitelist of APIs to clear from the cache, if specified only these apis will be removed from the cache
|
|
120
112
|
*/
|
|
121
113
|
clearCache(apis) {
|
|
@@ -128,18 +120,17 @@ class ApiFactoryService {
|
|
|
128
120
|
}
|
|
129
121
|
/**
|
|
130
122
|
* Retrieve the configuration for a specific API
|
|
131
|
-
*
|
|
132
123
|
* @param apiClass class of the API for which retrieving the configuration
|
|
133
124
|
*/
|
|
134
125
|
getConfigFor(apiClass) {
|
|
135
126
|
return this.apiManager.getConfiguration(apiClass.apiName);
|
|
136
127
|
}
|
|
137
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
138
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
128
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ApiFactoryService, deps: [{ token: API_TOKEN }, { token: INITIAL_APIS_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
129
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ApiFactoryService }); }
|
|
139
130
|
}
|
|
140
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
131
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ApiFactoryService, decorators: [{
|
|
141
132
|
type: Injectable
|
|
142
|
-
}], ctorParameters:
|
|
133
|
+
}], ctorParameters: () => [{ type: ApiManager, decorators: [{
|
|
143
134
|
type: Inject,
|
|
144
135
|
args: [API_TOKEN]
|
|
145
136
|
}] }, { type: undefined, decorators: [{
|
|
@@ -147,14 +138,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImpor
|
|
|
147
138
|
}, {
|
|
148
139
|
type: Inject,
|
|
149
140
|
args: [INITIAL_APIS_TOKEN]
|
|
150
|
-
}] }]
|
|
141
|
+
}] }] });
|
|
151
142
|
|
|
152
143
|
// Module that needs to be imported by the application to instantiate an SDK configuration.
|
|
153
144
|
class ApiManagerModule {
|
|
154
145
|
/**
|
|
155
146
|
* Provide a custom apiManager
|
|
156
147
|
* A factory can be provided via injection to the token API_TOKEN
|
|
157
|
-
*
|
|
158
148
|
* @param apiManager
|
|
159
149
|
*/
|
|
160
150
|
static forRoot(apiManager) {
|
|
@@ -165,13 +155,13 @@ class ApiManagerModule {
|
|
|
165
155
|
]
|
|
166
156
|
};
|
|
167
157
|
}
|
|
168
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
169
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
170
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
158
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ApiManagerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
159
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.8", ngImport: i0, type: ApiManagerModule }); }
|
|
160
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ApiManagerModule, providers: [
|
|
171
161
|
ApiFactoryService
|
|
172
162
|
] }); }
|
|
173
163
|
}
|
|
174
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
164
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.8", ngImport: i0, type: ApiManagerModule, decorators: [{
|
|
175
165
|
type: NgModule,
|
|
176
166
|
args: [{
|
|
177
167
|
providers: [
|
|
@@ -182,7 +172,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.0", ngImpor
|
|
|
182
172
|
|
|
183
173
|
/**
|
|
184
174
|
* Add a preconnect `<link>` element to the DOM
|
|
185
|
-
*
|
|
186
175
|
* @param baseUrl the origin href
|
|
187
176
|
* @param supportCrossOrigin add crossorigin attribute to the link element
|
|
188
177
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"o3r-apis-manager.mjs","sources":["../../src/apis-manager/api-manager.ts","../../src/apis-manager/api-manager.token.ts","../../src/apis-manager/api-factory.service.ts","../../src/apis-manager/api-manager.module.ts","../../src/apis-manager/api-manager.helpers.ts","../../src/o3r-apis-manager.ts"],"sourcesContent":["import type { ApiClient } from '@ama-sdk/core';\n\n/**\n * Api manager is responsible to provide an api configuration to a service factory, so that it could instantiate an API\n * with the right parameters. It contains a default configuration and a map of specific configurations for API / set of\n * API. Configurations are only exposed through the method getConfiguration, which will merge the default configuration\n * and the requested one.\n */\nexport class ApiManager {\n private defaultConfiguration: ApiClient;\n private apiConfigurations: { [key: string]: ApiClient };\n\n /**\n * Map of registered Api Client associated to specific API\n *\n * @warning This should not be used to get the ApiClient for an API, the function getConfiguration() should be used instead\n */\n public get registeredApiConfigurations() {\n return {...this.apiConfigurations} as const;\n }\n\n /**\n * Create an API manager using a custom ApiClient\n *\n * @param defaultConfiguration\n */\n constructor(defaultConfiguration: ApiClient, apiConfigurations: { [key: string]: ApiClient } = {}) {\n this.defaultConfiguration = defaultConfiguration;\n this.apiConfigurations = apiConfigurations;\n }\n\n /**\n * Retrieve a configuration for a specific API\n *\n * @param api API to get the configuration for\n */\n public getConfiguration(api?: string): ApiClient {\n return api && this.apiConfigurations[api] || this.defaultConfiguration;\n }\n\n /**\n * Set or override API configuration\n *\n * @param apiClient API configuration to override to the given api\n * @param api API name to override, the default configuration will be used if not specified\n */\n public setConfiguration(apiClient: ApiClient, api?: string): void {\n if (api) {\n this.apiConfigurations[api] = apiClient;\n } else {\n this.defaultConfiguration = apiClient;\n }\n }\n}\n","import { InjectionToken } from '@angular/core';\nimport { ApiManager } from './api-manager';\n\n/**\n * Token used by the core library to provide an Api manager to services. It can be provided in the app.\n */\nexport const API_TOKEN = new InjectionToken<ApiManager>('Custom API manager token');\n","import type { Api, ApiClient, ApiName } from '@ama-sdk/core';\nimport { Inject, Injectable, InjectionToken, Optional } from '@angular/core';\nimport { ApiManager } from './api-manager';\nimport { API_TOKEN } from './api-manager.token';\n\n/** Type of the Class of an SDK Api */\nexport type ApiClassType<T extends Api = Api> = (new (client: ApiClient) => T) & ApiName;\n\n/**\n * Initial APIs instantiations\n */\nexport const INITIAL_APIS_TOKEN = new InjectionToken<(Api | ApiClassType)[]>('Initial APIs token');\n\n@Injectable()\nexport class ApiFactoryService {\n\n /** Map of loaded APIs */\n private loadedApis: Record<string, Api> = {};\n\n constructor(@Inject(API_TOKEN) private apiManager: ApiManager, @Optional() @Inject(INITIAL_APIS_TOKEN) apis?: (Api | ApiClassType)[]) {\n if (apis) {\n this.updateApiMapping(apis);\n }\n }\n\n /**\n * Determine if the given parameter is a API class\n *\n * @param apiClass object to check\n */\n private isApiClass<T extends Api = Api>(apiClass: any): apiClass is ApiClassType<T> {\n return !!apiClass.apiName && typeof apiClass === 'function';\n }\n\n /**\n * Retrieve a specific API with loaded configuration\n *\n * @param apiClass class of the API to retrieve\n * @param refreshCache Ignore cached API instance and refresh it\n */\n public getApi<T extends Api>(apiClass: (new (client: ApiClient) => T) & ApiName, refreshCache = false): T {\n const cache = this.loadedApis[apiClass.apiName];\n if (!refreshCache && cache) {\n return cache as T;\n }\n\n // eslint-disable-next-line new-cap\n const instance = new apiClass(this.getConfigFor(apiClass));\n this.loadedApis[apiClass.apiName] = instance;\n return instance;\n }\n\n /**\n * Update the Map of loaded APIs.\n * Note: Can be used to override the a specific API\n *\n * @param map Map of loaded APIs to update\n */\n public updateApiMapping(map: (Api | ApiClassType)[] | Record<string, (Api | ApiClassType)>) {\n const newItems: Record<string, (Api | ApiClassType)> = Array.isArray(map) ? map\n .reduce<Record<string, Api | ApiClassType<Api>>>((acc, curr) => {\n acc[curr.apiName] = curr;\n return acc;\n }, {}) : map;\n\n this.loadedApis = {\n ...this.loadedApis,\n ...Object.entries(newItems)\n .reduce<Record<string, Api>>((acc, [apiName, api]) => {\n // eslint-disable-next-line new-cap\n acc[apiName] = this.isApiClass(api) ? new api(this.getConfigFor(api)) : api;\n return acc;\n }, {})\n };\n }\n\n /**\n * Clear the cache of loaded APIs\n *\n * @param apis Whitelist of APIs to clear from the cache, if specified only these apis will be removed from the cache\n */\n public clearCache(apis?: ApiName[]) {\n if (apis) {\n apis.forEach((api) => delete this.loadedApis[api.apiName]);\n } else {\n this.loadedApis = {};\n }\n }\n\n /**\n * Retrieve the configuration for a specific API\n *\n * @param apiClass class of the API for which retrieving the configuration\n */\n public getConfigFor(apiClass: ApiName): ApiClient {\n return this.apiManager.getConfiguration(apiClass.apiName);\n }\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { ApiFactoryService } from './api-factory.service';\nimport { ApiManager } from './api-manager';\nimport { API_TOKEN } from './api-manager.token';\n\n// Module that needs to be imported by the application to instantiate an SDK configuration.\n@NgModule({\n providers: [\n ApiFactoryService\n ]\n})\nexport class ApiManagerModule {\n /**\n * Provide a custom apiManager\n * A factory can be provided via injection to the token API_TOKEN\n *\n * @param apiManager\n */\n public static forRoot(apiManager: ApiManager): ModuleWithProviders<ApiManagerModule> {\n return {\n ngModule: ApiManagerModule,\n providers: [\n { provide: API_TOKEN, useValue: apiManager }\n ]\n };\n }\n}\n","/**\n * Add a preconnect `<link>` element to the DOM\n *\n * @param baseUrl the origin href\n * @param supportCrossOrigin add crossorigin attribute to the link element\n */\nexport function appendPreconnect(baseUrl: string, supportCrossOrigin = true): void {\n const preConnectLink = document.createElement('link');\n preConnectLink.setAttribute('rel', 'preconnect');\n preConnectLink.setAttribute('href', baseUrl);\n if (supportCrossOrigin) {\n preConnectLink.setAttribute('crossorigin', '');\n }\n document.head.appendChild(preConnectLink);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;AAEA;;;;;AAKG;MACU,UAAU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AAhB,uBAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gBAAgB,EAJhB,SAAA,EAAA;YACT,iBAAiB;AAClB,SAAA,EAAA,CAAA,CAAA,EAAA;;2FAEU,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAL5B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,SAAS,EAAE;wBACT,iBAAiB;AAClB,qBAAA;AACF,iBAAA,CAAA;;;ACVD;;;;;AAKG;SACa,gBAAgB,CAAC,OAAe,EAAE,kBAAkB,GAAG,IAAI,EAAA;IACzE,MAAM,cAAc,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AACtD,IAAA,cAAc,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AACjD,IAAA,cAAc,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC7C,IAAA,IAAI,kBAAkB,EAAE;AACtB,QAAA,cAAc,CAAC,YAAY,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AAChD,KAAA;AACD,IAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;AAC5C;;ACdA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"o3r-apis-manager.mjs","sources":["../../src/apis-manager/api-manager.ts","../../src/apis-manager/api-manager.token.ts","../../src/apis-manager/api-factory.service.ts","../../src/apis-manager/api-manager.module.ts","../../src/apis-manager/api-manager.helpers.ts","../../src/o3r-apis-manager.ts"],"sourcesContent":["import type { ApiClient } from '@ama-sdk/core';\n\n/**\n * Api manager is responsible to provide an api configuration to a service factory, so that it could instantiate an API\n * with the right parameters. It contains a default configuration and a map of specific configurations for API / set of\n * API. Configurations are only exposed through the method getConfiguration, which will merge the default configuration\n * and the requested one.\n */\nexport class ApiManager {\n private defaultConfiguration: ApiClient;\n private apiConfigurations: { [key: string]: ApiClient };\n\n /**\n * Map of registered Api Client associated to specific API\n * @warning This should not be used to get the ApiClient for an API, the function getConfiguration() should be used instead\n */\n public get registeredApiConfigurations() {\n return {...this.apiConfigurations} as const;\n }\n\n /**\n * Create an API manager using a custom ApiClient\n * @param defaultConfiguration\n */\n constructor(defaultConfiguration: ApiClient, apiConfigurations: { [key: string]: ApiClient } = {}) {\n this.defaultConfiguration = defaultConfiguration;\n this.apiConfigurations = apiConfigurations;\n }\n\n /**\n * Retrieve a configuration for a specific API\n * @param api API to get the configuration for\n */\n public getConfiguration(api?: string): ApiClient {\n return api && this.apiConfigurations[api] || this.defaultConfiguration;\n }\n\n /**\n * Set or override API configuration\n * @param apiClient API configuration to override to the given api\n * @param api API name to override, the default configuration will be used if not specified\n */\n public setConfiguration(apiClient: ApiClient, api?: string): void {\n if (api) {\n this.apiConfigurations[api] = apiClient;\n } else {\n this.defaultConfiguration = apiClient;\n }\n }\n}\n","import { InjectionToken } from '@angular/core';\nimport { ApiManager } from './api-manager';\n\n/**\n * Token used by the core library to provide an Api manager to services. It can be provided in the app.\n */\nexport const API_TOKEN = new InjectionToken<ApiManager>('Custom API manager token');\n","import type { Api, ApiClient, ApiName } from '@ama-sdk/core';\nimport { Inject, Injectable, InjectionToken, Optional } from '@angular/core';\nimport { ApiManager } from './api-manager';\nimport { API_TOKEN } from './api-manager.token';\n\n/** Type of the Class of an SDK Api */\nexport type ApiClassType<T extends Api = Api> = (new (client: ApiClient) => T) & ApiName;\n\n/**\n * Initial APIs instantiations\n */\nexport const INITIAL_APIS_TOKEN = new InjectionToken<(Api | ApiClassType)[]>('Initial APIs token');\n\n@Injectable()\nexport class ApiFactoryService {\n\n /** Map of loaded APIs */\n private loadedApis: Record<string, Api> = {};\n\n constructor(@Inject(API_TOKEN) private readonly apiManager: ApiManager, @Optional() @Inject(INITIAL_APIS_TOKEN) apis?: (Api | ApiClassType)[]) {\n if (apis) {\n this.updateApiMapping(apis);\n }\n }\n\n /**\n * Determine if the given parameter is a API class\n * @param apiClass object to check\n */\n private isApiClass<T extends Api = Api>(apiClass: any): apiClass is ApiClassType<T> {\n return !!apiClass.apiName && typeof apiClass === 'function';\n }\n\n /**\n * Retrieve a specific API with loaded configuration\n * @param apiClass class of the API to retrieve\n * @param refreshCache Ignore cached API instance and refresh it\n */\n public getApi<T extends Api>(apiClass: (new (client: ApiClient) => T) & ApiName, refreshCache = false): T {\n const cache = this.loadedApis[apiClass.apiName];\n if (!refreshCache && cache) {\n return cache as T;\n }\n\n // eslint-disable-next-line new-cap\n const instance = new apiClass(this.getConfigFor(apiClass));\n this.loadedApis[apiClass.apiName] = instance;\n return instance;\n }\n\n /**\n * Update the Map of loaded APIs.\n * Note: Can be used to override the a specific API\n * @param map Map of loaded APIs to update\n */\n public updateApiMapping(map: (Api | ApiClassType)[] | Record<string, (Api | ApiClassType)>) {\n const newItems: Record<string, (Api | ApiClassType)> = Array.isArray(map) ? map\n .reduce<Record<string, Api | ApiClassType<Api>>>((acc, curr) => {\n acc[curr.apiName] = curr;\n return acc;\n }, {}) : map;\n\n this.loadedApis = {\n ...this.loadedApis,\n ...Object.entries(newItems)\n .reduce<Record<string, Api>>((acc, [apiName, api]) => {\n // eslint-disable-next-line new-cap\n acc[apiName] = this.isApiClass(api) ? new api(this.getConfigFor(api)) : api;\n return acc;\n }, {})\n };\n }\n\n /**\n * Clear the cache of loaded APIs\n * @param apis Whitelist of APIs to clear from the cache, if specified only these apis will be removed from the cache\n */\n public clearCache(apis?: ApiName[]) {\n if (apis) {\n apis.forEach((api) => delete this.loadedApis[api.apiName]);\n } else {\n this.loadedApis = {};\n }\n }\n\n /**\n * Retrieve the configuration for a specific API\n * @param apiClass class of the API for which retrieving the configuration\n */\n public getConfigFor(apiClass: ApiName): ApiClient {\n return this.apiManager.getConfiguration(apiClass.apiName);\n }\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { ApiFactoryService } from './api-factory.service';\nimport { ApiManager } from './api-manager';\nimport { API_TOKEN } from './api-manager.token';\n\n// Module that needs to be imported by the application to instantiate an SDK configuration.\n@NgModule({\n providers: [\n ApiFactoryService\n ]\n})\nexport class ApiManagerModule {\n /**\n * Provide a custom apiManager\n * A factory can be provided via injection to the token API_TOKEN\n * @param apiManager\n */\n public static forRoot(apiManager: ApiManager): ModuleWithProviders<ApiManagerModule> {\n return {\n ngModule: ApiManagerModule,\n providers: [\n { provide: API_TOKEN, useValue: apiManager }\n ]\n };\n }\n}\n","/**\n * Add a preconnect `<link>` element to the DOM\n * @param baseUrl the origin href\n * @param supportCrossOrigin add crossorigin attribute to the link element\n */\nexport function appendPreconnect(baseUrl: string, supportCrossOrigin = true): void {\n const preConnectLink = document.createElement('link');\n preConnectLink.setAttribute('rel', 'preconnect');\n preConnectLink.setAttribute('href', baseUrl);\n if (supportCrossOrigin) {\n preConnectLink.setAttribute('crossorigin', '');\n }\n document.head.appendChild(preConnectLink);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;AAEA;;;;;AAKG;MACU,UAAU,CAAA;AAIrB;;;AAGG;AACH,IAAA,IAAW,2BAA2B,GAAA;AACpC,QAAA,OAAO,EAAC,GAAG,IAAI,CAAC,iBAAiB,EAAU,CAAC;KAC7C;AAED;;;AAGG;IACH,WAAY,CAAA,oBAA+B,EAAE,iBAAA,GAAkD,EAAE,EAAA;AAC/F,QAAA,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;AACjD,QAAA,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;KAC5C;AAED;;;AAGG;AACI,IAAA,gBAAgB,CAAC,GAAY,EAAA;AAClC,QAAA,OAAO,GAAG,IAAI,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,oBAAoB,CAAC;KACxE;AAED;;;;AAIG;IACI,gBAAgB,CAAC,SAAoB,EAA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CAAC,CAAC;AACtD,IAAA,cAAc,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AACjD,IAAA,cAAc,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC7C,IAAA,IAAI,kBAAkB,EAAE;AACtB,QAAA,cAAc,CAAC,YAAY,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AAChD,KAAA;AACD,IAAA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;AAC5C;;ACbA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/apis-manager",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0-next.0",
|
|
4
4
|
"description": "This module provides services to help you communicate with your APIs. Its responsibility is to provide an API configuration to a service factory so that it could instantiate an API with the right configurations.\nIt contains a default configuration and a map of specific configurations for an API / a set of APIs.\nConfigurations are only exposed through the method `getConfiguration`, which will merge the default configuration and the requested one.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apis-manager",
|
|
@@ -8,15 +8,14 @@
|
|
|
8
8
|
"otter-module"
|
|
9
9
|
],
|
|
10
10
|
"peerDependencies": {
|
|
11
|
-
"@ama-sdk/core": "^
|
|
12
|
-
"@angular-devkit/schematics": "~
|
|
13
|
-
"@angular/common": "~
|
|
14
|
-
"@angular/core": "~
|
|
15
|
-
"@o3r/
|
|
16
|
-
"@
|
|
17
|
-
"@schematics/angular": "~16.2.0",
|
|
11
|
+
"@ama-sdk/core": "^11.0.0-next.0",
|
|
12
|
+
"@angular-devkit/schematics": "~17.0.0",
|
|
13
|
+
"@angular/common": "~17.0.2",
|
|
14
|
+
"@angular/core": "~17.0.2",
|
|
15
|
+
"@o3r/schematics": "^11.0.0-next.0",
|
|
16
|
+
"@schematics/angular": "~17.0.0",
|
|
18
17
|
"rxjs": "^7.8.1",
|
|
19
|
-
"typescript": "~5.
|
|
18
|
+
"typescript": "~5.2.2"
|
|
20
19
|
},
|
|
21
20
|
"peerDependenciesMeta": {
|
|
22
21
|
"@angular-devkit/schematics": {
|
|
@@ -34,7 +33,7 @@
|
|
|
34
33
|
},
|
|
35
34
|
"schematics": "./collection.json",
|
|
36
35
|
"engines": {
|
|
37
|
-
"node": ">=
|
|
36
|
+
"node": ">=18.0.0"
|
|
38
37
|
},
|
|
39
38
|
"module": "fesm2022/o3r-apis-manager.mjs",
|
|
40
39
|
"typings": "index.d.ts",
|
|
@@ -113,5 +112,6 @@
|
|
|
113
112
|
],
|
|
114
113
|
"bugs": "https://github.com/AmadeusITGroup/otter/issues",
|
|
115
114
|
"repository": "https://github.com/AmadeusITGroup/otter",
|
|
116
|
-
"license": "BSD-3-Clause"
|
|
115
|
+
"license": "BSD-3-Clause",
|
|
116
|
+
"homepage": "https://amadeusitgroup.github.io/otter/"
|
|
117
117
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/helpers/update-api-deps/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/helpers/update-api-deps/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAYjF;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAC,GAAG,IAAI,CA0GvF"}
|
|
@@ -3,13 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateApiDependencies = void 0;
|
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
5
|
const schematics_2 = require("@o3r/schematics");
|
|
6
|
-
const ts = require("typescript");
|
|
7
6
|
const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
|
|
7
|
+
const utility_1 = require("@schematics/angular/utility");
|
|
8
|
+
const ts = require("typescript");
|
|
8
9
|
/**
|
|
9
10
|
* Update app.module file with api manager, if needed
|
|
11
|
+
* @param options
|
|
12
|
+
* @param options.projectName
|
|
10
13
|
*/
|
|
11
14
|
function updateApiDependencies(options) {
|
|
12
15
|
const updateAppModule = (tree, context) => {
|
|
16
|
+
const additionalRules = [];
|
|
13
17
|
const moduleFilePath = (0, schematics_2.getAppModuleFilePath)(tree, context, options.projectName);
|
|
14
18
|
if (!moduleFilePath) {
|
|
15
19
|
return tree;
|
|
@@ -20,16 +24,15 @@ function updateApiDependencies(options) {
|
|
|
20
24
|
return tree;
|
|
21
25
|
}
|
|
22
26
|
const recorder = tree.beginUpdate(moduleFilePath);
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const addImportToModuleFile = (name, file) => (0, schematics_2.addImportToModuleFile)(name, file, sourceFile, sourceFileContent, context, recorder, moduleFilePath, moduleIndex);
|
|
27
|
+
const { moduleIndex } = (0, schematics_2.getModuleIndex)(sourceFile, sourceFileContent);
|
|
28
|
+
const addImportToModuleFile = (name, file, moduleFunction) => additionalRules.push((0, utility_1.addRootImport)(options.projectName, ({ code, external }) => code `${external(name, file)}${moduleFunction}`));
|
|
26
29
|
const insertImportToModuleFile = (name, file, isDefault) => (0, schematics_2.insertImportToModuleFile)(name, file, sourceFile, recorder, moduleFilePath, isDefault);
|
|
27
|
-
const addProviderToModuleFile = (name, file, customProvider) => (0,
|
|
30
|
+
const addProviderToModuleFile = (name, file, customProvider) => additionalRules.push((0, utility_1.addRootProvider)(options.projectName, ({ code, external }) => code `{provide: ${external(name, file)}, ${customProvider}}`));
|
|
28
31
|
const insertBeforeModule = (line) => (0, schematics_2.insertBeforeModule)(line, sourceFileContent, recorder, moduleIndex);
|
|
29
32
|
insertImportToModuleFile('appendPreconnect', '@o3r/apis-manager', false);
|
|
30
|
-
insertBeforeModule('appendPreconnect(\'https://YOUR_API_ENDPOINT\');');
|
|
31
|
-
addImportToModuleFile('ApiManagerModule', '@o3r/apis-manager');
|
|
32
33
|
insertBeforeModule('const PROXY_SERVER = \'https://YOUR_API_ENDPOINT\';');
|
|
34
|
+
insertBeforeModule('appendPreconnect(PROXY_SERVER);');
|
|
35
|
+
addImportToModuleFile('ApiManagerModule', '@o3r/apis-manager');
|
|
33
36
|
insertBeforeModule(`
|
|
34
37
|
export function apiManagerFactory(): ApiManager {
|
|
35
38
|
const apiClient = new ApiFetchClient({
|
|
@@ -39,16 +42,16 @@ export function apiManagerFactory(): ApiManager {
|
|
|
39
42
|
|
|
40
43
|
return new ApiManager(apiClient);
|
|
41
44
|
}`);
|
|
42
|
-
addProviderToModuleFile('API_TOKEN', '@o3r/apis-manager', '
|
|
45
|
+
addProviderToModuleFile('API_TOKEN', '@o3r/apis-manager', 'useFactory: apiManagerFactory');
|
|
43
46
|
insertImportToModuleFile('ApiManager', '@o3r/apis-manager', false);
|
|
44
47
|
insertImportToModuleFile('ApiFetchClient', '@ama-sdk/core', false);
|
|
45
48
|
insertImportToModuleFile('ApiKeyRequest', '@ama-sdk/core', false);
|
|
46
49
|
tree.commitUpdate(recorder);
|
|
47
50
|
context.logger.info('Please update by hand the placeholders for YOUR_API_ENDPOINT and YOUR_API_KEY!');
|
|
48
|
-
return tree;
|
|
51
|
+
return (0, schematics_1.chain)(additionalRules)(tree, context);
|
|
49
52
|
};
|
|
50
53
|
const updateTsConfig = (tree, context) => {
|
|
51
|
-
const workspaceProject = (0, schematics_2.
|
|
54
|
+
const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
|
|
52
55
|
const tsconfig = workspaceProject &&
|
|
53
56
|
workspaceProject.architect &&
|
|
54
57
|
workspaceProject.architect.build &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/helpers/update-api-deps/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRo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e,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/C,WAAW,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5C,WAAW,CAAC,eAAe,CAAC,GAAG,GAAG,WAAW,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAa,EAAE,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;QAE1J,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,IAAA,kBAAK,EAAC;QACX,cAAc;QACd,eAAe;KAChB,CAAC,CAAC;AACL,CAAC;AA1GD,sDA0GC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAA0B,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,IAAI,EAA0B,MAAM,4BAA4B,CAAC;AAGvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD;;;GAGG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAoC1D"}
|
|
@@ -2,21 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ngAdd = void 0;
|
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
-
const schematics_2 = require("@o3r/schematics");
|
|
6
5
|
const path = require("node:path");
|
|
7
6
|
/**
|
|
8
7
|
* Add Otter apis manager to an Angular Project
|
|
9
|
-
*
|
|
10
8
|
* @param options
|
|
11
9
|
*/
|
|
12
10
|
function ngAdd(options) {
|
|
13
11
|
return async (tree, context) => {
|
|
14
12
|
try {
|
|
15
|
-
const { ngAddPackages, getO3rPeerDeps, applyEsLintFix,
|
|
13
|
+
const { ngAddPackages, getO3rPeerDeps, applyEsLintFix, getWorkspaceConfig, getProjectNewDependenciesType } = await Promise.resolve().then(() => require('@o3r/schematics'));
|
|
16
14
|
const { updateApiDependencies } = await Promise.resolve().then(() => require('../helpers/update-api-deps'));
|
|
17
15
|
const depsInfo = getO3rPeerDeps(path.resolve(__dirname, '..', '..', 'package.json'));
|
|
18
16
|
const rulesToExecute = [];
|
|
19
|
-
const workspaceProject =
|
|
17
|
+
const workspaceProject = options.projectName ? getWorkspaceConfig(tree)?.projects[options.projectName] : undefined;
|
|
20
18
|
const workingDirectory = workspaceProject?.root;
|
|
21
19
|
const projectType = workspaceProject?.projectType || 'application';
|
|
22
20
|
if (projectType === 'application') {
|
|
@@ -30,7 +28,7 @@ function ngAdd(options) {
|
|
|
30
28
|
version: depsInfo.packageVersion,
|
|
31
29
|
parentPackageInfo: depsInfo.packageName,
|
|
32
30
|
projectName: options.projectName,
|
|
33
|
-
dependencyType: (
|
|
31
|
+
dependencyType: getProjectNewDependenciesType(workspaceProject),
|
|
34
32
|
workingDirectory
|
|
35
33
|
})
|
|
36
34
|
])(tree, context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":";;;AAAA,2DAAuF;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":";;;AAAA,2DAAuF;AAEvF,kCAAkC;AAGlC;;;GAGG;AACH,SA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