ts-openapi-codegen 2.0.0-beta.8 → 2.0.0-beta.9

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 (239) hide show
  1. package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts +2 -1
  2. package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts.map +1 -1
  3. package/dist/cli/checkAndUpdateConfig/checkConfig.js +14 -6
  4. package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts +2 -1
  5. package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts.map +1 -1
  6. package/dist/cli/checkAndUpdateConfig/updateConfig.js +13 -5
  7. package/dist/cli/generateOpenApiClient/generateOpenApiClient.d.ts.map +1 -1
  8. package/dist/cli/generateOpenApiClient/generateOpenApiClient.js +4 -5
  9. package/dist/cli/index.js +5 -5
  10. package/dist/cli/initOpenApiConfig/init.d.ts.map +1 -1
  11. package/dist/cli/initOpenApiConfig/init.js +5 -13
  12. package/dist/cli/initOpenApiConfig/initConfig.js +3 -3
  13. package/dist/cli/previewChanges/previewChanges.d.ts.map +1 -1
  14. package/dist/cli/previewChanges/previewChanges.js +12 -5
  15. package/dist/cli/schemas/base.d.ts +6 -1
  16. package/dist/cli/schemas/base.d.ts.map +1 -1
  17. package/dist/cli/schemas/base.js +10 -6
  18. package/dist/cli/schemas/checkConfig.d.ts +1 -1
  19. package/dist/cli/schemas/generate.d.ts +1 -25
  20. package/dist/cli/schemas/generate.d.ts.map +1 -1
  21. package/dist/cli/schemas/generate.js +21 -32
  22. package/dist/cli/schemas/index.d.ts +2 -1
  23. package/dist/cli/schemas/index.d.ts.map +1 -1
  24. package/dist/cli/schemas/index.js +1 -0
  25. package/dist/cli/schemas/init.d.ts +5 -5
  26. package/dist/cli/schemas/init.d.ts.map +1 -1
  27. package/dist/cli/schemas/init.js +4 -5
  28. package/dist/cli/schemas/previewChanges.d.ts +9 -0
  29. package/dist/cli/schemas/previewChanges.d.ts.map +1 -0
  30. package/dist/cli/schemas/previewChanges.js +11 -0
  31. package/dist/cli/schemas/updateConfig.d.ts +1 -1
  32. package/dist/common/Consts.d.ts +2 -0
  33. package/dist/common/Consts.d.ts.map +1 -1
  34. package/dist/common/Consts.js +4 -1
  35. package/dist/common/LoggerMessages.js +1 -1
  36. package/dist/common/TRawOptions.d.ts +1 -1
  37. package/dist/common/TRawOptions.d.ts.map +1 -1
  38. package/dist/common/Validation/formatZodError.d.ts +10 -0
  39. package/dist/common/Validation/formatZodError.d.ts.map +1 -0
  40. package/dist/{cli/validation/errorFormatter.js → common/Validation/formatZodError.js} +14 -13
  41. package/dist/common/Validation/index.d.ts +3 -0
  42. package/dist/common/Validation/index.d.ts.map +1 -0
  43. package/dist/{cli/validation → common/Validation}/index.js +2 -2
  44. package/dist/{cli/validation/validateCLIOptions.d.ts → common/Validation/validateZodOptions.d.ts} +4 -4
  45. package/dist/common/Validation/validateZodOptions.d.ts.map +1 -0
  46. package/dist/{cli/validation/validateCLIOptions.js → common/Validation/validateZodOptions.js} +7 -10
  47. package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts +6 -1
  48. package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts.map +1 -1
  49. package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.js +8 -14
  50. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.d.ts +28 -0
  51. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.d.ts.map +1 -0
  52. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.js +25 -0
  53. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts +36 -6
  54. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts.map +1 -1
  55. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.js +33 -37
  56. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts +37 -6
  57. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts.map +1 -1
  58. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.js +30 -37
  59. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts +40 -0
  60. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts.map +1 -0
  61. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.js +36 -0
  62. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts +65 -0
  63. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts.map +1 -0
  64. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.js +31 -0
  65. package/dist/common/VersionedSchema/CommonSchemas.d.ts +53 -30
  66. package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
  67. package/dist/common/VersionedSchema/CommonSchemas.js +47 -72
  68. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts +25 -5
  69. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts.map +1 -1
  70. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.js +34 -17
  71. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts +25 -5
  72. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts.map +1 -1
  73. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.js +28 -19
  74. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts +25 -1
  75. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts.map +1 -1
  76. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.js +29 -2
  77. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts +25 -5
  78. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts.map +1 -1
  79. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.js +30 -14
  80. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts +23 -5
  81. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts.map +1 -1
  82. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.js +33 -18
  83. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas.d.ts +3 -2
  84. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas.d.ts.map +1 -1
  85. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas.js +18 -11
  86. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts +22 -5
  87. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts.map +1 -1
  88. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.js +30 -12
  89. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts +22 -5
  90. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts.map +1 -1
  91. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.js +27 -13
  92. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts +22 -1
  93. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts.map +1 -1
  94. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.js +28 -2
  95. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts +22 -5
  96. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts.map +1 -1
  97. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.js +31 -12
  98. package/dist/common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas.d.ts +3 -2
  99. package/dist/common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas.d.ts.map +1 -1
  100. package/dist/common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas.js +15 -9
  101. package/dist/common/VersionedSchema/Types.d.ts +5 -5
  102. package/dist/common/VersionedSchema/Types.d.ts.map +1 -1
  103. package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.d.ts +16 -0
  104. package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.d.ts.map +1 -0
  105. package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.js +85 -0
  106. package/dist/common/VersionedSchema/Utils/__tests__/compareShapes.test.d.ts +2 -0
  107. package/dist/common/VersionedSchema/Utils/__tests__/compareShapes.test.d.ts.map +1 -0
  108. package/dist/common/VersionedSchema/Utils/__tests__/compareShapes.test.js +23 -0
  109. package/dist/common/VersionedSchema/Utils/__tests__/migrateDataToLatestSchemaVersion.test.d.ts +2 -0
  110. package/dist/common/VersionedSchema/Utils/__tests__/migrateDataToLatestSchemaVersion.test.d.ts.map +1 -0
  111. package/dist/common/VersionedSchema/Utils/__tests__/migrateDataToLatestSchemaVersion.test.js +75 -0
  112. package/dist/common/VersionedSchema/Utils/buildVersionedSchema.d.ts +12 -0
  113. package/dist/common/VersionedSchema/Utils/buildVersionedSchema.d.ts.map +1 -0
  114. package/dist/common/VersionedSchema/Utils/buildVersionedSchema.js +13 -0
  115. package/dist/common/VersionedSchema/Utils/compareShapes.d.ts +16 -0
  116. package/dist/common/VersionedSchema/Utils/compareShapes.d.ts.map +1 -0
  117. package/dist/common/VersionedSchema/Utils/compareShapes.js +30 -0
  118. package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts +2 -1
  119. package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts.map +1 -1
  120. package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.js +5 -5
  121. package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.d.ts +2 -2
  122. package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.d.ts.map +1 -1
  123. package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.js +15 -7
  124. package/dist/common/VersionedSchema/Utils/getUniqueKeysFromSchemas.d.ts +2 -2
  125. package/dist/common/VersionedSchema/Utils/getUniqueKeysFromSchemas.d.ts.map +1 -1
  126. package/dist/common/VersionedSchema/Utils/getUniqueKeysFromSchemas.js +16 -3
  127. package/dist/common/VersionedSchema/Utils/getUniqueObjectKeys.d.ts.map +1 -1
  128. package/dist/common/VersionedSchema/Utils/getUniqueObjectKeys.js +19 -2
  129. package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts +2 -1
  130. package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts.map +1 -1
  131. package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.js +10 -9
  132. package/dist/common/VersionedSchema/refinements/dependentOptionsRefinement.d.ts +4 -0
  133. package/dist/common/VersionedSchema/refinements/dependentOptionsRefinement.d.ts.map +1 -0
  134. package/dist/common/VersionedSchema/refinements/dependentOptionsRefinement.js +43 -0
  135. package/dist/common/VersionedSchema/refinements/singleOrMultiRefinement.d.ts +4 -0
  136. package/dist/common/VersionedSchema/refinements/singleOrMultiRefinement.d.ts.map +1 -0
  137. package/dist/common/VersionedSchema/refinements/singleOrMultiRefinement.js +21 -0
  138. package/dist/core/Context.d.ts +6 -5
  139. package/dist/core/Context.d.ts.map +1 -1
  140. package/dist/core/Context.js +69 -26
  141. package/dist/core/OpenApiClient.d.ts.map +1 -1
  142. package/dist/core/OpenApiClient.js +12 -8
  143. package/dist/core/api/v2/Parser.d.ts +1 -1
  144. package/dist/core/api/v2/Parser.d.ts.map +1 -1
  145. package/dist/core/api/v2/Parser.js +2 -2
  146. package/dist/core/api/v2/parser/getModel.d.ts.map +1 -1
  147. package/dist/core/api/v2/parser/getModel.js +2 -5
  148. package/dist/core/api/v2/parser/getModelProperties.d.ts.map +1 -1
  149. package/dist/core/api/v2/parser/getModelProperties.js +1 -3
  150. package/dist/core/api/v2/parser/getModels.d.ts.map +1 -1
  151. package/dist/core/api/v2/parser/getModels.js +1 -2
  152. package/dist/core/api/v2/parser/getOperationParameter.d.ts.map +1 -1
  153. package/dist/core/api/v2/parser/getOperationParameter.js +2 -5
  154. package/dist/core/api/v2/parser/getOperationParameters.js +1 -1
  155. package/dist/core/api/v2/parser/getOperationResponse.d.ts.map +1 -1
  156. package/dist/core/api/v2/parser/getOperationResponse.js +1 -3
  157. package/dist/core/api/v2/parser/getOperationResponses.js +1 -1
  158. package/dist/core/api/v2/parser/getServices.d.ts.map +1 -1
  159. package/dist/core/api/v2/parser/getServices.js +4 -3
  160. package/dist/core/api/v2/parser/getType.d.ts.map +1 -1
  161. package/dist/core/api/v2/parser/getType.js +2 -2
  162. package/dist/core/api/v3/Parser.d.ts +1 -1
  163. package/dist/core/api/v3/Parser.d.ts.map +1 -1
  164. package/dist/core/api/v3/Parser.js +2 -2
  165. package/dist/core/api/v3/parser/getModel.d.ts.map +1 -1
  166. package/dist/core/api/v3/parser/getModel.js +2 -5
  167. package/dist/core/api/v3/parser/getModelProperties.d.ts.map +1 -1
  168. package/dist/core/api/v3/parser/getModelProperties.js +1 -3
  169. package/dist/core/api/v3/parser/getModels.d.ts.map +1 -1
  170. package/dist/core/api/v3/parser/getModels.js +1 -2
  171. package/dist/core/api/v3/parser/getOperation.js +1 -1
  172. package/dist/core/api/v3/parser/getOperationParameter.d.ts.map +1 -1
  173. package/dist/core/api/v3/parser/getOperationParameter.js +2 -5
  174. package/dist/core/api/v3/parser/getOperationParameters.js +1 -1
  175. package/dist/core/api/v3/parser/getOperationRequestBody.d.ts.map +1 -1
  176. package/dist/core/api/v3/parser/getOperationRequestBody.js +1 -3
  177. package/dist/core/api/v3/parser/getOperationResponse.d.ts.map +1 -1
  178. package/dist/core/api/v3/parser/getOperationResponse.js +1 -3
  179. package/dist/core/api/v3/parser/getOperationResponses.js +1 -1
  180. package/dist/core/api/v3/parser/getServices.d.ts.map +1 -1
  181. package/dist/core/api/v3/parser/getServices.js +4 -3
  182. package/dist/core/api/v3/parser/getType.js +2 -2
  183. package/dist/core/index.d.ts.map +1 -1
  184. package/dist/core/index.js +2 -0
  185. package/dist/core/utils/__tests__/isSubdirectory.test.js +2 -2
  186. package/dist/core/utils/serviceHelpers.d.ts.map +1 -1
  187. package/dist/core/utils/serviceHelpers.js +32 -6
  188. package/dist/core/utils/validateRawOptions.d.ts +3 -0
  189. package/dist/core/utils/validateRawOptions.d.ts.map +1 -0
  190. package/dist/core/utils/validateRawOptions.js +15 -0
  191. package/dist/templatesCompiled/client/exportService.js +1 -1
  192. package/dist/templatesCompiled/client/partials/exportComposition.d.ts +2 -0
  193. package/dist/templatesCompiled/client/partials/exportComposition.d.ts.map +1 -1
  194. package/dist/templatesCompiled/client/partials/exportComposition.js +17 -9
  195. package/package.json +1 -1
  196. package/dist/cli/validation/errorFormatter.d.ts +0 -6
  197. package/dist/cli/validation/errorFormatter.d.ts.map +0 -1
  198. package/dist/cli/validation/index.d.ts +0 -3
  199. package/dist/cli/validation/index.d.ts.map +0 -1
  200. package/dist/cli/validation/validateCLIOptions.d.ts.map +0 -1
  201. package/dist/common/VersionedSchema/Utils/getErrorFieldsFromValidation.d.ts +0 -6
  202. package/dist/common/VersionedSchema/Utils/getErrorFieldsFromValidation.d.ts.map +0 -1
  203. package/dist/common/VersionedSchema/Utils/getErrorFieldsFromValidation.js +0 -7
  204. package/dist/common/VersionedSchema/Utils/joiHandlers.d.ts +0 -6
  205. package/dist/common/VersionedSchema/Utils/joiHandlers.d.ts.map +0 -1
  206. package/dist/common/VersionedSchema/Utils/joiHandlers.js +0 -59
  207. package/dist/common/VersionedSchema/Utils/mergeObjectSchemas.d.ts +0 -3
  208. package/dist/common/VersionedSchema/Utils/mergeObjectSchemas.d.ts.map +0 -1
  209. package/dist/common/VersionedSchema/Utils/mergeObjectSchemas.js +0 -12
  210. package/dist/common/VersionedSchema/Utils/traverseObjectStructure.d.ts +0 -3
  211. package/dist/common/VersionedSchema/Utils/traverseObjectStructure.d.ts.map +0 -1
  212. package/dist/common/VersionedSchema/Utils/traverseObjectStructure.js +0 -31
  213. package/dist/common/schemas/configSchemas.d.ts +0 -91
  214. package/dist/common/schemas/configSchemas.d.ts.map +0 -1
  215. package/dist/common/schemas/configSchemas.js +0 -131
  216. package/dist/common/utils/__tests__/__mock__/mockJoiSchema.d.ts +0 -19
  217. package/dist/common/utils/__tests__/__mock__/mockJoiSchema.d.ts.map +0 -1
  218. package/dist/common/utils/__tests__/__mock__/mockJoiSchema.js +0 -14
  219. package/dist/common/utils/__tests__/determineBestMatchingSchemaVersion.test.d.ts +0 -2
  220. package/dist/common/utils/__tests__/determineBestMatchingSchemaVersion.test.d.ts.map +0 -1
  221. package/dist/common/utils/__tests__/determineBestMatchingSchemaVersion.test.js +0 -38
  222. package/dist/common/utils/__tests__/getUniqueKeysFromSchemas.test.d.ts +0 -2
  223. package/dist/common/utils/__tests__/getUniqueKeysFromSchemas.test.d.ts.map +0 -1
  224. package/dist/common/utils/__tests__/getUniqueKeysFromSchemas.test.js +0 -20
  225. package/dist/common/utils/__tests__/mergeObjectSchemas.test.d.ts +0 -2
  226. package/dist/common/utils/__tests__/mergeObjectSchemas.test.d.ts.map +0 -1
  227. package/dist/common/utils/__tests__/mergeObjectSchemas.test.js +0 -35
  228. package/dist/common/utils/__tests__/migrationForMultiOptions.test.d.ts +0 -2
  229. package/dist/common/utils/__tests__/migrationForMultiOptions.test.d.ts.map +0 -1
  230. package/dist/common/utils/__tests__/migrationForMultiOptions.test.js +0 -112
  231. package/dist/common/utils/__tests__/migrationForOptions.test.d.ts +0 -2
  232. package/dist/common/utils/__tests__/migrationForOptions.test.d.ts.map +0 -1
  233. package/dist/common/utils/__tests__/migrationForOptions.test.js +0 -56
  234. package/dist/core/utils/__tests__/getRelativeModelPath.test.d.ts +0 -2
  235. package/dist/core/utils/__tests__/getRelativeModelPath.test.d.ts.map +0 -1
  236. package/dist/core/utils/__tests__/getRelativeModelPath.test.js +0 -21
  237. package/dist/core/utils/getRelativeModelPath.d.ts +0 -9
  238. package/dist/core/utils/getRelativeModelPath.d.ts.map +0 -1
  239. package/dist/core/utils/getRelativeModelPath.js +0 -37
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleJoiDescription = exports.handleJoiSchema = void 0;
4
- /** Handler for Joi.Schema: only the launch remains .describe() */
5
- const handleJoiSchema = (value, recurse) => {
6
- if (value && typeof value.describe === 'function') {
7
- recurse(value.describe());
8
- // then the default bypass to the scheme itself is not needed.
9
- return true;
10
- }
11
- return false;
12
- };
13
- exports.handleJoiSchema = handleJoiSchema;
14
- /** Handler for the result of describe(): pulls out only the real keys of the field */
15
- const handleJoiDescription = (value, recurse, result) => {
16
- if (!value || typeof value !== 'object') {
17
- return false;
18
- }
19
- let processed = false;
20
- // only if there are keys/items/matches/patterns, we assume that this description
21
- if (value.keys && typeof value.keys === 'object') {
22
- processed = true;
23
- for (const key of Object.keys(value.keys)) {
24
- result.add(key);
25
- recurse(value.keys[key]);
26
- }
27
- }
28
- if (Array.isArray(value.items)) {
29
- processed = true;
30
- for (const item of value.items) {
31
- recurse(item);
32
- }
33
- }
34
- if (Array.isArray(value.matches)) {
35
- processed = true;
36
- for (const m of value.matches) {
37
- if (m.schema) {
38
- recurse(m.schema);
39
- }
40
- if (m.then) {
41
- recurse(m.then);
42
- }
43
- if (m.otherwise) {
44
- recurse(m.otherwise);
45
- }
46
- }
47
- }
48
- if (Array.isArray(value.patterns)) {
49
- processed = true;
50
- for (const p of value.patterns) {
51
- if (p.rule) {
52
- recurse(p.rule);
53
- }
54
- }
55
- }
56
- // if this is the description, the default bypass is not needed.
57
- return processed;
58
- };
59
- exports.handleJoiDescription = handleJoiDescription;
@@ -1,3 +0,0 @@
1
- import { ObjectSchema } from 'joi';
2
- export declare function mergeObjectSchemas<T extends object>(...schemas: ObjectSchema<T>[]): ObjectSchema<T>;
3
- //# sourceMappingURL=mergeObjectSchemas.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mergeObjectSchemas.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/mergeObjectSchemas.ts"],"names":[],"mappings":"AAAA,OAAY,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AAExC,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC,CAInG"}
@@ -1,12 +0,0 @@
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.mergeObjectSchemas = mergeObjectSchemas;
7
- const joi_1 = __importDefault(require("joi"));
8
- function mergeObjectSchemas(...schemas) {
9
- // We start with an "empty" object schema
10
- // we will immediately prohibit unknown fields
11
- return schemas.reduce((acc, sch) => acc.concat(sch), joi_1.default.object()).unknown(false);
12
- }
@@ -1,3 +0,0 @@
1
- import { TraverseHandler } from "../Types";
2
- export declare function traverseObjectStructure<T>(root: any, handlers: TraverseHandler<T>[], result: T): void;
3
- //# sourceMappingURL=traverseObjectStructure.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"traverseObjectStructure.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/traverseObjectStructure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,IAAI,EAAE,GAAG,EACT,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,EAC9B,MAAM,EAAE,CAAC,QA6BV"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.traverseObjectStructure = traverseObjectStructure;
4
- function traverseObjectStructure(root, handlers, result) {
5
- const recurse = (v) => traverseObjectStructure(v, handlers, result);
6
- // We try "special" handlers
7
- let handled = false;
8
- for (const handler of handlers) {
9
- if (handler(root, recurse, result)) {
10
- handled = true;
11
- }
12
- }
13
- // If none of the handlers worked, a basic bypass
14
- if (handled)
15
- return;
16
- if (root && typeof root === 'object') {
17
- if (Array.isArray(root)) {
18
- for (const item of root) {
19
- recurse(item);
20
- }
21
- }
22
- else {
23
- for (const key of Object.keys(root)) {
24
- if (result instanceof Set) {
25
- result.add(key);
26
- }
27
- recurse(root[key]);
28
- }
29
- }
30
- }
31
- }
@@ -1,91 +0,0 @@
1
- import { z } from 'zod';
2
- import { ValidationLibrary } from '../../core/types/enums/ValidationLibrary.enum';
3
- /**
4
- * Базовая схема опций без обязательных input/output
5
- * Используется как основа для CLI команд и конфиг-файлов
6
- */
7
- export declare const baseFlatOptionsSchema: z.ZodObject<{
8
- outputCore: z.ZodOptional<z.ZodString>;
9
- outputServices: z.ZodOptional<z.ZodString>;
10
- outputModels: z.ZodOptional<z.ZodString>;
11
- outputSchemas: z.ZodOptional<z.ZodString>;
12
- interfacePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
13
- enumPrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
14
- typePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
15
- httpClient: z.ZodOptional<z.ZodEnum<typeof import("../..").HttpClient>>;
16
- useOptions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
17
- useUnionTypes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
18
- excludeCoreServiceFiles: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
19
- request: z.ZodOptional<z.ZodString>;
20
- useCancelableRequest: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
21
- logLevel: z.ZodOptional<z.ZodEnum<typeof import("../Enums").ELogLevel>>;
22
- logTarget: z.ZodOptional<z.ZodEnum<typeof import("../Enums").ELogOutput>>;
23
- sortByRequired: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
24
- useSeparatedIndexes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
25
- validationLibrary: z.ZodOptional<z.ZodEnum<typeof ValidationLibrary>>;
26
- }, z.core.$strip>;
27
- /**
28
- * Полная схема для конфиг-файла (TRawOptions)
29
- * Поддерживает два формата:
30
- * 1. С массивом items (multi-options)
31
- * 2. С input/output в корне (single-options)
32
- */
33
- export declare const rawOptionsSchema: z.ZodObject<{
34
- items: z.ZodOptional<z.ZodArray<z.ZodObject<{
35
- input: z.ZodString;
36
- output: z.ZodString;
37
- outputCore: z.ZodOptional<z.ZodString>;
38
- outputServices: z.ZodOptional<z.ZodString>;
39
- outputModels: z.ZodOptional<z.ZodString>;
40
- outputSchemas: z.ZodOptional<z.ZodString>;
41
- request: z.ZodOptional<z.ZodString>;
42
- httpClient: z.ZodOptional<z.ZodEnum<typeof import("../..").HttpClient>>;
43
- }, z.core.$strip>>>;
44
- input: z.ZodOptional<z.ZodString>;
45
- output: z.ZodOptional<z.ZodString>;
46
- outputCore: z.ZodOptional<z.ZodString>;
47
- outputServices: z.ZodOptional<z.ZodString>;
48
- outputModels: z.ZodOptional<z.ZodString>;
49
- outputSchemas: z.ZodOptional<z.ZodString>;
50
- interfacePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
51
- enumPrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
52
- typePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
53
- httpClient: z.ZodOptional<z.ZodEnum<typeof import("../..").HttpClient>>;
54
- useOptions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
55
- useUnionTypes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
56
- excludeCoreServiceFiles: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
57
- request: z.ZodOptional<z.ZodString>;
58
- useCancelableRequest: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
59
- logLevel: z.ZodOptional<z.ZodEnum<typeof import("../Enums").ELogLevel>>;
60
- logTarget: z.ZodOptional<z.ZodEnum<typeof import("../Enums").ELogOutput>>;
61
- sortByRequired: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
62
- useSeparatedIndexes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
63
- validationLibrary: z.ZodOptional<z.ZodEnum<typeof ValidationLibrary>>;
64
- }, z.core.$strip>;
65
- /**
66
- * Схема для плоских опций (без items) - TFlatOptions
67
- * Используется для конфиг-файлов с одной спецификацией
68
- */
69
- export declare const flatOptionsSchema: z.ZodObject<{
70
- outputCore: z.ZodOptional<z.ZodString>;
71
- outputServices: z.ZodOptional<z.ZodString>;
72
- outputModels: z.ZodOptional<z.ZodString>;
73
- outputSchemas: z.ZodOptional<z.ZodString>;
74
- interfacePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
75
- enumPrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
76
- typePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
77
- httpClient: z.ZodOptional<z.ZodEnum<typeof import("../..").HttpClient>>;
78
- useOptions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
79
- useUnionTypes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
80
- excludeCoreServiceFiles: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
81
- request: z.ZodOptional<z.ZodString>;
82
- useCancelableRequest: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
83
- logLevel: z.ZodOptional<z.ZodEnum<typeof import("../Enums").ELogLevel>>;
84
- logTarget: z.ZodOptional<z.ZodEnum<typeof import("../Enums").ELogOutput>>;
85
- sortByRequired: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
86
- useSeparatedIndexes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
87
- validationLibrary: z.ZodOptional<z.ZodEnum<typeof ValidationLibrary>>;
88
- input: z.ZodString;
89
- output: z.ZodString;
90
- }, z.core.$strip>;
91
- //# sourceMappingURL=configSchemas.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"configSchemas.d.ts","sourceRoot":"","sources":["../../../src/common/schemas/configSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAqDlF;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;iBAAqE,CAAC;AAExG;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqDvB,CAAC;AAEP;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;iBAcxB,CAAC"}
@@ -1,131 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.flatOptionsSchema = exports.rawOptionsSchema = exports.baseFlatOptionsSchema = void 0;
4
- const zod_1 = require("zod");
5
- const base_1 = require("../../cli/schemas/base");
6
- const ValidationLibrary_enum_1 = require("../../core/types/enums/ValidationLibrary.enum");
7
- /**
8
- * Схема для отдельного элемента конфигурации (используется в массиве items)
9
- */
10
- const itemConfigSchema = zod_1.z.object({
11
- input: zod_1.z.string().min(1, 'Input is required'),
12
- output: zod_1.z.string().min(1, 'Output is required'),
13
- outputCore: zod_1.z.string().min(1).optional(),
14
- outputServices: zod_1.z.string().min(1).optional(),
15
- outputModels: zod_1.z.string().min(1).optional(),
16
- outputSchemas: zod_1.z.string().min(1).optional(),
17
- request: zod_1.z.string().min(1).optional(),
18
- httpClient: base_1.httpClientSchema.optional(),
19
- });
20
- /**
21
- * Схема для output директорий (используется как в items, так и в корне)
22
- */
23
- const outputPathsSchema = zod_1.z.object({
24
- outputCore: zod_1.z.string().min(1).optional(),
25
- outputServices: zod_1.z.string().min(1).optional(),
26
- outputModels: zod_1.z.string().min(1).optional(),
27
- outputSchemas: zod_1.z.string().min(1).optional(),
28
- });
29
- /**
30
- * Схема для префиксов
31
- */
32
- const prefixesSchema = zod_1.z.object({
33
- interfacePrefix: zod_1.z.string().min(1).optional().default('I'),
34
- enumPrefix: zod_1.z.string().min(1).optional().default('E'),
35
- typePrefix: zod_1.z.string().min(1).optional().default('T'),
36
- });
37
- /**
38
- * Базовая схема для общих опций (без items/input/output)
39
- */
40
- const commonOptionsSchema = zod_1.z.object({
41
- httpClient: base_1.httpClientSchema.optional(),
42
- useOptions: zod_1.z.boolean().optional().default(false),
43
- useUnionTypes: zod_1.z.boolean().optional().default(false),
44
- excludeCoreServiceFiles: zod_1.z.boolean().optional().default(false),
45
- request: zod_1.z.string().min(1).optional(),
46
- useCancelableRequest: zod_1.z.boolean().optional().default(false),
47
- logLevel: base_1.logLevelSchema.optional(),
48
- logTarget: base_1.logTargetSchema.optional(),
49
- sortByRequired: zod_1.z.boolean().optional().default(false),
50
- useSeparatedIndexes: zod_1.z.boolean().optional().default(false),
51
- validationLibrary: zod_1.z.nativeEnum(ValidationLibrary_enum_1.ValidationLibrary).optional()
52
- });
53
- /**
54
- * Базовая схема опций без обязательных input/output
55
- * Используется как основа для CLI команд и конфиг-файлов
56
- */
57
- exports.baseFlatOptionsSchema = outputPathsSchema.merge(prefixesSchema).merge(commonOptionsSchema);
58
- /**
59
- * Полная схема для конфиг-файла (TRawOptions)
60
- * Поддерживает два формата:
61
- * 1. С массивом items (multi-options)
62
- * 2. С input/output в корне (single-options)
63
- */
64
- exports.rawOptionsSchema = zod_1.z
65
- .object({
66
- // Multi-item configuration
67
- items: zod_1.z.array(itemConfigSchema).min(1, 'Items array must contain at least one item').optional(),
68
- // Single-item configuration (взаимоисключающие с items)
69
- input: zod_1.z.string().min(1).optional(),
70
- output: zod_1.z.string().min(1).optional(),
71
- })
72
- .merge(exports.baseFlatOptionsSchema)
73
- .superRefine((data, ctx) => {
74
- // Проверка: либо items, либо input+output должны быть указаны
75
- const hasItems = data.items && data.items.length > 0;
76
- const hasInputOutput = !!(data.input && data.output);
77
- if (!hasItems && !hasInputOutput) {
78
- ctx.addIssue({
79
- code: zod_1.z.ZodIssueCode.custom,
80
- message: 'Either "items" array or "input" + "output" must be provided',
81
- path: [],
82
- });
83
- }
84
- // Если есть items, то input и output в корне не должны быть указаны
85
- if (hasItems && hasInputOutput) {
86
- ctx.addIssue({
87
- code: zod_1.z.ZodIssueCode.custom,
88
- message: 'Cannot use both "items" array and "input"/"output" at the root level',
89
- path: ['items'],
90
- });
91
- }
92
- // Валидация: если excludeCoreServiceFiles === true, request не должен быть указан
93
- if (data.excludeCoreServiceFiles === true && data.request) {
94
- ctx.addIssue({
95
- code: zod_1.z.ZodIssueCode.custom,
96
- message: '"request" can only be used when "excludeCoreServiceFiles" is false',
97
- path: ['request'],
98
- });
99
- }
100
- // Валидация для каждого элемента в items
101
- if (hasItems && data.items) {
102
- data.items.forEach((item, index) => {
103
- if (item.request && data.excludeCoreServiceFiles === true) {
104
- ctx.addIssue({
105
- code: zod_1.z.ZodIssueCode.custom,
106
- message: '"request" in items can only be used when "excludeCoreServiceFiles" is false',
107
- path: ['items', index, 'request'],
108
- });
109
- }
110
- });
111
- }
112
- });
113
- /**
114
- * Схема для плоских опций (без items) - TFlatOptions
115
- * Используется для конфиг-файлов с одной спецификацией
116
- */
117
- exports.flatOptionsSchema = exports.baseFlatOptionsSchema
118
- .extend({
119
- input: zod_1.z.string().min(1, 'Input is required'),
120
- output: zod_1.z.string().min(1, 'Output is required'),
121
- })
122
- .superRefine((data, ctx) => {
123
- // Валидация: если excludeCoreServiceFiles === true, request не должен быть указан
124
- if (data.excludeCoreServiceFiles === true && data.request) {
125
- ctx.addIssue({
126
- code: zod_1.z.ZodIssueCode.custom,
127
- message: '"request" can only be used when "excludeCoreServiceFiles" is false',
128
- path: ['request'],
129
- });
130
- }
131
- });
@@ -1,19 +0,0 @@
1
- export declare const mockJoiSchema: (keys: string[], isValid: boolean, errors?: {
2
- path: string;
3
- type: string;
4
- }[], isArray?: boolean) => {
5
- validate: (input: any, options: any) => {
6
- error: {
7
- details: {
8
- path: string;
9
- type: string;
10
- }[];
11
- } | null;
12
- value: any;
13
- };
14
- describe: () => {
15
- keys: {} | undefined;
16
- items: {}[] | undefined;
17
- };
18
- };
19
- //# sourceMappingURL=mockJoiSchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mockJoiSchema.d.ts","sourceRoot":"","sources":["../../../../../src/common/utils/__tests__/__mock__/mockJoiSchema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,EAAE,EAAE,SAAS,OAAO,EAAE,SAAQ;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAO,EAAE,iBAAe;sBACxG,GAAG,WAAW,GAAG;;;sBADyC,MAAM;sBAAQ,MAAM;;;;;;;;;CASlG,CAAC"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mockJoiSchema = void 0;
4
- const mockJoiSchema = (keys, isValid, errors = [], isArray = false) => ({
5
- validate: (input, options) => ({
6
- error: isValid ? null : { details: errors },
7
- value: input,
8
- }),
9
- describe: () => ({
10
- keys: isArray ? undefined : keys.reduce((acc, key) => ({ ...acc, [key]: {} }), {}),
11
- items: isArray ? [{}] : undefined,
12
- }),
13
- });
14
- exports.mockJoiSchema = mockJoiSchema;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=determineBestMatchingSchemaVersion.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"determineBestMatchingSchemaVersion.test.d.ts","sourceRoot":"","sources":["../../../../src/common/utils/__tests__/determineBestMatchingSchemaVersion.test.ts"],"names":[],"mappings":""}
@@ -1,38 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_assert_1 = __importDefault(require("node:assert"));
7
- const node_test_1 = require("node:test");
8
- const Enums_1 = require("../../VersionedSchema/Enums");
9
- const determineBestMatchingSchemaVersion_1 = require("../../VersionedSchema/Utils/determineBestMatchingSchemaVersion");
10
- const mockJoiSchema_1 = require("./__mock__/mockJoiSchema");
11
- (0, node_test_1.describe)('@unit: determineBestMatchingSchemaVersion', () => {
12
- (0, node_test_1.test)('it should return the latest version if there is an exact match.', async () => {
13
- const schemas = [
14
- { schema: (0, mockJoiSchema_1.mockJoiSchema)(['name'], true), version: '1.0', type: Enums_1.EVersionedSchemaType.OPTIONS },
15
- { schema: (0, mockJoiSchema_1.mockJoiSchema)(['name', 'age'], true), version: '2.0', type: Enums_1.EVersionedSchemaType.OPTIONS },
16
- ];
17
- const input = { name: 'John', age: 30 };
18
- const result = (0, determineBestMatchingSchemaVersion_1.determineBestMatchingSchemaVersion)(input, schemas);
19
- node_assert_1.default.deepEqual(result, {
20
- lastVersionIndex: 1,
21
- latestVersion: '2.0',
22
- firstVersion: '1.0',
23
- });
24
- });
25
- (0, node_test_1.test)('should return the best scheme in the absence of exact matches.', async () => {
26
- const schemas = [
27
- { schema: (0, mockJoiSchema_1.mockJoiSchema)(['name'], false, [{ path: 'age', type: 'string' }]), version: '1.0', type: Enums_1.EVersionedSchemaType.OPTIONS },
28
- { schema: (0, mockJoiSchema_1.mockJoiSchema)(['name', 'age'], true), version: '2.0', type: Enums_1.EVersionedSchemaType.OPTIONS },
29
- ];
30
- const input = { name: 'John', age: 30 };
31
- const result = (0, determineBestMatchingSchemaVersion_1.determineBestMatchingSchemaVersion)(input, schemas);
32
- node_assert_1.default.deepEqual(result, {
33
- lastVersionIndex: 1,
34
- latestVersion: '2.0',
35
- firstVersion: '2.0',
36
- });
37
- });
38
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=getUniqueKeysFromSchemas.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getUniqueKeysFromSchemas.test.d.ts","sourceRoot":"","sources":["../../../../src/common/utils/__tests__/getUniqueKeysFromSchemas.test.ts"],"names":[],"mappings":""}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_assert_1 = __importDefault(require("node:assert"));
7
- const node_test_1 = require("node:test");
8
- const getUniqueKeysFromSchemas_1 = require("../../VersionedSchema/Utils/getUniqueKeysFromSchemas");
9
- const mockJoiSchema_1 = require("./__mock__/mockJoiSchema");
10
- (0, node_test_1.describe)('@unit: getUniqueKeysFromSchemas', () => {
11
- (0, node_test_1.test)('must return unique keys from the schema', async () => {
12
- const schema = (0, mockJoiSchema_1.mockJoiSchema)(['name', 'age'], true);
13
- const result = (0, getUniqueKeysFromSchemas_1.getUniqueKeysFromSchemas)([schema]);
14
- node_assert_1.default.deepEqual(result, new Set(['name', 'age']));
15
- });
16
- (0, node_test_1.test)('should return an empty set for an empty list of schemas', async () => {
17
- const result = (0, getUniqueKeysFromSchemas_1.getUniqueKeysFromSchemas)([]);
18
- node_assert_1.default.deepEqual(result, new Set());
19
- });
20
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=mergeObjectSchemas.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mergeObjectSchemas.test.d.ts","sourceRoot":"","sources":["../../../../src/common/utils/__tests__/mergeObjectSchemas.test.ts"],"names":[],"mappings":""}
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_assert_1 = __importDefault(require("node:assert"));
7
- const node_test_1 = require("node:test");
8
- const joi_1 = __importDefault(require("joi"));
9
- const OptionsSchemaV2_1 = require("../../VersionedSchema/OptionsVersioned/OptionsSchemaV2");
10
- const mergeObjectSchemas_1 = require("../../VersionedSchema/Utils/mergeObjectSchemas");
11
- (0, node_test_1.describe)('@unit: mergeObjectSchemas', () => {
12
- (0, node_test_1.test)('should combine multiple schemas correctly', () => {
13
- const schema1 = joi_1.default.object({ a: joi_1.default.string().required() });
14
- const schema2 = joi_1.default.object({ b: joi_1.default.number().optional() });
15
- const mergedSchema = (0, mergeObjectSchemas_1.mergeObjectSchemas)(schema1, schema2);
16
- const validData = { a: 'test', b: 123 };
17
- const invalidData = { a: 'test', b: 'not a number' };
18
- node_assert_1.default.equal(mergedSchema.validate(validData).error, null, 'Valid data should pass validation');
19
- node_assert_1.default.notEqual(mergedSchema.validate(invalidData).error, null, 'Invalid data should fail validation');
20
- });
21
- (0, node_test_1.test)('should work with real schemas from OptionSchemas', () => {
22
- const validData = {
23
- input: 'source/path',
24
- httpClient: 'axios',
25
- output: 'output/path',
26
- useOptions: true,
27
- };
28
- const invalidData = {
29
- input: 'source/path',
30
- httpClient: 'invalid-client',
31
- };
32
- node_assert_1.default.equal(OptionsSchemaV2_1.optionsSchemaV2.validate(validData).error, null, 'Valid data should pass optionsSchemaV2 validation');
33
- node_assert_1.default.notEqual(OptionsSchemaV2_1.optionsSchemaV2.validate(invalidData).error, null, 'Invalid data should fail optionsSchemaV2 validation');
34
- });
35
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=migrationForMultiOptions.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrationForMultiOptions.test.d.ts","sourceRoot":"","sources":["../../../../src/common/utils/__tests__/migrationForMultiOptions.test.ts"],"names":[],"mappings":""}
@@ -1,112 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const strict_1 = __importDefault(require("node:assert/strict"));
7
- const node_test_1 = require("node:test");
8
- const Enums_1 = require("../../Enums");
9
- const Enums_2 = require("../../VersionedSchema/Enums");
10
- const MultiOptionsMigrationPlan_1 = require("../../VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan");
11
- const MultiOptionsVersionedSchemas_1 = require("../../VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas");
12
- const migrateDataToLatestSchemaVersion_1 = require("../../VersionedSchema/Utils/migrateDataToLatestSchemaVersion");
13
- const mockJoiSchema_1 = require("./__mock__/mockJoiSchema");
14
- node_test_1.describe.skip('@unit: migrationForMultiOptions', () => {
15
- (0, node_test_1.test)('must successfully migrate MULTI_OPTIONS data to the latest version', async () => {
16
- const input = { input: 'input/path', output: 'output/path', client: 'fetch', items: [{ input: 'path/item1' }] };
17
- const result = (0, migrateDataToLatestSchemaVersion_1.migrateDataToLatestSchemaVersion)({
18
- rawInput: input,
19
- migrationPlans: MultiOptionsMigrationPlan_1.multiOptionsMigrationPlan,
20
- versionedSchemas: MultiOptionsVersionedSchemas_1.multiOptionsVersionedSchema,
21
- migrationMode: Enums_1.EMigrationMode.GENERATE_OPENAPI,
22
- });
23
- strict_1.default.deepEqual(result, {
24
- value: {
25
- excludeCoreServiceFiles: false,
26
- httpClient: 'fetch',
27
- includeSchemasFiles: false,
28
- items: [
29
- {
30
- input: 'input/path',
31
- output: 'output/path',
32
- outputCore: undefined,
33
- outputModels: undefined,
34
- outputSchemas: undefined,
35
- outputServices: undefined,
36
- },
37
- ],
38
- sortByRequired: false,
39
- useCancelableRequest: false,
40
- useSeparatedIndexes: false,
41
- },
42
- schemaVersion: 'v5',
43
- schemaType: Enums_2.EVersionedSchemaType.MULTI_OPTIONS,
44
- });
45
- });
46
- (0, node_test_1.test)('should return null in case of validation error of the last MULTI_OPTIONS scheme', async () => {
47
- const input = { input: 'input/path' };
48
- const result = (0, migrateDataToLatestSchemaVersion_1.migrateDataToLatestSchemaVersion)({
49
- rawInput: input,
50
- migrationPlans: MultiOptionsMigrationPlan_1.multiOptionsMigrationPlan,
51
- versionedSchemas: MultiOptionsVersionedSchemas_1.multiOptionsVersionedSchema,
52
- migrationMode: Enums_1.EMigrationMode.GENERATE_OPENAPI,
53
- });
54
- strict_1.default.equal(result, null);
55
- });
56
- (0, node_test_1.test)('should throw an error if the migration plan for MULTI_OPTIONS is not found.', async () => {
57
- const input = { input: 'input/path', output: 'output/path', client: 'fetch', items: [{ input: 'path/item1' }] };
58
- strict_1.default.throws(() => (0, migrateDataToLatestSchemaVersion_1.migrateDataToLatestSchemaVersion)({
59
- rawInput: input,
60
- migrationPlans: [],
61
- versionedSchemas: MultiOptionsVersionedSchemas_1.multiOptionsVersionedSchema,
62
- migrationMode: Enums_1.EMigrationMode.GENERATE_OPENAPI,
63
- }), /No migration plan from v1/);
64
- });
65
- (0, node_test_1.test)('should throw an error on unrecognized fields in MULTI_OPTIONS', async () => {
66
- const input = {
67
- input: 'input/path',
68
- output: 'output/path',
69
- client: 'fetch',
70
- items: [{ input: 'path/item1', name: 'Item1' }],
71
- };
72
- strict_1.default.throws(() => (0, migrateDataToLatestSchemaVersion_1.migrateDataToLatestSchemaVersion)({
73
- rawInput: input,
74
- migrationPlans: MultiOptionsMigrationPlan_1.multiOptionsMigrationPlan,
75
- versionedSchemas: MultiOptionsVersionedSchemas_1.multiOptionsVersionedSchema,
76
- migrationMode: Enums_1.EMigrationMode.GENERATE_OPENAPI,
77
- }), /The "name" field is not recognized./);
78
- });
79
- (0, node_test_1.test)('must process an empty array of MULTI_OPTIONS data', async () => {
80
- const schemas = [
81
- {
82
- schema: (0, mockJoiSchema_1.mockJoiSchema)(['name'], true, [], true),
83
- version: '1.0',
84
- type: Enums_2.EVersionedSchemaType.MULTI_OPTIONS,
85
- },
86
- {
87
- schema: (0, mockJoiSchema_1.mockJoiSchema)(['name', 'options'], true, [], true),
88
- version: '2.0',
89
- type: Enums_2.EVersionedSchemaType.MULTI_OPTIONS,
90
- },
91
- ];
92
- const migrationPlans = [
93
- {
94
- fromVersion: '1.0',
95
- toVersion: '2.0',
96
- migrate: (input) => input.map((item) => ({ ...item, options: [] })),
97
- },
98
- ];
99
- const input = [];
100
- const result = (0, migrateDataToLatestSchemaVersion_1.migrateDataToLatestSchemaVersion)({
101
- rawInput: input,
102
- migrationPlans,
103
- versionedSchemas: schemas,
104
- migrationMode: Enums_1.EMigrationMode.GENERATE_OPENAPI,
105
- });
106
- strict_1.default.deepEqual(result, {
107
- value: [],
108
- schemaVersion: '2.0',
109
- schemaType: Enums_2.EVersionedSchemaType.MULTI_OPTIONS,
110
- });
111
- });
112
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=migrationForOptions.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrationForOptions.test.d.ts","sourceRoot":"","sources":["../../../../src/common/utils/__tests__/migrationForOptions.test.ts"],"names":[],"mappings":""}