ts-openapi-codegen 2.0.0-beta.2 → 2.0.0-beta.3

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 (49) hide show
  1. package/dist/cli/generate/runGenerateOpenApi.d.ts.map +1 -1
  2. package/dist/cli/generate/runGenerateOpenApi.js +30 -9
  3. package/dist/cli/schemas/base.d.ts +17 -0
  4. package/dist/cli/schemas/base.d.ts.map +1 -0
  5. package/dist/cli/schemas/base.js +19 -0
  6. package/dist/cli/schemas/checkConfig.d.ts +6 -0
  7. package/dist/cli/schemas/checkConfig.d.ts.map +1 -0
  8. package/dist/cli/schemas/checkConfig.js +5 -0
  9. package/dist/cli/schemas/generate.d.ts +32 -0
  10. package/dist/cli/schemas/generate.d.ts.map +1 -0
  11. package/dist/cli/schemas/generate.js +56 -0
  12. package/dist/cli/schemas/index.d.ts +7 -0
  13. package/dist/cli/schemas/index.d.ts.map +1 -0
  14. package/dist/cli/schemas/index.js +21 -0
  15. package/dist/cli/schemas/init.d.ts +8 -0
  16. package/dist/cli/schemas/init.d.ts.map +1 -0
  17. package/dist/cli/schemas/init.js +9 -0
  18. package/dist/cli/schemas/updateConfig.d.ts +6 -0
  19. package/dist/cli/schemas/updateConfig.d.ts.map +1 -0
  20. package/dist/cli/schemas/updateConfig.js +5 -0
  21. package/dist/cli/validation/errorFormatter.d.ts +6 -0
  22. package/dist/cli/validation/errorFormatter.d.ts.map +1 -0
  23. package/dist/cli/validation/errorFormatter.js +113 -0
  24. package/dist/cli/validation/index.d.ts +3 -0
  25. package/dist/cli/validation/index.d.ts.map +1 -0
  26. package/dist/cli/validation/index.js +18 -0
  27. package/dist/cli/validation/validateCLIOptions.d.ts +27 -0
  28. package/dist/cli/validation/validateCLIOptions.d.ts.map +1 -0
  29. package/dist/cli/validation/validateCLIOptions.js +38 -0
  30. package/dist/common/TRawOptions.d.ts +4 -37
  31. package/dist/common/TRawOptions.d.ts.map +1 -1
  32. package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -1
  33. package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +9 -11
  34. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan.d.ts.map +1 -1
  35. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan.js +9 -16
  36. package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.d.ts.map +1 -1
  37. package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.js +2 -5
  38. package/dist/common/VersionedSchema/Utils/createFieldTransformationMigration.d.ts +32 -0
  39. package/dist/common/VersionedSchema/Utils/createFieldTransformationMigration.d.ts.map +1 -0
  40. package/dist/common/VersionedSchema/Utils/createFieldTransformationMigration.js +40 -0
  41. package/dist/common/VersionedSchema/Utils/getLatestVersionFromMigrationPlans.d.ts +16 -0
  42. package/dist/common/VersionedSchema/Utils/getLatestVersionFromMigrationPlans.d.ts.map +1 -0
  43. package/dist/common/VersionedSchema/Utils/getLatestVersionFromMigrationPlans.js +23 -0
  44. package/dist/common/schemas/configSchemas.d.ts +91 -0
  45. package/dist/common/schemas/configSchemas.d.ts.map +1 -0
  46. package/dist/common/schemas/configSchemas.js +131 -0
  47. package/dist/core/OpenApiClient.d.ts.map +1 -1
  48. package/dist/core/OpenApiClient.js +36 -1
  49. package/package.json +3 -2
@@ -1 +1 @@
1
- {"version":3,"file":"runGenerateOpenApi.d.ts","sourceRoot":"","sources":["../../../src/cli/generate/runGenerateOpenApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAYzC;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAwC7E"}
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"}
@@ -37,12 +37,15 @@ exports.runGenerateOpenApi = runGenerateOpenApi;
37
37
  const Consts_1 = require("../../common/Consts");
38
38
  const defaultOptions_1 = require("../../common/defaultOptions");
39
39
  const Enums_1 = require("../../common/Enums");
40
+ const LoggerMessages_1 = require("../../common/LoggerMessages");
40
41
  const convertArrayToObject_1 = require("../../common/utils/convertArrayToObject");
41
42
  const loadConfigIfExists_1 = require("../../common/utils/loadConfigIfExists");
42
43
  const AllMigrationPlans_1 = require("../../common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans");
43
44
  const AllVersionedSchemas_1 = require("../../common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas");
44
45
  const migrateDataToLatestSchemaVersion_1 = require("../../common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion");
45
46
  const OpenAPI = __importStar(require("../../core"));
47
+ const generate_1 = require("../schemas/generate");
48
+ const validation_1 = require("../validation");
46
49
  /**
47
50
  * Запускает генерацию OpenAPI клиента
48
51
  * Поддерживает как конфиг-файл, так и параметры из CLI
@@ -50,17 +53,35 @@ const OpenAPI = __importStar(require("../../core"));
50
53
  async function runGenerateOpenApi(options) {
51
54
  const { openapiConfig, ...clientOptions } = options;
52
55
  try {
53
- const hasMinimumRequiredOptions = !!clientOptions.input && !!clientOptions.output;
56
+ // Валидация опций через Zod
57
+ const validationResult = (0, validation_1.validateCLIOptions)(generate_1.generateOptionsSchema, {
58
+ openapiConfig,
59
+ ...clientOptions,
60
+ });
61
+ if (!validationResult.success) {
62
+ Consts_1.APP_LOGGER.error(validationResult.error);
63
+ process.exit(1);
64
+ }
65
+ const validatedOptions = validationResult.data;
66
+ // Если есть минимальные опции (input и output), используем их
67
+ const hasMinimumRequiredOptions = !!validatedOptions.input && !!validatedOptions.output;
54
68
  if (hasMinimumRequiredOptions) {
55
- const { error: defaultValuesError, value } = defaultOptions_1.defaultOptions.validate(clientOptions);
69
+ // Используем старую Joi валидацию для обратной совместимости
70
+ // В будущем можно заменить на Zod
71
+ const { error: defaultValuesError, value } = defaultOptions_1.defaultOptions.validate({
72
+ input: validatedOptions.input,
73
+ output: validatedOptions.output,
74
+ ...clientOptions,
75
+ });
56
76
  if (defaultValuesError) {
57
77
  await OpenAPI.generate(value);
58
78
  process.exit(0);
59
79
  }
60
80
  }
61
- const configData = (0, loadConfigIfExists_1.loadConfigIfExists)(openapiConfig);
81
+ const configData = (0, loadConfigIfExists_1.loadConfigIfExists)(validatedOptions.openapiConfig);
62
82
  if (!configData) {
63
- Consts_1.APP_LOGGER.error('The configuration file is missing');
83
+ Consts_1.APP_LOGGER.error(LoggerMessages_1.LOGGER_MESSAGES.CONFIG.FILE_MISSING);
84
+ process.exit(1);
64
85
  }
65
86
  const preparedOptions = (0, convertArrayToObject_1.convertArrayToObject)(configData);
66
87
  // Use unified migration system for all schema types
@@ -71,15 +92,15 @@ async function runGenerateOpenApi(options) {
71
92
  migrationMode: Enums_1.EMigrationMode.GENERATE_OPENAPI,
72
93
  });
73
94
  if (!migratedOptions) {
74
- Consts_1.APP_LOGGER.error("Couldn't convert the set of options to the current version");
75
- }
76
- else {
77
- const { value } = migratedOptions;
78
- await OpenAPI.generate(value);
95
+ Consts_1.APP_LOGGER.error(LoggerMessages_1.LOGGER_MESSAGES.CONFIG.CONVERSION_FAILED);
96
+ process.exit(1);
79
97
  }
98
+ const { value } = migratedOptions;
99
+ await OpenAPI.generate(value);
80
100
  process.exit(0);
81
101
  }
82
102
  catch (error) {
83
103
  Consts_1.APP_LOGGER.error(error.message);
104
+ process.exit(1);
84
105
  }
85
106
  }
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ import { ELogLevel, ELogOutput } from '../../common/Enums';
3
+ import { HttpClient } from '../../core/types/enums/HttpClient.enum';
4
+ /**
5
+ * Базовая схема с общими опциями для всех команд
6
+ */
7
+ export declare const baseCLIOptionsSchema: z.ZodObject<{
8
+ openapiConfig: z.ZodDefault<z.ZodOptional<z.ZodString>>;
9
+ }, z.core.$strip>;
10
+ export type BaseCLIOptions = z.infer<typeof baseCLIOptionsSchema>;
11
+ /**
12
+ * Enum схемы для типизированных значений
13
+ */
14
+ export declare const httpClientSchema: z.ZodEnum<typeof HttpClient>;
15
+ export declare const logLevelSchema: z.ZodEnum<typeof ELogLevel>;
16
+ export declare const logTargetSchema: z.ZodEnum<typeof ELogOutput>;
17
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/cli/schemas/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,oBAAoB;;iBAE/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,gBAAgB,8BAA2B,CAAC;AACzD,eAAO,MAAM,cAAc,6BAA0B,CAAC;AACtD,eAAO,MAAM,eAAe,8BAA2B,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logTargetSchema = exports.logLevelSchema = exports.httpClientSchema = exports.baseCLIOptionsSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const Consts_1 = require("../../common/Consts");
6
+ const Enums_1 = require("../../common/Enums");
7
+ const HttpClient_enum_1 = require("../../core/types/enums/HttpClient.enum");
8
+ /**
9
+ * Базовая схема с общими опциями для всех команд
10
+ */
11
+ exports.baseCLIOptionsSchema = zod_1.z.object({
12
+ openapiConfig: zod_1.z.string().optional().default(Consts_1.DEFAULT_OPENAPI_CONFIG_FILENAME),
13
+ });
14
+ /**
15
+ * Enum схемы для типизированных значений
16
+ */
17
+ exports.httpClientSchema = zod_1.z.nativeEnum(HttpClient_enum_1.HttpClient);
18
+ exports.logLevelSchema = zod_1.z.nativeEnum(Enums_1.ELogLevel);
19
+ exports.logTargetSchema = zod_1.z.nativeEnum(Enums_1.ELogOutput);
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+ export declare const checkConfigOptionsSchema: z.ZodObject<{
3
+ openapiConfig: z.ZodDefault<z.ZodOptional<z.ZodString>>;
4
+ }, z.core.$strip>;
5
+ export type CheckConfigOptions = z.infer<typeof checkConfigOptionsSchema>;
6
+ //# sourceMappingURL=checkConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkConfig.d.ts","sourceRoot":"","sources":["../../../src/cli/schemas/checkConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,wBAAwB;;iBAAuB,CAAC;AAE7D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkConfigOptionsSchema = void 0;
4
+ const base_1 = require("./base");
5
+ exports.checkConfigOptionsSchema = base_1.baseCLIOptionsSchema;
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Схема для команды generate
4
+ * Основана на baseFlatOptionsSchema, но с добавлением:
5
+ * - openapiConfig (из baseCLIOptionsSchema)
6
+ * - опциональными input/output (валидируются условно)
7
+ */
8
+ export declare const generateOptionsSchema: z.ZodObject<{
9
+ openapiConfig: z.ZodDefault<z.ZodOptional<z.ZodString>>;
10
+ outputCore: z.ZodOptional<z.ZodString>;
11
+ outputServices: z.ZodOptional<z.ZodString>;
12
+ outputModels: z.ZodOptional<z.ZodString>;
13
+ outputSchemas: z.ZodOptional<z.ZodString>;
14
+ interfacePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
15
+ enumPrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
16
+ typePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
17
+ httpClient: z.ZodOptional<z.ZodEnum<typeof import("../..").HttpClient>>;
18
+ useOptions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
19
+ useUnionTypes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
20
+ excludeCoreServiceFiles: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
21
+ request: z.ZodOptional<z.ZodString>;
22
+ useCancelableRequest: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
23
+ logLevel: z.ZodOptional<z.ZodEnum<typeof import("../../common/Enums").ELogLevel>>;
24
+ logTarget: z.ZodOptional<z.ZodEnum<typeof import("../../common/Enums").ELogOutput>>;
25
+ sortByRequired: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
26
+ useSeparatedIndexes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
27
+ validationLibrary: z.ZodOptional<z.ZodEnum<typeof import("../../core/types/enums/ValidationLibrary.enum").ValidationLibrary>>;
28
+ input: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
29
+ output: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
30
+ }, z.core.$strip>;
31
+ export type GenerateOptions = z.infer<typeof generateOptionsSchema>;
32
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/cli/schemas/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgBxB;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;iBAwC5B,CAAC;AAEP,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateOptionsSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const Consts_1 = require("../../common/Consts");
6
+ const configSchemas_1 = require("../../common/schemas/configSchemas");
7
+ const loadConfigIfExists_1 = require("../../common/utils/loadConfigIfExists");
8
+ const base_1 = require("./base");
9
+ /**
10
+ * Преобразует пустые строки в undefined для опциональных полей
11
+ * Это нужно, потому что Commander.js передает пустые строки для опций без значений
12
+ */
13
+ const emptyStringToUndefined = zod_1.z.preprocess((val) => (val === '' ? undefined : val), zod_1.z.string().min(1).optional());
14
+ /**
15
+ * Схема для команды generate
16
+ * Основана на baseFlatOptionsSchema, но с добавлением:
17
+ * - openapiConfig (из baseCLIOptionsSchema)
18
+ * - опциональными input/output (валидируются условно)
19
+ */
20
+ exports.generateOptionsSchema = base_1.baseCLIOptionsSchema
21
+ .merge(configSchemas_1.baseFlatOptionsSchema)
22
+ .extend({
23
+ input: emptyStringToUndefined,
24
+ output: emptyStringToUndefined,
25
+ })
26
+ .superRefine((data, ctx) => {
27
+ // Проверка: если excludeCoreServiceFiles === true, request не должен быть указан
28
+ if (data.excludeCoreServiceFiles === true && data.request) {
29
+ ctx.addIssue({
30
+ code: zod_1.z.ZodIssueCode.custom,
31
+ message: '"--request" can only be used when "excludeCoreServiceFiles" is false',
32
+ path: ['request'],
33
+ });
34
+ }
35
+ // Проверка: input и output обязательны, если конфиг-файл не существует или пуст
36
+ const configPath = data.openapiConfig || Consts_1.DEFAULT_OPENAPI_CONFIG_FILENAME;
37
+ const configData = (0, loadConfigIfExists_1.loadConfigIfExists)(configPath);
38
+ // Если конфиг не существует или пуст, требуем input и output
39
+ const needsInputOutput = !configData || (Array.isArray(configData) && configData.length === 0) || (typeof configData === 'object' && Object.keys(configData).length === 0);
40
+ if (needsInputOutput) {
41
+ if (!data.input || data.input.trim() === '') {
42
+ ctx.addIssue({
43
+ code: zod_1.z.ZodIssueCode.custom,
44
+ message: '"--input" is required when no valid config file is provided',
45
+ path: ['input'],
46
+ });
47
+ }
48
+ if (!data.output || data.output.trim() === '') {
49
+ ctx.addIssue({
50
+ code: zod_1.z.ZodIssueCode.custom,
51
+ message: '"--output" is required when no valid config file is provided',
52
+ path: ['output'],
53
+ });
54
+ }
55
+ }
56
+ });
@@ -0,0 +1,7 @@
1
+ export * from './base';
2
+ export * from './checkConfig';
3
+ export * from './generate';
4
+ export * from './init';
5
+ export * from './updateConfig';
6
+ export type CLIOptions = import('./generate').GenerateOptions | import('./checkConfig').CheckConfigOptions | import('./updateConfig').UpdateConfigOptions | import('./init').InitOptions;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAG/B,MAAM,MAAM,UAAU,GAAG,OAAO,YAAY,EAAE,eAAe,GAAG,OAAO,eAAe,EAAE,kBAAkB,GAAG,OAAO,gBAAgB,EAAE,mBAAmB,GAAG,OAAO,QAAQ,EAAE,WAAW,CAAC"}
@@ -0,0 +1,21 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./base"), exports);
18
+ __exportStar(require("./checkConfig"), exports);
19
+ __exportStar(require("./generate"), exports);
20
+ __exportStar(require("./init"), exports);
21
+ __exportStar(require("./updateConfig"), exports);
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ import { EOptionType } from '../initOpenApiConfig/Enums';
3
+ export declare const initOptionsSchema: z.ZodObject<{
4
+ openapiConfig: z.ZodDefault<z.ZodOptional<z.ZodString>>;
5
+ type: z.ZodDefault<z.ZodOptional<z.ZodEnum<typeof EOptionType>>>;
6
+ }, z.core.$strip>;
7
+ export type InitOptions = z.infer<typeof initOptionsSchema>;
8
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +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;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAGzD,eAAO,MAAM,iBAAiB;;;iBAE5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initOptionsSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const Enums_1 = require("../initOpenApiConfig/Enums");
6
+ const base_1 = require("./base");
7
+ exports.initOptionsSchema = base_1.baseCLIOptionsSchema.extend({
8
+ type: zod_1.z.nativeEnum(Enums_1.EOptionType).optional().default(Enums_1.EOptionType.OPTION),
9
+ });
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+ export declare const updateConfigOptionsSchema: z.ZodObject<{
3
+ openapiConfig: z.ZodDefault<z.ZodOptional<z.ZodString>>;
4
+ }, z.core.$strip>;
5
+ export type UpdateConfigOptions = z.infer<typeof updateConfigOptionsSchema>;
6
+ //# sourceMappingURL=updateConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateConfig.d.ts","sourceRoot":"","sources":["../../../src/cli/schemas/updateConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,yBAAyB;;iBAAuB,CAAC;AAE9D,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateConfigOptionsSchema = void 0;
4
+ const base_1 = require("./base");
5
+ exports.updateConfigOptionsSchema = base_1.baseCLIOptionsSchema;
@@ -0,0 +1,6 @@
1
+ import { ZodError } from 'zod';
2
+ /**
3
+ * Форматирует Zod ошибку в читаемое сообщение для CLI
4
+ */
5
+ export declare function formatZodErrorForCLI(error: ZodError): string;
6
+ //# sourceMappingURL=errorFormatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorFormatter.d.ts","sourceRoot":"","sources":["../../../src/cli/validation/errorFormatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAE/B;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAY5D"}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatZodErrorForCLI = formatZodErrorForCLI;
4
+ /**
5
+ * Форматирует Zod ошибку в читаемое сообщение для CLI
6
+ */
7
+ function formatZodErrorForCLI(error) {
8
+ if (!error || error.issues.length === 0) {
9
+ return 'Validation error occurred';
10
+ }
11
+ const messages = [];
12
+ for (const issue of error.issues) {
13
+ messages.push(formatIssue(issue));
14
+ }
15
+ return messages.join('\n');
16
+ }
17
+ /**
18
+ * Форматирует отдельную Zod issue в читаемое сообщение
19
+ */
20
+ function formatIssue(issue) {
21
+ const path = formatPath(issue.path);
22
+ const message = issue.message;
23
+ // Если issue имеет кастомное сообщение, используем его
24
+ if (issue.code === 'custom') {
25
+ return message;
26
+ }
27
+ // Форматируем стандартные ошибки с использованием type guards
28
+ if (issue.code === 'invalid_type') {
29
+ if ('received' in issue && issue.received === 'undefined') {
30
+ const fieldName = formatPath(issue.path).replace(/^--/, '');
31
+ return `${path}: "${fieldName}" is required`;
32
+ }
33
+ if ('expected' in issue && 'received' in issue) {
34
+ return `${path}: Expected ${issue.expected}, received ${issue.received}`;
35
+ }
36
+ }
37
+ if (issue.code === 'invalid_format' && 'format' in issue) {
38
+ const fieldName = formatPath(issue.path).replace(/^--/, '');
39
+ const format = issue.format;
40
+ if (format === 'email') {
41
+ return `${path}: "${fieldName}" must be a valid email`;
42
+ }
43
+ if (format === 'url') {
44
+ return `${path}: "${fieldName}" must be a valid URL`;
45
+ }
46
+ return `${path}: "${fieldName}" has invalid format: ${format}`;
47
+ }
48
+ if (issue.code === 'too_small' && 'minimum' in issue && 'type' in issue) {
49
+ const fieldName = formatPath(issue.path).replace(/^--/, '');
50
+ const type = issue.type;
51
+ const minimum = issue.minimum;
52
+ if (type === 'string') {
53
+ return `${path}: "${fieldName}" must be at least ${minimum} characters long`;
54
+ }
55
+ if (type === 'number') {
56
+ return `${path}: "${fieldName}" must be at least ${minimum}`;
57
+ }
58
+ if (type === 'array') {
59
+ return `${path}: "${fieldName}" must contain at least ${minimum} items`;
60
+ }
61
+ }
62
+ if (issue.code === 'too_big' && 'maximum' in issue && 'type' in issue) {
63
+ const fieldName = formatPath(issue.path).replace(/^--/, '');
64
+ const type = issue.type;
65
+ const maximum = issue.maximum;
66
+ if (type === 'string') {
67
+ return `${path}: "${fieldName}" must be at most ${maximum} characters long`;
68
+ }
69
+ if (type === 'number') {
70
+ return `${path}: "${fieldName}" must be at most ${maximum}`;
71
+ }
72
+ if (type === 'array') {
73
+ return `${path}: "${fieldName}" must contain at most ${maximum} items`;
74
+ }
75
+ }
76
+ if (issue.code === 'invalid_value') {
77
+ const fieldName = formatPath(issue.path).replace(/^--/, '');
78
+ return `${path}: "${fieldName}" has invalid value`;
79
+ }
80
+ if (issue.code === 'unrecognized_keys' && 'keys' in issue) {
81
+ return `${path}: Unrecognized keys: ${issue.keys.join(', ')}`;
82
+ }
83
+ // Для всех остальных случаев используем стандартное сообщение
84
+ return `${path}: ${message}`;
85
+ }
86
+ /**
87
+ * Форматирует путь к полю в читаемый формат
88
+ */
89
+ function formatPath(path) {
90
+ if (path.length === 0) {
91
+ return 'root';
92
+ }
93
+ // Объединяем путь, используя точки для вложенных полей
94
+ // Например: ['options', 'input'] -> 'options.input'
95
+ // Для CLI опций обычно это будет просто название опции: ['input'] -> '--input'
96
+ const formattedPath = path
97
+ .map(segment => {
98
+ if (typeof segment === 'number') {
99
+ return `[${segment}]`;
100
+ }
101
+ if (typeof segment === 'symbol') {
102
+ return `[Symbol(${segment.description || 'unknown'})]`;
103
+ }
104
+ return String(segment);
105
+ })
106
+ .join('.');
107
+ // Для CLI опций добавляем префикс --
108
+ // Проверяем, является ли это именем опции (не вложенным полем)
109
+ if (path.length === 1 && typeof path[0] === 'string') {
110
+ return `--${formattedPath}`;
111
+ }
112
+ return formattedPath;
113
+ }
@@ -0,0 +1,3 @@
1
+ export * from './errorFormatter';
2
+ export * from './validateCLIOptions';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/validation/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./errorFormatter"), exports);
18
+ __exportStar(require("./validateCLIOptions"), exports);
@@ -0,0 +1,27 @@
1
+ import { ZodError, ZodSchema } from 'zod';
2
+ /**
3
+ * Результат валидации
4
+ */
5
+ export type ValidationResult<T> = {
6
+ success: true;
7
+ data: T;
8
+ } | {
9
+ success: false;
10
+ error: string;
11
+ };
12
+ /**
13
+ * Валидирует данные с помощью Zod схемы и возвращает отформатированный результат
14
+ */
15
+ export declare function validateCLIOptions<T>(schema: ZodSchema<T>, data: unknown): ValidationResult<T>;
16
+ /**
17
+ * Валидирует данные с помощью Zod схемы и возвращает raw результат
18
+ * (полезно когда нужен доступ к ZodError для дополнительной обработки)
19
+ */
20
+ export declare function validateCLIOptionsRaw<T>(schema: ZodSchema<T>, data: unknown): {
21
+ success: true;
22
+ data: T;
23
+ } | {
24
+ success: false;
25
+ error: ZodError;
26
+ };
27
+ //# sourceMappingURL=validateCLIOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateCLIOptions.d.ts","sourceRoot":"","sources":["../../../src/cli/validation/validateCLIOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAI1C;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjG;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAiB9F;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAA;CAAE,CAQ9I"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateCLIOptions = validateCLIOptions;
4
+ exports.validateCLIOptionsRaw = validateCLIOptionsRaw;
5
+ const zod_1 = require("zod");
6
+ const errorFormatter_1 = require("./errorFormatter");
7
+ /**
8
+ * Валидирует данные с помощью Zod схемы и возвращает отформатированный результат
9
+ */
10
+ function validateCLIOptions(schema, data) {
11
+ try {
12
+ const result = schema.parse(data);
13
+ return { success: true, data: result };
14
+ }
15
+ catch (error) {
16
+ if (error instanceof zod_1.ZodError) {
17
+ return {
18
+ success: false,
19
+ error: (0, errorFormatter_1.formatZodErrorForCLI)(error),
20
+ };
21
+ }
22
+ return {
23
+ success: false,
24
+ error: error instanceof Error ? error.message : 'Unknown validation error',
25
+ };
26
+ }
27
+ }
28
+ /**
29
+ * Валидирует данные с помощью Zod схемы и возвращает raw результат
30
+ * (полезно когда нужен доступ к ZodError для дополнительной обработки)
31
+ */
32
+ function validateCLIOptionsRaw(schema, data) {
33
+ const result = schema.safeParse(data);
34
+ if (result.success) {
35
+ return { success: true, data: result.data };
36
+ }
37
+ return { success: false, error: result.error };
38
+ }
@@ -1,41 +1,8 @@
1
- import { HttpClient } from '../core/types/enums/HttpClient.enum';
2
- import { ValidationLibrary } from '../core/types/enums/ValidationLibrary.enum';
3
- import { ELogLevel, ELogOutput } from './Enums';
4
- type TItemConfig = {
5
- input: string;
6
- output: string;
7
- outputCore?: string;
8
- outputServices?: string;
9
- outputModels?: string;
10
- outputSchemas?: string;
11
- request?: string;
12
- };
13
- export type TRawOptions = {
14
- items?: TItemConfig[];
15
- input?: string;
16
- output?: string;
17
- outputCore?: string;
18
- outputServices?: string;
19
- outputModels?: string;
20
- outputSchemas?: string;
21
- httpClient?: HttpClient;
22
- useOptions?: boolean;
23
- useUnionTypes?: boolean;
24
- excludeCoreServiceFiles?: boolean;
25
- request?: string;
26
- interfacePrefix?: string;
27
- enumPrefix?: string;
28
- typePrefix?: string;
29
- useCancelableRequest?: boolean;
30
- logLevel?: ELogLevel;
31
- logTarget?: ELogOutput;
32
- sortByRequired?: boolean;
33
- useSeparatedIndexes?: boolean;
34
- validationLibrary?: ValidationLibrary;
35
- };
36
- export type TFlatOptions = Omit<TRawOptions, 'items'>;
1
+ import { z } from 'zod';
2
+ import { flatOptionsSchema, rawOptionsSchema } from "./schemas/configSchemas";
3
+ export type TRawOptions = z.infer<typeof rawOptionsSchema>;
4
+ export type TFlatOptions = z.infer<typeof flatOptionsSchema>;
37
5
  export type TStrictFlatOptions = {
38
6
  [P in keyof TFlatOptions]-?: NonNullable<TFlatOptions[P]>;
39
7
  };
40
- export {};
41
8
  //# sourceMappingURL=TRawOptions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TRawOptions.d.ts","sourceRoot":"","sources":["../../src/common/TRawOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEhD,KAAK,WAAW,GAAG;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACtB,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;CACxC,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAEtD,MAAM,MAAM,kBAAkB,GAAG;KAC5B,CAAC,IAAI,MAAM,YAAY,CAAC,CAAC,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;CAC5D,CAAC"}
1
+ {"version":3,"file":"TRawOptions.d.ts","sourceRoot":"","sources":["../../src/common/TRawOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE9E,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE3D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE7D,MAAM,MAAM,kBAAkB,GAAG;KAC5B,CAAC,IAAI,MAAM,YAAY,CAAC,CAAC,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;CAC5D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"AllMigrationPlans.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAc/C;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAmB5F,CAAC"}
1
+ {"version":3,"file":"AllMigrationPlans.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAgB/C;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EA4B5F,CAAC"}
@@ -4,7 +4,9 @@ exports.allMigrationPlans = void 0;
4
4
  const ValidationLibrary_enum_1 = require("../../../core/types/enums/ValidationLibrary.enum");
5
5
  const MultiOptionsMigrationPlan_1 = require("../MultiOptionsVersioned/MultiOptionsMigrationPlan");
6
6
  const OptionsMigrationPlans_1 = require("../OptionsVersioned/OptionsMigrationPlans");
7
+ const createFieldTransformationMigration_1 = require("../Utils/createFieldTransformationMigration");
7
8
  const createTrivialMigration_1 = require("../Utils/createTrivialMigration");
9
+ const getLatestVersionFromMigrationPlans_1 = require("../Utils/getLatestVersionFromMigrationPlans");
8
10
  /**
9
11
  * Adds a prefix to all version strings in a migration plan array.
10
12
  */
@@ -23,17 +25,13 @@ function addVersionPrefixToMigrationPlans(plans, prefix) {
23
25
  exports.allMigrationPlans = [
24
26
  // ===== OPTIONS migrations (with prefix) =====
25
27
  ...addVersionPrefixToMigrationPlans(OptionsMigrationPlans_1.optionsMigrationPlans, 'OPTIONS'),
26
- // Migration from OPTIONS v4 to UNIFIED v1
27
- (0, createTrivialMigration_1.createTrivialMigration)('OPTIONS_v4', 'UNIFIED_v1', 'Migrate from OPTIONS to UNIFIED schema'),
28
+ // Migration from OPTIONS latest version to UNIFIED v1
29
+ (0, createTrivialMigration_1.createTrivialMigration)(`OPTIONS_${(0, getLatestVersionFromMigrationPlans_1.getLatestVersionFromMigrationPlans)(OptionsMigrationPlans_1.optionsMigrationPlans)}`, 'UNIFIED_v1', 'Migrate from OPTIONS to UNIFIED schema'),
28
30
  // ===== MULTI_OPTIONS migrations (with prefix) =====
29
31
  ...addVersionPrefixToMigrationPlans(MultiOptionsMigrationPlan_1.multiOptionsMigrationPlan, 'MULTI_OPTIONS'),
30
- // Migration from MULTI_OPTIONS v5 to UNIFIED v1
31
- (0, createTrivialMigration_1.createTrivialMigration)('MULTI_OPTIONS_v5', 'UNIFIED_v1', 'Migrate from MULTI_OPTIONS to UNIFIED schema'),
32
- {
33
- fromVersion: 'UNIFIED_v1',
34
- toVersion: 'UNIFIED_v2',
35
- migrate: ({ includeSchemasFiles, ...otherProps }) => {
36
- return { ...otherProps, validationLibrary: !includeSchemasFiles ? ValidationLibrary_enum_1.ValidationLibrary.NONE : undefined };
37
- },
38
- },
32
+ // Migration from MULTI_OPTIONS latest version to UNIFIED v1
33
+ (0, createTrivialMigration_1.createTrivialMigration)(`MULTI_OPTIONS_${(0, getLatestVersionFromMigrationPlans_1.getLatestVersionFromMigrationPlans)(MultiOptionsMigrationPlan_1.multiOptionsMigrationPlan)}`, 'UNIFIED_v1', 'Migrate from MULTI_OPTIONS to UNIFIED schema'),
34
+ (0, createFieldTransformationMigration_1.createFieldTransformationMigration)('UNIFIED_v1', 'UNIFIED_v2', ({ includeSchemasFiles, ...otherProps }) => {
35
+ return { ...otherProps, validationLibrary: !includeSchemasFiles ? ValidationLibrary_enum_1.ValidationLibrary.NONE : undefined };
36
+ }, 'Transforms includeSchemasFiles to validationLibrary: if includeSchemasFiles is false, sets validationLibrary to NONE'),
39
37
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"MultiOptionsMigrationPlan.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EA0BpG,CAAC"}
1
+ {"version":3,"file":"MultiOptionsMigrationPlan.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAI/C;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EA4BpG,CAAC"}
@@ -2,29 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.multiOptionsMigrationPlan = void 0;
4
4
  const createDefaultFieldsMigration_1 = require("../Utils/createDefaultFieldsMigration");
5
+ const createFieldTransformationMigration_1 = require("../Utils/createFieldTransformationMigration");
5
6
  /**
6
7
  * Migration plan for multi options models.
7
8
  */
8
9
  exports.multiOptionsMigrationPlan = [
9
- {
10
- fromVersion: 'v1',
11
- toVersion: 'v2',
12
- migrate: ({ client, ...otherProps }) => ({
13
- ...otherProps,
14
- httpClient: client,
15
- }),
16
- },
10
+ (0, createFieldTransformationMigration_1.createFieldTransformationMigration)('v1', 'v2', ({ client, ...otherProps }) => ({
11
+ ...otherProps,
12
+ httpClient: client,
13
+ }), 'Renames client field to httpClient'),
17
14
  (0, createDefaultFieldsMigration_1.createDefaultFieldsMigration)('v2', 'v3', {
18
15
  useCancelableRequest: false,
19
16
  }),
20
- {
21
- fromVersion: 'v3',
22
- toVersion: 'v4',
23
- migrate: ({ items, input, output, outputCore, outputServices, outputModels, outputSchemas, ...otherProps }) => ({
24
- ...otherProps,
25
- items: items.map((el) => ({ ...el, input, output, outputCore, outputServices, outputModels, outputSchemas })),
26
- }),
27
- },
17
+ (0, createFieldTransformationMigration_1.createFieldTransformationMigration)('v3', 'v4', ({ items, input, output, outputCore, outputServices, outputModels, outputSchemas, ...otherProps }) => ({
18
+ ...otherProps,
19
+ items: items.map((el) => ({ ...el, input, output, outputCore, outputServices, outputModels, outputSchemas })),
20
+ }), 'Moves input, output, and output paths from root level into each item in the items array'),
28
21
  (0, createDefaultFieldsMigration_1.createDefaultFieldsMigration)('v4', 'v5', {
29
22
  excludeCoreServiceFiles: false,
30
23
  includeSchemasFiles: false,
@@ -1 +1 @@
1
- {"version":3,"file":"OptionsMigrationPlans.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAehG,CAAC"}
1
+ {"version":3,"file":"OptionsMigrationPlans.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAI/C;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAgBhG,CAAC"}
@@ -2,15 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.optionsMigrationPlans = void 0;
4
4
  const createDefaultFieldsMigration_1 = require("../Utils/createDefaultFieldsMigration");
5
+ const createFieldTransformationMigration_1 = require("../Utils/createFieldTransformationMigration");
5
6
  /**
6
7
  * Migration plan for option models.
7
8
  */
8
9
  exports.optionsMigrationPlans = [
9
- {
10
- fromVersion: 'v1',
11
- toVersion: 'v2',
12
- migrate: ({ client, ...otherProps }) => ({ ...otherProps, httpClient: client }),
13
- },
10
+ (0, createFieldTransformationMigration_1.createFieldTransformationMigration)('v1', 'v2', ({ client, ...otherProps }) => ({ ...otherProps, httpClient: client }), 'Renames client field to httpClient'),
14
11
  (0, createDefaultFieldsMigration_1.createDefaultFieldsMigration)('v2', 'v3', {
15
12
  useCancelableRequest: false,
16
13
  }),
@@ -0,0 +1,32 @@
1
+ import { SchemaMigrationPlan } from '../Types';
2
+ /**
3
+ * Creates a migration plan that transforms fields using a custom migration function.
4
+ * Use this for migrations that require field renaming, restructuring, or complex transformations
5
+ * that cannot be handled by createDefaultFieldsMigration or createTrivialMigration.
6
+ *
7
+ * @param fromVersion - Source version
8
+ * @param toVersion - Target version
9
+ * @param migrate - Custom migration function that transforms the data
10
+ * @param description - Optional description of what this migration does
11
+ * @returns A migration plan with the custom transformation
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * // Rename field: client -> httpClient
16
+ * createFieldTransformationMigration('v1', 'v2',
17
+ * ({ client, ...otherProps }) => ({ ...otherProps, httpClient: client }),
18
+ * 'Renames client field to httpClient'
19
+ * )
20
+ *
21
+ * // Transform items array
22
+ * createFieldTransformationMigration('v3', 'v4',
23
+ * ({ items, input, output, ...otherProps }) => ({
24
+ * ...otherProps,
25
+ * items: items.map(el => ({ ...el, input, output }))
26
+ * }),
27
+ * 'Moves input/output fields into each item'
28
+ * )
29
+ * ```
30
+ */
31
+ export declare function createFieldTransformationMigration<From extends Record<string, any>, To extends Record<string, any>>(fromVersion: string, toVersion: string, migrate: (input: From) => To, description?: string): SchemaMigrationPlan<From, To>;
32
+ //# sourceMappingURL=createFieldTransformationMigration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFieldTransformationMigration.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/createFieldTransformationMigration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,kCAAkC,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC/G,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,EAAE,EAC5B,WAAW,CAAC,EAAE,MAAM,GACrB,mBAAmB,CAAC,IAAI,EAAE,EAAE,CAAC,CAO/B"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createFieldTransformationMigration = createFieldTransformationMigration;
4
+ /**
5
+ * Creates a migration plan that transforms fields using a custom migration function.
6
+ * Use this for migrations that require field renaming, restructuring, or complex transformations
7
+ * that cannot be handled by createDefaultFieldsMigration or createTrivialMigration.
8
+ *
9
+ * @param fromVersion - Source version
10
+ * @param toVersion - Target version
11
+ * @param migrate - Custom migration function that transforms the data
12
+ * @param description - Optional description of what this migration does
13
+ * @returns A migration plan with the custom transformation
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * // Rename field: client -> httpClient
18
+ * createFieldTransformationMigration('v1', 'v2',
19
+ * ({ client, ...otherProps }) => ({ ...otherProps, httpClient: client }),
20
+ * 'Renames client field to httpClient'
21
+ * )
22
+ *
23
+ * // Transform items array
24
+ * createFieldTransformationMigration('v3', 'v4',
25
+ * ({ items, input, output, ...otherProps }) => ({
26
+ * ...otherProps,
27
+ * items: items.map(el => ({ ...el, input, output }))
28
+ * }),
29
+ * 'Moves input/output fields into each item'
30
+ * )
31
+ * ```
32
+ */
33
+ function createFieldTransformationMigration(fromVersion, toVersion, migrate, description) {
34
+ return {
35
+ fromVersion,
36
+ toVersion,
37
+ migrate,
38
+ description: description || `Custom field transformation migration from ${fromVersion} to ${toVersion}`,
39
+ };
40
+ }
@@ -0,0 +1,16 @@
1
+ import { SchemaMigrationPlan } from '../Types';
2
+ /**
3
+ * Gets the latest version from a migration plans array.
4
+ * Returns the `toVersion` of the last migration plan in the array.
5
+ *
6
+ * @param migrationPlans - Array of migration plans
7
+ * @returns The latest version string (e.g., 'v4')
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const latestVersion = getLatestVersionFromMigrationPlans(optionsMigrationPlans);
12
+ * // Returns 'v4'
13
+ * ```
14
+ */
15
+ export declare function getLatestVersionFromMigrationPlans(migrationPlans: SchemaMigrationPlan<Record<string, any>, Record<string, any>>[]): string;
16
+ //# sourceMappingURL=getLatestVersionFromMigrationPlans.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getLatestVersionFromMigrationPlans.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/getLatestVersionFromMigrationPlans.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;;;;;;;;GAYG;AACH,wBAAgB,kCAAkC,CAC9C,cAAc,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,GAChF,MAAM,CAOR"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLatestVersionFromMigrationPlans = getLatestVersionFromMigrationPlans;
4
+ /**
5
+ * Gets the latest version from a migration plans array.
6
+ * Returns the `toVersion` of the last migration plan in the array.
7
+ *
8
+ * @param migrationPlans - Array of migration plans
9
+ * @returns The latest version string (e.g., 'v4')
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const latestVersion = getLatestVersionFromMigrationPlans(optionsMigrationPlans);
14
+ * // Returns 'v4'
15
+ * ```
16
+ */
17
+ function getLatestVersionFromMigrationPlans(migrationPlans) {
18
+ if (migrationPlans.length === 0) {
19
+ throw new Error('Migration plans array is empty. Cannot determine latest version.');
20
+ }
21
+ const lastPlan = migrationPlans[migrationPlans.length - 1];
22
+ return lastPlan.toVersion;
23
+ }
@@ -0,0 +1,91 @@
1
+ import { z } from 'zod';
2
+ import { ValidationLibrary } from '../../core/types/enums/ValidationLibrary.enum';
3
+ /**
4
+ * Базовая схема опций без обязательных input/output
5
+ * Используется как основа для CLI команд и конфиг-файлов
6
+ */
7
+ export declare const baseFlatOptionsSchema: z.ZodObject<{
8
+ outputCore: z.ZodOptional<z.ZodString>;
9
+ outputServices: z.ZodOptional<z.ZodString>;
10
+ outputModels: z.ZodOptional<z.ZodString>;
11
+ outputSchemas: z.ZodOptional<z.ZodString>;
12
+ interfacePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
13
+ enumPrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
14
+ typePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
15
+ httpClient: z.ZodOptional<z.ZodEnum<typeof import("../..").HttpClient>>;
16
+ useOptions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
17
+ useUnionTypes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
18
+ excludeCoreServiceFiles: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
19
+ request: z.ZodOptional<z.ZodString>;
20
+ useCancelableRequest: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
21
+ logLevel: z.ZodOptional<z.ZodEnum<typeof import("../Enums").ELogLevel>>;
22
+ logTarget: z.ZodOptional<z.ZodEnum<typeof import("../Enums").ELogOutput>>;
23
+ sortByRequired: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
24
+ useSeparatedIndexes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
25
+ validationLibrary: z.ZodOptional<z.ZodEnum<typeof ValidationLibrary>>;
26
+ }, z.core.$strip>;
27
+ /**
28
+ * Полная схема для конфиг-файла (TRawOptions)
29
+ * Поддерживает два формата:
30
+ * 1. С массивом items (multi-options)
31
+ * 2. С input/output в корне (single-options)
32
+ */
33
+ export declare const rawOptionsSchema: z.ZodObject<{
34
+ items: z.ZodOptional<z.ZodArray<z.ZodObject<{
35
+ input: z.ZodString;
36
+ output: z.ZodString;
37
+ outputCore: z.ZodOptional<z.ZodString>;
38
+ outputServices: z.ZodOptional<z.ZodString>;
39
+ outputModels: z.ZodOptional<z.ZodString>;
40
+ outputSchemas: z.ZodOptional<z.ZodString>;
41
+ request: z.ZodOptional<z.ZodString>;
42
+ httpClient: z.ZodOptional<z.ZodEnum<typeof import("../..").HttpClient>>;
43
+ }, z.core.$strip>>>;
44
+ input: z.ZodOptional<z.ZodString>;
45
+ output: z.ZodOptional<z.ZodString>;
46
+ outputCore: z.ZodOptional<z.ZodString>;
47
+ outputServices: z.ZodOptional<z.ZodString>;
48
+ outputModels: z.ZodOptional<z.ZodString>;
49
+ outputSchemas: z.ZodOptional<z.ZodString>;
50
+ interfacePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
51
+ enumPrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
52
+ typePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
53
+ httpClient: z.ZodOptional<z.ZodEnum<typeof import("../..").HttpClient>>;
54
+ useOptions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
55
+ useUnionTypes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
56
+ excludeCoreServiceFiles: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
57
+ request: z.ZodOptional<z.ZodString>;
58
+ useCancelableRequest: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
59
+ logLevel: z.ZodOptional<z.ZodEnum<typeof import("../Enums").ELogLevel>>;
60
+ logTarget: z.ZodOptional<z.ZodEnum<typeof import("../Enums").ELogOutput>>;
61
+ sortByRequired: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
62
+ useSeparatedIndexes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
63
+ validationLibrary: z.ZodOptional<z.ZodEnum<typeof ValidationLibrary>>;
64
+ }, z.core.$strip>;
65
+ /**
66
+ * Схема для плоских опций (без items) - TFlatOptions
67
+ * Используется для конфиг-файлов с одной спецификацией
68
+ */
69
+ export declare const flatOptionsSchema: z.ZodObject<{
70
+ outputCore: z.ZodOptional<z.ZodString>;
71
+ outputServices: z.ZodOptional<z.ZodString>;
72
+ outputModels: z.ZodOptional<z.ZodString>;
73
+ outputSchemas: z.ZodOptional<z.ZodString>;
74
+ interfacePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
75
+ enumPrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
76
+ typePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
77
+ httpClient: z.ZodOptional<z.ZodEnum<typeof import("../..").HttpClient>>;
78
+ useOptions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
79
+ useUnionTypes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
80
+ excludeCoreServiceFiles: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
81
+ request: z.ZodOptional<z.ZodString>;
82
+ useCancelableRequest: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
83
+ logLevel: z.ZodOptional<z.ZodEnum<typeof import("../Enums").ELogLevel>>;
84
+ logTarget: z.ZodOptional<z.ZodEnum<typeof import("../Enums").ELogOutput>>;
85
+ sortByRequired: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
86
+ useSeparatedIndexes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
87
+ validationLibrary: z.ZodOptional<z.ZodEnum<typeof ValidationLibrary>>;
88
+ input: z.ZodString;
89
+ output: z.ZodString;
90
+ }, z.core.$strip>;
91
+ //# sourceMappingURL=configSchemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configSchemas.d.ts","sourceRoot":"","sources":["../../../src/common/schemas/configSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAqDlF;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;iBAAqE,CAAC;AAExG;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqDvB,CAAC;AAEP;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;iBAcxB,CAAC"}
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.flatOptionsSchema = exports.rawOptionsSchema = exports.baseFlatOptionsSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const base_1 = require("../../cli/schemas/base");
6
+ const ValidationLibrary_enum_1 = require("../../core/types/enums/ValidationLibrary.enum");
7
+ /**
8
+ * Схема для отдельного элемента конфигурации (используется в массиве items)
9
+ */
10
+ const itemConfigSchema = zod_1.z.object({
11
+ input: zod_1.z.string().min(1, 'Input is required'),
12
+ output: zod_1.z.string().min(1, 'Output is required'),
13
+ outputCore: zod_1.z.string().min(1).optional(),
14
+ outputServices: zod_1.z.string().min(1).optional(),
15
+ outputModels: zod_1.z.string().min(1).optional(),
16
+ outputSchemas: zod_1.z.string().min(1).optional(),
17
+ request: zod_1.z.string().min(1).optional(),
18
+ httpClient: base_1.httpClientSchema.optional(),
19
+ });
20
+ /**
21
+ * Схема для output директорий (используется как в items, так и в корне)
22
+ */
23
+ const outputPathsSchema = zod_1.z.object({
24
+ outputCore: zod_1.z.string().min(1).optional(),
25
+ outputServices: zod_1.z.string().min(1).optional(),
26
+ outputModels: zod_1.z.string().min(1).optional(),
27
+ outputSchemas: zod_1.z.string().min(1).optional(),
28
+ });
29
+ /**
30
+ * Схема для префиксов
31
+ */
32
+ const prefixesSchema = zod_1.z.object({
33
+ interfacePrefix: zod_1.z.string().min(1).optional().default('I'),
34
+ enumPrefix: zod_1.z.string().min(1).optional().default('E'),
35
+ typePrefix: zod_1.z.string().min(1).optional().default('T'),
36
+ });
37
+ /**
38
+ * Базовая схема для общих опций (без items/input/output)
39
+ */
40
+ const commonOptionsSchema = zod_1.z.object({
41
+ httpClient: base_1.httpClientSchema.optional(),
42
+ useOptions: zod_1.z.boolean().optional().default(false),
43
+ useUnionTypes: zod_1.z.boolean().optional().default(false),
44
+ excludeCoreServiceFiles: zod_1.z.boolean().optional().default(false),
45
+ request: zod_1.z.string().min(1).optional(),
46
+ useCancelableRequest: zod_1.z.boolean().optional().default(false),
47
+ logLevel: base_1.logLevelSchema.optional(),
48
+ logTarget: base_1.logTargetSchema.optional(),
49
+ sortByRequired: zod_1.z.boolean().optional().default(false),
50
+ useSeparatedIndexes: zod_1.z.boolean().optional().default(false),
51
+ validationLibrary: zod_1.z.nativeEnum(ValidationLibrary_enum_1.ValidationLibrary).optional()
52
+ });
53
+ /**
54
+ * Базовая схема опций без обязательных input/output
55
+ * Используется как основа для CLI команд и конфиг-файлов
56
+ */
57
+ exports.baseFlatOptionsSchema = outputPathsSchema.merge(prefixesSchema).merge(commonOptionsSchema);
58
+ /**
59
+ * Полная схема для конфиг-файла (TRawOptions)
60
+ * Поддерживает два формата:
61
+ * 1. С массивом items (multi-options)
62
+ * 2. С input/output в корне (single-options)
63
+ */
64
+ exports.rawOptionsSchema = zod_1.z
65
+ .object({
66
+ // Multi-item configuration
67
+ items: zod_1.z.array(itemConfigSchema).min(1, 'Items array must contain at least one item').optional(),
68
+ // Single-item configuration (взаимоисключающие с items)
69
+ input: zod_1.z.string().min(1).optional(),
70
+ output: zod_1.z.string().min(1).optional(),
71
+ })
72
+ .merge(exports.baseFlatOptionsSchema)
73
+ .superRefine((data, ctx) => {
74
+ // Проверка: либо items, либо input+output должны быть указаны
75
+ const hasItems = data.items && data.items.length > 0;
76
+ const hasInputOutput = !!(data.input && data.output);
77
+ if (!hasItems && !hasInputOutput) {
78
+ ctx.addIssue({
79
+ code: zod_1.z.ZodIssueCode.custom,
80
+ message: 'Either "items" array or "input" + "output" must be provided',
81
+ path: [],
82
+ });
83
+ }
84
+ // Если есть items, то input и output в корне не должны быть указаны
85
+ if (hasItems && hasInputOutput) {
86
+ ctx.addIssue({
87
+ code: zod_1.z.ZodIssueCode.custom,
88
+ message: 'Cannot use both "items" array and "input"/"output" at the root level',
89
+ path: ['items'],
90
+ });
91
+ }
92
+ // Валидация: если excludeCoreServiceFiles === true, request не должен быть указан
93
+ if (data.excludeCoreServiceFiles === true && data.request) {
94
+ ctx.addIssue({
95
+ code: zod_1.z.ZodIssueCode.custom,
96
+ message: '"request" can only be used when "excludeCoreServiceFiles" is false',
97
+ path: ['request'],
98
+ });
99
+ }
100
+ // Валидация для каждого элемента в items
101
+ if (hasItems && data.items) {
102
+ data.items.forEach((item, index) => {
103
+ if (item.request && data.excludeCoreServiceFiles === true) {
104
+ ctx.addIssue({
105
+ code: zod_1.z.ZodIssueCode.custom,
106
+ message: '"request" in items can only be used when "excludeCoreServiceFiles" is false',
107
+ path: ['items', index, 'request'],
108
+ });
109
+ }
110
+ });
111
+ }
112
+ });
113
+ /**
114
+ * Схема для плоских опций (без items) - TFlatOptions
115
+ * Используется для конфиг-файлов с одной спецификацией
116
+ */
117
+ exports.flatOptionsSchema = exports.baseFlatOptionsSchema
118
+ .extend({
119
+ input: zod_1.z.string().min(1, 'Input is required'),
120
+ output: zod_1.z.string().min(1, 'Output is required'),
121
+ })
122
+ .superRefine((data, ctx) => {
123
+ // Валидация: если excludeCoreServiceFiles === true, request не должен быть указан
124
+ if (data.excludeCoreServiceFiles === true && data.request) {
125
+ ctx.addIssue({
126
+ code: zod_1.z.ZodIssueCode.custom,
127
+ message: '"request" can only be used when "excludeCoreServiceFiles" is false',
128
+ path: ['request'],
129
+ });
130
+ }
131
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"OpenApiClient.d.ts","sourceRoot":"","sources":["../../src/core/OpenApiClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,WAAW,EAAsB,MAAM,uBAAuB,CAAC;AAetF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,qBAAa,aAAa;IACtB,OAAO,CAAC,YAAY,CAA4B;IAEhD,IAAW,WAAW,gBAKrB;IAED,OAAO,CAAC,gBAAgB;IAaxB,OAAO,CAAC,gBAAgB;YAyBV,sBAAsB;YAUtB,oBAAoB;YAmCpB,cAAc;IAkFtB,QAAQ,CAAC,UAAU,EAAE,WAAW;CAWzC"}
1
+ {"version":3,"file":"OpenApiClient.d.ts","sourceRoot":"","sources":["../../src/core/OpenApiClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,WAAW,EAAsB,MAAM,uBAAuB,CAAC;AAetF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,qBAAa,aAAa;IACtB,OAAO,CAAC,YAAY,CAA4B;IAEhD,IAAW,WAAW,gBAKrB;IAED,OAAO,CAAC,gBAAgB;IAgDxB,OAAO,CAAC,gBAAgB;YAyBV,sBAAsB;YAUtB,oBAAoB;YAmCpB,cAAc;IAkFtB,QAAQ,CAAC,UAAU,EAAE,WAAW;CAWzC"}
@@ -30,11 +30,46 @@ class OpenApiClient {
30
30
  return rawOptions.items.map(item => ({
31
31
  ...item,
32
32
  request: item.request ?? rawOptions.request, // ?? для fallback на глобальный
33
+ useOptions: rawOptions.useOptions,
34
+ useUnionTypes: rawOptions.useUnionTypes,
35
+ excludeCoreServiceFiles: rawOptions.excludeCoreServiceFiles,
36
+ interfacePrefix: rawOptions.interfacePrefix,
37
+ enumPrefix: rawOptions.enumPrefix,
38
+ typePrefix: rawOptions.typePrefix,
39
+ useCancelableRequest: rawOptions.useCancelableRequest,
40
+ logLevel: rawOptions.logLevel,
41
+ logTarget: rawOptions.logTarget,
42
+ sortByRequired: rawOptions.sortByRequired,
43
+ useSeparatedIndexes: rawOptions.useSeparatedIndexes,
44
+ validationLibrary: rawOptions.validationLibrary,
33
45
  }));
34
46
  }
35
47
  else {
36
48
  // Плоский формат (из CLI или старого конфига): Один item с глобальным request
37
- return [rawOptions];
49
+ return [
50
+ {
51
+ input: rawOptions.input ?? '',
52
+ output: rawOptions.output ?? '',
53
+ outputCore: rawOptions.outputCore,
54
+ outputServices: rawOptions.outputServices,
55
+ outputModels: rawOptions.outputModels,
56
+ outputSchemas: rawOptions.outputSchemas,
57
+ httpClient: rawOptions.httpClient,
58
+ useOptions: rawOptions.useOptions,
59
+ useUnionTypes: rawOptions.useUnionTypes,
60
+ excludeCoreServiceFiles: rawOptions.excludeCoreServiceFiles,
61
+ request: rawOptions.request,
62
+ interfacePrefix: rawOptions.interfacePrefix,
63
+ enumPrefix: rawOptions.enumPrefix,
64
+ typePrefix: rawOptions.typePrefix,
65
+ useCancelableRequest: rawOptions.useCancelableRequest,
66
+ logLevel: rawOptions.logLevel,
67
+ logTarget: rawOptions.logTarget,
68
+ sortByRequired: rawOptions.sortByRequired,
69
+ useSeparatedIndexes: rawOptions.useSeparatedIndexes,
70
+ validationLibrary: rawOptions.validationLibrary,
71
+ },
72
+ ];
38
73
  }
39
74
  }
40
75
  addDefaultValues(item) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-openapi-codegen",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.3",
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",
@@ -78,7 +78,8 @@
78
78
  "leven": "^4.0.0",
79
79
  "semver": "^7.7.1",
80
80
  "winston": "^3.17.0",
81
- "winston-daily-rotate-file": "^5.0.0"
81
+ "winston-daily-rotate-file": "^5.0.0",
82
+ "zod": "^4.3.5"
82
83
  },
83
84
  "devDependencies": {
84
85
  "@babel/cli": "7.14.8",