meocord 4.2.0 → 4.2.2

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 (103) hide show
  1. package/CHANGELOG.md +322 -0
  2. package/THIRD_PARTY_NOTICES.md +14 -13
  3. package/dist/cjs/_shared/{controller.decorator-CRn9kWob.cjs → controller.decorator-U2NBWcoU.cjs} +416 -108
  4. package/dist/cjs/_shared/{providers-ChvMqnLd.cjs → providers-B4MOFBrW.cjs} +202 -50
  5. package/dist/cjs/_shared/{sharded-cooldown-store-BdAUTdYs.cjs → sharded-cooldown-store-HTUb3Ii_.cjs} +10 -7
  6. package/dist/cjs/_shared/{startup-roots-CQo8mSP8.cjs → startup-roots-lA5xkBFq.cjs} +228 -71
  7. package/dist/cjs/_shared/{translate-error-DhDVbT5M.cjs → translate-error-CbBHUu5P.cjs} +10 -5
  8. package/dist/cjs/common/index.cjs +3 -3
  9. package/dist/cjs/core/index.cjs +188 -169
  10. package/dist/cjs/decorator/index.cjs +52 -7
  11. package/dist/cjs/testing/index.cjs +1854 -311
  12. package/dist/cli.json +1 -1
  13. package/dist/esm/bin/generator.js +4 -5
  14. package/dist/esm/bin/helper/filter-generator.helper.js +4 -5
  15. package/dist/esm/bin/helper/guard-generator.helper.js +4 -5
  16. package/dist/esm/bin/helper/interceptor-generator.helper.js +4 -5
  17. package/dist/esm/bin/helper/observer-generator.helper.js +4 -5
  18. package/dist/esm/bin/helper/pipe-generator.helper.js +4 -5
  19. package/dist/esm/bin/helper/service-generator.helper.js +4 -5
  20. package/dist/esm/bin/meocord.js +84 -25
  21. package/dist/esm/build/load-config.pre-entry.js +13 -3
  22. package/dist/esm/build/rsbuild-config.js +16 -12
  23. package/dist/esm/build/typed-externals.js +36 -0
  24. package/dist/esm/common/cooldown-store.js +10 -2
  25. package/dist/esm/common/errors.js +25 -0
  26. package/dist/esm/common/meocord-text.js +11 -8
  27. package/dist/esm/common/response/call-order.js +9 -4
  28. package/dist/esm/common/response/presenter.js +33 -6
  29. package/dist/esm/common/response/response-state.js +89 -15
  30. package/dist/esm/common/route.js +11 -4
  31. package/dist/esm/common/sharded-cooldown-store.js +1 -1
  32. package/dist/esm/common/translator.js +52 -11
  33. package/dist/esm/core/command-registration.js +93 -24
  34. package/dist/esm/core/command-routes.js +2 -2
  35. package/dist/esm/core/cooldown-runner.js +29 -8
  36. package/dist/esm/core/dispatcher.js +9 -8
  37. package/dist/esm/core/fallback.js +20 -11
  38. package/dist/esm/core/filter-runner.js +2 -2
  39. package/dist/esm/core/guard-runner.js +16 -3
  40. package/dist/esm/core/handler-input.js +4 -3
  41. package/dist/esm/core/handler-pipeline.js +10 -4
  42. package/dist/esm/core/lifecycle-hooks.js +134 -47
  43. package/dist/esm/core/meocord-factory.js +59 -34
  44. package/dist/esm/core/meocord.app.js +116 -75
  45. package/dist/esm/core/message-help.js +32 -6
  46. package/dist/esm/core/observer-runner.js +2 -1
  47. package/dist/esm/core/providers.js +19 -4
  48. package/dist/esm/core/running-calls.js +43 -0
  49. package/dist/esm/core/shard-context.js +5 -6
  50. package/dist/esm/core/shard-manager.js +16 -10
  51. package/dist/esm/core/stage-scope.js +2 -1
  52. package/dist/esm/core/startup-roots.js +21 -1
  53. package/dist/esm/core/theme-resolvers.js +4 -1
  54. package/dist/esm/core/theme-scope.js +7 -2
  55. package/dist/esm/core/theme-validation.js +17 -10
  56. package/dist/esm/decorator/app.decorator.js +31 -0
  57. package/dist/esm/decorator/controller.decorator.js +56 -20
  58. package/dist/esm/decorator/cooldown.decorator.js +17 -0
  59. package/dist/esm/decorator/filter.decorator.js +2 -2
  60. package/dist/esm/decorator/guard.decorator.js +3 -2
  61. package/dist/esm/package.json.js +1 -1
  62. package/dist/esm/testing/catalog.js +20 -13
  63. package/dist/esm/testing/cooldown-store-suite.js +67 -5
  64. package/dist/esm/testing/discord-defaults.js +225 -30
  65. package/dist/esm/testing/meocord-testing-module.js +158 -44
  66. package/dist/esm/testing/mock-fn.js +107 -26
  67. package/dist/esm/testing/mock-interaction.js +1250 -182
  68. package/dist/esm/testing/snowflake.js +9 -2
  69. package/dist/esm/testing/strict-mocks.js +40 -17
  70. package/dist/esm/util/common.util.js +47 -19
  71. package/dist/esm/util/dev-runner.util.js +8 -8
  72. package/dist/esm/util/generator-cli.util.js +4 -5
  73. package/dist/esm/util/interaction.util.js +2 -2
  74. package/dist/esm/util/meocord-config-loader.util.js +10 -2
  75. package/dist/esm/util/meocord-config-validation.util.js +3 -5
  76. package/dist/esm/util/meocord-source-config.util.js +65 -20
  77. package/dist/esm/util/method-wrapper.util.js +16 -0
  78. package/dist/esm/util/platform.util.js +10 -10
  79. package/dist/esm/util/shard-process.util.js +4 -1
  80. package/dist/esm/util/sharding-mode.util.js +5 -7
  81. package/dist/esm/util/shared-state.util.js +21 -0
  82. package/dist/esm/util/tsconfig-paths.util.js +29 -0
  83. package/dist/esm/util/tsconfig.util.js +10 -10
  84. package/dist/esm/util/value.util.js +30 -2
  85. package/dist/types/common/index.d.cts +10 -7
  86. package/dist/types/common/index.d.ts +10 -7
  87. package/dist/types/core/index.d.cts +3 -2
  88. package/dist/types/core/index.d.ts +3 -2
  89. package/dist/types/decorator/index.d.cts +1 -0
  90. package/dist/types/decorator/index.d.ts +1 -0
  91. package/dist/types/{index-CdXsFgjE.d.ts → index-DKJclIi-.d.ts} +45 -21
  92. package/dist/types/{index-nn5p7OoX.d.cts → index-Dlf0ZZtS.d.cts} +45 -21
  93. package/dist/types/interface/index.d.cts +1 -1
  94. package/dist/types/interface/index.d.ts +1 -1
  95. package/dist/types/{route-BZgFoNeB.d.cts → route-Bh1U13yy.d.cts} +3 -2
  96. package/dist/types/{route-BZgFoNeB.d.ts → route-Bh1U13yy.d.ts} +3 -2
  97. package/dist/types/testing/index.d.cts +198 -62
  98. package/dist/types/testing/index.d.ts +198 -62
  99. package/dist/types/{theme-resolvers-UKr3-6Ys.d.cts → theme-resolvers-CyEz9pnv.d.cts} +1 -1
  100. package/dist/types/{theme-resolvers-BcOJVzR9.d.ts → theme-resolvers-DA204O-q.d.ts} +1 -1
  101. package/dist/types/{translator-DHMkkCpg.d.cts → translator-Bg7hwxDF.d.cts} +21 -8
  102. package/dist/types/{translator-BViWKtLJ.d.ts → translator-CeP4bCzp.d.ts} +21 -8
  103. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
1
  import { Locale, Interaction, Guild } from 'discord.js';
2
- import { aq as MeoCordMessages } from './index-CdXsFgjE.js';
2
+ import { aq as MeoCordMessages } from './index-DKJclIi-.js';
3
3
 
4
4
  /**
5
5
  * The plural categories `Intl.PluralRules` selects between.
@@ -33,10 +33,13 @@ type IsPlural<T> = T extends object ? [Exclude<keyof T, PluralCategory>] extends
33
33
  /**
34
34
  * Every message key of a catalog: the dotted path to each message or plural.
35
35
  *
36
+ * A key with a `.` in its own name is left out, as a lookup reads it as a path and never finds it; `createTranslator`
37
+ * warns about one. Nest it as a group.
38
+ *
36
39
  * @group Types
37
40
  */
38
41
  type MessageKey<C> = {
39
- [K in keyof C & string]: C[K] extends string ? K : IsPlural<C[K]> extends true ? K : `${K}.${MessageKey<C[K]>}`;
42
+ [K in keyof C & string]: K extends `${string}.${string}` ? never : C[K] extends string ? K : IsPlural<C[K]> extends true ? K : `${K}.${MessageKey<C[K]>}`;
40
43
  }[keyof C & string];
41
44
  /**
42
45
  * The keys whose message is a single string rather than plural forms, with or without `{params}`.
@@ -45,7 +48,7 @@ type MessageKey<C> = {
45
48
  * @see {@link LocalizationKey}
46
49
  */
47
50
  type StringMessageKey<C> = {
48
- [K in keyof C & string]: C[K] extends string ? K : IsPlural<C[K]> extends true ? never : `${K}.${StringMessageKey<C[K]>}`;
51
+ [K in keyof C & string]: K extends `${string}.${string}` ? never : C[K] extends string ? K : IsPlural<C[K]> extends true ? never : `${K}.${StringMessageKey<C[K]>}`;
49
52
  }[keyof C & string];
50
53
  /**
51
54
  * The keys {@link Translator.localizations} takes: a single string with no `{params}`, since Discord shows a command's
@@ -105,12 +108,17 @@ type Translate<C> = <K extends MessageKey<C>>(key: K, ...params: ParamsArgs<Mess
105
108
  * Its messages may use only the `{params}` the default's take: `createTranslator` checks that for a catalog that keeps
106
109
  * its text, and `expectCompleteCatalog` for any.
107
110
  *
108
- * A message it leaves out falls back to a related locale, then to the default.
111
+ * A message it leaves out falls back to a related locale, then to the default. Its `meocord` group translates MeoCord's
112
+ * own texts.
109
113
  *
110
114
  * @group Types
111
115
  */
112
- type LocaleCatalog<C> = {
113
- readonly [K in keyof C]?: C[K] extends string ? string : IsPlural<C[K]> extends true ? PluralMessage : LocaleCatalog<C[K]>;
116
+ type LocaleCatalog<C> = LocaleMessages<C> & {
117
+ readonly meocord?: LocaleMessages<MeoCordMessages>;
118
+ };
119
+ /** Any part of a catalog, in a locale's own wording. */
120
+ type LocaleMessages<C> = {
121
+ readonly [K in keyof C]?: C[K] extends string ? string : IsPlural<C[K]> extends true ? PluralMessage : LocaleMessages<C[K]>;
114
122
  };
115
123
  /**
116
124
  * What is wrong with a catalog's `meocord` group, one message per mistake: a key MeoCord has no text for, a group where
@@ -266,8 +274,13 @@ declare abstract class Translator<C = CatalogShape> {
266
274
  /**
267
275
  * A message in every locale other than the default whose own catalog has it, for a builder's
268
276
  * `setNameLocalizations` or `setDescriptionLocalizations`. Locales without it are left out, so
269
- * Discord falls back to the default name for them, and so is a translation with a `{param}`, which
270
- * `expectCompleteCatalog` reports.
277
+ * Discord falls back to the default name for them, and so are an empty translation and a translation
278
+ * with a `{param}`, which `expectCompleteCatalog` reports.
279
+ *
280
+ * Discord shows en-US users the en-GB value, en-GB users the en-US one, and es-419 users the es-ES one,
281
+ * when their own locale has none. So when the default is en-US, en-GB or es-419 and its partner is in
282
+ * the result, the default's own message is added under the default's key, and its users keep the default
283
+ * wording.
271
284
  *
272
285
  * @param key - A plain message key without `{params}`: Discord shows a name or description as written, and has no
273
286
  * plural forms for it.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "meocord",
3
3
  "description": "Decorator-based framework for Discord bots on discord.js, with dependency injection, guards, a CLI and a testing toolkit.",
4
- "version": "4.2.0",
4
+ "version": "4.2.2",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=22.13"
@@ -138,6 +138,7 @@
138
138
  "cli-table3": "^0.6.5",
139
139
  "commander": "^15.0.0",
140
140
  "dayjs": "^1.11.23",
141
+ "get-tsconfig": "^4.14.3",
141
142
  "inversify": "^8.2.3",
142
143
  "jiti": "^2.7.0",
143
144
  "lodash-es": "^4.18.1",
@@ -171,7 +172,6 @@
171
172
  "prettier": "^3.9.9",
172
173
  "redis": "^6.3.0",
173
174
  "rollup": "^4.63.6",
174
- "rollup-plugin-copy": "^3.5.0",
175
175
  "rollup-plugin-dts": "^6.5.1",
176
176
  "typescript": "^6.0.3",
177
177
  "typescript-eslint": "^8.71.0",