ng-openapi 0.2.4 → 0.2.5
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/cli.cjs +124 -46
- package/index.d.ts +2 -1
- package/index.js +125 -45
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -44,7 +44,7 @@ var fs4 = __toESM(require("fs"));
|
|
|
44
44
|
var path12 = __toESM(require("path"));
|
|
45
45
|
|
|
46
46
|
// package.json
|
|
47
|
-
var version = "0.2.
|
|
47
|
+
var version = "0.2.4";
|
|
48
48
|
|
|
49
49
|
// src/lib/core/generator.ts
|
|
50
50
|
var import_ts_morph7 = require("ts-morph");
|
|
@@ -139,6 +139,11 @@ function getBasePathTokenName(clientName = "default") {
|
|
|
139
139
|
return `BASE_PATH_${clientSuffix}`;
|
|
140
140
|
}
|
|
141
141
|
__name(getBasePathTokenName, "getBasePathTokenName");
|
|
142
|
+
function getInterceptorsTokenName(clientName = "default") {
|
|
143
|
+
const clientSuffix = clientName.toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
144
|
+
return `HTTP_INTERCEPTORS_${clientSuffix}`;
|
|
145
|
+
}
|
|
146
|
+
__name(getInterceptorsTokenName, "getInterceptorsTokenName");
|
|
142
147
|
|
|
143
148
|
// ../shared/src/utils/functions/duplicate-function-name.ts
|
|
144
149
|
function hasDuplicateFunctionNames(arr) {
|
|
@@ -1011,19 +1016,21 @@ var TokenGenerator = class {
|
|
|
1011
1016
|
const sourceFile = this.project.createSourceFile(filePath, "", {
|
|
1012
1017
|
overwrite: true
|
|
1013
1018
|
});
|
|
1014
|
-
sourceFile.
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1019
|
+
sourceFile.addImportDeclarations([
|
|
1020
|
+
{
|
|
1021
|
+
namedImports: [
|
|
1022
|
+
"InjectionToken"
|
|
1023
|
+
],
|
|
1024
|
+
moduleSpecifier: "@angular/core"
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
namedImports: [
|
|
1028
|
+
"HttpInterceptor",
|
|
1029
|
+
"HttpContextToken"
|
|
1030
|
+
],
|
|
1031
|
+
moduleSpecifier: "@angular/common/http"
|
|
1032
|
+
}
|
|
1033
|
+
]);
|
|
1027
1034
|
const basePathTokenName = this.getBasePathTokenName();
|
|
1028
1035
|
const interceptorsTokenName = this.getInterceptorsTokenName();
|
|
1029
1036
|
const clientContextTokenName = this.getClientContextTokenName();
|
|
@@ -1138,6 +1145,15 @@ var FileDownloadGenerator = class {
|
|
|
1138
1145
|
const sourceFile = this.project.createSourceFile(filePath, "", {
|
|
1139
1146
|
overwrite: true
|
|
1140
1147
|
});
|
|
1148
|
+
sourceFile.addImportDeclarations([
|
|
1149
|
+
{
|
|
1150
|
+
namedImports: [
|
|
1151
|
+
"Observable",
|
|
1152
|
+
"tap"
|
|
1153
|
+
],
|
|
1154
|
+
moduleSpecifier: "rxjs"
|
|
1155
|
+
}
|
|
1156
|
+
]);
|
|
1141
1157
|
sourceFile.addFunction({
|
|
1142
1158
|
name: "downloadFile",
|
|
1143
1159
|
isExported: true,
|
|
@@ -1247,7 +1263,7 @@ var FileDownloadGenerator = class {
|
|
|
1247
1263
|
|
|
1248
1264
|
return fallbackFilename;`
|
|
1249
1265
|
});
|
|
1250
|
-
sourceFile.
|
|
1266
|
+
sourceFile.formatText();
|
|
1251
1267
|
sourceFile.saveSync();
|
|
1252
1268
|
}
|
|
1253
1269
|
};
|
|
@@ -1269,6 +1285,31 @@ var DateTransformerGenerator = class {
|
|
|
1269
1285
|
const sourceFile = this.project.createSourceFile(filePath, "", {
|
|
1270
1286
|
overwrite: true
|
|
1271
1287
|
});
|
|
1288
|
+
sourceFile.addImportDeclarations([
|
|
1289
|
+
{
|
|
1290
|
+
namedImports: [
|
|
1291
|
+
"HttpEvent",
|
|
1292
|
+
"HttpHandler",
|
|
1293
|
+
"HttpInterceptor",
|
|
1294
|
+
"HttpRequest",
|
|
1295
|
+
"HttpResponse"
|
|
1296
|
+
],
|
|
1297
|
+
moduleSpecifier: "@angular/common/http"
|
|
1298
|
+
},
|
|
1299
|
+
{
|
|
1300
|
+
namedImports: [
|
|
1301
|
+
"Injectable"
|
|
1302
|
+
],
|
|
1303
|
+
moduleSpecifier: "@angular/core"
|
|
1304
|
+
},
|
|
1305
|
+
{
|
|
1306
|
+
namedImports: [
|
|
1307
|
+
"Observable",
|
|
1308
|
+
"map"
|
|
1309
|
+
],
|
|
1310
|
+
moduleSpecifier: "rxjs"
|
|
1311
|
+
}
|
|
1312
|
+
]);
|
|
1272
1313
|
sourceFile.addVariableStatement({
|
|
1273
1314
|
isExported: true,
|
|
1274
1315
|
declarationKind: import_ts_morph3.VariableDeclarationKind.Const,
|
|
@@ -1355,7 +1396,7 @@ var DateTransformerGenerator = class {
|
|
|
1355
1396
|
}
|
|
1356
1397
|
]
|
|
1357
1398
|
});
|
|
1358
|
-
sourceFile.
|
|
1399
|
+
sourceFile.formatText();
|
|
1359
1400
|
sourceFile.saveSync();
|
|
1360
1401
|
}
|
|
1361
1402
|
};
|
|
@@ -1428,8 +1469,8 @@ var ProviderGenerator = class {
|
|
|
1428
1469
|
overwrite: true
|
|
1429
1470
|
});
|
|
1430
1471
|
sourceFile.insertText(0, PROVIDER_GENERATOR_HEADER_COMMENT);
|
|
1431
|
-
const basePathTokenName = this.
|
|
1432
|
-
const interceptorsTokenName = this.
|
|
1472
|
+
const basePathTokenName = getBasePathTokenName(this.clientName);
|
|
1473
|
+
const interceptorsTokenName = getInterceptorsTokenName(this.clientName);
|
|
1433
1474
|
const baseInterceptorClassName = `${this.capitalizeFirst(this.clientName)}BaseInterceptor`;
|
|
1434
1475
|
sourceFile.addImportDeclarations([
|
|
1435
1476
|
{
|
|
@@ -1602,14 +1643,6 @@ return makeEnvironmentProviders(providers);`;
|
|
|
1602
1643
|
});
|
|
1603
1644
|
}
|
|
1604
1645
|
}
|
|
1605
|
-
getBasePathTokenName() {
|
|
1606
|
-
const clientSuffix = this.clientName.toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
1607
|
-
return `BASE_PATH_${clientSuffix}`;
|
|
1608
|
-
}
|
|
1609
|
-
getInterceptorsTokenName() {
|
|
1610
|
-
const clientSuffix = this.clientName.toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
1611
|
-
return `HTTP_INTERCEPTORS_${clientSuffix}`;
|
|
1612
|
-
}
|
|
1613
1646
|
capitalizeFirst(str) {
|
|
1614
1647
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1615
1648
|
}
|
|
@@ -1635,14 +1668,38 @@ var BaseInterceptorGenerator = class {
|
|
|
1635
1668
|
overwrite: true
|
|
1636
1669
|
});
|
|
1637
1670
|
sourceFile.insertText(0, BASE_INTERCEPTOR_HEADER_COMMENT(this.#clientName));
|
|
1638
|
-
const interceptorsTokenName =
|
|
1639
|
-
const clientContextTokenName =
|
|
1671
|
+
const interceptorsTokenName = getInterceptorsTokenName(this.#clientName);
|
|
1672
|
+
const clientContextTokenName = getClientContextTokenName(this.#clientName);
|
|
1640
1673
|
sourceFile.addImportDeclarations([
|
|
1641
1674
|
{
|
|
1642
1675
|
namedImports: [
|
|
1676
|
+
"HttpContextToken",
|
|
1677
|
+
"HttpEvent",
|
|
1678
|
+
"HttpHandler",
|
|
1679
|
+
"HttpInterceptor",
|
|
1680
|
+
"HttpRequest"
|
|
1681
|
+
],
|
|
1682
|
+
moduleSpecifier: "@angular/common/http"
|
|
1683
|
+
},
|
|
1684
|
+
{
|
|
1685
|
+
namedImports: [
|
|
1686
|
+
"inject",
|
|
1643
1687
|
"Injectable"
|
|
1644
1688
|
],
|
|
1645
1689
|
moduleSpecifier: "@angular/core"
|
|
1690
|
+
},
|
|
1691
|
+
{
|
|
1692
|
+
namedImports: [
|
|
1693
|
+
"Observable"
|
|
1694
|
+
],
|
|
1695
|
+
moduleSpecifier: "rxjs"
|
|
1696
|
+
},
|
|
1697
|
+
{
|
|
1698
|
+
namedImports: [
|
|
1699
|
+
clientContextTokenName,
|
|
1700
|
+
interceptorsTokenName
|
|
1701
|
+
],
|
|
1702
|
+
moduleSpecifier: "../tokens"
|
|
1646
1703
|
}
|
|
1647
1704
|
]);
|
|
1648
1705
|
sourceFile.addClass({
|
|
@@ -1708,17 +1765,9 @@ var BaseInterceptorGenerator = class {
|
|
|
1708
1765
|
}
|
|
1709
1766
|
]
|
|
1710
1767
|
});
|
|
1711
|
-
sourceFile.
|
|
1768
|
+
sourceFile.formatText();
|
|
1712
1769
|
sourceFile.saveSync();
|
|
1713
1770
|
}
|
|
1714
|
-
getInterceptorsTokenName() {
|
|
1715
|
-
const clientSuffix = this.#clientName.toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
1716
|
-
return `HTTP_INTERCEPTORS_${clientSuffix}`;
|
|
1717
|
-
}
|
|
1718
|
-
getClientContextTokenName() {
|
|
1719
|
-
const clientSuffix = this.#clientName.toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
1720
|
-
return `CLIENT_CONTEXT_TOKEN_${clientSuffix}`;
|
|
1721
|
-
}
|
|
1722
1771
|
capitalizeFirst(str) {
|
|
1723
1772
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1724
1773
|
}
|
|
@@ -2547,26 +2596,55 @@ var ServiceGenerator = class {
|
|
|
2547
2596
|
const sourceFile = this.project.createSourceFile(filePath, "", {
|
|
2548
2597
|
overwrite: true
|
|
2549
2598
|
});
|
|
2550
|
-
this.addImports(sourceFile);
|
|
2551
2599
|
this.addServiceClass(sourceFile, controllerName, operations);
|
|
2552
|
-
sourceFile.fixMissingImports().
|
|
2600
|
+
sourceFile.fixMissingImports().formatText();
|
|
2553
2601
|
sourceFile.saveSync();
|
|
2554
2602
|
}
|
|
2555
|
-
|
|
2603
|
+
addServiceClass(sourceFile, controllerName, operations) {
|
|
2604
|
+
const className = `${controllerName}Service`;
|
|
2605
|
+
const basePathTokenName = getBasePathTokenName(this.config.clientName);
|
|
2606
|
+
const clientContextTokenName = getClientContextTokenName(this.config.clientName);
|
|
2607
|
+
sourceFile.insertText(0, SERVICE_GENERATOR_HEADER_COMMENT(controllerName));
|
|
2556
2608
|
sourceFile.addImportDeclarations([
|
|
2557
2609
|
{
|
|
2558
2610
|
namedImports: [
|
|
2611
|
+
"HttpClient",
|
|
2612
|
+
"HttpContext",
|
|
2613
|
+
"HttpContextToken",
|
|
2614
|
+
"HttpEvent",
|
|
2615
|
+
"HttpHeaders",
|
|
2616
|
+
"HttpParams",
|
|
2617
|
+
"HttpResponse"
|
|
2618
|
+
],
|
|
2619
|
+
moduleSpecifier: "@angular/common/http"
|
|
2620
|
+
},
|
|
2621
|
+
{
|
|
2622
|
+
namedImports: [
|
|
2623
|
+
"inject",
|
|
2559
2624
|
"Injectable"
|
|
2560
2625
|
],
|
|
2561
2626
|
moduleSpecifier: "@angular/core"
|
|
2627
|
+
},
|
|
2628
|
+
{
|
|
2629
|
+
namedImports: [
|
|
2630
|
+
"Observable"
|
|
2631
|
+
],
|
|
2632
|
+
moduleSpecifier: "rxjs"
|
|
2633
|
+
},
|
|
2634
|
+
{
|
|
2635
|
+
namedImports: [
|
|
2636
|
+
basePathTokenName,
|
|
2637
|
+
clientContextTokenName
|
|
2638
|
+
],
|
|
2639
|
+
moduleSpecifier: "../tokens"
|
|
2640
|
+
},
|
|
2641
|
+
{
|
|
2642
|
+
namedImports: [
|
|
2643
|
+
"HttpParamsBuilder"
|
|
2644
|
+
],
|
|
2645
|
+
moduleSpecifier: "../utils/http-params-builder"
|
|
2562
2646
|
}
|
|
2563
2647
|
]);
|
|
2564
|
-
}
|
|
2565
|
-
addServiceClass(sourceFile, controllerName, operations) {
|
|
2566
|
-
const className = `${controllerName}Service`;
|
|
2567
|
-
const basePathTokenName = getBasePathTokenName(this.config.clientName);
|
|
2568
|
-
const clientContextTokenName = getClientContextTokenName(this.config.clientName);
|
|
2569
|
-
sourceFile.insertText(0, SERVICE_GENERATOR_HEADER_COMMENT(controllerName));
|
|
2570
2648
|
const serviceClass = sourceFile.addClass({
|
|
2571
2649
|
name: className,
|
|
2572
2650
|
isExported: true,
|
package/index.d.ts
CHANGED
|
@@ -241,6 +241,7 @@ type placeHolder = {};
|
|
|
241
241
|
|
|
242
242
|
declare function getClientContextTokenName(clientName?: string): string;
|
|
243
243
|
declare function getBasePathTokenName(clientName?: string): string;
|
|
244
|
+
declare function getInterceptorsTokenName(clientName?: string): string;
|
|
244
245
|
|
|
245
246
|
declare function hasDuplicateFunctionNames<T extends MethodDeclaration | FunctionDeclaration>(arr: T[]): boolean;
|
|
246
247
|
|
|
@@ -286,4 +287,4 @@ declare function validateInput(inputPath: string): void;
|
|
|
286
287
|
*/
|
|
287
288
|
declare function generateFromConfig(config: GeneratorConfig): Promise<void>;
|
|
288
289
|
|
|
289
|
-
export { BASE_INTERCEPTOR_HEADER_COMMENT, CONTENT_TYPES, type EnumValueObject, type GeneratorConfig, type GetMethodGenerationContext, HTTP_RESOURCE_GENERATOR_HEADER_COMMENT, type IPluginGenerator, type IPluginGeneratorClass, MAIN_INDEX_GENERATOR_HEADER_COMMENT, type MethodGenerationContext, type NgOpenapiClientConfig, PROVIDER_GENERATOR_HEADER_COMMENT, type Parameter, type PathInfo, type RequestBody, SERVICE_GENERATOR_HEADER_COMMENT, SERVICE_INDEX_GENERATOR_HEADER_COMMENT, type SwaggerDefinition, SwaggerParser, type SwaggerResponse, type SwaggerSpec, TYPE_GENERATOR_HEADER_COMMENT, type TypeSchema, ZOD_PLUGIN_GENERATOR_HEADER_COMMENT, ZOD_PLUGIN_INDEX_GENERATOR_HEADER_COMMENT, camelCase, escapeString, extractPaths, generateFromConfig, generateParseRequestTypeParams, getBasePathTokenName, getClientContextTokenName, getRequestBodyType, getResponseType, getResponseTypeFromResponse, getTypeScriptType, hasDuplicateFunctionNames, inferResponseTypeFromContentType, isDataTypeInterface, isPrimitiveType, kebabCase, nullableType, pascalCase, type placeHolder, screamingSnakeCase, validateInput };
|
|
290
|
+
export { BASE_INTERCEPTOR_HEADER_COMMENT, CONTENT_TYPES, type EnumValueObject, type GeneratorConfig, type GetMethodGenerationContext, HTTP_RESOURCE_GENERATOR_HEADER_COMMENT, type IPluginGenerator, type IPluginGeneratorClass, MAIN_INDEX_GENERATOR_HEADER_COMMENT, type MethodGenerationContext, type NgOpenapiClientConfig, PROVIDER_GENERATOR_HEADER_COMMENT, type Parameter, type PathInfo, type RequestBody, SERVICE_GENERATOR_HEADER_COMMENT, SERVICE_INDEX_GENERATOR_HEADER_COMMENT, type SwaggerDefinition, SwaggerParser, type SwaggerResponse, type SwaggerSpec, TYPE_GENERATOR_HEADER_COMMENT, type TypeSchema, ZOD_PLUGIN_GENERATOR_HEADER_COMMENT, ZOD_PLUGIN_INDEX_GENERATOR_HEADER_COMMENT, camelCase, escapeString, extractPaths, generateFromConfig, generateParseRequestTypeParams, getBasePathTokenName, getClientContextTokenName, getInterceptorsTokenName, getRequestBodyType, getResponseType, getResponseTypeFromResponse, getTypeScriptType, hasDuplicateFunctionNames, inferResponseTypeFromContentType, isDataTypeInterface, isPrimitiveType, kebabCase, nullableType, pascalCase, type placeHolder, screamingSnakeCase, validateInput };
|
package/index.js
CHANGED
|
@@ -91,6 +91,7 @@ __export(index_exports, {
|
|
|
91
91
|
generateParseRequestTypeParams: () => generateParseRequestTypeParams,
|
|
92
92
|
getBasePathTokenName: () => getBasePathTokenName,
|
|
93
93
|
getClientContextTokenName: () => getClientContextTokenName,
|
|
94
|
+
getInterceptorsTokenName: () => getInterceptorsTokenName,
|
|
94
95
|
getRequestBodyType: () => getRequestBodyType,
|
|
95
96
|
getResponseType: () => getResponseType,
|
|
96
97
|
getResponseTypeFromResponse: () => getResponseTypeFromResponse,
|
|
@@ -208,6 +209,11 @@ function getBasePathTokenName(clientName = "default") {
|
|
|
208
209
|
return `BASE_PATH_${clientSuffix}`;
|
|
209
210
|
}
|
|
210
211
|
__name(getBasePathTokenName, "getBasePathTokenName");
|
|
212
|
+
function getInterceptorsTokenName(clientName = "default") {
|
|
213
|
+
const clientSuffix = clientName.toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
214
|
+
return `HTTP_INTERCEPTORS_${clientSuffix}`;
|
|
215
|
+
}
|
|
216
|
+
__name(getInterceptorsTokenName, "getInterceptorsTokenName");
|
|
211
217
|
|
|
212
218
|
// ../shared/src/utils/functions/duplicate-function-name.ts
|
|
213
219
|
function hasDuplicateFunctionNames(arr) {
|
|
@@ -1134,19 +1140,21 @@ var _TokenGenerator = class _TokenGenerator {
|
|
|
1134
1140
|
const sourceFile = this.project.createSourceFile(filePath, "", {
|
|
1135
1141
|
overwrite: true
|
|
1136
1142
|
});
|
|
1137
|
-
sourceFile.
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1143
|
+
sourceFile.addImportDeclarations([
|
|
1144
|
+
{
|
|
1145
|
+
namedImports: [
|
|
1146
|
+
"InjectionToken"
|
|
1147
|
+
],
|
|
1148
|
+
moduleSpecifier: "@angular/core"
|
|
1149
|
+
},
|
|
1150
|
+
{
|
|
1151
|
+
namedImports: [
|
|
1152
|
+
"HttpInterceptor",
|
|
1153
|
+
"HttpContextToken"
|
|
1154
|
+
],
|
|
1155
|
+
moduleSpecifier: "@angular/common/http"
|
|
1156
|
+
}
|
|
1157
|
+
]);
|
|
1150
1158
|
const basePathTokenName = this.getBasePathTokenName();
|
|
1151
1159
|
const interceptorsTokenName = this.getInterceptorsTokenName();
|
|
1152
1160
|
const clientContextTokenName = this.getClientContextTokenName();
|
|
@@ -1260,6 +1268,15 @@ var _FileDownloadGenerator = class _FileDownloadGenerator {
|
|
|
1260
1268
|
const sourceFile = this.project.createSourceFile(filePath, "", {
|
|
1261
1269
|
overwrite: true
|
|
1262
1270
|
});
|
|
1271
|
+
sourceFile.addImportDeclarations([
|
|
1272
|
+
{
|
|
1273
|
+
namedImports: [
|
|
1274
|
+
"Observable",
|
|
1275
|
+
"tap"
|
|
1276
|
+
],
|
|
1277
|
+
moduleSpecifier: "rxjs"
|
|
1278
|
+
}
|
|
1279
|
+
]);
|
|
1263
1280
|
sourceFile.addFunction({
|
|
1264
1281
|
name: "downloadFile",
|
|
1265
1282
|
isExported: true,
|
|
@@ -1369,7 +1386,7 @@ var _FileDownloadGenerator = class _FileDownloadGenerator {
|
|
|
1369
1386
|
|
|
1370
1387
|
return fallbackFilename;`
|
|
1371
1388
|
});
|
|
1372
|
-
sourceFile.
|
|
1389
|
+
sourceFile.formatText();
|
|
1373
1390
|
sourceFile.saveSync();
|
|
1374
1391
|
}
|
|
1375
1392
|
};
|
|
@@ -1390,6 +1407,31 @@ var _DateTransformerGenerator = class _DateTransformerGenerator {
|
|
|
1390
1407
|
const sourceFile = this.project.createSourceFile(filePath, "", {
|
|
1391
1408
|
overwrite: true
|
|
1392
1409
|
});
|
|
1410
|
+
sourceFile.addImportDeclarations([
|
|
1411
|
+
{
|
|
1412
|
+
namedImports: [
|
|
1413
|
+
"HttpEvent",
|
|
1414
|
+
"HttpHandler",
|
|
1415
|
+
"HttpInterceptor",
|
|
1416
|
+
"HttpRequest",
|
|
1417
|
+
"HttpResponse"
|
|
1418
|
+
],
|
|
1419
|
+
moduleSpecifier: "@angular/common/http"
|
|
1420
|
+
},
|
|
1421
|
+
{
|
|
1422
|
+
namedImports: [
|
|
1423
|
+
"Injectable"
|
|
1424
|
+
],
|
|
1425
|
+
moduleSpecifier: "@angular/core"
|
|
1426
|
+
},
|
|
1427
|
+
{
|
|
1428
|
+
namedImports: [
|
|
1429
|
+
"Observable",
|
|
1430
|
+
"map"
|
|
1431
|
+
],
|
|
1432
|
+
moduleSpecifier: "rxjs"
|
|
1433
|
+
}
|
|
1434
|
+
]);
|
|
1393
1435
|
sourceFile.addVariableStatement({
|
|
1394
1436
|
isExported: true,
|
|
1395
1437
|
declarationKind: import_ts_morph3.VariableDeclarationKind.Const,
|
|
@@ -1476,7 +1518,7 @@ var _DateTransformerGenerator = class _DateTransformerGenerator {
|
|
|
1476
1518
|
}
|
|
1477
1519
|
]
|
|
1478
1520
|
});
|
|
1479
|
-
sourceFile.
|
|
1521
|
+
sourceFile.formatText();
|
|
1480
1522
|
sourceFile.saveSync();
|
|
1481
1523
|
}
|
|
1482
1524
|
};
|
|
@@ -1547,8 +1589,8 @@ var _ProviderGenerator = class _ProviderGenerator {
|
|
|
1547
1589
|
overwrite: true
|
|
1548
1590
|
});
|
|
1549
1591
|
sourceFile.insertText(0, PROVIDER_GENERATOR_HEADER_COMMENT);
|
|
1550
|
-
const basePathTokenName = this.
|
|
1551
|
-
const interceptorsTokenName = this.
|
|
1592
|
+
const basePathTokenName = getBasePathTokenName(this.clientName);
|
|
1593
|
+
const interceptorsTokenName = getInterceptorsTokenName(this.clientName);
|
|
1552
1594
|
const baseInterceptorClassName = `${this.capitalizeFirst(this.clientName)}BaseInterceptor`;
|
|
1553
1595
|
sourceFile.addImportDeclarations([
|
|
1554
1596
|
{
|
|
@@ -1721,14 +1763,6 @@ return makeEnvironmentProviders(providers);`;
|
|
|
1721
1763
|
});
|
|
1722
1764
|
}
|
|
1723
1765
|
}
|
|
1724
|
-
getBasePathTokenName() {
|
|
1725
|
-
const clientSuffix = this.clientName.toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
1726
|
-
return `BASE_PATH_${clientSuffix}`;
|
|
1727
|
-
}
|
|
1728
|
-
getInterceptorsTokenName() {
|
|
1729
|
-
const clientSuffix = this.clientName.toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
1730
|
-
return `HTTP_INTERCEPTORS_${clientSuffix}`;
|
|
1731
|
-
}
|
|
1732
1766
|
capitalizeFirst(str) {
|
|
1733
1767
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1734
1768
|
}
|
|
@@ -1754,14 +1788,38 @@ var _BaseInterceptorGenerator = class _BaseInterceptorGenerator {
|
|
|
1754
1788
|
overwrite: true
|
|
1755
1789
|
});
|
|
1756
1790
|
sourceFile.insertText(0, BASE_INTERCEPTOR_HEADER_COMMENT(__privateGet(this, _clientName)));
|
|
1757
|
-
const interceptorsTokenName =
|
|
1758
|
-
const clientContextTokenName =
|
|
1791
|
+
const interceptorsTokenName = getInterceptorsTokenName(__privateGet(this, _clientName));
|
|
1792
|
+
const clientContextTokenName = getClientContextTokenName(__privateGet(this, _clientName));
|
|
1759
1793
|
sourceFile.addImportDeclarations([
|
|
1760
1794
|
{
|
|
1761
1795
|
namedImports: [
|
|
1796
|
+
"HttpContextToken",
|
|
1797
|
+
"HttpEvent",
|
|
1798
|
+
"HttpHandler",
|
|
1799
|
+
"HttpInterceptor",
|
|
1800
|
+
"HttpRequest"
|
|
1801
|
+
],
|
|
1802
|
+
moduleSpecifier: "@angular/common/http"
|
|
1803
|
+
},
|
|
1804
|
+
{
|
|
1805
|
+
namedImports: [
|
|
1806
|
+
"inject",
|
|
1762
1807
|
"Injectable"
|
|
1763
1808
|
],
|
|
1764
1809
|
moduleSpecifier: "@angular/core"
|
|
1810
|
+
},
|
|
1811
|
+
{
|
|
1812
|
+
namedImports: [
|
|
1813
|
+
"Observable"
|
|
1814
|
+
],
|
|
1815
|
+
moduleSpecifier: "rxjs"
|
|
1816
|
+
},
|
|
1817
|
+
{
|
|
1818
|
+
namedImports: [
|
|
1819
|
+
clientContextTokenName,
|
|
1820
|
+
interceptorsTokenName
|
|
1821
|
+
],
|
|
1822
|
+
moduleSpecifier: "../tokens"
|
|
1765
1823
|
}
|
|
1766
1824
|
]);
|
|
1767
1825
|
sourceFile.addClass({
|
|
@@ -1827,17 +1885,9 @@ var _BaseInterceptorGenerator = class _BaseInterceptorGenerator {
|
|
|
1827
1885
|
}
|
|
1828
1886
|
]
|
|
1829
1887
|
});
|
|
1830
|
-
sourceFile.
|
|
1888
|
+
sourceFile.formatText();
|
|
1831
1889
|
sourceFile.saveSync();
|
|
1832
1890
|
}
|
|
1833
|
-
getInterceptorsTokenName() {
|
|
1834
|
-
const clientSuffix = __privateGet(this, _clientName).toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
1835
|
-
return `HTTP_INTERCEPTORS_${clientSuffix}`;
|
|
1836
|
-
}
|
|
1837
|
-
getClientContextTokenName() {
|
|
1838
|
-
const clientSuffix = __privateGet(this, _clientName).toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
1839
|
-
return `CLIENT_CONTEXT_TOKEN_${clientSuffix}`;
|
|
1840
|
-
}
|
|
1841
1891
|
capitalizeFirst(str) {
|
|
1842
1892
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
1843
1893
|
}
|
|
@@ -2681,27 +2731,56 @@ var _ServiceGenerator = class _ServiceGenerator {
|
|
|
2681
2731
|
const sourceFile = this.project.createSourceFile(filePath, "", {
|
|
2682
2732
|
overwrite: true
|
|
2683
2733
|
});
|
|
2684
|
-
this.addImports(sourceFile);
|
|
2685
2734
|
this.addServiceClass(sourceFile, controllerName, operations);
|
|
2686
|
-
sourceFile.fixMissingImports().
|
|
2735
|
+
sourceFile.fixMissingImports().formatText();
|
|
2687
2736
|
sourceFile.saveSync();
|
|
2688
2737
|
});
|
|
2689
2738
|
}
|
|
2690
|
-
|
|
2739
|
+
addServiceClass(sourceFile, controllerName, operations) {
|
|
2740
|
+
const className = `${controllerName}Service`;
|
|
2741
|
+
const basePathTokenName = getBasePathTokenName(this.config.clientName);
|
|
2742
|
+
const clientContextTokenName = getClientContextTokenName(this.config.clientName);
|
|
2743
|
+
sourceFile.insertText(0, SERVICE_GENERATOR_HEADER_COMMENT(controllerName));
|
|
2691
2744
|
sourceFile.addImportDeclarations([
|
|
2692
2745
|
{
|
|
2693
2746
|
namedImports: [
|
|
2747
|
+
"HttpClient",
|
|
2748
|
+
"HttpContext",
|
|
2749
|
+
"HttpContextToken",
|
|
2750
|
+
"HttpEvent",
|
|
2751
|
+
"HttpHeaders",
|
|
2752
|
+
"HttpParams",
|
|
2753
|
+
"HttpResponse"
|
|
2754
|
+
],
|
|
2755
|
+
moduleSpecifier: "@angular/common/http"
|
|
2756
|
+
},
|
|
2757
|
+
{
|
|
2758
|
+
namedImports: [
|
|
2759
|
+
"inject",
|
|
2694
2760
|
"Injectable"
|
|
2695
2761
|
],
|
|
2696
2762
|
moduleSpecifier: "@angular/core"
|
|
2763
|
+
},
|
|
2764
|
+
{
|
|
2765
|
+
namedImports: [
|
|
2766
|
+
"Observable"
|
|
2767
|
+
],
|
|
2768
|
+
moduleSpecifier: "rxjs"
|
|
2769
|
+
},
|
|
2770
|
+
{
|
|
2771
|
+
namedImports: [
|
|
2772
|
+
basePathTokenName,
|
|
2773
|
+
clientContextTokenName
|
|
2774
|
+
],
|
|
2775
|
+
moduleSpecifier: "../tokens"
|
|
2776
|
+
},
|
|
2777
|
+
{
|
|
2778
|
+
namedImports: [
|
|
2779
|
+
"HttpParamsBuilder"
|
|
2780
|
+
],
|
|
2781
|
+
moduleSpecifier: "../utils/http-params-builder"
|
|
2697
2782
|
}
|
|
2698
2783
|
]);
|
|
2699
|
-
}
|
|
2700
|
-
addServiceClass(sourceFile, controllerName, operations) {
|
|
2701
|
-
const className = `${controllerName}Service`;
|
|
2702
|
-
const basePathTokenName = getBasePathTokenName(this.config.clientName);
|
|
2703
|
-
const clientContextTokenName = getClientContextTokenName(this.config.clientName);
|
|
2704
|
-
sourceFile.insertText(0, SERVICE_GENERATOR_HEADER_COMMENT(controllerName));
|
|
2705
2784
|
const serviceClass = sourceFile.addClass({
|
|
2706
2785
|
name: className,
|
|
2707
2786
|
isExported: true,
|
|
@@ -2910,6 +2989,7 @@ __name(generateFromConfig, "generateFromConfig");
|
|
|
2910
2989
|
generateParseRequestTypeParams,
|
|
2911
2990
|
getBasePathTokenName,
|
|
2912
2991
|
getClientContextTokenName,
|
|
2992
|
+
getInterceptorsTokenName,
|
|
2913
2993
|
getRequestBodyType,
|
|
2914
2994
|
getResponseType,
|
|
2915
2995
|
getResponseTypeFromResponse,
|