@rxap/schematics-open-api 16.0.0-dev.2 → 16.0.0-dev.4
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/CHANGELOG.md +73 -215
- package/README.md +7 -6
- package/collection.json +9 -0
- package/package.json +50 -34
- package/src/index.d.ts +2 -27
- package/src/index.js +2 -29
- package/src/index.js.map +1 -1
- package/src/lib/clear-operation.js.map +1 -1
- package/src/lib/coerce-open-api-project.js +3 -3
- package/src/lib/coerce-open-api-project.js.map +1 -1
- package/src/lib/config.js.map +1 -1
- package/src/lib/generate-components.js +4 -1
- package/src/lib/generate-components.js.map +1 -1
- package/src/lib/generate-index-exports.js +1 -1
- package/src/lib/generate-index-exports.js.map +1 -1
- package/src/lib/generate-operation.js.map +1 -1
- package/src/lib/generate-parameters.js +6 -2
- package/src/lib/generate-parameters.js.map +1 -1
- package/src/lib/generate-request-body.js +5 -1
- package/src/lib/generate-request-body.js.map +1 -1
- package/src/lib/generate-response.js +5 -1
- package/src/lib/generate-response.js.map +1 -1
- package/src/lib/index.d.ts +11 -0
- package/src/lib/index.js +15 -0
- package/src/lib/index.js.map +1 -0
- package/src/lib/load-open-api-config.js.map +1 -1
- package/src/lib/types.js.map +1 -1
- package/src/lib/utilities/any-schema-object.js +1 -1
- package/src/lib/utilities/any-schema-object.js.map +1 -1
- package/src/lib/utilities/get-parameter-type.js.map +1 -1
- package/src/lib/utilities/get-reqeust-body.js +2 -2
- package/src/lib/utilities/get-reqeust-body.js.map +1 -1
- package/src/lib/utilities/get-request-body-type.js.map +1 -1
- package/src/lib/utilities/get-response-type.js.map +1 -1
- package/src/lib/utilities/get-response.js +5 -5
- package/src/lib/utilities/get-response.js.map +1 -1
- package/src/lib/utilities/has-operation-paramters.js.map +1 -1
- package/src/lib/utilities/has-operation-request-body.js.map +1 -1
- package/src/lib/utilities/http-request.js +3 -1
- package/src/lib/utilities/http-request.js.map +1 -1
- package/src/lib/utilities/ignore-operation.js.map +1 -1
- package/src/lib/utilities/index.d.ts +16 -0
- package/src/lib/utilities/index.js +20 -0
- package/src/lib/utilities/index.js.map +1 -0
- package/src/lib/utilities/is-collection-response.js.map +1 -1
- package/src/lib/utilities/is-http-method.js.map +1 -1
- package/src/lib/utilities/is-open-api-schema-from-path.js +2 -1
- package/src/lib/utilities/is-open-api-schema-from-path.js.map +1 -1
- package/src/lib/utilities/is-operation-object.js +1 -1
- package/src/lib/utilities/is-operation-object.js.map +1 -1
- package/src/lib/utilities/is-reference-object.js +1 -1
- package/src/lib/utilities/is-reference-object.js.map +1 -1
- package/src/lib/utilities/is-without-parameters.js.map +1 -1
- package/src/schematics/generate/coerce-open-api-project.d.ts +5 -0
- package/src/schematics/generate/coerce-open-api-project.js +52 -0
- package/src/schematics/generate/coerce-open-api-project.js.map +1 -0
- package/src/schematics/generate/const.d.ts +4 -0
- package/src/schematics/generate/const.js +8 -0
- package/src/schematics/generate/const.js.map +1 -0
- package/src/schematics/generate/create-directive.d.ts +2 -0
- package/src/schematics/generate/create-directive.js +292 -0
- package/src/schematics/generate/create-directive.js.map +1 -0
- package/src/schematics/generate/generate-openapi-provider.d.ts +3 -0
- package/src/schematics/generate/generate-openapi-provider.js +41 -0
- package/src/schematics/generate/generate-openapi-provider.js.map +1 -0
- package/src/schematics/generate/generate-remote-method.d.ts +3 -0
- package/src/schematics/generate/generate-remote-method.js +176 -0
- package/src/schematics/generate/generate-remote-method.js.map +1 -0
- package/src/schematics/generate/index.d.ts +3 -0
- package/src/schematics/generate/index.js +100 -0
- package/src/schematics/generate/index.js.map +1 -0
- package/src/schematics/generate/options.d.ts +14 -0
- package/src/schematics/generate/options.js +3 -0
- package/src/schematics/generate/options.js.map +1 -0
- package/src/schematics/generate/schema.d.ts +23 -0
- package/src/schematics/generate/schema.json +116 -0
- package/LICENSE +0 -630
- package/migration.json +0 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/open-api/src/schematics/generate/const.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG,cAAc,CAAC;AACvC,QAAA,uBAAuB,GAAG,aAAa,CAAC;AACxC,QAAA,uBAAuB,GAAG,gBAAgB,CAAC;AAC3C,QAAA,yBAAyB,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateDirective = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const core_1 = require("@angular-devkit/core");
|
|
6
|
+
function AssertImportSpecifierStructureArray(obj) {
|
|
7
|
+
if (!obj || !Array.isArray(obj)) {
|
|
8
|
+
throw new Error('Should be a array of OptionalKind<ImportSpecifierStructure>');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const { classify, camelize, } = core_1.strings;
|
|
12
|
+
function CreateDirective({ filePath, sourceFile, name, prefix, parametersType, returnType, template, collection, withoutParameters, }) {
|
|
13
|
+
const remoteMethodName = classify([name, 'remote-method'].join('-'));
|
|
14
|
+
if (!sourceFile.getClass(remoteMethodName)) {
|
|
15
|
+
console.warn(`A remote method class with the name '${remoteMethodName}' is not declared in the file '${filePath}'.`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const directiveNameParts = [remoteMethodName];
|
|
19
|
+
if (template) {
|
|
20
|
+
directiveNameParts.push('template');
|
|
21
|
+
}
|
|
22
|
+
if (collection) {
|
|
23
|
+
directiveNameParts.push('collection');
|
|
24
|
+
}
|
|
25
|
+
directiveNameParts.push('directive');
|
|
26
|
+
const directiveName = classify(directiveNameParts.join('-'));
|
|
27
|
+
const classDeclaration = sourceFile.getClass(directiveName);
|
|
28
|
+
if (classDeclaration) {
|
|
29
|
+
console.warn(`A class with name '${directiveName}' already exists in the file '${filePath}'!`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// region build selector
|
|
33
|
+
const selectorFragments = [prefix, name];
|
|
34
|
+
if (collection) {
|
|
35
|
+
selectorFragments.push('collection');
|
|
36
|
+
}
|
|
37
|
+
selectorFragments.push('remote-method');
|
|
38
|
+
const selector = camelize(selectorFragments.join('-'));
|
|
39
|
+
// endregion
|
|
40
|
+
const ctorsParameters = [
|
|
41
|
+
{
|
|
42
|
+
name: 'remoteMethodLoader',
|
|
43
|
+
type: 'RemoteMethodLoader',
|
|
44
|
+
decorators: [
|
|
45
|
+
{
|
|
46
|
+
name: 'Inject',
|
|
47
|
+
arguments: ['RemoteMethodLoader'],
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
}, {
|
|
51
|
+
name: 'injector',
|
|
52
|
+
type: 'Injector',
|
|
53
|
+
decorators: [
|
|
54
|
+
{
|
|
55
|
+
name: 'Inject',
|
|
56
|
+
arguments: ['INJECTOR'],
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
}, {
|
|
60
|
+
name: 'remoteMethod',
|
|
61
|
+
type: remoteMethodName,
|
|
62
|
+
decorators: [
|
|
63
|
+
{
|
|
64
|
+
name: 'Inject',
|
|
65
|
+
arguments: [remoteMethodName],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
let ctorsSupperCallParameters = ['remoteMethodLoader', 'injector'].join(', ');
|
|
71
|
+
let directiveClassExtends;
|
|
72
|
+
const remoteMethodDirectiveImportStructure = {
|
|
73
|
+
namedImports: [],
|
|
74
|
+
moduleSpecifier: '@rxap/remote-method/directive',
|
|
75
|
+
};
|
|
76
|
+
const remoteMethodImportStructure = {
|
|
77
|
+
namedImports: [{ name: 'RemoteMethodLoader' }],
|
|
78
|
+
moduleSpecifier: '@rxap/remote-method',
|
|
79
|
+
};
|
|
80
|
+
const angularCoreImportStructure = {
|
|
81
|
+
namedImports: [
|
|
82
|
+
{ name: 'Inject' }, { name: 'Directive' }, { name: 'NgModule' }, { name: 'INJECTOR' }, { name: 'Injector' },
|
|
83
|
+
],
|
|
84
|
+
moduleSpecifier: '@angular/core',
|
|
85
|
+
};
|
|
86
|
+
const directiveClassProperties = [];
|
|
87
|
+
const directiveClassSetAccessors = [];
|
|
88
|
+
const ctorsStatements = [];
|
|
89
|
+
const importStructure = [
|
|
90
|
+
angularCoreImportStructure, remoteMethodImportStructure, remoteMethodDirectiveImportStructure,
|
|
91
|
+
];
|
|
92
|
+
AssertImportSpecifierStructureArray(angularCoreImportStructure.namedImports);
|
|
93
|
+
AssertImportSpecifierStructureArray(remoteMethodImportStructure.namedImports);
|
|
94
|
+
AssertImportSpecifierStructureArray(remoteMethodDirectiveImportStructure.namedImports);
|
|
95
|
+
if (template) {
|
|
96
|
+
if (parametersType === 'void' || withoutParameters) {
|
|
97
|
+
ctorsStatements.push('this.withoutParameters = true;');
|
|
98
|
+
}
|
|
99
|
+
angularCoreImportStructure.namedImports.push({ name: 'TemplateRef' });
|
|
100
|
+
ctorsSupperCallParameters = [
|
|
101
|
+
'template', 'remoteMethodLoader', 'injector', 'viewContainerRef', 'cdr',
|
|
102
|
+
].join(', ');
|
|
103
|
+
directiveClassProperties.push({
|
|
104
|
+
name: 'parameters',
|
|
105
|
+
hasQuestionToken: true,
|
|
106
|
+
scope: ts_morph_1.Scope.Public,
|
|
107
|
+
type: parametersType,
|
|
108
|
+
leadingTrivia: '// tslint:disable-next-line:no-input-rename',
|
|
109
|
+
hasOverrideKeyword: true,
|
|
110
|
+
decorators: [
|
|
111
|
+
{
|
|
112
|
+
name: 'Input',
|
|
113
|
+
arguments: [
|
|
114
|
+
(writer) => writer.quote(camelize([selector, 'Parameters'].join('-'))),
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
});
|
|
119
|
+
if (collection) {
|
|
120
|
+
ctorsSupperCallParameters = [
|
|
121
|
+
ctorsSupperCallParameters, 'differs', 'zone',
|
|
122
|
+
].join(', ');
|
|
123
|
+
directiveClassExtends = `RemoteMethodTemplateCollectionDirective<${returnType}, ${parametersType}>`;
|
|
124
|
+
remoteMethodDirectiveImportStructure.namedImports.push({
|
|
125
|
+
name: 'RemoteMethodTemplateCollectionDirective',
|
|
126
|
+
});
|
|
127
|
+
ctorsParameters.push({
|
|
128
|
+
name: 'template',
|
|
129
|
+
type: `TemplateRef<RemoteMethodTemplateCollectionDirectiveContext<${returnType}>>`,
|
|
130
|
+
decorators: [
|
|
131
|
+
{
|
|
132
|
+
name: 'Inject',
|
|
133
|
+
arguments: ['TemplateRef'],
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
}, {
|
|
137
|
+
name: 'differs',
|
|
138
|
+
type: 'IterableDiffers',
|
|
139
|
+
decorators: [
|
|
140
|
+
{
|
|
141
|
+
name: 'Inject',
|
|
142
|
+
arguments: ['IterableDiffers'],
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
}, {
|
|
146
|
+
name: 'zone',
|
|
147
|
+
type: 'NgZone',
|
|
148
|
+
decorators: [
|
|
149
|
+
{
|
|
150
|
+
name: 'Inject',
|
|
151
|
+
arguments: ['NgZone'],
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
});
|
|
155
|
+
remoteMethodDirectiveImportStructure.namedImports.push({ name: 'RemoteMethodTemplateCollectionDirectiveContext' }, { name: 'RemoteMethodTemplateCollectionDirectiveErrorContext' });
|
|
156
|
+
directiveClassProperties.push({
|
|
157
|
+
name: 'errorTemplate',
|
|
158
|
+
hasQuestionToken: true,
|
|
159
|
+
hasOverrideKeyword: true,
|
|
160
|
+
leadingTrivia: '// tslint:disable-next-line:no-input-rename',
|
|
161
|
+
scope: ts_morph_1.Scope.Public,
|
|
162
|
+
type: `TemplateRef<RemoteMethodTemplateCollectionDirectiveErrorContext>`,
|
|
163
|
+
decorators: [
|
|
164
|
+
{
|
|
165
|
+
name: 'Input',
|
|
166
|
+
arguments: [
|
|
167
|
+
(writer) => writer.quote(camelize([selector, 'Error'].join('-'))),
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
}, {
|
|
172
|
+
name: 'emptyTemplate',
|
|
173
|
+
leadingTrivia: '// tslint:disable-next-line:no-input-rename',
|
|
174
|
+
hasQuestionToken: true,
|
|
175
|
+
scope: ts_morph_1.Scope.Public,
|
|
176
|
+
type: 'TemplateRef<void>',
|
|
177
|
+
decorators: [
|
|
178
|
+
{
|
|
179
|
+
name: 'Input',
|
|
180
|
+
arguments: [
|
|
181
|
+
(writer) => writer.quote(camelize([selector, 'Empty'].join('-'))),
|
|
182
|
+
],
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
});
|
|
186
|
+
angularCoreImportStructure.namedImports.push({ name: 'IterableDiffers' }, { name: 'NgZone' });
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
directiveClassExtends = `RemoteMethodTemplateDirective<${returnType}, ${parametersType}>`;
|
|
190
|
+
remoteMethodDirectiveImportStructure.namedImports.push({
|
|
191
|
+
name: 'RemoteMethodTemplateDirective',
|
|
192
|
+
});
|
|
193
|
+
ctorsParameters.push({
|
|
194
|
+
name: 'template',
|
|
195
|
+
type: `TemplateRef<RemoteMethodTemplateDirectiveContext<${returnType}>>`,
|
|
196
|
+
decorators: [
|
|
197
|
+
{
|
|
198
|
+
name: 'Inject',
|
|
199
|
+
arguments: ['TemplateRef'],
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
});
|
|
203
|
+
remoteMethodDirectiveImportStructure.namedImports.push({ name: 'RemoteMethodTemplateDirectiveContext' }, { name: 'RemoteMethodTemplateDirectiveErrorContext' });
|
|
204
|
+
directiveClassProperties.push({
|
|
205
|
+
name: 'errorTemplate',
|
|
206
|
+
hasQuestionToken: true,
|
|
207
|
+
hasOverrideKeyword: true,
|
|
208
|
+
type: `TemplateRef<RemoteMethodTemplateDirectiveErrorContext>`,
|
|
209
|
+
leadingTrivia: '// tslint:disable-next-line:no-input-rename',
|
|
210
|
+
scope: ts_morph_1.Scope.Public,
|
|
211
|
+
decorators: [
|
|
212
|
+
{
|
|
213
|
+
name: 'Input',
|
|
214
|
+
arguments: [
|
|
215
|
+
(writer) => writer.quote(camelize([selector, 'Error'].join('-'))),
|
|
216
|
+
],
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
ctorsParameters.push({
|
|
222
|
+
name: 'viewContainerRef',
|
|
223
|
+
type: 'ViewContainerRef',
|
|
224
|
+
decorators: [
|
|
225
|
+
{
|
|
226
|
+
name: 'Inject',
|
|
227
|
+
arguments: ['ViewContainerRef'],
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
}, {
|
|
231
|
+
name: 'cdr',
|
|
232
|
+
type: 'ChangeDetectorRef',
|
|
233
|
+
decorators: [
|
|
234
|
+
{
|
|
235
|
+
name: 'Inject',
|
|
236
|
+
arguments: ['ChangeDetectorRef'],
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
});
|
|
240
|
+
angularCoreImportStructure.namedImports.push({ name: 'ChangeDetectorRef' }, { name: 'ViewContainerRef' }, { name: 'Input' });
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
directiveClassExtends = `RemoteMethodDirective<${returnType}, ${parametersType}>`;
|
|
244
|
+
remoteMethodDirectiveImportStructure.namedImports.push({
|
|
245
|
+
name: 'RemoteMethodDirective',
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
const directiveClassStructure = {
|
|
249
|
+
name: directiveName,
|
|
250
|
+
decorators: [
|
|
251
|
+
{
|
|
252
|
+
name: 'Directive',
|
|
253
|
+
arguments: ts_morph_1.Writers.object({
|
|
254
|
+
selector: (writer) => writer.quote(`[${selector}]`),
|
|
255
|
+
exportAs: (writer) => writer.quote(selector),
|
|
256
|
+
}),
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
extends: directiveClassExtends,
|
|
260
|
+
ctors: [
|
|
261
|
+
{
|
|
262
|
+
parameters: ctorsParameters,
|
|
263
|
+
statements: [
|
|
264
|
+
`super(${ctorsSupperCallParameters});`, 'this.remoteMethodOrIdOrToken = remoteMethod;', ...ctorsStatements,
|
|
265
|
+
],
|
|
266
|
+
},
|
|
267
|
+
],
|
|
268
|
+
setAccessors: directiveClassSetAccessors,
|
|
269
|
+
properties: directiveClassProperties,
|
|
270
|
+
isExported: true,
|
|
271
|
+
};
|
|
272
|
+
const directiveModuleClassStructure = {
|
|
273
|
+
name: directiveName + 'Module',
|
|
274
|
+
decorators: [
|
|
275
|
+
{
|
|
276
|
+
name: 'NgModule',
|
|
277
|
+
arguments: [
|
|
278
|
+
ts_morph_1.Writers.object({
|
|
279
|
+
declarations: `[ ${directiveName} ]`,
|
|
280
|
+
exports: `[ ${directiveName} ]`,
|
|
281
|
+
}),
|
|
282
|
+
],
|
|
283
|
+
},
|
|
284
|
+
],
|
|
285
|
+
isExported: true,
|
|
286
|
+
};
|
|
287
|
+
sourceFile.addClass(directiveClassStructure);
|
|
288
|
+
sourceFile.addClass(directiveModuleClassStructure);
|
|
289
|
+
sourceFile.addImportDeclarations(importStructure);
|
|
290
|
+
}
|
|
291
|
+
exports.CreateDirective = CreateDirective;
|
|
292
|
+
//# sourceMappingURL=create-directive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-directive.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/open-api/src/schematics/generate/create-directive.ts"],"names":[],"mappings":";;;AAAA,uCAWkB;AAClB,+CAA+C;AAG/C,SAAS,mCAAmC,CAAC,GAAQ;IACnD,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;KAChF;AACH,CAAC;AAED,MAAM,EACJ,QAAQ,EACR,QAAQ,GACT,GAAG,cAAO,CAAC;AAEZ,SAAgB,eAAe,CAAC,EACE,QAAQ,EACR,UAAU,EACV,IAAI,EACJ,MAAM,EACN,cA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ACH;SACF;QACD,OAAO,EAAE,qBAAqB;QAC9B,KAAK,EAAE;YACL;gBACE,UAAU,EAAE,eAAe;gBAC3B,UAAU,EAAE;oBACV,SAAU,yBAA0B,IAAI,EAAE,8CAA8C,EAAE,GAAG,eAAe;iBAC7G;aACF;SACF;QACD,YAAY,EAAE,0BAA0B;QACxC,UAAU,EAAE,wBAAwB;QACpC,UAAU,EAAE,IAAI;KACjB,CAAC;IAEF,MAAM,6BAA6B,GAA4C;QAC7E,IAAI,EAAE,aAAa,GAAG,QAAQ;QAC9B,UAAU,EAAE;YACV;gBACE,IAAI,EAAE,UAAU;gBAChB,SAAS,EAAE;oBACT,kBAAO,CAAC,MAAM,CAAC;wBACb,YAAY,EAAE,KAAM,aAAc,IAAI;wBACtC,OAAO,EAAE,KAAM,aAAc,IAAI;qBAClC,CAAC;iBACH;aACF;SACF;QACD,UAAU,EAAE,IAAI;KACjB,CAAC;IAEF,UAAU,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC;IAC7C,UAAU,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CAAC;IACnD,UAAU,CAAC,qBAAqB,CAAC,eAAe,CAAC,CAAC;AACpD,CAAC;AAhVD,0CAgVC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GenerateOpenapiProvider = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const core_1 = require("@angular-devkit/core");
|
|
7
|
+
const const_1 = require("./const");
|
|
8
|
+
const { dasherize, classify, } = core_1.strings;
|
|
9
|
+
function GenerateOpenapiProvider(project, operatorIdList, options) {
|
|
10
|
+
const sourceFile = project.createSourceFile('open-api-providers.ts');
|
|
11
|
+
const providerList = [];
|
|
12
|
+
sourceFile.addImportDeclaration({
|
|
13
|
+
moduleSpecifier: '@angular/core',
|
|
14
|
+
namedImports: ['Provider'],
|
|
15
|
+
});
|
|
16
|
+
for (const operationId of operatorIdList) {
|
|
17
|
+
if (!options.skipRemoteMethod) {
|
|
18
|
+
const name = [operationId, const_1.REMOTE_METHOD_FILE_SUFFIX].join('.');
|
|
19
|
+
const moduleSpecifier = './' + (0, path_1.join)(const_1.REMOTE_METHOD_BASE_PATH, dasherize(name));
|
|
20
|
+
const className = classify(name.replace(/\./g, '-'));
|
|
21
|
+
sourceFile.addImportDeclaration({
|
|
22
|
+
moduleSpecifier,
|
|
23
|
+
namedImports: [className],
|
|
24
|
+
});
|
|
25
|
+
providerList.push(className);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
sourceFile.addVariableStatement({
|
|
29
|
+
declarationKind: ts_morph_1.VariableDeclarationKind.Const,
|
|
30
|
+
isExported: true,
|
|
31
|
+
declarations: [
|
|
32
|
+
{
|
|
33
|
+
name: 'OPEN_API_PROVIDERS',
|
|
34
|
+
type: 'Provider[]',
|
|
35
|
+
initializer: `[${providerList.join(', ')}]`,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
exports.GenerateOpenapiProvider = GenerateOpenapiProvider;
|
|
41
|
+
//# sourceMappingURL=generate-openapi-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-openapi-provider.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/open-api/src/schematics/generate/generate-openapi-provider.ts"],"names":[],"mappings":";;;AAAA,uCAGkB;AAClB,+BAA4B;AAC5B,+CAA+C;AAC/C,mCAGiB;AAGjB,MAAM,EACJ,SAAS,EACT,QAAQ,GACT,GAAG,cAAO,CAAC;AAEZ,SAAgB,uBAAuB,CAAC,OAAgB,EAAE,cAAwB,EAAE,OAAsB;IAExG,MAAM,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;IAErE,MAAM,YAAY,GAAa,EAAE,CAAC;IAElC,UAAU,CAAC,oBAAoB,CAAC;QAC9B,eAAe,EAAE,eAAe;QAChC,YAAY,EAAE,CAAE,UAAU,CAAE;KAC7B,CAAC,CAAC;IAEH,KAAK,MAAM,WAAW,IAAI,cAAc,EAAE;QAExC,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE;YAC7B,MAAM,IAAI,GAAG,CAAE,WAAW,EAAE,iCAAyB,CAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAClE,MAAM,eAAe,GAAG,IAAI,GAAG,IAAA,WAAI,EAAC,+BAAuB,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YAC9E,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;YAErD,UAAU,CAAC,oBAAoB,CAAC;gBAC9B,eAAe;gBACf,YAAY,EAAE,CAAE,SAAS,CAAE;aAC5B,CAAC,CAAC;YAEH,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SAC9B;KAEF;IAED,UAAU,CAAC,oBAAoB,CAAC;QAC9B,eAAe,EAAE,kCAAuB,CAAC,KAAK;QAC9C,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE;YACZ;gBACE,IAAI,EAAE,oBAAoB;gBAC1B,IAAI,EAAE,YAAY;gBAClB,WAAW,EAAE,IAAK,YAAY,CAAC,IAAI,CAAC,IAAI,CAAE,GAAG;aAC9C;SACF;KACF,CAAC,CAAC;AAEL,CAAC;AAxCD,0DAwCC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GenerateRemoteMethod = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const ts_morph_1 = require("ts-morph");
|
|
7
|
+
const core_1 = require("@angular-devkit/core");
|
|
8
|
+
const create_directive_1 = require("./create-directive");
|
|
9
|
+
const const_1 = require("./const");
|
|
10
|
+
const types_1 = require("../../lib/types");
|
|
11
|
+
const get_response_type_1 = require("../../lib/utilities/get-response-type");
|
|
12
|
+
const get_request_body_type_1 = require("../../lib/utilities/get-request-body-type");
|
|
13
|
+
const get_parameter_type_1 = require("../../lib/utilities/get-parameter-type");
|
|
14
|
+
const is_collection_response_1 = require("../../lib/utilities/is-collection-response");
|
|
15
|
+
const is_without_parameters_1 = require("../../lib/utilities/is-without-parameters");
|
|
16
|
+
const { dasherize, classify, } = core_1.strings;
|
|
17
|
+
function GenerateRemoteMethod(parameter) {
|
|
18
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const operationId = parameter.operationId;
|
|
20
|
+
const name = [operationId, const_1.REMOTE_METHOD_FILE_SUFFIX].join('.');
|
|
21
|
+
const fileName = (0, path_1.join)(const_1.REMOTE_METHOD_BASE_PATH, dasherize(name) + '.ts');
|
|
22
|
+
const sourceFile = parameter.project.createSourceFile(fileName);
|
|
23
|
+
const importStructures = [
|
|
24
|
+
{
|
|
25
|
+
moduleSpecifier: '@rxap/open-api/remote-method',
|
|
26
|
+
namedImports: [
|
|
27
|
+
{ name: 'RxapOpenApiRemoteMethod' }, { name: 'OpenApiRemoteMethodParameter' },
|
|
28
|
+
],
|
|
29
|
+
}, {
|
|
30
|
+
moduleSpecifier: '@angular/core',
|
|
31
|
+
namedImports: [{ name: 'Injectable' }],
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
switch (parameter.options.transport) {
|
|
35
|
+
case 'amplify':
|
|
36
|
+
importStructures.push({
|
|
37
|
+
moduleSpecifier: '@rxap/amplify-open-api',
|
|
38
|
+
namedImports: [{ name: 'AmplifyOpenApiRemoteMethod' }],
|
|
39
|
+
});
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
importStructures.push({
|
|
43
|
+
moduleSpecifier: '@rxap/open-api/remote-method',
|
|
44
|
+
namedImports: [{ name: 'OpenApiRemoteMethod' }],
|
|
45
|
+
});
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
const responseType = (0, get_response_type_1.GetResponseType)(parameter);
|
|
49
|
+
const parameterType = (0, get_parameter_type_1.GetParameterType)(parameter);
|
|
50
|
+
const requestBodyType = (0, get_request_body_type_1.GetRequestBodyType)(parameter);
|
|
51
|
+
if (!['void', 'any'].includes(responseType)) {
|
|
52
|
+
importStructures.push({
|
|
53
|
+
moduleSpecifier: `../responses/${dasherize(responseType.replace(/Response$/, ''))}.response`,
|
|
54
|
+
namedImports: [{ name: responseType }],
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (!['void', 'any'].includes(parameterType)) {
|
|
58
|
+
importStructures.push({
|
|
59
|
+
moduleSpecifier: `../parameters/${dasherize(parameterType.replace(/Parameter$/, ''))}.parameter`,
|
|
60
|
+
namedImports: [{ name: parameterType }],
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (!['void', 'any'].includes(requestBodyType)) {
|
|
64
|
+
importStructures.push({
|
|
65
|
+
moduleSpecifier: `../request-bodies/${dasherize(requestBodyType.replace(/RequestBody$/, ''))}.request-body`,
|
|
66
|
+
namedImports: [{ name: requestBodyType }],
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const callMethodParameters = [];
|
|
70
|
+
const withoutParametersAndRequestBody = parameterType === 'void' && requestBodyType === 'void';
|
|
71
|
+
if (!withoutParametersAndRequestBody) {
|
|
72
|
+
callMethodParameters.push({
|
|
73
|
+
name: 'parameters',
|
|
74
|
+
type: `OpenApiRemoteMethodParameter<${parameterType}, ${requestBodyType}>`,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const classStructure = {
|
|
78
|
+
name: classify(name.replace(/\./g, '-')),
|
|
79
|
+
decorators: [
|
|
80
|
+
{
|
|
81
|
+
name: 'Injectable',
|
|
82
|
+
arguments: ts_morph_1.Writers.object({
|
|
83
|
+
providedIn: (writer) => writer.quote('root'),
|
|
84
|
+
}),
|
|
85
|
+
}, {
|
|
86
|
+
name: 'RxapOpenApiRemoteMethod',
|
|
87
|
+
arguments: parameter.options.inline ? (writer) => ts_morph_1.Writers.object({
|
|
88
|
+
serverId: parameter.options.serverId ? w => w.quote(parameter.options.serverId) : 'undefined',
|
|
89
|
+
operationId: w => w.quote(parameter.operationId),
|
|
90
|
+
operation: w => w.quote(JSON.stringify((0, types_1.GenerateParameterToOperationObjectWithMetadata)(parameter))
|
|
91
|
+
.replace(/[\n\r\\]+/g, '')),
|
|
92
|
+
})(writer) : w => w.quote(operationId),
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
methods: [
|
|
96
|
+
{
|
|
97
|
+
name: 'call',
|
|
98
|
+
parameters: callMethodParameters,
|
|
99
|
+
scope: ts_morph_1.Scope.Public,
|
|
100
|
+
returnType: `Promise<${responseType}>`,
|
|
101
|
+
hasOverrideKeyword: true,
|
|
102
|
+
statements: [
|
|
103
|
+
`return super.call(${withoutParametersAndRequestBody ? '' : 'parameters'});`,
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
extends: (writer) => {
|
|
108
|
+
switch (parameter.options.transport) {
|
|
109
|
+
case 'amplify':
|
|
110
|
+
writer.write('AmplifyOpenApiRemoteMethod');
|
|
111
|
+
break;
|
|
112
|
+
default:
|
|
113
|
+
writer.write('OpenApiRemoteMethod');
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
writer.write('<');
|
|
117
|
+
writer.write(responseType);
|
|
118
|
+
writer.write(', ');
|
|
119
|
+
writer.write(parameterType);
|
|
120
|
+
writer.write(', ');
|
|
121
|
+
writer.write(requestBodyType);
|
|
122
|
+
writer.write('>');
|
|
123
|
+
},
|
|
124
|
+
isExported: true,
|
|
125
|
+
};
|
|
126
|
+
sourceFile.addClass(classStructure);
|
|
127
|
+
const withoutParameters = (0, is_without_parameters_1.IsWithoutParameters)(parameter);
|
|
128
|
+
if (!parameter.options.skipDirectives) {
|
|
129
|
+
if ((0, is_collection_response_1.IsCollectionResponse)(parameter)) {
|
|
130
|
+
importStructures.push({
|
|
131
|
+
moduleSpecifier: '@rxap/utilities',
|
|
132
|
+
namedImports: [{ name: 'ArrayElement' }],
|
|
133
|
+
});
|
|
134
|
+
(0, create_directive_1.CreateDirective)({
|
|
135
|
+
filePath: fileName,
|
|
136
|
+
name: operationId,
|
|
137
|
+
prefix: parameter.options.prefix,
|
|
138
|
+
parametersType: `OpenApiRemoteMethodParameter<${parameterType}, ${requestBodyType}>`,
|
|
139
|
+
returnType: `ArrayElement<${responseType}>`,
|
|
140
|
+
template: true,
|
|
141
|
+
collection: true,
|
|
142
|
+
sourceFile,
|
|
143
|
+
withoutParameters,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
(0, create_directive_1.CreateDirective)({
|
|
147
|
+
filePath: fileName,
|
|
148
|
+
name: operationId,
|
|
149
|
+
prefix: parameter.options.prefix,
|
|
150
|
+
parametersType: `OpenApiRemoteMethodParameter<${parameterType}, ${requestBodyType}>`,
|
|
151
|
+
returnType: responseType,
|
|
152
|
+
template: true,
|
|
153
|
+
collection: false,
|
|
154
|
+
sourceFile,
|
|
155
|
+
withoutParameters,
|
|
156
|
+
});
|
|
157
|
+
(0, create_directive_1.CreateDirective)({
|
|
158
|
+
filePath: fileName,
|
|
159
|
+
name: operationId,
|
|
160
|
+
prefix: parameter.options.prefix,
|
|
161
|
+
parametersType: `OpenApiRemoteMethodParameter<${parameterType}, ${requestBodyType}>`,
|
|
162
|
+
returnType: responseType,
|
|
163
|
+
template: false,
|
|
164
|
+
collection: false,
|
|
165
|
+
sourceFile,
|
|
166
|
+
withoutParameters,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
sourceFile.addImportDeclarations(importStructures);
|
|
170
|
+
sourceFile.organizeImports({
|
|
171
|
+
ensureNewLineAtEndOfFile: true,
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
exports.GenerateRemoteMethod = GenerateRemoteMethod;
|
|
176
|
+
//# sourceMappingURL=generate-remote-method.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-remote-method.js","sourceRoot":"","sources":["../../../../../../../packages/schematic/open-api/src/schematics/generate/generate-remote-method.ts"],"names":[],"mappings":";;;;AACA,+BAA4B;AAC5B,uCAOkB;AAClB,+CAA+C;AAC/C,yDAAqD;AACrD,mCAGiB;AACjB,2CAGyB;AACzB,6EAAwE;AACxE,qFAA+E;AAC/E,+EAA0E;AAC1E,uFAAkF;AAClF,qFAAgF;AAEhF,MAAM,EACJ,SAAS,EACT,QAAQ,GACT,GAAG,cAAO,CAAC;AAEZ,SAAsB,oBAAoB,CAAC,SAA+C;;QACxF,MAAM,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC;QAE1C,MAAM,IAAI,GAAG,CAAE,WAAW,EAAE,iCAAyB,CAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClE,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,+BAAuB,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QAExE,MAAM,UAAU,GAAG,SAAS,CAAC,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAEhE,MAAM,gBAAgB,GAAoD;YACxE;gBACE,eAAe,EAAE,8BAA8B;gBAC/C,YAAY,EAAE;oBACZ,EAAE,IAAI,EAAE,yBAAyB,EAAE,EAAE,EAAE,IAAI,EAAE,8BAA8B,EAAE;iBAC9E;aACF,EAAE;gBACD,eAAe,EAAE,eAAe;gBAChC,YAAY,EAAE,CAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAE;aACzC;SACF,CAAC;QAEF,QAAQ,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE;YACnC,KAAK,SAAS;gBACZ,gBAAgB,CAAC,IAAI,CAAC;oBACpB,eAAe,EAAE,wBAAwB;oBACzC,YAAY,EAAE,CAAE,EAAE,IAAI,EAAE,4B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