adorn-api 1.0.23 → 1.0.24

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 (382) hide show
  1. package/.eslintignore +3 -0
  2. package/.eslintrc.cjs +30 -0
  3. package/README.md +375 -531
  4. package/dist/core/express-adapter.d.ts +27 -0
  5. package/dist/core/express-adapter.d.ts.map +1 -0
  6. package/dist/core/express-adapter.js +146 -0
  7. package/dist/core/express-adapter.js.map +1 -0
  8. package/dist/core/http-error.d.ts +7 -0
  9. package/dist/core/http-error.d.ts.map +1 -0
  10. package/dist/core/http-error.js +14 -0
  11. package/dist/core/http-error.js.map +1 -0
  12. package/dist/decorators/controller.decorator.d.ts +2 -0
  13. package/dist/decorators/controller.decorator.d.ts.map +1 -0
  14. package/dist/decorators/controller.decorator.js +26 -0
  15. package/dist/decorators/controller.decorator.js.map +1 -0
  16. package/dist/decorators/create.decorator.d.ts +8 -0
  17. package/dist/decorators/create.decorator.d.ts.map +1 -0
  18. package/dist/decorators/create.decorator.js +67 -0
  19. package/dist/decorators/create.decorator.js.map +1 -0
  20. package/dist/decorators/http-method.decorator.d.ts +16 -0
  21. package/dist/decorators/http-method.decorator.d.ts.map +1 -0
  22. package/dist/decorators/http-method.decorator.js +117 -0
  23. package/dist/decorators/http-method.decorator.js.map +1 -0
  24. package/dist/decorators/http-params.d.ts +17 -0
  25. package/dist/decorators/http-params.d.ts.map +1 -0
  26. package/dist/decorators/http-params.js +26 -0
  27. package/dist/decorators/http-params.js.map +1 -0
  28. package/dist/decorators/index.d.ts +10 -5
  29. package/dist/decorators/index.d.ts.map +1 -1
  30. package/dist/decorators/index.js +14 -0
  31. package/dist/decorators/index.js.map +1 -0
  32. package/dist/decorators/list.decorator.d.ts +18 -0
  33. package/dist/decorators/list.decorator.d.ts.map +1 -0
  34. package/dist/decorators/list.decorator.js +99 -0
  35. package/dist/decorators/list.decorator.js.map +1 -0
  36. package/dist/decorators/middleware.decorator.d.ts +4 -0
  37. package/dist/decorators/middleware.decorator.d.ts.map +1 -0
  38. package/dist/decorators/middleware.decorator.js +34 -0
  39. package/dist/decorators/middleware.decorator.js.map +1 -0
  40. package/dist/decorators/response.decorator.d.ts +8 -0
  41. package/dist/decorators/response.decorator.d.ts.map +1 -0
  42. package/dist/decorators/response.decorator.js +44 -0
  43. package/dist/decorators/response.decorator.js.map +1 -0
  44. package/dist/decorators/route-options.d.ts +14 -0
  45. package/dist/decorators/route-options.d.ts.map +1 -0
  46. package/dist/decorators/route-options.js +22 -0
  47. package/dist/decorators/route-options.js.map +1 -0
  48. package/dist/decorators/schema.decorator.d.ts +82 -0
  49. package/dist/decorators/schema.decorator.d.ts.map +1 -0
  50. package/dist/decorators/schema.decorator.js +123 -0
  51. package/dist/decorators/schema.decorator.js.map +1 -0
  52. package/dist/decorators/update.decorator.d.ts +8 -0
  53. package/dist/decorators/update.decorator.d.ts.map +1 -0
  54. package/dist/decorators/update.decorator.js +63 -0
  55. package/dist/decorators/update.decorator.js.map +1 -0
  56. package/dist/index.d.ts +11 -13
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +18 -637
  59. package/dist/index.js.map +1 -1
  60. package/dist/metadata/metadata-storage.d.ts +38 -0
  61. package/dist/metadata/metadata-storage.d.ts.map +1 -0
  62. package/dist/metadata/metadata-storage.js +102 -0
  63. package/dist/metadata/metadata-storage.js.map +1 -0
  64. package/dist/metal-orm-integration/dto-helper.d.ts +5 -0
  65. package/dist/metal-orm-integration/dto-helper.d.ts.map +1 -0
  66. package/dist/metal-orm-integration/dto-helper.js +48 -0
  67. package/dist/metal-orm-integration/dto-helper.js.map +1 -0
  68. package/dist/metal-orm-integration/dto-response.decorator.d.ts +4 -0
  69. package/dist/metal-orm-integration/dto-response.decorator.d.ts.map +1 -0
  70. package/dist/metal-orm-integration/dto-response.decorator.js +69 -0
  71. package/dist/metal-orm-integration/dto-response.decorator.js.map +1 -0
  72. package/dist/metal-orm-integration/entity-schema-builder.d.ts +20 -0
  73. package/dist/metal-orm-integration/entity-schema-builder.d.ts.map +1 -0
  74. package/dist/metal-orm-integration/entity-schema-builder.js +356 -0
  75. package/dist/metal-orm-integration/entity-schema-builder.js.map +1 -0
  76. package/dist/metal-orm-integration/index.d.ts +5 -0
  77. package/dist/metal-orm-integration/index.d.ts.map +1 -0
  78. package/dist/metal-orm-integration/index.js +5 -0
  79. package/dist/metal-orm-integration/index.js.map +1 -0
  80. package/dist/metal-orm-integration/schema-modifier.d.ts +11 -0
  81. package/dist/metal-orm-integration/schema-modifier.d.ts.map +1 -0
  82. package/dist/metal-orm-integration/schema-modifier.js +62 -0
  83. package/dist/metal-orm-integration/schema-modifier.js.map +1 -0
  84. package/dist/openapi/index.d.ts +4 -0
  85. package/dist/openapi/index.d.ts.map +1 -0
  86. package/dist/openapi/index.js +4 -0
  87. package/dist/openapi/index.js.map +1 -0
  88. package/dist/openapi/openapi-generator.d.ts +22 -0
  89. package/dist/openapi/openapi-generator.d.ts.map +1 -0
  90. package/dist/openapi/openapi-generator.js +428 -0
  91. package/dist/openapi/openapi-generator.js.map +1 -0
  92. package/dist/openapi/swagger-ui.d.ts +11 -0
  93. package/dist/openapi/swagger-ui.d.ts.map +1 -0
  94. package/dist/openapi/swagger-ui.js +20 -0
  95. package/dist/openapi/swagger-ui.js.map +1 -0
  96. package/dist/openapi/zod-to-openapi.d.ts +4 -0
  97. package/dist/openapi/zod-to-openapi.d.ts.map +1 -0
  98. package/dist/openapi/zod-to-openapi.js +184 -0
  99. package/dist/openapi/zod-to-openapi.js.map +1 -0
  100. package/dist/types/common.d.ts +4 -0
  101. package/dist/types/common.d.ts.map +1 -0
  102. package/dist/types/common.js +2 -0
  103. package/dist/types/common.js.map +1 -0
  104. package/dist/types/controller.d.ts +14 -0
  105. package/dist/types/controller.d.ts.map +1 -0
  106. package/dist/types/controller.js +2 -0
  107. package/dist/types/controller.js.map +1 -0
  108. package/dist/types/metadata.d.ts +48 -0
  109. package/dist/types/metadata.d.ts.map +1 -0
  110. package/dist/types/metadata.js +2 -0
  111. package/dist/types/metadata.js.map +1 -0
  112. package/dist/types/openapi.d.ts +30 -0
  113. package/dist/types/openapi.d.ts.map +1 -0
  114. package/dist/types/openapi.js +2 -0
  115. package/dist/types/openapi.js.map +1 -0
  116. package/dist/validation/zod-adapter.d.ts +15 -0
  117. package/dist/validation/zod-adapter.d.ts.map +1 -0
  118. package/dist/validation/zod-adapter.js +61 -0
  119. package/dist/validation/zod-adapter.js.map +1 -0
  120. package/examples/basic/app.ts +15 -0
  121. package/examples/basic/index.ts +6 -0
  122. package/examples/basic/user.controller.ts +35 -0
  123. package/examples/basic/user.dtos.ts +23 -0
  124. package/examples/metal-orm-sqlite/app.ts +18 -0
  125. package/examples/metal-orm-sqlite/db.ts +90 -0
  126. package/examples/metal-orm-sqlite/index.ts +6 -0
  127. package/examples/metal-orm-sqlite/post.controller.ts +209 -0
  128. package/examples/metal-orm-sqlite/post.dtos.ts +78 -0
  129. package/examples/metal-orm-sqlite/post.entity.ts +24 -0
  130. package/examples/metal-orm-sqlite/user.controller.helpers.ts +305 -0
  131. package/examples/metal-orm-sqlite/user.controller.ts +231 -0
  132. package/examples/metal-orm-sqlite/user.dtos.ts +88 -0
  133. package/examples/metal-orm-sqlite/user.entity.ts +21 -0
  134. package/examples/metal-orm-sqlite-music/album.controller.ts +278 -0
  135. package/examples/metal-orm-sqlite-music/album.dtos.ts +85 -0
  136. package/examples/metal-orm-sqlite-music/album.entity.ts +28 -0
  137. package/examples/metal-orm-sqlite-music/app.ts +19 -0
  138. package/examples/metal-orm-sqlite-music/artist.controller.ts +272 -0
  139. package/examples/metal-orm-sqlite-music/artist.dtos.ts +68 -0
  140. package/examples/metal-orm-sqlite-music/artist.entity.ts +27 -0
  141. package/examples/metal-orm-sqlite-music/db.ts +148 -0
  142. package/examples/metal-orm-sqlite-music/index.ts +6 -0
  143. package/examples/metal-orm-sqlite-music/track.controller.ts +221 -0
  144. package/examples/metal-orm-sqlite-music/track.dtos.ts +82 -0
  145. package/examples/metal-orm-sqlite-music/track.entity.ts +27 -0
  146. package/examples/openapi/health.controller.ts +11 -0
  147. package/examples/openapi/health.dto.ts +7 -0
  148. package/examples/openapi/index.ts +12 -0
  149. package/examples/restful/app.ts +15 -0
  150. package/examples/restful/index.ts +9 -0
  151. package/examples/restful/task.controller.ts +118 -0
  152. package/examples/restful/task.dtos.ts +66 -0
  153. package/examples/restful/task.store.ts +95 -0
  154. package/examples/tsconfig.json +8 -0
  155. package/examples/utils/start-server.ts +56 -0
  156. package/package.json +33 -97
  157. package/scripts/run-example.js +29 -0
  158. package/src/adapter/express.ts +589 -0
  159. package/src/adapter/metal-orm/convention-overrides.ts +115 -0
  160. package/src/adapter/metal-orm/crud-dtos.ts +141 -0
  161. package/src/adapter/metal-orm/dto.ts +20 -0
  162. package/src/adapter/metal-orm/error-dtos.ts +51 -0
  163. package/src/adapter/metal-orm/field-builder.ts +185 -0
  164. package/src/adapter/metal-orm/filters.ts +52 -0
  165. package/src/adapter/metal-orm/index.ts +66 -0
  166. package/src/adapter/metal-orm/paged-dtos.ts +94 -0
  167. package/src/adapter/metal-orm/pagination.ts +28 -0
  168. package/src/adapter/metal-orm/types.ts +250 -0
  169. package/src/adapter/metal-orm/utils.ts +36 -0
  170. package/src/adapter/metal-orm.test.ts +439 -0
  171. package/src/core/__tests__/coerce.test.ts +39 -0
  172. package/src/core/__tests__/dto-compose.test.ts +68 -0
  173. package/src/core/__tests__/schema-builder.test.ts +82 -0
  174. package/src/core/coerce.ts +190 -0
  175. package/src/core/decorators.ts +645 -0
  176. package/src/core/errors.ts +55 -0
  177. package/src/core/metadata.ts +110 -0
  178. package/src/core/openapi.ts +282 -0
  179. package/src/core/schema-builder.ts +287 -0
  180. package/src/core/schema.ts +400 -0
  181. package/src/core/types.ts +14 -0
  182. package/src/e2e/http-error.e2e.test.ts +52 -0
  183. package/src/e2e/sqlite-metal-orm.e2e.test.ts +174 -0
  184. package/src/e2e/sqlite.e2e.test.ts +126 -0
  185. package/src/index.ts +8 -0
  186. package/tsconfig.eslint.json +7 -0
  187. package/tsconfig.json +18 -0
  188. package/vitest.config.ts +8 -0
  189. package/dist/adapter/express/auth.d.ts +0 -13
  190. package/dist/adapter/express/auth.d.ts.map +0 -1
  191. package/dist/adapter/express/bootstrap.d.ts +0 -40
  192. package/dist/adapter/express/bootstrap.d.ts.map +0 -1
  193. package/dist/adapter/express/coercion.d.ts +0 -102
  194. package/dist/adapter/express/coercion.d.ts.map +0 -1
  195. package/dist/adapter/express/index.d.ts +0 -6
  196. package/dist/adapter/express/index.d.ts.map +0 -1
  197. package/dist/adapter/express/merge.d.ts +0 -45
  198. package/dist/adapter/express/merge.d.ts.map +0 -1
  199. package/dist/adapter/express/openapi.d.ts +0 -66
  200. package/dist/adapter/express/openapi.d.ts.map +0 -1
  201. package/dist/adapter/express/router.d.ts +0 -10
  202. package/dist/adapter/express/router.d.ts.map +0 -1
  203. package/dist/adapter/express/swagger.d.ts +0 -18
  204. package/dist/adapter/express/swagger.d.ts.map +0 -1
  205. package/dist/adapter/express/types.d.ts +0 -110
  206. package/dist/adapter/express/types.d.ts.map +0 -1
  207. package/dist/adapter/express/validation.d.ts +0 -27
  208. package/dist/adapter/express/validation.d.ts.map +0 -1
  209. package/dist/cli/progress.d.ts +0 -124
  210. package/dist/cli/progress.d.ts.map +0 -1
  211. package/dist/cli.cjs +0 -4622
  212. package/dist/cli.cjs.map +0 -1
  213. package/dist/cli.d.ts +0 -3
  214. package/dist/cli.d.ts.map +0 -1
  215. package/dist/cli.js +0 -4603
  216. package/dist/cli.js.map +0 -1
  217. package/dist/compiler/analyze/index.d.ts +0 -5
  218. package/dist/compiler/analyze/index.d.ts.map +0 -1
  219. package/dist/compiler/analyze/scanControllers.d.ts +0 -88
  220. package/dist/compiler/analyze/scanControllers.d.ts.map +0 -1
  221. package/dist/compiler/cache/isStale.d.ts +0 -46
  222. package/dist/compiler/cache/isStale.d.ts.map +0 -1
  223. package/dist/compiler/cache/loadArtifacts.d.ts +0 -149
  224. package/dist/compiler/cache/loadArtifacts.d.ts.map +0 -1
  225. package/dist/compiler/cache/schema.d.ts +0 -32
  226. package/dist/compiler/cache/schema.d.ts.map +0 -1
  227. package/dist/compiler/cache/writeCache.d.ts +0 -14
  228. package/dist/compiler/cache/writeCache.d.ts.map +0 -1
  229. package/dist/compiler/gems.d.ts +0 -75
  230. package/dist/compiler/gems.d.ts.map +0 -1
  231. package/dist/compiler/generator/index.d.ts +0 -7
  232. package/dist/compiler/generator/index.d.ts.map +0 -1
  233. package/dist/compiler/generator/manifest.d.ts +0 -23
  234. package/dist/compiler/generator/manifest.d.ts.map +0 -1
  235. package/dist/compiler/generator/openapi.d.ts +0 -118
  236. package/dist/compiler/generator/openapi.d.ts.map +0 -1
  237. package/dist/compiler/graph/builder.d.ts +0 -24
  238. package/dist/compiler/graph/builder.d.ts.map +0 -1
  239. package/dist/compiler/graph/index.d.ts +0 -7
  240. package/dist/compiler/graph/index.d.ts.map +0 -1
  241. package/dist/compiler/graph/schemaGraph.d.ts +0 -67
  242. package/dist/compiler/graph/schemaGraph.d.ts.map +0 -1
  243. package/dist/compiler/graph/types.d.ts +0 -203
  244. package/dist/compiler/graph/types.d.ts.map +0 -1
  245. package/dist/compiler/index.d.ts +0 -12
  246. package/dist/compiler/index.d.ts.map +0 -1
  247. package/dist/compiler/ir/index.d.ts +0 -7
  248. package/dist/compiler/ir/index.d.ts.map +0 -1
  249. package/dist/compiler/ir/pipeline.d.ts +0 -82
  250. package/dist/compiler/ir/pipeline.d.ts.map +0 -1
  251. package/dist/compiler/ir/stages.d.ts +0 -40
  252. package/dist/compiler/ir/stages.d.ts.map +0 -1
  253. package/dist/compiler/ir/visitor.d.ts +0 -98
  254. package/dist/compiler/ir/visitor.d.ts.map +0 -1
  255. package/dist/compiler/manifest/emit.d.ts +0 -21
  256. package/dist/compiler/manifest/emit.d.ts.map +0 -1
  257. package/dist/compiler/manifest/format.d.ts +0 -119
  258. package/dist/compiler/manifest/format.d.ts.map +0 -1
  259. package/dist/compiler/manifest/index.d.ts +0 -6
  260. package/dist/compiler/manifest/index.d.ts.map +0 -1
  261. package/dist/compiler/runner/createProgram.d.ts +0 -24
  262. package/dist/compiler/runner/createProgram.d.ts.map +0 -1
  263. package/dist/compiler/runner/index.d.ts +0 -5
  264. package/dist/compiler/runner/index.d.ts.map +0 -1
  265. package/dist/compiler/schema/extractAnnotations.d.ts +0 -57
  266. package/dist/compiler/schema/extractAnnotations.d.ts.map +0 -1
  267. package/dist/compiler/schema/index.d.ts +0 -10
  268. package/dist/compiler/schema/index.d.ts.map +0 -1
  269. package/dist/compiler/schema/intersectionHandler.d.ts +0 -44
  270. package/dist/compiler/schema/intersectionHandler.d.ts.map +0 -1
  271. package/dist/compiler/schema/objectHandler.d.ts +0 -146
  272. package/dist/compiler/schema/objectHandler.d.ts.map +0 -1
  273. package/dist/compiler/schema/openapi.d.ts +0 -71
  274. package/dist/compiler/schema/openapi.d.ts.map +0 -1
  275. package/dist/compiler/schema/parameters.d.ts +0 -90
  276. package/dist/compiler/schema/parameters.d.ts.map +0 -1
  277. package/dist/compiler/schema/partitioner.d.ts +0 -85
  278. package/dist/compiler/schema/partitioner.d.ts.map +0 -1
  279. package/dist/compiler/schema/primitives.d.ts +0 -68
  280. package/dist/compiler/schema/primitives.d.ts.map +0 -1
  281. package/dist/compiler/schema/queryBuilderAnalyzer.d.ts +0 -95
  282. package/dist/compiler/schema/queryBuilderAnalyzer.d.ts.map +0 -1
  283. package/dist/compiler/schema/queryBuilderSchemaBuilder.d.ts +0 -13
  284. package/dist/compiler/schema/queryBuilderSchemaBuilder.d.ts.map +0 -1
  285. package/dist/compiler/schema/serviceCallAnalyzer.d.ts +0 -102
  286. package/dist/compiler/schema/serviceCallAnalyzer.d.ts.map +0 -1
  287. package/dist/compiler/schema/splitOpenapi.d.ts +0 -46
  288. package/dist/compiler/schema/splitOpenapi.d.ts.map +0 -1
  289. package/dist/compiler/schema/typeToJsonSchema.d.ts +0 -26
  290. package/dist/compiler/schema/typeToJsonSchema.d.ts.map +0 -1
  291. package/dist/compiler/schema/types.d.ts +0 -70
  292. package/dist/compiler/schema/types.d.ts.map +0 -1
  293. package/dist/compiler/schema/unionHandler.d.ts +0 -70
  294. package/dist/compiler/schema/unionHandler.d.ts.map +0 -1
  295. package/dist/compiler/transform/dedup.d.ts +0 -35
  296. package/dist/compiler/transform/dedup.d.ts.map +0 -1
  297. package/dist/compiler/transform/flatten.d.ts +0 -50
  298. package/dist/compiler/transform/flatten.d.ts.map +0 -1
  299. package/dist/compiler/transform/index.d.ts +0 -7
  300. package/dist/compiler/transform/index.d.ts.map +0 -1
  301. package/dist/compiler/transform/inline.d.ts +0 -46
  302. package/dist/compiler/transform/inline.d.ts.map +0 -1
  303. package/dist/compiler/validation/emitPrecompiledValidators.d.ts +0 -62
  304. package/dist/compiler/validation/emitPrecompiledValidators.d.ts.map +0 -1
  305. package/dist/compiler/validation/index.d.ts +0 -5
  306. package/dist/compiler/validation/index.d.ts.map +0 -1
  307. package/dist/decorators/Auth.d.ts +0 -22
  308. package/dist/decorators/Auth.d.ts.map +0 -1
  309. package/dist/decorators/Controller.d.ts +0 -17
  310. package/dist/decorators/Controller.d.ts.map +0 -1
  311. package/dist/decorators/Public.d.ts +0 -15
  312. package/dist/decorators/Public.d.ts.map +0 -1
  313. package/dist/decorators/Use.d.ts +0 -23
  314. package/dist/decorators/Use.d.ts.map +0 -1
  315. package/dist/decorators/methods.d.ts +0 -26
  316. package/dist/decorators/methods.d.ts.map +0 -1
  317. package/dist/express.cjs +0 -1186
  318. package/dist/express.cjs.map +0 -1
  319. package/dist/express.d.ts +0 -8
  320. package/dist/express.d.ts.map +0 -1
  321. package/dist/express.js +0 -1150
  322. package/dist/express.js.map +0 -1
  323. package/dist/http.d.ts +0 -33
  324. package/dist/http.d.ts.map +0 -1
  325. package/dist/index.cjs +0 -724
  326. package/dist/index.cjs.map +0 -1
  327. package/dist/metal/applyListQuery.d.ts +0 -100
  328. package/dist/metal/applyListQuery.d.ts.map +0 -1
  329. package/dist/metal/index.cjs +0 -278
  330. package/dist/metal/index.cjs.map +0 -1
  331. package/dist/metal/index.d.ts +0 -15
  332. package/dist/metal/index.d.ts.map +0 -1
  333. package/dist/metal/index.js +0 -243
  334. package/dist/metal/index.js.map +0 -1
  335. package/dist/metal/listQuery.d.ts +0 -26
  336. package/dist/metal/listQuery.d.ts.map +0 -1
  337. package/dist/metal/queryOptions.d.ts +0 -16
  338. package/dist/metal/queryOptions.d.ts.map +0 -1
  339. package/dist/metal/readMetalBag.d.ts +0 -69
  340. package/dist/metal/readMetalBag.d.ts.map +0 -1
  341. package/dist/metal/registerMetalEntities.d.ts +0 -26
  342. package/dist/metal/registerMetalEntities.d.ts.map +0 -1
  343. package/dist/metal/schemaFromEntity.d.ts +0 -41
  344. package/dist/metal/schemaFromEntity.d.ts.map +0 -1
  345. package/dist/metal/searchWhere.d.ts +0 -97
  346. package/dist/metal/searchWhere.d.ts.map +0 -1
  347. package/dist/metal/symbolMetadata.d.ts +0 -8
  348. package/dist/metal/symbolMetadata.d.ts.map +0 -1
  349. package/dist/runtime/auth/runtime.d.ts +0 -183
  350. package/dist/runtime/auth/runtime.d.ts.map +0 -1
  351. package/dist/runtime/metadata/bucket.d.ts +0 -2
  352. package/dist/runtime/metadata/bucket.d.ts.map +0 -1
  353. package/dist/runtime/metadata/key.d.ts +0 -2
  354. package/dist/runtime/metadata/key.d.ts.map +0 -1
  355. package/dist/runtime/metadata/read.d.ts +0 -2
  356. package/dist/runtime/metadata/read.d.ts.map +0 -1
  357. package/dist/runtime/metadata/types.d.ts +0 -95
  358. package/dist/runtime/metadata/types.d.ts.map +0 -1
  359. package/dist/runtime/polyfill.d.ts +0 -2
  360. package/dist/runtime/polyfill.d.ts.map +0 -1
  361. package/dist/runtime/upload.d.ts +0 -44
  362. package/dist/runtime/upload.d.ts.map +0 -1
  363. package/dist/runtime/validation/ajv.d.ts +0 -120
  364. package/dist/runtime/validation/ajv.d.ts.map +0 -1
  365. package/dist/runtime/validation/index.d.ts +0 -11
  366. package/dist/runtime/validation/index.d.ts.map +0 -1
  367. package/dist/schema/decorators.d.ts +0 -37
  368. package/dist/schema/decorators.d.ts.map +0 -1
  369. package/dist/schema/index.cjs +0 -214
  370. package/dist/schema/index.cjs.map +0 -1
  371. package/dist/schema/index.d.ts +0 -2
  372. package/dist/schema/index.d.ts.map +0 -1
  373. package/dist/schema/index.js +0 -163
  374. package/dist/schema/index.js.map +0 -1
  375. package/dist/scripts/adorn-example.cjs +0 -404
  376. package/dist/scripts/adorn-example.cjs.map +0 -1
  377. package/dist/utils/operationId.d.ts +0 -2
  378. package/dist/utils/operationId.d.ts.map +0 -1
  379. package/dist/utils/path.d.ts +0 -2
  380. package/dist/utils/path.d.ts.map +0 -1
  381. package/dist/utils/port.d.ts +0 -9
  382. package/dist/utils/port.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -1,638 +1,19 @@
1
- // src/runtime/polyfill.ts
2
- Symbol.metadata ??= /* @__PURE__ */ Symbol("Symbol.metadata");
3
-
4
- // src/runtime/metadata/key.ts
5
- var ADORN_META = /* @__PURE__ */ Symbol.for("adorn-api/meta");
6
-
7
- // src/runtime/metadata/bucket.ts
8
- function getBucket(metadata) {
9
- if (!metadata) {
10
- throw new Error("Decorator context.metadata is undefined. Ensure Symbol.metadata polyfill runs before decorators.");
11
- }
12
- let bucket = metadata[ADORN_META];
13
- if (!bucket) {
14
- bucket = { ops: [], controllerUse: [] };
15
- metadata[ADORN_META] = bucket;
16
- }
17
- if (!bucket.controllerUse) {
18
- bucket.controllerUse = [];
19
- }
20
- return bucket;
21
- }
22
-
23
- // src/decorators/Controller.ts
24
- function Controller(basePath) {
25
- return function(target, context) {
26
- const bucket = getBucket(context.metadata);
27
- bucket.basePath = basePath;
28
- };
29
- }
30
-
31
- // src/decorators/methods.ts
32
- function createMethodDecorator(httpMethod, path2) {
33
- return function(target, context) {
34
- if (context.private || context.static) {
35
- return;
36
- }
37
- const methodName = String(context.name);
38
- const bucket = getBucket(context.metadata);
39
- let op = bucket.ops.find((op2) => op2.methodName === methodName);
40
- if (!op) {
41
- op = {
42
- httpMethod,
43
- path: path2,
44
- methodName
45
- };
46
- bucket.ops.push(op);
47
- } else {
48
- op.httpMethod = httpMethod;
49
- op.path = path2;
50
- }
51
- };
52
- }
53
- var Get = (path2) => createMethodDecorator("GET", path2);
54
- var Post = (path2) => createMethodDecorator("POST", path2);
55
- var Put = (path2) => createMethodDecorator("PUT", path2);
56
- var Patch = (path2) => createMethodDecorator("PATCH", path2);
57
- var Delete = (path2) => createMethodDecorator("DELETE", path2);
58
-
59
- // src/decorators/Use.ts
60
- function Use(...middleware) {
61
- return function(target, context) {
62
- if (context.kind === "class") {
63
- const bucket = getBucket(context.metadata);
64
- if (!bucket.controllerUse) {
65
- bucket.controllerUse = [];
66
- }
67
- bucket.controllerUse.push(...middleware);
68
- } else if (context.kind === "method") {
69
- const methodName = String(context.name);
70
- const bucket = getBucket(context.metadata);
71
- let op = bucket.ops.find((op2) => op2.methodName === methodName);
72
- if (!op) {
73
- op = {
74
- httpMethod: "GET",
75
- path: "/",
76
- methodName
77
- };
78
- bucket.ops.push(op);
79
- }
80
- if (!op.use) {
81
- op.use = [];
82
- }
83
- op.use.push(...middleware);
84
- } else {
85
- throw new Error("@Use decorator can only be applied to classes or methods");
86
- }
87
- };
88
- }
89
-
90
- // src/decorators/Auth.ts
91
- function Auth(scheme, options) {
92
- return function(target, context) {
93
- if (context.kind !== "method") {
94
- throw new Error("@Auth decorator can only be applied to methods");
95
- }
96
- const methodName = String(context.name);
97
- const bucket = getBucket(context.metadata);
98
- let op = bucket.ops.find((op2) => op2.methodName === methodName);
99
- if (!op) {
100
- op = {
101
- httpMethod: "GET",
102
- path: "/",
103
- methodName
104
- };
105
- bucket.ops.push(op);
106
- }
107
- op.auth = {
108
- scheme,
109
- scopes: options?.scopes,
110
- optional: options?.optional ?? false
111
- };
112
- };
113
- }
114
-
115
- // src/decorators/Public.ts
116
- function Public() {
117
- return function(target, context) {
118
- if (context.kind !== "method") {
119
- throw new Error("@Public decorator can only be applied to methods");
120
- }
121
- const methodName = String(context.name);
122
- const bucket = getBucket(context.metadata);
123
- let op = bucket.ops.find((op2) => op2.methodName === methodName);
124
- if (!op) {
125
- op = {
126
- httpMethod: "GET",
127
- path: "/",
128
- methodName
129
- };
130
- bucket.ops.push(op);
131
- }
132
- op.auth = "public";
133
- };
134
- }
135
-
136
- // src/runtime/metadata/read.ts
137
- function readAdornBucket(ctor) {
138
- const metaSym = Symbol.metadata;
139
- if (!metaSym) {
140
- return null;
141
- }
142
- const classMetadata = ctor[metaSym];
143
- if (!classMetadata) {
144
- return null;
145
- }
146
- const bucket = classMetadata[ADORN_META];
147
- return bucket ?? null;
148
- }
149
-
150
- // src/schema/decorators.ts
151
- var ADORN_META2 = /* @__PURE__ */ Symbol.for("adorn-api.metadata");
152
- function getOrCreateMetadata(metadata) {
153
- const meta = metadata[ADORN_META2] ??= {};
154
- meta.schema ??= { props: {} };
155
- return meta;
156
- }
157
- function pushSchemaFrag(target, propertyKey, metadata, frag) {
158
- const meta = getOrCreateMetadata(metadata);
159
- const props = meta.schema.props;
160
- (props[propertyKey] ??= []).push(frag);
161
- }
162
- function Schema(frag) {
163
- return function(target, propertyKey) {
164
- pushSchemaFrag(target, propertyKey, {}, frag);
165
- };
166
- }
167
- function Min(n) {
168
- return function(target, propertyKey) {
169
- pushSchemaFrag(target, propertyKey, {}, { minimum: n });
170
- };
171
- }
172
- function Max(n) {
173
- return function(target, propertyKey) {
174
- pushSchemaFrag(target, propertyKey, {}, { maximum: n });
175
- };
176
- }
177
- function ExclusiveMin(n) {
178
- return function(target, propertyKey) {
179
- pushSchemaFrag(target, propertyKey, {}, { exclusiveMinimum: n });
180
- };
181
- }
182
- function ExclusiveMax(n) {
183
- return function(target, propertyKey) {
184
- pushSchemaFrag(target, propertyKey, {}, { exclusiveMaximum: n });
185
- };
186
- }
187
- function MinLength(n) {
188
- return function(target, propertyKey) {
189
- pushSchemaFrag(target, propertyKey, {}, { minLength: n });
190
- };
191
- }
192
- function MaxLength(n) {
193
- return function(target, propertyKey) {
194
- pushSchemaFrag(target, propertyKey, {}, { maxLength: n });
195
- };
196
- }
197
- function Pattern(re) {
198
- return function(target, propertyKey) {
199
- pushSchemaFrag(target, propertyKey, {}, { pattern: typeof re === "string" ? re : re.source });
200
- };
201
- }
202
- function Format(fmt) {
203
- return function(target, propertyKey) {
204
- pushSchemaFrag(target, propertyKey, {}, { format: fmt });
205
- };
206
- }
207
- function MinItems(n) {
208
- return function(target, propertyKey) {
209
- pushSchemaFrag(target, propertyKey, {}, { minItems: n });
210
- };
211
- }
212
- function MaxItems(n) {
213
- return function(target, propertyKey) {
214
- pushSchemaFrag(target, propertyKey, {}, { maxItems: n });
215
- };
216
- }
217
- function MinProperties(n) {
218
- return function(target, propertyKey) {
219
- pushSchemaFrag(target, propertyKey, {}, { minProperties: n });
220
- };
221
- }
222
- function MaxProperties(n) {
223
- return function(target, propertyKey) {
224
- pushSchemaFrag(target, propertyKey, {}, { maxProperties: n });
225
- };
226
- }
227
- function MultipleOf(n) {
228
- return function(target, propertyKey) {
229
- pushSchemaFrag(target, propertyKey, {}, { multipleOf: n });
230
- };
231
- }
232
- function Example(value) {
233
- return function(target, propertyKey) {
234
- pushSchemaFrag(target, propertyKey, {}, { example: value });
235
- };
236
- }
237
- function Examples(values) {
238
- return function(target, propertyKey) {
239
- pushSchemaFrag(target, propertyKey, {}, { examples: values });
240
- };
241
- }
242
- function Description(desc) {
243
- return function(target, propertyKey) {
244
- pushSchemaFrag(target, propertyKey, {}, { description: desc });
245
- };
246
- }
247
- function Enum(vals) {
248
- return function(target, propertyKey) {
249
- pushSchemaFrag(target, propertyKey, {}, { enum: vals });
250
- };
251
- }
252
- function Const(val) {
253
- return function(target, propertyKey) {
254
- pushSchemaFrag(target, propertyKey, {}, { const: val });
255
- };
256
- }
257
- function Default(val) {
258
- return function(target, propertyKey) {
259
- pushSchemaFrag(target, propertyKey, {}, { default: val });
260
- };
261
- }
262
- function AdditionalProperties(value) {
263
- return function(target, propertyKey) {
264
- pushSchemaFrag(target, propertyKey, {}, { additionalProperties: value });
265
- };
266
- }
267
- function Closed() {
268
- return function(target, propertyKey) {
269
- pushSchemaFrag(target, propertyKey, {}, { additionalProperties: false });
270
- };
271
- }
272
- function ClosedUnevaluated() {
273
- return function(target, propertyKey) {
274
- pushSchemaFrag(target, propertyKey, {}, { unevaluatedProperties: false });
275
- };
276
- }
277
- function Union(mode) {
278
- return function(target) {
279
- target[ADORN_META2] = target[ADORN_META2] ?? {};
280
- const meta = target[ADORN_META2];
281
- meta.schema = meta.schema ?? { props: {} };
282
- meta.schema.unionMode = mode;
283
- };
284
- }
285
-
286
- // src/runtime/validation/ajv.ts
287
- import Ajv from "ajv";
288
- import addFormats from "ajv-formats";
289
- var ValidationErrorResponse = class extends Error {
290
- /**
291
- * HTTP status code for validation errors.
292
- */
293
- statusCode;
294
- /**
295
- * Detailed validation errors.
296
- */
297
- errors;
298
- /**
299
- * Creates a new ValidationErrorResponse.
300
- *
301
- * @param statusCode - HTTP status code (typically 400)
302
- * @param errors - Array of validation errors
303
- */
304
- constructor(statusCode, errors) {
305
- super("Validation failed");
306
- this.name = "ValidationErrorResponse";
307
- this.statusCode = statusCode;
308
- this.errors = errors;
309
- }
310
- };
311
- function createValidator() {
312
- const ajv = new Ajv.default({
313
- allErrors: true,
314
- coerceTypes: false,
315
- strict: false,
316
- validateFormats: true
317
- });
318
- addFormats.default(ajv);
319
- ajv.addFormat("br-phone", /^\(\d{2}\)\s\d{5}-\d{4}$/);
320
- return ajv;
321
- }
322
- function formatValidationErrors(errors) {
323
- const formatted = {};
324
- for (const error of errors) {
325
- const path2 = error.path || "body";
326
- if (!formatted[path2]) {
327
- formatted[path2] = [];
328
- }
329
- formatted[path2].push(error.message);
330
- }
331
- return {
332
- error: "Validation failed",
333
- details: formatted
334
- };
335
- }
336
-
337
- // src/http.ts
338
- var ADORN_META3 = /* @__PURE__ */ Symbol.for("adorn-api.metadata");
339
- function getMetadata(target) {
340
- const host = target;
341
- const metadata = host[ADORN_META3] ?? {};
342
- host[ADORN_META3] = metadata;
343
- return metadata;
344
- }
345
- function PartType(contentTypeOrOptions) {
346
- return function(target, propertyKey) {
347
- const metadata = getMetadata(target);
348
- const options = typeof contentTypeOrOptions === "string" ? { contentType: contentTypeOrOptions } : contentTypeOrOptions;
349
- metadata.fileParts ??= {};
350
- metadata.fileParts[propertyKey.toString()] = options;
351
- };
352
- }
353
- function File() {
354
- return function(target, propertyKey) {
355
- const metadata = getMetadata(target);
356
- metadata.fileParts ??= {};
357
- metadata.fileParts[propertyKey.toString()] = metadata.fileParts[propertyKey.toString()] ?? {};
358
- };
359
- }
360
- function Consumes(...contentTypes) {
361
- return function(target) {
362
- const metadata = getMetadata(target.prototype);
363
- metadata.consumes = contentTypes;
364
- };
365
- }
366
- function Produces(...contentTypes) {
367
- return function(target) {
368
- const metadata = getMetadata(target.prototype);
369
- metadata.produces = contentTypes;
370
- };
371
- }
372
-
373
- // src/compiler/cache/loadArtifacts.ts
374
- import fs from "fs";
375
- import path from "path";
376
- import { stat } from "fs/promises";
377
- var artifactCache = /* @__PURE__ */ new Map();
378
- async function getMtime(filePath) {
379
- try {
380
- const stats = await stat(filePath);
381
- return stats.mtimeMs;
382
- } catch {
383
- return null;
384
- }
385
- }
386
- async function loadArtifacts(options) {
387
- const { outDir } = options;
388
- const cacheKey = path.resolve(outDir);
389
- const entry = artifactCache.get(cacheKey);
390
- const openapiPath = path.join(outDir, "openapi.json");
391
- const manifestPath = path.join(outDir, "manifest.json");
392
- const validatorsPath = path.join(outDir, "validators.mjs");
393
- const openapiMtime = await getMtime(openapiPath);
394
- const manifestMtime = await getMtime(manifestPath);
395
- const validatorsMtime = await getMtime(validatorsPath);
396
- if (entry) {
397
- const mtimesMatch = entry.mtimes.openapi === openapiMtime && entry.mtimes.manifest === manifestMtime && entry.mtimes.validators === validatorsMtime;
398
- if (mtimesMatch) {
399
- if (entry.openapi && entry.manifest) {
400
- return {
401
- openapi: entry.openapi,
402
- manifest: entry.manifest,
403
- validators: entry.validators
404
- };
405
- }
406
- }
407
- }
408
- const openapiContent = fs.readFileSync(openapiPath, "utf-8");
409
- const manifestContent = fs.readFileSync(manifestPath, "utf-8");
410
- const openapi = JSON.parse(openapiContent);
411
- const manifest = JSON.parse(manifestContent);
412
- let validators = null;
413
- if (manifest.validation.mode === "precompiled" && manifest.validation.precompiledModule) {
414
- try {
415
- const validatorsModule = await import(path.join(outDir, manifest.validation.precompiledModule));
416
- validators = validatorsModule;
417
- } catch (err) {
418
- console.warn(`Failed to load precompiled validators: ${err}`);
419
- }
420
- }
421
- artifactCache.set(cacheKey, {
422
- openapi,
423
- manifest,
424
- validators,
425
- mtimes: {
426
- openapi: openapiMtime,
427
- manifest: manifestMtime,
428
- validators: validatorsMtime
429
- }
430
- });
431
- return {
432
- openapi,
433
- manifest,
434
- validators
435
- };
436
- }
437
- function clearArtifactCache(outDir) {
438
- if (outDir) {
439
- const cacheKey = path.resolve(outDir);
440
- artifactCache.delete(cacheKey);
441
- } else {
442
- artifactCache.clear();
443
- }
444
- }
445
- function getArtifactCacheStats() {
446
- return {
447
- size: artifactCache.size,
448
- keys: Array.from(artifactCache.keys())
449
- };
450
- }
451
-
452
- // src/utils/port.ts
453
- import { createServer } from "net";
454
- import { exec } from "child_process";
455
- import { promisify } from "util";
456
- var execAsync = promisify(exec);
457
- async function isPortAvailable(port, host = "0.0.0.0") {
458
- return new Promise((resolve) => {
459
- const server = createServer();
460
- server.on("error", (err) => {
461
- if (err.code === "EADDRINUSE") {
462
- resolve(false);
463
- } else {
464
- resolve(false);
465
- }
466
- });
467
- server.once("listening", () => {
468
- server.close(() => {
469
- resolve(true);
470
- });
471
- });
472
- server.listen(port, host);
473
- });
474
- }
475
- async function findProcessOnPort(port) {
476
- try {
477
- const platform = process.platform;
478
- if (platform === "win32") {
479
- const { stdout } = await execAsync(`netstat -ano | findstr :${port}`);
480
- for (const line of stdout.split("\n")) {
481
- const trimmed = line.trim();
482
- if (!trimmed || trimmed.includes("PID")) continue;
483
- const parts = trimmed.split(/\s+/);
484
- if (parts.length >= 5) {
485
- const address = parts[1];
486
- const pid = parseInt(parts[parts.length - 1], 10);
487
- if (address.includes(`:${port}`) && !isNaN(pid)) {
488
- const command = await getProcessNameOnWindows(pid);
489
- return { pid, command };
490
- }
491
- }
492
- }
493
- } else {
494
- const { stdout } = await execAsync(`lsof -ti:${port}`);
495
- const pids = stdout.trim().split("\n").filter(Boolean).map(Number);
496
- if (pids.length > 0) {
497
- const pid = pids[0];
498
- const command = await getProcessNameOnUnix(pid);
499
- return { pid, command };
500
- }
501
- }
502
- return null;
503
- } catch (error) {
504
- if (error.message.includes("matches found")) {
505
- return null;
506
- }
507
- return null;
508
- }
509
- }
510
- async function getProcessNameOnWindows(pid) {
511
- try {
512
- const { stdout } = await execAsync(`tasklist /FI "PID eq ${pid}" /FO CSV /NH`);
513
- const line = stdout.trim().split("\n")[0];
514
- if (line) {
515
- const parts = line.split('","');
516
- if (parts.length >= 2) {
517
- return parts[0].replace(/"/g, "");
518
- }
519
- }
520
- } catch {
521
- return void 0;
522
- }
523
- }
524
- async function getProcessNameOnUnix(pid) {
525
- try {
526
- const { stdout } = await execAsync(`ps -p ${pid} -o comm=`);
527
- return stdout.trim() || void 0;
528
- } catch {
529
- return void 0;
530
- }
531
- }
532
- async function killProcess(pid) {
533
- try {
534
- process.kill(pid, "SIGTERM");
535
- await new Promise((resolve, reject) => {
536
- const timeout = setTimeout(() => {
537
- reject(new Error("Process did not terminate gracefully"));
538
- }, 5e3);
539
- const check = () => {
540
- try {
541
- process.kill(pid, 0);
542
- setTimeout(check, 500);
543
- } catch {
544
- clearInterval(interval);
545
- clearTimeout(timeout);
546
- resolve();
547
- }
548
- };
549
- const interval = setInterval(check, 500);
550
- });
551
- return true;
552
- } catch {
553
- try {
554
- process.kill(pid, "SIGKILL");
555
- await new Promise((resolve, reject) => {
556
- const timeout = setTimeout(() => {
557
- reject(new Error("Process did not terminate"));
558
- }, 3e3);
559
- setTimeout(() => {
560
- try {
561
- process.kill(pid, 0);
562
- clearTimeout(timeout);
563
- reject(new Error("Process still running"));
564
- } catch {
565
- clearTimeout(timeout);
566
- resolve();
567
- }
568
- }, 1e3);
569
- });
570
- return true;
571
- } catch {
572
- return false;
573
- }
574
- }
575
- }
576
- async function waitForPort(port, host = "0.0.0.0", timeout = 5e3) {
577
- const start = Date.now();
578
- while (Date.now() - start < timeout) {
579
- if (await isPortAvailable(port, host)) {
580
- return true;
581
- }
582
- await new Promise((resolve) => setTimeout(resolve, 200));
583
- }
584
- return false;
585
- }
586
- export {
587
- ADORN_META2 as ADORN_META,
588
- AdditionalProperties,
589
- Auth,
590
- Closed,
591
- ClosedUnevaluated,
592
- Const,
593
- Consumes,
594
- Controller,
595
- Default,
596
- Delete,
597
- Description,
598
- Enum,
599
- Example,
600
- Examples,
601
- ExclusiveMax,
602
- ExclusiveMin,
603
- File,
604
- Format,
605
- Get,
606
- Max,
607
- MaxItems,
608
- MaxLength,
609
- MaxProperties,
610
- Min,
611
- MinItems,
612
- MinLength,
613
- MinProperties,
614
- MultipleOf,
615
- PartType,
616
- PartType as PartType2,
617
- Patch,
618
- Pattern,
619
- Post,
620
- Produces,
621
- Public,
622
- Put,
623
- Schema,
624
- Union,
625
- Use,
626
- ValidationErrorResponse,
627
- clearArtifactCache,
628
- createValidator,
629
- findProcessOnPort,
630
- formatValidationErrors,
631
- getArtifactCacheStats,
632
- isPortAvailable,
633
- killProcess,
634
- loadArtifacts,
635
- readAdornBucket,
636
- waitForPort
637
- };
1
+ // Decorators
2
+ export * from "./decorators/index.js";
3
+ // Core
4
+ export { ExpressAdapter, HttpError, isHttpError, } from "./core/express-adapter.js";
5
+ // Metadata
6
+ export { metadataStorage } from "./metadata/metadata-storage.js";
7
+ // Types
8
+ export * from "./types/controller.js";
9
+ export * from "./types/metadata.js";
10
+ export * from "./types/openapi.js";
11
+ export * from "./types/common.js";
12
+ // OpenAPI
13
+ export { OpenApiGenerator } from "./openapi/openapi-generator.js";
14
+ export { setupSwaggerUi } from "./openapi/swagger-ui.js";
15
+ // Integrations
16
+ export * from "./metal-orm-integration/index.js";
17
+ // Validation
18
+ export { createZodValidationMiddleware, formatZodErrors, } from "./validation/zod-adapter.js";
638
19
  //# sourceMappingURL=index.js.map