@rxap/open-api 12.3.0 → 12.4.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/bundles/rxap-open-api-data-source.umd.js +15 -7
- package/bundles/rxap-open-api-data-source.umd.js.map +1 -1
- package/bundles/rxap-open-api-remote-method.umd.js +14 -6
- package/bundles/rxap-open-api-remote-method.umd.js.map +1 -1
- package/bundles/rxap-open-api.umd.js +6 -1
- package/bundles/rxap-open-api.umd.js.map +1 -1
- package/data-source/lib/open-api.data-source.d.ts +3 -2
- package/esm2015/data-source/lib/open-api.data-source.js +15 -8
- package/esm2015/data-source/lib/open-api.data-source.js.map +1 -1
- package/esm2015/lib/schema-validation.mixin.js +3 -0
- package/esm2015/lib/schema-validation.mixin.js.map +1 -1
- package/esm2015/lib/tokens.js +2 -1
- package/esm2015/lib/tokens.js.map +1 -1
- package/esm2015/remote-method/lib/open-api.remote-method.js +14 -7
- package/esm2015/remote-method/lib/open-api.remote-method.js.map +1 -1
- package/fesm2015/rxap-open-api-data-source.js +15 -8
- package/fesm2015/rxap-open-api-data-source.js.map +1 -1
- package/fesm2015/rxap-open-api-remote-method.js +14 -7
- package/fesm2015/rxap-open-api-remote-method.js.map +1 -1
- package/fesm2015/rxap-open-api.js +6 -2
- package/fesm2015/rxap-open-api.js.map +1 -1
- package/lib/schema-validation.mixin.d.ts +1 -0
- package/lib/tokens.d.ts +1 -0
- package/package.json +1 -1
- package/remote-method/lib/open-api.remote-method.d.ts +3 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter, __decorate, __metadata } from "tslib";
|
|
2
2
|
import { Inject, Injector, Optional, Injectable } from '@angular/core';
|
|
3
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 } from '@rxap/open-api';
|
|
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
5
|
import { BaseHttpRemoteMethod } from '@rxap/remote-method/http';
|
|
6
6
|
import { RxapRemoteMethod } from '@rxap/remote-method';
|
|
7
7
|
import { joinPath } from '@rxap/utilities';
|
|
@@ -17,11 +17,12 @@ export function RxapOpenApiRemoteMethod(operationId, serverIndex = 0) {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
let OpenApiRemoteMethod = class OpenApiRemoteMethod extends BaseHttpRemoteMethod {
|
|
20
|
-
constructor(http, injector, openApiConfigService, metadata = null, strict = null, disableSchemaValidation = null) {
|
|
20
|
+
constructor(http, injector, openApiConfigService, metadata = null, strict = null, disableSchemaValidation = null, disableValidation = null) {
|
|
21
21
|
var _a, _b;
|
|
22
22
|
super(http, injector, metadata);
|
|
23
23
|
this.strict = false;
|
|
24
24
|
this.disableSchemaValidation = false;
|
|
25
|
+
this.disableValidation = false;
|
|
25
26
|
let operation;
|
|
26
27
|
if (!this.metadata.operation) {
|
|
27
28
|
this.metadata.operation = operation = openApiConfigService.getOperation(this.metadata.id);
|
|
@@ -38,13 +39,14 @@ let OpenApiRemoteMethod = class OpenApiRemoteMethod extends BaseHttpRemoteMethod
|
|
|
38
39
|
});
|
|
39
40
|
this.strict = strict || this.metadata.strict || false;
|
|
40
41
|
this.disableSchemaValidation = disableSchemaValidation || this.metadata.disableSchemaValidation || false;
|
|
42
|
+
this.disableValidation = disableValidation || this.metadata.disableValidation || false;
|
|
41
43
|
}
|
|
42
44
|
get operation() {
|
|
43
45
|
return this.metadata.operation;
|
|
44
46
|
}
|
|
45
47
|
_call(args = {}) {
|
|
46
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
if (!this.
|
|
49
|
+
if (!this.disableValidation) {
|
|
48
50
|
this.validateParameters(this.operation, args.parameters, this.strict);
|
|
49
51
|
this.validateRequestBody(this.operation, args.requestBody, this.strict);
|
|
50
52
|
}
|
|
@@ -75,7 +77,7 @@ let OpenApiRemoteMethod = class OpenApiRemoteMethod extends BaseHttpRemoteMethod
|
|
|
75
77
|
// TODO : update to the new call method concept (the remove of the _call method concept)
|
|
76
78
|
_callWithResponse(args = {}) {
|
|
77
79
|
var _a;
|
|
78
|
-
if (!this.
|
|
80
|
+
if (!this.disableValidation) {
|
|
79
81
|
this.validateParameters(this.operation, args.parameters, this.strict);
|
|
80
82
|
this.validateRequestBody(this.operation, args.requestBody, this.strict);
|
|
81
83
|
}
|
|
@@ -85,7 +87,7 @@ let OpenApiRemoteMethod = class OpenApiRemoteMethod extends BaseHttpRemoteMethod
|
|
|
85
87
|
.next({ response, parameters: args.parameters, requestBody: args.requestBody }));
|
|
86
88
|
return throwError(response);
|
|
87
89
|
}), filter((event) => event.type === HttpEventType.Response), tap((response) => {
|
|
88
|
-
if (this.
|
|
90
|
+
if (this.disableValidation) {
|
|
89
91
|
this.validateResponse(this.operation, response, this.strict);
|
|
90
92
|
}
|
|
91
93
|
}), tap((response) => {
|
|
@@ -95,13 +97,13 @@ let OpenApiRemoteMethod = class OpenApiRemoteMethod extends BaseHttpRemoteMethod
|
|
|
95
97
|
}), take(1), timeout(this.timeout)).toPromise();
|
|
96
98
|
}
|
|
97
99
|
};
|
|
98
|
-
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 }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
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 });
|
|
99
101
|
OpenApiRemoteMethod.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: OpenApiRemoteMethod });
|
|
100
102
|
OpenApiRemoteMethod = __decorate([
|
|
101
103
|
Mixin(SchemaValidationMixin),
|
|
102
104
|
__metadata("design:paramtypes", [HttpClient,
|
|
103
105
|
Injector,
|
|
104
|
-
OpenApiConfigService, Object, Object, Object])
|
|
106
|
+
OpenApiConfigService, Object, Object, Object, Object])
|
|
105
107
|
], OpenApiRemoteMethod);
|
|
106
108
|
export { OpenApiRemoteMethod };
|
|
107
109
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: OpenApiRemoteMethod, decorators: [{
|
|
@@ -130,5 +132,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
130
132
|
}, {
|
|
131
133
|
type: Inject,
|
|
132
134
|
args: [DISABLE_SCHEMA_VALIDATION]
|
|
135
|
+
}] }, { type: undefined, decorators: [{
|
|
136
|
+
type: Optional
|
|
137
|
+
}, {
|
|
138
|
+
type: Inject,
|
|
139
|
+
args: [DISABLE_VALIDATION]
|
|
133
140
|
}] }]; } });
|
|
134
141
|
//# sourceMappingURL=open-api.remote-method.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-api.remote-method.js","sourceRoot":"","sources":["../../../../../../libs/open-api/remote-method/src/lib/open-api.remote-method.ts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C,qBAAqB,CAAC;qCAaC,UAAU;QACR,QAAQ;QACgB,oBAAoB;GAb/D,mBAAmB,CA2G/B;SA3GY,mBAAmB;4FAAnB,mBAAmB;kBAD/B,UAAU;;0BAYN,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","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} 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\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 ) {\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 }\n\n protected async _call(args: OpenApiRemoteMethodParameter<Parameters, RequestBody> = {}): Promise<Response> {\n\n if (!this.disableSchemaValidation) {\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.disableSchemaValidation) {\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.disableSchemaValidation) {\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
|
+
{"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,EAC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;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"]}
|
|
@@ -4,7 +4,7 @@ import * as i1 from '@angular/common/http';
|
|
|
4
4
|
import { HttpEventType, HttpClient } from '@angular/common/http';
|
|
5
5
|
import { __decorate, __metadata } from 'tslib';
|
|
6
6
|
import * as i2 from '@rxap/open-api';
|
|
7
|
-
import { OpenApiConfigService, DEFAULT_OPEN_API_DATA_SOURCE_META_DATA, RXAP_OPEN_API_STRICT_VALIDATOR, DISABLE_SCHEMA_VALIDATION, SchemaValidationMixin, RxapOpenApiError } from '@rxap/open-api';
|
|
7
|
+
import { OpenApiConfigService, DEFAULT_OPEN_API_DATA_SOURCE_META_DATA, RXAP_OPEN_API_STRICT_VALIDATOR, DISABLE_SCHEMA_VALIDATION, DISABLE_VALIDATION, SchemaValidationMixin, RxapOpenApiError } from '@rxap/open-api';
|
|
8
8
|
export { IsReferenceObject, NotContainsReferenceObjects } from '@rxap/open-api';
|
|
9
9
|
import { joinPath, deepMerge } from '@rxap/utilities';
|
|
10
10
|
import { BaseHttpDataSource } from '@rxap/data-source/http';
|
|
@@ -23,11 +23,12 @@ function RxapOpenApiDataSource(operationIdOrMetadata, serverIndex = 0) {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
let OpenApiDataSource = OpenApiDataSource_1 = class OpenApiDataSource extends BaseHttpDataSource {
|
|
26
|
-
constructor(http, openApiConfigService, metadata = null, refresh$ = null, strict = null, disableSchemaValidation = null) {
|
|
26
|
+
constructor(http, openApiConfigService, metadata = null, refresh$ = null, strict = null, disableSchemaValidation = null, disableValidation = null) {
|
|
27
27
|
super(http, metadata);
|
|
28
28
|
this.openApiConfigService = openApiConfigService;
|
|
29
29
|
this.strict = false;
|
|
30
30
|
this.disableSchemaValidation = false;
|
|
31
|
+
this.disableValidation = false;
|
|
31
32
|
let operation;
|
|
32
33
|
if (!this.metadata.operation) {
|
|
33
34
|
this.metadata.operation = operation = openApiConfigService.getOperation(this.metadata.id);
|
|
@@ -45,6 +46,7 @@ let OpenApiDataSource = OpenApiDataSource_1 = class OpenApiDataSource extends Ba
|
|
|
45
46
|
});
|
|
46
47
|
this.strict = strict || this.metadata.strict || false;
|
|
47
48
|
this.disableSchemaValidation = disableSchemaValidation || this.metadata.disableSchemaValidation || false;
|
|
49
|
+
this.disableValidation = disableValidation || this.metadata.disableValidation || false;
|
|
48
50
|
}
|
|
49
51
|
get operation() {
|
|
50
52
|
return this.metadata.operation;
|
|
@@ -55,7 +57,7 @@ let OpenApiDataSource = OpenApiDataSource_1 = class OpenApiDataSource extends Ba
|
|
|
55
57
|
connect(viewer) {
|
|
56
58
|
var _a;
|
|
57
59
|
if (viewer.parameters) {
|
|
58
|
-
if (!this.
|
|
60
|
+
if (!this.disableValidation) {
|
|
59
61
|
this.validateParameters(this.operation, viewer.parameters, this.strict);
|
|
60
62
|
}
|
|
61
63
|
}
|
|
@@ -64,7 +66,7 @@ let OpenApiDataSource = OpenApiDataSource_1 = class OpenApiDataSource extends Ba
|
|
|
64
66
|
// set the viewer parameters to an empty parameter and test if that
|
|
65
67
|
// is valid.
|
|
66
68
|
viewer.parameters = {};
|
|
67
|
-
if (!this.
|
|
69
|
+
if (!this.disableValidation) {
|
|
68
70
|
this.validateParameters(this.operation, viewer.parameters, this.strict);
|
|
69
71
|
}
|
|
70
72
|
}
|
|
@@ -73,7 +75,7 @@ let OpenApiDataSource = OpenApiDataSource_1 = class OpenApiDataSource extends Ba
|
|
|
73
75
|
// if the view change is an empty observable. Then dont apply the pipe logic
|
|
74
76
|
// else the http request is never triggered
|
|
75
77
|
viewChange: viewer.viewChange === EMPTY ? viewer.viewChange : (_a = viewer.viewChange) === null || _a === void 0 ? void 0 : _a.pipe(tap(parameters => {
|
|
76
|
-
if (!this.
|
|
78
|
+
if (!this.disableValidation) {
|
|
77
79
|
this.validateParameters(this.operation, parameters, this.strict);
|
|
78
80
|
}
|
|
79
81
|
}), map(parameters => this.buildHttpOptions(this.operation, parameters))) }));
|
|
@@ -86,7 +88,7 @@ let OpenApiDataSource = OpenApiDataSource_1 = class OpenApiDataSource extends Ba
|
|
|
86
88
|
.next({ response, options }));
|
|
87
89
|
return throwError(response);
|
|
88
90
|
}), filter((event) => event.type === HttpEventType.Response), tap((response) => {
|
|
89
|
-
if (!this.
|
|
91
|
+
if (!this.disableValidation) {
|
|
90
92
|
this.validateResponse(this.operation, response, this.strict);
|
|
91
93
|
}
|
|
92
94
|
}), tap((response) => {
|
|
@@ -96,12 +98,12 @@ let OpenApiDataSource = OpenApiDataSource_1 = class OpenApiDataSource extends Ba
|
|
|
96
98
|
}), map((event) => event.body), isDefined(), take(1), timeout(this.timeout));
|
|
97
99
|
}
|
|
98
100
|
};
|
|
99
|
-
OpenApiDataSource.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: OpenApiDataSource, deps: [{ token: HttpClient }, { token: OpenApiConfigService }, { token: DEFAULT_OPEN_API_DATA_SOURCE_META_DATA, optional: true }, { token: RXAP_DATA_SOURCE_REFRESH, optional: true }, { token: RXAP_OPEN_API_STRICT_VALIDATOR, optional: true }, { token: DISABLE_SCHEMA_VALIDATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
101
|
+
OpenApiDataSource.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: OpenApiDataSource, deps: [{ token: HttpClient }, { token: OpenApiConfigService }, { token: DEFAULT_OPEN_API_DATA_SOURCE_META_DATA, optional: true }, { token: RXAP_DATA_SOURCE_REFRESH, 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 });
|
|
100
102
|
OpenApiDataSource.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: OpenApiDataSource });
|
|
101
103
|
OpenApiDataSource = OpenApiDataSource_1 = __decorate([
|
|
102
104
|
Mixin(SchemaValidationMixin),
|
|
103
105
|
__metadata("design:paramtypes", [HttpClient,
|
|
104
|
-
OpenApiConfigService, Object, Object, Object, Object])
|
|
106
|
+
OpenApiConfigService, Object, Object, Object, Object, Object])
|
|
105
107
|
], OpenApiDataSource);
|
|
106
108
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: OpenApiDataSource, decorators: [{
|
|
107
109
|
type: Injectable
|
|
@@ -131,6 +133,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
131
133
|
}, {
|
|
132
134
|
type: Inject,
|
|
133
135
|
args: [DISABLE_SCHEMA_VALIDATION]
|
|
136
|
+
}] }, { type: undefined, decorators: [{
|
|
137
|
+
type: Optional
|
|
138
|
+
}, {
|
|
139
|
+
type: Inject,
|
|
140
|
+
args: [DISABLE_VALIDATION]
|
|
134
141
|
}] }]; } });
|
|
135
142
|
|
|
136
143
|
class OpenApiDataSourceLoader {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rxap-open-api-data-source.js","sources":["../../../../libs/open-api/data-source/src/lib/open-api.data-source.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} 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\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 ) {\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\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.disableSchemaValidation) {\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.disableSchemaValidation) {\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.disableSchemaValidation) {\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.disableSchemaValidation) {\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":";;;;;;;;;;;;;;;;;;SA8EgB,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;I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C,iBAAiB,CAAC,aAAa,CAAC,CAAC;KACvC;;;ACPH;;;;;;"}
|
|
1
|
+
{"version":3,"file":"rxap-open-api-data-source.js","sources":["../../../../libs/open-api/data-source/src/lib/open-api.data-source.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;QAC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* as i1 from '@angular/common/http';
|
|
|
4
4
|
import { HttpEventType, HttpClient } from '@angular/common/http';
|
|
5
5
|
import { __awaiter, __decorate, __metadata } from 'tslib';
|
|
6
6
|
import * as i2 from '@rxap/open-api';
|
|
7
|
-
import { OpenApiConfigService, DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA, RXAP_OPEN_API_STRICT_VALIDATOR, DISABLE_SCHEMA_VALIDATION, SchemaValidationMixin, RxapOpenApiError } from '@rxap/open-api';
|
|
7
|
+
import { OpenApiConfigService, DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA, RXAP_OPEN_API_STRICT_VALIDATOR, DISABLE_SCHEMA_VALIDATION, DISABLE_VALIDATION, SchemaValidationMixin, RxapOpenApiError } from '@rxap/open-api';
|
|
8
8
|
import { BaseHttpRemoteMethod } from '@rxap/remote-method/http';
|
|
9
9
|
import { RxapRemoteMethod } from '@rxap/remote-method';
|
|
10
10
|
import { joinPath } from '@rxap/utilities';
|
|
@@ -18,11 +18,12 @@ function RxapOpenApiRemoteMethod(operationId, serverIndex = 0) {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
let OpenApiRemoteMethod = class OpenApiRemoteMethod extends BaseHttpRemoteMethod {
|
|
21
|
-
constructor(http, injector, openApiConfigService, metadata = null, strict = null, disableSchemaValidation = null) {
|
|
21
|
+
constructor(http, injector, openApiConfigService, metadata = null, strict = null, disableSchemaValidation = null, disableValidation = null) {
|
|
22
22
|
var _a, _b;
|
|
23
23
|
super(http, injector, metadata);
|
|
24
24
|
this.strict = false;
|
|
25
25
|
this.disableSchemaValidation = false;
|
|
26
|
+
this.disableValidation = false;
|
|
26
27
|
let operation;
|
|
27
28
|
if (!this.metadata.operation) {
|
|
28
29
|
this.metadata.operation = operation = openApiConfigService.getOperation(this.metadata.id);
|
|
@@ -39,13 +40,14 @@ let OpenApiRemoteMethod = class OpenApiRemoteMethod extends BaseHttpRemoteMethod
|
|
|
39
40
|
});
|
|
40
41
|
this.strict = strict || this.metadata.strict || false;
|
|
41
42
|
this.disableSchemaValidation = disableSchemaValidation || this.metadata.disableSchemaValidation || false;
|
|
43
|
+
this.disableValidation = disableValidation || this.metadata.disableValidation || false;
|
|
42
44
|
}
|
|
43
45
|
get operation() {
|
|
44
46
|
return this.metadata.operation;
|
|
45
47
|
}
|
|
46
48
|
_call(args = {}) {
|
|
47
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
if (!this.
|
|
50
|
+
if (!this.disableValidation) {
|
|
49
51
|
this.validateParameters(this.operation, args.parameters, this.strict);
|
|
50
52
|
this.validateRequestBody(this.operation, args.requestBody, this.strict);
|
|
51
53
|
}
|
|
@@ -76,7 +78,7 @@ let OpenApiRemoteMethod = class OpenApiRemoteMethod extends BaseHttpRemoteMethod
|
|
|
76
78
|
// TODO : update to the new call method concept (the remove of the _call method concept)
|
|
77
79
|
_callWithResponse(args = {}) {
|
|
78
80
|
var _a;
|
|
79
|
-
if (!this.
|
|
81
|
+
if (!this.disableValidation) {
|
|
80
82
|
this.validateParameters(this.operation, args.parameters, this.strict);
|
|
81
83
|
this.validateRequestBody(this.operation, args.requestBody, this.strict);
|
|
82
84
|
}
|
|
@@ -86,7 +88,7 @@ let OpenApiRemoteMethod = class OpenApiRemoteMethod extends BaseHttpRemoteMethod
|
|
|
86
88
|
.next({ response, parameters: args.parameters, requestBody: args.requestBody }));
|
|
87
89
|
return throwError(response);
|
|
88
90
|
}), filter((event) => event.type === HttpEventType.Response), tap((response) => {
|
|
89
|
-
if (this.
|
|
91
|
+
if (this.disableValidation) {
|
|
90
92
|
this.validateResponse(this.operation, response, this.strict);
|
|
91
93
|
}
|
|
92
94
|
}), tap((response) => {
|
|
@@ -96,13 +98,13 @@ let OpenApiRemoteMethod = class OpenApiRemoteMethod extends BaseHttpRemoteMethod
|
|
|
96
98
|
}), take(1), timeout(this.timeout)).toPromise();
|
|
97
99
|
}
|
|
98
100
|
};
|
|
99
|
-
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 }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
101
|
+
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 });
|
|
100
102
|
OpenApiRemoteMethod.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: OpenApiRemoteMethod });
|
|
101
103
|
OpenApiRemoteMethod = __decorate([
|
|
102
104
|
Mixin(SchemaValidationMixin),
|
|
103
105
|
__metadata("design:paramtypes", [HttpClient,
|
|
104
106
|
Injector,
|
|
105
|
-
OpenApiConfigService, Object, Object, Object])
|
|
107
|
+
OpenApiConfigService, Object, Object, Object, Object])
|
|
106
108
|
], OpenApiRemoteMethod);
|
|
107
109
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: OpenApiRemoteMethod, decorators: [{
|
|
108
110
|
type: Injectable
|
|
@@ -130,6 +132,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
|
|
|
130
132
|
}, {
|
|
131
133
|
type: Inject,
|
|
132
134
|
args: [DISABLE_SCHEMA_VALIDATION]
|
|
135
|
+
}] }, { type: undefined, decorators: [{
|
|
136
|
+
type: Optional
|
|
137
|
+
}, {
|
|
138
|
+
type: Inject,
|
|
139
|
+
args: [DISABLE_VALIDATION]
|
|
133
140
|
}] }]; } });
|
|
134
141
|
|
|
135
142
|
class OpenApiRemoteMethodLoader {
|
|
@@ -1 +1 @@
|
|
|
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} 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\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 ) {\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 }\n\n protected async _call(args: OpenApiRemoteMethodParameter<Parameters, RequestBody> = {}): Promise<Response> {\n\n if (!this.disableSchemaValidation) {\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.disableSchemaValidation) {\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.disableSchemaValidation) {\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":";;;;;;;;;;;;;;SAqCgB,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;IASlG,YACsB,IAAgB,EAClB,QAAkB,EACN,oBAA0C,EAGtE,WAA+C,IAAI,EAGnD,SAA2D,IAAI,EAGjE,0BAA0C,IAAI;;QAE9C,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAjBjB,WAAM,GAAY,KAAK,CAAC;QACtB,4BAAuB,GAAY,KAAK,CAAC;QAiB1D,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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C,IAAgB,EACpC,QAAkB;QAFY,kBAAa,GAAb,aAAa,CAAsB;QAC7C,SAAI,GAAJ,IAAI,CAAY;QACpC,aAAQ,GAAR,QAAQ,CAAU;KAChC;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;KAEb;;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;;;MCZT,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;KACzC;;;ACPH;;;;;;"}
|
|
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,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E,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;KAEb;;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;;;MCZT,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;KACzC;;;ACPH;;;;;;"}
|
|
@@ -9,7 +9,8 @@ const RXAP_OPEN_API_CONFIG = new InjectionToken('rxap/open-api/config');
|
|
|
9
9
|
const RXAP_OPEN_API_STRICT_VALIDATOR = new InjectionToken('rxap/open-api/strict-validator');
|
|
10
10
|
const DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA = new InjectionToken('rxap/open-api/default-remote-method-meta-data');
|
|
11
11
|
const DEFAULT_OPEN_API_DATA_SOURCE_META_DATA = new InjectionToken('rxap/open-api/default-data-source-meta-data');
|
|
12
|
-
const DISABLE_SCHEMA_VALIDATION = new InjectionToken('rxap/open-api/disable-
|
|
12
|
+
const DISABLE_SCHEMA_VALIDATION = new InjectionToken('rxap/open-api/disable-schema-validation');
|
|
13
|
+
const DISABLE_VALIDATION = new InjectionToken('rxap/open-api/disable-validation');
|
|
13
14
|
|
|
14
15
|
class RxapOpenApiError extends RxapError {
|
|
15
16
|
constructor(message, code, scope) {
|
|
@@ -386,6 +387,9 @@ class SchemaValidationMixin {
|
|
|
386
387
|
return options;
|
|
387
388
|
}
|
|
388
389
|
validate(schema, value) {
|
|
390
|
+
if (this.disableSchemaValidation) {
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
389
393
|
let result;
|
|
390
394
|
try {
|
|
391
395
|
result = new Ajv().validate(schema, clone(value));
|
|
@@ -406,5 +410,5 @@ SchemaValidationMixin.STRICT = false;
|
|
|
406
410
|
* Generated bundle index. Do not edit.
|
|
407
411
|
*/
|
|
408
412
|
|
|
409
|
-
export { AssertOpenApiV3, DEFAULT_OPEN_API_DATA_SOURCE_META_DATA, DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA, DISABLE_SCHEMA_VALIDATION, IsOpenApiV3, IsReferenceObject, NotContainsReferenceObjects, OpenApiConfigService, RXAP_OPEN_API_CONFIG, RXAP_OPEN_API_STRICT_VALIDATOR, RxapOpenApiError, SchemaValidationMixin };
|
|
413
|
+
export { AssertOpenApiV3, DEFAULT_OPEN_API_DATA_SOURCE_META_DATA, DEFAULT_OPEN_API_REMOTE_METHOD_META_DATA, DISABLE_SCHEMA_VALIDATION, DISABLE_VALIDATION, IsOpenApiV3, IsReferenceObject, NotContainsReferenceObjects, OpenApiConfigService, RXAP_OPEN_API_CONFIG, RXAP_OPEN_API_STRICT_VALIDATOR, RxapOpenApiError, SchemaValidationMixin };
|
|
410
414
|
//# sourceMappingURL=rxap-open-api.js.map
|