commandkit 1.2.0-rc.1 → 1.2.0-rc.3

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/dist/{CommandsRouter-Ci1Pe8Vd.js → CommandsRouter-tMAivEfv.js} +10 -7
  2. package/dist/{CommandsRouter-Ci1Pe8Vd.js.map → CommandsRouter-tMAivEfv.js.map} +1 -1
  3. package/dist/{EventWorkerContext-DJUi1W3T.d.ts → EventWorkerContext-C7CG7hIP.d.ts} +2 -2
  4. package/dist/analytics/analytics-engine.d.ts +1 -1
  5. package/dist/analytics/analytics-engine.js +2 -2
  6. package/dist/analytics/analytics-provider.d.ts +1 -1
  7. package/dist/analytics/utils.js +2 -2
  8. package/dist/{analytics-engine-vA4MaJYx.d.ts → analytics-engine-nkyqvYAE.d.ts} +2 -2
  9. package/dist/app/commands/AppCommandRunner.d.ts +1 -1
  10. package/dist/app/commands/AppCommandRunner.js +2 -2
  11. package/dist/app/commands/Context.d.ts +1 -1
  12. package/dist/app/commands/Context.js +2 -2
  13. package/dist/app/events/EventWorkerContext.d.ts +2 -2
  14. package/dist/app/handlers/AppCommandHandler.d.ts +1 -1
  15. package/dist/app/handlers/AppCommandHandler.js +2 -2
  16. package/dist/app/handlers/AppEventsHandler.d.ts +1 -1
  17. package/dist/app/handlers/AppEventsHandler.js +2 -2
  18. package/dist/app/index.d.ts +1 -1
  19. package/dist/app/index.js +2 -2
  20. package/dist/app/register/CommandRegistrar.d.ts +1 -1
  21. package/dist/app/register/CommandRegistrar.js +2 -2
  22. package/dist/app/router/CommandsRouter.js +1 -1
  23. package/dist/app/router/index.js +1 -1
  24. package/dist/{build-DXl8uEv4.js → build-BoGqWPIS.js} +2 -2
  25. package/dist/{build-DXl8uEv4.js.map → build-BoGqWPIS.js.map} +1 -1
  26. package/dist/cli/build.d.ts +1 -1
  27. package/dist/cli/build.js +3 -3
  28. package/dist/cli/common.d.ts +1 -1
  29. package/dist/cli/development.js +3 -3
  30. package/dist/cli/information.js +1 -1
  31. package/dist/cli/init.js +3 -3
  32. package/dist/cli/production.js +3 -3
  33. package/dist/{commandkit-DMEW0kJg.js → commandkit-5VMG2thU.js} +4 -4
  34. package/dist/{commandkit-DMEW0kJg.js.map → commandkit-5VMG2thU.js.map} +1 -1
  35. package/dist/commandkit.d.ts +1 -1
  36. package/dist/commandkit.js +2 -2
  37. package/dist/components/index.js +2 -2
  38. package/dist/components/v1/button/Button.js +2 -2
  39. package/dist/components/v1/button/ButtonKit.js +2 -2
  40. package/dist/components/v1/modal/Modal.js +2 -2
  41. package/dist/components/v1/modal/ModalKit.js +2 -2
  42. package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +2 -2
  43. package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +2 -2
  44. package/dist/components/v1/select-menu/RoleSelectMenuKit.js +2 -2
  45. package/dist/components/v1/select-menu/SelectMenu.js +2 -2
  46. package/dist/components/v1/select-menu/StringSelectMenuKit.js +2 -2
  47. package/dist/components/v1/select-menu/UserSelectMenuKit.js +2 -2
  48. package/dist/config/config.d.ts +2 -2
  49. package/dist/config/config.js +2 -2
  50. package/dist/config/default.d.ts +1 -1
  51. package/dist/config/default.js +2 -2
  52. package/dist/config/loader.d.ts +1 -1
  53. package/dist/config/loader.js +2 -2
  54. package/dist/config/types.d.ts +1 -1
  55. package/dist/config/utils.d.ts +1 -1
  56. package/dist/{config-CcWJ-vz5.d.ts → config-C1msSu1G.d.ts} +2 -2
  57. package/dist/{constants-DrjIvQd6.d.ts → constants-D8PMA9on.d.ts} +1 -1
  58. package/dist/context/async-context.d.ts +1 -1
  59. package/dist/context/async-context.js +2 -2
  60. package/dist/context/environment.d.ts +1 -1
  61. package/dist/context/environment.js +2 -2
  62. package/dist/error-codes-BzoEctmD.d.ts +54 -0
  63. package/dist/events/CommandKitEventsChannel.d.ts +1 -1
  64. package/dist/{feature-flags-Cxl9JtVG.js → feature-flags-C44dggkN.js} +2 -2
  65. package/dist/{feature-flags-Cxl9JtVG.js.map → feature-flags-C44dggkN.js.map} +1 -1
  66. package/dist/flags/FlagProvider.d.ts +1 -1
  67. package/dist/flags/feature-flags.d.ts +1 -1
  68. package/dist/flags/feature-flags.js +3 -3
  69. package/dist/flags/store.d.ts +1 -1
  70. package/dist/index.d.ts +5 -4
  71. package/dist/index.js +8 -6
  72. package/dist/{init-DTBFphOg.js → init-ZjceQTSt.js} +2 -2
  73. package/dist/{init-DTBFphOg.js.map → init-ZjceQTSt.js.map} +1 -1
  74. package/dist/kv/constants.d.ts +1 -1
  75. package/dist/kv/kv.d.ts +2 -2
  76. package/dist/kv/serde.d.ts +2 -2
  77. package/dist/logger/DefaultLogger.js +2 -2
  78. package/dist/logger/Logger.js +2 -2
  79. package/dist/plugins/CompilerPlugin.d.ts +1 -1
  80. package/dist/plugins/PluginCommon.d.ts +1 -1
  81. package/dist/plugins/RuntimePlugin.d.ts +1 -1
  82. package/dist/plugins/index.d.ts +1 -1
  83. package/dist/plugins/index.js +2 -2
  84. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -1
  85. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +2 -2
  86. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -1
  87. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +2 -2
  88. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -1
  89. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +2 -2
  90. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -1
  91. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +2 -2
  92. package/dist/plugins/plugin-runtime/runtime.d.ts +1 -1
  93. package/dist/plugins/types.d.ts +1 -1
  94. package/dist/{serde-BUDI03pX.d.ts → serde-BYaKrsOV.d.ts} +2 -2
  95. package/dist/types.d.ts +1 -1
  96. package/dist/utils/dev-hooks.d.ts +1 -1
  97. package/dist/utils/dev-hooks.js +2 -2
  98. package/dist/utils/error-codes.d.ts +2 -54
  99. package/dist/utils/utilities.js +2 -2
  100. package/dist/{version-rfStvlqX.js → version-D8HlFOxx.js} +2 -2
  101. package/dist/{version-rfStvlqX.js.map → version-D8HlFOxx.js.map} +1 -1
  102. package/dist/version.js +1 -1
  103. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- import { BootstrapFunction, CommandKit, CommandKitConfiguration, commandkit, onApplicationBootstrap, onBootstrap } from "./analytics-engine-vA4MaJYx.js";
1
+ import { BootstrapFunction, CommandKit, CommandKitConfiguration, commandkit, onApplicationBootstrap, onBootstrap } from "./analytics-engine-nkyqvYAE.js";
2
2
  import "./EventInterceptor-x-R2qshQ.js";
3
3
  import "./ButtonKit-C7r7RPNf.js";
4
4
  import "./ModalKit-Btz58KYn.js";
@@ -1,7 +1,7 @@
1
1
  require('./colors-Cd4Oz-r-.js');
2
2
  require('./ActionRow-CmTHbo2t.js');
3
3
  require('./error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('./commandkit-DMEW0kJg.js');
4
+ const require_commandkit = require('./commandkit-5VMG2thU.js');
5
5
  require('./common-CcfjYnPG.js');
6
6
  require('./common-vnMIelAE.js');
7
7
  require('./container-z621KfH5.js');
@@ -27,7 +27,7 @@ require('./EventWorkerContext-CSlD9rbx.js');
27
27
  require('./signals-DHdYrd-n.js');
28
28
  require('./constants-CUND8XkG.js');
29
29
  require('./MessageCommandParser-B_BEQ3p8.js');
30
- require('./CommandsRouter-Ci1Pe8Vd.js');
30
+ require('./CommandsRouter-tMAivEfv.js');
31
31
  require('./EventsRouter-C_J0M3uO.js');
32
32
  require('./router-DHnFRADH.js');
33
33
  require('./common-DNADUU3_.js');
@@ -1,7 +1,7 @@
1
1
  require('../colors-Cd4Oz-r-.js');
2
2
  const require_ActionRow = require('../ActionRow-CmTHbo2t.js');
3
3
  require('../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../commandkit-DMEW0kJg.js');
4
+ const require_commandkit = require('../commandkit-5VMG2thU.js');
5
5
  require('../common-CcfjYnPG.js');
6
6
  require('../common-vnMIelAE.js');
7
7
  const require_container = require('../container-z621KfH5.js');
@@ -27,7 +27,7 @@ require('../EventWorkerContext-CSlD9rbx.js');
27
27
  require('../signals-DHdYrd-n.js');
28
28
  require('../constants-CUND8XkG.js');
29
29
  require('../MessageCommandParser-B_BEQ3p8.js');
30
- require('../CommandsRouter-Ci1Pe8Vd.js');
30
+ require('../CommandsRouter-tMAivEfv.js');
31
31
  require('../EventsRouter-C_J0M3uO.js');
32
32
  require('../router-DHnFRADH.js');
33
33
  require('../common-DNADUU3_.js');
@@ -1,7 +1,7 @@
1
1
  require('../../../colors-Cd4Oz-r-.js');
2
2
  require('../../../ActionRow-CmTHbo2t.js');
3
3
  require('../../../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../../../commandkit-DMEW0kJg.js');
4
+ const require_commandkit = require('../../../commandkit-5VMG2thU.js');
5
5
  require('../../../common-CcfjYnPG.js');
6
6
  require('../../../common-vnMIelAE.js');
7
7
  require('../../../container-z621KfH5.js');
@@ -27,7 +27,7 @@ require('../../../EventWorkerContext-CSlD9rbx.js');
27
27
  require('../../../signals-DHdYrd-n.js');
28
28
  require('../../../constants-CUND8XkG.js');
29
29
  require('../../../MessageCommandParser-B_BEQ3p8.js');
30
- require('../../../CommandsRouter-Ci1Pe8Vd.js');
30
+ require('../../../CommandsRouter-tMAivEfv.js');
31
31
  require('../../../EventsRouter-C_J0M3uO.js');
32
32
  require('../../../router-DHnFRADH.js');
33
33
  require('../../../common-DNADUU3_.js');
@@ -1,7 +1,7 @@
1
1
  require('../../../colors-Cd4Oz-r-.js');
2
2
  require('../../../ActionRow-CmTHbo2t.js');
3
3
  require('../../../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../../../commandkit-DMEW0kJg.js');
4
+ const require_commandkit = require('../../../commandkit-5VMG2thU.js');
5
5
  require('../../../common-CcfjYnPG.js');
6
6
  require('../../../common-vnMIelAE.js');
7
7
  require('../../../container-z621KfH5.js');
@@ -27,7 +27,7 @@ require('../../../EventWorkerContext-CSlD9rbx.js');
27
27
  require('../../../signals-DHdYrd-n.js');
28
28
  require('../../../constants-CUND8XkG.js');
29
29
  require('../../../MessageCommandParser-B_BEQ3p8.js');
30
- require('../../../CommandsRouter-Ci1Pe8Vd.js');
30
+ require('../../../CommandsRouter-tMAivEfv.js');
31
31
  require('../../../EventsRouter-C_J0M3uO.js');
32
32
  require('../../../router-DHnFRADH.js');
33
33
  require('../../../common-DNADUU3_.js');
@@ -1,7 +1,7 @@
1
1
  require('../../../colors-Cd4Oz-r-.js');
2
2
  require('../../../ActionRow-CmTHbo2t.js');
3
3
  require('../../../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../../../commandkit-DMEW0kJg.js');
4
+ const require_commandkit = require('../../../commandkit-5VMG2thU.js');
5
5
  require('../../../common-CcfjYnPG.js');
6
6
  require('../../../common-vnMIelAE.js');
7
7
  require('../../../container-z621KfH5.js');
@@ -27,7 +27,7 @@ require('../../../EventWorkerContext-CSlD9rbx.js');
27
27
  require('../../../signals-DHdYrd-n.js');
28
28
  require('../../../constants-CUND8XkG.js');
29
29
  require('../../../MessageCommandParser-B_BEQ3p8.js');
30
- require('../../../CommandsRouter-Ci1Pe8Vd.js');
30
+ require('../../../CommandsRouter-tMAivEfv.js');
31
31
  require('../../../EventsRouter-C_J0M3uO.js');
32
32
  require('../../../router-DHnFRADH.js');
33
33
  require('../../../common-DNADUU3_.js');
@@ -1,7 +1,7 @@
1
1
  require('../../../colors-Cd4Oz-r-.js');
2
2
  require('../../../ActionRow-CmTHbo2t.js');
3
3
  require('../../../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../../../commandkit-DMEW0kJg.js');
4
+ const require_commandkit = require('../../../commandkit-5VMG2thU.js');
5
5
  require('../../../common-CcfjYnPG.js');
6
6
  require('../../../common-vnMIelAE.js');
7
7
  require('../../../container-z621KfH5.js');
@@ -27,7 +27,7 @@ require('../../../EventWorkerContext-CSlD9rbx.js');
27
27
  require('../../../signals-DHdYrd-n.js');
28
28
  require('../../../constants-CUND8XkG.js');
29
29
  require('../../../MessageCommandParser-B_BEQ3p8.js');
30
- require('../../../CommandsRouter-Ci1Pe8Vd.js');
30
+ require('../../../CommandsRouter-tMAivEfv.js');
31
31
  require('../../../EventsRouter-C_J0M3uO.js');
32
32
  require('../../../router-DHnFRADH.js');
33
33
  require('../../../common-DNADUU3_.js');
@@ -1,7 +1,7 @@
1
1
  require('../../../colors-Cd4Oz-r-.js');
2
2
  require('../../../ActionRow-CmTHbo2t.js');
3
3
  require('../../../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../../../commandkit-DMEW0kJg.js');
4
+ const require_commandkit = require('../../../commandkit-5VMG2thU.js');
5
5
  require('../../../common-CcfjYnPG.js');
6
6
  require('../../../common-vnMIelAE.js');
7
7
  require('../../../container-z621KfH5.js');
@@ -27,7 +27,7 @@ require('../../../EventWorkerContext-CSlD9rbx.js');
27
27
  require('../../../signals-DHdYrd-n.js');
28
28
  require('../../../constants-CUND8XkG.js');
29
29
  require('../../../MessageCommandParser-B_BEQ3p8.js');
30
- require('../../../CommandsRouter-Ci1Pe8Vd.js');
30
+ require('../../../CommandsRouter-tMAivEfv.js');
31
31
  require('../../../EventsRouter-C_J0M3uO.js');
32
32
  require('../../../router-DHnFRADH.js');
33
33
  require('../../../common-DNADUU3_.js');
@@ -1,7 +1,7 @@
1
1
  require('../../../colors-Cd4Oz-r-.js');
2
2
  require('../../../ActionRow-CmTHbo2t.js');
3
3
  require('../../../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../../../commandkit-DMEW0kJg.js');
4
+ const require_commandkit = require('../../../commandkit-5VMG2thU.js');
5
5
  require('../../../common-CcfjYnPG.js');
6
6
  require('../../../common-vnMIelAE.js');
7
7
  require('../../../container-z621KfH5.js');
@@ -27,7 +27,7 @@ require('../../../EventWorkerContext-CSlD9rbx.js');
27
27
  require('../../../signals-DHdYrd-n.js');
28
28
  require('../../../constants-CUND8XkG.js');
29
29
  require('../../../MessageCommandParser-B_BEQ3p8.js');
30
- require('../../../CommandsRouter-Ci1Pe8Vd.js');
30
+ require('../../../CommandsRouter-tMAivEfv.js');
31
31
  require('../../../EventsRouter-C_J0M3uO.js');
32
32
  require('../../../router-DHnFRADH.js');
33
33
  require('../../../common-DNADUU3_.js');
@@ -1,7 +1,7 @@
1
1
  require('../../../colors-Cd4Oz-r-.js');
2
2
  require('../../../ActionRow-CmTHbo2t.js');
3
3
  require('../../../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../../../commandkit-DMEW0kJg.js');
4
+ const require_commandkit = require('../../../commandkit-5VMG2thU.js');
5
5
  require('../../../common-CcfjYnPG.js');
6
6
  require('../../../common-vnMIelAE.js');
7
7
  require('../../../container-z621KfH5.js');
@@ -27,7 +27,7 @@ require('../../../EventWorkerContext-CSlD9rbx.js');
27
27
  require('../../../signals-DHdYrd-n.js');
28
28
  require('../../../constants-CUND8XkG.js');
29
29
  require('../../../MessageCommandParser-B_BEQ3p8.js');
30
- require('../../../CommandsRouter-Ci1Pe8Vd.js');
30
+ require('../../../CommandsRouter-tMAivEfv.js');
31
31
  require('../../../EventsRouter-C_J0M3uO.js');
32
32
  require('../../../router-DHnFRADH.js');
33
33
  require('../../../common-DNADUU3_.js');
@@ -1,7 +1,7 @@
1
1
  require('../../../colors-Cd4Oz-r-.js');
2
2
  require('../../../ActionRow-CmTHbo2t.js');
3
3
  require('../../../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../../../commandkit-DMEW0kJg.js');
4
+ const require_commandkit = require('../../../commandkit-5VMG2thU.js');
5
5
  require('../../../common-CcfjYnPG.js');
6
6
  require('../../../common-vnMIelAE.js');
7
7
  require('../../../container-z621KfH5.js');
@@ -27,7 +27,7 @@ require('../../../EventWorkerContext-CSlD9rbx.js');
27
27
  require('../../../signals-DHdYrd-n.js');
28
28
  require('../../../constants-CUND8XkG.js');
29
29
  require('../../../MessageCommandParser-B_BEQ3p8.js');
30
- require('../../../CommandsRouter-Ci1Pe8Vd.js');
30
+ require('../../../CommandsRouter-tMAivEfv.js');
31
31
  require('../../../EventsRouter-C_J0M3uO.js');
32
32
  require('../../../router-DHnFRADH.js');
33
33
  require('../../../common-DNADUU3_.js');
@@ -1,7 +1,7 @@
1
1
  require('../../../colors-Cd4Oz-r-.js');
2
2
  require('../../../ActionRow-CmTHbo2t.js');
3
3
  require('../../../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../../../commandkit-DMEW0kJg.js');
4
+ const require_commandkit = require('../../../commandkit-5VMG2thU.js');
5
5
  require('../../../common-CcfjYnPG.js');
6
6
  require('../../../common-vnMIelAE.js');
7
7
  require('../../../container-z621KfH5.js');
@@ -27,7 +27,7 @@ require('../../../EventWorkerContext-CSlD9rbx.js');
27
27
  require('../../../signals-DHdYrd-n.js');
28
28
  require('../../../constants-CUND8XkG.js');
29
29
  require('../../../MessageCommandParser-B_BEQ3p8.js');
30
- require('../../../CommandsRouter-Ci1Pe8Vd.js');
30
+ require('../../../CommandsRouter-tMAivEfv.js');
31
31
  require('../../../EventsRouter-C_J0M3uO.js');
32
32
  require('../../../router-DHnFRADH.js');
33
33
  require('../../../common-DNADUU3_.js');
@@ -1,7 +1,7 @@
1
1
  require('../../../colors-Cd4Oz-r-.js');
2
2
  require('../../../ActionRow-CmTHbo2t.js');
3
3
  require('../../../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../../../commandkit-DMEW0kJg.js');
4
+ const require_commandkit = require('../../../commandkit-5VMG2thU.js');
5
5
  require('../../../common-CcfjYnPG.js');
6
6
  require('../../../common-vnMIelAE.js');
7
7
  require('../../../container-z621KfH5.js');
@@ -27,7 +27,7 @@ require('../../../EventWorkerContext-CSlD9rbx.js');
27
27
  require('../../../signals-DHdYrd-n.js');
28
28
  require('../../../constants-CUND8XkG.js');
29
29
  require('../../../MessageCommandParser-B_BEQ3p8.js');
30
- require('../../../CommandsRouter-Ci1Pe8Vd.js');
30
+ require('../../../CommandsRouter-tMAivEfv.js');
31
31
  require('../../../EventsRouter-C_J0M3uO.js');
32
32
  require('../../../router-DHnFRADH.js');
33
33
  require('../../../common-DNADUU3_.js');
@@ -1,4 +1,4 @@
1
- import "../analytics-engine-vA4MaJYx.js";
1
+ import "../analytics-engine-nkyqvYAE.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -29,5 +29,5 @@ import "../CommandsRouter-CoOA7hkf.js";
29
29
  import "../EventsRouter-BacqK6z3.js";
30
30
  import "../index-DKcmsWXw.js";
31
31
  import "../constants-MKu-Q1jh.js";
32
- import { defineConfig, getConfig } from "../config-CcWJ-vz5.js";
32
+ import { defineConfig, getConfig } from "../config-C1msSu1G.js";
33
33
  export { defineConfig, getConfig };
@@ -1,7 +1,7 @@
1
1
  require('../colors-Cd4Oz-r-.js');
2
2
  require('../ActionRow-CmTHbo2t.js');
3
3
  require('../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../commandkit-DMEW0kJg.js');
4
+ const require_commandkit = require('../commandkit-5VMG2thU.js');
5
5
  require('../common-CcfjYnPG.js');
6
6
  require('../common-vnMIelAE.js');
7
7
  require('../container-z621KfH5.js');
@@ -27,7 +27,7 @@ require('../EventWorkerContext-CSlD9rbx.js');
27
27
  require('../signals-DHdYrd-n.js');
28
28
  require('../constants-CUND8XkG.js');
29
29
  require('../MessageCommandParser-B_BEQ3p8.js');
30
- require('../CommandsRouter-Ci1Pe8Vd.js');
30
+ require('../CommandsRouter-tMAivEfv.js');
31
31
  require('../EventsRouter-C_J0M3uO.js');
32
32
  require('../router-DHnFRADH.js');
33
33
  require('../common-DNADUU3_.js');
@@ -1,4 +1,4 @@
1
- import { ResolvedCommandKitConfig } from "../analytics-engine-vA4MaJYx.js";
1
+ import { ResolvedCommandKitConfig } from "../analytics-engine-nkyqvYAE.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -1,7 +1,7 @@
1
1
  require('../colors-Cd4Oz-r-.js');
2
2
  require('../ActionRow-CmTHbo2t.js');
3
3
  require('../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../commandkit-DMEW0kJg.js');
4
+ const require_commandkit = require('../commandkit-5VMG2thU.js');
5
5
  require('../common-CcfjYnPG.js');
6
6
  require('../common-vnMIelAE.js');
7
7
  require('../container-z621KfH5.js');
@@ -27,7 +27,7 @@ require('../EventWorkerContext-CSlD9rbx.js');
27
27
  require('../signals-DHdYrd-n.js');
28
28
  require('../constants-CUND8XkG.js');
29
29
  require('../MessageCommandParser-B_BEQ3p8.js');
30
- require('../CommandsRouter-Ci1Pe8Vd.js');
30
+ require('../CommandsRouter-tMAivEfv.js');
31
31
  require('../EventsRouter-C_J0M3uO.js');
32
32
  require('../router-DHnFRADH.js');
33
33
  require('../common-DNADUU3_.js');
@@ -1,4 +1,4 @@
1
- import { CommandKitConfig, DeepRequired } from "../analytics-engine-vA4MaJYx.js";
1
+ import { CommandKitConfig, DeepRequired } from "../analytics-engine-nkyqvYAE.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -1,7 +1,7 @@
1
1
  require('../colors-Cd4Oz-r-.js');
2
2
  require('../ActionRow-CmTHbo2t.js');
3
3
  require('../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../commandkit-DMEW0kJg.js');
4
+ const require_commandkit = require('../commandkit-5VMG2thU.js');
5
5
  require('../common-CcfjYnPG.js');
6
6
  require('../common-vnMIelAE.js');
7
7
  require('../container-z621KfH5.js');
@@ -27,7 +27,7 @@ require('../EventWorkerContext-CSlD9rbx.js');
27
27
  require('../signals-DHdYrd-n.js');
28
28
  require('../constants-CUND8XkG.js');
29
29
  require('../MessageCommandParser-B_BEQ3p8.js');
30
- require('../CommandsRouter-Ci1Pe8Vd.js');
30
+ require('../CommandsRouter-tMAivEfv.js');
31
31
  require('../EventsRouter-C_J0M3uO.js');
32
32
  require('../router-DHnFRADH.js');
33
33
  require('../common-DNADUU3_.js');
@@ -1,4 +1,4 @@
1
- import { CommandKitCompilerOptions, CommandKitConfig } from "../analytics-engine-vA4MaJYx.js";
1
+ import { CommandKitCompilerOptions, CommandKitConfig } from "../analytics-engine-nkyqvYAE.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -1,4 +1,4 @@
1
- import { DeepPartial, DeepRequired, ResolvedCommandKitConfig, mergeDeep } from "../analytics-engine-vA4MaJYx.js";
1
+ import { DeepPartial, DeepRequired, ResolvedCommandKitConfig, mergeDeep } from "../analytics-engine-nkyqvYAE.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -1,4 +1,4 @@
1
- import { CommandKitConfig, ResolvedCommandKitConfig } from "./analytics-engine-vA4MaJYx.js";
1
+ import { CommandKitConfig, ResolvedCommandKitConfig } from "./analytics-engine-nkyqvYAE.js";
2
2
 
3
3
  //#region src/config/config.d.ts
4
4
 
@@ -13,4 +13,4 @@ declare function getConfig(): ResolvedCommandKitConfig;
13
13
  declare function defineConfig(config?: Partial<CommandKitConfig>): ResolvedCommandKitConfig;
14
14
  //#endregion
15
15
  export { defineConfig, getConfig };
16
- //# sourceMappingURL=config-CcWJ-vz5.d.ts.map
16
+ //# sourceMappingURL=config-C1msSu1G.d.ts.map
@@ -16,4 +16,4 @@ declare enum SerializerType {
16
16
  }
17
17
  //#endregion
18
18
  export { SerializerType };
19
- //# sourceMappingURL=constants-DrjIvQd6.d.ts.map
19
+ //# sourceMappingURL=constants-D8PMA9on.d.ts.map
@@ -1,4 +1,4 @@
1
- import { AsyncFunction, GenericFunction, exitContext, getCommandKit, getContext, isCommandWorkerContext, makeContextAwareFunction, provideContext, useEnvironment } from "../analytics-engine-vA4MaJYx.js";
1
+ import { AsyncFunction, GenericFunction, exitContext, getCommandKit, getContext, isCommandWorkerContext, makeContextAwareFunction, provideContext, useEnvironment } from "../analytics-engine-nkyqvYAE.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -1,7 +1,7 @@
1
1
  require('../colors-Cd4Oz-r-.js');
2
2
  require('../ActionRow-CmTHbo2t.js');
3
3
  require('../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../commandkit-DMEW0kJg.js');
4
+ const require_commandkit = require('../commandkit-5VMG2thU.js');
5
5
  require('../common-CcfjYnPG.js');
6
6
  require('../common-vnMIelAE.js');
7
7
  require('../container-z621KfH5.js');
@@ -27,7 +27,7 @@ require('../EventWorkerContext-CSlD9rbx.js');
27
27
  require('../signals-DHdYrd-n.js');
28
28
  require('../constants-CUND8XkG.js');
29
29
  require('../MessageCommandParser-B_BEQ3p8.js');
30
- require('../CommandsRouter-Ci1Pe8Vd.js');
30
+ require('../CommandsRouter-tMAivEfv.js');
31
31
  require('../EventsRouter-C_J0M3uO.js');
32
32
  require('../router-DHnFRADH.js');
33
33
  require('../common-DNADUU3_.js');
@@ -1,4 +1,4 @@
1
- import { CommandKitEnvironment, CommandKitEnvironmentInternalData, CommandKitEnvironmentType, after, cancelAfter } from "../analytics-engine-vA4MaJYx.js";
1
+ import { CommandKitEnvironment, CommandKitEnvironmentInternalData, CommandKitEnvironmentType, after, cancelAfter } from "../analytics-engine-nkyqvYAE.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -1,7 +1,7 @@
1
1
  require('../colors-Cd4Oz-r-.js');
2
2
  require('../ActionRow-CmTHbo2t.js');
3
3
  require('../error-codes-C-ViHyu-.js');
4
- const require_commandkit = require('../commandkit-DMEW0kJg.js');
4
+ const require_commandkit = require('../commandkit-5VMG2thU.js');
5
5
  require('../common-CcfjYnPG.js');
6
6
  require('../common-vnMIelAE.js');
7
7
  require('../container-z621KfH5.js');
@@ -27,7 +27,7 @@ require('../EventWorkerContext-CSlD9rbx.js');
27
27
  require('../signals-DHdYrd-n.js');
28
28
  require('../constants-CUND8XkG.js');
29
29
  require('../MessageCommandParser-B_BEQ3p8.js');
30
- require('../CommandsRouter-Ci1Pe8Vd.js');
30
+ require('../CommandsRouter-tMAivEfv.js');
31
31
  require('../EventsRouter-C_J0M3uO.js');
32
32
  require('../router-DHnFRADH.js');
33
33
  require('../common-DNADUU3_.js');
@@ -0,0 +1,54 @@
1
+ //#region src/utils/error-codes.d.ts
2
+ /**
3
+ * The error codes used by CommandKit.
4
+ */
5
+ declare const CommandKitErrorCodes: {
6
+ /**
7
+ * Error code for exiting middleware.
8
+ */
9
+ readonly ExitMiddleware: symbol;
10
+ /**
11
+ * Error code for forwarded commands.
12
+ */
13
+ readonly ForwardedCommand: symbol;
14
+ /**
15
+ * Error code for invalid command prefix.
16
+ */
17
+ readonly InvalidCommandPrefix: symbol;
18
+ /**
19
+ * Error code for plugin capture handle.
20
+ */
21
+ readonly PluginCaptureHandle: symbol;
22
+ /**
23
+ * Error code for event interruption signal
24
+ */
25
+ readonly StopEvents: symbol;
26
+ };
27
+ /**
28
+ * The type for CommandKit errors.
29
+ */
30
+ type CommandKitError = Error & {
31
+ code: symbol;
32
+ };
33
+ /**
34
+ * Creates a new CommandKit error with the specified code.
35
+ * @param code The error code to assign to the error.
36
+ * @returns A new CommandKit error instance.
37
+ */
38
+ declare function createCommandKitError(code: symbol): CommandKitError;
39
+ /**
40
+ * Checks if the given error is a CommandKit error.
41
+ * @param error The error to check.
42
+ * @returns True if the error is a CommandKit error, false otherwise.
43
+ */
44
+ declare function isCommandKitError(error: unknown): error is CommandKitError;
45
+ /**
46
+ * Checks if the given error is of a specific CommandKit error type.
47
+ * @param error The error to check.
48
+ * @param code The error code or an array of error codes to check against.
49
+ * @returns True if the error matches the specified code(s), false otherwise.
50
+ */
51
+ declare function isErrorType(error: unknown, code: symbol | symbol[]): boolean;
52
+ //#endregion
53
+ export { CommandKitError, CommandKitErrorCodes, createCommandKitError, isCommandKitError, isErrorType };
54
+ //# sourceMappingURL=error-codes-BzoEctmD.d.ts.map
@@ -1,4 +1,4 @@
1
- import { CommandKitEventsChannel, ListenerFunction } from "../analytics-engine-vA4MaJYx.js";
1
+ import { CommandKitEventsChannel, ListenerFunction } from "../analytics-engine-nkyqvYAE.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -1,4 +1,4 @@
1
- const require_commandkit = require('./commandkit-DMEW0kJg.js');
1
+ const require_commandkit = require('./commandkit-5VMG2thU.js');
2
2
  const require_EventWorkerContext = require('./EventWorkerContext-CSlD9rbx.js');
3
3
  const require_constants = require('./constants-CUND8XkG.js');
4
4
 
@@ -162,4 +162,4 @@ Object.defineProperty(exports, 'setFlagProvider', {
162
162
  return setFlagProvider;
163
163
  }
164
164
  });
165
- //# sourceMappingURL=feature-flags-Cxl9JtVG.js.map
165
+ //# sourceMappingURL=feature-flags-C44dggkN.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"feature-flags-Cxl9JtVG.js","names":[],"sources":["../src/flags/feature-flags.ts"],"sourcesContent":["import { getCommandKit, getContext } from '../context/async-context';\nimport { eventWorkerContext } from '../app/events/EventWorkerContext';\nimport { ParsedEvent } from '../app/router';\nimport { CommandKit } from '../commandkit';\nimport {\n AutocompleteInteraction,\n ChatInputCommandInteraction,\n Client,\n ClientEvents,\n ContextMenuCommandInteraction,\n Guild,\n Message,\n TextBasedChannel,\n} from 'discord.js';\nimport { LoadedCommand } from '../app';\nimport { defer, JsonSerialize } from '../utils/utilities';\nimport { AnalyticsEvents } from '../analytics/constants';\nimport { FlagProvider, FlagConfiguration } from './FlagProvider';\nimport { Logger } from '../logger/Logger';\n\n// Global flag provider\nlet flagProvider: FlagProvider | null = null;\n\n/**\n * Set the global flag provider for all feature flags\n */\nexport function setFlagProvider(provider: FlagProvider): void {\n flagProvider = provider;\n}\n\n/**\n * @private\n */\nexport type MaybePromise<T> = T | Promise<T>;\n\n/**\n * Function type for identifying entities in the context of feature flags.\n * This function should return an object representing the entity that will be used\n * to evaluate the feature flag.\n * It can be synchronous or asynchronous.\n */\nexport type IdentifyFunction<R> = (\n context: EvaluationContext,\n) => MaybePromise<R>;\n\n/**\n * Function type for deciding the outcome of a feature flag based on the provided entities.\n * This function receives an object containing the entities and optionally the provider configuration,\n * and should return the result of the decision.\n * It can be synchronous or asynchronous.\n */\nexport type DecideFunction<E, R> = (data: {\n entities: E;\n provider?: FlagConfiguration | null;\n}) => MaybePromise<R>;\n\n/**\n * Definition for a feature flag, including its key, description, identify function,\n * and decide function.\n * The identify function is used to determine the entities that will be evaluated\n * against the feature flag, while the decide function contains the logic for\n * determining the outcome of the flag based on those entities.\n */\nexport interface FeatureFlagDefinition<R, Entity> {\n /**\n * Unique key for the feature flag.\n * Should be a string that identifies the flag.\n */\n key: string;\n /**\n * Optional description of the feature flag.\n * This can be used for documentation or debugging purposes.\n */\n description?: string;\n /**\n * Optional flag to enable integration with an external flag provider.\n * If true, the flag will use the global flag provider to determine its state.\n * Default: false\n */\n identify?: IdentifyFunction<Entity>;\n /**\n * Function to decide the outcome of the feature flag.\n * This function receives the identified entities and should return the result of the decision.\n */\n decide: DecideFunction<Entity, R>;\n /**\n * Whether to disable analytics tracking for this flag.\n * Default: false\n */\n disableAnalytics?: boolean;\n}\n\n/**\n * Context for evaluating command flags in CommandKit.\n */\nexport interface CommandFlagContext {\n /**\n * The Discord client instance.\n * This is the main entry point for interacting with the Discord API.\n */\n client: Client<true>;\n /**\n * The CommandKit instance, which provides access to the command framework.\n * This includes commands, events, and other features of CommandKit.\n */\n commandkit: CommandKit;\n /**\n * The command context, which includes information about the command being executed.\n * This can include the interaction, message, guild, channel, and the loaded command.\n */\n command: {\n /**\n * The interaction object if the command was invoked via an interaction.\n * This can be a ChatInputCommandInteraction, AutocompleteInteraction, or ContextMenuCommandInteraction.\n */\n interaction?:\n | ChatInputCommandInteraction\n | AutocompleteInteraction\n | ContextMenuCommandInteraction;\n /**\n * The message object if the command was invoked via a message.\n */\n message?: Message;\n /**\n * The guild where the command was invoked, if applicable.\n * This will be null for commands invoked in DMs.\n */\n guild: Guild | null;\n /**\n * The channel where the command was invoked.\n * This can be a text channel, DM channel, or any other type of text-based channel.\n */\n channel: TextBasedChannel | null;\n /**\n * The loaded command instance that is being executed.\n * This contains the command's metadata and logic.\n */\n command: LoadedCommand;\n };\n /**\n * The event context is null for command flags, as they are not tied to a specific event.\n * This is used to differentiate between command and event flags.\n */\n event: null;\n}\n\n/**\n * Context for evaluating event flags in CommandKit.\n */\nexport interface EventFlagContext {\n /**\n * The Discord client instance.\n * This is the main entry point for interacting with the Discord API.\n */\n client: Client<true>;\n /**\n * The CommandKit instance, which provides access to the command framework.\n * This includes commands, events, and other features of CommandKit.\n */\n commandkit: CommandKit;\n /**\n * The event context, which includes information about the event being processed.\n * This can include the parsed event data, the event name, and the namespace if applicable.\n */\n event: {\n /**\n * The parsed event data, which contains the raw data from the event.\n * This can include information like user IDs, channel IDs, and other relevant data.\n */\n data: ParsedEvent;\n /**\n * The name of the event being processed.\n * This is the string identifier for the event, such as 'messageCreate' or 'guildMemberAdd'.\n */\n event: string;\n /**\n * The namespace of the event, if applicable.\n * This can be used to group related events or commands together.\n * It is null if the event does not belong to a specific namespace.\n */\n namespace: string | null;\n /**\n * The arguments passed to the event handler.\n * This is an array of arguments that were passed when the event was triggered.\n * It can be used to access specific data related to the event.\n */\n arguments: any[];\n /**\n * A function to retrieve the arguments for a specific event type.\n * This allows for type-safe access to the arguments based on the event name.\n * @param event - The name of the event to retrieve arguments for.\n */\n argumentsAs<E extends keyof ClientEvents>(event: E): ClientEvents[E];\n };\n /**\n * The command context is null for event flags, as they are not tied to a specific command.\n * This is used to differentiate between command and event flags.\n */\n command: null;\n}\n\n/**\n * Combined context type for feature flag evaluation.\n */\nexport type EvaluationContext = CommandFlagContext | EventFlagContext;\n\n/**\n * Function type for custom evaluation of feature flags.\n * This function can be used to provide a custom evaluation context for the flag.\n * It should return an object representing the entities to be evaluated.\n */\nexport type CustomEvaluationFunction<E> = () => MaybePromise<E>;\n\n/**\n * Context for custom evaluation of feature flags.\n * This allows for more flexible evaluation based on custom logic or external data.\n * The identify function can be a direct object or a function that returns the entities.\n */\nexport type CustomEvaluationContext<E> = {\n /**\n * Optional function to identify the entities for evaluation.\n * This can be a function that returns the entities based on the current context.\n */\n identify: E | CustomEvaluationFunction<E>;\n};\n\nexport interface FlagRunner<E, R> {\n /**\n * Execute the feature flag evaluation with the provided entities.\n * This method will run the identify and decide functions to determine the flag's outcome.\n * @param res - Optional entities to use for evaluation. If not provided, it will call the identify function.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n (): Promise<R>;\n /**\n * Run the feature flag evaluation with a custom context.\n * This allows for more flexible evaluation based on custom logic or external data.\n * @param context - The custom evaluation context containing the identify function or object.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n run(context: CustomEvaluationContext<E>): Promise<R>;\n}\n\n/**\n * Class representing a feature flag in CommandKit.\n */\nexport class FeatureFlag<R, T> {\n private commandkit: CommandKit;\n\n /**\n * Create a new feature flag.\n * @param options - The options for the feature flag.\n */\n public constructor(public readonly options: FeatureFlagDefinition<R, T>) {\n this.commandkit = getCommandKit(true);\n const FlagStore = this.commandkit.flags;\n\n if (FlagStore.has(options.key)) {\n throw new Error(`Feature flag with key \"${options.key}\" already exists.`);\n }\n\n FlagStore.set(options.key, this);\n }\n\n private getContext(): EvaluationContext {\n const env = getContext();\n\n if (env?.context) {\n const {\n client,\n commandkit,\n interaction,\n message,\n guild,\n channel,\n command,\n } = env.context;\n\n return {\n client: client as Client<true>,\n commandkit,\n command: {\n interaction,\n message,\n guild,\n channel,\n command,\n },\n event: null,\n };\n }\n\n const eventCtx = eventWorkerContext.getStore();\n\n if (eventCtx) {\n const { commandkit, data, event, namespace } = eventCtx;\n\n return {\n client: commandkit.client as Client<true>,\n commandkit,\n event: {\n data,\n event,\n namespace,\n arguments: eventCtx.arguments,\n argumentsAs: (eventName) => {\n const args = eventCtx.arguments as ClientEvents[typeof eventName];\n return args;\n },\n },\n command: null,\n };\n }\n\n throw new Error(\n 'Could not determine the execution context. Feature flags may only be used inside a command or event.',\n );\n }\n\n /**\n * Execute the feature flag evaluation.\n * @param res - Optional entities to use for evaluation. If not provided, it will call the identify function.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n public async execute(res?: T): Promise<R> {\n const { decide, identify, disableAnalytics } = this.options;\n\n const identificationStart = performance.now();\n const entities =\n res ??\n (await (async () => {\n const ctx = this.getContext();\n return (await identify?.(ctx)) ?? ({} as T);\n })());\n const identificationTime = performance.now() - identificationStart;\n\n // Get provider configuration if global provider is available\n let providerConfig: FlagConfiguration | null = null;\n if (flagProvider) {\n try {\n providerConfig = await flagProvider.getFlag(this.options.key, entities);\n\n // If provider says flag is disabled, return early with default behavior\n if (providerConfig && !providerConfig.enabled) {\n // For boolean flags, return false; for others, let decide function handle it\n if (typeof decide === 'function') {\n const decisionResult = await decide({\n entities,\n provider: providerConfig,\n });\n return decisionResult as R;\n }\n }\n } catch (error) {\n Logger.error(\n `Error fetching flag provider configuration for \"${this.options.key}\": ${error}`,\n );\n // continue with local decision if provider fails\n }\n }\n\n const decisionStart = performance.now();\n const decisionResult = await decide({\n entities,\n provider: providerConfig,\n });\n const decisionTime = performance.now() - decisionStart;\n\n // Skip analytics if disabled\n if (!disableAnalytics) {\n defer(async () => {\n await this.commandkit.analytics.track({\n name: AnalyticsEvents.FEATURE_FLAG_METRICS,\n data: {\n flag: this.options.key,\n identificationTime: identificationTime.toFixed(2),\n decisionTime: decisionTime.toFixed(2),\n usedProvider: flagProvider !== null,\n providerEnabled: providerConfig?.enabled ?? null,\n },\n });\n });\n\n defer(async () => {\n await this.commandkit.analytics.track({\n name: AnalyticsEvents.FEATURE_FLAG_DECISION,\n id:\n entities &&\n typeof entities === 'object' &&\n 'id' in entities &&\n typeof entities.id === 'string'\n ? entities.id\n : undefined,\n data: {\n flag: this.options.key,\n decision: JsonSerialize(decisionResult, 'unknown'),\n providerUsed: flagProvider !== null,\n },\n });\n });\n }\n\n return decisionResult as R;\n }\n}\n\n/**\n * Create a new feature flag.\n * @param options - The options for the feature flag.\n * @returns A new instance of the FeatureFlag class.\n */\nexport function flag<Returns = boolean, Entity = Record<any, any>>(\n options: FeatureFlagDefinition<Returns, Entity>,\n): FlagRunner<Entity, Returns> {\n const flag = new FeatureFlag<Returns, Entity>(options);\n const runner = flag.execute.bind(flag, undefined) as FlagRunner<\n Entity,\n Returns\n >;\n\n runner.run = async function (ctx) {\n if (!ctx?.identify) {\n throw new Error(\n 'Custom evaluation context must have an identify function or object.',\n );\n }\n\n const context = (\n typeof ctx === 'function'\n ? await (ctx as CustomEvaluationFunction<Entity>)()\n : ctx\n ) as Entity;\n\n const decisionResult = await flag.execute(context);\n\n return decisionResult;\n };\n\n return runner;\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"feature-flags-C44dggkN.js","names":[],"sources":["../src/flags/feature-flags.ts"],"sourcesContent":["import { getCommandKit, getContext } from '../context/async-context';\nimport { eventWorkerContext } from '../app/events/EventWorkerContext';\nimport { ParsedEvent } from '../app/router';\nimport { CommandKit } from '../commandkit';\nimport {\n AutocompleteInteraction,\n ChatInputCommandInteraction,\n Client,\n ClientEvents,\n ContextMenuCommandInteraction,\n Guild,\n Message,\n TextBasedChannel,\n} from 'discord.js';\nimport { LoadedCommand } from '../app';\nimport { defer, JsonSerialize } from '../utils/utilities';\nimport { AnalyticsEvents } from '../analytics/constants';\nimport { FlagProvider, FlagConfiguration } from './FlagProvider';\nimport { Logger } from '../logger/Logger';\n\n// Global flag provider\nlet flagProvider: FlagProvider | null = null;\n\n/**\n * Set the global flag provider for all feature flags\n */\nexport function setFlagProvider(provider: FlagProvider): void {\n flagProvider = provider;\n}\n\n/**\n * @private\n */\nexport type MaybePromise<T> = T | Promise<T>;\n\n/**\n * Function type for identifying entities in the context of feature flags.\n * This function should return an object representing the entity that will be used\n * to evaluate the feature flag.\n * It can be synchronous or asynchronous.\n */\nexport type IdentifyFunction<R> = (\n context: EvaluationContext,\n) => MaybePromise<R>;\n\n/**\n * Function type for deciding the outcome of a feature flag based on the provided entities.\n * This function receives an object containing the entities and optionally the provider configuration,\n * and should return the result of the decision.\n * It can be synchronous or asynchronous.\n */\nexport type DecideFunction<E, R> = (data: {\n entities: E;\n provider?: FlagConfiguration | null;\n}) => MaybePromise<R>;\n\n/**\n * Definition for a feature flag, including its key, description, identify function,\n * and decide function.\n * The identify function is used to determine the entities that will be evaluated\n * against the feature flag, while the decide function contains the logic for\n * determining the outcome of the flag based on those entities.\n */\nexport interface FeatureFlagDefinition<R, Entity> {\n /**\n * Unique key for the feature flag.\n * Should be a string that identifies the flag.\n */\n key: string;\n /**\n * Optional description of the feature flag.\n * This can be used for documentation or debugging purposes.\n */\n description?: string;\n /**\n * Optional flag to enable integration with an external flag provider.\n * If true, the flag will use the global flag provider to determine its state.\n * Default: false\n */\n identify?: IdentifyFunction<Entity>;\n /**\n * Function to decide the outcome of the feature flag.\n * This function receives the identified entities and should return the result of the decision.\n */\n decide: DecideFunction<Entity, R>;\n /**\n * Whether to disable analytics tracking for this flag.\n * Default: false\n */\n disableAnalytics?: boolean;\n}\n\n/**\n * Context for evaluating command flags in CommandKit.\n */\nexport interface CommandFlagContext {\n /**\n * The Discord client instance.\n * This is the main entry point for interacting with the Discord API.\n */\n client: Client<true>;\n /**\n * The CommandKit instance, which provides access to the command framework.\n * This includes commands, events, and other features of CommandKit.\n */\n commandkit: CommandKit;\n /**\n * The command context, which includes information about the command being executed.\n * This can include the interaction, message, guild, channel, and the loaded command.\n */\n command: {\n /**\n * The interaction object if the command was invoked via an interaction.\n * This can be a ChatInputCommandInteraction, AutocompleteInteraction, or ContextMenuCommandInteraction.\n */\n interaction?:\n | ChatInputCommandInteraction\n | AutocompleteInteraction\n | ContextMenuCommandInteraction;\n /**\n * The message object if the command was invoked via a message.\n */\n message?: Message;\n /**\n * The guild where the command was invoked, if applicable.\n * This will be null for commands invoked in DMs.\n */\n guild: Guild | null;\n /**\n * The channel where the command was invoked.\n * This can be a text channel, DM channel, or any other type of text-based channel.\n */\n channel: TextBasedChannel | null;\n /**\n * The loaded command instance that is being executed.\n * This contains the command's metadata and logic.\n */\n command: LoadedCommand;\n };\n /**\n * The event context is null for command flags, as they are not tied to a specific event.\n * This is used to differentiate between command and event flags.\n */\n event: null;\n}\n\n/**\n * Context for evaluating event flags in CommandKit.\n */\nexport interface EventFlagContext {\n /**\n * The Discord client instance.\n * This is the main entry point for interacting with the Discord API.\n */\n client: Client<true>;\n /**\n * The CommandKit instance, which provides access to the command framework.\n * This includes commands, events, and other features of CommandKit.\n */\n commandkit: CommandKit;\n /**\n * The event context, which includes information about the event being processed.\n * This can include the parsed event data, the event name, and the namespace if applicable.\n */\n event: {\n /**\n * The parsed event data, which contains the raw data from the event.\n * This can include information like user IDs, channel IDs, and other relevant data.\n */\n data: ParsedEvent;\n /**\n * The name of the event being processed.\n * This is the string identifier for the event, such as 'messageCreate' or 'guildMemberAdd'.\n */\n event: string;\n /**\n * The namespace of the event, if applicable.\n * This can be used to group related events or commands together.\n * It is null if the event does not belong to a specific namespace.\n */\n namespace: string | null;\n /**\n * The arguments passed to the event handler.\n * This is an array of arguments that were passed when the event was triggered.\n * It can be used to access specific data related to the event.\n */\n arguments: any[];\n /**\n * A function to retrieve the arguments for a specific event type.\n * This allows for type-safe access to the arguments based on the event name.\n * @param event - The name of the event to retrieve arguments for.\n */\n argumentsAs<E extends keyof ClientEvents>(event: E): ClientEvents[E];\n };\n /**\n * The command context is null for event flags, as they are not tied to a specific command.\n * This is used to differentiate between command and event flags.\n */\n command: null;\n}\n\n/**\n * Combined context type for feature flag evaluation.\n */\nexport type EvaluationContext = CommandFlagContext | EventFlagContext;\n\n/**\n * Function type for custom evaluation of feature flags.\n * This function can be used to provide a custom evaluation context for the flag.\n * It should return an object representing the entities to be evaluated.\n */\nexport type CustomEvaluationFunction<E> = () => MaybePromise<E>;\n\n/**\n * Context for custom evaluation of feature flags.\n * This allows for more flexible evaluation based on custom logic or external data.\n * The identify function can be a direct object or a function that returns the entities.\n */\nexport type CustomEvaluationContext<E> = {\n /**\n * Optional function to identify the entities for evaluation.\n * This can be a function that returns the entities based on the current context.\n */\n identify: E | CustomEvaluationFunction<E>;\n};\n\nexport interface FlagRunner<E, R> {\n /**\n * Execute the feature flag evaluation with the provided entities.\n * This method will run the identify and decide functions to determine the flag's outcome.\n * @param res - Optional entities to use for evaluation. If not provided, it will call the identify function.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n (): Promise<R>;\n /**\n * Run the feature flag evaluation with a custom context.\n * This allows for more flexible evaluation based on custom logic or external data.\n * @param context - The custom evaluation context containing the identify function or object.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n run(context: CustomEvaluationContext<E>): Promise<R>;\n}\n\n/**\n * Class representing a feature flag in CommandKit.\n */\nexport class FeatureFlag<R, T> {\n private commandkit: CommandKit;\n\n /**\n * Create a new feature flag.\n * @param options - The options for the feature flag.\n */\n public constructor(public readonly options: FeatureFlagDefinition<R, T>) {\n this.commandkit = getCommandKit(true);\n const FlagStore = this.commandkit.flags;\n\n if (FlagStore.has(options.key)) {\n throw new Error(`Feature flag with key \"${options.key}\" already exists.`);\n }\n\n FlagStore.set(options.key, this);\n }\n\n private getContext(): EvaluationContext {\n const env = getContext();\n\n if (env?.context) {\n const {\n client,\n commandkit,\n interaction,\n message,\n guild,\n channel,\n command,\n } = env.context;\n\n return {\n client: client as Client<true>,\n commandkit,\n command: {\n interaction,\n message,\n guild,\n channel,\n command,\n },\n event: null,\n };\n }\n\n const eventCtx = eventWorkerContext.getStore();\n\n if (eventCtx) {\n const { commandkit, data, event, namespace } = eventCtx;\n\n return {\n client: commandkit.client as Client<true>,\n commandkit,\n event: {\n data,\n event,\n namespace,\n arguments: eventCtx.arguments,\n argumentsAs: (eventName) => {\n const args = eventCtx.arguments as ClientEvents[typeof eventName];\n return args;\n },\n },\n command: null,\n };\n }\n\n throw new Error(\n 'Could not determine the execution context. Feature flags may only be used inside a command or event.',\n );\n }\n\n /**\n * Execute the feature flag evaluation.\n * @param res - Optional entities to use for evaluation. If not provided, it will call the identify function.\n * @returns A promise that resolves to the result of the feature flag evaluation.\n */\n public async execute(res?: T): Promise<R> {\n const { decide, identify, disableAnalytics } = this.options;\n\n const identificationStart = performance.now();\n const entities =\n res ??\n (await (async () => {\n const ctx = this.getContext();\n return (await identify?.(ctx)) ?? ({} as T);\n })());\n const identificationTime = performance.now() - identificationStart;\n\n // Get provider configuration if global provider is available\n let providerConfig: FlagConfiguration | null = null;\n if (flagProvider) {\n try {\n providerConfig = await flagProvider.getFlag(this.options.key, entities);\n\n // If provider says flag is disabled, return early with default behavior\n if (providerConfig && !providerConfig.enabled) {\n // For boolean flags, return false; for others, let decide function handle it\n if (typeof decide === 'function') {\n const decisionResult = await decide({\n entities,\n provider: providerConfig,\n });\n return decisionResult as R;\n }\n }\n } catch (error) {\n Logger.error(\n `Error fetching flag provider configuration for \"${this.options.key}\": ${error}`,\n );\n // continue with local decision if provider fails\n }\n }\n\n const decisionStart = performance.now();\n const decisionResult = await decide({\n entities,\n provider: providerConfig,\n });\n const decisionTime = performance.now() - decisionStart;\n\n // Skip analytics if disabled\n if (!disableAnalytics) {\n defer(async () => {\n await this.commandkit.analytics.track({\n name: AnalyticsEvents.FEATURE_FLAG_METRICS,\n data: {\n flag: this.options.key,\n identificationTime: identificationTime.toFixed(2),\n decisionTime: decisionTime.toFixed(2),\n usedProvider: flagProvider !== null,\n providerEnabled: providerConfig?.enabled ?? null,\n },\n });\n });\n\n defer(async () => {\n await this.commandkit.analytics.track({\n name: AnalyticsEvents.FEATURE_FLAG_DECISION,\n id:\n entities &&\n typeof entities === 'object' &&\n 'id' in entities &&\n typeof entities.id === 'string'\n ? entities.id\n : undefined,\n data: {\n flag: this.options.key,\n decision: JsonSerialize(decisionResult, 'unknown'),\n providerUsed: flagProvider !== null,\n },\n });\n });\n }\n\n return decisionResult as R;\n }\n}\n\n/**\n * Create a new feature flag.\n * @param options - The options for the feature flag.\n * @returns A new instance of the FeatureFlag class.\n */\nexport function flag<Returns = boolean, Entity = Record<any, any>>(\n options: FeatureFlagDefinition<Returns, Entity>,\n): FlagRunner<Entity, Returns> {\n const flag = new FeatureFlag<Returns, Entity>(options);\n const runner = flag.execute.bind(flag, undefined) as FlagRunner<\n Entity,\n Returns\n >;\n\n runner.run = async function (ctx) {\n if (!ctx?.identify) {\n throw new Error(\n 'Custom evaluation context must have an identify function or object.',\n );\n }\n\n const context = (\n typeof ctx === 'function'\n ? await (ctx as CustomEvaluationFunction<Entity>)()\n : ctx\n ) as Entity;\n\n const decisionResult = await flag.execute(context);\n\n return decisionResult;\n };\n\n return runner;\n}\n"],"mappings":"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"}
@@ -1,4 +1,4 @@
1
- import { FlagConfiguration, FlagProvider, JsonFlagProvider } from "../analytics-engine-vA4MaJYx.js";
1
+ import { FlagConfiguration, FlagProvider, JsonFlagProvider } from "../analytics-engine-nkyqvYAE.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -1,4 +1,4 @@
1
- import { CommandFlagContext, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, EvaluationContext, EventFlagContext, FeatureFlag, FeatureFlagDefinition, FlagRunner, IdentifyFunction, MaybePromise, flag, setFlagProvider } from "../analytics-engine-vA4MaJYx.js";
1
+ import { CommandFlagContext, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, EvaluationContext, EventFlagContext, FeatureFlag, FeatureFlagDefinition, FlagRunner, IdentifyFunction, MaybePromise, flag, setFlagProvider } from "../analytics-engine-nkyqvYAE.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";
@@ -1,7 +1,7 @@
1
1
  require('../colors-Cd4Oz-r-.js');
2
2
  require('../ActionRow-CmTHbo2t.js');
3
3
  require('../error-codes-C-ViHyu-.js');
4
- require('../commandkit-DMEW0kJg.js');
4
+ require('../commandkit-5VMG2thU.js');
5
5
  require('../common-CcfjYnPG.js');
6
6
  require('../common-vnMIelAE.js');
7
7
  require('../container-z621KfH5.js');
@@ -27,13 +27,13 @@ require('../EventWorkerContext-CSlD9rbx.js');
27
27
  require('../signals-DHdYrd-n.js');
28
28
  require('../constants-CUND8XkG.js');
29
29
  require('../MessageCommandParser-B_BEQ3p8.js');
30
- require('../CommandsRouter-Ci1Pe8Vd.js');
30
+ require('../CommandsRouter-tMAivEfv.js');
31
31
  require('../EventsRouter-C_J0M3uO.js');
32
32
  require('../router-DHnFRADH.js');
33
33
  require('../common-DNADUU3_.js');
34
34
  require('../CommandKitEventsChannel-Bgw0XCOl.js');
35
35
  require('../store-CiqLHedg.js');
36
- const require_feature_flags = require('../feature-flags-Cxl9JtVG.js');
36
+ const require_feature_flags = require('../feature-flags-C44dggkN.js');
37
37
 
38
38
  exports.FeatureFlag = require_feature_flags.FeatureFlag;
39
39
  exports.flag = require_feature_flags.flag;
@@ -1,4 +1,4 @@
1
- import { FlagStore } from "../analytics-engine-vA4MaJYx.js";
1
+ import { FlagStore } from "../analytics-engine-nkyqvYAE.js";
2
2
  import "../EventInterceptor-x-R2qshQ.js";
3
3
  import "../ButtonKit-C7r7RPNf.js";
4
4
  import "../ModalKit-Btz58KYn.js";