stratal 0.0.20 → 0.0.22

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 (247) hide show
  1. package/README.md +1 -1
  2. package/dist/{base-email.provider-CfQCA08m.mjs → base-email.provider-BWZHIjt8.mjs} +1 -1
  3. package/dist/{base-email.provider-CfQCA08m.mjs.map → base-email.provider-BWZHIjt8.mjs.map} +1 -1
  4. package/dist/bin/cloudflare-workers-loader.mjs.map +1 -1
  5. package/dist/bin/quarry.mjs +46 -109
  6. package/dist/bin/quarry.mjs.map +1 -1
  7. package/dist/cache/index.d.mts +6 -46
  8. package/dist/cache/index.d.mts.map +1 -1
  9. package/dist/cache/index.mjs +22 -67
  10. package/dist/cache/index.mjs.map +1 -1
  11. package/dist/{cache.service-DsnKuNyO.d.mts → cache.service-e34gV6tz.d.mts} +8 -8
  12. package/dist/{cache.service-DsnKuNyO.d.mts.map → cache.service-e34gV6tz.d.mts.map} +1 -1
  13. package/dist/{cache.tokens-B7Rw1C9Q.mjs → cache.tokens-ovi_c52J.mjs} +1 -1
  14. package/dist/{cache.tokens-B7Rw1C9Q.mjs.map → cache.tokens-ovi_c52J.mjs.map} +1 -1
  15. package/dist/{colors-DJaRDXoS.mjs → colors-axmupKdp.mjs} +1 -1
  16. package/dist/{colors-DJaRDXoS.mjs.map → colors-axmupKdp.mjs.map} +1 -1
  17. package/dist/{command-BgSlsS4M.mjs → command-BU4ApTo5.mjs} +2 -3
  18. package/dist/command-BU4ApTo5.mjs.map +1 -0
  19. package/dist/{command-Bu-PjJrX.d.mts → command-wXfvHbBZ.d.mts} +3 -2
  20. package/dist/command-wXfvHbBZ.d.mts.map +1 -0
  21. package/dist/config/index.d.mts +24 -11
  22. package/dist/config/index.d.mts.map +1 -1
  23. package/dist/config/index.mjs +33 -57
  24. package/dist/config/index.mjs.map +1 -1
  25. package/dist/{consumer-registry-B7yUNh0q.d.mts → consumer-registry-DHQtypr1.d.mts} +1 -1
  26. package/dist/{consumer-registry-B7yUNh0q.d.mts.map → consumer-registry-DHQtypr1.d.mts.map} +1 -1
  27. package/dist/container-storage-GpNNz79X.mjs +52 -0
  28. package/dist/container-storage-GpNNz79X.mjs.map +1 -0
  29. package/dist/{controller.decorator-DQzenvSN.mjs → controller.decorator-DIUazNU7.mjs} +8 -8
  30. package/dist/controller.decorator-DIUazNU7.mjs.map +1 -0
  31. package/dist/cron/index.d.mts +26 -5
  32. package/dist/cron/index.d.mts.map +1 -1
  33. package/dist/cron/index.mjs +1 -1
  34. package/dist/{cron-manager-7Symz_TE.mjs → cron-manager-9bpN9bu4.mjs} +42 -16
  35. package/dist/cron-manager-9bpN9bu4.mjs.map +1 -0
  36. package/dist/{cron-manager-BEsH1mjW.d.mts → cron-manager-CSTIBPcM.d.mts} +6 -13
  37. package/dist/cron-manager-CSTIBPcM.d.mts.map +1 -0
  38. package/dist/decorate-HgTKAYK8.mjs +16 -0
  39. package/dist/deep-merge-C8NgcXw4.mjs +18 -0
  40. package/dist/deep-merge-C8NgcXw4.mjs.map +1 -0
  41. package/dist/di/index.d.mts +2 -2
  42. package/dist/di/index.mjs +4 -3
  43. package/dist/di-BO1QIb5H.mjs +415 -0
  44. package/dist/di-BO1QIb5H.mjs.map +1 -0
  45. package/dist/email/index.d.mts +14 -89
  46. package/dist/email/index.d.mts.map +1 -1
  47. package/dist/email/index.mjs +30 -125
  48. package/dist/email/index.mjs.map +1 -1
  49. package/dist/en-BPP6h6y5.mjs +202 -0
  50. package/dist/en-BPP6h6y5.mjs.map +1 -0
  51. package/dist/{env-D1rcZ8_r.d.mts → env-DKSbuBi5.d.mts} +1 -1
  52. package/dist/env-DKSbuBi5.d.mts.map +1 -0
  53. package/dist/errors/index.d.mts +2 -2
  54. package/dist/errors/index.mjs +4 -2
  55. package/dist/errors-BBZTnjdq.mjs +333 -0
  56. package/dist/errors-BBZTnjdq.mjs.map +1 -0
  57. package/dist/events/index.d.mts +2 -2
  58. package/dist/events/index.d.mts.map +1 -1
  59. package/dist/events/index.mjs +1 -1
  60. package/dist/{events-COKixqnG.mjs → events-D1KdDaiP.mjs} +13 -11
  61. package/dist/events-D1KdDaiP.mjs.map +1 -0
  62. package/dist/exception-context-B4kM-M53.mjs +429 -0
  63. package/dist/exception-context-B4kM-M53.mjs.map +1 -0
  64. package/dist/{gateway-context-CdJjpUCW.mjs → gateway-context-CFe6a9gz.mjs} +20 -31
  65. package/dist/gateway-context-CFe6a9gz.mjs.map +1 -0
  66. package/dist/guards/index.d.mts +3 -3
  67. package/dist/guards/index.d.mts.map +1 -1
  68. package/dist/guards/index.mjs +1 -1
  69. package/dist/{guards-DUk_Kzst.mjs → guards-Ced-uNIF.mjs} +7 -5
  70. package/dist/guards-Ced-uNIF.mjs.map +1 -0
  71. package/dist/{http-method.decorator-DXwxAfb_.mjs → http-method.decorator-CdjKFJZZ.mjs} +7 -6
  72. package/dist/http-method.decorator-CdjKFJZZ.mjs.map +1 -0
  73. package/dist/i18n/index.d.mts +238 -3
  74. package/dist/i18n/index.d.mts.map +1 -0
  75. package/dist/i18n/index.mjs +39 -3
  76. package/dist/i18n/index.mjs.map +1 -0
  77. package/dist/i18n/messages/en/index.d.mts +2 -2
  78. package/dist/i18n/messages/en/index.mjs +2 -2
  79. package/dist/i18n/utils/index.d.mts +4 -26
  80. package/dist/i18n/utils/index.d.mts.map +1 -1
  81. package/dist/i18n/utils/index.mjs +2 -2
  82. package/dist/i18n/validation/index.d.mts +3 -2
  83. package/dist/i18n/validation/index.mjs +4 -2
  84. package/dist/i18n.module-BlXrtAlV.mjs +219 -0
  85. package/dist/i18n.module-BlXrtAlV.mjs.map +1 -0
  86. package/dist/i18n.tokens-hwRpmjRq.mjs +19 -0
  87. package/dist/i18n.tokens-hwRpmjRq.mjs.map +1 -0
  88. package/dist/{index-7-hU3GTV.d.mts → index-B4UBK-2T.d.mts} +1 -1
  89. package/dist/{index-7-hU3GTV.d.mts.map → index-B4UBK-2T.d.mts.map} +1 -1
  90. package/dist/index-BtlE9RuO.d.mts +124 -0
  91. package/dist/index-BtlE9RuO.d.mts.map +1 -0
  92. package/dist/{index-CjaQ6_tZ.d.mts → index-CW1YHSft.d.mts} +71 -167
  93. package/dist/index-CW1YHSft.d.mts.map +1 -0
  94. package/dist/{index-D0US0X14.d.mts → index-DEncMcC6.d.mts} +559 -2239
  95. package/dist/index-DEncMcC6.d.mts.map +1 -0
  96. package/dist/index-Dj5IMwtr.d.mts +44 -0
  97. package/dist/index-Dj5IMwtr.d.mts.map +1 -0
  98. package/dist/{index-C1KvMncZ.d.mts → index-KMgSCSM7.d.mts} +3 -108
  99. package/dist/index-KMgSCSM7.d.mts.map +1 -0
  100. package/dist/index.d.mts +5 -43
  101. package/dist/index.mjs +1 -1
  102. package/dist/{is-command-C6a7WTPw.mjs → is-command-CX5rAfZW.mjs} +2 -2
  103. package/dist/{is-command-C6a7WTPw.mjs.map → is-command-CX5rAfZW.mjs.map} +1 -1
  104. package/dist/{is-seeder-CebjZCDn.mjs → is-seeder-CYCtELlm.mjs} +1 -1
  105. package/dist/{is-seeder-CebjZCDn.mjs.map → is-seeder-CYCtELlm.mjs.map} +1 -1
  106. package/dist/logger/index.d.mts +2 -2
  107. package/dist/logger/index.mjs +170 -2
  108. package/dist/logger/index.mjs.map +1 -0
  109. package/dist/macroable/index.d.mts +1 -1
  110. package/dist/macroable/index.mjs +1 -1
  111. package/dist/{macroable-BmufBshB.mjs → macroable-DzlfzT50.mjs} +1 -1
  112. package/dist/{macroable-BmufBshB.mjs.map → macroable-DzlfzT50.mjs.map} +1 -1
  113. package/dist/metadata-BVkc4aUu.mjs +39 -0
  114. package/dist/metadata-BVkc4aUu.mjs.map +1 -0
  115. package/dist/module/index.d.mts +6 -24
  116. package/dist/module/index.d.mts.map +1 -1
  117. package/dist/module/index.mjs +2 -2
  118. package/dist/module-xYoHba6B.mjs +422 -0
  119. package/dist/module-xYoHba6B.mjs.map +1 -0
  120. package/dist/openapi/index.d.mts +3 -3
  121. package/dist/openapi/index.d.mts.map +1 -1
  122. package/dist/openapi/index.mjs +1 -2
  123. package/dist/openapi-C6lm0RmV.mjs +483 -0
  124. package/dist/openapi-C6lm0RmV.mjs.map +1 -0
  125. package/dist/{openapi.service-BLgvn3hJ.d.mts → openapi.service-CrLlsXAd.d.mts} +3 -3
  126. package/dist/openapi.service-CrLlsXAd.d.mts.map +1 -0
  127. package/dist/quarry/index.d.mts +5 -163
  128. package/dist/quarry/index.d.mts.map +1 -1
  129. package/dist/quarry/index.mjs +5 -5
  130. package/dist/quarry/runner.d.mts +184 -0
  131. package/dist/quarry/runner.d.mts.map +1 -0
  132. package/dist/quarry/runner.mjs +775 -0
  133. package/dist/quarry/runner.mjs.map +1 -0
  134. package/dist/quarry-registry-D4hIGScf.d.mts +69 -0
  135. package/dist/quarry-registry-D4hIGScf.d.mts.map +1 -0
  136. package/dist/quarry-registry-DkraZNwn.mjs +311 -0
  137. package/dist/quarry-registry-DkraZNwn.mjs.map +1 -0
  138. package/dist/queue/index.d.mts +3 -3
  139. package/dist/queue/index.mjs +27 -28
  140. package/dist/queue/index.mjs.map +1 -1
  141. package/dist/{queue.module-BCdCiySt.mjs → queue.module-DeWJ0tQM.mjs} +67 -112
  142. package/dist/queue.module-DeWJ0tQM.mjs.map +1 -0
  143. package/dist/{r2-storage.provider-Co6F0ZYV.mjs → r2-storage.provider-Hfm6LdZQ.mjs} +8 -5
  144. package/dist/r2-storage.provider-Hfm6LdZQ.mjs.map +1 -0
  145. package/dist/{rate-limit.decorator--o6Q6p9w.mjs → rate-limit.decorator-D69zdZbp.mjs} +6 -11
  146. package/dist/rate-limit.decorator-D69zdZbp.mjs.map +1 -0
  147. package/dist/rate-limiter/index.d.mts +11 -50
  148. package/dist/rate-limiter/index.d.mts.map +1 -1
  149. package/dist/rate-limiter/index.mjs +25 -30
  150. package/dist/rate-limiter/index.mjs.map +1 -1
  151. package/dist/{resend.provider-M6qRLrcy.mjs → resend.provider-Ur6tU7fK.mjs} +8 -7
  152. package/dist/resend.provider-Ur6tU7fK.mjs.map +1 -0
  153. package/dist/router/index.d.mts +2 -2
  154. package/dist/router/index.mjs +8 -7
  155. package/dist/{i18n.module-BBlNNlcG.mjs → router-Cy6DjkvP.mjs} +215 -855
  156. package/dist/router-Cy6DjkvP.mjs.map +1 -0
  157. package/dist/seeder/index.d.mts +6 -11
  158. package/dist/seeder/index.d.mts.map +1 -1
  159. package/dist/seeder/index.mjs +3 -3
  160. package/dist/{seeder-CJAOHEIo.mjs → seeder-BADTig4n.mjs} +17 -22
  161. package/dist/seeder-BADTig4n.mjs.map +1 -0
  162. package/dist/{signed-url-BQPbv2In.mjs → signed-url-BqUqt5dF.mjs} +1 -1
  163. package/dist/{signed-url-BQPbv2In.mjs.map → signed-url-BqUqt5dF.mjs.map} +1 -1
  164. package/dist/{smtp.provider-w0Ve52Xg.mjs → smtp.provider-C129sNBT.mjs} +7 -6
  165. package/dist/smtp.provider-C129sNBT.mjs.map +1 -0
  166. package/dist/storage/index.d.mts +15 -39
  167. package/dist/storage/index.d.mts.map +1 -1
  168. package/dist/storage/index.mjs +3 -3
  169. package/dist/storage/providers/index.d.mts +2 -2
  170. package/dist/storage/providers/index.mjs +1 -1
  171. package/dist/{storage-1zw-6Yiz.mjs → storage-BA3ppVYM.mjs} +70 -59
  172. package/dist/storage-BA3ppVYM.mjs.map +1 -0
  173. package/dist/{storage-provider.interface-Bd6vA4ak.d.mts → storage-provider.interface-DQMtT42e.d.mts} +2 -3
  174. package/dist/storage-provider.interface-DQMtT42e.d.mts.map +1 -0
  175. package/dist/storage.error-C6FY037a.mjs +8 -0
  176. package/dist/storage.error-C6FY037a.mjs.map +1 -0
  177. package/dist/{stratal-DeEcGgdq.mjs → stratal-Bdq4IdB3.mjs} +31 -183
  178. package/dist/stratal-Bdq4IdB3.mjs.map +1 -0
  179. package/dist/stratal-BsKmvP6J.d.mts +43 -0
  180. package/dist/stratal-BsKmvP6J.d.mts.map +1 -0
  181. package/dist/{types-cySNS_lp.d.mts → types-BaeHi67f.d.mts} +1 -1
  182. package/dist/types-BaeHi67f.d.mts.map +1 -0
  183. package/dist/{usage-generator-BUdlhnCK.mjs → usage-generator-DTqaUMR9.mjs} +6 -3
  184. package/dist/usage-generator-DTqaUMR9.mjs.map +1 -0
  185. package/dist/validation-DUzcjb8Q.mjs +49 -0
  186. package/dist/validation-DUzcjb8Q.mjs.map +1 -0
  187. package/dist/validation.context-XTysWJ3b.mjs +117 -0
  188. package/dist/validation.context-XTysWJ3b.mjs.map +1 -0
  189. package/dist/websocket/index.d.mts +7 -14
  190. package/dist/websocket/index.d.mts.map +1 -1
  191. package/dist/websocket/index.mjs +2 -2
  192. package/dist/workers/index.d.mts +2 -2
  193. package/dist/workers/index.mjs +3 -2
  194. package/dist/workers/index.mjs.map +1 -1
  195. package/dist/{index-Bnpfq6uk.d.mts → zod-DvWTfRpI.d.mts} +58 -133
  196. package/dist/zod-DvWTfRpI.d.mts.map +1 -0
  197. package/dist/zod-hMa3rSHV.mjs +72 -0
  198. package/dist/zod-hMa3rSHV.mjs.map +1 -0
  199. package/package.json +20 -20
  200. package/dist/command-BgSlsS4M.mjs.map +0 -1
  201. package/dist/command-Bu-PjJrX.d.mts.map +0 -1
  202. package/dist/controller.decorator-DQzenvSN.mjs.map +0 -1
  203. package/dist/cron-manager-7Symz_TE.mjs.map +0 -1
  204. package/dist/cron-manager-BEsH1mjW.d.mts.map +0 -1
  205. package/dist/en-DSH_bhh6.mjs +0 -308
  206. package/dist/en-DSH_bhh6.mjs.map +0 -1
  207. package/dist/env-D1rcZ8_r.d.mts.map +0 -1
  208. package/dist/errors-BdyV5PnY.mjs +0 -1725
  209. package/dist/errors-BdyV5PnY.mjs.map +0 -1
  210. package/dist/errors-Da3Pz2X7.mjs +0 -74
  211. package/dist/errors-Da3Pz2X7.mjs.map +0 -1
  212. package/dist/events-COKixqnG.mjs.map +0 -1
  213. package/dist/gateway-context-CdJjpUCW.mjs.map +0 -1
  214. package/dist/guards-DUk_Kzst.mjs.map +0 -1
  215. package/dist/http-method.decorator-DXwxAfb_.mjs.map +0 -1
  216. package/dist/i18n.module-BBlNNlcG.mjs.map +0 -1
  217. package/dist/index-Bnpfq6uk.d.mts.map +0 -1
  218. package/dist/index-C1KvMncZ.d.mts.map +0 -1
  219. package/dist/index-CjaQ6_tZ.d.mts.map +0 -1
  220. package/dist/index-D0US0X14.d.mts.map +0 -1
  221. package/dist/index-DBd_2wv8.d.mts +0 -263
  222. package/dist/index-DBd_2wv8.d.mts.map +0 -1
  223. package/dist/index.d.mts.map +0 -1
  224. package/dist/logger-V6Ms3QnQ.mjs +0 -436
  225. package/dist/logger-V6Ms3QnQ.mjs.map +0 -1
  226. package/dist/module-Dk2qTa77.mjs +0 -860
  227. package/dist/module-Dk2qTa77.mjs.map +0 -1
  228. package/dist/openapi-tools.service-Zs-Ewv7F.mjs +0 -200
  229. package/dist/openapi-tools.service-Zs-Ewv7F.mjs.map +0 -1
  230. package/dist/openapi.service-BLgvn3hJ.d.mts.map +0 -1
  231. package/dist/quarry-registry-DNEej-Db.mjs +0 -688
  232. package/dist/quarry-registry-DNEej-Db.mjs.map +0 -1
  233. package/dist/queue.module-BCdCiySt.mjs.map +0 -1
  234. package/dist/r2-storage.provider-Co6F0ZYV.mjs.map +0 -1
  235. package/dist/rate-limit.decorator--o6Q6p9w.mjs.map +0 -1
  236. package/dist/resend.provider-M6qRLrcy.mjs.map +0 -1
  237. package/dist/seeder-CJAOHEIo.mjs.map +0 -1
  238. package/dist/setup-CefZKV_e.mjs +0 -37
  239. package/dist/setup-CefZKV_e.mjs.map +0 -1
  240. package/dist/smtp.provider-w0Ve52Xg.mjs.map +0 -1
  241. package/dist/storage-1zw-6Yiz.mjs.map +0 -1
  242. package/dist/storage-provider.interface-Bd6vA4ak.d.mts.map +0 -1
  243. package/dist/stratal-DeEcGgdq.mjs.map +0 -1
  244. package/dist/types-cySNS_lp.d.mts.map +0 -1
  245. package/dist/usage-generator-BUdlhnCK.mjs.map +0 -1
  246. package/dist/validation-DtJwAv7O.mjs +0 -248
  247. package/dist/validation-DtJwAv7O.mjs.map +0 -1
@@ -1,860 +0,0 @@
1
- import { A as Scope, H as ApplicationError, S as HttpException, k as ERROR_CODES } from "./errors-BdyV5PnY.mjs";
2
- import { a as __decorate, d as CONTAINER_TOKEN, o as __decorateParam, p as Transient, s as __decorateMetadata } from "./logger-V6Ms3QnQ.mjs";
3
- import { a as isListener } from "./events-COKixqnG.mjs";
4
- import { t as isCommand } from "./is-command-C6a7WTPw.mjs";
5
- import { t as isSeeder } from "./is-seeder-CebjZCDn.mjs";
6
- import { inject, injectable, instancePerContainerCachingFactory, registry } from "tsyringe";
7
- //#region src/module/errors/invalid-module-provider.error.ts
8
- /**
9
- * InvalidModuleProviderError
10
- *
11
- * Thrown when a module provider configuration is invalid.
12
- * This indicates a misconfiguration in the @Module decorator providers array.
13
- */
14
- var InvalidModuleProviderError = class extends ApplicationError {
15
- constructor(provider) {
16
- super("errors.invalidModuleProvider", ERROR_CODES.SYSTEM.INVALID_MODULE_PROVIDER, { provider: JSON.stringify(provider) });
17
- }
18
- };
19
- //#endregion
20
- //#region src/module/module.decorator.ts
21
- const MODULE_OPTIONS_KEY = Symbol.for("stratal:module:options");
22
- /**
23
- * `@Module` decorator - defines a module with imports, providers, controllers, consumers, jobs
24
- *
25
- * Uses tsyringe's `@registry` internally to auto-register providers when module is imported.
26
- *
27
- * @example
28
- * ```typescript
29
- * @Module({
30
- * imports: [OtherModule],
31
- * providers: [MyService, MyRepository],
32
- * controllers: [MyController],
33
- * })
34
- * export class MyModule {}
35
- * ```
36
- */
37
- function Module(options) {
38
- return (target) => {
39
- Reflect.defineMetadata(MODULE_OPTIONS_KEY, options, target);
40
- const registryEntries = buildRegistryEntries(options.providers ?? []);
41
- if (registryEntries.length > 0) registry(registryEntries)(target);
42
- return target;
43
- };
44
- }
45
- /**
46
- * Get module options from decorated class
47
- */
48
- function getModuleOptions(target) {
49
- return Reflect.getMetadata(MODULE_OPTIONS_KEY, target);
50
- }
51
- /**
52
- * Check if a class is decorated with `@Module`
53
- */
54
- function isModuleClass(target) {
55
- return typeof target === "function" && Reflect.hasMetadata(MODULE_OPTIONS_KEY, target);
56
- }
57
- /**
58
- * Convert our Provider types to tsyringe registry format
59
- *
60
- * Maps provider scope to tsyringe's lifecycle option.
61
- * Scope enum values map directly to Lifecycle enum values.
62
- */
63
- function buildRegistryEntries(providers) {
64
- return providers.map((provider) => {
65
- if (typeof provider === "function") return {
66
- token: provider,
67
- useClass: provider
68
- };
69
- if ("useClass" in provider) return {
70
- token: provider.provide,
71
- useClass: provider.useClass,
72
- options: provider.scope !== void 0 ? { lifecycle: provider.scope } : void 0
73
- };
74
- if ("useValue" in provider) return {
75
- token: provider.provide,
76
- useValue: provider.useValue
77
- };
78
- if ("useFactory" in provider) {
79
- const { provide, useFactory, inject = [] } = provider;
80
- return {
81
- token: provide,
82
- useFactory: instancePerContainerCachingFactory((dependencyContainer) => {
83
- return useFactory(...inject.map((token) => dependencyContainer.resolve(token)));
84
- })
85
- };
86
- }
87
- if ("useExisting" in provider) return {
88
- token: provider.provide,
89
- useToken: provider.useExisting
90
- };
91
- throw new InvalidModuleProviderError(provider);
92
- });
93
- }
94
- //#endregion
95
- //#region src/rate-limiter/errors.ts
96
- /**
97
- * Thrown when a request exceeds a configured rate limit.
98
- *
99
- * HTTP Status: 429 Too Many Requests
100
- * Error Code: 4290
101
- *
102
- * The {@link ExceptionHandler} renders the body via content negotiation
103
- * (HTML for HTML clients, JSON for everything else). Standard rate-limit
104
- * headers (`Retry-After`, `X-RateLimit-*`) are injected by the
105
- * `respond()` callback registered via `RateLimiterModule.onException`.
106
- */
107
- var TooManyRequestsError = class extends HttpException {
108
- constructor(info) {
109
- super(429, "errors.rateLimit.tooManyRequests");
110
- this.info = info;
111
- }
112
- };
113
- /**
114
- * Thrown when `RateLimiterRegistry.handle(name, ...)` is invoked for a
115
- * name that was never registered via `.for()`.
116
- *
117
- * Most likely cause: a typo in `router.throttle('foo')` or `@RateLimit('foo')`,
118
- * or the module that registers the limiter is missing from imports.
119
- */
120
- var RateLimiterNotDefinedError = class extends ApplicationError {
121
- constructor(limiterName) {
122
- super("errors.rateLimit.notDefined", ERROR_CODES.SYSTEM.CONFIGURATION_ERROR, { name: limiterName });
123
- this.limiterName = limiterName;
124
- }
125
- };
126
- /**
127
- * Thrown by `RateLimiterStoreFactory.create()` (during the module's eager
128
- * `onInitialize` validation) when the user imported `RateLimiterModule`
129
- * without calling `.forRoot({ store: ... })`. There is no implicit default
130
- * store — the user must pick one.
131
- */
132
- var RateLimiterNotConfiguredError = class extends HttpException {
133
- constructor() {
134
- super(500, "errors.rateLimit.notConfigured");
135
- }
136
- };
137
- /**
138
- * Thrown when a throttled route fires but `RateLimiterModule` was never
139
- * imported in the user's AppModule (so the registry token is unbound).
140
- *
141
- * Distinct from {@link RateLimiterNotConfiguredError}, which fires when
142
- * the module IS imported but `forRoot` was not called.
143
- */
144
- var RateLimiterModuleNotImportedError = class extends ApplicationError {
145
- constructor(limiterName) {
146
- super("errors.rateLimit.moduleNotImported", ERROR_CODES.SYSTEM.CONFIGURATION_ERROR, { name: limiterName });
147
- this.limiterName = limiterName;
148
- }
149
- };
150
- //#endregion
151
- //#region src/rate-limiter/rate-limiter.tokens.ts
152
- const RATE_LIMITER_TOKENS = {
153
- Registry: Symbol.for("stratal:rate-limiter:registry"),
154
- Store: Symbol.for("stratal:rate-limiter:store"),
155
- StoreFactory: Symbol.for("stratal:rate-limiter:store-factory"),
156
- Options: Symbol.for("stratal:rate-limiter:options"),
157
- /**
158
- * Per-app marker registered by RateLimiterModule.onInitialize. Used by
159
- * ThrottleMiddleware to detect "module not imported" — the @Module
160
- * decorator globally registers providers via tsyringe's registry(),
161
- * so the Registry/Store tokens are globally bound the moment the module
162
- * file is loaded. The only way to confirm the module was actually wired
163
- * into the *user's* AppModule is to look for an artifact registered
164
- * inside the user's app container (not the root container).
165
- */
166
- ModuleMarker: Symbol.for("stratal:rate-limiter:module-marker")
167
- };
168
- //#endregion
169
- //#region src/rate-limiter/throttle.middleware.ts
170
- const cache = /* @__PURE__ */ new Map();
171
- /**
172
- * Memoized factory that produces a Stratal `Middleware` class bound to a
173
- * named limiter. Calling twice with the same name returns the *same* class
174
- * — important for `Router.middleware` deduplication via class identity.
175
- *
176
- * Detection of "module not imported" works against a per-app marker
177
- * registered by `RateLimiterModule.onInitialize` (NOT via inject decorator,
178
- * because tsyringe would still try to construct Registry — whose Store
179
- * inject would explode with a less-actionable tsyringe wrapping). We hold
180
- * the user's container, then check `isRegistered(marker, recursive=true)`
181
- * at request time before resolving Registry.
182
- */
183
- function createThrottleMiddleware(name) {
184
- const existing = cache.get(name);
185
- if (existing) return existing;
186
- let ThrottleMiddleware = class ThrottleMiddleware {
187
- constructor(container) {
188
- this.container = container;
189
- }
190
- handle(ctx, next) {
191
- if (!this.container.getTsyringeContainer().isRegistered(RATE_LIMITER_TOKENS.ModuleMarker, true)) throw new RateLimiterModuleNotImportedError(name);
192
- return this.container.resolve(RATE_LIMITER_TOKENS.Registry).handle(name, ctx, next);
193
- }
194
- };
195
- ThrottleMiddleware = __decorate([
196
- Transient(),
197
- __decorateParam(0, inject(CONTAINER_TOKEN)),
198
- __decorateMetadata("design:paramtypes", [Object])
199
- ], ThrottleMiddleware);
200
- Object.defineProperty(ThrottleMiddleware, "name", { value: `Throttle(${name})` });
201
- cache.set(name, ThrottleMiddleware);
202
- return ThrottleMiddleware;
203
- }
204
- //#endregion
205
- //#region src/router/errors/controller-method-not-found.error.ts
206
- /**
207
- * ControllerMethodNotFoundError
208
- *
209
- * Thrown when a controller method is registered but doesn't exist on the controller instance.
210
- * This typically indicates a mismatch between route registration and controller implementation.
211
- */
212
- var ControllerMethodNotFoundError = class extends ApplicationError {
213
- constructor(methodName, controllerName) {
214
- super("errors.controllerMethodNotFound", ERROR_CODES.ROUTER.CONTROLLER_METHOD_NOT_FOUND, {
215
- methodName,
216
- controllerName
217
- });
218
- }
219
- };
220
- //#endregion
221
- //#region src/router/errors/controller-registration.error.ts
222
- /**
223
- * Error thrown when a controller fails to register
224
- *
225
- * This typically happens when:
226
- * - Controller is missing the `@Controller` decorator
227
- * - Controller route metadata is not set
228
- * - Controller class name is invalid
229
- *
230
- * Error Code: 9005
231
- */
232
- var ControllerRegistrationError = class extends ApplicationError {
233
- constructor(controllerName, reason) {
234
- super("errors.controllerRegistration", ERROR_CODES.ROUTER.CONTROLLER_REGISTRATION_ERROR, {
235
- controllerName,
236
- reason
237
- });
238
- }
239
- };
240
- //#endregion
241
- //#region src/router/errors/hono-app-already-configured.error.ts
242
- /**
243
- * Error thrown when HonoApp.configure() is called more than once.
244
- *
245
- * HonoApp can only be configured a single time during application bootstrap.
246
- */
247
- var HonoAppAlreadyConfiguredError = class extends ApplicationError {
248
- constructor() {
249
- super("errors.honoAppAlreadyConfigured", ERROR_CODES.SYSTEM.CONFIGURATION_ERROR);
250
- }
251
- };
252
- //#endregion
253
- //#region src/router/errors/openapi-route-registration.error.ts
254
- /**
255
- * OpenAPIRouteRegistrationError
256
- *
257
- * Thrown when an OpenAPI route fails to register properly
258
- * This indicates a configuration issue with route decorators or metadata
259
- * Uses i18n key for localized error messages
260
- *
261
- * @example
262
- * ```typescript
263
- * throw new OpenAPIRouteRegistrationError('/api/v1/users', 'Missing response schema')
264
- * ```
265
- */
266
- var OpenAPIRouteRegistrationError = class extends ApplicationError {
267
- constructor(path, reason) {
268
- super("errors.openapiRouteRegistration", ERROR_CODES.ROUTER.OPENAPI_ROUTE_REGISTRATION, {
269
- path,
270
- reason
271
- });
272
- }
273
- };
274
- //#endregion
275
- //#region src/router/errors/openapi-validation.error.ts
276
- /**
277
- * OpenAPIValidationError
278
- *
279
- * Thrown when OpenAPI request/response validation fails
280
- * Uses i18n key for localized error messages
281
- *
282
- * HTTP Status: 400 Bad Request
283
- * Error Code: 1004
284
- *
285
- * @example
286
- * ```typescript
287
- * throw new OpenAPIValidationError('Request body missing required field: email')
288
- * ```
289
- */
290
- var OpenAPIValidationError = class extends ApplicationError {
291
- constructor(details) {
292
- super("errors.openapiValidation", ERROR_CODES.VALIDATION.REQUEST_VALIDATION, { details });
293
- }
294
- };
295
- //#endregion
296
- //#region src/router/errors/route-not-found.error.ts
297
- /**
298
- * Error thrown when a requested route is not found
299
- *
300
- * HTTP Status: 404 Not Found
301
- * Error Code: 4004
302
- */
303
- var RouteNotFoundError = class extends ApplicationError {
304
- constructor(path, method) {
305
- super("errors.routeNotFound", ERROR_CODES.RESOURCE.ROUTE_NOT_FOUND, {
306
- path,
307
- method
308
- });
309
- }
310
- };
311
- //#endregion
312
- //#region src/router/errors/schema-validation.error.ts
313
- /**
314
- * SchemaValidationError
315
- *
316
- * Thrown when Zod schema validation fails
317
- */
318
- var SchemaValidationError = class extends ApplicationError {
319
- constructor(zodError) {
320
- const issues = zodError.issues.map((err) => ({
321
- path: err.path.join("."),
322
- message: err.message,
323
- code: err.code
324
- }));
325
- super("errors.schemaValidation", ERROR_CODES.VALIDATION.SCHEMA_VALIDATION, { issues });
326
- }
327
- };
328
- //#endregion
329
- //#region src/router/errors/index.ts
330
- /**
331
- * Error thrown when a request's host header does not match the expected domain pattern.
332
- *
333
- * HTTP Status: 404 Not Found
334
- */
335
- var DomainMismatchError = class extends HttpException {
336
- constructor() {
337
- super(404, "errors.domainMismatch");
338
- }
339
- };
340
- /**
341
- * Thrown when registering a named route that conflicts with an existing route name.
342
- *
343
- * Error Code: 9010
344
- */
345
- var DuplicateRouteNameError = class extends ApplicationError {
346
- constructor(name, existingHandler, newHandler) {
347
- super("errors.duplicateRouteName", ERROR_CODES.ROUTER.DUPLICATE_ROUTE_NAME, {
348
- name,
349
- existingHandler,
350
- newHandler
351
- });
352
- }
353
- };
354
- /**
355
- * Error thrown when a signed URL has an invalid or expired signature.
356
- *
357
- * HTTP Status: 403 Forbidden
358
- */
359
- var InvalidSignatureError = class extends HttpException {
360
- constructor() {
361
- super(403, "errors.invalidSignature");
362
- }
363
- };
364
- /**
365
- * Thrown when a required environment variable is not set.
366
- *
367
- * Maps to HTTP 500 via error code range (9xxx → 500).
368
- */
369
- var MissingEnvironmentVariableError = class extends ApplicationError {
370
- constructor(variable) {
371
- super("errors.missingEnvironmentVariable", ERROR_CODES.SYSTEM.MISSING_ENVIRONMENT_VARIABLE, { variable });
372
- }
373
- };
374
- /**
375
- * Thrown when a required path or domain parameter is missing during URL generation.
376
- *
377
- * Error Code: 9012
378
- */
379
- var MissingRouteParamError = class extends ApplicationError {
380
- constructor(param, name, path) {
381
- super("errors.missingRouteParam", ERROR_CODES.ROUTER.MISSING_ROUTE_PARAM, {
382
- param,
383
- name,
384
- path
385
- });
386
- }
387
- };
388
- /**
389
- * ResponseValidationError
390
- *
391
- * Thrown when a controller's response body does not match the declared Zod response schema.
392
- * Indicates a server-side schema mismatch — the controller is returning data that
393
- * violates its own API contract.
394
- */
395
- var ResponseValidationError = class extends ApplicationError {
396
- constructor(zodError) {
397
- const issues = zodError.issues.map((err) => ({
398
- path: err.path.join("."),
399
- message: err.message,
400
- code: err.code
401
- }));
402
- super("errors.responseValidation", ERROR_CODES.VALIDATION.RESPONSE_VALIDATION, { issues });
403
- }
404
- };
405
- /**
406
- * Thrown when attempting to generate a URL for a route name that doesn't exist in the registry.
407
- *
408
- * Error Code: 9011
409
- */
410
- var RouteNameNotFoundError = class extends ApplicationError {
411
- constructor(name) {
412
- super("errors.routeNameNotFound", ERROR_CODES.ROUTER.ROUTE_NAME_NOT_FOUND, { name });
413
- }
414
- };
415
- /**
416
- * Thrown when `router.use()` is called inside a `group()` callback.
417
- * `use()` registers global middleware and is only allowed on the root Router.
418
- *
419
- * Error Code: 9013
420
- */
421
- var RouterUseScopeError = class extends ApplicationError {
422
- constructor() {
423
- super("errors.routerUseScopeViolation", ERROR_CODES.ROUTER.USE_SCOPE_VIOLATION);
424
- }
425
- };
426
- /**
427
- * Thrown when a middleware calls next() more than once.
428
- * This is a programming error — each middleware must call next() at most once.
429
- *
430
- * Error Code: 9014
431
- */
432
- var MiddlewareNextCalledMultipleTimesError = class extends ApplicationError {
433
- constructor(middlewareName) {
434
- super("errors.middlewareNextCalledMultipleTimes", ERROR_CODES.ROUTER.MIDDLEWARE_NEXT_CALLED_MULTIPLE_TIMES, { middlewareName });
435
- }
436
- };
437
- //#endregion
438
- //#region src/router/router.internals.ts
439
- /**
440
- * Symbol keys for Router internal accessors.
441
- *
442
- * These symbols are NOT exported from the public `stratal/router` barrel.
443
- * Only internal modules (RouterResolver) import them, keeping the Router's
444
- * public API clean — users never see these methods.
445
- *
446
- * Declared as individual unique symbols so TypeScript can distinguish
447
- * their return types in computed property access.
448
- *
449
- * @internal
450
- */
451
- /** @internal */
452
- const getDefaultEntry = Symbol("Router.getDefaultEntry");
453
- /** @internal */
454
- const getGroups = Symbol("Router.getGroups");
455
- /** @internal */
456
- const getGlobalMiddleware = Symbol("Router.getGlobalMiddleware");
457
- //#endregion
458
- //#region src/router/router.ts
459
- /**
460
- * Fluent builder for route and middleware configuration.
461
- *
462
- * Scoped methods (`middleware()`, `prefix()`, `domain()`, `name()`, `version()`, `hideFromDocs()`)
463
- * apply only to this module's controllers or the sub-group's controllers.
464
- *
465
- * `use()` registers global middleware (all routes in the entire app).
466
- * Only callable on the root Router — throws inside `group()` callbacks.
467
- *
468
- * `group()` creates sub-groups for specific controllers with a callback.
469
- * Controllers in a sub-group are excluded from the parent scope.
470
- */
471
- var Router = class Router {
472
- _isChild;
473
- _defaultEntry = { middleware: [] };
474
- _groups = [];
475
- _globalMiddleware = [];
476
- constructor(isChild = false) {
477
- this._isChild = isChild;
478
- }
479
- /** Dynamic path prefix. For shared segments like `/:companyId` */
480
- prefix(path, params) {
481
- this._defaultEntry.prefix = path;
482
- this._defaultEntry.params = params;
483
- return this;
484
- }
485
- /** Domain pattern for controllers in this scope */
486
- domain(pattern) {
487
- this._defaultEntry.domain = pattern;
488
- return this;
489
- }
490
- /** Name prefix for routes in this scope */
491
- name(prefix) {
492
- this._defaultEntry.name = prefix;
493
- return this;
494
- }
495
- /** Middleware applied to controllers in this scope */
496
- middleware(...middlewares) {
497
- this._defaultEntry.middleware.push(...middlewares);
498
- return this;
499
- }
500
- /**
501
- * Apply a named rate limiter to controllers in this scope.
502
- *
503
- * The named limiter must be registered via `RateLimiterRegistry.for(name, ...)`
504
- * (typically inside a module's `onInitialize` hook), and the user must
505
- * import `RateLimiterModule.forRoot({ store: ... })` in their AppModule.
506
- *
507
- * @example
508
- * ```typescript
509
- * router.prefix('/uploads').throttle('uploads')
510
- * router.group([AdminController], (admin) => admin.throttle('admin'))
511
- * ```
512
- */
513
- throttle(name) {
514
- this._defaultEntry.middleware.push(createThrottleMiddleware(name));
515
- return this;
516
- }
517
- /** API version for controllers in this scope */
518
- version(version) {
519
- this._defaultEntry.version = version;
520
- return this;
521
- }
522
- /** Hide/show routes in this scope from OpenAPI docs */
523
- hideFromDocs(hide = true) {
524
- this._defaultEntry.hideFromDocs = hide;
525
- return this;
526
- }
527
- /**
528
- * Global middleware — applied to ALL routes in the entire app.
529
- * Only callable on the root Router. Throws if called inside `group()`.
530
- */
531
- use(...middlewares) {
532
- if (this._isChild) throw new RouterUseScopeError();
533
- this._globalMiddleware.push(...middlewares);
534
- return this;
535
- }
536
- /**
537
- * Create a sub-group for specific controllers/gateways.
538
- * Controllers in a sub-group are excluded from the parent (default) scope.
539
- * The callback receives a new Router (without `use()`) for fluent configuration.
540
- */
541
- group(controllers, callback) {
542
- const childRouter = new Router(true);
543
- callback(childRouter);
544
- this._groups.push({
545
- ...childRouter._defaultEntry,
546
- controllers
547
- });
548
- return this;
549
- }
550
- [getDefaultEntry]() {
551
- return this._defaultEntry;
552
- }
553
- [getGroups]() {
554
- return this._groups;
555
- }
556
- [getGlobalMiddleware]() {
557
- return this._globalMiddleware;
558
- }
559
- };
560
- //#endregion
561
- //#region src/module/module-registry.ts
562
- /**
563
- * Module Registry
564
- *
565
- * Manages module lifecycle for the @Module decorator pattern.
566
- * Simplified for tsyringe's flat container model:
567
- * - Imports are traversed for registration (organization only)
568
- * - Modules registered in declaration order
569
- * - Lifecycle hooks: onInitialize, onShutdown
570
- */
571
- /**
572
- * ModuleRegistry - manages module lifecycle
573
- *
574
- * @example
575
- * ```typescript
576
- * const registry = new ModuleRegistry(container, logger)
577
- * registry.register(AppModule) // Traverses imports recursively
578
- * await registry.initialize()
579
- * // ... application running ...
580
- * await registry.shutdown()
581
- * ```
582
- */
583
- var ModuleRegistry = class {
584
- modules = [];
585
- registeredClasses = /* @__PURE__ */ new Set();
586
- initialized = false;
587
- allControllers = [];
588
- allConsumers = [];
589
- allJobs = [];
590
- allListeners = [];
591
- allCommands = [];
592
- allSeeders = [];
593
- allRouterConfigs = [];
594
- constructor(container, logger) {
595
- this.container = container;
596
- this.logger = logger;
597
- }
598
- /**
599
- * Register a module (static or dynamic)
600
- *
601
- * @param moduleOrDynamic - Module class decorated with `@Module` or DynamicModule from configure()
602
- */
603
- register(moduleOrDynamic) {
604
- const { moduleClass, options } = this.resolveModule(moduleOrDynamic);
605
- const isDynamic = this.isDynamicModule(moduleOrDynamic);
606
- if (this.registeredClasses.has(moduleClass)) {
607
- if (isDynamic) {
608
- this.logger.debug(`Module ${moduleClass.name} already registered, registering DynamicModule providers`);
609
- const { module: _, ...dynamicRest } = moduleOrDynamic;
610
- for (const provider of dynamicRest.providers ?? []) this.registerProvider(provider);
611
- } else this.logger.debug(`Module ${moduleClass.name} already registered, skipping`);
612
- return;
613
- }
614
- this.registeredClasses.add(moduleClass);
615
- this.logger.info(`Registering module: ${moduleClass.name}`);
616
- for (const ImportedModule of options.imports ?? []) this.register(ImportedModule);
617
- for (const provider of options.providers ?? []) this.registerProvider(provider);
618
- for (const controller of options.controllers ?? []) {
619
- this.container.register(controller);
620
- this.allControllers.push(controller);
621
- }
622
- for (const consumer of options.consumers ?? []) {
623
- this.container.register(consumer, Scope.Singleton);
624
- this.allConsumers.push(consumer);
625
- this.logger.info(`Collected consumer: ${consumer.name}`, { queueCount: this.allConsumers.length });
626
- }
627
- for (const job of options.jobs ?? []) {
628
- this.container.register(job, Scope.Singleton);
629
- this.allJobs.push(job);
630
- }
631
- this.modules.push({
632
- moduleClass,
633
- options,
634
- instance: null
635
- });
636
- }
637
- /**
638
- * Register multiple modules in order
639
- */
640
- registerAll(modules) {
641
- for (const module of modules) this.register(module);
642
- }
643
- /**
644
- * Initialize all modules (call configure and onInitialize hooks)
645
- */
646
- async initialize() {
647
- if (this.initialized) return;
648
- this.logger.info("Initializing modules...");
649
- const context = {
650
- container: this.container,
651
- logger: this.logger
652
- };
653
- for (const registered of this.modules) {
654
- const instance = new registered.moduleClass();
655
- registered.instance = instance;
656
- if (this.hasOnInitialize(instance)) {
657
- this.logger.info(`Initializing: ${registered.moduleClass.name}`);
658
- await instance.onInitialize(context);
659
- }
660
- }
661
- this.initialized = true;
662
- this.logger.info("All modules initialized");
663
- }
664
- /**
665
- * Get all controllers registered from all modules
666
- */
667
- getAllControllers() {
668
- return this.allControllers;
669
- }
670
- /**
671
- * Get all consumers registered from all modules
672
- */
673
- getAllConsumers() {
674
- return this.allConsumers;
675
- }
676
- /**
677
- * Get all jobs registered from all modules
678
- */
679
- getAllJobs() {
680
- return this.allJobs;
681
- }
682
- /**
683
- * Get all listeners registered from all modules
684
- */
685
- getAllListeners() {
686
- return this.allListeners;
687
- }
688
- /**
689
- * Get all commands registered from all modules
690
- */
691
- getAllCommands() {
692
- return this.allCommands;
693
- }
694
- /**
695
- * Get all seeders registered from all modules
696
- */
697
- getAllSeeders() {
698
- return this.allSeeders;
699
- }
700
- /**
701
- * Get all Router configurations from modules implementing RouteConfigurable.
702
- * Runs configureRoutes() lazily on first call (deferred from initialize()).
703
- */
704
- getAllRouterConfigs() {
705
- if (this.allRouterConfigs.length === 0) {
706
- for (const { moduleClass, options, instance } of this.modules) if (instance && this.hasRouteConfigurable(instance)) {
707
- this.logger.debug(`Configuring routes for: ${moduleClass.name}`);
708
- const router = new Router();
709
- instance.configureRoutes(router);
710
- const moduleControllers = options.controllers ?? [];
711
- this.allRouterConfigs.push({
712
- router,
713
- controllers: moduleControllers
714
- });
715
- }
716
- }
717
- return this.allRouterConfigs;
718
- }
719
- /**
720
- * Call `onException()` on all modules that implement the OnException interface.
721
- * Invoked by Application after the ExceptionHandler is resolved and `register()` is called.
722
- *
723
- * @param handler - The resolved ExceptionHandler instance
724
- */
725
- configureExceptionHandlers(handler) {
726
- for (const { moduleClass, instance } of this.modules) if (instance && this.hasOnException(instance)) {
727
- this.logger.debug(`Configuring exception handlers for: ${moduleClass.name}`);
728
- instance.onException(handler);
729
- }
730
- }
731
- /**
732
- * Shutdown all modules (call onShutdown hooks in reverse order)
733
- */
734
- async shutdown() {
735
- this.logger.info("Shutting down modules...");
736
- const context = {
737
- container: this.container,
738
- logger: this.logger
739
- };
740
- const reversed = [...this.modules].reverse();
741
- for (const { moduleClass, instance } of reversed) if (instance && this.hasOnShutdown(instance)) try {
742
- await instance.onShutdown(context);
743
- } catch (error) {
744
- this.logger.error(`Error shutting down ${moduleClass.name}:`, error);
745
- }
746
- this.logger.info("All modules shut down");
747
- }
748
- /**
749
- * Type guard for RouteConfigurable
750
- */
751
- hasRouteConfigurable(instance) {
752
- return typeof instance === "object" && instance !== null && "configureRoutes" in instance && typeof instance.configureRoutes === "function";
753
- }
754
- /**
755
- * Type guard for OnInitialize
756
- */
757
- hasOnInitialize(instance) {
758
- return typeof instance === "object" && instance !== null && "onInitialize" in instance && typeof instance.onInitialize === "function";
759
- }
760
- /**
761
- * Type guard for OnShutdown
762
- */
763
- hasOnShutdown(instance) {
764
- return typeof instance === "object" && instance !== null && "onShutdown" in instance && typeof instance.onShutdown === "function";
765
- }
766
- /**
767
- * Type guard for OnException
768
- */
769
- hasOnException(instance) {
770
- return typeof instance === "object" && instance !== null && "onException" in instance && typeof instance.onException === "function";
771
- }
772
- /**
773
- * Resolve module class and options from static or dynamic module
774
- *
775
- * For DynamicModules, merges the decorator metadata (consumers, controllers, jobs)
776
- * with the DynamicModule options (providers, imports). This ensures modules using
777
- * forRoot/forRootAsync patterns still have their decorator-defined consumers registered.
778
- */
779
- resolveModule(moduleOrDynamic) {
780
- if (this.isDynamicModule(moduleOrDynamic)) {
781
- const { module: moduleClass, ...dynamicRest } = moduleOrDynamic;
782
- const decoratorOptions = getModuleOptions(moduleClass) ?? {};
783
- return {
784
- moduleClass,
785
- options: {
786
- ...decoratorOptions,
787
- ...dynamicRest,
788
- providers: [...decoratorOptions.providers ?? [], ...dynamicRest.providers ?? []],
789
- imports: [...decoratorOptions.imports ?? []]
790
- }
791
- };
792
- }
793
- const moduleClass = moduleOrDynamic;
794
- return {
795
- moduleClass,
796
- options: getModuleOptions(moduleClass) ?? {}
797
- };
798
- }
799
- /**
800
- * Type guard for DynamicModule
801
- */
802
- isDynamicModule(value) {
803
- return typeof value === "object" && value !== null && "module" in value && typeof value.module === "function";
804
- }
805
- /**
806
- * Register a single provider in the container
807
- */
808
- registerProvider(provider) {
809
- if (typeof provider === "function") {
810
- this.container.register(provider);
811
- this.collectIfListener(provider);
812
- this.collectIfCommand(provider);
813
- this.collectIfSeeder(provider);
814
- } else if ("useClass" in provider) {
815
- this.container.register(provider.provide, provider.useClass, provider.scope);
816
- this.collectIfListener(provider.useClass);
817
- this.collectIfCommand(provider.useClass);
818
- this.collectIfSeeder(provider.useClass);
819
- } else if ("useValue" in provider) this.container.registerValue(provider.provide, provider.useValue);
820
- else if ("useFactory" in provider) {
821
- const { provide, useFactory, inject = [] } = provider;
822
- this.container.getTsyringeContainer().register(provide, { useFactory: instancePerContainerCachingFactory((dependencyContainer) => {
823
- return useFactory(...inject.map((token) => dependencyContainer.resolve(token)));
824
- }) });
825
- } else if ("useExisting" in provider) this.container.registerExisting(provider.provide, provider.useExisting);
826
- }
827
- /**
828
- * Check if a class is a `Command` and collect it for auto-wiring
829
- */
830
- collectIfCommand(providerClass) {
831
- if (isCommand(providerClass) && !this.allCommands.includes(providerClass)) {
832
- injectable()(providerClass);
833
- this.allCommands.push(providerClass);
834
- this.logger.debug(`Collected command: ${providerClass.name}`);
835
- }
836
- }
837
- /**
838
- * Check if a class is a `Seeder` and collect it for auto-wiring
839
- */
840
- collectIfSeeder(providerClass) {
841
- if (isSeeder(providerClass) && !this.allSeeders.includes(providerClass)) {
842
- this.allSeeders.push(providerClass);
843
- this.logger.debug(`Collected seeder: ${providerClass.name}`);
844
- }
845
- }
846
- /**
847
- * Check if a class is a `@Listener()` and collect it for auto-wiring
848
- */
849
- collectIfListener(providerClass) {
850
- if (isListener(providerClass)) {
851
- this.container.register(providerClass, providerClass, Scope.Singleton);
852
- this.allListeners.push(providerClass);
853
- this.logger.debug(`Collected listener: ${providerClass.name}`);
854
- }
855
- }
856
- };
857
- //#endregion
858
- export { getModuleOptions as A, RATE_LIMITER_TOKENS as C, TooManyRequestsError as D, RateLimiterNotDefinedError as E, MODULE_OPTIONS_KEY as O, createThrottleMiddleware as S, RateLimiterNotConfiguredError as T, OpenAPIValidationError as _, getGroups as a, ControllerRegistrationError as b, InvalidSignatureError as c, MissingRouteParamError as d, ResponseValidationError as f, RouteNotFoundError as g, SchemaValidationError as h, getGlobalMiddleware as i, isModuleClass as j, Module as k, MiddlewareNextCalledMultipleTimesError as l, RouterUseScopeError as m, Router as n, DomainMismatchError as o, RouteNameNotFoundError as p, getDefaultEntry as r, DuplicateRouteNameError as s, ModuleRegistry as t, MissingEnvironmentVariableError as u, OpenAPIRouteRegistrationError as v, RateLimiterModuleNotImportedError as w, ControllerMethodNotFoundError as x, HonoAppAlreadyConfiguredError as y };
859
-
860
- //# sourceMappingURL=module-Dk2qTa77.mjs.map