commandkit 1.2.0-rc.9 → 1.2.1
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.
- package/LICENSE +19 -3
- package/README.md +45 -26
- package/bin/index.mjs +1 -1
- package/cli.d.ts +19 -0
- package/config.cjs +3 -0
- package/config.d.ts +1 -0
- package/dist/{ActionRow-DKnFVDME.d.ts → ActionRow-Bt9qi0Mb.d.ts} +4 -5
- package/dist/{Button-4ZUXdA56.d.ts → Button-DxJLcZIU.d.ts} +7 -8
- package/dist/{ButtonKit-C7r7RPNf.d.ts → ButtonKit-BfcyvWfj.d.ts} +4 -5
- package/dist/{ChannelSelectMenuKit-BrXvBYNH.d.ts → ChannelSelectMenuKit-DYkudikb.d.ts} +5 -6
- package/dist/{CommandsRouter-CoOA7hkf.d.ts → CommandsRouter-DiNoF0dq.d.ts} +2 -3
- package/dist/{EventInterceptor-x-R2qshQ.d.ts → EventInterceptor-D9JKMcfi.d.ts} +2 -2
- package/dist/{EventsRouter-BacqK6z3.d.ts → EventsRouter-EuuSu6NH.d.ts} +2 -2
- package/dist/{MentionableSelectMenuKit-CPTKqx-O.d.ts → MentionableSelectMenuKit-Mu4xqP6B.d.ts} +5 -6
- package/dist/{MessageCommandParser-ROLibZPX.d.ts → MessageCommandParser-DPCbHXCS.d.ts} +4 -5
- package/dist/{Modal-C6UTRdYQ.d.ts → Modal-v9rrcMl-.d.ts} +25 -12
- package/dist/{ModalKit-Btz58KYn.d.ts → ModalKit-XJSM65SV.d.ts} +4 -5
- package/dist/{RoleSelectMenuKit-C26lU3sN.d.ts → RoleSelectMenuKit-CCjcp3HY.d.ts} +5 -6
- package/dist/{SelectMenu-Diy87_ba.d.ts → SelectMenu-CY0vvoSu.d.ts} +17 -14
- package/dist/{StringSelectMenuKit-Bhs8U6WI.d.ts → StringSelectMenuKit-G5nBTicX.d.ts} +5 -6
- package/dist/{UserSelectMenuKit-CfqFJdxz.d.ts → UserSelectMenuKit-D3SO_fXA.d.ts} +5 -6
- package/dist/analytics/analytics-engine.d.ts +1 -31
- package/dist/analytics/analytics-engine.js +2 -36
- package/dist/analytics/analytics-provider.d.ts +1 -31
- package/dist/analytics/analytics-provider.js +1 -0
- package/dist/analytics/constants.js +26 -3
- package/dist/analytics/constants.js.map +1 -0
- package/dist/analytics/utils.js +2 -36
- package/dist/{analytics-engine-B7JNRnEN.d.ts → analytics-engine-DnRsHBId.d.ts} +48 -34
- package/dist/app/commands/AppCommandRunner.d.ts +1 -31
- package/dist/app/commands/AppCommandRunner.js +2 -36
- package/dist/app/commands/Context.d.ts +1 -31
- package/dist/app/commands/Context.js +2 -36
- package/dist/app/commands/MessageCommandParser.d.ts +1 -1
- package/dist/app/commands/MessageCommandParser.js +261 -4
- package/dist/app/commands/MessageCommandParser.js.map +1 -0
- package/dist/app/commands/helpers.d.ts +1 -1
- package/dist/app/commands/helpers.js +25 -3
- package/dist/app/commands/helpers.js.map +1 -0
- package/dist/app/events/EventWorkerContext.d.ts +42 -33
- package/dist/app/events/EventWorkerContext.js +48 -5
- package/dist/app/events/EventWorkerContext.js.map +1 -0
- package/dist/app/handlers/AppCommandHandler.d.ts +1 -31
- package/dist/app/handlers/AppCommandHandler.js +2 -36
- package/dist/app/handlers/AppEventsHandler.d.ts +1 -31
- package/dist/app/handlers/AppEventsHandler.js +2 -36
- package/dist/app/index.d.ts +4 -31
- package/dist/app/index.js +13 -45
- package/dist/app/interrupt/signals.d.ts +1 -1
- package/dist/app/interrupt/signals.js +54 -7
- package/dist/app/interrupt/signals.js.map +1 -0
- package/dist/app/middlewares/permissions.d.ts +1 -31
- package/dist/app/middlewares/permissions.js +2 -36
- package/dist/app/register/CommandRegistrar.d.ts +1 -31
- package/dist/app/register/CommandRegistrar.js +2 -36
- package/dist/app/router/CommandsRouter.d.ts +1 -1
- package/dist/app/router/CommandsRouter.js +210 -2
- package/dist/app/router/CommandsRouter.js.map +1 -0
- package/dist/app/router/EventsRouter.d.ts +1 -1
- package/dist/app/router/EventsRouter.js +128 -2
- package/dist/app/router/EventsRouter.js.map +1 -0
- package/dist/app/router/index.d.ts +2 -3
- package/dist/app/router/index.js +5 -5
- package/dist/{chunk-nOFOJqeH.js → chunk-BE-pF4vm.js} +11 -7
- package/dist/cli/app-process.d.ts +2 -3
- package/dist/cli/app-process.js +60 -7
- package/dist/cli/app-process.js.map +1 -0
- package/dist/cli/build.d.ts +2 -31
- package/dist/cli/build.js +171 -41
- package/dist/cli/build.js.map +1 -0
- package/dist/cli/common.d.ts +10 -34
- package/dist/cli/common.js +182 -11
- package/dist/cli/common.js.map +1 -0
- package/dist/cli/development.d.ts +18 -1
- package/dist/cli/development.js +52 -78
- package/dist/cli/development.js.map +1 -1
- package/dist/cli/env.d.ts +4 -0
- package/dist/cli/env.js +73 -9
- package/dist/cli/env.js.map +1 -0
- package/dist/cli/generators.js +10 -13
- package/dist/cli/generators.js.map +1 -1
- package/dist/cli/information.js +11 -10
- package/dist/cli/information.js.map +1 -1
- package/dist/cli/init.d.ts +12 -2
- package/dist/cli/init.js +83 -38
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/production.d.ts +2 -3
- package/dist/cli/production.js +19 -52
- package/dist/cli/production.js.map +1 -1
- package/dist/cli/type-checker.js +83 -6
- package/dist/cli/type-checker.js.map +1 -0
- package/dist/cli/utils.d.ts +0 -1
- package/dist/cli/utils.js +18 -2
- package/dist/cli/utils.js.map +1 -0
- package/dist/{commandkit-Bm0gLN8i.js → commandkit-Bh7C1_c7.js} +3219 -2616
- package/dist/commandkit-Bh7C1_c7.js.map +1 -0
- package/dist/commandkit.d.ts +1 -31
- package/dist/commandkit.js +2 -36
- package/dist/{common-DOCvOVC4.d.ts → common-CCvvgnxi.d.ts} +4 -5
- package/dist/components/common/EventInterceptor.d.ts +1 -1
- package/dist/components/common/EventInterceptor.js +137 -2
- package/dist/components/common/EventInterceptor.js.map +1 -0
- package/dist/components/common/element.d.ts +2 -5
- package/dist/components/common/element.js +10 -8
- package/dist/components/common/types.d.ts +1 -1
- package/dist/components/common/types.js +1 -1
- package/dist/components/{v2 → display}/common.d.ts +1 -2
- package/dist/components/display/common.js +4 -0
- package/dist/components/display/container.d.ts +2 -0
- package/dist/components/display/container.js +4 -0
- package/dist/components/display/file.d.ts +2 -0
- package/dist/{file-DVOELoNv.js → components/display/file.js} +5 -10
- package/dist/components/display/file.js.map +1 -0
- package/dist/components/display/index.d.ts +9 -0
- package/dist/components/display/index.js +19 -0
- package/dist/components/display/label.d.ts +2 -0
- package/dist/components/display/label.js +4 -0
- package/dist/components/display/media-gallery.d.ts +2 -0
- package/dist/components/display/media-gallery.js +5 -0
- package/dist/components/display/poll.d.ts +2 -0
- package/dist/components/display/poll.js +86 -0
- package/dist/components/display/poll.js.map +1 -0
- package/dist/components/display/section.d.ts +2 -0
- package/dist/components/display/section.js +5 -0
- package/dist/components/display/separator.d.ts +2 -0
- package/dist/{separator-DL6QH5H1.js → components/display/separator.js} +5 -10
- package/dist/components/display/separator.js.map +1 -0
- package/dist/components/display/text-display.d.ts +2 -0
- package/dist/{text-display-DbMumig_.js → components/display/text-display.js} +5 -10
- package/dist/components/display/text-display.js.map +1 -0
- package/dist/components/index.d.ts +23 -24
- package/dist/components/index.js +29 -53
- package/dist/components/interactive/action-row/ActionRow.d.ts +2 -0
- package/dist/{ActionRow-CbdGFWMT.js → components/interactive/action-row/ActionRow.js} +5 -10
- package/dist/components/interactive/action-row/ActionRow.js.map +1 -0
- package/dist/components/interactive/button/Button.d.ts +2 -0
- package/dist/components/interactive/button/Button.js +4 -0
- package/dist/components/interactive/button/ButtonKit.d.ts +2 -0
- package/dist/components/interactive/button/ButtonKit.js +4 -0
- package/dist/components/interactive/modal/Modal.d.ts +2 -0
- package/dist/components/interactive/modal/Modal.js +8 -0
- package/dist/components/interactive/modal/ModalKit.d.ts +2 -0
- package/dist/components/interactive/modal/ModalKit.js +4 -0
- package/dist/components/interactive/select-menu/ChannelSelectMenuKit.d.ts +2 -0
- package/dist/components/interactive/select-menu/ChannelSelectMenuKit.js +4 -0
- package/dist/components/interactive/select-menu/MentionableSelectMenuKit.d.ts +2 -0
- package/dist/components/interactive/select-menu/MentionableSelectMenuKit.js +4 -0
- package/dist/components/interactive/select-menu/RoleSelectMenuKit.d.ts +2 -0
- package/dist/components/interactive/select-menu/RoleSelectMenuKit.js +4 -0
- package/dist/components/interactive/select-menu/SelectMenu.d.ts +2 -0
- package/dist/components/interactive/select-menu/SelectMenu.js +9 -0
- package/dist/components/interactive/select-menu/StringSelectMenuKit.d.ts +2 -0
- package/dist/components/interactive/select-menu/StringSelectMenuKit.js +4 -0
- package/dist/components/interactive/select-menu/UserSelectMenuKit.d.ts +2 -0
- package/dist/components/interactive/select-menu/UserSelectMenuKit.js +4 -0
- package/dist/components/interactive/select-menu/common.d.ts +2 -0
- package/dist/components/interactive/select-menu/common.js +1 -0
- package/dist/config/config.d.ts +15 -33
- package/dist/config/config.js +2 -36
- package/dist/config/default.d.ts +1 -31
- package/dist/config/default.js +2 -36
- package/dist/config/loader.d.ts +1 -31
- package/dist/config/loader.js +2 -36
- package/dist/config/types.d.ts +1 -31
- package/dist/config/types.js +1 -0
- package/dist/config/utils.d.ts +1 -31
- package/dist/config/utils.js +29 -2
- package/dist/config/utils.js.map +1 -0
- package/dist/{constants-D8PMA9on.d.ts → constants-DqtJY0t-.d.ts} +3 -3
- package/dist/{constants-MKu-Q1jh.d.ts → constants-DwxpkIeH.d.ts} +8 -2
- package/dist/{container-DHBELeJ3.d.ts → container-CYojOA9d.d.ts} +3 -4
- package/dist/context/async-context.d.ts +1 -31
- package/dist/context/async-context.js +2 -36
- package/dist/context/environment.d.ts +1 -31
- package/dist/context/environment.js +2 -36
- package/dist/{element-CAXu1XtK.d.ts → element-DeLvTMfZ.d.ts} +5 -5
- package/dist/events/CommandKitEventsChannel.d.ts +1 -31
- package/dist/events/CommandKitEventsChannel.js +83 -2
- package/dist/events/CommandKitEventsChannel.js.map +1 -0
- package/dist/{file-DTrr-p09.d.ts → file-DLO1zEcH.d.ts} +3 -4
- package/dist/flags/FlagProvider.d.ts +1 -31
- package/dist/flags/FlagProvider.js +1 -0
- package/dist/flags/FlagProvider.js.map +1 -1
- package/dist/flags/feature-flags.d.ts +1 -31
- package/dist/flags/feature-flags.js +5 -40
- package/dist/flags/store.d.ts +1 -31
- package/dist/flags/store.js +13 -2
- package/dist/flags/store.js.map +1 -0
- package/dist/{helpers-Wg6P5fRQ.d.ts → helpers-zmC44Mcu.d.ts} +2 -3
- package/dist/index-BIsCUWAs.d.ts +1 -0
- package/dist/index-CwHYpK-f.d.ts +1 -0
- package/dist/index-DHrsNvX1.d.ts +1 -0
- package/dist/index.d.ts +41 -42
- package/dist/index.js +80 -98
- package/dist/kv/constants.d.ts +1 -1
- package/dist/kv/constants.js +22 -2
- package/dist/kv/constants.js.map +1 -0
- package/dist/kv/dotprops.js +26 -3
- package/dist/kv/dotprops.js.map +1 -0
- package/dist/kv/kv.d.ts +1 -2
- package/dist/kv/kv.js +15 -18
- package/dist/kv/kv.js.map +1 -1
- package/dist/kv/serde.d.ts +12 -3
- package/dist/kv/serde.js +87 -4
- package/dist/kv/serde.js.map +1 -0
- package/dist/label-DqGRqodo.d.ts +28 -0
- package/dist/logger/DefaultLogger.d.ts +66 -3
- package/dist/logger/DefaultLogger.js +2 -36
- package/dist/logger/ILogger.d.ts +64 -2
- package/dist/logger/ILogger.js +1 -1
- package/dist/logger/Logger.d.ts +36 -3
- package/dist/logger/Logger.js +2 -36
- package/dist/logger/NoopLogger.d.ts +1 -2
- package/dist/logger/NoopLogger.js +1 -0
- package/dist/logger/NoopLogger.js.map +1 -1
- package/dist/{media-gallery-BMsXSot3.d.ts → media-gallery-Ca8es-eB.d.ts} +3 -4
- package/dist/plugins/CompilerPlugin.d.ts +1 -31
- package/dist/plugins/CompilerPlugin.js +33 -4
- package/dist/plugins/CompilerPlugin.js.map +1 -0
- package/dist/plugins/PluginCommon.d.ts +1 -31
- package/dist/plugins/PluginCommon.js +55 -4
- package/dist/plugins/PluginCommon.js.map +1 -0
- package/dist/plugins/RuntimePlugin.d.ts +1 -31
- package/dist/plugins/RuntimePlugin.js +124 -4
- package/dist/plugins/RuntimePlugin.js.map +1 -0
- package/dist/plugins/index.d.ts +1 -31
- package/dist/plugins/index.js +8 -40
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -31
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +2 -36
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -31
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +2 -36
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -31
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +2 -36
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -31
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +2 -36
- package/dist/plugins/plugin-runtime/runtime.d.ts +1 -31
- package/dist/plugins/plugin-runtime/runtime.js +1 -1
- package/dist/plugins/types.d.ts +1 -31
- package/dist/plugins/types.js +1 -1
- package/dist/poll-DQ6DX_Tt.d.ts +88 -0
- package/dist/{section-Dh_FhPeC.d.ts → section-Q8nwx_-q.d.ts} +3 -4
- package/dist/{separator-CMf6Cyy5.d.ts → separator-B8P-kdIK.d.ts} +3 -4
- package/dist/{signals-SHg7J1U_.d.ts → signals-CBXwugBW.d.ts} +2 -2
- package/dist/{text-display-DRw3r_lK.d.ts → text-display-CL9C2yMc.d.ts} +3 -4
- package/dist/{types-CJ-XvOFN.d.ts → types-DZy7U-Ld.d.ts} +2 -2
- package/dist/types.d.ts +2 -32
- package/dist/types.js +1 -0
- package/dist/utils/colors.js +9 -3
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/constants.d.ts +2 -2
- package/dist/utils/constants.js +50 -7
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/dev-hooks.d.ts +1 -31
- package/dist/utils/dev-hooks.js +2 -36
- package/dist/utils/error-codes.d.ts +54 -2
- package/dist/utils/error-codes.js +53 -5
- package/dist/utils/error-codes.js.map +1 -0
- package/dist/utils/resolve-file-url.d.ts +11 -2
- package/dist/utils/resolve-file-url.js +18 -2
- package/dist/utils/resolve-file-url.js.map +1 -0
- package/dist/utils/types-package.js +61 -4
- package/dist/utils/types-package.js.map +1 -0
- package/dist/utils/useful-stuff/async-queue.js +2 -2
- package/dist/utils/useful-stuff/async-queue.js.map +1 -1
- package/dist/utils/useful-stuff/mutex.js +1 -0
- package/dist/utils/useful-stuff/mutex.js.map +1 -1
- package/dist/utils/useful-stuff/ratelimiter.js +2 -2
- package/dist/utils/useful-stuff/ratelimiter.js.map +1 -1
- package/dist/utils/useful-stuff/semaphore.js +2 -3
- package/dist/utils/useful-stuff/semaphore.js.map +1 -1
- package/dist/utils/utilities.d.ts +113 -2
- package/dist/utils/utilities.js +5 -37
- package/dist/utils/{warn-unstable.d.ts → warning.d.ts} +12 -3
- package/dist/utils/{warn-unstable.js → warning.js} +15 -2
- package/dist/utils/warning.js.map +1 -0
- package/dist/version.d.ts +8 -2
- package/dist/version.js +13 -2
- package/dist/version.js.map +1 -0
- package/hooks.cjs +11 -4
- package/package.json +22 -18
- package/ratelimit.cjs +0 -1
- package/dist/ActionRow-CbdGFWMT.js.map +0 -1
- package/dist/CommandKitEventsChannel-BtRzr3Tz.js +0 -88
- package/dist/CommandKitEventsChannel-BtRzr3Tz.js.map +0 -1
- package/dist/CommandsRouter-Cgcy6cK9.js +0 -220
- package/dist/CommandsRouter-Cgcy6cK9.js.map +0 -1
- package/dist/CompilerPlugin-M8r3yNAl.js +0 -43
- package/dist/CompilerPlugin-M8r3yNAl.js.map +0 -1
- package/dist/DefaultLogger-XCOl5nLd.d.ts +0 -67
- package/dist/EventInterceptor-CQEXyUTp.js +0 -142
- package/dist/EventInterceptor-CQEXyUTp.js.map +0 -1
- package/dist/EventWorkerContext-BMk7IXpC.d.ts +0 -43
- package/dist/EventWorkerContext-Dq29tieI.js +0 -69
- package/dist/EventWorkerContext-Dq29tieI.js.map +0 -1
- package/dist/EventsRouter-3Gygh-km.js +0 -137
- package/dist/EventsRouter-3Gygh-km.js.map +0 -1
- package/dist/ILogger-BW8GM-YZ.d.ts +0 -64
- package/dist/ILogger-dQ7Y9X1f.js +0 -0
- package/dist/Logger-DyfkPk7u.d.ts +0 -37
- package/dist/MessageCommandParser-CEuO6Ex3.js +0 -269
- package/dist/MessageCommandParser-CEuO6Ex3.js.map +0 -1
- package/dist/PluginCommon-Cvl5yYM_.js +0 -71
- package/dist/PluginCommon-Cvl5yYM_.js.map +0 -1
- package/dist/RuntimePlugin-BUecuBIU.js +0 -134
- package/dist/RuntimePlugin-BUecuBIU.js.map +0 -1
- package/dist/app-HN1cVg8J.js +0 -0
- package/dist/app-process-DoG6Spkf.js +0 -68
- package/dist/app-process-DoG6Spkf.js.map +0 -1
- package/dist/build-C9ltqPmn.js +0 -175
- package/dist/build-C9ltqPmn.js.map +0 -1
- package/dist/colors-DL3ucTiT.js +0 -15
- package/dist/colors-DL3ucTiT.js.map +0 -1
- package/dist/commandkit-Bm0gLN8i.js.map +0 -1
- package/dist/common-CcfjYnPG.js +0 -0
- package/dist/common-Dxr9-XPa.js +0 -211
- package/dist/common-Dxr9-XPa.js.map +0 -1
- package/dist/common-vnMIelAE.js +0 -17
- package/dist/common-vnMIelAE.js.map +0 -1
- package/dist/components/v1/action-row/ActionRow.d.ts +0 -6
- package/dist/components/v1/action-row/ActionRow.js +0 -3
- package/dist/components/v1/button/Button.d.ts +0 -7
- package/dist/components/v1/button/Button.js +0 -38
- package/dist/components/v1/button/ButtonKit.d.ts +0 -3
- package/dist/components/v1/button/ButtonKit.js +0 -38
- package/dist/components/v1/modal/Modal.d.ts +0 -7
- package/dist/components/v1/modal/Modal.js +0 -41
- package/dist/components/v1/modal/ModalKit.d.ts +0 -3
- package/dist/components/v1/modal/ModalKit.js +0 -38
- package/dist/components/v1/select-menu/ChannelSelectMenuKit.d.ts +0 -4
- package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +0 -38
- package/dist/components/v1/select-menu/MentionableSelectMenuKit.d.ts +0 -4
- package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +0 -38
- package/dist/components/v1/select-menu/RoleSelectMenuKit.d.ts +0 -4
- package/dist/components/v1/select-menu/RoleSelectMenuKit.js +0 -38
- package/dist/components/v1/select-menu/SelectMenu.d.ts +0 -10
- package/dist/components/v1/select-menu/SelectMenu.js +0 -43
- package/dist/components/v1/select-menu/StringSelectMenuKit.d.ts +0 -4
- package/dist/components/v1/select-menu/StringSelectMenuKit.js +0 -38
- package/dist/components/v1/select-menu/UserSelectMenuKit.d.ts +0 -4
- package/dist/components/v1/select-menu/UserSelectMenuKit.js +0 -38
- package/dist/components/v1/select-menu/common.d.ts +0 -3
- package/dist/components/v1/select-menu/common.js +0 -1
- package/dist/components/v2/common.js +0 -3
- package/dist/components/v2/container.d.ts +0 -2
- package/dist/components/v2/container.js +0 -4
- package/dist/components/v2/file.d.ts +0 -2
- package/dist/components/v2/file.js +0 -3
- package/dist/components/v2/index.d.ts +0 -8
- package/dist/components/v2/index.js +0 -17
- package/dist/components/v2/media-gallery.d.ts +0 -2
- package/dist/components/v2/media-gallery.js +0 -5
- package/dist/components/v2/section.d.ts +0 -2
- package/dist/components/v2/section.js +0 -5
- package/dist/components/v2/separator.d.ts +0 -2
- package/dist/components/v2/separator.js +0 -3
- package/dist/components/v2/text-display.d.ts +0 -2
- package/dist/components/v2/text-display.js +0 -3
- package/dist/config-BhVxyjmZ.d.ts +0 -16
- package/dist/constants-4oxxvaJA.js +0 -27
- package/dist/constants-4oxxvaJA.js.map +0 -1
- package/dist/constants-B5_Ta7PR.js +0 -70
- package/dist/constants-B5_Ta7PR.js.map +0 -1
- package/dist/constants-BOOGN85p.js +0 -37
- package/dist/constants-BOOGN85p.js.map +0 -1
- package/dist/container-C6GtfAPW.js +0 -44
- package/dist/container-C6GtfAPW.js.map +0 -1
- package/dist/dotprops-tnhpnszJ.js +0 -36
- package/dist/dotprops-tnhpnszJ.js.map +0 -1
- package/dist/element-Bak9llw_.js +0 -84
- package/dist/element-Bak9llw_.js.map +0 -1
- package/dist/env-_68PRRoA.js +0 -109
- package/dist/env-_68PRRoA.js.map +0 -1
- package/dist/error-codes-B4TyW4Ct.d.ts +0 -54
- package/dist/error-codes-Ds0bnPvT.js +0 -73
- package/dist/error-codes-Ds0bnPvT.js.map +0 -1
- package/dist/feature-flags-nZJB7-e5.js +0 -160
- package/dist/feature-flags-nZJB7-e5.js.map +0 -1
- package/dist/file-DVOELoNv.js.map +0 -1
- package/dist/helpers-BSwwrKJW.js +0 -36
- package/dist/helpers-BSwwrKJW.js.map +0 -1
- package/dist/index-DKcmsWXw.d.ts +0 -1
- package/dist/index-DSBMRX9A.d.ts +0 -1
- package/dist/index-DdqikUQD.d.ts +0 -1
- package/dist/index.js.map +0 -1
- package/dist/init-Cy_bcUt4.js +0 -95
- package/dist/init-Cy_bcUt4.js.map +0 -1
- package/dist/init-DOr-Y3GQ.d.ts +0 -13
- package/dist/media-gallery-zDtJ3kxb.js +0 -62
- package/dist/media-gallery-zDtJ3kxb.js.map +0 -1
- package/dist/resolve-file-url-ChIyw-Vf.js +0 -23
- package/dist/resolve-file-url-ChIyw-Vf.js.map +0 -1
- package/dist/resolve-file-url-yO8bUxok.d.ts +0 -11
- package/dist/router-Dn35v30f.js +0 -0
- package/dist/runtime-DB9CiPfe.js +0 -0
- package/dist/section-DlvrDoJK.js +0 -60
- package/dist/section-DlvrDoJK.js.map +0 -1
- package/dist/separator-DL6QH5H1.js.map +0 -1
- package/dist/serde-BYaKrsOV.d.ts +0 -12
- package/dist/serde-Cc8iUa9J.js +0 -97
- package/dist/serde-Cc8iUa9J.js.map +0 -1
- package/dist/signals-ChFMD7mB.js +0 -74
- package/dist/signals-ChFMD7mB.js.map +0 -1
- package/dist/store-CM6pWVZh.js +0 -19
- package/dist/store-CM6pWVZh.js.map +0 -1
- package/dist/text-display-DbMumig_.js.map +0 -1
- package/dist/type-checker-DR7RZFs5.js +0 -90
- package/dist/type-checker-DR7RZFs5.js.map +0 -1
- package/dist/types-CUZOquUl.js +0 -0
- package/dist/types-package-BWArjyBF.js +0 -75
- package/dist/types-package-BWArjyBF.js.map +0 -1
- package/dist/types-q0Nm882H.js +0 -0
- package/dist/utilities-DtdPlr4c.d.ts +0 -87
- package/dist/utils/warn-unstable.js.map +0 -1
- package/dist/utils-DCSnVAZ6.js +0 -23
- package/dist/utils-DCSnVAZ6.js.map +0 -1
- package/dist/utils-KsNof0Xz.js +0 -34
- package/dist/utils-KsNof0Xz.js.map +0 -1
- package/dist/v2-DofkPKHs.js +0 -0
- package/dist/version-CtJtBJXI.d.ts +0 -8
- package/dist/version-DRSQMx0w.js +0 -18
- package/dist/version-DRSQMx0w.js.map +0 -1
package/dist/kv/kv.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kv.js","names":[],"sources":["../../src/kv/kv.ts"],"sourcesContent":["import { DatabaseSync, StatementSync } from 'node:sqlite';\nimport { deserializer, serializer } from './serde';\nimport { getNestedValue, setNestedValue } from './dotprops';\n\nexport type { SerializedValue } from './serde';\n\n/**\n * Mathematical operators supported by the KV math method\n */\nexport type KvMathOperator = '+' | '-' | '*' | '/' | '^' | '%';\n\n/**\n * Configuration options for the KV store\n */\nexport interface KvOptions {\n /** Enable Write-Ahead Logging for better performance and durability */\n enableWAL?: boolean;\n /** Namespace for the key-value store table */\n namespace?: string;\n}\n\n/**\n * A key-value store implementation using SQLite\n *\n * This class provides a simple, persistent key-value storage solution\n * with support for namespaces, automatic cleanup, iteration, expiration, and JSON serialization.\n *\n * @example\n * ```typescript\n * const kv = new KV('data.db');\n *\n * // Store any JSON-serializable data\n * kv.set('user:123', { name: 'John', age: 30 });\n * kv.set('counter', 42);\n * kv.set('active', true);\n * kv.set('dates', [new Date(), new Date()]);\n *\n * // Use dot notation for nested properties\n * kv.set('user:123.name', 'John');\n * kv.set('user:123.settings.theme', 'dark');\n *\n * // Retrieve data\n * const user = kv.get('user:123'); // { name: 'John', age: 30, settings: { theme: 'dark' } }\n * const name = kv.get('user:123.name'); // 'John'\n * ```\n */\nexport class KV implements Disposable, AsyncDisposable {\n private db: DatabaseSync;\n private statements: Record<string, StatementSync> = {};\n\n /**\n * Creates a new KV store instance\n *\n * @param path - Database file path, buffer, URL, or existing DatabaseSync instance\n * @param options - Configuration options for the KV store\n */\n public constructor(\n path: string | Buffer | URL | DatabaseSync,\n private options: KvOptions = {\n enableWAL: true,\n namespace: 'commandkit_kv',\n },\n ) {\n this.db =\n path instanceof DatabaseSync\n ? path\n : new DatabaseSync(path, { open: true });\n\n if (options.enableWAL) {\n this.db.exec(/* sql */ `PRAGMA journal_mode = WAL;`);\n }\n\n const namespace = this.options.namespace ?? 'commandkit_kv';\n\n this.db.exec(/* sql */ `\n CREATE TABLE IF NOT EXISTS ${namespace} (\n key TEXT PRIMARY KEY,\n value TEXT,\n expires_at INTEGER\n )\n `);\n\n this.statements = {\n get: this.db.prepare(\n /* sql */ `SELECT value, expires_at FROM ${namespace} WHERE key = ?`,\n ),\n set: this.db.prepare(\n /* sql */ `INSERT OR REPLACE INTO ${namespace} (key, value, expires_at) VALUES (?, ?, ?)`,\n ),\n setex: this.db.prepare(\n /* sql */ `INSERT OR REPLACE INTO ${namespace} (key, value, expires_at) VALUES (?, ?, ?)`,\n ),\n delete: this.db.prepare(\n /* sql */ `DELETE FROM ${namespace} WHERE key = ?`,\n ),\n has: this.db.prepare(\n /* sql */ `SELECT COUNT(*) FROM ${namespace} WHERE key = ? AND (expires_at IS NULL OR expires_at > ?)`,\n ),\n keys: this.db.prepare(\n /* sql */ `SELECT key FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n values: this.db.prepare(\n /* sql */ `SELECT value FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n clear: this.db.prepare(/* sql */ `DELETE FROM ${namespace}`),\n count: this.db.prepare(\n /* sql */ `SELECT COUNT(*) FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n all: this.db.prepare(\n /* sql */ `SELECT key, value FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n expire: this.db.prepare(\n /* sql */ `UPDATE ${namespace} SET expires_at = ? WHERE key = ?`,\n ),\n ttl: this.db.prepare(\n /* sql */ `SELECT expires_at FROM ${namespace} WHERE key = ?`,\n ),\n namespaces: this.db.prepare(\n /* sql */ `SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%'`,\n ),\n begin: this.db.prepare(/* sql */ `BEGIN TRANSACTION`),\n commit: this.db.prepare(/* sql */ `COMMIT`),\n rollback: this.db.prepare(/* sql */ `ROLLBACK`),\n };\n }\n\n /**\n * Gets the current timestamp in milliseconds\n */\n private getCurrentTime(): number {\n return Date.now();\n }\n\n /**\n * Checks if the database connection is open\n *\n * @returns `true` if the database is open, `false` otherwise\n */\n public isOpen(): boolean {\n return this.db.isOpen;\n }\n\n /**\n * Gets the underlying SQLite database instance\n *\n * @returns The DatabaseSync instance\n */\n public getDatabase(): DatabaseSync {\n return this.db;\n }\n\n /**\n * Closes the database connection\n */\n public close(): void {\n if (this.db.isOpen) this.db.close();\n }\n\n /**\n * Disposable implementation - closes the database when disposed\n */\n public [Symbol.dispose]() {\n this.close();\n }\n\n /**\n * AsyncDisposable implementation - closes the database when disposed\n */\n public async [Symbol.asyncDispose]() {\n this.close();\n }\n\n /**\n * Retrieves a value by key\n *\n * @param key - The key to retrieve (supports dot notation for nested properties)\n * @returns The value associated with the key, or `undefined` if not found or expired\n *\n * @example\n * ```typescript\n * // Store an object\n * kv.set('user:123', { name: 'John', age: 30, settings: { theme: 'dark' } });\n *\n * // Get the entire object\n * const user = kv.get('user:123');\n * // { name: 'John', age: 30, settings: { theme: 'dark' } }\n *\n * // Get nested properties using dot notation\n * const name = kv.get('user:123.name'); // 'John'\n * const theme = kv.get('user:123.settings.theme'); // 'dark'\n * ```\n */\n public get<T = any>(key: string): T | undefined {\n const result = this.statements.get.get(key);\n\n if (!result) return undefined;\n\n // Check if the key has expired\n if (\n result.expires_at &&\n Number(result.expires_at) <= this.getCurrentTime()\n ) {\n this.delete(key);\n return undefined;\n }\n\n const serialized = JSON.parse(result.value as string);\n const deserialized = deserializer(serialized);\n\n // Handle dot notation for nested properties\n if (key.includes('.')) {\n return getNestedValue(deserialized, key.split('.').slice(1).join('.'));\n }\n\n return deserialized;\n }\n\n /**\n * Sets a key-value pair\n *\n * @param key - The key to set (supports dot notation for nested properties)\n * @param value - The value to associate with the key (any JSON-serializable type)\n *\n * @example\n * ```typescript\n * // Store primitive values\n * kv.set('counter', 42);\n * kv.set('active', true);\n * kv.set('name', 'John');\n *\n * // Store objects\n * kv.set('user:123', { name: 'John', age: 30 });\n *\n * // Store arrays\n * kv.set('tags', ['javascript', 'typescript', 'sqlite']);\n *\n * // Store dates\n * kv.set('created', new Date());\n *\n * // Store maps and sets\n * kv.set('permissions', new Map([['admin', true], ['user', false]]));\n * kv.set('unique_ids', new Set([1, 2, 3, 4, 5]));\n *\n * // Use dot notation for nested properties\n * kv.set('user:123.settings.theme', 'dark');\n * kv.set('user:123.settings.notifications', true);\n * ```\n */\n public set(key: string, value: any): void {\n let serializedValue: string;\n\n if (key.includes('.')) {\n // Handle dot notation for nested properties\n const [baseKey, ...pathParts] = key.split('.');\n const path = pathParts.join('.');\n\n // Get existing value or create new object\n const existing = this.get(baseKey) || {};\n setNestedValue(existing, path, value);\n\n const serialized = serializer(existing);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.set.run(baseKey, serializedValue, null);\n } else {\n const serialized = serializer(value);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.set.run(key, serializedValue, null);\n }\n }\n\n /**\n * Sets a key-value pair with expiration\n *\n * @param key - The key to set (supports dot notation for nested properties)\n * @param value - The value to associate with the key (any JSON-serializable type)\n * @param ttl - Time to live in milliseconds\n *\n * @example\n * ```typescript\n * // Set with 1 hour expiration\n * kv.setex('session:123', { userId: 123, token: 'abc123' }, 60 * 60 * 1000);\n *\n * // Set with 5 minutes expiration\n * kv.setex('temp:data', { cached: true, timestamp: Date.now() }, 5 * 60 * 1000);\n *\n * // Use dot notation with expiration\n * kv.setex('user:123.temp_settings', { theme: 'light' }, 30 * 60 * 1000);\n * ```\n */\n public setex(key: string, value: any, ttl: number): void {\n const expiresAt = this.getCurrentTime() + ttl;\n let serializedValue: string;\n\n if (key.includes('.')) {\n // Handle dot notation for nested properties\n const [baseKey, ...pathParts] = key.split('.');\n const path = pathParts.join('.');\n\n // Get existing value or create new object\n const existing = this.get(baseKey) || {};\n setNestedValue(existing, path, value);\n\n const serialized = serializer(existing);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.setex.run(baseKey, serializedValue, expiresAt);\n } else {\n const serialized = serializer(value);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.setex.run(key, serializedValue, expiresAt);\n }\n }\n\n /**\n * Performs mathematical operations on numeric values in the KV store\n *\n * @param key - The key to perform math operation on (supports dot notation for nested properties)\n * @param operator - The mathematical operator to apply\n * @param value - The value to use in the operation\n * @returns The updated value after the mathematical operation\n * @throws Error if the existing value is not numeric or if the operation is invalid\n *\n * @example\n * ```typescript\n * // Initialize a counter\n * kv.set('counter', 10);\n *\n * // Increment by 5\n * const result1 = kv.math('counter', '+', 5); // 15\n *\n * // Multiply by 2\n * const result2 = kv.math('counter', '*', 2); // 30\n *\n * // Use with bigint\n * kv.set('big_counter', BigInt(1000));\n * const result3 = kv.math('big_counter', '+', BigInt(500)); // 1500n\n *\n * // Use with dot notation\n * kv.set('user:123', { score: 100, level: 5 });\n * const result4 = kv.math('user:123.score', '+', 50); // 150\n * ```\n */\n public math(\n key: string,\n operator: KvMathOperator,\n value: number | bigint,\n ): number | bigint {\n const existingValue = this.get(key);\n\n if (existingValue === undefined) {\n throw new Error(`Key '${key}' does not exist`);\n }\n\n if (\n typeof existingValue !== 'number' &&\n typeof existingValue !== 'bigint'\n ) {\n throw new Error(\n `Value at key '${key}' is not numeric. Expected number or bigint, got ${typeof existingValue}`,\n );\n }\n\n // Handle mixed number/bigint operations by converting to bigint\n const isBigIntOperation =\n typeof existingValue === 'bigint' || typeof value === 'bigint';\n\n const existing = isBigIntOperation\n ? typeof existingValue === 'bigint'\n ? existingValue\n : BigInt(existingValue)\n : (existingValue as number);\n const operand = isBigIntOperation\n ? typeof value === 'bigint'\n ? value\n : BigInt(value)\n : (value as number);\n\n let result: number | bigint;\n\n switch (operator) {\n case '+':\n result = (existing as any) + (operand as any);\n break;\n case '-':\n result = (existing as any) - (operand as any);\n break;\n case '*':\n result = (existing as any) * (operand as any);\n break;\n case '/':\n if (operand === 0 || operand === 0n) {\n throw new Error('Division by zero');\n }\n result = (existing as any) / (operand as any);\n break;\n case '^':\n if (isBigIntOperation && operand < 0n) {\n throw new Error(\n 'Exponentiation with negative exponent is not supported for bigint',\n );\n }\n result = (existing as any) ** (operand as any);\n break;\n case '%':\n if (operand === 0 || operand === 0n) {\n throw new Error('Modulo by zero');\n }\n result = (existing as any) % (operand as any);\n break;\n default:\n throw new Error(`Invalid operator: ${operator}`);\n }\n\n // Update the value in the store\n this.set(key, result);\n\n return result;\n }\n\n /**\n * Sets expiration for an existing key\n *\n * @param key - The key to set expiration for\n * @param ttl - Time to live in milliseconds\n * @returns `true` if the key exists and expiration was set, `false` otherwise\n *\n * @example\n * ```typescript\n * kv.set('user:123', { name: 'John', age: 30 });\n *\n * // Set 30 minute expiration\n * if (kv.expire('user:123', 30 * 60 * 1000)) {\n * console.log('Expiration set successfully');\n * }\n * ```\n */\n public expire(key: string, ttl: number): boolean {\n if (!this.has(key)) return false;\n\n const expiresAt = this.getCurrentTime() + ttl;\n this.statements.expire.run(expiresAt, key);\n return true;\n }\n\n /**\n * Gets the time to live for a key\n *\n * @param key - The key to check\n * @returns Time to live in milliseconds, or `-1` if the key doesn't exist, or `-2` if the key has no expiration\n *\n * @example\n * ```typescript\n * const ttl = kv.ttl('user:123');\n * if (ttl > 0) {\n * console.log(`Key expires in ${ttl}ms`);\n * } else if (ttl === -2) {\n * console.log('Key has no expiration');\n * } else {\n * console.log('Key does not exist');\n * }\n * ```\n */\n public ttl(key: string): number {\n const result = this.statements.ttl.get(key);\n\n if (!result) return -1; // Key doesn't exist\n\n if (!result.expires_at) return -2; // No expiration\n\n const remaining = Number(result.expires_at) - this.getCurrentTime();\n return remaining > 0 ? remaining : -1; // Expired or doesn't exist\n }\n\n /**\n * Deletes a key-value pair\n *\n * @param key - The key to delete\n *\n * @example\n * ```typescript\n * kv.delete('user:123');\n * kv.delete('user:123.settings.theme'); // Delete nested property\n * ```\n */\n public delete(key: string): void {\n this.statements.delete.run(key);\n }\n\n /**\n * Checks if a key exists and is not expired\n *\n * @param key - The key to check\n * @returns `true` if the key exists and is not expired, `false` otherwise\n *\n * @example\n * ```typescript\n * if (kv.has('user:123')) {\n * console.log('User exists and is not expired');\n * }\n *\n * if (kv.has('user:123.settings.theme')) {\n * console.log('Theme setting exists');\n * }\n * ```\n */\n public has(key: string): boolean {\n const result = this.statements.has.get(key, this.getCurrentTime());\n\n return (\n result?.count !== undefined &&\n result.count !== null &&\n Number(result.count) > 0\n );\n }\n\n /**\n * Gets all keys in the current namespace (excluding expired keys)\n *\n * @returns Array of all non-expired keys\n *\n * @example\n * ```typescript\n * const keys = kv.keys();\n * console.log('All keys:', keys);\n * ```\n */\n public keys(): string[] {\n const result = this.statements.keys.all(this.getCurrentTime());\n\n return result.map((row) => row.key as string);\n }\n\n /**\n * Gets all values in the current namespace (excluding expired keys)\n *\n * @returns Array of all non-expired values\n *\n * @example\n * ```typescript\n * const values = kv.values();\n * console.log('All values:', values);\n * ```\n */\n public values(): any[] {\n const result = this.statements.values.all(this.getCurrentTime());\n\n return result.map((row) => {\n const serialized = JSON.parse(row.value as string);\n return deserializer(serialized);\n });\n }\n\n /**\n * Gets the total number of key-value pairs in the current namespace (excluding expired keys)\n *\n * @returns The count of non-expired key-value pairs\n *\n * @example\n * ```typescript\n * const count = kv.count();\n * console.log(`Total entries: ${count}`);\n * ```\n */\n public count(): number {\n const result = this.statements.count.get(this.getCurrentTime());\n\n return Number(result?.count ?? 0);\n }\n\n /**\n * Removes all key-value pairs from the current namespace\n *\n * @example\n * ```typescript\n * kv.clear(); // Removes all entries in current namespace\n * ```\n */\n public clear(): void {\n this.statements.clear.run();\n }\n\n /**\n * Gets all key-value pairs as an object (excluding expired keys)\n *\n * @returns Object with all non-expired key-value pairs\n *\n * @example\n * ```typescript\n * const all = kv.all();\n * console.log('All entries:', all);\n * // Output: { 'key1': value1, 'key2': value2 }\n * ```\n */\n public all(): Record<string, any> {\n const result = this.statements.all.all(this.getCurrentTime());\n\n return Object.fromEntries(\n result.map((row) => {\n const serialized = JSON.parse(row.value as string);\n return [row.key as string, deserializer(serialized)];\n }),\n );\n }\n\n /**\n * Gets all available namespaces (tables) in the database\n *\n * @returns Array of namespace names\n *\n * @example\n * ```typescript\n * const namespaces = kv.namespaces();\n * console.log('Available namespaces:', namespaces);\n * ```\n */\n public namespaces(): string[] {\n const result = this.statements.namespaces.all();\n\n return result.map((row) => row.name as string);\n }\n\n /**\n * Gets the current namespace name\n *\n * @returns The current namespace string\n */\n public getCurrentNamespace(): string {\n return this.options.namespace ?? 'commandkit_kv';\n }\n\n /**\n * Creates a new KV instance with a different namespace\n *\n * @param namespace - The namespace to use for the new instance\n * @returns A new KV instance with the specified namespace\n *\n * @example\n * ```typescript\n * const userKv = kv.namespace('users');\n * const configKv = kv.namespace('config');\n *\n * userKv.set('123', { name: 'John', age: 30 });\n * configKv.set('theme', 'dark');\n * ```\n */\n public namespace(namespace: string): KV {\n return new KV(this.db, {\n enableWAL: this.options.enableWAL,\n namespace,\n });\n }\n\n /**\n * Iterator implementation for iterating over all non-expired key-value pairs\n *\n * @returns Iterator yielding [key, value] tuples\n *\n * @example\n * ```typescript\n * for (const [key, value] of kv) {\n * console.log(`${key}:`, value);\n * }\n *\n * // Or using spread operator\n * const entries = [...kv];\n * ```\n */\n public *[Symbol.iterator](): Iterator<[string, any]> {\n const result = this.statements.all.iterate(this.getCurrentTime());\n\n for (const row of result) {\n const serialized = JSON.parse(row.value as string);\n yield [row.key as string, deserializer(serialized)];\n }\n }\n\n /**\n * Executes a function within a transaction\n *\n * @param fn - Function to execute within the transaction (can be async)\n * @returns The result of the function\n *\n * @example\n * ```typescript\n * // Synchronous transaction\n * kv.transaction(() => {\n * kv.set('user:123', { name: 'John', age: 30 });\n * kv.set('user:456', { name: 'Jane', age: 25 });\n * // If any operation fails, all changes are rolled back\n * });\n *\n * // Async transaction\n * await kv.transaction(async () => {\n * kv.set('user:123', { name: 'John', age: 30 });\n * await someAsyncOperation();\n * kv.set('user:456', { name: 'Jane', age: 25 });\n * // If any operation fails, all changes are rolled back\n * });\n * ```\n */\n public async transaction<T>(fn: () => T | Promise<T>): Promise<T> {\n try {\n // Begin transaction\n this.statements.begin.run();\n\n // Execute the function\n const result = await fn();\n\n // Commit transaction\n this.statements.commit.run();\n\n return result;\n } catch (error) {\n // Rollback transaction on error\n this.statements.rollback.run();\n throw error;\n }\n }\n}\n\n/**\n * Opens a new KV instance\n *\n * @param path - Database file path, buffer, URL, or existing DatabaseSync instance\n * @param options - Configuration options for the KV store\n * @returns A new KV instance\n */\nexport function openKV(\n path: string | Buffer | URL | DatabaseSync = 'commandkit_kv.db',\n options: KvOptions = { enableWAL: true, namespace: 'commandkit_kv' },\n): KV {\n return new KV(path, options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,IAAa,KAAb,MAAa,GAA0C;CACrD,AAAQ;CACR,AAAQ,aAA4C,EAAE;;;;;;;CAQtD,AAAO,YACP,MACA,AAAQ,UAAqB;EAC3B,WAAW;EACX,WAAW;EACZ,EACD;EAJQ;AAKN,OAAK,KACL,gBAAgB,2BAChB,OACA,IAAI,yBAAa,MAAM,EAAE,MAAM,MAAM,CAAC;AAEtC,MAAI,QAAQ,UACV,MAAK,G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DatabaseSync, StatementSync } from 'node:sqlite';\nimport { deserializer, serializer } from './serde';\nimport { getNestedValue, setNestedValue } from './dotprops';\n\nexport type { SerializedValue } from './serde';\n\n/**\n * Mathematical operators supported by the KV math method\n */\nexport type KvMathOperator = '+' | '-' | '*' | '/' | '^' | '%';\n\n/**\n * Configuration options for the KV store\n */\nexport interface KvOptions {\n /** Enable Write-Ahead Logging for better performance and durability */\n enableWAL?: boolean;\n /** Namespace for the key-value store table */\n namespace?: string;\n}\n\n/**\n * A key-value store implementation using SQLite\n *\n * This class provides a simple, persistent key-value storage solution\n * with support for namespaces, automatic cleanup, iteration, expiration, and JSON serialization.\n *\n * @example\n * ```typescript\n * const kv = new KV('data.db');\n *\n * // Store any JSON-serializable data\n * kv.set('user:123', { name: 'John', age: 30 });\n * kv.set('counter', 42);\n * kv.set('active', true);\n * kv.set('dates', [new Date(), new Date()]);\n *\n * // Use dot notation for nested properties\n * kv.set('user:123.name', 'John');\n * kv.set('user:123.settings.theme', 'dark');\n *\n * // Retrieve data\n * const user = kv.get('user:123'); // { name: 'John', age: 30, settings: { theme: 'dark' } }\n * const name = kv.get('user:123.name'); // 'John'\n * ```\n */\nexport class KV implements Disposable, AsyncDisposable {\n private db: DatabaseSync;\n private statements: Record<string, StatementSync> = {};\n\n /**\n * Creates a new KV store instance\n *\n * @param path - Database file path, buffer, URL, or existing DatabaseSync instance\n * @param options - Configuration options for the KV store\n */\n public constructor(\n path: string | Buffer | URL | DatabaseSync,\n private options: KvOptions = {\n enableWAL: true,\n namespace: 'commandkit_kv',\n },\n ) {\n this.db =\n path instanceof DatabaseSync\n ? path\n : new DatabaseSync(path, { open: true });\n\n if (options.enableWAL) {\n this.db.exec(/* sql */ `PRAGMA journal_mode = WAL;`);\n }\n\n const namespace = this.options.namespace ?? 'commandkit_kv';\n\n this.db.exec(/* sql */ `\n CREATE TABLE IF NOT EXISTS ${namespace} (\n key TEXT PRIMARY KEY,\n value TEXT,\n expires_at INTEGER\n )\n `);\n\n this.statements = {\n get: this.db.prepare(\n /* sql */ `SELECT value, expires_at FROM ${namespace} WHERE key = ?`,\n ),\n set: this.db.prepare(\n /* sql */ `INSERT OR REPLACE INTO ${namespace} (key, value, expires_at) VALUES (?, ?, ?)`,\n ),\n setex: this.db.prepare(\n /* sql */ `INSERT OR REPLACE INTO ${namespace} (key, value, expires_at) VALUES (?, ?, ?)`,\n ),\n delete: this.db.prepare(\n /* sql */ `DELETE FROM ${namespace} WHERE key = ?`,\n ),\n has: this.db.prepare(\n /* sql */ `SELECT COUNT(*) FROM ${namespace} WHERE key = ? AND (expires_at IS NULL OR expires_at > ?)`,\n ),\n keys: this.db.prepare(\n /* sql */ `SELECT key FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n values: this.db.prepare(\n /* sql */ `SELECT value FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n clear: this.db.prepare(/* sql */ `DELETE FROM ${namespace}`),\n count: this.db.prepare(\n /* sql */ `SELECT COUNT(*) FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n all: this.db.prepare(\n /* sql */ `SELECT key, value FROM ${namespace} WHERE expires_at IS NULL OR expires_at > ?`,\n ),\n expire: this.db.prepare(\n /* sql */ `UPDATE ${namespace} SET expires_at = ? WHERE key = ?`,\n ),\n ttl: this.db.prepare(\n /* sql */ `SELECT expires_at FROM ${namespace} WHERE key = ?`,\n ),\n namespaces: this.db.prepare(\n /* sql */ `SELECT name FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%'`,\n ),\n begin: this.db.prepare(/* sql */ `BEGIN TRANSACTION`),\n commit: this.db.prepare(/* sql */ `COMMIT`),\n rollback: this.db.prepare(/* sql */ `ROLLBACK`),\n };\n }\n\n /**\n * Gets the current timestamp in milliseconds\n */\n private getCurrentTime(): number {\n return Date.now();\n }\n\n /**\n * Checks if the database connection is open\n *\n * @returns `true` if the database is open, `false` otherwise\n */\n public isOpen(): boolean {\n return this.db.isOpen;\n }\n\n /**\n * Gets the underlying SQLite database instance\n *\n * @returns The DatabaseSync instance\n */\n public getDatabase(): DatabaseSync {\n return this.db;\n }\n\n /**\n * Closes the database connection\n */\n public close(): void {\n if (this.db.isOpen) this.db.close();\n }\n\n /**\n * Disposable implementation - closes the database when disposed\n */\n public [Symbol.dispose]() {\n this.close();\n }\n\n /**\n * AsyncDisposable implementation - closes the database when disposed\n */\n public async [Symbol.asyncDispose]() {\n this.close();\n }\n\n /**\n * Retrieves a value by key\n *\n * @param key - The key to retrieve (supports dot notation for nested properties)\n * @returns The value associated with the key, or `undefined` if not found or expired\n *\n * @example\n * ```typescript\n * // Store an object\n * kv.set('user:123', { name: 'John', age: 30, settings: { theme: 'dark' } });\n *\n * // Get the entire object\n * const user = kv.get('user:123');\n * // { name: 'John', age: 30, settings: { theme: 'dark' } }\n *\n * // Get nested properties using dot notation\n * const name = kv.get('user:123.name'); // 'John'\n * const theme = kv.get('user:123.settings.theme'); // 'dark'\n * ```\n */\n public get<T = any>(key: string): T | undefined {\n const result = this.statements.get.get(key);\n\n if (!result) return undefined;\n\n // Check if the key has expired\n if (\n result.expires_at &&\n Number(result.expires_at) <= this.getCurrentTime()\n ) {\n this.delete(key);\n return undefined;\n }\n\n const serialized = JSON.parse(result.value as string);\n const deserialized = deserializer(serialized);\n\n // Handle dot notation for nested properties\n if (key.includes('.')) {\n return getNestedValue(deserialized, key.split('.').slice(1).join('.'));\n }\n\n return deserialized;\n }\n\n /**\n * Sets a key-value pair\n *\n * @param key - The key to set (supports dot notation for nested properties)\n * @param value - The value to associate with the key (any JSON-serializable type)\n *\n * @example\n * ```typescript\n * // Store primitive values\n * kv.set('counter', 42);\n * kv.set('active', true);\n * kv.set('name', 'John');\n *\n * // Store objects\n * kv.set('user:123', { name: 'John', age: 30 });\n *\n * // Store arrays\n * kv.set('tags', ['javascript', 'typescript', 'sqlite']);\n *\n * // Store dates\n * kv.set('created', new Date());\n *\n * // Store maps and sets\n * kv.set('permissions', new Map([['admin', true], ['user', false]]));\n * kv.set('unique_ids', new Set([1, 2, 3, 4, 5]));\n *\n * // Use dot notation for nested properties\n * kv.set('user:123.settings.theme', 'dark');\n * kv.set('user:123.settings.notifications', true);\n * ```\n */\n public set(key: string, value: any): void {\n let serializedValue: string;\n\n if (key.includes('.')) {\n // Handle dot notation for nested properties\n const [baseKey, ...pathParts] = key.split('.');\n const path = pathParts.join('.');\n\n // Get existing value or create new object\n const existing = this.get(baseKey) || {};\n setNestedValue(existing, path, value);\n\n const serialized = serializer(existing);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.set.run(baseKey, serializedValue, null);\n } else {\n const serialized = serializer(value);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.set.run(key, serializedValue, null);\n }\n }\n\n /**\n * Sets a key-value pair with expiration\n *\n * @param key - The key to set (supports dot notation for nested properties)\n * @param value - The value to associate with the key (any JSON-serializable type)\n * @param ttl - Time to live in milliseconds\n *\n * @example\n * ```typescript\n * // Set with 1 hour expiration\n * kv.setex('session:123', { userId: 123, token: 'abc123' }, 60 * 60 * 1000);\n *\n * // Set with 5 minutes expiration\n * kv.setex('temp:data', { cached: true, timestamp: Date.now() }, 5 * 60 * 1000);\n *\n * // Use dot notation with expiration\n * kv.setex('user:123.temp_settings', { theme: 'light' }, 30 * 60 * 1000);\n * ```\n */\n public setex(key: string, value: any, ttl: number): void {\n const expiresAt = this.getCurrentTime() + ttl;\n let serializedValue: string;\n\n if (key.includes('.')) {\n // Handle dot notation for nested properties\n const [baseKey, ...pathParts] = key.split('.');\n const path = pathParts.join('.');\n\n // Get existing value or create new object\n const existing = this.get(baseKey) || {};\n setNestedValue(existing, path, value);\n\n const serialized = serializer(existing);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.setex.run(baseKey, serializedValue, expiresAt);\n } else {\n const serialized = serializer(value);\n serializedValue = JSON.stringify(serialized);\n\n this.statements.setex.run(key, serializedValue, expiresAt);\n }\n }\n\n /**\n * Performs mathematical operations on numeric values in the KV store\n *\n * @param key - The key to perform math operation on (supports dot notation for nested properties)\n * @param operator - The mathematical operator to apply\n * @param value - The value to use in the operation\n * @returns The updated value after the mathematical operation\n * @throws Error if the existing value is not numeric or if the operation is invalid\n *\n * @example\n * ```typescript\n * // Initialize a counter\n * kv.set('counter', 10);\n *\n * // Increment by 5\n * const result1 = kv.math('counter', '+', 5); // 15\n *\n * // Multiply by 2\n * const result2 = kv.math('counter', '*', 2); // 30\n *\n * // Use with bigint\n * kv.set('big_counter', BigInt(1000));\n * const result3 = kv.math('big_counter', '+', BigInt(500)); // 1500n\n *\n * // Use with dot notation\n * kv.set('user:123', { score: 100, level: 5 });\n * const result4 = kv.math('user:123.score', '+', 50); // 150\n * ```\n */\n public math(\n key: string,\n operator: KvMathOperator,\n value: number | bigint,\n ): number | bigint {\n const existingValue = this.get(key);\n\n if (existingValue === undefined) {\n throw new Error(`Key '${key}' does not exist`);\n }\n\n if (\n typeof existingValue !== 'number' &&\n typeof existingValue !== 'bigint'\n ) {\n throw new Error(\n `Value at key '${key}' is not numeric. Expected number or bigint, got ${typeof existingValue}`,\n );\n }\n\n // Handle mixed number/bigint operations by converting to bigint\n const isBigIntOperation =\n typeof existingValue === 'bigint' || typeof value === 'bigint';\n\n const existing = isBigIntOperation\n ? typeof existingValue === 'bigint'\n ? existingValue\n : BigInt(existingValue)\n : (existingValue as number);\n const operand = isBigIntOperation\n ? typeof value === 'bigint'\n ? value\n : BigInt(value)\n : (value as number);\n\n let result: number | bigint;\n\n switch (operator) {\n case '+':\n result = (existing as any) + (operand as any);\n break;\n case '-':\n result = (existing as any) - (operand as any);\n break;\n case '*':\n result = (existing as any) * (operand as any);\n break;\n case '/':\n if (operand === 0 || operand === 0n) {\n throw new Error('Division by zero');\n }\n result = (existing as any) / (operand as any);\n break;\n case '^':\n if (isBigIntOperation && operand < 0n) {\n throw new Error(\n 'Exponentiation with negative exponent is not supported for bigint',\n );\n }\n result = (existing as any) ** (operand as any);\n break;\n case '%':\n if (operand === 0 || operand === 0n) {\n throw new Error('Modulo by zero');\n }\n result = (existing as any) % (operand as any);\n break;\n default:\n throw new Error(`Invalid operator: ${operator}`);\n }\n\n // Update the value in the store\n this.set(key, result);\n\n return result;\n }\n\n /**\n * Sets expiration for an existing key\n *\n * @param key - The key to set expiration for\n * @param ttl - Time to live in milliseconds\n * @returns `true` if the key exists and expiration was set, `false` otherwise\n *\n * @example\n * ```typescript\n * kv.set('user:123', { name: 'John', age: 30 });\n *\n * // Set 30 minute expiration\n * if (kv.expire('user:123', 30 * 60 * 1000)) {\n * console.log('Expiration set successfully');\n * }\n * ```\n */\n public expire(key: string, ttl: number): boolean {\n if (!this.has(key)) return false;\n\n const expiresAt = this.getCurrentTime() + ttl;\n this.statements.expire.run(expiresAt, key);\n return true;\n }\n\n /**\n * Gets the time to live for a key\n *\n * @param key - The key to check\n * @returns Time to live in milliseconds, or `-1` if the key doesn't exist, or `-2` if the key has no expiration\n *\n * @example\n * ```typescript\n * const ttl = kv.ttl('user:123');\n * if (ttl > 0) {\n * console.log(`Key expires in ${ttl}ms`);\n * } else if (ttl === -2) {\n * console.log('Key has no expiration');\n * } else {\n * console.log('Key does not exist');\n * }\n * ```\n */\n public ttl(key: string): number {\n const result = this.statements.ttl.get(key);\n\n if (!result) return -1; // Key doesn't exist\n\n if (!result.expires_at) return -2; // No expiration\n\n const remaining = Number(result.expires_at) - this.getCurrentTime();\n return remaining > 0 ? remaining : -1; // Expired or doesn't exist\n }\n\n /**\n * Deletes a key-value pair\n *\n * @param key - The key to delete\n *\n * @example\n * ```typescript\n * kv.delete('user:123');\n * kv.delete('user:123.settings.theme'); // Delete nested property\n * ```\n */\n public delete(key: string): void {\n this.statements.delete.run(key);\n }\n\n /**\n * Checks if a key exists and is not expired\n *\n * @param key - The key to check\n * @returns `true` if the key exists and is not expired, `false` otherwise\n *\n * @example\n * ```typescript\n * if (kv.has('user:123')) {\n * console.log('User exists and is not expired');\n * }\n *\n * if (kv.has('user:123.settings.theme')) {\n * console.log('Theme setting exists');\n * }\n * ```\n */\n public has(key: string): boolean {\n const result = this.statements.has.get(key, this.getCurrentTime());\n\n return (\n result?.count !== undefined &&\n result.count !== null &&\n Number(result.count) > 0\n );\n }\n\n /**\n * Gets all keys in the current namespace (excluding expired keys)\n *\n * @returns Array of all non-expired keys\n *\n * @example\n * ```typescript\n * const keys = kv.keys();\n * console.log('All keys:', keys);\n * ```\n */\n public keys(): string[] {\n const result = this.statements.keys.all(this.getCurrentTime());\n\n return result.map((row) => row.key as string);\n }\n\n /**\n * Gets all values in the current namespace (excluding expired keys)\n *\n * @returns Array of all non-expired values\n *\n * @example\n * ```typescript\n * const values = kv.values();\n * console.log('All values:', values);\n * ```\n */\n public values(): any[] {\n const result = this.statements.values.all(this.getCurrentTime());\n\n return result.map((row) => {\n const serialized = JSON.parse(row.value as string);\n return deserializer(serialized);\n });\n }\n\n /**\n * Gets the total number of key-value pairs in the current namespace (excluding expired keys)\n *\n * @returns The count of non-expired key-value pairs\n *\n * @example\n * ```typescript\n * const count = kv.count();\n * console.log(`Total entries: ${count}`);\n * ```\n */\n public count(): number {\n const result = this.statements.count.get(this.getCurrentTime());\n\n return Number(result?.count ?? 0);\n }\n\n /**\n * Removes all key-value pairs from the current namespace\n *\n * @example\n * ```typescript\n * kv.clear(); // Removes all entries in current namespace\n * ```\n */\n public clear(): void {\n this.statements.clear.run();\n }\n\n /**\n * Gets all key-value pairs as an object (excluding expired keys)\n *\n * @returns Object with all non-expired key-value pairs\n *\n * @example\n * ```typescript\n * const all = kv.all();\n * console.log('All entries:', all);\n * // Output: { 'key1': value1, 'key2': value2 }\n * ```\n */\n public all(): Record<string, any> {\n const result = this.statements.all.all(this.getCurrentTime());\n\n return Object.fromEntries(\n result.map((row) => {\n const serialized = JSON.parse(row.value as string);\n return [row.key as string, deserializer(serialized)];\n }),\n );\n }\n\n /**\n * Gets all available namespaces (tables) in the database\n *\n * @returns Array of namespace names\n *\n * @example\n * ```typescript\n * const namespaces = kv.namespaces();\n * console.log('Available namespaces:', namespaces);\n * ```\n */\n public namespaces(): string[] {\n const result = this.statements.namespaces.all();\n\n return result.map((row) => row.name as string);\n }\n\n /**\n * Gets the current namespace name\n *\n * @returns The current namespace string\n */\n public getCurrentNamespace(): string {\n return this.options.namespace ?? 'commandkit_kv';\n }\n\n /**\n * Creates a new KV instance with a different namespace\n *\n * @param namespace - The namespace to use for the new instance\n * @returns A new KV instance with the specified namespace\n *\n * @example\n * ```typescript\n * const userKv = kv.namespace('users');\n * const configKv = kv.namespace('config');\n *\n * userKv.set('123', { name: 'John', age: 30 });\n * configKv.set('theme', 'dark');\n * ```\n */\n public namespace(namespace: string): KV {\n return new KV(this.db, {\n enableWAL: this.options.enableWAL,\n namespace,\n });\n }\n\n /**\n * Iterator implementation for iterating over all non-expired key-value pairs\n *\n * @returns Iterator yielding [key, value] tuples\n *\n * @example\n * ```typescript\n * for (const [key, value] of kv) {\n * console.log(`${key}:`, value);\n * }\n *\n * // Or using spread operator\n * const entries = [...kv];\n * ```\n */\n public *[Symbol.iterator](): Iterator<[string, any]> {\n const result = this.statements.all.iterate(this.getCurrentTime());\n\n for (const row of result) {\n const serialized = JSON.parse(row.value as string);\n yield [row.key as string, deserializer(serialized)];\n }\n }\n\n /**\n * Executes a function within a transaction\n *\n * @param fn - Function to execute within the transaction (can be async)\n * @returns The result of the function\n *\n * @example\n * ```typescript\n * // Synchronous transaction\n * kv.transaction(() => {\n * kv.set('user:123', { name: 'John', age: 30 });\n * kv.set('user:456', { name: 'Jane', age: 25 });\n * // If any operation fails, all changes are rolled back\n * });\n *\n * // Async transaction\n * await kv.transaction(async () => {\n * kv.set('user:123', { name: 'John', age: 30 });\n * await someAsyncOperation();\n * kv.set('user:456', { name: 'Jane', age: 25 });\n * // If any operation fails, all changes are rolled back\n * });\n * ```\n */\n public async transaction<T>(fn: () => T | Promise<T>): Promise<T> {\n try {\n // Begin transaction\n this.statements.begin.run();\n\n // Execute the function\n const result = await fn();\n\n // Commit transaction\n this.statements.commit.run();\n\n return result;\n } catch (error) {\n // Rollback transaction on error\n this.statements.rollback.run();\n throw error;\n }\n }\n}\n\n/**\n * Opens a new KV instance\n *\n * @param path - Database file path, buffer, URL, or existing DatabaseSync instance\n * @param options - Configuration options for the KV store\n * @returns A new KV instance\n */\nexport function openKV(\n path: string | Buffer | URL | DatabaseSync = 'commandkit_kv.db',\n options: KvOptions = { enableWAL: true, namespace: 'commandkit_kv' },\n): KV {\n return new KV(path, options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,IAAa,KAAb,MAAa,GAA0C;CACrD,AAAQ;CACR,AAAQ,aAA4C,EAAE;;;;;;;CAQtD,AAAO,YACP,MACA,AAAE,UAA2B;EAC3B,WAAW;EACX,WAAW;EACZ,EACD;EAJE;AAKA,OAAK,KACL,gBAAO,2BACP,OACA,IAAI,yBAAM,MAAa,EAAA,MAAQ,MAAM,CAAA;AAErC,MAAI,QAAQ,UACV,MAAK,GAAG,KAAc,6BAA6B;EAGrD,MAAM,YAAY,KAAK,QAAQ,aAAa;AAE5C,OAAK,GAAG,KAAc;mCACS,UAAU;;;;;MAKvC;AAEF,OAAK,aAAa;GAChB,KAAK,KAAK,GAAG,QACF,iCAAiC,UAAU,gBACrD;GACD,KAAK,KAAK,GAAG,QACF,0BAA0B,UAAU,4CAC9C;GACD,OAAO,KAAK,GAAG,QACJ,0BAA0B,UAAU,4CAC9C;GACD,QAAQ,KAAK,GAAG,QACL,eAAe,UAAU,gBACnC;GACD,KAAK,KAAK,GAAG,QACF,wBAAwB,UAAU,2DAC5C;GACD,MAAM,KAAK,GAAG,QACH,mBAAmB,UAAU,6CACvC;GACD,QAAQ,KAAK,GAAG,QACL,qBAAqB,UAAU,6CACzC;GACD,OAAO,KAAK,GAAG,QAAiB,eAAe,YAAY;GAC3D,OAAO,KAAK,GAAG,QACJ,wBAAwB,UAAU,6CAC5C;GACD,KAAK,KAAK,GAAG,QACF,0BAA0B,UAAU,6CAC9C;GACD,QAAQ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AEjE,OAAK,MAAM,OAAO,QAAQ;GACxB,MAAM,aAAa,KAAK,MAAM,IAAI,MAAgB;AAClD,SAAM,CAAC,IAAI,KAAe,8BAAa,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BvD,MAAa,YAAe,IAAsC;AAChE,MAAI;AAEF,QAAK,WAAW,MAAM,KAAK;GAG3B,MAAM,SAAS,MAAM,IAAI;AAGzB,QAAK,WAAW,OAAO,KAAK;AAE5B,UAAO;WACA,OAAO;AAEd,QAAK,WAAW,SAAS,KAAK;AAC9B,SAAM;;;;;;;;;;;AAYZ,SAAgB,OAChB,OAA6C,oBAC7C,UAAqB;CAAE,WAAW;CAAM,WAAW;CAAiB,EAC/D;AACH,QAAO,IAAI,GAAG,MAAM,QAAQ"}
|
package/dist/kv/serde.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
import "../constants-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { t as SerializerType } from "../constants-DqtJY0t-.js";
|
|
2
|
+
|
|
3
|
+
//#region src/kv/serde.d.ts
|
|
4
|
+
interface SerializedValue {
|
|
5
|
+
t: SerializerType;
|
|
6
|
+
v: any;
|
|
7
|
+
}
|
|
8
|
+
declare function serializer(value: any): SerializedValue;
|
|
9
|
+
declare function deserializer(serialized: SerializedValue): any;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { SerializedValue, deserializer, serializer };
|
|
12
|
+
//# sourceMappingURL=serde.d.ts.map
|
package/dist/kv/serde.js
CHANGED
|
@@ -1,5 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_kv_constants = require('./constants.js');
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
//#region src/kv/serde.ts
|
|
5
|
+
function serializer(value) {
|
|
6
|
+
if (value === null) return {
|
|
7
|
+
t: require_kv_constants.SerializerType.Null,
|
|
8
|
+
v: null
|
|
9
|
+
};
|
|
10
|
+
if (value === void 0) return {
|
|
11
|
+
t: require_kv_constants.SerializerType.Undefined,
|
|
12
|
+
v: void 0
|
|
13
|
+
};
|
|
14
|
+
if (typeof value === "string") return {
|
|
15
|
+
t: require_kv_constants.SerializerType.String,
|
|
16
|
+
v: value
|
|
17
|
+
};
|
|
18
|
+
if (typeof value === "number") return {
|
|
19
|
+
t: require_kv_constants.SerializerType.Number,
|
|
20
|
+
v: value
|
|
21
|
+
};
|
|
22
|
+
if (typeof value === "boolean") return {
|
|
23
|
+
t: require_kv_constants.SerializerType.Boolean,
|
|
24
|
+
v: value
|
|
25
|
+
};
|
|
26
|
+
if (typeof value === "bigint") return {
|
|
27
|
+
t: require_kv_constants.SerializerType.BigInt,
|
|
28
|
+
v: value.toString()
|
|
29
|
+
};
|
|
30
|
+
if (value instanceof Date) return {
|
|
31
|
+
t: require_kv_constants.SerializerType.Date,
|
|
32
|
+
v: value.toISOString()
|
|
33
|
+
};
|
|
34
|
+
if (Array.isArray(value)) return {
|
|
35
|
+
t: require_kv_constants.SerializerType.Array,
|
|
36
|
+
v: value
|
|
37
|
+
};
|
|
38
|
+
if (value instanceof Map) return {
|
|
39
|
+
t: require_kv_constants.SerializerType.Map,
|
|
40
|
+
v: Array.from(value.entries())
|
|
41
|
+
};
|
|
42
|
+
if (value instanceof Set) return {
|
|
43
|
+
t: require_kv_constants.SerializerType.Set,
|
|
44
|
+
v: Array.from(value)
|
|
45
|
+
};
|
|
46
|
+
if (Buffer.isBuffer(value)) return {
|
|
47
|
+
t: require_kv_constants.SerializerType.Buffer,
|
|
48
|
+
v: value.toString("base64")
|
|
49
|
+
};
|
|
50
|
+
if (value instanceof RegExp) return {
|
|
51
|
+
t: require_kv_constants.SerializerType.RegExp,
|
|
52
|
+
v: {
|
|
53
|
+
source: value.source,
|
|
54
|
+
flags: value.flags
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
if (typeof value === "object") return {
|
|
58
|
+
t: require_kv_constants.SerializerType.Object,
|
|
59
|
+
v: value
|
|
60
|
+
};
|
|
61
|
+
return {
|
|
62
|
+
t: require_kv_constants.SerializerType.String,
|
|
63
|
+
v: String(value)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function deserializer(serialized) {
|
|
67
|
+
switch (serialized.t) {
|
|
68
|
+
case require_kv_constants.SerializerType.Null: return null;
|
|
69
|
+
case require_kv_constants.SerializerType.Undefined: return;
|
|
70
|
+
case require_kv_constants.SerializerType.String: return serialized.v;
|
|
71
|
+
case require_kv_constants.SerializerType.Number: return serialized.v;
|
|
72
|
+
case require_kv_constants.SerializerType.Boolean: return serialized.v;
|
|
73
|
+
case require_kv_constants.SerializerType.BigInt: return BigInt(serialized.v);
|
|
74
|
+
case require_kv_constants.SerializerType.Date: return new Date(serialized.v);
|
|
75
|
+
case require_kv_constants.SerializerType.Array: return serialized.v;
|
|
76
|
+
case require_kv_constants.SerializerType.Map: return new Map(serialized.v);
|
|
77
|
+
case require_kv_constants.SerializerType.Set: return new Set(serialized.v);
|
|
78
|
+
case require_kv_constants.SerializerType.Buffer: return Buffer.from(serialized.v, "base64");
|
|
79
|
+
case require_kv_constants.SerializerType.RegExp: return new RegExp(serialized.v.source, serialized.v.flags);
|
|
80
|
+
case require_kv_constants.SerializerType.Object: return serialized.v;
|
|
81
|
+
default: return serialized.v;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
//#endregion
|
|
86
|
+
exports.deserializer = deserializer;
|
|
87
|
+
exports.serializer = serializer;
|
|
88
|
+
//# sourceMappingURL=serde.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serde.js","names":[],"sources":["../../src/kv/serde.ts"],"sourcesContent":["import { SerializerType } from './constants';\n\nexport interface SerializedValue {\n t: SerializerType;\n v: any;\n}\n\nexport function serializer(value: any): SerializedValue {\n if (value === null) {\n return { t: SerializerType.Null, v: null };\n }\n\n if (value === undefined) {\n return { t: SerializerType.Undefined, v: undefined };\n }\n\n if (typeof value === 'string') {\n return { t: SerializerType.String, v: value };\n }\n\n if (typeof value === 'number') {\n return { t: SerializerType.Number, v: value };\n }\n\n if (typeof value === 'boolean') {\n return { t: SerializerType.Boolean, v: value };\n }\n\n if (typeof value === 'bigint') {\n return { t: SerializerType.BigInt, v: value.toString() };\n }\n\n if (value instanceof Date) {\n return { t: SerializerType.Date, v: value.toISOString() };\n }\n\n if (Array.isArray(value)) {\n return { t: SerializerType.Array, v: value };\n }\n\n if (value instanceof Map) {\n return { t: SerializerType.Map, v: Array.from(value.entries()) };\n }\n\n if (value instanceof Set) {\n return { t: SerializerType.Set, v: Array.from(value) };\n }\n\n if (Buffer.isBuffer(value)) {\n return { t: SerializerType.Buffer, v: value.toString('base64') };\n }\n\n if (value instanceof RegExp) {\n return {\n t: SerializerType.RegExp,\n v: { source: value.source, flags: value.flags },\n };\n }\n\n if (typeof value === 'object') {\n return { t: SerializerType.Object, v: value };\n }\n\n // Fallback to string\n return { t: SerializerType.String, v: String(value) };\n}\n\nexport function deserializer(serialized: SerializedValue): any {\n switch (serialized.t) {\n case SerializerType.Null:\n return null;\n case SerializerType.Undefined:\n return undefined;\n case SerializerType.String:\n return serialized.v;\n case SerializerType.Number:\n return serialized.v;\n case SerializerType.Boolean:\n return serialized.v;\n case SerializerType.BigInt:\n return BigInt(serialized.v);\n case SerializerType.Date:\n return new Date(serialized.v);\n case SerializerType.Array:\n return serialized.v;\n case SerializerType.Map:\n return new Map(serialized.v);\n case SerializerType.Set:\n return new Set(serialized.v);\n case SerializerType.Buffer:\n return Buffer.from(serialized.v, 'base64');\n case SerializerType.RegExp:\n return new RegExp(serialized.v.source, serialized.v.flags);\n case SerializerType.Object:\n return serialized.v;\n default:\n return serialized.v;\n }\n}\n"],"mappings":";;;;AAOA,SAAgB,WAAW,OAA6B;AACtD,KAAI,UAAU,KACZ,QAAO;EAAE,GAAG,oCAAe;EAAM,GAAG;EAAM;AAG5C,KAAI,U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K,oCAAe,OAClB,QAAO,WAAW;EACpB,KAAK,oCAAe,QAClB,QAAO,WAAW;EACpB,KAAK,oCAAe,OAClB,QAAO,OAAO,WAAW,EAAE;EAC7B,KAAK,oCAAe,KAClB,QAAO,IAAI,KAAK,WAAW,EAAE;EAC/B,KAAK,oCAAe,MAClB,QAAO,WAAW;EACpB,KAAK,oCAAe,IAClB,QAAO,IAAI,IAAI,WAAW,EAAE;EAC9B,KAAK,oCAAe,IAClB,QAAO,IAAI,IAAI,WAAW,EAAE;EAC9B,KAAK,oCAAe,OAClB,QAAO,OAAO,KAAK,WAAW,GAAG,SAAS;EAC5C,KAAK,oCAAe,OAClB,QAAO,IAAI,OAAO,WAAW,EAAE,QAAQ,WAAW,EAAE,MAAM;EAC5D,KAAK,oCAAe,OAClB,QAAO,WAAW;EACpB,QACE,QAAO,WAAW"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LabelBuilder, LabelBuilderData } from "discord.js";
|
|
2
|
+
|
|
3
|
+
//#region src/components/display/label.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The label properties for the label component.
|
|
6
|
+
*/
|
|
7
|
+
interface LabelProps extends Omit<LabelBuilderData, 'component' | 'type'> {
|
|
8
|
+
/**
|
|
9
|
+
* The component that will be wrapped by the label component.
|
|
10
|
+
*/
|
|
11
|
+
children: LabelBuilderData['component'] & {};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The label component wraps modal components with text as a label and optional description.
|
|
15
|
+
* @param props The label properties.
|
|
16
|
+
* @returns The label builder instance.
|
|
17
|
+
* @example ```tsx
|
|
18
|
+
* import { Label } from 'commandkit';
|
|
19
|
+
*
|
|
20
|
+
* const label = <Label label="Name" description="Enter your name">
|
|
21
|
+
* <ShortInput customId="name" label="Name" placeholder="John" required />
|
|
22
|
+
* </Label>;
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
declare function Label(props: LabelProps): LabelBuilder;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { LabelProps as n, Label as t };
|
|
28
|
+
//# sourceMappingURL=label-DqGRqodo.d.ts.map
|
|
@@ -1,3 +1,66 @@
|
|
|
1
|
-
import "
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ILogger } from "./ILogger.js";
|
|
2
|
+
|
|
3
|
+
//#region src/logger/DefaultLogger.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Default logger implementation that logs messages to the console.
|
|
6
|
+
* It formats the log messages with timestamps, log levels, and context information.
|
|
7
|
+
*/
|
|
8
|
+
declare class DefaultLogger implements ILogger {
|
|
9
|
+
stdout: NodeJS.WriteStream & {
|
|
10
|
+
fd: 1;
|
|
11
|
+
};
|
|
12
|
+
stderr: NodeJS.WriteStream & {
|
|
13
|
+
fd: 2;
|
|
14
|
+
};
|
|
15
|
+
private logger;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new instance of DefaultLogger.
|
|
18
|
+
* @param stdout The output stream for standard messages (default: process.stdout).
|
|
19
|
+
* @param stderr The output stream for error messages (default: process.stderr).
|
|
20
|
+
*/
|
|
21
|
+
constructor(stdout?: NodeJS.WriteStream & {
|
|
22
|
+
fd: 1;
|
|
23
|
+
}, stderr?: NodeJS.WriteStream & {
|
|
24
|
+
fd: 2;
|
|
25
|
+
});
|
|
26
|
+
private _formatTime;
|
|
27
|
+
private _getContext;
|
|
28
|
+
private _getLevelLabel;
|
|
29
|
+
private _getPrefix;
|
|
30
|
+
private _log;
|
|
31
|
+
private _logTemplate;
|
|
32
|
+
/**
|
|
33
|
+
* Logs a debug message.
|
|
34
|
+
* @param message The message to log.
|
|
35
|
+
*/
|
|
36
|
+
debug(message: any): void;
|
|
37
|
+
debug(strings: TemplateStringsArray, ...values: any[]): void;
|
|
38
|
+
/**
|
|
39
|
+
* Logs an error message.
|
|
40
|
+
* @param message The error message to log.
|
|
41
|
+
*/
|
|
42
|
+
error(message: any): void;
|
|
43
|
+
error(strings: TemplateStringsArray, ...values: any[]): void;
|
|
44
|
+
/**
|
|
45
|
+
* Logs a default message.
|
|
46
|
+
* @param message The message to log.
|
|
47
|
+
*/
|
|
48
|
+
log(message: any): void;
|
|
49
|
+
log(strings: TemplateStringsArray, ...values: any[]): void;
|
|
50
|
+
/**
|
|
51
|
+
* Logs an info message.
|
|
52
|
+
* @param message The informational message to log.
|
|
53
|
+
*/
|
|
54
|
+
info(message: any): void;
|
|
55
|
+
info(strings: TemplateStringsArray, ...values: any[]): void;
|
|
56
|
+
/**
|
|
57
|
+
* Logs a warning message.
|
|
58
|
+
* @param message The warning message to log.
|
|
59
|
+
*/
|
|
60
|
+
warn(message: any): void;
|
|
61
|
+
warn(strings: TemplateStringsArray, ...values: any[]): void;
|
|
62
|
+
private _isTemplateStringsArray;
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { DefaultLogger };
|
|
66
|
+
//# sourceMappingURL=DefaultLogger.d.ts.map
|
|
@@ -1,38 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
require('../
|
|
3
|
-
require('../error-codes-Ds0bnPvT.js');
|
|
4
|
-
const require_commandkit = require('../commandkit-Bm0gLN8i.js');
|
|
5
|
-
require('../common-CcfjYnPG.js');
|
|
6
|
-
require('../common-vnMIelAE.js');
|
|
7
|
-
require('../container-C6GtfAPW.js');
|
|
8
|
-
require('../file-DVOELoNv.js');
|
|
9
|
-
require('../media-gallery-zDtJ3kxb.js');
|
|
10
|
-
require('../section-DlvrDoJK.js');
|
|
11
|
-
require('../separator-DL6QH5H1.js');
|
|
12
|
-
require('../text-display-DbMumig_.js');
|
|
13
|
-
require('../v2-DofkPKHs.js');
|
|
14
|
-
require('../element-Bak9llw_.js');
|
|
15
|
-
require('../types-CUZOquUl.js');
|
|
16
|
-
require('../EventInterceptor-CQEXyUTp.js');
|
|
17
|
-
require('../constants-B5_Ta7PR.js');
|
|
18
|
-
require('../PluginCommon-Cvl5yYM_.js');
|
|
19
|
-
require('../CompilerPlugin-M8r3yNAl.js');
|
|
20
|
-
require('../RuntimePlugin-BUecuBIU.js');
|
|
21
|
-
require('../types-q0Nm882H.js');
|
|
22
|
-
require('../resolve-file-url-ChIyw-Vf.js');
|
|
23
|
-
require('../runtime-DB9CiPfe.js');
|
|
24
|
-
require('../utils-KsNof0Xz.js');
|
|
25
|
-
require('../types-package-BWArjyBF.js');
|
|
26
|
-
require('../constants-BOOGN85p.js');
|
|
27
|
-
require('../EventWorkerContext-Dq29tieI.js');
|
|
28
|
-
require('../signals-ChFMD7mB.js');
|
|
29
|
-
require('../MessageCommandParser-CEuO6Ex3.js');
|
|
30
|
-
require('../helpers-BSwwrKJW.js');
|
|
31
|
-
require('../CommandsRouter-Cgcy6cK9.js');
|
|
32
|
-
require('../EventsRouter-3Gygh-km.js');
|
|
33
|
-
require('../router-Dn35v30f.js');
|
|
34
|
-
require('../common-Dxr9-XPa.js');
|
|
35
|
-
require('../CommandKitEventsChannel-BtRzr3Tz.js');
|
|
36
|
-
require('../store-CM6pWVZh.js');
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_commandkit = require('../commandkit-Bh7C1_c7.js');
|
|
37
3
|
|
|
38
4
|
exports.DefaultLogger = require_commandkit.DefaultLogger;
|
package/dist/logger/ILogger.d.ts
CHANGED
|
@@ -1,2 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/logger/ILogger.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* ILogger interface for logging functionality.
|
|
4
|
+
*/
|
|
5
|
+
interface ILogger {
|
|
6
|
+
/**
|
|
7
|
+
* Logs a message with the default log level.
|
|
8
|
+
* @param message The message to log.
|
|
9
|
+
*/
|
|
10
|
+
log(message: any): void;
|
|
11
|
+
/**
|
|
12
|
+
* Logs a message with the default log level using template literals.
|
|
13
|
+
* @param strings The template literal strings.
|
|
14
|
+
* @param values The values to interpolate.
|
|
15
|
+
*/
|
|
16
|
+
log(strings: TemplateStringsArray, ...values: any[]): void;
|
|
17
|
+
/**
|
|
18
|
+
* Logs an error message.
|
|
19
|
+
* @param message The error message to log.
|
|
20
|
+
*/
|
|
21
|
+
error(message: any): void;
|
|
22
|
+
/**
|
|
23
|
+
* Logs an error message using template literals.
|
|
24
|
+
* @param strings The template literal strings.
|
|
25
|
+
* @param values The values to interpolate.
|
|
26
|
+
*/
|
|
27
|
+
error(strings: TemplateStringsArray, ...values: any[]): void;
|
|
28
|
+
/**
|
|
29
|
+
* Logs a warning message.
|
|
30
|
+
* @param message The warning message to log.
|
|
31
|
+
*/
|
|
32
|
+
warn(message: any): void;
|
|
33
|
+
/**
|
|
34
|
+
* Logs a warning message using template literals.
|
|
35
|
+
* @param strings The template literal strings.
|
|
36
|
+
* @param values The values to interpolate.
|
|
37
|
+
*/
|
|
38
|
+
warn(strings: TemplateStringsArray, ...values: any[]): void;
|
|
39
|
+
/**
|
|
40
|
+
* Logs an informational message.
|
|
41
|
+
* @param message The informational message to log.
|
|
42
|
+
*/
|
|
43
|
+
info(message: any): void;
|
|
44
|
+
/**
|
|
45
|
+
* Logs an informational message using template literals.
|
|
46
|
+
* @param strings The template literal strings.
|
|
47
|
+
* @param values The values to interpolate.
|
|
48
|
+
*/
|
|
49
|
+
info(strings: TemplateStringsArray, ...values: any[]): void;
|
|
50
|
+
/**
|
|
51
|
+
* Logs a debug message.
|
|
52
|
+
* @param message The debug message to log.
|
|
53
|
+
*/
|
|
54
|
+
debug(message: any): void;
|
|
55
|
+
/**
|
|
56
|
+
* Logs a debug message using template literals.
|
|
57
|
+
* @param strings The template literal strings.
|
|
58
|
+
* @param values The values to interpolate.
|
|
59
|
+
*/
|
|
60
|
+
debug(strings: TemplateStringsArray, ...values: any[]): void;
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { ILogger };
|
|
64
|
+
//# sourceMappingURL=ILogger.d.ts.map
|
package/dist/logger/ILogger.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
package/dist/logger/Logger.d.ts
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
-
import "
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ILogger } from "./ILogger.js";
|
|
2
|
+
|
|
3
|
+
//#region src/logger/Logger.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Options for configuring the CommandKit logger.
|
|
6
|
+
*/
|
|
7
|
+
interface CommandKitLoggerOptions {
|
|
8
|
+
/**
|
|
9
|
+
* The logger provider to use.
|
|
10
|
+
*/
|
|
11
|
+
provider: ILogger;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Logger implementation for CommandKit.
|
|
15
|
+
*/
|
|
16
|
+
interface LoggerImpl extends ILogger {
|
|
17
|
+
/**
|
|
18
|
+
* Configures the logger with the specified options.
|
|
19
|
+
* @param options The logger options to apply.
|
|
20
|
+
*/
|
|
21
|
+
configure(options: CommandKitLoggerOptions): void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new logger instance with the specified options.
|
|
25
|
+
* @param options The options for configuring the logger.
|
|
26
|
+
* @returns A new logger instance.
|
|
27
|
+
*/
|
|
28
|
+
declare function createLogger(options: CommandKitLoggerOptions): LoggerImpl;
|
|
29
|
+
/**
|
|
30
|
+
* Default logger instance for CommandKit. This logger uses the DefaultLogger as its provider.
|
|
31
|
+
* The provider can be replaced with a custom logger implementation using the `configure` method.
|
|
32
|
+
*/
|
|
33
|
+
declare const Logger: LoggerImpl;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { CommandKitLoggerOptions, Logger, LoggerImpl, createLogger };
|
|
36
|
+
//# sourceMappingURL=Logger.d.ts.map
|
package/dist/logger/Logger.js
CHANGED
|
@@ -1,39 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
require('../
|
|
3
|
-
require('../error-codes-Ds0bnPvT.js');
|
|
4
|
-
const require_commandkit = require('../commandkit-Bm0gLN8i.js');
|
|
5
|
-
require('../common-CcfjYnPG.js');
|
|
6
|
-
require('../common-vnMIelAE.js');
|
|
7
|
-
require('../container-C6GtfAPW.js');
|
|
8
|
-
require('../file-DVOELoNv.js');
|
|
9
|
-
require('../media-gallery-zDtJ3kxb.js');
|
|
10
|
-
require('../section-DlvrDoJK.js');
|
|
11
|
-
require('../separator-DL6QH5H1.js');
|
|
12
|
-
require('../text-display-DbMumig_.js');
|
|
13
|
-
require('../v2-DofkPKHs.js');
|
|
14
|
-
require('../element-Bak9llw_.js');
|
|
15
|
-
require('../types-CUZOquUl.js');
|
|
16
|
-
require('../EventInterceptor-CQEXyUTp.js');
|
|
17
|
-
require('../constants-B5_Ta7PR.js');
|
|
18
|
-
require('../PluginCommon-Cvl5yYM_.js');
|
|
19
|
-
require('../CompilerPlugin-M8r3yNAl.js');
|
|
20
|
-
require('../RuntimePlugin-BUecuBIU.js');
|
|
21
|
-
require('../types-q0Nm882H.js');
|
|
22
|
-
require('../resolve-file-url-ChIyw-Vf.js');
|
|
23
|
-
require('../runtime-DB9CiPfe.js');
|
|
24
|
-
require('../utils-KsNof0Xz.js');
|
|
25
|
-
require('../types-package-BWArjyBF.js');
|
|
26
|
-
require('../constants-BOOGN85p.js');
|
|
27
|
-
require('../EventWorkerContext-Dq29tieI.js');
|
|
28
|
-
require('../signals-ChFMD7mB.js');
|
|
29
|
-
require('../MessageCommandParser-CEuO6Ex3.js');
|
|
30
|
-
require('../helpers-BSwwrKJW.js');
|
|
31
|
-
require('../CommandsRouter-Cgcy6cK9.js');
|
|
32
|
-
require('../EventsRouter-3Gygh-km.js');
|
|
33
|
-
require('../router-Dn35v30f.js');
|
|
34
|
-
require('../common-Dxr9-XPa.js');
|
|
35
|
-
require('../CommandKitEventsChannel-BtRzr3Tz.js');
|
|
36
|
-
require('../store-CM6pWVZh.js');
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_commandkit = require('../commandkit-Bh7C1_c7.js');
|
|
37
3
|
|
|
38
4
|
exports.Logger = require_commandkit.Logger;
|
|
39
5
|
exports.createLogger = require_commandkit.createLogger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoopLogger.js","names":[],"sources":["../../src/logger/NoopLogger.ts"],"sourcesContent":["import { ILogger } from './ILogger';\n\n/**\n * Noop logger implementation that does nothing.\n */\nexport class NoopLogger implements ILogger {\n /**\n * Logs a debug message.\n * @param message The message to log.\n */\n public debug(message: any): void;\n /**\n * Logs a debug message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public debug(strings: TemplateStringsArray, ...values: any[]): void;\n public debug(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n\n /**\n * Logs an error message.\n * @param message The error message to log.\n */\n public error(message: any): void;\n /**\n * Logs an error message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public error(strings: TemplateStringsArray, ...values: any[]): void;\n public error(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n\n /**\n * Logs a default message.\n * @param message The message to log.\n */\n public log(message: any): void;\n /**\n * Logs a default message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public log(strings: TemplateStringsArray, ...values: any[]): void;\n public log(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n\n /**\n * Logs an info message.\n * @param message The informational message to log.\n */\n public info(message: any): void;\n /**\n * Logs an info message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public info(strings: TemplateStringsArray, ...values: any[]): void;\n public info(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n\n /**\n * Logs a warning message.\n * @param message The warning message to log.\n */\n public warn(message: any): void;\n /**\n * Logs a warning message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public warn(strings: TemplateStringsArray, ...values: any[]): void;\n public warn(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"NoopLogger.js","names":[],"sources":["../../src/logger/NoopLogger.ts"],"sourcesContent":["import { ILogger } from './ILogger';\n\n/**\n * Noop logger implementation that does nothing.\n */\nexport class NoopLogger implements ILogger {\n /**\n * Logs a debug message.\n * @param message The message to log.\n */\n public debug(message: any): void;\n /**\n * Logs a debug message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public debug(strings: TemplateStringsArray, ...values: any[]): void;\n public debug(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n\n /**\n * Logs an error message.\n * @param message The error message to log.\n */\n public error(message: any): void;\n /**\n * Logs an error message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public error(strings: TemplateStringsArray, ...values: any[]): void;\n public error(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n\n /**\n * Logs a default message.\n * @param message The message to log.\n */\n public log(message: any): void;\n /**\n * Logs a default message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public log(strings: TemplateStringsArray, ...values: any[]): void;\n public log(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n\n /**\n * Logs an info message.\n * @param message The informational message to log.\n */\n public info(message: any): void;\n /**\n * Logs an info message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public info(strings: TemplateStringsArray, ...values: any[]): void;\n public info(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n\n /**\n * Logs a warning message.\n * @param message The warning message to log.\n */\n public warn(message: any): void;\n /**\n * Logs a warning message using template literals.\n * @param strings The template literal strings.\n * @param values The values to interpolate.\n */\n public warn(strings: TemplateStringsArray, ...values: any[]): void;\n public warn(\n messageOrStrings: any | TemplateStringsArray,\n ...values: any[]\n ): void {}\n}\n"],"mappings":";;;;;;AAKA,IAAa,aAAb,MAA2C;CAYzC,AAAO,MACP,kBACA,GAAG,QACI;CAaP,AAAO,MACP,kBACA,GAAG,QACI;CAaP,AAAO,IACP,kBACA,GAAG,QACI;CAaP,AAAO,KACP,kBACA,GAAG,QACI;CAaP,AAAO,KACP,kBACA,GAAG,QACI"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MediaGalleryBuilder, MediaGalleryItemBuilder } from "discord.js";
|
|
2
2
|
|
|
3
|
-
//#region src/components/
|
|
4
|
-
|
|
3
|
+
//#region src/components/display/media-gallery.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Represents the properties for a media gallery component.
|
|
7
6
|
*/
|
|
@@ -45,5 +44,5 @@ interface MediaGalleryItemProps {
|
|
|
45
44
|
*/
|
|
46
45
|
declare function MediaGalleryItem(props: MediaGalleryItemProps): MediaGalleryItemBuilder;
|
|
47
46
|
//#endregion
|
|
48
|
-
export {
|
|
49
|
-
//# sourceMappingURL=media-gallery-
|
|
47
|
+
export { MediaGalleryProps as i, MediaGalleryItem as n, MediaGalleryItemProps as r, MediaGallery as t };
|
|
48
|
+
//# sourceMappingURL=media-gallery-Ca8es-eB.d.ts.map
|
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../EventInterceptor-x-R2qshQ.js";
|
|
3
|
-
import "../ButtonKit-C7r7RPNf.js";
|
|
4
|
-
import "../ModalKit-Btz58KYn.js";
|
|
5
|
-
import "../element-CAXu1XtK.js";
|
|
6
|
-
import "../ActionRow-DKnFVDME.js";
|
|
7
|
-
import "../types-CJ-XvOFN.js";
|
|
8
|
-
import "../Button-4ZUXdA56.js";
|
|
9
|
-
import "../Modal-C6UTRdYQ.js";
|
|
10
|
-
import "../common-DOCvOVC4.js";
|
|
11
|
-
import "../StringSelectMenuKit-Bhs8U6WI.js";
|
|
12
|
-
import "../ChannelSelectMenuKit-BrXvBYNH.js";
|
|
13
|
-
import "../MentionableSelectMenuKit-CPTKqx-O.js";
|
|
14
|
-
import "../UserSelectMenuKit-CfqFJdxz.js";
|
|
15
|
-
import "../RoleSelectMenuKit-C26lU3sN.js";
|
|
16
|
-
import "../SelectMenu-Diy87_ba.js";
|
|
17
|
-
import "../container-DHBELeJ3.js";
|
|
18
|
-
import "../file-DTrr-p09.js";
|
|
19
|
-
import "../media-gallery-BMsXSot3.js";
|
|
20
|
-
import "../section-Dh_FhPeC.js";
|
|
21
|
-
import "../separator-CMf6Cyy5.js";
|
|
22
|
-
import "../text-display-DRw3r_lK.js";
|
|
23
|
-
import "../index-DSBMRX9A.js";
|
|
24
|
-
import "../index-DdqikUQD.js";
|
|
25
|
-
import "../MessageCommandParser-ROLibZPX.js";
|
|
26
|
-
import "../signals-SHg7J1U_.js";
|
|
27
|
-
import "../helpers-Wg6P5fRQ.js";
|
|
28
|
-
import "../CommandsRouter-CoOA7hkf.js";
|
|
29
|
-
import "../EventsRouter-BacqK6z3.js";
|
|
30
|
-
import "../index-DKcmsWXw.js";
|
|
31
|
-
import "../constants-MKu-Q1jh.js";
|
|
1
|
+
import { G as PluginTransformParameters, K as TransformedResult, W as CompilerPlugin, q as isCompilerPlugin } from "../analytics-engine-DnRsHBId.js";
|
|
32
2
|
export { CompilerPlugin, PluginTransformParameters, TransformedResult, isCompilerPlugin };
|