ts-openapi-codegen 2.0.0-beta.3 → 2.0.0-beta.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.
Files changed (45) hide show
  1. package/dist/cli/{generate/runGenerateOpenApi.d.ts → generateOpenApiClient/generateOpenApiClient.d.ts} +2 -2
  2. package/dist/cli/generateOpenApiClient/generateOpenApiClient.d.ts.map +1 -0
  3. package/dist/cli/{generate/runGenerateOpenApi.js → generateOpenApiClient/generateOpenApiClient.js} +2 -2
  4. package/dist/cli/index.js +20 -2
  5. package/dist/cli/previewChanges/previewChanges.d.ts +8 -0
  6. package/dist/cli/previewChanges/previewChanges.d.ts.map +1 -0
  7. package/dist/cli/previewChanges/previewChanges.js +182 -0
  8. package/dist/cli/previewChanges/utils/compareFiles.d.ts +6 -0
  9. package/dist/cli/previewChanges/utils/compareFiles.d.ts.map +1 -0
  10. package/dist/cli/previewChanges/utils/compareFiles.js +50 -0
  11. package/dist/cli/previewChanges/utils/formatDiff.d.ts +6 -0
  12. package/dist/cli/previewChanges/utils/formatDiff.d.ts.map +1 -0
  13. package/dist/cli/previewChanges/utils/formatDiff.js +30 -0
  14. package/dist/cli/previewChanges/utils/isDirectoryEmpty.d.ts +5 -0
  15. package/dist/cli/previewChanges/utils/isDirectoryEmpty.d.ts.map +1 -0
  16. package/dist/cli/previewChanges/utils/isDirectoryEmpty.js +17 -0
  17. package/dist/cli/previewChanges/utils/readDirectoryRecursive.d.ts +5 -0
  18. package/dist/cli/previewChanges/utils/readDirectoryRecursive.d.ts.map +1 -0
  19. package/dist/cli/previewChanges/utils/readDirectoryRecursive.js +28 -0
  20. package/dist/cli/previewChanges/utils/updateOutputPaths.d.ts +10 -0
  21. package/dist/cli/previewChanges/utils/updateOutputPaths.d.ts.map +1 -0
  22. package/dist/cli/previewChanges/utils/updateOutputPaths.js +106 -0
  23. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts.map +1 -1
  24. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.js +5 -6
  25. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts.map +1 -1
  26. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.js +5 -6
  27. package/dist/common/utils/fileSystemHelpers.d.ts +3 -1
  28. package/dist/common/utils/fileSystemHelpers.d.ts.map +1 -1
  29. package/dist/common/utils/fileSystemHelpers.js +3 -0
  30. package/dist/core/__tests__/WriteClient.test.js +0 -4
  31. package/dist/core/utils/__mocks__/templates.d.ts.map +1 -1
  32. package/dist/core/utils/__mocks__/templates.js +0 -4
  33. package/dist/core/utils/__tests__/registerHandlebarTemplates.test.js +2 -0
  34. package/dist/core/utils/registerHandlebarTemplates.d.ts +1 -5
  35. package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
  36. package/dist/core/utils/registerHandlebarTemplates.js +9 -10
  37. package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
  38. package/dist/core/utils/writeClientSchemas.js +22 -31
  39. package/dist/templatesCompiled/client/core/request-executor.js +1 -1
  40. package/dist/templatesCompiled/client/partials/parameters.js +1 -1
  41. package/dist/templatesCompiled/client/partials/serviceOption.d.ts +1 -4
  42. package/dist/templatesCompiled/client/partials/serviceOption.d.ts.map +1 -1
  43. package/dist/templatesCompiled/client/partials/serviceOption.js +28 -48
  44. package/package.json +2 -1
  45. package/dist/cli/generate/runGenerateOpenApi.d.ts.map +0 -1
@@ -3,5 +3,5 @@ import { OptionValues } from 'commander';
3
3
  * Запускает генерацию OpenAPI клиента
4
4
  * Поддерживает как конфиг-файл, так и параметры из CLI
5
5
  */
6
- export declare function runGenerateOpenApi(options: OptionValues): Promise<void>;
7
- //# sourceMappingURL=runGenerateOpenApi.d.ts.map
6
+ export declare function generateOpenApiClient(options: OptionValues): Promise<void>;
7
+ //# sourceMappingURL=generateOpenApiClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateOpenApiClient.d.ts","sourceRoot":"","sources":["../../../src/cli/generateOpenApiClient/generateOpenApiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAgBzC;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA8DhF"}
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.runGenerateOpenApi = runGenerateOpenApi;
36
+ exports.generateOpenApiClient = generateOpenApiClient;
37
37
  const Consts_1 = require("../../common/Consts");
38
38
  const defaultOptions_1 = require("../../common/defaultOptions");
39
39
  const Enums_1 = require("../../common/Enums");
@@ -50,7 +50,7 @@ const validation_1 = require("../validation");
50
50
  * Запускает генерацию OpenAPI клиента
51
51
  * Поддерживает как конфиг-файл, так и параметры из CLI
52
52
  */
53
- async function runGenerateOpenApi(options) {
53
+ async function generateOpenApiClient(options) {
54
54
  const { openapiConfig, ...clientOptions } = options;
55
55
  try {
56
56
  // Валидация опций через Zod
package/dist/cli/index.js CHANGED
@@ -14,9 +14,10 @@ const HttpClient_enum_1 = require("../core/types/enums/HttpClient.enum");
14
14
  const ValidationLibrary_enum_1 = require("../core/types/enums/ValidationLibrary.enum");
15
15
  const checkConfig_1 = require("./checkAndUpdateConfig/checkConfig");
16
16
  const updateConfig_1 = require("./checkAndUpdateConfig/updateConfig");
17
- const runGenerateOpenApi_1 = require("./generate/runGenerateOpenApi");
17
+ const generateOpenApiClient_1 = require("./generateOpenApiClient/generateOpenApiClient");
18
18
  const Enums_2 = require("./initOpenApiConfig/Enums");
19
19
  const runInitOpenapiConfig_1 = require("./initOpenApiConfig/runInitOpenapiConfig");
20
+ const previewChanges_1 = require("./previewChanges/previewChanges");
20
21
  const utils_1 = require("./utils");
21
22
  const packageDetails = JSON.parse(fs_1.default.readFileSync((0, pathHelpers_1.joinHelper)(__dirname, '../../package.json'), 'utf-8'));
22
23
  const APP_NAME = packageDetails.name || 'ts-openapi-codegen-cli';
@@ -61,7 +62,7 @@ program
61
62
  await updateNotifier.checkAndNotify();
62
63
  })
63
64
  .action(async (options) => {
64
- await (0, runGenerateOpenApi_1.runGenerateOpenApi)(options);
65
+ await (0, generateOpenApiClient_1.generateOpenApiClient)(options);
65
66
  });
66
67
  /**
67
68
  * check - Команда для проверки конфигурационного файла
@@ -106,6 +107,23 @@ program
106
107
  .action(async (options) => {
107
108
  await (0, runInitOpenapiConfig_1.runInitOpenapiConfig)(options);
108
109
  });
110
+ /**
111
+ * preview-changes - Команда для предпросмотра изменений перед генерацией
112
+ */
113
+ program
114
+ .command('preview-changes')
115
+ .description('Preview changes that will be made to generated code before applying them')
116
+ .addHelpText('before', (0, utils_1.getCLIName)(APP_NAME))
117
+ .option('-ocn, --openapi-config <value>', 'The path to the configuration file, listing the options', Consts_1.DEFAULT_OPENAPI_CONFIG_FILENAME)
118
+ .option('-gd, --generated-dir <value>', 'Directory with previously generated code (default: "generated")', './generated')
119
+ .option('-pd, --preview-dir <value>', 'Temporary directory for preview generation (default: "generated-preview")', './generated-preview')
120
+ .option('-dd, --diff-dir <value>', 'Directory to save diff files (default: "generated-diff")', './generated-diff')
121
+ .hook('preAction', async () => {
122
+ await updateNotifier.checkAndNotify();
123
+ })
124
+ .action(async (options) => {
125
+ await (0, previewChanges_1.previewChanges)(options);
126
+ });
109
127
  program.exitOverride();
110
128
  // TODO: Включить позже!
111
129
  // program.showSuggestionAfterError(false);
@@ -0,0 +1,8 @@
1
+ import { OptionValues } from 'commander';
2
+ /**
3
+ * Основная функция для предпросмотра изменений
4
+ *
5
+ * TODO: Добавить проверку опций команды перед выполнением
6
+ */
7
+ export declare function previewChanges(options: OptionValues): Promise<void>;
8
+ //# sourceMappingURL=previewChanges.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"previewChanges.d.ts","sourceRoot":"","sources":["../../../src/cli/previewChanges/previewChanges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AA0BzC;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA0IzE"}
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.previewChanges = previewChanges;
37
+ const Consts_1 = require("../../common/Consts");
38
+ const Enums_1 = require("../../common/Enums");
39
+ const convertArrayToObject_1 = require("../../common/utils/convertArrayToObject");
40
+ const fileSystemHelpers_1 = require("../../common/utils/fileSystemHelpers");
41
+ const loadConfigIfExists_1 = require("../../common/utils/loadConfigIfExists");
42
+ const pathHelpers_1 = require("../../common/utils/pathHelpers");
43
+ const AllMigrationPlans_1 = require("../../common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans");
44
+ const AllVersionedSchemas_1 = require("../../common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas");
45
+ const migrateDataToLatestSchemaVersion_1 = require("../../common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion");
46
+ const OpenAPI = __importStar(require("../../core"));
47
+ const compareFiles_1 = require("./utils/compareFiles");
48
+ const formatDiff_1 = require("./utils/formatDiff");
49
+ const isDirectoryEmpty_1 = require("./utils/isDirectoryEmpty");
50
+ const readDirectoryRecursive_1 = require("./utils/readDirectoryRecursive");
51
+ const updateOutputPaths_1 = require("./utils/updateOutputPaths");
52
+ /**
53
+ * Основная функция для предпросмотра изменений
54
+ *
55
+ * TODO: Добавить проверку опций команды перед выполнением
56
+ */
57
+ async function previewChanges(options) {
58
+ const { openapiConfig, generatedDir = 'generated', previewDir = 'generated-preview', diffDir = 'generated-diff' } = options;
59
+ const resolvedGeneratedDir = (0, pathHelpers_1.resolveHelper)(process.cwd(), generatedDir);
60
+ const resolvedPreviewDir = (0, pathHelpers_1.resolveHelper)(process.cwd(), previewDir);
61
+ const resolvedDiffDir = (0, pathHelpers_1.resolveHelper)(process.cwd(), diffDir);
62
+ let previewDirCreated = false;
63
+ try {
64
+ // 1. Проверка директории со сгенерированным кодом
65
+ if (await (0, isDirectoryEmpty_1.isDirectoryEmpty)(resolvedGeneratedDir)) {
66
+ Consts_1.APP_LOGGER.info(`Directory "${generatedDir}" is empty or does not exist. Nothing to compare.`);
67
+ process.exit(0);
68
+ }
69
+ // 2. Создание временной директории для preview
70
+ await fileSystemHelpers_1.fileSystemHelpers.mkdir(resolvedPreviewDir);
71
+ previewDirCreated = true;
72
+ // 3. Загрузка конфигурации
73
+ const configData = (0, loadConfigIfExists_1.loadConfigIfExists)(openapiConfig);
74
+ if (!configData) {
75
+ Consts_1.APP_LOGGER.error('The configuration file is missing');
76
+ process.exit(1);
77
+ }
78
+ const preparedOptions = (0, convertArrayToObject_1.convertArrayToObject)(configData);
79
+ // Миграция опций
80
+ const migratedOptions = (0, migrateDataToLatestSchemaVersion_1.migrateDataToLatestSchemaVersion)({
81
+ rawInput: preparedOptions,
82
+ migrationPlans: AllMigrationPlans_1.allMigrationPlans,
83
+ versionedSchemas: AllVersionedSchemas_1.allVersionedSchemas,
84
+ migrationMode: Enums_1.EMigrationMode.GENERATE_OPENAPI,
85
+ });
86
+ if (!migratedOptions) {
87
+ Consts_1.APP_LOGGER.error("Couldn't convert the set of options to the current version");
88
+ process.exit(1);
89
+ }
90
+ // 4. Обновление путей output для генерации в preview директорию
91
+ const migratedValue = migratedOptions.value;
92
+ const previewOptions = (0, updateOutputPaths_1.updateOutputPaths)(migratedValue, previewDir, generatedDir);
93
+ // 5. Генерация кода в preview директорию
94
+ Consts_1.APP_LOGGER.info(`Generating code to preview directory: ${previewDir}`);
95
+ await OpenAPI.generate(previewOptions);
96
+ // 6. Сравнение файлов
97
+ Consts_1.APP_LOGGER.info('Comparing files...');
98
+ const oldFiles = await (0, readDirectoryRecursive_1.readDirectoryRecursive)(resolvedGeneratedDir);
99
+ const newFiles = await (0, readDirectoryRecursive_1.readDirectoryRecursive)(resolvedPreviewDir);
100
+ const allFiles = new Set([...oldFiles, ...newFiles]);
101
+ const changes = [];
102
+ for (const file of allFiles) {
103
+ const oldPath = (0, pathHelpers_1.joinHelper)(resolvedGeneratedDir, file);
104
+ const newPath = (0, pathHelpers_1.joinHelper)(resolvedPreviewDir, file);
105
+ const oldExists = await fileSystemHelpers_1.fileSystemHelpers.exists(oldPath);
106
+ const newExists = await fileSystemHelpers_1.fileSystemHelpers.exists(newPath);
107
+ if (oldExists && newExists) {
108
+ // Файл существует в обеих директориях - сравниваем
109
+ const fileDiff = await (0, compareFiles_1.compareFiles)(oldPath, newPath);
110
+ if (fileDiff) {
111
+ changes.push({
112
+ file,
113
+ status: 'modified',
114
+ diff: fileDiff,
115
+ });
116
+ }
117
+ else {
118
+ Consts_1.APP_LOGGER.info(`File "${file}" has no changes`);
119
+ }
120
+ }
121
+ else if (!oldExists && newExists) {
122
+ // Новый файл
123
+ changes.push({
124
+ file,
125
+ status: 'added',
126
+ });
127
+ }
128
+ else if (oldExists && !newExists) {
129
+ // Удаленный файл
130
+ changes.push({
131
+ file,
132
+ status: 'removed',
133
+ });
134
+ }
135
+ }
136
+ // 7. Сохранение результатов в diff директорию
137
+ if (changes.length > 0) {
138
+ await fileSystemHelpers_1.fileSystemHelpers.mkdir(resolvedDiffDir);
139
+ for (const change of changes) {
140
+ const diffFilePath = (0, pathHelpers_1.joinHelper)(resolvedDiffDir, `${change.file}.md`);
141
+ const diffDirPath = (0, pathHelpers_1.dirNameHelper)(diffFilePath);
142
+ await fileSystemHelpers_1.fileSystemHelpers.mkdir(diffDirPath);
143
+ let diffContent = '';
144
+ if (change.status === 'added') {
145
+ diffContent = (0, formatDiff_1.formatDiff)(change.file, change.status);
146
+ }
147
+ else if (change.status === 'removed') {
148
+ diffContent = (0, formatDiff_1.formatDiff)(change.file, change.status);
149
+ }
150
+ else if (change.diff) {
151
+ diffContent = (0, formatDiff_1.formatDiff)(change.file, change.status, change.diff);
152
+ }
153
+ await fileSystemHelpers_1.fileSystemHelpers.writeFile(diffFilePath, diffContent, 'utf-8');
154
+ Consts_1.APP_LOGGER.info(`Diff saved: ${diffFilePath}`);
155
+ }
156
+ Consts_1.APP_LOGGER.info(`\nTotal changes: ${changes.length}`);
157
+ Consts_1.APP_LOGGER.info(`Diff files saved to: ${diffDir}`);
158
+ }
159
+ else {
160
+ Consts_1.APP_LOGGER.info('No changes detected. All files are identical.');
161
+ }
162
+ // 8. Удаление временной директории preview
163
+ Consts_1.APP_LOGGER.info(`Cleaning up preview directory: ${previewDir}`);
164
+ await fileSystemHelpers_1.fileSystemHelpers.rmdir(resolvedPreviewDir);
165
+ previewDirCreated = false;
166
+ process.exit(0);
167
+ }
168
+ catch (error) {
169
+ // Очистка preview директории в случае ошибки
170
+ if (previewDirCreated) {
171
+ try {
172
+ Consts_1.APP_LOGGER.info(`Cleaning up preview directory after error: ${previewDir}`);
173
+ await fileSystemHelpers_1.fileSystemHelpers.rmdir(resolvedPreviewDir);
174
+ }
175
+ catch (cleanupError) {
176
+ Consts_1.APP_LOGGER.error(`Failed to cleanup preview directory: ${cleanupError.message}`);
177
+ }
178
+ }
179
+ Consts_1.APP_LOGGER.error(error.message);
180
+ process.exit(1);
181
+ }
182
+ }
@@ -0,0 +1,6 @@
1
+ import * as diff from 'diff';
2
+ /**
3
+ * Сравнивает два файла и возвращает diff
4
+ */
5
+ export declare function compareFiles(oldPath: string, newPath: string): Promise<diff.Change[] | null>;
6
+ //# sourceMappingURL=compareFiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compareFiles.d.ts","sourceRoot":"","sources":["../../../../src/cli/previewChanges/utils/compareFiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAI7B;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAUlG"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.compareFiles = compareFiles;
37
+ const diff = __importStar(require("diff"));
38
+ const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
39
+ /**
40
+ * Сравнивает два файла и возвращает diff
41
+ */
42
+ async function compareFiles(oldPath, newPath) {
43
+ const oldContent = await fileSystemHelpers_1.fileSystemHelpers.readFile(oldPath, 'utf-8');
44
+ const newContent = await fileSystemHelpers_1.fileSystemHelpers.readFile(newPath, 'utf-8');
45
+ const fileDiff = diff.diffLines(oldContent, newContent);
46
+ if (fileDiff.some(part => part.added || part.removed)) {
47
+ return fileDiff;
48
+ }
49
+ return null;
50
+ }
@@ -0,0 +1,6 @@
1
+ import * as diff from 'diff';
2
+ /**
3
+ * Форматирует diff для сохранения в markdown файл
4
+ */
5
+ export declare function formatDiff(filePath: string, status: 'added' | 'modified' | 'removed', fileDiff?: diff.Change[]): string;
6
+ //# sourceMappingURL=formatDiff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatDiff.d.ts","sourceRoot":"","sources":["../../../../src/cli/previewChanges/utils/formatDiff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B;;GAEG;AACH,wBAAgB,UAAU,CACtB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,EACxC,QAAQ,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,GACzB,MAAM,CAyBR"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatDiff = formatDiff;
4
+ /**
5
+ * Форматирует diff для сохранения в markdown файл
6
+ */
7
+ function formatDiff(filePath, status, fileDiff) {
8
+ const lines = [`# ${filePath}`, '', `**Status:** ${status.toUpperCase()}`, ''];
9
+ if (status === 'added') {
10
+ lines.push('This is a new file.');
11
+ }
12
+ else if (status === 'removed') {
13
+ lines.push('This file was deleted.');
14
+ }
15
+ else if (fileDiff) {
16
+ lines.push('## Changes', '');
17
+ lines.push('```diff');
18
+ fileDiff.forEach(part => {
19
+ const prefix = part.added ? '+' : part.removed ? '-' : ' ';
20
+ const lines_ = part.value.split('\n');
21
+ lines_.forEach(line => {
22
+ if (line || lines_.length > 1) {
23
+ lines.push(`${prefix} ${line}`);
24
+ }
25
+ });
26
+ });
27
+ lines.push('```');
28
+ }
29
+ return lines.join('\n');
30
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Проверяет, пуста ли директория
3
+ */
4
+ export declare function isDirectoryEmpty(dirPath: string): Promise<boolean>;
5
+ //# sourceMappingURL=isDirectoryEmpty.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isDirectoryEmpty.d.ts","sourceRoot":"","sources":["../../../../src/cli/previewChanges/utils/isDirectoryEmpty.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAWxE"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isDirectoryEmpty = isDirectoryEmpty;
4
+ const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
5
+ /**
6
+ * Проверяет, пуста ли директория
7
+ */
8
+ async function isDirectoryEmpty(dirPath) {
9
+ if (!(await fileSystemHelpers_1.fileSystemHelpers.exists(dirPath))) {
10
+ return true;
11
+ }
12
+ if (!fileSystemHelpers_1.fileSystemHelpers.isDirectory(dirPath)) {
13
+ return true;
14
+ }
15
+ const entries = await fileSystemHelpers_1.fileSystemHelpers.readdir(dirPath);
16
+ return entries.length === 0;
17
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Рекурсивно читает все файлы в директории
3
+ */
4
+ export declare function readDirectoryRecursive(dirPath: string, basePath?: string): Promise<string[]>;
5
+ //# sourceMappingURL=readDirectoryRecursive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readDirectoryRecursive.d.ts","sourceRoot":"","sources":["../../../../src/cli/previewChanges/utils/readDirectoryRecursive.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAgB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAqB3G"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readDirectoryRecursive = readDirectoryRecursive;
4
+ const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
5
+ const pathHelpers_1 = require("../../../common/utils/pathHelpers");
6
+ /**
7
+ * Рекурсивно читает все файлы в директории
8
+ */
9
+ async function readDirectoryRecursive(dirPath, basePath = dirPath) {
10
+ const files = [];
11
+ const entries = await fileSystemHelpers_1.fileSystemHelpers.readdir(dirPath);
12
+ for (const entry of entries) {
13
+ const fullPath = (0, pathHelpers_1.joinHelper)(dirPath, entry);
14
+ let relativePath = (0, pathHelpers_1.relativeHelper)(basePath, fullPath);
15
+ // Убираем префикс ./ если он есть
16
+ if (relativePath.startsWith('./')) {
17
+ relativePath = relativePath.substring(2);
18
+ }
19
+ if (fileSystemHelpers_1.fileSystemHelpers.isDirectory(fullPath)) {
20
+ const subFiles = await readDirectoryRecursive(fullPath, basePath);
21
+ files.push(...subFiles);
22
+ }
23
+ else if (fileSystemHelpers_1.fileSystemHelpers.isPathToFile(fullPath)) {
24
+ files.push(relativePath);
25
+ }
26
+ }
27
+ return files;
28
+ }
@@ -0,0 +1,10 @@
1
+ import { TRawOptions } from '../../../common/TRawOptions';
2
+ /**
3
+ * Обновляет пути output в опциях для генерации в preview директорию
4
+ * Удаляет generatedDir из путей и заменяет на previewDir
5
+ *
6
+ * Пример: generatedDir = "./test/generated", output = "./test/generated/api"
7
+ * Результат: output = "./generated-preview/api"
8
+ */
9
+ export declare function updateOutputPaths(options: TRawOptions, previewDir: string, generatedDir: string): TRawOptions;
10
+ //# sourceMappingURL=updateOutputPaths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateOutputPaths.d.ts","sourceRoot":"","sources":["../../../../src/cli/previewChanges/utils/updateOutputPaths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG1D;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC7B,OAAO,EAAE,WAAW,EACpB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACrB,WAAW,CAuIb"}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateOutputPaths = updateOutputPaths;
4
+ const pathHelpers_1 = require("../../../common/utils/pathHelpers");
5
+ /**
6
+ * Обновляет пути output в опциях для генерации в preview директорию
7
+ * Удаляет generatedDir из путей и заменяет на previewDir
8
+ *
9
+ * Пример: generatedDir = "./test/generated", output = "./test/generated/api"
10
+ * Результат: output = "./generated-preview/api"
11
+ */
12
+ function updateOutputPaths(options, previewDir, generatedDir) {
13
+ const resolvedGeneratedDir = (0, pathHelpers_1.resolveHelper)(process.cwd(), generatedDir);
14
+ // const resolvedPreviewDir = resolveHelper(process.cwd(), previewDir);
15
+ /**
16
+ * Заменяет путь, удаляя generatedDir и добавляя previewDir
17
+ * Если путь находится внутри generatedDir, сохраняется относительная структура
18
+ */
19
+ const replacePath = (oldPath) => {
20
+ const resolvedOldPath = (0, pathHelpers_1.resolveHelper)(process.cwd(), oldPath);
21
+ let relativePath = (0, pathHelpers_1.relativeHelper)(resolvedGeneratedDir, resolvedOldPath);
22
+ // Убираем префикс ./ если он есть
23
+ if (relativePath.startsWith('./')) {
24
+ relativePath = relativePath.substring(2);
25
+ }
26
+ // Если путь пустой или равен текущей директории, возвращаем previewDir
27
+ if (!relativePath || relativePath === '' || relativePath === './') {
28
+ return previewDir;
29
+ }
30
+ // Используем previewDir (относительный путь) вместо resolvedPreviewDir
31
+ return (0, pathHelpers_1.joinHelper)(previewDir, relativePath);
32
+ };
33
+ /**
34
+ * Обновляет output* пути относительно нового output
35
+ * Если output* был указан явно, сохраняем его относительную структуру от старого output
36
+ */
37
+ const updateRelativePaths = (newOutput, oldOutput, oldOutputCore, oldOutputServices, oldOutputModels, oldOutputSchemas) => {
38
+ const resolvedOldOutput = (0, pathHelpers_1.resolveHelper)(process.cwd(), oldOutput);
39
+ const resolvedNewOutput = (0, pathHelpers_1.resolveHelper)(process.cwd(), newOutput);
40
+ const result = {};
41
+ // Для каждого output* пути, если он был указан, сохраняем относительную структуру
42
+ if (oldOutputCore) {
43
+ const resolvedOldCore = (0, pathHelpers_1.resolveHelper)(process.cwd(), oldOutputCore);
44
+ let relativeCore = (0, pathHelpers_1.relativeHelper)(resolvedOldOutput, resolvedOldCore);
45
+ if (relativeCore.startsWith('./')) {
46
+ relativeCore = relativeCore.substring(2);
47
+ }
48
+ // Если относительный путь пустой, используем стандартное имя 'core'
49
+ result.outputCore = relativeCore && relativeCore !== '' && relativeCore !== './'
50
+ ? (0, pathHelpers_1.joinHelper)(resolvedNewOutput, relativeCore)
51
+ : (0, pathHelpers_1.joinHelper)(resolvedNewOutput, 'core');
52
+ }
53
+ if (oldOutputServices) {
54
+ const resolvedOldServices = (0, pathHelpers_1.resolveHelper)(process.cwd(), oldOutputServices);
55
+ let relativeServices = (0, pathHelpers_1.relativeHelper)(resolvedOldOutput, resolvedOldServices);
56
+ if (relativeServices.startsWith('./')) {
57
+ relativeServices = relativeServices.substring(2);
58
+ }
59
+ result.outputServices = relativeServices && relativeServices !== '' && relativeServices !== './'
60
+ ? (0, pathHelpers_1.joinHelper)(resolvedNewOutput, relativeServices)
61
+ : (0, pathHelpers_1.joinHelper)(resolvedNewOutput, 'services');
62
+ }
63
+ if (oldOutputModels) {
64
+ const resolvedOldModels = (0, pathHelpers_1.resolveHelper)(process.cwd(), oldOutputModels);
65
+ let relativeModels = (0, pathHelpers_1.relativeHelper)(resolvedOldOutput, resolvedOldModels);
66
+ if (relativeModels.startsWith('./')) {
67
+ relativeModels = relativeModels.substring(2);
68
+ }
69
+ result.outputModels = relativeModels && relativeModels !== '' && relativeModels !== './'
70
+ ? (0, pathHelpers_1.joinHelper)(resolvedNewOutput, relativeModels)
71
+ : (0, pathHelpers_1.joinHelper)(resolvedNewOutput, 'models');
72
+ }
73
+ if (oldOutputSchemas) {
74
+ const resolvedOldSchemas = (0, pathHelpers_1.resolveHelper)(process.cwd(), oldOutputSchemas);
75
+ let relativeSchemas = (0, pathHelpers_1.relativeHelper)(resolvedOldOutput, resolvedOldSchemas);
76
+ if (relativeSchemas.startsWith('./')) {
77
+ relativeSchemas = relativeSchemas.substring(2);
78
+ }
79
+ result.outputSchemas = relativeSchemas && relativeSchemas !== '' && relativeSchemas !== './'
80
+ ? (0, pathHelpers_1.joinHelper)(resolvedNewOutput, relativeSchemas)
81
+ : (0, pathHelpers_1.joinHelper)(resolvedNewOutput, 'schemas');
82
+ }
83
+ return result;
84
+ };
85
+ if (options.items && Array.isArray(options.items)) {
86
+ return {
87
+ ...options,
88
+ items: options.items.map(item => {
89
+ const newOutput = replacePath(item.output);
90
+ const relativePaths = updateRelativePaths(newOutput, item.output, item.outputCore, item.outputServices, item.outputModels, item.outputSchemas);
91
+ return {
92
+ ...item,
93
+ output: newOutput,
94
+ ...relativePaths,
95
+ };
96
+ }),
97
+ };
98
+ }
99
+ const newOutput = replacePath(options.output || '');
100
+ const relativePaths = updateRelativePaths(newOutput, options.output || '', options.outputCore, options.outputServices, options.outputModels, options.outputSchemas);
101
+ return {
102
+ ...options,
103
+ output: newOutput,
104
+ ...relativePaths,
105
+ };
106
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"UnifiedOptionsSchemaV1.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAqBtB;;;GAGG;AACH,eAAO,MAAM,sBAAsB,uBA6BZ,CAAC"}
1
+ {"version":3,"file":"UnifiedOptionsSchemaV1.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAgBtB;;;GAGG;AACH,eAAO,MAAM,sBAAsB,uBA4BZ,CAAC"}
@@ -10,7 +10,7 @@ const CommonSchemas_1 = require("../CommonSchemas");
10
10
  const mergeObjectSchemas_1 = require("../Utils/mergeObjectSchemas");
11
11
  const itemSchema = (0, mergeObjectSchemas_1.mergeObjectSchemas)(joi_1.default.object({
12
12
  input: joi_1.default.string().required().description('Путь, URL или строка OpenAPI спецификации'),
13
- httpClient: joi_1.default.string().valid(...Object.values(HttpClient_enum_1.HttpClient)).optional(),
13
+ request: joi_1.default.string().optional(),
14
14
  }), CommonSchemas_1.outputPathsSchema, CommonSchemas_1.additionalParametersSchemaV2, CommonSchemas_1.experimentalParametersSchemaV2);
15
15
  /**
16
16
  * Unified options schema that supports both single and multi-item configurations.
@@ -18,11 +18,7 @@ const itemSchema = (0, mergeObjectSchemas_1.mergeObjectSchemas)(joi_1.default.ob
18
18
  */
19
19
  exports.unifiedOptionsSchemaV1 = (0, mergeObjectSchemas_1.mergeObjectSchemas)(joi_1.default.object({
20
20
  // Multi-item configuration
21
- items: joi_1.default.array()
22
- .items(itemSchema)
23
- .min(1)
24
- .optional()
25
- .description('Массив спецификаций для генерации'),
21
+ items: joi_1.default.array().items(itemSchema).min(1).optional().description('Массив спецификаций для генерации'),
26
22
  // Single-item configuration (mutually exclusive with items)
27
23
  input: joi_1.default.string()
28
24
  .when('items', {
@@ -38,5 +34,8 @@ exports.unifiedOptionsSchemaV1 = (0, mergeObjectSchemas_1.mergeObjectSchemas)(jo
38
34
  otherwise: joi_1.default.required(),
39
35
  })
40
36
  .description('Выходная директория'),
37
+ httpClient: joi_1.default.string()
38
+ .valid(...Object.values(HttpClient_enum_1.HttpClient))
39
+ .optional(),
41
40
  }), CommonSchemas_1.outputPathsSchema, // outputCore, outputServices, etc. for single-item mode
42
41
  CommonSchemas_1.specialParametersSchemasV2, CommonSchemas_1.additionalParametersSchemaV2, CommonSchemas_1.experimentalParametersSchemaV2).xor('items', 'input');
@@ -1 +1 @@
1
- {"version":3,"file":"UnifiedOptionsSchemaV2.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAqBtB;;;GAGG;AACH,eAAO,MAAM,sBAAsB,uBA6BZ,CAAC"}
1
+ {"version":3,"file":"UnifiedOptionsSchemaV2.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAgBtB;;;GAGG;AACH,eAAO,MAAM,sBAAsB,uBA4BZ,CAAC"}
@@ -10,7 +10,7 @@ const CommonSchemas_1 = require("../CommonSchemas");
10
10
  const mergeObjectSchemas_1 = require("../Utils/mergeObjectSchemas");
11
11
  const itemSchema = (0, mergeObjectSchemas_1.mergeObjectSchemas)(joi_1.default.object({
12
12
  input: joi_1.default.string().required().description('Путь, URL или строка OpenAPI спецификации'),
13
- httpClient: joi_1.default.string().valid(...Object.values(HttpClient_enum_1.HttpClient)).optional(),
13
+ request: joi_1.default.string().optional(),
14
14
  }), CommonSchemas_1.outputPathsSchema, CommonSchemas_1.additionalParametersSchemaV2, CommonSchemas_1.experimentalParametersSchemaV2);
15
15
  /**
16
16
  * Unified options schema that supports both single and multi-item configurations.
@@ -18,11 +18,7 @@ const itemSchema = (0, mergeObjectSchemas_1.mergeObjectSchemas)(joi_1.default.ob
18
18
  */
19
19
  exports.unifiedOptionsSchemaV2 = (0, mergeObjectSchemas_1.mergeObjectSchemas)(joi_1.default.object({
20
20
  // Multi-item configuration
21
- items: joi_1.default.array()
22
- .items(itemSchema)
23
- .min(1)
24
- .optional()
25
- .description('Массив спецификаций для генерации'),
21
+ items: joi_1.default.array().items(itemSchema).min(1).optional().description('Массив спецификаций для генерации'),
26
22
  // Single-item configuration (mutually exclusive with items)
27
23
  input: joi_1.default.string()
28
24
  .when('items', {
@@ -38,5 +34,8 @@ exports.unifiedOptionsSchemaV2 = (0, mergeObjectSchemas_1.mergeObjectSchemas)(jo
38
34
  otherwise: joi_1.default.required(),
39
35
  })
40
36
  .description('Выходная директория'),
37
+ httpClient: joi_1.default.string()
38
+ .valid(...Object.values(HttpClient_enum_1.HttpClient))
39
+ .optional(),
41
40
  }), CommonSchemas_1.outputPathsSchema, // outputCore, outputServices, etc. for single-item mode
42
41
  CommonSchemas_1.specialParametersSchemasV3, CommonSchemas_1.additionalParametersSchemaV2, CommonSchemas_1.experimentalParametersSchemaV2).xor('items', 'input');
@@ -1,4 +1,4 @@
1
- import { copyFile as __copyFile, exists as __exists, readFile as __readFile, writeFile as __writeFile } from 'fs';
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
4
  declare const fileSystemHelpers: {
@@ -6,10 +6,12 @@ declare const fileSystemHelpers: {
6
6
  writeFile: typeof __writeFile.__promisify__;
7
7
  copyFile: typeof __copyFile.__promisify__;
8
8
  exists: typeof __exists.__promisify__;
9
+ cp: (arg1: string | import("url").URL, arg2: string | import("url").URL) => Promise<void>;
9
10
  mkdir: (path: string) => Promise<void>;
10
11
  rmdir: (path: string) => Promise<void>;
11
12
  isDirectory: typeof isDirectory;
12
13
  isPathToFile: typeof isPathToFile;
14
+ readdir: typeof __readdir.__promisify__;
13
15
  };
14
16
  export { fileSystemHelpers };
15
17
  //# 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,EACtB,MAAM,IAAI,QAAQ,EAGlB,QAAQ,IAAI,UAAU,EAKtB,SAAS,IAAI,WAAW,EAC3B,MAAM,IAAI,CAAC;AAyDZ,iBAAS,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM1C;AAED,iBAAS,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM3C;AAED,QAAA,MAAM,iBAAiB;;;;;kBArDI,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;kBAgBtB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;;;CA8ChD,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
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,EAKtB,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,QAAA,MAAM,iBAAiB;;;;;;kBArDI,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;kBAgBtB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;;;;CAgDhD,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -16,6 +16,7 @@ const readFile = (0, util_1.promisify)(fs_1.readFile);
16
16
  const writeFile = (0, util_1.promisify)(fs_1.writeFile);
17
17
  const copyFile = (0, util_1.promisify)(fs_1.copyFile);
18
18
  const exists = (0, util_1.promisify)(fs_1.exists);
19
+ const cp = (0, util_1.promisify)(fs_1.cp);
19
20
  // Рекурсивное создание директорий (замена mkdirp)
20
21
  const mkdir = async (path) => {
21
22
  try {
@@ -77,9 +78,11 @@ const fileSystemHelpers = {
77
78
  writeFile,
78
79
  copyFile,
79
80
  exists,
81
+ cp,
80
82
  mkdir,
81
83
  rmdir,
82
84
  isDirectory,
83
85
  isPathToFile,
86
+ readdir,
84
87
  };
85
88
  exports.fileSystemHelpers = fileSystemHelpers;
@@ -42,10 +42,6 @@ const WriteClient_1 = require("../WriteClient");
42
42
  exports: {
43
43
  model: () => 'model',
44
44
  schema: () => 'schema',
45
- zodSchema: () => 'zodSchema',
46
- yupSchema: () => 'yupSchema',
47
- joiSchema: () => 'joiSchema',
48
- jsonSchemaSchema: () => 'jsonSchemaSchema',
49
45
  service: () => 'service',
50
46
  },
51
47
  core: {
@@ -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,+BAA+B,CAAC;AAE1D,eAAO,MAAM,SAAS,EAAE,SA6BvB,CAAC"}
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__mocks__/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,eAAO,MAAM,SAAS,EAAE,SAyBvB,CAAC"}
@@ -13,10 +13,6 @@ exports.templates = {
13
13
  exports: {
14
14
  model: () => 'model',
15
15
  schema: () => 'schema',
16
- zodSchema: () => 'zodSchema',
17
- yupSchema: () => 'yupSchema',
18
- joiSchema: () => 'joiSchema',
19
- jsonSchemaSchema: () => 'jsonSchemaSchema',
20
16
  service: () => 'service',
21
17
  },
22
18
  core: {
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  const node_assert_1 = __importDefault(require("node:assert"));
40
40
  const node_test_1 = __importStar(require("node:test"));
41
41
  const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
42
+ const ValidationLibrary_enum_1 = require("../../types/enums/ValidationLibrary.enum");
42
43
  const registerHandlebarTemplates_1 = require("../registerHandlebarTemplates");
43
44
  (0, node_test_1.describe)('@unit: registerHandlebarTemplates', () => {
44
45
  (0, node_test_1.default)('should return correct templates', () => {
@@ -46,6 +47,7 @@ const registerHandlebarTemplates_1 = require("../registerHandlebarTemplates");
46
47
  httpClient: HttpClient_enum_1.HttpClient.FETCH,
47
48
  useOptions: false,
48
49
  useUnionTypes: false,
50
+ validationLibrary: ValidationLibrary_enum_1.ValidationLibrary.ZOD,
49
51
  });
50
52
  node_assert_1.default.notEqual(templates.indexes.full, undefined);
51
53
  node_assert_1.default.notEqual(templates.indexes.models, undefined);
@@ -12,11 +12,7 @@ export interface Templates {
12
12
  };
13
13
  exports: {
14
14
  model: Handlebars.TemplateDelegate;
15
- schema: Handlebars.TemplateDelegate;
16
- zodSchema: Handlebars.TemplateDelegate;
17
- yupSchema: Handlebars.TemplateDelegate;
18
- joiSchema: Handlebars.TemplateDelegate;
19
- jsonSchemaSchema: Handlebars.TemplateDelegate;
15
+ schema: Handlebars.TemplateDelegate | undefined;
20
16
  service: Handlebars.TemplateDelegate;
21
17
  };
22
18
  core: {
@@ -1 +1 @@
1
- {"version":3,"file":"registerHandlebarTemplates.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarTemplates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAyFjD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AA0C1E,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,KAAK,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACnC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,SAAS,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACvC,SAAS,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACvC,SAAS,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACvC,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,CAAA;QAC7C,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,oBAAoB,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACrD,CAAC;CACL;AAED;;;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,CAiK1K"}
1
+ {"version":3,"file":"registerHandlebarTemplates.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarTemplates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAwFjD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AA0C1E,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,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,oBAAoB,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACrD,CAAC;CACL;AAED;;;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,CAqK1K"}
@@ -86,7 +86,6 @@ const getResponseHeader_4 = __importDefault(require("../../templatesCompiled/cli
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
88
  const exportModel_1 = __importDefault(require("../../templatesCompiled/client/exportModel"));
89
- const exportSchema_1 = __importDefault(require("../../templatesCompiled/client/exportSchema"));
90
89
  const exportService_1 = __importDefault(require("../../templatesCompiled/client/exportService"));
91
90
  const indexFull_1 = __importDefault(require("../../templatesCompiled/client/indexFull"));
92
91
  const indexSimple_1 = __importDefault(require("../../templatesCompiled/client/indexSimple"));
@@ -127,7 +126,7 @@ const typeReference_1 = __importDefault(require("../../templatesCompiled/client/
127
126
  const typeUnion_1 = __importDefault(require("../../templatesCompiled/client/partials/typeUnion"));
128
127
  const registerHandlebarHelpers_1 = require("./registerHandlebarHelpers");
129
128
  const ValidationLibrary_enum_1 = require("../types/enums/ValidationLibrary.enum");
130
- const exportSchema_2 = __importDefault(require("../../templatesCompiled/client/zod/exportSchema"));
129
+ const exportSchema_1 = __importDefault(require("../../templatesCompiled/client/zod/exportSchema"));
131
130
  const zodSchema_1 = __importDefault(require("../../templatesCompiled/client/zod/partials/zodSchema"));
132
131
  const zodSchemaInterface_1 = __importDefault(require("../../templatesCompiled/client/zod/partials/zodSchemaInterface"));
133
132
  const zodSchemaEnum_1 = __importDefault(require("../../templatesCompiled/client/zod/partials/zodSchemaEnum"));
@@ -136,7 +135,7 @@ const zodSchemaDictionary_1 = __importDefault(require("../../templatesCompiled/c
136
135
  const zodSchemaGeneric_1 = __importDefault(require("../../templatesCompiled/client/zod/partials/zodSchemaGeneric"));
137
136
  const zodSchemaReference_1 = __importDefault(require("../../templatesCompiled/client/zod/partials/zodSchemaReference"));
138
137
  const zodSchemaComposition_1 = __importDefault(require("../../templatesCompiled/client/zod/partials/zodSchemaComposition"));
139
- const exportSchema_3 = __importDefault(require("../../templatesCompiled/client/yup/exportSchema"));
138
+ const exportSchema_2 = __importDefault(require("../../templatesCompiled/client/yup/exportSchema"));
140
139
  const yupSchema_1 = __importDefault(require("../../templatesCompiled/client/yup/partials/yupSchema"));
141
140
  const yupSchemaInterface_1 = __importDefault(require("../../templatesCompiled/client/yup/partials/yupSchemaInterface"));
142
141
  const yupSchemaEnum_1 = __importDefault(require("../../templatesCompiled/client/yup/partials/yupSchemaEnum"));
@@ -145,7 +144,7 @@ const yupSchemaDictionary_1 = __importDefault(require("../../templatesCompiled/c
145
144
  const yupSchemaGeneric_1 = __importDefault(require("../../templatesCompiled/client/yup/partials/yupSchemaGeneric"));
146
145
  const yupSchemaReference_1 = __importDefault(require("../../templatesCompiled/client/yup/partials/yupSchemaReference"));
147
146
  const yupSchemaComposition_1 = __importDefault(require("../../templatesCompiled/client/yup/partials/yupSchemaComposition"));
148
- const exportSchema_4 = __importDefault(require("../../templatesCompiled/client/joi/exportSchema"));
147
+ const exportSchema_3 = __importDefault(require("../../templatesCompiled/client/joi/exportSchema"));
149
148
  const joiSchema_1 = __importDefault(require("../../templatesCompiled/client/joi/partials/joiSchema"));
150
149
  const joiSchemaInterface_1 = __importDefault(require("../../templatesCompiled/client/joi/partials/joiSchemaInterface"));
151
150
  const joiSchemaEnum_1 = __importDefault(require("../../templatesCompiled/client/joi/partials/joiSchemaEnum"));
@@ -154,7 +153,7 @@ const joiSchemaDictionary_1 = __importDefault(require("../../templatesCompiled/c
154
153
  const joiSchemaGeneric_1 = __importDefault(require("../../templatesCompiled/client/joi/partials/joiSchemaGeneric"));
155
154
  const joiSchemaReference_1 = __importDefault(require("../../templatesCompiled/client/joi/partials/joiSchemaReference"));
156
155
  const joiSchemaComposition_1 = __importDefault(require("../../templatesCompiled/client/joi/partials/joiSchemaComposition"));
157
- const exportSchema_5 = __importDefault(require("../../templatesCompiled/client/jsonschema/exportSchema"));
156
+ const exportSchema_4 = __importDefault(require("../../templatesCompiled/client/jsonschema/exportSchema"));
158
157
  const jsonschemaSchema_1 = __importDefault(require("../../templatesCompiled/client/jsonschema/partials/jsonschemaSchema"));
159
158
  const jsonschemaSchemaInterface_1 = __importDefault(require("../../templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface"));
160
159
  const jsonschemaSchemaEnum_1 = __importDefault(require("../../templatesCompiled/client/jsonschema/partials/jsonschemaSchemaEnum"));
@@ -181,11 +180,7 @@ function registerHandlebarTemplates(root) {
181
180
  },
182
181
  exports: {
183
182
  model: Handlebars.template(exportModel_1.default),
184
- schema: Handlebars.template(exportSchema_1.default),
185
- zodSchema: Handlebars.template(exportSchema_2.default),
186
- yupSchema: Handlebars.template(exportSchema_3.default),
187
- joiSchema: Handlebars.template(exportSchema_4.default),
188
- jsonSchemaSchema: Handlebars.template(exportSchema_5.default),
183
+ schema: undefined,
189
184
  service: Handlebars.template(exportService_1.default),
190
185
  },
191
186
  core: {
@@ -274,6 +269,7 @@ function registerHandlebarTemplates(root) {
274
269
  Handlebars.registerPartial('axios/request', Handlebars.template(request_1.default));
275
270
  // Register Zod partials if validationLibrary is ZOD
276
271
  if (root?.validationLibrary === ValidationLibrary_enum_1.ValidationLibrary.ZOD) {
272
+ templates.exports.schema = Handlebars.template(exportSchema_1.default);
277
273
  Handlebars.registerPartial('zodSchema', Handlebars.template(zodSchema_1.default));
278
274
  Handlebars.registerPartial('zodSchemaInterface', Handlebars.template(zodSchemaInterface_1.default));
279
275
  Handlebars.registerPartial('zodSchemaEnum', Handlebars.template(zodSchemaEnum_1.default));
@@ -285,6 +281,7 @@ function registerHandlebarTemplates(root) {
285
281
  }
286
282
  // Register Yup partials if validationLibrary is YUP
287
283
  if (root?.validationLibrary === ValidationLibrary_enum_1.ValidationLibrary.YUP) {
284
+ templates.exports.schema = Handlebars.template(exportSchema_2.default);
288
285
  Handlebars.registerPartial('yupSchema', Handlebars.template(yupSchema_1.default));
289
286
  Handlebars.registerPartial('yupSchemaInterface', Handlebars.template(yupSchemaInterface_1.default));
290
287
  Handlebars.registerPartial('yupSchemaEnum', Handlebars.template(yupSchemaEnum_1.default));
@@ -296,6 +293,7 @@ function registerHandlebarTemplates(root) {
296
293
  }
297
294
  // Register Joi partials if validationLibrary is JOI
298
295
  if (root?.validationLibrary === ValidationLibrary_enum_1.ValidationLibrary.JOI) {
296
+ templates.exports.schema = Handlebars.template(exportSchema_3.default);
299
297
  Handlebars.registerPartial('joiSchema', Handlebars.template(joiSchema_1.default));
300
298
  Handlebars.registerPartial('joiSchemaInterface', Handlebars.template(joiSchemaInterface_1.default));
301
299
  Handlebars.registerPartial('joiSchemaEnum', Handlebars.template(joiSchemaEnum_1.default));
@@ -306,6 +304,7 @@ function registerHandlebarTemplates(root) {
306
304
  Handlebars.registerPartial('joiSchemaComposition', Handlebars.template(joiSchemaComposition_1.default));
307
305
  }
308
306
  if (root.validationLibrary === ValidationLibrary_enum_1.ValidationLibrary.JSONSCHEMA) {
307
+ templates.exports.schema = Handlebars.template(exportSchema_4.default);
309
308
  Handlebars.registerPartial('jsonschemaSchema', Handlebars.template(jsonschemaSchema_1.default));
310
309
  Handlebars.registerPartial('jsonschemaSchemaInterface', Handlebars.template(jsonschemaSchemaInterface_1.default));
311
310
  Handlebars.registerPartial('jsonschemaSchemaEnum', Handlebars.template(jsonschemaSchemaEnum_1.default));
@@ -1 +1 @@
1
- {"version":3,"file":"writeClientSchemas.d.ts","sourceRoot":"","sources":["../../../src/core/utils/writeClientSchemas.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD;;;;;;GAMG;AACH,UAAU,mBAAmB;IACzB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4CvG"}
1
+ {"version":3,"file":"writeClientSchemas.d.ts","sourceRoot":"","sources":["../../../src/core/utils/writeClientSchemas.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD;;;;;;GAMG;AACH,UAAU,mBAAmB;IACzB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCvG"}
@@ -5,7 +5,6 @@ const fs_1 = require("fs");
5
5
  const fileSystemHelpers_1 = require("../../common/utils/fileSystemHelpers");
6
6
  const format_1 = require("../../common/utils/format");
7
7
  const pathHelpers_1 = require("../../common/utils/pathHelpers");
8
- const ValidationLibrary_enum_1 = require("../types/enums/ValidationLibrary.enum");
9
8
  /**
10
9
  * Generate Schemas using the Handlebar template and write to disk.
11
10
  * @param models Array of Models to write
@@ -16,36 +15,28 @@ const ValidationLibrary_enum_1 = require("../types/enums/ValidationLibrary.enum"
16
15
  */
17
16
  async function writeClientSchemas(options) {
18
17
  const { models, templates, outputSchemasPath, httpClient, useUnionTypes, validationLibrary } = options;
19
- this.logger.info('The recording of model validation schema files begins.');
20
- // Choose template based on validation library
21
- const schemaTemplate = validationLibrary === ValidationLibrary_enum_1.ValidationLibrary.ZOD
22
- ? templates.exports.zodSchema
23
- : validationLibrary === ValidationLibrary_enum_1.ValidationLibrary.YUP
24
- ? templates.exports.yupSchema
25
- : validationLibrary === ValidationLibrary_enum_1.ValidationLibrary.JOI
26
- ? templates.exports.joiSchema
27
- : validationLibrary === ValidationLibrary_enum_1.ValidationLibrary.JSONSCHEMA
28
- ? templates.exports.jsonSchemaSchema
29
- : templates.exports.schema;
30
- for (const model of models) {
31
- const modelFolderPath = model?.path;
32
- const dir = (0, pathHelpers_1.dirNameHelper)(modelFolderPath);
33
- if (dir) {
34
- const directory = (0, pathHelpers_1.resolveHelper)(outputSchemasPath, dir);
35
- this.logger.info(`A directory is being created: ${directory}`);
36
- (0, fs_1.mkdirSync)(directory, { recursive: true });
18
+ if (templates.exports.schema) {
19
+ this.logger.info('The recording of model validation schema files begins.');
20
+ for (const model of models) {
21
+ const modelFolderPath = model?.path;
22
+ const dir = (0, pathHelpers_1.dirNameHelper)(modelFolderPath);
23
+ if (dir) {
24
+ const directory = (0, pathHelpers_1.resolveHelper)(outputSchemasPath, dir);
25
+ this.logger.info(`A directory is being created: ${directory}`);
26
+ (0, fs_1.mkdirSync)(directory, { recursive: true });
27
+ }
28
+ const file = (0, pathHelpers_1.resolveHelper)(outputSchemasPath, `${modelFolderPath}Schema.ts`);
29
+ this.logger.info(`The recording of the file data begins: ${file}`);
30
+ const templateResult = templates.exports.schema({
31
+ ...model,
32
+ httpClient,
33
+ useUnionTypes,
34
+ validationLibrary,
35
+ });
36
+ const formattedValue = await (0, format_1.format)(templateResult);
37
+ await fileSystemHelpers_1.fileSystemHelpers.writeFile(file, formattedValue);
38
+ this.logger.info(`File recording completed: ${file}`);
37
39
  }
38
- const file = (0, pathHelpers_1.resolveHelper)(outputSchemasPath, `${modelFolderPath}Schema.ts`);
39
- this.logger.info(`The recording of the file data begins: ${file}`);
40
- const templateResult = schemaTemplate({
41
- ...model,
42
- httpClient,
43
- useUnionTypes,
44
- validationLibrary,
45
- });
46
- const formattedValue = await (0, format_1.format)(templateResult);
47
- await fileSystemHelpers_1.fileSystemHelpers.writeFile(file, formattedValue);
48
- this.logger.info(`File recording completed: ${file}`);
40
+ this.logger.info('The recording of model validation schema files has been completed successfully');
49
41
  }
50
- this.logger.info('The recording of model validation schema files has been completed successfully');
51
42
  }
@@ -7,5 +7,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  /* eslint: disable */
8
8
  // @ts-nocheck
9
9
  exports.default = { "compiler": [8, ">= 4.3.0"], "main": function (container, depth0, helpers, partials, data) {
10
- return "export interface RequestConfig {\n method: string;\n url: string;\n headers?: Record<string, string>;\n query?: Record<string, any>;\n body?: unknown;\n}\n\nexport interface RequestExecutor<TOptions = unknown> {\n request<TResponse>(\n config: RequestConfig,\n options?: TOptions\n ): Promise<TResponse>;\n}";
10
+ return "export interface RequestConfig {\n method: string;\n path: string;\n\n headers?: Record<string, string>;\n query?: Record<string, any>;\n body?: unknown;\n\n requestMediaType?: string;\n cookies?: Record<string, string>;\n}\n\nexport interface RequestExecutor<TOptions = unknown> {\n request<TResponse>(\n config: RequestConfig,\n options?: TOptions\n ): Promise<TResponse>;\n}";
11
11
  }, "useData": true };
@@ -25,7 +25,7 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
25
25
  + ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "parameters"), { "name": "each", "hash": {}, "fn": container.program(3, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 11, "column": 9 } } })) != null ? stack1 : "")
26
26
  + "}: {\n"
27
27
  + ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "parameters"), { "name": "each", "hash": {}, "fn": container.program(8, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 13, "column": 0 }, "end": { "line": 23, "column": 9 } } })) != null ? stack1 : "")
28
- + "}";
28
+ + "},";
29
29
  }, "3": function (container, depth0, helpers, partials, data) {
30
30
  var stack1, alias1 = depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty = container.lookupProperty || function (parent, propertyName) {
31
31
  if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
@@ -4,11 +4,8 @@ declare const _default: {
4
4
  "4": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
5
5
  "6": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
6
6
  "8": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
7
- "10": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
7
+ "9": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
8
8
  "11": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
9
- "13": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
10
- "15": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
11
- "16": (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
12
9
  compiler: (string | number)[];
13
10
  main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
14
11
  useData: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"serviceOption.d.ts","sourceRoot":"","sources":["../../../../src/templatesCompiled/client/partials/serviceOption.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMA,wBAwHiB"}
1
+ {"version":3,"file":"serviceOption.d.ts","sourceRoot":"","sources":["../../../../src/templatesCompiled/client/partials/serviceOption.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,wBAiGiB"}
@@ -13,15 +13,15 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
13
13
  }
14
14
  return undefined;
15
15
  };
16
- return " cookies: {\n"
17
- + ((stack1 = lookupProperty(helpers, "each").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "parametersCookie"), { "name": "each", "hash": {}, "fn": container.program(2, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 5, "column": 4 }, "end": { "line": 7, "column": 13 } } })) != null ? stack1 : "")
16
+ return " headers: {\n"
17
+ + ((stack1 = lookupProperty(helpers, "each").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "parametersHeader"), { "name": "each", "hash": {}, "fn": container.program(2, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 6, "column": 4 }, "end": { "line": 9, "column": 13 } } })) != null ? stack1 : "")
18
18
  + " },\n";
19
19
  }, "2": function (container, depth0, helpers, partials, data) {
20
20
  var stack1, alias1 = container.strict, alias2 = container.lambda;
21
21
  return " '"
22
- + ((stack1 = alias2(alias1(depth0, "prop", { "start": { "line": 6, "column": 12 }, "end": { "line": 6, "column": 16 } }), depth0)) != null ? stack1 : "")
23
- + "': "
24
- + ((stack1 = alias2(alias1(depth0, "name", { "start": { "line": 6, "column": 25 }, "end": { "line": 6, "column": 29 } }), depth0)) != null ? stack1 : "")
22
+ + ((stack1 = alias2(alias1(depth0, "prop", { "start": { "line": 7, "column": 12 }, "end": { "line": 7, "column": 16 } }), depth0)) != null ? stack1 : "")
23
+ + "':\n "
24
+ + ((stack1 = alias2(alias1(depth0, "name", { "start": { "line": 8, "column": 11 }, "end": { "line": 8, "column": 15 } }), depth0)) != null ? stack1 : "")
25
25
  + ",\n";
26
26
  }, "4": function (container, depth0, helpers, partials, data) {
27
27
  var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
@@ -30,8 +30,8 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
30
30
  }
31
31
  return undefined;
32
32
  };
33
- return " headers: {\n"
34
- + ((stack1 = lookupProperty(helpers, "each").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "parametersHeader"), { "name": "each", "hash": {}, "fn": container.program(2, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 12, "column": 4 }, "end": { "line": 14, "column": 13 } } })) != null ? stack1 : "")
33
+ return " cookies: {\n"
34
+ + ((stack1 = lookupProperty(helpers, "each").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "parametersCookie"), { "name": "each", "hash": {}, "fn": container.program(2, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 15, "column": 4 }, "end": { "line": 18, "column": 13 } } })) != null ? stack1 : "")
35
35
  + " },\n";
36
36
  }, "6": function (container, depth0, helpers, partials, data) {
37
37
  var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
@@ -41,7 +41,7 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
41
41
  return undefined;
42
42
  };
43
43
  return " query: {\n"
44
- + ((stack1 = lookupProperty(helpers, "each").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "parametersQuery"), { "name": "each", "hash": {}, "fn": container.program(2, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 19, "column": 4 }, "end": { "line": 21, "column": 13 } } })) != null ? stack1 : "")
44
+ + ((stack1 = lookupProperty(helpers, "each").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "parametersQuery"), { "name": "each", "hash": {}, "fn": container.program(2, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 27, "column": 13 } } })) != null ? stack1 : "")
45
45
  + " },\n";
46
46
  }, "8": function (container, depth0, helpers, partials, data) {
47
47
  var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
@@ -50,52 +50,30 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
50
50
  }
51
51
  return undefined;
52
52
  };
53
- return " formData: {\n"
54
- + ((stack1 = lookupProperty(helpers, "each").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "parametersForm"), { "name": "each", "hash": {}, "fn": container.program(2, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 26, "column": 4 }, "end": { "line": 28, "column": 13 } } })) != null ? stack1 : "")
55
- + " },\n";
56
- }, "10": function (container, depth0, helpers, partials, data) {
57
- var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
58
- if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
59
- return parent[propertyName];
60
- }
61
- return undefined;
62
- };
63
- return " body: "
64
- + ((stack1 = container.lambda(container.strict(lookupProperty(depth0, "parametersBody"), "name", { "start": { "line": 32, "column": 13 }, "end": { "line": 32, "column": 32 } }), depth0)) != null ? stack1 : "")
53
+ return " body:\n "
54
+ + ((stack1 = container.lambda(container.strict(lookupProperty(depth0, "parametersBody"), "name", { "start": { "line": 33, "column": 7 }, "end": { "line": 33, "column": 26 } }), depth0)) != null ? stack1 : "")
65
55
  + ",\n"
66
- + ((stack1 = lookupProperty(helpers, "if").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(lookupProperty(depth0, "parametersBody"), "mediaType"), { "name": "if", "hash": {}, "fn": container.program(11, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 33, "column": 4 }, "end": { "line": 35, "column": 11 } } })) != null ? stack1 : "");
67
- }, "11": function (container, depth0, helpers, partials, data) {
56
+ + ((stack1 = lookupProperty(helpers, "if").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(lookupProperty(depth0, "parametersBody"), "mediaType"), { "name": "if", "hash": {}, "fn": container.program(9, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 34, "column": 4 }, "end": { "line": 36, "column": 11 } } })) != null ? stack1 : "");
57
+ }, "9": function (container, depth0, helpers, partials, data) {
68
58
  var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
69
59
  if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
70
60
  return parent[propertyName];
71
61
  }
72
62
  return undefined;
73
63
  };
74
- return " mediaType: '"
75
- + ((stack1 = container.lambda(container.strict(lookupProperty(depth0, "parametersBody"), "mediaType", { "start": { "line": 34, "column": 23 }, "end": { "line": 34, "column": 47 } }), depth0)) != null ? stack1 : "")
64
+ return " requestMediaType: '"
65
+ + ((stack1 = container.lambda(container.strict(lookupProperty(depth0, "parametersBody"), "mediaType", { "start": { "line": 35, "column": 30 }, "end": { "line": 35, "column": 54 } }), depth0)) != null ? stack1 : "")
76
66
  + "',\n";
77
- }, "13": function (container, depth0, helpers, partials, data) {
78
- var stack1;
79
- return " responseHeader: '"
80
- + ((stack1 = container.lambda(container.strict(depth0, "responseHeader", { "start": { "line": 38, "column": 24 }, "end": { "line": 38, "column": 38 } }), depth0)) != null ? stack1 : "")
81
- + "',\n";
82
- }, "15": function (container, depth0, helpers, partials, data) {
67
+ }, "11": function (container, depth0, helpers, partials, data) {
83
68
  var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
84
69
  if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
85
70
  return parent[propertyName];
86
71
  }
87
72
  return undefined;
88
73
  };
89
- return " errors: {\n"
90
- + ((stack1 = lookupProperty(helpers, "each").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "errors"), { "name": "each", "hash": {}, "fn": container.program(16, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 42, "column": 4 }, "end": { "line": 44, "column": 13 } } })) != null ? stack1 : "")
91
- + " },\n";
92
- }, "16": function (container, depth0, helpers, partials, data) {
93
- var stack1, alias1 = container.strict, alias2 = container.lambda;
94
- return " "
95
- + ((stack1 = alias2(alias1(depth0, "code", { "start": { "line": 43, "column": 11 }, "end": { "line": 43, "column": 15 } }), depth0)) != null ? stack1 : "")
96
- + ": `"
97
- + ((stack1 = alias2(alias1(depth0, "description", { "start": { "line": 43, "column": 24 }, "end": { "line": 43, "column": 35 } }), depth0)) != null ? stack1 : "")
98
- + "`,\n";
74
+ return " body: {\n"
75
+ + ((stack1 = lookupProperty(helpers, "each").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "parametersForm"), { "name": "each", "hash": {}, "fn": container.program(2, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 41, "column": 4 }, "end": { "line": 44, "column": 13 } } })) != null ? stack1 : "")
76
+ + " }, requestMediaType: 'multipart/form-data',\n";
99
77
  }, "compiler": [8, ">= 4.3.0"], "main": function (container, depth0, helpers, partials, data) {
100
78
  var stack1, alias1 = container.strict, alias2 = container.lambda, alias3 = depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty = container.lookupProperty || function (parent, propertyName) {
101
79
  if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
@@ -107,12 +85,14 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
107
85
  + ((stack1 = alias2(alias1(depth0, "method", { "start": { "line": 1, "column": 12 }, "end": { "line": 1, "column": 18 } }), depth0)) != null ? stack1 : "")
108
86
  + "',\npath: `"
109
87
  + ((stack1 = alias2(alias1(depth0, "path", { "start": { "line": 2, "column": 10 }, "end": { "line": 2, "column": 14 } }), depth0)) != null ? stack1 : "")
110
- + "`,\n"
111
- + ((stack1 = lookupProperty(helpers, "if").call(alias3, lookupProperty(depth0, "parametersCookie"), { "name": "if", "hash": {}, "fn": container.program(1, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 9, "column": 7 } } })) != null ? stack1 : "")
112
- + ((stack1 = lookupProperty(helpers, "if").call(alias3, lookupProperty(depth0, "parametersHeader"), { "name": "if", "hash": {}, "fn": container.program(4, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 16, "column": 7 } } })) != null ? stack1 : "")
113
- + ((stack1 = lookupProperty(helpers, "if").call(alias3, lookupProperty(depth0, "parametersQuery"), { "name": "if", "hash": {}, "fn": container.program(6, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 17, "column": 0 }, "end": { "line": 23, "column": 7 } } })) != null ? stack1 : "")
114
- + ((stack1 = lookupProperty(helpers, "if").call(alias3, lookupProperty(depth0, "parametersForm"), { "name": "if", "hash": {}, "fn": container.program(8, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 24, "column": 0 }, "end": { "line": 30, "column": 7 } } })) != null ? stack1 : "")
115
- + ((stack1 = lookupProperty(helpers, "if").call(alias3, lookupProperty(depth0, "parametersBody"), { "name": "if", "hash": {}, "fn": container.program(10, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 31, "column": 0 }, "end": { "line": 36, "column": 7 } } })) != null ? stack1 : "")
116
- + ((stack1 = lookupProperty(helpers, "if").call(alias3, lookupProperty(depth0, "responseHeader"), { "name": "if", "hash": {}, "fn": container.program(13, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 37, "column": 0 }, "end": { "line": 39, "column": 7 } } })) != null ? stack1 : "")
117
- + ((stack1 = lookupProperty(helpers, "if").call(alias3, lookupProperty(depth0, "errors"), { "name": "if", "hash": {}, "fn": container.program(15, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 40, "column": 0 }, "end": { "line": 46, "column": 7 } } })) != null ? stack1 : "");
88
+ + "`,\n\n"
89
+ + ((stack1 = lookupProperty(helpers, "if").call(alias3, lookupProperty(depth0, "parametersHeader"), { "name": "if", "hash": {}, "fn": container.program(1, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 11, "column": 7 } } })) != null ? stack1 : "")
90
+ + "\n"
91
+ + ((stack1 = lookupProperty(helpers, "if").call(alias3, lookupProperty(depth0, "parametersCookie"), { "name": "if", "hash": {}, "fn": container.program(4, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 13, "column": 0 }, "end": { "line": 20, "column": 7 } } })) != null ? stack1 : "")
92
+ + "\n"
93
+ + ((stack1 = lookupProperty(helpers, "if").call(alias3, lookupProperty(depth0, "parametersQuery"), { "name": "if", "hash": {}, "fn": container.program(6, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 22, "column": 0 }, "end": { "line": 29, "column": 7 } } })) != null ? stack1 : "")
94
+ + "\n"
95
+ + ((stack1 = lookupProperty(helpers, "if").call(alias3, lookupProperty(depth0, "parametersBody"), { "name": "if", "hash": {}, "fn": container.program(8, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 31, "column": 0 }, "end": { "line": 37, "column": 7 } } })) != null ? stack1 : "")
96
+ + "\n"
97
+ + ((stack1 = lookupProperty(helpers, "if").call(alias3, lookupProperty(depth0, "parametersForm"), { "name": "if", "hash": {}, "fn": container.program(11, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 39, "column": 0 }, "end": { "line": 46, "column": 7 } } })) != null ? stack1 : "");
118
98
  }, "useData": true };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-openapi-codegen",
3
- "version": "2.0.0-beta.3",
3
+ "version": "2.0.0-beta.4",
4
4
  "description": "Library that generates Typescript clients based on the OpenAPI specification. It bases on openapi-typescript-codegen",
5
5
  "author": "Alexey Zverev",
6
6
  "homepage": "https://github.com/ozonophore/openapi-codegen.git",
@@ -69,6 +69,7 @@
69
69
  "chalk": "^4.1.2",
70
70
  "commander": "8.0.0",
71
71
  "configstore": "^5.0.1",
72
+ "diff": "^8.0.2",
72
73
  "enquirer": "^2.4.1",
73
74
  "fast-deep-equal": "^3.1.3",
74
75
  "figlet": "^1.8.0",
@@ -1 +0,0 @@
1
- {"version":3,"file":"runGenerateOpenApi.d.ts","sourceRoot":"","sources":["../../../src/cli/generate/runGenerateOpenApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAgBzC;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA8D7E"}