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

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 (370) hide show
  1. package/README.md +88 -18
  2. package/README.rus.md +88 -21
  3. package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts +2 -1
  4. package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts.map +1 -1
  5. package/dist/cli/checkAndUpdateConfig/checkConfig.js +14 -6
  6. package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts +2 -1
  7. package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts.map +1 -1
  8. package/dist/cli/checkAndUpdateConfig/updateConfig.js +13 -5
  9. package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.d.ts.map +1 -1
  10. package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.js +5 -0
  11. package/dist/cli/generateOpenApiClient/generateOpenApiClient.d.ts.map +1 -1
  12. package/dist/cli/generateOpenApiClient/generateOpenApiClient.js +24 -13
  13. package/dist/cli/index.js +10 -8
  14. package/dist/cli/initOpenApiConfig/init.d.ts.map +1 -1
  15. package/dist/cli/initOpenApiConfig/init.js +5 -13
  16. package/dist/cli/initOpenApiConfig/initConfig.js +3 -3
  17. package/dist/cli/previewChanges/previewChanges.d.ts.map +1 -1
  18. package/dist/cli/previewChanges/previewChanges.js +119 -28
  19. package/dist/cli/previewChanges/utils/updateOutputPaths.d.ts.map +1 -1
  20. package/dist/cli/previewChanges/utils/updateOutputPaths.js +6 -0
  21. package/dist/cli/schemas/base.d.ts +6 -1
  22. package/dist/cli/schemas/base.d.ts.map +1 -1
  23. package/dist/cli/schemas/base.js +10 -6
  24. package/dist/cli/schemas/checkConfig.d.ts +1 -1
  25. package/dist/cli/schemas/generate.d.ts +1 -25
  26. package/dist/cli/schemas/generate.d.ts.map +1 -1
  27. package/dist/cli/schemas/generate.js +21 -32
  28. package/dist/cli/schemas/index.d.ts +2 -1
  29. package/dist/cli/schemas/index.d.ts.map +1 -1
  30. package/dist/cli/schemas/index.js +1 -0
  31. package/dist/cli/schemas/init.d.ts +5 -5
  32. package/dist/cli/schemas/init.d.ts.map +1 -1
  33. package/dist/cli/schemas/init.js +4 -5
  34. package/dist/cli/schemas/previewChanges.d.ts +9 -0
  35. package/dist/cli/schemas/previewChanges.d.ts.map +1 -0
  36. package/dist/cli/schemas/previewChanges.js +11 -0
  37. package/dist/cli/schemas/updateConfig.d.ts +1 -1
  38. package/dist/common/Consts.d.ts +2 -0
  39. package/dist/common/Consts.d.ts.map +1 -1
  40. package/dist/common/Consts.js +8 -2
  41. package/dist/common/LoggerMessages.d.ts +1 -0
  42. package/dist/common/LoggerMessages.d.ts.map +1 -1
  43. package/dist/common/LoggerMessages.js +2 -1
  44. package/dist/common/TRawOptions.d.ts +1 -1
  45. package/dist/common/TRawOptions.d.ts.map +1 -1
  46. package/dist/common/Validation/formatZodError.d.ts +10 -0
  47. package/dist/common/Validation/formatZodError.d.ts.map +1 -0
  48. package/dist/{cli/validation/errorFormatter.js → common/Validation/formatZodError.js} +14 -13
  49. package/dist/common/Validation/index.d.ts +3 -0
  50. package/dist/common/Validation/index.d.ts.map +1 -0
  51. package/dist/{cli/validation → common/Validation}/index.js +2 -2
  52. package/dist/{cli/validation/validateCLIOptions.d.ts → common/Validation/validateZodOptions.d.ts} +4 -4
  53. package/dist/common/Validation/validateZodOptions.d.ts.map +1 -0
  54. package/dist/{cli/validation/validateCLIOptions.js → common/Validation/validateZodOptions.js} +7 -10
  55. package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts +1 -1
  56. package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -1
  57. package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +14 -4
  58. package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts +6 -1
  59. package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts.map +1 -1
  60. package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.js +8 -14
  61. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.d.ts +28 -0
  62. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.d.ts.map +1 -0
  63. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.js +25 -0
  64. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts +36 -6
  65. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts.map +1 -1
  66. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.js +33 -37
  67. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts +37 -6
  68. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts.map +1 -1
  69. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.js +30 -37
  70. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts +40 -0
  71. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts.map +1 -0
  72. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.js +36 -0
  73. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts +42 -0
  74. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts.map +1 -0
  75. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.js +38 -0
  76. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts +192 -0
  77. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts.map +1 -0
  78. package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.js +27 -0
  79. package/dist/common/VersionedSchema/CommonSchemas.d.ts +61 -30
  80. package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
  81. package/dist/common/VersionedSchema/CommonSchemas.js +56 -73
  82. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts +25 -5
  83. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts.map +1 -1
  84. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.js +34 -17
  85. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts +25 -5
  86. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts.map +1 -1
  87. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.js +28 -19
  88. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts +25 -1
  89. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts.map +1 -1
  90. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.js +29 -2
  91. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts +25 -5
  92. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts.map +1 -1
  93. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.js +30 -14
  94. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts +23 -5
  95. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts.map +1 -1
  96. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.js +33 -18
  97. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas.d.ts +3 -2
  98. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas.d.ts.map +1 -1
  99. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas.js +18 -11
  100. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts +22 -5
  101. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts.map +1 -1
  102. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.js +30 -12
  103. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts +22 -5
  104. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts.map +1 -1
  105. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.js +27 -13
  106. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts +22 -1
  107. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts.map +1 -1
  108. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.js +28 -2
  109. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts +22 -5
  110. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts.map +1 -1
  111. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.js +31 -12
  112. package/dist/common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas.d.ts +3 -2
  113. package/dist/common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas.d.ts.map +1 -1
  114. package/dist/common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas.js +15 -9
  115. package/dist/common/VersionedSchema/Types.d.ts +5 -5
  116. package/dist/common/VersionedSchema/Types.d.ts.map +1 -1
  117. package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.d.ts +16 -0
  118. package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.d.ts.map +1 -0
  119. package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.js +104 -0
  120. package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.d.ts +2 -0
  121. package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.d.ts.map +1 -0
  122. package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.js +185 -0
  123. package/dist/common/VersionedSchema/Utils/__tests__/compareShapes.test.d.ts +2 -0
  124. package/dist/common/VersionedSchema/Utils/__tests__/compareShapes.test.d.ts.map +1 -0
  125. package/dist/common/VersionedSchema/Utils/__tests__/compareShapes.test.js +40 -0
  126. package/dist/common/VersionedSchema/Utils/__tests__/migrateDataToLatestSchemaVersion.test.d.ts +2 -0
  127. package/dist/common/VersionedSchema/Utils/__tests__/migrateDataToLatestSchemaVersion.test.d.ts.map +1 -0
  128. package/dist/common/VersionedSchema/Utils/__tests__/migrateDataToLatestSchemaVersion.test.js +93 -0
  129. package/dist/common/VersionedSchema/Utils/buildVersionedSchema.d.ts +12 -0
  130. package/dist/common/VersionedSchema/Utils/buildVersionedSchema.d.ts.map +1 -0
  131. package/dist/common/VersionedSchema/Utils/buildVersionedSchema.js +13 -0
  132. package/dist/common/VersionedSchema/Utils/compareShapes.d.ts +16 -0
  133. package/dist/common/VersionedSchema/Utils/compareShapes.d.ts.map +1 -0
  134. package/dist/common/VersionedSchema/Utils/compareShapes.js +30 -0
  135. package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts +6 -1
  136. package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts.map +1 -1
  137. package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.js +70 -25
  138. package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.d.ts +2 -2
  139. package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.d.ts.map +1 -1
  140. package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.js +15 -7
  141. package/dist/common/VersionedSchema/Utils/getUniqueKeysFromSchemas.d.ts +3 -3
  142. package/dist/common/VersionedSchema/Utils/getUniqueKeysFromSchemas.d.ts.map +1 -1
  143. package/dist/common/VersionedSchema/Utils/getUniqueKeysFromSchemas.js +17 -4
  144. package/dist/common/VersionedSchema/Utils/getUniqueObjectKeys.d.ts.map +1 -1
  145. package/dist/common/VersionedSchema/Utils/getUniqueObjectKeys.js +19 -2
  146. package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts +12 -1
  147. package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts.map +1 -1
  148. package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.js +41 -22
  149. package/dist/common/VersionedSchema/refinements/dependentOptionsRefinement.d.ts +4 -0
  150. package/dist/common/VersionedSchema/refinements/dependentOptionsRefinement.d.ts.map +1 -0
  151. package/dist/common/VersionedSchema/refinements/dependentOptionsRefinement.js +43 -0
  152. package/dist/common/VersionedSchema/refinements/singleOrMultiRefinement.d.ts +4 -0
  153. package/dist/common/VersionedSchema/refinements/singleOrMultiRefinement.d.ts.map +1 -0
  154. package/dist/common/VersionedSchema/refinements/singleOrMultiRefinement.js +21 -0
  155. package/dist/common/utils/__tests__/convertArrayToObject.test.js +64 -169
  156. package/dist/common/utils/convertArrayToObject.d.ts.map +1 -1
  157. package/dist/common/utils/convertArrayToObject.js +51 -14
  158. package/dist/core/Context.d.ts +6 -5
  159. package/dist/core/Context.d.ts.map +1 -1
  160. package/dist/core/Context.js +69 -26
  161. package/dist/core/OpenApiClient.d.ts.map +1 -1
  162. package/dist/core/OpenApiClient.js +24 -9
  163. package/dist/core/WriteClient.d.ts +8 -1
  164. package/dist/core/WriteClient.d.ts.map +1 -1
  165. package/dist/core/WriteClient.js +48 -7
  166. package/dist/core/__tests__/WriteClient.test.js +2 -0
  167. package/dist/core/api/v2/Parser.d.ts +1 -1
  168. package/dist/core/api/v2/Parser.d.ts.map +1 -1
  169. package/dist/core/api/v2/Parser.js +2 -2
  170. package/dist/core/api/v2/parser/getModel.d.ts.map +1 -1
  171. package/dist/core/api/v2/parser/getModel.js +2 -5
  172. package/dist/core/api/v2/parser/getModelProperties.d.ts.map +1 -1
  173. package/dist/core/api/v2/parser/getModelProperties.js +1 -3
  174. package/dist/core/api/v2/parser/getModels.d.ts.map +1 -1
  175. package/dist/core/api/v2/parser/getModels.js +1 -2
  176. package/dist/core/api/v2/parser/getOperationParameter.d.ts.map +1 -1
  177. package/dist/core/api/v2/parser/getOperationParameter.js +2 -5
  178. package/dist/core/api/v2/parser/getOperationParameters.js +1 -1
  179. package/dist/core/api/v2/parser/getOperationResponse.d.ts.map +1 -1
  180. package/dist/core/api/v2/parser/getOperationResponse.js +1 -3
  181. package/dist/core/api/v2/parser/getOperationResponses.js +1 -1
  182. package/dist/core/api/v2/parser/getServices.d.ts.map +1 -1
  183. package/dist/core/api/v2/parser/getServices.js +4 -3
  184. package/dist/core/api/v2/parser/getType.d.ts.map +1 -1
  185. package/dist/core/api/v2/parser/getType.js +4 -3
  186. package/dist/core/api/v3/Parser.d.ts +1 -1
  187. package/dist/core/api/v3/Parser.d.ts.map +1 -1
  188. package/dist/core/api/v3/Parser.js +2 -2
  189. package/dist/core/api/v3/parser/getModel.d.ts.map +1 -1
  190. package/dist/core/api/v3/parser/getModel.js +2 -5
  191. package/dist/core/api/v3/parser/getModelProperties.d.ts.map +1 -1
  192. package/dist/core/api/v3/parser/getModelProperties.js +1 -3
  193. package/dist/core/api/v3/parser/getModels.d.ts.map +1 -1
  194. package/dist/core/api/v3/parser/getModels.js +1 -2
  195. package/dist/core/api/v3/parser/getOperation.js +1 -1
  196. package/dist/core/api/v3/parser/getOperationParameter.d.ts.map +1 -1
  197. package/dist/core/api/v3/parser/getOperationParameter.js +2 -5
  198. package/dist/core/api/v3/parser/getOperationParameters.js +1 -1
  199. package/dist/core/api/v3/parser/getOperationRequestBody.d.ts.map +1 -1
  200. package/dist/core/api/v3/parser/getOperationRequestBody.js +1 -3
  201. package/dist/core/api/v3/parser/getOperationResponse.d.ts.map +1 -1
  202. package/dist/core/api/v3/parser/getOperationResponse.js +1 -3
  203. package/dist/core/api/v3/parser/getOperationResponses.js +1 -1
  204. package/dist/core/api/v3/parser/getServices.d.ts.map +1 -1
  205. package/dist/core/api/v3/parser/getServices.js +4 -3
  206. package/dist/core/api/v3/parser/getType.d.ts.map +1 -1
  207. package/dist/core/api/v3/parser/getType.js +4 -3
  208. package/dist/core/index.d.ts.map +1 -1
  209. package/dist/core/index.js +2 -0
  210. package/dist/core/types/base/Templates.model.d.ts +1 -1
  211. package/dist/core/types/base/Templates.model.d.ts.map +1 -1
  212. package/dist/core/types/enums/EmptySchemaStrategy.enum.d.ts +6 -0
  213. package/dist/core/types/enums/EmptySchemaStrategy.enum.d.ts.map +1 -0
  214. package/dist/core/types/enums/EmptySchemaStrategy.enum.js +9 -0
  215. package/dist/core/utils/__tests__/getRelativeModelPath.test.js +9 -3
  216. package/dist/core/utils/__tests__/isSubdirectory.test.js +2 -2
  217. package/dist/core/utils/__tests__/modelHelpers.test.d.ts +2 -0
  218. package/dist/core/utils/__tests__/modelHelpers.test.d.ts.map +1 -0
  219. package/dist/core/utils/__tests__/modelHelpers.test.js +151 -0
  220. package/dist/core/utils/__tests__/postProcessModelImports.test.d.ts +2 -0
  221. package/dist/core/utils/__tests__/postProcessModelImports.test.d.ts.map +1 -0
  222. package/dist/core/utils/__tests__/postProcessModelImports.test.js +67 -0
  223. package/dist/core/utils/__tests__/postProcessServiceImports.test.d.ts +2 -0
  224. package/dist/core/utils/__tests__/postProcessServiceImports.test.d.ts.map +1 -0
  225. package/dist/core/utils/__tests__/postProcessServiceImports.test.js +26 -0
  226. package/dist/core/utils/__tests__/resolveRefPath.test.d.ts +2 -0
  227. package/dist/core/utils/__tests__/resolveRefPath.test.d.ts.map +1 -0
  228. package/dist/core/utils/__tests__/resolveRefPath.test.js +22 -0
  229. package/dist/core/utils/__tests__/serviceHelpers.test.d.ts +2 -0
  230. package/dist/core/utils/__tests__/serviceHelpers.test.d.ts.map +1 -0
  231. package/dist/core/utils/__tests__/serviceHelpers.test.js +121 -0
  232. package/dist/core/utils/__tests__/writeClientExecutor.test.d.ts +2 -0
  233. package/dist/core/utils/__tests__/writeClientExecutor.test.d.ts.map +1 -0
  234. package/dist/core/utils/__tests__/writeClientExecutor.test.js +20 -0
  235. package/dist/core/utils/__tests__/writeClientSchemas.test.js +2 -0
  236. package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
  237. package/dist/core/utils/getOpenApiSpec.js +14 -1
  238. package/dist/core/utils/modelHelpers.d.ts.map +1 -1
  239. package/dist/core/utils/modelHelpers.js +37 -3
  240. package/dist/core/utils/postProcessModelImports.d.ts.map +1 -1
  241. package/dist/core/utils/postProcessModelImports.js +14 -1
  242. package/dist/core/utils/postProcessServiceImports.d.ts.map +1 -1
  243. package/dist/core/utils/postProcessServiceImports.js +1 -2
  244. package/dist/core/utils/precompileTemplates.js +1 -0
  245. package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
  246. package/dist/core/utils/registerHandlebarHelpers.js +25 -0
  247. package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
  248. package/dist/core/utils/registerHandlebarTemplates.js +42 -41
  249. package/dist/core/utils/resolveRefPath.d.ts.map +1 -1
  250. package/dist/core/utils/resolveRefPath.js +1 -4
  251. package/dist/core/utils/serviceHelpers.d.ts.map +1 -1
  252. package/dist/core/utils/serviceHelpers.js +32 -6
  253. package/dist/core/utils/validateRawOptions.d.ts +3 -0
  254. package/dist/core/utils/validateRawOptions.d.ts.map +1 -0
  255. package/dist/core/utils/validateRawOptions.js +15 -0
  256. package/dist/core/utils/writeClientExecutor.d.ts +4 -1
  257. package/dist/core/utils/writeClientExecutor.d.ts.map +1 -1
  258. package/dist/core/utils/writeClientExecutor.js +17 -2
  259. package/dist/core/utils/writeClientSchemas.d.ts +4 -1
  260. package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
  261. package/dist/core/utils/writeClientSchemas.js +11 -2
  262. package/dist/templatesCompiled/client/core/ApiError.js +1 -1
  263. package/dist/templatesCompiled/client/core/ApiResult.js +1 -1
  264. package/dist/templatesCompiled/client/core/axios/request.js +3 -3
  265. package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.d.ts +2 -0
  266. package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.d.ts.map +1 -1
  267. package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.js +13 -8
  268. package/dist/templatesCompiled/client/core/executor/requestExecutor.js +1 -1
  269. package/dist/templatesCompiled/client/core/fetch/request.js +3 -3
  270. package/dist/templatesCompiled/client/core/functions/catchErrors.js +1 -1
  271. package/dist/templatesCompiled/client/core/interceptors/withInterceptors.js +1 -1
  272. package/dist/templatesCompiled/client/core/node/request.js +3 -3
  273. package/dist/templatesCompiled/client/core/xhr/request.js +3 -3
  274. package/dist/templatesCompiled/client/exportClient.d.ts +4 -0
  275. package/dist/templatesCompiled/client/exportClient.d.ts.map +1 -1
  276. package/dist/templatesCompiled/client/exportClient.js +51 -13
  277. package/dist/templatesCompiled/client/exportSchema.d.ts +5 -1
  278. package/dist/templatesCompiled/client/exportSchema.d.ts.map +1 -1
  279. package/dist/templatesCompiled/client/exportSchema.js +37 -7
  280. package/dist/templatesCompiled/client/exportService.d.ts +2 -0
  281. package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
  282. package/dist/templatesCompiled/client/exportService.js +71 -31
  283. package/dist/templatesCompiled/client/indexFull.d.ts +1 -0
  284. package/dist/templatesCompiled/client/indexFull.d.ts.map +1 -1
  285. package/dist/templatesCompiled/client/indexFull.js +4 -1
  286. package/dist/templatesCompiled/client/indexSimple.d.ts +1 -0
  287. package/dist/templatesCompiled/client/indexSimple.d.ts.map +1 -1
  288. package/dist/templatesCompiled/client/indexSimple.js +4 -1
  289. package/dist/templatesCompiled/client/joi/exportSchema.js +5 -5
  290. package/dist/templatesCompiled/client/joi/partials/joiSchema.js +7 -7
  291. package/dist/templatesCompiled/client/joi/partials/joiSchemaComposition.js +4 -4
  292. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.d.ts +5 -3
  293. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.d.ts.map +1 -1
  294. package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.js +39 -12
  295. package/dist/templatesCompiled/client/jsonschema/exportSchema.js +5 -5
  296. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchema.js +7 -7
  297. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaArray.js +5 -5
  298. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaComposition.js +2 -2
  299. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaDictionary.js +5 -5
  300. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts +3 -1
  301. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts.map +1 -1
  302. package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.js +45 -15
  303. package/dist/templatesCompiled/client/partials/exportComposition.d.ts +2 -0
  304. package/dist/templatesCompiled/client/partials/exportComposition.d.ts.map +1 -1
  305. package/dist/templatesCompiled/client/partials/exportComposition.js +17 -9
  306. package/dist/templatesCompiled/client/yup/exportSchema.js +3 -3
  307. package/dist/templatesCompiled/client/yup/partials/yupSchema.js +7 -7
  308. package/dist/templatesCompiled/client/yup/partials/yupSchemaComposition.js +4 -4
  309. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.d.ts +5 -3
  310. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.d.ts.map +1 -1
  311. package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.js +39 -12
  312. package/dist/templatesCompiled/client/zod/exportSchema.js +3 -3
  313. package/dist/templatesCompiled/client/zod/partials/zodSchema.js +7 -7
  314. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts +5 -6
  315. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts.map +1 -1
  316. package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.js +14 -28
  317. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts +3 -0
  318. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts.map +1 -1
  319. package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.js +32 -8
  320. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts +3 -4
  321. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts.map +1 -1
  322. package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.js +9 -23
  323. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts +4 -2
  324. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts.map +1 -1
  325. package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.js +18 -7
  326. package/package.json +2 -2
  327. package/dist/cli/validation/errorFormatter.d.ts +0 -6
  328. package/dist/cli/validation/errorFormatter.d.ts.map +0 -1
  329. package/dist/cli/validation/index.d.ts +0 -3
  330. package/dist/cli/validation/index.d.ts.map +0 -1
  331. package/dist/cli/validation/validateCLIOptions.d.ts.map +0 -1
  332. package/dist/common/VersionedSchema/Utils/getErrorFieldsFromValidation.d.ts +0 -6
  333. package/dist/common/VersionedSchema/Utils/getErrorFieldsFromValidation.d.ts.map +0 -1
  334. package/dist/common/VersionedSchema/Utils/getErrorFieldsFromValidation.js +0 -7
  335. package/dist/common/VersionedSchema/Utils/joiHandlers.d.ts +0 -6
  336. package/dist/common/VersionedSchema/Utils/joiHandlers.d.ts.map +0 -1
  337. package/dist/common/VersionedSchema/Utils/joiHandlers.js +0 -59
  338. package/dist/common/VersionedSchema/Utils/mergeObjectSchemas.d.ts +0 -3
  339. package/dist/common/VersionedSchema/Utils/mergeObjectSchemas.d.ts.map +0 -1
  340. package/dist/common/VersionedSchema/Utils/mergeObjectSchemas.js +0 -12
  341. package/dist/common/VersionedSchema/Utils/traverseObjectStructure.d.ts +0 -3
  342. package/dist/common/VersionedSchema/Utils/traverseObjectStructure.d.ts.map +0 -1
  343. package/dist/common/VersionedSchema/Utils/traverseObjectStructure.js +0 -31
  344. package/dist/common/defaultOptions.d.ts +0 -3
  345. package/dist/common/defaultOptions.d.ts.map +0 -1
  346. package/dist/common/defaultOptions.js +0 -28
  347. package/dist/common/schemas/configSchemas.d.ts +0 -91
  348. package/dist/common/schemas/configSchemas.d.ts.map +0 -1
  349. package/dist/common/schemas/configSchemas.js +0 -131
  350. package/dist/common/utils/__tests__/__mock__/mockJoiSchema.d.ts +0 -19
  351. package/dist/common/utils/__tests__/__mock__/mockJoiSchema.d.ts.map +0 -1
  352. package/dist/common/utils/__tests__/__mock__/mockJoiSchema.js +0 -14
  353. package/dist/common/utils/__tests__/determineBestMatchingSchemaVersion.test.d.ts +0 -2
  354. package/dist/common/utils/__tests__/determineBestMatchingSchemaVersion.test.d.ts.map +0 -1
  355. package/dist/common/utils/__tests__/determineBestMatchingSchemaVersion.test.js +0 -38
  356. package/dist/common/utils/__tests__/getUniqueKeysFromSchemas.test.d.ts +0 -2
  357. package/dist/common/utils/__tests__/getUniqueKeysFromSchemas.test.d.ts.map +0 -1
  358. package/dist/common/utils/__tests__/getUniqueKeysFromSchemas.test.js +0 -20
  359. package/dist/common/utils/__tests__/mergeObjectSchemas.test.d.ts +0 -2
  360. package/dist/common/utils/__tests__/mergeObjectSchemas.test.d.ts.map +0 -1
  361. package/dist/common/utils/__tests__/mergeObjectSchemas.test.js +0 -35
  362. package/dist/common/utils/__tests__/migrationForMultiOptions.test.d.ts +0 -2
  363. package/dist/common/utils/__tests__/migrationForMultiOptions.test.d.ts.map +0 -1
  364. package/dist/common/utils/__tests__/migrationForMultiOptions.test.js +0 -112
  365. package/dist/common/utils/__tests__/migrationForOptions.test.d.ts +0 -2
  366. package/dist/common/utils/__tests__/migrationForOptions.test.d.ts.map +0 -1
  367. package/dist/common/utils/__tests__/migrationForOptions.test.js +0 -56
  368. package/dist/core/utils/advancedDeduplicatePath.d.ts +0 -5
  369. package/dist/core/utils/advancedDeduplicatePath.d.ts.map +0 -1
  370. package/dist/core/utils/advancedDeduplicatePath.js +0 -29
@@ -1,41 +1,86 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.determineBestMatchingSchemaVersion = determineBestMatchingSchemaVersion;
4
- const getErrorFieldsFromValidation_1 = require("./getErrorFieldsFromValidation");
4
+ const validateZodOptions_1 = require("../../Validation/validateZodOptions");
5
5
  const getUniqueKeysFromSchemas_1 = require("./getUniqueKeysFromSchemas");
6
6
  const getUniqueObjectKeys_1 = require("./getUniqueObjectKeys");
7
- // Determining the most appropriate schema version
7
+ /**
8
+ * Counts unknown keys using a strict schema variant.
9
+ * The strict check is used only for ranking candidates, not for final validation.
10
+ */
11
+ function getStrictUnrecognizedKeyCount(schema, inputData) {
12
+ const strictResult = (0, validateZodOptions_1.validateZodOptionsRaw)(schema.strict(), inputData);
13
+ if (strictResult.success) {
14
+ return 0;
15
+ }
16
+ return strictResult.error.issues.reduce((count, issue) => {
17
+ if (issue.code !== 'unrecognized_keys' || !('keys' in issue)) {
18
+ return count;
19
+ }
20
+ return count + issue.keys.length;
21
+ }, 0);
22
+ }
23
+ /**
24
+ * Compares two schema candidates and returns the better one.
25
+ * Priority:
26
+ * 1) fewer structural errors;
27
+ * 2) fewer strict-mode unknown keys;
28
+ * 3) more matching keys;
29
+ * 4) newer version inside the same schema family;
30
+ * 5) lower index when schema families differ.
31
+ */
32
+ function compareCandidates(best, current) {
33
+ if (current.structuralErrorCount !== best.structuralErrorCount) {
34
+ return current.structuralErrorCount < best.structuralErrorCount ? current : best;
35
+ }
36
+ if (current.strictUnrecognizedKeyCount !== best.strictUnrecognizedKeyCount) {
37
+ return current.strictUnrecognizedKeyCount < best.strictUnrecognizedKeyCount ? current : best;
38
+ }
39
+ if (current.matchingKeysCount !== best.matchingKeysCount) {
40
+ return current.matchingKeysCount > best.matchingKeysCount ? current : best;
41
+ }
42
+ if (current.type === best.type) {
43
+ return current.index > best.index ? current : best;
44
+ }
45
+ return current.index < best.index ? current : best;
46
+ }
47
+ /**
48
+ * Determines the best matching schema version for input data.
49
+ * `invalid_value` issues are intentionally ignored to allow migration from older enum/value variants.
50
+ */
8
51
  function determineBestMatchingSchemaVersion(inputData, versionedSchemas) {
9
52
  if (!versionedSchemas.length) {
10
53
  throw new Error('The list of schemes cannot be empty');
11
54
  }
12
55
  const inputKeys = (0, getUniqueObjectKeys_1.getUniqueObjectKeys)(inputData);
13
- const matchingSchemas = versionedSchemas
14
- .map(({ schema, version }, idx) => {
15
- const { error } = schema.validate(inputData, { allowUnknown: true });
16
- const errorFields = (0, getErrorFieldsFromValidation_1.getErrorFieldsFromValidation)(error).filter(err => err.type !== 'any.only');
17
- return errorFields.length === 0 ? { version, index: idx } : null;
18
- })
19
- .filter((match) => match !== null);
20
- if (matchingSchemas.length > 0) {
21
- const latestMatch = matchingSchemas.reduce((prev, curr) => (curr.index > prev.index ? curr : prev));
56
+ const schemaMatches = versionedSchemas.map(({ schema, baseSchema, version, type }, idx) => {
57
+ const schemaKeys = (0, getUniqueKeysFromSchemas_1.getUniqueKeysFromSchemas)([schema]);
58
+ const matchingKeysCount = inputKeys.filter(key => schemaKeys.has(key)).length;
59
+ const strictUnrecognizedKeyCount = getStrictUnrecognizedKeyCount(baseSchema, inputData);
60
+ const validationResult = (0, validateZodOptions_1.validateZodOptionsRaw)(schema, inputData);
61
+ const structuralErrorCount = !validationResult.success
62
+ ? validationResult.error.issues.filter(issue => issue.code !== 'invalid_value').length
63
+ : 0;
22
64
  return {
23
- lastVersionIndex: latestMatch.index,
24
- latestVersion: latestMatch.version,
25
- firstVersion: matchingSchemas[0].version,
65
+ index: idx,
66
+ version,
67
+ type,
68
+ structuralErrorCount,
69
+ strictUnrecognizedKeyCount,
70
+ matchingKeysCount,
26
71
  };
27
- }
28
- const schemaMatches = versionedSchemas.map(({ schema, version }, idx) => {
29
- const schemaKeys = (0, getUniqueKeysFromSchemas_1.getUniqueKeysFromSchemas)([schema]);
30
- const { error } = schema.validate(inputData, { allowUnknown: true });
31
- const errorFields = (0, getErrorFieldsFromValidation_1.getErrorFieldsFromValidation)(error).filter(err => err.type !== 'any.only');
32
- const matchingKeys = inputKeys.filter(key => schemaKeys.has(key));
33
- return { index: idx, version, errorFields, matchingKeys };
34
72
  });
35
- const bestMatch = schemaMatches.reduce((best, current) => {
36
- const isBetterMatch = current.matchingKeys.length >= best.matchingKeys.length && current.errorFields.length <= best.errorFields.length;
37
- return isBetterMatch ? current : best;
38
- }, schemaMatches[0]);
73
+ const structurallyValidMatches = schemaMatches.filter(match => match.structuralErrorCount === 0);
74
+ if (structurallyValidMatches.length > 0) {
75
+ const bestStructurallyValidMatch = structurallyValidMatches.reduce(compareCandidates);
76
+ const firstVersion = structurallyValidMatches.reduce((earliest, current) => (current.index < earliest.index ? current : earliest)).version;
77
+ return {
78
+ lastVersionIndex: bestStructurallyValidMatch.index,
79
+ latestVersion: bestStructurallyValidMatch.version,
80
+ firstVersion,
81
+ };
82
+ }
83
+ const bestMatch = schemaMatches.reduce(compareCandidates);
39
84
  return {
40
85
  lastVersionIndex: bestMatch.index,
41
86
  latestVersion: bestMatch.version,
@@ -1,3 +1,3 @@
1
- import Joi from "joi";
2
- export declare function getCurrentErrorMessage(error: Joi.ValidationError, replaicingKeysMap: Map<string, string>): void;
1
+ import { z } from 'zod';
2
+ export declare function getCurrentErrorMessage(error: z.ZodError, replaicingKeysMap: Map<string, string>): void;
3
3
  //# sourceMappingURL=getCurrentErrorMessage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getCurrentErrorMessage.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/getCurrentErrorMessage.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAKtB,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,GAAG,CAAC,eAAe,EAAE,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,QAQxG"}
1
+ {"version":3,"file":"getCurrentErrorMessage.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/getCurrentErrorMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,QAqB/F"}
@@ -1,14 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCurrentErrorMessage = getCurrentErrorMessage;
4
- const getErrorFieldsFromValidation_1 = require("./getErrorFieldsFromValidation");
4
+ const formatZodError_1 = require("../../Validation/formatZodError");
5
5
  const getKeyByMapValue_1 = require("./getKeyByMapValue");
6
6
  function getCurrentErrorMessage(error, replaicingKeysMap) {
7
- const { path } = (0, getErrorFieldsFromValidation_1.getErrorFieldsFromValidation)(error)[0];
8
- const reverseKey = (0, getKeyByMapValue_1.getKeyByMapValue)(replaicingKeysMap, path);
9
- let currentMessage = error.message;
10
- if (reverseKey) {
11
- currentMessage = error.message.replace(path, reverseKey);
7
+ if (!error || error.issues.length === 0) {
8
+ return;
12
9
  }
13
- throw new Error(currentMessage);
10
+ const messages = new Set();
11
+ error.issues.forEach(issue => {
12
+ const path = (0, formatZodError_1.formatZodPath)(issue.path);
13
+ const reverseKey = (0, getKeyByMapValue_1.getKeyByMapValue)(replaicingKeysMap, path);
14
+ let currentMessage = issue.message;
15
+ if (reverseKey) {
16
+ currentMessage = error.message.replace(path, reverseKey);
17
+ }
18
+ messages.add(currentMessage);
19
+ });
20
+ const result = Array.from(messages.values());
21
+ throw new Error(result.join('\n'));
14
22
  }
@@ -1,8 +1,8 @@
1
- import Joi from 'joi';
1
+ import { z } from 'zod';
2
2
  /**
3
3
  * Get all the unique parameter keys of all Joi schemes in the array
4
- * @param schemas array of joi schemes
4
+ * @param schemas array of zod schemes
5
5
  * @returns All the unique parameter keys of all Joi schemes in the array
6
6
  */
7
- export declare function getUniqueKeysFromSchemas(schemas: Joi.Schema[]): Set<string>;
7
+ export declare function getUniqueKeysFromSchemas(schemas: z.ZodTypeAny[]): Set<string>;
8
8
  //# sourceMappingURL=getUniqueKeysFromSchemas.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getUniqueKeysFromSchemas.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/getUniqueKeysFromSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAKtB;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,eAQ7D"}
1
+ {"version":3,"file":"getUniqueKeysFromSchemas.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/getUniqueKeysFromSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqBxB;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,CAAC,CAAC,UAAU,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAQ7E"}
@@ -1,17 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getUniqueKeysFromSchemas = getUniqueKeysFromSchemas;
4
- const joiHandlers_1 = require("./joiHandlers");
5
- const traverseObjectStructure_1 = require("./traverseObjectStructure");
4
+ const zod_1 = require("zod");
5
+ function collectKeys(schema, result) {
6
+ if (!(schema instanceof zod_1.z.ZodObject)) {
7
+ return;
8
+ }
9
+ const shape = schema.shape;
10
+ for (const key of Object.keys(shape)) {
11
+ result.add(key);
12
+ const fieldSchema = shape[key];
13
+ // если поле — вложенный объект, идём глубже
14
+ if (fieldSchema instanceof zod_1.z.ZodObject) {
15
+ collectKeys(fieldSchema, result);
16
+ }
17
+ }
18
+ }
6
19
  /**
7
20
  * Get all the unique parameter keys of all Joi schemes in the array
8
- * @param schemas array of joi schemes
21
+ * @param schemas array of zod schemes
9
22
  * @returns All the unique parameter keys of all Joi schemes in the array
10
23
  */
11
24
  function getUniqueKeysFromSchemas(schemas) {
12
25
  const result = new Set();
13
26
  for (const schema of schemas) {
14
- (0, traverseObjectStructure_1.traverseObjectStructure)(schema, [joiHandlers_1.handleJoiSchema, joiHandlers_1.handleJoiDescription], result);
27
+ collectKeys(schema, result);
15
28
  }
16
29
  return result;
17
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getUniqueObjectKeys.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/getUniqueObjectKeys.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAKhE"}
1
+ {"version":3,"file":"getUniqueObjectKeys.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/getUniqueObjectKeys.ts"],"names":[],"mappings":"AAmBA;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,YAKhE"}
@@ -1,7 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getUniqueObjectKeys = getUniqueObjectKeys;
4
- const traverseObjectStructure_1 = require("./traverseObjectStructure");
4
+ function collectUniqueObjectKeys(root, result) {
5
+ const recurse = (v) => collectUniqueObjectKeys(v, result);
6
+ if (root && typeof root === 'object') {
7
+ if (Array.isArray(root)) {
8
+ for (const item of root) {
9
+ recurse(item);
10
+ }
11
+ }
12
+ else {
13
+ for (const key of Object.keys(root)) {
14
+ if (result instanceof Set) {
15
+ result.add(key);
16
+ }
17
+ recurse(root[key]);
18
+ }
19
+ }
20
+ }
21
+ }
5
22
  /**
6
23
  * Get unique keys from object properties (set of options)
7
24
  * @param rawInput object properties (set of options)
@@ -9,6 +26,6 @@ const traverseObjectStructure_1 = require("./traverseObjectStructure");
9
26
  */
10
27
  function getUniqueObjectKeys(rawInput) {
11
28
  const result = new Set();
12
- (0, traverseObjectStructure_1.traverseObjectStructure)(rawInput, [], result);
29
+ collectUniqueObjectKeys(rawInput, result);
13
30
  return Array.from(result);
14
31
  }
@@ -1,18 +1,29 @@
1
+ import { z } from 'zod';
1
2
  import { EMigrationMode } from '../../Enums';
2
3
  import { EVersionedSchemaType } from '../Enums';
3
4
  import { SchemaMigrationPlan, VersionedSchema, VersionMatchResult } from '../Types';
5
+ /**
6
+ * Input arguments for migrating arbitrary config data to the latest schema version.
7
+ */
4
8
  type MigrateToLatestProps = {
5
9
  rawInput: Record<string, any>;
6
10
  migrationPlans: SchemaMigrationPlan<Record<string, any>, Record<string, any>>[];
7
- versionedSchemas: VersionedSchema<Record<string, any>>[];
11
+ versionedSchemas: VersionedSchema<z.ZodTypeAny>[];
8
12
  migrationMode: EMigrationMode;
9
13
  };
14
+ /**
15
+ * Result of successful migration to the latest schema.
16
+ */
10
17
  type MigrateToLatestResult = {
11
18
  value: Record<string, any>;
12
19
  guessedVersion: VersionMatchResult;
13
20
  schemaVersion: string;
14
21
  schemaType: EVersionedSchemaType;
15
22
  };
23
+ /**
24
+ * Migrates raw input through the migration graph to the latest schema version.
25
+ * Migration path is resolved by `fromVersion -> toVersion` links from `migrationPlans`.
26
+ */
16
27
  export declare function migrateDataToLatestSchemaVersion({ rawInput, migrationPlans, versionedSchemas, migrationMode }: MigrateToLatestProps): MigrateToLatestResult | null;
17
28
  export {};
18
29
  //# sourceMappingURL=migrateDataToLatestSchemaVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"migrateDataToLatestSchemaVersion.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AASpF,KAAK,oBAAoB,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,cAAc,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;IAChF,gBAAgB,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;IACzD,aAAa,EAAE,cAAc,CAAC;CACjC,CAAC;AAEF,KAAK,qBAAqB,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,cAAc,EAAE,kBAAkB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,oBAAoB,CAAC;CACpC,CAAC;AAEF,wBAAgB,gCAAgC,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,EAAE,oBAAoB,GAAG,qBAAqB,GAAG,IAAI,CAiElK"}
1
+ {"version":3,"file":"migrateDataToLatestSchemaVersion.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AASpF;;GAEG;AACH,KAAK,oBAAoB,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,cAAc,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;IAChF,gBAAgB,EAAE,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC;IAClD,aAAa,EAAE,cAAc,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,KAAK,qBAAqB,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,cAAc,EAAE,kBAAkB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,oBAAoB,CAAC;CACpC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,EAAE,oBAAoB,GAAG,qBAAqB,GAAG,IAAI,CAoFlK"}
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.migrateDataToLatestSchemaVersion = migrateDataToLatestSchemaVersion;
4
+ const Consts_1 = require("../../Consts");
4
5
  const Enums_1 = require("../../Enums");
6
+ const validateZodOptions_1 = require("../../Validation/validateZodOptions");
5
7
  const determineBestMatchingSchemaVersion_1 = require("./determineBestMatchingSchemaVersion");
6
8
  const generateKeyMappingForInvalidKeys_1 = require("./generateKeyMappingForInvalidKeys");
7
9
  const getCurrentErrorMessage_1 = require("./getCurrentErrorMessage");
@@ -9,6 +11,10 @@ const getUniqueKeysFromSchemas_1 = require("./getUniqueKeysFromSchemas");
9
11
  const getUniqueObjectKeys_1 = require("./getUniqueObjectKeys");
10
12
  const replaceInvalidKeysWithMappedNames_1 = require("./replaceInvalidKeysWithMappedNames");
11
13
  const validateAndSuggestKeyCorrections_1 = require("./validateAndSuggestKeyCorrections");
14
+ /**
15
+ * Migrates raw input through the migration graph to the latest schema version.
16
+ * Migration path is resolved by `fromVersion -> toVersion` links from `migrationPlans`.
17
+ */
12
18
  function migrateDataToLatestSchemaVersion({ rawInput, migrationPlans, versionedSchemas, migrationMode }) {
13
19
  const schemas = versionedSchemas.map(el => el.schema);
14
20
  const allUniqueKeysFromSchemas = (0, getUniqueKeysFromSchemas_1.getUniqueKeysFromSchemas)(schemas);
@@ -19,39 +25,52 @@ function migrateDataToLatestSchemaVersion({ rawInput, migrationPlans, versionedS
19
25
  const schemaPossibleKeys = (0, getUniqueKeysFromSchemas_1.getUniqueKeysFromSchemas)([guessedValidationSchema]);
20
26
  const replacingKeysMap = (0, generateKeyMappingForInvalidKeys_1.generateKeyMappingForInvalidKeys)(allUniqueKeysFromRawInput, schemaPossibleKeys);
21
27
  let currentData = replacingKeysMap.size ? (0, replaceInvalidKeysWithMappedNames_1.replaceInvalidKeysWithMappedNames)(rawInput, replacingKeysMap) : rawInput;
22
- const actualVersionIndex = versionedSchemas.length - 1;
23
- const actualSchema = versionedSchemas[actualVersionIndex];
24
- for (let idx = guessedVersion.lastVersionIndex; idx < versionedSchemas.length - 1; idx++) {
25
- const currentVersionSchema = versionedSchemas[idx];
26
- const { error: firstError } = currentVersionSchema.schema.validate(currentData);
27
- if (firstError) {
28
- (0, getCurrentErrorMessage_1.getCurrentErrorMessage)(firstError, replacingKeysMap);
28
+ const actualSchema = versionedSchemas[versionedSchemas.length - 1];
29
+ const schemasByVersion = new Map(versionedSchemas.map(schemaInfo => [schemaInfo.version, schemaInfo.schema]));
30
+ const migrationPlanByFromVersion = new Map(migrationPlans.map(plan => [plan.fromVersion, plan]));
31
+ let currentVersion = guessedVersion.latestVersion;
32
+ const visitedVersions = new Set([currentVersion]);
33
+ while (currentVersion !== actualSchema.version) {
34
+ const currentVersionSchema = schemasByVersion.get(currentVersion);
35
+ if (!currentVersionSchema) {
36
+ throw new Error(`No schema found for version ${currentVersion}.`);
29
37
  }
30
- const fromVersion = currentVersionSchema.version;
31
- const migrationPlan = migrationPlans.find(p => p.fromVersion === fromVersion);
38
+ const firstValidationResult = (0, validateZodOptions_1.validateZodOptionsRaw)(currentVersionSchema, currentData);
39
+ if (!firstValidationResult.success) {
40
+ (0, getCurrentErrorMessage_1.getCurrentErrorMessage)(firstValidationResult.error, replacingKeysMap);
41
+ }
42
+ const migrationPlan = migrationPlanByFromVersion.get(currentVersion);
32
43
  if (!migrationPlan) {
33
- const availableVersions = migrationPlans.map(p => p.fromVersion).join(', ');
34
- throw new Error(`No migration plan from ${fromVersion}. ` +
44
+ const availableVersions = Array.from(migrationPlanByFromVersion.keys()).join(', ');
45
+ throw new Error(`No migration plan from ${currentVersion}. ` +
35
46
  `Available migration plans: ${availableVersions}. ` +
36
47
  `This usually means the migration chain is incomplete.`);
37
48
  }
38
- const toVersion = versionedSchemas[idx + 1].version;
49
+ const nextVersion = migrationPlan.toVersion;
50
+ const nextSchema = schemasByVersion.get(nextVersion);
51
+ if (!nextSchema) {
52
+ throw new Error(`Migration plan from ${migrationPlan.fromVersion} points to unknown schema version ${nextVersion}.`);
53
+ }
39
54
  const migratedRaw = migrationPlan.migrate(currentData);
40
- const { error } = versionedSchemas[idx + 1].schema.validate(migratedRaw, { allowUnknown: false });
41
- if (error) {
42
- throw new Error(`Migration from ${fromVersion} to ${toVersion} failed validation. ` +
43
- `Error: ${error.message}. ` +
55
+ const validationResult = (0, validateZodOptions_1.validateZodOptions)(nextSchema, migratedRaw);
56
+ if (!validationResult.success) {
57
+ throw new Error(`Migration from ${currentVersion} to ${nextVersion} failed validation. ` +
58
+ `Error: ${validationResult.errors.join('\n')}. ` +
44
59
  `Migration description: ${migrationPlan.description || 'No description provided'}.`);
45
60
  }
46
61
  currentData = { ...migratedRaw };
47
- const isLastIteration = idx + 1 === actualVersionIndex;
48
- if (isLastIteration && migrationMode === Enums_1.EMigrationMode.GENERATE_OPENAPI) {
49
- console.warn('Для выполнения генерации OpenApi потребовалось мигрировать схему Ваших данных на актуальную. Для обновленмя конфигурации в файле используйте команду `npm name_cli_tool update-config`');
62
+ currentVersion = nextVersion;
63
+ if (visitedVersions.has(currentVersion)) {
64
+ throw new Error(`Migration loop detected at version ${currentVersion}.`);
65
+ }
66
+ visitedVersions.add(currentVersion);
67
+ if (currentVersion === actualSchema.version && migrationMode === Enums_1.EMigrationMode.GENERATE_OPENAPI) {
68
+ Consts_1.APP_LOGGER.warn('To perform OpenAPI generation, it was necessary to migrate the schema of your data to the current one. To update the configuration in the file, use the command `npm openapi-codegen-cli update-config`');
50
69
  }
51
70
  }
52
- const { error } = actualSchema.schema.validate(currentData, { allowUnknown: false });
53
- if (error) {
54
- (0, getCurrentErrorMessage_1.getCurrentErrorMessage)(error, replacingKeysMap);
71
+ const validationResult = (0, validateZodOptions_1.validateZodOptionsRaw)(actualSchema.schema, currentData);
72
+ if (!validationResult.success) {
73
+ (0, getCurrentErrorMessage_1.getCurrentErrorMessage)(validationResult.error, replacingKeysMap);
55
74
  }
56
75
  return { value: currentData, guessedVersion, schemaVersion: actualSchema.version, schemaType: actualSchema.type };
57
76
  }
@@ -0,0 +1,4 @@
1
+ import { z } from 'zod';
2
+ import { TRawOptions } from "../../TRawOptions";
3
+ export declare function dependentOptionsRefinement(data: TRawOptions, ctx: z.RefinementCtx): void;
4
+ //# sourceMappingURL=dependentOptionsRefinement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependentOptionsRefinement.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/refinements/dependentOptionsRefinement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,aAAa,QA2C7E"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dependentOptionsRefinement = dependentOptionsRefinement;
4
+ function dependentOptionsRefinement(data, ctx) {
5
+ // Проверка: либо items, либо input+output должны быть указаны
6
+ const hasItems = data.items && data.items.length > 0;
7
+ const hasInputOutput = !!(data.input && data.output);
8
+ if (!hasItems && !hasInputOutput) {
9
+ ctx.addIssue({
10
+ code: 'custom',
11
+ message: 'Either "items" array or "input" + "output" must be provided',
12
+ path: [],
13
+ });
14
+ }
15
+ // Если есть items, то input и output в корне не должны быть указаны
16
+ if (hasItems && hasInputOutput) {
17
+ ctx.addIssue({
18
+ code: 'custom',
19
+ message: 'Cannot use both "items" array and "input"/"output" at the root level',
20
+ path: ['items'],
21
+ });
22
+ }
23
+ // Валидация: если excludeCoreServiceFiles === true, request не должен быть указан
24
+ if (data.excludeCoreServiceFiles === true && data.request) {
25
+ ctx.addIssue({
26
+ code: 'custom',
27
+ message: '"request" can only be used when "excludeCoreServiceFiles" is false',
28
+ path: ['request'],
29
+ });
30
+ }
31
+ // Валидация для каждого элемента в items
32
+ if (hasItems && data.items) {
33
+ data.items.forEach((item, index) => {
34
+ if (item.request && data.excludeCoreServiceFiles === true) {
35
+ ctx.addIssue({
36
+ code: 'custom',
37
+ message: '"request" in items can only be used when "excludeCoreServiceFiles" is false',
38
+ path: ['items', index, 'request'],
39
+ });
40
+ }
41
+ });
42
+ }
43
+ }
@@ -0,0 +1,4 @@
1
+ import { z } from 'zod';
2
+ import { unifiedOptionsShape } from '../AllVersionedSchemas/UnifiedBase';
3
+ export declare function singleOrMultiRefinement(data: z.infer<typeof unifiedOptionsShape>, ctx: z.RefinementCtx): void;
4
+ //# sourceMappingURL=singleOrMultiRefinement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"singleOrMultiRefinement.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/refinements/singleOrMultiRefinement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,aAAa,QAmBtG"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.singleOrMultiRefinement = singleOrMultiRefinement;
4
+ function singleOrMultiRefinement(data, ctx) {
5
+ const hasItems = !!data.items?.length;
6
+ const hasSingle = !!data.input;
7
+ if (hasItems && hasSingle) {
8
+ ctx.addIssue({
9
+ code: 'custom',
10
+ message: 'Use either items or input/output, but not both options.',
11
+ path: ['items'],
12
+ });
13
+ }
14
+ if (!hasItems && !hasSingle) {
15
+ ctx.addIssue({
16
+ code: 'custom',
17
+ message: 'You must specify either items or input/output',
18
+ path: ['input'],
19
+ });
20
+ }
21
+ }