ts-openapi-codegen 1.0.0 → 2.0.0-beta.1
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 +74 -0
- package/README.rus.md +73 -0
- package/dist/cli/generate/runGenerateOpenApi.d.ts.map +1 -1
- package/dist/cli/generate/runGenerateOpenApi.js +10 -25
- package/dist/common/Consts.d.ts +2 -21
- package/dist/common/Consts.d.ts.map +1 -1
- package/dist/common/Consts.js +5 -2
- package/dist/common/Logger.d.ts.map +1 -1
- package/dist/common/Logger.js +3 -2
- package/dist/common/LoggerMessages.d.ts +64 -0
- package/dist/common/LoggerMessages.d.ts.map +1 -0
- package/dist/common/LoggerMessages.js +82 -0
- package/dist/common/TRawOptions.d.ts +40 -0
- package/dist/common/TRawOptions.d.ts.map +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts +8 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +31 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts +8 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts.map +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.js +33 -0
- package/dist/common/VersionedSchema/Enums.d.ts +2 -1
- package/dist/common/VersionedSchema/Enums.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Enums.js +1 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan.js +10 -19
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.js +10 -10
- package/dist/common/VersionedSchema/Types.d.ts +5 -0
- package/dist/common/VersionedSchema/Types.d.ts.map +1 -1
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.d.ts +3 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.d.ts.map +1 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.js +28 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsSchemaV1.d.ts +7 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsSchemaV1.d.ts.map +1 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsSchemaV1.js +42 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.d.ts +3 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.d.ts.map +1 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.js +10 -0
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.d.ts +11 -0
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.js +19 -0
- package/dist/common/VersionedSchema/Utils/createTrivialMigration.d.ts +7 -0
- package/dist/common/VersionedSchema/Utils/createTrivialMigration.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/createTrivialMigration.js +15 -0
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.js +11 -4
- package/dist/core/OpenApiClient.d.ts +13 -0
- package/dist/core/OpenApiClient.d.ts.map +1 -0
- package/dist/core/OpenApiClient.js +175 -0
- package/dist/core/WriteClient.d.ts +1 -1
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +2 -2
- package/dist/core/__tests__/WriteClient.test.js +2 -0
- package/dist/core/index.d.ts +2 -6
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +6 -168
- package/dist/core/utils/__mocks__/templates.d.ts +3 -0
- package/dist/core/utils/__mocks__/templates.d.ts.map +1 -0
- package/dist/core/utils/__mocks__/templates.js +29 -0
- package/dist/core/utils/__tests__/writeClientCore.test.js +2 -25
- package/dist/core/utils/__tests__/writeClientFullIndex.test.js +2 -25
- package/dist/core/utils/__tests__/writeClientModels.test.js +2 -25
- package/dist/core/utils/__tests__/writeClientSchemas.test.js +2 -25
- package/dist/core/utils/__tests__/writeClientServices.test.js +2 -25
- package/dist/core/utils/registerHandlebarTemplates.d.ts +2 -0
- package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarTemplates.js +4 -0
- package/dist/core/utils/writeClientCore.d.ts.map +1 -1
- package/dist/core/utils/writeClientCore.js +3 -0
- package/dist/templatesCompiled/client/core/legacy-request-adapter.d.ts +8 -0
- package/dist/templatesCompiled/client/core/legacy-request-adapter.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/legacy-request-adapter.js +18 -0
- package/dist/templatesCompiled/client/core/request-executor.d.ts +7 -0
- package/dist/templatesCompiled/client/core/request-executor.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/request-executor.js +11 -0
- package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportService.js +46 -50
- package/package.json +1 -1
- package/dist/common/Options.d.ts +0 -26
- package/dist/common/Options.d.ts.map +0 -1
- package/dist/core/utils/prepareOptions.d.ts +0 -8
- package/dist/core/utils/prepareOptions.d.ts.map +0 -1
- package/dist/core/utils/prepareOptions.js +0 -31
- /package/dist/common/{Options.js → TRawOptions.js} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.multiOptionsMigrationPlan = void 0;
|
|
4
|
+
const createDefaultFieldsMigration_1 = require("../Utils/createDefaultFieldsMigration");
|
|
4
5
|
/**
|
|
5
6
|
* Migration plan for multi options models.
|
|
6
7
|
*/
|
|
@@ -13,14 +14,9 @@ exports.multiOptionsMigrationPlan = [
|
|
|
13
14
|
httpClient: client,
|
|
14
15
|
}),
|
|
15
16
|
},
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
migrate: oldVersion => ({
|
|
20
|
-
...oldVersion,
|
|
21
|
-
useCancelableRequest: false,
|
|
22
|
-
}),
|
|
23
|
-
},
|
|
17
|
+
(0, createDefaultFieldsMigration_1.createDefaultFieldsMigration)('v2', 'v3', {
|
|
18
|
+
useCancelableRequest: false,
|
|
19
|
+
}),
|
|
24
20
|
{
|
|
25
21
|
fromVersion: 'v3',
|
|
26
22
|
toVersion: 'v4',
|
|
@@ -29,15 +25,10 @@ exports.multiOptionsMigrationPlan = [
|
|
|
29
25
|
items: items.map((el) => ({ ...el, input, output, outputCore, outputServices, outputModels, outputSchemas })),
|
|
30
26
|
}),
|
|
31
27
|
},
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
includeSchemasFiles: false,
|
|
39
|
-
sortByRequired: false,
|
|
40
|
-
useSeparatedIndexes: false,
|
|
41
|
-
}),
|
|
42
|
-
},
|
|
28
|
+
(0, createDefaultFieldsMigration_1.createDefaultFieldsMigration)('v4', 'v5', {
|
|
29
|
+
excludeCoreServiceFiles: false,
|
|
30
|
+
includeSchemasFiles: false,
|
|
31
|
+
sortByRequired: false,
|
|
32
|
+
useSeparatedIndexes: false,
|
|
33
|
+
}),
|
|
43
34
|
];
|
|
@@ -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;
|
|
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,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.optionsMigrationPlans = void 0;
|
|
4
|
+
const createDefaultFieldsMigration_1 = require("../Utils/createDefaultFieldsMigration");
|
|
4
5
|
/**
|
|
5
6
|
* Migration plan for option models.
|
|
6
7
|
*/
|
|
@@ -10,14 +11,13 @@ exports.optionsMigrationPlans = [
|
|
|
10
11
|
toVersion: 'v2',
|
|
11
12
|
migrate: ({ client, ...otherProps }) => ({ ...otherProps, httpClient: client }),
|
|
12
13
|
},
|
|
13
|
-
{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
14
|
+
(0, createDefaultFieldsMigration_1.createDefaultFieldsMigration)('v2', 'v3', {
|
|
15
|
+
useCancelableRequest: false,
|
|
16
|
+
}),
|
|
17
|
+
(0, createDefaultFieldsMigration_1.createDefaultFieldsMigration)('v3', 'v4', {
|
|
18
|
+
excludeCoreServiceFiles: false,
|
|
19
|
+
includeSchemasFiles: false,
|
|
20
|
+
sortByRequired: false,
|
|
21
|
+
useSeparatedIndexes: false,
|
|
22
|
+
}),
|
|
23
23
|
];
|
|
@@ -9,6 +9,11 @@ export type SchemaMigrationPlan<From, To> = {
|
|
|
9
9
|
fromVersion: string;
|
|
10
10
|
toVersion: string;
|
|
11
11
|
migrate: (input: From) => To;
|
|
12
|
+
/**
|
|
13
|
+
* Optional description of what this migration does.
|
|
14
|
+
* Helps with debugging and documentation.
|
|
15
|
+
*/
|
|
16
|
+
description?: string;
|
|
12
17
|
};
|
|
13
18
|
export type TraverseHandler<T> = (value: any, recurse: (v: any) => void, result: T) => boolean;
|
|
14
19
|
export type VersionMatchResult = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../../src/common/VersionedSchema/Types.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC7B,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACtB,IAAI,EAAE,oBAAoB,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACnB,
|
|
1
|
+
{"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../../src/common/VersionedSchema/Types.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC7B,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACtB,IAAI,EAAE,oBAAoB,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,IAAI,EAAE,EAAE,IAAI;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,EAAE,CAAC;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAGF,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC;AAE/F,MAAM,MAAM,kBAAkB,GAAG;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACxB,CAAC"}
|
package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnifiedOptionsMigrationPlan.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,eAAO,MAAM,2BAA2B,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAwBtG,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unifiedOptionsMigrationPlan = void 0;
|
|
4
|
+
exports.unifiedOptionsMigrationPlan = [
|
|
5
|
+
// Migration from OPTIONS v4 to UNIFIED_OPTIONS v1
|
|
6
|
+
// OPTIONS v4 already has input/output structure, so we just pass it through
|
|
7
|
+
// Unified schema supports this format directly
|
|
8
|
+
{
|
|
9
|
+
fromVersion: 'OPTIONS_v4',
|
|
10
|
+
toVersion: 'UNIFIED_v1',
|
|
11
|
+
migrate: (oldVersion) => {
|
|
12
|
+
// OPTIONS v4 structure is already compatible with unified schema
|
|
13
|
+
// Just return as-is, unified schema will handle input/output
|
|
14
|
+
return { ...oldVersion };
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
// Migration from MULTI_OPTIONS v5 to UNIFIED_OPTIONS v1
|
|
18
|
+
// MULTI_OPTIONS v5 has items array, which unified schema also supports
|
|
19
|
+
{
|
|
20
|
+
fromVersion: 'MULTI_OPTIONS_v5',
|
|
21
|
+
toVersion: 'UNIFIED_v1',
|
|
22
|
+
migrate: (oldVersion) => {
|
|
23
|
+
// MULTI_OPTIONS v5 structure with items is already compatible
|
|
24
|
+
// Just return as-is, unified schema will handle items
|
|
25
|
+
return { ...oldVersion };
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Joi from 'joi';
|
|
2
|
+
/**
|
|
3
|
+
* Unified options schema that supports both single and multi-item configurations.
|
|
4
|
+
* Use either 'items' array for multiple specs OR 'input'/'output' for single spec.
|
|
5
|
+
*/
|
|
6
|
+
export declare const unifiedOptionsSchemaV1: Joi.ObjectSchema<any>;
|
|
7
|
+
//# sourceMappingURL=UnifiedOptionsSchemaV1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnifiedOptionsSchemaV1.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsSchemaV1.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAqBtB;;;GAGG;AACH,eAAO,MAAM,sBAAsB,uBA6BZ,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.unifiedOptionsSchemaV1 = void 0;
|
|
7
|
+
const joi_1 = __importDefault(require("joi"));
|
|
8
|
+
const core_1 = require("../../../core");
|
|
9
|
+
const CommonSchemas_1 = require("../CommonSchemas");
|
|
10
|
+
const mergeObjectSchemas_1 = require("../Utils/mergeObjectSchemas");
|
|
11
|
+
const itemSchema = (0, mergeObjectSchemas_1.mergeObjectSchemas)(joi_1.default.object({
|
|
12
|
+
input: joi_1.default.string().required().description('Путь, URL или строка OpenAPI спецификации'),
|
|
13
|
+
httpClient: joi_1.default.string().valid(...Object.values(core_1.HttpClient)).optional(),
|
|
14
|
+
}), CommonSchemas_1.outputPathsSchema, CommonSchemas_1.additionalParametersSchemaV2, CommonSchemas_1.experimentalParametersSchemaV2);
|
|
15
|
+
/**
|
|
16
|
+
* Unified options schema that supports both single and multi-item configurations.
|
|
17
|
+
* Use either 'items' array for multiple specs OR 'input'/'output' for single spec.
|
|
18
|
+
*/
|
|
19
|
+
exports.unifiedOptionsSchemaV1 = (0, mergeObjectSchemas_1.mergeObjectSchemas)(joi_1.default.object({
|
|
20
|
+
// Multi-item configuration
|
|
21
|
+
items: joi_1.default.array()
|
|
22
|
+
.items(itemSchema)
|
|
23
|
+
.min(1)
|
|
24
|
+
.optional()
|
|
25
|
+
.description('Массив спецификаций для генерации'),
|
|
26
|
+
// Single-item configuration (mutually exclusive with items)
|
|
27
|
+
input: joi_1.default.string()
|
|
28
|
+
.when('items', {
|
|
29
|
+
is: joi_1.default.exist(),
|
|
30
|
+
then: joi_1.default.forbidden(),
|
|
31
|
+
otherwise: joi_1.default.required(),
|
|
32
|
+
})
|
|
33
|
+
.description('Путь, URL или строка OpenAPI спецификации'),
|
|
34
|
+
output: joi_1.default.string()
|
|
35
|
+
.when('items', {
|
|
36
|
+
is: joi_1.default.exist(),
|
|
37
|
+
then: joi_1.default.forbidden(),
|
|
38
|
+
otherwise: joi_1.default.required(),
|
|
39
|
+
})
|
|
40
|
+
.description('Выходная директория'),
|
|
41
|
+
}), CommonSchemas_1.outputPathsSchema, // outputCore, outputServices, etc. for single-item mode
|
|
42
|
+
CommonSchemas_1.specialParametersSchemasV2, CommonSchemas_1.additionalParametersSchemaV2, CommonSchemas_1.experimentalParametersSchemaV2).xor('items', 'input');
|
package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnifiedOptionsVersionedSchemas.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,eAAO,MAAM,8BAA8B,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAI/E,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unifiedOptionsVersionedSchemas = void 0;
|
|
4
|
+
const Enums_1 = require("../Enums");
|
|
5
|
+
const UnifiedOptionsSchemaV1_1 = require("./UnifiedOptionsSchemaV1");
|
|
6
|
+
exports.unifiedOptionsVersionedSchemas = [{
|
|
7
|
+
version: 'v1',
|
|
8
|
+
schema: UnifiedOptionsSchemaV1_1.unifiedOptionsSchemaV1,
|
|
9
|
+
type: Enums_1.EVersionedSchemaType.UNIFIED_OPTIONS,
|
|
10
|
+
}];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SchemaMigrationPlan } from "../Types";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a simple migration plan that adds optional fields.
|
|
4
|
+
* Use this when migration only adds optional fields.
|
|
5
|
+
* @param fromVersion
|
|
6
|
+
* @param toVersion
|
|
7
|
+
* @param defaultFields
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function createDefaultFieldsMigration<From extends Record<string, any>>(fromVersion: string, toVersion: string, defaultFields: Record<string, any>): SchemaMigrationPlan<From, From>;
|
|
11
|
+
//# sourceMappingURL=createDefaultFieldsMigration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDefaultFieldsMigration.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/createDefaultFieldsMigration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzE,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACnC,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAOjC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDefaultFieldsMigration = createDefaultFieldsMigration;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a simple migration plan that adds optional fields.
|
|
6
|
+
* Use this when migration only adds optional fields.
|
|
7
|
+
* @param fromVersion
|
|
8
|
+
* @param toVersion
|
|
9
|
+
* @param defaultFields
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
function createDefaultFieldsMigration(fromVersion, toVersion, defaultFields) {
|
|
13
|
+
return {
|
|
14
|
+
fromVersion,
|
|
15
|
+
toVersion,
|
|
16
|
+
migrate: (oldVersion) => ({ ...oldVersion, ...defaultFields }),
|
|
17
|
+
description: `Adds default values for new optional fields: ${Object.keys(defaultFields).join(', ')}`,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SchemaMigrationPlan } from '../Types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a trivial migration plan that just copies all fields.
|
|
4
|
+
* Use this when migration only adds doesn't require transformation.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createTrivialMigration<From extends Record<string, any>>(fromVersion: string, toVersion: string, description?: string): SchemaMigrationPlan<From, From>;
|
|
7
|
+
//# sourceMappingURL=createTrivialMigration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTrivialMigration.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/createTrivialMigration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACnE,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,MAAM,GACrB,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAOjC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTrivialMigration = createTrivialMigration;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a trivial migration plan that just copies all fields.
|
|
6
|
+
* Use this when migration only adds doesn't require transformation.
|
|
7
|
+
*/
|
|
8
|
+
function createTrivialMigration(fromVersion, toVersion, description) {
|
|
9
|
+
return {
|
|
10
|
+
fromVersion,
|
|
11
|
+
toVersion,
|
|
12
|
+
migrate: (oldVersion) => ({ ...oldVersion }),
|
|
13
|
+
description: description || 'Trivial migration that copies all fields without changes',
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrateDataToLatestSchemaVersion.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AASpF,KAAK,oBAAoB,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,cAAc,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;IAChF,gBAAgB,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;IACzD,aAAa,EAAE,cAAc,CAAC;CACjC,CAAC;AAEF,KAAK,qBAAqB,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,cAAc,EAAE,kBAAkB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,oBAAoB,CAAC;CACpC,CAAC;AAEF,wBAAgB,gCAAgC,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,EAAE,oBAAoB,GAAG,qBAAqB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"migrateDataToLatestSchemaVersion.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AASpF,KAAK,oBAAoB,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,cAAc,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;IAChF,gBAAgB,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;IACzD,aAAa,EAAE,cAAc,CAAC;CACjC,CAAC;AAEF,KAAK,qBAAqB,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,cAAc,EAAE,kBAAkB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,oBAAoB,CAAC;CACpC,CAAC;AAEF,wBAAgB,gCAAgC,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,EAAE,oBAAoB,GAAG,qBAAqB,GAAG,IAAI,CAiElK"}
|
|
@@ -22,19 +22,26 @@ function migrateDataToLatestSchemaVersion({ rawInput, migrationPlans, versionedS
|
|
|
22
22
|
const actualVersionIndex = versionedSchemas.length - 1;
|
|
23
23
|
const actualSchema = versionedSchemas[actualVersionIndex];
|
|
24
24
|
for (let idx = guessedVersion.lastVersionIndex; idx < versionedSchemas.length - 1; idx++) {
|
|
25
|
-
const
|
|
25
|
+
const currentVersionSchema = versionedSchemas[idx];
|
|
26
|
+
const { error: firstError } = currentVersionSchema.schema.validate(currentData);
|
|
26
27
|
if (firstError) {
|
|
27
28
|
(0, getCurrentErrorMessage_1.getCurrentErrorMessage)(firstError, replacingKeysMap);
|
|
28
29
|
}
|
|
29
|
-
const fromVersion =
|
|
30
|
+
const fromVersion = currentVersionSchema.version;
|
|
30
31
|
const migrationPlan = migrationPlans.find(p => p.fromVersion === fromVersion);
|
|
31
32
|
if (!migrationPlan) {
|
|
32
|
-
|
|
33
|
+
const availableVersions = migrationPlans.map(p => p.fromVersion).join(', ');
|
|
34
|
+
throw new Error(`No migration plan from ${fromVersion}. ` +
|
|
35
|
+
`Available migration plans: ${availableVersions}. ` +
|
|
36
|
+
`This usually means the migration chain is incomplete.`);
|
|
33
37
|
}
|
|
38
|
+
const toVersion = versionedSchemas[idx + 1].version;
|
|
34
39
|
const migratedRaw = migrationPlan.migrate(currentData);
|
|
35
40
|
const { error } = versionedSchemas[idx + 1].schema.validate(migratedRaw, { allowUnknown: false });
|
|
36
41
|
if (error) {
|
|
37
|
-
throw new Error(
|
|
42
|
+
throw new Error(`Migration from ${fromVersion} to ${toVersion} failed validation. ` +
|
|
43
|
+
`Error: ${error.message}. ` +
|
|
44
|
+
`Migration description: ${migrationPlan.description || 'No description provided'}.`);
|
|
38
45
|
}
|
|
39
46
|
currentData = { ...migratedRaw };
|
|
40
47
|
const isLastIteration = idx + 1 === actualVersionIndex;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TRawOptions } from '../common/TRawOptions';
|
|
2
|
+
import { WriteClient } from './WriteClient';
|
|
3
|
+
export declare class OpenApiClient {
|
|
4
|
+
private _writeClient;
|
|
5
|
+
get writeClient(): WriteClient;
|
|
6
|
+
private normalizeOptions;
|
|
7
|
+
private addDefaultValues;
|
|
8
|
+
private cleanOutputDirectories;
|
|
9
|
+
private generateCodeForItems;
|
|
10
|
+
private generateSingle;
|
|
11
|
+
generate(rawOptions: TRawOptions): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=OpenApiClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenApiClient.d.ts","sourceRoot":"","sources":["../../src/core/OpenApiClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,WAAW,EAAsB,MAAM,uBAAuB,CAAC;AActF,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;IAiFtB,QAAQ,CAAC,UAAU,EAAE,WAAW;CAWzC"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpenApiClient = void 0;
|
|
4
|
+
const Consts_1 = require("../common/Consts");
|
|
5
|
+
const Logger_1 = require("../common/Logger");
|
|
6
|
+
const LoggerMessages_1 = require("../common/LoggerMessages");
|
|
7
|
+
const fileSystemHelpers_1 = require("../common/utils/fileSystemHelpers");
|
|
8
|
+
const pathHelpers_1 = require("../common/utils/pathHelpers");
|
|
9
|
+
const Parser_1 = require("./api/v2/Parser");
|
|
10
|
+
const Parser_2 = require("./api/v3/Parser");
|
|
11
|
+
const Context_1 = require("./Context");
|
|
12
|
+
const getOpenApiSpec_1 = require("./utils/getOpenApiSpec");
|
|
13
|
+
const getOpenApiVersion_1 = require("./utils/getOpenApiVersion");
|
|
14
|
+
const getOutputPaths_1 = require("./utils/getOutputPaths");
|
|
15
|
+
const postProcessClient_1 = require("./utils/postProcessClient");
|
|
16
|
+
const registerHandlebarTemplates_1 = require("./utils/registerHandlebarTemplates");
|
|
17
|
+
const WriteClient_1 = require("./WriteClient");
|
|
18
|
+
class OpenApiClient {
|
|
19
|
+
_writeClient = null;
|
|
20
|
+
get writeClient() {
|
|
21
|
+
if (!this._writeClient) {
|
|
22
|
+
throw new Error('WriteClient must be initialized');
|
|
23
|
+
}
|
|
24
|
+
return this._writeClient;
|
|
25
|
+
}
|
|
26
|
+
normalizeOptions(rawOptions) {
|
|
27
|
+
if (rawOptions.items && rawOptions.items.length > 0) {
|
|
28
|
+
// Для items: Наследуем глобальный request, если не переопределён
|
|
29
|
+
return rawOptions.items.map(item => ({
|
|
30
|
+
...item,
|
|
31
|
+
request: item.request ?? rawOptions.request, // ?? для fallback на глобальный
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// Плоский формат (из CLI или старого конфига): Один item с глобальным request
|
|
36
|
+
return [rawOptions];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
addDefaultValues(item) {
|
|
40
|
+
return {
|
|
41
|
+
input: item.input || Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.input,
|
|
42
|
+
output: item.output || Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.output,
|
|
43
|
+
outputCore: item.outputCore || Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.outputCore,
|
|
44
|
+
outputServices: item.outputServices || Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.outputServices,
|
|
45
|
+
outputModels: item.outputModels || Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.outputModels,
|
|
46
|
+
outputSchemas: item.outputSchemas || Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.outputSchemas,
|
|
47
|
+
httpClient: item.httpClient || Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.httpClient,
|
|
48
|
+
useOptions: item.useOptions ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useOptions,
|
|
49
|
+
useUnionTypes: item.useUnionTypes ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useUnionTypes,
|
|
50
|
+
excludeCoreServiceFiles: item.excludeCoreServiceFiles ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.excludeCoreServiceFiles,
|
|
51
|
+
includeSchemasFiles: item.includeSchemasFiles ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.includeSchemasFiles,
|
|
52
|
+
request: item.request || Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.request,
|
|
53
|
+
interfacePrefix: item.interfacePrefix || Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.interfacePrefix,
|
|
54
|
+
enumPrefix: item.enumPrefix || Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.enumPrefix,
|
|
55
|
+
typePrefix: item.typePrefix || Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.typePrefix,
|
|
56
|
+
useCancelableRequest: item.useCancelableRequest ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useCancelableRequest,
|
|
57
|
+
logLevel: item.logLevel || Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.logLevel,
|
|
58
|
+
logTarget: item.logTarget || Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.logTarget,
|
|
59
|
+
sortByRequired: item.sortByRequired ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.sortByRequired,
|
|
60
|
+
useSeparatedIndexes: item.useSeparatedIndexes ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.useSeparatedIndexes,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async cleanOutputDirectories(option) {
|
|
64
|
+
const outputDirs = [option.output, option.outputCore, option.outputSchemas, option.outputModels, option.outputServices];
|
|
65
|
+
for (const dir of outputDirs) {
|
|
66
|
+
if (dir) {
|
|
67
|
+
await fileSystemHelpers_1.fileSystemHelpers.rmdir(dir);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async generateCodeForItems(items) {
|
|
72
|
+
if (items.length === 0) {
|
|
73
|
+
throw new Error(LoggerMessages_1.LOGGER_MESSAGES.GENERATION.NO_OPTIONS);
|
|
74
|
+
}
|
|
75
|
+
this.writeClient.logger.forceInfo(LoggerMessages_1.LOGGER_MESSAGES.GENERATION.STARTED(items.length));
|
|
76
|
+
try {
|
|
77
|
+
const start = process.hrtime();
|
|
78
|
+
for (const option of items) {
|
|
79
|
+
await this.cleanOutputDirectories(option);
|
|
80
|
+
}
|
|
81
|
+
for (const option of items) {
|
|
82
|
+
const fileStart = process.hrtime();
|
|
83
|
+
await this.generateSingle(option);
|
|
84
|
+
const [fileSeconds, fileNanoseconds] = process.hrtime(fileStart);
|
|
85
|
+
const fileDuration = fileSeconds + fileNanoseconds / 1e6;
|
|
86
|
+
this.writeClient.logger.info(LoggerMessages_1.LOGGER_MESSAGES.GENERATION.DURATION_FOR_FILE(option.input, fileDuration.toFixed(2)));
|
|
87
|
+
}
|
|
88
|
+
if (items[0]?.useSeparatedIndexes) {
|
|
89
|
+
await this.writeClient.combineAndWrightSimple();
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
await this.writeClient.combineAndWrite();
|
|
93
|
+
}
|
|
94
|
+
this.writeClient.logger.forceInfo(LoggerMessages_1.LOGGER_MESSAGES.GENERATION.FINISHED);
|
|
95
|
+
const [seconds, nanoseconds] = process.hrtime(start);
|
|
96
|
+
const durationInMs = seconds + nanoseconds / 1e6;
|
|
97
|
+
this.writeClient.logger.forceInfo(LoggerMessages_1.LOGGER_MESSAGES.GENERATION.FINISHED_WITH_DURATION(durationInMs.toFixed(2)));
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
this.writeClient.logger.error(LoggerMessages_1.LOGGER_MESSAGES.ERROR.GENERIC(error.message));
|
|
101
|
+
}
|
|
102
|
+
this.writeClient.logger.shutdownLogger();
|
|
103
|
+
}
|
|
104
|
+
async generateSingle(item) {
|
|
105
|
+
const { input, output, outputCore, outputServices, outputModels, outputSchemas, httpClient, useOptions, useUnionTypes, excludeCoreServiceFiles, includeSchemasFiles, request, interfacePrefix, enumPrefix, typePrefix, useCancelableRequest, sortByRequired, useSeparatedIndexes, } = item;
|
|
106
|
+
const outputPaths = (0, getOutputPaths_1.getOutputPaths)({
|
|
107
|
+
output,
|
|
108
|
+
outputCore,
|
|
109
|
+
outputServices,
|
|
110
|
+
outputModels,
|
|
111
|
+
outputSchemas,
|
|
112
|
+
});
|
|
113
|
+
const absoluteInput = (0, pathHelpers_1.resolveHelper)(process.cwd(), input);
|
|
114
|
+
const context = new Context_1.Context({ input: absoluteInput, output: outputPaths, prefix: { interface: interfacePrefix, enum: enumPrefix, type: typePrefix }, sortByRequired });
|
|
115
|
+
const openApi = await (0, getOpenApiSpec_1.getOpenApiSpec)(context, absoluteInput);
|
|
116
|
+
const openApiVersion = (0, getOpenApiVersion_1.getOpenApiVersion)(openApi);
|
|
117
|
+
const templates = (0, registerHandlebarTemplates_1.registerHandlebarTemplates)({
|
|
118
|
+
httpClient,
|
|
119
|
+
useUnionTypes,
|
|
120
|
+
useOptions,
|
|
121
|
+
});
|
|
122
|
+
this.writeClient.logger.info(LoggerMessages_1.LOGGER_MESSAGES.OPENAPI.DEFINING_VERSION);
|
|
123
|
+
switch (openApiVersion) {
|
|
124
|
+
case getOpenApiVersion_1.OpenApiVersion.V2: {
|
|
125
|
+
const client = new Parser_1.Parser(context).parse(openApi);
|
|
126
|
+
const clientFinal = (0, postProcessClient_1.postProcessClient)(client);
|
|
127
|
+
this.writeClient.logger.info(LoggerMessages_1.LOGGER_MESSAGES.OPENAPI.WRITING_V2);
|
|
128
|
+
await this.writeClient.writeClient({
|
|
129
|
+
client: clientFinal,
|
|
130
|
+
templates,
|
|
131
|
+
outputPaths,
|
|
132
|
+
httpClient,
|
|
133
|
+
useOptions,
|
|
134
|
+
useUnionTypes,
|
|
135
|
+
excludeCoreServiceFiles,
|
|
136
|
+
includeSchemasFiles,
|
|
137
|
+
request,
|
|
138
|
+
useCancelableRequest,
|
|
139
|
+
useSeparatedIndexes,
|
|
140
|
+
});
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
case getOpenApiVersion_1.OpenApiVersion.V3: {
|
|
144
|
+
const client = new Parser_2.Parser(context).parse(openApi);
|
|
145
|
+
const clientFinal = (0, postProcessClient_1.postProcessClient)(client);
|
|
146
|
+
this.writeClient.logger.info(LoggerMessages_1.LOGGER_MESSAGES.OPENAPI.WRITING_V3);
|
|
147
|
+
await this.writeClient.writeClient({
|
|
148
|
+
client: clientFinal,
|
|
149
|
+
templates,
|
|
150
|
+
outputPaths,
|
|
151
|
+
httpClient,
|
|
152
|
+
useOptions,
|
|
153
|
+
useUnionTypes,
|
|
154
|
+
excludeCoreServiceFiles,
|
|
155
|
+
includeSchemasFiles,
|
|
156
|
+
request,
|
|
157
|
+
useCancelableRequest,
|
|
158
|
+
useSeparatedIndexes,
|
|
159
|
+
});
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async generate(rawOptions) {
|
|
165
|
+
const logger = new Logger_1.Logger({
|
|
166
|
+
level: rawOptions.logLevel ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.logLevel,
|
|
167
|
+
instanceId: 'client',
|
|
168
|
+
logOutput: rawOptions.logTarget ?? Consts_1.COMMON_DEFAULT_OPTIONS_VALUES.logTarget,
|
|
169
|
+
});
|
|
170
|
+
this._writeClient = new WriteClient_1.WriteClient(logger);
|
|
171
|
+
const items = this.normalizeOptions(rawOptions).map(item => this.addDefaultValues(item));
|
|
172
|
+
await this.generateCodeForItems(items);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.OpenApiClient = OpenApiClient;
|
|
@@ -46,7 +46,7 @@ type TAPIClientGeneratorConfig = Omit<TWriteClientProps, 'httpClient' | 'useOpti
|
|
|
46
46
|
export declare class WriteClient {
|
|
47
47
|
private config;
|
|
48
48
|
private _logger;
|
|
49
|
-
constructor();
|
|
49
|
+
constructor(logger?: Logger);
|
|
50
50
|
/**
|
|
51
51
|
* Write our OpenAPI client, using the given templates at the given output
|
|
52
52
|
* @param client Client object with all the models, services, etc.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WriteClient.d.ts","sourceRoot":"","sources":["../../src/core/WriteClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAM1C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAG/D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE;;;;;;;;;;;;GAYG;AACH,KAAK,iBAAiB,GAAG;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,uBAAuB,EAAE,OAAO,CAAC;IACjC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,KAAK,yBAAyB,GAAG,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,YAAY,GAAG,SAAS,GAAG,sBAAsB,GAAG,qBAAqB,CAAC,CAAC;AAEnJ;;GAEG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAAuD;IACrE,OAAO,CAAC,OAAO,CAAS
|
|
1
|
+
{"version":3,"file":"WriteClient.d.ts","sourceRoot":"","sources":["../../src/core/WriteClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAM1C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAG/D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE;;;;;;;;;;;;GAYG;AACH,KAAK,iBAAiB,GAAG;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,uBAAuB,EAAE,OAAO,CAAC;IACjC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,KAAK,yBAAyB,GAAG,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,YAAY,GAAG,SAAS,GAAG,sBAAsB,GAAG,qBAAqB,CAAC,CAAC;AAEnJ;;GAEG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAAuD;IACrE,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,CAAC,EAAE,MAAM;IAQ3B;;;;;;;;;;;;OAYG;IACG,WAAW,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IA2F5D;;;OAGG;IACH,6BAA6B,CAAC,MAAM,EAAE,yBAAyB;IAUzD,eAAe;IAKf,sBAAsB;IAK5B,IAAW,MAAM,WAEhB;IAED,OAAO,CAAC,yBAAyB;IAyCjC,OAAO,CAAC,mBAAmB;YA4Db,gBAAgB;YAUhB,uBAAuB;IAMrC,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,uBAAuB;IAe/B,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,aAAa;IAId,eAAe,yBAAmB;IAClC,oBAAoB,8BAAwB;IAC5C,oBAAoB,8BAAwB;IAC5C,iBAAiB,2BAAqB;IACtC,sBAAsB,gCAA0B;IAChD,kBAAkB,4BAAsB;IACxC,uBAAuB,iCAA2B;IAClD,mBAAmB,6BAAuB;IAC1C,wBAAwB,kCAA4B;IACpD,sBAAsB,gCAA0B;CAC1D"}
|
package/dist/core/WriteClient.js
CHANGED
|
@@ -24,8 +24,8 @@ const writeClientSimpleIndex_1 = require("./utils/writeClientSimpleIndex");
|
|
|
24
24
|
class WriteClient {
|
|
25
25
|
config = new Map();
|
|
26
26
|
_logger;
|
|
27
|
-
constructor() {
|
|
28
|
-
this._logger = new Logger_1.Logger({
|
|
27
|
+
constructor(logger) {
|
|
28
|
+
this._logger = logger || new Logger_1.Logger({
|
|
29
29
|
level: Enums_1.ELogLevel.ERROR,
|
|
30
30
|
instanceId: 'client',
|
|
31
31
|
logOutput: Enums_1.ELogOutput.CONSOLE,
|
|
@@ -51,6 +51,8 @@ const WriteClient_1 = require("../WriteClient");
|
|
|
51
51
|
request: () => 'request',
|
|
52
52
|
cancelablePromise: () => 'cancelablePromise',
|
|
53
53
|
httpStatusCode: () => 'httpStatusCode',
|
|
54
|
+
legacyRequestAdapter: () => 'legacyRequestAdapter',
|
|
55
|
+
requestExecutor: () => 'requestExecutor',
|
|
54
56
|
},
|
|
55
57
|
};
|
|
56
58
|
const outputPaths = (0, getOutputPaths_1.getOutputPaths)({ output: './dist' });
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TRawOptions } from '../common/TRawOptions';
|
|
2
2
|
export { HttpClient } from './types/enums/HttpClient.enum';
|
|
3
|
-
|
|
4
|
-
* @throws {Error} If options validation fails or generation encounters an error
|
|
5
|
-
* @returns {Promise<void>}
|
|
6
|
-
*/
|
|
7
|
-
export declare function generate(options: TOptions | TOptions[] | TMultiOptions): Promise<void>;
|
|
3
|
+
export declare function generate(rawOptions: TRawOptions): Promise<void>;
|
|
8
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,wBAAsB,QAAQ,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAGrE"}
|