dfx 0.45.4 → 0.45.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/package.json +2 -2
  2. package/src/DiscordGateway/Sharder.ts +7 -6
  3. package/src/package.json +2 -2
  4. package/tsconfig.json +2 -15
  5. package/Cache/driver.d.ts +0 -22
  6. package/Cache/driver.js +0 -3
  7. package/Cache/driver.js.map +0 -1
  8. package/Cache/memory.d.ts +0 -3
  9. package/Cache/memory.js +0 -48
  10. package/Cache/memory.js.map +0 -1
  11. package/Cache/memoryTTL.d.ts +0 -20
  12. package/Cache/memoryTTL.js +0 -121
  13. package/Cache/memoryTTL.js.map +0 -1
  14. package/Cache/prelude.d.ts +0 -56
  15. package/Cache/prelude.js +0 -108
  16. package/Cache/prelude.js.map +0 -1
  17. package/Cache.d.ts +0 -75
  18. package/Cache.js +0 -62
  19. package/Cache.js.map +0 -1
  20. package/DiscordConfig.d.ts +0 -28
  21. package/DiscordConfig.js +0 -29
  22. package/DiscordConfig.js.map +0 -1
  23. package/DiscordGateway/DiscordWS.d.ts +0 -31
  24. package/DiscordGateway/DiscordWS.js +0 -31
  25. package/DiscordGateway/DiscordWS.js.map +0 -1
  26. package/DiscordGateway/Shard/heartbeats.d.ts +0 -3
  27. package/DiscordGateway/Shard/heartbeats.js +0 -17
  28. package/DiscordGateway/Shard/heartbeats.js.map +0 -1
  29. package/DiscordGateway/Shard/identify.d.ts +0 -12
  30. package/DiscordGateway/Shard/identify.js +0 -26
  31. package/DiscordGateway/Shard/identify.js.map +0 -1
  32. package/DiscordGateway/Shard/invalidSession.d.ts +0 -3
  33. package/DiscordGateway/Shard/invalidSession.js +0 -6
  34. package/DiscordGateway/Shard/invalidSession.js.map +0 -1
  35. package/DiscordGateway/Shard/sendEvents.d.ts +0 -7
  36. package/DiscordGateway/Shard/sendEvents.js +0 -25
  37. package/DiscordGateway/Shard/sendEvents.js.map +0 -1
  38. package/DiscordGateway/Shard/utils.d.ts +0 -3
  39. package/DiscordGateway/Shard/utils.js +0 -9
  40. package/DiscordGateway/Shard/utils.js.map +0 -1
  41. package/DiscordGateway/Shard.d.ts +0 -16
  42. package/DiscordGateway/Shard.js +0 -85
  43. package/DiscordGateway/Shard.js.map +0 -1
  44. package/DiscordGateway/ShardStore.d.ts +0 -12
  45. package/DiscordGateway/ShardStore.js +0 -22
  46. package/DiscordGateway/ShardStore.js.map +0 -1
  47. package/DiscordGateway/Sharder.d.ts +0 -15
  48. package/DiscordGateway/Sharder.js +0 -49
  49. package/DiscordGateway/Sharder.js.map +0 -1
  50. package/DiscordGateway/WS.d.ts +0 -31
  51. package/DiscordGateway/WS.js +0 -77
  52. package/DiscordGateway/WS.js.map +0 -1
  53. package/DiscordGateway.d.ts +0 -12
  54. package/DiscordGateway.js +0 -29
  55. package/DiscordGateway.js.map +0 -1
  56. package/DiscordREST/types.d.ts +0 -7
  57. package/DiscordREST/types.js +0 -2
  58. package/DiscordREST/types.js.map +0 -1
  59. package/DiscordREST/utils.d.ts +0 -10
  60. package/DiscordREST/utils.js +0 -21
  61. package/DiscordREST/utils.js.map +0 -1
  62. package/DiscordREST.d.ts +0 -16
  63. package/DiscordREST.js +0 -123
  64. package/DiscordREST.js.map +0 -1
  65. package/Helpers/flags.d.ts +0 -27
  66. package/Helpers/flags.js +0 -36
  67. package/Helpers/flags.js.map +0 -1
  68. package/Helpers/intents.d.ts +0 -24
  69. package/Helpers/intents.js +0 -29
  70. package/Helpers/intents.js.map +0 -1
  71. package/Helpers/interactions.d.ts +0 -96
  72. package/Helpers/interactions.js +0 -97
  73. package/Helpers/interactions.js.map +0 -1
  74. package/Helpers/members.d.ts +0 -9
  75. package/Helpers/members.js +0 -10
  76. package/Helpers/members.js.map +0 -1
  77. package/Helpers/permissions.d.ts +0 -40
  78. package/Helpers/permissions.js +0 -83
  79. package/Helpers/permissions.js.map +0 -1
  80. package/Helpers/ui.d.ts +0 -47
  81. package/Helpers/ui.js +0 -66
  82. package/Helpers/ui.js.map +0 -1
  83. package/Interactions/builder.d.ts +0 -48
  84. package/Interactions/builder.js +0 -68
  85. package/Interactions/builder.js.map +0 -1
  86. package/Interactions/context.d.ts +0 -58
  87. package/Interactions/context.js +0 -61
  88. package/Interactions/context.js.map +0 -1
  89. package/Interactions/definitions.d.ts +0 -126
  90. package/Interactions/definitions.js +0 -53
  91. package/Interactions/definitions.js.map +0 -1
  92. package/Interactions/gateway.d.ts +0 -20
  93. package/Interactions/gateway.js +0 -39
  94. package/Interactions/gateway.js.map +0 -1
  95. package/Interactions/handlers.d.ts +0 -10
  96. package/Interactions/handlers.js +0 -45
  97. package/Interactions/handlers.js.map +0 -1
  98. package/Interactions/index.d.ts +0 -10
  99. package/Interactions/index.js +0 -12
  100. package/Interactions/index.js.map +0 -1
  101. package/Interactions/utils.d.ts +0 -78
  102. package/Interactions/utils.js +0 -74
  103. package/Interactions/utils.js.map +0 -1
  104. package/Interactions/webhook.d.ts +0 -45
  105. package/Interactions/webhook.js +0 -56
  106. package/Interactions/webhook.js.map +0 -1
  107. package/Log.d.ts +0 -10
  108. package/Log.js +0 -17
  109. package/Log.js.map +0 -1
  110. package/RateLimit/memory.d.ts +0 -2
  111. package/RateLimit/memory.js +0 -35
  112. package/RateLimit/memory.js.map +0 -1
  113. package/RateLimit/utils.d.ts +0 -2
  114. package/RateLimit/utils.js +0 -18
  115. package/RateLimit/utils.js.map +0 -1
  116. package/RateLimit.d.ts +0 -25
  117. package/RateLimit.js +0 -25
  118. package/RateLimit.js.map +0 -1
  119. package/_common.d.ts +0 -36
  120. package/_common.js +0 -8
  121. package/_common.js.map +0 -1
  122. package/gateway.d.ts +0 -13
  123. package/gateway.js +0 -25
  124. package/gateway.js.map +0 -1
  125. package/global.d.ts +0 -17
  126. package/global.js +0 -2
  127. package/global.js.map +0 -1
  128. package/index.d.ts +0 -13
  129. package/index.js +0 -14
  130. package/index.js.map +0 -1
  131. package/types.d.ts +0 -4449
  132. package/types.js +0 -1204
  133. package/types.js.map +0 -1
  134. package/utils/effect.d.ts +0 -1
  135. package/utils/effect.js +0 -2
  136. package/utils/effect.js.map +0 -1
  137. package/utils/hub.d.ts +0 -11
  138. package/utils/hub.js +0 -23
  139. package/utils/hub.js.map +0 -1
  140. package/utils/tsplus.d.ts +0 -12
  141. package/utils/tsplus.js +0 -2
  142. package/utils/tsplus.js.map +0 -1
  143. package/webhooks.d.ts +0 -9
  144. package/webhooks.js +0 -22
  145. package/webhooks.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/Interactions/context.ts"],"names":[],"mappings":";;;AAAA,OAAO,KAAK,GAAG,MAAM,4BAA4B,CAAA;AACjD,OAAO,EAAU,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,SAAS,MAAM,0BAA0B,CAAA;AAGrD,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAA,GAAG,EAAuB,CAAA;AACrD,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAA,GAAG,EAAmC,CAAA;AACxE,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAA,GAAG,EAAiC,CAAA;AACxE,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAA,GAAG,EAA4B,CAAA;AAK9D,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAA,GAAG,EAAwB,CAAA;AAK/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAA,GAAG,EAAqB,CAAA;AAEzD,MAAM,OAAO,oBAAoB;IAEV;IAAoC;IADhD,IAAI,GAAG,sBAAsB,CAAA;IACtC,YAAqB,IAAyB,EAAW,IAAa;QAAjD,SAAI,GAAJ,IAAI,CAAqB;QAAW,SAAI,GAAJ,IAAI,CAAS;IAAG,CAAC;CAC3E;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,CAAwE,EACxE,EAAE,CACF,wBAAA,WAAW,EAAS,EAAE,CAAC,EAAE,CACvB,yBAAA,SAAS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CAAC,CAAA;AAErD,MAAM,OAAO,kBAAkB;IAER;IAAiC;IAD7C,IAAI,GAAG,oBAAoB,CAAA;IACpC,YAAqB,IAAsB,EAAW,IAAY;QAA7C,SAAI,GAAJ,IAAI,CAAkB;QAAW,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;CACvE;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CACzC,wBAAA,eAAe,EAAS,IAAI,CAAC,EAAE,CAC7B,yBAAA,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAClC,GAAG,EAAE,CAAC,IAAI,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,CACzC,CACF,CAAA"}
@@ -1,126 +0,0 @@
1
- import { Discord, Maybe } from "dfx/_common";
2
- import { Effect, EffectTypeId } from "@effect/io/Effect";
3
- import { FocusedOptionContext, ResolvedDataNotFound, SubCommandContext } from "./context.js";
4
- type DescriptionMissing<A> = A extends {
5
- type: Exclude<Discord.ApplicationCommandType, 1>;
6
- } ? false : A extends {
7
- readonly description: string;
8
- } ? false : true;
9
- export type InteractionDefinition<R, E> = GlobalApplicationCommand<R, E> | GuildApplicationCommand<R, E> | MessageComponent<R, E> | ModalSubmit<R, E> | Autocomplete<R, E>;
10
- export declare class GlobalApplicationCommand<R, E> {
11
- readonly command: Discord.CreateGlobalApplicationCommandParams;
12
- readonly handle: CommandHandler<R, E>;
13
- readonly _tag = "GlobalApplicationCommand";
14
- constructor(command: Discord.CreateGlobalApplicationCommandParams, handle: CommandHandler<R, E>);
15
- }
16
- export declare const global: <R, E, const A extends DeepReadonlyObject<import("../types.js").CreateGlobalApplicationCommandParams>>(command: A, handle: DescriptionMissing<A> extends true ? "command description is missing" : CommandHandler<R, E, A>) => GlobalApplicationCommand<Exclude<R, import("../types.js").Interaction | import("../types.js").ApplicationCommandDatum>, E>;
17
- export declare class GuildApplicationCommand<R, E> {
18
- readonly command: Discord.CreateGuildApplicationCommandParams;
19
- readonly handle: CommandHandler<R, E>;
20
- readonly _tag = "GuildApplicationCommand";
21
- constructor(command: Discord.CreateGuildApplicationCommandParams, handle: CommandHandler<R, E>);
22
- }
23
- export declare const guild: <R, E, const A extends DeepReadonlyObject<import("../types.js").CreateGuildApplicationCommandParams>>(command: A, handle: DescriptionMissing<A> extends true ? "command description is missing" : CommandHandler<R, E, A>) => GuildApplicationCommand<Exclude<R, import("../types.js").Interaction | import("../types.js").ApplicationCommandDatum>, E>;
24
- export declare class MessageComponent<R, E> {
25
- readonly predicate: (customId: string) => Effect<R, E, boolean>;
26
- readonly handle: Effect<R, E, Discord.InteractionResponse>;
27
- readonly _tag = "MessageComponent";
28
- constructor(predicate: (customId: string) => Effect<R, E, boolean>, handle: Effect<R, E, Discord.InteractionResponse>);
29
- }
30
- export declare const messageComponent: <R1, R2, E1, E2>(pred: (customId: string) => Effect<R1, E1, boolean>, handle: CommandHandler<R2, E2, import("../types.js").InteractionResponse>) => MessageComponent<Exclude<R1, import("../types.js").Interaction | import("../types.js").MessageComponentDatum> | Exclude<R2, import("../types.js").Interaction | import("../types.js").MessageComponentDatum>, E1 | E2>;
31
- export declare class ModalSubmit<R, E> {
32
- readonly predicate: (customId: string) => Effect<R, E, boolean>;
33
- readonly handle: Effect<R, E, Discord.InteractionResponse>;
34
- readonly _tag = "ModalSubmit";
35
- constructor(predicate: (customId: string) => Effect<R, E, boolean>, handle: Effect<R, E, Discord.InteractionResponse>);
36
- }
37
- export declare const modalSubmit: <R1, R2, E1, E2>(pred: (customId: string) => Effect<R1, E1, boolean>, handle: Effect<R2, E2, import("../types.js").InteractionResponse>) => ModalSubmit<Exclude<R1, import("../types.js").Interaction | import("../types.js").ModalSubmitDatum> | Exclude<R2, import("../types.js").Interaction | import("../types.js").ModalSubmitDatum>, E1 | E2>;
38
- export declare class Autocomplete<R, E> {
39
- readonly predicate: (data: Discord.ApplicationCommandDatum, focusedOption: Discord.ApplicationCommandInteractionDataOption) => Effect<R, E, boolean>;
40
- readonly handle: Effect<R, E, Discord.InteractionResponse>;
41
- readonly _tag = "Autocomplete";
42
- constructor(predicate: (data: Discord.ApplicationCommandDatum, focusedOption: Discord.ApplicationCommandInteractionDataOption) => Effect<R, E, boolean>, handle: Effect<R, E, Discord.InteractionResponse>);
43
- }
44
- 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>;
45
- type DeepReadonly<T> = T extends (infer R)[] ? DeepReadonlyArray<R> : T extends Function ? T : T extends object ? DeepReadonlyObject<T> : T;
46
- interface DeepReadonlyArray<T> extends ReadonlyArray<DeepReadonly<T>> {
47
- }
48
- type DeepReadonlyObject<T> = {
49
- readonly [P in keyof T]: DeepReadonly<T[P]>;
50
- };
51
- export type CommandHandler<R, E, A = any> = Effect<R, E, Discord.InteractionResponse> | CommandHandlerFn<R, E, A>;
52
- export interface CommandHelper<A> {
53
- resolve: <T>(name: AllResolvables<A>["name"], f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => T | undefined) => Effect<Discord.Interaction, ResolvedDataNotFound, T>;
54
- option: (name: AllCommandOptions<A>["name"]) => Effect<Discord.ApplicationCommandDatum, never, Maybe<Discord.ApplicationCommandInteractionDataOption>>;
55
- optionValue: <N extends AllRequiredCommandOptions<A>["name"]>(name: N) => Effect<Discord.ApplicationCommandDatum, never, CommandValue<A, N>>;
56
- optionValueOptional: <N extends AllCommandOptions<A>["name"]>(name: N) => Effect<Discord.ApplicationCommandDatum, never, Maybe<CommandValue<A, N>>>;
57
- subCommands: <NER extends SubCommandNames<A> extends never ? never : Record<SubCommandNames<A>, Effect<any, any, Discord.InteractionResponse>>>(commands: NER) => Effect<Exclude<[
58
- NER[keyof NER]
59
- ] extends [
60
- {
61
- [EffectTypeId]: {
62
- _R: (_: never) => infer R;
63
- };
64
- }
65
- ] ? R : never, SubCommandContext> | Discord.Interaction | Discord.ApplicationCommandDatum, [
66
- NER[keyof NER]
67
- ] extends [{
68
- [EffectTypeId]: {
69
- _E: (_: never) => infer E;
70
- };
71
- }] ? E : never, Discord.InteractionResponse>;
72
- }
73
- export type CommandHandlerFn<R, E, A> = (i: CommandHelper<A>) => Effect<R, E, Discord.InteractionResponse>;
74
- interface CommandOption {
75
- readonly type: any;
76
- readonly name: string;
77
- readonly options?: ReadonlyArray<CommandOption>;
78
- }
79
- type SubCommands<A> = A extends {
80
- readonly type: Discord.ApplicationCommandOptionType.SUB_COMMAND;
81
- readonly options?: ReadonlyArray<CommandOption>;
82
- } ? A : A extends {
83
- readonly options: ReadonlyArray<CommandOption>;
84
- } ? SubCommands<A["options"][number]> : never;
85
- type SubCommandNames<A> = Option<SubCommands<A>>["name"];
86
- type CommandOptionType = Exclude<Discord.ApplicationCommandOptionType, Discord.ApplicationCommandOptionType.SUB_COMMAND | Discord.ApplicationCommandOptionType.SUB_COMMAND_GROUP>;
87
- type CommandOptions<A> = OptionsWithLiteral<A, {
88
- readonly type: CommandOptionType;
89
- }>;
90
- type SubCommandOptions<A> = Extract<Option<Exclude<SubCommands<A>["options"], undefined>[number]>, {
91
- readonly type: CommandOptionType;
92
- }>;
93
- type AllCommandOptions<A> = CommandOptions<A> | SubCommandOptions<A>;
94
- type CommandWithName<A, N> = Extract<AllCommandOptions<A>, {
95
- readonly name: N;
96
- }>;
97
- type OptionTypeValue = {
98
- [Discord.ApplicationCommandOptionType.BOOLEAN]: boolean;
99
- [Discord.ApplicationCommandOptionType.INTEGER]: number;
100
- [Discord.ApplicationCommandOptionType.NUMBER]: number;
101
- };
102
- type CommandValue<A, N> = CommandWithName<A, N>["type"] extends keyof OptionTypeValue ? OptionTypeValue[CommandWithName<A, N>["type"]] : string;
103
- type RequiredCommandOptions<A> = OptionsWithLiteral<A, {
104
- readonly type: CommandOptionType;
105
- readonly required: true;
106
- }>;
107
- type RequiredSubCommandOptions<A> = Extract<SubCommandOptions<A>, {
108
- readonly required: true;
109
- }>;
110
- type AllRequiredCommandOptions<A> = RequiredCommandOptions<A> | RequiredSubCommandOptions<A>;
111
- type ResolvableType = Discord.ApplicationCommandOptionType.ROLE | Discord.ApplicationCommandOptionType.USER | Discord.ApplicationCommandOptionType.MENTIONABLE | Discord.ApplicationCommandOptionType.CHANNEL;
112
- type Resolvables<A> = OptionsWithLiteral<A, {
113
- readonly type: ResolvableType;
114
- }>;
115
- type SubCommandResolvables<A> = Extract<Option<Exclude<SubCommands<A>["options"], undefined>[number]>, {
116
- readonly type: ResolvableType;
117
- }>;
118
- type AllResolvables<A> = Resolvables<A> | SubCommandResolvables<A>;
119
- type StringLiteral<T> = T extends string ? string extends T ? never : T : never;
120
- type Option<A> = A extends {
121
- readonly name: infer N;
122
- } ? N extends StringLiteral<N> ? A : never : never;
123
- type OptionsWithLiteral<A, T> = A extends {
124
- readonly options: ReadonlyArray<CommandOption>;
125
- } ? Extract<A["options"][number], Option<A["options"][number]> & T> : never;
126
- export {};
@@ -1,53 +0,0 @@
1
- import * as tsplus_module_1 from "dfx/_common";
2
- import { EffectTypeId } from "@effect/io/Effect";
3
- export class GlobalApplicationCommand {
4
- command;
5
- handle;
6
- _tag = "GlobalApplicationCommand";
7
- constructor(command, handle) {
8
- this.command = command;
9
- this.handle = handle;
10
- }
11
- }
12
- export const global = (command, handle) => new GlobalApplicationCommand(command, handle);
13
- export class GuildApplicationCommand {
14
- command;
15
- handle;
16
- _tag = "GuildApplicationCommand";
17
- constructor(command, handle) {
18
- this.command = command;
19
- this.handle = handle;
20
- }
21
- }
22
- export const guild = (command, handle) => new GuildApplicationCommand(command, handle);
23
- export class MessageComponent {
24
- predicate;
25
- handle;
26
- _tag = "MessageComponent";
27
- constructor(predicate, handle) {
28
- this.predicate = predicate;
29
- this.handle = handle;
30
- }
31
- }
32
- export const messageComponent = (pred, handle) => new MessageComponent(pred, handle);
33
- export class ModalSubmit {
34
- predicate;
35
- handle;
36
- _tag = "ModalSubmit";
37
- constructor(predicate, handle) {
38
- this.predicate = predicate;
39
- this.handle = handle;
40
- }
41
- }
42
- export const modalSubmit = (pred, handle) => new ModalSubmit(pred, handle);
43
- export class Autocomplete {
44
- predicate;
45
- handle;
46
- _tag = "Autocomplete";
47
- constructor(predicate, handle) {
48
- this.predicate = predicate;
49
- this.handle = handle;
50
- }
51
- }
52
- export const autocomplete = (pred, handle) => new Autocomplete(pred, handle);
53
- //# sourceMappingURL=definitions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../src/Interactions/definitions.ts"],"names":[],"mappings":";AAAA,OAAO,EAAU,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAsBxD,MAAM,OAAO,wBAAwB;IAGxB;IACA;IAHF,IAAI,GAAG,0BAA0B,CAAA;IAC1C,YACW,OAAqD,EACrD,MAA4B;QAD5B,YAAO,GAAP,OAAO,CAA8C;QACrD,WAAM,GAAN,MAAM,CAAsB;IACpC,CAAC;CACL;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CAKpB,OAAU,EACV,MAE2B,EAC3B,EAAE,CACF,IAAI,wBAAwB,CAG1B,OAAc,EAAE,MAAa,CAAC,CAAA;AAElC,MAAM,OAAO,uBAAuB;IAGvB;IACA;IAHF,IAAI,GAAG,yBAAyB,CAAA;IACzC,YACW,OAAoD,EACpD,MAA4B;QAD5B,YAAO,GAAP,OAAO,CAA6C;QACpD,WAAM,GAAN,MAAM,CAAsB;IACpC,CAAC;CACL;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,CAKnB,OAAU,EACV,MAE2B,EAC3B,EAAE,CACF,IAAI,uBAAuB,CAGzB,OAAc,EAAE,MAAa,CAAC,CAAA;AAElC,MAAM,OAAO,gBAAgB;IAGhB;IACA;IAHF,IAAI,GAAG,kBAAkB,CAAA;IAClC,YACW,SAAsD,EACtD,MAAiD;QADjD,cAAS,GAAT,SAAS,CAA6C;QACtD,WAAM,GAAN,MAAM,CAA2C;IACzD,CAAC;CACL;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,IAAmD,EACnD,MAA2D,EAC3D,EAAE,CACF,IAAI,gBAAgB,CAGlB,IAAW,EAAE,MAAa,CAAC,CAAA;AAE/B,MAAM,OAAO,WAAW;IAGX;IACA;IAHF,IAAI,GAAG,aAAa,CAAA;IAC7B,YACW,SAAsD,EACtD,MAAiD;QADjD,cAAS,GAAT,SAAS,CAA6C;QACtD,WAAM,GAAN,MAAM,CAA2C;IACzD,CAAC;CACL;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,IAAmD,EACnD,MAAmD,EACnD,EAAE,CACF,IAAI,WAAW,CAGb,IAAW,EAAE,MAAa,CAAC,CAAA;AAE/B,MAAM,OAAO,YAAY;IAGZ;IAIA;IANF,IAAI,GAAG,cAAc,CAAA;IAC9B,YACW,SAGiB,EACjB,MAAiD;QAJjD,cAAS,GAAT,SAAS,CAGQ;QACjB,WAAM,GAAN,MAAM,CAA2C;IACzD,CAAC;CACL;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,IAG4B,EAC5B,MAAmD,EACnD,EAAE,CACF,IAAI,YAAY,CAQd,IAAW,EAAE,MAAa,CAAC,CAAA"}
@@ -1,20 +0,0 @@
1
- import { Effect, Discord, Cause } from "dfx/_common";
2
- import * as Http from "@effect-http/client";
3
- import { DiscordGateway } from "dfx/DiscordGateway";
4
- import { DiscordREST, DiscordRESTError } from "dfx/DiscordREST";
5
- import { DefinitionNotFound } from "./handlers.js";
6
- import { Interaction, InteractionBuilder } from "./index.js";
7
- export interface RunOpts {
8
- sync?: boolean;
9
- }
10
- /**
11
- * @tsplus pipeable dfx/InteractionBuilder runGateway
12
- * @tsplus location "dfx/Interactions/gateway"
13
- */
14
- export declare const run: <R, R2, E, TE, E2>(postHandler: (effect: import("@effect/io/Effect").Effect<R | DiscordREST | import("../types.js").Interaction, TE | DiscordRESTError | DefinitionNotFound, void>) => import("@effect/io/Effect").Effect<R2, E2, void>, { sync }?: RunOpts) => (ix: InteractionBuilder<R, E, TE>) => import("@effect/io/Effect").Effect<DiscordREST | DiscordGateway | Exclude<R2, import("../types.js").Interaction>, E2 | DiscordRESTError | Http.ResponseDecodeError, never>;
15
- export interface InteractionsRegistry {
16
- readonly register: <E>(ix: InteractionBuilder<never, E, never>) => Effect<never, never, void>;
17
- readonly run: <R, E>(onError: (_: Cause<DiscordRESTError | DefinitionNotFound>) => Effect<R, E, void>, opts?: RunOpts) => Effect<DiscordREST | DiscordGateway | Exclude<R, Discord.Interaction>, DiscordRESTError | Http.ResponseDecodeError | E, never>;
18
- }
19
- export declare const InteractionsRegistry: import("@effect/data/Context").Tag<InteractionsRegistry, InteractionsRegistry>;
20
- export declare const InteractionsRegistryLive: import("@effect-http/client/_common").Layer<never, never, InteractionsRegistry>;
@@ -1,39 +0,0 @@
1
- import * as tsplus_module_1 from "@effect/io/Effect";
2
- import * as tsplus_module_2 from "@effect/data/Chunk";
3
- import * as tsplus_module_3 from "dfx/utils/hub";
4
- import * as tsplus_module_4 from "@effect/io/Ref";
5
- import * as tsplus_module_5 from "@effect/io/Queue";
6
- import * as tsplus_module_6 from "dfx/_common";
7
- import * as Http from "@effect-http/client";
8
- import { DiscordGateway } from "dfx/DiscordGateway";
9
- import { DiscordREST } from "dfx/DiscordREST";
10
- import { handlers } from "./handlers.js";
11
- import { Interaction, builder } from "./index.js";
12
- /**
13
- * @tsplus pipeable dfx/InteractionBuilder runGateway
14
- */
15
- const run_1 = (postHandler, { sync = true } = {}) => (ix) => (() => {
16
- const GlobalApplicationCommand = tsplus_module_2.toReadonlyArray(tsplus_module_2.filter(tsplus_module_2.map(ix.definitions, _ => _[0]), (_) => _._tag === "GlobalApplicationCommand"));
17
- const GuildApplicationCommand = tsplus_module_2.toReadonlyArray(tsplus_module_2.filter(tsplus_module_2.map(ix.definitions, _ => _[0]), (_) => _._tag === "GuildApplicationCommand"));
18
- return tsplus_module_1.flatMap(DiscordGateway, gateway => tsplus_module_1.flatMap(DiscordREST, rest => tsplus_module_1.flatMap(tsplus_module_1.flatMap(rest.getCurrentBotApplicationInformation(), a => a.json), application => {
19
- const globalSync = rest.bulkOverwriteGlobalApplicationCommands(application.id, {
20
- body: Http.body.json(GlobalApplicationCommand.map(_ => _.command)),
21
- });
22
- const guildSync = GuildApplicationCommand.length
23
- ? gateway.handleDispatch("GUILD_CREATE", a => rest.bulkOverwriteGuildApplicationCommands(application.id, a.id, GuildApplicationCommand.map(_ => _.command)))
24
- : tsplus_module_1.never();
25
- const handle = handlers(ix.definitions, (i, r) => rest.createInteractionResponse(i.id, i.token, r));
26
- const run = gateway.handleDispatch("INTERACTION_CREATE", i => tsplus_module_1.provideService(postHandler(handle[i.type](i)), Interaction, i));
27
- return sync ? tsplus_module_1.zipParRight(tsplus_module_1.zipParRight(run, globalSync), guildSync) : run;
28
- })));
29
- })();
30
- export const run = run_1;
31
- const makeRegistry = tsplus_module_1.flatMap(tsplus_module_4.make(builder), ref => tsplus_module_1.map(tsplus_module_5.sliding(1), queue => {
32
- const register = (ix) => tsplus_module_1.flatMap(tsplus_module_4.updateAndGet(ref, _ => _.concat(ix)), _ => queue.offer(_));
33
- const run = (onError, opts) => tsplus_module_3.foreverSwitch(queue
34
- .take(), ix => run_1(_ => tsplus_module_1.catchAllCause(_, onError), opts)(ix));
35
- return { register, run };
36
- }));
37
- export const InteractionsRegistry = tsplus_module_6.Tag();
38
- export const InteractionsRegistryLive = tsplus_module_1.toLayer(makeRegistry, InteractionsRegistry);
39
- //# sourceMappingURL=gateway.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gateway.js","sourceRoot":"","sources":["../src/Interactions/gateway.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAC3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Ac,CAAC,CAAC,EAAE,CAAC,8BAAA,CAAC,EAAe,OAAO,CAAC,EAAE,IAAI,EAAjD,EAAE,CAAgD,CAAC,CAAA;IAE5E,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAW,CAAA;GACjC,CAAA;AAmBF,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAA,GAAG,EAAwB,CAAA;AAC/D,MAAM,CAAC,MAAM,wBAAwB,GACnC,wBAAA,YAAY,EAAS,oBAAoB,CAAC,CAAA"}
@@ -1,10 +0,0 @@
1
- import { Discord, Effect, Chunk } from "dfx/_common";
2
- import * as D from "./definitions.js";
3
- export declare class DefinitionNotFound {
4
- readonly interaction: Discord.Interaction;
5
- readonly _tag = "DefinitionNotFound";
6
- constructor(interaction: Discord.Interaction);
7
- }
8
- type Handler<R, E, A> = Effect<R | Discord.Interaction, E | DefinitionNotFound, A>;
9
- export declare const handlers: <R, E, TE, A, B>(definitions: import("../_common.js").Chunk<readonly [handler: D.InteractionDefinition<R, E>, transform: (self: import("@effect/io/Effect").Effect<R, E, A>) => import("@effect/io/Effect").Effect<R, TE, B>]>, handleResponse: (ix: Discord.Interaction, _: Discord.InteractionResponse) => import("@effect/io/Effect").Effect<R, E, A>) => Record<import("../types.js").InteractionType, (i: Discord.Interaction) => Handler<R, E, B>>;
10
- export {};
@@ -1,45 +0,0 @@
1
- import * as tsplus_module_1 from "dfx/_common";
2
- import * as tsplus_module_2 from "@effect/io/Effect";
3
- import * as tsplus_module_3 from "@effect/data/Option";
4
- import * as IxHelpers from "dfx/Helpers/interactions";
5
- import * as Ctx from "./context.js";
6
- import { flattenDefinitions, splitDefinitions } from "./utils.js";
7
- export class DefinitionNotFound {
8
- interaction;
9
- _tag = "DefinitionNotFound";
10
- constructor(interaction) {
11
- this.interaction = interaction;
12
- }
13
- }
14
- export const handlers = (definitions, handleResponse) => {
15
- const flattened = flattenDefinitions(definitions, handleResponse);
16
- const { Commands, Autocomplete, MessageComponent, ModalSubmit } = splitDefinitions(flattened);
17
- return {
18
- [1 /* Discord.InteractionType.PING */]: () => tsplus_module_2.succeed({
19
- type: 1 /* Discord.InteractionCallbackType.PONG */,
20
- }),
21
- [2 /* Discord.InteractionType.APPLICATION_COMMAND */]: i => {
22
- const data = i.data;
23
- return tsplus_module_3.match(tsplus_module_3.fromNullable(Commands[data.name]), () => tsplus_module_2.fail(new DefinitionNotFound(i)), command => tsplus_module_2.provideService(command
24
- .handle(i), Ctx.ApplicationCommand, data));
25
- },
26
- [5 /* Discord.InteractionType.MODAL_SUBMIT */]: i => {
27
- const data = i.data;
28
- return tsplus_module_2.flatMap(tsplus_module_2.find(ModalSubmit, _ => _.predicate(data.custom_id)), _ => tsplus_module_3.match(_, () => tsplus_module_2.fail(new DefinitionNotFound(i)), match => tsplus_module_2.provideService(match
29
- .handle(i), Ctx.ModalSubmitData, data)));
30
- },
31
- [3 /* Discord.InteractionType.MESSAGE_COMPONENT */]: i => {
32
- const data = i.data;
33
- return tsplus_module_2.flatMap(tsplus_module_2.find(MessageComponent, _ => _.predicate(data.custom_id)), _ => tsplus_module_3.match(_, () => tsplus_module_2.fail(new DefinitionNotFound(i)), match => tsplus_module_2.provideService(match
34
- .handle(i), Ctx.MessageComponentData, data)));
35
- },
36
- [4 /* Discord.InteractionType.APPLICATION_COMMAND_AUTOCOMPLETE */]: i => {
37
- const data = i.data;
38
- return tsplus_module_3.match(IxHelpers.focusedOption(data), () => tsplus_module_2.fail(new DefinitionNotFound(i)), focusedOption => tsplus_module_2.flatMap(tsplus_module_2.find(Autocomplete, _ => _.predicate(data, focusedOption)), _ => tsplus_module_3.match(_, () => tsplus_module_2.fail(new DefinitionNotFound(i)), match => tsplus_module_2.provideService(tsplus_module_2.provideService(match
39
- .handle(i), Ctx.ApplicationCommand, data), Ctx.FocusedOptionContext, {
40
- focusedOption,
41
- }))));
42
- },
43
- };
44
- };
45
- //# sourceMappingURL=handlers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handlers.js","sourceRoot":"","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+BAAA,+BAAA,KAAK;iBACF,MAAM,CAAC,CAAC,CAAC,EACM,GAAG,CAAC,kBAAkB,EAAE,IAAI,CAAC,EAC7B,GAAG,CAAC,oBAAoB,EAAE;gBACxC,aAAa;aACd,CAAqB,CAC3B,CACF,CACJ,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
@@ -1,10 +0,0 @@
1
- import { Discord, Effect } from "dfx/_common";
2
- export { response } from "../Helpers/interactions.js";
3
- export * from "./builder.js";
4
- export * from "./context.js";
5
- export { InteractionDefinition, autocomplete, global, guild, messageComponent, modalSubmit, } from "./definitions.js";
6
- export declare const id: (query: string) => (customId: string) => Effect<never, never, boolean>;
7
- export declare const idStartsWith: (query: string) => (customId: string) => Effect<never, never, boolean>;
8
- export declare const idRegex: (query: RegExp) => (customId: string) => Effect<never, never, boolean>;
9
- export declare const option: (command: string, optionName: string) => (data: Pick<Discord.ApplicationCommandDatum, "name">, focusedOption: Pick<Discord.ApplicationCommandInteractionDataOption, "name">) => Effect<never, never, boolean>;
10
- export declare const optionOnly: (optionName: string) => (_: unknown, focusedOption: Pick<Discord.ApplicationCommandInteractionDataOption, "name">) => Effect<never, never, boolean>;
@@ -1,12 +0,0 @@
1
- import * as tsplus_module_1 from "@effect/io/Effect";
2
- export { response } from "../Helpers/interactions.js";
3
- export * from "./builder.js";
4
- export * from "./context.js";
5
- export { autocomplete, global, guild, messageComponent, modalSubmit, } from "./definitions.js";
6
- // Filters
7
- export const id = (query) => (customId) => tsplus_module_1.succeed(query === customId);
8
- export const idStartsWith = (query) => (customId) => tsplus_module_1.succeed(customId.startsWith(query));
9
- export const idRegex = (query) => (customId) => tsplus_module_1.succeed(query.test(customId));
10
- export const option = (command, optionName) => (data, focusedOption) => tsplus_module_1.succeed(data.name === command && focusedOption.name === optionName);
11
- export const optionOnly = (optionName) => (_, focusedOption) => tsplus_module_1.succeed(focusedOption.name === optionName);
12
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/Interactions/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,OAAO,EAEL,YAAY,EACZ,MAAM,EACN,KAAK,EACL,gBAAgB,EAChB,WAAW,GACZ,MAAM,kBAAkB,CAAA;AAEzB,UAAU;AACV,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,QAAgB,EAAE,EAAE,CACxD,wBAAe,KAAK,KAAK,QAAQ,CAAC,CAAA;AAEpC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,QAAgB,EAAE,EAAE,CAClE,wBAAe,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAA;AAE5C,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,QAAgB,EAAE,EAAE,CAC7D,wBAAe,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEtC,MAAM,CAAC,MAAM,MAAM,GACjB,CAAC,OAAe,EAAE,UAAkB,EAAE,EAAE,CACxC,CACE,IAAmD,EACnD,aAGC,EACD,EAAE,CACF,wBAAe,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,aAAa,CAAC,IAAI,KAAK,UAAU,CAAC,CAAA;AAE9E,MAAM,CAAC,MAAM,UAAU,GACrB,CAAC,UAAkB,EAAE,EAAE,CACvB,CACE,CAAU,EACV,aAGC,EACD,EAAE,CACF,wBAAe,aAAa,CAAC,IAAI,KAAK,UAAU,CAAC,CAAA"}
@@ -1,78 +0,0 @@
1
- import { Discord, Effect, Chunk } from "dfx/_common";
2
- import * as D from "./definitions.js";
3
- export type DefinitionFlattened<R, E, TE, A> = D.InteractionDefinition<R, E> extends infer D ? {
4
- [K in keyof D]: K extends "handle" ? (_: Discord.Interaction) => Effect<R, TE, A> : D[K];
5
- } : never;
6
- export type DefinitionFlattenedCommand<R, E, TE, A> = Extract<DefinitionFlattened<R, E, TE, A>, {
7
- _tag: "GlobalApplicationCommand" | "GuildApplicationCommand";
8
- }>;
9
- export declare const flattenDefinitions: <R, E, TE, A, B>(definitions: import("../_common.js").Chunk<readonly [handler: D.InteractionDefinition<R, E>, transform: (self: import("@effect/io/Effect").Effect<R, E, A>) => import("@effect/io/Effect").Effect<R, TE, B>]>, handleResponse: (ix: Discord.Interaction, _: Discord.InteractionResponse) => import("@effect/io/Effect").Effect<R, E, A>) => import("../_common.js").Chunk<{
10
- handle: (i: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, B>;
11
- _tag: "GlobalApplicationCommand";
12
- command: import("../types.js").CreateGlobalApplicationCommandParams;
13
- } | {
14
- handle: (i: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, B>;
15
- _tag: "GuildApplicationCommand";
16
- command: import("../types.js").CreateGuildApplicationCommandParams;
17
- } | {
18
- handle: (i: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, B>;
19
- _tag: "MessageComponent";
20
- predicate: (customId: string) => import("@effect/io/Effect").Effect<R, E, boolean>;
21
- } | {
22
- handle: (i: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, B>;
23
- _tag: "ModalSubmit";
24
- predicate: (customId: string) => import("@effect/io/Effect").Effect<R, E, boolean>;
25
- } | {
26
- handle: (i: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, B>;
27
- _tag: "Autocomplete";
28
- predicate: (data: import("../types.js").ApplicationCommandDatum, focusedOption: import("../types.js").ApplicationCommandInteractionDataOption) => import("@effect/io/Effect").Effect<R, E, boolean>;
29
- }>;
30
- export declare const splitDefinitions: <R, E, TE, A>(definitions: import("../_common.js").Chunk<{
31
- readonly _tag: "GlobalApplicationCommand";
32
- readonly command: import("../types.js").CreateGlobalApplicationCommandParams;
33
- readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
34
- } | {
35
- readonly _tag: "GuildApplicationCommand";
36
- readonly command: import("../types.js").CreateGuildApplicationCommandParams;
37
- readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
38
- } | {
39
- readonly _tag: "MessageComponent";
40
- readonly predicate: (customId: string) => import("@effect/io/Effect").Effect<R, E, boolean>;
41
- readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
42
- } | {
43
- readonly _tag: "ModalSubmit";
44
- readonly predicate: (customId: string) => import("@effect/io/Effect").Effect<R, E, boolean>;
45
- readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
46
- } | {
47
- readonly _tag: "Autocomplete";
48
- readonly predicate: (data: import("../types.js").ApplicationCommandDatum, focusedOption: import("../types.js").ApplicationCommandInteractionDataOption) => import("@effect/io/Effect").Effect<R, E, boolean>;
49
- readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
50
- }>) => {
51
- Commands: Record<string, DefinitionFlattenedCommand<R, E, TE, A>>;
52
- GlobalApplicationCommand: import("../_common.js").Chunk<{
53
- readonly _tag: "GlobalApplicationCommand";
54
- readonly command: import("../types.js").CreateGlobalApplicationCommandParams;
55
- readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
56
- }>;
57
- GuildApplicationCommand: import("../_common.js").Chunk<{
58
- readonly _tag: "GuildApplicationCommand";
59
- readonly command: import("../types.js").CreateGuildApplicationCommandParams;
60
- readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
61
- }>;
62
- MessageComponent: import("../_common.js").Chunk<{
63
- readonly _tag: "MessageComponent";
64
- readonly predicate: (customId: string) => import("@effect/io/Effect").Effect<R, E, boolean>;
65
- readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
66
- }>;
67
- ModalSubmit: import("../_common.js").Chunk<{
68
- readonly _tag: "ModalSubmit";
69
- readonly predicate: (customId: string) => import("@effect/io/Effect").Effect<R, E, boolean>;
70
- readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
71
- }>;
72
- Autocomplete: import("../_common.js").Chunk<{
73
- readonly _tag: "Autocomplete";
74
- readonly predicate: (data: import("../types.js").ApplicationCommandDatum, focusedOption: import("../types.js").ApplicationCommandInteractionDataOption) => import("@effect/io/Effect").Effect<R, E, boolean>;
75
- readonly handle: (_: Discord.Interaction) => import("@effect/io/Effect").Effect<R, TE, A>;
76
- }>;
77
- };
78
- export declare function fromHex(hexString: string): Uint8Array;
@@ -1,74 +0,0 @@
1
- import * as tsplus_module_1 from "@effect/io/Effect";
2
- import * as tsplus_module_2 from "@effect/data/Chunk";
3
- import * as Ctx from "./context.js";
4
- const context = {
5
- resolve: Ctx.resolved,
6
- option: Ctx.option,
7
- optionValue: Ctx.optionValue,
8
- optionValueOptional: Ctx.optionValueOptional,
9
- subCommands: Ctx.handleSubCommands,
10
- };
11
- export const flattenDefinitions = (definitions, handleResponse) => tsplus_module_2.map(definitions, ([definition, transform]) => ({
12
- ...definition,
13
- handle: (i) => tsplus_module_1.isEffect(definition.handle)
14
- ? transform(tsplus_module_1.flatMap(definition.handle, _ => handleResponse(i, _)))
15
- : transform(tsplus_module_1.flatMap(definition.handle(context), _ => handleResponse(i, _))),
16
- }));
17
- export const splitDefinitions = (definitions) => {
18
- const grouped = tsplus_module_2.reduce(definitions, {
19
- Autocomplete: tsplus_module_2.empty(),
20
- GlobalApplicationCommand: tsplus_module_2.empty(),
21
- GuildApplicationCommand: tsplus_module_2.empty(),
22
- MessageComponent: tsplus_module_2.empty(),
23
- ModalSubmit: tsplus_module_2.empty(),
24
- }, (acc, d) => ({
25
- ...acc,
26
- [d._tag]: tsplus_module_2.append(acc[d._tag], d),
27
- }));
28
- const Commands = tsplus_module_2.reduce(tsplus_module_2.concat(grouped.GlobalApplicationCommand, grouped.GuildApplicationCommand), {}, (acc, d) => ({
29
- ...acc,
30
- [d.command.name]: d,
31
- }));
32
- return {
33
- ...grouped,
34
- Commands,
35
- };
36
- };
37
- const MAP_HEX = {
38
- 0: 0,
39
- 1: 1,
40
- 2: 2,
41
- 3: 3,
42
- 4: 4,
43
- 5: 5,
44
- 6: 6,
45
- 7: 7,
46
- 8: 8,
47
- 9: 9,
48
- a: 10,
49
- b: 11,
50
- c: 12,
51
- d: 13,
52
- e: 14,
53
- f: 15,
54
- A: 10,
55
- B: 11,
56
- C: 12,
57
- D: 13,
58
- E: 14,
59
- F: 15,
60
- };
61
- export function fromHex(hexString) {
62
- const bytes = new Uint8Array(Math.floor((hexString || "").length / 2));
63
- let i;
64
- for (i = 0; i < bytes.length; i++) {
65
- const a = MAP_HEX[hexString[i * 2]];
66
- const b = MAP_HEX[hexString[i * 2 + 1]];
67
- if (a === undefined || b === undefined) {
68
- break;
69
- }
70
- bytes[i] = (a << 4) | b;
71
- }
72
- return i === bytes.length ? bytes : bytes.slice(0, i);
73
- }
74
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/Interactions/utils.ts"],"names":[],"mappings":";;AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAkBnC,MAAM,OAAO,GAAyB;IACpC,OAAO,EAAE,GAAG,CAAC,QAAQ;IACrB,MAAM,EAAE,GAAG,CAAC,MAAM;IAClB,WAAW,EAAE,GAAG,CAAC,WAAW;IAC5B,mBAAmB,EAAE,GAAG,CAAC,mBAAmB;IAC5C,WAAW,EAAE,GAAG,CAAC,iBAAiB;CAC5B,CAAA;AAER,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,WAKC,EACD,cAGoB,EACpB,EAAE,CACF,oBAAA,WAAW,EAAK,CAAC,CAAC,UAAU,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;IAC5C,GAAG,UAAU;IACb,MAAM,EAAE,CAAC,CAA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AAC"}
@@ -1,45 +0,0 @@
1
- import { ConfigSecret, Config, Discord, Chunk, Effect, Cause } from "dfx/_common";
2
- import { DefinitionNotFound } from "./handlers.js";
3
- import { InteractionBuilder } from "./index.js";
4
- export declare class BadWebhookSignature {
5
- readonly _tag = "BadWebhookSignature";
6
- }
7
- export type Headers = Record<string, string | string[] | undefined>;
8
- export interface MakeConfigOpts {
9
- applicationId: string;
10
- publicKey: ConfigSecret;
11
- }
12
- declare const makeConfig: ({ applicationId, publicKey }: MakeConfigOpts) => {
13
- applicationId: string;
14
- publicKey: Uint8Array;
15
- };
16
- export interface WebhookConfig extends ReturnType<typeof makeConfig> {
17
- }
18
- export declare const WebhookConfig: import("@effect/data/Context").Tag<WebhookConfig, WebhookConfig>;
19
- export declare const makeConfigLayer: (a_0: MakeConfigOpts) => import("@effect-http/client/_common").Layer<never, never, WebhookConfig>;
20
- export declare const makeFromConfig: (a: Config<MakeConfigOpts>) => import("@effect-http/client/_common").Layer<never, import("../_common.js").ConfigError, WebhookConfig>;
21
- export declare class WebhookParseError {
22
- readonly reason: unknown;
23
- readonly _tag = "WebhookParseError";
24
- constructor(reason: unknown);
25
- }
26
- export interface HandleWebhookOpts<E> {
27
- headers: Headers;
28
- body: string;
29
- success: (a: Discord.InteractionResponse) => Effect<never, never, void>;
30
- error: (e: Cause<E>) => Effect<never, never, void>;
31
- }
32
- /**
33
- * @tsplus getter dfx/InteractionBuilder webhookHandler
34
- * @tsplus location "dfx/Interactions/webhook"
35
- */
36
- export declare const makeHandler: <R, E, TE>(ix: InteractionBuilder<R, E, TE>) => ({ headers, body, success, error, }: HandleWebhookOpts<DefinitionNotFound | BadWebhookSignature | WebhookParseError | E>) => import("@effect/io/Effect").Effect<WebhookConfig, never, void>;
37
- /**
38
- * @tsplus getter dfx/InteractionBuilder simpleWebhookHandler
39
- * @tsplus location "dfx/Interactions/webhook"
40
- */
41
- export declare const makeSimpleHandler: <R, E, TE>(ix: InteractionBuilder<R, E, TE>) => ({ headers, body }: {
42
- headers: Headers;
43
- body: string;
44
- }) => import("@effect/io/Effect").Effect<WebhookConfig, DefinitionNotFound | BadWebhookSignature | WebhookParseError, import("../types.js").InteractionResponse>;
45
- export {};
@@ -1,56 +0,0 @@
1
- import * as tsplus_module_1 from "@effect/data/Option";
2
- import * as tsplus_module_2 from "@effect/data/Either";
3
- import * as tsplus_module_3 from "@effect/io/Config/Secret";
4
- import * as tsplus_module_4 from "dfx/_common";
5
- import * as tsplus_module_5 from "@effect/io/Layer";
6
- import * as tsplus_module_6 from "@effect/data/Function";
7
- import * as tsplus_module_7 from "@effect/io/Effect";
8
- import * as tsplus_module_8 from "@effect/data/Chunk";
9
- import Nacl from "tweetnacl";
10
- import { handlers } from "./handlers.js";
11
- import { Interaction } from "./index.js";
12
- import { fromHex } from "./utils.js";
13
- export class BadWebhookSignature {
14
- _tag = "BadWebhookSignature";
15
- }
16
- const checkSignature = (publicKey, headers, body) => tsplus_module_2.asUnit(tsplus_module_1.toEither(() => new BadWebhookSignature())(tsplus_module_1.filter(a => {
17
- const enc = new TextEncoder();
18
- return Nacl.sign.detached.verify(enc.encode(a.timestamp + body), fromHex(`${a.signature}`), publicKey);
19
- })(tsplus_module_1.struct({
20
- signature: tsplus_module_1.fromNullable(headers["x-signature-ed25519"]),
21
- timestamp: tsplus_module_1.fromNullable(headers["x-signature-timestamp"]),
22
- }))));
23
- const makeConfig = ({ applicationId, publicKey }) => ({
24
- applicationId,
25
- publicKey: fromHex(tsplus_module_3.value(publicKey)),
26
- });
27
- export const WebhookConfig = tsplus_module_4.Tag();
28
- export const makeConfigLayer = tsplus_module_6.flow(makeConfig, _ => tsplus_module_5.succeed(WebhookConfig, _));
29
- export const makeFromConfig = (a) => tsplus_module_7.toLayer(tsplus_module_7.map(tsplus_module_7.config(a), makeConfig), WebhookConfig);
30
- export class WebhookParseError {
31
- reason;
32
- _tag = "WebhookParseError";
33
- constructor(reason) {
34
- this.reason = reason;
35
- }
36
- }
37
- const fromHeadersAndBody = (headers, body) => tsplus_module_7.flatMap(WebhookConfig, ({ publicKey }) => tsplus_module_7.flatMap(checkSignature(publicKey, headers, body), () => tsplus_module_7.tryCatch(() => JSON.parse(body), reason => new WebhookParseError(reason))));
38
- const run = (definitions, handleResponse) => {
39
- const handler = handlers(definitions, handleResponse);
40
- return (headers, body) => tsplus_module_7.flatMap(fromHeadersAndBody(headers, body), interaction => tsplus_module_7.provideService(handler[interaction.type](interaction), Interaction, interaction));
41
- };
42
- /**
43
- * @tsplus getter dfx/InteractionBuilder webhookHandler
44
- */
45
- export const makeHandler = (ix) => {
46
- const handle = run(tsplus_module_8.map(ix.definitions, ([d]) => [d, tsplus_module_6.identity]), (_i, r) => tsplus_module_7.succeed(r));
47
- return ({ headers, body, success, error, }) => tsplus_module_7.catchAllCause(tsplus_module_7.flatMap(handle(headers, body), success), error);
48
- };
49
- /**
50
- * @tsplus getter dfx/InteractionBuilder simpleWebhookHandler
51
- */
52
- export const makeSimpleHandler = (ix) => {
53
- const handle = run(tsplus_module_8.map(ix.definitions, ([d]) => [d, tsplus_module_6.identity]), (_i, r) => tsplus_module_7.succeed(r));
54
- return ({ headers, body }) => handle(headers, body);
55
- };
56
- //# sourceMappingURL=webhook.js.map