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/README.md CHANGED
@@ -60,11 +60,8 @@ $ openapi --help
60
60
  -c, --httpClient <value> HTTP client to generate [fetch, xhr, node] (default: "fetch")
61
61
  --useOptions <value> Use options instead of arguments (default: false)
62
62
  --useUnionTypes <value> Use union types instead of enums (default: false)
63
- --exportCore <value> Write core files to disk (default: true)
64
- --exportServices <value> Write services to disk (default: true)
65
- --exportModels <value> Write models to disk (default: true)
66
- --exportSchemas <value> Write schemas to disk (default: false)
67
- --clean <value> Clean a directory before generation (default: true)
63
+ --excludeCoreServiceFiles (default: false)
64
+ --includeSchemasFiles (default: false)
68
65
  --interfacePrefix <value> Prefix for interface model(default: "I")
69
66
  --enumPrefix <value> Prefix for enum model(default: "E")
70
67
  --typePrefix <value> Prefix for type model(default: "T")
@@ -87,18 +84,14 @@ You should create a file in the root of a project with the name '[openapi.config
87
84
  "input": "./first.yml",
88
85
  "output": "./dist",
89
86
  "client": "xhr",
90
- "exportCore": true,
91
- "exportServices": true,
92
- "exportModels": true,
93
- "exportSchemas": true
87
+ "excludeCoreServiceFiles": true,
88
+ "includeSchemasFiles": true,
94
89
  },{
95
90
  "input": "./second.yml",
96
91
  "output": "./dist",
97
92
  "client": "xhr",
98
- "exportCore": true,
99
- "exportServices": true,
100
- "exportModels": true,
101
- "exportSchemas": true
93
+ "excludeCoreServiceFiles": true,
94
+ "includeSchemasFiles": true,
102
95
  }]
103
96
  ```
104
97
  or with common block
@@ -106,10 +99,8 @@ or with common block
106
99
  {
107
100
  "output": "./dist",
108
101
  "client": "xhr",
109
- "exportCore": true,
110
- "exportServices": true,
111
- "exportModels": true,
112
- "exportSchemas": true,
102
+ "excludeCoreServiceFiles": true,
103
+ "includeSchemasFiles": true,
113
104
  "items": [{
114
105
  "input": "./first.yml"
115
106
  },{
@@ -118,47 +109,41 @@ or with common block
118
109
  }
119
110
  ```
120
111
 
121
- | Name | Item | type | Default | Description |
122
- |----------------------|----------------------|-------------|----------|-----------------------------------------------------------|
123
- | output | | string | |The relative location of the output directory |
124
- | outputCore | | string | {output} |The relative location of the output directory for core |
125
- | outputServices | | string | {output} |The relative location of the output directory for services |
126
- | outputModels | | string | {output} |The relative location of the output directory for models |
127
- | outputSchemas | | string | {output} |The relative location of the output directory for schemas |
128
- | client | | string |'fetch' |The selected httpClient (fetch or XHR) |
129
- | useOptions | | boolean |false |Use options or arguments functions |
130
- | useUnionTypes | | boolean |false |Use union types instead of enums |
131
- | exportCore | | boolean |true |Generate core client classes |
132
- | exportServices | | boolean |true |Generate services |
133
- | exportModels | | boolean |true |Generate models |
134
- | exportSchemas | | boolean |false |Generate schemas |
135
- | clean | | boolean |true |Clean a directory before generation |
136
- | request | | string | |Path to custom request file |
137
- | interfacePrefix | | string |'I' |Prefix for interface model |
138
- | enumPrefix | | string |'E' |Prefix for enum model |
139
- | typePrefix | | string |'T' |Prefix for type model |
140
- | useCancelableRequest | | boolean |false |Use cancelled promise as returned data type in request |
141
- | items | | array | | |
142
- | | input | string | |The relative location of the OpenAPI spec |
143
- | | output | string | | |
144
- | | outputCore | string | | |
145
- | | outputServices | string | | |
146
- | | outputModels | string | | |
147
- | | outputSchemas | string | | |
148
- | | client | string |'fetch' |The selected httpClient (fetch or XHR) |
149
- | | useOptions | boolean |false |Use options or arguments functions |
150
- | | useUnionTypes | boolean |false |Use union types instead of enums |
151
- | | exportCore | boolean |true |Generate core client classes |
152
- | | exportServices | boolean |true |Generate services client classes |
153
- | | exportModels | boolean |true |Generate models client classes |
154
- | | exportSchemas | boolean |true |Generate schemas client classes |
155
- | | clean | boolean |true |Clean a directory before generation |
156
- | | request | string | |Path to custom request file |
157
- | | write | boolean |true |Write the files to disk (true or false) |
158
- | | interfacePrefix | string | |Prefix for interface model(I) |
159
- | | enumPrefix | string | |Prefix for enum model(E) |
160
- | | typePrefix | string | |Prefix for type model(T) |
161
- | | useCancelableRequest | boolean |false |Use cancelled promise as returned data type in request |
112
+ | Name | Item | type | Default | Description |
113
+ |-------------------------|-------------------------|-------------|----------|-----------------------------------------------------------|
114
+ | output | | string | |The relative location of the output directory |
115
+ | outputCore | | string | {output} |The relative location of the output directory for core |
116
+ | outputServices | | string | {output} |The relative location of the output directory for services |
117
+ | outputModels | | string | {output} |The relative location of the output directory for models |
118
+ | outputSchemas | | string | {output} |The relative location of the output directory for schemas |
119
+ | client | | string | 'fetch' |The selected httpClient (fetch or XHR) |
120
+ | useOptions | | boolean | false |Use options or arguments functions |
121
+ | useUnionTypes | | boolean | false |Use union types instead of enums |
122
+ | excludeCoreServiceFiles | | boolean | true | |
123
+ | includeSchemasFiles | | boolean | true | |
124
+ | request | | string | |Path to custom request file |
125
+ | interfacePrefix | | string | 'I' |Prefix for interface model |
126
+ | enumPrefix | | string | 'E' |Prefix for enum model |
127
+ | typePrefix | | string | 'T' |Prefix for type model |
128
+ | useCancelableRequest | | boolean | false |Use cancelled promise as returned data type in request |
129
+ | items | | array | | |
130
+ | | input | string | |The relative location of the OpenAPI spec |
131
+ | | output | string | | |
132
+ | | outputCore | string | | |
133
+ | | outputServices | string | | |
134
+ | | outputModels | string | | |
135
+ | | outputSchemas | string | | |
136
+ | | client | string |'fetch' |The selected httpClient (fetch or XHR) |
137
+ | | useOptions | boolean |false |Use options or arguments functions |
138
+ | | useUnionTypes | boolean |false |Use union types instead of enums |
139
+ | | excludeCoreServiceFiles | boolean |true | |
140
+ | | includeSchemasFiles | boolean |true | |
141
+ | | request | string | |Path to custom request file |
142
+ | | write | boolean |true |Write the files to disk (true or false) |
143
+ | | interfacePrefix | string | |Prefix for interface model(I) |
144
+ | | enumPrefix | string | |Prefix for enum model(E) |
145
+ | | typePrefix | string | |Prefix for type model(T) |
146
+ | | useCancelableRequest | boolean |false |Use cancelled promise as returned data type in request |
162
147
 
163
148
  ## Example
164
149
 
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The function checks whether the configuration file data is filled in correctly
3
+ */
4
+ export declare function chekOpenApiConfig(): void;
5
+ //# sourceMappingURL=chekOpenApiConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chekOpenApiConfig.d.ts","sourceRoot":"","sources":["../../../src/cli/chekOpenApiConfig/chekOpenApiConfig.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,wBAAgB,iBAAiB,SA4BhC"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chekOpenApiConfig = chekOpenApiConfig;
4
+ const Enums_1 = require("../../common/Enums");
5
+ const Logger_1 = require("../../common/Logger");
6
+ const Utils_1 = require("../../common/Utils");
7
+ const MultiOptionsVersionedSchemas_1 = require("../../common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas");
8
+ const OptionsVersionedSchemas_1 = require("../../common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas");
9
+ const getErrorFieldsFromValidation_1 = require("../../common/VersionedSchema/Utils/getErrorFieldsFromValidation");
10
+ const isInstanceOfMultiOptions_1 = require("../../core/utils/isInstanceOfMultiOptions");
11
+ /**
12
+ * The function checks whether the configuration file data is filled in correctly
13
+ */
14
+ function chekOpenApiConfig() {
15
+ const logger = new Logger_1.Logger({
16
+ level: Enums_1.ELogLevel.INFO,
17
+ instanceId: 'check-openapi-config',
18
+ logOutput: Enums_1.ELogOutput.CONSOLE,
19
+ });
20
+ try {
21
+ const configData = (0, Utils_1.loadConfigIfExists)();
22
+ if (!configData) {
23
+ logger.error('The configuration file is missing');
24
+ }
25
+ const preparedOptions = (0, Utils_1.convertArrayToObject)(configData);
26
+ const isMultiOptions = (0, isInstanceOfMultiOptions_1.isInstanceOfMultioptions)(preparedOptions);
27
+ const currentMigrationPlan = isMultiOptions ? MultiOptionsVersionedSchemas_1.multiOptionsVersionedSchema : OptionsVersionedSchemas_1.optionsVersionedSchemas;
28
+ const currentSchema = currentMigrationPlan
29
+ .map((sch, idx) => ({ ...sch, index: idx + 1 }))
30
+ .reduce((prev, curr) => (curr.index > prev.index ? curr : prev));
31
+ const { error } = currentSchema.schema.validate(preparedOptions);
32
+ if (error) {
33
+ const details = (0, getErrorFieldsFromValidation_1.getErrorFieldsFromValidation)(error).map((e) => `${e.path}: ${e.type}`).join(',');
34
+ logger.error(`The configuration file data is specified incorrectly: ${details}`);
35
+ }
36
+ }
37
+ catch (error) {
38
+ logger.error(error.message);
39
+ }
40
+ }
@@ -38,10 +38,10 @@ const defaultOptions_1 = require("../../common/defaultOptions");
38
38
  const Enums_1 = require("../../common/Enums");
39
39
  const Logger_1 = require("../../common/Logger");
40
40
  const Utils_1 = require("../../common/Utils");
41
- const MultiOptionsMigrationPlan_1 = require("../../common/VersionedSchema/MultiOptionsMigrationPlan");
42
- const MultiOptionsVersionedSchemas_1 = require("../../common/VersionedSchema/MultiOptionsVersionedSchemas");
43
- const OptionsMigrationPlans_1 = require("../../common/VersionedSchema/OptionsMigrationPlans");
44
- const OptionsVersionedSchemas_1 = require("../../common/VersionedSchema/OptionsVersionedSchemas");
41
+ const MultiOptionsMigrationPlan_1 = require("../../common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan");
42
+ const MultiOptionsVersionedSchemas_1 = require("../../common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas");
43
+ const OptionsMigrationPlans_1 = require("../../common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans");
44
+ const OptionsVersionedSchemas_1 = require("../../common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas");
45
45
  const migrateDataToLatestSchemaVersion_1 = require("../../common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion");
46
46
  const OpenAPI = __importStar(require("../../core"));
47
47
  const isInstanceOfMultiOptions_1 = require("../../core/utils/isInstanceOfMultiOptions");
package/dist/cli/index.js CHANGED
@@ -1,40 +1,79 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  const commander_1 = require("commander");
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
4
9
  const Enums_1 = require("../common/Enums");
5
- const Enums_2 = require("../core/types/Enums");
10
+ const Logger_1 = require("../common/Logger");
11
+ const UpdateNotifier_1 = require("../common/UpdateNotifier");
12
+ const HttpClient_enum_1 = require("../core/types/enums/HttpClient.enum");
13
+ const chekOpenApiConfig_1 = require("./chekOpenApiConfig/chekOpenApiConfig");
6
14
  const runGenerateOpenApi_1 = require("./generate/runGenerateOpenApi");
7
- const APP_NAME = 'ts-openapi-codegen-cli';
8
- const APP_VERSION = '1.0.0';
15
+ const utils_1 = require("./utils");
16
+ const packageDetails = JSON.parse(fs_1.default.readFileSync(path_1.default.join(__dirname, '../../package.json'), 'utf-8'));
17
+ const APP_NAME = packageDetails.name || 'ts-openapi-codegen-cli';
18
+ const APP_VERSION = packageDetails.version || '1.0.0';
19
+ const APP_DESCRIPTION = packageDetails.description || 'Description';
20
+ const updateNotifier = new UpdateNotifier_1.UpdateNotifier(APP_NAME, APP_VERSION);
9
21
  const program = new commander_1.Command();
10
- program.version(APP_VERSION).name(APP_NAME).description('Description').addHelpText('before', 'Additional text');
22
+ program.version(APP_VERSION).name(APP_NAME).description(APP_DESCRIPTION).addHelpText('before', (0, utils_1.getCLIName)(APP_NAME));
11
23
  program
12
24
  .command('generate')
25
+ .description('Starts code generation based on the provided opeanpi specifications')
26
+ .addHelpText('before', (0, utils_1.getCLIName)(APP_NAME))
13
27
  .usage('[options]')
14
- .version(APP_VERSION)
15
28
  .option('-i, --input <value>', 'OpenAPI specification, can be a path, url or string content (required)', '')
16
29
  .option('-o, --output <value>', 'Output directory (required)', '')
17
30
  .option('-oc, --outputCore <value>', 'Output directory for core files')
18
31
  .option('-os, --outputServices <value>', 'Output directory for services')
19
32
  .option('-om, --outputModels <value>', 'Output directory for models')
20
33
  .option('-osm, --outputSchemas <value>', 'Output directory for schemas')
21
- .addOption(new commander_1.Option('-c, --httpClient <value>', 'HTTP client to generate').choices([...Object.values(Enums_2.HttpClient)]).default(Enums_2.HttpClient.FETCH))
22
- .option('--useOptions <value>', 'Use options instead of arguments', false)
23
- .option('--useUnionTypes <value>', 'Use union types instead of enums', false)
24
- .option('--exportCore <value>', 'Write core files to disk', true)
25
- .option('--exportServices <value>', 'Write services to disk', true)
26
- .option('--exportModels <value>', 'Write models to disk', true)
27
- .option('--exportSchemas <value>', 'Write schemas to disk', false)
28
- .option('--clean <value>', 'Clean a directory before generation', true)
34
+ .addOption(new commander_1.Option('-c, --httpClient <value>', 'HTTP client to generate').choices([...Object.values(HttpClient_enum_1.HttpClient)]).default(HttpClient_enum_1.HttpClient.FETCH))
35
+ .option('--useOptions', 'Use options instead of arguments (default: false)')
36
+ .option('--useUnionTypes', 'Use union types instead of enums (default: false)')
37
+ .option('--excludeCoreServiceFiles', 'The generation of the core and services is excluded (default: false)')
38
+ .option('--includeSchemasFiles', 'The generation of model validation schemes is enabled (default: false)')
29
39
  .option('--request <value>', 'Path to custom request file')
30
- .option('--interfacePrefix <value>', 'Prefix for interface model(default: "I")')
31
- .option('--enumPrefix <value>', 'Prefix for enum model(default: "E")')
32
- .option('--typePrefix <value>', 'Prefix for type model(default: "T")')
33
- .option('--useCancelableRequest <value>', 'Use cancelled promise as returned data type in request(default: false)', false)
40
+ .option('--interfacePrefix <value>', 'Prefix for interface model(default: "I")', "I")
41
+ .option('--enumPrefix <value>', 'Prefix for enum model(default: "E")', "E")
42
+ .option('--typePrefix <value>', 'Prefix for type model(default: "T")', "T")
43
+ .option('--useCancelableRequest', 'Use cancelled promise as returned data type in request (default: false)')
34
44
  .addOption(new commander_1.Option('-l, --logLevel <level>', 'Logging level').choices([...Object.values(Enums_1.ELogLevel)]).default(Enums_1.ELogLevel.ERROR))
35
45
  .addOption(new commander_1.Option('-t, --logTarget <target>', 'Target of logging').choices([...Object.values(Enums_1.ELogOutput)]).default(Enums_1.ELogOutput.CONSOLE))
36
46
  .option('-s, --sortByRequired', 'Property sorting strategy: simplified or extended')
47
+ .option('--useSeparatedIndexes', 'Use separate index files for the core, models, schemas, and services.')
48
+ .hook('preAction', () => {
49
+ updateNotifier.checkAndNotify();
50
+ })
37
51
  .action(async (options) => {
38
52
  await (0, runGenerateOpenApi_1.runGenerateOpenApi)(options);
39
53
  });
40
- program.parse(process.argv);
54
+ program
55
+ .command('check-openapi-config')
56
+ .description('Starts checking whether the configuration file data is filled in correctly.')
57
+ .addHelpText('before', (0, utils_1.getCLIName)(APP_NAME))
58
+ .hook('preAction', () => {
59
+ updateNotifier.checkAndNotify();
60
+ })
61
+ .action(() => {
62
+ (0, chekOpenApiConfig_1.chekOpenApiConfig)();
63
+ });
64
+ try {
65
+ program.parse(process.argv);
66
+ }
67
+ catch (error) {
68
+ if (error.code === 'commander.unknownOption') {
69
+ const errorMessage = error?.message ?? '';
70
+ if (errorMessage) {
71
+ const logger = new Logger_1.Logger({
72
+ level: Enums_1.ELogLevel.INFO,
73
+ instanceId: 'check-openapi-config',
74
+ logOutput: Enums_1.ELogOutput.CONSOLE,
75
+ });
76
+ logger.error(errorMessage);
77
+ }
78
+ }
79
+ }
@@ -1,19 +1,7 @@
1
+ export declare function isValidJson(value: any): boolean;
1
2
  /**
2
- * Checks if `value` is `null` or `undefined`.
3
- *
4
- * @param {*} value The value to check.
5
- * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
6
- * @example
7
- *
8
- * isNil(null)
9
- * // => true
10
- *
11
- * isNil(void 0)
12
- * // => true
13
- *
14
- * isNil(NaN)
15
- * // => false
3
+ * Returns the stylized package name to display in the terminal
4
+ * @param appName Package name
16
5
  */
17
- export declare function isNil(value: any): boolean;
18
- export declare function isValidJson(value: any): boolean;
6
+ export declare function getCLIName(appName: string): string;
19
7
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/cli/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,GAAG,WAE/B;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,WAOrC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/cli/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,WAOrC;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,UAazC"}
package/dist/cli/utils.js CHANGED
@@ -1,26 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isNil = isNil;
4
6
  exports.isValidJson = isValidJson;
5
- /**
6
- * Checks if `value` is `null` or `undefined`.
7
- *
8
- * @param {*} value The value to check.
9
- * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
10
- * @example
11
- *
12
- * isNil(null)
13
- * // => true
14
- *
15
- * isNil(void 0)
16
- * // => true
17
- *
18
- * isNil(NaN)
19
- * // => false
20
- */
21
- function isNil(value) {
22
- return value == null;
23
- }
7
+ exports.getCLIName = getCLIName;
8
+ const figlet_1 = __importDefault(require("figlet"));
24
9
  function isValidJson(value) {
25
10
  try {
26
11
  JSON.parse(value);
@@ -30,3 +15,20 @@ function isValidJson(value) {
30
15
  return false;
31
16
  }
32
17
  }
18
+ /**
19
+ * Returns the stylized package name to display in the terminal
20
+ * @param appName Package name
21
+ */
22
+ function getCLIName(appName) {
23
+ const name = figlet_1.default.textSync(appName, {
24
+ horizontalLayout: 'default',
25
+ verticalLayout: 'default',
26
+ width: 75,
27
+ whitespaceBreak: true,
28
+ });
29
+ return `
30
+
31
+ ${name}
32
+
33
+ `;
34
+ }
@@ -1,4 +1,4 @@
1
- import { HttpClient } from "../core/types/Enums";
1
+ import { HttpClient } from '../core';
2
2
  export type TOptions = {
3
3
  input: string | Record<string, any>;
4
4
  output: string;
@@ -9,11 +9,8 @@ export type TOptions = {
9
9
  httpClient?: HttpClient;
10
10
  useOptions?: boolean;
11
11
  useUnionTypes?: boolean;
12
- exportCore?: boolean;
13
- exportServices?: boolean;
14
- exportModels?: boolean;
15
- exportSchemas?: boolean;
16
- clean?: boolean;
12
+ excludeCoreServiceFiles?: boolean;
13
+ includeSchemasFiles?: boolean;
17
14
  request?: string;
18
15
  write?: boolean;
19
16
  interfacePrefix?: string;
@@ -21,6 +18,7 @@ export type TOptions = {
21
18
  typePrefix?: string;
22
19
  useCancelableRequest?: boolean;
23
20
  sortByRequired?: boolean;
21
+ useSeparatedIndexes?: boolean;
24
22
  };
25
23
  export type TMultiOptions = {
26
24
  items: TOptions[];
@@ -1 +1 @@
1
- {"version":3,"file":"Options.d.ts","sourceRoot":"","sources":["../../src/common/Options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,MAAM,MAAM,QAAQ,GAAG;IACnB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,GAAG,IAAI,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,CAAC,CAAC"}
1
+ {"version":3,"file":"Options.d.ts","sourceRoot":"","sources":["../../src/common/Options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,MAAM,QAAQ,GAAG;IACnB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IACxB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACrB,GAAG,IAAI,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A class for tracking the release of a newer version of the generator
3
+ */
4
+ export declare class UpdateNotifier {
5
+ private _packageName;
6
+ private _packageVersion;
7
+ private _configStore;
8
+ private _packageStoreInfo;
9
+ private _logger;
10
+ constructor(packageName: string, packageVersion: string);
11
+ /**
12
+ * Requests the latest version of the generator via npm
13
+ */
14
+ private fetchNpmPackageInfo;
15
+ /**
16
+ * Checks for updates and writes useful information to the cache
17
+ */
18
+ private checkUpdate;
19
+ /**
20
+ * Checks for updates and notifies about the possibility to install a new version.
21
+ */
22
+ checkAndNotify(): void;
23
+ }
24
+ //# sourceMappingURL=UpdateNotifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UpdateNotifier.d.ts","sourceRoot":"","sources":["../../src/common/UpdateNotifier.ts"],"names":[],"mappings":"AAqBA;;GAEG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,iBAAiB,CAAkC;IAC3D,OAAO,CAAC,OAAO,CAAS;gBAEZ,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IA0BvD;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAkB3B;;OAEG;IACH,OAAO,CAAC,WAAW;IAwBnB;;OAEG;IACH,cAAc;CAmCjB"}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.UpdateNotifier = void 0;
7
+ const boxen_1 = __importDefault(require("boxen"));
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const child_process_1 = require("child_process");
10
+ const configstore_1 = __importDefault(require("configstore"));
11
+ const semver_1 = __importDefault(require("semver"));
12
+ const Enums_1 = require("./Enums");
13
+ const Logger_1 = require("./Logger");
14
+ // one week
15
+ const UPDATE_CHECK_INTERVAL = 1000 * 60 * 60 * 24 * 7;
16
+ const INCLUDED_RELEASE_TYPES = ['major', 'minor'];
17
+ /**
18
+ * A class for tracking the release of a newer version of the generator
19
+ */
20
+ class UpdateNotifier {
21
+ _packageName;
22
+ _packageVersion;
23
+ _configStore = null;
24
+ _packageStoreInfo = null;
25
+ _logger;
26
+ constructor(packageName, packageVersion) {
27
+ this._logger = new Logger_1.Logger({
28
+ instanceId: '',
29
+ level: Enums_1.ELogLevel.INFO,
30
+ logOutput: Enums_1.ELogOutput.CONSOLE,
31
+ });
32
+ if (!packageName || !packageVersion) {
33
+ this._logger.warn(`
34
+ The necessary parameters for checking the version are not specified.
35
+ Current values packageName: ${packageName}, packageVersion: ${packageVersion}
36
+ `);
37
+ }
38
+ this._packageName = packageName;
39
+ this._packageVersion = packageVersion;
40
+ try {
41
+ this._configStore = new configstore_1.default(`-${this._packageName}`, {
42
+ lastUpdateCheck: Date.now(),
43
+ });
44
+ }
45
+ catch {
46
+ this._logger.warn('The settings store has not been created. The package update will be checked more often than once every 1 week!');
47
+ }
48
+ }
49
+ /**
50
+ * Requests the latest version of the generator via npm
51
+ */
52
+ fetchNpmPackageInfo() {
53
+ try {
54
+ const latestVersion = (0, child_process_1.execSync)(`npm view ${this._packageName} version`).toString().trim();
55
+ const releaseType = semver_1.default.diff(this._packageVersion, latestVersion);
56
+ return {
57
+ currentVersion: this._packageVersion,
58
+ differenceType: releaseType,
59
+ latestVersion,
60
+ packageName: this._packageName,
61
+ };
62
+ }
63
+ catch {
64
+ this._logger.warn("Couldn't get information about the latest current version");
65
+ return null;
66
+ }
67
+ }
68
+ /**
69
+ * Checks for updates and writes useful information to the cache
70
+ */
71
+ checkUpdate() {
72
+ if (!this._configStore) {
73
+ return;
74
+ }
75
+ this._packageStoreInfo = this._configStore.get('package_store_info');
76
+ if (this._packageStoreInfo) {
77
+ this._packageStoreInfo.currentVersion = this._packageVersion;
78
+ // clean cache
79
+ this._configStore.delete('package_store_info');
80
+ }
81
+ if (Date.now() - this._configStore.get('lastUpdateCheck') < UPDATE_CHECK_INTERVAL) {
82
+ return;
83
+ }
84
+ const fetchInfo = this.fetchNpmPackageInfo();
85
+ this._configStore.set('lastUpdateCheck', Date.now());
86
+ if (fetchInfo?.differenceType && INCLUDED_RELEASE_TYPES.includes(fetchInfo.differenceType)) {
87
+ this._configStore.set('package_store_info', fetchInfo);
88
+ }
89
+ }
90
+ /**
91
+ * Checks for updates and notifies about the possibility to install a new version.
92
+ */
93
+ checkAndNotify() {
94
+ if (!this._configStore) {
95
+ this._logger.warn("Couldn't get information about the latest current version");
96
+ this._logger.shutdownLogger();
97
+ return;
98
+ }
99
+ this.checkUpdate();
100
+ if (!this._packageStoreInfo || !semver_1.default.gt(this._packageStoreInfo.latestVersion, this._packageStoreInfo.currentVersion)) {
101
+ return;
102
+ }
103
+ const { packageName, currentVersion, latestVersion } = this._packageStoreInfo;
104
+ const scriptText = chalk_1.default.yellowBright(`npm i -D ${packageName}@${latestVersion}`);
105
+ const message = `
106
+ An update is available: ${chalk_1.default.gray(currentVersion)} -> ${chalk_1.default.greenBright(latestVersion)}}
107
+ Run ${scriptText} to update
108
+ `;
109
+ console.log((0, boxen_1.default)(message, {
110
+ borderColor: 'cyanBright',
111
+ margin: 1,
112
+ padding: 1,
113
+ title: 'Pay attention',
114
+ titleAlignment: 'center',
115
+ textAlignment: 'center',
116
+ }));
117
+ this._logger.shutdownLogger();
118
+ }
119
+ }
120
+ exports.UpdateNotifier = UpdateNotifier;
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../src/common/Utils.ts"],"names":[],"mappings":"AAOA,wBAAgB,kBAAkB,uDAYjC;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CA6DxH"}
1
+ {"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../src/common/Utils.ts"],"names":[],"mappings":"AAOA,wBAAgB,kBAAkB,uDAYjC;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CA4DxH"}
@@ -24,10 +24,8 @@ function loadConfigIfExists() {
24
24
  function convertArrayToObject(optionsArr) {
25
25
  const emptyResult = {
26
26
  items: [],
27
- exportCore: undefined,
28
- exportServices: undefined,
29
- exportModels: undefined,
30
- exportSchemas: undefined,
27
+ excludeCoreServiceFiles: undefined,
28
+ includeSchemasFiles: undefined,
31
29
  request: undefined,
32
30
  useOptions: undefined,
33
31
  useCancelableRequest: undefined,
@@ -52,16 +50,17 @@ function convertArrayToObject(optionsArr) {
52
50
  'httpClient',
53
51
  'useOptions',
54
52
  'useUnionTypes',
55
- 'exportCore',
56
- 'exportServices',
57
- 'exportModels',
58
- 'exportSchemas',
59
- 'clean',
53
+ 'excludeCoreServiceFiles',
54
+ 'includeSchemasFiles',
60
55
  'request',
61
56
  'interfacePrefix',
62
57
  'enumPrefix',
63
58
  'typePrefix',
64
59
  'useCancelableRequest',
60
+ 'logLevel',
61
+ 'logTarget',
62
+ 'sortByRequired',
63
+ 'useSeparatedIndexes',
65
64
  ];
66
65
  const extractedFields = fieldsToExtract.reduce((acc, field) => ({
67
66
  ...acc,