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

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 (177) hide show
  1. package/README.md +145 -55
  2. package/README.rus.md +144 -54
  3. package/dist/cli/index.js +2 -1
  4. package/dist/common/Consts.d.ts.map +1 -1
  5. package/dist/common/Consts.js +2 -1
  6. package/dist/common/TRawOptions.d.ts +2 -1
  7. package/dist/common/TRawOptions.d.ts.map +1 -1
  8. package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -1
  9. package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +8 -0
  10. package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts.map +1 -1
  11. package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.js +7 -1
  12. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts.map +1 -0
  13. package/dist/common/VersionedSchema/{UnifiedOptionsVersioned → AllVersionedSchemas}/UnifiedOptionsSchemaV1.js +2 -2
  14. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts +7 -0
  15. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts.map +1 -0
  16. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.js +42 -0
  17. package/dist/common/VersionedSchema/CommonSchemas.d.ts +1 -0
  18. package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
  19. package/dist/common/VersionedSchema/CommonSchemas.js +8 -1
  20. package/dist/common/defaultOptions.d.ts.map +1 -1
  21. package/dist/common/defaultOptions.js +2 -1
  22. package/dist/common/utils/__tests__/convertArrayToObject.test.js +5 -6
  23. package/dist/common/utils/convertArrayToObject.d.ts.map +1 -1
  24. package/dist/common/utils/convertArrayToObject.js +1 -2
  25. package/dist/core/OpenApiClient.d.ts.map +1 -1
  26. package/dist/core/OpenApiClient.js +6 -4
  27. package/dist/core/WriteClient.d.ts +3 -12
  28. package/dist/core/WriteClient.d.ts.map +1 -1
  29. package/dist/core/WriteClient.js +20 -22
  30. package/dist/core/__tests__/WriteClient.test.js +8 -1
  31. package/dist/core/types/enums/ValidationLibrary.enum.d.ts +8 -0
  32. package/dist/core/types/enums/ValidationLibrary.enum.d.ts.map +1 -0
  33. package/dist/core/types/enums/ValidationLibrary.enum.js +11 -0
  34. package/dist/core/utils/__mocks__/templates.d.ts +3 -0
  35. package/dist/core/utils/__mocks__/templates.d.ts.map +1 -0
  36. package/dist/core/utils/__mocks__/templates.js +33 -0
  37. package/dist/core/utils/__tests__/writeClientCore.test.js +2 -25
  38. package/dist/core/utils/__tests__/writeClientFullIndex.test.js +2 -25
  39. package/dist/core/utils/__tests__/writeClientModels.test.js +2 -25
  40. package/dist/core/utils/__tests__/writeClientSchemas.test.js +4 -25
  41. package/dist/core/utils/__tests__/writeClientServices.test.js +2 -25
  42. package/dist/core/utils/precompileTemplates.js +6 -0
  43. package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
  44. package/dist/core/utils/registerHandlebarHelpers.js +74 -0
  45. package/dist/core/utils/registerHandlebarTemplates.d.ts +8 -0
  46. package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
  47. package/dist/core/utils/registerHandlebarTemplates.js +88 -0
  48. package/dist/core/utils/writeClientCore.d.ts.map +1 -1
  49. package/dist/core/utils/writeClientCore.js +3 -0
  50. package/dist/core/utils/writeClientSchemas.d.ts +2 -0
  51. package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
  52. package/dist/core/utils/writeClientSchemas.js +14 -2
  53. package/dist/templatesCompiled/client/core/legacy-request-adapter.d.ts +8 -0
  54. package/dist/templatesCompiled/client/core/legacy-request-adapter.d.ts.map +1 -0
  55. package/dist/templatesCompiled/client/core/legacy-request-adapter.js +18 -0
  56. package/dist/templatesCompiled/client/core/request-executor.d.ts +7 -0
  57. package/dist/templatesCompiled/client/core/request-executor.d.ts.map +1 -0
  58. package/dist/templatesCompiled/client/core/request-executor.js +11 -0
  59. package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
  60. package/dist/templatesCompiled/client/exportService.js +46 -50
  61. package/dist/templatesCompiled/client/joi/exportSchema.d.ts +11 -0
  62. package/dist/templatesCompiled/client/joi/exportSchema.d.ts.map +1 -0
  63. package/dist/templatesCompiled/client/joi/exportSchema.js +71 -0
  64. package/dist/templatesCompiled/client/joi/partials/joiSchema.d.ts +22 -0
  65. package/dist/templatesCompiled/client/joi/partials/joiSchema.d.ts.map +1 -0
  66. package/dist/templatesCompiled/client/joi/partials/joiSchema.js +129 -0
  67. package/dist/templatesCompiled/client/joi/partials/joiSchemaArray.d.ts +16 -0
  68. package/dist/templatesCompiled/client/joi/partials/joiSchemaArray.d.ts.map +1 -0
  69. package/dist/templatesCompiled/client/joi/partials/joiSchemaArray.js +84 -0
  70. package/dist/templatesCompiled/client/joi/partials/joiSchemaComposition.d.ts +18 -0
  71. package/dist/templatesCompiled/client/joi/partials/joiSchemaComposition.d.ts.map +1 -0
  72. package/dist/templatesCompiled/client/joi/partials/joiSchemaComposition.js +96 -0
  73. package/dist/templatesCompiled/client/joi/partials/joiSchemaDictionary.d.ts +14 -0
  74. package/dist/templatesCompiled/client/joi/partials/joiSchemaDictionary.d.ts.map +1 -0
  75. package/dist/templatesCompiled/client/joi/partials/joiSchemaDictionary.js +72 -0
  76. package/dist/templatesCompiled/client/joi/partials/joiSchemaEnum.d.ts +14 -0
  77. package/dist/templatesCompiled/client/joi/partials/joiSchemaEnum.d.ts.map +1 -0
  78. package/dist/templatesCompiled/client/joi/partials/joiSchemaEnum.js +74 -0
  79. package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.d.ts +35 -0
  80. package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.d.ts.map +1 -0
  81. package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.js +201 -0
  82. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.d.ts +14 -0
  83. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.d.ts.map +1 -0
  84. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.js +50 -0
  85. package/dist/templatesCompiled/client/joi/partials/joiSchemaReference.d.ts +9 -0
  86. package/dist/templatesCompiled/client/joi/partials/joiSchemaReference.d.ts.map +1 -0
  87. package/dist/templatesCompiled/client/joi/partials/joiSchemaReference.js +25 -0
  88. package/dist/templatesCompiled/client/jsonschema/exportSchema.d.ts +11 -0
  89. package/dist/templatesCompiled/client/jsonschema/exportSchema.d.ts.map +1 -0
  90. package/dist/templatesCompiled/client/jsonschema/exportSchema.js +69 -0
  91. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchema.d.ts +22 -0
  92. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchema.d.ts.map +1 -0
  93. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchema.js +129 -0
  94. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaArray.d.ts +16 -0
  95. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaArray.d.ts.map +1 -0
  96. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaArray.js +74 -0
  97. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaComposition.d.ts +16 -0
  98. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaComposition.d.ts.map +1 -0
  99. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaComposition.js +84 -0
  100. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaDictionary.d.ts +13 -0
  101. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaDictionary.d.ts.map +1 -0
  102. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaDictionary.js +56 -0
  103. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaEnum.d.ts +12 -0
  104. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaEnum.d.ts.map +1 -0
  105. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaEnum.js +49 -0
  106. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaGeneric.d.ts +29 -0
  107. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaGeneric.d.ts.map +1 -0
  108. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaGeneric.js +175 -0
  109. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts +15 -0
  110. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts.map +1 -0
  111. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.js +63 -0
  112. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaReference.d.ts +9 -0
  113. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaReference.d.ts.map +1 -0
  114. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaReference.js +25 -0
  115. package/dist/templatesCompiled/client/yup/exportSchema.d.ts +11 -0
  116. package/dist/templatesCompiled/client/yup/exportSchema.d.ts.map +1 -0
  117. package/dist/templatesCompiled/client/yup/exportSchema.js +73 -0
  118. package/dist/templatesCompiled/client/yup/partials/yupSchema.d.ts +22 -0
  119. package/dist/templatesCompiled/client/yup/partials/yupSchema.d.ts.map +1 -0
  120. package/dist/templatesCompiled/client/yup/partials/yupSchema.js +129 -0
  121. package/dist/templatesCompiled/client/yup/partials/yupSchemaArray.d.ts +16 -0
  122. package/dist/templatesCompiled/client/yup/partials/yupSchemaArray.d.ts.map +1 -0
  123. package/dist/templatesCompiled/client/yup/partials/yupSchemaArray.js +84 -0
  124. package/dist/templatesCompiled/client/yup/partials/yupSchemaComposition.d.ts +18 -0
  125. package/dist/templatesCompiled/client/yup/partials/yupSchemaComposition.d.ts.map +1 -0
  126. package/dist/templatesCompiled/client/yup/partials/yupSchemaComposition.js +96 -0
  127. package/dist/templatesCompiled/client/yup/partials/yupSchemaDictionary.d.ts +14 -0
  128. package/dist/templatesCompiled/client/yup/partials/yupSchemaDictionary.d.ts.map +1 -0
  129. package/dist/templatesCompiled/client/yup/partials/yupSchemaDictionary.js +72 -0
  130. package/dist/templatesCompiled/client/yup/partials/yupSchemaEnum.d.ts +14 -0
  131. package/dist/templatesCompiled/client/yup/partials/yupSchemaEnum.d.ts.map +1 -0
  132. package/dist/templatesCompiled/client/yup/partials/yupSchemaEnum.js +74 -0
  133. package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.d.ts +34 -0
  134. package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.d.ts.map +1 -0
  135. package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.js +201 -0
  136. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.d.ts +14 -0
  137. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.d.ts.map +1 -0
  138. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.js +50 -0
  139. package/dist/templatesCompiled/client/yup/partials/yupSchemaReference.d.ts +9 -0
  140. package/dist/templatesCompiled/client/yup/partials/yupSchemaReference.d.ts.map +1 -0
  141. package/dist/templatesCompiled/client/yup/partials/yupSchemaReference.js +25 -0
  142. package/dist/templatesCompiled/client/zod/exportSchema.d.ts +11 -0
  143. package/dist/templatesCompiled/client/zod/exportSchema.d.ts.map +1 -0
  144. package/dist/templatesCompiled/client/zod/exportSchema.js +67 -0
  145. package/dist/templatesCompiled/client/zod/partials/zodSchema.d.ts +22 -0
  146. package/dist/templatesCompiled/client/zod/partials/zodSchema.d.ts.map +1 -0
  147. package/dist/templatesCompiled/client/zod/partials/zodSchema.js +129 -0
  148. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts +14 -0
  149. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts.map +1 -0
  150. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.js +65 -0
  151. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts +15 -0
  152. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts.map +1 -0
  153. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.js +70 -0
  154. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts +12 -0
  155. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts.map +1 -0
  156. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.js +53 -0
  157. package/dist/templatesCompiled/client/zod/partials/zodSchemaEnum.d.ts +15 -0
  158. package/dist/templatesCompiled/client/zod/partials/zodSchemaEnum.d.ts.map +1 -0
  159. package/dist/templatesCompiled/client/zod/partials/zodSchemaEnum.js +86 -0
  160. package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.d.ts +34 -0
  161. package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.d.ts.map +1 -0
  162. package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.js +193 -0
  163. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts +14 -0
  164. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts.map +1 -0
  165. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.js +50 -0
  166. package/dist/templatesCompiled/client/zod/partials/zodSchemaReference.d.ts +9 -0
  167. package/dist/templatesCompiled/client/zod/partials/zodSchemaReference.d.ts.map +1 -0
  168. package/dist/templatesCompiled/client/zod/partials/zodSchemaReference.js +25 -0
  169. package/package.json +12 -3
  170. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.d.ts +0 -3
  171. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.d.ts.map +0 -1
  172. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.js +0 -28
  173. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsSchemaV1.d.ts.map +0 -1
  174. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.d.ts +0 -3
  175. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.d.ts.map +0 -1
  176. package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.js +0 -10
  177. /package/dist/common/VersionedSchema/{UnifiedOptionsVersioned → AllVersionedSchemas}/UnifiedOptionsSchemaV1.d.ts +0 -0
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.templates = void 0;
4
+ exports.templates = {
5
+ indexes: {
6
+ full: () => 'fullIndex',
7
+ simple: () => 'simpleIndex',
8
+ core: () => 'coreIndex',
9
+ models: () => 'modelsIndex',
10
+ schemas: () => 'schemasIndex',
11
+ services: () => 'servicesIndex',
12
+ },
13
+ exports: {
14
+ model: () => 'model',
15
+ schema: () => 'schema',
16
+ zodSchema: () => 'zodSchema',
17
+ yupSchema: () => 'yupSchema',
18
+ joiSchema: () => 'joiSchema',
19
+ jsonSchemaSchema: () => 'jsonSchemaSchema',
20
+ service: () => 'service',
21
+ },
22
+ core: {
23
+ settings: () => 'settings',
24
+ apiError: () => 'apiError',
25
+ apiRequestOptions: () => 'apiRequestOptions',
26
+ apiResult: () => 'apiResult',
27
+ request: () => 'request',
28
+ cancelablePromise: () => 'cancelablePromise',
29
+ httpStatusCode: () => 'httpStatusCode',
30
+ legacyRequestAdapter: () => 'legacyRequestAdapter',
31
+ requestExecutor: () => 'requestExecutor',
32
+ },
33
+ };
@@ -8,6 +8,7 @@ const node_test_1 = require("node:test");
8
8
  const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
9
9
  const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
10
10
  const WriteClient_1 = require("../../WriteClient");
11
+ const templates_1 = require("../__mocks__/templates");
11
12
  (0, node_test_1.describe)('@unit: writeClientCore', () => {
12
13
  (0, node_test_1.test)('writes to filesystem', async () => {
13
14
  const writeFileCalls = [];
@@ -22,33 +23,9 @@ const WriteClient_1 = require("../../WriteClient");
22
23
  models: [],
23
24
  services: [],
24
25
  };
25
- const templates = {
26
- indexes: {
27
- full: () => 'fullIndex',
28
- simple: () => 'simpleIndex',
29
- core: () => 'coreIndex',
30
- models: () => 'modelsIndex',
31
- schemas: () => 'schemasIndex',
32
- services: () => 'servicesIndex',
33
- },
34
- exports: {
35
- model: () => 'model',
36
- schema: () => 'schema',
37
- service: () => 'service',
38
- },
39
- core: {
40
- settings: () => 'settings',
41
- apiError: () => 'apiError',
42
- apiRequestOptions: () => 'apiRequestOptions',
43
- apiResult: () => 'apiResult',
44
- request: () => 'request',
45
- cancelablePromise: () => 'cancelablePromise',
46
- httpStatusCode: () => 'httpStatusCode',
47
- },
48
- };
49
26
  const useCancelableRequest = true;
50
27
  const writeClient = new WriteClient_1.WriteClient();
51
- await writeClient.writeClientCore({ client, templates, outputCorePath: '/', httpClient: HttpClient_enum_1.HttpClient.FETCH, useCancelableRequest });
28
+ await writeClient.writeClientCore({ client, templates: templates_1.templates, outputCorePath: '/', httpClient: HttpClient_enum_1.HttpClient.FETCH, useCancelableRequest });
52
29
  node_assert_1.default.ok(writeFileCalls.some(([filePath, content]) => filePath.toString().includes('OpenAPI.ts') && content.toString().includes('settings')), 'Expected writeFile to be called with settings content for OpenAPI.ts');
53
30
  node_assert_1.default.ok(writeFileCalls.some(([filePath, content]) => filePath.toString().includes('ApiError.ts') && content.toString().includes('apiError')), 'Expected writeFile to be called with apiError content for ApiError.ts');
54
31
  node_assert_1.default.ok(writeFileCalls.some(([filePath, content]) => filePath.toString().includes('ApiRequestOptions.ts') && content.toString().includes('apiRequestOptions')), 'Expected writeFile to be called with apiRequestOptions content for ApiRequestOptions.ts');
@@ -7,6 +7,7 @@ const node_assert_1 = __importDefault(require("node:assert"));
7
7
  const node_test_1 = require("node:test");
8
8
  const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
9
9
  const WriteClient_1 = require("../../WriteClient");
10
+ const templates_1 = require("../__mocks__/templates");
10
11
  (0, node_test_1.describe)('@unit: writeClientFullIndex', () => {
11
12
  (0, node_test_1.test)('writes to filesystem', async () => {
12
13
  const writeFileCalls = [];
@@ -15,32 +16,8 @@ const WriteClient_1 = require("../../WriteClient");
15
16
  fileSystemHelpers_1.fileSystemHelpers.writeFile = async (path, content) => {
16
17
  writeFileCalls.push([path, content]);
17
18
  };
18
- const templates = {
19
- indexes: {
20
- full: () => 'fullIndex',
21
- simple: () => 'simpleIndex',
22
- core: () => 'coreIndex',
23
- models: () => 'modelsIndex',
24
- schemas: () => 'schemasIndex',
25
- services: () => 'servicesIndex',
26
- },
27
- exports: {
28
- model: () => 'model',
29
- schema: () => 'schema',
30
- service: () => 'service',
31
- },
32
- core: {
33
- settings: () => 'settings',
34
- apiError: () => 'apiError',
35
- apiRequestOptions: () => 'apiRequestOptions',
36
- apiResult: () => 'apiResult',
37
- request: () => 'request',
38
- cancelablePromise: () => 'cancelablePromise',
39
- httpStatusCode: () => 'httpStatusCode',
40
- },
41
- };
42
19
  const writeClient = new WriteClient_1.WriteClient();
43
- await writeClient.writeClientFullIndex({ templates, outputPath: '/', core: [], models: [], schemas: [], services: [] });
20
+ await writeClient.writeClientFullIndex({ templates: templates_1.templates, outputPath: '/', core: [], models: [], schemas: [], services: [] });
44
21
  node_assert_1.default.ok(writeFileCalls.some(([filePath, content]) => filePath.toString().includes('index.ts') && content.toString().includes('fullIndex')), 'Expected writeFile to be called with index content for index.ts');
45
22
  // Restoring the original function
46
23
  fileSystemHelpers_1.fileSystemHelpers.writeFile = originalWriteFile;
@@ -8,6 +8,7 @@ const node_test_1 = require("node:test");
8
8
  const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
9
9
  const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
10
10
  const WriteClient_1 = require("../../WriteClient");
11
+ const templates_1 = require("../__mocks__/templates");
11
12
  (0, node_test_1.describe)('@unit: writeClientModels', () => {
12
13
  (0, node_test_1.test)('writes to filesystem', async () => {
13
14
  const writeFileCalls = [];
@@ -37,34 +38,10 @@ const WriteClient_1 = require("../../WriteClient");
37
38
  alias: '',
38
39
  },
39
40
  ];
40
- const templates = {
41
- indexes: {
42
- full: () => 'fullIndex',
43
- simple: () => 'simpleIndex',
44
- core: () => 'coreIndex',
45
- models: () => 'modelsIndex',
46
- schemas: () => 'schemasIndex',
47
- services: () => 'servicesIndex',
48
- },
49
- exports: {
50
- model: () => 'model',
51
- schema: () => 'schema',
52
- service: () => 'service',
53
- },
54
- core: {
55
- settings: () => 'settings',
56
- apiError: () => 'apiError',
57
- apiRequestOptions: () => 'apiRequestOptions',
58
- apiResult: () => 'apiResult',
59
- request: () => 'request',
60
- cancelablePromise: () => 'cancelablePromise',
61
- httpStatusCode: () => 'httpStatusCode',
62
- },
63
- };
64
41
  const writeClient = new WriteClient_1.WriteClient();
65
42
  await writeClient.writeClientModels({
66
43
  models,
67
- templates,
44
+ templates: templates_1.templates,
68
45
  outputModelsPath: '/',
69
46
  httpClient: HttpClient_enum_1.HttpClient.FETCH,
70
47
  useUnionTypes: false,
@@ -7,7 +7,9 @@ const node_assert_1 = __importDefault(require("node:assert"));
7
7
  const node_test_1 = require("node:test");
8
8
  const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
9
9
  const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
10
+ const ValidationLibrary_enum_1 = require("../../types/enums/ValidationLibrary.enum");
10
11
  const WriteClient_1 = require("../../WriteClient");
12
+ const templates_1 = require("../__mocks__/templates");
11
13
  (0, node_test_1.describe)('@unit: writeClientSchemas', () => {
12
14
  (0, node_test_1.test)('writes to filesystem', async () => {
13
15
  const writeFileCalls = [];
@@ -37,37 +39,14 @@ const WriteClient_1 = require("../../WriteClient");
37
39
  properties: [],
38
40
  },
39
41
  ];
40
- const templates = {
41
- indexes: {
42
- full: () => 'fullIndex',
43
- simple: () => 'simpleIndex',
44
- core: () => 'coreIndex',
45
- models: () => 'modelsIndex',
46
- schemas: () => 'schemasIndex',
47
- services: () => 'servicesIndex',
48
- },
49
- exports: {
50
- model: () => 'model',
51
- schema: () => 'schema',
52
- service: () => 'service',
53
- },
54
- core: {
55
- settings: () => 'settings',
56
- apiError: () => 'apiError',
57
- apiRequestOptions: () => 'apiRequestOptions',
58
- apiResult: () => 'apiResult',
59
- request: () => 'request',
60
- cancelablePromise: () => 'cancelablePromise',
61
- httpStatusCode: () => 'httpStatusCode',
62
- },
63
- };
64
42
  const writeClient = new WriteClient_1.WriteClient();
65
43
  await writeClient.writeClientSchemas({
66
44
  models,
67
- templates,
45
+ templates: templates_1.templates,
68
46
  outputSchemasPath: '/',
69
47
  httpClient: HttpClient_enum_1.HttpClient.FETCH,
70
48
  useUnionTypes: false,
49
+ validationLibrary: ValidationLibrary_enum_1.ValidationLibrary.NONE,
71
50
  });
72
51
  node_assert_1.default.ok(writeFileCalls.some(([filePath, content]) => filePath.toString().includes('MyModelSchema.ts') && content.toString().includes('schema')), 'Expected writeFile to be called with schema content for MyModelSchema.ts');
73
52
  // Restoring the original function
@@ -8,6 +8,7 @@ const node_test_1 = require("node:test");
8
8
  const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
9
9
  const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
10
10
  const WriteClient_1 = require("../../WriteClient");
11
+ const templates_1 = require("../__mocks__/templates");
11
12
  (0, node_test_1.describe)('@unit: writeClientServices', () => {
12
13
  (0, node_test_1.test)('writes to filesystem', async () => {
13
14
  const writeFileCalls = [];
@@ -24,34 +25,10 @@ const WriteClient_1 = require("../../WriteClient");
24
25
  imports: [],
25
26
  },
26
27
  ];
27
- const templates = {
28
- indexes: {
29
- full: () => 'fullIndex',
30
- simple: () => 'simpleIndex',
31
- core: () => 'coreIndex',
32
- models: () => 'modelsIndex',
33
- schemas: () => 'schemasIndex',
34
- services: () => 'servicesIndex',
35
- },
36
- exports: {
37
- model: () => 'model',
38
- schema: () => 'schema',
39
- service: () => 'service',
40
- },
41
- core: {
42
- settings: () => 'settings',
43
- apiError: () => 'apiError',
44
- apiRequestOptions: () => 'apiRequestOptions',
45
- apiResult: () => 'apiResult',
46
- request: () => 'request',
47
- cancelablePromise: () => 'cancelablePromise',
48
- httpStatusCode: () => 'httpStatusCode',
49
- },
50
- };
51
28
  const writeClient = new WriteClient_1.WriteClient();
52
29
  await writeClient.writeClientServices({
53
30
  services,
54
- templates,
31
+ templates: templates_1.templates,
55
32
  outputPaths: {
56
33
  outputCore: '/',
57
34
  outputModels: '/',
@@ -62,6 +62,12 @@ const precompileTemplates = () => {
62
62
  containsSystemName: true,
63
63
  normalizePath: true,
64
64
  joinPath: true,
65
+ isNumericEnum: true,
66
+ isBasicType: true,
67
+ yupBaseSchema: true,
68
+ joiBaseSchema: true,
69
+ getRequiredFields: true,
70
+ getEnumType: true,
65
71
  },
66
72
  });
67
73
  const tsContent = header + precompiled;
@@ -1 +1 @@
1
- {"version":3,"file":"registerHandlebarHelpers.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarHelpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAK5D,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CA+E5H"}
1
+ {"version":3,"file":"registerHandlebarHelpers.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarHelpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAK5D,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CA6J5H"}
@@ -104,4 +104,78 @@ function registerHandlebarHelpers(root) {
104
104
  const cleanedSecondPath = secondPath.startsWith('./') ? secondPath.slice(2) : secondPath;
105
105
  return `${cleanedFirstPath}/${cleanedSecondPath}`.replace(Consts_1.REGEX_BACKSLASH, '/').replace(Consts_1.REGEX_MULTIPLE_SLASHES, '/');
106
106
  });
107
+ Handlebars.registerHelper('isNumericEnum', function (enumerators, options) {
108
+ if (!enumerators || enumerators.length === 0) {
109
+ return options.inverse(this);
110
+ }
111
+ const firstEnum = enumerators[0];
112
+ return firstEnum.type === 'number' ? options.fn(this) : options.inverse(this);
113
+ });
114
+ Handlebars.registerHelper('isBasicType', function (link) {
115
+ if (!link)
116
+ return false;
117
+ // Если есть imports, это реальная схема, а не базовый тип
118
+ if (link.imports && link.imports.length > 0)
119
+ return false;
120
+ // Если есть path и это не базовый тип, это схема
121
+ if (link.path && link.path !== link.base?.toLowerCase())
122
+ return false;
123
+ // Проверяем, является ли base базовым типом
124
+ const basicTypes = ['string', 'number', 'integer', 'int', 'boolean', 'file', 'File', 'any', 'null'];
125
+ return basicTypes.includes(link.base);
126
+ });
127
+ Handlebars.registerHelper('yupBaseSchema', function (base) {
128
+ if (!base)
129
+ return 'yup.mixed()';
130
+ const baseLower = base.toLowerCase();
131
+ switch (baseLower) {
132
+ case 'string':
133
+ return 'yup.string()';
134
+ case 'number':
135
+ return 'yup.number()';
136
+ case 'integer':
137
+ case 'int':
138
+ return 'yup.number().integer()';
139
+ case 'boolean':
140
+ return 'yup.boolean()';
141
+ case 'file':
142
+ return 'yup.mixed()';
143
+ default:
144
+ return 'yup.mixed()';
145
+ }
146
+ });
147
+ Handlebars.registerHelper('joiBaseSchema', function (base) {
148
+ if (!base)
149
+ return 'Joi.any()';
150
+ const baseLower = base.toLowerCase();
151
+ switch (baseLower) {
152
+ case 'string':
153
+ return 'Joi.string()';
154
+ case 'number':
155
+ return 'Joi.number()';
156
+ case 'integer':
157
+ case 'int':
158
+ return 'Joi.number().integer()';
159
+ case 'boolean':
160
+ return 'Joi.boolean()';
161
+ case 'file':
162
+ return 'Joi.any()';
163
+ default:
164
+ return 'Joi.any()';
165
+ }
166
+ });
167
+ Handlebars.registerHelper('getRequiredFields', function (properties) {
168
+ const required = properties
169
+ .filter(prop => prop.isRequired)
170
+ .map(prop => `'${prop.name}'`)
171
+ .join(', ');
172
+ return required ? `required: [${required}],` : '';
173
+ });
174
+ Handlebars.registerHelper('getEnumType', function (enumerators) {
175
+ if (!enumerators || enumerators.length === 0) {
176
+ return 'string';
177
+ }
178
+ const firstEnum = enumerators[0];
179
+ return firstEnum.type === 'number' ? 'number' : 'string';
180
+ });
107
181
  }
@@ -1,5 +1,6 @@
1
1
  import * as Handlebars from 'handlebars/runtime';
2
2
  import { HttpClient } from '../types/enums/HttpClient.enum';
3
+ import { ValidationLibrary } from '../types/enums/ValidationLibrary.enum';
3
4
  export interface Templates {
4
5
  indexes: {
5
6
  full: Handlebars.TemplateDelegate;
@@ -12,6 +13,10 @@ export interface Templates {
12
13
  exports: {
13
14
  model: Handlebars.TemplateDelegate;
14
15
  schema: Handlebars.TemplateDelegate;
16
+ zodSchema: Handlebars.TemplateDelegate;
17
+ yupSchema: Handlebars.TemplateDelegate;
18
+ joiSchema: Handlebars.TemplateDelegate;
19
+ jsonSchemaSchema: Handlebars.TemplateDelegate;
15
20
  service: Handlebars.TemplateDelegate;
16
21
  };
17
22
  core: {
@@ -22,6 +27,8 @@ export interface Templates {
22
27
  request: Handlebars.TemplateDelegate;
23
28
  cancelablePromise: Handlebars.TemplateDelegate;
24
29
  httpStatusCode: Handlebars.TemplateDelegate;
30
+ requestExecutor: Handlebars.TemplateDelegate;
31
+ legacyRequestAdapter: Handlebars.TemplateDelegate;
25
32
  };
26
33
  }
27
34
  /**
@@ -32,5 +39,6 @@ export declare function registerHandlebarTemplates(root: {
32
39
  httpClient: HttpClient;
33
40
  useOptions: boolean;
34
41
  useUnionTypes: boolean;
42
+ validationLibrary?: ValidationLibrary;
35
43
  }): Templates;
36
44
  //# sourceMappingURL=registerHandlebarTemplates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"registerHandlebarTemplates.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarTemplates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAuFjD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAE5D,MAAM,WAAW,SAAS;IACtB,OAAO,EAAE;QACL,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAClC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAClC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACrC,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACzC,CAAA;IACD,OAAO,EAAE;QACL,KAAK,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACnC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACxC,CAAC;IACF,IAAI,EAAE;QACF,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACtC,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACtC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC/C,SAAS,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACvC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACrC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC/C,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC;KAC/C,CAAC;CACL;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CA4GnI"}
1
+ {"version":3,"file":"registerHandlebarTemplates.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarTemplates.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAyFjD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AA0C1E,MAAM,WAAW,SAAS;IACtB,OAAO,EAAE;QACL,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAClC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAClC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACrC,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACzC,CAAC;IACF,OAAO,EAAE;QACL,KAAK,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACnC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,SAAS,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACvC,SAAS,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACvC,SAAS,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACvC,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,CAAA;QAC7C,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACxC,CAAC;IACF,IAAI,EAAE;QACF,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACtC,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACtC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC/C,SAAS,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACvC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACrC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC/C,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC5C,eAAe,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC7C,oBAAoB,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACrD,CAAC;CACL;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAC;IAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;CAAE,GAAG,SAAS,CAiK1K"}
@@ -77,6 +77,8 @@ const sendRequest_3 = __importDefault(require("../../templatesCompiled/client/co
77
77
  const OpenAPI_1 = __importDefault(require("../../templatesCompiled/client/core/OpenAPI"));
78
78
  const CancelablePromise_1 = __importDefault(require("../../templatesCompiled/client/core/CancelablePromise"));
79
79
  const request_4 = __importDefault(require("../../templatesCompiled/client/core/request"));
80
+ const request_executor_1 = __importDefault(require("../../templatesCompiled/client/core/request-executor"));
81
+ const legacy_request_adapter_1 = __importDefault(require("../../templatesCompiled/client/core/legacy-request-adapter"));
80
82
  const getHeaders_4 = __importDefault(require("../../templatesCompiled/client/core/xhr/getHeaders"));
81
83
  const getRequestBody_4 = __importDefault(require("../../templatesCompiled/client/core/xhr/getRequestBody"));
82
84
  const getResponseBody_4 = __importDefault(require("../../templatesCompiled/client/core/xhr/getResponseBody"));
@@ -124,6 +126,43 @@ const typeIntersection_1 = __importDefault(require("../../templatesCompiled/clie
124
126
  const typeReference_1 = __importDefault(require("../../templatesCompiled/client/partials/typeReference"));
125
127
  const typeUnion_1 = __importDefault(require("../../templatesCompiled/client/partials/typeUnion"));
126
128
  const registerHandlebarHelpers_1 = require("./registerHandlebarHelpers");
129
+ const ValidationLibrary_enum_1 = require("../types/enums/ValidationLibrary.enum");
130
+ const exportSchema_2 = __importDefault(require("../../templatesCompiled/client/zod/exportSchema"));
131
+ const zodSchema_1 = __importDefault(require("../../templatesCompiled/client/zod/partials/zodSchema"));
132
+ const zodSchemaInterface_1 = __importDefault(require("../../templatesCompiled/client/zod/partials/zodSchemaInterface"));
133
+ const zodSchemaEnum_1 = __importDefault(require("../../templatesCompiled/client/zod/partials/zodSchemaEnum"));
134
+ const zodSchemaArray_1 = __importDefault(require("../../templatesCompiled/client/zod/partials/zodSchemaArray"));
135
+ const zodSchemaDictionary_1 = __importDefault(require("../../templatesCompiled/client/zod/partials/zodSchemaDictionary"));
136
+ const zodSchemaGeneric_1 = __importDefault(require("../../templatesCompiled/client/zod/partials/zodSchemaGeneric"));
137
+ const zodSchemaReference_1 = __importDefault(require("../../templatesCompiled/client/zod/partials/zodSchemaReference"));
138
+ const zodSchemaComposition_1 = __importDefault(require("../../templatesCompiled/client/zod/partials/zodSchemaComposition"));
139
+ const exportSchema_3 = __importDefault(require("../../templatesCompiled/client/yup/exportSchema"));
140
+ const yupSchema_1 = __importDefault(require("../../templatesCompiled/client/yup/partials/yupSchema"));
141
+ const yupSchemaInterface_1 = __importDefault(require("../../templatesCompiled/client/yup/partials/yupSchemaInterface"));
142
+ const yupSchemaEnum_1 = __importDefault(require("../../templatesCompiled/client/yup/partials/yupSchemaEnum"));
143
+ const yupSchemaArray_1 = __importDefault(require("../../templatesCompiled/client/yup/partials/yupSchemaArray"));
144
+ const yupSchemaDictionary_1 = __importDefault(require("../../templatesCompiled/client/yup/partials/yupSchemaDictionary"));
145
+ const yupSchemaGeneric_1 = __importDefault(require("../../templatesCompiled/client/yup/partials/yupSchemaGeneric"));
146
+ const yupSchemaReference_1 = __importDefault(require("../../templatesCompiled/client/yup/partials/yupSchemaReference"));
147
+ const yupSchemaComposition_1 = __importDefault(require("../../templatesCompiled/client/yup/partials/yupSchemaComposition"));
148
+ const exportSchema_4 = __importDefault(require("../../templatesCompiled/client/joi/exportSchema"));
149
+ const joiSchema_1 = __importDefault(require("../../templatesCompiled/client/joi/partials/joiSchema"));
150
+ const joiSchemaInterface_1 = __importDefault(require("../../templatesCompiled/client/joi/partials/joiSchemaInterface"));
151
+ const joiSchemaEnum_1 = __importDefault(require("../../templatesCompiled/client/joi/partials/joiSchemaEnum"));
152
+ const joiSchemaArray_1 = __importDefault(require("../../templatesCompiled/client/joi/partials/joiSchemaArray"));
153
+ const joiSchemaDictionary_1 = __importDefault(require("../../templatesCompiled/client/joi/partials/joiSchemaDictionary"));
154
+ const joiSchemaGeneric_1 = __importDefault(require("../../templatesCompiled/client/joi/partials/joiSchemaGeneric"));
155
+ const joiSchemaReference_1 = __importDefault(require("../../templatesCompiled/client/joi/partials/joiSchemaReference"));
156
+ const joiSchemaComposition_1 = __importDefault(require("../../templatesCompiled/client/joi/partials/joiSchemaComposition"));
157
+ const exportSchema_5 = __importDefault(require("../../templatesCompiled/client/jsonschema/exportSchema"));
158
+ const jsonschemaSchema_1 = __importDefault(require("../../templatesCompiled/client/jsonschema/partials/jsonschemaSchema"));
159
+ const jsonschemaSchemaInterface_1 = __importDefault(require("../../templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface"));
160
+ const jsonschemaSchemaEnum_1 = __importDefault(require("../../templatesCompiled/client/jsonschema/partials/jsonschemaSchemaEnum"));
161
+ const jsonschemaSchemaArray_1 = __importDefault(require("../../templatesCompiled/client/jsonschema/partials/jsonschemaSchemaArray"));
162
+ const jsonschemaSchemaDictionary_1 = __importDefault(require("../../templatesCompiled/client/jsonschema/partials/jsonschemaSchemaDictionary"));
163
+ const jsonschemaSchemaGeneric_1 = __importDefault(require("../../templatesCompiled/client/jsonschema/partials/jsonschemaSchemaGeneric"));
164
+ const jsonschemaSchemaReference_1 = __importDefault(require("../../templatesCompiled/client/jsonschema/partials/jsonschemaSchemaReference"));
165
+ const jsonschemaSchemaComposition_1 = __importDefault(require("../../templatesCompiled/client/jsonschema/partials/jsonschemaSchemaComposition"));
127
166
  /**
128
167
  * Read all the Handlebar templates that we need and return on wrapper object
129
168
  * so we can easily access the templates in out generator / write functions.
@@ -143,6 +182,10 @@ function registerHandlebarTemplates(root) {
143
182
  exports: {
144
183
  model: Handlebars.template(exportModel_1.default),
145
184
  schema: Handlebars.template(exportSchema_1.default),
185
+ zodSchema: Handlebars.template(exportSchema_2.default),
186
+ yupSchema: Handlebars.template(exportSchema_3.default),
187
+ joiSchema: Handlebars.template(exportSchema_4.default),
188
+ jsonSchemaSchema: Handlebars.template(exportSchema_5.default),
146
189
  service: Handlebars.template(exportService_1.default),
147
190
  },
148
191
  core: {
@@ -153,6 +196,8 @@ function registerHandlebarTemplates(root) {
153
196
  request: Handlebars.template(request_4.default),
154
197
  cancelablePromise: Handlebars.template(CancelablePromise_1.default),
155
198
  httpStatusCode: Handlebars.template(HttpStatusCode_1.default),
199
+ requestExecutor: Handlebars.template(request_executor_1.default),
200
+ legacyRequestAdapter: Handlebars.template(legacy_request_adapter_1.default),
156
201
  },
157
202
  };
158
203
  // Partials for the generations of the models, services, etc.
@@ -227,5 +272,48 @@ function registerHandlebarTemplates(root) {
227
272
  Handlebars.registerPartial('axios/getResponseHeader', Handlebars.template(getResponseHeader_1.default));
228
273
  Handlebars.registerPartial('axios/sendRequest', Handlebars.template(sendRequest_1.default));
229
274
  Handlebars.registerPartial('axios/request', Handlebars.template(request_1.default));
275
+ // Register Zod partials if validationLibrary is ZOD
276
+ if (root?.validationLibrary === ValidationLibrary_enum_1.ValidationLibrary.ZOD) {
277
+ Handlebars.registerPartial('zodSchema', Handlebars.template(zodSchema_1.default));
278
+ Handlebars.registerPartial('zodSchemaInterface', Handlebars.template(zodSchemaInterface_1.default));
279
+ Handlebars.registerPartial('zodSchemaEnum', Handlebars.template(zodSchemaEnum_1.default));
280
+ Handlebars.registerPartial('zodSchemaArray', Handlebars.template(zodSchemaArray_1.default));
281
+ Handlebars.registerPartial('zodSchemaDictionary', Handlebars.template(zodSchemaDictionary_1.default));
282
+ Handlebars.registerPartial('zodSchemaGeneric', Handlebars.template(zodSchemaGeneric_1.default));
283
+ Handlebars.registerPartial('zodSchemaReference', Handlebars.template(zodSchemaReference_1.default));
284
+ Handlebars.registerPartial('zodSchemaComposition', Handlebars.template(zodSchemaComposition_1.default));
285
+ }
286
+ // Register Yup partials if validationLibrary is YUP
287
+ if (root?.validationLibrary === ValidationLibrary_enum_1.ValidationLibrary.YUP) {
288
+ Handlebars.registerPartial('yupSchema', Handlebars.template(yupSchema_1.default));
289
+ Handlebars.registerPartial('yupSchemaInterface', Handlebars.template(yupSchemaInterface_1.default));
290
+ Handlebars.registerPartial('yupSchemaEnum', Handlebars.template(yupSchemaEnum_1.default));
291
+ Handlebars.registerPartial('yupSchemaArray', Handlebars.template(yupSchemaArray_1.default));
292
+ Handlebars.registerPartial('yupSchemaDictionary', Handlebars.template(yupSchemaDictionary_1.default));
293
+ Handlebars.registerPartial('yupSchemaGeneric', Handlebars.template(yupSchemaGeneric_1.default));
294
+ Handlebars.registerPartial('yupSchemaReference', Handlebars.template(yupSchemaReference_1.default));
295
+ Handlebars.registerPartial('yupSchemaComposition', Handlebars.template(yupSchemaComposition_1.default));
296
+ }
297
+ // Register Joi partials if validationLibrary is JOI
298
+ if (root?.validationLibrary === ValidationLibrary_enum_1.ValidationLibrary.JOI) {
299
+ Handlebars.registerPartial('joiSchema', Handlebars.template(joiSchema_1.default));
300
+ Handlebars.registerPartial('joiSchemaInterface', Handlebars.template(joiSchemaInterface_1.default));
301
+ Handlebars.registerPartial('joiSchemaEnum', Handlebars.template(joiSchemaEnum_1.default));
302
+ Handlebars.registerPartial('joiSchemaArray', Handlebars.template(joiSchemaArray_1.default));
303
+ Handlebars.registerPartial('joiSchemaDictionary', Handlebars.template(joiSchemaDictionary_1.default));
304
+ Handlebars.registerPartial('joiSchemaGeneric', Handlebars.template(joiSchemaGeneric_1.default));
305
+ Handlebars.registerPartial('joiSchemaReference', Handlebars.template(joiSchemaReference_1.default));
306
+ Handlebars.registerPartial('joiSchemaComposition', Handlebars.template(joiSchemaComposition_1.default));
307
+ }
308
+ if (root.validationLibrary === ValidationLibrary_enum_1.ValidationLibrary.JSONSCHEMA) {
309
+ Handlebars.registerPartial('jsonschemaSchema', Handlebars.template(jsonschemaSchema_1.default));
310
+ Handlebars.registerPartial('jsonschemaSchemaInterface', Handlebars.template(jsonschemaSchemaInterface_1.default));
311
+ Handlebars.registerPartial('jsonschemaSchemaEnum', Handlebars.template(jsonschemaSchemaEnum_1.default));
312
+ Handlebars.registerPartial('jsonschemaSchemaArray', Handlebars.template(jsonschemaSchemaArray_1.default));
313
+ Handlebars.registerPartial('jsonschemaSchemaDictionary', Handlebars.template(jsonschemaSchemaDictionary_1.default));
314
+ Handlebars.registerPartial('jsonschemaSchemaGeneric', Handlebars.template(jsonschemaSchemaGeneric_1.default));
315
+ Handlebars.registerPartial('jsonschemaSchemaReference', Handlebars.template(jsonschemaSchemaReference_1.default));
316
+ Handlebars.registerPartial('jsonschemaSchemaComposition', Handlebars.template(jsonschemaSchemaComposition_1.default));
317
+ }
230
318
  return templates;
231
319
  }
@@ -1 +1 @@
1
- {"version":3,"file":"writeClientCore.d.ts","sourceRoot":"","sources":["../../../src/core/utils/writeClientCore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD;;;;;;;GAOG;AACH,UAAU,gBAAgB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCjG"}
1
+ {"version":3,"file":"writeClientCore.d.ts","sourceRoot":"","sources":["../../../src/core/utils/writeClientCore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD;;;;;;;GAOG;AACH,UAAU,gBAAgB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCjG"}
@@ -31,6 +31,9 @@ async function writeClientCore(options) {
31
31
  }
32
32
  await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'HttpStatusCode.ts'), templates.core.httpStatusCode({}));
33
33
  await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'request.ts'), templates.core.request(context));
34
+ await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'request-executor.ts'), templates.core.requestExecutor({}));
35
+ // TODO: Добавлять только, если не выбран custom-ный request
36
+ await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'legacy-request-adapter.ts'), templates.core.legacyRequestAdapter({}));
34
37
  if (request) {
35
38
  const requestFile = (0, pathHelpers_1.resolveHelper)(process.cwd(), request);
36
39
  const requestFileExists = await fileSystemHelpers_1.fileSystemHelpers.exists(requestFile);
@@ -1,4 +1,5 @@
1
1
  import { HttpClient } from '../types/enums/HttpClient.enum';
2
+ import { ValidationLibrary } from '../types/enums/ValidationLibrary.enum';
2
3
  import type { Model } from '../types/shared/Model.model';
3
4
  import { WriteClient } from '../WriteClient';
4
5
  import { Templates } from './registerHandlebarTemplates';
@@ -15,6 +16,7 @@ interface IWriteClientSchemas {
15
16
  outputSchemasPath: string;
16
17
  httpClient: HttpClient;
17
18
  useUnionTypes: boolean;
19
+ validationLibrary?: ValidationLibrary;
18
20
  }
19
21
  /**
20
22
  * Generate Schemas using the Handlebar template and write to disk.
@@ -1 +1 @@
1
- {"version":3,"file":"writeClientSchemas.d.ts","sourceRoot":"","sources":["../../../src/core/utils/writeClientSchemas.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD;;;;;;GAMG;AACH,UAAU,mBAAmB;IACzB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BvG"}
1
+ {"version":3,"file":"writeClientSchemas.d.ts","sourceRoot":"","sources":["../../../src/core/utils/writeClientSchemas.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD;;;;;;GAMG;AACH,UAAU,mBAAmB;IACzB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4CvG"}
@@ -5,6 +5,7 @@ const fs_1 = require("fs");
5
5
  const fileSystemHelpers_1 = require("../../common/utils/fileSystemHelpers");
6
6
  const format_1 = require("../../common/utils/format");
7
7
  const pathHelpers_1 = require("../../common/utils/pathHelpers");
8
+ const ValidationLibrary_enum_1 = require("../types/enums/ValidationLibrary.enum");
8
9
  /**
9
10
  * Generate Schemas using the Handlebar template and write to disk.
10
11
  * @param models Array of Models to write
@@ -14,8 +15,18 @@ const pathHelpers_1 = require("../../common/utils/pathHelpers");
14
15
  * @param useUnionTypes Use union types instead of enums
15
16
  */
16
17
  async function writeClientSchemas(options) {
17
- const { models, templates, outputSchemasPath, httpClient, useUnionTypes } = options;
18
+ const { models, templates, outputSchemasPath, httpClient, useUnionTypes, validationLibrary } = options;
18
19
  this.logger.info('The recording of model validation schema files begins.');
20
+ // Choose template based on validation library
21
+ const schemaTemplate = validationLibrary === ValidationLibrary_enum_1.ValidationLibrary.ZOD
22
+ ? templates.exports.zodSchema
23
+ : validationLibrary === ValidationLibrary_enum_1.ValidationLibrary.YUP
24
+ ? templates.exports.yupSchema
25
+ : validationLibrary === ValidationLibrary_enum_1.ValidationLibrary.JOI
26
+ ? templates.exports.joiSchema
27
+ : validationLibrary === ValidationLibrary_enum_1.ValidationLibrary.JSONSCHEMA
28
+ ? templates.exports.jsonSchemaSchema
29
+ : templates.exports.schema;
19
30
  for (const model of models) {
20
31
  const modelFolderPath = model?.path;
21
32
  const dir = (0, pathHelpers_1.dirNameHelper)(modelFolderPath);
@@ -26,10 +37,11 @@ async function writeClientSchemas(options) {
26
37
  }
27
38
  const file = (0, pathHelpers_1.resolveHelper)(outputSchemasPath, `${modelFolderPath}Schema.ts`);
28
39
  this.logger.info(`The recording of the file data begins: ${file}`);
29
- const templateResult = templates.exports.schema({
40
+ const templateResult = schemaTemplate({
30
41
  ...model,
31
42
  httpClient,
32
43
  useUnionTypes,
44
+ validationLibrary,
33
45
  });
34
46
  const formattedValue = await (0, format_1.format)(templateResult);
35
47
  await fileSystemHelpers_1.fileSystemHelpers.writeFile(file, formattedValue);
@@ -0,0 +1,8 @@
1
+ declare const _default: {
2
+ compiler: (string | number)[];
3
+ main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
4
+ usePartial: boolean;
5
+ useData: boolean;
6
+ };
7
+ export default _default;
8
+ //# sourceMappingURL=legacy-request-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-request-adapter.d.ts","sourceRoot":"","sources":["../../../../src/templatesCompiled/client/core/legacy-request-adapter.ts"],"names":[],"mappings":";;;;;;AAMA,wBAUmC"}