@rxap/open-api 14.2.0-dev.0 → 15.0.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/esm2020/lib/open-api-config.service.mjs +4 -4
- package/esm2020/remote-method/lib/open-api-remote-method.loader.mjs +3 -3
- package/esm2020/remote-method/lib/open-api.remote-method.mjs +4 -4
- package/fesm2015/rxap-open-api-remote-method.mjs +7 -6
- package/fesm2015/rxap-open-api-remote-method.mjs.map +1 -1
- package/fesm2015/rxap-open-api.mjs +4 -3
- package/fesm2015/rxap-open-api.mjs.map +1 -1
- package/fesm2020/rxap-open-api-remote-method.mjs +7 -6
- package/fesm2020/rxap-open-api-remote-method.mjs.map +1 -1
- package/fesm2020/rxap-open-api.mjs +4 -3
- package/fesm2020/rxap-open-api.mjs.map +1 -1
- package/package.json +16 -32
- package/src/schematics/open-api/index.js +0 -5
- package/src/schematics/open-api/index.js.map +1 -1
- package/src/schematics/open-api/schema.json +0 -8
- package/data-source/index.d.ts +0 -5
- package/data-source/lib/error.d.ts +0 -4
- package/data-source/lib/open-api-data-source.loader.d.ts +0 -12
- package/data-source/lib/open-api.data-source.d.ts +0 -41
- package/data-source/public_api.d.ts +0 -5
- package/data-source/table/index.d.ts +0 -5
- package/data-source/table/lib/error.d.ts +0 -4
- package/data-source/table/lib/open-api-table.data-source.d.ts +0 -29
- package/data-source/table/lib/to-open-api-table-data-source.pipe.d.ts +0 -17
- package/data-source/table/lib/tokens.d.ts +0 -2
- package/data-source/table/public_api.d.ts +0 -4
- package/esm2020/data-source/lib/error.mjs +0 -8
- package/esm2020/data-source/lib/open-api-data-source.loader.mjs +0 -36
- package/esm2020/data-source/lib/open-api.data-source.mjs +0 -140
- package/esm2020/data-source/public_api.mjs +0 -6
- package/esm2020/data-source/rxap-open-api-data-source.mjs +0 -5
- package/esm2020/data-source/table/lib/error.mjs +0 -8
- package/esm2020/data-source/table/lib/open-api-table.data-source.mjs +0 -127
- package/esm2020/data-source/table/lib/to-open-api-table-data-source.pipe.mjs +0 -29
- package/esm2020/data-source/table/lib/tokens.mjs +0 -3
- package/esm2020/data-source/table/public_api.mjs +0 -5
- package/esm2020/data-source/table/rxap-open-api-data-source-table.mjs +0 -5
- package/fesm2015/rxap-open-api-data-source-table.mjs +0 -172
- package/fesm2015/rxap-open-api-data-source-table.mjs.map +0 -1
- package/fesm2015/rxap-open-api-data-source.mjs +0 -188
- package/fesm2015/rxap-open-api-data-source.mjs.map +0 -1
- package/fesm2020/rxap-open-api-data-source-table.mjs +0 -168
- package/fesm2020/rxap-open-api-data-source-table.mjs.map +0 -1
- package/fesm2020/rxap-open-api-data-source.mjs +0 -183
- package/fesm2020/rxap-open-api-data-source.mjs.map +0 -1
- package/src/schematics/open-api/generate-data-source.d.ts +0 -2
- package/src/schematics/open-api/generate-data-source.js +0 -76
- package/src/schematics/open-api/generate-data-source.js.map +0 -1
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, Inject, Optional } from '@angular/core';
|
|
3
|
-
import * as i1 from '@angular/common/http';
|
|
4
|
-
import { HttpEventType, HttpClient } from '@angular/common/http';
|
|
5
|
-
import { __decorate, __metadata } from 'tslib';
|
|
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, DISABLE_VALIDATION, SchemaValidationMixin, RxapOpenApiError } from '@rxap/open-api';
|
|
8
|
-
export { IsReferenceObject, NotContainsReferenceObjects } from '@rxap/open-api';
|
|
9
|
-
import { deepMerge } from '@rxap/utilities';
|
|
10
|
-
import { BaseHttpDataSource } from '@rxap/data-source/http';
|
|
11
|
-
import { RxapDataSource, RXAP_DATA_SOURCE_REFRESH } from '@rxap/data-source';
|
|
12
|
-
import * as i3 from 'rxjs';
|
|
13
|
-
import { EMPTY, throwError } from 'rxjs';
|
|
14
|
-
import { tap, map, retry, catchError, filter, take, timeout } from 'rxjs/operators';
|
|
15
|
-
import { Mixin } from '@rxap/mixin';
|
|
16
|
-
import { isDefined } from '@rxap/utilities/rxjs';
|
|
17
|
-
|
|
18
|
-
var OpenApiDataSource_1;
|
|
19
|
-
function RxapOpenApiDataSource(operationIdOrMetadata, serverIndex = 0) {
|
|
20
|
-
const metadata = typeof operationIdOrMetadata === 'string' ? { id: operationIdOrMetadata, serverIndex } : operationIdOrMetadata;
|
|
21
|
-
return function (target) {
|
|
22
|
-
RxapDataSource(metadata)(target);
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
let OpenApiDataSource = OpenApiDataSource_1 = class OpenApiDataSource extends BaseHttpDataSource {
|
|
26
|
-
constructor(http, openApiConfigService, metadata = null, refresh$ = null, strict = null, disableSchemaValidation = null, disableValidation = null) {
|
|
27
|
-
super(http, metadata);
|
|
28
|
-
this.openApiConfigService = openApiConfigService;
|
|
29
|
-
this.strict = false;
|
|
30
|
-
this.disableSchemaValidation = false;
|
|
31
|
-
this.disableValidation = false;
|
|
32
|
-
let operation;
|
|
33
|
-
if (!this.metadata.operation) {
|
|
34
|
-
this.metadata.operation = operation = openApiConfigService.getOperation(this.metadata.id);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
operation = this.metadata.operation;
|
|
38
|
-
}
|
|
39
|
-
if (operation.method !== 'GET') {
|
|
40
|
-
throw new Error('OpenApi DataSource only supports GET Operations!');
|
|
41
|
-
}
|
|
42
|
-
this.applyMetadata({
|
|
43
|
-
id: operation.operationId,
|
|
44
|
-
url: () => openApiConfigService.getBaseUrl(this.metadata.serverIndex) + operation.path,
|
|
45
|
-
method: 'GET'
|
|
46
|
-
});
|
|
47
|
-
this.strict = strict || this.metadata.strict || false;
|
|
48
|
-
this.disableSchemaValidation = disableSchemaValidation || this.metadata.disableSchemaValidation || false;
|
|
49
|
-
this.disableValidation = disableValidation || this.metadata.disableValidation || false;
|
|
50
|
-
}
|
|
51
|
-
get operation() {
|
|
52
|
-
return this.metadata.operation;
|
|
53
|
-
}
|
|
54
|
-
derive(id, metadata = this.metadata, isolated = false) {
|
|
55
|
-
return new OpenApiDataSource_1(this.http, this.openApiConfigService, { ...deepMerge(this.metadata, metadata), id }, isolated ? null : this.refresh$);
|
|
56
|
-
}
|
|
57
|
-
connect(viewer) {
|
|
58
|
-
if (viewer.parameters) {
|
|
59
|
-
if (!this.disableValidation) {
|
|
60
|
-
this.validateParameters(this.operation, viewer.parameters, this.strict);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
if (viewer.viewChange === EMPTY || viewer.viewChange === undefined) {
|
|
65
|
-
// set the viewer parameters to an empty parameter and test if that
|
|
66
|
-
// is valid.
|
|
67
|
-
viewer.parameters = {};
|
|
68
|
-
if (!this.disableValidation) {
|
|
69
|
-
this.validateParameters(this.operation, viewer.parameters, this.strict);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return super.connect({
|
|
74
|
-
...viewer,
|
|
75
|
-
...this.buildHttpOptions(this.operation, viewer.parameters),
|
|
76
|
-
// if the view change is an empty observable. Then dont apply the pipe logic
|
|
77
|
-
// else the http request is never triggered
|
|
78
|
-
viewChange: viewer.viewChange === EMPTY ? viewer.viewChange : viewer.viewChange?.pipe(tap(parameters => {
|
|
79
|
-
if (!this.disableValidation) {
|
|
80
|
-
this.validateParameters(this.operation, parameters, this.strict);
|
|
81
|
-
}
|
|
82
|
-
}), map(parameters => this.buildHttpOptions(this.operation, parameters)))
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
buildRequest(options) {
|
|
86
|
-
return this.http.request(this.buildHttpRequest(options)).pipe(retry(this.metadata.retry ?? 0), catchError((response) => {
|
|
87
|
-
this.interceptors?.forEach(interceptor => interceptor
|
|
88
|
-
.next({ response, options }));
|
|
89
|
-
return throwError(response);
|
|
90
|
-
}), filter((event) => event.type === HttpEventType.Response), tap((response) => {
|
|
91
|
-
if (!this.disableValidation) {
|
|
92
|
-
this.validateResponse(this.operation, response, this.strict);
|
|
93
|
-
}
|
|
94
|
-
}), tap((response) => {
|
|
95
|
-
this.interceptors?.forEach(interceptor => interceptor
|
|
96
|
-
.next({ response, options }));
|
|
97
|
-
}), map((event) => event.body), isDefined(), take(1), timeout(this.timeout));
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
OpenApiDataSource.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", 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 });
|
|
101
|
-
OpenApiDataSource.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: OpenApiDataSource });
|
|
102
|
-
OpenApiDataSource = OpenApiDataSource_1 = __decorate([
|
|
103
|
-
Mixin(SchemaValidationMixin),
|
|
104
|
-
__metadata("design:paramtypes", [HttpClient,
|
|
105
|
-
OpenApiConfigService, Object, Object, Object, Object, Object])
|
|
106
|
-
], OpenApiDataSource);
|
|
107
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: OpenApiDataSource, decorators: [{
|
|
108
|
-
type: Injectable
|
|
109
|
-
}], ctorParameters: function () { return [{ type: i1.HttpClient, decorators: [{
|
|
110
|
-
type: Inject,
|
|
111
|
-
args: [HttpClient]
|
|
112
|
-
}] }, { type: i2.OpenApiConfigService, decorators: [{
|
|
113
|
-
type: Inject,
|
|
114
|
-
args: [OpenApiConfigService]
|
|
115
|
-
}] }, { type: undefined, decorators: [{
|
|
116
|
-
type: Optional
|
|
117
|
-
}, {
|
|
118
|
-
type: Inject,
|
|
119
|
-
args: [DEFAULT_OPEN_API_DATA_SOURCE_META_DATA]
|
|
120
|
-
}] }, { type: i3.Subject, decorators: [{
|
|
121
|
-
type: Optional
|
|
122
|
-
}, {
|
|
123
|
-
type: Inject,
|
|
124
|
-
args: [RXAP_DATA_SOURCE_REFRESH]
|
|
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
|
-
|
|
142
|
-
class OpenApiDataSourceLoader {
|
|
143
|
-
constructor(openApiConfig, http) {
|
|
144
|
-
this.openApiConfig = openApiConfig;
|
|
145
|
-
this.http = http;
|
|
146
|
-
}
|
|
147
|
-
load(definitionId) {
|
|
148
|
-
const operation = this.openApiConfig.getOperation(definitionId);
|
|
149
|
-
if (operation) {
|
|
150
|
-
return new OpenApiDataSource(this.http, this.openApiConfig, {
|
|
151
|
-
id: definitionId,
|
|
152
|
-
operation
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
OpenApiDataSourceLoader.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: OpenApiDataSourceLoader, deps: [{ token: OpenApiConfigService }, { token: HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
159
|
-
OpenApiDataSourceLoader.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: OpenApiDataSourceLoader, providedIn: 'root' });
|
|
160
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: OpenApiDataSourceLoader, decorators: [{
|
|
161
|
-
type: Injectable,
|
|
162
|
-
args: [{ providedIn: 'root' }]
|
|
163
|
-
}], ctorParameters: function () { return [{ type: i2.OpenApiConfigService, decorators: [{
|
|
164
|
-
type: Inject,
|
|
165
|
-
args: [OpenApiConfigService]
|
|
166
|
-
}] }, { type: i1.HttpClient, decorators: [{
|
|
167
|
-
type: Inject,
|
|
168
|
-
args: [HttpClient]
|
|
169
|
-
}] }]; } });
|
|
170
|
-
|
|
171
|
-
class RxapOpenApiDataSourceError extends RxapOpenApiError {
|
|
172
|
-
constructor(message, code, scope) {
|
|
173
|
-
super(message, code, scope);
|
|
174
|
-
this.addSubPackageName('data-source');
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Generated bundle index. Do not edit.
|
|
180
|
-
*/
|
|
181
|
-
|
|
182
|
-
export { OpenApiDataSource, OpenApiDataSourceLoader, RxapOpenApiDataSource, RxapOpenApiDataSourceError };
|
|
183
|
-
//# sourceMappingURL=rxap-open-api-data-source.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rxap-open-api-data-source.mjs","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: () => 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,EAAA;IACtH,MAAM,QAAQ,GAAG,OAAO,qBAAqB,KAAK,QAAQ,GAAG,EAAE,EAAE,EAAE,qBAAqB,EAAE,WAAW,EAAE,GAAG,qBAAqB,CAAC;AAChI,IAAA,OAAO,UAAS,MAAW,EAAA;AACzB,QAAA,cAAc,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AACnC,KAAC,CAAC;AACJ,CAAC;IAMY,iBAAiB,GAAA,mBAAA,GAAA,MAAjB,iBACX,SAAQ,kBAA4B,CAAA;AAUpC,IAAA,WAAA,CAEI,IAAgB,EAED,oBAA0C,EAGzD,QAAA,GAA6C,IAAI,EAGjD,QAAA,GAAkD,IAAI,EAGxD,SAAyB,IAAI,EAG7B,0BAA0C,IAAI,EAG5C,oBAAoC,IAAI,EAAA;AAE1C,QAAA,KAAK,CAAC,IAAI,EAAE,QAAe,CAAC,CAAC;QAjBZ,IAAoB,CAAA,oBAAA,GAApB,oBAAoB,CAAsB;QAR1C,IAAM,CAAA,MAAA,GAAY,KAAK,CAAC;QACxB,IAAuB,CAAA,uBAAA,GAAY,KAAK,CAAC;QACzC,IAAiB,CAAA,iBAAA,GAAY,KAAK,CAAC;AAwBpD,QAAA,IAAI,SAAsC,CAAC;AAC3C,QAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE;AAC5B,YAAA,IAAI,CAAC,QAAQ,CAAC,SAAS,GAAG,SAAS,GAAG,oBAAoB,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,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defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GenerateDataSource = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const schematics_open_api_1 = require("@rxap/schematics-open-api");
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
const ts_morph_1 = require("ts-morph");
|
|
8
|
-
const const_1 = require("./const");
|
|
9
|
-
const core_1 = require("@angular-devkit/core");
|
|
10
|
-
const { dasherize, classify } = core_1.strings;
|
|
11
|
-
function GenerateDataSource(parameter) {
|
|
12
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
-
if (parameter.method.toUpperCase() !== 'GET') {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const operationId = parameter.operationId;
|
|
17
|
-
const name = [operationId, const_1.DATA_SOURCE_FILE_SUFFIX].join('.');
|
|
18
|
-
const fileName = (0, path_1.join)(const_1.DATA_SOURCE_BASE_PATH, dasherize(name) + '.ts');
|
|
19
|
-
const sourceFile = parameter.project.createSourceFile(fileName);
|
|
20
|
-
const importStructures = [
|
|
21
|
-
{
|
|
22
|
-
moduleSpecifier: '@rxap/open-api/data-source',
|
|
23
|
-
namedImports: [
|
|
24
|
-
{ name: 'RxapOpenApiDataSource' },
|
|
25
|
-
{ name: 'OpenApiDataSource' }
|
|
26
|
-
]
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
moduleSpecifier: '@angular/core',
|
|
30
|
-
namedImports: [{ name: 'Injectable' }]
|
|
31
|
-
}
|
|
32
|
-
];
|
|
33
|
-
const responseType = (0, schematics_open_api_1.GetResponseType)(parameter);
|
|
34
|
-
const parameterType = (0, schematics_open_api_1.GetParameterType)(parameter);
|
|
35
|
-
if (!['void', 'any'].includes(responseType)) {
|
|
36
|
-
importStructures.push({
|
|
37
|
-
moduleSpecifier: `../responses/${dasherize(responseType.replace(/Response$/, ''))}.response`,
|
|
38
|
-
namedImports: [{ name: responseType }]
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
if (!['void', 'any'].includes(parameterType)) {
|
|
42
|
-
importStructures.push({
|
|
43
|
-
moduleSpecifier: `../parameters/${dasherize(parameterType.replace(/Parameter$/, ''))}.parameter`,
|
|
44
|
-
namedImports: [{ name: parameterType }]
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
const classStructure = {
|
|
48
|
-
name: classify(name.replace(/\./g, '-')),
|
|
49
|
-
decorators: [
|
|
50
|
-
{
|
|
51
|
-
name: 'Injectable',
|
|
52
|
-
arguments: ts_morph_1.Writers.object({
|
|
53
|
-
providedIn: (writer) => writer.quote('root')
|
|
54
|
-
})
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: 'RxapOpenApiDataSource',
|
|
58
|
-
arguments: (writer) => writer.quote(operationId)
|
|
59
|
-
}
|
|
60
|
-
],
|
|
61
|
-
extends: (writer) => {
|
|
62
|
-
writer.write('OpenApiDataSource');
|
|
63
|
-
writer.write('<');
|
|
64
|
-
writer.write(responseType);
|
|
65
|
-
writer.write(', ');
|
|
66
|
-
writer.write(parameterType);
|
|
67
|
-
writer.write('>');
|
|
68
|
-
},
|
|
69
|
-
isExported: true
|
|
70
|
-
};
|
|
71
|
-
sourceFile.addImportDeclarations(importStructures);
|
|
72
|
-
sourceFile.addClass(classStructure);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
exports.GenerateDataSource = GenerateDataSource;
|
|
76
|
-
//# sourceMappingURL=generate-data-source.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-data-source.js","sourceRoot":"","sources":["../../../../../../libs/open-api/src/schematics/open-api/generate-data-source.ts"],"names":[],"mappings":";;;;AAAA,mEAImC;AACnC,+BAA4B;AAC5B,uCAKkB;AAClB,mCAGiB;AACjB,+CAA+C;AAE/C,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,cAAO,CAAC;AAExC,SAAsB,kBAAkB,CACtC,SAA4B;;QAE5B,IAAI,SAAS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