ts-openapi-codegen 1.0.0-beta.5 → 1.0.0-beta.7

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 (368) hide show
  1. package/README.md +43 -58
  2. package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.d.ts +5 -0
  3. package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.d.ts.map +1 -0
  4. package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.js +40 -0
  5. package/dist/cli/generate/runGenerateOpenApi.js +4 -4
  6. package/dist/cli/index.js +57 -18
  7. package/dist/cli/utils.d.ts +4 -16
  8. package/dist/cli/utils.d.ts.map +1 -1
  9. package/dist/cli/utils.js +22 -20
  10. package/dist/common/Options.d.ts +4 -6
  11. package/dist/common/Options.d.ts.map +1 -1
  12. package/dist/common/UpdateNotifier.d.ts +24 -0
  13. package/dist/common/UpdateNotifier.d.ts.map +1 -0
  14. package/dist/common/UpdateNotifier.js +120 -0
  15. package/dist/common/Utils.d.ts.map +1 -1
  16. package/dist/common/Utils.js +8 -9
  17. package/dist/common/VersionedSchema/CommonSchemas.d.ts +12 -0
  18. package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
  19. package/dist/common/VersionedSchema/CommonSchemas.js +27 -1
  20. package/dist/common/VersionedSchema/{MultiOptionsMigrationPlan.d.ts → MultiOptionsVersioned/MultiOptionsMigrationPlan.d.ts} +1 -1
  21. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan.d.ts.map +1 -0
  22. package/dist/common/VersionedSchema/{MultiOptionsMigrationPlan.js → MultiOptionsVersioned/MultiOptionsMigrationPlan.js} +18 -7
  23. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts +6 -0
  24. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts.map +1 -0
  25. package/dist/common/VersionedSchema/{MultiOptionsSchemaV1.js → MultiOptionsVersioned/MultiOptionsSchemaV1.js} +4 -4
  26. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts +6 -0
  27. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts.map +1 -0
  28. package/dist/common/VersionedSchema/{MultiOptionsSchemaV2.js → MultiOptionsVersioned/MultiOptionsSchemaV2.js} +4 -4
  29. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts +5 -0
  30. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts.map +1 -0
  31. package/dist/common/VersionedSchema/{MultiOptionsSchemaV3.js → MultiOptionsVersioned/MultiOptionsSchemaV3.js} +3 -3
  32. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts +6 -0
  33. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts.map +1 -0
  34. package/dist/common/VersionedSchema/{MultiOptionsSchemaV4.js → MultiOptionsVersioned/MultiOptionsSchemaV4.js} +4 -4
  35. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts +6 -0
  36. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts.map +1 -0
  37. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.js +22 -0
  38. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas.d.ts +3 -0
  39. package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas.d.ts.map +1 -0
  40. package/dist/common/VersionedSchema/{MultiOptionsVersionedSchemas.js → MultiOptionsVersioned/MultiOptionsVersionedSchemas.js} +10 -5
  41. package/dist/common/VersionedSchema/{OptionsMigrationPlans.d.ts → OptionsVersioned/OptionsMigrationPlans.d.ts} +1 -1
  42. package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.d.ts.map +1 -0
  43. package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.js +23 -0
  44. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts +6 -0
  45. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts.map +1 -0
  46. package/dist/common/VersionedSchema/{OptionsSchemaV1.js → OptionsVersioned/OptionsSchemaV1.js} +4 -4
  47. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts +6 -0
  48. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts.map +1 -0
  49. package/dist/common/VersionedSchema/{OptionsSchemaV2.js → OptionsVersioned/OptionsSchemaV2.js} +4 -4
  50. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts +5 -0
  51. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts.map +1 -0
  52. package/dist/common/VersionedSchema/{OptionsSchemaV3.js → OptionsVersioned/OptionsSchemaV3.js} +3 -3
  53. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts +6 -0
  54. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts.map +1 -0
  55. package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.js +17 -0
  56. package/dist/common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas.d.ts +3 -0
  57. package/dist/common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas.d.ts.map +1 -0
  58. package/dist/common/VersionedSchema/{OptionsVersionedSchemas.js → OptionsVersioned/OptionsVersionedSchemas.js} +9 -4
  59. package/dist/common/VersionedSchema/Types.d.ts +0 -4
  60. package/dist/common/VersionedSchema/Types.d.ts.map +1 -1
  61. package/dist/common/__tests__/convertArrayToObject.test.js +62 -59
  62. package/dist/common/__tests__/mergeObjectSchemas.test.js +1 -1
  63. package/dist/common/__tests__/migrationForMultiOptions.test.js +9 -5
  64. package/dist/common/__tests__/migrationForOptions.test.js +17 -8
  65. package/dist/common/defaultOptions.d.ts.map +1 -1
  66. package/dist/common/defaultOptions.js +5 -7
  67. package/dist/core/Context.d.ts +15 -7
  68. package/dist/core/Context.d.ts.map +1 -1
  69. package/dist/core/Context.js +3 -0
  70. package/dist/core/WriteClient.d.ts +94 -0
  71. package/dist/core/WriteClient.d.ts.map +1 -0
  72. package/dist/core/WriteClient.js +293 -0
  73. package/dist/core/__tests__/WriteClient.test.d.ts +2 -0
  74. package/dist/core/__tests__/WriteClient.test.d.ts.map +1 -0
  75. package/dist/core/{utils/__tests__/writeClient.test.js → __tests__/WriteClient.test.js} +16 -12
  76. package/dist/core/api/v2/parser/__tests__/getType.test.js +7 -25
  77. package/dist/core/api/v2/parser/getModel.d.ts.map +1 -1
  78. package/dist/core/api/v2/parser/getModel.js +5 -2
  79. package/dist/core/api/v2/parser/getModelProperties.d.ts.map +1 -1
  80. package/dist/core/api/v2/parser/getModelProperties.js +3 -1
  81. package/dist/core/api/v2/parser/getModels.d.ts.map +1 -1
  82. package/dist/core/api/v2/parser/getModels.js +3 -29
  83. package/dist/core/api/v2/parser/getOperation.d.ts +1 -1
  84. package/dist/core/api/v2/parser/getOperation.d.ts.map +1 -1
  85. package/dist/core/api/v2/parser/getOperation.js +3 -3
  86. package/dist/core/api/v2/parser/getOperationParameter.d.ts +1 -1
  87. package/dist/core/api/v2/parser/getOperationParameter.d.ts.map +1 -1
  88. package/dist/core/api/v2/parser/getOperationParameter.js +4 -2
  89. package/dist/core/api/v2/parser/getOperationParameters.d.ts +1 -1
  90. package/dist/core/api/v2/parser/getOperationParameters.d.ts.map +1 -1
  91. package/dist/core/api/v2/parser/getOperationParameters.js +2 -2
  92. package/dist/core/api/v2/parser/getOperationResponse.d.ts.map +1 -1
  93. package/dist/core/api/v2/parser/getOperationResponse.js +3 -1
  94. package/dist/core/api/v2/parser/getOperationResponses.d.ts +1 -1
  95. package/dist/core/api/v2/parser/getOperationResponses.d.ts.map +1 -1
  96. package/dist/core/api/v2/parser/getOperationResponses.js +2 -2
  97. package/dist/core/api/v2/parser/getServiceName.d.ts +3 -0
  98. package/dist/core/api/v2/parser/getServiceName.d.ts.map +1 -0
  99. package/dist/core/api/v2/parser/getServiceName.js +8 -0
  100. package/dist/core/api/v2/parser/getServices.d.ts.map +1 -1
  101. package/dist/core/api/v2/parser/getServices.js +21 -32
  102. package/dist/core/api/v2/parser/getType.d.ts.map +1 -1
  103. package/dist/core/api/v2/parser/getType.js +13 -9
  104. package/dist/core/api/v3/parser/__tests__/getType.test.js +6 -24
  105. package/dist/core/api/v3/parser/getModel.d.ts.map +1 -1
  106. package/dist/core/api/v3/parser/getModel.js +5 -2
  107. package/dist/core/api/v3/parser/getModelProperties.d.ts.map +1 -1
  108. package/dist/core/api/v3/parser/getModelProperties.js +3 -1
  109. package/dist/core/api/v3/parser/getModels.d.ts.map +1 -1
  110. package/dist/core/api/v3/parser/getModels.js +3 -29
  111. package/dist/core/api/v3/parser/getOperation.d.ts +1 -1
  112. package/dist/core/api/v3/parser/getOperation.d.ts.map +1 -1
  113. package/dist/core/api/v3/parser/getOperation.js +4 -4
  114. package/dist/core/api/v3/parser/getOperationParameter.d.ts +1 -1
  115. package/dist/core/api/v3/parser/getOperationParameter.d.ts.map +1 -1
  116. package/dist/core/api/v3/parser/getOperationParameter.js +6 -3
  117. package/dist/core/api/v3/parser/getOperationParameters.d.ts +1 -1
  118. package/dist/core/api/v3/parser/getOperationParameters.d.ts.map +1 -1
  119. package/dist/core/api/v3/parser/getOperationParameters.js +2 -2
  120. package/dist/core/api/v3/parser/getOperationRequestBody.d.ts.map +1 -1
  121. package/dist/core/api/v3/parser/getOperationRequestBody.js +3 -1
  122. package/dist/core/api/v3/parser/getOperationResponse.d.ts.map +1 -1
  123. package/dist/core/api/v3/parser/getOperationResponse.js +3 -1
  124. package/dist/core/api/v3/parser/getOperationResponses.d.ts +1 -1
  125. package/dist/core/api/v3/parser/getOperationResponses.d.ts.map +1 -1
  126. package/dist/core/api/v3/parser/getOperationResponses.js +2 -2
  127. package/dist/core/api/v3/parser/getServiceName.d.ts +3 -0
  128. package/dist/core/api/v3/parser/getServiceName.d.ts.map +1 -0
  129. package/dist/core/api/v3/parser/getServiceName.js +8 -0
  130. package/dist/core/api/v3/parser/getServices.d.ts.map +1 -1
  131. package/dist/core/api/v3/parser/getServices.js +18 -84
  132. package/dist/core/api/v3/parser/getType.d.ts.map +1 -1
  133. package/dist/core/api/v3/parser/getType.js +22 -10
  134. package/dist/core/api/v3/types/OpenApiPath.model.d.ts +2 -1
  135. package/dist/core/api/v3/types/OpenApiPath.model.d.ts.map +1 -1
  136. package/dist/core/index.d.ts +1 -1
  137. package/dist/core/index.d.ts.map +1 -1
  138. package/dist/core/index.js +21 -22
  139. package/dist/core/types/base/ClientArtifacts.model.d.ts +12 -0
  140. package/dist/core/types/base/ClientArtifacts.model.d.ts.map +1 -0
  141. package/dist/core/types/base/ExportedModel.model.d.ts +17 -0
  142. package/dist/core/types/base/ExportedModel.model.d.ts.map +1 -0
  143. package/dist/core/types/base/ExportedService.model.d.ts +9 -0
  144. package/dist/core/types/base/ExportedService.model.d.ts.map +1 -0
  145. package/dist/core/types/base/ExportedService.model.js +2 -0
  146. package/dist/core/types/base/OutputPaths.model.d.ts +15 -0
  147. package/dist/core/types/base/OutputPaths.model.d.ts.map +1 -0
  148. package/dist/core/types/base/OutputPaths.model.js +2 -0
  149. package/dist/core/types/base/PrefixArtifacts.model.d.ts +6 -0
  150. package/dist/core/types/base/PrefixArtifacts.model.d.ts.map +1 -0
  151. package/dist/core/types/base/PrefixArtifacts.model.js +2 -0
  152. package/dist/core/types/base/PropertyGroup.model.d.ts +4 -0
  153. package/dist/core/types/base/PropertyGroup.model.d.ts.map +1 -0
  154. package/dist/core/types/base/PropertyGroup.model.js +2 -0
  155. package/dist/core/types/base/RefWithtype.model.d.ts +11 -0
  156. package/dist/core/types/base/RefWithtype.model.d.ts.map +1 -0
  157. package/dist/core/types/base/RefWithtype.model.js +2 -0
  158. package/dist/core/types/base/Root.model.d.ts +5 -0
  159. package/dist/core/types/base/Root.model.d.ts.map +1 -0
  160. package/dist/core/types/base/Root.model.js +2 -0
  161. package/dist/core/types/base/SimpleClientArtifacts.model.d.ts +10 -0
  162. package/dist/core/types/base/SimpleClientArtifacts.model.d.ts.map +1 -0
  163. package/dist/core/types/base/SimpleClientArtifacts.model.js +2 -0
  164. package/dist/core/types/enums/HttpClient.enum.d.ts +7 -0
  165. package/dist/core/types/enums/HttpClient.enum.d.ts.map +1 -0
  166. package/dist/core/types/{Enums.js → enums/HttpClient.enum.js} +1 -9
  167. package/dist/core/types/enums/TypeRef.enum.d.ts +8 -0
  168. package/dist/core/types/enums/TypeRef.enum.d.ts.map +1 -0
  169. package/dist/core/types/enums/TypeRef.enum.js +11 -0
  170. package/dist/core/utils/__tests__/getAbsolutePath.test.js +1 -1
  171. package/dist/core/utils/__tests__/getGatheringRefs.test.js +3 -6
  172. package/dist/core/utils/__tests__/getRefFromSchema.test.js +1 -1
  173. package/dist/core/utils/__tests__/pathHelpers.test.js +4 -4
  174. package/dist/core/utils/__tests__/refResolver.test.d.ts +2 -0
  175. package/dist/core/utils/__tests__/refResolver.test.d.ts.map +1 -0
  176. package/dist/core/utils/__tests__/refResolver.test.js +55 -0
  177. package/dist/core/utils/__tests__/registerHandlebarHelpers.test.js +2 -2
  178. package/dist/core/utils/__tests__/registerHandlebarTemplates.test.js +7 -3
  179. package/dist/core/utils/__tests__/resolveRefToImportPath.test.d.ts +2 -0
  180. package/dist/core/utils/__tests__/resolveRefToImportPath.test.d.ts.map +1 -0
  181. package/dist/core/utils/__tests__/resolveRefToImportPath.test.js +67 -0
  182. package/dist/core/utils/__tests__/sortByRequiredExtended.test.js +24 -24
  183. package/dist/core/utils/__tests__/sortByRequiredSimple.test.js +13 -13
  184. package/dist/core/utils/__tests__/writeClientCore.test.js +14 -6
  185. package/dist/core/utils/__tests__/writeClientFullIndex.test.d.ts +2 -0
  186. package/dist/core/utils/__tests__/writeClientFullIndex.test.d.ts.map +1 -0
  187. package/dist/core/utils/__tests__/{writeClientIndex.test.js → writeClientFullIndex.test.js} +15 -7
  188. package/dist/core/utils/__tests__/writeClientModels.test.js +15 -7
  189. package/dist/core/utils/__tests__/writeClientSchemas.test.js +15 -7
  190. package/dist/core/utils/__tests__/writeClientServices.test.js +15 -7
  191. package/dist/core/utils/advancedDeduplicatePath.d.ts +5 -0
  192. package/dist/core/utils/advancedDeduplicatePath.d.ts.map +1 -0
  193. package/dist/core/utils/advancedDeduplicatePath.js +29 -0
  194. package/dist/core/utils/appendUniqueLinesToFile.d.ts +2 -0
  195. package/dist/core/utils/appendUniqueLinesToFile.d.ts.map +1 -0
  196. package/dist/core/utils/appendUniqueLinesToFile.js +24 -0
  197. package/dist/core/utils/createNormalizedRef.d.ts +7 -0
  198. package/dist/core/utils/createNormalizedRef.d.ts.map +1 -0
  199. package/dist/core/utils/createNormalizedRef.js +24 -0
  200. package/dist/core/utils/findCommonParent.d.ts +7 -0
  201. package/dist/core/utils/findCommonParent.d.ts.map +1 -0
  202. package/dist/core/utils/findCommonParent.js +20 -0
  203. package/dist/core/utils/getAbsolutePath.d.ts.map +1 -1
  204. package/dist/core/utils/getAbsolutePath.js +16 -5
  205. package/dist/core/utils/getGatheringRefs.d.ts +2 -2
  206. package/dist/core/utils/getGatheringRefs.d.ts.map +1 -1
  207. package/dist/core/utils/getGatheringRefs.js +26 -17
  208. package/dist/core/utils/getMappedType.d.ts +0 -1
  209. package/dist/core/utils/getMappedType.d.ts.map +1 -1
  210. package/dist/core/utils/getMappedType.js +3 -4
  211. package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
  212. package/dist/core/utils/getOpenApiSpec.js +9 -32
  213. package/dist/core/utils/getOutputPaths.d.ts +2 -2
  214. package/dist/core/utils/getOutputPaths.d.ts.map +1 -1
  215. package/dist/core/utils/getPropertyGroupExtended.d.ts +2 -2
  216. package/dist/core/utils/getPropertyGroupExtended.d.ts.map +1 -1
  217. package/dist/core/utils/getPropertyGroupSimple.d.ts +2 -2
  218. package/dist/core/utils/getPropertyGroupSimple.d.ts.map +1 -1
  219. package/dist/core/utils/getRefFromSchema.js +2 -2
  220. package/dist/core/utils/getRelativeModelImportPath.js +1 -1
  221. package/dist/core/utils/getRelativeModelPath.d.ts.map +1 -1
  222. package/dist/core/utils/getRelativeModelPath.js +5 -0
  223. package/dist/core/utils/isDirectory.d.ts +2 -0
  224. package/dist/core/utils/isDirectory.d.ts.map +1 -0
  225. package/dist/core/utils/isDirectory.js +13 -0
  226. package/dist/core/utils/isFileName.d.ts +7 -0
  227. package/dist/core/utils/isFileName.d.ts.map +1 -0
  228. package/dist/core/utils/isFileName.js +30 -0
  229. package/dist/core/utils/mapPathToTargetDirSafe.d.ts +10 -0
  230. package/dist/core/utils/mapPathToTargetDirSafe.d.ts.map +1 -0
  231. package/dist/core/utils/mapPathToTargetDirSafe.js +49 -0
  232. package/dist/core/utils/modelHelpers.d.ts +28 -0
  233. package/dist/core/utils/modelHelpers.d.ts.map +1 -0
  234. package/dist/core/utils/modelHelpers.js +73 -0
  235. package/dist/core/utils/normalizeAllRefs.d.ts +6 -0
  236. package/dist/core/utils/normalizeAllRefs.d.ts.map +1 -0
  237. package/dist/core/utils/normalizeAllRefs.js +35 -0
  238. package/dist/core/utils/normalizePath.d.ts +5 -0
  239. package/dist/core/utils/normalizePath.d.ts.map +1 -0
  240. package/dist/core/utils/normalizePath.js +19 -0
  241. package/dist/core/utils/normalizeRef.d.ts +5 -0
  242. package/dist/core/utils/normalizeRef.d.ts.map +1 -0
  243. package/dist/core/utils/normalizeRef.js +17 -0
  244. package/dist/core/utils/parseRef.d.ts +18 -0
  245. package/dist/core/utils/parseRef.d.ts.map +1 -0
  246. package/dist/core/utils/parseRef.js +64 -0
  247. package/dist/core/utils/pathHelpers.d.ts +1 -0
  248. package/dist/core/utils/pathHelpers.d.ts.map +1 -1
  249. package/dist/core/utils/pathHelpers.js +23 -3
  250. package/dist/core/utils/prepareAlias.d.ts +3 -0
  251. package/dist/core/utils/prepareAlias.d.ts.map +1 -0
  252. package/dist/core/utils/prepareAlias.js +20 -0
  253. package/dist/core/utils/prepareOptions.d.ts.map +1 -1
  254. package/dist/core/utils/prepareOptions.js +5 -7
  255. package/dist/core/utils/registerHandlebarHelpers.d.ts +1 -1
  256. package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
  257. package/dist/core/utils/registerHandlebarTemplates.d.ts +9 -2
  258. package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
  259. package/dist/core/utils/registerHandlebarTemplates.js +16 -2
  260. package/dist/core/utils/resolveRefPath.d.ts +7 -0
  261. package/dist/core/utils/resolveRefPath.d.ts.map +1 -0
  262. package/dist/core/utils/resolveRefPath.js +34 -0
  263. package/dist/core/utils/resolveRefToImportPath.d.ts +7 -0
  264. package/dist/core/utils/resolveRefToImportPath.d.ts.map +1 -0
  265. package/dist/core/utils/resolveRefToImportPath.js +45 -0
  266. package/dist/core/utils/serviceHelpers.d.ts +41 -0
  267. package/dist/core/utils/serviceHelpers.d.ts.map +1 -0
  268. package/dist/core/utils/serviceHelpers.js +115 -0
  269. package/dist/core/utils/sortModelByName.d.ts +3 -0
  270. package/dist/core/utils/sortModelByName.d.ts.map +1 -0
  271. package/dist/core/utils/sortModelByName.js +12 -0
  272. package/dist/core/utils/writeClientCore.d.ts +4 -2
  273. package/dist/core/utils/writeClientCore.d.ts.map +1 -1
  274. package/dist/core/utils/writeClientCore.js +4 -1
  275. package/dist/core/utils/writeClientCoreIndex.d.ts +11 -0
  276. package/dist/core/utils/writeClientCoreIndex.d.ts.map +1 -0
  277. package/dist/core/utils/writeClientCoreIndex.js +16 -0
  278. package/dist/core/utils/writeClientFullIndex.d.ts +9 -0
  279. package/dist/core/utils/writeClientFullIndex.d.ts.map +1 -0
  280. package/dist/core/utils/writeClientFullIndex.js +22 -0
  281. package/dist/core/utils/writeClientModels.d.ts +3 -2
  282. package/dist/core/utils/writeClientModels.d.ts.map +1 -1
  283. package/dist/core/utils/writeClientModels.js +5 -0
  284. package/dist/core/utils/writeClientModelsIndex.d.ts +12 -0
  285. package/dist/core/utils/writeClientModelsIndex.d.ts.map +1 -0
  286. package/dist/core/utils/writeClientModelsIndex.js +16 -0
  287. package/dist/core/utils/writeClientSchemas.d.ts +3 -2
  288. package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
  289. package/dist/core/utils/writeClientSchemas.js +5 -0
  290. package/dist/core/utils/writeClientSchemasIndex.d.ts +12 -0
  291. package/dist/core/utils/writeClientSchemasIndex.d.ts.map +1 -0
  292. package/dist/core/utils/writeClientSchemasIndex.js +16 -0
  293. package/dist/core/utils/writeClientServices.d.ts +5 -4
  294. package/dist/core/utils/writeClientServices.d.ts.map +1 -1
  295. package/dist/core/utils/writeClientServices.js +4 -0
  296. package/dist/core/utils/writeClientServicesIndex.d.ts +12 -0
  297. package/dist/core/utils/writeClientServicesIndex.d.ts.map +1 -0
  298. package/dist/core/utils/writeClientServicesIndex.js +16 -0
  299. package/dist/core/utils/writeClientSimpleIndex.d.ts +9 -0
  300. package/dist/core/utils/writeClientSimpleIndex.d.ts.map +1 -0
  301. package/dist/core/utils/writeClientSimpleIndex.js +22 -0
  302. package/dist/templatesCompiled/exportModel.js +2 -2
  303. package/dist/templatesCompiled/indexCore.d.ts +9 -0
  304. package/dist/templatesCompiled/indexCore.d.ts.map +1 -0
  305. package/dist/templatesCompiled/indexCore.js +22 -0
  306. package/dist/templatesCompiled/{index.d.ts → indexFull.d.ts} +1 -1
  307. package/dist/templatesCompiled/indexFull.d.ts.map +1 -0
  308. package/dist/templatesCompiled/indexModels.d.ts +15 -0
  309. package/dist/templatesCompiled/indexModels.d.ts.map +1 -0
  310. package/dist/templatesCompiled/indexModels.js +82 -0
  311. package/dist/templatesCompiled/indexServices.d.ts +10 -0
  312. package/dist/templatesCompiled/indexServices.d.ts.map +1 -0
  313. package/dist/templatesCompiled/indexServices.js +35 -0
  314. package/dist/templatesCompiled/indexShemas.d.ts +11 -0
  315. package/dist/templatesCompiled/indexShemas.d.ts.map +1 -0
  316. package/dist/templatesCompiled/indexShemas.js +47 -0
  317. package/dist/templatesCompiled/indexSimple.d.ts +21 -0
  318. package/dist/templatesCompiled/indexSimple.d.ts.map +1 -0
  319. package/dist/templatesCompiled/indexSimple.js +121 -0
  320. package/dist/templatesCompiled/partials/isReadOnly.d.ts +1 -1
  321. package/dist/templatesCompiled/partials/isReadOnly.d.ts.map +1 -1
  322. package/dist/templatesCompiled/partials/isReadOnly.js +1 -2
  323. package/dist/templatesCompiled/partials/isRequiredDefinition.d.ts +9 -0
  324. package/dist/templatesCompiled/partials/isRequiredDefinition.d.ts.map +1 -0
  325. package/dist/templatesCompiled/partials/isRequiredDefinition.js +27 -0
  326. package/dist/templatesCompiled/partials/parametersDefinition.js +1 -1
  327. package/package.json +15 -4
  328. package/dist/common/VersionedSchema/MultiOptionsMigrationPlan.d.ts.map +0 -1
  329. package/dist/common/VersionedSchema/MultiOptionsSchemaV1.d.ts +0 -6
  330. package/dist/common/VersionedSchema/MultiOptionsSchemaV1.d.ts.map +0 -1
  331. package/dist/common/VersionedSchema/MultiOptionsSchemaV2.d.ts +0 -6
  332. package/dist/common/VersionedSchema/MultiOptionsSchemaV2.d.ts.map +0 -1
  333. package/dist/common/VersionedSchema/MultiOptionsSchemaV3.d.ts +0 -5
  334. package/dist/common/VersionedSchema/MultiOptionsSchemaV3.d.ts.map +0 -1
  335. package/dist/common/VersionedSchema/MultiOptionsSchemaV4.d.ts +0 -6
  336. package/dist/common/VersionedSchema/MultiOptionsSchemaV4.d.ts.map +0 -1
  337. package/dist/common/VersionedSchema/MultiOptionsVersionedSchemas.d.ts +0 -3
  338. package/dist/common/VersionedSchema/MultiOptionsVersionedSchemas.d.ts.map +0 -1
  339. package/dist/common/VersionedSchema/OptionsMigrationPlans.d.ts.map +0 -1
  340. package/dist/common/VersionedSchema/OptionsMigrationPlans.js +0 -15
  341. package/dist/common/VersionedSchema/OptionsSchemaV1.d.ts +0 -6
  342. package/dist/common/VersionedSchema/OptionsSchemaV1.d.ts.map +0 -1
  343. package/dist/common/VersionedSchema/OptionsSchemaV2.d.ts +0 -6
  344. package/dist/common/VersionedSchema/OptionsSchemaV2.d.ts.map +0 -1
  345. package/dist/common/VersionedSchema/OptionsSchemaV3.d.ts +0 -5
  346. package/dist/common/VersionedSchema/OptionsSchemaV3.d.ts.map +0 -1
  347. package/dist/common/VersionedSchema/OptionsVersionedSchemas.d.ts +0 -3
  348. package/dist/common/VersionedSchema/OptionsVersionedSchemas.d.ts.map +0 -1
  349. package/dist/core/types/Enums.d.ts +0 -14
  350. package/dist/core/types/Enums.d.ts.map +0 -1
  351. package/dist/core/types/Models.d.ts +0 -37
  352. package/dist/core/types/Models.d.ts.map +0 -1
  353. package/dist/core/types/shared/ConverterData.model.d.ts +0 -7
  354. package/dist/core/types/shared/ConverterData.model.d.ts.map +0 -1
  355. package/dist/core/utils/__tests__/writeClient.test.d.ts +0 -2
  356. package/dist/core/utils/__tests__/writeClient.test.d.ts.map +0 -1
  357. package/dist/core/utils/__tests__/writeClientIndex.test.d.ts +0 -2
  358. package/dist/core/utils/__tests__/writeClientIndex.test.d.ts.map +0 -1
  359. package/dist/core/utils/writeClient.d.ts +0 -89
  360. package/dist/core/utils/writeClient.d.ts.map +0 -1
  361. package/dist/core/utils/writeClient.js +0 -227
  362. package/dist/core/utils/writeClientIndex.d.ts +0 -59
  363. package/dist/core/utils/writeClientIndex.d.ts.map +0 -1
  364. package/dist/core/utils/writeClientIndex.js +0 -27
  365. package/dist/templatesCompiled/index.d.ts.map +0 -1
  366. /package/dist/core/types/{Models.js → base/ClientArtifacts.model.js} +0 -0
  367. /package/dist/core/types/{shared/ConverterData.model.js → base/ExportedModel.model.js} +0 -0
  368. /package/dist/templatesCompiled/{index.js → indexFull.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-openapi-codegen",
3
- "version": "1.0.0-beta.5",
3
+ "version": "1.0.0-beta.7",
4
4
  "description": "Library that generates Typescript clients based on the OpenAPI specification. It bases on openapi-typescript-codegen",
5
5
  "author": "Alexey Zverev",
6
6
  "homepage": "https://github.com/ozonophore/openapi-codegen.git",
@@ -44,7 +44,7 @@
44
44
  ],
45
45
  "scripts": {
46
46
  "clean": "rimraf ./dist ./generated ./test/generated ./test/e2e/generated ./samples/generated ./coverage ./node_modules/.cache",
47
- "build": "tsc -p .",
47
+ "build": "tsc -p . && npm run test:unit",
48
48
  "build:hbs": "tsx ./src/core/utils/precompileTemplates.ts",
49
49
  "release": "npm run build:hbs && npm run build",
50
50
  "run": "node ./test/index.js",
@@ -56,19 +56,25 @@
56
56
  "prettier": "prettier \"./src/**/*.ts\" \"./types/index.d.ts\" --check",
57
57
  "prettier:fix": "prettier \"./src/**/*.ts\" \"./types/index.d.ts\" --write",
58
58
  "prepublish": "npm run clean && npm run release",
59
- "codecov": "codecov --token=89a9fe76-2714-4b5b-83e3-9d809615064d"
59
+ "codecov": "codecov --token=89a9fe76-2714-4b5b-83e3-9d809615064d",
60
+ "find-deadcode": "ts-prune -e"
60
61
  },
61
62
  "dependencies": {
63
+ "@apidevtools/swagger-parser": "12.0.0",
64
+ "boxen": "^5.1.2",
62
65
  "camelcase": "6.2.0",
66
+ "chalk": "^4.1.2",
63
67
  "commander": "8.0.0",
68
+ "configstore": "^5.0.1",
64
69
  "fast-deep-equal": "^3.1.3",
70
+ "figlet": "^1.8.0",
65
71
  "handlebars": "4.7.6",
66
72
  "joi": "^17.13.3",
67
73
  "json-schema": "0.4.0",
68
- "json-schema-ref-parser": "9.0.7",
69
74
  "leven": "^4.0.0",
70
75
  "mkdirp": "1.0.4",
71
76
  "rimraf": "3.0.2",
77
+ "semver": "^7.7.1",
72
78
  "winston": "^3.17.0",
73
79
  "winston-daily-rotate-file": "^5.0.0"
74
80
  },
@@ -81,13 +87,17 @@
81
87
  "@eslint/eslintrc": "^3.3.1",
82
88
  "@eslint/js": "^9.29.0",
83
89
  "@types/axios": "^0.14.0",
90
+ "@types/configstore": "^6.0.2",
84
91
  "@types/express": "4.17.13",
92
+ "@types/figlet": "^1.5.8",
93
+ "@types/glob": "^8.1.0",
85
94
  "@types/json-schema": "^7.0.15",
86
95
  "@types/lodash-es": "^4.17.12",
87
96
  "@types/node": "22.5.1",
88
97
  "@types/node-fetch": "2.5.12",
89
98
  "@types/prettier": "3.0.0",
90
99
  "@types/qs": "6.9.7",
100
+ "@types/semver": "^7.7.0",
91
101
  "@types/winston": "^2.4.4",
92
102
  "@typescript-eslint/eslint-plugin": "^8.34.1",
93
103
  "@typescript-eslint/parser": "^8.34.1",
@@ -109,6 +119,7 @@
109
119
  "prettier": "^3.4.2",
110
120
  "puppeteer": "10.1.0",
111
121
  "qs": "6.10.1",
122
+ "ts-prune": "^0.10.3",
112
123
  "tsx": "^4.20.3",
113
124
  "typescript": "5.8.3"
114
125
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"MultiOptionsMigrationPlan.d.ts","sourceRoot":"","sources":["../../../src/common/VersionedSchema/MultiOptionsMigrationPlan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAyBpG,CAAC"}
@@ -1,6 +0,0 @@
1
- import Joi from 'joi';
2
- /**
3
- * The scheme of a set of generator options (1.0.0)
4
- */
5
- export declare const multiOptionsSchemaV1: Joi.ObjectSchema<any>;
6
- //# sourceMappingURL=MultiOptionsSchemaV1.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MultiOptionsSchemaV1.d.ts","sourceRoot":"","sources":["../../../src/common/VersionedSchema/MultiOptionsSchemaV1.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAMtB;;GAEG;AACH,eAAO,MAAM,oBAAoB,uBAchC,CAAC"}
@@ -1,6 +0,0 @@
1
- import Joi from 'joi';
2
- /**
3
- * The scheme of a set of generator options (1.0.1)
4
- */
5
- export declare const multiOptionsSchemaV2: Joi.ObjectSchema<any>;
6
- //# sourceMappingURL=MultiOptionsSchemaV2.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MultiOptionsSchemaV2.d.ts","sourceRoot":"","sources":["../../../src/common/VersionedSchema/MultiOptionsSchemaV2.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAMtB;;GAEG;AACH,eAAO,MAAM,oBAAoB,uBAchC,CAAC"}
@@ -1,5 +0,0 @@
1
- /**
2
- * The scheme of a set of generator options (1.0.2)
3
- */
4
- export declare const multiOptionsSchemaV3: import("joi").ObjectSchema<any>;
5
- //# sourceMappingURL=MultiOptionsSchemaV3.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MultiOptionsSchemaV3.d.ts","sourceRoot":"","sources":["../../../src/common/VersionedSchema/MultiOptionsSchemaV3.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,oBAAoB,iCAAyE,CAAA"}
@@ -1,6 +0,0 @@
1
- import Joi from 'joi';
2
- /**
3
- * The scheme of a set of generator options (1.0.2)
4
- */
5
- export declare const multiOptionsSchemaV4: Joi.ObjectSchema<any>;
6
- //# sourceMappingURL=MultiOptionsSchemaV4.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MultiOptionsSchemaV4.d.ts","sourceRoot":"","sources":["../../../src/common/VersionedSchema/MultiOptionsSchemaV4.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAMtB;;GAEG;AACH,eAAO,MAAM,oBAAoB,uBAgBhC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { VersionedSchema } from "./Types";
2
- export declare const multiOptionsVersionedSchema: VersionedSchema<Record<string, any>>[];
3
- //# sourceMappingURL=MultiOptionsVersionedSchemas.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MultiOptionsVersionedSchemas.d.ts","sourceRoot":"","sources":["../../../src/common/VersionedSchema/MultiOptionsVersionedSchemas.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,2BAA2B,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAgB5E,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"OptionsMigrationPlans.d.ts","sourceRoot":"","sources":["../../../src/common/VersionedSchema/OptionsMigrationPlans.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAQ/F,CAAC"}
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.optionsMigrationPlans = void 0;
4
- /**
5
- * Migration plan for option models.
6
- */
7
- exports.optionsMigrationPlans = [{
8
- fromVersion: '1.0.0',
9
- toVersion: '1.0.1',
10
- migrate: ({ client, ...otherProps }) => ({ ...otherProps, httpClient: client })
11
- }, {
12
- fromVersion: '1.0.1',
13
- toVersion: '2.0.0',
14
- migrate: (input) => ({ ...input, useCancelableRequest: false })
15
- }];
@@ -1,6 +0,0 @@
1
- import Joi from "joi";
2
- /**
3
- * The scheme of the set of generator options (Version 1.0.0).
4
- */
5
- export declare const optionsSchemaV1: Joi.ObjectSchema<any>;
6
- //# sourceMappingURL=OptionsSchemaV1.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OptionsSchemaV1.d.ts","sourceRoot":"","sources":["../../../src/common/VersionedSchema/OptionsSchemaV1.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAMtB;;GAEG;AACH,eAAO,MAAM,eAAe,uBAQ3B,CAAC"}
@@ -1,6 +0,0 @@
1
- import Joi from "joi";
2
- /**
3
- * The scheme of a set of generator options (Версия 1.0.1).
4
- */
5
- export declare const optionsSchemaV2: Joi.ObjectSchema<any>;
6
- //# sourceMappingURL=OptionsSchemaV2.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OptionsSchemaV2.d.ts","sourceRoot":"","sources":["../../../src/common/VersionedSchema/OptionsSchemaV2.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAMtB;;GAEG;AACH,eAAO,MAAM,eAAe,uBAQ3B,CAAC"}
@@ -1,5 +0,0 @@
1
- /**
2
- * The scheme of a set of generator options (Версия 2.0.0).
3
- */
4
- export declare const optionsSchemaV3: import("joi").ObjectSchema<any>;
5
- //# sourceMappingURL=OptionsSchemaV3.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OptionsSchemaV3.d.ts","sourceRoot":"","sources":["../../../src/common/VersionedSchema/OptionsSchemaV3.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,eAAe,iCAAoE,CAAC"}
@@ -1,3 +0,0 @@
1
- import { VersionedSchema } from "./Types";
2
- export declare const optionsVersionedSchemas: VersionedSchema<Record<string, any>>[];
3
- //# sourceMappingURL=OptionsVersionedSchemas.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OptionsVersionedSchemas.d.ts","sourceRoot":"","sources":["../../../src/common/VersionedSchema/OptionsVersionedSchemas.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,uBAAuB,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAYxE,CAAC"}
@@ -1,14 +0,0 @@
1
- /**
2
- * The type of object passed via ref
3
- */
4
- export declare enum TypeRef {
5
- SCHEMA = 0,
6
- OTHERS = 1
7
- }
8
- export declare enum HttpClient {
9
- FETCH = "fetch",
10
- XHR = "xhr",
11
- NODE = "node",
12
- AXIOS = "axios"
13
- }
14
- //# sourceMappingURL=Enums.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Enums.d.ts","sourceRoot":"","sources":["../../../src/core/types/Enums.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,OAAO;IACf,MAAM,IAAA;IACN,MAAM,IAAA;CACT;AAED,oBAAY,UAAU;IAClB,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,KAAK,UAAU;CAClB"}
@@ -1,37 +0,0 @@
1
- import { GROUP_PRIORITY_EXTENDED, GROUP_PRIORITY_SIMPLE } from './Consts';
2
- import { TypeRef } from './Enums';
3
- /**
4
- * @param output The relative location of the output directory(or index)
5
- * @param outputCore The relative location of the output directory for core
6
- * @param outputServices The relative location of the output directory for services
7
- * @param outputModels The relative location of the output directory for models
8
- * @param outputSchemas The relative location of the output directory for schemas
9
- */
10
- export interface IOutput {
11
- output: string;
12
- outputCore: string;
13
- outputServices: string;
14
- outputModels: string;
15
- outputSchemas: string;
16
- }
17
- /**
18
- * Ref With type
19
- * @prop value Value
20
- * @prop type The type of object passed via ref
21
- */
22
- export interface IRefWithtype {
23
- value: string;
24
- type: TypeRef;
25
- }
26
- export interface $Root {
27
- path: string;
28
- fileName?: string;
29
- }
30
- export interface Prefix {
31
- interface: string;
32
- enum: string;
33
- type: string;
34
- }
35
- export type TPropertyGroupExtended = keyof typeof GROUP_PRIORITY_EXTENDED;
36
- export type TPropertyGroupSimple = keyof typeof GROUP_PRIORITY_SIMPLE;
37
- //# sourceMappingURL=Models.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Models.d.ts","sourceRoot":"","sources":["../../../src/core/types/Models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,WAAW,OAAO;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,KAAK;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,MAAM;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,sBAAsB,GAAG,MAAM,OAAO,uBAAuB,CAAC;AAE1E,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,qBAAqB,CAAC"}
@@ -1,7 +0,0 @@
1
- export interface ConverterData {
2
- fieldName: string;
3
- format?: 'int32' | 'int64' | 'float' | 'double' | 'byte' | 'binary' | 'date' | 'date-time' | 'password';
4
- type?: string;
5
- properties: ConverterData[];
6
- }
7
- //# sourceMappingURL=ConverterData.model.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConverterData.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/shared/ConverterData.model.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,CAAC;IACxG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,aAAa,EAAE,CAAC;CAC/B"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=writeClient.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"writeClient.test.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__tests__/writeClient.test.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=writeClientIndex.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"writeClientIndex.test.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__tests__/writeClientIndex.test.ts"],"names":[],"mappings":""}
@@ -1,89 +0,0 @@
1
- import { Logger } from '../../common/Logger';
2
- import { HttpClient } from '../types/Enums';
3
- import { IOutput } from '../types/Models';
4
- import type { Client } from '../types/shared/Client.model';
5
- import { Templates } from './registerHandlebarTemplates';
6
- /**
7
- * @param client Client object with all the models, services, etc.
8
- * @param templates Templates wrapper with all loaded Handlebars templates
9
- * @param outputPaths The relative location of the output directory
10
- * @param httpClient The selected httpClient (fetch, xhr or node)
11
- * @param useOptions Use options or arguments functions
12
- * @param useUnionTypes Use union types instead of enums
13
- * @param exportCore: Generate core client classes
14
- * @param exportServices: Generate services
15
- * @param exportModels: Generate models
16
- * @param exportSchemas: Generate schemas
17
- * @param clean: Clean a directory before generation
18
- * @param request: Path to custom request file
19
- * @param useCancelableRequest Use cancelable request type.
20
- */
21
- interface IWriteClient {
22
- client: Client;
23
- templates: Templates;
24
- outputPaths: IOutput;
25
- httpClient: HttpClient;
26
- useOptions: boolean;
27
- useUnionTypes: boolean;
28
- exportCore: boolean;
29
- exportServices: boolean;
30
- exportModels: boolean;
31
- exportSchemas: boolean;
32
- clean: boolean;
33
- request?: string;
34
- useCancelableRequest?: boolean;
35
- }
36
- /**
37
- * @param client Client object with all the models, services, etc.
38
- * @param templates The loaded handlebar templates
39
- * @param outputPaths Directory to write the generated files to
40
- * @param useUnionTypes Use union types instead of enums
41
- * @param exportCore: Generate core
42
- * @param exportServices: Generate services
43
- * @param exportModels: Generate models
44
- * @param exportSchemas: Generate schemas
45
- */
46
- export interface IWriteClientIndex {
47
- client: Client;
48
- templates: Templates;
49
- outputPaths: IOutput;
50
- useUnionTypes: boolean;
51
- exportCore: boolean;
52
- exportServices: boolean;
53
- exportModels: boolean;
54
- exportSchemas: boolean;
55
- }
56
- /**
57
- * The client which is writing all items and keep the parameters to write index file
58
- */
59
- export declare class WriteClient {
60
- private options;
61
- private _logger;
62
- constructor();
63
- /**
64
- * Write our OpenAPI client, using the given templates at the given output
65
- * @param client Client object with all the models, services, etc.
66
- * @param templates Templates wrapper with all loaded Handlebars templates
67
- * @param outputPaths A set of parameters with paths for generating main sections (folders)
68
- * @param httpClient The selected httpClient (fetch, xhr or node)
69
- * @param useOptions Use options or arguments functions
70
- * @param useUnionTypes Use union types instead of enums
71
- * @param exportCore: Generate core client classes
72
- * @param exportServices: Generate services
73
- * @param exportModels: Generate models
74
- * @param exportSchemas: Generate schemas
75
- * @param clean: Clean a directory before generation
76
- * @param request: Path to custom request file
77
- * @param useCancelableRequest Use cancelable request type.
78
- */
79
- writeClient(options: IWriteClient): Promise<void>;
80
- /**
81
- * Method keeps all options that is need to create index file
82
- * @param options
83
- */
84
- writeClientIndex(options: IWriteClientIndex): Promise<void>;
85
- combineAndWrite(): Promise<void>;
86
- get logger(): Logger;
87
- }
88
- export {};
89
- //# sourceMappingURL=writeClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"writeClient.d.ts","sourceRoot":"","sources":["../../../src/core/utils/writeClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAG3D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAoCzD;;;;;;;;;;;;;;GAcG;AACH,UAAU,YAAY;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;IACxB,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;IACxB,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,OAAO,CAA+C;IAC9D,OAAO,CAAC,OAAO,CAAS;;IAUxB;;;;;;;;;;;;;;;OAeG;IACG,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IA+DvD;;;OAGG;IACG,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3D,eAAe;IAuFrB,IAAW,MAAM,WAEhB;CACJ"}
@@ -1,227 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WriteClient = void 0;
4
- const Enums_1 = require("../../common/Enums");
5
- const Logger_1 = require("../../common/Logger");
6
- const pathHelpers_1 = require("../utils/pathHelpers");
7
- const fileSystem_1 = require("./fileSystem");
8
- const unique_1 = require("./unique");
9
- const writeClientCore_1 = require("./writeClientCore");
10
- const writeClientIndex_1 = require("./writeClientIndex");
11
- const writeClientModels_1 = require("./writeClientModels");
12
- const writeClientSchemas_1 = require("./writeClientSchemas");
13
- const writeClientServices_1 = require("./writeClientServices");
14
- function sortModelByName(a, b) {
15
- if (a.name > b.name) {
16
- return 1;
17
- }
18
- if (a.name < b.name) {
19
- return -1;
20
- }
21
- return 0;
22
- }
23
- function prepareAlias(models) {
24
- let modelPrevious = undefined;
25
- let index = 1;
26
- for (const model of models) {
27
- if (modelPrevious && model.name === modelPrevious.name) {
28
- model.alias = `${model.name}$${index}`;
29
- if (!modelPrevious.alias) {
30
- modelPrevious.alias = `${modelPrevious.name}$${index - 1}`;
31
- }
32
- index++;
33
- }
34
- else if (modelPrevious && model.name !== modelPrevious.name) {
35
- index = 1;
36
- }
37
- modelPrevious = model;
38
- }
39
- }
40
- /**
41
- * The client which is writing all items and keep the parameters to write index file
42
- */
43
- class WriteClient {
44
- options = new Map();
45
- _logger;
46
- constructor() {
47
- this._logger = new Logger_1.Logger({
48
- level: Enums_1.ELogLevel.ERROR,
49
- instanceId: 'client',
50
- logOutput: Enums_1.ELogOutput.CONSOLE,
51
- });
52
- }
53
- /**
54
- * Write our OpenAPI client, using the given templates at the given output
55
- * @param client Client object with all the models, services, etc.
56
- * @param templates Templates wrapper with all loaded Handlebars templates
57
- * @param outputPaths A set of parameters with paths for generating main sections (folders)
58
- * @param httpClient The selected httpClient (fetch, xhr or node)
59
- * @param useOptions Use options or arguments functions
60
- * @param useUnionTypes Use union types instead of enums
61
- * @param exportCore: Generate core client classes
62
- * @param exportServices: Generate services
63
- * @param exportModels: Generate models
64
- * @param exportSchemas: Generate schemas
65
- * @param clean: Clean a directory before generation
66
- * @param request: Path to custom request file
67
- * @param useCancelableRequest Use cancelable request type.
68
- */
69
- async writeClient(options) {
70
- const { client, templates, outputPaths, httpClient, useOptions, useUnionTypes, exportCore, exportServices, exportModels, exportSchemas, request, useCancelableRequest = false } = options;
71
- if (exportCore) {
72
- await fileSystem_1.fileSystem.mkdir(outputPaths.outputCore);
73
- await (0, writeClientCore_1.writeClientCore)({ client, templates, outputCorePath: outputPaths.outputCore, httpClient, request, useCancelableRequest });
74
- }
75
- if (exportServices) {
76
- const { outputCore, outputServices, outputModels } = outputPaths;
77
- await fileSystem_1.fileSystem.mkdir(outputPaths.outputServices);
78
- await (0, writeClientServices_1.writeClientServices)({
79
- services: client.services,
80
- templates,
81
- outputPaths: {
82
- outputServices,
83
- outputCore: exportCore ? `${(0, pathHelpers_1.relative)(outputServices, outputCore)}` : '../core/',
84
- outputModels: exportModels ? `${(0, pathHelpers_1.relative)(outputServices, outputModels)}` : '../models/',
85
- },
86
- httpClient,
87
- useUnionTypes,
88
- useOptions,
89
- useCancelableRequest,
90
- });
91
- }
92
- if (exportSchemas) {
93
- await fileSystem_1.fileSystem.mkdir(outputPaths.outputSchemas);
94
- await (0, writeClientSchemas_1.writeClientSchemas)({
95
- models: client.models,
96
- templates,
97
- outputSchemasPath: outputPaths.outputSchemas,
98
- httpClient,
99
- useUnionTypes,
100
- });
101
- }
102
- if (exportModels) {
103
- await fileSystem_1.fileSystem.mkdir(outputPaths.outputModels);
104
- await (0, writeClientModels_1.writeClientModels)({
105
- models: client.models,
106
- templates,
107
- outputModelsPath: outputPaths.outputModels,
108
- httpClient,
109
- useUnionTypes,
110
- });
111
- }
112
- if (exportCore || exportServices || exportSchemas || exportModels) {
113
- await fileSystem_1.fileSystem.mkdir(outputPaths.output);
114
- await this.writeClientIndex({
115
- client,
116
- templates,
117
- outputPaths,
118
- useUnionTypes,
119
- exportCore,
120
- exportServices,
121
- exportModels,
122
- exportSchemas,
123
- });
124
- }
125
- }
126
- /**
127
- * Method keeps all options that is need to create index file
128
- * @param options
129
- */
130
- async writeClientIndex(options) {
131
- const { outputPaths } = options;
132
- const values = this.options.get(outputPaths.output);
133
- if (values) {
134
- values.push(options);
135
- }
136
- else {
137
- this.options.set(outputPaths.output, Array.of(options));
138
- }
139
- }
140
- async combineAndWrite() {
141
- const result = new Map();
142
- for (const [key, value] of this.options.entries()) {
143
- for (const item of value) {
144
- const { exportCore, outputPaths, exportModels, exportSchemas, exportServices, client, templates } = item;
145
- const outputCore = outputPaths.outputCore ? outputPaths.outputCore : (0, pathHelpers_1.resolve)(key, 'core');
146
- const outputModels = outputPaths.outputModels ? outputPaths.outputModels : (0, pathHelpers_1.resolve)(key, 'models');
147
- const outputSchemas = outputPaths.outputSchemas ? outputPaths.outputSchemas : (0, pathHelpers_1.resolve)(key, 'schemas');
148
- const outputServices = outputPaths.outputServices ? outputPaths.outputServices : (0, pathHelpers_1.resolve)(key, 'services');
149
- let clientIndex = result.get(`${key}`);
150
- if (!clientIndex) {
151
- clientIndex = {
152
- templates: templates,
153
- outputPath: key,
154
- core: [],
155
- models: [],
156
- schemas: [],
157
- services: [],
158
- };
159
- result.set(`${key}`, clientIndex);
160
- }
161
- if (exportCore) {
162
- const relativePath = `${(0, pathHelpers_1.relative)(key, outputCore)}`;
163
- const clientCore = clientIndex.core.find(item => item === relativePath);
164
- if (!clientCore) {
165
- clientIndex.core.push(relativePath);
166
- }
167
- }
168
- if (exportModels || exportSchemas) {
169
- const relativePathModel = `${(0, pathHelpers_1.relative)(key, outputModels)}`;
170
- const relativePathSchema = `${(0, pathHelpers_1.relative)(key, outputSchemas)}`;
171
- for (const model of client.models) {
172
- const modelFinal = {
173
- name: model.name,
174
- alias: '',
175
- path: model.path,
176
- package: relativePathModel,
177
- enum: model.enum && model.enum.length > 0,
178
- useUnionTypes: item.useUnionTypes,
179
- enums: model.enums && model.enums.length > 0,
180
- };
181
- if (exportModels) {
182
- const value = clientIndex.models.find(item => item.name === modelFinal.name &&
183
- item.path === modelFinal.path &&
184
- item.package === modelFinal.package &&
185
- item.enum === modelFinal.enum &&
186
- item.enums === modelFinal.enums &&
187
- item.useUnionTypes === modelFinal.useUnionTypes);
188
- if (!value) {
189
- clientIndex.models.push(modelFinal);
190
- }
191
- }
192
- if (exportSchemas) {
193
- const schema = { ...modelFinal, package: relativePathSchema };
194
- const indexValue = clientIndex.schemas.find(item => item.name === schema.name && item.path === schema.path && item.package === schema.package);
195
- if (!indexValue) {
196
- clientIndex.schemas.push(schema);
197
- }
198
- }
199
- }
200
- }
201
- if (exportServices) {
202
- const relativeService = `${(0, pathHelpers_1.relative)(key, outputServices)}`;
203
- for (const service of client.services) {
204
- const valueIndex = clientIndex.services.find(item => item.name === service.name && item.package === relativeService);
205
- if (!valueIndex) {
206
- clientIndex.services.push({
207
- name: service.name,
208
- package: relativeService,
209
- });
210
- }
211
- }
212
- }
213
- }
214
- }
215
- for (const value of result.values()) {
216
- value.models = value.models.filter(unique_1.unique).sort(sortModelByName);
217
- prepareAlias(value.models);
218
- value.schemas = value.schemas.filter(unique_1.unique).sort(sortModelByName);
219
- prepareAlias(value.schemas);
220
- await (0, writeClientIndex_1.writeClientIndex)(value);
221
- }
222
- }
223
- get logger() {
224
- return this._logger;
225
- }
226
- }
227
- exports.WriteClient = WriteClient;