dfx 0.17.6 → 0.17.8

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.
@@ -45,10 +45,10 @@ export declare class Autocomplete<R, E> {
45
45
  export declare const autocomplete: <R1, R2, E1, E2>(pred: (data: Discord.ApplicationCommandDatum, focusedOption: Discord.ApplicationCommandInteractionDataOption) => Effect<R1, E1, boolean>, handle: Effect<R2, E2, import("../types.js").InteractionResponse>) => Autocomplete<Exclude<R1, import("../types.js").Interaction | import("../types.js").ApplicationCommandDatum | FocusedOptionContext> | Exclude<R2, import("../types.js").Interaction | import("../types.js").ApplicationCommandDatum | FocusedOptionContext>, E1 | E2>;
46
46
  type CommandHandler<R, E, A = any> = Effect<R, E, Discord.InteractionResponse> | CommandHandlerFn<R, E, A>;
47
47
  export interface CommandHelper<A> {
48
- resolve: <T>(name: Resolvables<A>["name"], f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => T | undefined) => Effect<Discord.Interaction, ResolvedDataNotFound, T>;
48
+ resolve: <T>(name: AllResolvables<A>["name"], f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => T | undefined) => Effect<Discord.Interaction, ResolvedDataNotFound, T>;
49
49
  option: (name: AllCommandOptions<A>["name"]) => Effect<Discord.ApplicationCommandDatum, never, Maybe<Discord.ApplicationCommandInteractionDataOption>>;
50
- optionValue: (name: AllRequiredCommandOptions<A>["name"]) => Effect<Discord.ApplicationCommandDatum, never, string>;
51
- optionValueOptional: (name: AllCommandOptions<A>["name"]) => Effect<Discord.ApplicationCommandDatum, never, Maybe<string>>;
50
+ optionValue: <N extends AllRequiredCommandOptions<A>["name"]>(name: N) => Effect<Discord.ApplicationCommandDatum, never, CommandValue<A, N>>;
51
+ optionValueOptional: <N extends AllCommandOptions<A>["name"]>(name: N) => Effect<Discord.ApplicationCommandDatum, never, Maybe<CommandValue<A, N>>>;
52
52
  subCommands: <NER extends SubCommandNames<A> extends never ? never : Record<SubCommandNames<A>, Effect<any, any, Discord.InteractionResponse>>>(commands: NER) => Effect<Exclude<[
53
53
  NER[keyof NER]
54
54
  ] extends [
@@ -66,44 +66,51 @@ export interface CommandHelper<A> {
66
66
  }] ? E : never, Discord.InteractionResponse>;
67
67
  }
68
68
  type CommandHandlerFn<R, E, A> = (i: CommandHelper<A>) => Effect<R, E, Discord.InteractionResponse>;
69
- type StringLiteral<T> = T extends string ? string extends T ? never : T : never;
70
- type Option<A> = A extends {
71
- name: infer N;
72
- } ? N extends StringLiteral<N> ? A : never : never;
73
- type Options<A, T> = A extends T ? T : A extends {
74
- options: Discord.ApplicationCommandOption[];
75
- } ? Options<A["options"][number], T> : never;
76
- type OptionsWithLiteral<A, T> = A extends {
77
- options: Discord.ApplicationCommandOption[];
78
- } ? Extract<A["options"][number], Option<A["options"][number]> & T> : never;
79
- type CommandOptionType = Exclude<Discord.ApplicationCommandOptionType, Discord.ApplicationCommandOptionType.SUB_COMMAND | Discord.ApplicationCommandOptionType.SUB_COMMAND_GROUP>;
80
- type CommandOptions<A> = OptionsWithLiteral<A, {
81
- name: string;
82
- type: CommandOptionType;
83
- }>;
84
- type RequiredCommandOptions<A> = OptionsWithLiteral<A, {
85
- type: CommandOptionType;
86
- name: string;
87
- required: true;
88
- }>;
89
69
  type SubCommands<A> = A extends {
90
- name: string;
91
70
  type: Discord.ApplicationCommandOptionType.SUB_COMMAND;
92
71
  options?: Discord.ApplicationCommandOption[];
93
72
  } ? A : A extends {
94
73
  options: Discord.ApplicationCommandOption[];
95
74
  } ? SubCommands<A["options"][number]> : never;
96
75
  type SubCommandNames<A> = Option<SubCommands<A>>["name"];
76
+ type CommandOptionType = Exclude<Discord.ApplicationCommandOptionType, Discord.ApplicationCommandOptionType.SUB_COMMAND | Discord.ApplicationCommandOptionType.SUB_COMMAND_GROUP>;
77
+ type CommandOptions<A> = OptionsWithLiteral<A, {
78
+ type: CommandOptionType;
79
+ }>;
97
80
  type SubCommandOptions<A> = Extract<Option<Exclude<SubCommands<A>["options"], undefined>[number]>, {
98
81
  type: CommandOptionType;
99
82
  }>;
100
83
  type AllCommandOptions<A> = CommandOptions<A> | SubCommandOptions<A>;
84
+ type CommandWithName<A, N> = Extract<AllCommandOptions<A>, {
85
+ name: N;
86
+ }>;
87
+ type OptionTypeValue = {
88
+ [Discord.ApplicationCommandOptionType.BOOLEAN]: boolean;
89
+ [Discord.ApplicationCommandOptionType.INTEGER]: number;
90
+ [Discord.ApplicationCommandOptionType.NUMBER]: number;
91
+ };
92
+ type CommandValue<A, N> = CommandWithName<A, N>["type"] extends keyof OptionTypeValue ? OptionTypeValue[CommandWithName<A, N>["type"]] : string;
93
+ type RequiredCommandOptions<A> = OptionsWithLiteral<A, {
94
+ type: CommandOptionType;
95
+ required: true;
96
+ }>;
101
97
  type RequiredSubCommandOptions<A> = Extract<SubCommandOptions<A>, {
102
98
  required: true;
103
99
  }>;
104
100
  type AllRequiredCommandOptions<A> = RequiredCommandOptions<A> | RequiredSubCommandOptions<A>;
105
- type Resolvables<A> = Options<A, {
106
- name: string;
107
- type: Discord.ApplicationCommandOptionType.ROLE | Discord.ApplicationCommandOptionType.USER | Discord.ApplicationCommandOptionType.MENTIONABLE | Discord.ApplicationCommandOptionType.CHANNEL;
101
+ type ResolvableType = Discord.ApplicationCommandOptionType.ROLE | Discord.ApplicationCommandOptionType.USER | Discord.ApplicationCommandOptionType.MENTIONABLE | Discord.ApplicationCommandOptionType.CHANNEL;
102
+ type Resolvables<A> = OptionsWithLiteral<A, {
103
+ type: ResolvableType;
108
104
  }>;
105
+ type SubCommandResolvables<A> = Extract<Option<Exclude<SubCommands<A>["options"], undefined>[number]>, {
106
+ type: ResolvableType;
107
+ }>;
108
+ type AllResolvables<A> = Resolvables<A> | SubCommandResolvables<A>;
109
+ type StringLiteral<T> = T extends string ? string extends T ? never : T : never;
110
+ type Option<A> = A extends {
111
+ name: infer N;
112
+ } ? N extends StringLiteral<N> ? A : never : never;
113
+ type OptionsWithLiteral<A, T> = A extends {
114
+ options: Discord.ApplicationCommandOption[];
115
+ } ? Extract<A["options"][number], Option<A["options"][number]> & T> : never;
109
116
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dfx",
3
- "version": "0.17.6",
3
+ "version": "0.17.8",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -49,5 +49,5 @@
49
49
  "@fp-ts/data": "^0.0.20"
50
50
  }
51
51
  },
52
- "gitHead": "763704b1bafd514802579e2ee9336aafd01083b3"
52
+ "gitHead": "35af35155667a7b8f1803cc0cdc2a194a817deb8"
53
53
  }