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.
Files changed (37) hide show
  1. package/Interactions/context.d.ts +1 -4
  2. package/Interactions/context.d.ts.map +1 -1
  3. package/Interactions/context.js +1 -1
  4. package/Interactions/context.js.map +1 -1
  5. package/Interactions/definitions.d.ts +11 -15
  6. package/Interactions/definitions.d.ts.map +1 -1
  7. package/Interactions/definitions.js.map +1 -1
  8. package/Interactions/handlers.d.ts.map +1 -1
  9. package/Interactions/handlers.js +25 -23
  10. package/Interactions/handlers.js.map +1 -1
  11. package/Interactions/index.d.ts +5 -6
  12. package/Interactions/index.d.ts.map +1 -1
  13. package/Interactions/index.js +5 -8
  14. package/Interactions/index.js.map +1 -1
  15. package/Interactions/utils.d.ts +21 -20
  16. package/Interactions/utils.d.ts.map +1 -1
  17. package/Interactions/utils.js +18 -20
  18. package/Interactions/utils.js.map +1 -1
  19. package/mjs/Interactions/context.mjs +1 -1
  20. package/mjs/Interactions/context.mjs.map +1 -1
  21. package/mjs/Interactions/definitions.mjs.map +1 -1
  22. package/mjs/Interactions/handlers.mjs +25 -23
  23. package/mjs/Interactions/handlers.mjs.map +1 -1
  24. package/mjs/Interactions/index.mjs +5 -6
  25. package/mjs/Interactions/index.mjs.map +1 -1
  26. package/mjs/Interactions/utils.mjs +18 -20
  27. package/mjs/Interactions/utils.mjs.map +1 -1
  28. package/mjs/version.mjs +1 -1
  29. package/package.json +2 -2
  30. package/src/Interactions/context.ts +2 -5
  31. package/src/Interactions/definitions.ts +23 -37
  32. package/src/Interactions/handlers.ts +40 -66
  33. package/src/Interactions/index.ts +5 -7
  34. package/src/Interactions/utils.ts +49 -42
  35. package/src/version.ts +1 -1
  36. package/version.d.ts +1 -1
  37. 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
- Chunk.map(definitions, ([definition, transform]) => ({
42
- ...definition,
43
- handle: (i: Discord.Interaction) =>
44
- Effect.scoped(
45
- Effect.isEffect(definition.handle)
46
- ? transform(
47
- Effect.flatMap(definition.handle, _ => handleResponse(i, _)),
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
- : transform(
50
- Effect.flatMap(definition.handle(context), _ =>
51
- handleResponse(i, _),
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: Chunk.Chunk<DefinitionFlattened<R, E, TE, A>>,
73
+ definitions: ReadonlyArray<DefinitionFlattened<R, E, TE, A>>,
59
74
  ) => {
60
- const grouped = Chunk.reduce(
75
+ const grouped = ReadonlyArray.reduce(
61
76
  definitions,
62
77
  {
63
- Autocomplete: Chunk.empty(),
64
- GlobalApplicationCommand: Chunk.empty(),
65
- GuildApplicationCommand: Chunk.empty(),
66
- MessageComponent: Chunk.empty(),
67
- ModalSubmit: Chunk.empty(),
78
+ Autocomplete: [],
79
+ GlobalApplicationCommand: [],
80
+ GuildApplicationCommand: [],
81
+ MessageComponent: [],
82
+ ModalSubmit: [],
83
+ Commands: {},
68
84
  } as {
69
- [K in D.InteractionDefinition<R, E>["_tag"]]: Chunk.Chunk<
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.91.3";
1
+ export const LIB_VERSION = "0.92.0";
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const LIB_VERSION = "0.91.3";
1
+ export declare const LIB_VERSION = "0.92.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.LIB_VERSION = void 0;
7
- const LIB_VERSION = exports.LIB_VERSION = "0.91.3";
7
+ const LIB_VERSION = exports.LIB_VERSION = "0.92.0";
8
8
  //# sourceMappingURL=version.js.map