ts-openapi-codegen 2.1.0-beta.4 → 2.1.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -957
- package/README.rus.md +11 -957
- package/dist/cli/checkAndUpdateConfig/__tests__/checkConfig.test.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/__tests__/checkConfig.test.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/__tests__/checkConfig.test.js +63 -0
- package/dist/cli/checkAndUpdateConfig/__tests__/updateConfig.test.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/__tests__/updateConfig.test.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/__tests__/updateConfig.test.js +62 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/prepareConfigData.test.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/prepareConfigData.test.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/prepareConfigData.test.js +20 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/removeDefaultConfigValues.test.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/removeDefaultConfigValues.test.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/removeDefaultConfigValues.test.js +35 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/validateAndMigrateConfigData.test.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/validateAndMigrateConfigData.test.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/validateAndMigrateConfigData.test.js +59 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/initOpenApiConfig/__tests__/init.test.d.ts +2 -0
- package/dist/cli/initOpenApiConfig/__tests__/init.test.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/__tests__/init.test.js +30 -0
- package/dist/cli/initOpenApiConfig/__tests__/initConfig.test.d.ts +2 -0
- package/dist/cli/initOpenApiConfig/__tests__/initConfig.test.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/__tests__/initConfig.test.js +47 -0
- package/dist/cli/initOpenApiConfig/init.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/init.js +2 -0
- package/dist/cli/initOpenApiConfig/initCustomRequest.d.ts +1 -0
- package/dist/cli/initOpenApiConfig/initCustomRequest.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/initCustomRequest.js +2 -1
- package/dist/cli/initOpenApiConfig/utils/__tests__/buildConfig.test.d.ts +2 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/buildConfig.test.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/buildConfig.test.js +99 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/findSpecFiles.test.d.ts +2 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/findSpecFiles.test.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/findSpecFiles.test.js +45 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/validateSpecFiles.test.d.ts +2 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/validateSpecFiles.test.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/validateSpecFiles.test.js +52 -0
- package/dist/cli/initOpenApiConfig/utils/buildConfig.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/utils/buildConfig.js +4 -0
- package/dist/cli/previewChanges/utils/__tests__/compareFiles.test.d.ts +2 -0
- package/dist/cli/previewChanges/utils/__tests__/compareFiles.test.d.ts.map +1 -0
- package/dist/cli/previewChanges/utils/__tests__/compareFiles.test.js +52 -0
- package/dist/cli/previewChanges/utils/__tests__/isDirectoryEmpty.test.d.ts +2 -0
- package/dist/cli/previewChanges/utils/__tests__/isDirectoryEmpty.test.d.ts.map +1 -0
- package/dist/cli/previewChanges/utils/__tests__/isDirectoryEmpty.test.js +43 -0
- package/dist/cli/previewChanges/utils/__tests__/readDirectoryRecursive.test.d.ts +2 -0
- package/dist/cli/previewChanges/utils/__tests__/readDirectoryRecursive.test.d.ts.map +1 -0
- package/dist/cli/previewChanges/utils/__tests__/readDirectoryRecursive.test.js +32 -0
- package/dist/cli/previewChanges/utils/__tests__/updateOutputPaths.test.d.ts +2 -0
- package/dist/cli/previewChanges/utils/__tests__/updateOutputPaths.test.d.ts.map +1 -0
- package/dist/cli/previewChanges/utils/__tests__/updateOutputPaths.test.js +68 -0
- package/dist/cli/schemas/__tests__/checkConfigAndUpdate.test.d.ts +2 -0
- package/dist/cli/schemas/__tests__/checkConfigAndUpdate.test.d.ts.map +1 -0
- package/dist/cli/schemas/__tests__/checkConfigAndUpdate.test.js +36 -0
- package/dist/cli/schemas/__tests__/generateOptionsSchema.test.d.ts +2 -0
- package/dist/cli/schemas/__tests__/generateOptionsSchema.test.d.ts.map +1 -0
- package/dist/cli/schemas/__tests__/generateOptionsSchema.test.js +59 -0
- package/dist/cli/schemas/__tests__/initOptionsSchema.test.d.ts +2 -0
- package/dist/cli/schemas/__tests__/initOptionsSchema.test.d.ts.map +1 -0
- package/dist/cli/schemas/__tests__/initOptionsSchema.test.js +43 -0
- package/dist/cli/schemas/__tests__/previewChangesSchema.test.d.ts +2 -0
- package/dist/cli/schemas/__tests__/previewChangesSchema.test.d.ts.map +1 -0
- package/dist/cli/schemas/__tests__/previewChangesSchema.test.js +31 -0
- package/dist/cli/schemas/init.d.ts +1 -0
- package/dist/cli/schemas/init.d.ts.map +1 -1
- package/dist/cli/schemas/init.js +1 -0
- package/dist/common/Consts.d.ts.map +1 -1
- package/dist/common/Consts.js +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.d.ts +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts +2 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts +2 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts +2 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts +2 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.d.ts +2 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts +11 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/CommonSchemas.d.ts +2 -0
- package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/CommonSchemas.js +1 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan.js +1 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts +1 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts +1 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts +1 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.js +1 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts +1 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts +1 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.js +8 -2
- package/dist/common/utils/__tests__/convertArrayToObject.test.js +3 -0
- package/dist/common/utils/convertArrayToObject.d.ts.map +1 -1
- package/dist/common/utils/convertArrayToObject.js +2 -0
- package/dist/core/OpenApiClient.d.ts.map +1 -1
- package/dist/core/OpenApiClient.js +6 -1
- package/dist/core/WriteClient.d.ts +3 -1
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +3 -2
- package/dist/core/utils/GenerationCache.d.ts +18 -0
- package/dist/core/utils/GenerationCache.d.ts.map +1 -0
- package/dist/core/utils/GenerationCache.js +41 -0
- package/dist/core/utils/__tests__/GenerationCache.test.d.ts +2 -0
- package/dist/core/utils/__tests__/GenerationCache.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/GenerationCache.test.js +37 -0
- package/dist/core/utils/__tests__/loadDiffReport.test.d.ts +2 -0
- package/dist/core/utils/__tests__/loadDiffReport.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/loadDiffReport.test.js +97 -0
- package/dist/core/utils/__tests__/templateRendering.test.d.ts +2 -0
- package/dist/core/utils/__tests__/templateRendering.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/templateRendering.test.js +119 -0
- package/dist/core/utils/__tests__/writeClientServices.test.js +1 -0
- package/dist/core/utils/__tests__/writeFileIfChanged.test.d.ts +2 -0
- package/dist/core/utils/__tests__/writeFileIfChanged.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/writeFileIfChanged.test.js +30 -0
- package/dist/core/utils/writeClientCore.d.ts +2 -0
- package/dist/core/utils/writeClientCore.d.ts.map +1 -1
- package/dist/core/utils/writeClientCore.js +5 -4
- package/dist/core/utils/writeClientServices.d.ts +2 -0
- package/dist/core/utils/writeClientServices.d.ts.map +1 -1
- package/dist/core/utils/writeClientServices.js +2 -1
- package/dist/core/utils/writeFileIfChanged.d.ts +3 -0
- package/dist/core/utils/writeFileIfChanged.d.ts.map +1 -0
- package/dist/core/utils/writeFileIfChanged.js +22 -0
- package/dist/templatesCompiled/cli/customRequest.d.ts +6 -2
- package/dist/templatesCompiled/cli/customRequest.d.ts.map +1 -1
- package/dist/templatesCompiled/cli/customRequest.js +28 -8
- package/dist/templatesCompiled/cli/customRequestExecutor.d.ts +3 -0
- package/dist/templatesCompiled/cli/customRequestExecutor.d.ts.map +1 -1
- package/dist/templatesCompiled/cli/customRequestExecutor.js +28 -5
- package/dist/templatesCompiled/client/core/axios/request.d.ts +6 -2
- package/dist/templatesCompiled/client/core/axios/request.d.ts.map +1 -1
- package/dist/templatesCompiled/client/core/axios/request.js +22 -2
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.d.ts +5 -2
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.d.ts.map +1 -1
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.js +42 -12
- package/dist/templatesCompiled/client/core/executor/requestExecutor.d.ts +2 -0
- package/dist/templatesCompiled/client/core/executor/requestExecutor.d.ts.map +1 -1
- package/dist/templatesCompiled/client/core/executor/requestExecutor.js +11 -3
- package/dist/templatesCompiled/client/core/fetch/request.d.ts +6 -2
- package/dist/templatesCompiled/client/core/fetch/request.d.ts.map +1 -1
- package/dist/templatesCompiled/client/core/fetch/request.js +22 -2
- package/dist/templatesCompiled/client/core/interceptors/withInterceptors.d.ts +2 -0
- package/dist/templatesCompiled/client/core/interceptors/withInterceptors.d.ts.map +1 -1
- package/dist/templatesCompiled/client/core/interceptors/withInterceptors.js +11 -3
- package/dist/templatesCompiled/client/core/node/request.d.ts +6 -2
- package/dist/templatesCompiled/client/core/node/request.d.ts.map +1 -1
- package/dist/templatesCompiled/client/core/node/request.js +22 -2
- package/dist/templatesCompiled/client/core/xhr/request.d.ts +6 -2
- package/dist/templatesCompiled/client/core/xhr/request.d.ts.map +1 -1
- package/dist/templatesCompiled/client/core/xhr/request.js +22 -2
- package/dist/templatesCompiled/client/exportService.d.ts +11 -9
- package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportService.js +82 -64
- package/package.json +1 -2
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const node_test_1 = require("node:test");
|
|
10
|
+
const validateSpecFile_1 = require("../validateSpecFile");
|
|
11
|
+
const validateSpecFiles_1 = require("../validateSpecFiles");
|
|
12
|
+
const minimalOpenApi = {
|
|
13
|
+
openapi: '3.0.3',
|
|
14
|
+
info: { title: 'Test API', version: '1.0.0' },
|
|
15
|
+
paths: {},
|
|
16
|
+
};
|
|
17
|
+
const createSpecFile = (t, content) => {
|
|
18
|
+
const root = node_path_1.default.join(__dirname, 'generated');
|
|
19
|
+
node_fs_1.default.mkdirSync(root, { recursive: true });
|
|
20
|
+
const dir = node_fs_1.default.mkdtempSync(node_path_1.default.join(root, 'spec-'));
|
|
21
|
+
const filePath = node_path_1.default.join(dir, 'spec.json');
|
|
22
|
+
node_fs_1.default.writeFileSync(filePath, JSON.stringify(content), 'utf-8');
|
|
23
|
+
t.after(() => {
|
|
24
|
+
node_fs_1.default.rmSync(dir, { recursive: true, force: true });
|
|
25
|
+
});
|
|
26
|
+
return filePath;
|
|
27
|
+
};
|
|
28
|
+
(0, node_test_1.describe)('@unit: validateSpecFiles', () => {
|
|
29
|
+
(0, node_test_1.test)('validateSpecFile returns true for valid OpenAPI spec', async (t) => {
|
|
30
|
+
const specPath = createSpecFile(t, minimalOpenApi);
|
|
31
|
+
const isValid = await (0, validateSpecFile_1.validateSpecFile)(specPath);
|
|
32
|
+
node_assert_1.default.strictEqual(isValid, true);
|
|
33
|
+
});
|
|
34
|
+
(0, node_test_1.test)('validateSpecFile returns false for invalid file', async (t) => {
|
|
35
|
+
const specPath = createSpecFile(t, { not: 'openapi' });
|
|
36
|
+
const isValid = await (0, validateSpecFile_1.validateSpecFile)(specPath);
|
|
37
|
+
node_assert_1.default.strictEqual(isValid, false);
|
|
38
|
+
});
|
|
39
|
+
(0, node_test_1.test)('validateSpecFiles returns only valid specs with relative paths', async (t) => {
|
|
40
|
+
const validPath = createSpecFile(t, minimalOpenApi);
|
|
41
|
+
const invalidPath = createSpecFile(t, { invalid: true });
|
|
42
|
+
const validated = await (0, validateSpecFiles_1.validateSpecFiles)([validPath, invalidPath]);
|
|
43
|
+
node_assert_1.default.strictEqual(validated.length, 1);
|
|
44
|
+
node_assert_1.default.strictEqual(validated[0].path, validPath);
|
|
45
|
+
node_assert_1.default.ok(validated[0].relativePath.endsWith('spec.json'));
|
|
46
|
+
});
|
|
47
|
+
(0, node_test_1.test)('validateSpecFiles returns empty array when all files invalid', async (t) => {
|
|
48
|
+
const invalidPath = createSpecFile(t, { invalid: true });
|
|
49
|
+
const validated = await (0, validateSpecFiles_1.validateSpecFiles)([invalidPath]);
|
|
50
|
+
node_assert_1.default.deepStrictEqual(validated, []);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildConfig.d.ts","sourceRoot":"","sources":["../../../../src/cli/initOpenApiConfig/utils/buildConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,cAAc,EAAE,aAAa,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"buildConfig.d.ts","sourceRoot":"","sources":["../../../../src/cli/initOpenApiConfig/utils/buildConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,cAAc,EAAE,aAAa,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CA8ElK;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,OAAO,GAAG,WAAW,CAuEzH"}
|
|
@@ -28,6 +28,7 @@ async function buildConfig(validatedSpecs, useMultiOption, customRequest, perSpe
|
|
|
28
28
|
interfacePrefix: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.interfacePrefix,
|
|
29
29
|
typePrefix: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.typePrefix,
|
|
30
30
|
useCancelableRequest: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useCancelableRequest,
|
|
31
|
+
useRequestRaw: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useRequestRaw,
|
|
31
32
|
useOptions: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useOptions,
|
|
32
33
|
useSeparatedIndexes: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useSeparatedIndexes,
|
|
33
34
|
useUnionTypes: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useUnionTypes,
|
|
@@ -65,6 +66,7 @@ async function buildConfig(validatedSpecs, useMultiOption, customRequest, perSpe
|
|
|
65
66
|
interfacePrefix: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.interfacePrefix,
|
|
66
67
|
typePrefix: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.typePrefix,
|
|
67
68
|
useCancelableRequest: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useCancelableRequest,
|
|
69
|
+
useRequestRaw: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useRequestRaw,
|
|
68
70
|
useOptions: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useOptions,
|
|
69
71
|
useSeparatedIndexes: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useSeparatedIndexes,
|
|
70
72
|
useUnionTypes: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useUnionTypes,
|
|
@@ -111,6 +113,7 @@ function buildExampleConfig(useMultiOption, customRequest, perSpecRequest) {
|
|
|
111
113
|
interfacePrefix: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.interfacePrefix,
|
|
112
114
|
typePrefix: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.typePrefix,
|
|
113
115
|
useCancelableRequest: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useCancelableRequest,
|
|
116
|
+
useRequestRaw: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useRequestRaw,
|
|
114
117
|
useOptions: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useOptions,
|
|
115
118
|
useSeparatedIndexes: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useSeparatedIndexes,
|
|
116
119
|
useUnionTypes: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useUnionTypes,
|
|
@@ -143,6 +146,7 @@ function buildExampleConfig(useMultiOption, customRequest, perSpecRequest) {
|
|
|
143
146
|
interfacePrefix: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.interfacePrefix,
|
|
144
147
|
typePrefix: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.typePrefix,
|
|
145
148
|
useCancelableRequest: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useCancelableRequest,
|
|
149
|
+
useRequestRaw: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useRequestRaw,
|
|
146
150
|
useOptions: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useOptions,
|
|
147
151
|
useSeparatedIndexes: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useSeparatedIndexes,
|
|
148
152
|
useUnionTypes: Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useUnionTypes,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compareFiles.test.d.ts","sourceRoot":"","sources":["../../../../../src/cli/previewChanges/utils/__tests__/compareFiles.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const node_test_1 = require("node:test");
|
|
10
|
+
const compareFiles_1 = require("../compareFiles");
|
|
11
|
+
const formatDiff_1 = require("../formatDiff");
|
|
12
|
+
const createTempDir = (t, prefix) => {
|
|
13
|
+
const root = node_path_1.default.join(__dirname, 'generated');
|
|
14
|
+
node_fs_1.default.mkdirSync(root, { recursive: true });
|
|
15
|
+
const tempDir = node_fs_1.default.mkdtempSync(node_path_1.default.join(root, prefix));
|
|
16
|
+
t.after(() => {
|
|
17
|
+
node_fs_1.default.rmSync(tempDir, { recursive: true, force: true });
|
|
18
|
+
});
|
|
19
|
+
return tempDir;
|
|
20
|
+
};
|
|
21
|
+
(0, node_test_1.describe)('@unit: compareFiles and formatDiff', () => {
|
|
22
|
+
(0, node_test_1.test)('compareFiles returns null when files are identical', async (t) => {
|
|
23
|
+
const dir = createTempDir(t, 'compare-same-');
|
|
24
|
+
const filePath = node_path_1.default.join(dir, 'same.ts');
|
|
25
|
+
node_fs_1.default.writeFileSync(filePath, 'line1\nline2\n', 'utf-8');
|
|
26
|
+
const diff = await (0, compareFiles_1.compareFiles)(filePath, filePath);
|
|
27
|
+
node_assert_1.default.strictEqual(diff, null);
|
|
28
|
+
});
|
|
29
|
+
(0, node_test_1.test)('compareFiles returns diff when content changed', async (t) => {
|
|
30
|
+
const dir = createTempDir(t, 'compare-diff-');
|
|
31
|
+
const oldPath = node_path_1.default.join(dir, 'old.ts');
|
|
32
|
+
const newPath = node_path_1.default.join(dir, 'new.ts');
|
|
33
|
+
node_fs_1.default.writeFileSync(oldPath, 'alpha\n', 'utf-8');
|
|
34
|
+
node_fs_1.default.writeFileSync(newPath, 'beta\n', 'utf-8');
|
|
35
|
+
const fileDiff = await (0, compareFiles_1.compareFiles)(oldPath, newPath);
|
|
36
|
+
node_assert_1.default.ok(fileDiff);
|
|
37
|
+
node_assert_1.default.ok(fileDiff.some(part => part.added || part.removed));
|
|
38
|
+
});
|
|
39
|
+
(0, node_test_1.test)('formatDiff renders added, removed, and modified statuses', () => {
|
|
40
|
+
const added = (0, formatDiff_1.formatDiff)('new.ts', 'added');
|
|
41
|
+
node_assert_1.default.match(added, /new file/i);
|
|
42
|
+
const removed = (0, formatDiff_1.formatDiff)('old.ts', 'removed');
|
|
43
|
+
node_assert_1.default.match(removed, /deleted/i);
|
|
44
|
+
const modified = (0, formatDiff_1.formatDiff)('changed.ts', 'modified', [
|
|
45
|
+
{ value: 'old\n', removed: true, added: false, count: 0 },
|
|
46
|
+
{ value: 'new\n', removed: false, added: true, count: 0 },
|
|
47
|
+
]);
|
|
48
|
+
node_assert_1.default.match(modified, /```diff/);
|
|
49
|
+
node_assert_1.default.match(modified, /\+\s*new/);
|
|
50
|
+
node_assert_1.default.match(modified, /-\s*old/);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isDirectoryEmpty.test.d.ts","sourceRoot":"","sources":["../../../../../src/cli/previewChanges/utils/__tests__/isDirectoryEmpty.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const node_test_1 = require("node:test");
|
|
10
|
+
const isDirectoryEmpty_1 = require("../isDirectoryEmpty");
|
|
11
|
+
const createTempDir = (t, prefix) => {
|
|
12
|
+
const root = node_path_1.default.join(__dirname, 'generated');
|
|
13
|
+
node_fs_1.default.mkdirSync(root, { recursive: true });
|
|
14
|
+
const tempDir = node_fs_1.default.mkdtempSync(node_path_1.default.join(root, prefix));
|
|
15
|
+
t.after(() => {
|
|
16
|
+
node_fs_1.default.rmSync(tempDir, { recursive: true, force: true });
|
|
17
|
+
});
|
|
18
|
+
return tempDir;
|
|
19
|
+
};
|
|
20
|
+
(0, node_test_1.describe)('@unit: isDirectoryEmpty', () => {
|
|
21
|
+
(0, node_test_1.test)('returns true for missing directory', async () => {
|
|
22
|
+
const result = await (0, isDirectoryEmpty_1.isDirectoryEmpty)(node_path_1.default.join(__dirname, 'missing-dir-never-exists'));
|
|
23
|
+
node_assert_1.default.strictEqual(result, true);
|
|
24
|
+
});
|
|
25
|
+
(0, node_test_1.test)('returns true for empty directory', async (t) => {
|
|
26
|
+
const dir = createTempDir(t, 'empty-dir-');
|
|
27
|
+
const result = await (0, isDirectoryEmpty_1.isDirectoryEmpty)(dir);
|
|
28
|
+
node_assert_1.default.strictEqual(result, true);
|
|
29
|
+
});
|
|
30
|
+
(0, node_test_1.test)('returns false for directory with entries', async (t) => {
|
|
31
|
+
const dir = createTempDir(t, 'nonempty-dir-');
|
|
32
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(dir, 'file.txt'), 'content');
|
|
33
|
+
const result = await (0, isDirectoryEmpty_1.isDirectoryEmpty)(dir);
|
|
34
|
+
node_assert_1.default.strictEqual(result, false);
|
|
35
|
+
});
|
|
36
|
+
(0, node_test_1.test)('returns true when path is a file', async (t) => {
|
|
37
|
+
const dir = createTempDir(t, 'file-path-');
|
|
38
|
+
const filePath = node_path_1.default.join(dir, 'not-dir.txt');
|
|
39
|
+
node_fs_1.default.writeFileSync(filePath, 'x');
|
|
40
|
+
const result = await (0, isDirectoryEmpty_1.isDirectoryEmpty)(filePath);
|
|
41
|
+
node_assert_1.default.strictEqual(result, true);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readDirectoryRecursive.test.d.ts","sourceRoot":"","sources":["../../../../../src/cli/previewChanges/utils/__tests__/readDirectoryRecursive.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const node_test_1 = require("node:test");
|
|
10
|
+
const readDirectoryRecursive_1 = require("../readDirectoryRecursive");
|
|
11
|
+
const createTempDir = (t, prefix) => {
|
|
12
|
+
const root = node_path_1.default.join(__dirname, 'generated');
|
|
13
|
+
node_fs_1.default.mkdirSync(root, { recursive: true });
|
|
14
|
+
const tempDir = node_fs_1.default.mkdtempSync(node_path_1.default.join(root, prefix));
|
|
15
|
+
t.after(() => {
|
|
16
|
+
node_fs_1.default.rmSync(tempDir, { recursive: true, force: true });
|
|
17
|
+
});
|
|
18
|
+
return tempDir;
|
|
19
|
+
};
|
|
20
|
+
(0, node_test_1.describe)('@unit: readDirectoryRecursive', () => {
|
|
21
|
+
(0, node_test_1.test)('returns relative paths for nested files', async (t) => {
|
|
22
|
+
const dir = createTempDir(t, 'read-recursive-');
|
|
23
|
+
const nested = node_path_1.default.join(dir, 'nested');
|
|
24
|
+
node_fs_1.default.mkdirSync(nested, { recursive: true });
|
|
25
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(dir, 'root.ts'), 'export {}');
|
|
26
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(nested, 'child.ts'), 'export {}');
|
|
27
|
+
const files = await (0, readDirectoryRecursive_1.readDirectoryRecursive)(dir);
|
|
28
|
+
node_assert_1.default.ok(files.includes('root.ts'));
|
|
29
|
+
node_assert_1.default.ok(files.some(file => file.endsWith('child.ts')));
|
|
30
|
+
node_assert_1.default.strictEqual(files.length, 2);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateOutputPaths.test.d.ts","sourceRoot":"","sources":["../../../../../src/cli/previewChanges/utils/__tests__/updateOutputPaths.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const node_test_1 = require("node:test");
|
|
9
|
+
const HttpClient_enum_1 = require("../../../../core/types/enums/HttpClient.enum");
|
|
10
|
+
const updateOutputPaths_1 = require("../updateOutputPaths");
|
|
11
|
+
(0, node_test_1.describe)('@unit: updateOutputPaths', () => {
|
|
12
|
+
(0, node_test_1.test)('rewrites output inside generatedDir to previewDir', () => {
|
|
13
|
+
const generatedDir = './test/generated';
|
|
14
|
+
const previewDir = './generated-preview';
|
|
15
|
+
const options = {
|
|
16
|
+
input: './test/spec/v3.json',
|
|
17
|
+
output: node_path_1.default.join(generatedDir, 'api'),
|
|
18
|
+
httpClient: HttpClient_enum_1.HttpClient.FETCH,
|
|
19
|
+
};
|
|
20
|
+
const updated = (0, updateOutputPaths_1.updateOutputPaths)(options, previewDir, generatedDir);
|
|
21
|
+
node_assert_1.default.strictEqual(updated.output, node_path_1.default.join(previewDir, 'api'));
|
|
22
|
+
});
|
|
23
|
+
(0, node_test_1.test)('uses basename when output escapes generatedDir via ../', () => {
|
|
24
|
+
const generatedDir = './test/generated';
|
|
25
|
+
const previewDir = './generated-preview';
|
|
26
|
+
const options = {
|
|
27
|
+
input: './test/spec/v3.json',
|
|
28
|
+
output: '../outside/api',
|
|
29
|
+
httpClient: HttpClient_enum_1.HttpClient.FETCH,
|
|
30
|
+
};
|
|
31
|
+
const updated = (0, updateOutputPaths_1.updateOutputPaths)(options, previewDir, generatedDir);
|
|
32
|
+
node_assert_1.default.strictEqual(updated.output, node_path_1.default.join(previewDir, 'api'));
|
|
33
|
+
});
|
|
34
|
+
(0, node_test_1.test)('rewrites outputCore and sibling paths for flat config', () => {
|
|
35
|
+
const generatedDir = './test/generated';
|
|
36
|
+
const previewDir = './generated-preview';
|
|
37
|
+
const options = {
|
|
38
|
+
input: './test/spec/v3.json',
|
|
39
|
+
output: node_path_1.default.join(generatedDir, 'api'),
|
|
40
|
+
outputCore: node_path_1.default.join(generatedDir, 'api', 'core'),
|
|
41
|
+
outputServices: node_path_1.default.join(generatedDir, 'api', 'services'),
|
|
42
|
+
outputModels: node_path_1.default.join(generatedDir, 'api', 'models'),
|
|
43
|
+
outputSchemas: node_path_1.default.join(generatedDir, 'api', 'schemas'),
|
|
44
|
+
httpClient: HttpClient_enum_1.HttpClient.FETCH,
|
|
45
|
+
};
|
|
46
|
+
const updated = (0, updateOutputPaths_1.updateOutputPaths)(options, previewDir, generatedDir);
|
|
47
|
+
node_assert_1.default.strictEqual(updated.output, node_path_1.default.join(previewDir, 'api'));
|
|
48
|
+
node_assert_1.default.ok(updated.outputCore?.includes('core'));
|
|
49
|
+
node_assert_1.default.ok(updated.outputServices?.includes('services'));
|
|
50
|
+
node_assert_1.default.ok(updated.outputModels?.includes('models'));
|
|
51
|
+
node_assert_1.default.ok(updated.outputSchemas?.includes('schemas'));
|
|
52
|
+
});
|
|
53
|
+
(0, node_test_1.test)('updates items array for multi-option config', () => {
|
|
54
|
+
const generatedDir = './test/generated';
|
|
55
|
+
const previewDir = './generated-preview';
|
|
56
|
+
const options = {
|
|
57
|
+
items: [
|
|
58
|
+
{ input: './a.json', output: node_path_1.default.join(generatedDir, 'client-a') },
|
|
59
|
+
{ input: './b.json', output: node_path_1.default.join(generatedDir, 'client-b') },
|
|
60
|
+
],
|
|
61
|
+
httpClient: HttpClient_enum_1.HttpClient.FETCH,
|
|
62
|
+
};
|
|
63
|
+
const updated = (0, updateOutputPaths_1.updateOutputPaths)(options, previewDir, generatedDir);
|
|
64
|
+
node_assert_1.default.strictEqual(updated.items?.length, 2);
|
|
65
|
+
node_assert_1.default.strictEqual(updated.items?.[0].output, node_path_1.default.join(previewDir, 'client-a'));
|
|
66
|
+
node_assert_1.default.strictEqual(updated.items?.[1].output, node_path_1.default.join(previewDir, 'client-b'));
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkConfigAndUpdate.test.d.ts","sourceRoot":"","sources":["../../../../src/cli/schemas/__tests__/checkConfigAndUpdate.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
|
+
const node_test_1 = require("node:test");
|
|
8
|
+
const checkConfig_1 = require("../checkConfig");
|
|
9
|
+
const updateConfig_1 = require("../updateConfig");
|
|
10
|
+
(0, node_test_1.describe)('@unit: checkConfig and updateConfig schemas', () => {
|
|
11
|
+
(0, node_test_1.test)('checkConfigOptionsSchema accepts empty options', () => {
|
|
12
|
+
const parsed = checkConfig_1.checkConfigOptionsSchema.safeParse({});
|
|
13
|
+
node_assert_1.default.strictEqual(parsed.success, true);
|
|
14
|
+
});
|
|
15
|
+
(0, node_test_1.test)('checkConfigOptionsSchema accepts openapiConfig path', () => {
|
|
16
|
+
const parsed = checkConfig_1.checkConfigOptionsSchema.safeParse({
|
|
17
|
+
openapiConfig: './custom/openapi.config.json',
|
|
18
|
+
});
|
|
19
|
+
node_assert_1.default.strictEqual(parsed.success, true);
|
|
20
|
+
});
|
|
21
|
+
(0, node_test_1.test)('checkConfigOptionsSchema treats empty openapiConfig as undefined', () => {
|
|
22
|
+
const parsed = checkConfig_1.checkConfigOptionsSchema.safeParse({
|
|
23
|
+
openapiConfig: '',
|
|
24
|
+
});
|
|
25
|
+
node_assert_1.default.strictEqual(parsed.success, true);
|
|
26
|
+
if (parsed.success) {
|
|
27
|
+
node_assert_1.default.strictEqual(parsed.data.openapiConfig, undefined);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
(0, node_test_1.test)('updateConfigOptionsSchema accepts valid paths', () => {
|
|
31
|
+
const parsed = updateConfig_1.updateConfigOptionsSchema.safeParse({
|
|
32
|
+
openapiConfig: './openapi.config.json',
|
|
33
|
+
});
|
|
34
|
+
node_assert_1.default.strictEqual(parsed.success, true);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateOptionsSchema.test.d.ts","sourceRoot":"","sources":["../../../../src/cli/schemas/__tests__/generateOptionsSchema.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
|
+
const node_test_1 = require("node:test");
|
|
8
|
+
const generate_1 = require("../generate");
|
|
9
|
+
(0, node_test_1.describe)('@unit: generateOptionsSchema', () => {
|
|
10
|
+
(0, node_test_1.test)('accepts openapiConfig only', () => {
|
|
11
|
+
const parsed = generate_1.generateOptionsSchema.safeParse({
|
|
12
|
+
openapiConfig: './openapi.config.json',
|
|
13
|
+
});
|
|
14
|
+
node_assert_1.default.strictEqual(parsed.success, true);
|
|
15
|
+
});
|
|
16
|
+
(0, node_test_1.test)('accepts input and output without config', () => {
|
|
17
|
+
const parsed = generate_1.generateOptionsSchema.safeParse({
|
|
18
|
+
input: './spec.json',
|
|
19
|
+
output: './generated',
|
|
20
|
+
});
|
|
21
|
+
node_assert_1.default.strictEqual(parsed.success, true);
|
|
22
|
+
});
|
|
23
|
+
(0, node_test_1.test)('rejects both openapiConfig and input/output', () => {
|
|
24
|
+
const parsed = generate_1.generateOptionsSchema.safeParse({
|
|
25
|
+
openapiConfig: './openapi.config.json',
|
|
26
|
+
input: './spec.json',
|
|
27
|
+
output: './generated',
|
|
28
|
+
});
|
|
29
|
+
node_assert_1.default.strictEqual(parsed.success, false);
|
|
30
|
+
});
|
|
31
|
+
(0, node_test_1.test)('rejects when neither config nor input/output is provided', () => {
|
|
32
|
+
const parsed = generate_1.generateOptionsSchema.safeParse({});
|
|
33
|
+
node_assert_1.default.strictEqual(parsed.success, false);
|
|
34
|
+
});
|
|
35
|
+
(0, node_test_1.test)('requires non-empty input when using direct generation', () => {
|
|
36
|
+
const parsed = generate_1.generateOptionsSchema.safeParse({
|
|
37
|
+
input: ' ',
|
|
38
|
+
output: './generated',
|
|
39
|
+
});
|
|
40
|
+
node_assert_1.default.strictEqual(parsed.success, false);
|
|
41
|
+
});
|
|
42
|
+
(0, node_test_1.test)('requires non-empty output when using direct generation', () => {
|
|
43
|
+
const parsed = generate_1.generateOptionsSchema.safeParse({
|
|
44
|
+
input: './spec.json',
|
|
45
|
+
output: '',
|
|
46
|
+
});
|
|
47
|
+
node_assert_1.default.strictEqual(parsed.success, false);
|
|
48
|
+
});
|
|
49
|
+
(0, node_test_1.test)('accepts cache-related flags with config path', () => {
|
|
50
|
+
const parsed = generate_1.generateOptionsSchema.safeParse({
|
|
51
|
+
openapiConfig: './openapi.config.json',
|
|
52
|
+
cache: true,
|
|
53
|
+
cachePath: '.cache.json',
|
|
54
|
+
cacheStrategy: 'entity',
|
|
55
|
+
cacheDebug: true,
|
|
56
|
+
});
|
|
57
|
+
node_assert_1.default.strictEqual(parsed.success, true);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initOptionsSchema.test.d.ts","sourceRoot":"","sources":["../../../../src/cli/schemas/__tests__/initOptionsSchema.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
|
+
const node_test_1 = require("node:test");
|
|
8
|
+
const init_1 = require("../init");
|
|
9
|
+
(0, node_test_1.describe)('@unit: initOptionsSchema', () => {
|
|
10
|
+
(0, node_test_1.test)('accepts minimal options', () => {
|
|
11
|
+
const parsed = init_1.initOptionsSchema.safeParse({});
|
|
12
|
+
node_assert_1.default.strictEqual(parsed.success, true);
|
|
13
|
+
});
|
|
14
|
+
(0, node_test_1.test)('accepts interactive init flags', () => {
|
|
15
|
+
const parsed = init_1.initOptionsSchema.safeParse({
|
|
16
|
+
specsDir: './openapi',
|
|
17
|
+
request: './src/custom/request.ts',
|
|
18
|
+
useCancelableRequest: true,
|
|
19
|
+
useInteractiveMode: true,
|
|
20
|
+
});
|
|
21
|
+
node_assert_1.default.strictEqual(parsed.success, true);
|
|
22
|
+
});
|
|
23
|
+
(0, node_test_1.test)('converts empty strings to undefined', () => {
|
|
24
|
+
const parsed = init_1.initOptionsSchema.safeParse({
|
|
25
|
+
specsDir: '',
|
|
26
|
+
request: '',
|
|
27
|
+
});
|
|
28
|
+
node_assert_1.default.strictEqual(parsed.success, true);
|
|
29
|
+
if (parsed.success) {
|
|
30
|
+
node_assert_1.default.strictEqual(parsed.data.specsDir, undefined);
|
|
31
|
+
node_assert_1.default.strictEqual(parsed.data.request, undefined);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
(0, node_test_1.test)('treats empty openapiConfig as undefined', () => {
|
|
35
|
+
const parsed = init_1.initOptionsSchema.safeParse({
|
|
36
|
+
openapiConfig: '',
|
|
37
|
+
});
|
|
38
|
+
node_assert_1.default.strictEqual(parsed.success, true);
|
|
39
|
+
if (parsed.success) {
|
|
40
|
+
node_assert_1.default.strictEqual(parsed.data.openapiConfig, undefined);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"previewChangesSchema.test.d.ts","sourceRoot":"","sources":["../../../../src/cli/schemas/__tests__/previewChangesSchema.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
|
+
const node_test_1 = require("node:test");
|
|
8
|
+
const previewChanges_1 = require("../previewChanges");
|
|
9
|
+
(0, node_test_1.describe)('@unit: previewChangesSchema', () => {
|
|
10
|
+
(0, node_test_1.test)('accepts preview directories', () => {
|
|
11
|
+
const parsed = previewChanges_1.previewChangesSchema.safeParse({
|
|
12
|
+
generatedDir: './test/generated',
|
|
13
|
+
previewDir: './generated-preview',
|
|
14
|
+
diffDir: './diff-preview',
|
|
15
|
+
});
|
|
16
|
+
node_assert_1.default.strictEqual(parsed.success, true);
|
|
17
|
+
});
|
|
18
|
+
(0, node_test_1.test)('treats empty strings as undefined', () => {
|
|
19
|
+
const parsed = previewChanges_1.previewChangesSchema.safeParse({
|
|
20
|
+
generatedDir: '',
|
|
21
|
+
previewDir: '',
|
|
22
|
+
diffDir: '',
|
|
23
|
+
});
|
|
24
|
+
node_assert_1.default.strictEqual(parsed.success, true);
|
|
25
|
+
if (parsed.success) {
|
|
26
|
+
node_assert_1.default.strictEqual(parsed.data.generatedDir, undefined);
|
|
27
|
+
node_assert_1.default.strictEqual(parsed.data.previewDir, undefined);
|
|
28
|
+
node_assert_1.default.strictEqual(parsed.data.diffDir, undefined);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -4,6 +4,7 @@ export declare const initOptionsSchema: z.ZodObject<{
|
|
|
4
4
|
specsDir: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
5
5
|
request: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
6
6
|
useCancelableRequest: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
useRequestRaw: z.ZodOptional<z.ZodBoolean>;
|
|
7
8
|
useInteractiveMode: z.ZodOptional<z.ZodBoolean>;
|
|
8
9
|
}, z.core.$strip>;
|
|
9
10
|
export type InitOptions = z.infer<typeof initOptionsSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/schemas/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/schemas/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,iBAAiB;;;;;;;iBAM5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
package/dist/cli/schemas/init.js
CHANGED
|
@@ -7,5 +7,6 @@ exports.initOptionsSchema = base_1.baseCLIOptionsSchema.extend({
|
|
|
7
7
|
specsDir: base_1.emptyStringToUndefined,
|
|
8
8
|
request: base_1.emptyStringToUndefined,
|
|
9
9
|
useCancelableRequest: zod_1.z.boolean().optional(),
|
|
10
|
+
useRequestRaw: zod_1.z.boolean().optional(),
|
|
10
11
|
useInteractiveMode: zod_1.z.boolean().optional(),
|
|
11
12
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Consts.d.ts","sourceRoot":"","sources":["../../src/common/Consts.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,eAAO,MAAM,+BAA+B,wBAAwB,CAAC;AACrE,eAAO,MAAM,gCAAgC,+BAA+B,CAAC;AAE7E,eAAO,MAAM,6BAA6B,EAAE,
|
|
1
|
+
{"version":3,"file":"Consts.d.ts","sourceRoot":"","sources":["../../src/common/Consts.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,eAAO,MAAM,+BAA+B,wBAAwB,CAAC;AACrE,eAAO,MAAM,gCAAgC,+BAA+B,CAAC;AAE7E,eAAO,MAAM,6BAA6B,EAAE,kBAqC3C,CAAC;AAEF,eAAO,MAAM,UAAU,QAIrB,CAAC;AAEH,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAE5C,eAAO,MAAM,2BAA2B,4BAA4B,CAAA;AAEpE,eAAO,MAAM,sBAAsB,gBAAgB,CAAC;AAEpD,eAAO,MAAM,2BAA2B,0CAA0C,CAAC;AAEnF,eAAO,MAAM,wBAAwB,uCAAuC,CAAC"}
|
package/dist/common/Consts.js
CHANGED
|
@@ -8,6 +8,7 @@ export declare const unifiedOptionsShape: z.ZodObject<{
|
|
|
8
8
|
sortByRequired: z.ZodOptional<z.ZodBoolean>;
|
|
9
9
|
useSeparatedIndexes: z.ZodOptional<z.ZodBoolean>;
|
|
10
10
|
useCancelableRequest: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
useRequestRaw: z.ZodOptional<z.ZodBoolean>;
|
|
11
12
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
12
13
|
interfacePrefix: z.ZodOptional<z.ZodString>;
|
|
13
14
|
enumPrefix: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnifiedBase.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,MAAM,2CAA2C,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAapD,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"UnifiedBase.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,MAAM,2CAA2C,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAapD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;iBAK9B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;iBAG7B,CAAC"}
|
|
@@ -3,6 +3,7 @@ export declare const unifiedOptionsSchemaV1: z.ZodObject<{
|
|
|
3
3
|
sortByRequired: z.ZodOptional<z.ZodBoolean>;
|
|
4
4
|
useSeparatedIndexes: z.ZodOptional<z.ZodBoolean>;
|
|
5
5
|
useCancelableRequest: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
+
useRequestRaw: z.ZodOptional<z.ZodBoolean>;
|
|
6
7
|
request: z.ZodOptional<z.ZodString>;
|
|
7
8
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
8
9
|
interfacePrefix: z.ZodOptional<z.ZodString>;
|
|
@@ -25,6 +26,7 @@ export declare const unifiedOptionsSchemaV1: z.ZodObject<{
|
|
|
25
26
|
sortByRequired: z.ZodOptional<z.ZodBoolean>;
|
|
26
27
|
useSeparatedIndexes: z.ZodOptional<z.ZodBoolean>;
|
|
27
28
|
useCancelableRequest: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
useRequestRaw: z.ZodOptional<z.ZodBoolean>;
|
|
28
30
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
29
31
|
interfacePrefix: z.ZodOptional<z.ZodString>;
|
|
30
32
|
enumPrefix: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnifiedOptionsSchemaV1.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAOtB,eAAO,MAAM,sBAAsB
|
|
1
|
+
{"version":3,"file":"UnifiedOptionsSchemaV1.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAOtB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMjC,CAAC"}
|
|
@@ -7,6 +7,7 @@ export declare const unifiedOptionsSchemaV2: z.ZodObject<{
|
|
|
7
7
|
sortByRequired: z.ZodOptional<z.ZodBoolean>;
|
|
8
8
|
useSeparatedIndexes: z.ZodOptional<z.ZodBoolean>;
|
|
9
9
|
useCancelableRequest: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
useRequestRaw: z.ZodOptional<z.ZodBoolean>;
|
|
10
11
|
request: z.ZodOptional<z.ZodString>;
|
|
11
12
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
12
13
|
interfacePrefix: z.ZodOptional<z.ZodString>;
|
|
@@ -26,6 +27,7 @@ export declare const unifiedOptionsSchemaV2: z.ZodObject<{
|
|
|
26
27
|
sortByRequired: z.ZodOptional<z.ZodBoolean>;
|
|
27
28
|
useSeparatedIndexes: z.ZodOptional<z.ZodBoolean>;
|
|
28
29
|
useCancelableRequest: z.ZodOptional<z.ZodBoolean>;
|
|
30
|
+
useRequestRaw: z.ZodOptional<z.ZodBoolean>;
|
|
29
31
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
30
32
|
interfacePrefix: z.ZodOptional<z.ZodString>;
|
|
31
33
|
enumPrefix: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnifiedOptionsSchemaV2.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAKtB,eAAO,MAAM,sBAAsB
|
|
1
|
+
{"version":3,"file":"UnifiedOptionsSchemaV2.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAKtB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGjC,CAAC"}
|