@azurioh/discord-kernel 0.1.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 (373) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -0
  3. package/dist/authz/authorizer.d.ts +45 -0
  4. package/dist/authz/authorizer.d.ts.map +1 -0
  5. package/dist/authz/authorizer.js +31 -0
  6. package/dist/authz/authorizer.js.map +1 -0
  7. package/dist/authz/require-level-guard.d.ts +23 -0
  8. package/dist/authz/require-level-guard.d.ts.map +1 -0
  9. package/dist/authz/require-level-guard.js +37 -0
  10. package/dist/authz/require-level-guard.js.map +1 -0
  11. package/dist/clock.d.ts +13 -0
  12. package/dist/clock.d.ts.map +1 -0
  13. package/dist/clock.js +13 -0
  14. package/dist/clock.js.map +1 -0
  15. package/dist/concurrency/keyed-queue.d.ts +18 -0
  16. package/dist/concurrency/keyed-queue.d.ts.map +1 -0
  17. package/dist/concurrency/keyed-queue.js +37 -0
  18. package/dist/concurrency/keyed-queue.js.map +1 -0
  19. package/dist/concurrency/run-with-concurrency.d.ts +15 -0
  20. package/dist/concurrency/run-with-concurrency.d.ts.map +1 -0
  21. package/dist/concurrency/run-with-concurrency.js +40 -0
  22. package/dist/concurrency/run-with-concurrency.js.map +1 -0
  23. package/dist/config/env.d.ts +17 -0
  24. package/dist/config/env.d.ts.map +1 -0
  25. package/dist/config/env.js +49 -0
  26. package/dist/config/env.js.map +1 -0
  27. package/dist/config/errors.d.ts +14 -0
  28. package/dist/config/errors.d.ts.map +1 -0
  29. package/dist/config/errors.js +25 -0
  30. package/dist/config/errors.js.map +1 -0
  31. package/dist/datetime.d.ts +34 -0
  32. package/dist/datetime.d.ts.map +1 -0
  33. package/dist/datetime.js +188 -0
  34. package/dist/datetime.js.map +1 -0
  35. package/dist/discord/api-errors.d.ts +20 -0
  36. package/dist/discord/api-errors.d.ts.map +1 -0
  37. package/dist/discord/api-errors.js +90 -0
  38. package/dist/discord/api-errors.js.map +1 -0
  39. package/dist/discord/channel-exporter.d.ts +42 -0
  40. package/dist/discord/channel-exporter.d.ts.map +1 -0
  41. package/dist/discord/channel-exporter.js +3 -0
  42. package/dist/discord/channel-exporter.js.map +1 -0
  43. package/dist/discord/command/autocomplete-dispatcher.d.ts +26 -0
  44. package/dist/discord/command/autocomplete-dispatcher.d.ts.map +1 -0
  45. package/dist/discord/command/autocomplete-dispatcher.js +41 -0
  46. package/dist/discord/command/autocomplete-dispatcher.js.map +1 -0
  47. package/dist/discord/command/autocomplete.d.ts +18 -0
  48. package/dist/discord/command/autocomplete.d.ts.map +1 -0
  49. package/dist/discord/command/autocomplete.js +65 -0
  50. package/dist/discord/command/autocomplete.js.map +1 -0
  51. package/dist/discord/command/context.d.ts +33 -0
  52. package/dist/discord/command/context.d.ts.map +1 -0
  53. package/dist/discord/command/context.js +48 -0
  54. package/dist/discord/command/context.js.map +1 -0
  55. package/dist/discord/command/cooldown-guard.d.ts +25 -0
  56. package/dist/discord/command/cooldown-guard.d.ts.map +1 -0
  57. package/dist/discord/command/cooldown-guard.js +60 -0
  58. package/dist/discord/command/cooldown-guard.js.map +1 -0
  59. package/dist/discord/command/create-command.d.ts +100 -0
  60. package/dist/discord/command/create-command.d.ts.map +1 -0
  61. package/dist/discord/command/create-command.js +245 -0
  62. package/dist/discord/command/create-command.js.map +1 -0
  63. package/dist/discord/command/create-context-menu-command.d.ts +51 -0
  64. package/dist/discord/command/create-context-menu-command.d.ts.map +1 -0
  65. package/dist/discord/command/create-context-menu-command.js +128 -0
  66. package/dist/discord/command/create-context-menu-command.js.map +1 -0
  67. package/dist/discord/command/errors.d.ts +19 -0
  68. package/dist/discord/command/errors.d.ts.map +1 -0
  69. package/dist/discord/command/errors.js +27 -0
  70. package/dist/discord/command/errors.js.map +1 -0
  71. package/dist/discord/command/guard.d.ts +30 -0
  72. package/dist/discord/command/guard.d.ts.map +1 -0
  73. package/dist/discord/command/guard.js +34 -0
  74. package/dist/discord/command/guard.js.map +1 -0
  75. package/dist/discord/command/localization.d.ts +9 -0
  76. package/dist/discord/command/localization.d.ts.map +1 -0
  77. package/dist/discord/command/localization.js +13 -0
  78. package/dist/discord/command/localization.js.map +1 -0
  79. package/dist/discord/command/options.d.ts +113 -0
  80. package/dist/discord/command/options.d.ts.map +1 -0
  81. package/dist/discord/command/options.js +509 -0
  82. package/dist/discord/command/options.js.map +1 -0
  83. package/dist/discord/command/permission-guard.d.ts +21 -0
  84. package/dist/discord/command/permission-guard.d.ts.map +1 -0
  85. package/dist/discord/command/permission-guard.js +69 -0
  86. package/dist/discord/command/permission-guard.js.map +1 -0
  87. package/dist/discord/command/router.d.ts +48 -0
  88. package/dist/discord/command/router.d.ts.map +1 -0
  89. package/dist/discord/command/router.js +118 -0
  90. package/dist/discord/command/router.js.map +1 -0
  91. package/dist/discord/command/types.d.ts +51 -0
  92. package/dist/discord/command/types.d.ts.map +1 -0
  93. package/dist/discord/command/types.js +3 -0
  94. package/dist/discord/command/types.js.map +1 -0
  95. package/dist/discord/components/component-router.d.ts +116 -0
  96. package/dist/discord/components/component-router.d.ts.map +1 -0
  97. package/dist/discord/components/component-router.js +123 -0
  98. package/dist/discord/components/component-router.js.map +1 -0
  99. package/dist/discord/components/interactive-message/index.d.ts +3 -0
  100. package/dist/discord/components/interactive-message/index.d.ts.map +1 -0
  101. package/dist/discord/components/interactive-message/index.js +11 -0
  102. package/dist/discord/components/interactive-message/index.js.map +1 -0
  103. package/dist/discord/components/interactive-message/interactive-message-collector.d.ts +195 -0
  104. package/dist/discord/components/interactive-message/interactive-message-collector.d.ts.map +1 -0
  105. package/dist/discord/components/interactive-message/interactive-message-collector.js +151 -0
  106. package/dist/discord/components/interactive-message/interactive-message-collector.js.map +1 -0
  107. package/dist/discord/components/interactive-message/mount-interactive-message.d.ts +30 -0
  108. package/dist/discord/components/interactive-message/mount-interactive-message.d.ts.map +1 -0
  109. package/dist/discord/components/interactive-message/mount-interactive-message.js +44 -0
  110. package/dist/discord/components/interactive-message/mount-interactive-message.js.map +1 -0
  111. package/dist/discord/components/paginator/index.d.ts +5 -0
  112. package/dist/discord/components/paginator/index.d.ts.map +1 -0
  113. package/dist/discord/components/paginator/index.js +15 -0
  114. package/dist/discord/components/paginator/index.js.map +1 -0
  115. package/dist/discord/components/paginator/mount-paginator.d.ts +25 -0
  116. package/dist/discord/components/paginator/mount-paginator.d.ts.map +1 -0
  117. package/dist/discord/components/paginator/mount-paginator.js +41 -0
  118. package/dist/discord/components/paginator/mount-paginator.js.map +1 -0
  119. package/dist/discord/components/paginator/page-state.d.ts +21 -0
  120. package/dist/discord/components/paginator/page-state.d.ts.map +1 -0
  121. package/dist/discord/components/paginator/page-state.js +44 -0
  122. package/dist/discord/components/paginator/page-state.js.map +1 -0
  123. package/dist/discord/components/paginator/paginator-buttons.d.ts +17 -0
  124. package/dist/discord/components/paginator/paginator-buttons.d.ts.map +1 -0
  125. package/dist/discord/components/paginator/paginator-buttons.js +45 -0
  126. package/dist/discord/components/paginator/paginator-buttons.js.map +1 -0
  127. package/dist/discord/components/paginator/paginator-view.d.ts +26 -0
  128. package/dist/discord/components/paginator/paginator-view.d.ts.map +1 -0
  129. package/dist/discord/components/paginator/paginator-view.js +28 -0
  130. package/dist/discord/components/paginator/paginator-view.js.map +1 -0
  131. package/dist/discord/components/persistent-paginator.d.ts +47 -0
  132. package/dist/discord/components/persistent-paginator.d.ts.map +1 -0
  133. package/dist/discord/components/persistent-paginator.js +137 -0
  134. package/dist/discord/components/persistent-paginator.js.map +1 -0
  135. package/dist/discord/components/settings-editor/index.d.ts +7 -0
  136. package/dist/discord/components/settings-editor/index.d.ts.map +1 -0
  137. package/dist/discord/components/settings-editor/index.js +22 -0
  138. package/dist/discord/components/settings-editor/index.js.map +1 -0
  139. package/dist/discord/components/settings-editor/mount-settings-editor.d.ts +140 -0
  140. package/dist/discord/components/settings-editor/mount-settings-editor.d.ts.map +1 -0
  141. package/dist/discord/components/settings-editor/mount-settings-editor.js +344 -0
  142. package/dist/discord/components/settings-editor/mount-settings-editor.js.map +1 -0
  143. package/dist/discord/components/settings-editor/navigation.d.ts +49 -0
  144. package/dist/discord/components/settings-editor/navigation.d.ts.map +1 -0
  145. package/dist/discord/components/settings-editor/navigation.js +39 -0
  146. package/dist/discord/components/settings-editor/navigation.js.map +1 -0
  147. package/dist/discord/components/settings-editor/settings-editor-card.view.d.ts +56 -0
  148. package/dist/discord/components/settings-editor/settings-editor-card.view.d.ts.map +1 -0
  149. package/dist/discord/components/settings-editor/settings-editor-card.view.js +284 -0
  150. package/dist/discord/components/settings-editor/settings-editor-card.view.js.map +1 -0
  151. package/dist/discord/components/settings-editor/settings-editor-field-modal.d.ts +69 -0
  152. package/dist/discord/components/settings-editor/settings-editor-field-modal.d.ts.map +1 -0
  153. package/dist/discord/components/settings-editor/settings-editor-field-modal.js +353 -0
  154. package/dist/discord/components/settings-editor/settings-editor-field-modal.js.map +1 -0
  155. package/dist/discord/components/settings-editor/settings-editor-fields.d.ts +216 -0
  156. package/dist/discord/components/settings-editor/settings-editor-fields.d.ts.map +1 -0
  157. package/dist/discord/components/settings-editor/settings-editor-fields.js +66 -0
  158. package/dist/discord/components/settings-editor/settings-editor-fields.js.map +1 -0
  159. package/dist/discord/components/settings-editor/settings-editor.view.d.ts +303 -0
  160. package/dist/discord/components/settings-editor/settings-editor.view.d.ts.map +1 -0
  161. package/dist/discord/components/settings-editor/settings-editor.view.js +316 -0
  162. package/dist/discord/components/settings-editor/settings-editor.view.js.map +1 -0
  163. package/dist/discord/events/create-event.d.ts +5 -0
  164. package/dist/discord/events/create-event.d.ts.map +1 -0
  165. package/dist/discord/events/create-event.js +8 -0
  166. package/dist/discord/events/create-event.js.map +1 -0
  167. package/dist/discord/events/event-router.d.ts +16 -0
  168. package/dist/discord/events/event-router.d.ts.map +1 -0
  169. package/dist/discord/events/event-router.js +51 -0
  170. package/dist/discord/events/event-router.js.map +1 -0
  171. package/dist/discord/events/types.d.ts +16 -0
  172. package/dist/discord/events/types.d.ts.map +1 -0
  173. package/dist/discord/events/types.js +3 -0
  174. package/dist/discord/events/types.js.map +1 -0
  175. package/dist/discord/i18n.d.ts +58 -0
  176. package/dist/discord/i18n.d.ts.map +1 -0
  177. package/dist/discord/i18n.js +173 -0
  178. package/dist/discord/i18n.js.map +1 -0
  179. package/dist/discord/interaction/button.d.ts +39 -0
  180. package/dist/discord/interaction/button.d.ts.map +1 -0
  181. package/dist/discord/interaction/button.js +36 -0
  182. package/dist/discord/interaction/button.js.map +1 -0
  183. package/dist/discord/interaction/interaction-router.d.ts +21 -0
  184. package/dist/discord/interaction/interaction-router.d.ts.map +1 -0
  185. package/dist/discord/interaction/interaction-router.js +24 -0
  186. package/dist/discord/interaction/interaction-router.js.map +1 -0
  187. package/dist/discord/interaction/modal.d.ts +171 -0
  188. package/dist/discord/interaction/modal.d.ts.map +1 -0
  189. package/dist/discord/interaction/modal.js +264 -0
  190. package/dist/discord/interaction/modal.js.map +1 -0
  191. package/dist/discord/interaction/select-menu.d.ts +104 -0
  192. package/dist/discord/interaction/select-menu.d.ts.map +1 -0
  193. package/dist/discord/interaction/select-menu.js +126 -0
  194. package/dist/discord/interaction/select-menu.js.map +1 -0
  195. package/dist/discord/permissions.d.ts +32 -0
  196. package/dist/discord/permissions.d.ts.map +1 -0
  197. package/dist/discord/permissions.js +40 -0
  198. package/dist/discord/permissions.js.map +1 -0
  199. package/dist/discord/placeholder-registry-errors.d.ts +10 -0
  200. package/dist/discord/placeholder-registry-errors.d.ts.map +1 -0
  201. package/dist/discord/placeholder-registry-errors.js +18 -0
  202. package/dist/discord/placeholder-registry-errors.js.map +1 -0
  203. package/dist/discord/placeholder-registry.d.ts +53 -0
  204. package/dist/discord/placeholder-registry.d.ts.map +1 -0
  205. package/dist/discord/placeholder-registry.js +52 -0
  206. package/dist/discord/placeholder-registry.js.map +1 -0
  207. package/dist/discord/presenter.d.ts +26 -0
  208. package/dist/discord/presenter.d.ts.map +1 -0
  209. package/dist/discord/presenter.js +3 -0
  210. package/dist/discord/presenter.js.map +1 -0
  211. package/dist/discord/ui/card.d.ts +114 -0
  212. package/dist/discord/ui/card.d.ts.map +1 -0
  213. package/dist/discord/ui/card.js +162 -0
  214. package/dist/discord/ui/card.js.map +1 -0
  215. package/dist/discord/ui/color-input-errors.d.ts +12 -0
  216. package/dist/discord/ui/color-input-errors.d.ts.map +1 -0
  217. package/dist/discord/ui/color-input-errors.js +21 -0
  218. package/dist/discord/ui/color-input-errors.js.map +1 -0
  219. package/dist/discord/ui/color-input.d.ts +37 -0
  220. package/dist/discord/ui/color-input.d.ts.map +1 -0
  221. package/dist/discord/ui/color-input.js +166 -0
  222. package/dist/discord/ui/color-input.js.map +1 -0
  223. package/dist/discord/ui/colors.d.ts +44 -0
  224. package/dist/discord/ui/colors.d.ts.map +1 -0
  225. package/dist/discord/ui/colors.js +45 -0
  226. package/dist/discord/ui/colors.js.map +1 -0
  227. package/dist/discord/ui/embed.d.ts +16 -0
  228. package/dist/discord/ui/embed.d.ts.map +1 -0
  229. package/dist/discord/ui/embed.js +53 -0
  230. package/dist/discord/ui/embed.js.map +1 -0
  231. package/dist/discord/ui/message-attachments.d.ts +40 -0
  232. package/dist/discord/ui/message-attachments.d.ts.map +1 -0
  233. package/dist/discord/ui/message-attachments.js +27 -0
  234. package/dist/discord/ui/message-attachments.js.map +1 -0
  235. package/dist/errors/business-error.d.ts +41 -0
  236. package/dist/errors/business-error.d.ts.map +1 -0
  237. package/dist/errors/business-error.js +39 -0
  238. package/dist/errors/business-error.js.map +1 -0
  239. package/dist/errors/describe-error.d.ts +29 -0
  240. package/dist/errors/describe-error.d.ts.map +1 -0
  241. package/dist/errors/describe-error.js +49 -0
  242. package/dist/errors/describe-error.js.map +1 -0
  243. package/dist/errors/incident-ref.d.ts +7 -0
  244. package/dist/errors/incident-ref.d.ts.map +1 -0
  245. package/dist/errors/incident-ref.js +13 -0
  246. package/dist/errors/incident-ref.js.map +1 -0
  247. package/dist/errors/index.d.ts +4 -0
  248. package/dist/errors/index.d.ts.map +1 -0
  249. package/dist/errors/index.js +15 -0
  250. package/dist/errors/index.js.map +1 -0
  251. package/dist/i18n/business-message.d.ts +14 -0
  252. package/dist/i18n/business-message.d.ts.map +1 -0
  253. package/dist/i18n/business-message.js +19 -0
  254. package/dist/i18n/business-message.js.map +1 -0
  255. package/dist/i18n/catalog.d.ts +27 -0
  256. package/dist/i18n/catalog.d.ts.map +1 -0
  257. package/dist/i18n/catalog.js +25 -0
  258. package/dist/i18n/catalog.js.map +1 -0
  259. package/dist/i18n/errors.d.ts +10 -0
  260. package/dist/i18n/errors.d.ts.map +1 -0
  261. package/dist/i18n/errors.js +18 -0
  262. package/dist/i18n/errors.js.map +1 -0
  263. package/dist/i18n/index.d.ts +6 -0
  264. package/dist/i18n/index.d.ts.map +1 -0
  265. package/dist/i18n/index.js +16 -0
  266. package/dist/i18n/index.js.map +1 -0
  267. package/dist/i18n/locale.d.ts +22 -0
  268. package/dist/i18n/locale.d.ts.map +1 -0
  269. package/dist/i18n/locale.js +40 -0
  270. package/dist/i18n/locale.js.map +1 -0
  271. package/dist/i18n/translator.d.ts +35 -0
  272. package/dist/i18n/translator.d.ts.map +1 -0
  273. package/dist/i18n/translator.js +40 -0
  274. package/dist/i18n/translator.js.map +1 -0
  275. package/dist/logger.d.ts +28 -0
  276. package/dist/logger.d.ts.map +1 -0
  277. package/dist/logger.js +3 -0
  278. package/dist/logger.js.map +1 -0
  279. package/dist/module/module.d.ts +42 -0
  280. package/dist/module/module.d.ts.map +1 -0
  281. package/dist/module/module.js +3 -0
  282. package/dist/module/module.js.map +1 -0
  283. package/dist/persistence/database.d.ts +24 -0
  284. package/dist/persistence/database.d.ts.map +1 -0
  285. package/dist/persistence/database.js +3 -0
  286. package/dist/persistence/database.js.map +1 -0
  287. package/dist/resilience/retry.d.ts +36 -0
  288. package/dist/resilience/retry.d.ts.map +1 -0
  289. package/dist/resilience/retry.js +78 -0
  290. package/dist/resilience/retry.js.map +1 -0
  291. package/dist/scheduler/errors.d.ts +25 -0
  292. package/dist/scheduler/errors.d.ts.map +1 -0
  293. package/dist/scheduler/errors.js +45 -0
  294. package/dist/scheduler/errors.js.map +1 -0
  295. package/dist/scheduler/scheduler.d.ts +68 -0
  296. package/dist/scheduler/scheduler.d.ts.map +1 -0
  297. package/dist/scheduler/scheduler.js +162 -0
  298. package/dist/scheduler/scheduler.js.map +1 -0
  299. package/package.json +89 -0
  300. package/src/authz/authorizer.ts +76 -0
  301. package/src/authz/require-level-guard.ts +42 -0
  302. package/src/clock.ts +18 -0
  303. package/src/concurrency/keyed-queue.ts +50 -0
  304. package/src/concurrency/run-with-concurrency.ts +44 -0
  305. package/src/config/env.ts +58 -0
  306. package/src/config/errors.ts +21 -0
  307. package/src/datetime.ts +221 -0
  308. package/src/discord/api-errors.ts +91 -0
  309. package/src/discord/channel-exporter.ts +48 -0
  310. package/src/discord/command/autocomplete-dispatcher.ts +54 -0
  311. package/src/discord/command/autocomplete.ts +76 -0
  312. package/src/discord/command/context.ts +85 -0
  313. package/src/discord/command/cooldown-guard.ts +81 -0
  314. package/src/discord/command/create-command.ts +431 -0
  315. package/src/discord/command/create-context-menu-command.ts +227 -0
  316. package/src/discord/command/errors.ts +22 -0
  317. package/src/discord/command/guard.ts +54 -0
  318. package/src/discord/command/localization.ts +11 -0
  319. package/src/discord/command/options.ts +847 -0
  320. package/src/discord/command/permission-guard.ts +74 -0
  321. package/src/discord/command/router.ts +142 -0
  322. package/src/discord/command/types.ts +52 -0
  323. package/src/discord/components/component-router.ts +213 -0
  324. package/src/discord/components/interactive-message/index.ts +18 -0
  325. package/src/discord/components/interactive-message/interactive-message-collector.ts +374 -0
  326. package/src/discord/components/interactive-message/mount-interactive-message.ts +71 -0
  327. package/src/discord/components/paginator/index.ts +17 -0
  328. package/src/discord/components/paginator/mount-paginator.ts +69 -0
  329. package/src/discord/components/paginator/page-state.ts +45 -0
  330. package/src/discord/components/paginator/paginator-buttons.ts +60 -0
  331. package/src/discord/components/paginator/paginator-view.ts +61 -0
  332. package/src/discord/components/persistent-paginator.ts +197 -0
  333. package/src/discord/components/settings-editor/index.ts +41 -0
  334. package/src/discord/components/settings-editor/mount-settings-editor.ts +646 -0
  335. package/src/discord/components/settings-editor/navigation.ts +67 -0
  336. package/src/discord/components/settings-editor/settings-editor-card.view.ts +344 -0
  337. package/src/discord/components/settings-editor/settings-editor-field-modal.ts +538 -0
  338. package/src/discord/components/settings-editor/settings-editor-fields.ts +290 -0
  339. package/src/discord/components/settings-editor/settings-editor.view.ts +654 -0
  340. package/src/discord/events/create-event.ts +7 -0
  341. package/src/discord/events/event-router.ts +53 -0
  342. package/src/discord/events/types.ts +17 -0
  343. package/src/discord/i18n.ts +173 -0
  344. package/src/discord/interaction/button.ts +75 -0
  345. package/src/discord/interaction/interaction-router.ts +28 -0
  346. package/src/discord/interaction/modal.ts +505 -0
  347. package/src/discord/interaction/select-menu.ts +246 -0
  348. package/src/discord/permissions.ts +57 -0
  349. package/src/discord/placeholder-registry-errors.ts +11 -0
  350. package/src/discord/placeholder-registry.ts +77 -0
  351. package/src/discord/presenter.ts +26 -0
  352. package/src/discord/ui/card.ts +303 -0
  353. package/src/discord/ui/color-input-errors.ts +17 -0
  354. package/src/discord/ui/color-input.ts +179 -0
  355. package/src/discord/ui/colors.ts +58 -0
  356. package/src/discord/ui/embed.ts +64 -0
  357. package/src/discord/ui/message-attachments.ts +57 -0
  358. package/src/errors/business-error.ts +49 -0
  359. package/src/errors/describe-error.ts +73 -0
  360. package/src/errors/incident-ref.ts +10 -0
  361. package/src/errors/index.ts +12 -0
  362. package/src/i18n/business-message.ts +23 -0
  363. package/src/i18n/catalog.ts +41 -0
  364. package/src/i18n/errors.ts +11 -0
  365. package/src/i18n/index.ts +11 -0
  366. package/src/i18n/locale.ts +41 -0
  367. package/src/i18n/translator.ts +78 -0
  368. package/src/logger.ts +28 -0
  369. package/src/module/module.ts +42 -0
  370. package/src/persistence/database.ts +23 -0
  371. package/src/resilience/retry.ts +102 -0
  372. package/src/scheduler/errors.ts +40 -0
  373. package/src/scheduler/scheduler.ts +248 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-attachments.d.ts","sourceRoot":"","sources":["../../../src/discord/ui/message-attachments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC3B;AAED,0DAA0D;AAC1D,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAED,yFAAyF;AACzF,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,CAAC;CAChC;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,aAAa,CAEhE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,SAAS,UAAU,EAAE,EAC/B,MAAM,EAAE,SAAS,WAAW,EAAE,GAC5B,kBAAkB,CAQpB"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toMessageUpload = toMessageUpload;
4
+ exports.planMessageAttachments = planMessageAttachments;
5
+ function toMessageUpload(file) {
6
+ return { attachment: Buffer.from(file.bytes), name: file.name };
7
+ }
8
+ /**
9
+ * Split what a message should carry into what is already up there and what has
10
+ * to be uploaded.
11
+ *
12
+ * Discord reads an edit's `attachments` field as the complete set the message
13
+ * keeps — so `attachments: []` strips whatever it was published with, and
14
+ * re-sending the bytes to hold on to a file would upload the same one again on
15
+ * every unrelated re-render. Existing attachments are matched by name because
16
+ * that is what an embed resolves `attachment://` on, so a file already up there
17
+ * under the wanted name is the very one to keep.
18
+ *
19
+ * A caller carrying no files of its own never reaches this: it states neither
20
+ * field, and Discord leaves the message's own alone.
21
+ */
22
+ function planMessageAttachments(existing, wanted) {
23
+ const kept = existing.filter((attachment) => wanted.some((file) => file.name === attachment.name));
24
+ const uploaded = wanted.filter((file) => !kept.some((attachment) => attachment.name === file.name));
25
+ return { attachments: kept, files: uploaded.map(toMessageUpload) };
26
+ }
27
+ //# sourceMappingURL=message-attachments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-attachments.js","sourceRoot":"","sources":["../../../src/discord/ui/message-attachments.ts"],"names":[],"mappings":";;AA2BA,0CAEC;AAgBD,wDAWC;AA7BD,SAAgB,eAAe,CAAC,IAAiB;IAChD,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;AACjE,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,sBAAsB,CACrC,QAA+B,EAC/B,MAA8B;IAE9B,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAC3C,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,CAAC,CACpD,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAC7B,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,CACnE,CAAC;IACF,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC;AACpE,CAAC"}
@@ -0,0 +1,41 @@
1
+ export type ErrorSeverity = "warning" | "error";
2
+ /**
3
+ * Optional catalog reference carried by a {@link BusinessError}. When present,
4
+ * the command pipeline renders the translated text for the interaction's
5
+ * locale; `message` stays the English source used for logs and as fallback.
6
+ * Declared structurally (not imported from `core/i18n`'s `LocalizedText`) to
7
+ * keep this file a pure error declaration; the shapes are checked compatible
8
+ * where the pipeline resolves it.
9
+ */
10
+ export interface ErrorTranslation {
11
+ readonly key: string;
12
+ readonly params?: Readonly<Record<string, string | number>>;
13
+ }
14
+ /**
15
+ * Base class for expected, user-facing errors. Anything that is NOT a
16
+ * {@link BusinessError} is treated as unexpected: it is logged with an incident
17
+ * reference and the user sees a generic message.
18
+ */
19
+ export declare abstract class BusinessError extends Error {
20
+ readonly translation?: ErrorTranslation | undefined;
21
+ abstract readonly severity: ErrorSeverity;
22
+ constructor(message: string, translation?: ErrorTranslation | undefined);
23
+ }
24
+ /** Benign business error (invalid input, missing resource, conflict). */
25
+ export declare class WarningError extends BusinessError {
26
+ readonly severity: "warning";
27
+ }
28
+ /** Serious business error that still carries a user-facing message. */
29
+ export declare class CriticalError extends BusinessError {
30
+ readonly severity: "error";
31
+ }
32
+ /** The referenced resource does not exist. */
33
+ export declare class NotFoundError extends WarningError {
34
+ }
35
+ /** User input failed validation. */
36
+ export declare class ValidationError extends WarningError {
37
+ }
38
+ /** The action conflicts with the current state (e.g. a duplicate). */
39
+ export declare class ConflictError extends WarningError {
40
+ }
41
+ //# sourceMappingURL=business-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"business-error.d.ts","sourceRoot":"","sources":["../../src/errors/business-error.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,OAAO,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;CAC5D;AAED;;;;GAIG;AACH,8BAAsB,aAAc,SAAQ,KAAK;IAK/C,QAAQ,CAAC,WAAW,CAAC,EAAE,gBAAgB;IAJxC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;gBAGzC,OAAO,EAAE,MAAM,EACN,WAAW,CAAC,EAAE,gBAAgB,YAAA;CAIxC;AAED,yEAAyE;AACzE,qBAAa,YAAa,SAAQ,aAAa;IAC9C,SAAkB,QAAQ,EAAG,SAAS,CAAU;CAChD;AAED,uEAAuE;AACvE,qBAAa,aAAc,SAAQ,aAAa;IAC/C,SAAkB,QAAQ,EAAG,OAAO,CAAU;CAC9C;AAED,8CAA8C;AAC9C,qBAAa,aAAc,SAAQ,YAAY;CAAG;AAElD,oCAAoC;AACpC,qBAAa,eAAgB,SAAQ,YAAY;CAAG;AAEpD,sEAAsE;AACtE,qBAAa,aAAc,SAAQ,YAAY;CAAG"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConflictError = exports.ValidationError = exports.NotFoundError = exports.CriticalError = exports.WarningError = exports.BusinessError = void 0;
4
+ /**
5
+ * Base class for expected, user-facing errors. Anything that is NOT a
6
+ * {@link BusinessError} is treated as unexpected: it is logged with an incident
7
+ * reference and the user sees a generic message.
8
+ */
9
+ class BusinessError extends Error {
10
+ translation;
11
+ constructor(message, translation) {
12
+ super(message);
13
+ this.translation = translation;
14
+ }
15
+ }
16
+ exports.BusinessError = BusinessError;
17
+ /** Benign business error (invalid input, missing resource, conflict). */
18
+ class WarningError extends BusinessError {
19
+ severity = "warning";
20
+ }
21
+ exports.WarningError = WarningError;
22
+ /** Serious business error that still carries a user-facing message. */
23
+ class CriticalError extends BusinessError {
24
+ severity = "error";
25
+ }
26
+ exports.CriticalError = CriticalError;
27
+ /** The referenced resource does not exist. */
28
+ class NotFoundError extends WarningError {
29
+ }
30
+ exports.NotFoundError = NotFoundError;
31
+ /** User input failed validation. */
32
+ class ValidationError extends WarningError {
33
+ }
34
+ exports.ValidationError = ValidationError;
35
+ /** The action conflicts with the current state (e.g. a duplicate). */
36
+ class ConflictError extends WarningError {
37
+ }
38
+ exports.ConflictError = ConflictError;
39
+ //# sourceMappingURL=business-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"business-error.js","sourceRoot":"","sources":["../../src/errors/business-error.ts"],"names":[],"mappings":";;;AAeA;;;;GAIG;AACH,MAAsB,aAAc,SAAQ,KAAK;IAKtC;IAFV,YACC,OAAe,EACN,WAA8B;QAEvC,KAAK,CAAC,OAAO,CAAC,CAAC;QAFN,gBAAW,GAAX,WAAW,CAAmB;IAGxC,CAAC;CACD;AATD,sCASC;AAED,yEAAyE;AACzE,MAAa,YAAa,SAAQ,aAAa;IAC5B,QAAQ,GAAG,SAAkB,CAAC;CAChD;AAFD,oCAEC;AAED,uEAAuE;AACvE,MAAa,aAAc,SAAQ,aAAa;IAC7B,QAAQ,GAAG,OAAgB,CAAC;CAC9C;AAFD,sCAEC;AAED,8CAA8C;AAC9C,MAAa,aAAc,SAAQ,YAAY;CAAG;AAAlD,sCAAkD;AAElD,oCAAoC;AACpC,MAAa,eAAgB,SAAQ,YAAY;CAAG;AAApD,0CAAoD;AAEpD,sEAAsE;AACtE,MAAa,aAAc,SAAQ,YAAY;CAAG;AAAlD,sCAAkD"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * An error as a log record keeps it: what it says, where it came from, and
3
+ * whatever it is wrapping.
4
+ *
5
+ * `message` alone is not enough for the errors this bot actually hits. A
6
+ * builder that refuses a payload throws `CombinedPropertyError`, whose own
7
+ * message is the constant "Received one or more errors" — everything that
8
+ * names the offending field lives in the errors nested under it. Logging the
9
+ * message and dropping the rest turns a precise complaint into a sentence that
10
+ * says nothing.
11
+ */
12
+ export interface DescribedError {
13
+ readonly message: string;
14
+ readonly name?: string;
15
+ readonly stack?: string;
16
+ /**
17
+ * What this error wraps: the entries of an aggregate, or the `cause` a
18
+ * rethrow attached.
19
+ */
20
+ readonly causes?: DescribedError[];
21
+ }
22
+ /**
23
+ * Render an unknown thrown value for a structured log.
24
+ *
25
+ * Use it wherever an error is caught to be reported rather than handled:
26
+ * `logger.error({ err: describeError(error) }, "…")`.
27
+ */
28
+ export declare function describeError(error: unknown, depth?: number): DescribedError;
29
+ //# sourceMappingURL=describe-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe-error.d.ts","sourceRoot":"","sources":["../../src/errors/describe-error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;CACnC;AA8BD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,cAAc,CAgBvE"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.describeError = describeError;
4
+ /**
5
+ * How deep the wrapping is followed. Aggregates nest two or three levels in
6
+ * practice; the bound is there so a cyclic `cause` cannot spin.
7
+ */
8
+ const MAX_DEPTH = 5;
9
+ /** How many entries of one aggregate are kept, so a wide failure stays readable. */
10
+ const MAX_CAUSES = 10;
11
+ /**
12
+ * The errors nested inside one, whatever shape it wraps them in.
13
+ *
14
+ * `AggregateError` and shapeshift's `CombinedError` both expose `errors` as a
15
+ * plain array; shapeshift's `CombinedPropertyError` uses the same field but
16
+ * pairs each error with the property it came from, as `[key, error]`. Taking
17
+ * the last element of an entry reads both, and keeping the key out of the way
18
+ * costs nothing — the nested message names the constraint that failed.
19
+ */
20
+ function aggregated(error) {
21
+ const { errors } = error;
22
+ if (!Array.isArray(errors)) {
23
+ return [];
24
+ }
25
+ return errors
26
+ .slice(0, MAX_CAUSES)
27
+ .map((entry) => (Array.isArray(entry) ? entry[entry.length - 1] : entry));
28
+ }
29
+ /**
30
+ * Render an unknown thrown value for a structured log.
31
+ *
32
+ * Use it wherever an error is caught to be reported rather than handled:
33
+ * `logger.error({ err: describeError(error) }, "…")`.
34
+ */
35
+ function describeError(error, depth = 0) {
36
+ if (!(error instanceof Error)) {
37
+ return { message: String(error) };
38
+ }
39
+ const causes = depth >= MAX_DEPTH
40
+ ? []
41
+ : [...aggregated(error), ...(error.cause === undefined ? [] : [error.cause])].map((nested) => describeError(nested, depth + 1));
42
+ return {
43
+ message: error.message,
44
+ name: error.name,
45
+ ...(error.stack === undefined ? {} : { stack: error.stack }),
46
+ ...(causes.length === 0 ? {} : { causes }),
47
+ };
48
+ }
49
+ //# sourceMappingURL=describe-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe-error.js","sourceRoot":"","sources":["../../src/errors/describe-error.ts"],"names":[],"mappings":";;AAwDA,sCAgBC;AAlDD;;;GAGG;AACH,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,oFAAoF;AACpF,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB;;;;;;;;GAQG;AACH,SAAS,UAAU,CAAC,KAAa;IAChC,MAAM,EAAE,MAAM,EAAE,GAAG,KAA6B,CAAC;IACjD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO,MAAM;SACX,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC;SACpB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,KAAc,EAAE,KAAK,GAAG,CAAC;IACtD,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IACnC,CAAC;IACD,MAAM,MAAM,GACX,KAAK,IAAI,SAAS;QACjB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAC3F,aAAa,CAAC,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,CAChC,CAAC;IACL,OAAO;QACN,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,GAAG,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;QAC5D,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;KAC1C,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Generate a unique incident reference attached to unexpected errors. The same
3
+ * value is logged server-side and shown to the user, so a support request can be
4
+ * traced back to a single log line.
5
+ */
6
+ export declare function createIncidentRef(): string;
7
+ //# sourceMappingURL=incident-ref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incident-ref.d.ts","sourceRoot":"","sources":["../../src/errors/incident-ref.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createIncidentRef = createIncidentRef;
4
+ const node_crypto_1 = require("node:crypto");
5
+ /**
6
+ * Generate a unique incident reference attached to unexpected errors. The same
7
+ * value is logged server-side and shown to the user, so a support request can be
8
+ * traced back to a single log line.
9
+ */
10
+ function createIncidentRef() {
11
+ return (0, node_crypto_1.randomUUID)();
12
+ }
13
+ //# sourceMappingURL=incident-ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incident-ref.js","sourceRoot":"","sources":["../../src/errors/incident-ref.ts"],"names":[],"mappings":";;AAOA,8CAEC;AATD,6CAAyC;AAEzC;;;;GAIG;AACH,SAAgB,iBAAiB;IAChC,OAAO,IAAA,wBAAU,GAAE,CAAC;AACrB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { BusinessError, ConflictError, CriticalError, type ErrorSeverity, type ErrorTranslation, NotFoundError, ValidationError, WarningError, } from "../errors/business-error";
2
+ export { type DescribedError, describeError } from "../errors/describe-error";
3
+ export { createIncidentRef } from "../errors/incident-ref";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,aAAa,EACb,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,aAAa,EACb,eAAe,EACf,YAAY,GACZ,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createIncidentRef = exports.describeError = exports.WarningError = exports.ValidationError = exports.NotFoundError = exports.CriticalError = exports.ConflictError = exports.BusinessError = void 0;
4
+ var business_error_1 = require("../errors/business-error");
5
+ Object.defineProperty(exports, "BusinessError", { enumerable: true, get: function () { return business_error_1.BusinessError; } });
6
+ Object.defineProperty(exports, "ConflictError", { enumerable: true, get: function () { return business_error_1.ConflictError; } });
7
+ Object.defineProperty(exports, "CriticalError", { enumerable: true, get: function () { return business_error_1.CriticalError; } });
8
+ Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return business_error_1.NotFoundError; } });
9
+ Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return business_error_1.ValidationError; } });
10
+ Object.defineProperty(exports, "WarningError", { enumerable: true, get: function () { return business_error_1.WarningError; } });
11
+ var describe_error_1 = require("../errors/describe-error");
12
+ Object.defineProperty(exports, "describeError", { enumerable: true, get: function () { return describe_error_1.describeError; } });
13
+ var incident_ref_1 = require("../errors/incident-ref");
14
+ Object.defineProperty(exports, "createIncidentRef", { enumerable: true, get: function () { return incident_ref_1.createIncidentRef; } });
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":";;;AAAA,0DASiC;AARhC,+GAAA,aAAa,OAAA;AACb,+GAAA,aAAa,OAAA;AACb,+GAAA,aAAa,OAAA;AAGb,+GAAA,aAAa,OAAA;AACb,iHAAA,eAAe,OAAA;AACf,8GAAA,YAAY,OAAA;AAEb,0DAA6E;AAA/C,+GAAA,aAAa,OAAA;AAC3C,sDAA0D;AAAjD,iHAAA,iBAAiB,OAAA"}
@@ -0,0 +1,14 @@
1
+ import type { BusinessError } from "../errors";
2
+ import type { Locale } from "../i18n/locale";
3
+ import type { Translator } from "../i18n/translator";
4
+ /**
5
+ * The user-facing wording of an expected failure: the catalog entry it points
6
+ * at, or its English source when it carries none.
7
+ *
8
+ * Lives beside the translator rather than with any one surface: the command
9
+ * pipeline, the `ComponentRouter` and every collector-scoped screen owe the same
10
+ * answer to the same failure, and a screen that has to translate its own
11
+ * refusals must not reach into another module to do it.
12
+ */
13
+ export declare function resolveBusinessMessage(error: BusinessError, translator: Translator, locale: Locale): string;
14
+ //# sourceMappingURL=business-message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"business-message.d.ts","sourceRoot":"","sources":["../../src/i18n/business-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,aAAa,EACpB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,GACZ,MAAM,CAKR"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveBusinessMessage = resolveBusinessMessage;
4
+ /**
5
+ * The user-facing wording of an expected failure: the catalog entry it points
6
+ * at, or its English source when it carries none.
7
+ *
8
+ * Lives beside the translator rather than with any one surface: the command
9
+ * pipeline, the `ComponentRouter` and every collector-scoped screen owe the same
10
+ * answer to the same failure, and a screen that has to translate its own
11
+ * refusals must not reach into another module to do it.
12
+ */
13
+ function resolveBusinessMessage(error, translator, locale) {
14
+ if (error.translation === undefined) {
15
+ return error.message;
16
+ }
17
+ return translator.translate(locale, error.translation.key, error.translation.params);
18
+ }
19
+ //# sourceMappingURL=business-message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"business-message.js","sourceRoot":"","sources":["../../src/i18n/business-message.ts"],"names":[],"mappings":";;AAaA,wDASC;AAlBD;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CACrC,KAAoB,EACpB,UAAsB,EACtB,MAAc;IAEd,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO,KAAK,CAAC,OAAO,CAAC;IACtB,CAAC;IACD,OAAO,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AACtF,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * One translatable message. `en` is mandatory by construction — it is the last
3
+ * link of every fallback chain, so a missing translation can only ever degrade
4
+ * to English, never to a broken reply. Templates carry `{name}` placeholders
5
+ * interpolated by the translator.
6
+ */
7
+ export interface CatalogEntry {
8
+ readonly en: string;
9
+ readonly fr?: string;
10
+ }
11
+ /**
12
+ * A set of keyed message templates. Keys are namespaced `<owner>.<area>.<name>`
13
+ * (e.g. `core.presenter.success-title`, `comms.event.created`) so two modules
14
+ * can never collide accidentally.
15
+ */
16
+ export type Catalog = Readonly<Record<string, CatalogEntry>>;
17
+ /**
18
+ * Accumulates the core catalog and every module's catalog at boot. Registration
19
+ * is fail-fast: a duplicate key throws {@link DuplicateTranslationKeyError}
20
+ * instead of silently letting one module's copy shadow another's.
21
+ */
22
+ export declare class TranslationRegistry {
23
+ private readonly entries;
24
+ register(catalog: Catalog): void;
25
+ get(key: string): CatalogEntry | undefined;
26
+ }
27
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/i18n/catalog.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAE7D;;;;GAIG;AACH,qBAAa,mBAAmB;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmC;IAE3D,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAShC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;CAG1C"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TranslationRegistry = void 0;
4
+ const errors_1 = require("../i18n/errors");
5
+ /**
6
+ * Accumulates the core catalog and every module's catalog at boot. Registration
7
+ * is fail-fast: a duplicate key throws {@link DuplicateTranslationKeyError}
8
+ * instead of silently letting one module's copy shadow another's.
9
+ */
10
+ class TranslationRegistry {
11
+ entries = new Map();
12
+ register(catalog) {
13
+ for (const [key, entry] of Object.entries(catalog)) {
14
+ if (this.entries.has(key)) {
15
+ throw new errors_1.DuplicateTranslationKeyError(key);
16
+ }
17
+ this.entries.set(key, entry);
18
+ }
19
+ }
20
+ get(key) {
21
+ return this.entries.get(key);
22
+ }
23
+ }
24
+ exports.TranslationRegistry = TranslationRegistry;
25
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/i18n/catalog.ts"],"names":[],"mappings":";;;AAAA,0CAA6D;AAoB7D;;;;GAIG;AACH,MAAa,mBAAmB;IACd,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAC;IAE3D,QAAQ,CAAC,OAAgB;QACxB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACpD,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC3B,MAAM,IAAI,qCAA4B,CAAC,GAAG,CAAC,CAAC;YAC7C,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC9B,CAAC;IACF,CAAC;IAED,GAAG,CAAC,GAAW;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;CACD;AAfD,kDAeC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Two catalogs declared the same translation key. Raised while modules register
3
+ * their catalogs at boot — a wiring mistake that must stop the boot, never a
4
+ * runtime condition.
5
+ */
6
+ export declare class DuplicateTranslationKeyError extends Error {
7
+ readonly key: string;
8
+ constructor(key: string);
9
+ }
10
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/i18n/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;IAC1C,QAAQ,CAAC,GAAG,EAAE,MAAM;gBAAX,GAAG,EAAE,MAAM;CAIhC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DuplicateTranslationKeyError = void 0;
4
+ /**
5
+ * Two catalogs declared the same translation key. Raised while modules register
6
+ * their catalogs at boot — a wiring mistake that must stop the boot, never a
7
+ * runtime condition.
8
+ */
9
+ class DuplicateTranslationKeyError extends Error {
10
+ key;
11
+ constructor(key) {
12
+ super(`Translation key "${key}" is registered twice`);
13
+ this.key = key;
14
+ this.name = "DuplicateTranslationKeyError";
15
+ }
16
+ }
17
+ exports.DuplicateTranslationKeyError = DuplicateTranslationKeyError;
18
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/i18n/errors.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,MAAa,4BAA6B,SAAQ,KAAK;IACjC;IAArB,YAAqB,GAAW;QAC/B,KAAK,CAAC,oBAAoB,GAAG,uBAAuB,CAAC,CAAC;QADlC,QAAG,GAAH,GAAG,CAAQ;QAE/B,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAC5C,CAAC;CACD;AALD,oEAKC"}
@@ -0,0 +1,6 @@
1
+ export { resolveBusinessMessage } from "../i18n/business-message";
2
+ export { type Catalog, type CatalogEntry, TranslationRegistry } from "../i18n/catalog";
3
+ export { DuplicateTranslationKeyError } from "../i18n/errors";
4
+ export { type Locale, normalizeLocale, resolveLocale, SUPPORTED_LOCALES } from "../i18n/locale";
5
+ export { createTranslator, type LocalizedText, type TranslationParams, type Translator, type TranslatorOptions, } from "../i18n/translator";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,KAAK,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EACN,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,iBAAiB,GACtB,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTranslator = exports.SUPPORTED_LOCALES = exports.resolveLocale = exports.normalizeLocale = exports.DuplicateTranslationKeyError = exports.TranslationRegistry = exports.resolveBusinessMessage = void 0;
4
+ var business_message_1 = require("../i18n/business-message");
5
+ Object.defineProperty(exports, "resolveBusinessMessage", { enumerable: true, get: function () { return business_message_1.resolveBusinessMessage; } });
6
+ var catalog_1 = require("../i18n/catalog");
7
+ Object.defineProperty(exports, "TranslationRegistry", { enumerable: true, get: function () { return catalog_1.TranslationRegistry; } });
8
+ var errors_1 = require("../i18n/errors");
9
+ Object.defineProperty(exports, "DuplicateTranslationKeyError", { enumerable: true, get: function () { return errors_1.DuplicateTranslationKeyError; } });
10
+ var locale_1 = require("../i18n/locale");
11
+ Object.defineProperty(exports, "normalizeLocale", { enumerable: true, get: function () { return locale_1.normalizeLocale; } });
12
+ Object.defineProperty(exports, "resolveLocale", { enumerable: true, get: function () { return locale_1.resolveLocale; } });
13
+ Object.defineProperty(exports, "SUPPORTED_LOCALES", { enumerable: true, get: function () { return locale_1.SUPPORTED_LOCALES; } });
14
+ var translator_1 = require("../i18n/translator");
15
+ Object.defineProperty(exports, "createTranslator", { enumerable: true, get: function () { return translator_1.createTranslator; } });
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":";;;AAAA,4DAAiE;AAAxD,0HAAA,sBAAsB,OAAA;AAC/B,0CAAsF;AAA5C,8GAAA,mBAAmB,OAAA;AAC7D,wCAA6D;AAApD,sHAAA,4BAA4B,OAAA;AACrC,wCAA+F;AAAzE,yGAAA,eAAe,OAAA;AAAE,uGAAA,aAAa,OAAA;AAAE,2GAAA,iBAAiB,OAAA;AACvE,gDAM2B;AAL1B,8GAAA,gBAAgB,OAAA"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The languages the framework can render replies in. `en` is structurally the
3
+ * fallback source: every catalog entry must provide it (see `catalog.ts`), so
4
+ * adding a language here can degrade gracefully instead of failing lookups.
5
+ */
6
+ export declare const SUPPORTED_LOCALES: readonly ["en", "fr"];
7
+ export type Locale = (typeof SUPPORTED_LOCALES)[number];
8
+ /**
9
+ * Map a raw Discord locale string (`en-US`, `en-GB`, `fr`, `de`…) to a
10
+ * supported base language. Regional variants collapse to their base tag, so
11
+ * both English variants resolve to `en` without duplicating catalog entries.
12
+ * Returns `undefined` for unsupported languages so callers can keep walking
13
+ * their fallback chain.
14
+ */
15
+ export declare function normalizeLocale(raw: string | null | undefined): Locale | undefined;
16
+ /**
17
+ * Pick the reply language for one message: the first supported candidate wins,
18
+ * otherwise the configured default. Callers list candidates in priority order
19
+ * (user locale, then guild locale).
20
+ */
21
+ export declare function resolveLocale(candidates: readonly (string | null | undefined)[], defaultLocale: Locale): Locale;
22
+ //# sourceMappingURL=locale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../src/i18n/locale.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,uBAAwB,CAAC;AAEvD,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAMlF;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC5B,UAAU,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,EAClD,aAAa,EAAE,MAAM,GACnB,MAAM,CAQR"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SUPPORTED_LOCALES = void 0;
4
+ exports.normalizeLocale = normalizeLocale;
5
+ exports.resolveLocale = resolveLocale;
6
+ /**
7
+ * The languages the framework can render replies in. `en` is structurally the
8
+ * fallback source: every catalog entry must provide it (see `catalog.ts`), so
9
+ * adding a language here can degrade gracefully instead of failing lookups.
10
+ */
11
+ exports.SUPPORTED_LOCALES = ["en", "fr"];
12
+ /**
13
+ * Map a raw Discord locale string (`en-US`, `en-GB`, `fr`, `de`…) to a
14
+ * supported base language. Regional variants collapse to their base tag, so
15
+ * both English variants resolve to `en` without duplicating catalog entries.
16
+ * Returns `undefined` for unsupported languages so callers can keep walking
17
+ * their fallback chain.
18
+ */
19
+ function normalizeLocale(raw) {
20
+ if (!raw) {
21
+ return undefined;
22
+ }
23
+ const base = raw.split("-")[0]?.toLowerCase();
24
+ return exports.SUPPORTED_LOCALES.find((locale) => locale === base);
25
+ }
26
+ /**
27
+ * Pick the reply language for one message: the first supported candidate wins,
28
+ * otherwise the configured default. Callers list candidates in priority order
29
+ * (user locale, then guild locale).
30
+ */
31
+ function resolveLocale(candidates, defaultLocale) {
32
+ for (const candidate of candidates) {
33
+ const normalized = normalizeLocale(candidate);
34
+ if (normalized !== undefined) {
35
+ return normalized;
36
+ }
37
+ }
38
+ return defaultLocale;
39
+ }
40
+ //# sourceMappingURL=locale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale.js","sourceRoot":"","sources":["../../src/i18n/locale.ts"],"names":[],"mappings":";;;AAgBA,0CAMC;AAOD,sCAWC;AAxCD;;;;GAIG;AACU,QAAA,iBAAiB,GAAG,CAAC,IAAI,EAAE,IAAI,CAAU,CAAC;AAIvD;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,GAA8B;IAC7D,IAAI,CAAC,GAAG,EAAE,CAAC;QACV,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;IAC9C,OAAO,yBAAiB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;AAC5D,CAAC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAC5B,UAAkD,EAClD,aAAqB;IAErB,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACpC,MAAM,UAAU,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO,UAAU,CAAC;QACnB,CAAC;IACF,CAAC;IACD,OAAO,aAAa,CAAC;AACtB,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { TranslationRegistry } from "../i18n/catalog";
2
+ import type { Locale } from "../i18n/locale";
3
+ import type { Logger } from "../logger";
4
+ /** Values interpolated into a template's `{name}` placeholders. */
5
+ export type TranslationParams = Readonly<Record<string, string | number>>;
6
+ /**
7
+ * A message that may be translated: either a plain string delivered verbatim
8
+ * (ad-hoc dynamic text, backward-compatible call sites) or a catalog key with
9
+ * its interpolation parameters. Accepted by guard denials, fallback errors and
10
+ * business errors, and resolved by the dispatch pipeline with the locale of the
11
+ * interaction being answered.
12
+ */
13
+ export type LocalizedText = string | {
14
+ readonly key: string;
15
+ readonly params?: TranslationParams;
16
+ };
17
+ /** Translates catalog keys for a resolved locale; never throws on lookup. */
18
+ export interface Translator {
19
+ readonly defaultLocale: Locale;
20
+ translate(locale: Locale, key: string, params?: TranslationParams): string;
21
+ /** Resolve a {@link LocalizedText}: plain strings pass through untranslated. */
22
+ resolve(locale: Locale, text: LocalizedText): string;
23
+ }
24
+ export interface TranslatorOptions {
25
+ readonly defaultLocale: Locale;
26
+ readonly logger: Logger;
27
+ }
28
+ /**
29
+ * Build the translator over a filled registry. Lookup order per call:
30
+ * requested locale → configured default → `en`. A key absent from the registry
31
+ * renders as the key itself (logged) — a lookup can degrade but never prevent
32
+ * a reply from being delivered.
33
+ */
34
+ export declare function createTranslator(registry: TranslationRegistry, options: TranslatorOptions): Translator;
35
+ //# sourceMappingURL=translator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translator.d.ts","sourceRoot":"","sources":["../../src/i18n/translator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,mEAAmE;AACnE,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;AAE1E;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAEnG,6EAA6E;AAC7E,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAAC;IAC3E,gFAAgF;IAChF,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC;CACrD;AAED,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAsBD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC/B,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE,iBAAiB,GACxB,UAAU,CAmBZ"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTranslator = createTranslator;
4
+ const PLACEHOLDER_PATTERN = /\{(\w+)\}/g;
5
+ function interpolate(template, params, key, logger) {
6
+ return template.replace(PLACEHOLDER_PATTERN, (placeholder, name) => {
7
+ const value = params?.[name];
8
+ if (value === undefined) {
9
+ // A missing value is a call-site bug, but the reply must still go out:
10
+ // keep the placeholder visible and leave a trace for the operator.
11
+ logger.warn({ key, placeholder: name }, "Missing interpolation parameter");
12
+ return placeholder;
13
+ }
14
+ return String(value);
15
+ });
16
+ }
17
+ /**
18
+ * Build the translator over a filled registry. Lookup order per call:
19
+ * requested locale → configured default → `en`. A key absent from the registry
20
+ * renders as the key itself (logged) — a lookup can degrade but never prevent
21
+ * a reply from being delivered.
22
+ */
23
+ function createTranslator(registry, options) {
24
+ const { defaultLocale, logger } = options;
25
+ const translate = (locale, key, params) => {
26
+ const entry = registry.get(key);
27
+ if (entry === undefined) {
28
+ logger.warn({ key }, "Unknown translation key");
29
+ return key;
30
+ }
31
+ const template = entry[locale] ?? entry[defaultLocale] ?? entry.en;
32
+ return interpolate(template, params, key, logger);
33
+ };
34
+ return {
35
+ defaultLocale,
36
+ translate,
37
+ resolve: (locale, text) => typeof text === "string" ? text : translate(locale, text.key, text.params),
38
+ };
39
+ }
40
+ //# sourceMappingURL=translator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translator.js","sourceRoot":"","sources":["../../src/i18n/translator.ts"],"names":[],"mappings":";;AAuDA,4CAsBC;AAhDD,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAEzC,SAAS,WAAW,CACnB,QAAgB,EAChB,MAAqC,EACrC,GAAW,EACX,MAAc;IAEd,OAAO,QAAQ,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC,WAAW,EAAE,IAAY,EAAE,EAAE;QAC1E,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,uEAAuE;YACvE,mEAAmE;YACnE,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,iCAAiC,CAAC,CAAC;YAC3E,OAAO,WAAW,CAAC;QACpB,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,gBAAgB,CAC/B,QAA6B,EAC7B,OAA0B;IAE1B,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE1C,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,GAAW,EAAE,MAA0B,EAAU,EAAE;QACrF,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,yBAAyB,CAAC,CAAC;YAChD,OAAO,GAAG,CAAC;QACZ,CAAC;QACD,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACnE,OAAO,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IACnD,CAAC,CAAC;IAEF,OAAO;QACN,aAAa;QACb,SAAS;QACT,OAAO,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CACzB,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC;KAC3E,CAAC;AACH,CAAC"}