@rxap/open-api 12.4.0 → 13.0.0-next.10
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/data-source/package.json +5 -5
- package/data-source/table/package.json +5 -5
- package/esm2020/data-source/lib/error.mjs +8 -0
- package/esm2020/data-source/lib/open-api-data-source.loader.mjs +36 -0
- package/esm2020/data-source/lib/open-api.data-source.mjs +140 -0
- package/esm2020/data-source/public_api.mjs +6 -0
- package/esm2020/data-source/rxap-open-api-data-source.mjs +5 -0
- package/esm2020/data-source/table/lib/error.mjs +8 -0
- package/esm2020/data-source/table/lib/open-api-table.data-source.mjs +127 -0
- package/esm2020/data-source/table/lib/to-open-api-table-data-source.pipe.mjs +29 -0
- package/esm2020/data-source/table/lib/tokens.mjs +3 -0
- package/esm2020/data-source/table/public_api.mjs +5 -0
- package/esm2020/data-source/table/rxap-open-api-data-source-table.mjs +5 -0
- package/esm2020/index.mjs +7 -0
- package/esm2020/lib/error.mjs +7 -0
- package/esm2020/lib/open-api-config.service.mjs +160 -0
- package/esm2020/lib/open-api.mjs +2 -0
- package/esm2020/lib/schema-validation.mixin.mjs +256 -0
- package/esm2020/lib/tokens.mjs +8 -0
- package/esm2020/lib/utilities.mjs +16 -0
- package/esm2020/remote-method/lib/error.mjs +8 -0
- package/esm2020/remote-method/lib/open-api-remote-method.loader.mjs +37 -0
- package/esm2020/remote-method/lib/open-api.remote-method.mjs +145 -0
- package/esm2020/remote-method/public_api.mjs +4 -0
- package/esm2020/remote-method/rxap-open-api-remote-method.mjs +5 -0
- package/esm2020/rxap-open-api.mjs +5 -0
- package/fesm2015/rxap-open-api-data-source-table.mjs +172 -0
- package/fesm2015/rxap-open-api-data-source-table.mjs.map +1 -0
- package/{esm2015/data-source/lib/open-api.data-source.js → fesm2015/rxap-open-api-data-source.mjs} +96 -49
- package/fesm2015/rxap-open-api-data-source.mjs.map +1 -0
- package/fesm2015/rxap-open-api-remote-method.mjs +201 -0
- package/fesm2015/rxap-open-api-remote-method.mjs.map +1 -0
- package/fesm2015/{rxap-open-api.js → rxap-open-api.mjs} +55 -20
- package/fesm2015/rxap-open-api.mjs.map +1 -0
- package/{fesm2015/rxap-open-api-data-source-table.js → fesm2020/rxap-open-api-data-source-table.mjs} +18 -20
- package/fesm2020/rxap-open-api-data-source-table.mjs.map +1 -0
- package/{fesm2015/rxap-open-api-data-source.js → fesm2020/rxap-open-api-data-source.mjs} +17 -18
- package/fesm2020/rxap-open-api-data-source.mjs.map +1 -0
- package/{fesm2015/rxap-open-api-remote-method.js → fesm2020/rxap-open-api-remote-method.mjs} +50 -46
- package/fesm2020/rxap-open-api-remote-method.mjs.map +1 -0
- package/{esm2015/lib/schema-validation.mixin.js → fesm2020/rxap-open-api.mjs} +197 -8
- package/fesm2020/rxap-open-api.mjs.map +1 -0
- package/lib/open-api-config.service.d.ts +6 -4
- package/package.json +60 -22
- package/remote-method/lib/open-api.remote-method.d.ts +16 -1
- package/remote-method/package.json +5 -5
- package/src/schematics/open-api/coerce-open-api-project.js +4 -3
- package/src/schematics/open-api/coerce-open-api-project.js.map +1 -1
- package/src/schematics/open-api/create-directive.js +6 -7
- package/src/schematics/open-api/create-directive.js.map +1 -1
- package/src/schematics/open-api/generate-data-source.js +1 -1
- package/src/schematics/open-api/generate-remote-method.js +5 -2
- package/src/schematics/open-api/generate-remote-method.js.map +1 -1
- package/src/schematics/open-api/index.js +1 -1
- package/src/schematics/open-api/schema.json +6 -0
- package/bundles/rxap-open-api-data-source-table.umd.js +0 -534
- package/bundles/rxap-open-api-data-source-table.umd.js.map +0 -1
- package/bundles/rxap-open-api-data-source.umd.js +0 -548
- package/bundles/rxap-open-api-data-source.umd.js.map +0 -1
- package/bundles/rxap-open-api-remote-method.umd.js +0 -557
- package/bundles/rxap-open-api-remote-method.umd.js.map +0 -1
- package/bundles/rxap-open-api.umd.js +0 -868
- package/bundles/rxap-open-api.umd.js.map +0 -1
- package/esm2015/data-source/lib/error.js +0 -8
- package/esm2015/data-source/lib/error.js.map +0 -1
- package/esm2015/data-source/lib/open-api-data-source.loader.js +0 -36
- package/esm2015/data-source/lib/open-api-data-source.loader.js.map +0 -1
- package/esm2015/data-source/lib/open-api.data-source.js.map +0 -1
- package/esm2015/data-source/public_api.js +0 -6
- package/esm2015/data-source/public_api.js.map +0 -1
- package/esm2015/data-source/rxap-open-api-data-source.js +0 -5
- package/esm2015/data-source/rxap-open-api-data-source.js.map +0 -1
- package/esm2015/data-source/table/lib/error.js +0 -8
- package/esm2015/data-source/table/lib/error.js.map +0 -1
- package/esm2015/data-source/table/lib/open-api-table.data-source.js +0 -129
- package/esm2015/data-source/table/lib/open-api-table.data-source.js.map +0 -1
- package/esm2015/data-source/table/lib/to-open-api-table-data-source.pipe.js +0 -29
- package/esm2015/data-source/table/lib/to-open-api-table-data-source.pipe.js.map +0 -1
- package/esm2015/data-source/table/lib/tokens.js +0 -3
- package/esm2015/data-source/table/lib/tokens.js.map +0 -1
- package/esm2015/data-source/table/public_api.js +0 -5
- package/esm2015/data-source/table/public_api.js.map +0 -1
- package/esm2015/data-source/table/rxap-open-api-data-source-table.js +0 -5
- package/esm2015/data-source/table/rxap-open-api-data-source-table.js.map +0 -1
- package/esm2015/index.js +0 -7
- package/esm2015/index.js.map +0 -1
- package/esm2015/lib/error.js +0 -7
- package/esm2015/lib/error.js.map +0 -1
- package/esm2015/lib/open-api-config.service.js +0 -127
- package/esm2015/lib/open-api-config.service.js.map +0 -1
- package/esm2015/lib/open-api.js +0 -2
- package/esm2015/lib/open-api.js.map +0 -1
- package/esm2015/lib/schema-validation.mixin.js.map +0 -1
- package/esm2015/lib/tokens.js +0 -8
- package/esm2015/lib/tokens.js.map +0 -1
- package/esm2015/lib/utilities.js +0 -16
- package/esm2015/lib/utilities.js.map +0 -1
- package/esm2015/remote-method/lib/error.js +0 -8
- package/esm2015/remote-method/lib/error.js.map +0 -1
- package/esm2015/remote-method/lib/open-api-remote-method.loader.js +0 -37
- package/esm2015/remote-method/lib/open-api-remote-method.loader.js.map +0 -1
- package/esm2015/remote-method/lib/open-api.remote-method.js +0 -141
- package/esm2015/remote-method/lib/open-api.remote-method.js.map +0 -1
- package/esm2015/remote-method/public_api.js +0 -4
- package/esm2015/remote-method/public_api.js.map +0 -1
- package/esm2015/remote-method/rxap-open-api-remote-method.js +0 -5
- package/esm2015/remote-method/rxap-open-api-remote-method.js.map +0 -1
- package/esm2015/rxap-open-api.js +0 -5
- package/esm2015/rxap-open-api.js.map +0 -1
- package/fesm2015/rxap-open-api-data-source-table.js.map +0 -1
- package/fesm2015/rxap-open-api-data-source.js.map +0 -1
- package/fesm2015/rxap-open-api-remote-method.js.map +0 -1
- package/fesm2015/rxap-open-api.js.map +0 -1
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { Injectable, Inject, Optional } from '@angular/core';
|
|
3
|
-
import { RXAP_OPEN_API_CONFIG } from './tokens';
|
|
4
|
-
import { AssertOpenApiV3 } from './utilities';
|
|
5
|
-
import * as i0 from "@angular/core";
|
|
6
|
-
export class OpenApiConfigService {
|
|
7
|
-
constructor(config = null) {
|
|
8
|
-
this.defaultServerIndex = OpenApiConfigService.DefaultServerIndex;
|
|
9
|
-
config = config !== null && config !== void 0 ? config : OpenApiConfigService.Config;
|
|
10
|
-
if (!config) {
|
|
11
|
-
throw new Error('Could not load open api config');
|
|
12
|
-
}
|
|
13
|
-
this.config = config;
|
|
14
|
-
this._operations = OpenApiConfigService.LoadOperations(config);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Used to load the app open api config from a remote resource.
|
|
18
|
-
*
|
|
19
|
-
* Promise.all([ OpenApiDataSourceLoader.Load() ])
|
|
20
|
-
* .then(() => platformBrowserDynamic().bootstrapModule(AppModule))
|
|
21
|
-
* .catch(err => console.error(err))
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
static Load(openApiUrl = 'openapi.json') {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
if (!openApiUrl) {
|
|
27
|
-
throw new Error('The open api url is not defined!');
|
|
28
|
-
}
|
|
29
|
-
let config = null;
|
|
30
|
-
try {
|
|
31
|
-
const response = yield fetch(openApiUrl);
|
|
32
|
-
config = yield response.json();
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
console.debug(`Could not load the open api config from '${openApiUrl}'!`, error);
|
|
36
|
-
console.error(`Could not load the open api config from '${openApiUrl}'!`, error.message);
|
|
37
|
-
}
|
|
38
|
-
if (config) {
|
|
39
|
-
const expandedConfig = yield this.ExpandOpenApi(config);
|
|
40
|
-
AssertOpenApiV3(expandedConfig);
|
|
41
|
-
this.Config = expandedConfig;
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
this.Config = null;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
static GetOperation(operationId) {
|
|
49
|
-
if (!this.Config) {
|
|
50
|
-
throw new Error('Could not load open api config');
|
|
51
|
-
}
|
|
52
|
-
if (!this._operations) {
|
|
53
|
-
this._operations = this.LoadOperations(this.Config);
|
|
54
|
-
}
|
|
55
|
-
if (!this._operations.has(operationId)) {
|
|
56
|
-
throw new Error(`The operation '${operationId}' is not defined in the openapi-json`);
|
|
57
|
-
}
|
|
58
|
-
return this._operations.get(operationId);
|
|
59
|
-
}
|
|
60
|
-
static LoadOperations(config) {
|
|
61
|
-
const operations = new Map();
|
|
62
|
-
Object.entries(config.paths)
|
|
63
|
-
.filter((item) => item[0] !== undefined)
|
|
64
|
-
.filter(([_, methods]) => methods &&
|
|
65
|
-
Object.keys(methods).some((method) => ['get', 'put', 'post', 'delete', 'patch'].includes(method)))
|
|
66
|
-
.forEach(([path, methods]) => Object.entries(methods)
|
|
67
|
-
.filter((item) => item[0] !== undefined)
|
|
68
|
-
.forEach(([method, operation]) => {
|
|
69
|
-
if (!operation.operationId) {
|
|
70
|
-
throw new Error('The OpenApu OperationId is not defined');
|
|
71
|
-
}
|
|
72
|
-
if (operations.has(operation.operationId)) {
|
|
73
|
-
throw new Error(`The OpenApi Operation '${operation.operationId}' is already defined.`);
|
|
74
|
-
}
|
|
75
|
-
operations.set(operation.operationId, Object.assign(Object.assign({}, operation), { path: path, method: method.toUpperCase() }));
|
|
76
|
-
}));
|
|
77
|
-
return operations;
|
|
78
|
-
}
|
|
79
|
-
static GetBaseUrl(config, serverIndex = this.DefaultServerIndex) {
|
|
80
|
-
const server = config.servers ? config.servers[serverIndex] : null;
|
|
81
|
-
if (!server) {
|
|
82
|
-
console.debug(`Could not extract the server config with the index '${serverIndex}' from the open api config`, config);
|
|
83
|
-
throw new Error(`Could not extract the server config with the index '${serverIndex}' from the open api config`);
|
|
84
|
-
}
|
|
85
|
-
return server.url;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Replaces all $ref with the concrete definition
|
|
89
|
-
*
|
|
90
|
-
* @param config
|
|
91
|
-
* @private
|
|
92
|
-
*/
|
|
93
|
-
static ExpandOpenApi(config) {
|
|
94
|
-
return Promise.resolve(config);
|
|
95
|
-
}
|
|
96
|
-
getOperation(operationId) {
|
|
97
|
-
if (!this._operations.has(operationId)) {
|
|
98
|
-
console.debug(`The operation '${operationId}' is not defined in the openapi-json`, this.config);
|
|
99
|
-
throw new Error(`The operation '${operationId}' is not defined in the openapi-json`);
|
|
100
|
-
}
|
|
101
|
-
return this._operations.get(operationId);
|
|
102
|
-
}
|
|
103
|
-
getBaseUrl(serverIndex = this.defaultServerIndex) {
|
|
104
|
-
return OpenApiConfigService.GetBaseUrl(this.config, serverIndex);
|
|
105
|
-
}
|
|
106
|
-
insertServer(serverConfig, index = this.defaultServerIndex) {
|
|
107
|
-
if (!this.config.servers) {
|
|
108
|
-
this.config.servers = [];
|
|
109
|
-
}
|
|
110
|
-
this.config.servers.splice(index, 1, serverConfig);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
OpenApiConfigService.Config = null;
|
|
114
|
-
OpenApiConfigService.DefaultServerIndex = 0;
|
|
115
|
-
OpenApiConfigService._operations = null;
|
|
116
|
-
OpenApiConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: OpenApiConfigService, deps: [{ token: RXAP_OPEN_API_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
117
|
-
OpenApiConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: OpenApiConfigService, providedIn: 'root' });
|
|
118
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: OpenApiConfigService, decorators: [{
|
|
119
|
-
type: Injectable,
|
|
120
|
-
args: [{ providedIn: 'root' }]
|
|
121
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
122
|
-
type: Optional
|
|
123
|
-
}, {
|
|
124
|
-
type: Inject,
|
|
125
|
-
args: [RXAP_OPEN_API_CONFIG]
|
|
126
|
-
}] }]; } });
|
|
127
|
-
//# sourceMappingURL=open-api-config.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"open-api-config.service.js","sourceRoot":"","sources":["../../../../../libs/open-api/src/lib/open-api-config.service.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,MAAM,EACN,QAAQ,EACT,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAKhD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;;AAK9C,MAAM,OAAO,oBAAoB;IAgJ/B,YAGE,SAAoC,IAAI;QAPnC,uBAAkB,GAAW,oBAAoB,CAAC,kBAAkB,CAAC;QAS1E,MAAM,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,oBAAoB,CAAC,MAAM,CAAC;QAC/C,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,C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,CAAC,kBAAkB;QAEvC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACxB,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;SAC1B;QACD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;IACrD,CAAC;;AArLa,2BAAM,GAA8B,IAAI,CAAC;AAEzC,uCAAkB,GAAW,CAAC,CAAC;AAE9B,gCAAW,GAAwB,IAAI,CAAC;kHAL5C,oBAAoB,kBAkJrB,oBAAoB;sHAlJnB,oBAAoB,cADP,MAAM;4FACnB,oBAAoB;kBADhC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;0BAkJ7B,QAAQ;;0BACR,MAAM;2BAAC,oBAAoB","sourcesContent":["import {\n Injectable,\n Inject,\n Optional\n} from '@angular/core';\nimport { OperationObjectWithMetadata } from './open-api';\nimport { RXAP_OPEN_API_CONFIG } from './tokens';\nimport {\n OpenAPIV3,\n OpenAPI\n} from 'openapi-types';\nimport { AssertOpenApiV3 } from './utilities';\n\nexport type OperationMap = Map<string, OperationObjectWithMetadata>;\n\n@Injectable({ providedIn: 'root' })\nexport class OpenApiConfigService {\n public static Config: OpenAPIV3.Document | null = null;\n\n public static DefaultServerIndex: number = 0;\n\n private static _operations: OperationMap | null = null;\n\n /**\n * Used to load the app open api config from a remote resource.\n *\n * Promise.all([ OpenApiDataSourceLoader.Load() ])\n * .then(() => platformBrowserDynamic().bootstrapModule(AppModule))\n * .catch(err => console.error(err))\n *\n */\n public static async Load(openApiUrl: string = 'openapi.json'): Promise<void> {\n if (!openApiUrl) {\n throw new Error('The open api url is not defined!');\n }\n\n let config: OpenAPIV3.Document | null = null;\n try {\n const response = await fetch(openApiUrl);\n config = await response.json();\n } catch (error) {\n console.debug(\n `Could not load the open api config from '${openApiUrl}'!`,\n error\n );\n console.error(\n `Could not load the open api config from '${openApiUrl}'!`,\n error.message\n );\n }\n\n if (config) {\n const expandedConfig = await this.ExpandOpenApi(config);\n\n AssertOpenApiV3(expandedConfig);\n\n this.Config = expandedConfig;\n } else {\n this.Config = null;\n }\n }\n\n public static GetOperation(operationId: string): OperationObjectWithMetadata {\n if (!this.Config) {\n throw new Error('Could not load open api config');\n }\n\n if (!this._operations) {\n this._operations = this.LoadOperations(this.Config);\n }\n if (!this._operations!.has(operationId)) {\n throw new Error(\n `The operation '${operationId}' is not defined in the openapi-json`\n );\n }\n return this._operations!.get(operationId)!;\n }\n\n private static LoadOperations(config: OpenAPIV3.Document): OperationMap {\n const operations = new Map<string, OperationObjectWithMetadata>();\n\n Object.entries(config.paths)\n .filter(\n (item): item is [string, OpenAPIV3.PathItemObject] =>\n item[0] !== undefined\n )\n .filter(\n ([_, methods]: [string, OpenAPIV3.PathItemObject]) =>\n methods &&\n Object.keys(methods).some((method) =>\n ['get', 'put', 'post', 'delete', 'patch'].includes(method)\n )\n )\n .forEach(([path, methods]: [string, OpenAPIV3.PathItemObject]) =>\n Object.entries(methods)\n .filter(\n (item): item is [string, OpenAPIV3.OperationObject] =>\n item[0] !== undefined\n )\n .forEach(\n ([method, operation]: [string, OpenAPIV3.OperationObject]) => {\n if (!operation.operationId) {\n throw new Error('The OpenApu OperationId is not defined');\n }\n\n if (operations!.has(operation.operationId)) {\n throw new Error(\n `The OpenApi Operation '${operation.operationId}' is already defined.`\n );\n }\n\n operations!.set(operation.operationId, {\n ...operation,\n path: path,\n method: method.toUpperCase(),\n });\n }\n )\n );\n\n return operations;\n }\n\n private static GetBaseUrl(\n config: OpenAPIV3.Document,\n serverIndex: number = this.DefaultServerIndex\n ): string {\n const server = config.servers ? config.servers[serverIndex] : null;\n\n if (!server) {\n console.debug(\n `Could not extract the server config with the index '${serverIndex}' from the open api config`,\n config\n );\n throw new Error(\n `Could not extract the server config with the index '${serverIndex}' from the open api config`\n );\n }\n\n return server.url;\n }\n\n /**\n * Replaces all $ref with the concrete definition\n *\n * @param config\n * @private\n */\n private static ExpandOpenApi(\n config: OpenAPI.Document\n ): Promise<OpenAPI.Document> {\n return Promise.resolve(config);\n }\n\n public readonly config: OpenAPIV3.Document;\n\n public defaultServerIndex: number = OpenApiConfigService.DefaultServerIndex;\n\n private readonly _operations: OperationMap;\n\n constructor(\n @Optional()\n @Inject(RXAP_OPEN_API_CONFIG)\n config: OpenAPIV3.Document | null = null\n ) {\n config = config ?? OpenApiConfigService.Config;\n if (!config) {\n throw new Error('Could not load open api config');\n }\n this.config = config;\n this._operations = OpenApiConfigService.LoadOperations(config);\n }\n\n public getOperation(operationId: string): OperationObjectWithMetadata {\n if (!this._operations!.has(operationId)) {\n console.debug(\n `The operation '${operationId}' is not defined in the openapi-json`,\n this.config\n );\n throw new Error(\n `The operation '${operationId}' is not defined in the openapi-json`\n );\n }\n return this._operations!.get(operationId)!;\n }\n\n public getBaseUrl(serverIndex: number = this.defaultServerIndex): string {\n return OpenApiConfigService.GetBaseUrl(this.config, serverIndex);\n }\n\n public insertServer(\n serverConfig: OpenAPIV3.ServerObject,\n index: number = this.defaultServerIndex\n ): void {\n if (!this.config.servers) {\n this.config.servers = [];\n }\n this.config.servers.splice(index, 1, serverConfig);\n }\n}\n"]}
|
package/esm2015/lib/open-api.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"open-api.js","sourceRoot":"","sources":["../../../../../libs/open-api/src/lib/open-api.ts"],"names":[],"mappings":"","sourcesContent":["import { OpenAPIV3 } from 'openapi-types';\n\nexport interface OperationObjectWithMetadata extends OpenAPIV3.OperationObject {\n path: string;\n method: string;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-validation.mixin.js","sourceRoot":"","sources":["../../../../../libs/open-api/src/lib/schema-validation.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,aAAa,EACb,QAAQ,EACR,KAAK,EACN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAA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;YACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;YACzB,OAAO,KAAK,CAAC;SACd;QAED,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,uGAAuG,CAAC,CAAC;SAC1H;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;;AAjWa,4BAAM,GAAY,KAAK,CAAC","sourcesContent":["import {\n coerceArray,\n isPromiseLike,\n IsRecord,\n clone\n} from '@rxap/utilities';\nimport { isDevMode } from '@angular/core';\nimport * as Ajv from 'ajv-oai';\nimport {\n HttpParams,\n HttpHeaders\n} from '@angular/common/http';\nimport {\n NotContainsReferenceObjects,\n IsReferenceObject\n} from './utilities';\nimport { OperationObjectWithMetadata } from './open-api';\nimport { RxapOpenApiError } from './error';\nimport { OpenAPIV3 } from 'openapi-types';\nimport { HttpRemoteMethodParameter } from '@rxap/remote-method/http';\n\nexport interface SchemaValidationResponse<Data> {\n headers: Record<string, any>;\n status: number;\n body?: Data | null;\n data?: Data;\n}\n\nexport class SchemaValidationMixin<Response = any, Parameters extends Record<string, any> | void = any, RequestBody = any> {\n\n public static STRICT: boolean = false;\n\n protected disableSchemaValidation?: boolean\n\n /**\n * Validates the parameters against the schema specified in the operation object\n *\n * @param operation\n * @param parameters\n * @param strict\n * @protected\n */\n public validateParameters(operation: OperationObjectWithMetadata, parameters?: Parameters, strict: boolean = false): void {\n\n const operationParameters = coerceArray(operation.parameters);\n\n if (!NotContainsReferenceObjects<OpenAPIV3.ParameterObject>(operationParameters)) {\n throw new RxapOpenApiError('The operation parameters contains ReferenceObject!');\n }\n\n if (parameters === undefined) {\n // TODO : find concept to definition witch parameter should not be checked if required\n // header parameters are never required if changes the semantic release manager breaks\n const requiredParameters = operationParameters.filter(parameter => parameter.required && parameter.in !== 'header');\n if (requiredParameters.length) {\n if (isDevMode()) {\n console.debug('Some operation parameters are required!', requiredParameters.map(p => p.name));\n }\n this.validationError('Some operation parameters are required!', strict);\n }\n\n } else if (IsRecord(parameters)) {\n\n for (const parameter of operationParameters) {\n\n if (parameter.required) {\n // header parameters are never required if changes the semantic release manager breaks\n if (parameter.in !== 'header') {\n if (!parameters.hasOwnProperty(parameter.name)) {\n this.validationError(`The operation parameter '${parameter.name}' is required!`, strict);\n }\n }\n }\n\n\n if (parameter.schema) {\n if (parameters.hasOwnProperty(parameter.name)) {\n\n const value = parameters[ parameter.name ];\n\n if (!this.validate(parameter.schema, value)) {\n this.validationError(`The parameter '${parameter.name}' is not valid against the schema!`, strict, parameter.schema, value);\n }\n\n }\n }\n\n }\n\n } else {\n if (operationParameters.length === 0 || operationParameters.every(op => !op.required)) {\n if (isDevMode()) {\n console.warn(`The operation ${operation.operationId} does not expect any parameters. But a parameter is provided.`, parameters);\n }\n } else {\n throw new Error('The parameters object is not a record');\n }\n }\n\n }\n\n /**\n * Validates the http response against the schema specified in the operation object\n *\n * @param operation\n * @param response\n * @param strict\n * @protected\n */\n public validateResponse(operation: OperationObjectWithMetadata, response: SchemaValidationResponse<Response>, strict: boolean = false): void {\n\n // region only validate the response if the content type is undefined or application/json\n\n const contentType = response.headers.get('Content-Type');\n\n if (contentType && contentType !== 'application/json') {\n if (isDevMode()) {\n console.warn('Response validation is only supported for content type application/json');\n }\n return;\n }\n\n // endregion\n\n if (operation.responses) {\n\n const status = response.status;\n\n // region extract the response object based on the response status\n let responseObject: OpenAPIV3.ResponseObject | OpenAPIV3.ReferenceObject | undefined;\n\n if (operation.responses[status]) {\n responseObject = operation.responses[status];\n } else {\n // use the default response object if no matching was found.\n responseObject = operation.responses.default;\n }\n // endregion\n\n if (responseObject) {\n\n if (IsReferenceObject(responseObject)) {\n throw new RxapOpenApiError('Found a reference object. The operation config is not expand!');\n }\n\n // region validate the response against the schema if defined\n\n // TODO : create schema that validates all parameters at once\n\n if (responseObject.content && responseObject.content['application/json'] && responseObject.content['application/json'].schema) {\n\n const schema = responseObject.content['application/json'].schema;\n\n const data = response.body ?? response.data;\n\n if (!this.validate(schema, data)) {\n this.validationError('The response is not valid ageist the operation schema!', strict, schema, data);\n }\n\n }\n\n // endregion\n\n }\n\n\n }\n\n }\n\n public validateRequestBody(operation: OperationObjectWithMetadata, body?: RequestBody, strict: boolean = false): void {\n\n // only validate body if type of object\n if (typeof body !== 'object') {\n return;\n }\n\n if (operation.requestBody) {\n\n if (IsReferenceObject(operation.requestBody)) {\n throw new RxapOpenApiError('Found a reference object. The operation config is not expand!');\n }\n\n if (body === undefined && operation.requestBody.required) {\n this.validationError('The request body is required!', strict);\n }\n\n if (operation.requestBody.content && operation.requestBody.content['application/json']) {\n\n const schema = operation.requestBody.content['application/json'].schema;\n\n if (schema) {\n if (!this.validate(schema, body)) {\n this.validationError('The request body is not valid!', strict, schema, body);\n }\n }\n\n }\n\n }\n\n }\n\n public validationError(message: string, strict: boolean, schema?: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject, value?: any) {\n if (isDevMode() && schema !== undefined) {\n // tslint:disable-next-line:no-console\n console.debug(message, { schema, value });\n }\n if (strict || SchemaValidationMixin.STRICT) {\n throw new RxapOpenApiError(message, '', 'SchemaValidationMixin');\n } else {\n console.warn(message);\n }\n }\n\n public buildHttpParams(operationParameters: OpenAPIV3.ParameterObject[], parameters?: Parameters, ignoreUndefined = true): HttpParams {\n\n let params = new HttpParams();\n\n if (IsRecord(parameters)) {\n\n for (const parameter of operationParameters.filter(p => p.in === 'query')) {\n const parameterName = parameter.name;\n\n if (parameters.hasOwnProperty(parameter.name)) {\n\n const value = parameters[ parameter.name ];\n\n if (value === undefined && ignoreUndefined) {\n continue;\n }\n\n if (Array.isArray(value)) {\n\n if (value.length) {\n\n const first = value.shift();\n\n params = params.set(parameterName, first);\n\n for (const item of value) {\n params = params.append(parameterName, item);\n }\n\n }\n\n } else {\n params = params.set(parameter.name, value);\n }\n\n }\n\n }\n\n }\n\n return params;\n\n }\n\n public buildHttpHeaders(operationParameters: OpenAPIV3.ParameterObject[], parameters?: Parameters): HttpHeaders {\n\n let headers = new HttpHeaders();\n\n if (IsRecord(parameters)) {\n\n for (const parameter of operationParameters.filter(p => p.in === 'header')) {\n\n if (parameters.hasOwnProperty(parameter.name)) {\n\n const value = parameters[ parameter.name ];\n\n if (Array.isArray(value)) {\n\n if (value.length) {\n\n const first = value.shift();\n\n headers = headers.set(parameters.name, first);\n\n for (const item of value) {\n headers = headers.append(parameters.name, item);\n }\n\n }\n\n } else {\n headers = headers.set(parameter.name, value);\n }\n\n }\n\n }\n\n }\n\n return headers;\n\n }\n\n public buildHttpPathParams(operationParameters: OpenAPIV3.ParameterObject[], parameters?: Parameters): Record<string, string> {\n\n const pathParams: Record<string, any> = {};\n\n if (IsRecord(parameters)) {\n\n for (const parameter of operationParameters.filter(p => p.in === 'path')) {\n\n if (parameters.hasOwnProperty(parameter.name)) {\n pathParams[ parameter.name ] = encodeURIComponent(parameters[ parameter.name ]);\n }\n\n }\n\n }\n\n return pathParams;\n\n }\n\n /**\n * Converts open api parameters into the corresponding http options to\n * create a http request. The transformation is guided by the openapi definition\n *\n * @param operation\n * @param parameters\n * @param requestBody\n * @param ignoreUndefined\n */\n public buildHttpOptions(operation: OperationObjectWithMetadata, parameters?: Parameters, requestBody?: RequestBody, ignoreUndefined = true): HttpRemoteMethodParameter {\n\n const options: HttpRemoteMethodParameter = {};\n\n const operationParameters = coerceArray(operation.parameters);\n\n if (!NotContainsReferenceObjects<OpenAPIV3.ParameterObject>(operationParameters)) {\n throw new RxapOpenApiError('The operation parameters contains ReferenceObject!');\n }\n\n const params = this.buildHttpParams(operationParameters, parameters, ignoreUndefined);\n const headers = this.buildHttpHeaders(operationParameters, parameters);\n const pathParams: Record<string, any> = this.buildHttpPathParams(operationParameters, parameters);\n\n if (params.keys().length) {\n options.params = params;\n }\n\n if (headers.keys().length) {\n options.headers = headers;\n }\n\n if (Object.keys(pathParams).length) {\n options.pathParams = pathParams;\n }\n\n if (requestBody !== undefined) {\n options.body = requestBody;\n }\n\n return options;\n\n }\n\n private validate(schema: string | boolean | object, value: any): boolean {\n\n if (this.disableSchemaValidation) {\n return true;\n }\n\n let result: boolean | PromiseLike<any>;\n\n try {\n result = new Ajv().validate(schema, clone(value));\n } catch (e) {\n console.error(e.message);\n return false;\n }\n\n if (isPromiseLike(result)) {\n throw new Error('Async schema validation is not yet supported. Ensure the all refs in the openapi schema are internal!');\n }\n\n return result;\n }\n\n}\n"]}
|
package/esm2015/lib/tokens.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
export const RXAP_OPEN_API_CONFIG = new InjectionToken('rxap/open-api/config');
|
|
3
|
-
export const RXAP_OPEN_API_STRICT_VALIDATOR = new InjectionToken('rxap/open-api/strict-validator');
|
|
4
|
-
export const DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA = new InjectionToken('rxap/open-api/default-remote-method-meta-data');
|
|
5
|
-
export const DEFAULT_OPEN_API_DATA_SOURCE_META_DATA = new InjectionToken('rxap/open-api/default-data-source-meta-data');
|
|
6
|
-
export const DISABLE_SCHEMA_VALIDATION = new InjectionToken('rxap/open-api/disable-schema-validation');
|
|
7
|
-
export const DISABLE_VALIDATION = new InjectionToken('rxap/open-api/disable-validation');
|
|
8
|
-
//# sourceMappingURL=tokens.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../../../libs/open-api/src/lib/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,CAAC,MAAM,oBAAoB,GAAuB,IAAI,cAAc,CAAC,sBAAsB,CAAC,CAAC;AACnG,MAAM,CAAC,MAAM,8BAA8B,GAAa,IAAI,cAAc,CAAC,gCAAgC,CAAC,CAAC;AAC7G,MAAM,CAAC,MAAM,wCAAwC,GAAG,IAAI,cAAc,CAAC,+CAA+C,CAAC,CAAC;AAC5H,MAAM,CAAC,MAAM,sCAAsC,GAAK,IAAI,cAAc,CAAC,6CAA6C,CAAC,CAAC;AAC1H,MAAM,CAAC,MAAM,yBAAyB,GAAkB,IAAI,cAAc,CAAU,yCAAyC,CAAC,CAAC;AAC/H,MAAM,CAAC,MAAM,kBAAkB,GAAkB,IAAI,cAAc,CAAU,kCAAkC,CAAC,CAAC","sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const RXAP_OPEN_API_CONFIG = new InjectionToken('rxap/open-api/config');\nexport const RXAP_OPEN_API_STRICT_VALIDATOR = new InjectionToken('rxap/open-api/strict-validator');\nexport const DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA = new InjectionToken('rxap/open-api/default-remote-method-meta-data');\nexport const DEFAULT_OPEN_API_DATA_SOURCE_META_DATA = new InjectionToken('rxap/open-api/default-data-source-meta-data');\nexport const DISABLE_SCHEMA_VALIDATION = new InjectionToken<boolean>('rxap/open-api/disable-schema-validation');\nexport const DISABLE_VALIDATION = new InjectionToken<boolean>('rxap/open-api/disable-validation');\n"]}
|
package/esm2015/lib/utilities.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { RxapOpenApiError } from './error';
|
|
2
|
-
export function IsReferenceObject(obj) {
|
|
3
|
-
return !!obj && obj.hasOwnProperty('$ref');
|
|
4
|
-
}
|
|
5
|
-
export function NotContainsReferenceObjects(array) {
|
|
6
|
-
return !!array && array.every(item => !IsReferenceObject(item) && !!item);
|
|
7
|
-
}
|
|
8
|
-
export function IsOpenApiV3(obj) {
|
|
9
|
-
return !!obj && obj.hasOwnProperty('openapi') && obj.openapi.match(/^3\./);
|
|
10
|
-
}
|
|
11
|
-
export function AssertOpenApiV3(obj) {
|
|
12
|
-
if (!IsOpenApiV3(obj)) {
|
|
13
|
-
throw new RxapOpenApiError('Only openapi version 3.x.x is supported');
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=utilities.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../../../libs/open-api/src/lib/utilities.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,UAAU,iBAAiB,CAAC,GAAS;IACzC,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAI,KAAwD;IACrG,OAAO,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAS;IACnC,OAAO,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAS;IAEvC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;QACrB,MAAM,IAAI,gBAAgB,CAAC,yCAAyC,CAAC,CAAC;KACvE;AAEH,CAAC","sourcesContent":["import { OpenAPIV3 } from 'openapi-types';\nimport { RxapOpenApiError } from './error';\n\nexport function IsReferenceObject(obj?: any): obj is OpenAPIV3.ReferenceObject {\n return !!obj && obj.hasOwnProperty('$ref');\n}\n\nexport function NotContainsReferenceObjects<T>(array?: Array<OpenAPIV3.ReferenceObject | T | undefined>): array is T[] {\n return !!array && array.every(item => !IsReferenceObject(item) && !!item);\n}\n\nexport function IsOpenApiV3(obj?: any): obj is OpenAPIV3.Document {\n return !!obj && obj.hasOwnProperty('openapi') && obj.openapi.match(/^3\\./);\n}\n\nexport function AssertOpenApiV3(obj?: any): asserts obj is OpenAPIV3.Document {\n\n if (!IsOpenApiV3(obj)) {\n throw new RxapOpenApiError('Only openapi version 3.x.x is supported');\n }\n\n}\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { RxapOpenApiError } from '@rxap/open-api';
|
|
2
|
-
export class RxapOpenApiRemoteMethodError extends RxapOpenApiError {
|
|
3
|
-
constructor(message, code, scope) {
|
|
4
|
-
super(message, code, scope);
|
|
5
|
-
this.addSubPackageName('remote-method');
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=error.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../../../libs/open-api/remote-method/src/lib/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,OAAO,4BAA6B,SAAQ,gBAAgB;IAEhE,YAAY,OAAe,EAAE,IAAa,EAAE,KAAc;QACxD,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;IAC1C,CAAC;CAEF","sourcesContent":["import { RxapOpenApiError } from '@rxap/open-api';\n\nexport class RxapOpenApiRemoteMethodError extends RxapOpenApiError {\n\n constructor(message: string, code?: string, scope?: string) {\n super(message, code, scope);\n this.addSubPackageName('remote-method');\n }\n\n}\n"]}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Injectable, Injector, Inject } from '@angular/core';
|
|
2
|
-
import { HttpClient } from '@angular/common/http';
|
|
3
|
-
import { OpenApiRemoteMethod } from './open-api.remote-method';
|
|
4
|
-
import { OpenApiConfigService } from '@rxap/open-api';
|
|
5
|
-
import * as i0 from "@angular/core";
|
|
6
|
-
import * as i1 from "@rxap/open-api";
|
|
7
|
-
import * as i2 from "@angular/common/http";
|
|
8
|
-
export class OpenApiRemoteMethodLoader {
|
|
9
|
-
constructor(openApiConfig, http, injector) {
|
|
10
|
-
this.openApiConfig = openApiConfig;
|
|
11
|
-
this.http = http;
|
|
12
|
-
this.injector = injector;
|
|
13
|
-
}
|
|
14
|
-
load(definitionId) {
|
|
15
|
-
const operation = this.openApiConfig.getOperation(definitionId);
|
|
16
|
-
if (operation) {
|
|
17
|
-
return new OpenApiRemoteMethod(this.http, this.injector, this.openApiConfig, {
|
|
18
|
-
id: definitionId,
|
|
19
|
-
operation
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
OpenApiRemoteMethodLoader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: OpenApiRemoteMethodLoader, deps: [{ token: OpenApiConfigService }, { token: HttpClient }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
26
|
-
OpenApiRemoteMethodLoader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: OpenApiRemoteMethodLoader, providedIn: 'root' });
|
|
27
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: OpenApiRemoteMethodLoader, decorators: [{
|
|
28
|
-
type: Injectable,
|
|
29
|
-
args: [{ providedIn: 'root' }]
|
|
30
|
-
}], ctorParameters: function () { return [{ type: i1.OpenApiConfigService, decorators: [{
|
|
31
|
-
type: Inject,
|
|
32
|
-
args: [OpenApiConfigService]
|
|
33
|
-
}] }, { type: i2.HttpClient, decorators: [{
|
|
34
|
-
type: Inject,
|
|
35
|
-
args: [HttpClient]
|
|
36
|
-
}] }, { type: i0.Injector }]; } });
|
|
37
|
-
//# sourceMappingURL=open-api-remote-method.loader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"open-api-remote-method.loader.js","sourceRoot":"","sources":["../../../../../../libs/open-api/remote-method/src/lib/open-api-remote-method.loader.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,MAAM,EACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;;;;AAGtD,MAAM,OAAO,yBAAyB;IAEpC,YACgD,aAAmC,EAC7C,IAAgB,EACpC,QAAkB;QAFY,kBAAa,GAAb,aAAa,CAAsB;QAC7C,SAAI,GAAJ,IAAI,CAAY;QACpC,aAAQ,GAAR,QAAQ,CAAU;IACjC,CAAC;IAEG,IAAI,CAAC,YAAoB;QAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QAEhE,IAAI,SAAS,EAAE;YAEb,OAAO,IAAI,mBAAmB,CAC5B,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,aAAa,EAClB;gBACE,EAAE,EAAE,YAAY;gBAChB,SAAS;aACV,CACF,CAAC;SAEH;QAED,OAAO,IAAI,CAAC;IAEd,CAAC;;uHA3BU,yBAAyB,kBAG1B,oBAAoB,aACpB,UAAU;2HAJT,yBAAyB,cADZ,MAAM;4FACnB,yBAAyB;kBADrC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;0BAI7B,MAAM;2BAAC,oBAAoB;;0BAC3B,MAAM;2BAAC,UAAU","sourcesContent":["import {\n Injectable,\n Injector,\n Inject\n} from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { OpenApiRemoteMethod } from './open-api.remote-method';\nimport { OpenApiConfigService } from '@rxap/open-api';\n\n@Injectable({ providedIn: 'root' })\nexport class OpenApiRemoteMethodLoader {\n\n constructor(\n @Inject(OpenApiConfigService) public readonly openApiConfig: OpenApiConfigService,\n @Inject(HttpClient) public readonly http: HttpClient,\n public readonly injector: Injector\n ) {}\n\n public load(definitionId: string): OpenApiRemoteMethod | null {\n const operation = this.openApiConfig.getOperation(definitionId);\n\n if (operation) {\n\n return new OpenApiRemoteMethod(\n this.http,\n this.injector,\n this.openApiConfig,\n {\n id: definitionId,\n operation\n }\n );\n\n }\n\n return null;\n\n }\n\n}\n"]}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { __awaiter, __decorate, __metadata } from "tslib";
|
|
2
|
-
import { Inject, Injector, Optional, Injectable } from '@angular/core';
|
|
3
|
-
import { HttpClient, HttpEventType } from '@angular/common/http';
|
|
4
|
-
import { OpenApiConfigService, SchemaValidationMixin, RXAP_OPEN_API_STRICT_VALIDATOR, DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA, DISABLE_SCHEMA_VALIDATION, DISABLE_VALIDATION } from '@rxap/open-api';
|
|
5
|
-
import { BaseHttpRemoteMethod } from '@rxap/remote-method/http';
|
|
6
|
-
import { RxapRemoteMethod } from '@rxap/remote-method';
|
|
7
|
-
import { joinPath } from '@rxap/utilities';
|
|
8
|
-
import { filter, timeout, retry, catchError, tap, take } from 'rxjs/operators';
|
|
9
|
-
import { throwError } from 'rxjs';
|
|
10
|
-
import { Mixin } from '@rxap/mixin';
|
|
11
|
-
import * as i0 from "@angular/core";
|
|
12
|
-
import * as i1 from "@angular/common/http";
|
|
13
|
-
import * as i2 from "@rxap/open-api";
|
|
14
|
-
export function RxapOpenApiRemoteMethod(operationId, serverIndex = 0) {
|
|
15
|
-
return function (target) {
|
|
16
|
-
RxapRemoteMethod({ id: operationId, serverIndex })(target);
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
let OpenApiRemoteMethod = class OpenApiRemoteMethod extends BaseHttpRemoteMethod {
|
|
20
|
-
constructor(http, injector, openApiConfigService, metadata = null, strict = null, disableSchemaValidation = null, disableValidation = null) {
|
|
21
|
-
var _a, _b;
|
|
22
|
-
super(http, injector, metadata);
|
|
23
|
-
this.strict = false;
|
|
24
|
-
this.disableSchemaValidation = false;
|
|
25
|
-
this.disableValidation = false;
|
|
26
|
-
let operation;
|
|
27
|
-
if (!this.metadata.operation) {
|
|
28
|
-
this.metadata.operation = operation = openApiConfigService.getOperation(this.metadata.id);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
operation = this.metadata.operation;
|
|
32
|
-
}
|
|
33
|
-
this.applyMetadata({
|
|
34
|
-
id: operation.operationId,
|
|
35
|
-
url: () => joinPath(openApiConfigService.getBaseUrl(this.metadata.serverIndex), operation.path),
|
|
36
|
-
method: operation.method,
|
|
37
|
-
withCredentials: (_a = this.metadata.withCredentials) !== null && _a !== void 0 ? _a : true,
|
|
38
|
-
ignoreUndefined: (_b = this.metadata.ignoreUndefined) !== null && _b !== void 0 ? _b : true,
|
|
39
|
-
});
|
|
40
|
-
this.strict = strict || this.metadata.strict || false;
|
|
41
|
-
this.disableSchemaValidation = disableSchemaValidation || this.metadata.disableSchemaValidation || false;
|
|
42
|
-
this.disableValidation = disableValidation || this.metadata.disableValidation || false;
|
|
43
|
-
}
|
|
44
|
-
get operation() {
|
|
45
|
-
return this.metadata.operation;
|
|
46
|
-
}
|
|
47
|
-
_call(args = {}) {
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
if (!this.disableValidation) {
|
|
50
|
-
this.validateParameters(this.operation, args.parameters, this.strict);
|
|
51
|
-
this.validateRequestBody(this.operation, args.requestBody, this.strict);
|
|
52
|
-
}
|
|
53
|
-
const response = yield this._callWithResponse(args);
|
|
54
|
-
if (response.body) {
|
|
55
|
-
return response.body;
|
|
56
|
-
}
|
|
57
|
-
console.warn('The response body is empty!');
|
|
58
|
-
return null;
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Instead of returning the response body the full response object is returned
|
|
63
|
-
*/
|
|
64
|
-
callWithResponse(args = {}) {
|
|
65
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
this.init();
|
|
67
|
-
this.executionsInProgress$.increase();
|
|
68
|
-
const result = yield this._callWithResponse(args);
|
|
69
|
-
this.executionsInProgress$.decrease();
|
|
70
|
-
if (result.body) {
|
|
71
|
-
this.executed$.next(result.body);
|
|
72
|
-
this.executed(result.body);
|
|
73
|
-
}
|
|
74
|
-
return result;
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
// TODO : update to the new call method concept (the remove of the _call method concept)
|
|
78
|
-
_callWithResponse(args = {}) {
|
|
79
|
-
var _a;
|
|
80
|
-
if (!this.disableValidation) {
|
|
81
|
-
this.validateParameters(this.operation, args.parameters, this.strict);
|
|
82
|
-
this.validateRequestBody(this.operation, args.requestBody, this.strict);
|
|
83
|
-
}
|
|
84
|
-
return this.http.request(this.updateRequest(this.buildHttpOptions(this.operation, args.parameters, args.requestBody, this.metadata.ignoreUndefined))).pipe(retry((_a = this.metadata.retry) !== null && _a !== void 0 ? _a : 0), catchError((response) => {
|
|
85
|
-
var _a;
|
|
86
|
-
(_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.forEach(interceptor => interceptor
|
|
87
|
-
.next({ response, parameters: args.parameters, requestBody: args.requestBody }));
|
|
88
|
-
return throwError(response);
|
|
89
|
-
}), filter((event) => event.type === HttpEventType.Response), tap((response) => {
|
|
90
|
-
if (this.disableValidation) {
|
|
91
|
-
this.validateResponse(this.operation, response, this.strict);
|
|
92
|
-
}
|
|
93
|
-
}), tap((response) => {
|
|
94
|
-
var _a;
|
|
95
|
-
(_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.forEach(interceptor => interceptor
|
|
96
|
-
.next({ response, parameters: args.parameters, requestBody: args.requestBody }));
|
|
97
|
-
}), take(1), timeout(this.timeout)).toPromise();
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
OpenApiRemoteMethod.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: OpenApiRemoteMethod, deps: [{ token: HttpClient }, { token: Injector }, { token: OpenApiConfigService }, { token: DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA, optional: true }, { token: RXAP_OPEN_API_STRICT_VALIDATOR, optional: true }, { token: DISABLE_SCHEMA_VALIDATION, optional: true }, { token: DISABLE_VALIDATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
101
|
-
OpenApiRemoteMethod.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: OpenApiRemoteMethod });
|
|
102
|
-
OpenApiRemoteMethod = __decorate([
|
|
103
|
-
Mixin(SchemaValidationMixin),
|
|
104
|
-
__metadata("design:paramtypes", [HttpClient,
|
|
105
|
-
Injector,
|
|
106
|
-
OpenApiConfigService, Object, Object, Object, Object])
|
|
107
|
-
], OpenApiRemoteMethod);
|
|
108
|
-
export { OpenApiRemoteMethod };
|
|
109
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: OpenApiRemoteMethod, decorators: [{
|
|
110
|
-
type: Injectable
|
|
111
|
-
}], ctorParameters: function () { return [{ type: i1.HttpClient, decorators: [{
|
|
112
|
-
type: Inject,
|
|
113
|
-
args: [HttpClient]
|
|
114
|
-
}] }, { type: i0.Injector, decorators: [{
|
|
115
|
-
type: Inject,
|
|
116
|
-
args: [Injector]
|
|
117
|
-
}] }, { type: i2.OpenApiConfigService, decorators: [{
|
|
118
|
-
type: Inject,
|
|
119
|
-
args: [OpenApiConfigService]
|
|
120
|
-
}] }, { type: undefined, decorators: [{
|
|
121
|
-
type: Optional
|
|
122
|
-
}, {
|
|
123
|
-
type: Inject,
|
|
124
|
-
args: [DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA]
|
|
125
|
-
}] }, { type: undefined, decorators: [{
|
|
126
|
-
type: Optional
|
|
127
|
-
}, {
|
|
128
|
-
type: Inject,
|
|
129
|
-
args: [RXAP_OPEN_API_STRICT_VALIDATOR]
|
|
130
|
-
}] }, { type: undefined, decorators: [{
|
|
131
|
-
type: Optional
|
|
132
|
-
}, {
|
|
133
|
-
type: Inject,
|
|
134
|
-
args: [DISABLE_SCHEMA_VALIDATION]
|
|
135
|
-
}] }, { type: undefined, decorators: [{
|
|
136
|
-
type: Optional
|
|
137
|
-
}, {
|
|
138
|
-
type: Inject,
|
|
139
|
-
args: [DISABLE_VALIDATION]
|
|
140
|
-
}] }]; } });
|
|
141
|
-
//# sourceMappingURL=open-api.remote-method.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"open-api.remote-method.js","sourceRoot":"","sources":["../../../../../../libs/open-api/remote-method/src/lib/open-api.remote-method.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,UAAU,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,UAAU,EAEV,aAAa,EAEd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,oBAAoB,EACpB,qBAAqB,EACrB,8BAA8B,EAC9B,wCAAwC,EACxC,yBAAyB,EACzB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAEL,gBAAgB,EACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EACL,MAAM,EACN,OAAO,EACP,KAAK,EACL,UAAU,EACV,GAAG,EACH,IAAI,EACL,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;;;;AAEpC,MAAM,UAAU,uBAAuB,CAAC,WAAmB,EAAE,cAAsB,CAAC;IAClF,OAAO,UAAS,MAAW;QACzB,gBAAgB,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC;IAwBY,mBAAmB,SAAnB,mBACX,SAAQ,oBA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;YACvC,MAAA,IAAI,CAAC,YAAY,0CAAE,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,WAAW;iBAClD,IAAI,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAChF,CAAC;QACJ,CAAC,CAAC,EACF,IAAI,CAAC,CAAC,CAAC,EACP,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CACtB,CAAC,SAAS,EAAE,CAAC;IAEhB,CAAC;CAEF,CAAA;iHAhHY,mBAAmB,kBAYpB,UAAU,aACV,QAAQ,aACR,oBAAoB,aAEpB,wCAAwC,6BAGxC,8BAA8B,6BAG9B,yBAAyB,6BAGzB,kBAAkB;qHAzBjB,mBAAmB;AAAnB,mBAAmB;IAF/B,KAAK,CAAC,qBAAqB,CAAC;qCAcC,UAAU;QACR,QAAQ;QACgB,oBAAoB;GAd/D,mBAAmB,CAgH/B;SAhHY,mBAAmB;4FAAnB,mBAAmB;kBAD/B,UAAU;;0BAaN,MAAM;2BAAC,UAAU;;0BACjB,MAAM;2BAAC,QAAQ;;0BACf,MAAM;2BAAC,oBAAoB;;0BAC3B,QAAQ;;0BACR,MAAM;2BAAC,wCAAwC;;0BAE/C,QAAQ;;0BACR,MAAM;2BAAC,8BAA8B;;0BAErC,QAAQ;;0BACR,MAAM;2BAAC,yBAAyB;;0BAEhC,QAAQ;;0BACR,MAAM;2BAAC,kBAAkB","sourcesContent":["import {\n Inject,\n Injector,\n Optional,\n Injectable\n} from '@angular/core';\nimport {\n HttpClient,\n HttpResponse,\n HttpEventType,\n HttpErrorResponse\n} from '@angular/common/http';\nimport {\n OperationObjectWithMetadata,\n OpenApiConfigService,\n SchemaValidationMixin,\n RXAP_OPEN_API_STRICT_VALIDATOR,\n DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA,\n DISABLE_SCHEMA_VALIDATION,\n DISABLE_VALIDATION\n} from '@rxap/open-api';\nimport { BaseHttpRemoteMethod } from '@rxap/remote-method/http';\nimport {\n BaseRemoteMethodMetadata,\n RxapRemoteMethod\n} from '@rxap/remote-method';\nimport { joinPath } from '@rxap/utilities';\nimport {\n filter,\n timeout,\n retry,\n catchError,\n tap,\n take\n} from 'rxjs/operators';\nimport { throwError } from 'rxjs';\nimport { Mixin } from '@rxap/mixin';\n\nexport function RxapOpenApiRemoteMethod(operationId: string, serverIndex: number = 0) {\n return function(target: any) {\n RxapRemoteMethod({ id: operationId, serverIndex })(target);\n };\n}\n\nexport interface OpenApiRemoteMethodMetadata extends BaseRemoteMethodMetadata {\n /**\n * The operation object with path and method\n */\n operation?: OperationObjectWithMetadata;\n /**\n * The index of the server object in the servers array in the open api config\n */\n serverIndex?: number;\n id: string;\n}\n\nexport interface OpenApiRemoteMethodParameter<Parameters extends Record<string, any> | void = any, RequestBody = any> {\n parameters?: Parameters,\n requestBody?: RequestBody\n}\n\nexport interface OpenApiRemoteMethod<Response = any, Parameters extends Record<string, any> | void = any, RequestBody = any>\n extends SchemaValidationMixin<Response, Parameters, RequestBody> {}\n\n@Mixin(SchemaValidationMixin)\n@Injectable()\nexport class OpenApiRemoteMethod<Response = any, Parameters extends Record<string, any> | void = any, RequestBody = any>\n extends BaseHttpRemoteMethod<Response, any, OpenApiRemoteMethodParameter<Parameters, RequestBody>> {\n\n public get operation(): OperationObjectWithMetadata {\n return this.metadata.operation;\n }\n\n private readonly strict: boolean = false;\n protected readonly disableSchemaValidation: boolean = false;\n protected readonly disableValidation: boolean = false;\n\n constructor(\n @Inject(HttpClient) http: HttpClient,\n @Inject(Injector) injector: Injector,\n @Inject(OpenApiConfigService) openApiConfigService: OpenApiConfigService,\n @Optional()\n @Inject(DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA)\n metadata: OpenApiRemoteMethodMetadata | null = null,\n @Optional()\n @Inject(RXAP_OPEN_API_STRICT_VALIDATOR)\n strict: boolean | null = null,\n @Optional()\n @Inject(DISABLE_SCHEMA_VALIDATION)\n disableSchemaValidation: boolean | null = null,\n @Optional()\n @Inject(DISABLE_VALIDATION)\n disableValidation: boolean | null = null\n ) {\n super(http, injector, metadata);\n let operation: OperationObjectWithMetadata;\n if (!this.metadata.operation) {\n this.metadata.operation = operation = openApiConfigService.getOperation(this.metadata.id);\n } else {\n operation = this.metadata.operation;\n }\n this.applyMetadata({\n id: operation.operationId,\n url: () => joinPath(openApiConfigService.getBaseUrl(this.metadata.serverIndex), operation.path),\n method: operation.method as any,\n withCredentials: this.metadata.withCredentials ?? true,\n ignoreUndefined: this.metadata.ignoreUndefined ?? true,\n });\n this.strict = strict || this.metadata.strict || false;\n this.disableSchemaValidation = disableSchemaValidation || this.metadata.disableSchemaValidation || false;\n this.disableValidation = disableValidation || this.metadata.disableValidation || false;\n }\n\n protected async _call(args: OpenApiRemoteMethodParameter<Parameters, RequestBody> = {}): Promise<Response> {\n\n if (!this.disableValidation) {\n this.validateParameters(this.operation, args.parameters, this.strict);\n this.validateRequestBody(this.operation, args.requestBody, this.strict);\n }\n\n const response = await this._callWithResponse(args);\n\n if (response.body) {\n return response.body;\n }\n\n console.warn('The response body is empty!');\n return null as any;\n }\n\n /**\n * Instead of returning the response body the full response object is returned\n */\n public async callWithResponse(args: OpenApiRemoteMethodParameter<Parameters, RequestBody> = {}): Promise<HttpResponse<Response>> {\n this.init();\n this.executionsInProgress$.increase();\n const result = await this._callWithResponse(args);\n this.executionsInProgress$.decrease();\n if (result.body) {\n this.executed$.next(result.body);\n this.executed(result.body);\n }\n return result;\n }\n\n // TODO : update to the new call method concept (the remove of the _call method concept)\n public _callWithResponse(args: OpenApiRemoteMethodParameter<Parameters, RequestBody> = {}): Promise<HttpResponse<Response>> {\n\n if (!this.disableValidation) {\n this.validateParameters(this.operation, args.parameters, this.strict);\n this.validateRequestBody(this.operation, args.requestBody, this.strict);\n }\n\n return this.http.request<Response>(this.updateRequest(this.buildHttpOptions(this.operation, args.parameters, args.requestBody, this.metadata.ignoreUndefined))).pipe(\n retry(this.metadata.retry ?? 0),\n catchError((response: HttpErrorResponse) => {\n this.interceptors?.forEach(interceptor => interceptor\n .next({ response, parameters: args.parameters, requestBody: args.requestBody })\n );\n return throwError(response);\n }),\n filter((event: any) => event.type === HttpEventType.Response),\n tap((response: HttpResponse<Response>) => {\n if (this.disableValidation) {\n this.validateResponse(this.operation, response, this.strict);\n }\n }),\n tap((response: HttpResponse<Response>) => {\n this.interceptors?.forEach(interceptor => interceptor\n .next({ response, parameters: args.parameters, requestBody: args.requestBody })\n );\n }),\n take(1),\n timeout(this.timeout)\n ).toPromise();\n\n }\n\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"public_api.js","sourceRoot":"","sources":["../../../../../libs/open-api/remote-method/src/public_api.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,aAAa,CAAC","sourcesContent":["export * from './lib/open-api-remote-method.loader';\nexport * from './lib/open-api.remote-method';\nexport * from './lib/error';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rxap-open-api-remote-method.js","sourceRoot":"","sources":["../../../../../libs/open-api/remote-method/src/rxap-open-api-remote-method.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,cAAc,CAAC","sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"]}
|
package/esm2015/rxap-open-api.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rxap-open-api.js","sourceRoot":"","sources":["../../../../libs/open-api/src/rxap-open-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC","sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rxap-open-api-data-source-table.js","sources":["../../../../libs/open-api/data-source/table/src/lib/error.ts","../../../../libs/open-api/data-source/table/src/lib/tokens.ts","../../../../libs/open-api/data-source/table/src/lib/open-api-table.data-source.ts","../../../../libs/open-api/data-source/table/src/lib/to-open-api-table-data-source.pipe.ts","../../../../libs/open-api/data-source/table/src/rxap-open-api-data-source-table.ts"],"sourcesContent":["import { RxapOpenApiDataSourceError } from '@rxap/open-api/data-source';\n\nexport class RxapOpenApiDataSourceTableError extends RxapOpenApiDataSourceError {\n\n constructor(message: string, code?: string, scope?: string) {\n super(message, code, scope);\n this.addSubPackageName('table');\n }\n\n}\n","import { InjectionToken } from '@angular/core';\n\nexport const RXAP_OPEN_API_TABLE_DATA_SOURCE_TO_PARAMETERS_FUNCTION = new InjectionToken('rxap/open-api/data-source/table/to-parameters-function')\n","import {\n AbstractTableDataSource,\n RXAP_TABLE_DATA_SOURCE,\n RXAP_TABLE_DATA_SOURCE_PAGINATOR,\n RXAP_TABLE_DATA_SOURCE_SORT,\n SortLike,\n RXAP_TABLE_DATA_SOURCE_FILTER,\n FilterLike,\n Sort,\n AbstractTableDataSourceMetadata,\n RxapAbstractTableDataSource,\n RXAP_TABLE_DATA_SOURCE_PARAMETERS\n} from '@rxap/data-source/table';\nimport {\n Injectable,\n Inject,\n Optional\n} from '@angular/core';\nimport {\n RXAP_DATA_SOURCE_METADATA,\n BaseDataSourceViewer\n} from '@rxap/data-source';\nimport {\n PaginatorLike,\n PageEvent\n} from '@rxap/data-source/pagination';\nimport { PaginationData } from '@rxap/data-source/http/pagination';\nimport {\n Observable,\n TeardownLogic,\n EMPTY,\n combineLatest,\n of,\n isObservable\n} from 'rxjs';\nimport { RxapOpenApiDataSourceTableError } from './error';\nimport {\n startWith,\n tap,\n filter as rxjsFilter,\n map,\n switchMap\n} from 'rxjs/operators';\nimport { RXAP_OPEN_API_TABLE_DATA_SOURCE_TO_PARAMETERS_FUNCTION } from './tokens';\nimport {\n Constructor,\n isPromise\n} from '@rxap/utilities';\nimport type { OpenApiDataSource } from '@rxap/open-api/data-source';\nimport { OpenApiDataSourceViewer } from '@rxap/open-api/data-source';\n\nexport interface TableEvent {\n page: PageEvent;\n sort: Sort | null;\n filter: Record<string, any> | string | null;\n}\n\nexport interface OpenApiTableDataSourceViewer extends BaseDataSourceViewer {\n readonly viewChange: Observable<TableEvent>;\n}\n\nexport interface OpenApiTableDataSourceMetadata\n extends AbstractTableDataSourceMetadata {}\n\nexport type TableEventToOpenApiParametersFunction<\n Parameters extends Record<string, any>\n> = (\n event: TableEvent\n) => Parameters | Observable<Parameters> | Promise<Parameters>;\n\n@Injectable()\nexport class OpenApiTableDataSource<\n Data extends object = any,\n Parameters extends Record<string, any> = any\n> extends AbstractTableDataSource<Data> {\n constructor(\n @Inject(RXAP_TABLE_DATA_SOURCE)\n private readonly dataSource: OpenApiDataSource<PaginationData<Data>>,\n @Optional()\n @Inject(RXAP_TABLE_DATA_SOURCE_PAGINATOR)\n paginator: PaginatorLike | null = null,\n @Optional()\n @Inject(RXAP_OPEN_API_TABLE_DATA_SOURCE_TO_PARAMETERS_FUNCTION)\n tableEventToOpenApiParameters: any | null = null,\n @Optional()\n @Inject(RXAP_TABLE_DATA_SOURCE_SORT)\n sort: SortLike | null = null,\n @Optional()\n @Inject(RXAP_TABLE_DATA_SOURCE_FILTER)\n filter: FilterLike | null = null,\n @Optional()\n @Inject(RXAP_TABLE_DATA_SOURCE_PARAMETERS)\n parameters: Observable<Parameters> | null = null,\n @Optional()\n @Inject(RXAP_DATA_SOURCE_METADATA)\n metadata: OpenApiTableDataSourceMetadata | null = dataSource.metadata\n ) {\n super(paginator, sort, filter, parameters, metadata);\n if (tableEventToOpenApiParameters) {\n this.tableEventToOpenApiParameters = tableEventToOpenApiParameters;\n }\n }\n\n public tableEventToOpenApiParameters(\n event: TableEvent\n ): Parameters | Observable<Parameters> | Promise<Parameters> {\n return {\n page: event.page.pageIndex,\n size: event.page.pageSize,\n sortBy: event.sort?.active,\n direction: event.sort?.direction,\n filter: event.filter,\n } as any;\n }\n\n protected _connect(\n viewer: OpenApiDataSourceViewer\n ): [Observable<Data[]>, TeardownLogic] {\n this.assertPaginator();\n\n if (viewer.viewChange && viewer.viewChange !== EMPTY) {\n console.warn('The viewChange property is readonly');\n }\n\n if (this.paginator === undefined || this.paginator.page === undefined) {\n throw new RxapOpenApiDataSourceTableError(\n 'The paginator instance has not a page property',\n ''\n );\n }\n\n viewer.viewChange = combineLatest([\n this.paginator.page.pipe(\n startWith({\n pageIndex: this.paginator.pageIndex,\n pageSize: this.paginator.pageSize,\n length: this.paginator.length,\n }),\n tap((page) => {\n if (typeof page.pageSize !== 'number') {\n console.warn('The page size is not defined!');\n }\n }),\n rxjsFilter((page) => typeof page.pageSize === 'number')\n ),\n this.sort?.sortChange?.pipe(\n startWith({\n active: this.sort?.active,\n direction: this.sort?.direction,\n })\n ) ?? of(null),\n this.filter?.change ?? of(null),\n ]).pipe(\n map(([page, sort, filter]) => ({ page, sort, filter })),\n switchMap((event) => {\n const options = this.tableEventToOpenApiParameters(event);\n if (isPromise(options) || isObservable(options)) {\n return options;\n }\n return of(options);\n })\n );\n\n return [\n this.dataSource.connect(viewer).pipe(\n tap((paginationData) => {\n if (typeof paginationData !== 'object') {\n throw new RxapOpenApiDataSourceTableError(\n 'The open api data source does not return a PaginationData object. Value is not an object',\n ''\n );\n }\n if (!paginationData.hasOwnProperty('total')) {\n throw new RxapOpenApiDataSourceTableError(\n 'The open api data source does not return a PaginationData object. Object has not the property total',\n ''\n );\n }\n if (\n !paginationData.hasOwnProperty('data') &&\n !Array.isArray(paginationData.data)\n ) {\n throw new RxapOpenApiDataSourceTableError(\n 'The open api data source does not return a PaginationData object. Object has not the property data' +\n ' property of the value not an array',\n ''\n );\n }\n if (\n paginationData.size !== undefined &&\n paginationData.size !== this.paginator!.pageSize\n ) {\n console.warn(\n 'The selected page size from the paginator is not equal to the page size from the PaginationData object'\n );\n }\n if (\n paginationData.page !== undefined &&\n paginationData.page !== this.paginator!.pageIndex\n ) {\n console.warn(\n 'The selected page index from the paginator is not equal to the page index from the PaginationData object'\n );\n }\n }),\n tap((paginationData) => this.updateTotalLength(paginationData.total)),\n map((paginationData) => paginationData.data)\n ),\n () => this.dataSource.disconnect(viewer),\n ];\n }\n}\n\nexport function RxapOpenApiTableDataSource<\n Data extends object,\n Parameters extends Record<string, any>\n>(\n metadata: OpenApiTableDataSourceMetadata,\n className: string = 'OpenApiTableDataSource',\n packageName: string = '@rxap/open-api/data-source/table'\n) {\n return function (\n target: Constructor<OpenApiTableDataSource<Data, Parameters>>\n ) {\n RxapAbstractTableDataSource(metadata, className, packageName)(target);\n };\n}\n","import {\n Pipe,\n PipeTransform,\n NgModule\n} from '@angular/core';\nimport { PaginationData } from '@rxap/data-source/http/pagination';\nimport { PaginatorLike } from '@rxap/data-source/pagination';\nimport {\n SortLike,\n FilterLike\n} from '@rxap/data-source/table';\nimport { OpenApiDataSource } from '@rxap/open-api/data-source';\nimport {\n OpenApiTableDataSource,\n TableEventToOpenApiParametersFunction\n} from './open-api-table.data-source';\n\n@Pipe({\n name: 'toOpenApiTableDataSource'\n})\nexport class ToOpenApiTableDataSourcePipe implements PipeTransform {\n\n public transform<Data extends object, Parameters extends Record<string, any>>(\n dataSource: OpenApiDataSource<PaginationData<Data>>,\n paginator: PaginatorLike,\n tableEventToOpenApiParameters?: TableEventToOpenApiParametersFunction<Parameters>,\n sort?: SortLike,\n filter?: FilterLike\n ): OpenApiTableDataSource<Data> {\n return new OpenApiTableDataSource(dataSource, paginator, tableEventToOpenApiParameters, sort, filter);\n }\n\n}\n\n@NgModule({\n exports: [ ToOpenApiTableDataSourcePipe ],\n declarations: [ ToOpenApiTableDataSourcePipe ]\n})\nexport class ToOpenApiTableDataSourcePipeModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["rxjsFilter"],"mappings":";;;;;;;;;;MAEa,+BAAgC,SAAQ,0BAA0B;IAE7E,YAAY,OAAe,EAAE,IAAa,EAAE,KAAc;QACxD,KAAK,CAAC,OAAO,EAAE,IAAI,EA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ts","../../../../libs/open-api/data-source/src/lib/open-api-data-source.loader.ts","../../../../libs/open-api/data-source/src/lib/error.ts","../../../../libs/open-api/data-source/src/rxap-open-api-data-source.ts"],"sourcesContent":["import {\n Injectable,\n Optional,\n Inject\n} from '@angular/core';\nimport {\n OperationObjectWithMetadata,\n OpenApiConfigService,\n SchemaValidationMixin,\n RXAP_OPEN_API_STRICT_VALIDATOR,\n DEFAULT_OPEN_API_DATA_SOURCE_META_DATA,\n DISABLE_SCHEMA_VALIDATION,\n DISABLE_VALIDATION\n} from '@rxap/open-api';\nimport {\n HttpClient,\n HttpResponse,\n HttpErrorResponse,\n HttpEventType\n} from '@angular/common/http';\nimport {\n KeyValue,\n joinPath,\n deepMerge\n} from '@rxap/utilities';\nimport {\n HttpDataSourceMetadata,\n HttpDataSourceOptions,\n BaseHttpDataSource\n} from '@rxap/data-source/http';\nimport {\n RxapDataSource,\n BaseDataSourceViewer,\n RXAP_DATA_SOURCE_REFRESH\n} from '@rxap/data-source';\nimport {\n Observable,\n throwError,\n Subject,\n EMPTY\n} from 'rxjs';\nimport {\n map,\n tap,\n retry,\n filter,\n catchError,\n timeout,\n take\n} from 'rxjs/operators';\nimport { Mixin } from '@rxap/mixin';\nimport { isDefined } from '@rxap/utilities/rxjs';\n\nexport interface OpenApiDataSourceMetadata<PathParams = KeyValue, Body = any | null> extends Partial<HttpDataSourceMetadata<PathParams, Body>> {\n\n /**\n * The operation object with path and method\n */\n operation?: OperationObjectWithMetadata;\n\n /**\n * The index of the server object in the servers array in the open api config\n */\n serverIndex?: number;\n\n /**\n * The operation id\n */\n id: string;\n\n strict?: boolean;\n\n}\n\nexport interface OpenApiDataSourceViewer<Parameters = any>\n extends BaseDataSourceViewer<Parameters> {\n parameters?: Parameters;\n}\n\nexport function RxapOpenApiDataSource(operationIdOrMetadata: string | OpenApiDataSourceMetadata, serverIndex: number = 0) {\n const metadata = typeof operationIdOrMetadata === 'string' ? { id: operationIdOrMetadata, serverIndex } : operationIdOrMetadata;\n return function(target: any) {\n RxapDataSource(metadata)(target);\n };\n}\n\nexport interface OpenApiDataSource<Response = any, Parameters = any> extends SchemaValidationMixin<Response, Parameters> {}\n\n@Mixin(SchemaValidationMixin)\n@Injectable()\nexport class OpenApiDataSource<Response = any, Parameters = any>\n extends BaseHttpDataSource<Response> {\n\n public get operation(): OperationObjectWithMetadata {\n return this.metadata.operation;\n }\n\n protected readonly strict: boolean = false;\n protected readonly disableSchemaValidation: boolean = false;\n protected readonly disableValidation: boolean = false;\n\n constructor(\n @Inject(HttpClient)\n http: HttpClient,\n @Inject(OpenApiConfigService)\n private readonly openApiConfigService: OpenApiConfigService,\n @Optional()\n @Inject(DEFAULT_OPEN_API_DATA_SOURCE_META_DATA)\n metadata: OpenApiDataSourceMetadata | null = null,\n @Optional()\n @Inject(RXAP_DATA_SOURCE_REFRESH)\n refresh$: Subject<HttpDataSourceOptions> | null = null,\n @Optional()\n @Inject(RXAP_OPEN_API_STRICT_VALIDATOR)\n strict: boolean | null = null,\n @Optional()\n @Inject(DISABLE_SCHEMA_VALIDATION)\n disableSchemaValidation: boolean | null = null,\n @Optional()\n @Inject(DISABLE_VALIDATION)\n disableValidation: boolean | null = null\n ) {\n super(http, metadata as any);\n let operation: OperationObjectWithMetadata;\n if (!this.metadata.operation) {\n this.metadata.operation = operation = openApiConfigService.getOperation(this.metadata.id);\n } else {\n operation = this.metadata.operation;\n }\n\n if (operation.method !== 'GET') {\n throw new Error('OpenApi DataSource only supports GET Operations!');\n }\n\n this.applyMetadata({\n id: operation.operationId,\n url: () => joinPath(openApiConfigService.getBaseUrl(this.metadata.serverIndex), operation.path),\n method: 'GET'\n });\n\n this.strict = strict || this.metadata.strict || false;\n this.disableSchemaValidation = disableSchemaValidation || this.metadata.disableSchemaValidation || false;\n this.disableValidation = disableValidation || this.metadata.disableValidation || false;\n\n }\n\n public derive<D = Response>(\n id: string,\n metadata: Partial<OpenApiDataSourceMetadata> = this.metadata,\n isolated: boolean = false\n ): OpenApiDataSource<D, Parameters> {\n return new OpenApiDataSource<D, Parameters>(\n this.http,\n this.openApiConfigService,\n { ...deepMerge(this.metadata, metadata), id },\n isolated ? null : this.refresh$\n );\n }\n\n public connect(viewer: OpenApiDataSourceViewer<Parameters>): Observable<Response> {\n\n\n if (viewer.parameters) {\n if (!this.disableValidation) {\n this.validateParameters(this.operation, viewer.parameters, this.strict);\n }\n } else {\n if (viewer.viewChange === EMPTY || viewer.viewChange === undefined) {\n // set the viewer parameters to an empty parameter and test if that\n // is valid.\n viewer.parameters = {} as any;\n if (!this.disableValidation) {\n this.validateParameters(this.operation, viewer.parameters, this.strict);\n }\n }\n }\n\n return super.connect({\n ...viewer,\n ...this.buildHttpOptions(this.operation, viewer.parameters),\n // if the view change is an empty observable. Then dont apply the pipe logic\n // else the http request is never triggered\n viewChange: viewer.viewChange === EMPTY ? viewer.viewChange : viewer.viewChange?.pipe(\n tap(parameters => {\n if (!this.disableValidation) {\n this.validateParameters(this.operation, parameters, this.strict);\n }\n }),\n map(parameters => this.buildHttpOptions(this.operation, parameters))\n )\n });\n\n }\n\n protected buildRequest(options: HttpDataSourceOptions): Observable<Response> {\n return this.http.request<Response>(this.buildHttpRequest(options)).pipe(\n retry(this.metadata.retry ?? 0),\n catchError((response: HttpErrorResponse) => {\n this.interceptors?.forEach(interceptor => interceptor\n .next({ response, options })\n );\n return throwError(response);\n }),\n filter((event: any) => event.type === HttpEventType.Response),\n tap((response: HttpResponse<Response>) => {\n if (!this.disableValidation) {\n this.validateResponse(this.operation, response, this.strict);\n }\n }),\n tap((response: HttpResponse<Response>) => {\n this.interceptors?.forEach(interceptor => interceptor\n .next({ response, options })\n );\n }),\n map((event: HttpResponse<Response>) => event.body),\n isDefined(),\n take(1),\n timeout(this.timeout)\n );\n }\n\n}\n","import {\n Injectable,\n Inject\n} from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { OpenApiDataSource } from './open-api.data-source';\nimport { OpenApiConfigService } from '@rxap/open-api';\n\n@Injectable({ providedIn: 'root' })\nexport class OpenApiDataSourceLoader {\n\n constructor(\n @Inject(OpenApiConfigService) public readonly openApiConfig: OpenApiConfigService,\n @Inject(HttpClient) public readonly http: HttpClient\n ) {}\n\n public load(definitionId: string): OpenApiDataSource | null {\n\n const operation = this.openApiConfig.getOperation(definitionId);\n\n if (operation) {\n return new OpenApiDataSource(\n this.http,\n this.openApiConfig,\n {\n id: definitionId,\n operation\n }\n );\n }\n\n return null;\n }\n\n}\n","import { RxapOpenApiError } from '@rxap/open-api';\n\nexport class RxapOpenApiDataSourceError extends RxapOpenApiError {\n\n constructor(message: string, code?: string, scope?: string) {\n super(message, code, scope);\n this.addSubPackageName('data-source');\n }\n\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;SA+EgB,qBAAqB,CAAC,qBAAyD,EAAE,cAAsB,CAAC;IACtH,MAAM,QAAQ,GAAG,OAAO,qBAAqB,KAAK,QAAQ,GAAG,EAAE,EAAE,EAAE,qBAAqB,EAAE,WAAW,EAAE,GAAG,qBAAqB,CAAC;IAChI,OAAO,UAAS,MAAW;QACzB,cAAc,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;KAClC,CAAC;AACJ,CAAC;IAMY,iBAAiB,+BAAjB,iBACX,SAAQ,kBAA4B;IAUpC,YAEI,IAAgB,EAED,oBAA0C,EAGzD,WAA6C,IAAI,EAGjD,WAAkD,IAAI,EAGxD,SAAyB,IAAI,EAG7B,0BAA0C,IAAI,EAG5C,oBAAoC,IAAI;QAE1C,KAAK,CAAC,IAAI,EAAE,QAAe,CAAC,CAAC;QAjBZ,yBAAoB,GAApB,oBAAoB,CAAsB;QAR1C,WAAM,GAAY,KAAK,CAAC;QACxB,4BAAuB,GAAY,KAAK,CAAC;QACzC,sBAAiB,GAAY,KAAK,CAAC;QAwBpD,IAAI,SAAsC,CAAC;QAC3C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS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C,oBAAoB;;0BAE3B,QAAQ;;0BACR,MAAM;2BAAC,sCAAsC;;0BAE7C,QAAQ;;0BACR,MAAM;2BAAC,wBAAwB;;0BAE/B,QAAQ;;0BACR,MAAM;2BAAC,8BAA8B;;0BAErC,QAAQ;;0BACR,MAAM;2BAAC,yBAAyB;;0BAEhC,QAAQ;;0BACR,MAAM;2BAAC,kBAAkB;;;MC9GjB,uBAAuB;IAElC,YACgD,aAAmC,EAC7C,IAAgB;QADN,kBAAa,GAAb,aAAa,CAAsB;QAC7C,SAAI,GAAJ,IAAI,CAAY;KAClD;IAEG,IAAI,CAAC,YAAoB;QAE9B,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QAEhE,IAAI,SAAS,EAAE;YACb,OAAO,IAAI,iBAAiB,CAC1B,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,aAAa,EAClB;gBACE,EAAE,EAAE,YAAY;gBAChB,SAAS;aACV,CACF,CAAC;SACH;QAED,OAAO,IAAI,CAAC;KACb;;qHAvBU,uBAAuB,kBAGxB,oBAAoB,aACpB,UAAU;yHAJT,uBAAuB,cADV,MAAM;4FACnB,uBAAuB;kBADnC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;0BAI7B,MAAM;2BAAC,oBAAoB;;0BAC3B,MAAM;2BAAC,UAAU;;;MCXT,0BAA2B,SAAQ,gBAAgB;IAE9D,YAAY,OAAe,EAAE,IAAa,EAAE,KAAc;QACxD,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;KACvC;;;ACPH;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rxap-open-api-remote-method.js","sources":["../../../../libs/open-api/remote-method/src/lib/open-api.remote-method.ts","../../../../libs/open-api/remote-method/src/lib/open-api-remote-method.loader.ts","../../../../libs/open-api/remote-method/src/lib/error.ts","../../../../libs/open-api/remote-method/src/rxap-open-api-remote-method.ts"],"sourcesContent":["import {\n Inject,\n Injector,\n Optional,\n Injectable\n} from '@angular/core';\nimport {\n HttpClient,\n HttpResponse,\n HttpEventType,\n HttpErrorResponse\n} from '@angular/common/http';\nimport {\n OperationObjectWithMetadata,\n OpenApiConfigService,\n SchemaValidationMixin,\n RXAP_OPEN_API_STRICT_VALIDATOR,\n DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA,\n DISABLE_SCHEMA_VALIDATION,\n DISABLE_VALIDATION\n} from '@rxap/open-api';\nimport { BaseHttpRemoteMethod } from '@rxap/remote-method/http';\nimport {\n BaseRemoteMethodMetadata,\n RxapRemoteMethod\n} from '@rxap/remote-method';\nimport { joinPath } from '@rxap/utilities';\nimport {\n filter,\n timeout,\n retry,\n catchError,\n tap,\n take\n} from 'rxjs/operators';\nimport { throwError } from 'rxjs';\nimport { Mixin } from '@rxap/mixin';\n\nexport function RxapOpenApiRemoteMethod(operationId: string, serverIndex: number = 0) {\n return function(target: any) {\n RxapRemoteMethod({ id: operationId, serverIndex })(target);\n };\n}\n\nexport interface OpenApiRemoteMethodMetadata extends BaseRemoteMethodMetadata {\n /**\n * The operation object with path and method\n */\n operation?: OperationObjectWithMetadata;\n /**\n * The index of the server object in the servers array in the open api config\n */\n serverIndex?: number;\n id: string;\n}\n\nexport interface OpenApiRemoteMethodParameter<Parameters extends Record<string, any> | void = any, RequestBody = any> {\n parameters?: Parameters,\n requestBody?: RequestBody\n}\n\nexport interface OpenApiRemoteMethod<Response = any, Parameters extends Record<string, any> | void = any, RequestBody = any>\n extends SchemaValidationMixin<Response, Parameters, RequestBody> {}\n\n@Mixin(SchemaValidationMixin)\n@Injectable()\nexport class OpenApiRemoteMethod<Response = any, Parameters extends Record<string, any> | void = any, RequestBody = any>\n extends BaseHttpRemoteMethod<Response, any, OpenApiRemoteMethodParameter<Parameters, RequestBody>> {\n\n public get operation(): OperationObjectWithMetadata {\n return this.metadata.operation;\n }\n\n private readonly strict: boolean = false;\n protected readonly disableSchemaValidation: boolean = false;\n protected readonly disableValidation: boolean = false;\n\n constructor(\n @Inject(HttpClient) http: HttpClient,\n @Inject(Injector) injector: Injector,\n @Inject(OpenApiConfigService) openApiConfigService: OpenApiConfigService,\n @Optional()\n @Inject(DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA)\n metadata: OpenApiRemoteMethodMetadata | null = null,\n @Optional()\n @Inject(RXAP_OPEN_API_STRICT_VALIDATOR)\n strict: boolean | null = null,\n @Optional()\n @Inject(DISABLE_SCHEMA_VALIDATION)\n disableSchemaValidation: boolean | null = null,\n @Optional()\n @Inject(DISABLE_VALIDATION)\n disableValidation: boolean | null = null\n ) {\n super(http, injector, metadata);\n let operation: OperationObjectWithMetadata;\n if (!this.metadata.operation) {\n this.metadata.operation = operation = openApiConfigService.getOperation(this.metadata.id);\n } else {\n operation = this.metadata.operation;\n }\n this.applyMetadata({\n id: operation.operationId,\n url: () => joinPath(openApiConfigService.getBaseUrl(this.metadata.serverIndex), operation.path),\n method: operation.method as any,\n withCredentials: this.metadata.withCredentials ?? true,\n ignoreUndefined: this.metadata.ignoreUndefined ?? true,\n });\n this.strict = strict || this.metadata.strict || false;\n this.disableSchemaValidation = disableSchemaValidation || this.metadata.disableSchemaValidation || false;\n this.disableValidation = disableValidation || this.metadata.disableValidation || false;\n }\n\n protected async _call(args: OpenApiRemoteMethodParameter<Parameters, RequestBody> = {}): Promise<Response> {\n\n if (!this.disableValidation) {\n this.validateParameters(this.operation, args.parameters, this.strict);\n this.validateRequestBody(this.operation, args.requestBody, this.strict);\n }\n\n const response = await this._callWithResponse(args);\n\n if (response.body) {\n return response.body;\n }\n\n console.warn('The response body is empty!');\n return null as any;\n }\n\n /**\n * Instead of returning the response body the full response object is returned\n */\n public async callWithResponse(args: OpenApiRemoteMethodParameter<Parameters, RequestBody> = {}): Promise<HttpResponse<Response>> {\n this.init();\n this.executionsInProgress$.increase();\n const result = await this._callWithResponse(args);\n this.executionsInProgress$.decrease();\n if (result.body) {\n this.executed$.next(result.body);\n this.executed(result.body);\n }\n return result;\n }\n\n // TODO : update to the new call method concept (the remove of the _call method concept)\n public _callWithResponse(args: OpenApiRemoteMethodParameter<Parameters, RequestBody> = {}): Promise<HttpResponse<Response>> {\n\n if (!this.disableValidation) {\n this.validateParameters(this.operation, args.parameters, this.strict);\n this.validateRequestBody(this.operation, args.requestBody, this.strict);\n }\n\n return this.http.request<Response>(this.updateRequest(this.buildHttpOptions(this.operation, args.parameters, args.requestBody, this.metadata.ignoreUndefined))).pipe(\n retry(this.metadata.retry ?? 0),\n catchError((response: HttpErrorResponse) => {\n this.interceptors?.forEach(interceptor => interceptor\n .next({ response, parameters: args.parameters, requestBody: args.requestBody })\n );\n return throwError(response);\n }),\n filter((event: any) => event.type === HttpEventType.Response),\n tap((response: HttpResponse<Response>) => {\n if (this.disableValidation) {\n this.validateResponse(this.operation, response, this.strict);\n }\n }),\n tap((response: HttpResponse<Response>) => {\n this.interceptors?.forEach(interceptor => interceptor\n .next({ response, parameters: args.parameters, requestBody: args.requestBody })\n );\n }),\n take(1),\n timeout(this.timeout)\n ).toPromise();\n\n }\n\n}\n","import {\n Injectable,\n Injector,\n Inject\n} from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { OpenApiRemoteMethod } from './open-api.remote-method';\nimport { OpenApiConfigService } from '@rxap/open-api';\n\n@Injectable({ providedIn: 'root' })\nexport class OpenApiRemoteMethodLoader {\n\n constructor(\n @Inject(OpenApiConfigService) public readonly openApiConfig: OpenApiConfigService,\n @Inject(HttpClient) public readonly http: HttpClient,\n public readonly injector: Injector\n ) {}\n\n public load(definitionId: string): OpenApiRemoteMethod | null {\n const operation = this.openApiConfig.getOperation(definitionId);\n\n if (operation) {\n\n return new OpenApiRemoteMethod(\n this.http,\n this.injector,\n this.openApiConfig,\n {\n id: definitionId,\n operation\n }\n );\n\n }\n\n return null;\n\n }\n\n}\n","import { RxapOpenApiError } from '@rxap/open-api';\n\nexport class RxapOpenApiRemoteMethodError extends RxapOpenApiError {\n\n constructor(message: string, code?: string, scope?: string) {\n super(message, code, scope);\n this.addSubPackageName('remote-method');\n }\n\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;SAsCgB,uBAAuB,CAAC,WAAmB,EAAE,cAAsB,CAAC;IAClF,OAAO,UAAS,MAAW;QACzB,gBAAgB,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;KAC5D,CAAC;AACJ,CAAC;IAwBY,mBAAmB,SAAnB,mBACX,SAAQ,oBAA0F;IAUlG,YACsB,IAAgB,EAClB,QAAkB,EACN,oBAA0C,EAGtE,WAA+C,IAAI,EAGnD,SAA2D,IAAI,EAGjE,0BAA0C,IAAI,EAG5C,oBAAoC,IAAI;;QAE1C,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QArBjB,WAAM,GAAY,KAAK,CAAC;QACtB,4BAAuB,GAAY,KAAK,CAAC;QACzC,sBAAiB,GAAY,KAAK,CAAC;QAoBpD,IAAI,SAAsC,CAAC;QAC3C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE;YAC5B,IAAI,CAAC,QAAQ,CAAC,SAAS,GAAG,SAAS,GAAG,oBAAoB,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;SAC3F;aAAM;YACL,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;SACrC;QACD,IAAI,CAAC,aAAa,CAAC;YACjB,EAAE,EAAM,SAAS,CAAC,WAAW;YAC7B,GAAG,EAAK,MAAM,QAAQ,CAAC,oBAAoB,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC;YAClG,MAAM,EAA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