@lakutata/entrypoint 3.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (325) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +183 -0
  3. package/THIRD_PARTY_NOTICES.md +206 -0
  4. package/dist/cjs/Entrypoint.d.ts +868 -0
  5. package/dist/cjs/Entrypoint.js +998 -0
  6. package/dist/cjs/adapter/commander/CommanderCLIEntrypoint.d.ts +192 -0
  7. package/dist/cjs/adapter/commander/CommanderCLIEntrypoint.js +439 -0
  8. package/dist/cjs/adapter/commander/Prompt.d.ts +22 -0
  9. package/dist/cjs/adapter/commander/Prompt.js +164 -0
  10. package/dist/cjs/adapter/commander/Width.d.ts +12 -0
  11. package/dist/cjs/adapter/commander/Width.js +67 -0
  12. package/dist/cjs/adapter/electron/ElectronIPCServiceEntrypoint.d.ts +203 -0
  13. package/dist/cjs/adapter/electron/ElectronIPCServiceEntrypoint.js +249 -0
  14. package/dist/cjs/adapter/express/ExpressHTTPEntrypoint.d.ts +172 -0
  15. package/dist/cjs/adapter/express/ExpressHTTPEntrypoint.js +301 -0
  16. package/dist/cjs/adapter/express/Responders.d.ts +89 -0
  17. package/dist/cjs/adapter/express/Responders.js +71 -0
  18. package/dist/cjs/adapter/express/StaticUI.d.ts +83 -0
  19. package/dist/cjs/adapter/express/StaticUI.js +104 -0
  20. package/dist/cjs/adapter/fastify/FastifyHTTPEntrypoint.d.ts +156 -0
  21. package/dist/cjs/adapter/fastify/FastifyHTTPEntrypoint.js +339 -0
  22. package/dist/cjs/adapter/fastify/Responders.d.ts +88 -0
  23. package/dist/cjs/adapter/fastify/Responders.js +77 -0
  24. package/dist/cjs/adapter/http/HTTPServiceEntrypoint.d.ts +117 -0
  25. package/dist/cjs/adapter/http/HTTPServiceEntrypoint.js +257 -0
  26. package/dist/cjs/adapter/jsonrpc/JSONRPCProtocol.d.ts +194 -0
  27. package/dist/cjs/adapter/jsonrpc/JSONRPCProtocol.js +187 -0
  28. package/dist/cjs/adapter/jsonrpc/JSONRPCServiceEntrypoint.d.ts +154 -0
  29. package/dist/cjs/adapter/jsonrpc/JSONRPCServiceEntrypoint.js +397 -0
  30. package/dist/cjs/adapter/schedule/ScheduleEntrypoint.d.ts +86 -0
  31. package/dist/cjs/adapter/schedule/ScheduleEntrypoint.js +275 -0
  32. package/dist/cjs/adapter/socket.io/SocketIOServiceEntrypoint.d.ts +138 -0
  33. package/dist/cjs/adapter/socket.io/SocketIOServiceEntrypoint.js +216 -0
  34. package/dist/cjs/channel/BuiltinChannels.d.ts +18 -0
  35. package/dist/cjs/channel/BuiltinChannels.js +128 -0
  36. package/dist/cjs/channel/Channel.d.ts +196 -0
  37. package/dist/cjs/channel/Channel.js +106 -0
  38. package/dist/cjs/channel/EntrypointAdapter.d.ts +195 -0
  39. package/dist/cjs/channel/EntrypointAdapter.js +43 -0
  40. package/dist/cjs/context/BaseContext.d.ts +75 -0
  41. package/dist/cjs/context/BaseContext.js +90 -0
  42. package/dist/cjs/context/CLIContext.d.ts +38 -0
  43. package/dist/cjs/context/CLIContext.js +53 -0
  44. package/dist/cjs/context/HTTPContext.d.ts +52 -0
  45. package/dist/cjs/context/HTTPContext.js +78 -0
  46. package/dist/cjs/context/ScheduleContext.d.ts +47 -0
  47. package/dist/cjs/context/ScheduleContext.js +65 -0
  48. package/dist/cjs/context/ServiceContext.d.ts +47 -0
  49. package/dist/cjs/context/ServiceContext.js +62 -0
  50. package/dist/cjs/decorators/CLIAction.d.ts +120 -0
  51. package/dist/cjs/decorators/CLIAction.js +13 -0
  52. package/dist/cjs/decorators/HTTPAction.d.ts +178 -0
  53. package/dist/cjs/decorators/HTTPAction.js +14 -0
  54. package/dist/cjs/decorators/Prefix.d.ts +44 -0
  55. package/dist/cjs/decorators/Prefix.js +48 -0
  56. package/dist/cjs/decorators/Schedule.d.ts +120 -0
  57. package/dist/cjs/decorators/Schedule.js +64 -0
  58. package/dist/cjs/decorators/ServiceAction.d.ts +116 -0
  59. package/dist/cjs/decorators/ServiceAction.js +12 -0
  60. package/dist/cjs/decorators/UseMiddlewares.d.ts +52 -0
  61. package/dist/cjs/decorators/UseMiddlewares.js +58 -0
  62. package/dist/cjs/decorators/http/DELETE.d.ts +87 -0
  63. package/dist/cjs/decorators/http/DELETE.js +7 -0
  64. package/dist/cjs/decorators/http/GET.d.ts +89 -0
  65. package/dist/cjs/decorators/http/GET.js +7 -0
  66. package/dist/cjs/decorators/http/HEAD.d.ts +84 -0
  67. package/dist/cjs/decorators/http/HEAD.js +7 -0
  68. package/dist/cjs/decorators/http/OPTIONS.d.ts +80 -0
  69. package/dist/cjs/decorators/http/OPTIONS.js +7 -0
  70. package/dist/cjs/decorators/http/PATCH.d.ts +90 -0
  71. package/dist/cjs/decorators/http/PATCH.js +7 -0
  72. package/dist/cjs/decorators/http/POST.d.ts +91 -0
  73. package/dist/cjs/decorators/http/POST.js +7 -0
  74. package/dist/cjs/decorators/http/PUT.d.ts +92 -0
  75. package/dist/cjs/decorators/http/PUT.js +7 -0
  76. package/dist/cjs/exceptions/AccessDeniedException.d.ts +10 -0
  77. package/dist/cjs/exceptions/AccessDeniedException.js +17 -0
  78. package/dist/cjs/exceptions/ControllerActionNotFoundException.d.ts +9 -0
  79. package/dist/cjs/exceptions/ControllerActionNotFoundException.js +16 -0
  80. package/dist/cjs/exceptions/DuplicateActionNameException.d.ts +8 -0
  81. package/dist/cjs/exceptions/DuplicateActionNameException.js +15 -0
  82. package/dist/cjs/exceptions/EntrypointStoppedException.d.ts +9 -0
  83. package/dist/cjs/exceptions/EntrypointStoppedException.js +16 -0
  84. package/dist/cjs/exceptions/InvalidActionGroupException.d.ts +4 -0
  85. package/dist/cjs/exceptions/InvalidActionGroupException.js +11 -0
  86. package/dist/cjs/exceptions/InvalidChannelException.d.ts +8 -0
  87. package/dist/cjs/exceptions/InvalidChannelException.js +15 -0
  88. package/dist/cjs/exceptions/InvalidEntrypointAdapterException.d.ts +9 -0
  89. package/dist/cjs/exceptions/InvalidEntrypointAdapterException.js +16 -0
  90. package/dist/cjs/exceptions/InvalidMiddlewareException.d.ts +8 -0
  91. package/dist/cjs/exceptions/InvalidMiddlewareException.js +15 -0
  92. package/dist/cjs/exceptions/InvalidPrefixException.d.ts +8 -0
  93. package/dist/cjs/exceptions/InvalidPrefixException.js +15 -0
  94. package/dist/cjs/exceptions/MiddlewareNextCalledException.d.ts +8 -0
  95. package/dist/cjs/exceptions/MiddlewareNextCalledException.js +15 -0
  96. package/dist/cjs/exceptions/RouteNotFoundException.d.ts +9 -0
  97. package/dist/cjs/exceptions/RouteNotFoundException.js +16 -0
  98. package/dist/cjs/exceptions/ServiceInvokeException.d.ts +11 -0
  99. package/dist/cjs/exceptions/ServiceInvokeException.js +14 -0
  100. package/dist/cjs/exports/CTRLDecorators.d.ts +13 -0
  101. package/dist/cjs/exports/CTRLDecorators.js +38 -0
  102. package/dist/cjs/exports/Channel.d.ts +14 -0
  103. package/dist/cjs/exports/Channel.js +33 -0
  104. package/dist/cjs/exports/CommanderAdapter.d.ts +1 -0
  105. package/dist/cjs/exports/CommanderAdapter.js +8 -0
  106. package/dist/cjs/exports/ElectronAdapter.d.ts +1 -0
  107. package/dist/cjs/exports/ElectronAdapter.js +9 -0
  108. package/dist/cjs/exports/Entrypoint.d.ts +24 -0
  109. package/dist/cjs/exports/Entrypoint.js +55 -0
  110. package/dist/cjs/exports/ExpressAdapter.d.ts +4 -0
  111. package/dist/cjs/exports/ExpressAdapter.js +15 -0
  112. package/dist/cjs/exports/FastifyAdapter.d.ts +4 -0
  113. package/dist/cjs/exports/FastifyAdapter.js +14 -0
  114. package/dist/cjs/exports/JSONRPCAdapter.d.ts +2 -0
  115. package/dist/cjs/exports/JSONRPCAdapter.js +11 -0
  116. package/dist/cjs/exports/SocketIOAdapter.d.ts +1 -0
  117. package/dist/cjs/exports/SocketIOAdapter.js +9 -0
  118. package/dist/cjs/lib/AccessControl.d.ts +118 -0
  119. package/dist/cjs/lib/AccessControl.js +208 -0
  120. package/dist/cjs/lib/AccessControlRule.d.ts +91 -0
  121. package/dist/cjs/lib/AccessControlRule.js +76 -0
  122. package/dist/cjs/lib/ActionOptions.d.ts +67 -0
  123. package/dist/cjs/lib/ActionOptions.js +67 -0
  124. package/dist/cjs/lib/ActionResult.d.ts +28 -0
  125. package/dist/cjs/lib/ActionResult.js +28 -0
  126. package/dist/cjs/lib/ApplicationOf.d.ts +6 -0
  127. package/dist/cjs/lib/ApplicationOf.js +14 -0
  128. package/dist/cjs/lib/Controller.d.ts +59 -0
  129. package/dist/cjs/lib/Controller.js +64 -0
  130. package/dist/cjs/lib/ControllerEntrypoint.d.ts +168 -0
  131. package/dist/cjs/lib/ControllerEntrypoint.js +239 -0
  132. package/dist/cjs/lib/GetActionDTOAndOptions.d.ts +29 -0
  133. package/dist/cjs/lib/GetActionDTOAndOptions.js +49 -0
  134. package/dist/cjs/lib/HTTPErrors.d.ts +55 -0
  135. package/dist/cjs/lib/HTTPErrors.js +52 -0
  136. package/dist/cjs/lib/Middleware.d.ts +146 -0
  137. package/dist/cjs/lib/Middleware.js +144 -0
  138. package/dist/cjs/lib/Prefix.d.ts +98 -0
  139. package/dist/cjs/lib/Prefix.js +151 -0
  140. package/dist/cjs/lib/Result.d.ts +173 -0
  141. package/dist/cjs/lib/Result.js +153 -0
  142. package/dist/cjs/lib/ServiceResponseCodec.d.ts +82 -0
  143. package/dist/cjs/lib/ServiceResponseCodec.js +117 -0
  144. package/dist/cjs/lib/StringifyPattern.d.ts +7 -0
  145. package/dist/cjs/lib/StringifyPattern.js +58 -0
  146. package/dist/cjs/lib/UnsetValue.d.ts +12 -0
  147. package/dist/cjs/lib/UnsetValue.js +216 -0
  148. package/dist/cjs/lib/pattern/GlobPattern.d.ts +34 -0
  149. package/dist/cjs/lib/pattern/GlobPattern.js +68 -0
  150. package/dist/cjs/lib/pattern/PatternManager.d.ts +103 -0
  151. package/dist/cjs/lib/pattern/PatternManager.js +233 -0
  152. package/dist/cjs/lib/schedule/Cron.d.ts +56 -0
  153. package/dist/cjs/lib/schedule/Cron.js +282 -0
  154. package/dist/cjs/package.json +1 -0
  155. package/dist/cjs/types/CLIContextParams.d.ts +14 -0
  156. package/dist/cjs/types/CLIContextParams.js +2 -0
  157. package/dist/cjs/types/ErrorDescription.d.ts +14 -0
  158. package/dist/cjs/types/ErrorDescription.js +2 -0
  159. package/dist/cjs/types/HTTPContextParams.d.ts +27 -0
  160. package/dist/cjs/types/HTTPContextParams.js +2 -0
  161. package/dist/cjs/types/ScheduleContextParams.d.ts +21 -0
  162. package/dist/cjs/types/ScheduleContextParams.js +2 -0
  163. package/dist/cjs/types/ServiceContextParams.d.ts +16 -0
  164. package/dist/cjs/types/ServiceContextParams.js +2 -0
  165. package/dist/esm/Entrypoint.js +985 -0
  166. package/dist/esm/adapter/commander/CommanderCLIEntrypoint.js +433 -0
  167. package/dist/esm/adapter/commander/Prompt.js +127 -0
  168. package/dist/esm/adapter/commander/Width.js +63 -0
  169. package/dist/esm/adapter/electron/ElectronIPCServiceEntrypoint.js +212 -0
  170. package/dist/esm/adapter/express/ExpressHTTPEntrypoint.js +295 -0
  171. package/dist/esm/adapter/express/Responders.js +66 -0
  172. package/dist/esm/adapter/express/StaticUI.js +96 -0
  173. package/dist/esm/adapter/fastify/FastifyHTTPEntrypoint.js +333 -0
  174. package/dist/esm/adapter/fastify/Responders.js +73 -0
  175. package/dist/esm/adapter/http/HTTPServiceEntrypoint.js +253 -0
  176. package/dist/esm/adapter/jsonrpc/JSONRPCProtocol.js +182 -0
  177. package/dist/esm/adapter/jsonrpc/JSONRPCServiceEntrypoint.js +361 -0
  178. package/dist/esm/adapter/schedule/ScheduleEntrypoint.js +272 -0
  179. package/dist/esm/adapter/socket.io/SocketIOServiceEntrypoint.js +212 -0
  180. package/dist/esm/channel/BuiltinChannels.js +125 -0
  181. package/dist/esm/channel/Channel.js +100 -0
  182. package/dist/esm/channel/EntrypointAdapter.js +39 -0
  183. package/dist/esm/context/BaseContext.js +87 -0
  184. package/dist/esm/context/CLIContext.js +49 -0
  185. package/dist/esm/context/HTTPContext.js +74 -0
  186. package/dist/esm/context/ScheduleContext.js +61 -0
  187. package/dist/esm/context/ServiceContext.js +58 -0
  188. package/dist/esm/decorators/CLIAction.js +10 -0
  189. package/dist/esm/decorators/HTTPAction.js +11 -0
  190. package/dist/esm/decorators/Prefix.js +45 -0
  191. package/dist/esm/decorators/Schedule.js +61 -0
  192. package/dist/esm/decorators/ServiceAction.js +9 -0
  193. package/dist/esm/decorators/UseMiddlewares.js +55 -0
  194. package/dist/esm/decorators/http/DELETE.js +4 -0
  195. package/dist/esm/decorators/http/GET.js +4 -0
  196. package/dist/esm/decorators/http/HEAD.js +4 -0
  197. package/dist/esm/decorators/http/OPTIONS.js +4 -0
  198. package/dist/esm/decorators/http/PATCH.js +4 -0
  199. package/dist/esm/decorators/http/POST.js +4 -0
  200. package/dist/esm/decorators/http/PUT.js +4 -0
  201. package/dist/esm/exceptions/AccessDeniedException.js +13 -0
  202. package/dist/esm/exceptions/ControllerActionNotFoundException.js +12 -0
  203. package/dist/esm/exceptions/DuplicateActionNameException.js +11 -0
  204. package/dist/esm/exceptions/EntrypointStoppedException.js +12 -0
  205. package/dist/esm/exceptions/InvalidActionGroupException.js +7 -0
  206. package/dist/esm/exceptions/InvalidChannelException.js +11 -0
  207. package/dist/esm/exceptions/InvalidEntrypointAdapterException.js +12 -0
  208. package/dist/esm/exceptions/InvalidMiddlewareException.js +11 -0
  209. package/dist/esm/exceptions/InvalidPrefixException.js +11 -0
  210. package/dist/esm/exceptions/MiddlewareNextCalledException.js +11 -0
  211. package/dist/esm/exceptions/RouteNotFoundException.js +12 -0
  212. package/dist/esm/exceptions/ServiceInvokeException.js +10 -0
  213. package/dist/esm/exports/CTRLDecorators.js +19 -0
  214. package/dist/esm/exports/Channel.js +11 -0
  215. package/dist/esm/exports/CommanderAdapter.js +1 -0
  216. package/dist/esm/exports/ElectronAdapter.js +1 -0
  217. package/dist/esm/exports/Entrypoint.js +22 -0
  218. package/dist/esm/exports/ExpressAdapter.js +3 -0
  219. package/dist/esm/exports/FastifyAdapter.js +3 -0
  220. package/dist/esm/exports/JSONRPCAdapter.js +2 -0
  221. package/dist/esm/exports/SocketIOAdapter.js +1 -0
  222. package/dist/esm/lib/AccessControl.js +204 -0
  223. package/dist/esm/lib/AccessControlRule.js +72 -0
  224. package/dist/esm/lib/ActionOptions.js +63 -0
  225. package/dist/esm/lib/ActionResult.js +24 -0
  226. package/dist/esm/lib/ApplicationOf.js +11 -0
  227. package/dist/esm/lib/Controller.js +61 -0
  228. package/dist/esm/lib/ControllerEntrypoint.js +229 -0
  229. package/dist/esm/lib/GetActionDTOAndOptions.js +46 -0
  230. package/dist/esm/lib/HTTPErrors.js +48 -0
  231. package/dist/esm/lib/Middleware.js +134 -0
  232. package/dist/esm/lib/Prefix.js +143 -0
  233. package/dist/esm/lib/Result.js +147 -0
  234. package/dist/esm/lib/ServiceResponseCodec.js +113 -0
  235. package/dist/esm/lib/StringifyPattern.js +55 -0
  236. package/dist/esm/lib/UnsetValue.js +213 -0
  237. package/dist/esm/lib/pattern/GlobPattern.js +64 -0
  238. package/dist/esm/lib/pattern/PatternManager.js +229 -0
  239. package/dist/esm/lib/schedule/Cron.js +277 -0
  240. package/dist/esm/types/CLIContextParams.js +1 -0
  241. package/dist/esm/types/ErrorDescription.js +1 -0
  242. package/dist/esm/types/HTTPContextParams.js +1 -0
  243. package/dist/esm/types/ScheduleContextParams.js +1 -0
  244. package/dist/esm/types/ServiceContextParams.js +1 -0
  245. package/dist/types/Entrypoint.d.ts +868 -0
  246. package/dist/types/adapter/commander/CommanderCLIEntrypoint.d.ts +192 -0
  247. package/dist/types/adapter/commander/Prompt.d.ts +22 -0
  248. package/dist/types/adapter/commander/Width.d.ts +12 -0
  249. package/dist/types/adapter/electron/ElectronIPCServiceEntrypoint.d.ts +203 -0
  250. package/dist/types/adapter/express/ExpressHTTPEntrypoint.d.ts +172 -0
  251. package/dist/types/adapter/express/Responders.d.ts +89 -0
  252. package/dist/types/adapter/express/StaticUI.d.ts +83 -0
  253. package/dist/types/adapter/fastify/FastifyHTTPEntrypoint.d.ts +156 -0
  254. package/dist/types/adapter/fastify/Responders.d.ts +88 -0
  255. package/dist/types/adapter/http/HTTPServiceEntrypoint.d.ts +117 -0
  256. package/dist/types/adapter/jsonrpc/JSONRPCProtocol.d.ts +194 -0
  257. package/dist/types/adapter/jsonrpc/JSONRPCServiceEntrypoint.d.ts +154 -0
  258. package/dist/types/adapter/schedule/ScheduleEntrypoint.d.ts +86 -0
  259. package/dist/types/adapter/socket.io/SocketIOServiceEntrypoint.d.ts +138 -0
  260. package/dist/types/channel/BuiltinChannels.d.ts +18 -0
  261. package/dist/types/channel/Channel.d.ts +196 -0
  262. package/dist/types/channel/EntrypointAdapter.d.ts +195 -0
  263. package/dist/types/context/BaseContext.d.ts +75 -0
  264. package/dist/types/context/CLIContext.d.ts +38 -0
  265. package/dist/types/context/HTTPContext.d.ts +52 -0
  266. package/dist/types/context/ScheduleContext.d.ts +47 -0
  267. package/dist/types/context/ServiceContext.d.ts +47 -0
  268. package/dist/types/decorators/CLIAction.d.ts +120 -0
  269. package/dist/types/decorators/HTTPAction.d.ts +178 -0
  270. package/dist/types/decorators/Prefix.d.ts +44 -0
  271. package/dist/types/decorators/Schedule.d.ts +120 -0
  272. package/dist/types/decorators/ServiceAction.d.ts +116 -0
  273. package/dist/types/decorators/UseMiddlewares.d.ts +52 -0
  274. package/dist/types/decorators/http/DELETE.d.ts +87 -0
  275. package/dist/types/decorators/http/GET.d.ts +89 -0
  276. package/dist/types/decorators/http/HEAD.d.ts +84 -0
  277. package/dist/types/decorators/http/OPTIONS.d.ts +80 -0
  278. package/dist/types/decorators/http/PATCH.d.ts +90 -0
  279. package/dist/types/decorators/http/POST.d.ts +91 -0
  280. package/dist/types/decorators/http/PUT.d.ts +92 -0
  281. package/dist/types/exceptions/AccessDeniedException.d.ts +10 -0
  282. package/dist/types/exceptions/ControllerActionNotFoundException.d.ts +9 -0
  283. package/dist/types/exceptions/DuplicateActionNameException.d.ts +8 -0
  284. package/dist/types/exceptions/EntrypointStoppedException.d.ts +9 -0
  285. package/dist/types/exceptions/InvalidActionGroupException.d.ts +4 -0
  286. package/dist/types/exceptions/InvalidChannelException.d.ts +8 -0
  287. package/dist/types/exceptions/InvalidEntrypointAdapterException.d.ts +9 -0
  288. package/dist/types/exceptions/InvalidMiddlewareException.d.ts +8 -0
  289. package/dist/types/exceptions/InvalidPrefixException.d.ts +8 -0
  290. package/dist/types/exceptions/MiddlewareNextCalledException.d.ts +8 -0
  291. package/dist/types/exceptions/RouteNotFoundException.d.ts +9 -0
  292. package/dist/types/exceptions/ServiceInvokeException.d.ts +11 -0
  293. package/dist/types/exports/CTRLDecorators.d.ts +13 -0
  294. package/dist/types/exports/Channel.d.ts +14 -0
  295. package/dist/types/exports/CommanderAdapter.d.ts +1 -0
  296. package/dist/types/exports/ElectronAdapter.d.ts +1 -0
  297. package/dist/types/exports/Entrypoint.d.ts +24 -0
  298. package/dist/types/exports/ExpressAdapter.d.ts +4 -0
  299. package/dist/types/exports/FastifyAdapter.d.ts +4 -0
  300. package/dist/types/exports/JSONRPCAdapter.d.ts +2 -0
  301. package/dist/types/exports/SocketIOAdapter.d.ts +1 -0
  302. package/dist/types/lib/AccessControl.d.ts +118 -0
  303. package/dist/types/lib/AccessControlRule.d.ts +91 -0
  304. package/dist/types/lib/ActionOptions.d.ts +67 -0
  305. package/dist/types/lib/ActionResult.d.ts +28 -0
  306. package/dist/types/lib/ApplicationOf.d.ts +6 -0
  307. package/dist/types/lib/Controller.d.ts +59 -0
  308. package/dist/types/lib/ControllerEntrypoint.d.ts +168 -0
  309. package/dist/types/lib/GetActionDTOAndOptions.d.ts +29 -0
  310. package/dist/types/lib/HTTPErrors.d.ts +55 -0
  311. package/dist/types/lib/Middleware.d.ts +146 -0
  312. package/dist/types/lib/Prefix.d.ts +98 -0
  313. package/dist/types/lib/Result.d.ts +173 -0
  314. package/dist/types/lib/ServiceResponseCodec.d.ts +82 -0
  315. package/dist/types/lib/StringifyPattern.d.ts +7 -0
  316. package/dist/types/lib/UnsetValue.d.ts +12 -0
  317. package/dist/types/lib/pattern/GlobPattern.d.ts +34 -0
  318. package/dist/types/lib/pattern/PatternManager.d.ts +103 -0
  319. package/dist/types/lib/schedule/Cron.d.ts +56 -0
  320. package/dist/types/types/CLIContextParams.d.ts +14 -0
  321. package/dist/types/types/ErrorDescription.d.ts +14 -0
  322. package/dist/types/types/HTTPContextParams.d.ts +27 -0
  323. package/dist/types/types/ScheduleContextParams.d.ts +21 -0
  324. package/dist/types/types/ServiceContextParams.d.ts +16 -0
  325. package/package.json +152 -0
@@ -0,0 +1,87 @@
1
+ import { Controller, type ControllerProperty } from '../../lib/Controller.js';
2
+ import { DTO, MethodDecorator } from '@lakutata/core';
3
+ import { ActionOptions } from '../../lib/ActionOptions.js';
4
+ import { HTTPContext } from '../../context/HTTPContext.js';
5
+ /**
6
+ * Expose the controller method as an HTTP DELETE action on a route, to delete a resource: the shorthand of
7
+ * `@HTTPAction(route, 'delete', …)`. The adapter assembles the input: by default, the query string merged with the
8
+ * parsed body (JSON or URL encoded), then the route parameters over them. The middlewares run, the input is validated
9
+ * against the DTO (the defaults applied, the unknown keys removed; without a DTO, it is accepted as it is), the access
10
+ * control runs when `acl` is set, then the method receives the validated input as a plain object. The query values and
11
+ * the route parameters are strings and the DTO schemas are strict: convert them with `.strict(false)`. The value
12
+ * returned is answered by the adapter's responder: as JSON by default, with the status 204 for `undefined`;
13
+ * `Result.status()` sets a status and headers. An error thrown is answered as `{errno, errMsg}` with the first 4xx
14
+ * `statusCode` along its causes (400 for an invalid input), else its own `statusCode`, else 500.
15
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
16
+ * prepended to it.
17
+ * @returns The method decorator.
18
+ * @example
19
+ * ```typescript
20
+ * import {DTO} from 'lakutata'
21
+ * import {Controller} from 'lakutata/com/entrypoint'
22
+ * import {DELETE} from 'lakutata/decorator/ctrl'
23
+ * import {Expect} from 'lakutata/decorator/dto'
24
+ *
25
+ * class SessionIdDTO extends DTO {
26
+ * @Expect(DTO.String().uuid().required())
27
+ * public id!: string
28
+ * }
29
+ *
30
+ * class SessionController extends Controller {
31
+ * //DELETE /sessions/<uuid>: answered with the status 204 (no content), an invalid id with the status 400
32
+ * @DELETE('/sessions/:id', SessionIdDTO, {acl: true})
33
+ * public async revoke(input: SessionIdDTO): Promise<void> {
34
+ * console.log(`revoke ${input.id}`)
35
+ * }
36
+ * }
37
+ * ```
38
+ */
39
+ export declare function DELETE<ClassPrototype extends Controller, Method>(r: string): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
40
+ /**
41
+ * Expose the controller method as an HTTP DELETE action on a route, its input validated against a DTO: the shorthand of
42
+ * `@HTTPAction(route, 'delete', …)`. The input is the query string merged with the parsed body, then the route
43
+ * parameters over them (the default of the adapters); the method receives it validated, as a plain object. The value
44
+ * returned is answered as JSON (204 for `undefined`), an error as `{errno, errMsg}` with its status (400 for an invalid
45
+ * input, else 500 by default).
46
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
47
+ * prepended to it.
48
+ * @param dtoConstructor The DTO class validating the input; the query values and the route parameters are strings,
49
+ * convert them with `.strict(false)`.
50
+ * @returns The method decorator.
51
+ */
52
+ export declare function DELETE<ClassPrototype extends Controller, Method, DTOConstructor extends typeof DTO = typeof DTO>(r: string, dtoConstructor: DTOConstructor): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
53
+ /**
54
+ * Expose the controller method as an HTTP DELETE action on a route, with action options: the shorthand of
55
+ * `@HTTPAction(route, 'delete', …)`. The input is the query string merged with the parsed body, then the route
56
+ * parameters over them (the default of the adapters), accepted as it is. The value returned is answered as JSON (204
57
+ * for `undefined`), an error as `{errno, errMsg}` with its status (500 by default).
58
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
59
+ * prepended to it.
60
+ * @param actionOptions The action options: `acl` runs the access control rules (false by default); `name` (unique in the
61
+ * HTTP actions, `ClassName:method` by default), `description` and `groups` describe the action; `rule` is an access
62
+ * rule of the action; `middlewares` run before the ones `@UseMiddlewares` adds to the method.
63
+ * @returns The method decorator.
64
+ * @throws {InvalidValueException} When the class is declared, if the action options are invalid.
65
+ * @throws {InvalidMiddlewareException} When the class is declared, if a middleware of the options is neither a function
66
+ * nor a class extending `Middleware`.
67
+ */
68
+ export declare function DELETE<ClassPrototype extends Controller, Method>(r: string, actionOptions: ActionOptions<HTTPContext>): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
69
+ /**
70
+ * Expose the controller method as an HTTP DELETE action on a route, its input validated against a DTO, with action
71
+ * options: the shorthand of `@HTTPAction(route, 'delete', …)`. The input is the query string merged with the parsed
72
+ * body, then the route parameters over them (the default of the adapters); the method receives it validated, as a plain
73
+ * object. The value returned is answered as JSON (204 for `undefined`), an error as `{errno, errMsg}` with its status
74
+ * (400 for an invalid input, else 500 by default).
75
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
76
+ * prepended to it.
77
+ * @param dtoConstructor The DTO class validating the input; the query values and the route parameters are strings,
78
+ * convert them with `.strict(false)`.
79
+ * @param actionOptions The action options: `acl` runs the access control rules (false by default); `name` (unique in the
80
+ * HTTP actions, `ClassName:method` by default), `description` and `groups` describe the action; `rule` is an access
81
+ * rule of the action; `middlewares` run before the ones `@UseMiddlewares` adds to the method.
82
+ * @returns The method decorator.
83
+ * @throws {InvalidValueException} When the class is declared, if the action options are invalid.
84
+ * @throws {InvalidMiddlewareException} When the class is declared, if a middleware of the options is neither a function
85
+ * nor a class extending `Middleware`.
86
+ */
87
+ export declare function DELETE<ClassPrototype extends Controller, Method, DTOConstructor extends typeof DTO = typeof DTO>(r: string, dtoConstructor: DTOConstructor, actionOptions: ActionOptions<HTTPContext>): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
@@ -0,0 +1,89 @@
1
+ import { Controller, type ControllerProperty } from '../../lib/Controller.js';
2
+ import { DTO, MethodDecorator } from '@lakutata/core';
3
+ import { ActionOptions } from '../../lib/ActionOptions.js';
4
+ import { HTTPContext } from '../../context/HTTPContext.js';
5
+ /**
6
+ * Expose the controller method as an HTTP GET action on a route, to read a resource: the shorthand of
7
+ * `@HTTPAction(route, 'get', …)`. The adapter assembles the input: by default, the query string merged with the parsed
8
+ * body (JSON or URL encoded), then the route parameters over them. The middlewares run, the input is validated against
9
+ * the DTO (the defaults applied, the unknown keys removed; without a DTO, it is accepted as it is), the access control
10
+ * runs when `acl` is set, then the method receives the validated input as a plain object. The query values and the
11
+ * route parameters are strings and the DTO schemas are strict: convert them with `.strict(false)`. The value returned
12
+ * is answered by the adapter's responder: as JSON by default, with the status 204 for `undefined`; `Result.status()`
13
+ * sets a status and headers. An error thrown is answered as `{errno, errMsg}` with the first 4xx `statusCode` along its
14
+ * causes (400 for an invalid input), else its own `statusCode`, else 500.
15
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
16
+ * prepended to it.
17
+ * @returns The method decorator.
18
+ * @example
19
+ * ```typescript
20
+ * import {DTO} from 'lakutata'
21
+ * import {Controller} from 'lakutata/com/entrypoint'
22
+ * import {GET} from 'lakutata/decorator/ctrl'
23
+ * import {Expect} from 'lakutata/decorator/dto'
24
+ *
25
+ * class UserIdDTO extends DTO {
26
+ * //A route parameter is a string: converted to a number
27
+ * @Expect(DTO.Number().integer().min(1).strict(false).required())
28
+ * public id!: number
29
+ * }
30
+ *
31
+ * class UserController extends Controller {
32
+ * //GET /users/42: answered with the JSON {"id": 42, "name": "user42"}; GET /users/abc: the status 400 and
33
+ * //{"errno": "E_INVALID_VALUE", "errMsg": …}
34
+ * @GET('/users/:id', UserIdDTO)
35
+ * public async get(input: UserIdDTO): Promise<{ id: number, name: string }> {
36
+ * return {id: input.id, name: `user${input.id}`}
37
+ * }
38
+ * }
39
+ * ```
40
+ */
41
+ export declare function GET<ClassPrototype extends Controller, Method>(r: string): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
42
+ /**
43
+ * Expose the controller method as an HTTP GET action on a route, its input validated against a DTO: the shorthand of
44
+ * `@HTTPAction(route, 'get', …)`. The input is the query string merged with the parsed body, then the route parameters
45
+ * over them (the default of the adapters); the method receives it validated, as a plain object. The value returned is
46
+ * answered as JSON (204 for `undefined`), an error as `{errno, errMsg}` with its status (400 for an invalid input, else
47
+ * 500 by default).
48
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
49
+ * prepended to it.
50
+ * @param dtoConstructor The DTO class validating the input; the query values and the route parameters are strings,
51
+ * convert them with `.strict(false)`.
52
+ * @returns The method decorator.
53
+ */
54
+ export declare function GET<ClassPrototype extends Controller, Method, DTOConstructor extends typeof DTO = typeof DTO>(r: string, dtoConstructor: DTOConstructor): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
55
+ /**
56
+ * Expose the controller method as an HTTP GET action on a route, with action options: the shorthand of
57
+ * `@HTTPAction(route, 'get', …)`. The input is the query string merged with the parsed body, then the route parameters
58
+ * over them (the default of the adapters), accepted as it is. The value returned is answered as JSON (204 for
59
+ * `undefined`), an error as `{errno, errMsg}` with its status (500 by default).
60
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
61
+ * prepended to it.
62
+ * @param actionOptions The action options: `acl` runs the access control rules (false by default); `name` (unique in the
63
+ * HTTP actions, `ClassName:method` by default), `description` and `groups` describe the action; `rule` is an access
64
+ * rule of the action; `middlewares` run before the ones `@UseMiddlewares` adds to the method.
65
+ * @returns The method decorator.
66
+ * @throws {InvalidValueException} When the class is declared, if the action options are invalid.
67
+ * @throws {InvalidMiddlewareException} When the class is declared, if a middleware of the options is neither a function
68
+ * nor a class extending `Middleware`.
69
+ */
70
+ export declare function GET<ClassPrototype extends Controller, Method>(r: string, actionOptions: ActionOptions<HTTPContext>): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
71
+ /**
72
+ * Expose the controller method as an HTTP GET action on a route, its input validated against a DTO, with action
73
+ * options: the shorthand of `@HTTPAction(route, 'get', …)`. The input is the query string merged with the parsed body,
74
+ * then the route parameters over them (the default of the adapters); the method receives it validated, as a plain
75
+ * object. The value returned is answered as JSON (204 for `undefined`), an error as `{errno, errMsg}` with its status
76
+ * (400 for an invalid input, else 500 by default).
77
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
78
+ * prepended to it.
79
+ * @param dtoConstructor The DTO class validating the input; the query values and the route parameters are strings,
80
+ * convert them with `.strict(false)`.
81
+ * @param actionOptions The action options: `acl` runs the access control rules (false by default); `name` (unique in the
82
+ * HTTP actions, `ClassName:method` by default), `description` and `groups` describe the action; `rule` is an access
83
+ * rule of the action; `middlewares` run before the ones `@UseMiddlewares` adds to the method.
84
+ * @returns The method decorator.
85
+ * @throws {InvalidValueException} When the class is declared, if the action options are invalid.
86
+ * @throws {InvalidMiddlewareException} When the class is declared, if a middleware of the options is neither a function
87
+ * nor a class extending `Middleware`.
88
+ */
89
+ export declare function GET<ClassPrototype extends Controller, Method, DTOConstructor extends typeof DTO = typeof DTO>(r: string, dtoConstructor: DTOConstructor, actionOptions: ActionOptions<HTTPContext>): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
@@ -0,0 +1,84 @@
1
+ import { Controller, type ControllerProperty } from '../../lib/Controller.js';
2
+ import { DTO, MethodDecorator } from '@lakutata/core';
3
+ import { ActionOptions } from '../../lib/ActionOptions.js';
4
+ import { HTTPContext } from '../../context/HTTPContext.js';
5
+ /**
6
+ * Expose the controller method as an HTTP HEAD action on a route, to answer the headers of a resource without its body:
7
+ * the shorthand of `@HTTPAction(route, 'head', …)`. The adapter assembles the input: by default, the query string
8
+ * merged with the parsed body (JSON or URL encoded), then the route parameters over them. The middlewares run, the
9
+ * input is validated against the DTO (the defaults applied, the unknown keys removed; without a DTO, it is accepted as
10
+ * it is), the access control runs when `acl` is set, then the method receives the validated input as a plain object.
11
+ * The query values and the route parameters are strings and the DTO schemas are strict: convert them with
12
+ * `.strict(false)`. The value returned is answered by the adapter's responder: as JSON by default, with the status 204
13
+ * for `undefined`; `Result.status()` sets a status and headers. An error thrown is answered as `{errno, errMsg}` with
14
+ * the first 4xx `statusCode` along its causes (400 for an invalid input), else its own `statusCode`, else 500.
15
+ * With Fastify, a GET action also answers the HEAD requests of its route unless the route has a HEAD action.
16
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
17
+ * prepended to it.
18
+ * @returns The method decorator.
19
+ * @example
20
+ * ```typescript
21
+ * import {Controller, Result, type StatusResult} from 'lakutata/com/entrypoint'
22
+ * import {HEAD} from 'lakutata/decorator/ctrl'
23
+ *
24
+ * class HealthController extends Controller {
25
+ * //HEAD /health: answered with the status 200 and the header X-Health, without a body
26
+ * @HEAD('/health')
27
+ * public async health(): Promise<StatusResult> {
28
+ * return Result.status(200, undefined, {'X-Health': 'ok'})
29
+ * }
30
+ * }
31
+ * ```
32
+ */
33
+ export declare function HEAD<ClassPrototype extends Controller, Method>(r: string): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
34
+ /**
35
+ * Expose the controller method as an HTTP HEAD action on a route, its input validated against a DTO: the shorthand of
36
+ * `@HTTPAction(route, 'head', …)`. The input is the query string merged with the parsed body, then the route parameters
37
+ * over them (the default of the adapters); the method receives it validated, as a plain object. The value returned is
38
+ * answered as JSON (204 for `undefined`), an error as `{errno, errMsg}` with its status (400 for an invalid input, else
39
+ * 500 by default).
40
+ * With Fastify, a GET action also answers the HEAD requests of its route unless the route has a HEAD action.
41
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
42
+ * prepended to it.
43
+ * @param dtoConstructor The DTO class validating the input; the query values and the route parameters are strings,
44
+ * convert them with `.strict(false)`.
45
+ * @returns The method decorator.
46
+ */
47
+ export declare function HEAD<ClassPrototype extends Controller, Method, DTOConstructor extends typeof DTO = typeof DTO>(r: string, dtoConstructor: DTOConstructor): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
48
+ /**
49
+ * Expose the controller method as an HTTP HEAD action on a route, with action options: the shorthand of
50
+ * `@HTTPAction(route, 'head', …)`. The input is the query string merged with the parsed body, then the route parameters
51
+ * over them (the default of the adapters), accepted as it is. The value returned is answered as JSON (204 for
52
+ * `undefined`), an error as `{errno, errMsg}` with its status (500 by default).
53
+ * With Fastify, a GET action also answers the HEAD requests of its route unless the route has a HEAD action.
54
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
55
+ * prepended to it.
56
+ * @param actionOptions The action options: `acl` runs the access control rules (false by default); `name` (unique in the
57
+ * HTTP actions, `ClassName:method` by default), `description` and `groups` describe the action; `rule` is an access
58
+ * rule of the action; `middlewares` run before the ones `@UseMiddlewares` adds to the method.
59
+ * @returns The method decorator.
60
+ * @throws {InvalidValueException} When the class is declared, if the action options are invalid.
61
+ * @throws {InvalidMiddlewareException} When the class is declared, if a middleware of the options is neither a function
62
+ * nor a class extending `Middleware`.
63
+ */
64
+ export declare function HEAD<ClassPrototype extends Controller, Method>(r: string, actionOptions: ActionOptions<HTTPContext>): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
65
+ /**
66
+ * Expose the controller method as an HTTP HEAD action on a route, its input validated against a DTO, with action
67
+ * options: the shorthand of `@HTTPAction(route, 'head', …)`. The input is the query string merged with the parsed body,
68
+ * then the route parameters over them (the default of the adapters); the method receives it validated, as a plain
69
+ * object. The value returned is answered as JSON (204 for `undefined`), an error as `{errno, errMsg}` with its status
70
+ * (400 for an invalid input, else 500 by default).
71
+ * With Fastify, a GET action also answers the HEAD requests of its route unless the route has a HEAD action.
72
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
73
+ * prepended to it.
74
+ * @param dtoConstructor The DTO class validating the input; the query values and the route parameters are strings,
75
+ * convert them with `.strict(false)`.
76
+ * @param actionOptions The action options: `acl` runs the access control rules (false by default); `name` (unique in the
77
+ * HTTP actions, `ClassName:method` by default), `description` and `groups` describe the action; `rule` is an access
78
+ * rule of the action; `middlewares` run before the ones `@UseMiddlewares` adds to the method.
79
+ * @returns The method decorator.
80
+ * @throws {InvalidValueException} When the class is declared, if the action options are invalid.
81
+ * @throws {InvalidMiddlewareException} When the class is declared, if a middleware of the options is neither a function
82
+ * nor a class extending `Middleware`.
83
+ */
84
+ export declare function HEAD<ClassPrototype extends Controller, Method, DTOConstructor extends typeof DTO = typeof DTO>(r: string, dtoConstructor: DTOConstructor, actionOptions: ActionOptions<HTTPContext>): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
@@ -0,0 +1,80 @@
1
+ import { Controller, type ControllerProperty } from '../../lib/Controller.js';
2
+ import { DTO, MethodDecorator } from '@lakutata/core';
3
+ import { ActionOptions } from '../../lib/ActionOptions.js';
4
+ import { HTTPContext } from '../../context/HTTPContext.js';
5
+ /**
6
+ * Expose the controller method as an HTTP OPTIONS action on a route, to describe the communication options of a
7
+ * resource: the shorthand of `@HTTPAction(route, 'options', …)`. The adapter assembles the input: by default, the query
8
+ * string merged with the parsed body (JSON or URL encoded), then the route parameters over them. The middlewares run,
9
+ * the input is validated against the DTO (the defaults applied, the unknown keys removed; without a DTO, it is accepted
10
+ * as it is), the access control runs when `acl` is set, then the method receives the validated input as a plain object.
11
+ * The query values and the route parameters are strings and the DTO schemas are strict: convert them with
12
+ * `.strict(false)`. The value returned is answered by the adapter's responder: as JSON by default, with the status 204
13
+ * for `undefined`; `Result.status()` sets a status and headers. An error thrown is answered as `{errno, errMsg}` with
14
+ * the first 4xx `statusCode` along its causes (400 for an invalid input), else its own `statusCode`, else 500.
15
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
16
+ * prepended to it.
17
+ * @returns The method decorator.
18
+ * @example
19
+ * ```typescript
20
+ * import {Controller, Result, type StatusResult} from 'lakutata/com/entrypoint'
21
+ * import {OPTIONS} from 'lakutata/decorator/ctrl'
22
+ *
23
+ * class UploadController extends Controller {
24
+ * //OPTIONS /uploads: answered with the status 204 and the header Allow
25
+ * @OPTIONS('/uploads')
26
+ * public async options(): Promise<StatusResult> {
27
+ * return Result.status(204, undefined, {Allow: 'OPTIONS, POST'})
28
+ * }
29
+ * }
30
+ * ```
31
+ */
32
+ export declare function OPTIONS<ClassPrototype extends Controller, Method>(r: string): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
33
+ /**
34
+ * Expose the controller method as an HTTP OPTIONS action on a route, its input validated against a DTO: the shorthand
35
+ * of `@HTTPAction(route, 'options', …)`. The input is the query string merged with the parsed body, then the route
36
+ * parameters over them (the default of the adapters); the method receives it validated, as a plain object. The value
37
+ * returned is answered as JSON (204 for `undefined`), an error as `{errno, errMsg}` with its status (400 for an invalid
38
+ * input, else 500 by default).
39
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
40
+ * prepended to it.
41
+ * @param dtoConstructor The DTO class validating the input; the query values and the route parameters are strings,
42
+ * convert them with `.strict(false)`.
43
+ * @returns The method decorator.
44
+ */
45
+ export declare function OPTIONS<ClassPrototype extends Controller, Method, DTOConstructor extends typeof DTO = typeof DTO>(r: string, dtoConstructor: DTOConstructor): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
46
+ /**
47
+ * Expose the controller method as an HTTP OPTIONS action on a route, with action options: the shorthand of
48
+ * `@HTTPAction(route, 'options', …)`. The input is the query string merged with the parsed body, then the route
49
+ * parameters over them (the default of the adapters), accepted as it is. The value returned is answered as JSON (204
50
+ * for `undefined`), an error as `{errno, errMsg}` with its status (500 by default).
51
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
52
+ * prepended to it.
53
+ * @param actionOptions The action options: `acl` runs the access control rules (false by default); `name` (unique in the
54
+ * HTTP actions, `ClassName:method` by default), `description` and `groups` describe the action; `rule` is an access
55
+ * rule of the action; `middlewares` run before the ones `@UseMiddlewares` adds to the method.
56
+ * @returns The method decorator.
57
+ * @throws {InvalidValueException} When the class is declared, if the action options are invalid.
58
+ * @throws {InvalidMiddlewareException} When the class is declared, if a middleware of the options is neither a function
59
+ * nor a class extending `Middleware`.
60
+ */
61
+ export declare function OPTIONS<ClassPrototype extends Controller, Method>(r: string, actionOptions: ActionOptions<HTTPContext>): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
62
+ /**
63
+ * Expose the controller method as an HTTP OPTIONS action on a route, its input validated against a DTO, with action
64
+ * options: the shorthand of `@HTTPAction(route, 'options', …)`. The input is the query string merged with the parsed
65
+ * body, then the route parameters over them (the default of the adapters); the method receives it validated, as a plain
66
+ * object. The value returned is answered as JSON (204 for `undefined`), an error as `{errno, errMsg}` with its status
67
+ * (400 for an invalid input, else 500 by default).
68
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
69
+ * prepended to it.
70
+ * @param dtoConstructor The DTO class validating the input; the query values and the route parameters are strings,
71
+ * convert them with `.strict(false)`.
72
+ * @param actionOptions The action options: `acl` runs the access control rules (false by default); `name` (unique in the
73
+ * HTTP actions, `ClassName:method` by default), `description` and `groups` describe the action; `rule` is an access
74
+ * rule of the action; `middlewares` run before the ones `@UseMiddlewares` adds to the method.
75
+ * @returns The method decorator.
76
+ * @throws {InvalidValueException} When the class is declared, if the action options are invalid.
77
+ * @throws {InvalidMiddlewareException} When the class is declared, if a middleware of the options is neither a function
78
+ * nor a class extending `Middleware`.
79
+ */
80
+ export declare function OPTIONS<ClassPrototype extends Controller, Method, DTOConstructor extends typeof DTO = typeof DTO>(r: string, dtoConstructor: DTOConstructor, actionOptions: ActionOptions<HTTPContext>): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
@@ -0,0 +1,90 @@
1
+ import { Controller, type ControllerProperty } from '../../lib/Controller.js';
2
+ import { DTO, MethodDecorator } from '@lakutata/core';
3
+ import { ActionOptions } from '../../lib/ActionOptions.js';
4
+ import { HTTPContext } from '../../context/HTTPContext.js';
5
+ /**
6
+ * Expose the controller method as an HTTP PATCH action on a route, to update a part of a resource: the shorthand of
7
+ * `@HTTPAction(route, 'patch', …)`. The adapter assembles the input: by default, the query string merged with the
8
+ * parsed body (JSON or URL encoded), then the route parameters over them. The middlewares run, the input is validated
9
+ * against the DTO (the defaults applied, the unknown keys removed; without a DTO, it is accepted as it is), the access
10
+ * control runs when `acl` is set, then the method receives the validated input as a plain object. The query values and
11
+ * the route parameters are strings and the DTO schemas are strict: convert them with `.strict(false)`. The value
12
+ * returned is answered by the adapter's responder: as JSON by default, with the status 204 for `undefined`;
13
+ * `Result.status()` sets a status and headers. An error thrown is answered as `{errno, errMsg}` with the first 4xx
14
+ * `statusCode` along its causes (400 for an invalid input), else its own `statusCode`, else 500.
15
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
16
+ * prepended to it.
17
+ * @returns The method decorator.
18
+ * @example
19
+ * ```typescript
20
+ * import {DTO} from 'lakutata'
21
+ * import {Controller} from 'lakutata/com/entrypoint'
22
+ * import {PATCH} from 'lakutata/decorator/ctrl'
23
+ * import {Expect} from 'lakutata/decorator/dto'
24
+ *
25
+ * class RenameDTO extends DTO {
26
+ * @Expect(DTO.String().required())
27
+ * public id!: string
28
+ *
29
+ * @Expect(DTO.String().min(1).optional())
30
+ * public name?: string
31
+ * }
32
+ *
33
+ * class ProjectController extends Controller {
34
+ * //PATCH /projects/p1 with the body {"name": "Apollo"}: answered with the status 204 (no content)
35
+ * @PATCH('/projects/:id', RenameDTO)
36
+ * public async rename(input: RenameDTO): Promise<void> {
37
+ * console.log(`rename ${input.id} to ${input.name}`)
38
+ * }
39
+ * }
40
+ * ```
41
+ */
42
+ export declare function PATCH<ClassPrototype extends Controller, Method>(r: string): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
43
+ /**
44
+ * Expose the controller method as an HTTP PATCH action on a route, its input validated against a DTO: the shorthand of
45
+ * `@HTTPAction(route, 'patch', …)`. The input is the query string merged with the parsed body, then the route
46
+ * parameters over them (the default of the adapters); the method receives it validated, as a plain object. The value
47
+ * returned is answered as JSON (204 for `undefined`), an error as `{errno, errMsg}` with its status (400 for an invalid
48
+ * input, else 500 by default).
49
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
50
+ * prepended to it.
51
+ * @param dtoConstructor The DTO class validating the input; the query values and the route parameters are strings,
52
+ * convert them with `.strict(false)`.
53
+ * @returns The method decorator.
54
+ */
55
+ export declare function PATCH<ClassPrototype extends Controller, Method, DTOConstructor extends typeof DTO = typeof DTO>(r: string, dtoConstructor: DTOConstructor): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
56
+ /**
57
+ * Expose the controller method as an HTTP PATCH action on a route, with action options: the shorthand of
58
+ * `@HTTPAction(route, 'patch', …)`. The input is the query string merged with the parsed body, then the route
59
+ * parameters over them (the default of the adapters), accepted as it is. The value returned is answered as JSON (204
60
+ * for `undefined`), an error as `{errno, errMsg}` with its status (500 by default).
61
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
62
+ * prepended to it.
63
+ * @param actionOptions The action options: `acl` runs the access control rules (false by default); `name` (unique in the
64
+ * HTTP actions, `ClassName:method` by default), `description` and `groups` describe the action; `rule` is an access
65
+ * rule of the action; `middlewares` run before the ones `@UseMiddlewares` adds to the method.
66
+ * @returns The method decorator.
67
+ * @throws {InvalidValueException} When the class is declared, if the action options are invalid.
68
+ * @throws {InvalidMiddlewareException} When the class is declared, if a middleware of the options is neither a function
69
+ * nor a class extending `Middleware`.
70
+ */
71
+ export declare function PATCH<ClassPrototype extends Controller, Method>(r: string, actionOptions: ActionOptions<HTTPContext>): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
72
+ /**
73
+ * Expose the controller method as an HTTP PATCH action on a route, its input validated against a DTO, with action
74
+ * options: the shorthand of `@HTTPAction(route, 'patch', …)`. The input is the query string merged with the parsed
75
+ * body, then the route parameters over them (the default of the adapters); the method receives it validated, as a plain
76
+ * object. The value returned is answered as JSON (204 for `undefined`), an error as `{errno, errMsg}` with its status
77
+ * (400 for an invalid input, else 500 by default).
78
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
79
+ * prepended to it.
80
+ * @param dtoConstructor The DTO class validating the input; the query values and the route parameters are strings,
81
+ * convert them with `.strict(false)`.
82
+ * @param actionOptions The action options: `acl` runs the access control rules (false by default); `name` (unique in the
83
+ * HTTP actions, `ClassName:method` by default), `description` and `groups` describe the action; `rule` is an access
84
+ * rule of the action; `middlewares` run before the ones `@UseMiddlewares` adds to the method.
85
+ * @returns The method decorator.
86
+ * @throws {InvalidValueException} When the class is declared, if the action options are invalid.
87
+ * @throws {InvalidMiddlewareException} When the class is declared, if a middleware of the options is neither a function
88
+ * nor a class extending `Middleware`.
89
+ */
90
+ export declare function PATCH<ClassPrototype extends Controller, Method, DTOConstructor extends typeof DTO = typeof DTO>(r: string, dtoConstructor: DTOConstructor, actionOptions: ActionOptions<HTTPContext>): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
@@ -0,0 +1,91 @@
1
+ import { Controller, type ControllerProperty } from '../../lib/Controller.js';
2
+ import { DTO, MethodDecorator } from '@lakutata/core';
3
+ import { ActionOptions } from '../../lib/ActionOptions.js';
4
+ import { HTTPContext } from '../../context/HTTPContext.js';
5
+ /**
6
+ * Expose the controller method as an HTTP POST action on a route, to create a resource or run a command: the shorthand
7
+ * of `@HTTPAction(route, 'post', …)`. The adapter assembles the input: by default, the query string merged with the
8
+ * parsed body (JSON or URL encoded), then the route parameters over them. The middlewares run, the input is validated
9
+ * against the DTO (the defaults applied, the unknown keys removed; without a DTO, it is accepted as it is), the access
10
+ * control runs when `acl` is set, then the method receives the validated input as a plain object. The query values and
11
+ * the route parameters are strings and the DTO schemas are strict: convert them with `.strict(false)`. The value
12
+ * returned is answered by the adapter's responder: as JSON by default, with the status 204 for `undefined`;
13
+ * `Result.status()` sets a status and headers. An error thrown is answered as `{errno, errMsg}` with the first 4xx
14
+ * `statusCode` along its causes (400 for an invalid input), else its own `statusCode`, else 500.
15
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
16
+ * prepended to it.
17
+ * @returns The method decorator.
18
+ * @example
19
+ * ```typescript
20
+ * import {DTO} from 'lakutata'
21
+ * import {Controller, Result, type StatusResult} from 'lakutata/com/entrypoint'
22
+ * import {POST} from 'lakutata/decorator/ctrl'
23
+ * import {Expect} from 'lakutata/decorator/dto'
24
+ *
25
+ * class CreateUserDTO extends DTO {
26
+ * @Expect(DTO.String().email().required())
27
+ * public email!: string
28
+ *
29
+ * @Expect(DTO.String().min(1).required())
30
+ * public name!: string
31
+ * }
32
+ *
33
+ * class UserController extends Controller {
34
+ * //POST /users with the body {"email": "ada@example.com", "name": "Ada"}: answered with the status 201 and the JSON
35
+ * //{"id": 1, "email": "ada@example.com", "name": "Ada"}; an invalid body with the status 400
36
+ * @POST('/users', CreateUserDTO, {acl: true, name: 'Create a user'})
37
+ * public async create(input: CreateUserDTO): Promise<StatusResult> {
38
+ * return Result.status(201, {id: 1, email: input.email, name: input.name})
39
+ * }
40
+ * }
41
+ * ```
42
+ */
43
+ export declare function POST<ClassPrototype extends Controller, Method>(r: string): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
44
+ /**
45
+ * Expose the controller method as an HTTP POST action on a route, its input validated against a DTO: the shorthand of
46
+ * `@HTTPAction(route, 'post', …)`. The input is the query string merged with the parsed body, then the route parameters
47
+ * over them (the default of the adapters); the method receives it validated, as a plain object. The value returned is
48
+ * answered as JSON (204 for `undefined`), an error as `{errno, errMsg}` with its status (400 for an invalid input, else
49
+ * 500 by default).
50
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
51
+ * prepended to it.
52
+ * @param dtoConstructor The DTO class validating the input; the query values and the route parameters are strings,
53
+ * convert them with `.strict(false)`.
54
+ * @returns The method decorator.
55
+ */
56
+ export declare function POST<ClassPrototype extends Controller, Method, DTOConstructor extends typeof DTO = typeof DTO>(r: string, dtoConstructor: DTOConstructor): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
57
+ /**
58
+ * Expose the controller method as an HTTP POST action on a route, with action options: the shorthand of
59
+ * `@HTTPAction(route, 'post', …)`. The input is the query string merged with the parsed body, then the route parameters
60
+ * over them (the default of the adapters), accepted as it is. The value returned is answered as JSON (204 for
61
+ * `undefined`), an error as `{errno, errMsg}` with its status (500 by default).
62
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
63
+ * prepended to it.
64
+ * @param actionOptions The action options: `acl` runs the access control rules (false by default); `name` (unique in the
65
+ * HTTP actions, `ClassName:method` by default), `description` and `groups` describe the action; `rule` is an access
66
+ * rule of the action; `middlewares` run before the ones `@UseMiddlewares` adds to the method.
67
+ * @returns The method decorator.
68
+ * @throws {InvalidValueException} When the class is declared, if the action options are invalid.
69
+ * @throws {InvalidMiddlewareException} When the class is declared, if a middleware of the options is neither a function
70
+ * nor a class extending `Middleware`.
71
+ */
72
+ export declare function POST<ClassPrototype extends Controller, Method>(r: string, actionOptions: ActionOptions<HTTPContext>): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
73
+ /**
74
+ * Expose the controller method as an HTTP POST action on a route, its input validated against a DTO, with action
75
+ * options: the shorthand of `@HTTPAction(route, 'post', …)`. The input is the query string merged with the parsed body,
76
+ * then the route parameters over them (the default of the adapters); the method receives it validated, as a plain
77
+ * object. The value returned is answered as JSON (204 for `undefined`), an error as `{errno, errMsg}` with its status
78
+ * (400 for an invalid input, else 500 by default).
79
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
80
+ * prepended to it.
81
+ * @param dtoConstructor The DTO class validating the input; the query values and the route parameters are strings,
82
+ * convert them with `.strict(false)`.
83
+ * @param actionOptions The action options: `acl` runs the access control rules (false by default); `name` (unique in the
84
+ * HTTP actions, `ClassName:method` by default), `description` and `groups` describe the action; `rule` is an access
85
+ * rule of the action; `middlewares` run before the ones `@UseMiddlewares` adds to the method.
86
+ * @returns The method decorator.
87
+ * @throws {InvalidValueException} When the class is declared, if the action options are invalid.
88
+ * @throws {InvalidMiddlewareException} When the class is declared, if a middleware of the options is neither a function
89
+ * nor a class extending `Middleware`.
90
+ */
91
+ export declare function POST<ClassPrototype extends Controller, Method, DTOConstructor extends typeof DTO = typeof DTO>(r: string, dtoConstructor: DTOConstructor, actionOptions: ActionOptions<HTTPContext>): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
@@ -0,0 +1,92 @@
1
+ import { Controller, type ControllerProperty } from '../../lib/Controller.js';
2
+ import { DTO, MethodDecorator } from '@lakutata/core';
3
+ import { ActionOptions } from '../../lib/ActionOptions.js';
4
+ import { HTTPContext } from '../../context/HTTPContext.js';
5
+ /**
6
+ * Expose the controller method as an HTTP PUT action on a route, to replace a resource: the shorthand of
7
+ * `@HTTPAction(route, 'put', …)`. The adapter assembles the input: by default, the query string merged with the parsed
8
+ * body (JSON or URL encoded), then the route parameters over them. The middlewares run, the input is validated against
9
+ * the DTO (the defaults applied, the unknown keys removed; without a DTO, it is accepted as it is), the access control
10
+ * runs when `acl` is set, then the method receives the validated input as a plain object. The query values and the
11
+ * route parameters are strings and the DTO schemas are strict: convert them with `.strict(false)`. The value returned
12
+ * is answered by the adapter's responder: as JSON by default, with the status 204 for `undefined`; `Result.status()`
13
+ * sets a status and headers. An error thrown is answered as `{errno, errMsg}` with the first 4xx `statusCode` along its
14
+ * causes (400 for an invalid input), else its own `statusCode`, else 500.
15
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
16
+ * prepended to it.
17
+ * @returns The method decorator.
18
+ * @example
19
+ * ```typescript
20
+ * import {DTO} from 'lakutata'
21
+ * import {Controller} from 'lakutata/com/entrypoint'
22
+ * import {PUT} from 'lakutata/decorator/ctrl'
23
+ * import {Expect} from 'lakutata/decorator/dto'
24
+ *
25
+ * class ReplaceSettingsDTO extends DTO {
26
+ * //The route parameter
27
+ * @Expect(DTO.String().required())
28
+ * public user!: string
29
+ *
30
+ * //The body
31
+ * @Expect(DTO.String().valid('light', 'dark').required())
32
+ * public theme!: string
33
+ * }
34
+ *
35
+ * class SettingsController extends Controller {
36
+ * //PUT /settings/ada with the body {"theme": "dark"}: answered with the JSON {"user": "ada", "theme": "dark"}
37
+ * @PUT('/settings/:user', ReplaceSettingsDTO)
38
+ * public async replace(input: ReplaceSettingsDTO): Promise<{ user: string, theme: string }> {
39
+ * return {user: input.user, theme: input.theme}
40
+ * }
41
+ * }
42
+ * ```
43
+ */
44
+ export declare function PUT<ClassPrototype extends Controller, Method>(r: string): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
45
+ /**
46
+ * Expose the controller method as an HTTP PUT action on a route, its input validated against a DTO: the shorthand of
47
+ * `@HTTPAction(route, 'put', …)`. The input is the query string merged with the parsed body, then the route parameters
48
+ * over them (the default of the adapters); the method receives it validated, as a plain object. The value returned is
49
+ * answered as JSON (204 for `undefined`), an error as `{errno, errMsg}` with its status (400 for an invalid input, else
50
+ * 500 by default).
51
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
52
+ * prepended to it.
53
+ * @param dtoConstructor The DTO class validating the input; the query values and the route parameters are strings,
54
+ * convert them with `.strict(false)`.
55
+ * @returns The method decorator.
56
+ */
57
+ export declare function PUT<ClassPrototype extends Controller, Method, DTOConstructor extends typeof DTO = typeof DTO>(r: string, dtoConstructor: DTOConstructor): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
58
+ /**
59
+ * Expose the controller method as an HTTP PUT action on a route, with action options: the shorthand of
60
+ * `@HTTPAction(route, 'put', …)`. The input is the query string merged with the parsed body, then the route parameters
61
+ * over them (the default of the adapters), accepted as it is. The value returned is answered as JSON (204 for
62
+ * `undefined`), an error as `{errno, errMsg}` with its status (500 by default).
63
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
64
+ * prepended to it.
65
+ * @param actionOptions The action options: `acl` runs the access control rules (false by default); `name` (unique in the
66
+ * HTTP actions, `ClassName:method` by default), `description` and `groups` describe the action; `rule` is an access
67
+ * rule of the action; `middlewares` run before the ones `@UseMiddlewares` adds to the method.
68
+ * @returns The method decorator.
69
+ * @throws {InvalidValueException} When the class is declared, if the action options are invalid.
70
+ * @throws {InvalidMiddlewareException} When the class is declared, if a middleware of the options is neither a function
71
+ * nor a class extending `Middleware`.
72
+ */
73
+ export declare function PUT<ClassPrototype extends Controller, Method>(r: string, actionOptions: ActionOptions<HTTPContext>): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;
74
+ /**
75
+ * Expose the controller method as an HTTP PUT action on a route, its input validated against a DTO, with action
76
+ * options: the shorthand of `@HTTPAction(route, 'put', …)`. The input is the query string merged with the parsed body,
77
+ * then the route parameters over them (the default of the adapters); the method receives it validated, as a plain
78
+ * object. The value returned is answered as JSON (204 for `undefined`), an error as `{errno, errMsg}` with its status
79
+ * (400 for an invalid input, else 500 by default).
80
+ * @param r The route, in the syntax of the HTTP adapter (`/users/:id`); the controller's `@Prefix({route})` is
81
+ * prepended to it.
82
+ * @param dtoConstructor The DTO class validating the input; the query values and the route parameters are strings,
83
+ * convert them with `.strict(false)`.
84
+ * @param actionOptions The action options: `acl` runs the access control rules (false by default); `name` (unique in the
85
+ * HTTP actions, `ClassName:method` by default), `description` and `groups` describe the action; `rule` is an access
86
+ * rule of the action; `middlewares` run before the ones `@UseMiddlewares` adds to the method.
87
+ * @returns The method decorator.
88
+ * @throws {InvalidValueException} When the class is declared, if the action options are invalid.
89
+ * @throws {InvalidMiddlewareException} When the class is declared, if a middleware of the options is neither a function
90
+ * nor a class extending `Middleware`.
91
+ */
92
+ export declare function PUT<ClassPrototype extends Controller, Method, DTOConstructor extends typeof DTO = typeof DTO>(r: string, dtoConstructor: DTOConstructor, actionOptions: ActionOptions<HTTPContext>): MethodDecorator<ClassPrototype, Method, ControllerProperty<ClassPrototype>>;