ts-openapi-codegen 2.0.0-beta.4 → 2.0.0-beta.6
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/dist/cli/index.js +6 -4
- package/dist/cli/initOpenApiConfig/Types.d.ts +5 -0
- package/dist/cli/initOpenApiConfig/Types.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/init.d.ts +6 -0
- package/dist/cli/initOpenApiConfig/init.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/init.js +61 -0
- package/dist/cli/initOpenApiConfig/initConfig.d.ts +11 -0
- package/dist/cli/initOpenApiConfig/initConfig.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/initConfig.js +102 -0
- package/dist/cli/initOpenApiConfig/initCustomRequest.d.ts +3 -0
- package/dist/cli/initOpenApiConfig/initCustomRequest.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/initCustomRequest.js +23 -0
- package/dist/cli/initOpenApiConfig/utils/buildConfig.d.ts +21 -0
- package/dist/cli/initOpenApiConfig/utils/buildConfig.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/utils/buildConfig.js +107 -0
- package/dist/cli/initOpenApiConfig/utils/findSpecFiles.d.ts +8 -0
- package/dist/cli/initOpenApiConfig/utils/findSpecFiles.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/utils/findSpecFiles.js +40 -0
- package/dist/cli/initOpenApiConfig/utils/registerHandlebarTemplates.d.ts +3 -0
- package/dist/cli/initOpenApiConfig/utils/registerHandlebarTemplates.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/utils/registerHandlebarTemplates.js +53 -0
- package/dist/cli/initOpenApiConfig/utils/validateSpecFile.d.ts +7 -0
- package/dist/cli/initOpenApiConfig/utils/validateSpecFile.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/utils/validateSpecFile.js +23 -0
- package/dist/cli/initOpenApiConfig/utils/validateSpecFiles.d.ts +11 -0
- package/dist/cli/initOpenApiConfig/utils/validateSpecFiles.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/utils/validateSpecFiles.js +24 -0
- package/dist/cli/initOpenApiConfig/utils/writeConfigFile.d.ts +11 -0
- package/dist/cli/initOpenApiConfig/utils/writeConfigFile.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/utils/writeConfigFile.js +31 -0
- package/dist/cli/schemas/init.d.ts +4 -2
- package/dist/cli/schemas/init.d.ts.map +1 -1
- package/dist/cli/schemas/init.js +5 -2
- package/dist/common/Consts.d.ts +3 -0
- package/dist/common/Consts.d.ts.map +1 -1
- package/dist/common/Consts.js +4 -1
- package/dist/common/utils/fileSystemHelpers.d.ts +2 -0
- package/dist/common/utils/fileSystemHelpers.d.ts.map +1 -1
- package/dist/common/utils/fileSystemHelpers.js +9 -0
- package/dist/core/WriteClient.d.ts +3 -1
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +8 -0
- package/dist/core/__tests__/WriteClient.test.js +2 -1
- package/dist/core/types/base/ClientArtifacts.model.d.ts +1 -1
- package/dist/core/types/base/ClientArtifacts.model.d.ts.map +1 -1
- package/dist/core/types/base/SimpleClientArtifacts.model.d.ts +1 -1
- package/dist/core/types/base/SimpleClientArtifacts.model.d.ts.map +1 -1
- package/dist/core/types/base/Templates.model.d.ts +29 -0
- package/dist/core/types/base/Templates.model.d.ts.map +1 -0
- package/dist/core/types/base/Templates.model.js +2 -0
- package/dist/core/utils/__mocks__/templates.d.ts +1 -1
- package/dist/core/utils/__mocks__/templates.d.ts.map +1 -1
- package/dist/core/utils/__mocks__/templates.js +2 -1
- package/dist/core/utils/__tests__/resolveRefToImportPath.test.js +73 -0
- package/dist/core/utils/precompileTemplates.js +1 -0
- package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarHelpers.js +11 -0
- package/dist/core/utils/registerHandlebarTemplates.d.ts +1 -27
- package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarTemplates.js +4 -2
- package/dist/core/utils/resolveRefToImportPath.d.ts.map +1 -1
- package/dist/core/utils/resolveRefToImportPath.js +7 -6
- package/dist/core/utils/writeClientCore.d.ts +1 -1
- package/dist/core/utils/writeClientCore.d.ts.map +1 -1
- package/dist/core/utils/writeClientCore.js +3 -2
- package/dist/core/utils/writeClientCoreIndex.d.ts +1 -1
- package/dist/core/utils/writeClientCoreIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientExecutor.d.ts +12 -0
- package/dist/core/utils/writeClientExecutor.d.ts.map +1 -0
- package/dist/core/utils/writeClientExecutor.js +18 -0
- package/dist/core/utils/writeClientFullIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientFullIndex.js +1 -1
- package/dist/core/utils/writeClientModels.d.ts +1 -1
- package/dist/core/utils/writeClientModels.d.ts.map +1 -1
- package/dist/core/utils/writeClientModelsIndex.d.ts +1 -1
- package/dist/core/utils/writeClientModelsIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemas.d.ts +1 -1
- package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemasIndex.d.ts +1 -1
- package/dist/core/utils/writeClientSchemasIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientServices.d.ts +1 -1
- package/dist/core/utils/writeClientServices.d.ts.map +1 -1
- package/dist/core/utils/writeClientServicesIndex.d.ts +1 -1
- package/dist/core/utils/writeClientServicesIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientSimpleIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientSimpleIndex.js +1 -1
- package/dist/templatesCompiled/cli/customRequest.d.ts +11 -0
- package/dist/templatesCompiled/cli/customRequest.d.ts.map +1 -0
- package/dist/templatesCompiled/cli/customRequest.js +27 -0
- package/dist/templatesCompiled/cli/customRequestExecutor.d.ts +11 -0
- package/dist/templatesCompiled/cli/customRequestExecutor.d.ts.map +1 -0
- package/dist/templatesCompiled/cli/customRequestExecutor.js +27 -0
- package/dist/templatesCompiled/cli/openApiConfig.d.ts +2 -1
- package/dist/templatesCompiled/cli/openApiConfig.d.ts.map +1 -1
- package/dist/templatesCompiled/cli/openApiConfig.js +76 -4
- package/dist/templatesCompiled/client/core/createExecutorAdapter.d.ts +12 -0
- package/dist/templatesCompiled/client/core/createExecutorAdapter.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/createExecutorAdapter.js +32 -0
- package/dist/templatesCompiled/client/{core/legacy-request-adapter.d.ts → exportClient.d.ts} +3 -1
- package/dist/templatesCompiled/client/exportClient.d.ts.map +1 -0
- package/dist/templatesCompiled/client/exportClient.js +49 -0
- package/dist/templatesCompiled/client/indexCore.js +2 -2
- package/dist/templatesCompiled/client/indexFull.d.ts +12 -9
- package/dist/templatesCompiled/client/indexFull.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexFull.js +69 -46
- package/dist/templatesCompiled/client/indexSimple.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexSimple.js +2 -1
- package/dist/templatesCompiled/client/partials/serviceOption.d.ts +2 -1
- package/dist/templatesCompiled/client/partials/serviceOption.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/serviceOption.js +36 -30
- package/package.json +1 -1
- package/dist/cli/initOpenApiConfig/runInitOpenapiConfig.d.ts +0 -3
- package/dist/cli/initOpenApiConfig/runInitOpenapiConfig.d.ts.map +0 -1
- package/dist/cli/initOpenApiConfig/runInitOpenapiConfig.js +0 -70
- package/dist/templatesCompiled/client/core/legacy-request-adapter.d.ts.map +0 -1
- package/dist/templatesCompiled/client/core/legacy-request-adapter.js +0 -18
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.writeConfigFile = writeConfigFile;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const Consts_1 = require("../../../common/Consts");
|
|
9
|
+
const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
|
|
10
|
+
const format_1 = require("../../../common/utils/format");
|
|
11
|
+
const pathHelpers_1 = require("../../../common/utils/pathHelpers");
|
|
12
|
+
/**
|
|
13
|
+
* Записывает конфигурацию в файл
|
|
14
|
+
* @param configPath - Путь к файлу конфигурации
|
|
15
|
+
* @param config - Объект конфигурации для записи
|
|
16
|
+
* @param templates
|
|
17
|
+
* @throws {Error} Если не удалось записать файл
|
|
18
|
+
*/
|
|
19
|
+
async function writeConfigFile(configPath, config, templates) {
|
|
20
|
+
const resolvedPath = (0, pathHelpers_1.resolveHelper)(process.cwd(), configPath);
|
|
21
|
+
const configDir = path_1.default.dirname(resolvedPath);
|
|
22
|
+
// Создаем директорию, если она не существует
|
|
23
|
+
const dirExists = await fileSystemHelpers_1.fileSystemHelpers.exists(configDir);
|
|
24
|
+
if (!dirExists) {
|
|
25
|
+
await fileSystemHelpers_1.fileSystemHelpers.mkdir(configDir);
|
|
26
|
+
}
|
|
27
|
+
const templateResult = templates.config(config);
|
|
28
|
+
const formattedValue = await (0, format_1.format)(templateResult, 'json');
|
|
29
|
+
await fileSystemHelpers_1.fileSystemHelpers.writeFile(resolvedPath, formattedValue);
|
|
30
|
+
Consts_1.APP_LOGGER.info(`Configuration file created: ${resolvedPath}`);
|
|
31
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { EOptionType } from '../initOpenApiConfig/Enums';
|
|
3
2
|
export declare const initOptionsSchema: z.ZodObject<{
|
|
4
3
|
openapiConfig: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
5
|
-
|
|
4
|
+
specsDir: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
5
|
+
request: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
6
|
+
useCancelableRequest: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
7
|
+
useInteractiveMode: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
6
8
|
}, z.core.$strip>;
|
|
7
9
|
export type InitOptions = z.infer<typeof initOptionsSchema>;
|
|
8
10
|
//# sourceMappingURL=init.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/schemas/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/schemas/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,iBAAiB;;;;;;iBAK5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
package/dist/cli/schemas/init.js
CHANGED
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initOptionsSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
5
|
+
const Consts_1 = require("../../common/Consts");
|
|
6
6
|
const base_1 = require("./base");
|
|
7
7
|
exports.initOptionsSchema = base_1.baseCLIOptionsSchema.extend({
|
|
8
|
-
|
|
8
|
+
specsDir: zod_1.z.string().min(1).optional().default(Consts_1.DEFAULT_SPECS_DIR),
|
|
9
|
+
request: zod_1.z.string().min(1).optional().default(Consts_1.DEFAULT_CUSTOM_REQUEST_PATH),
|
|
10
|
+
useCancelableRequest: zod_1.z.boolean().optional().default(false),
|
|
11
|
+
useInteractiveMode: zod_1.z.boolean().optional().default(false),
|
|
9
12
|
});
|
package/dist/common/Consts.d.ts
CHANGED
|
@@ -3,4 +3,7 @@ import { TStrictFlatOptions } from './TRawOptions';
|
|
|
3
3
|
export declare const DEFAULT_OPENAPI_CONFIG_FILENAME = "openapi.config.json";
|
|
4
4
|
export declare const COMMON_DEFAULT_OPTIONS_VALUES: TStrictFlatOptions;
|
|
5
5
|
export declare const APP_LOGGER: Logger;
|
|
6
|
+
export declare const DEFAULT_SPECS_DIR = "openapi/";
|
|
7
|
+
export declare const DEFAULT_CUSTOM_REQUEST_PATH = "./src/custom/request.ts";
|
|
8
|
+
export declare const DEFAULT_OUTPUT_API_DIR = "./generated";
|
|
6
9
|
//# sourceMappingURL=Consts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Consts.d.ts","sourceRoot":"","sources":["../../src/common/Consts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,eAAO,MAAM,+BAA+B,wBAAwB,CAAC;AAErE,eAAO,MAAM,6BAA6B,EAAE,kBAqB3C,CAAC;AAEF,eAAO,MAAM,UAAU,QAIrB,CAAC"}
|
|
1
|
+
{"version":3,"file":"Consts.d.ts","sourceRoot":"","sources":["../../src/common/Consts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,eAAO,MAAM,+BAA+B,wBAAwB,CAAC;AAErE,eAAO,MAAM,6BAA6B,EAAE,kBAqB3C,CAAC;AAEF,eAAO,MAAM,UAAU,QAIrB,CAAC;AAEH,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAE5C,eAAO,MAAM,2BAA2B,4BAA4B,CAAA;AAEpE,eAAO,MAAM,sBAAsB,gBAAgB,CAAC"}
|
package/dist/common/Consts.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.APP_LOGGER = exports.COMMON_DEFAULT_OPTIONS_VALUES = exports.DEFAULT_OPENAPI_CONFIG_FILENAME = void 0;
|
|
3
|
+
exports.DEFAULT_OUTPUT_API_DIR = exports.DEFAULT_CUSTOM_REQUEST_PATH = exports.DEFAULT_SPECS_DIR = exports.APP_LOGGER = exports.COMMON_DEFAULT_OPTIONS_VALUES = exports.DEFAULT_OPENAPI_CONFIG_FILENAME = void 0;
|
|
4
4
|
const HttpClient_enum_1 = require("../core/types/enums/HttpClient.enum");
|
|
5
5
|
const ValidationLibrary_enum_1 = require("../core/types/enums/ValidationLibrary.enum");
|
|
6
6
|
const Enums_1 = require("./Enums");
|
|
@@ -33,3 +33,6 @@ exports.APP_LOGGER = new Logger_1.Logger({
|
|
|
33
33
|
instanceId: 'cli',
|
|
34
34
|
logOutput: Enums_1.ELogOutput.CONSOLE,
|
|
35
35
|
});
|
|
36
|
+
exports.DEFAULT_SPECS_DIR = 'openapi/';
|
|
37
|
+
exports.DEFAULT_CUSTOM_REQUEST_PATH = './src/custom/request.ts';
|
|
38
|
+
exports.DEFAULT_OUTPUT_API_DIR = './generated';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { copyFile as __copyFile, exists as __exists, readdir as __readdir, readFile as __readFile, writeFile as __writeFile } from 'fs';
|
|
2
2
|
declare function isDirectory(path: string): boolean;
|
|
3
3
|
declare function isPathToFile(path: string): boolean;
|
|
4
|
+
declare function isSameFilePath(a: string, b: string): boolean;
|
|
4
5
|
declare const fileSystemHelpers: {
|
|
5
6
|
readFile: typeof __readFile.__promisify__;
|
|
6
7
|
writeFile: typeof __writeFile.__promisify__;
|
|
@@ -12,6 +13,7 @@ declare const fileSystemHelpers: {
|
|
|
12
13
|
isDirectory: typeof isDirectory;
|
|
13
14
|
isPathToFile: typeof isPathToFile;
|
|
14
15
|
readdir: typeof __readdir.__promisify__;
|
|
16
|
+
isSameFilePath: typeof isSameFilePath;
|
|
15
17
|
};
|
|
16
18
|
export { fileSystemHelpers };
|
|
17
19
|
//# sourceMappingURL=fileSystemHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileSystemHelpers.d.ts","sourceRoot":"","sources":["../../../src/common/utils/fileSystemHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,IAAI,UAAU,EAEtB,MAAM,IAAI,QAAQ,EAElB,OAAO,IAAI,SAAS,EACpB,QAAQ,IAAI,UAAU,
|
|
1
|
+
{"version":3,"file":"fileSystemHelpers.d.ts","sourceRoot":"","sources":["../../../src/common/utils/fileSystemHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,IAAI,UAAU,EAEtB,MAAM,IAAI,QAAQ,EAElB,OAAO,IAAI,SAAS,EACpB,QAAQ,IAAI,UAAU,EAMtB,SAAS,IAAI,WAAW,EAC3B,MAAM,IAAI,CAAC;AA0DZ,iBAAS,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM1C;AAED,iBAAS,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM3C;AAED,iBAAS,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAMrD;AAED,QAAA,MAAM,iBAAiB;;;;;;kBA7DI,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;kBAgBtB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;;;;;CAyDhD,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -73,6 +73,14 @@ function isPathToFile(path) {
|
|
|
73
73
|
return false;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
+
function isSameFilePath(a, b) {
|
|
77
|
+
try {
|
|
78
|
+
return (0, fs_1.realpathSync)(a) === (0, fs_1.realpathSync)(b);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
76
84
|
const fileSystemHelpers = {
|
|
77
85
|
readFile,
|
|
78
86
|
writeFile,
|
|
@@ -84,5 +92,6 @@ const fileSystemHelpers = {
|
|
|
84
92
|
isDirectory,
|
|
85
93
|
isPathToFile,
|
|
86
94
|
readdir,
|
|
95
|
+
isSameFilePath,
|
|
87
96
|
};
|
|
88
97
|
exports.fileSystemHelpers = fileSystemHelpers;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Logger } from '../common/Logger';
|
|
2
2
|
import { OutputPaths } from './types/base/OutputPaths.model';
|
|
3
|
+
import { Templates } from './types/base/Templates.model';
|
|
3
4
|
import { HttpClient } from './types/enums/HttpClient.enum';
|
|
4
5
|
import { ValidationLibrary } from './types/enums/ValidationLibrary.enum';
|
|
5
6
|
import type { Client } from './types/shared/Client.model';
|
|
6
|
-
import { Templates } from './utils/registerHandlebarTemplates';
|
|
7
7
|
import { writeClientCore } from './utils/writeClientCore';
|
|
8
8
|
import { writeClientCoreIndex } from './utils/writeClientCoreIndex';
|
|
9
|
+
import { writeClientExecutor } from './utils/writeClientExecutor';
|
|
9
10
|
import { writeClientFullIndex } from './utils/writeClientFullIndex';
|
|
10
11
|
import { writeClientModels } from './utils/writeClientModels';
|
|
11
12
|
import { writeClientModelsIndex } from './utils/writeClientModelsIndex';
|
|
@@ -80,6 +81,7 @@ export declare class WriteClient {
|
|
|
80
81
|
writeClientServices: typeof writeClientServices;
|
|
81
82
|
writeClientServicesIndex: typeof writeClientServicesIndex;
|
|
82
83
|
writeClientSimpleIndex: typeof writeClientSimpleIndex;
|
|
84
|
+
writeClientExecutor: typeof writeClientExecutor;
|
|
83
85
|
}
|
|
84
86
|
export {};
|
|
85
87
|
//# sourceMappingURL=WriteClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WriteClient.d.ts","sourceRoot":"","sources":["../../src/core/WriteClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAM1C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"WriteClient.d.ts","sourceRoot":"","sources":["../../src/core/WriteClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAM1C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAI1D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE;;;;;;;;;;;;GAYG;AACH,KAAK,iBAAiB,GAAG;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,uBAAuB,EAAE,OAAO,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACzC,CAAC;AAEF,KAAK,yBAAyB,GAAG,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,YAAY,GAAG,SAAS,GAAG,sBAAsB,GAAG,qBAAqB,CAAC,CAAC;AAEnJ;;GAEG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAAuD;IACrE,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,CAAC,EAAE,MAAM;IAU3B;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsG5D;;;OAGG;IACH,6BAA6B,CAAC,MAAM,EAAE,yBAAyB;IAUzD,eAAe;IAKf,sBAAsB;IAK5B,IAAW,MAAM,WAEhB;IAED,OAAO,CAAC,yBAAyB;IAyCjC,OAAO,CAAC,mBAAmB;YA4Db,gBAAgB;YAUhB,uBAAuB;IAMrC,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,uBAAuB;IAe/B,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,aAAa;IAId,eAAe,yBAAmB;IAClC,oBAAoB,8BAAwB;IAC5C,oBAAoB,8BAAwB;IAC5C,iBAAiB,2BAAqB;IACtC,sBAAsB,gCAA0B;IAChD,kBAAkB,4BAAsB;IACxC,uBAAuB,iCAA2B;IAClD,mBAAmB,6BAAuB;IAC1C,wBAAwB,kCAA4B;IACpD,sBAAsB,gCAA0B;IAChD,mBAAmB,6BAAuB;CACpD"}
|
package/dist/core/WriteClient.js
CHANGED
|
@@ -11,6 +11,7 @@ const sortModelByName_1 = require("./utils/sortModelByName");
|
|
|
11
11
|
const unique_1 = require("./utils/unique");
|
|
12
12
|
const writeClientCore_1 = require("./utils/writeClientCore");
|
|
13
13
|
const writeClientCoreIndex_1 = require("./utils/writeClientCoreIndex");
|
|
14
|
+
const writeClientExecutor_1 = require("./utils/writeClientExecutor");
|
|
14
15
|
const writeClientFullIndex_1 = require("./utils/writeClientFullIndex");
|
|
15
16
|
const writeClientModels_1 = require("./utils/writeClientModels");
|
|
16
17
|
const writeClientModelsIndex_1 = require("./utils/writeClientModelsIndex");
|
|
@@ -69,6 +70,12 @@ class WriteClient {
|
|
|
69
70
|
outputServices,
|
|
70
71
|
useSeparatedIndexes,
|
|
71
72
|
});
|
|
73
|
+
await this.writeClientExecutor({
|
|
74
|
+
outputPath: outputPaths.output,
|
|
75
|
+
outputCorePath: (0, pathHelpers_1.relativeHelper)(outputPaths.output, outputCore),
|
|
76
|
+
services: client.services,
|
|
77
|
+
templates,
|
|
78
|
+
});
|
|
72
79
|
}
|
|
73
80
|
/**
|
|
74
81
|
* TODO: Нужно собирать импорты из всех вложенных моделей (link, properties в composition и т.д.) и передавать их в шаблон.
|
|
@@ -287,5 +294,6 @@ class WriteClient {
|
|
|
287
294
|
writeClientServices = writeClientServices_1.writeClientServices;
|
|
288
295
|
writeClientServicesIndex = writeClientServicesIndex_1.writeClientServicesIndex;
|
|
289
296
|
writeClientSimpleIndex = writeClientSimpleIndex_1.writeClientSimpleIndex;
|
|
297
|
+
writeClientExecutor = writeClientExecutor_1.writeClientExecutor;
|
|
290
298
|
}
|
|
291
299
|
exports.WriteClient = WriteClient;
|
|
@@ -40,6 +40,7 @@ const WriteClient_1 = require("../WriteClient");
|
|
|
40
40
|
services: () => 'servicesIndex',
|
|
41
41
|
},
|
|
42
42
|
exports: {
|
|
43
|
+
client: () => 'client',
|
|
43
44
|
model: () => 'model',
|
|
44
45
|
schema: () => 'schema',
|
|
45
46
|
service: () => 'service',
|
|
@@ -52,7 +53,7 @@ const WriteClient_1 = require("../WriteClient");
|
|
|
52
53
|
request: () => 'request',
|
|
53
54
|
cancelablePromise: () => 'cancelablePromise',
|
|
54
55
|
httpStatusCode: () => 'httpStatusCode',
|
|
55
|
-
|
|
56
|
+
createExecutorAdapter: () => 'createExecutorAdapter',
|
|
56
57
|
requestExecutor: () => 'requestExecutor',
|
|
57
58
|
},
|
|
58
59
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Templates } from "../../
|
|
1
|
+
import { Templates } from "../../types/base/Templates.model";
|
|
2
2
|
import { ExportedModel } from "./ExportedModel.model";
|
|
3
3
|
import { ExportedService } from "./ExportedService.model";
|
|
4
4
|
export type ClientArtifacts = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientArtifacts.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/ClientArtifacts.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ClientArtifacts.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/ClientArtifacts.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG;IAC1B,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC/B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleClientArtifacts.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/SimpleClientArtifacts.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"SimpleClientArtifacts.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/SimpleClientArtifacts.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAM,MAAM,qBAAqB,GAAG;IAChC,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACtB,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as Handlebars from 'handlebars/runtime';
|
|
2
|
+
export interface Templates {
|
|
3
|
+
indexes: {
|
|
4
|
+
full: Handlebars.TemplateDelegate;
|
|
5
|
+
simple: Handlebars.TemplateDelegate;
|
|
6
|
+
core: Handlebars.TemplateDelegate;
|
|
7
|
+
models: Handlebars.TemplateDelegate;
|
|
8
|
+
schemas: Handlebars.TemplateDelegate;
|
|
9
|
+
services: Handlebars.TemplateDelegate;
|
|
10
|
+
};
|
|
11
|
+
exports: {
|
|
12
|
+
client: Handlebars.TemplateDelegate;
|
|
13
|
+
model: Handlebars.TemplateDelegate;
|
|
14
|
+
schema: Handlebars.TemplateDelegate | undefined;
|
|
15
|
+
service: Handlebars.TemplateDelegate;
|
|
16
|
+
};
|
|
17
|
+
core: {
|
|
18
|
+
settings: Handlebars.TemplateDelegate;
|
|
19
|
+
apiError: Handlebars.TemplateDelegate;
|
|
20
|
+
apiRequestOptions: Handlebars.TemplateDelegate;
|
|
21
|
+
apiResult: Handlebars.TemplateDelegate;
|
|
22
|
+
request: Handlebars.TemplateDelegate;
|
|
23
|
+
cancelablePromise: Handlebars.TemplateDelegate;
|
|
24
|
+
httpStatusCode: Handlebars.TemplateDelegate;
|
|
25
|
+
requestExecutor: Handlebars.TemplateDelegate;
|
|
26
|
+
createExecutorAdapter: Handlebars.TemplateDelegate;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=Templates.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Templates.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/Templates.model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAEjD,MAAM,WAAW,SAAS;IACtB,OAAO,EAAE;QACL,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAClC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAClC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACrC,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACzC,CAAC;IACF,OAAO,EAAE;QACL,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,KAAK,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACnC,MAAM,EAAE,UAAU,CAAC,gBAAgB,GAAG,SAAS,CAAC;QAChD,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACxC,CAAC;IACF,IAAI,EAAE;QACF,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACtC,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACtC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC/C,SAAS,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACvC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACrC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC/C,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC5C,eAAe,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC7C,qBAAqB,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACtD,CAAC;CACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__mocks__/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__mocks__/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,eAAO,MAAM,SAAS,EAAE,SA0BvB,CAAC"}
|
|
@@ -11,6 +11,7 @@ exports.templates = {
|
|
|
11
11
|
services: () => 'servicesIndex',
|
|
12
12
|
},
|
|
13
13
|
exports: {
|
|
14
|
+
client: () => 'client',
|
|
14
15
|
model: () => 'model',
|
|
15
16
|
schema: () => 'schema',
|
|
16
17
|
service: () => 'service',
|
|
@@ -23,7 +24,7 @@ exports.templates = {
|
|
|
23
24
|
request: () => 'request',
|
|
24
25
|
cancelablePromise: () => 'cancelablePromise',
|
|
25
26
|
httpStatusCode: () => 'httpStatusCode',
|
|
26
|
-
|
|
27
|
+
createExecutorAdapter: () => 'createExecutorAdapter',
|
|
27
28
|
requestExecutor: () => 'requestExecutor',
|
|
28
29
|
},
|
|
29
30
|
};
|
|
@@ -183,6 +183,16 @@ const normalizePath = (p) => p.replace(Consts_1.REGEX_BACKSLASH, '/');
|
|
|
183
183
|
// so it returns relative path instead of fallback
|
|
184
184
|
node_assert_1.strict.equal(normalizePath(result), './spec/UserList');
|
|
185
185
|
});
|
|
186
|
+
(0, node_test_1.test)('EXTERNAL_FILE_FRAGMENT self-reference → treated as LOCAL_FRAGMENT', () => {
|
|
187
|
+
const parent = '/Users/user/Developer/my_app/openapi/app/spec/dir/some.yaml';
|
|
188
|
+
const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
|
|
189
|
+
mainSpecPath,
|
|
190
|
+
parentFilePath: parent,
|
|
191
|
+
refValuePath: '../some.yaml#/components/schemas/User',
|
|
192
|
+
outputModelsPath,
|
|
193
|
+
});
|
|
194
|
+
node_assert_1.strict.equal(normalizePath(result), './spec/dir/User');
|
|
195
|
+
});
|
|
186
196
|
});
|
|
187
197
|
(0, node_test_1.describe)('EXTERNAL_FILE', () => {
|
|
188
198
|
(0, node_test_1.test)('external link to the file → correct name via getClassName', () => {
|
|
@@ -246,6 +256,59 @@ const normalizePath = (p) => p.replace(Consts_1.REGEX_BACKSLASH, '/');
|
|
|
246
256
|
const normalized = normalizePath(result);
|
|
247
257
|
node_assert_1.strict.ok(normalized.includes('User') || normalized === './User');
|
|
248
258
|
});
|
|
259
|
+
node_test_1.test.skip('external file reference with parentFilePath as directory', () => {
|
|
260
|
+
const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
|
|
261
|
+
mainSpecPath: '/Developer/my-app/api/openapi_spec.yaml',
|
|
262
|
+
parentFilePath: '/Developer/my-app/api/ui/components/dir/some.yaml',
|
|
263
|
+
refValuePath: '../components/dir/file_name.yaml',
|
|
264
|
+
outputModelsPath: '/generated/models',
|
|
265
|
+
});
|
|
266
|
+
// NOTE:
|
|
267
|
+
// When parentFilePath is a directory, it is treated as a resolve base,
|
|
268
|
+
// not as a namespace to be duplicated.
|
|
269
|
+
node_assert_1.strict.equal(normalizePath(result), './ui/components/dir/FileName');
|
|
270
|
+
});
|
|
271
|
+
(0, node_test_1.test)('EXTERNAL_FILE self-reference via ./same.yaml → treated as LOCAL_FRAGMENT', () => {
|
|
272
|
+
const parent = '/Users/user/Developer/my_app/openapi/app/spec/dir/some.yaml';
|
|
273
|
+
const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
|
|
274
|
+
mainSpecPath,
|
|
275
|
+
parentFilePath: parent,
|
|
276
|
+
refValuePath: './some.yaml',
|
|
277
|
+
outputModelsPath,
|
|
278
|
+
});
|
|
279
|
+
node_assert_1.strict.equal(normalizePath(result), './spec/dir/Some');
|
|
280
|
+
});
|
|
281
|
+
(0, node_test_1.test)('EXTERNAL_FILE via ../same.yaml → treated as external sibling file', () => {
|
|
282
|
+
const parent = '/Users/user/Developer/my_app/openapi/app/spec/dir/some.yaml';
|
|
283
|
+
const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
|
|
284
|
+
mainSpecPath,
|
|
285
|
+
parentFilePath: parent,
|
|
286
|
+
refValuePath: '../some.yaml',
|
|
287
|
+
outputModelsPath,
|
|
288
|
+
});
|
|
289
|
+
node_assert_1.strict.equal(normalizePath(result), './spec/Some');
|
|
290
|
+
});
|
|
291
|
+
(0, node_test_1.test)('EXTERNAL_FILE self-reference via ./same.yaml', () => {
|
|
292
|
+
const parent = '/Users/user/Developer/my_app/openapi/app/spec/dir/some.yaml';
|
|
293
|
+
const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
|
|
294
|
+
mainSpecPath,
|
|
295
|
+
parentFilePath: parent,
|
|
296
|
+
refValuePath: './some.yaml',
|
|
297
|
+
outputModelsPath,
|
|
298
|
+
});
|
|
299
|
+
node_assert_1.strict.equal(normalizePath(result), './spec/dir/Some');
|
|
300
|
+
});
|
|
301
|
+
(0, node_test_1.test)('EXTERNAL_FILE with same basename but different path is NOT self-reference', () => {
|
|
302
|
+
const parent = '/Users/user/Developer/my_app/openapi/app/spec/dir/some.yaml';
|
|
303
|
+
const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
|
|
304
|
+
mainSpecPath,
|
|
305
|
+
parentFilePath: parent,
|
|
306
|
+
refValuePath: '../other/some.yaml',
|
|
307
|
+
outputModelsPath,
|
|
308
|
+
});
|
|
309
|
+
const normalized = normalizePath(result);
|
|
310
|
+
node_assert_1.strict.ok(normalized.includes('Some') && normalized.includes('other'), 'should be treated as external file');
|
|
311
|
+
});
|
|
249
312
|
});
|
|
250
313
|
(0, node_test_1.describe)('ABSOLUTE_PATH (default case)', () => {
|
|
251
314
|
(0, node_test_1.test)('absolute path to file → resolves correctly', () => {
|
|
@@ -373,4 +436,14 @@ const normalizePath = (p) => p.replace(Consts_1.REGEX_BACKSLASH, '/');
|
|
|
373
436
|
node_assert_1.strict.ok(typeof normalized === 'string');
|
|
374
437
|
});
|
|
375
438
|
});
|
|
439
|
+
(0, node_test_1.test)('self-reference works even with redundant path segments', () => {
|
|
440
|
+
const parent = '/Users/user/Developer/my_app/openapi/app/spec/dir/some.yaml';
|
|
441
|
+
const result = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
|
|
442
|
+
mainSpecPath,
|
|
443
|
+
parentFilePath: parent,
|
|
444
|
+
refValuePath: './sub/../some.yaml',
|
|
445
|
+
outputModelsPath,
|
|
446
|
+
});
|
|
447
|
+
node_assert_1.strict.equal(normalizePath(result), './spec/dir/Some');
|
|
448
|
+
});
|
|
376
449
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerHandlebarHelpers.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarHelpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registerHandlebarHelpers.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarHelpers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAK5D,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAqK5H"}
|
|
@@ -32,8 +32,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
exports.registerHandlebarHelpers = registerHandlebarHelpers;
|
|
40
|
+
const camelcase_1 = __importDefault(require("camelcase"));
|
|
37
41
|
const Handlebars = __importStar(require("handlebars/runtime"));
|
|
38
42
|
const Consts_1 = require("../types/Consts");
|
|
39
43
|
const unique_1 = require("./unique");
|
|
@@ -178,4 +182,11 @@ function registerHandlebarHelpers(root) {
|
|
|
178
182
|
const firstEnum = enumerators[0];
|
|
179
183
|
return firstEnum.type === 'number' ? 'number' : 'string';
|
|
180
184
|
});
|
|
185
|
+
Handlebars.registerHelper('camelCase', function (value) {
|
|
186
|
+
const name = (0, camelcase_1.default)(value, { pascalCase: true });
|
|
187
|
+
if (name && !name.endsWith('Service')) {
|
|
188
|
+
return `${name}Service`;
|
|
189
|
+
}
|
|
190
|
+
return name;
|
|
191
|
+
});
|
|
181
192
|
}
|
|
@@ -1,32 +1,6 @@
|
|
|
1
|
-
import * as Handlebars from 'handlebars/runtime';
|
|
2
1
|
import { HttpClient } from '../types/enums/HttpClient.enum';
|
|
3
2
|
import { ValidationLibrary } from '../types/enums/ValidationLibrary.enum';
|
|
4
|
-
|
|
5
|
-
indexes: {
|
|
6
|
-
full: Handlebars.TemplateDelegate;
|
|
7
|
-
simple: Handlebars.TemplateDelegate;
|
|
8
|
-
core: Handlebars.TemplateDelegate;
|
|
9
|
-
models: Handlebars.TemplateDelegate;
|
|
10
|
-
schemas: Handlebars.TemplateDelegate;
|
|
11
|
-
services: Handlebars.TemplateDelegate;
|
|
12
|
-
};
|
|
13
|
-
exports: {
|
|
14
|
-
model: Handlebars.TemplateDelegate;
|
|
15
|
-
schema: Handlebars.TemplateDelegate | undefined;
|
|
16
|
-
service: Handlebars.TemplateDelegate;
|
|
17
|
-
};
|
|
18
|
-
core: {
|
|
19
|
-
settings: Handlebars.TemplateDelegate;
|
|
20
|
-
apiError: Handlebars.TemplateDelegate;
|
|
21
|
-
apiRequestOptions: Handlebars.TemplateDelegate;
|
|
22
|
-
apiResult: Handlebars.TemplateDelegate;
|
|
23
|
-
request: Handlebars.TemplateDelegate;
|
|
24
|
-
cancelablePromise: Handlebars.TemplateDelegate;
|
|
25
|
-
httpStatusCode: Handlebars.TemplateDelegate;
|
|
26
|
-
requestExecutor: Handlebars.TemplateDelegate;
|
|
27
|
-
legacyRequestAdapter: Handlebars.TemplateDelegate;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
3
|
+
import { Templates } from '../types/base/Templates.model';
|
|
30
4
|
/**
|
|
31
5
|
* Read all the Handlebar templates that we need and return on wrapper object
|
|
32
6
|
* so we can easily access the templates in out generator / write functions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerHandlebarTemplates.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarTemplates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registerHandlebarTemplates.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarTemplates.ts"],"names":[],"mappings":"AA0FA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AA0C1E,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAC;IAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;CAAE,GAAG,SAAS,CAsK1K"}
|
|
@@ -78,13 +78,14 @@ const OpenAPI_1 = __importDefault(require("../../templatesCompiled/client/core/O
|
|
|
78
78
|
const CancelablePromise_1 = __importDefault(require("../../templatesCompiled/client/core/CancelablePromise"));
|
|
79
79
|
const request_4 = __importDefault(require("../../templatesCompiled/client/core/request"));
|
|
80
80
|
const request_executor_1 = __importDefault(require("../../templatesCompiled/client/core/request-executor"));
|
|
81
|
-
const
|
|
81
|
+
const createExecutorAdapter_1 = __importDefault(require("../../templatesCompiled/client/core/createExecutorAdapter"));
|
|
82
82
|
const getHeaders_4 = __importDefault(require("../../templatesCompiled/client/core/xhr/getHeaders"));
|
|
83
83
|
const getRequestBody_4 = __importDefault(require("../../templatesCompiled/client/core/xhr/getRequestBody"));
|
|
84
84
|
const getResponseBody_4 = __importDefault(require("../../templatesCompiled/client/core/xhr/getResponseBody"));
|
|
85
85
|
const getResponseHeader_4 = __importDefault(require("../../templatesCompiled/client/core/xhr/getResponseHeader"));
|
|
86
86
|
const request_5 = __importDefault(require("../../templatesCompiled/client/core/xhr/request"));
|
|
87
87
|
const sendRequest_4 = __importDefault(require("../../templatesCompiled/client/core/xhr/sendRequest"));
|
|
88
|
+
const exportClient_1 = __importDefault(require("../../templatesCompiled/client/exportClient"));
|
|
88
89
|
const exportModel_1 = __importDefault(require("../../templatesCompiled/client/exportModel"));
|
|
89
90
|
const exportService_1 = __importDefault(require("../../templatesCompiled/client/exportService"));
|
|
90
91
|
const indexFull_1 = __importDefault(require("../../templatesCompiled/client/indexFull"));
|
|
@@ -179,6 +180,7 @@ function registerHandlebarTemplates(root) {
|
|
|
179
180
|
services: Handlebars.template(indexServices_1.default),
|
|
180
181
|
},
|
|
181
182
|
exports: {
|
|
183
|
+
client: Handlebars.template(exportClient_1.default),
|
|
182
184
|
model: Handlebars.template(exportModel_1.default),
|
|
183
185
|
schema: undefined,
|
|
184
186
|
service: Handlebars.template(exportService_1.default),
|
|
@@ -192,7 +194,7 @@ function registerHandlebarTemplates(root) {
|
|
|
192
194
|
cancelablePromise: Handlebars.template(CancelablePromise_1.default),
|
|
193
195
|
httpStatusCode: Handlebars.template(HttpStatusCode_1.default),
|
|
194
196
|
requestExecutor: Handlebars.template(request_executor_1.default),
|
|
195
|
-
|
|
197
|
+
createExecutorAdapter: Handlebars.template(createExecutorAdapter_1.default),
|
|
196
198
|
},
|
|
197
199
|
};
|
|
198
200
|
// Partials for the generations of the models, services, etc.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveRefToImportPath.d.ts","sourceRoot":"","sources":["../../../src/core/utils/resolveRefToImportPath.ts"],"names":[],"mappings":"AAQA,UAAU,OAAO;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;CAC5B;
|
|
1
|
+
{"version":3,"file":"resolveRefToImportPath.d.ts","sourceRoot":"","sources":["../../../src/core/utils/resolveRefToImportPath.ts"],"names":[],"mappings":"AAQA,UAAU,OAAO;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAoED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,EAAE,OAAO,UA4C/G"}
|
|
@@ -60,9 +60,7 @@ function prepareParentDirForResolve(parentFilePath, mainSpecPath, sourceRoot) {
|
|
|
60
60
|
function removeParentBasenamePrefix(refValueClean, parentDirForResolveWithSep) {
|
|
61
61
|
const baseNameParent = (0, path_1.basename)(parentDirForResolveWithSep);
|
|
62
62
|
const baseNameParentWithSep = baseNameParent.endsWith('/') ? baseNameParent : baseNameParent + '/';
|
|
63
|
-
return refValueClean.startsWith(baseNameParentWithSep)
|
|
64
|
-
? refValueClean.replace(baseNameParentWithSep, '')
|
|
65
|
-
: refValueClean;
|
|
63
|
+
return refValueClean.startsWith(baseNameParentWithSep) ? refValueClean.replace(baseNameParentWithSep, '') : refValueClean;
|
|
66
64
|
}
|
|
67
65
|
/**
|
|
68
66
|
* Resolves $ref reference to import path for generated code.
|
|
@@ -95,11 +93,14 @@ function resolveRefToImportPath({ mainSpecPath, parentFilePath, refValuePath, ou
|
|
|
95
93
|
// EXTERNAL_FILE: reference to external file (e.g., ./file.yaml)
|
|
96
94
|
if (parsed.type === parseRef_1.RefType.EXTERNAL_FILE) {
|
|
97
95
|
const targetFileAbs = (0, pathHelpers_1.joinHelper)(parentDirForResolveWithSep, currentRefValue);
|
|
96
|
+
// ВАЖНО: проверка self-reference
|
|
97
|
+
if (parentFilePath && fileSystemHelpers_1.fileSystemHelpers.isSameFilePath(targetFileAbs, parentFilePath)) {
|
|
98
|
+
const modelName = (0, stripNamespace_1.stripNamespace)(parentFilePath);
|
|
99
|
+
return resolveFragmentRef(modelName, parentFilePath, mainSpecPath, sourceRoot, outputModelsPath, absOutputModelsPath);
|
|
100
|
+
}
|
|
98
101
|
return resolveExternalFileOrAbsolutePath(targetFileAbs, sourceRoot, outputModelsPath, absOutputModelsPath);
|
|
99
102
|
}
|
|
100
103
|
// ABSOLUTE_PATH (default case): absolute path reference
|
|
101
|
-
const targetFileAbs = fileSystemHelpers_1.fileSystemHelpers.isPathToFile(refValueClean)
|
|
102
|
-
? (0, pathHelpers_1.joinHelper)(parentDirForResolveWithSep, refValueClean)
|
|
103
|
-
: (0, pathHelpers_1.resolveHelper)(parentDirForResolveWithSep, refValueClean);
|
|
104
|
+
const targetFileAbs = fileSystemHelpers_1.fileSystemHelpers.isPathToFile(refValueClean) ? (0, pathHelpers_1.joinHelper)(parentDirForResolveWithSep, refValueClean) : (0, pathHelpers_1.resolveHelper)(parentDirForResolveWithSep, refValueClean);
|
|
104
105
|
return resolveExternalFileOrAbsolutePath(targetFileAbs, sourceRoot, outputModelsPath, absOutputModelsPath);
|
|
105
106
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Templates } from '../types/base/Templates.model';
|
|
1
2
|
import { HttpClient } from '../types/enums/HttpClient.enum';
|
|
2
3
|
import type { Client } from '../types/shared/Client.model';
|
|
3
4
|
import { WriteClient } from '../WriteClient';
|
|
4
|
-
import { Templates } from './registerHandlebarTemplates';
|
|
5
5
|
/**
|
|
6
6
|
* @param client Client object, containing, models, schemas and services
|
|
7
7
|
* @param templates The loaded handlebar templates
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeClientCore.d.ts","sourceRoot":"","sources":["../../../src/core/utils/writeClientCore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"writeClientCore.d.ts","sourceRoot":"","sources":["../../../src/core/utils/writeClientCore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;;;;GAOG;AACH,UAAU,gBAAgB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqCjG"}
|
|
@@ -22,6 +22,7 @@ async function writeClientCore(options) {
|
|
|
22
22
|
useSeparatedIndexes,
|
|
23
23
|
};
|
|
24
24
|
this.logger.info("The recording of the kernel files begins");
|
|
25
|
+
const hasCustomRequest = !!request;
|
|
25
26
|
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'OpenAPI.ts'), templates.core.settings(context));
|
|
26
27
|
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'ApiError.ts'), templates.core.apiError({}));
|
|
27
28
|
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'ApiRequestOptions.ts'), templates.core.apiRequestOptions({}));
|
|
@@ -33,8 +34,8 @@ async function writeClientCore(options) {
|
|
|
33
34
|
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'request.ts'), templates.core.request(context));
|
|
34
35
|
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'request-executor.ts'), templates.core.requestExecutor({}));
|
|
35
36
|
// TODO: Добавлять только, если не выбран custom-ный request
|
|
36
|
-
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, '
|
|
37
|
-
if (
|
|
37
|
+
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'createExecutorAdapter.ts'), templates.core.createExecutorAdapter({ useCustomRequest: hasCustomRequest }));
|
|
38
|
+
if (hasCustomRequest) {
|
|
38
39
|
const requestFile = (0, pathHelpers_1.resolveHelper)(process.cwd(), request);
|
|
39
40
|
const requestFileExists = await fileSystemHelpers_1.fileSystemHelpers.exists(requestFile);
|
|
40
41
|
if (!requestFileExists) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeClientCoreIndex.d.ts","sourceRoot":"","sources":["../../../src/core/utils/writeClientCoreIndex.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"writeClientCoreIndex.d.ts","sourceRoot":"","sources":["../../../src/core/utils/writeClientCoreIndex.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,UAAU,aAAa;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,iBAcnF"}
|