dfx 0.91.3 → 0.92.0
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/Interactions/context.d.ts +1 -4
- package/Interactions/context.d.ts.map +1 -1
- package/Interactions/context.js +1 -1
- package/Interactions/context.js.map +1 -1
- package/Interactions/definitions.d.ts +11 -15
- package/Interactions/definitions.d.ts.map +1 -1
- package/Interactions/definitions.js.map +1 -1
- package/Interactions/handlers.d.ts.map +1 -1
- package/Interactions/handlers.js +25 -23
- package/Interactions/handlers.js.map +1 -1
- package/Interactions/index.d.ts +5 -6
- package/Interactions/index.d.ts.map +1 -1
- package/Interactions/index.js +5 -8
- package/Interactions/index.js.map +1 -1
- package/Interactions/utils.d.ts +21 -20
- package/Interactions/utils.d.ts.map +1 -1
- package/Interactions/utils.js +18 -20
- package/Interactions/utils.js.map +1 -1
- package/mjs/Interactions/context.mjs +1 -1
- package/mjs/Interactions/context.mjs.map +1 -1
- package/mjs/Interactions/definitions.mjs.map +1 -1
- package/mjs/Interactions/handlers.mjs +25 -23
- package/mjs/Interactions/handlers.mjs.map +1 -1
- package/mjs/Interactions/index.mjs +5 -6
- package/mjs/Interactions/index.mjs.map +1 -1
- package/mjs/Interactions/utils.mjs +18 -20
- package/mjs/Interactions/utils.mjs.map +1 -1
- package/mjs/version.mjs +1 -1
- package/package.json +2 -2
- package/src/Interactions/context.ts +2 -5
- package/src/Interactions/definitions.ts +23 -37
- package/src/Interactions/handlers.ts +40 -66
- package/src/Interactions/index.ts +5 -7
- package/src/Interactions/utils.ts +49 -42
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -3,6 +3,7 @@ import * as Effect from "effect/Effect"
|
|
|
3
3
|
import * as Ctx from "dfx/Interactions/context"
|
|
4
4
|
import type * as D from "dfx/Interactions/definitions"
|
|
5
5
|
import type * as Discord from "dfx/types"
|
|
6
|
+
import * as ReadonlyArray from "effect/ReadonlyArray"
|
|
6
7
|
|
|
7
8
|
export type DefinitionFlattened<R, E, TE, A> =
|
|
8
9
|
D.InteractionDefinition<R, E> extends infer D
|
|
@@ -38,60 +39,66 @@ export const flattenDefinitions = <R, E, TE, A, B>(
|
|
|
38
39
|
_: Discord.InteractionResponse,
|
|
39
40
|
) => Effect.Effect<A, E, R>,
|
|
40
41
|
) =>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
ReadonlyArray.map(
|
|
43
|
+
Chunk.toReadonlyArray(definitions),
|
|
44
|
+
([definition, transform]) => ({
|
|
45
|
+
...definition,
|
|
46
|
+
handle: Effect.isEffect(definition.handle)
|
|
47
|
+
? (i: Discord.Interaction) =>
|
|
48
|
+
Effect.scoped(
|
|
49
|
+
transform(
|
|
50
|
+
Effect.flatMap(
|
|
51
|
+
definition.handle as Effect.Effect<Discord.InteractionResponse>,
|
|
52
|
+
_ => handleResponse(i, _),
|
|
53
|
+
),
|
|
54
|
+
),
|
|
48
55
|
)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
: (i: Discord.Interaction) =>
|
|
57
|
+
Effect.scoped(
|
|
58
|
+
transform(
|
|
59
|
+
Effect.flatMap(
|
|
60
|
+
(
|
|
61
|
+
definition.handle as (
|
|
62
|
+
_: any,
|
|
63
|
+
) => Effect.Effect<Discord.InteractionResponse>
|
|
64
|
+
)(context),
|
|
65
|
+
_ => handleResponse(i, _),
|
|
66
|
+
),
|
|
52
67
|
),
|
|
53
68
|
),
|
|
54
|
-
|
|
55
|
-
|
|
69
|
+
}),
|
|
70
|
+
)
|
|
56
71
|
|
|
57
72
|
export const splitDefinitions = <R, E, TE, A>(
|
|
58
|
-
definitions:
|
|
73
|
+
definitions: ReadonlyArray<DefinitionFlattened<R, E, TE, A>>,
|
|
59
74
|
) => {
|
|
60
|
-
const grouped =
|
|
75
|
+
const grouped = ReadonlyArray.reduce(
|
|
61
76
|
definitions,
|
|
62
77
|
{
|
|
63
|
-
Autocomplete:
|
|
64
|
-
GlobalApplicationCommand:
|
|
65
|
-
GuildApplicationCommand:
|
|
66
|
-
MessageComponent:
|
|
67
|
-
ModalSubmit:
|
|
78
|
+
Autocomplete: [],
|
|
79
|
+
GlobalApplicationCommand: [],
|
|
80
|
+
GuildApplicationCommand: [],
|
|
81
|
+
MessageComponent: [],
|
|
82
|
+
ModalSubmit: [],
|
|
83
|
+
Commands: {},
|
|
68
84
|
} as {
|
|
69
|
-
[K in D.InteractionDefinition<R, E>["_tag"]]:
|
|
85
|
+
[K in D.InteractionDefinition<R, E>["_tag"]]: Array<
|
|
70
86
|
Extract<DefinitionFlattened<R, E, TE, A>, { _tag: K }>
|
|
71
87
|
>
|
|
88
|
+
} & {
|
|
89
|
+
readonly Commands: Record<string, DefinitionFlattenedCommand<R, E, TE, A>>
|
|
90
|
+
},
|
|
91
|
+
(acc, d) => {
|
|
92
|
+
acc[d._tag].push(d as any)
|
|
93
|
+
if (
|
|
94
|
+
d._tag === "GlobalApplicationCommand" ||
|
|
95
|
+
d._tag === "GuildApplicationCommand"
|
|
96
|
+
) {
|
|
97
|
+
acc.Commands[d.command.name] = d as any
|
|
98
|
+
}
|
|
99
|
+
return acc
|
|
72
100
|
},
|
|
73
|
-
(acc, d) => ({
|
|
74
|
-
...acc,
|
|
75
|
-
[d._tag]: Chunk.append(acc[d._tag] as Chunk.Chunk<any>, d),
|
|
76
|
-
}),
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
const Commands = Chunk.appendAll(
|
|
80
|
-
grouped.GlobalApplicationCommand,
|
|
81
|
-
grouped.GuildApplicationCommand,
|
|
82
|
-
).pipe(
|
|
83
|
-
Chunk.reduce(
|
|
84
|
-
{} as Record<string, DefinitionFlattenedCommand<R, E, TE, A>>,
|
|
85
|
-
(acc, d) =>
|
|
86
|
-
({
|
|
87
|
-
...acc,
|
|
88
|
-
[d.command.name]: d,
|
|
89
|
-
}) as any,
|
|
90
|
-
),
|
|
91
101
|
)
|
|
92
102
|
|
|
93
|
-
return
|
|
94
|
-
...grouped,
|
|
95
|
-
Commands,
|
|
96
|
-
}
|
|
103
|
+
return grouped
|
|
97
104
|
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "0.
|
|
1
|
+
export const LIB_VERSION = "0.92.0";
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "0.
|
|
1
|
+
export declare const LIB_VERSION = "0.92.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED