@tsed/schema 7.0.0-beta.2 → 7.0.0-beta.20

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 (367) hide show
  1. package/coverage.json +6 -0
  2. package/jest.config.js +1 -6
  3. package/lib/cjs/components/lazyRefMapper.js +1 -2
  4. package/lib/cjs/components/lazyRefMapper.js.map +1 -1
  5. package/lib/cjs/components/objectMapper.js +1 -1
  6. package/lib/cjs/components/objectMapper.js.map +1 -1
  7. package/lib/cjs/components/schemaMapper.js +1 -1
  8. package/lib/cjs/components/schemaMapper.js.map +1 -1
  9. package/lib/cjs/constants/httpStatusMessages.js +14 -100
  10. package/lib/cjs/constants/httpStatusMessages.js.map +1 -1
  11. package/lib/cjs/decorators/collections/collectionOf.js +3 -4
  12. package/lib/cjs/decorators/collections/collectionOf.js.map +1 -1
  13. package/lib/cjs/decorators/common/anyOf.js +4 -0
  14. package/lib/cjs/decorators/common/anyOf.js.map +1 -1
  15. package/lib/cjs/decorators/common/description.js +1 -2
  16. package/lib/cjs/decorators/common/description.js.map +1 -1
  17. package/lib/cjs/decorators/common/enum.js +1 -20
  18. package/lib/cjs/decorators/common/enum.js.map +1 -1
  19. package/lib/cjs/decorators/common/ignore.js.map +1 -1
  20. package/lib/cjs/decorators/common/jsonEntityFn.js.map +1 -1
  21. package/lib/cjs/decorators/common/oneOf.js +4 -0
  22. package/lib/cjs/decorators/common/oneOf.js.map +1 -1
  23. package/lib/cjs/decorators/common/recordOf.js +63 -0
  24. package/lib/cjs/decorators/common/recordOf.js.map +1 -0
  25. package/lib/cjs/decorators/operations/acceptMime.js +28 -0
  26. package/lib/cjs/decorators/operations/acceptMime.js.map +1 -0
  27. package/lib/cjs/decorators/operations/in.js +6 -4
  28. package/lib/cjs/decorators/operations/in.js.map +1 -1
  29. package/lib/cjs/decorators/operations/redirect.js +1 -2
  30. package/lib/cjs/decorators/operations/redirect.js.map +1 -1
  31. package/lib/cjs/decorators/operations/returns.js +43 -21
  32. package/lib/cjs/decorators/operations/returns.js.map +1 -1
  33. package/lib/cjs/decorators/operations/route.js +1 -4
  34. package/lib/cjs/decorators/operations/route.js.map +1 -1
  35. package/lib/cjs/decorators/operations/view.js +31 -0
  36. package/lib/cjs/decorators/operations/view.js.map +1 -0
  37. package/lib/cjs/domain/DecoratorContext.js +6 -3
  38. package/lib/cjs/domain/DecoratorContext.js.map +1 -1
  39. package/lib/cjs/domain/JsonClassStore.js +5 -8
  40. package/lib/cjs/domain/JsonClassStore.js.map +1 -1
  41. package/lib/cjs/domain/JsonEntityStore.js +40 -1
  42. package/lib/cjs/domain/JsonEntityStore.js.map +1 -1
  43. package/lib/cjs/domain/JsonLazyRef.js +2 -1
  44. package/lib/cjs/domain/JsonLazyRef.js.map +1 -1
  45. package/lib/cjs/domain/JsonMap.js.map +1 -1
  46. package/lib/cjs/domain/JsonMethodStore.js +85 -39
  47. package/lib/cjs/domain/JsonMethodStore.js.map +1 -1
  48. package/lib/cjs/domain/JsonOperation.js +15 -34
  49. package/lib/cjs/domain/JsonOperation.js.map +1 -1
  50. package/lib/cjs/domain/JsonOperationPathsMap.js +2 -16
  51. package/lib/cjs/domain/JsonOperationPathsMap.js.map +1 -1
  52. package/lib/cjs/domain/JsonOperationRoute.js +11 -8
  53. package/lib/cjs/domain/JsonOperationRoute.js.map +1 -1
  54. package/lib/cjs/domain/JsonParameter.js +42 -48
  55. package/lib/cjs/domain/JsonParameter.js.map +1 -1
  56. package/lib/cjs/domain/JsonParameterStore.js +26 -10
  57. package/lib/cjs/domain/JsonParameterStore.js.map +1 -1
  58. package/lib/cjs/domain/JsonPropertyStore.js +7 -6
  59. package/lib/cjs/domain/JsonPropertyStore.js.map +1 -1
  60. package/lib/cjs/domain/JsonResponse.js +7 -18
  61. package/lib/cjs/domain/JsonResponse.js.map +1 -1
  62. package/lib/cjs/domain/JsonSchema.js +62 -71
  63. package/lib/cjs/domain/JsonSchema.js.map +1 -1
  64. package/lib/cjs/domain/SpecTypes.js +1 -0
  65. package/lib/cjs/domain/SpecTypes.js.map +1 -1
  66. package/lib/cjs/hooks/alterIgnore.js +2 -3
  67. package/lib/cjs/hooks/alterIgnore.js.map +1 -1
  68. package/lib/cjs/hooks/alterRequiredGroups.js +1 -2
  69. package/lib/cjs/hooks/alterRequiredGroups.js.map +1 -1
  70. package/lib/cjs/index.js +150 -20
  71. package/lib/cjs/index.js.map +1 -1
  72. package/lib/cjs/interfaces/JsonSchemaOptions.js.map +1 -1
  73. package/lib/cjs/package.json +3 -0
  74. package/lib/cjs/utils/concatPath.js +16 -1
  75. package/lib/cjs/utils/concatPath.js.map +1 -1
  76. package/lib/cjs/utils/from.js +9 -8
  77. package/lib/cjs/utils/from.js.map +1 -1
  78. package/lib/cjs/utils/generateSpec.js +46 -0
  79. package/lib/cjs/utils/generateSpec.js.map +1 -0
  80. package/lib/cjs/utils/generics.js.map +1 -1
  81. package/lib/cjs/utils/getJsonPathParameters.js +20 -6
  82. package/lib/cjs/utils/getJsonPathParameters.js.map +1 -1
  83. package/lib/cjs/utils/getJsonSchema.js +12 -3
  84. package/lib/cjs/utils/getJsonSchema.js.map +1 -1
  85. package/lib/cjs/utils/getJsonType.js +1 -1
  86. package/lib/cjs/utils/getJsonType.js.map +1 -1
  87. package/lib/cjs/utils/getOperationsRoutes.js +2 -1
  88. package/lib/cjs/utils/getOperationsRoutes.js.map +1 -1
  89. package/lib/cjs/utils/getRequiredProperties.js +3 -3
  90. package/lib/cjs/utils/getRequiredProperties.js.map +1 -1
  91. package/lib/cjs/utils/getSpec.js +58 -43
  92. package/lib/cjs/utils/getSpec.js.map +1 -1
  93. package/lib/cjs/utils/getSpecType.js +21 -0
  94. package/lib/cjs/utils/getSpecType.js.map +1 -0
  95. package/lib/cjs/utils/mapNullableType.js +1 -1
  96. package/lib/cjs/utils/mapNullableType.js.map +1 -1
  97. package/lib/cjs/utils/mapOpenSpec.js +41 -0
  98. package/lib/cjs/utils/mapOpenSpec.js.map +1 -0
  99. package/lib/cjs/utils/mapOpenSpec2.js +34 -0
  100. package/lib/cjs/utils/mapOpenSpec2.js.map +1 -0
  101. package/lib/cjs/utils/mapOpenSpec3.js +26 -0
  102. package/lib/cjs/utils/mapOpenSpec3.js.map +1 -0
  103. package/lib/cjs/utils/mapOpenSpecInfo.js +21 -0
  104. package/lib/cjs/utils/mapOpenSpecInfo.js.map +1 -0
  105. package/lib/cjs/utils/matchGroups.js +1 -1
  106. package/lib/cjs/utils/matchGroups.js.map +1 -1
  107. package/lib/cjs/utils/mergeOperation.js +2 -2
  108. package/lib/cjs/utils/mergeOperation.js.map +1 -1
  109. package/lib/cjs/utils/mergeSpec.js.map +1 -1
  110. package/lib/cjs/utils/operationIdFormatter.js +3 -3
  111. package/lib/cjs/utils/operationIdFormatter.js.map +1 -1
  112. package/lib/cjs/utils/ref.js +2 -2
  113. package/lib/cjs/utils/ref.js.map +1 -1
  114. package/lib/cjs/utils/serializeEnumValues.js +26 -0
  115. package/lib/cjs/utils/serializeEnumValues.js.map +1 -0
  116. package/lib/cjs/utils/transformToOS2.js +510 -0
  117. package/lib/cjs/utils/transformToOS2.js.map +1 -0
  118. package/lib/esm/components/anyMapper.js +4 -4
  119. package/lib/esm/components/classMapper.js +4 -4
  120. package/lib/esm/components/genericsMapper.js +4 -4
  121. package/lib/esm/components/inheritedClassMapper.js +2 -2
  122. package/lib/esm/components/itemMapper.js +1 -1
  123. package/lib/esm/components/lazyRefMapper.js +4 -5
  124. package/lib/esm/components/lazyRefMapper.js.map +1 -1
  125. package/lib/esm/components/mapMapper.js +2 -2
  126. package/lib/esm/components/objectMapper.js +4 -4
  127. package/lib/esm/components/objectMapper.js.map +1 -1
  128. package/lib/esm/components/ofMapper.js +1 -1
  129. package/lib/esm/components/propertiesMapper.js +1 -1
  130. package/lib/esm/components/schemaMapper.js +7 -7
  131. package/lib/esm/components/schemaMapper.js.map +1 -1
  132. package/lib/esm/constants/httpStatusMessages.js +13 -100
  133. package/lib/esm/constants/httpStatusMessages.js.map +1 -1
  134. package/lib/esm/decorators/class/children.js +1 -1
  135. package/lib/esm/decorators/collections/collectionContains.js +1 -1
  136. package/lib/esm/decorators/collections/collectionOf.js +4 -5
  137. package/lib/esm/decorators/collections/collectionOf.js.map +1 -1
  138. package/lib/esm/decorators/collections/maxItems.js +1 -1
  139. package/lib/esm/decorators/collections/maxProperties.js +1 -1
  140. package/lib/esm/decorators/collections/minItems.js +1 -1
  141. package/lib/esm/decorators/collections/minProperties.js +1 -1
  142. package/lib/esm/decorators/collections/uniqueItems.js +1 -1
  143. package/lib/esm/decorators/common/additionalProperties.js +1 -1
  144. package/lib/esm/decorators/common/allOf.js +1 -1
  145. package/lib/esm/decorators/common/allow.js +2 -2
  146. package/lib/esm/decorators/common/any.js +1 -1
  147. package/lib/esm/decorators/common/anyOf.js +5 -1
  148. package/lib/esm/decorators/common/anyOf.js.map +1 -1
  149. package/lib/esm/decorators/common/const.js +1 -1
  150. package/lib/esm/decorators/common/customKey.js +1 -1
  151. package/lib/esm/decorators/common/default.js +1 -1
  152. package/lib/esm/decorators/common/description.js +2 -3
  153. package/lib/esm/decorators/common/description.js.map +1 -1
  154. package/lib/esm/decorators/common/enum.js +2 -21
  155. package/lib/esm/decorators/common/enum.js.map +1 -1
  156. package/lib/esm/decorators/common/example.js +1 -1
  157. package/lib/esm/decorators/common/examples.js +1 -1
  158. package/lib/esm/decorators/common/exclusiveMaximum.js +1 -1
  159. package/lib/esm/decorators/common/exclusiveMinimum.js +1 -1
  160. package/lib/esm/decorators/common/format.js +2 -2
  161. package/lib/esm/decorators/common/forwardGroups.js +1 -1
  162. package/lib/esm/decorators/common/groups.js +2 -2
  163. package/lib/esm/decorators/common/ignore.js +1 -1
  164. package/lib/esm/decorators/common/ignore.js.map +1 -1
  165. package/lib/esm/decorators/common/integer.js +1 -1
  166. package/lib/esm/decorators/common/jsonEntityFn.js +1 -1
  167. package/lib/esm/decorators/common/jsonEntityFn.js.map +1 -1
  168. package/lib/esm/decorators/common/maxLength.js +1 -1
  169. package/lib/esm/decorators/common/maximum.js +1 -1
  170. package/lib/esm/decorators/common/minLength.js +1 -1
  171. package/lib/esm/decorators/common/minimum.js +1 -1
  172. package/lib/esm/decorators/common/multipleOf.js +1 -1
  173. package/lib/esm/decorators/common/name.js +1 -1
  174. package/lib/esm/decorators/common/nullable.js +2 -2
  175. package/lib/esm/decorators/common/oneOf.js +5 -1
  176. package/lib/esm/decorators/common/oneOf.js.map +1 -1
  177. package/lib/esm/decorators/common/optional.js +1 -1
  178. package/lib/esm/decorators/common/pattern.js +1 -1
  179. package/lib/esm/decorators/common/property.js +1 -1
  180. package/lib/esm/decorators/common/readOnly.js +1 -1
  181. package/lib/esm/decorators/common/recordOf.js +59 -0
  182. package/lib/esm/decorators/common/recordOf.js.map +1 -0
  183. package/lib/esm/decorators/common/required.js +2 -2
  184. package/lib/esm/decorators/common/requiredGroups.js +2 -2
  185. package/lib/esm/decorators/common/schema.js +1 -1
  186. package/lib/esm/decorators/common/title.js +1 -1
  187. package/lib/esm/decorators/common/writeOnly.js +1 -1
  188. package/lib/esm/decorators/config/jsonEntityComponent.js +1 -1
  189. package/lib/esm/decorators/generics/genericOf.js +2 -2
  190. package/lib/esm/decorators/generics/generics.js +1 -1
  191. package/lib/esm/decorators/operations/acceptMime.js +24 -0
  192. package/lib/esm/decorators/operations/acceptMime.js.map +1 -0
  193. package/lib/esm/decorators/operations/consumes.js +1 -1
  194. package/lib/esm/decorators/operations/contentType.js +1 -1
  195. package/lib/esm/decorators/operations/deprecated.js +1 -1
  196. package/lib/esm/decorators/operations/header.js +1 -1
  197. package/lib/esm/decorators/operations/in.js +3 -1
  198. package/lib/esm/decorators/operations/in.js.map +1 -1
  199. package/lib/esm/decorators/operations/inFile.js +5 -5
  200. package/lib/esm/decorators/operations/location.js +1 -1
  201. package/lib/esm/decorators/operations/operationId.js +1 -1
  202. package/lib/esm/decorators/operations/operationPath.js +1 -1
  203. package/lib/esm/decorators/operations/partial.js +1 -1
  204. package/lib/esm/decorators/operations/path.js +1 -1
  205. package/lib/esm/decorators/operations/produces.js +1 -1
  206. package/lib/esm/decorators/operations/redirect.js +3 -4
  207. package/lib/esm/decorators/operations/redirect.js.map +1 -1
  208. package/lib/esm/decorators/operations/returns.js +51 -29
  209. package/lib/esm/decorators/operations/returns.js.map +1 -1
  210. package/lib/esm/decorators/operations/route.js +4 -7
  211. package/lib/esm/decorators/operations/route.js.map +1 -1
  212. package/lib/esm/decorators/operations/security.js +1 -1
  213. package/lib/esm/decorators/operations/status.js +1 -1
  214. package/lib/esm/decorators/operations/summary.js +1 -1
  215. package/lib/esm/decorators/operations/tags.js +1 -1
  216. package/lib/esm/decorators/operations/view.js +27 -0
  217. package/lib/esm/decorators/operations/view.js.map +1 -0
  218. package/lib/esm/domain/DecoratorContext.js +6 -3
  219. package/lib/esm/domain/DecoratorContext.js.map +1 -1
  220. package/lib/esm/domain/JsonClassStore.js +7 -10
  221. package/lib/esm/domain/JsonClassStore.js.map +1 -1
  222. package/lib/esm/domain/JsonEntityStore.js +40 -1
  223. package/lib/esm/domain/JsonEntityStore.js.map +1 -1
  224. package/lib/esm/domain/JsonLazyRef.js +4 -3
  225. package/lib/esm/domain/JsonLazyRef.js.map +1 -1
  226. package/lib/esm/domain/JsonMap.js +1 -1
  227. package/lib/esm/domain/JsonMap.js.map +1 -1
  228. package/lib/esm/domain/JsonMethodStore.js +86 -40
  229. package/lib/esm/domain/JsonMethodStore.js.map +1 -1
  230. package/lib/esm/domain/JsonOperation.js +22 -41
  231. package/lib/esm/domain/JsonOperation.js.map +1 -1
  232. package/lib/esm/domain/JsonOperationPathsMap.js +3 -17
  233. package/lib/esm/domain/JsonOperationPathsMap.js.map +1 -1
  234. package/lib/esm/domain/JsonOperationRoute.js +12 -9
  235. package/lib/esm/domain/JsonOperationRoute.js.map +1 -1
  236. package/lib/esm/domain/JsonParameter.js +46 -52
  237. package/lib/esm/domain/JsonParameter.js.map +1 -1
  238. package/lib/esm/domain/JsonParameterStore.js +29 -13
  239. package/lib/esm/domain/JsonParameterStore.js.map +1 -1
  240. package/lib/esm/domain/JsonPropertyStore.js +8 -7
  241. package/lib/esm/domain/JsonPropertyStore.js.map +1 -1
  242. package/lib/esm/domain/JsonRequestBody.js +2 -2
  243. package/lib/esm/domain/JsonResponse.js +10 -21
  244. package/lib/esm/domain/JsonResponse.js.map +1 -1
  245. package/lib/esm/domain/JsonSchema.js +67 -76
  246. package/lib/esm/domain/JsonSchema.js.map +1 -1
  247. package/lib/esm/domain/SpecTypes.js +1 -0
  248. package/lib/esm/domain/SpecTypes.js.map +1 -1
  249. package/lib/esm/hooks/alterIgnore.js +2 -3
  250. package/lib/esm/hooks/alterIgnore.js.map +1 -1
  251. package/lib/esm/hooks/alterRequiredGroups.js +1 -2
  252. package/lib/esm/hooks/alterRequiredGroups.js.map +1 -1
  253. package/lib/esm/index.js +150 -20
  254. package/lib/esm/index.js.map +1 -1
  255. package/lib/esm/interfaces/JsonSchemaOptions.js.map +1 -1
  256. package/lib/esm/package.json +3 -0
  257. package/lib/esm/utils/concatPath.js +16 -1
  258. package/lib/esm/utils/concatPath.js.map +1 -1
  259. package/lib/esm/utils/from.js +5 -4
  260. package/lib/esm/utils/from.js.map +1 -1
  261. package/lib/esm/utils/generateSpec.js +41 -0
  262. package/lib/esm/utils/generateSpec.js.map +1 -0
  263. package/lib/esm/utils/generics.js.map +1 -1
  264. package/lib/esm/utils/getInheritedStores.js +1 -1
  265. package/lib/esm/utils/getJsonEntityStore.js +5 -5
  266. package/lib/esm/utils/getJsonPathParameters.js +20 -6
  267. package/lib/esm/utils/getJsonPathParameters.js.map +1 -1
  268. package/lib/esm/utils/getJsonSchema.js +15 -6
  269. package/lib/esm/utils/getJsonSchema.js.map +1 -1
  270. package/lib/esm/utils/getJsonType.js +2 -2
  271. package/lib/esm/utils/getJsonType.js.map +1 -1
  272. package/lib/esm/utils/getOperationsRoutes.js +5 -4
  273. package/lib/esm/utils/getOperationsRoutes.js.map +1 -1
  274. package/lib/esm/utils/getOperationsStores.js +4 -4
  275. package/lib/esm/utils/getPropertiesStores.js +3 -3
  276. package/lib/esm/utils/getRequiredProperties.js +4 -4
  277. package/lib/esm/utils/getRequiredProperties.js.map +1 -1
  278. package/lib/esm/utils/getSpec.js +65 -50
  279. package/lib/esm/utils/getSpec.js.map +1 -1
  280. package/lib/esm/utils/getSpecType.js +16 -0
  281. package/lib/esm/utils/getSpecType.js.map +1 -0
  282. package/lib/esm/utils/mapNullableType.js +2 -2
  283. package/lib/esm/utils/mapNullableType.js.map +1 -1
  284. package/lib/esm/utils/mapOpenSpec.js +37 -0
  285. package/lib/esm/utils/mapOpenSpec.js.map +1 -0
  286. package/lib/esm/utils/mapOpenSpec2.js +30 -0
  287. package/lib/esm/utils/mapOpenSpec2.js.map +1 -0
  288. package/lib/esm/utils/mapOpenSpec3.js +22 -0
  289. package/lib/esm/utils/mapOpenSpec3.js.map +1 -0
  290. package/lib/esm/utils/mapOpenSpecInfo.js +17 -0
  291. package/lib/esm/utils/mapOpenSpecInfo.js.map +1 -0
  292. package/lib/esm/utils/mapRouteOptions.js +1 -1
  293. package/lib/esm/utils/mergeOperation.js +5 -5
  294. package/lib/esm/utils/mergeOperation.js.map +1 -1
  295. package/lib/esm/utils/mergeSpec.js.map +1 -1
  296. package/lib/esm/utils/operationIdFormatter.js +1 -1
  297. package/lib/esm/utils/operationIdFormatter.js.map +1 -1
  298. package/lib/esm/utils/ref.js +2 -2
  299. package/lib/esm/utils/ref.js.map +1 -1
  300. package/lib/esm/utils/serializeEnumValues.js +21 -0
  301. package/lib/esm/utils/serializeEnumValues.js.map +1 -0
  302. package/lib/esm/utils/toJsonMapCollection.js +1 -1
  303. package/lib/esm/utils/transformToOS2.js +504 -0
  304. package/lib/esm/utils/transformToOS2.js.map +1 -0
  305. package/lib/types/constants/httpStatusMessages.d.ts +2 -263
  306. package/lib/types/decorators/common/anyOf.d.ts +4 -0
  307. package/lib/types/decorators/common/ignore.d.ts +1 -1
  308. package/lib/types/decorators/common/jsonEntityFn.d.ts +1 -1
  309. package/lib/types/decorators/common/oneOf.d.ts +4 -0
  310. package/lib/types/decorators/common/recordOf.d.ts +46 -0
  311. package/lib/types/decorators/operations/acceptMime.d.ts +19 -0
  312. package/lib/types/decorators/operations/in.d.ts +1 -1
  313. package/lib/types/decorators/operations/returns.d.ts +7 -2
  314. package/lib/types/decorators/operations/view.d.ts +23 -0
  315. package/lib/types/domain/JsonEntityStore.d.ts +1 -0
  316. package/lib/types/domain/JsonMap.d.ts +1 -1
  317. package/lib/types/domain/JsonMethodStore.d.ts +56 -4
  318. package/lib/types/domain/JsonOperation.d.ts +2 -2
  319. package/lib/types/domain/JsonOperationPathsMap.d.ts +0 -2
  320. package/lib/types/domain/JsonOperationRoute.d.ts +7 -6
  321. package/lib/types/domain/JsonParameter.d.ts +2 -1
  322. package/lib/types/domain/JsonParameterStore.d.ts +23 -1
  323. package/lib/types/domain/JsonPropertyStore.d.ts +7 -0
  324. package/lib/types/domain/JsonResponse.d.ts +3 -1
  325. package/lib/types/domain/JsonSchema.d.ts +2 -2
  326. package/lib/types/domain/SpecTypes.d.ts +1 -0
  327. package/lib/types/index.d.ts +143 -13
  328. package/lib/types/interfaces/JsonSchemaOptions.d.ts +2 -2
  329. package/lib/types/utils/concatPath.d.ts +1 -1
  330. package/lib/types/utils/generateSpec.d.ts +16 -0
  331. package/lib/types/utils/generics.d.ts +1 -1
  332. package/lib/types/utils/getJsonSchema.d.ts +12 -2
  333. package/lib/types/utils/getOperationsRoutes.d.ts +2 -2
  334. package/lib/types/utils/getSpec.d.ts +5 -4
  335. package/lib/types/utils/getSpecType.d.ts +12 -0
  336. package/lib/types/utils/mapNullableType.d.ts +1 -1
  337. package/lib/types/utils/mapOpenSpec.d.ts +10 -0
  338. package/lib/types/utils/mapOpenSpec2.d.ts +9 -0
  339. package/lib/types/utils/mapOpenSpec3.d.ts +8 -0
  340. package/lib/types/utils/mapOpenSpecInfo.d.ts +6 -0
  341. package/lib/types/utils/mergeSpec.d.ts +2 -2
  342. package/lib/types/utils/serializeEnumValues.d.ts +5 -0
  343. package/lib/types/utils/transformToOS2.d.ts +25 -0
  344. package/package.json +35 -18
  345. package/readme.md +4 -2
  346. package/tsconfig.compile.esm.json +4 -13
  347. package/benchmark/cold-start.js +0 -17
  348. package/lib/cjs/components/index.js +0 -15
  349. package/lib/cjs/components/index.js.map +0 -1
  350. package/lib/cjs/decorators/index.js +0 -77
  351. package/lib/cjs/decorators/index.js.map +0 -1
  352. package/lib/cjs/domain/index.js +0 -20
  353. package/lib/cjs/domain/index.js.map +0 -1
  354. package/lib/cjs/interfaces/index.js +0 -8
  355. package/lib/cjs/interfaces/index.js.map +0 -1
  356. package/lib/esm/components/index.js +0 -12
  357. package/lib/esm/components/index.js.map +0 -1
  358. package/lib/esm/decorators/index.js +0 -74
  359. package/lib/esm/decorators/index.js.map +0 -1
  360. package/lib/esm/domain/index.js +0 -17
  361. package/lib/esm/domain/index.js.map +0 -1
  362. package/lib/esm/interfaces/index.js +0 -5
  363. package/lib/esm/interfaces/index.js.map +0 -1
  364. package/lib/types/components/index.d.ts +0 -11
  365. package/lib/types/decorators/index.d.ts +0 -68
  366. package/lib/types/domain/index.d.ts +0 -16
  367. package/lib/types/interfaces/index.d.ts +0 -4
@@ -1,8 +1,8 @@
1
1
  import { isClass, isPrimitiveClass } from "@tsed/core";
2
- import { JsonEntityStore } from "../domain/JsonEntityStore";
3
- import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
4
- import { popGenerics } from "../utils/generics";
5
- import { getJsonType } from "../utils/getJsonType";
2
+ import { JsonEntityStore } from "../domain/JsonEntityStore.js";
3
+ import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
4
+ import { popGenerics } from "../utils/generics.js";
5
+ import { getJsonType } from "../utils/getJsonType.js";
6
6
  /**
7
7
  * @ignore
8
8
  */
@@ -1,6 +1,6 @@
1
1
  import { classOf, deepMerge } from "@tsed/core";
2
- import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
3
- import { getInheritedStores } from "../utils/getInheritedStores";
2
+ import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
3
+ import { getInheritedStores } from "../utils/getInheritedStores.js";
4
4
  /**
5
5
  * @ignore
6
6
  */
@@ -1,4 +1,4 @@
1
- import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
1
+ import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
2
2
  export function itemMapper(value, options) {
3
3
  return value && value.isClass ? execMapper("class", value, options) : execMapper("any", value, options);
4
4
  }
@@ -1,10 +1,9 @@
1
- import { registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
2
- import { mapGenericsOptions } from "../utils/generics";
3
- import { createRef, toRef } from "../utils/ref";
1
+ import { registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
2
+ import { mapGenericsOptions } from "../utils/generics.js";
3
+ import { createRef, toRef } from "../utils/ref.js";
4
4
  export function lazyRefMapper(input, options) {
5
- var _a;
6
5
  const name = input.name;
7
- if ((_a = options.$refs) === null || _a === void 0 ? void 0 : _a.find((t) => t === input.target)) {
6
+ if (options.$refs?.find((t) => t === input.target)) {
8
7
  return createRef(name, input.schema, options);
9
8
  }
10
9
  options.$refs = [...(options.$refs || []), input.target];
@@ -1 +1 @@
1
- {"version":3,"file":"lazyRefMapper.js","sourceRoot":"","sources":["../../../src/components/lazyRefMapper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAC,SAAS,EAAE,KAAK,EAAC,MAAM,cAAc,CAAC;AAE9C,MAAM,UAAU,aAAa,CAAC,KAAkB,EAAE,OAA0B;;IAC1E,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IAExB,IAAI,MAAA,OAAO,CAAC,KAAK,0CAAE,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC,EAAE;QACvD,OAAO,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC/C;IAED,OAAO,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEzD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;IAEzD,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,wBAAwB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import {JsonLazyRef} from \"../domain/JsonLazyRef\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {mapGenericsOptions} from \"../utils/generics\";\nimport {createRef, toRef} from \"../utils/ref\";\n\nexport function lazyRefMapper(input: JsonLazyRef, options: JsonSchemaOptions) {\n const name = input.name;\n\n if (options.$refs?.find((t: any) => t === input.target)) {\n return createRef(name, input.schema, options);\n }\n\n options.$refs = [...(options.$refs || []), input.target];\n\n const schema = input.toJSON(mapGenericsOptions(options));\n\n return toRef(input.schema, schema, options);\n}\n\nregisterJsonSchemaMapper(\"lazyRef\", lazyRefMapper);\n"]}
1
+ {"version":3,"file":"lazyRefMapper.js","sourceRoot":"","sources":["../../../src/components/lazyRefMapper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAC,SAAS,EAAE,KAAK,EAAC,MAAM,cAAc,CAAC;AAE9C,MAAM,UAAU,aAAa,CAAC,KAAkB,EAAE,OAA0B;IAC1E,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IAExB,IAAI,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC,EAAE;QACvD,OAAO,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC/C;IAED,OAAO,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEzD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;IAEzD,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,wBAAwB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import {JsonLazyRef} from \"../domain/JsonLazyRef\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {mapGenericsOptions} from \"../utils/generics\";\nimport {createRef, toRef} from \"../utils/ref\";\n\nexport function lazyRefMapper(input: JsonLazyRef, options: JsonSchemaOptions) {\n const name = input.name;\n\n if (options.$refs?.find((t: any) => t === input.target)) {\n return createRef(name, input.schema, options);\n }\n\n options.$refs = [...(options.$refs || []), input.target];\n\n const schema = input.toJSON(mapGenericsOptions(options));\n\n return toRef(input.schema, schema, options);\n}\n\nregisterJsonSchemaMapper(\"lazyRef\", lazyRefMapper);\n"]}
@@ -1,5 +1,5 @@
1
- import { mapGenericsOptions } from "../utils/generics";
2
- import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
1
+ import { mapGenericsOptions } from "../utils/generics.js";
2
+ import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
3
3
  /**
4
4
  * Serialize class which inherit from Map like JsonMap, JsonOperation, JsonParameter.
5
5
  * @param input
@@ -1,7 +1,7 @@
1
1
  import { isArray } from "@tsed/core";
2
- import { alterIgnore } from "../hooks/alterIgnore";
3
- import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
4
- import { mapNullableType } from "../utils/mapNullableType";
2
+ import { alterIgnore } from "../hooks/alterIgnore.js";
3
+ import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
4
+ import { mapNullableType } from "../utils/mapNullableType.js";
5
5
  /**
6
6
  * Serialize Any object to a json schema
7
7
  * @param input
@@ -14,7 +14,7 @@ export function objectMapper(input, options) {
14
14
  if (options.withIgnoredProps !== false && !alterIgnore(value, ctx)) {
15
15
  const opts = {
16
16
  ...options,
17
- groups: (input === null || input === void 0 ? void 0 : input.$forwardGroups) || (value === null || value === void 0 ? void 0 : value.$forwardGroups) ? options.groups : undefined
17
+ groups: input?.$forwardGroups || value?.$forwardGroups ? options.groups : undefined
18
18
  };
19
19
  // remove groups to avoid bad schema generation over children models
20
20
  obj[key] = execMapper("item", value, opts);
@@ -1 +1 @@
1
- {"version":3,"file":"objectMapper.js","sourceRoot":"","sources":["../../../src/components/objectMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAC,UAAU,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAU,EAAE,OAA0B;IACjE,MAAM,EAAC,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,GAAG,EAAC,GAAG,OAAO,CAAC;IAE/H,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CACjC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAA6B,EAAE,EAAE;QAChD,IAAI,OAAO,CAAC,gBAAgB,KAAK,KAAK,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;YAClE,MAAM,IAAI,GAAG;gBACX,GAAG,OAAO;gBACV,MAAM,EAAE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,MAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,cAAc,CAAA,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;aACpF,CAAC;YACF,oEAAoE;YACpE,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YAC3C,GAAG,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;SACnD;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EACD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CACzB,CAAC;AACJ,CAAC;AAED,wBAAwB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import {isArray} from \"@tsed/core\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {alterIgnore} from \"../hooks/alterIgnore\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {mapNullableType} from \"../utils/mapNullableType\";\n\n/**\n * Serialize Any object to a json schema\n * @param input\n * @param options\n * @ignore\n */\nexport function objectMapper(input: any, options: JsonSchemaOptions) {\n const {specType, operationIdFormatter, root, schemas, genericTypes, nestedGenerics, useAlias, genericLabels, ...ctx} = options;\n\n return Object.entries(input).reduce<any>(\n (obj, [key, value]: [string, any | JsonSchema]) => {\n if (options.withIgnoredProps !== false && !alterIgnore(value, ctx)) {\n const opts = {\n ...options,\n groups: input?.$forwardGroups || value?.$forwardGroups ? options.groups : undefined\n };\n // remove groups to avoid bad schema generation over children models\n obj[key] = execMapper(\"item\", value, opts);\n obj[key] = mapNullableType(obj[key], value, opts);\n }\n\n return obj;\n },\n isArray(input) ? [] : {}\n );\n}\n\nregisterJsonSchemaMapper(\"object\", objectMapper);\n"]}
1
+ {"version":3,"file":"objectMapper.js","sourceRoot":"","sources":["../../../src/components/objectMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAC,UAAU,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AAC7F,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAU,EAAE,OAA0B;IACjE,MAAM,EAAC,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,GAAG,EAAC,GAAG,OAAO,CAAC;IAE/H,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CACjC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAA6B,EAAE,EAAE;QAChD,IAAI,OAAO,CAAC,gBAAgB,KAAK,KAAK,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE;YAClE,MAAM,IAAI,GAAG;gBACX,GAAG,OAAO;gBACV,MAAM,EAAE,KAAK,EAAE,cAAc,IAAI,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;aACpF,CAAC;YACF,oEAAoE;YACpE,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YAC3C,GAAG,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;SACnD;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EACD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CACzB,CAAC;AACJ,CAAC;AAED,wBAAwB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import {isArray} from \"@tsed/core\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {alterIgnore} from \"../hooks/alterIgnore\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {mapNullableType} from \"../utils/mapNullableType\";\n\n/**\n * Serialize Any object to a json schema\n * @param input\n * @param options\n * @ignore\n */\nexport function objectMapper(input: any, options: JsonSchemaOptions) {\n const {specType, operationIdFormatter, root, schemas, genericTypes, nestedGenerics, useAlias, genericLabels, ...ctx} = options;\n\n return Object.entries(input).reduce<any>(\n (obj, [key, value]: [string, any | JsonSchema]) => {\n if (options.withIgnoredProps !== false && !alterIgnore(value, ctx)) {\n const opts = {\n ...options,\n groups: input?.$forwardGroups || value?.$forwardGroups ? options.groups : undefined\n };\n // remove groups to avoid bad schema generation over children models\n obj[key] = execMapper(\"item\", value, opts);\n obj[key] = mapNullableType(obj[key], value, opts);\n }\n\n return obj;\n },\n isArray(input) ? [] : {}\n );\n}\n\nregisterJsonSchemaMapper(\"object\", objectMapper);\n"]}
@@ -1,4 +1,4 @@
1
- import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
1
+ import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
2
2
  export function ofMapper(input, options, parent) {
3
3
  return input.map((value) => {
4
4
  return execMapper("item", value, {
@@ -1,4 +1,4 @@
1
- import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
1
+ import { execMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
2
2
  export function propertiesMapper(input, options, parent) {
3
3
  if (input.isClass) {
4
4
  return execMapper("class", input, options);
@@ -1,14 +1,14 @@
1
1
  import { isObject } from "@tsed/core";
2
- import { mapAliasedProperties } from "../domain/JsonAliasMap";
3
- import { SpecTypes } from "../domain/SpecTypes";
4
- import { execMapper, hasMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer";
5
- import { getRequiredProperties } from "../utils/getRequiredProperties";
6
- import { alterOneOf } from "../hooks/alterOneOf";
7
- import { mapNullableType } from "../utils/mapNullableType";
2
+ import { mapAliasedProperties } from "../domain/JsonAliasMap.js";
3
+ import { SpecTypes } from "../domain/SpecTypes.js";
4
+ import { execMapper, hasMapper, registerJsonSchemaMapper } from "../registries/JsonSchemaMapperContainer.js";
5
+ import { getRequiredProperties } from "../utils/getRequiredProperties.js";
6
+ import { alterOneOf } from "../hooks/alterOneOf.js";
7
+ import { mapNullableType } from "../utils/mapNullableType.js";
8
8
  /**
9
9
  * @ignore
10
10
  */
11
- const IGNORES = ["name", "$required", "$hooks", "_nestedGenerics", SpecTypes.OPENAPI, SpecTypes.JSON];
11
+ const IGNORES = ["name", "$required", "$hooks", "_nestedGenerics", SpecTypes.OPENAPI, SpecTypes.SWAGGER, SpecTypes.JSON];
12
12
  /**
13
13
  * @ignore
14
14
  */
@@ -1 +1 @@
1
- {"version":3,"file":"schemaMapper.js","sourceRoot":"","sources":["../../../src/components/schemaMapper.ts"],"names":[],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AO,EAAE,QAAQ,EAAC,CAAC,CAAC;IACjE,GAAG,GAAG,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,GAAG,GAAG,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAEvC,OAAO,GAAG,CAAC;AACb,CAAC;AAED,wBAAwB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import {isObject} from \"@tsed/core\";\nimport {mapAliasedProperties} from \"../domain/JsonAliasMap\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, hasMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getRequiredProperties} from \"../utils/getRequiredProperties\";\nimport {alterOneOf} from \"../hooks/alterOneOf\";\nimport {mapNullableType} from \"../utils/mapNullableType\";\n\n/**\n * @ignore\n */\nconst IGNORES = [\"name\", \"$required\", \"$hooks\", \"_nestedGenerics\", SpecTypes.OPENAPI, SpecTypes.JSON];\n/**\n * @ignore\n */\nconst IGNORES_OPENSPEC = [\"const\"];\n\n/**\n * @ignore\n */\nfunction isEmptyProperties(key: string, value: any) {\n return typeof value === \"object\" && [\"items\", \"properties\", \"additionalProperties\"].includes(key) && Object.keys(value).length === 0;\n}\n\n/**\n * @ignore\n */\nfunction shouldMapAlias(key: string, value: any, useAlias: boolean) {\n return typeof value === \"object\" && useAlias && [\"properties\", \"additionalProperties\"].includes(key);\n}\n\n/**\n * @ignore\n */\nfunction shouldSkipKey(key: string, {specType = SpecTypes.JSON, customKeys = false}: JsonSchemaOptions) {\n return (\n IGNORES.includes(key) ||\n (key.startsWith(\"#\") && (customKeys === false || specType !== SpecTypes.JSON)) ||\n (specType !== SpecTypes.JSON && IGNORES_OPENSPEC.includes(key))\n );\n}\n\nfunction isExample(key: string, value: any, options: JsonSchemaOptions) {\n return key === \"examples\" && isObject(value) && SpecTypes.OPENAPI === options.specType!;\n}\n\nexport function schemaMapper(schema: JsonSchema, options: JsonSchemaOptions): any {\n const {useAlias = true, schemas = {}} = options;\n options = {\n ...options,\n useAlias,\n schemas\n };\n\n let obj: any = [...schema.keys()]\n .filter((key) => !shouldSkipKey(key, options))\n .reduce((item: any, key) => {\n let value = schema.get(key);\n\n key = key.replace(/^#/, \"\");\n\n if (key === \"type\") {\n return {\n ...item,\n [key]: schema.getJsonType()\n };\n }\n\n if (isExample(key, value, options)) {\n key = \"example\";\n value = Object.values(value)[0];\n }\n\n if (value && typeof value === \"object\" && hasMapper(key)) {\n value = execMapper(key, value, options, schema);\n\n if (isEmptyProperties(key, value)) {\n return item;\n }\n\n if (shouldMapAlias(key, value, useAlias)) {\n value = mapAliasedProperties(value, schema.alias);\n }\n }\n\n return {\n ...item,\n [key]: value\n };\n }, {});\n\n if (schema.isClass) {\n obj = execMapper(\"inheritedClass\", obj, {...options, root: false, schemas, target: schema.getComputedType()});\n }\n\n obj = execMapper(\"generics\", obj, {...options, root: false, schemas} as any);\n\n if (schema.has(options.specType as string)) {\n obj = {\n ...obj,\n ...schema.get(options.specType as string).toJSON(options)\n };\n }\n\n obj = getRequiredProperties(obj, schema, {...options, useAlias});\n obj = mapNullableType(obj, schema, options);\n obj = alterOneOf(obj, schema, options);\n\n return obj;\n}\n\nregisterJsonSchemaMapper(\"schema\", schemaMapper);\n"]}
1
+ {"version":3,"file":"schemaMapper.js","sourceRoot":"","sources":["../../../src/components/schemaMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,wBAAwB,EAAC,MAAM,yCAAyC,CAAC;AACxG,OAAO,EAAC,qBAA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AQ,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import {isObject} from \"@tsed/core\";\nimport {mapAliasedProperties} from \"../domain/JsonAliasMap\";\nimport {JsonSchema} from \"../domain/JsonSchema\";\nimport {SpecTypes} from \"../domain/SpecTypes\";\nimport {JsonSchemaOptions} from \"../interfaces/JsonSchemaOptions\";\nimport {execMapper, hasMapper, registerJsonSchemaMapper} from \"../registries/JsonSchemaMapperContainer\";\nimport {getRequiredProperties} from \"../utils/getRequiredProperties\";\nimport {alterOneOf} from \"../hooks/alterOneOf\";\nimport {mapNullableType} from \"../utils/mapNullableType\";\n\n/**\n * @ignore\n */\nconst IGNORES = [\"name\", \"$required\", \"$hooks\", \"_nestedGenerics\", SpecTypes.OPENAPI, SpecTypes.SWAGGER, SpecTypes.JSON];\n/**\n * @ignore\n */\nconst IGNORES_OPENSPEC = [\"const\"];\n\n/**\n * @ignore\n */\nfunction isEmptyProperties(key: string, value: any) {\n return typeof value === \"object\" && [\"items\", \"properties\", \"additionalProperties\"].includes(key) && Object.keys(value).length === 0;\n}\n\n/**\n * @ignore\n */\nfunction shouldMapAlias(key: string, value: any, useAlias: boolean) {\n return typeof value === \"object\" && useAlias && [\"properties\", \"additionalProperties\"].includes(key);\n}\n\n/**\n * @ignore\n */\nfunction shouldSkipKey(key: string, {specType = SpecTypes.JSON, customKeys = false}: JsonSchemaOptions) {\n return (\n IGNORES.includes(key) ||\n (key.startsWith(\"#\") && (customKeys === false || specType !== SpecTypes.JSON)) ||\n (specType !== SpecTypes.JSON && IGNORES_OPENSPEC.includes(key))\n );\n}\n\nfunction isExample(key: string, value: any, options: JsonSchemaOptions) {\n return key === \"examples\" && isObject(value) && SpecTypes.OPENAPI === options.specType!;\n}\n\nexport function schemaMapper(schema: JsonSchema, options: JsonSchemaOptions): any {\n const {useAlias = true, schemas = {}} = options;\n options = {\n ...options,\n useAlias,\n schemas\n };\n\n let obj: any = [...schema.keys()]\n .filter((key) => !shouldSkipKey(key, options))\n .reduce((item: any, key) => {\n let value = schema.get(key);\n\n key = key.replace(/^#/, \"\");\n\n if (key === \"type\") {\n return {\n ...item,\n [key]: schema.getJsonType()\n };\n }\n\n if (isExample(key, value, options)) {\n key = \"example\";\n value = Object.values(value)[0];\n }\n\n if (value && typeof value === \"object\" && hasMapper(key)) {\n value = execMapper(key, value, options, schema);\n\n if (isEmptyProperties(key, value)) {\n return item;\n }\n\n if (shouldMapAlias(key, value, useAlias)) {\n value = mapAliasedProperties(value, schema.alias);\n }\n }\n\n return {\n ...item,\n [key]: value\n };\n }, {});\n\n if (schema.isClass) {\n obj = execMapper(\"inheritedClass\", obj, {...options, root: false, schemas, target: schema.getComputedType()});\n }\n\n obj = execMapper(\"generics\", obj, {...options, root: false, schemas} as any);\n\n if (schema.has(options.specType as string)) {\n obj = {\n ...obj,\n ...schema.get(options.specType as string).toJSON(options)\n };\n }\n\n obj = getRequiredProperties(obj, schema, {...options, useAlias});\n obj = mapNullableType(obj, schema, options);\n obj = alterOneOf(obj, schema, options);\n\n return obj;\n}\n\nregisterJsonSchemaMapper(\"schema\", schemaMapper);\n"]}
@@ -1,105 +1,18 @@
1
- export const HTTP_STATUS_MESSAGES = {
2
- "100": { label: "Continue", code: "CONTINUE" },
3
- "101": { label: "Switching Protocols", code: "SWITCHING_PROTOCOLS" },
4
- "102": { label: "Processing", code: "PROCESSING" },
5
- "103": { label: "Early Hints", code: "EARLY_HINTS" },
6
- "200": { label: "Success", code: "SUCCESS" },
7
- "201": { label: "Created", code: "CREATED" },
8
- "202": { label: "Accepted", code: "ACCEPTED" },
9
- "203": {
10
- label: "Non-Authoritative Information",
11
- code: "NON_AUTHORITATIVE_INFORMATION"
12
- },
13
- "204": { label: "No Content", code: "NO_CONTENT" },
14
- "205": { label: "Reset Content", code: "RESET_CONTENT" },
15
- "206": { label: "Partial Content", code: "PARTIAL_CONTENT" },
16
- "207": { label: "Multi-Status", code: "MULTI_STATUS" },
17
- "208": { label: "Already Reported", code: "ALREADY_REPORTED" },
18
- "226": { label: "IM Used", code: "IM_USED" },
19
- "300": { label: "Multiple Choices", code: "MULTIPLE_CHOICES" },
20
- "301": { label: "Moved Permanently", code: "MOVED_PERMANENTLY" },
21
- "302": { label: "Found", code: "FOUND" },
22
- "303": { label: "See Other", code: "SEE_OTHER" },
23
- "304": { label: "Not Modified", code: "NOT_MODIFIED" },
24
- "305": { label: "Use Proxy", code: "USE_PROXY" },
25
- "306": { label: "(Unused)", code: "UNUSED" },
26
- "307": { label: "Temporary Redirect", code: "TEMPORARY_REDIRECT" },
27
- "308": { label: "Permanent Redirect", code: "PERMANENT_REDIRECT" },
28
- "310": { label: "Too Many Redirects", code: "TOO_MANY_REDIRECTS" },
29
- "400": { label: "Bad Request", code: "BAD_REQUEST" },
30
- "401": { label: "Unauthorized", code: "UNAUTHORIZED" },
31
- "402": { label: "Payment Required", code: "PAYMENT_REQUIRED" },
32
- "403": { label: "Forbidden", code: "FORBIDDEN" },
33
- "404": { label: "Not Found", code: "NOT_FOUND" },
34
- "405": { label: "Method Not Allowed", code: "METHOD_NOT_ALLOWED" },
35
- "406": { label: "Not Acceptable", code: "NOT_ACCEPTABLE" },
36
- "407": {
37
- label: "Proxy Authentication Required",
38
- code: "PROXY_AUTHENTICATION_REQUIRED"
39
- },
40
- "408": { label: "Request Timeout", code: "REQUEST_TIMEOUT" },
41
- "409": { label: "Conflict", code: "CONFLICT" },
42
- "410": { label: "Gone", code: "GONE" },
43
- "411": { label: "Length Required", code: "LENGTH_REQUIRED" },
44
- "412": { label: "Precondition Failed", code: "PRECONDITION_FAILED" },
45
- "413": {
46
- label: "Request Entity Too Large",
47
- code: "REQUEST_ENTITY_TOO_LARGE"
48
- },
49
- "414": { label: "Request URI Too Long", code: "REQUEST_URI_TOO_LONG" },
50
- "415": { label: "Unsupported Media Type", code: "UNSUPPORTED_MEDIA_TYPE" },
51
- "416": {
52
- label: "Request Range Unsatisfiable",
53
- code: "REQUEST_RANGE_UNSATISFIABLE"
54
- },
55
- "417": { label: "Expectation Failed", code: "EXPECTATION_FAILED" },
56
- "418": { label: "I'm a Teapot", code: "I_M_A_TEAPOT" },
57
- "421": { label: "Misdirected Request", code: "MISDIRECTED_REQUEST" },
58
- "422": { label: "Unprocessable Entity", code: "UNPROCESSABLE_ENTITY" },
59
- "423": { label: "Locked", code: "LOCKED" },
60
- "424": { label: "Failed Dependency", code: "FAILED_DEPENDENCY" },
61
- "425": { label: "Too Early", code: "TOO_EARLY" },
62
- "426": { label: "Upgrade Required", code: "UPGRADE_REQUIRED" },
63
- "427": { label: "Unassigned", code: "UNASSIGNED" },
64
- "428": { label: "Precondition Required", code: "PRECONDITION_REQUIRED" },
65
- "429": { label: "Too Many Requests", code: "TOO_MANY_REQUESTS" },
66
- "430": { label: "Unassigned", code: "UNASSIGNED" },
67
- "431": {
68
- label: "Request Header Fields Too Large",
69
- code: "REQUEST_HEADER_FIELDS_TOO_LARGE"
70
- },
71
- "451": {
72
- label: "Unavailable For Legal Reasons",
73
- code: "UNAVAILABLE_FOR_LEGAL_REASONS"
74
- },
75
- "500": { label: "Internal Server Error", code: "INTERNAL_SERVER_ERROR" },
76
- "501": { label: "Not Implemented", code: "NOT_IMPLEMENTED" },
77
- "502": { label: "Bad Gateway", code: "BAD_GATEWAY" },
78
- "503": { label: "Service Unavailable", code: "SERVICE_UNAVAILABLE" },
79
- "504": { label: "Gateway Timeout", code: "GATEWAY_TIMEOUT" },
80
- "505": {
81
- label: "HTTP Version Not Supported",
82
- code: "HTTP_VERSION_NOT_SUPPORTED"
83
- },
84
- "506": { label: "Variant Also Negotiates", code: "VARIANT_ALSO_NEGOTIATES" },
85
- "507": { label: "Insufficient Storage", code: "INSUFFICIENT_STORAGE" },
86
- "508": { label: "Loop Detected", code: "LOOP_DETECTED" },
87
- "509": {
88
- label: "Bandwidth Limit Exceeded",
89
- code: "BANDWIDTH_LIMIT_EXCEEDED"
90
- },
91
- "510": { label: "Not Extended", code: "NOT_EXTENDED" },
92
- "511": {
93
- label: "Network Authentication Required",
94
- code: "NETWORK_AUTHENTICATION_REQUIRED"
95
- }
96
- };
1
+ import statuses from "statuses";
2
+ import { constantCase } from "change-case";
3
+ export const HTTP_STATUS_MESSAGES = statuses.codes.reduce((map, code) => {
4
+ const message = String(statuses(code));
5
+ return {
6
+ ...map,
7
+ [String(code)]: { label: message, code: constantCase(message) }
8
+ };
9
+ }, {});
10
+ HTTP_STATUS_MESSAGES["200"].label = "Success";
11
+ HTTP_STATUS_MESSAGES["200"].code = "SUCCESS";
97
12
  export function getStatusConstant(status) {
98
- var _a;
99
- return (_a = HTTP_STATUS_MESSAGES[status]) === null || _a === void 0 ? void 0 : _a.code;
13
+ return HTTP_STATUS_MESSAGES[status]?.code;
100
14
  }
101
15
  export function getStatusMessage(status) {
102
- var _a;
103
- return (_a = HTTP_STATUS_MESSAGES[status]) === null || _a === void 0 ? void 0 : _a.label;
16
+ return HTTP_STATUS_MESSAGES[status]?.label;
104
17
  }
105
18
  //# sourceMappingURL=httpStatusMessages.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"httpStatusMessages.js","sourceRoot":"","sources":["../../../src/constants/httpStatusMessages.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,KAAK,EAAE,EAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAC;IAC5C,KAAK,EAAE,EAAC,KAAK,EAAE,qBAAqB,EAAE,IAAI,EAAE,qBAAqB,EAAC;IAClE,KAAK,EAAE,EAAC,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAC;IAChD,KAAK,EAAE,EAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAC;IAClD,KAAK,EAAE,EAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAC;IAC1C,KAAK,EAAE,EAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAC;IAC1C,KAAK,EAAE,EAAC,KAAK,EAAE,UAAU,EA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EAAE,uBAAuB,EAAC;IACtE,KAAK,EAAE,EAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,EAAC;IAC1D,KAAK,EAAE,EAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAC;IAClD,KAAK,EAAE,EAAC,KAAK,EAAE,qBAAqB,EAAE,IAAI,EAAE,qBAAqB,EAAC;IAClE,KAAK,EAAE,EAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,EAAC;IAC1D,KAAK,EAAE;QACL,KAAK,EAAE,4BAA4B;QACnC,IAAI,EAAE,4BAA4B;KACnC;IACD,KAAK,EAAE,EAAC,KAAK,EAAE,yBAAyB,EAAE,IAAI,EAAE,yBAAyB,EAAC;IAC1E,KAAK,EAAE,EAAC,KAAK,EAAE,sBAAsB,EAAE,IAAI,EAAE,sBAAsB,EAAC;IACpE,KAAK,EAAE,EAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,eAAe,EAAC;IACtD,KAAK,EAAE;QACL,KAAK,EAAE,0BAA0B;QACjC,IAAI,EAAE,0BAA0B;KACjC;IACD,KAAK,EAAE,EAAC,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc,EAAC;IACpD,KAAK,EAAE;QACL,KAAK,EAAE,iCAAiC;QACxC,IAAI,EAAE,iCAAiC;KACxC;CACF,CAAC;AAEF,MAAM,UAAU,iBAAiB,CAAC,MAAuB;;IACvD,OAAO,MAAC,oBAA4B,CAAC,MAAM,CAAC,0CAAE,IAAI,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAuB;;IACtD,OAAO,MAAC,oBAA4B,CAAC,MAAM,CAAC,0CAAE,KAAK,CAAC;AACtD,CAAC","sourcesContent":["export const HTTP_STATUS_MESSAGES = {\n \"100\": {label: \"Continue\", code: \"CONTINUE\"},\n \"101\": {label: \"Switching Protocols\", code: \"SWITCHING_PROTOCOLS\"},\n \"102\": {label: \"Processing\", code: \"PROCESSING\"},\n \"103\": {label: \"Early Hints\", code: \"EARLY_HINTS\"},\n \"200\": {label: \"Success\", code: \"SUCCESS\"},\n \"201\": {label: \"Created\", code: \"CREATED\"},\n \"202\": {label: \"Accepted\", code: \"ACCEPTED\"},\n \"203\": {\n label: \"Non-Authoritative Information\",\n code: \"NON_AUTHORITATIVE_INFORMATION\"\n },\n \"204\": {label: \"No Content\", code: \"NO_CONTENT\"},\n \"205\": {label: \"Reset Content\", code: \"RESET_CONTENT\"},\n \"206\": {label: \"Partial Content\", code: \"PARTIAL_CONTENT\"},\n \"207\": {label: \"Multi-Status\", code: \"MULTI_STATUS\"},\n \"208\": {label: \"Already Reported\", code: \"ALREADY_REPORTED\"},\n \"226\": {label: \"IM Used\", code: \"IM_USED\"},\n \"300\": {label: \"Multiple Choices\", code: \"MULTIPLE_CHOICES\"},\n \"301\": {label: \"Moved Permanently\", code: \"MOVED_PERMANENTLY\"},\n \"302\": {label: \"Found\", code: \"FOUND\"},\n \"303\": {label: \"See Other\", code: \"SEE_OTHER\"},\n \"304\": {label: \"Not Modified\", code: \"NOT_MODIFIED\"},\n \"305\": {label: \"Use Proxy\", code: \"USE_PROXY\"},\n \"306\": {label: \"(Unused)\", code: \"UNUSED\"},\n \"307\": {label: \"Temporary Redirect\", code: \"TEMPORARY_REDIRECT\"},\n \"308\": {label: \"Permanent Redirect\", code: \"PERMANENT_REDIRECT\"},\n \"310\": {label: \"Too Many Redirects\", code: \"TOO_MANY_REDIRECTS\"},\n \"400\": {label: \"Bad Request\", code: \"BAD_REQUEST\"},\n \"401\": {label: \"Unauthorized\", code: \"UNAUTHORIZED\"},\n \"402\": {label: \"Payment Required\", code: \"PAYMENT_REQUIRED\"},\n \"403\": {label: \"Forbidden\", code: \"FORBIDDEN\"},\n \"404\": {label: \"Not Found\", code: \"NOT_FOUND\"},\n \"405\": {label: \"Method Not Allowed\", code: \"METHOD_NOT_ALLOWED\"},\n \"406\": {label: \"Not Acceptable\", code: \"NOT_ACCEPTABLE\"},\n \"407\": {\n label: \"Proxy Authentication Required\",\n code: \"PROXY_AUTHENTICATION_REQUIRED\"\n },\n \"408\": {label: \"Request Timeout\", code: \"REQUEST_TIMEOUT\"},\n \"409\": {label: \"Conflict\", code: \"CONFLICT\"},\n \"410\": {label: \"Gone\", code: \"GONE\"},\n \"411\": {label: \"Length Required\", code: \"LENGTH_REQUIRED\"},\n \"412\": {label: \"Precondition Failed\", code: \"PRECONDITION_FAILED\"},\n \"413\": {\n label: \"Request Entity Too Large\",\n code: \"REQUEST_ENTITY_TOO_LARGE\"\n },\n \"414\": {label: \"Request URI Too Long\", code: \"REQUEST_URI_TOO_LONG\"},\n \"415\": {label: \"Unsupported Media Type\", code: \"UNSUPPORTED_MEDIA_TYPE\"},\n \"416\": {\n label: \"Request Range Unsatisfiable\",\n code: \"REQUEST_RANGE_UNSATISFIABLE\"\n },\n \"417\": {label: \"Expectation Failed\", code: \"EXPECTATION_FAILED\"},\n \"418\": {label: \"I'm a Teapot\", code: \"I_M_A_TEAPOT\"},\n \"421\": {label: \"Misdirected Request\", code: \"MISDIRECTED_REQUEST\"},\n \"422\": {label: \"Unprocessable Entity\", code: \"UNPROCESSABLE_ENTITY\"},\n \"423\": {label: \"Locked\", code: \"LOCKED\"},\n \"424\": {label: \"Failed Dependency\", code: \"FAILED_DEPENDENCY\"},\n \"425\": {label: \"Too Early\", code: \"TOO_EARLY\"},\n \"426\": {label: \"Upgrade Required\", code: \"UPGRADE_REQUIRED\"},\n \"427\": {label: \"Unassigned\", code: \"UNASSIGNED\"},\n \"428\": {label: \"Precondition Required\", code: \"PRECONDITION_REQUIRED\"},\n \"429\": {label: \"Too Many Requests\", code: \"TOO_MANY_REQUESTS\"},\n \"430\": {label: \"Unassigned\", code: \"UNASSIGNED\"},\n \"431\": {\n label: \"Request Header Fields Too Large\",\n code: \"REQUEST_HEADER_FIELDS_TOO_LARGE\"\n },\n \"451\": {\n label: \"Unavailable For Legal Reasons\",\n code: \"UNAVAILABLE_FOR_LEGAL_REASONS\"\n },\n \"500\": {label: \"Internal Server Error\", code: \"INTERNAL_SERVER_ERROR\"},\n \"501\": {label: \"Not Implemented\", code: \"NOT_IMPLEMENTED\"},\n \"502\": {label: \"Bad Gateway\", code: \"BAD_GATEWAY\"},\n \"503\": {label: \"Service Unavailable\", code: \"SERVICE_UNAVAILABLE\"},\n \"504\": {label: \"Gateway Timeout\", code: \"GATEWAY_TIMEOUT\"},\n \"505\": {\n label: \"HTTP Version Not Supported\",\n code: \"HTTP_VERSION_NOT_SUPPORTED\"\n },\n \"506\": {label: \"Variant Also Negotiates\", code: \"VARIANT_ALSO_NEGOTIATES\"},\n \"507\": {label: \"Insufficient Storage\", code: \"INSUFFICIENT_STORAGE\"},\n \"508\": {label: \"Loop Detected\", code: \"LOOP_DETECTED\"},\n \"509\": {\n label: \"Bandwidth Limit Exceeded\",\n code: \"BANDWIDTH_LIMIT_EXCEEDED\"\n },\n \"510\": {label: \"Not Extended\", code: \"NOT_EXTENDED\"},\n \"511\": {\n label: \"Network Authentication Required\",\n code: \"NETWORK_AUTHENTICATION_REQUIRED\"\n }\n};\n\nexport function getStatusConstant(status: number | string) {\n return (HTTP_STATUS_MESSAGES as any)[status]?.code;\n}\n\nexport function getStatusMessage(status: number | string) {\n return (HTTP_STATUS_MESSAGES as any)[status]?.label;\n}\n"]}
1
+ {"version":3,"file":"httpStatusMessages.js","sourceRoot":"","sources":["../../../src/constants/httpStatusMessages.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAEzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAkD,EAAE,IAAY,EAAE,EAAE;IAC7H,MAAM,OAAO,GAAW,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,OAAO;QACL,GAAG,GAAG;QACN,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,EAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC,EAAC;KAC9D,CAAC;AACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AAEP,oBAAoB,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,SAAS,CAAC;AAC9C,oBAAoB,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,SAAS,CAAC;AAE7C,MAAM,UAAU,iBAAiB,CAAC,MAAuB;IACvD,OAAQ,oBAA4B,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAuB;IACtD,OAAQ,oBAA4B,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC;AACtD,CAAC","sourcesContent":["import statuses from \"statuses\";\nimport {constantCase} from \"change-case\";\n\nexport const HTTP_STATUS_MESSAGES = statuses.codes.reduce((map: Record<string, {label: string; code: string}>, code: number) => {\n const message: string = String(statuses(code));\n return {\n ...map,\n [String(code)]: {label: message, code: constantCase(message)}\n };\n}, {});\n\nHTTP_STATUS_MESSAGES[\"200\"].label = \"Success\";\nHTTP_STATUS_MESSAGES[\"200\"].code = \"SUCCESS\";\n\nexport function getStatusConstant(status: number | string) {\n return (HTTP_STATUS_MESSAGES as any)[status]?.code;\n}\n\nexport function getStatusMessage(status: number | string) {\n return (HTTP_STATUS_MESSAGES as any)[status]?.label;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { Store } from "@tsed/core";
2
- import { JsonEntityFn } from "../common/jsonEntityFn";
2
+ import { JsonEntityFn } from "../common/jsonEntityFn.js";
3
3
  /**
4
4
  * Add Children class to compose routes
5
5
  *
@@ -1,4 +1,4 @@
1
- import { CollectionOf } from "./collectionOf";
1
+ import { CollectionOf } from "./collectionOf.js";
2
2
  /**
3
3
  * Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...
4
4
  *
@@ -1,4 +1,4 @@
1
- import { JsonEntityStore } from "../../domain/JsonEntityStore";
1
+ import { JsonEntityStore } from "../../domain/JsonEntityStore.js";
2
2
  /**
3
3
  * Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...
4
4
  *
@@ -32,20 +32,19 @@ import { JsonEntityStore } from "../../domain/JsonEntityStore";
32
32
  * @collections
33
33
  */
34
34
  export function CollectionOf(type, collectionType) {
35
+ if (!type) {
36
+ throw new Error("A type is required on `@CollectionOf(type)` decorator. Please give a type or wrap it inside an arrow function if you have a circular reference.");
37
+ }
35
38
  const schema = {};
36
39
  let contains = false;
37
40
  const decorator = (...args) => {
38
41
  const store = JsonEntityStore.from(...args);
39
- // const itemSchema = store.itemSchema.toJSON();
40
42
  if (collectionType) {
41
43
  store.collectionType = collectionType;
42
44
  store.schema.type(collectionType);
43
45
  }
44
46
  store.type = type;
45
- // console.log(type);
46
47
  store.itemSchema.type(type);
47
- // console.log(store.itemSchema.getComputedType(), schema);
48
- // store.itemSchema.assign({...itemSchema, type});
49
48
  store.schema.assign(schema);
50
49
  if (store.isArray && contains) {
51
50
  store.schema.set("contains", store.schema.get("items"));
@@ -1 +1 @@
1
- {"version":3,"file":"collectionOf.js","sourceRoot":"","sources":["../../../../src/decorators/collections/collectionOf.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAkE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,YAAY,CAAC,IAAS,EAAE,cAAoB;IAC1D,MAAM,MAAM,GAAQ,EAAE,CAAC;IACvB,IAAI,QAAQ,GAAY,KAAK,CAAC;IAE9B,MAAM,SAAS,GAAG,CAAC,GAAG,IAAS,EAAE,EAAE;QACjC,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QAC5C,gDAAgD;QAEhD,IAAI,cAAc,EAAE;YAClB,KAAK,CAAC,cAAc,GAA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S,CAAC,WAAW,GAAG,CAAC,WAAW,GAAG,IAAI,EAAE,EAAE;QAC7C,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;QAEjC,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,IAAS;IAC/B,OAAO,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACnC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,IAAS;IAC7B,OAAO,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\n\nexport interface ArrayOfChainedDecorators {\n (...args: any): any;\n\n /**\n * An array instance is valid against `minItems` if its size is greater than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value `minItems` MUST be a non-negative integer.\n * :::\n *\n * ::: tip\n * Omitting this keyword has the same behavior as a value of 0.\n * :::\n */\n MinItems(minItems: number): this;\n\n /**\n * The value `maxItems` MUST be a non-negative integer.\n *\n * An array instance is valid against `maxItems` if its size is less than, or equal to, the value of this keyword.\n *\n * :: warning\n * The value `maxItems` MUST be a non-negative integer.\n * :::\n */\n MaxItems(maxItems: number): this;\n\n /**\n * Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...\n *\n * The array instance will be valid against \"contains\" if at least one of its elements is valid against the given schema.\n */\n Contains(): this;\n\n /**\n * If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique.\n */\n UniqueItems(uniqueItems?: boolean): this;\n}\n\nexport interface MapOfChainedDecorators {\n (...args: any): any;\n\n /**\n * An object instance is valid against `minProperties` if its number of properties is less than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value of this keyword MUST be a non-negative integer.\n * :::\n */\n MinProperties(minProperties: number): this;\n\n /**\n * An object instance is valid against `maxProperties` if its number of properties is less than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value of this keyword MUST be a non-negative integer.\n * :::\n */\n MaxProperties(maxProperties: number): this;\n}\n\nexport interface CollectionOfChainedDecorators extends MapOfChainedDecorators, ArrayOfChainedDecorators {}\n\n/**\n * Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...\n *\n * ```typescript\n * class Model {\n * @CollectionOf(String).MinLength(0).MaxLength(0)\n * property: string[];\n * }\n * ```\n * ::: warning\n * You mustn't use the `type Type = string | number` as parameters Type.\n *\n * This example doesn't work:\n *\n * ```typescript\n * type Type = \"string\" | \"number\"\n * class Model {\n * @CollectionOf(Type)\n * property: Type[];\n * }\n * ```\n * :::\n *\n * @param {Type<any>} type\n * @param collectionType\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @collections\n */\nexport function CollectionOf(type: any, collectionType?: any): CollectionOfChainedDecorators {\n const schema: any = {};\n let contains: boolean = false;\n\n const decorator = (...args: any) => {\n const store = JsonEntityStore.from(...args);\n // const itemSchema = store.itemSchema.toJSON();\n\n if (collectionType) {\n store.collectionType = collectionType;\n store.schema.type(collectionType);\n }\n\n store.type = type;\n // console.log(type);\n store.itemSchema.type(type);\n // console.log(store.itemSchema.getComputedType(), schema);\n // store.itemSchema.assign({...itemSchema, type});\n store.schema.assign(schema);\n\n if (store.isArray && contains) {\n store.schema.set(\"contains\", store.schema.get(\"items\"));\n store.schema.delete(\"items\");\n }\n };\n\n decorator.MinItems = (minItems: number) => {\n schema.minItems = minItems;\n\n return decorator;\n };\n\n decorator.MaxItems = (maxItems: number) => {\n schema.maxItems = maxItems;\n\n return decorator;\n };\n decorator.MinProperties = (minProperties: number) => {\n schema.minProperties = minProperties;\n\n return decorator;\n };\n\n decorator.MaxProperties = (maxProperties: number) => {\n schema.maxProperties = maxProperties;\n\n return decorator;\n };\n\n decorator.Contains = () => {\n contains = true;\n\n return decorator;\n };\n\n decorator.UniqueItems = (uniqueItems = true) => {\n schema.uniqueItems = uniqueItems;\n\n return decorator;\n };\n\n return decorator;\n}\n\n/**\n * Alias of @@GenericOf@@ decorator.\n * @param type\n * @decorator\n */\nexport function ArrayOf(type: any): ArrayOfChainedDecorators {\n return CollectionOf(type, Array);\n}\n\n/**\n * Alias of @@GenericOf@@ decorator.\n * @param type\n * @decorator\n */\nexport function MapOf(type: any): MapOfChainedDecorators {\n return CollectionOf(type, Map);\n}\n"]}
1
+ {"version":3,"file":"collectionOf.js","sourceRoot":"","sources":["../../../../src/decorators/collections/collectionOf.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAkE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,YAAY,CAAC,IAAS,EAAE,cAAoB;IAC1D,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CACb,iJAAiJ,CAClJ,CAAC;KACH;IAED,MAAM,MAAM,GAAQ,EAAE,CAAC;IACvB,IAAI,QAAQ,GAAY,KAAK,CAAC;IAE9B,MAAM,SAAS,GAAG,CAAC,GAAG,IAAS,EAAE,EAAE;QACjC,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QAE5C,IAAI,cAAc,EAAE;YAClB,KAAK,CAAC,cAAc,GAAG,cAAc,CAAC;YACtC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;SACnC;QAED,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAClB,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE5B,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAE5B,IAAI,KAAK,CAAC,OAAO,IAAI,QAAQ,EAAE;YAC7B,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,CA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type} from \"@tsed/core\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\n\nexport interface ArrayOfChainedDecorators {\n (...args: any): any;\n\n /**\n * An array instance is valid against `minItems` if its size is greater than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value `minItems` MUST be a non-negative integer.\n * :::\n *\n * ::: tip\n * Omitting this keyword has the same behavior as a value of 0.\n * :::\n */\n MinItems(minItems: number): this;\n\n /**\n * The value `maxItems` MUST be a non-negative integer.\n *\n * An array instance is valid against `maxItems` if its size is less than, or equal to, the value of this keyword.\n *\n * :: warning\n * The value `maxItems` MUST be a non-negative integer.\n * :::\n */\n MaxItems(maxItems: number): this;\n\n /**\n * Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...\n *\n * The array instance will be valid against \"contains\" if at least one of its elements is valid against the given schema.\n */\n Contains(): this;\n\n /**\n * If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique.\n */\n UniqueItems(uniqueItems?: boolean): this;\n}\n\nexport interface MapOfChainedDecorators {\n (...args: any): any;\n\n /**\n * An object instance is valid against `minProperties` if its number of properties is less than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value of this keyword MUST be a non-negative integer.\n * :::\n */\n MinProperties(minProperties: number): this;\n\n /**\n * An object instance is valid against `maxProperties` if its number of properties is less than, or equal to, the value of this keyword.\n *\n * ::: warning\n * The value of this keyword MUST be a non-negative integer.\n * :::\n */\n MaxProperties(maxProperties: number): this;\n}\n\nexport interface CollectionOfChainedDecorators extends MapOfChainedDecorators, ArrayOfChainedDecorators {}\n\n/**\n * Set the type of the item collection. The possible value is String, Boolean, Number, Date, Object, Class, etc...\n *\n * ```typescript\n * class Model {\n * @CollectionOf(String).MinLength(0).MaxLength(0)\n * property: string[];\n * }\n * ```\n * ::: warning\n * You mustn't use the `type Type = string | number` as parameters Type.\n *\n * This example doesn't work:\n *\n * ```typescript\n * type Type = \"string\" | \"number\"\n * class Model {\n * @CollectionOf(Type)\n * property: Type[];\n * }\n * ```\n * :::\n *\n * @param {Type<any>} type\n * @param collectionType\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @collections\n */\nexport function CollectionOf(type: any, collectionType?: any): CollectionOfChainedDecorators {\n if (!type) {\n throw new Error(\n \"A type is required on `@CollectionOf(type)` decorator. Please give a type or wrap it inside an arrow function if you have a circular reference.\"\n );\n }\n\n const schema: any = {};\n let contains: boolean = false;\n\n const decorator = (...args: any) => {\n const store = JsonEntityStore.from(...args);\n\n if (collectionType) {\n store.collectionType = collectionType;\n store.schema.type(collectionType);\n }\n\n store.type = type;\n store.itemSchema.type(type);\n\n store.schema.assign(schema);\n\n if (store.isArray && contains) {\n store.schema.set(\"contains\", store.schema.get(\"items\"));\n store.schema.delete(\"items\");\n }\n };\n\n decorator.MinItems = (minItems: number) => {\n schema.minItems = minItems;\n\n return decorator;\n };\n\n decorator.MaxItems = (maxItems: number) => {\n schema.maxItems = maxItems;\n\n return decorator;\n };\n decorator.MinProperties = (minProperties: number) => {\n schema.minProperties = minProperties;\n\n return decorator;\n };\n\n decorator.MaxProperties = (maxProperties: number) => {\n schema.maxProperties = maxProperties;\n\n return decorator;\n };\n\n decorator.Contains = () => {\n contains = true;\n\n return decorator;\n };\n\n decorator.UniqueItems = (uniqueItems = true) => {\n schema.uniqueItems = uniqueItems;\n\n return decorator;\n };\n\n return decorator;\n}\n\n/**\n * Alias of @@GenericOf@@ decorator.\n * @param type\n * @decorator\n */\nexport function ArrayOf(type: any): ArrayOfChainedDecorators {\n return CollectionOf(type, Array);\n}\n\n/**\n * Alias of @@GenericOf@@ decorator.\n * @param type\n * @decorator\n */\nexport function MapOf(type: any): MapOfChainedDecorators {\n return CollectionOf(type, Map);\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { JsonEntityFn } from "../common/jsonEntityFn";
1
+ import { JsonEntityFn } from "../common/jsonEntityFn.js";
2
2
  /**
3
3
  * The value `maxItems` MUST be a non-negative integer.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { JsonEntityFn } from "../common/jsonEntityFn";
1
+ import { JsonEntityFn } from "../common/jsonEntityFn.js";
2
2
  /**
3
3
  * An object instance is valid against `maxProperties` if its number of properties is less than, or equal to, the value of this keyword.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { JsonEntityFn } from "../common/jsonEntityFn";
1
+ import { JsonEntityFn } from "../common/jsonEntityFn.js";
2
2
  /**
3
3
  * An array instance is valid against `minItems` if its size is greater than, or equal to, the value of this keyword.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { JsonEntityFn } from "../common/jsonEntityFn";
1
+ import { JsonEntityFn } from "../common/jsonEntityFn.js";
2
2
  /**
3
3
  * An object instance is valid against `minProperties` if its number of properties is less than, or equal to, the value of this keyword.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { JsonEntityFn } from "../common/jsonEntityFn";
1
+ import { JsonEntityFn } from "../common/jsonEntityFn.js";
2
2
  /**
3
3
  * If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { JsonEntityFn } from "./jsonEntityFn";
1
+ import { JsonEntityFn } from "./jsonEntityFn.js";
2
2
  /**
3
3
  * Accept unknown properties on the deserialized model.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { JsonEntityFn } from "./jsonEntityFn";
1
+ import { JsonEntityFn } from "./jsonEntityFn.js";
2
2
  /**
3
3
  * See https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.26
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { DecoratorTypes, isClass, useDecorators } from "@tsed/core";
2
- import { JsonEntityFn } from "./jsonEntityFn";
3
- import { Property } from "./property";
2
+ import { JsonEntityFn } from "./jsonEntityFn.js";
3
+ import { Property } from "./property.js";
4
4
  /**
5
5
  * Add allowed values when the property or parameters is required.
6
6
  *
@@ -1,4 +1,4 @@
1
- import { JsonEntityFn } from "./jsonEntityFn";
1
+ import { JsonEntityFn } from "./jsonEntityFn.js";
2
2
  /**
3
3
  * Set the type of the array items.
4
4
  *
@@ -1,7 +1,11 @@
1
- import { JsonEntityFn } from "./jsonEntityFn";
1
+ import { JsonEntityFn } from "./jsonEntityFn.js";
2
2
  /**
3
3
  * See https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.27
4
4
  *
5
+ * ::: warning
6
+ * AnyOf isn't supported by OS2
7
+ * :::
8
+ *
5
9
  * @decorator
6
10
  * @validation
7
11
  * @swagger
@@ -1 +1 @@
1
- {"version":3,"file":"anyOf.js","sourceRoot":"","sources":["../../../../src/decorators/common/anyOf.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,KAAK,CAAC,GAAG,KAAsB;IAC7C,OAAO,YAAY,CAAC,CAAC,MAAM,EAAE,EAAE;QAC7B,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {AnyJsonSchema} from \"../../domain/JsonSchema\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * See https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.27\n *\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @classDecorator\n * @input\n * @param anyOf\n */\nexport function AnyOf(...anyOf: AnyJsonSchema[]) {\n return JsonEntityFn((entity) => {\n entity.itemSchema.anyOf(anyOf);\n });\n}\n"]}
1
+ {"version":3,"file":"anyOf.js","sourceRoot":"","sources":["../../../../src/decorators/common/anyOf.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,KAAK,CAAC,GAAG,KAAsB;IAC7C,OAAO,YAAY,CAAC,CAAC,MAAM,EAAE,EAAE;QAC7B,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {AnyJsonSchema} from \"../../domain/JsonSchema\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\n\n/**\n * See https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.27\n *\n * ::: warning\n * AnyOf isn't supported by OS2\n * :::\n *\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @classDecorator\n * @input\n * @param anyOf\n */\nexport function AnyOf(...anyOf: AnyJsonSchema[]) {\n return JsonEntityFn((entity) => {\n entity.itemSchema.anyOf(anyOf);\n });\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { JsonEntityFn } from "./jsonEntityFn";
1
+ import { JsonEntityFn } from "./jsonEntityFn.js";
2
2
  /**
3
3
  * The const keyword is used to restrict a value to a fixed value.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { JsonEntityFn } from "./jsonEntityFn";
1
+ import { JsonEntityFn } from "./jsonEntityFn.js";
2
2
  /**
3
3
  * Set a custom key on JsonSchema that is not a part of the official spec.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { JsonEntityFn } from "./jsonEntityFn";
1
+ import { JsonEntityFn } from "./jsonEntityFn.js";
2
2
  /**
3
3
  * There are no restrictions placed on the value of this keyword.
4
4
  *
@@ -1,5 +1,5 @@
1
1
  import { decoratorTypeOf, DecoratorTypes } from "@tsed/core";
2
- import { JsonEntityFn } from "./jsonEntityFn";
2
+ import { JsonEntityFn } from "./jsonEntityFn.js";
3
3
  /**
4
4
  * Add a description to the class, method or property
5
5
  *
@@ -54,7 +54,6 @@ import { JsonEntityFn } from "./jsonEntityFn";
54
54
  */
55
55
  export function Description(description) {
56
56
  return JsonEntityFn((store, args) => {
57
- var _a;
58
57
  switch (decoratorTypeOf(args)) {
59
58
  case DecoratorTypes.PROP:
60
59
  case DecoratorTypes.CLASS:
@@ -64,7 +63,7 @@ export function Description(description) {
64
63
  store.parameter.description(description);
65
64
  break;
66
65
  case DecoratorTypes.METHOD:
67
- (_a = store.operation) === null || _a === void 0 ? void 0 : _a.description(description);
66
+ store.operation?.description(description);
68
67
  break;
69
68
  }
70
69
  });
@@ -1 +1 @@
1
- {"version":3,"file":"description.js","sourceRoot":"","sources":["../../../../src/decorators/common/description.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,cAAc,EAAC,MAAM,YAAY,CAAC;AAEhF,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAG5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,UAAU,WAAW,CAAC,WAAgB;IAC1C,OAAO,YAAY,CAAC,CAAC,KAAsB,EAAE,IAAyB,EAAE,EAAE;;QACxE,QAAQ,eAAe,CAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,cAAc,CAAC,IAAI,CAAC;YACzB,KAAK,cAAc,CAAC,KAAK;gBACvB,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBACtC,MAAM;YAER,KAAK,cAAc,CAAC,KAAK;gBACtB,KAA4B,CAAC,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBACjE,MAAM;YAER,KAAK,cAAc,CAAC,MAAM;gBACxB,MAAC,KAAyB,CAAC,SAAS,0CAAE,WAAW,CAAC,WAAW,CAAC,CAAC;gBAC/D,MAAM;SACT;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {DecoratorParameters, decoratorTypeOf, DecoratorTypes} from \"@tsed/core\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\nimport type {JsonMethodStore, JsonParameterStore} from \"../../domain\";\n\n/**\n * Add a description to the class, method or property\n *\n * ## Examples\n * ### On class\n *\n * ```typescript\n * @Description(\"description\")\n * class Model {\n *\n * }\n * ```\n *\n * ### On method\n *\n * ```typescript\n * @Controller(\"/\")\n * class ModelCtrl {\n * @Description(\"description\")\n * async method() {}\n * }\n * ```\n *\n * ### On parameter\n *\n * ```typescript\n * @Controller(\"/\")\n * class ModelCtrl {\n * async method(@Description(\"description\") @PathParam(\"id\") id: string) {}\n * }\n * ```\n *\n * ### On property\n *\n * ```typescript\n * class Model {\n * @Description(\"description\")\n * id: string;\n * }\n * ```\n *\n * @param {string} description\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @classDecorator\n * @methodDecorator\n * @propertyDecorator\n * @parameterDecorator\n */\nexport function Description(description: any) {\n return JsonEntityFn((store: JsonEntityStore, args: DecoratorParameters) => {\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.PROP:\n case DecoratorTypes.CLASS:\n store.schema.description(description);\n break;\n\n case DecoratorTypes.PARAM:\n (store as JsonParameterStore).parameter.description(description);\n break;\n\n case DecoratorTypes.METHOD:\n (store as JsonMethodStore).operation?.description(description);\n break;\n }\n });\n}\n"]}
1
+ {"version":3,"file":"description.js","sourceRoot":"","sources":["../../../../src/decorators/common/description.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,eAAe,EAAE,cAAc,EAAC,MAAM,YAAY,CAAC;AAEhF,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAI5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,UAAU,WAAW,CAAC,WAAgB;IAC1C,OAAO,YAAY,CAAC,CAAC,KAAsB,EAAE,IAAyB,EAAE,EAAE;QACxE,QAAQ,eAAe,CAAC,IAAI,CAAC,EAAE;YAC7B,KAAK,cAAc,CAAC,IAAI,CAAC;YACzB,KAAK,cAAc,CAAC,KAAK;gBACvB,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBACtC,MAAM;YAER,KAAK,cAAc,CAAC,KAAK;gBACtB,KAA4B,CAAC,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;gBACjE,MAAM;YAER,KAAK,cAAc,CAAC,MAAM;gBACvB,KAAyB,CAAC,SAAS,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;gBAC/D,MAAM;SACT;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {DecoratorParameters, decoratorTypeOf, DecoratorTypes} from \"@tsed/core\";\nimport {JsonEntityStore} from \"../../domain/JsonEntityStore\";\nimport {JsonEntityFn} from \"./jsonEntityFn\";\nimport type {JsonMethodStore} from \"../../domain/JsonMethodStore\";\nimport type {JsonParameterStore} from \"../../domain/JsonParameterStore\";\n\n/**\n * Add a description to the class, method or property\n *\n * ## Examples\n * ### On class\n *\n * ```typescript\n * @Description(\"description\")\n * class Model {\n *\n * }\n * ```\n *\n * ### On method\n *\n * ```typescript\n * @Controller(\"/\")\n * class ModelCtrl {\n * @Description(\"description\")\n * async method() {}\n * }\n * ```\n *\n * ### On parameter\n *\n * ```typescript\n * @Controller(\"/\")\n * class ModelCtrl {\n * async method(@Description(\"description\") @PathParam(\"id\") id: string) {}\n * }\n * ```\n *\n * ### On property\n *\n * ```typescript\n * class Model {\n * @Description(\"description\")\n * id: string;\n * }\n * ```\n *\n * @param {string} description\n * @decorator\n * @validation\n * @swagger\n * @schema\n * @input\n * @classDecorator\n * @methodDecorator\n * @propertyDecorator\n * @parameterDecorator\n */\nexport function Description(description: any) {\n return JsonEntityFn((store: JsonEntityStore, args: DecoratorParameters) => {\n switch (decoratorTypeOf(args)) {\n case DecoratorTypes.PROP:\n case DecoratorTypes.CLASS:\n store.schema.description(description);\n break;\n\n case DecoratorTypes.PARAM:\n (store as JsonParameterStore).parameter.description(description);\n break;\n\n case DecoratorTypes.METHOD:\n (store as JsonMethodStore).operation?.description(description);\n break;\n }\n });\n}\n"]}
@@ -1,26 +1,7 @@
1
- import { isObject } from "@tsed/core";
2
- import { JsonEntityFn } from "./jsonEntityFn";
3
- const transformTsEnum = (enumValue) => {
4
- return Object.keys(enumValue).reduce((acc, key) => {
5
- if (isNaN(+key)) {
6
- const value = enumValue[key];
7
- return acc.concat(value);
8
- }
9
- return acc;
10
- }, []);
11
- };
1
+ import { JsonEntityFn } from "./jsonEntityFn.js";
12
2
  export function Enum(enumValue, ...enumValues) {
13
3
  return JsonEntityFn((store) => {
14
- const values = [enumValue].concat(enumValues).reduce((acc, value) => {
15
- if (isObject(value) && value !== null) {
16
- value = transformTsEnum(value);
17
- }
18
- return acc.concat(value);
19
- }, []);
20
- const types = values.reduce((set, value) => {
21
- return set.add(value === null ? "null" : typeof value);
22
- }, new Set());
23
- store.itemSchema.enum(values).any(...types);
4
+ store.itemSchema.enum(enumValue, ...enumValues);
24
5
  });
25
6
  }
26
7
  //# sourceMappingURL=enum.js.map