@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,146 @@
1
+ import { Container, Provider, type IBaseObjectConstructor } from '@lakutata/core';
2
+ import type { CLIContext } from '../context/CLIContext.js';
3
+ import type { HTTPContext } from '../context/HTTPContext.js';
4
+ import type { ServiceContext } from '../context/ServiceContext.js';
5
+ import type { CLIActionInfo, HTTPActionInfo, ServiceActionInfo } from '../Entrypoint.js';
6
+ import type { BaseContext } from '../context/BaseContext.js';
7
+ import type { ChannelActionInfo } from '../channel/EntrypointAdapter.js';
8
+ /**
9
+ * A request to a controller action, as the middlewares receive it.
10
+ */
11
+ export interface ActionInvocation {
12
+ /**
13
+ * The request's context; its `data` is the action's input before validation (a middleware may change it).
14
+ */
15
+ readonly context: CLIContext | HTTPContext | ServiceContext | BaseContext;
16
+ /**
17
+ * The requested action's description.
18
+ */
19
+ readonly action: HTTPActionInfo | CLIActionInfo | ServiceActionInfo | ChannelActionInfo;
20
+ /**
21
+ * The parameters taken from the request's address (such as route parameters), merged over the data into the
22
+ * input.
23
+ */
24
+ readonly params?: Record<string, unknown>;
25
+ /**
26
+ * The request's container, destroyed when the request ends: the controller and the middleware classes are
27
+ * created in it.
28
+ */
29
+ readonly container: Container;
30
+ /**
31
+ * Aborts when the request is aborted (its client gone, the entrypoint stopping).
32
+ */
33
+ readonly signal?: AbortSignal;
34
+ }
35
+ /**
36
+ * Run the rest of the pipeline: the next middlewares, then the input validation, the access control and the action.
37
+ * It may be called once per middleware; a second call rejects with a `MiddlewareNextCalledException`.
38
+ * @returns The action's result, as the next middlewares return it.
39
+ */
40
+ export type Next = () => Promise<unknown>;
41
+ /**
42
+ * A middleware function: it runs around the rest of the pipeline (see {@link Middleware.handle}).
43
+ * @param invocation The request.
44
+ * @param next Runs the rest of the pipeline.
45
+ * @returns The result given to the previous middleware (finally, to the adapter).
46
+ */
47
+ export type MiddlewareHandler = (invocation: ActionInvocation, next: Next) => Promise<unknown>;
48
+ /**
49
+ * A middleware class: it runs around the actions, created in each request's container (its dependencies are
50
+ * injected). Give it, or a {@link MiddlewareHandler} function, to the entrypoint's `middlewares` option (every
51
+ * action), an adapter's `middlewares` option (its requests), `@UseMiddlewares` (a controller class or a method) or an
52
+ * action's `middlewares` option. They run in that order: the entrypoint's, the adapter's, the controller parents'
53
+ * then the controller's, the action option's, then the method's.
54
+ * @example
55
+ * ```typescript
56
+ * import {Application} from 'lakutata'
57
+ * import {buildEntrypoints, Controller, Middleware, type ActionInvocation, type Next} from 'lakutata/com/entrypoint'
58
+ * import {GET, UseMiddlewares} from 'lakutata/decorator/ctrl'
59
+ *
60
+ * //Log the duration of each request
61
+ * class Timing extends Middleware {
62
+ * public async handle(invocation: ActionInvocation, next: Next): Promise<unknown> {
63
+ * const start: number = Date.now()
64
+ * try {
65
+ * return await next()
66
+ * } finally {
67
+ * console.log(`${invocation.action.name}: ${Date.now() - start}ms`)
68
+ * }
69
+ * }
70
+ * }
71
+ *
72
+ * @UseMiddlewares(async (invocation: ActionInvocation, next: Next): Promise<unknown> => {
73
+ * //Short-circuit: the action does not run
74
+ * if (invocation.context.data.maintenance) return {error: 'maintenance'}
75
+ * return next()
76
+ * })
77
+ * class StatusController extends Controller {
78
+ * @GET('/status')
79
+ * public async status(): Promise<string> {
80
+ * return 'ok'
81
+ * }
82
+ * }
83
+ *
84
+ * Application.run(() => ({
85
+ * id: 'status.app',
86
+ * name: 'Status',
87
+ * components: {
88
+ * entrypoint: buildEntrypoints({
89
+ * controllers: [StatusController],
90
+ * middlewares: [Timing]
91
+ * })
92
+ * }
93
+ * }))
94
+ * ```
95
+ */
96
+ export declare abstract class Middleware extends Provider {
97
+ /**
98
+ * Handle a request: call `next()` to continue the pipeline and return its result (changed or not), or return
99
+ * without calling it to answer instead of the action. A thrown error fails the request.
100
+ * @param invocation The request.
101
+ * @param next Runs the rest of the pipeline; once at most.
102
+ * @returns The result given to the previous middleware (finally, to the adapter).
103
+ */
104
+ abstract handle(invocation: ActionInvocation, next: Next): Promise<unknown>;
105
+ }
106
+ /**
107
+ * A middleware: a {@link Middleware} subclass, created in each request's container, or a {@link MiddlewareHandler}
108
+ * function. Any other value (a class not extending `Middleware` included) fails with an `InvalidMiddlewareException`.
109
+ */
110
+ export type MiddlewareDefinition = IBaseObjectConstructor<Middleware> | MiddlewareHandler;
111
+ export type InvocationRunner = (invocation: ActionInvocation) => Promise<unknown>;
112
+ /**
113
+ * Whether a middleware is a middleware class
114
+ * @param middleware
115
+ */
116
+ export declare function isMiddlewareClass(middleware: MiddlewareDefinition): middleware is IBaseObjectConstructor<Middleware>;
117
+ /**
118
+ * Check middleware definitions: middleware classes or functions
119
+ * @param middlewares
120
+ */
121
+ export declare function validateMiddlewares(middlewares: unknown[]): MiddlewareDefinition[];
122
+ /**
123
+ * Add middlewares to a controller class or an action method, the middlewares of each decorator run in their order,
124
+ * the decorators from top to bottom
125
+ * @param target
126
+ * @param propertyKey
127
+ * @param middlewares
128
+ */
129
+ export declare function addMiddlewares(target: object, propertyKey: string | symbol | undefined, middlewares: MiddlewareDefinition[]): void;
130
+ /**
131
+ * The middlewares of a controller class, the ones of its parent classes first
132
+ * @param controller
133
+ */
134
+ export declare function getClassMiddlewares(controller: Function): MiddlewareDefinition[];
135
+ /**
136
+ * The middlewares of an action method, declared on the method in the class hierarchy
137
+ * @param controller
138
+ * @param method
139
+ */
140
+ export declare function getMethodMiddlewares(controller: Function, method: string | symbol): MiddlewareDefinition[];
141
+ /**
142
+ * Compose middlewares around the innermost runner
143
+ * @param middlewares
144
+ * @param innermost
145
+ */
146
+ export declare function composeMiddlewares(middlewares: MiddlewareDefinition[], innermost: InvocationRunner): InvocationRunner;
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Middleware = void 0;
4
+ exports.isMiddlewareClass = isMiddlewareClass;
5
+ exports.validateMiddlewares = validateMiddlewares;
6
+ exports.addMiddlewares = addMiddlewares;
7
+ exports.getClassMiddlewares = getClassMiddlewares;
8
+ exports.getMethodMiddlewares = getMethodMiddlewares;
9
+ exports.composeMiddlewares = composeMiddlewares;
10
+ const core_1 = require("@lakutata/core");
11
+ const utils_1 = require("@lakutata/utils");
12
+ const InvalidMiddlewareException_js_1 = require("../exceptions/InvalidMiddlewareException.js");
13
+ const MiddlewareNextCalledException_js_1 = require("../exceptions/MiddlewareNextCalledException.js");
14
+ /**
15
+ * A middleware class: it runs around the actions, created in each request's container (its dependencies are
16
+ * injected). Give it, or a {@link MiddlewareHandler} function, to the entrypoint's `middlewares` option (every
17
+ * action), an adapter's `middlewares` option (its requests), `@UseMiddlewares` (a controller class or a method) or an
18
+ * action's `middlewares` option. They run in that order: the entrypoint's, the adapter's, the controller parents'
19
+ * then the controller's, the action option's, then the method's.
20
+ * @example
21
+ * ```typescript
22
+ * import {Application} from 'lakutata'
23
+ * import {buildEntrypoints, Controller, Middleware, type ActionInvocation, type Next} from 'lakutata/com/entrypoint'
24
+ * import {GET, UseMiddlewares} from 'lakutata/decorator/ctrl'
25
+ *
26
+ * //Log the duration of each request
27
+ * class Timing extends Middleware {
28
+ * public async handle(invocation: ActionInvocation, next: Next): Promise<unknown> {
29
+ * const start: number = Date.now()
30
+ * try {
31
+ * return await next()
32
+ * } finally {
33
+ * console.log(`${invocation.action.name}: ${Date.now() - start}ms`)
34
+ * }
35
+ * }
36
+ * }
37
+ *
38
+ * @UseMiddlewares(async (invocation: ActionInvocation, next: Next): Promise<unknown> => {
39
+ * //Short-circuit: the action does not run
40
+ * if (invocation.context.data.maintenance) return {error: 'maintenance'}
41
+ * return next()
42
+ * })
43
+ * class StatusController extends Controller {
44
+ * @GET('/status')
45
+ * public async status(): Promise<string> {
46
+ * return 'ok'
47
+ * }
48
+ * }
49
+ *
50
+ * Application.run(() => ({
51
+ * id: 'status.app',
52
+ * name: 'Status',
53
+ * components: {
54
+ * entrypoint: buildEntrypoints({
55
+ * controllers: [StatusController],
56
+ * middlewares: [Timing]
57
+ * })
58
+ * }
59
+ * }))
60
+ * ```
61
+ */
62
+ class Middleware extends core_1.Provider {
63
+ }
64
+ exports.Middleware = Middleware;
65
+ const CLASS_MIDDLEWARES = Symbol('ENTRYPOINT.CLASS.MIDDLEWARES');
66
+ const METHOD_MIDDLEWARES = Symbol('ENTRYPOINT.METHOD.MIDDLEWARES');
67
+ /**
68
+ * Whether a middleware is a middleware class
69
+ * @param middleware
70
+ */
71
+ function isMiddlewareClass(middleware) {
72
+ return (0, utils_1.isSubclassOf)(middleware, Middleware);
73
+ }
74
+ /**
75
+ * Check middleware definitions: middleware classes or functions
76
+ * @param middlewares
77
+ */
78
+ function validateMiddlewares(middlewares) {
79
+ for (const middleware of middlewares) {
80
+ if (typeof middleware !== 'function')
81
+ throw new InvalidMiddlewareException_js_1.InvalidMiddlewareException('A middleware must be a function or a class extending Middleware');
82
+ if (!isMiddlewareClass(middleware) && /^class[\s{]/.test(Function.prototype.toString.call(middleware)))
83
+ throw new InvalidMiddlewareException_js_1.InvalidMiddlewareException('The middleware class "{0}" does not extend Middleware', [middleware.name]);
84
+ }
85
+ return middlewares;
86
+ }
87
+ /**
88
+ * Add middlewares to a controller class or an action method, the middlewares of each decorator run in their order,
89
+ * the decorators from top to bottom
90
+ * @param target
91
+ * @param propertyKey
92
+ * @param middlewares
93
+ */
94
+ function addMiddlewares(target, propertyKey, middlewares) {
95
+ const key = propertyKey === undefined ? CLASS_MIDDLEWARES : METHOD_MIDDLEWARES;
96
+ const existing = (propertyKey === undefined ? Reflect.getOwnMetadata(key, target) : Reflect.getOwnMetadata(key, target, propertyKey)) || [];
97
+ //The decorators are applied from bottom to top
98
+ const merged = [...validateMiddlewares(middlewares), ...existing];
99
+ propertyKey === undefined ? Reflect.defineMetadata(key, merged, target) : Reflect.defineMetadata(key, merged, target, propertyKey);
100
+ }
101
+ /**
102
+ * The middlewares of a controller class, the ones of its parent classes first
103
+ * @param controller
104
+ */
105
+ function getClassMiddlewares(controller) {
106
+ const chain = [];
107
+ for (let current = controller; current && current !== Function.prototype; current = Object.getPrototypeOf(current))
108
+ chain.unshift(current);
109
+ return chain.flatMap((constructor) => Reflect.getOwnMetadata(CLASS_MIDDLEWARES, constructor) || []);
110
+ }
111
+ /**
112
+ * The middlewares of an action method, declared on the method in the class hierarchy
113
+ * @param controller
114
+ * @param method
115
+ */
116
+ function getMethodMiddlewares(controller, method) {
117
+ for (let prototype = controller.prototype; prototype; prototype = Object.getPrototypeOf(prototype)) {
118
+ const middlewares = Reflect.getOwnMetadata(METHOD_MIDDLEWARES, prototype, method);
119
+ if (middlewares)
120
+ return middlewares;
121
+ }
122
+ return [];
123
+ }
124
+ /**
125
+ * Compose middlewares around the innermost runner
126
+ * @param middlewares
127
+ * @param innermost
128
+ */
129
+ function composeMiddlewares(middlewares, innermost) {
130
+ return middlewares.reduceRight((next, middleware) => {
131
+ const handle = isMiddlewareClass(middleware)
132
+ ? async (invocation, nextStep) => (await invocation.container.get(middleware)).handle(invocation, nextStep)
133
+ : middleware;
134
+ return (invocation) => {
135
+ let called = false;
136
+ return handle(invocation, () => {
137
+ if (called)
138
+ return Promise.reject(new MiddlewareNextCalledException_js_1.MiddlewareNextCalledException('next() is called more than once'));
139
+ called = true;
140
+ return next(invocation);
141
+ });
142
+ };
143
+ }, innermost);
144
+ }
@@ -0,0 +1,98 @@
1
+ import { DTO, type ActionPattern } from '@lakutata/core';
2
+ /**
3
+ * A controller's action prefixes, given to `@Prefix`. The packages of the other channels add their own prefix keys
4
+ * (declaration merging); the keys are kept even when not declared here.
5
+ * @example
6
+ * ```typescript
7
+ * import {Controller} from 'lakutata/com/entrypoint'
8
+ * import {CLIAction, GET, Prefix, ServiceAction} from 'lakutata/decorator/ctrl'
9
+ *
10
+ * //GET /users/:id, the command user:get, the pattern {resource: 'user', act: 'get'}
11
+ * @Prefix({route: '/users', command: 'user', pattern: {resource: 'user'}})
12
+ * class UserController extends Controller {
13
+ * @GET('/:id')
14
+ * @CLIAction('get')
15
+ * @ServiceAction({act: 'get'})
16
+ * public async get(input: {id: string}): Promise<{id: string}> {
17
+ * return {id: input.id}
18
+ * }
19
+ * }
20
+ * ```
21
+ */
22
+ export declare class PrefixOptions extends DTO {
23
+ /**
24
+ * The path prepended to the HTTP actions' routes, the slashes between them normalized (`/users` + `/:id` =
25
+ * `/users/:id`).
26
+ */
27
+ route?: string;
28
+ /**
29
+ * The command prepended to the CLI actions' commands, joined by `:` (`user` + `get` = `user:get`; an empty
30
+ * command gives the prefix alone).
31
+ */
32
+ command?: string;
33
+ /**
34
+ * The pattern merged into the service actions' patterns, deeply (`{resource: 'user'}` + `{act: 'get'}` =
35
+ * `{resource: 'user', act: 'get'}`); a key the prefix and the pattern set to different values fails the
36
+ * entrypoint's initialization with an `InvalidPrefixException`.
37
+ */
38
+ pattern?: ActionPattern;
39
+ }
40
+ /**
41
+ * Set a controller class's prefixes, merged over the ones already set on the class (by the decorators of the other
42
+ * channels). Used by `@Prefix` and by the prefix decorators of the packages providing a channel.
43
+ * @param controller The controller class.
44
+ * @param options The prefixes to set.
45
+ * @throws {Error} When the merged prefixes are invalid (the validation error of {@link PrefixOptions}).
46
+ * @example
47
+ * ```typescript
48
+ * import {Controller} from 'lakutata/com/entrypoint'
49
+ * import {setPrefix} from '@lakutata/entrypoint/channel'
50
+ *
51
+ * //A decorator of a "queue" channel prefixing the topics of a controller
52
+ * export function TopicPrefix(topic: string) {
53
+ * return (target: typeof Controller): void => setPrefix(target, {topic: topic})
54
+ * }
55
+ * ```
56
+ */
57
+ export declare function setPrefix(controller: Function, options: PrefixOptions): void;
58
+ /**
59
+ * Get a controller's prefixes: the ones of the class, or else of its nearest parent class declaring them (they are not
60
+ * merged across the hierarchy).
61
+ * @param controller The controller class.
62
+ * @returns The prefixes, `undefined` when neither the class nor its parents declare any.
63
+ * @example
64
+ * ```typescript
65
+ * import {Controller} from 'lakutata/com/entrypoint'
66
+ * import {Prefix} from 'lakutata/decorator/ctrl'
67
+ * import {getPrefix} from '@lakutata/entrypoint/channel'
68
+ *
69
+ * @Prefix({route: '/users'})
70
+ * class UserController extends Controller {
71
+ * }
72
+ *
73
+ * class AdminController extends UserController {
74
+ * }
75
+ *
76
+ * console.log(getPrefix(AdminController)?.route) //'/users'
77
+ * ```
78
+ */
79
+ export declare function getPrefix(controller: Function): PrefixOptions | undefined;
80
+ /**
81
+ * Join a route prefix and a route
82
+ * @param prefix
83
+ * @param route
84
+ */
85
+ export declare function prefixRoute(prefix: string, route: string): string;
86
+ /**
87
+ * Join a command prefix and a command
88
+ * @param prefix
89
+ * @param command
90
+ */
91
+ export declare function prefixCommand(prefix: string, command: string): string;
92
+ /**
93
+ * Merge a pattern prefix into a pattern, a key cannot have different values
94
+ * @param prefix
95
+ * @param pattern
96
+ * @param path
97
+ */
98
+ export declare function prefixPattern(prefix: ActionPattern, pattern: ActionPattern, path?: string): ActionPattern;
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PrefixOptions = void 0;
13
+ exports.setPrefix = setPrefix;
14
+ exports.getPrefix = getPrefix;
15
+ exports.prefixRoute = prefixRoute;
16
+ exports.prefixCommand = prefixCommand;
17
+ exports.prefixPattern = prefixPattern;
18
+ const core_1 = require("@lakutata/core");
19
+ const dto_1 = require("@lakutata/core/decorator/dto");
20
+ const InvalidPrefixException_js_1 = require("../exceptions/InvalidPrefixException.js");
21
+ /**
22
+ * A controller's action prefixes, given to `@Prefix`. The packages of the other channels add their own prefix keys
23
+ * (declaration merging); the keys are kept even when not declared here.
24
+ * @example
25
+ * ```typescript
26
+ * import {Controller} from 'lakutata/com/entrypoint'
27
+ * import {CLIAction, GET, Prefix, ServiceAction} from 'lakutata/decorator/ctrl'
28
+ *
29
+ * //GET /users/:id, the command user:get, the pattern {resource: 'user', act: 'get'}
30
+ * @Prefix({route: '/users', command: 'user', pattern: {resource: 'user'}})
31
+ * class UserController extends Controller {
32
+ * @GET('/:id')
33
+ * @CLIAction('get')
34
+ * @ServiceAction({act: 'get'})
35
+ * public async get(input: {id: string}): Promise<{id: string}> {
36
+ * return {id: input.id}
37
+ * }
38
+ * }
39
+ * ```
40
+ */
41
+ let PrefixOptions = class PrefixOptions extends core_1.DTO {
42
+ };
43
+ exports.PrefixOptions = PrefixOptions;
44
+ __decorate([
45
+ (0, dto_1.Expect)(core_1.DTO.String().optional()),
46
+ __metadata("design:type", String)
47
+ ], PrefixOptions.prototype, "route", void 0);
48
+ __decorate([
49
+ (0, dto_1.Expect)(core_1.DTO.String().optional()),
50
+ __metadata("design:type", String)
51
+ ], PrefixOptions.prototype, "command", void 0);
52
+ __decorate([
53
+ (0, dto_1.Expect)(core_1.DTO.Object().optional()),
54
+ __metadata("design:type", Object)
55
+ ], PrefixOptions.prototype, "pattern", void 0);
56
+ exports.PrefixOptions = PrefixOptions = __decorate([
57
+ (0, dto_1.IndexSignature)(core_1.DTO.Any())
58
+ ], PrefixOptions);
59
+ const CONTROLLER_PREFIX = Symbol('ENTRYPOINT.CONTROLLER.PREFIX');
60
+ /**
61
+ * Set a controller class's prefixes, merged over the ones already set on the class (by the decorators of the other
62
+ * channels). Used by `@Prefix` and by the prefix decorators of the packages providing a channel.
63
+ * @param controller The controller class.
64
+ * @param options The prefixes to set.
65
+ * @throws {Error} When the merged prefixes are invalid (the validation error of {@link PrefixOptions}).
66
+ * @example
67
+ * ```typescript
68
+ * import {Controller} from 'lakutata/com/entrypoint'
69
+ * import {setPrefix} from '@lakutata/entrypoint/channel'
70
+ *
71
+ * //A decorator of a "queue" channel prefixing the topics of a controller
72
+ * export function TopicPrefix(topic: string) {
73
+ * return (target: typeof Controller): void => setPrefix(target, {topic: topic})
74
+ * }
75
+ * ```
76
+ */
77
+ function setPrefix(controller, options) {
78
+ const own = Reflect.getOwnMetadata(CONTROLLER_PREFIX, controller);
79
+ Reflect.defineMetadata(CONTROLLER_PREFIX, PrefixOptions.validate({ ...own, ...options }), controller);
80
+ }
81
+ /**
82
+ * Get a controller's prefixes: the ones of the class, or else of its nearest parent class declaring them (they are not
83
+ * merged across the hierarchy).
84
+ * @param controller The controller class.
85
+ * @returns The prefixes, `undefined` when neither the class nor its parents declare any.
86
+ * @example
87
+ * ```typescript
88
+ * import {Controller} from 'lakutata/com/entrypoint'
89
+ * import {Prefix} from 'lakutata/decorator/ctrl'
90
+ * import {getPrefix} from '@lakutata/entrypoint/channel'
91
+ *
92
+ * @Prefix({route: '/users'})
93
+ * class UserController extends Controller {
94
+ * }
95
+ *
96
+ * class AdminController extends UserController {
97
+ * }
98
+ *
99
+ * console.log(getPrefix(AdminController)?.route) //'/users'
100
+ * ```
101
+ */
102
+ function getPrefix(controller) {
103
+ for (let current = controller; current && current !== Function.prototype; current = Object.getPrototypeOf(current)) {
104
+ const prefix = Reflect.getOwnMetadata(CONTROLLER_PREFIX, current);
105
+ if (prefix)
106
+ return prefix;
107
+ }
108
+ return undefined;
109
+ }
110
+ /**
111
+ * Join a route prefix and a route
112
+ * @param prefix
113
+ * @param route
114
+ */
115
+ function prefixRoute(prefix, route) {
116
+ const segments = [prefix, route].map((part) => part.replace(/^\/+|\/+$/g, '')).filter(Boolean);
117
+ return `/${segments.join('/')}`;
118
+ }
119
+ /**
120
+ * Join a command prefix and a command
121
+ * @param prefix
122
+ * @param command
123
+ */
124
+ function prefixCommand(prefix, command) {
125
+ return command ? `${prefix}:${command}` : prefix;
126
+ }
127
+ /**
128
+ * Merge a pattern prefix into a pattern, a key cannot have different values
129
+ * @param prefix
130
+ * @param pattern
131
+ * @param path
132
+ */
133
+ function prefixPattern(prefix, pattern, path = '') {
134
+ const merged = { ...pattern };
135
+ for (const [key, value] of Object.entries(prefix)) {
136
+ if (!(key in merged)) {
137
+ merged[key] = value;
138
+ }
139
+ else if (value !== null && typeof value === 'object' && merged[key] !== null && typeof merged[key] === 'object') {
140
+ merged[key] = prefixPattern(value, merged[key], `${path}${key}.`);
141
+ }
142
+ else if (merged[key] !== value) {
143
+ throw new InvalidPrefixException_js_1.InvalidPrefixException('The pattern prefix sets "{key}" to {prefix}, the pattern sets it to {pattern}', {
144
+ key: `${path}${key}`,
145
+ prefix: JSON.stringify(value),
146
+ pattern: JSON.stringify(merged[key])
147
+ });
148
+ }
149
+ }
150
+ return merged;
151
+ }