commandkit 1.0.0-dev.20250608124717 → 1.0.0-dev.20250609020912
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/dist/{CommandKit-CEFWQpDo.d.ts → CommandKit-VTym8VA2.d.ts} +235 -2
- package/dist/CommandKit.d.ts +1 -1
- package/dist/{EventWorkerContext-Dk7c6sRe.d.ts → EventWorkerContext-BXKO7FMY.d.ts} +2 -2
- package/dist/analytics/analytics-engine.d.ts +1 -1
- package/dist/analytics/analytics-provider.d.ts +1 -1
- package/dist/app/commands/AppCommandRunner.d.ts +1 -1
- package/dist/app/commands/Context.d.ts +1 -1
- package/dist/app/events/EventWorkerContext.d.ts +2 -2
- package/dist/app/handlers/AppCommandHandler.d.ts +1 -1
- package/dist/app/handlers/AppEventsHandler.d.ts +1 -1
- package/dist/app/index.d.ts +1 -1
- package/dist/app/register/CommandRegistrar.d.ts +1 -1
- package/dist/cli/app-process.d.ts +2 -2
- package/dist/cli/build.d.ts +1 -1
- package/dist/cli/common.d.ts +5 -5
- package/dist/cli/information.js +1 -1
- package/dist/config/config.d.ts +4 -4
- package/dist/config/default.d.ts +3 -3
- package/dist/config/loader.d.ts +3 -3
- package/dist/config/types.d.ts +2 -2
- package/dist/config/utils.d.ts +3 -3
- package/dist/{config-BX3KH7XB.d.ts → config-aIOTA81x.d.ts} +3 -3
- package/dist/context/async-context.d.ts +1 -1
- package/dist/context/environment.d.ts +1 -1
- package/dist/events/CommandKitEventsChannel.d.ts +1 -1
- package/dist/{feature-flags-DJi3gEFN.js → feature-flags-BFiGn38a.js} +74 -21
- package/dist/feature-flags-BFiGn38a.js.map +1 -0
- package/dist/flags/FlagProvider.d.ts +32 -0
- package/dist/flags/FlagProvider.js +27 -0
- package/dist/flags/FlagProvider.js.map +1 -0
- package/dist/flags/feature-flags.d.ts +2 -2
- package/dist/flags/feature-flags.js +3 -2
- package/dist/flags/store.d.ts +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +3 -2
- package/dist/plugins/CompilerPlugin.d.ts +1 -1
- package/dist/plugins/PluginCommon.d.ts +1 -1
- package/dist/plugins/RuntimePlugin.d.ts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -1
- package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -1
- package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -1
- package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -1
- package/dist/plugins/plugin-runtime/runtime.d.ts +1 -1
- package/dist/plugins/types.d.ts +1 -1
- package/dist/{types-DFaFI0H7.d.ts → types-CICvhb0c.d.ts} +2 -2
- package/dist/types.d.ts +1 -1
- package/dist/utils/dev-hooks.d.ts +1 -1
- package/dist/{utils-DOSJ2rn3.d.ts → utils-B1KWblpG.d.ts} +2 -2
- package/dist/{version-DR9rRG__.js → version-CObFfDEn.js} +2 -2
- package/dist/{version-DR9rRG__.js.map → version-CObFfDEn.js.map} +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/dist/feature-flags-DJi3gEFN.js.map +0 -1
|
@@ -761,58 +761,291 @@ declare class CommandKitPluginRuntime {
|
|
|
761
761
|
execute<R = any>(f: AsyncFunction<[CommandKitPluginRuntime, RuntimePlugin], R | undefined>): Promise<true | R | undefined>;
|
|
762
762
|
}
|
|
763
763
|
//#endregion
|
|
764
|
+
//#region src/flags/FlagProvider.d.ts
|
|
765
|
+
/**
|
|
766
|
+
* Interface for external feature flag providers.
|
|
767
|
+
* Implement this interface to integrate with external flag management systems
|
|
768
|
+
* like LaunchDarkly, Split, Unleash, etc.
|
|
769
|
+
*/
|
|
770
|
+
interface FlagProvider {
|
|
771
|
+
/**
|
|
772
|
+
* Initialize the provider (e.g., establish connections, load initial config)
|
|
773
|
+
*/
|
|
774
|
+
initialize?(): MaybePromise<void>;
|
|
775
|
+
/**
|
|
776
|
+
* Get the current value/configuration for a feature flag
|
|
777
|
+
* @param key - The feature flag key
|
|
778
|
+
* @param context - Optional context for flag evaluation
|
|
779
|
+
* @returns The flag configuration or null if not found
|
|
780
|
+
*/
|
|
781
|
+
getFlag(key: string, context?: any): MaybePromise<FlagConfiguration | null>;
|
|
782
|
+
/**
|
|
783
|
+
* Check if a flag exists in the external system
|
|
784
|
+
* @param key - The feature flag key
|
|
785
|
+
*/
|
|
786
|
+
hasFlag(key: string): MaybePromise<boolean>;
|
|
787
|
+
/**
|
|
788
|
+
* Cleanup resources when the provider is no longer needed
|
|
789
|
+
*/
|
|
790
|
+
destroy?(): MaybePromise<void>;
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Configuration returned by external flag providers
|
|
794
|
+
*/
|
|
795
|
+
interface FlagConfiguration {
|
|
796
|
+
/**
|
|
797
|
+
* Whether the flag is enabled/disabled at the provider level
|
|
798
|
+
*/
|
|
799
|
+
enabled: boolean;
|
|
800
|
+
/**
|
|
801
|
+
* Optional configuration data that can be used in the decide function
|
|
802
|
+
*/
|
|
803
|
+
config?: Record<string, any>;
|
|
804
|
+
/**
|
|
805
|
+
* Optional percentage for gradual rollouts (0-100)
|
|
806
|
+
*/
|
|
807
|
+
percentage?: number;
|
|
808
|
+
/**
|
|
809
|
+
* Optional targeting rules or segments
|
|
810
|
+
*/
|
|
811
|
+
targeting?: {
|
|
812
|
+
segments?: string[];
|
|
813
|
+
rules?: Array<{
|
|
814
|
+
condition: string;
|
|
815
|
+
value: any;
|
|
816
|
+
}>;
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Example implementation for a simple JSON-based flag provider
|
|
821
|
+
*/
|
|
822
|
+
declare class JsonFlagProvider implements FlagProvider {
|
|
823
|
+
private config;
|
|
824
|
+
private flags;
|
|
825
|
+
constructor(config: Record<string, FlagConfiguration>);
|
|
826
|
+
getFlag(key: string): Promise<FlagConfiguration | null>;
|
|
827
|
+
hasFlag(key: string): Promise<boolean>;
|
|
828
|
+
destroy(): Promise<void>;
|
|
829
|
+
}
|
|
830
|
+
//#endregion
|
|
764
831
|
//#region src/flags/feature-flags.d.ts
|
|
832
|
+
/**
|
|
833
|
+
* Set the global flag provider for all feature flags
|
|
834
|
+
*/
|
|
835
|
+
declare function setFlagProvider(provider: FlagProvider): void;
|
|
765
836
|
type MaybePromise<T> = T | Promise<T>;
|
|
837
|
+
/**
|
|
838
|
+
* Function type for identifying entities in the context of feature flags.
|
|
839
|
+
* This function should return an object representing the entity that will be used
|
|
840
|
+
* to evaluate the feature flag.
|
|
841
|
+
* It can be synchronous or asynchronous.
|
|
842
|
+
*/
|
|
766
843
|
type IdentifyFunction<R> = (context: EvaluationContext) => MaybePromise<R>;
|
|
844
|
+
/**
|
|
845
|
+
* Function type for deciding the outcome of a feature flag based on the provided entities.
|
|
846
|
+
* This function receives an object containing the entities and optionally the provider configuration,
|
|
847
|
+
* and should return the result of the decision.
|
|
848
|
+
* It can be synchronous or asynchronous.
|
|
849
|
+
*/
|
|
767
850
|
type DecideFunction<E, R> = (data: {
|
|
768
851
|
entities: E;
|
|
852
|
+
provider?: FlagConfiguration | null;
|
|
769
853
|
}) => MaybePromise<R>;
|
|
854
|
+
/**
|
|
855
|
+
* Definition for a feature flag, including its key, description, identify function,
|
|
856
|
+
* and decide function.
|
|
857
|
+
* The identify function is used to determine the entities that will be evaluated
|
|
858
|
+
* against the feature flag, while the decide function contains the logic for
|
|
859
|
+
* determining the outcome of the flag based on those entities.
|
|
860
|
+
*/
|
|
770
861
|
interface FeatureFlagDefinition<R, Entity> {
|
|
862
|
+
/**
|
|
863
|
+
* Unique key for the feature flag.
|
|
864
|
+
* Should be a string that identifies the flag.
|
|
865
|
+
*/
|
|
771
866
|
key: string;
|
|
867
|
+
/**
|
|
868
|
+
* Optional description of the feature flag.
|
|
869
|
+
* This can be used for documentation or debugging purposes.
|
|
870
|
+
*/
|
|
772
871
|
description?: string;
|
|
872
|
+
/**
|
|
873
|
+
* Optional flag to enable integration with an external flag provider.
|
|
874
|
+
* If true, the flag will use the global flag provider to determine its state.
|
|
875
|
+
* Default: false
|
|
876
|
+
*/
|
|
773
877
|
identify?: IdentifyFunction<Entity>;
|
|
878
|
+
/**
|
|
879
|
+
* Function to decide the outcome of the feature flag.
|
|
880
|
+
* This function receives the identified entities and should return the result of the decision.
|
|
881
|
+
*/
|
|
774
882
|
decide: DecideFunction<Entity, R>;
|
|
883
|
+
/**
|
|
884
|
+
* Whether to disable analytics tracking for this flag.
|
|
885
|
+
* Default: false
|
|
886
|
+
*/
|
|
887
|
+
disableAnalytics?: boolean;
|
|
775
888
|
}
|
|
776
889
|
interface CommandFlagContext {
|
|
890
|
+
/**
|
|
891
|
+
* The Discord client instance.
|
|
892
|
+
* This is the main entry point for interacting with the Discord API.
|
|
893
|
+
*/
|
|
777
894
|
client: Client<true>;
|
|
895
|
+
/**
|
|
896
|
+
* The CommandKit instance, which provides access to the command framework.
|
|
897
|
+
* This includes commands, events, and other features of CommandKit.
|
|
898
|
+
*/
|
|
778
899
|
commandkit: CommandKit;
|
|
900
|
+
/**
|
|
901
|
+
* The command context, which includes information about the command being executed.
|
|
902
|
+
* This can include the interaction, message, guild, channel, and the loaded command.
|
|
903
|
+
*/
|
|
779
904
|
command: {
|
|
905
|
+
/**
|
|
906
|
+
* The interaction object if the command was invoked via an interaction.
|
|
907
|
+
* This can be a ChatInputCommandInteraction, AutocompleteInteraction, or ContextMenuCommandInteraction.
|
|
908
|
+
*/
|
|
780
909
|
interaction?: ChatInputCommandInteraction | AutocompleteInteraction | ContextMenuCommandInteraction;
|
|
910
|
+
/**
|
|
911
|
+
* The message object if the command was invoked via a message.
|
|
912
|
+
*/
|
|
781
913
|
message?: Message;
|
|
914
|
+
/**
|
|
915
|
+
* The guild where the command was invoked, if applicable.
|
|
916
|
+
* This will be null for commands invoked in DMs.
|
|
917
|
+
*/
|
|
782
918
|
guild: Guild | null;
|
|
919
|
+
/**
|
|
920
|
+
* The channel where the command was invoked.
|
|
921
|
+
* This can be a text channel, DM channel, or any other type of text-based channel.
|
|
922
|
+
*/
|
|
783
923
|
channel: TextBasedChannel | null;
|
|
924
|
+
/**
|
|
925
|
+
* The loaded command instance that is being executed.
|
|
926
|
+
* This contains the command's metadata and logic.
|
|
927
|
+
*/
|
|
784
928
|
command: LoadedCommand;
|
|
785
929
|
};
|
|
930
|
+
/**
|
|
931
|
+
* The event context is null for command flags, as they are not tied to a specific event.
|
|
932
|
+
* This is used to differentiate between command and event flags.
|
|
933
|
+
*/
|
|
786
934
|
event: null;
|
|
787
935
|
}
|
|
788
936
|
interface EventFlagContext {
|
|
937
|
+
/**
|
|
938
|
+
* The Discord client instance.
|
|
939
|
+
* This is the main entry point for interacting with the Discord API.
|
|
940
|
+
*/
|
|
789
941
|
client: Client<true>;
|
|
942
|
+
/**
|
|
943
|
+
* The CommandKit instance, which provides access to the command framework.
|
|
944
|
+
* This includes commands, events, and other features of CommandKit.
|
|
945
|
+
*/
|
|
790
946
|
commandkit: CommandKit;
|
|
947
|
+
/**
|
|
948
|
+
* The event context, which includes information about the event being processed.
|
|
949
|
+
* This can include the parsed event data, the event name, and the namespace if applicable.
|
|
950
|
+
*/
|
|
791
951
|
event: {
|
|
952
|
+
/**
|
|
953
|
+
* The parsed event data, which contains the raw data from the event.
|
|
954
|
+
* This can include information like user IDs, channel IDs, and other relevant data.
|
|
955
|
+
*/
|
|
792
956
|
data: ParsedEvent;
|
|
957
|
+
/**
|
|
958
|
+
* The name of the event being processed.
|
|
959
|
+
* This is the string identifier for the event, such as 'messageCreate' or 'guildMemberAdd'.
|
|
960
|
+
*/
|
|
793
961
|
event: string;
|
|
962
|
+
/**
|
|
963
|
+
* The namespace of the event, if applicable.
|
|
964
|
+
* This can be used to group related events or commands together.
|
|
965
|
+
* It is null if the event does not belong to a specific namespace.
|
|
966
|
+
*/
|
|
794
967
|
namespace: string | null;
|
|
968
|
+
/**
|
|
969
|
+
* The arguments passed to the event handler.
|
|
970
|
+
* This is an array of arguments that were passed when the event was triggered.
|
|
971
|
+
* It can be used to access specific data related to the event.
|
|
972
|
+
*/
|
|
795
973
|
arguments: any[];
|
|
974
|
+
/**
|
|
975
|
+
* A function to retrieve the arguments for a specific event type.
|
|
976
|
+
* This allows for type-safe access to the arguments based on the event name.
|
|
977
|
+
* @param event - The name of the event to retrieve arguments for.
|
|
978
|
+
*/
|
|
796
979
|
argumentsAs<E extends keyof ClientEvents>(event: E): ClientEvents[E];
|
|
797
980
|
};
|
|
981
|
+
/**
|
|
982
|
+
* The command context is null for event flags, as they are not tied to a specific command.
|
|
983
|
+
* This is used to differentiate between command and event flags.
|
|
984
|
+
*/
|
|
798
985
|
command: null;
|
|
799
986
|
}
|
|
987
|
+
/**
|
|
988
|
+
* Combined context type for feature flag evaluation.
|
|
989
|
+
*/
|
|
800
990
|
type EvaluationContext = CommandFlagContext | EventFlagContext;
|
|
991
|
+
/**
|
|
992
|
+
* Function type for custom evaluation of feature flags.
|
|
993
|
+
* This function can be used to provide a custom evaluation context for the flag.
|
|
994
|
+
* It should return an object representing the entities to be evaluated.
|
|
995
|
+
*/
|
|
801
996
|
type CustomEvaluationFunction<E> = () => MaybePromise<E>;
|
|
997
|
+
/**
|
|
998
|
+
* Context for custom evaluation of feature flags.
|
|
999
|
+
* This allows for more flexible evaluation based on custom logic or external data.
|
|
1000
|
+
* The identify function can be a direct object or a function that returns the entities.
|
|
1001
|
+
*/
|
|
802
1002
|
type CustomEvaluationContext<E> = {
|
|
1003
|
+
/**
|
|
1004
|
+
* Optional function to identify the entities for evaluation.
|
|
1005
|
+
* This can be a function that returns the entities based on the current context.
|
|
1006
|
+
*/
|
|
803
1007
|
identify: E | CustomEvaluationFunction<E>;
|
|
804
1008
|
};
|
|
805
1009
|
interface FlagRunner<E, R> {
|
|
1010
|
+
/**
|
|
1011
|
+
* Execute the feature flag evaluation with the provided entities.
|
|
1012
|
+
* This method will run the identify and decide functions to determine the flag's outcome.
|
|
1013
|
+
* @param res - Optional entities to use for evaluation. If not provided, it will call the identify function.
|
|
1014
|
+
* @returns A promise that resolves to the result of the feature flag evaluation.
|
|
1015
|
+
*/
|
|
806
1016
|
(): Promise<R>;
|
|
1017
|
+
/**
|
|
1018
|
+
* Run the feature flag evaluation with a custom context.
|
|
1019
|
+
* This allows for more flexible evaluation based on custom logic or external data.
|
|
1020
|
+
* @param context - The custom evaluation context containing the identify function or object.
|
|
1021
|
+
* @returns A promise that resolves to the result of the feature flag evaluation.
|
|
1022
|
+
*/
|
|
807
1023
|
run(context: CustomEvaluationContext<E>): Promise<R>;
|
|
808
1024
|
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Class representing a feature flag in CommandKit.
|
|
1027
|
+
*/
|
|
809
1028
|
declare class FeatureFlag<R, T> {
|
|
810
1029
|
readonly options: FeatureFlagDefinition<R, T>;
|
|
811
1030
|
private commandkit;
|
|
1031
|
+
/**
|
|
1032
|
+
* Create a new feature flag.
|
|
1033
|
+
* @param options - The options for the feature flag.
|
|
1034
|
+
*/
|
|
812
1035
|
constructor(options: FeatureFlagDefinition<R, T>);
|
|
813
1036
|
private getContext;
|
|
1037
|
+
/**
|
|
1038
|
+
* Execute the feature flag evaluation.
|
|
1039
|
+
* @param res - Optional entities to use for evaluation. If not provided, it will call the identify function.
|
|
1040
|
+
* @returns A promise that resolves to the result of the feature flag evaluation.
|
|
1041
|
+
*/
|
|
814
1042
|
execute(res?: T): Promise<R>;
|
|
815
1043
|
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Create a new feature flag.
|
|
1046
|
+
* @param options - The options for the feature flag.
|
|
1047
|
+
* @returns A new instance of the FeatureFlag class.
|
|
1048
|
+
*/
|
|
816
1049
|
declare function flag<Returns = boolean, Entity = Record<any, any>>(options: FeatureFlagDefinition<Returns, Entity>): FlagRunner<Entity, Returns>;
|
|
817
1050
|
//#endregion
|
|
818
1051
|
//#region src/flags/store.d.ts
|
|
@@ -961,5 +1194,5 @@ declare class CommandKit extends EventEmitter {
|
|
|
961
1194
|
}
|
|
962
1195
|
declare const commandkit: CommandKit;
|
|
963
1196
|
//#endregion
|
|
964
|
-
export { AnalyticsEngine, AnalyticsEvent, AnalyticsProvider, AnyCommandExecute, AppCommandHandler, AppCommandRunner, AppEventsHandler, AppEventsHandlerLoadedData, AsyncFunction, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, BootstrapFunction, ChatInputCommand, ChatInputCommandContext, CommandBuilderLike, CommandContext, CommandContextOptions, CommandData, CommandExecutionMode, CommandFlagContext, CommandKit, CommandKitConfiguration, CommandKitEnvironment, CommandKitEnvironmentInternalData, CommandKitEnvironmentType, CommandKitEventDispatch, CommandKitEventsChannel, CommandKitHMREvent, CommandKitOptions, CommandKitPlugin, CommandKitPluginRuntime, CommandRegistrar, CommandTypeData, CommonDirectiveTransformer, CommonDirectiveTransformerOptions, CommonPluginRuntime, CompilerPlugin, CompilerPluginRuntime, Context, ContextParameters, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, EvaluationContext, EventFlagContext, EventListener, FeatureFlag, FeatureFlagDefinition, FilterFunction, FlagRunner, FlagStore, GenericFunction, IdentifyEvent, IdentifyFunction, InteractionCommandContext, InteractionCommandMiddlewareContext, ListenerFunction, LoadedCommand, LoadedEvent, MaybeFalsey, MaybePromise, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, PluginCommon, PluginOptions, PluginTransformParameters, PluginType, PreRegisterCommandsEvent, PreparedAppCommandExecution, ResolvableCommand, RunCommand, RuntimePlugin, SlashCommandMiddlewareContext, TemplateHandler, TransformedResult, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext, after, cancelAfter, commandkit, exitContext, flag, getCommandKit, getContext, isCommandWorkerContext, isCompilerPlugin, isPlugin, isRuntimePlugin, makeContextAwareFunction, onApplicationBootstrap, onBootstrap, provideContext, registerDevHooks, useEnvironment };
|
|
965
|
-
//# sourceMappingURL=CommandKit-
|
|
1197
|
+
export { AnalyticsEngine, AnalyticsEvent, AnalyticsProvider, AnyCommandExecute, AppCommandHandler, AppCommandRunner, AppEventsHandler, AppEventsHandlerLoadedData, AsyncFunction, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, BootstrapFunction, ChatInputCommand, ChatInputCommandContext, CommandBuilderLike, CommandContext, CommandContextOptions, CommandData, CommandExecutionMode, CommandFlagContext, CommandKit, CommandKitConfiguration, CommandKitEnvironment, CommandKitEnvironmentInternalData, CommandKitEnvironmentType, CommandKitEventDispatch, CommandKitEventsChannel, CommandKitHMREvent, CommandKitOptions, CommandKitPlugin, CommandKitPluginRuntime, CommandRegistrar, CommandTypeData, CommonDirectiveTransformer, CommonDirectiveTransformerOptions, CommonPluginRuntime, CompilerPlugin, CompilerPluginRuntime, Context, ContextParameters, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, EvaluationContext, EventFlagContext, EventListener, FeatureFlag, FeatureFlagDefinition, FilterFunction, FlagConfiguration, FlagProvider, FlagRunner, FlagStore, GenericFunction, IdentifyEvent, IdentifyFunction, InteractionCommandContext, InteractionCommandMiddlewareContext, JsonFlagProvider, ListenerFunction, LoadedCommand, LoadedEvent, MaybeFalsey, MaybePromise, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, PluginCommon, PluginOptions, PluginTransformParameters, PluginType, PreRegisterCommandsEvent, PreparedAppCommandExecution, ResolvableCommand, RunCommand, RuntimePlugin, SlashCommandMiddlewareContext, TemplateHandler, TransformedResult, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext, after, cancelAfter, commandkit, exitContext, flag, getCommandKit, getContext, isCommandWorkerContext, isCompilerPlugin, isPlugin, isRuntimePlugin, makeContextAwareFunction, onApplicationBootstrap, onBootstrap, provideContext, registerDevHooks, setFlagProvider, useEnvironment };
|
|
1198
|
+
//# sourceMappingURL=CommandKit-VTym8VA2.d.ts.map
|
package/dist/CommandKit.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BootstrapFunction, CommandKit, CommandKitConfiguration, commandkit, onApplicationBootstrap, onBootstrap } from "./CommandKit-
|
|
1
|
+
import { BootstrapFunction, CommandKit, CommandKitConfiguration, commandkit, onApplicationBootstrap, onBootstrap } from "./CommandKit-VTym8VA2.js";
|
|
2
2
|
import "./EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "./ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "./ModalKit-CKtQ8eXW.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandKit } from "./CommandKit-
|
|
1
|
+
import { CommandKit } from "./CommandKit-VTym8VA2.js";
|
|
2
2
|
import { ParsedEvent } from "./EventsRouter-BacqK6z3.js";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
|
|
@@ -17,4 +17,4 @@ declare function getEventWorkerContext(): EventWorkerContext;
|
|
|
17
17
|
declare function isEventWorkerContext(worker: any): worker is EventWorkerContext;
|
|
18
18
|
//#endregion
|
|
19
19
|
export { EventWorkerContext, eventWorkerContext, getEventWorkerContext, isEventWorkerContext, runInEventWorkerContext };
|
|
20
|
-
//# sourceMappingURL=EventWorkerContext-
|
|
20
|
+
//# sourceMappingURL=EventWorkerContext-BXKO7FMY.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnalyticsEngine, FilterFunction } from "../CommandKit-
|
|
1
|
+
import { AnalyticsEngine, FilterFunction } from "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnalyticsEvent, AnalyticsProvider, IdentifyEvent } from "../CommandKit-
|
|
1
|
+
import { AnalyticsEvent, AnalyticsProvider, IdentifyEvent } from "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyCommandExecute, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, ChatInputCommand, ChatInputCommandContext, CommandContextOptions, CommandExecutionMode, Context, ContextParameters, InteractionCommandContext, InteractionCommandMiddlewareContext, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, SlashCommandMiddlewareContext, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext } from "../../CommandKit-
|
|
1
|
+
import { AnyCommandExecute, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, ChatInputCommand, ChatInputCommandContext, CommandContextOptions, CommandExecutionMode, Context, ContextParameters, InteractionCommandContext, InteractionCommandMiddlewareContext, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, SlashCommandMiddlewareContext, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext } from "../../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../../ModalKit-CKtQ8eXW.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../../CommandKit-
|
|
1
|
+
import "../../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../../ModalKit-CKtQ8eXW.js";
|
|
@@ -29,5 +29,5 @@ import "../../CommandsRouter-C7X-eXE2.js";
|
|
|
29
29
|
import "../../EventsRouter-BacqK6z3.js";
|
|
30
30
|
import "../../index-CUPkUUOR.js";
|
|
31
31
|
import "../../constants-BPWSrMkn.js";
|
|
32
|
-
import { EventWorkerContext, eventWorkerContext, getEventWorkerContext, isEventWorkerContext, runInEventWorkerContext } from "../../EventWorkerContext-
|
|
32
|
+
import { EventWorkerContext, eventWorkerContext, getEventWorkerContext, isEventWorkerContext, runInEventWorkerContext } from "../../EventWorkerContext-BXKO7FMY.js";
|
|
33
33
|
export { EventWorkerContext, eventWorkerContext, getEventWorkerContext, isEventWorkerContext, runInEventWorkerContext };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppCommandHandler, CommandBuilderLike, CommandTypeData, LoadedCommand, PreparedAppCommandExecution, ResolvableCommand, RunCommand } from "../../CommandKit-
|
|
1
|
+
import { AppCommandHandler, CommandBuilderLike, CommandTypeData, LoadedCommand, PreparedAppCommandExecution, ResolvableCommand, RunCommand } from "../../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../../ModalKit-CKtQ8eXW.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppEventsHandler, AppEventsHandlerLoadedData, EventListener, LoadedEvent } from "../../CommandKit-
|
|
1
|
+
import { AppEventsHandler, AppEventsHandlerLoadedData, EventListener, LoadedEvent } from "../../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../../ModalKit-CKtQ8eXW.js";
|
package/dist/app/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyCommandExecute, AppCommandHandler, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, ChatInputCommand, ChatInputCommandContext, CommandBuilderLike, CommandContextOptions, CommandExecutionMode, CommandRegistrar, CommandTypeData, Context, ContextParameters, InteractionCommandContext, InteractionCommandMiddlewareContext, LoadedCommand, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, PreRegisterCommandsEvent, PreparedAppCommandExecution, ResolvableCommand, RunCommand, SlashCommandMiddlewareContext, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext } from "../CommandKit-
|
|
1
|
+
import { AnyCommandExecute, AppCommandHandler, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, ChatInputCommand, ChatInputCommandContext, CommandBuilderLike, CommandContextOptions, CommandExecutionMode, CommandRegistrar, CommandTypeData, Context, ContextParameters, InteractionCommandContext, InteractionCommandMiddlewareContext, LoadedCommand, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, PreRegisterCommandsEvent, PreparedAppCommandExecution, ResolvableCommand, RunCommand, SlashCommandMiddlewareContext, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext } from "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandRegistrar, PreRegisterCommandsEvent } from "../../CommandKit-
|
|
1
|
+
import { CommandRegistrar, PreRegisterCommandsEvent } from "../../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../../ModalKit-CKtQ8eXW.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as child_process4 from "child_process";
|
|
2
2
|
|
|
3
3
|
//#region src/cli/app-process.d.ts
|
|
4
|
-
declare function createAppProcess(fileName: string, cwd: string, isDev: boolean):
|
|
4
|
+
declare function createAppProcess(fileName: string, cwd: string, isDev: boolean): child_process4.ChildProcess;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { createAppProcess };
|
|
7
7
|
//# sourceMappingURL=app-process.d.ts.map
|
package/dist/cli/build.d.ts
CHANGED
package/dist/cli/common.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../CommandKit-
|
|
1
|
+
import "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
|
@@ -29,9 +29,9 @@ import "../CommandsRouter-C7X-eXE2.js";
|
|
|
29
29
|
import "../EventsRouter-BacqK6z3.js";
|
|
30
30
|
import "../index-CUPkUUOR.js";
|
|
31
31
|
import "../constants-BPWSrMkn.js";
|
|
32
|
-
import "../types-
|
|
33
|
-
import { ResolvedCommandKitConfig } from "../utils-
|
|
34
|
-
import * as
|
|
32
|
+
import "../types-CICvhb0c.js";
|
|
33
|
+
import { ResolvedCommandKitConfig } from "../utils-B1KWblpG.js";
|
|
34
|
+
import * as typescript5 from "typescript";
|
|
35
35
|
|
|
36
36
|
//#region src/cli/common.d.ts
|
|
37
37
|
declare function write(message: any): void;
|
|
@@ -41,7 +41,7 @@ declare function findEntrypoint(dir: string): string;
|
|
|
41
41
|
*/
|
|
42
42
|
declare function panic(message: any): never;
|
|
43
43
|
declare function findPackageJSON(): any;
|
|
44
|
-
declare function loadTypeScript(e?: string): Promise<typeof
|
|
44
|
+
declare function loadTypeScript(e?: string): Promise<typeof typescript5>;
|
|
45
45
|
declare function loadConfigFileFromPath(target: string): Promise<ResolvedCommandKitConfig>;
|
|
46
46
|
declare function erase(dir: string): void;
|
|
47
47
|
declare function copyLocaleFiles(_from: string, _to: string): Promise<void>;
|
package/dist/cli/information.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('../chunk-nOFOJqeH.js');
|
|
2
|
-
const require_version = require('../version-
|
|
2
|
+
const require_version = require('../version-CObFfDEn.js');
|
|
3
3
|
const node_fs = require_chunk.__toESM(require("node:fs"));
|
|
4
4
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
5
5
|
const node_child_process = require_chunk.__toESM(require("node:child_process"));
|
package/dist/config/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../CommandKit-
|
|
1
|
+
import "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
|
@@ -29,7 +29,7 @@ import "../CommandsRouter-C7X-eXE2.js";
|
|
|
29
29
|
import "../EventsRouter-BacqK6z3.js";
|
|
30
30
|
import "../index-CUPkUUOR.js";
|
|
31
31
|
import "../constants-BPWSrMkn.js";
|
|
32
|
-
import "../types-
|
|
33
|
-
import "../utils-
|
|
34
|
-
import { defineConfig, getConfig } from "../config-
|
|
32
|
+
import "../types-CICvhb0c.js";
|
|
33
|
+
import "../utils-B1KWblpG.js";
|
|
34
|
+
import { defineConfig, getConfig } from "../config-aIOTA81x.js";
|
|
35
35
|
export { defineConfig, getConfig };
|
package/dist/config/default.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../CommandKit-
|
|
1
|
+
import "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
|
@@ -29,8 +29,8 @@ import "../CommandsRouter-C7X-eXE2.js";
|
|
|
29
29
|
import "../EventsRouter-BacqK6z3.js";
|
|
30
30
|
import "../index-CUPkUUOR.js";
|
|
31
31
|
import "../constants-BPWSrMkn.js";
|
|
32
|
-
import "../types-
|
|
33
|
-
import { ResolvedCommandKitConfig } from "../utils-
|
|
32
|
+
import "../types-CICvhb0c.js";
|
|
33
|
+
import { ResolvedCommandKitConfig } from "../utils-B1KWblpG.js";
|
|
34
34
|
|
|
35
35
|
//#region src/config/default.d.ts
|
|
36
36
|
declare const defaultConfig: ResolvedCommandKitConfig;
|
package/dist/config/loader.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../CommandKit-
|
|
1
|
+
import "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
|
@@ -29,8 +29,8 @@ import "../CommandsRouter-C7X-eXE2.js";
|
|
|
29
29
|
import "../EventsRouter-BacqK6z3.js";
|
|
30
30
|
import "../index-CUPkUUOR.js";
|
|
31
31
|
import "../constants-BPWSrMkn.js";
|
|
32
|
-
import { CommandKitConfig } from "../types-
|
|
33
|
-
import { DeepRequired } from "../utils-
|
|
32
|
+
import { CommandKitConfig } from "../types-CICvhb0c.js";
|
|
33
|
+
import { DeepRequired } from "../utils-B1KWblpG.js";
|
|
34
34
|
|
|
35
35
|
//#region src/config/loader.d.ts
|
|
36
36
|
declare function getPossibleConfigPaths(root: string): string[];
|
package/dist/config/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../CommandKit-
|
|
1
|
+
import "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
|
@@ -29,5 +29,5 @@ import "../CommandsRouter-C7X-eXE2.js";
|
|
|
29
29
|
import "../EventsRouter-BacqK6z3.js";
|
|
30
30
|
import "../index-CUPkUUOR.js";
|
|
31
31
|
import "../constants-BPWSrMkn.js";
|
|
32
|
-
import { CommandKitConfig } from "../types-
|
|
32
|
+
import { CommandKitConfig } from "../types-CICvhb0c.js";
|
|
33
33
|
export { CommandKitConfig };
|
package/dist/config/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../CommandKit-
|
|
1
|
+
import "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
|
@@ -29,6 +29,6 @@ import "../CommandsRouter-C7X-eXE2.js";
|
|
|
29
29
|
import "../EventsRouter-BacqK6z3.js";
|
|
30
30
|
import "../index-CUPkUUOR.js";
|
|
31
31
|
import "../constants-BPWSrMkn.js";
|
|
32
|
-
import "../types-
|
|
33
|
-
import { DeepPartial, DeepRequired, ResolvedCommandKitConfig, mergeDeep } from "../utils-
|
|
32
|
+
import "../types-CICvhb0c.js";
|
|
33
|
+
import { DeepPartial, DeepRequired, ResolvedCommandKitConfig, mergeDeep } from "../utils-B1KWblpG.js";
|
|
34
34
|
export { DeepPartial, DeepRequired, ResolvedCommandKitConfig, mergeDeep };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CommandKitConfig } from "./types-
|
|
2
|
-
import { ResolvedCommandKitConfig } from "./utils-
|
|
1
|
+
import { CommandKitConfig } from "./types-CICvhb0c.js";
|
|
2
|
+
import { ResolvedCommandKitConfig } from "./utils-B1KWblpG.js";
|
|
3
3
|
|
|
4
4
|
//#region src/config/config.d.ts
|
|
5
5
|
|
|
@@ -14,4 +14,4 @@ declare function getConfig(): ResolvedCommandKitConfig;
|
|
|
14
14
|
declare function defineConfig(config?: Partial<CommandKitConfig>): ResolvedCommandKitConfig;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { defineConfig, getConfig };
|
|
17
|
-
//# sourceMappingURL=config-
|
|
17
|
+
//# sourceMappingURL=config-aIOTA81x.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AsyncFunction, GenericFunction, exitContext, getCommandKit, getContext, isCommandWorkerContext, makeContextAwareFunction, provideContext, useEnvironment } from "../CommandKit-
|
|
1
|
+
import { AsyncFunction, GenericFunction, exitContext, getCommandKit, getContext, isCommandWorkerContext, makeContextAwareFunction, provideContext, useEnvironment } from "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandKitEnvironment, CommandKitEnvironmentInternalData, CommandKitEnvironmentType, after, cancelAfter } from "../CommandKit-
|
|
1
|
+
import { CommandKitEnvironment, CommandKitEnvironmentInternalData, CommandKitEnvironmentType, after, cancelAfter } from "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandKitEventsChannel, ListenerFunction } from "../CommandKit-
|
|
1
|
+
import { CommandKitEventsChannel, ListenerFunction } from "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
|
@@ -3,8 +3,22 @@ const require_EventWorkerContext = require('./EventWorkerContext-BAKiTqJz.js');
|
|
|
3
3
|
const require_constants = require('./constants-DWe181uQ.js');
|
|
4
4
|
|
|
5
5
|
//#region src/flags/feature-flags.ts
|
|
6
|
+
let flagProvider = null;
|
|
7
|
+
/**
|
|
8
|
+
* Set the global flag provider for all feature flags
|
|
9
|
+
*/
|
|
10
|
+
function setFlagProvider(provider) {
|
|
11
|
+
flagProvider = provider;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Class representing a feature flag in CommandKit.
|
|
15
|
+
*/
|
|
6
16
|
var FeatureFlag = class {
|
|
7
17
|
commandkit;
|
|
18
|
+
/**
|
|
19
|
+
* Create a new feature flag.
|
|
20
|
+
* @param options - The options for the feature flag.
|
|
21
|
+
*/
|
|
8
22
|
constructor(options) {
|
|
9
23
|
this.options = options;
|
|
10
24
|
this.commandkit = require_CommandKit.getCommandKit(true);
|
|
@@ -50,40 +64,73 @@ var FeatureFlag = class {
|
|
|
50
64
|
}
|
|
51
65
|
throw new Error("Could not determine the execution context. Feature flags may only be used inside a command or event.");
|
|
52
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Execute the feature flag evaluation.
|
|
69
|
+
* @param res - Optional entities to use for evaluation. If not provided, it will call the identify function.
|
|
70
|
+
* @returns A promise that resolves to the result of the feature flag evaluation.
|
|
71
|
+
*/
|
|
53
72
|
async execute(res) {
|
|
54
|
-
const { decide, identify } = this.options;
|
|
73
|
+
const { decide, identify, disableAnalytics } = this.options;
|
|
55
74
|
const identificationStart = performance.now();
|
|
56
75
|
const entities = res ?? await (async () => {
|
|
57
76
|
const ctx = this.getContext();
|
|
58
77
|
return await (identify === null || identify === void 0 ? void 0 : identify(ctx)) ?? {};
|
|
59
78
|
})();
|
|
60
79
|
const identificationTime = performance.now() - identificationStart;
|
|
80
|
+
let providerConfig = null;
|
|
81
|
+
if (flagProvider) try {
|
|
82
|
+
providerConfig = await flagProvider.getFlag(this.options.key, entities);
|
|
83
|
+
if (providerConfig && !providerConfig.enabled) {
|
|
84
|
+
if (typeof decide === "function") {
|
|
85
|
+
const decisionResult$1 = await decide({
|
|
86
|
+
entities,
|
|
87
|
+
provider: providerConfig
|
|
88
|
+
});
|
|
89
|
+
return decisionResult$1;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
} catch (error) {
|
|
93
|
+
require_CommandKit.Logger.error(`Error fetching flag provider configuration for "${this.options.key}": ${error}`);
|
|
94
|
+
}
|
|
61
95
|
const decisionStart = performance.now();
|
|
62
|
-
const decisionResult = await decide({
|
|
96
|
+
const decisionResult = await decide({
|
|
97
|
+
entities,
|
|
98
|
+
provider: providerConfig
|
|
99
|
+
});
|
|
63
100
|
const decisionTime = performance.now() - decisionStart;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
101
|
+
if (!disableAnalytics) {
|
|
102
|
+
require_CommandKit.defer(async () => {
|
|
103
|
+
await this.commandkit.analytics.track({
|
|
104
|
+
name: require_constants.AnalyticsEvents.FEATURE_FLAG_METRICS,
|
|
105
|
+
data: {
|
|
106
|
+
flag: this.options.key,
|
|
107
|
+
identificationTime: identificationTime.toFixed(2),
|
|
108
|
+
decisionTime: decisionTime.toFixed(2),
|
|
109
|
+
usedProvider: flagProvider !== null,
|
|
110
|
+
providerEnabled: (providerConfig === null || providerConfig === void 0 ? void 0 : providerConfig.enabled) ?? null
|
|
111
|
+
}
|
|
112
|
+
});
|
|
72
113
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
114
|
+
require_CommandKit.defer(async () => {
|
|
115
|
+
await this.commandkit.analytics.track({
|
|
116
|
+
name: require_constants.AnalyticsEvents.FEATURE_FLAG_DECISION,
|
|
117
|
+
id: entities && typeof entities === "object" && "id" in entities && typeof entities.id === "string" ? entities.id : void 0,
|
|
118
|
+
data: {
|
|
119
|
+
flag: this.options.key,
|
|
120
|
+
decision: require_CommandKit.JsonSerialize(decisionResult, "unknown"),
|
|
121
|
+
providerUsed: flagProvider !== null
|
|
122
|
+
}
|
|
123
|
+
});
|
|
82
124
|
});
|
|
83
|
-
}
|
|
125
|
+
}
|
|
84
126
|
return decisionResult;
|
|
85
127
|
}
|
|
86
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* Create a new feature flag.
|
|
131
|
+
* @param options - The options for the feature flag.
|
|
132
|
+
* @returns A new instance of the FeatureFlag class.
|
|
133
|
+
*/
|
|
87
134
|
function flag(options) {
|
|
88
135
|
const flag$1 = new FeatureFlag(options);
|
|
89
136
|
const runner = flag$1.execute.bind(flag$1, void 0);
|
|
@@ -109,4 +156,10 @@ Object.defineProperty(exports, 'flag', {
|
|
|
109
156
|
return flag;
|
|
110
157
|
}
|
|
111
158
|
});
|
|
112
|
-
|
|
159
|
+
Object.defineProperty(exports, 'setFlagProvider', {
|
|
160
|
+
enumerable: true,
|
|
161
|
+
get: function () {
|
|
162
|
+
return setFlagProvider;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
//# sourceMappingURL=feature-flags-BFiGn38a.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature-flags-BFiGn38a.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\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\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\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":";;;;;AAqBA,IAAI,eAAoC;;;;AAKxC,SAAgB,gBAAgB,UAA8B;AAC5D,gBAAe;AACjB;;;;AAiNA,IAAa,cAAb,MAA+B;CAC7B,AAAQ;;;;;CAMR,AAAO,YAA4B,SAAsC;EAAtC;AACjC,OAAK,aAAa,iCAAc,KAAK;EACrC,MAAM,YAAY,KAAK,WAAW;AAElC,MAAI,UAAU,IAAI,QAAQ,IAAI,CAC5B,OAAM,IAAI,OAAO,yBAAyB,QAAQ,IAAI;AAGxD,YAAU,IAAI,QAAQ,KAAK,KAAK;CAClC;CAEA,AAAQ,aAAgC;EACtC,MAAM,MAAM,+BAAY;AAExB,gDAAI,IAAK,SAAS;GAChB,MAAM,EACJ,QACA,YACA,aACA,SACA,OACA,SACA,SACD,GAAG,IAAI;AAER,UAAO;IACG;IACR;IACA,SAAS;KACP;KACA;KACA;KACA;KACA;IACD;IACD,OAAO;GACR;EACH;EAEA,MAAM,WAAW,8CAAmB,UAAU;AAE9C,MAAI,UAAU;GACZ,MAAM,EAAE,YAAY,MAAM,OAAO,WAAW,GAAG;AAE/C,UAAO;IACL,QAAQ,WAAW;IACnB;IACA,OAAO;KACL;KACA;KACA;KACA,WAAW,SAAS;KACpB,aAAa,CAAC,cAAc;MAC1B,MAAM,OAAO,SAAS;AACtB,aAAO;KACR;IACF;IACD,SAAS;GACV;EACH;AAEA,QAAM,IAAI,MACR;CAEJ;;;;;;CAOA,MAAa,QAAQ,KAAqB;EACxC,MAAM,EAAE,QAAQ,UAAU,kBAAkB,GAAG,KAAK;EAEpD,MAAM,sBAAsB,YAAY,KAAK;EAC7C,MAAM,WACN,OACA,MAAM,CAAC,YAAY;GACjB,MAAM,MAAM,KAAK,YAAY;AAC7B,UAAQ,2DAAM,SAAW,IAAI,KAAK,CAAE;EACrC,IAAG;EACJ,MAAM,qBAAqB,YAAY,KAAK,GAAG;EAG/C,IAAI,iBAA2C;AAC/C,MAAI,aACF,KAAI;AACF,oBAAiB,MAAM,aAAa,QAAQ,KAAK,QAAQ,KAAK,SAAS;AAGvE,OAAI,mBAAmB,eAAe,SAEpC;eAAW,WAAW,YAAY;KAChC,MAAM,mBAAiB,MAAM,OAAO;MAClC;MACA,UAAU;KACX,EAAC;AACF,YAAO;IACT;;EAEH,SAAQ,OAAO;AACd,6BAAO,OACJ,kDAAkD,KAAK,QAAQ,IAAI,KAAK,MAAM,EAChF;EAEH;EAGF,MAAM,gBAAgB,YAAY,KAAK;EACvC,MAAM,iBAAiB,MAAM,OAAO;GAClC;GACA,UAAU;EACX,EAAC;EACF,MAAM,eAAe,YAAY,KAAK,GAAG;AAGzC,OAAK,kBAAkB;AACrB,4BAAM,YAAY;AAChB,UAAM,KAAK,WAAW,UAAU,MAAM;KACpC,MAAM,kCAAgB;KACtB,MAAM;MACJ,MAAM,KAAK,QAAQ;MACnB,oBAAoB,mBAAmB,QAAQ,EAAE;MACjD,cAAc,aAAa,QAAQ,EAAE;MACrC,cAAc,iBAAiB;MAC/B,kFAAiB,eAAgB,YAAW;KAC7C;IACF,EAAC;GACH,EAAC;AAEF,4BAAM,YAAY;AAChB,UAAM,KAAK,WAAW,UAAU,MAAM;KACpC,MAAM,kCAAgB;KACtB,IACA,mBACO,aAAa,YACpB,QAAQ,mBACD,SAAS,OAAO,WACvB,SAAS;KAET,MAAM;MACJ,MAAM,KAAK,QAAQ;MACnB,UAAU,iCAAc,gBAAgB,UAAU;MAClD,cAAc,iBAAiB;KAChC;IACF,EAAC;GACH,EAAC;EACJ;AAEA,SAAO;CACT;AACF;;;;;;AAOA,SAAgB,KAChB,SAC8B;CAC5B,MAAM,SAAO,IAAI,YAA6B;CAC9C,MAAM,SAAS,OAAK,QAAQ,KAAK,eAAgB;AAKjD,QAAO,MAAM,eAAgB,KAAK;AAChC,kDAAK,IAAK,UACR,OAAM,IAAI,MACR;EAIJ,MAAM,iBACC,QAAQ,aACf,MAAM,AAAC,KAA0C,GACjD;EAGA,MAAM,iBAAiB,MAAM,OAAK,QAAQ,QAAQ;AAElD,SAAO;CACR;AAED,QAAO;AACT"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FlagConfiguration, FlagProvider, JsonFlagProvider } from "../CommandKit-VTym8VA2.js";
|
|
2
|
+
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
|
+
import "../ButtonKit-BSI7lCI0.js";
|
|
4
|
+
import "../ModalKit-CKtQ8eXW.js";
|
|
5
|
+
import "../element-D_nyVwgB.js";
|
|
6
|
+
import "../ActionRow-D0wafJhZ.js";
|
|
7
|
+
import "../types-CJ-XvOFN.js";
|
|
8
|
+
import "../Button-Bl5nbwTS.js";
|
|
9
|
+
import "../Modal-Cxm6cs5c.js";
|
|
10
|
+
import "../common-pvPJVTfe.js";
|
|
11
|
+
import "../StringSelectMenuKit-B9FHTe48.js";
|
|
12
|
+
import "../ChannelSelectMenuKit-L15A2jpT.js";
|
|
13
|
+
import "../MentionableSelectMenuKit-BiUSKUtZ.js";
|
|
14
|
+
import "../UserSelectMenuKit-DiP0imyo.js";
|
|
15
|
+
import "../RoleSelectMenuKit-BSMKkru2.js";
|
|
16
|
+
import "../SelectMenu-b7jgrkjO.js";
|
|
17
|
+
import "../container-CwEATQy2.js";
|
|
18
|
+
import "../file-BdyYwkaI.js";
|
|
19
|
+
import "../media-gallery-DCu02VXc.js";
|
|
20
|
+
import "../section-fktaECHL.js";
|
|
21
|
+
import "../separator-CuesaLrC.js";
|
|
22
|
+
import "../text-display-DNMwmGHJ.js";
|
|
23
|
+
import "../index-Dw5cCt-A.js";
|
|
24
|
+
import "../index-E7Wvm5uX.js";
|
|
25
|
+
import "../MessageCommandParser-tzroBwij.js";
|
|
26
|
+
import "../signals-DUoWkeZ7.js";
|
|
27
|
+
import "../helpers-DAmE106r.js";
|
|
28
|
+
import "../CommandsRouter-C7X-eXE2.js";
|
|
29
|
+
import "../EventsRouter-BacqK6z3.js";
|
|
30
|
+
import "../index-CUPkUUOR.js";
|
|
31
|
+
import "../constants-BPWSrMkn.js";
|
|
32
|
+
export { FlagConfiguration, FlagProvider, JsonFlagProvider };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/flags/FlagProvider.ts
|
|
3
|
+
/**
|
|
4
|
+
* Example implementation for a simple JSON-based flag provider
|
|
5
|
+
*/
|
|
6
|
+
var JsonFlagProvider = class {
|
|
7
|
+
flags = /* @__PURE__ */ new Map();
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.config = config;
|
|
10
|
+
Object.entries(config).forEach(([key, value]) => {
|
|
11
|
+
this.flags.set(key, value);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
async getFlag(key) {
|
|
15
|
+
return this.flags.get(key) || null;
|
|
16
|
+
}
|
|
17
|
+
async hasFlag(key) {
|
|
18
|
+
return this.flags.has(key);
|
|
19
|
+
}
|
|
20
|
+
async destroy() {
|
|
21
|
+
this.flags.clear();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.JsonFlagProvider = JsonFlagProvider;
|
|
27
|
+
//# sourceMappingURL=FlagProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlagProvider.js","names":[],"sources":["../../src/flags/FlagProvider.ts"],"sourcesContent":["import type { MaybePromise } from './feature-flags';\n\n/**\n * Interface for external feature flag providers.\n * Implement this interface to integrate with external flag management systems\n * like LaunchDarkly, Split, Unleash, etc.\n */\nexport interface FlagProvider {\n /**\n * Initialize the provider (e.g., establish connections, load initial config)\n */\n initialize?(): MaybePromise<void>;\n\n /**\n * Get the current value/configuration for a feature flag\n * @param key - The feature flag key\n * @param context - Optional context for flag evaluation\n * @returns The flag configuration or null if not found\n */\n getFlag(key: string, context?: any): MaybePromise<FlagConfiguration | null>;\n\n /**\n * Check if a flag exists in the external system\n * @param key - The feature flag key\n */\n hasFlag(key: string): MaybePromise<boolean>;\n\n /**\n * Cleanup resources when the provider is no longer needed\n */\n destroy?(): MaybePromise<void>;\n}\n\n/**\n * Configuration returned by external flag providers\n */\nexport interface FlagConfiguration {\n /**\n * Whether the flag is enabled/disabled at the provider level\n */\n enabled: boolean;\n\n /**\n * Optional configuration data that can be used in the decide function\n */\n config?: Record<string, any>;\n\n /**\n * Optional percentage for gradual rollouts (0-100)\n */\n percentage?: number;\n\n /**\n * Optional targeting rules or segments\n */\n targeting?: {\n segments?: string[];\n rules?: Array<{\n condition: string;\n value: any;\n }>;\n };\n}\n\n/**\n * Example implementation for a simple JSON-based flag provider\n */\nexport class JsonFlagProvider implements FlagProvider {\n private flags: Map<string, FlagConfiguration> = new Map();\n\n public constructor(private config: Record<string, FlagConfiguration>) {\n Object.entries(config).forEach(([key, value]) => {\n this.flags.set(key, value);\n });\n }\n\n public async getFlag(key: string): Promise<FlagConfiguration | null> {\n return this.flags.get(key) || null;\n }\n\n public async hasFlag(key: string): Promise<boolean> {\n return this.flags.has(key);\n }\n\n public async destroy(): Promise<void> {\n this.flags.clear();\n }\n}\n"],"mappings":";;;;;AAmEA,IAAa,mBAAb,MAAsD;CACpD,AAAQ,wBAAwC,IAAI;CAEpD,AAAO,YAAoB,QAA2C;EAA3C;AACzB,SAAO,QAAQ,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,MAAM,KAAK;AAC/C,QAAK,MAAM,IAAI,KAAK,MAAM;EAC3B,EAAC;CACJ;CAEA,MAAa,QAAQ,KAAgD;AACnE,SAAO,KAAK,MAAM,IAAI,IAAI,IAAI;CAChC;CAEA,MAAa,QAAQ,KAA+B;AAClD,SAAO,KAAK,MAAM,IAAI,IAAI;CAC5B;CAEA,MAAa,UAAyB;AACpC,OAAK,MAAM,OAAO;CACpB;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandFlagContext, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, EvaluationContext, EventFlagContext, FeatureFlag, FeatureFlagDefinition, FlagRunner, IdentifyFunction, MaybePromise, flag } from "../CommandKit-
|
|
1
|
+
import { CommandFlagContext, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, EvaluationContext, EventFlagContext, FeatureFlag, FeatureFlagDefinition, FlagRunner, IdentifyFunction, MaybePromise, flag, setFlagProvider } from "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
|
@@ -29,4 +29,4 @@ import "../CommandsRouter-C7X-eXE2.js";
|
|
|
29
29
|
import "../EventsRouter-BacqK6z3.js";
|
|
30
30
|
import "../index-CUPkUUOR.js";
|
|
31
31
|
import "../constants-BPWSrMkn.js";
|
|
32
|
-
export { CommandFlagContext, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, EvaluationContext, EventFlagContext, FeatureFlag, FeatureFlagDefinition, FlagRunner, IdentifyFunction, MaybePromise, flag };
|
|
32
|
+
export { CommandFlagContext, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, EvaluationContext, EventFlagContext, FeatureFlag, FeatureFlagDefinition, FlagRunner, IdentifyFunction, MaybePromise, flag, setFlagProvider };
|
|
@@ -34,7 +34,8 @@ require('../router-Dn35v30f.js');
|
|
|
34
34
|
require('../common-CW8v7gAn.js');
|
|
35
35
|
require('../CommandKitEventsChannel-B6LKgxmv.js');
|
|
36
36
|
require('../store-Ci6ib2C9.js');
|
|
37
|
-
const require_feature_flags = require('../feature-flags-
|
|
37
|
+
const require_feature_flags = require('../feature-flags-BFiGn38a.js');
|
|
38
38
|
|
|
39
39
|
exports.FeatureFlag = require_feature_flags.FeatureFlag;
|
|
40
|
-
exports.flag = require_feature_flags.flag;
|
|
40
|
+
exports.flag = require_feature_flags.flag;
|
|
41
|
+
exports.setFlagProvider = require_feature_flags.setFlagProvider;
|
package/dist/flags/store.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyCommandExecute, AppCommandHandler, AsyncFunction, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, BootstrapFunction, ChatInputCommand, ChatInputCommandContext, CommandBuilderLike, CommandContext, CommandContextOptions, CommandData, CommandExecutionMode, CommandFlagContext, CommandKit, CommandKitConfiguration, CommandKitEnvironment, CommandKitEnvironmentInternalData, CommandKitEnvironmentType, CommandKitEventDispatch, CommandKitHMREvent, CommandKitOptions, CommandKitPlugin, CommandKitPluginRuntime, CommandRegistrar, CommandTypeData, CommonDirectiveTransformer, CommonDirectiveTransformerOptions, CommonPluginRuntime, CompilerPlugin, CompilerPluginRuntime, Context, ContextParameters, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, EvaluationContext, EventFlagContext, FeatureFlag, FeatureFlagDefinition, FlagRunner, GenericFunction, IdentifyFunction, InteractionCommandContext, InteractionCommandMiddlewareContext, LoadedCommand, MaybeFalsey, MaybePromise, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, PluginTransformParameters, PreRegisterCommandsEvent, PreparedAppCommandExecution, ResolvableCommand, RunCommand, RuntimePlugin, SlashCommandMiddlewareContext, TemplateHandler, TransformedResult, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext, after, cancelAfter, commandkit, exitContext, flag, getCommandKit, getContext, isCommandWorkerContext, isCompilerPlugin, isRuntimePlugin, makeContextAwareFunction, onApplicationBootstrap, onBootstrap, provideContext, useEnvironment } from "./CommandKit-
|
|
1
|
+
import { AnyCommandExecute, AppCommandHandler, AsyncFunction, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, BootstrapFunction, ChatInputCommand, ChatInputCommandContext, CommandBuilderLike, CommandContext, CommandContextOptions, CommandData, CommandExecutionMode, CommandFlagContext, CommandKit, CommandKitConfiguration, CommandKitEnvironment, CommandKitEnvironmentInternalData, CommandKitEnvironmentType, CommandKitEventDispatch, CommandKitHMREvent, CommandKitOptions, CommandKitPlugin, CommandKitPluginRuntime, CommandRegistrar, CommandTypeData, CommonDirectiveTransformer, CommonDirectiveTransformerOptions, CommonPluginRuntime, CompilerPlugin, CompilerPluginRuntime, Context, ContextParameters, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, EvaluationContext, EventFlagContext, FeatureFlag, FeatureFlagDefinition, FlagRunner, GenericFunction, IdentifyFunction, InteractionCommandContext, InteractionCommandMiddlewareContext, LoadedCommand, MaybeFalsey, MaybePromise, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, MiddlewareContext, MiddlewareContextArgs, PluginTransformParameters, PreRegisterCommandsEvent, PreparedAppCommandExecution, ResolvableCommand, RunCommand, RuntimePlugin, SlashCommandMiddlewareContext, TemplateHandler, TransformedResult, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext, after, cancelAfter, commandkit, exitContext, flag, getCommandKit, getContext, isCommandWorkerContext, isCompilerPlugin, isRuntimePlugin, makeContextAwareFunction, onApplicationBootstrap, onBootstrap, provideContext, setFlagProvider, useEnvironment } from "./CommandKit-VTym8VA2.js";
|
|
2
2
|
import { EventInterceptor, EventInterceptorContextData, EventInterceptorErrorHandler } from "./EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import { ButtonKit, ButtonKitPredicate, CommandKitButtonBuilderInteractionCollectorDispatch, CommandKitButtonBuilderInteractionCollectorDispatchContextData, CommandKitButtonBuilderOnEnd, OnButtonKitClick, OnButtonKitEnd } from "./ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import { CommandKitModalBuilderInteractionCollectorDispatch, CommandKitModalBuilderInteractionCollectorDispatchContextData, CommandKitModalBuilderOnEnd, ModalKit, ModalKitPredicate, OnModalKitEnd, OnModalKitSubmit } from "./ModalKit-CKtQ8eXW.js";
|
|
@@ -29,14 +29,14 @@ import { Command, CommandsRouter, CommandsRouterOptions, Middleware, ParsedComma
|
|
|
29
29
|
import { EventsRouter, EventsRouterOptions, EventsTree, ParsedEvent } from "./EventsRouter-BacqK6z3.js";
|
|
30
30
|
import "./index-CUPkUUOR.js";
|
|
31
31
|
import { COMMANDKIT_BOOTSTRAP_MODE, COMMANDKIT_CACHE_TAG, COMMANDKIT_IS_CLI, COMMANDKIT_IS_DEV, COMMANDKIT_IS_TEST, HMREventType } from "./constants-BPWSrMkn.js";
|
|
32
|
-
import { EventWorkerContext, eventWorkerContext, getEventWorkerContext, isEventWorkerContext, runInEventWorkerContext } from "./EventWorkerContext-
|
|
33
|
-
import "./types-
|
|
34
|
-
import "./utils-
|
|
32
|
+
import { EventWorkerContext, eventWorkerContext, getEventWorkerContext, isEventWorkerContext, runInEventWorkerContext } from "./EventWorkerContext-BXKO7FMY.js";
|
|
33
|
+
import "./types-CICvhb0c.js";
|
|
34
|
+
import "./utils-B1KWblpG.js";
|
|
35
35
|
import { bootstrapCommandkitCLI } from "./init-CT348Okf.js";
|
|
36
|
-
import { defineConfig, getConfig } from "./config-
|
|
36
|
+
import { defineConfig, getConfig } from "./config-aIOTA81x.js";
|
|
37
37
|
import { ILogger } from "./ILogger-kqwb2kUu.js";
|
|
38
38
|
import { DefaultLogger } from "./DefaultLogger-CcW-Fuq5.js";
|
|
39
39
|
import { CommandKitLoggerOptions, Logger, LoggerImpl, createLogger } from "./Logger-B4B_URL-.js";
|
|
40
40
|
import { version } from "./version-DggMfP_1.js";
|
|
41
41
|
import { StopEventPropagationError, debounce, defer, devOnly, getCurrentDirectory, getSourceDirectories, stopEvents } from "./utilities-DQT4lzAB.js";
|
|
42
|
-
export { ActionRow, ActionRowProps, AnyCommandExecute, AnyCommandKitElement, AppCommandHandler, AsyncFunction, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, BootstrapFunction, Button, ButtonChildrenLike, ButtonKit, ButtonKitPredicate, ButtonProps, COMMANDKIT_BOOTSTRAP_MODE, COMMANDKIT_CACHE_TAG, COMMANDKIT_IS_CLI, COMMANDKIT_IS_DEV, COMMANDKIT_IS_TEST, ChannelSelectMenu, ChannelSelectMenuKit, ChannelSelectMenuKitPredicate, ChannelSelectMenuProps, ChatInputCommand, ChatInputCommandContext, Command, CommandBuilderLike, CommandContext, CommandContextOptions, CommandData, CommandExecutionMode, CommandFlagContext, CommandKit, CommandKitButtonBuilderInteractionCollectorDispatch, CommandKitButtonBuilderInteractionCollectorDispatchContextData, CommandKitButtonBuilderOnEnd, CommandKitConfiguration, CommandKitElement, CommandKitElementData, CommandKitEnvironment, CommandKitEnvironmentInternalData, CommandKitEnvironmentType, CommandKitEventDispatch, CommandKitHMREvent, CommandKitLoggerOptions, CommandKitModalBuilderInteractionCollectorDispatch, CommandKitModalBuilderInteractionCollectorDispatchContextData, CommandKitModalBuilderOnEnd, CommandKitOptions, CommandKitPlugin, CommandKitPluginRuntime, CommandKitSelectMenuBuilderInteractionCollectorDispatch, CommandKitSelectMenuBuilderInteractionCollectorDispatchContextData, CommandKitSelectMenuBuilderOnEnd, CommandRegistrar, CommandSource, CommandTypeData, CommandsRouter, CommandsRouterOptions, CommonBuilderKit, CommonDirectiveTransformer, CommonDirectiveTransformerOptions, CommonPluginRuntime, CommonSelectMenuProps, CompilerPlugin, CompilerPluginRuntime, Container, ContainerProps, Context, ContextParameters, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, DefaultLogger, ElementType, EvaluationContext, EventFlagContext, EventInterceptor, EventInterceptorContextData, EventInterceptorErrorHandler, EventWorkerContext, EventsRouter, EventsRouterOptions, EventsTree, FeatureFlag, FeatureFlagDefinition, File, FileProps, FlagRunner, Fragment, FragmentElementProps, GenericFunction, HMREventType, ILogger, IdentifyFunction, InteractionCommandContext, InteractionCommandMiddlewareContext, LoadedCommand, Logger, LoggerImpl, MaybeArray, MaybeFalsey, MaybePromise, MediaGallery, MediaGalleryItem, MediaGalleryItemProps, MediaGalleryProps, MentionableSelectMenu, MentionableSelectMenuKit, MentionableSelectMenuKitPredicate, MentionableSelectMenuProps, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageCommandOptions, MessageCommandOptionsSchema, MessageCommandParser, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, Middleware, MiddlewareContext, MiddlewareContextArgs, Modal, ModalKit, ModalKitPredicate, ModalProps, OnButtonKitClick, OnButtonKitEnd, OnChannelSelectMenuKitSubmit, OnMentionableSelectMenuKitSubmit, OnModalKitEnd, OnModalKitSubmit, OnRoleSelectMenuKitSubmit, OnSelectMenuKitEnd, OnSelectMenuKitSubmit, OnStringSelectMenuKitSubmit, OnUserSelectMenuKitSubmit, ParagraphInput, ParsedCommandData, ParsedEvent, ParsedMessageCommand, PluginTransformParameters, PreRegisterCommandsEvent, PreparedAppCommandExecution, ResolvableCommand, ResolveBuilderInteraction, RoleSelectMenu, RoleSelectMenuKit, RoleSelectMenuKitPredicate, RoleSelectMenuProps, RunCommand, RuntimePlugin, Section, SectionProps, SelectMenuKitPredicate, SelectMenuProps, Separator, SeparatorProps, ShortInput, SlashCommandMiddlewareContext, StopEventPropagationError, StringEncodable, StringSelectMenu, StringSelectMenuKit, StringSelectMenuKitPredicate, StringSelectMenuOption, StringSelectMenuOptionProps, StringSelectMenuProps, TemplateHandler, TextDisplay, TextDisplayProps, TextInput, TextInputProps, Thumbnail, ThumbnailProps, TransformedResult, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext, UserSelectMenu, UserSelectMenuKit, UserSelectMenuKitPredicate, UserSelectMenuProps, after, bootstrapCommandkitCLI, cancelAfter, commandkit, createElement, createElement as jsx, createElement as jsxs, createLogger, debounce, CommandKit as default, defer, defineConfig, devOnly, eventWorkerContext, exitContext, exitMiddleware, flag, getCommandKit, getConfig, getContext, getCurrentDirectory, getElement, getEventWorkerContext, getSourceDirectories, isCommandKitElement, isCommandWorkerContext, isCompilerPlugin, isEventWorkerContext, isInteractionSource, isMessageSource, isRuntimePlugin, makeContextAwareFunction, onApplicationBootstrap, onBootstrap, provideContext, redirect, rethrow, runInEventWorkerContext, stopEvents, useEnvironment, version };
|
|
42
|
+
export { ActionRow, ActionRowProps, AnyCommandExecute, AnyCommandKitElement, AppCommandHandler, AsyncFunction, AutocompleteCommand, AutocompleteCommandContext, AutocompleteCommandMiddlewareContext, BootstrapFunction, Button, ButtonChildrenLike, ButtonKit, ButtonKitPredicate, ButtonProps, COMMANDKIT_BOOTSTRAP_MODE, COMMANDKIT_CACHE_TAG, COMMANDKIT_IS_CLI, COMMANDKIT_IS_DEV, COMMANDKIT_IS_TEST, ChannelSelectMenu, ChannelSelectMenuKit, ChannelSelectMenuKitPredicate, ChannelSelectMenuProps, ChatInputCommand, ChatInputCommandContext, Command, CommandBuilderLike, CommandContext, CommandContextOptions, CommandData, CommandExecutionMode, CommandFlagContext, CommandKit, CommandKitButtonBuilderInteractionCollectorDispatch, CommandKitButtonBuilderInteractionCollectorDispatchContextData, CommandKitButtonBuilderOnEnd, CommandKitConfiguration, CommandKitElement, CommandKitElementData, CommandKitEnvironment, CommandKitEnvironmentInternalData, CommandKitEnvironmentType, CommandKitEventDispatch, CommandKitHMREvent, CommandKitLoggerOptions, CommandKitModalBuilderInteractionCollectorDispatch, CommandKitModalBuilderInteractionCollectorDispatchContextData, CommandKitModalBuilderOnEnd, CommandKitOptions, CommandKitPlugin, CommandKitPluginRuntime, CommandKitSelectMenuBuilderInteractionCollectorDispatch, CommandKitSelectMenuBuilderInteractionCollectorDispatchContextData, CommandKitSelectMenuBuilderOnEnd, CommandRegistrar, CommandSource, CommandTypeData, CommandsRouter, CommandsRouterOptions, CommonBuilderKit, CommonDirectiveTransformer, CommonDirectiveTransformerOptions, CommonPluginRuntime, CommonSelectMenuProps, CompilerPlugin, CompilerPluginRuntime, Container, ContainerProps, Context, ContextParameters, CustomEvaluationContext, CustomEvaluationFunction, DecideFunction, DefaultLogger, ElementType, EvaluationContext, EventFlagContext, EventInterceptor, EventInterceptorContextData, EventInterceptorErrorHandler, EventWorkerContext, EventsRouter, EventsRouterOptions, EventsTree, FeatureFlag, FeatureFlagDefinition, File, FileProps, FlagRunner, Fragment, FragmentElementProps, GenericFunction, HMREventType, ILogger, IdentifyFunction, InteractionCommandContext, InteractionCommandMiddlewareContext, LoadedCommand, Logger, LoggerImpl, MaybeArray, MaybeFalsey, MaybePromise, MediaGallery, MediaGalleryItem, MediaGalleryItemProps, MediaGalleryProps, MentionableSelectMenu, MentionableSelectMenuKit, MentionableSelectMenuKitPredicate, MentionableSelectMenuProps, MessageCommand, MessageCommandContext, MessageCommandMiddlewareContext, MessageCommandOptions, MessageCommandOptionsSchema, MessageCommandParser, MessageContextMenuCommand, MessageContextMenuCommandContext, MessageContextMenuCommandMiddlewareContext, Middleware, MiddlewareContext, MiddlewareContextArgs, Modal, ModalKit, ModalKitPredicate, ModalProps, OnButtonKitClick, OnButtonKitEnd, OnChannelSelectMenuKitSubmit, OnMentionableSelectMenuKitSubmit, OnModalKitEnd, OnModalKitSubmit, OnRoleSelectMenuKitSubmit, OnSelectMenuKitEnd, OnSelectMenuKitSubmit, OnStringSelectMenuKitSubmit, OnUserSelectMenuKitSubmit, ParagraphInput, ParsedCommandData, ParsedEvent, ParsedMessageCommand, PluginTransformParameters, PreRegisterCommandsEvent, PreparedAppCommandExecution, ResolvableCommand, ResolveBuilderInteraction, RoleSelectMenu, RoleSelectMenuKit, RoleSelectMenuKitPredicate, RoleSelectMenuProps, RunCommand, RuntimePlugin, Section, SectionProps, SelectMenuKitPredicate, SelectMenuProps, Separator, SeparatorProps, ShortInput, SlashCommandMiddlewareContext, StopEventPropagationError, StringEncodable, StringSelectMenu, StringSelectMenuKit, StringSelectMenuKitPredicate, StringSelectMenuOption, StringSelectMenuOptionProps, StringSelectMenuProps, TemplateHandler, TextDisplay, TextDisplayProps, TextInput, TextInputProps, Thumbnail, ThumbnailProps, TransformedResult, UserContextMenuCommand, UserContextMenuCommandContext, UserContextMenuCommandMiddlewareContext, UserSelectMenu, UserSelectMenuKit, UserSelectMenuKitPredicate, UserSelectMenuProps, after, bootstrapCommandkitCLI, cancelAfter, commandkit, createElement, createElement as jsx, createElement as jsxs, createLogger, debounce, CommandKit as default, defer, defineConfig, devOnly, eventWorkerContext, exitContext, exitMiddleware, flag, getCommandKit, getConfig, getContext, getCurrentDirectory, getElement, getEventWorkerContext, getSourceDirectories, isCommandKitElement, isCommandWorkerContext, isCompilerPlugin, isEventWorkerContext, isInteractionSource, isMessageSource, isRuntimePlugin, makeContextAwareFunction, onApplicationBootstrap, onBootstrap, provideContext, redirect, rethrow, runInEventWorkerContext, setFlagProvider, stopEvents, useEnvironment, version };
|
package/dist/index.js
CHANGED
|
@@ -38,8 +38,8 @@ require('./store-Ci6ib2C9.js');
|
|
|
38
38
|
const require_helpers = require('./helpers-CswC9gKF.js');
|
|
39
39
|
require('./app-CXCbKsPz.js');
|
|
40
40
|
require('./ILogger-DucYb0bG.js');
|
|
41
|
-
const require_version = require('./version-
|
|
42
|
-
const require_feature_flags = require('./feature-flags-
|
|
41
|
+
const require_version = require('./version-CObFfDEn.js');
|
|
42
|
+
const require_feature_flags = require('./feature-flags-BFiGn38a.js');
|
|
43
43
|
const require_init = require('./init-BDgyvx9E.js');
|
|
44
44
|
|
|
45
45
|
//#region src/index.ts
|
|
@@ -141,6 +141,7 @@ exports.provideContext = require_CommandKit.provideContext;
|
|
|
141
141
|
exports.redirect = require_signals.redirect;
|
|
142
142
|
exports.rethrow = require_signals.rethrow;
|
|
143
143
|
exports.runInEventWorkerContext = require_EventWorkerContext.runInEventWorkerContext;
|
|
144
|
+
exports.setFlagProvider = require_feature_flags.setFlagProvider;
|
|
144
145
|
exports.stopEvents = require_CommandKit.stopEvents;
|
|
145
146
|
exports.useEnvironment = require_CommandKit.useEnvironment;
|
|
146
147
|
exports.version = require_version.version;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CompilerPlugin, PluginTransformParameters, TransformedResult, isCompilerPlugin } from "../CommandKit-
|
|
1
|
+
import { CompilerPlugin, PluginTransformParameters, TransformedResult, isCompilerPlugin } from "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PluginCommon, PluginOptions, PluginType, isPlugin } from "../CommandKit-
|
|
1
|
+
import { PluginCommon, PluginOptions, PluginType, isPlugin } from "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandKitEventDispatch, CommandKitPlugin, CommandKitPluginRuntime, CommonDirectiveTransformer, CommonDirectiveTransformerOptions, CommonPluginRuntime, CompilerPlugin, CompilerPluginRuntime, MaybeFalsey, PluginTransformParameters, RuntimePlugin, TemplateHandler, TransformedResult, isCompilerPlugin, isRuntimePlugin } from "../CommandKit-
|
|
1
|
+
import { CommandKitEventDispatch, CommandKitPlugin, CommandKitPluginRuntime, CommonDirectiveTransformer, CommonDirectiveTransformerOptions, CommonPluginRuntime, CompilerPlugin, CompilerPluginRuntime, MaybeFalsey, PluginTransformParameters, RuntimePlugin, TemplateHandler, TransformedResult, isCompilerPlugin, isRuntimePlugin } from "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommonDirectiveTransformer, CommonDirectiveTransformerOptions } from "../../../CommandKit-
|
|
1
|
+
import { CommonDirectiveTransformer, CommonDirectiveTransformerOptions } from "../../../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../../../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../../../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../../../ModalKit-CKtQ8eXW.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CompilerPlugin, MaybeFalsey, PluginTransformParameters, TransformedResult } from "../../../CommandKit-
|
|
1
|
+
import { CompilerPlugin, MaybeFalsey, PluginTransformParameters, TransformedResult } from "../../../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../../../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../../../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../../../ModalKit-CKtQ8eXW.js";
|
package/dist/plugins/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandKitEventDispatch, CommandKitPlugin, MaybeFalsey, TemplateHandler } from "../CommandKit-
|
|
1
|
+
import { CommandKitEventDispatch, CommandKitPlugin, MaybeFalsey, TemplateHandler } from "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandKitPlugin } from "./CommandKit-
|
|
1
|
+
import { CommandKitPlugin } from "./CommandKit-VTym8VA2.js";
|
|
2
2
|
import { MaybeArray } from "./types-CJ-XvOFN.js";
|
|
3
3
|
|
|
4
4
|
//#region src/config/types.d.ts
|
|
@@ -70,4 +70,4 @@ interface CommandKitConfig {
|
|
|
70
70
|
}
|
|
71
71
|
//#endregion
|
|
72
72
|
export { CommandKitConfig };
|
|
73
|
-
//# sourceMappingURL=types-
|
|
73
|
+
//# sourceMappingURL=types-CICvhb0c.d.ts.map
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandContext, CommandData, CommandKitOptions } from "./CommandKit-
|
|
1
|
+
import { CommandContext, CommandData, CommandKitOptions } from "./CommandKit-VTym8VA2.js";
|
|
2
2
|
import "./EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "./ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "./ModalKit-CKtQ8eXW.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandKitHMREvent, registerDevHooks } from "../CommandKit-
|
|
1
|
+
import { CommandKitHMREvent, registerDevHooks } from "../CommandKit-VTym8VA2.js";
|
|
2
2
|
import "../EventInterceptor-D_oEWSnF.js";
|
|
3
3
|
import "../ButtonKit-BSI7lCI0.js";
|
|
4
4
|
import "../ModalKit-CKtQ8eXW.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandKitConfig } from "./types-
|
|
1
|
+
import { CommandKitConfig } from "./types-CICvhb0c.js";
|
|
2
2
|
|
|
3
3
|
//#region src/config/utils.d.ts
|
|
4
4
|
type DeepRequired<T> = { [P in keyof T]-?: DeepRequired<T[P]> };
|
|
@@ -7,4 +7,4 @@ declare const mergeDeep: <T extends Record<string, any>>(target: T, source: T) =
|
|
|
7
7
|
type ResolvedCommandKitConfig = DeepRequired<CommandKitConfig>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { DeepPartial, DeepRequired, ResolvedCommandKitConfig, mergeDeep };
|
|
10
|
-
//# sourceMappingURL=utils-
|
|
10
|
+
//# sourceMappingURL=utils-B1KWblpG.d.ts.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* The current version of CommandKit.
|
|
5
5
|
*/
|
|
6
|
-
const version = "1.0.0-dev.
|
|
6
|
+
const version = "1.0.0-dev.20250609020912";
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
9
9
|
Object.defineProperty(exports, 'version', {
|
|
@@ -12,4 +12,4 @@ Object.defineProperty(exports, 'version', {
|
|
|
12
12
|
return version;
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
-
//# sourceMappingURL=version-
|
|
15
|
+
//# sourceMappingURL=version-CObFfDEn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-
|
|
1
|
+
{"version":3,"file":"version-CObFfDEn.js","names":[],"sources":["../src/version.ts"],"sourcesContent":["function $version(): string {\n 'use macro';\n return require('../package.json').version;\n}\n\n/**\n * The current version of CommandKit.\n */\nexport const version: string = $version();\n"],"mappings":";;;;;AAQA,MAAa,UAA4B"}
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commandkit",
|
|
3
3
|
"description": "Beginner friendly command & event handler for Discord.js",
|
|
4
|
-
"version": "1.0.0-dev.
|
|
4
|
+
"version": "1.0.0-dev.20250609020912",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"tsx": "^4.19.2",
|
|
130
130
|
"typescript": "^5.7.3",
|
|
131
131
|
"vitest": "^3.0.5",
|
|
132
|
-
"tsconfig": "0.0.0-dev.
|
|
132
|
+
"tsconfig": "0.0.0-dev.20250609020912"
|
|
133
133
|
},
|
|
134
134
|
"peerDependencies": {
|
|
135
135
|
"discord.js": "^14"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"feature-flags-DJi3gEFN.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';\n\nexport type MaybePromise<T> = T | Promise<T>;\n\nexport type IdentifyFunction<R> = (\n context: EvaluationContext,\n) => MaybePromise<R>;\n\nexport type DecideFunction<E, R> = (data: { entities: E }) => MaybePromise<R>;\n\nexport interface FeatureFlagDefinition<R, Entity> {\n key: string;\n description?: string;\n identify?: IdentifyFunction<Entity>;\n decide: DecideFunction<Entity, R>;\n}\n\nexport interface CommandFlagContext {\n client: Client<true>;\n commandkit: CommandKit;\n command: {\n interaction?:\n | ChatInputCommandInteraction\n | AutocompleteInteraction\n | ContextMenuCommandInteraction;\n message?: Message;\n guild: Guild | null;\n channel: TextBasedChannel | null;\n command: LoadedCommand;\n };\n event: null;\n}\n\nexport interface EventFlagContext {\n client: Client<true>;\n commandkit: CommandKit;\n event: {\n data: ParsedEvent;\n event: string;\n namespace: string | null;\n arguments: any[];\n argumentsAs<E extends keyof ClientEvents>(event: E): ClientEvents[E];\n };\n command: null;\n}\n\nexport type EvaluationContext = CommandFlagContext | EventFlagContext;\n\nexport type CustomEvaluationFunction<E> = () => MaybePromise<E>;\n\nexport type CustomEvaluationContext<E> = {\n identify: E | CustomEvaluationFunction<E>;\n};\n\nexport interface FlagRunner<E, R> {\n (): Promise<R>;\n run(context: CustomEvaluationContext<E>): Promise<R>;\n}\n\nexport class FeatureFlag<R, T> {\n private commandkit: CommandKit;\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 public async execute(res?: T): Promise<R> {\n const { decide, identify } = 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 const decisionStart = performance.now();\n const decisionResult = await decide({\n entities,\n });\n const decisionTime = performance.now() - decisionStart;\n\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 },\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 },\n });\n });\n\n return decisionResult as R;\n }\n}\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":";;;;;AA2EA,IAAa,cAAb,MAA+B;CAC7B,AAAQ;CACR,AAAO,YAA4B,SAAsC;EAAtC;AACjC,OAAK,aAAa,iCAAc,KAAK;EACrC,MAAM,YAAY,KAAK,WAAW;AAElC,MAAI,UAAU,IAAI,QAAQ,IAAI,CAC5B,OAAM,IAAI,OAAO,yBAAyB,QAAQ,IAAI;AAGxD,YAAU,IAAI,QAAQ,KAAK,KAAK;CAClC;CAEA,AAAQ,aAAgC;EACtC,MAAM,MAAM,+BAAY;AAExB,gDAAI,IAAK,SAAS;GAChB,MAAM,EACJ,QACA,YACA,aACA,SACA,OACA,SACA,SACD,GAAG,IAAI;AAER,UAAO;IACG;IACR;IACA,SAAS;KACP;KACA;KACA;KACA;KACA;IACD;IACD,OAAO;GACR;EACH;EAEA,MAAM,WAAW,8CAAmB,UAAU;AAE9C,MAAI,UAAU;GACZ,MAAM,EAAE,YAAY,MAAM,OAAO,WAAW,GAAG;AAE/C,UAAO;IACL,QAAQ,WAAW;IACnB;IACA,OAAO;KACL;KACA;KACA;KACA,WAAW,SAAS;KACpB,aAAa,CAAC,cAAc;MAC1B,MAAM,OAAO,SAAS;AACtB,aAAO;KACR;IACF;IACD,SAAS;GACV;EACH;AAEA,QAAM,IAAI,MACR;CAEJ;CAEA,MAAa,QAAQ,KAAqB;EACxC,MAAM,EAAE,QAAQ,UAAU,GAAG,KAAK;EAElC,MAAM,sBAAsB,YAAY,KAAK;EAC7C,MAAM,WACN,OACA,MAAM,CAAC,YAAY;GACjB,MAAM,MAAM,KAAK,YAAY;AAC7B,UAAQ,2DAAM,SAAW,IAAI,KAAK,CAAE;EACrC,IAAG;EACJ,MAAM,qBAAqB,YAAY,KAAK,GAAG;EAE/C,MAAM,gBAAgB,YAAY,KAAK;EACvC,MAAM,iBAAiB,MAAM,OAAO,EAClC,SACD,EAAC;EACF,MAAM,eAAe,YAAY,KAAK,GAAG;AAEzC,2BAAM,YAAY;AAChB,SAAM,KAAK,WAAW,UAAU,MAAM;IACpC,MAAM,kCAAgB;IACtB,MAAM;KACJ,MAAM,KAAK,QAAQ;KACnB,oBAAoB,mBAAmB,QAAQ,EAAE;KACjD,cAAc,aAAa,QAAQ,EAAE;IACtC;GACF,EAAC;EACH,EAAC;AAEF,2BAAM,YAAY;AAChB,SAAM,KAAK,WAAW,UAAU,MAAM;IACpC,MAAM,kCAAgB;IACtB,IACA,mBACO,aAAa,YACpB,QAAQ,mBACD,SAAS,OAAO,WACvB,SAAS;IAET,MAAM;KACJ,MAAM,KAAK,QAAQ;KACnB,UAAU,iCAAc,gBAAgB,UAAU;IACnD;GACF,EAAC;EACH,EAAC;AAEF,SAAO;CACT;AACF;AAEA,SAAgB,KAChB,SAC8B;CAC5B,MAAM,SAAO,IAAI,YAA6B;CAC9C,MAAM,SAAS,OAAK,QAAQ,KAAK,eAAgB;AAKjD,QAAO,MAAM,eAAgB,KAAK;AAChC,kDAAK,IAAK,UACR,OAAM,IAAI,MACR;EAIJ,MAAM,iBACC,QAAQ,aACf,MAAM,AAAC,KAA0C,GACjD;EAGA,MAAM,iBAAiB,MAAM,OAAK,QAAQ,QAAQ;AAElD,SAAO;CACR;AAED,QAAO;AACT"}
|