dfx 0.86.0 → 0.88.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 (166) hide show
  1. package/Cache/driver.d.ts +15 -15
  2. package/Cache/driver.d.ts.map +1 -1
  3. package/Cache/driver.js.map +1 -1
  4. package/Cache/memory.d.ts +2 -2
  5. package/Cache/memory.d.ts.map +1 -1
  6. package/Cache/memory.js.map +1 -1
  7. package/Cache/memoryTTL.d.ts +2 -2
  8. package/Cache/memoryTTL.d.ts.map +1 -1
  9. package/Cache/memoryTTL.js.map +1 -1
  10. package/Cache/prelude.d.ts +13 -16
  11. package/Cache/prelude.d.ts.map +1 -1
  12. package/Cache/prelude.js +4 -4
  13. package/Cache/prelude.js.map +1 -1
  14. package/Cache.d.ts +25 -25
  15. package/Cache.d.ts.map +1 -1
  16. package/Cache.js.map +1 -1
  17. package/DiscordConfig.d.ts +3 -4
  18. package/DiscordConfig.d.ts.map +1 -1
  19. package/DiscordConfig.js +1 -1
  20. package/DiscordConfig.js.map +1 -1
  21. package/DiscordGateway/DiscordWS.d.ts +10 -11
  22. package/DiscordGateway/DiscordWS.d.ts.map +1 -1
  23. package/DiscordGateway/DiscordWS.js +2 -2
  24. package/DiscordGateway/DiscordWS.js.map +1 -1
  25. package/DiscordGateway/Messaging.d.ts +12 -13
  26. package/DiscordGateway/Messaging.d.ts.map +1 -1
  27. package/DiscordGateway/Messaging.js +1 -1
  28. package/DiscordGateway/Messaging.js.map +1 -1
  29. package/DiscordGateway/Shard/heartbeats.d.ts +1 -1
  30. package/DiscordGateway/Shard/heartbeats.d.ts.map +1 -1
  31. package/DiscordGateway/Shard/heartbeats.js.map +1 -1
  32. package/DiscordGateway/Shard/identify.d.ts +1 -1
  33. package/DiscordGateway/Shard/identify.d.ts.map +1 -1
  34. package/DiscordGateway/Shard/identify.js.map +1 -1
  35. package/DiscordGateway/Shard/invalidSession.d.ts +1 -1
  36. package/DiscordGateway/Shard/invalidSession.d.ts.map +1 -1
  37. package/DiscordGateway/Shard/utils.d.ts +2 -2
  38. package/DiscordGateway/Shard/utils.d.ts.map +1 -1
  39. package/DiscordGateway/Shard/utils.js.map +1 -1
  40. package/DiscordGateway/Shard.d.ts +10 -11
  41. package/DiscordGateway/Shard.d.ts.map +1 -1
  42. package/DiscordGateway/Shard.js +1 -1
  43. package/DiscordGateway/Shard.js.map +1 -1
  44. package/DiscordGateway/ShardStore.d.ts +5 -6
  45. package/DiscordGateway/ShardStore.d.ts.map +1 -1
  46. package/DiscordGateway/ShardStore.js +1 -1
  47. package/DiscordGateway/ShardStore.js.map +1 -1
  48. package/DiscordGateway/Sharder.d.ts +3 -4
  49. package/DiscordGateway/Sharder.d.ts.map +1 -1
  50. package/DiscordGateway/Sharder.js +1 -1
  51. package/DiscordGateway/Sharder.js.map +1 -1
  52. package/DiscordGateway/WS.d.ts +7 -8
  53. package/DiscordGateway/WS.d.ts.map +1 -1
  54. package/DiscordGateway/WS.js +1 -1
  55. package/DiscordGateway/WS.js.map +1 -1
  56. package/DiscordGateway.d.ts +8 -9
  57. package/DiscordGateway.d.ts.map +1 -1
  58. package/DiscordGateway.js +1 -1
  59. package/DiscordGateway.js.map +1 -1
  60. package/DiscordREST/types.d.ts +6 -2
  61. package/DiscordREST/types.d.ts.map +1 -1
  62. package/DiscordREST.d.ts +4 -4
  63. package/DiscordREST.d.ts.map +1 -1
  64. package/DiscordREST.js +19 -2
  65. package/DiscordREST.js.map +1 -1
  66. package/Helpers/permissions.d.ts +3 -3
  67. package/Helpers/permissions.d.ts.map +1 -1
  68. package/Interactions/builder.d.ts +12 -12
  69. package/Interactions/builder.d.ts.map +1 -1
  70. package/Interactions/context.d.ts +22 -23
  71. package/Interactions/context.d.ts.map +1 -1
  72. package/Interactions/context.js +6 -6
  73. package/Interactions/context.js.map +1 -1
  74. package/Interactions/definitions.d.ts +23 -23
  75. package/Interactions/definitions.d.ts.map +1 -1
  76. package/Interactions/gateway.d.ts +5 -6
  77. package/Interactions/gateway.d.ts.map +1 -1
  78. package/Interactions/gateway.js +5 -5
  79. package/Interactions/gateway.js.map +1 -1
  80. package/Interactions/handlers.d.ts +2 -2
  81. package/Interactions/handlers.d.ts.map +1 -1
  82. package/Interactions/index.d.ts +5 -5
  83. package/Interactions/utils.d.ts +26 -26
  84. package/Interactions/utils.d.ts.map +1 -1
  85. package/Interactions/utils.js.map +1 -1
  86. package/Interactions/webhook.d.ts +7 -8
  87. package/Interactions/webhook.d.ts.map +1 -1
  88. package/Interactions/webhook.js +1 -1
  89. package/Interactions/webhook.js.map +1 -1
  90. package/RateLimit.d.ts +11 -12
  91. package/RateLimit.d.ts.map +1 -1
  92. package/RateLimit.js +2 -2
  93. package/RateLimit.js.map +1 -1
  94. package/gateway.d.ts +2 -2
  95. package/mjs/Cache/driver.mjs.map +1 -1
  96. package/mjs/Cache/memory.mjs.map +1 -1
  97. package/mjs/Cache/memoryTTL.mjs.map +1 -1
  98. package/mjs/Cache/prelude.mjs +4 -4
  99. package/mjs/Cache/prelude.mjs.map +1 -1
  100. package/mjs/Cache.mjs.map +1 -1
  101. package/mjs/DiscordConfig.mjs +2 -2
  102. package/mjs/DiscordConfig.mjs.map +1 -1
  103. package/mjs/DiscordGateway/DiscordWS.mjs +3 -3
  104. package/mjs/DiscordGateway/DiscordWS.mjs.map +1 -1
  105. package/mjs/DiscordGateway/Messaging.mjs +2 -2
  106. package/mjs/DiscordGateway/Messaging.mjs.map +1 -1
  107. package/mjs/DiscordGateway/Shard/heartbeats.mjs.map +1 -1
  108. package/mjs/DiscordGateway/Shard/identify.mjs.map +1 -1
  109. package/mjs/DiscordGateway/Shard/utils.mjs.map +1 -1
  110. package/mjs/DiscordGateway/Shard.mjs +2 -2
  111. package/mjs/DiscordGateway/Shard.mjs.map +1 -1
  112. package/mjs/DiscordGateway/ShardStore.mjs +2 -2
  113. package/mjs/DiscordGateway/ShardStore.mjs.map +1 -1
  114. package/mjs/DiscordGateway/Sharder.mjs +2 -2
  115. package/mjs/DiscordGateway/Sharder.mjs.map +1 -1
  116. package/mjs/DiscordGateway/WS.mjs +2 -2
  117. package/mjs/DiscordGateway/WS.mjs.map +1 -1
  118. package/mjs/DiscordGateway.mjs +2 -2
  119. package/mjs/DiscordGateway.mjs.map +1 -1
  120. package/mjs/DiscordREST.mjs +20 -3
  121. package/mjs/DiscordREST.mjs.map +1 -1
  122. package/mjs/Interactions/context.mjs +7 -7
  123. package/mjs/Interactions/context.mjs.map +1 -1
  124. package/mjs/Interactions/gateway.mjs +6 -6
  125. package/mjs/Interactions/gateway.mjs.map +1 -1
  126. package/mjs/Interactions/utils.mjs.map +1 -1
  127. package/mjs/Interactions/webhook.mjs +2 -2
  128. package/mjs/Interactions/webhook.mjs.map +1 -1
  129. package/mjs/RateLimit.mjs +3 -3
  130. package/mjs/RateLimit.mjs.map +1 -1
  131. package/mjs/version.mjs +1 -1
  132. package/package.json +4 -4
  133. package/src/Cache/driver.ts +15 -21
  134. package/src/Cache/memory.ts +1 -7
  135. package/src/Cache/memoryTTL.ts +3 -4
  136. package/src/Cache/prelude.ts +33 -34
  137. package/src/Cache.ts +31 -31
  138. package/src/DiscordConfig.ts +4 -4
  139. package/src/DiscordGateway/DiscordWS.ts +8 -7
  140. package/src/DiscordGateway/Messaging.ts +9 -8
  141. package/src/DiscordGateway/Shard/heartbeats.ts +2 -2
  142. package/src/DiscordGateway/Shard/identify.ts +0 -2
  143. package/src/DiscordGateway/Shard/invalidSession.ts +1 -1
  144. package/src/DiscordGateway/Shard/utils.ts +4 -6
  145. package/src/DiscordGateway/Shard.ts +2 -2
  146. package/src/DiscordGateway/ShardStore.ts +5 -7
  147. package/src/DiscordGateway/Sharder.ts +10 -4
  148. package/src/DiscordGateway/WS.ts +7 -10
  149. package/src/DiscordGateway.ts +8 -12
  150. package/src/DiscordREST/types.ts +7 -6
  151. package/src/DiscordREST.ts +36 -7
  152. package/src/Helpers/permissions.ts +1 -1
  153. package/src/Interactions/builder.ts +11 -11
  154. package/src/Interactions/context.ts +25 -24
  155. package/src/Interactions/definitions.ts +35 -34
  156. package/src/Interactions/gateway.ts +19 -18
  157. package/src/Interactions/handlers.ts +4 -4
  158. package/src/Interactions/utils.ts +10 -12
  159. package/src/Interactions/webhook.ts +17 -16
  160. package/src/RateLimit.ts +9 -9
  161. package/src/utils/Effect.ts +9 -9
  162. package/src/version.ts +1 -1
  163. package/utils/Effect.d.ts +2 -2
  164. package/version.d.ts +1 -1
  165. package/version.js +1 -1
  166. package/webhooks.d.ts +1 -1
@@ -65,13 +65,13 @@ export const guild = <
65
65
  export class MessageComponent<R, E> {
66
66
  readonly _tag = "MessageComponent"
67
67
  constructor(
68
- readonly predicate: (customId: string) => Effect.Effect<R, E, boolean>,
69
- readonly handle: Effect.Effect<R, E, Discord.InteractionResponse>,
68
+ readonly predicate: (customId: string) => Effect.Effect<boolean, E, R>,
69
+ readonly handle: Effect.Effect<Discord.InteractionResponse, E, R>,
70
70
  ) {}
71
71
  }
72
72
 
73
73
  export const messageComponent = <R1, R2, E1, E2>(
74
- pred: (customId: string) => Effect.Effect<R1, E1, boolean>,
74
+ pred: (customId: string) => Effect.Effect<boolean, E1, R1>,
75
75
  handle: CommandHandler<R2, E2, Discord.InteractionResponse>,
76
76
  ) =>
77
77
  new MessageComponent<
@@ -82,14 +82,14 @@ export const messageComponent = <R1, R2, E1, E2>(
82
82
  export class ModalSubmit<R, E> {
83
83
  readonly _tag = "ModalSubmit"
84
84
  constructor(
85
- readonly predicate: (customId: string) => Effect.Effect<R, E, boolean>,
86
- readonly handle: Effect.Effect<R, E, Discord.InteractionResponse>,
85
+ readonly predicate: (customId: string) => Effect.Effect<boolean, E, R>,
86
+ readonly handle: Effect.Effect<Discord.InteractionResponse, E, R>,
87
87
  ) {}
88
88
  }
89
89
 
90
90
  export const modalSubmit = <R1, R2, E1, E2>(
91
- pred: (customId: string) => Effect.Effect<R1, E1, boolean>,
92
- handle: Effect.Effect<R2, E2, Discord.InteractionResponse>,
91
+ pred: (customId: string) => Effect.Effect<boolean, E1, R1>,
92
+ handle: Effect.Effect<Discord.InteractionResponse, E2, R2>,
93
93
  ) =>
94
94
  new ModalSubmit<
95
95
  Exclude<R1 | R2, DiscordInteraction | DiscordModalSubmit>,
@@ -102,8 +102,8 @@ export class Autocomplete<R, E> {
102
102
  readonly predicate: (
103
103
  data: Discord.ApplicationCommandDatum,
104
104
  focusedOption: Discord.ApplicationCommandInteractionDataOption,
105
- ) => Effect.Effect<R, E, boolean>,
106
- readonly handle: Effect.Effect<R, E, Discord.InteractionResponse>,
105
+ ) => Effect.Effect<boolean, E, R>,
106
+ readonly handle: Effect.Effect<Discord.InteractionResponse, E, R>,
107
107
  ) {}
108
108
  }
109
109
 
@@ -111,8 +111,8 @@ export const autocomplete = <R1, R2, E1, E2>(
111
111
  pred: (
112
112
  data: Discord.ApplicationCommandDatum,
113
113
  focusedOption: Discord.ApplicationCommandInteractionDataOption,
114
- ) => Effect.Effect<R1, E1, boolean>,
115
- handle: Effect.Effect<R2, E2, Discord.InteractionResponse>,
114
+ ) => Effect.Effect<boolean, E1, R1>,
115
+ handle: Effect.Effect<Discord.InteractionResponse, E2, R2>,
116
116
  ) =>
117
117
  new Autocomplete<
118
118
  Exclude<
@@ -123,45 +123,46 @@ export const autocomplete = <R1, R2, E1, E2>(
123
123
  >(pred as any, handle as any)
124
124
 
125
125
  // ==== Command handler helpers
126
- type DeepReadonly<T> = T extends Array<infer R>
127
- ? ReadonlyArray<DeepReadonly<R>>
128
- : T extends Function
129
- ? T
130
- : T extends object
131
- ? DeepReadonlyObject<T>
132
- : T
126
+ type DeepReadonly<T> =
127
+ T extends Array<infer R>
128
+ ? ReadonlyArray<DeepReadonly<R>>
129
+ : T extends Function
130
+ ? T
131
+ : T extends object
132
+ ? DeepReadonlyObject<T>
133
+ : T
133
134
  type DeepReadonlyObject<T> = {
134
135
  readonly [P in keyof T]: DeepReadonly<T[P]>
135
136
  }
136
137
 
137
138
  export type CommandHandler<R, E, A = any> =
138
- | Effect.Effect<R, E, Discord.InteractionResponse>
139
+ | Effect.Effect<Discord.InteractionResponse, E, R>
139
140
  | CommandHandlerFn<R, E, A>
140
141
 
141
142
  export interface CommandHelper<A> {
142
143
  resolve: <T>(
143
144
  name: AllResolvables<A>["name"],
144
145
  f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => T | undefined,
145
- ) => Effect.Effect<DiscordInteraction, ResolvedDataNotFound, T>
146
+ ) => Effect.Effect<T, ResolvedDataNotFound, DiscordInteraction>
146
147
 
147
148
  option: (
148
149
  name: AllCommandOptions<A>["name"],
149
150
  ) => Effect.Effect<
150
- DiscordApplicationCommand,
151
+ Option.Option<Discord.ApplicationCommandInteractionDataOption>,
151
152
  never,
152
- Option.Option<Discord.ApplicationCommandInteractionDataOption>
153
+ DiscordApplicationCommand
153
154
  >
154
155
 
155
156
  optionValue: <N extends AllRequiredCommandOptions<A>["name"]>(
156
157
  name: N,
157
- ) => Effect.Effect<DiscordApplicationCommand, never, CommandValue<A, N>>
158
+ ) => Effect.Effect<CommandValue<A, N>, never, DiscordApplicationCommand>
158
159
 
159
160
  optionValueOptional: <N extends AllCommandOptions<A>["name"]>(
160
161
  name: N,
161
162
  ) => Effect.Effect<
162
- DiscordApplicationCommand,
163
+ Option.Option<CommandValue<A, N>>,
163
164
  never,
164
- Option.Option<CommandValue<A, N>>
165
+ DiscordApplicationCommand
165
166
  >
166
167
 
167
168
  subCommands: <
@@ -169,11 +170,17 @@ export interface CommandHelper<A> {
169
170
  ? never
170
171
  : Record<
171
172
  SubCommandNames<A>,
172
- Effect.Effect<any, any, Discord.InteractionResponse>
173
+ Effect.Effect<Discord.InteractionResponse, any, any>
173
174
  >,
174
175
  >(
175
176
  commands: NER,
176
177
  ) => Effect.Effect<
178
+ Discord.InteractionResponse,
179
+ [NER[keyof NER]] extends [
180
+ { [Effect.EffectTypeId]: { _E: (_: never) => infer E } },
181
+ ]
182
+ ? E
183
+ : never,
177
184
  | Exclude<
178
185
  [NER[keyof NER]] extends [
179
186
  { [Effect.EffectTypeId]: { _R: (_: never) => infer R } },
@@ -183,19 +190,13 @@ export interface CommandHelper<A> {
183
190
  SubCommandContext
184
191
  >
185
192
  | DiscordInteraction
186
- | DiscordApplicationCommand,
187
- [NER[keyof NER]] extends [
188
- { [Effect.EffectTypeId]: { _E: (_: never) => infer E } },
189
- ]
190
- ? E
191
- : never,
192
- Discord.InteractionResponse
193
+ | DiscordApplicationCommand
193
194
  >
194
195
  }
195
196
 
196
197
  export type CommandHandlerFn<R, E, A> = (
197
198
  i: CommandHelper<A>,
198
- ) => Effect.Effect<R, E, Discord.InteractionResponse>
199
+ ) => Effect.Effect<Discord.InteractionResponse, E, R>
199
200
 
200
201
  interface CommandOption {
201
202
  readonly type: any
@@ -1,5 +1,5 @@
1
1
  import * as Chunk from "effect/Chunk"
2
- import { Tag } from "effect/Context"
2
+ import { GenericTag } from "effect/Context"
3
3
  import * as Duration from "effect/Duration"
4
4
  import { pipe } from "effect/Function"
5
5
  import * as Effect from "effect/Effect"
@@ -38,18 +38,18 @@ export const run =
38
38
  <R, R2, E, TE, E2>(
39
39
  postHandler: (
40
40
  effect: Effect.Effect<
41
- R | DiscordREST | DiscordInteraction,
41
+ void,
42
42
  TE | DiscordRESTError | DefinitionNotFound,
43
- void
43
+ R | DiscordREST | DiscordInteraction
44
44
  >,
45
- ) => Effect.Effect<R2, E2, void>,
45
+ ) => Effect.Effect<void, E2, R2>,
46
46
  ) =>
47
47
  (
48
48
  ix: InteractionBuilder<R, E, TE>,
49
49
  ): Effect.Effect<
50
- DiscordREST | DiscordGateway | Exclude<R2, DiscordInteraction>,
50
+ never,
51
51
  E2 | DiscordRESTError | Http.error.ResponseError,
52
- never
52
+ DiscordREST | DiscordGateway | Exclude<R2, DiscordInteraction>
53
53
  > =>
54
54
  Effect.gen(function* (_) {
55
55
  const GlobalApplicationCommand = ix.definitions.pipe(
@@ -73,8 +73,7 @@ export const run =
73
73
  const rest = yield* _(DiscordREST)
74
74
 
75
75
  const application = yield* _(
76
- rest.getCurrentBotApplicationInformation(),
77
- Effect.flatMap(a => a.json),
76
+ rest.getCurrentBotApplicationInformation().json,
78
77
  )
79
78
 
80
79
  const globalSync = rest.bulkOverwriteGlobalApplicationCommands(
@@ -84,20 +83,22 @@ export const run =
84
83
  GlobalApplicationCommand.map(_ => _.command),
85
84
  ),
86
85
  },
87
- )
86
+ ).asUnit
88
87
 
89
88
  const guildSync = GuildApplicationCommand.length
90
- ? gateway.handleDispatch("GUILD_CREATE", a =>
91
- rest.bulkOverwriteGuildApplicationCommands(
92
- application.id,
93
- a.id,
94
- GuildApplicationCommand.map(_ => _.command) as any,
95
- ),
89
+ ? gateway.handleDispatch(
90
+ "GUILD_CREATE",
91
+ a =>
92
+ rest.bulkOverwriteGuildApplicationCommands(
93
+ application.id,
94
+ a.id,
95
+ GuildApplicationCommand.map(_ => _.command) as any,
96
+ ).asUnit,
96
97
  )
97
98
  : Effect.never
98
99
 
99
100
  const handle = handlers(ix.definitions, (i, r) =>
100
- rest.createInteractionResponse(i.id, i.token, r),
101
+ rest.createInteractionResponse(i.id, i.token, r).pipe(Effect.scoped),
101
102
  )
102
103
 
103
104
  const run = gateway.handleDispatch("INTERACTION_CREATE", i =>
@@ -160,13 +161,13 @@ const makeRegistry = Effect.gen(function* (_) {
160
161
  export interface InteractionsRegistryService {
161
162
  readonly register: <E>(
162
163
  ix: InteractionBuilder<never, E, never>,
163
- ) => Effect.Effect<never, never, void>
164
+ ) => Effect.Effect<void>
164
165
  }
165
166
  export interface InteractionsRegistry {
166
167
  readonly _: unique symbol
167
168
  }
168
169
 
169
- export const InteractionsRegistry = Tag<
170
+ export const InteractionsRegistry = GenericTag<
170
171
  InteractionsRegistry,
171
172
  InteractionsRegistryService
172
173
  >("dfx/Interactions/InteractionsRegistry")
@@ -13,22 +13,22 @@ export class DefinitionNotFound {
13
13
  }
14
14
 
15
15
  type Handler<R, E, A> = Effect.Effect<
16
- R | Ctx.DiscordInteraction,
16
+ A,
17
17
  E | DefinitionNotFound,
18
- A
18
+ R | Ctx.DiscordInteraction
19
19
  >
20
20
 
21
21
  export const handlers = <R, E, TE, A, B>(
22
22
  definitions: Chunk.Chunk<
23
23
  readonly [
24
24
  handler: D.InteractionDefinition<R, E>,
25
- transform: (self: Effect.Effect<R, E, A>) => Effect.Effect<R, TE, B>,
25
+ transform: (self: Effect.Effect<A, E, R>) => Effect.Effect<B, TE, R>,
26
26
  ]
27
27
  >,
28
28
  handleResponse: (
29
29
  ix: Discord.Interaction,
30
30
  _: Discord.InteractionResponse,
31
- ) => Effect.Effect<R, E, A>,
31
+ ) => Effect.Effect<A, E, R>,
32
32
  ): Record<
33
33
  Discord.InteractionType,
34
34
  (i: Discord.Interaction) => Handler<R, E, B>
@@ -4,16 +4,14 @@ 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
6
 
7
- export type DefinitionFlattened<R, E, TE, A> = D.InteractionDefinition<
8
- R,
9
- E
10
- > extends infer D
11
- ? {
12
- [K in keyof D]: K extends "handle"
13
- ? (_: Discord.Interaction) => Effect.Effect<R, TE, A>
14
- : D[K]
15
- }
16
- : never
7
+ export type DefinitionFlattened<R, E, TE, A> =
8
+ D.InteractionDefinition<R, E> extends infer D
9
+ ? {
10
+ [K in keyof D]: K extends "handle"
11
+ ? (_: Discord.Interaction) => Effect.Effect<A, TE, R>
12
+ : D[K]
13
+ }
14
+ : never
17
15
 
18
16
  export type DefinitionFlattenedCommand<R, E, TE, A> = Extract<
19
17
  DefinitionFlattened<R, E, TE, A>,
@@ -32,13 +30,13 @@ export const flattenDefinitions = <R, E, TE, A, B>(
32
30
  definitions: Chunk.Chunk<
33
31
  readonly [
34
32
  handler: D.InteractionDefinition<R, E>,
35
- transform: (self: Effect.Effect<R, E, A>) => Effect.Effect<R, TE, B>,
33
+ transform: (self: Effect.Effect<A, E, R>) => Effect.Effect<B, TE, R>,
36
34
  ]
37
35
  >,
38
36
  handleResponse: (
39
37
  ix: Discord.Interaction,
40
38
  _: Discord.InteractionResponse,
41
- ) => Effect.Effect<R, E, A>,
39
+ ) => Effect.Effect<A, E, R>,
42
40
  ) =>
43
41
  Chunk.map(definitions, ([definition, transform]) => ({
44
42
  ...definition,
@@ -1,5 +1,5 @@
1
1
  import * as Chunk from "effect/Chunk"
2
- import { Tag } from "effect/Context"
2
+ import { GenericTag } from "effect/Context"
3
3
  import { identity } from "effect/Function"
4
4
  import * as Option from "effect/Option"
5
5
  import type * as Cause from "effect/Cause"
@@ -74,16 +74,17 @@ const makeConfig = ({
74
74
  export interface WebhookConfig {
75
75
  readonly _: unique symbol
76
76
  }
77
- export const WebhookConfig = Tag<WebhookConfig, ReturnType<typeof makeConfig>>(
78
- "dfx/Interactions/WebhookConfig",
79
- )
77
+ export const WebhookConfig = GenericTag<
78
+ WebhookConfig,
79
+ ReturnType<typeof makeConfig>
80
+ >("dfx/Interactions/WebhookConfig")
80
81
 
81
82
  export const layer = (opts: MakeConfigOpts) =>
82
83
  Layer.succeed(WebhookConfig, makeConfig(opts))
83
84
 
84
85
  export const layerConfig: (
85
86
  config: Config.Config<MakeConfigOpts>,
86
- ) => Layer.Layer<never, ConfigError.ConfigError, WebhookConfig> = (
87
+ ) => Layer.Layer<WebhookConfig, ConfigError.ConfigError> = (
87
88
  config: Config.Config<MakeConfigOpts>,
88
89
  ) => Layer.effect(WebhookConfig, Effect.map(config, makeConfig))
89
90
 
@@ -109,23 +110,23 @@ const run = <R, E>(
109
110
  readonly [
110
111
  handler: D.InteractionDefinition<R, E>,
111
112
  transform: (
112
- self: Effect.Effect<R, E, Discord.InteractionResponse>,
113
- ) => Effect.Effect<R, E, Discord.InteractionResponse>,
113
+ self: Effect.Effect<Discord.InteractionResponse, E, R>,
114
+ ) => Effect.Effect<Discord.InteractionResponse, E, R>,
114
115
  ]
115
116
  >,
116
117
  handleResponse: (
117
118
  ix: Discord.Interaction,
118
119
  _: Discord.InteractionResponse,
119
- ) => Effect.Effect<R, E, Discord.InteractionResponse>,
120
+ ) => Effect.Effect<Discord.InteractionResponse, E, R>,
120
121
  ) => {
121
122
  const handler = handlers(definitions, handleResponse)
122
123
  return (
123
124
  headers: Headers,
124
125
  body: string,
125
126
  ): Effect.Effect<
126
- WebhookConfig | Exclude<R, DiscordInteraction>,
127
+ Discord.InteractionResponse,
127
128
  BadWebhookSignature | WebhookParseError | E | DefinitionNotFound,
128
- Discord.InteractionResponse
129
+ WebhookConfig | Exclude<R, DiscordInteraction>
129
130
  > =>
130
131
  Effect.flatMap(fromHeadersAndBody(headers, body), interaction =>
131
132
  Effect.provideService(
@@ -139,8 +140,8 @@ const run = <R, E>(
139
140
  export interface HandleWebhookOpts<E> {
140
141
  headers: Headers
141
142
  body: string
142
- success: (a: Discord.InteractionResponse) => Effect.Effect<never, never, void>
143
- error: (e: Cause.Cause<E>) => Effect.Effect<never, never, void>
143
+ success: (a: Discord.InteractionResponse) => Effect.Effect<void>
144
+ error: (e: Cause.Cause<E>) => Effect.Effect<void>
144
145
  }
145
146
 
146
147
  /**
@@ -155,7 +156,7 @@ export const makeHandler = <R, E, TE>(
155
156
  success,
156
157
  }: HandleWebhookOpts<
157
158
  E | WebhookParseError | BadWebhookSignature | DefinitionNotFound
158
- >) => Effect.Effect<WebhookConfig, never, void>) => {
159
+ >) => Effect.Effect<void, never, WebhookConfig>) => {
159
160
  const handle = run(
160
161
  Chunk.map(ix.definitions, ([d]) => [d, identity] as any),
161
162
  (_i, r) => Effect.succeed(r),
@@ -168,7 +169,7 @@ export const makeHandler = <R, E, TE>(
168
169
  success,
169
170
  }: HandleWebhookOpts<
170
171
  E | WebhookParseError | BadWebhookSignature | DefinitionNotFound
171
- >): Effect.Effect<WebhookConfig, never, void> =>
172
+ >): Effect.Effect<void, never, WebhookConfig> =>
172
173
  handle(headers, body).pipe(
173
174
  Effect.flatMap(success),
174
175
  Effect.catchAllCause(error),
@@ -187,9 +188,9 @@ export const makeSimpleHandler = <R, E, TE>(
187
188
  headers: Headers
188
189
  body: string
189
190
  }) => Effect.Effect<
190
- WebhookConfig,
191
+ Discord.InteractionResponse,
191
192
  BadWebhookSignature | WebhookParseError | DefinitionNotFound,
192
- Discord.InteractionResponse
193
+ WebhookConfig
193
194
  >) => {
194
195
  const handle = run(
195
196
  Chunk.map(ix.definitions, ([d]) => [d, identity] as any),
package/src/RateLimit.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Tag } from "effect/Context"
1
+ import { GenericTag } from "effect/Context"
2
2
  import * as Duration from "effect/Duration"
3
3
  import type * as Option from "effect/Option"
4
4
  import * as Effect from "effect/Effect"
@@ -15,35 +15,35 @@ export type BucketDetails = {
15
15
  export interface RateLimitStoreService {
16
16
  readonly hasBucket: (
17
17
  bucketKey: string,
18
- ) => Effect.Effect<never, never, boolean>
18
+ ) => Effect.Effect<boolean>
19
19
 
20
20
  readonly putBucket: (
21
21
  bucket: BucketDetails,
22
- ) => Effect.Effect<never, never, void>
22
+ ) => Effect.Effect<void>
23
23
 
24
24
  readonly getBucketForRoute: (
25
25
  route: string,
26
- ) => Effect.Effect<never, never, Option.Option<BucketDetails>>
26
+ ) => Effect.Effect<Option.Option<BucketDetails>>
27
27
 
28
28
  readonly putBucketRoute: (
29
29
  route: string,
30
30
  bucketKey: string,
31
- ) => Effect.Effect<never, never, void>
31
+ ) => Effect.Effect<void>
32
32
 
33
33
  readonly incrementCounter: (
34
34
  key: string,
35
35
  window: number,
36
36
  limit: number,
37
- ) => Effect.Effect<never, never, readonly [count: number, ttl: number]>
37
+ ) => Effect.Effect<readonly [count: number, ttl: number]>
38
38
 
39
- readonly removeCounter: (key: string) => Effect.Effect<never, never, void>
39
+ readonly removeCounter: (key: string) => Effect.Effect<void>
40
40
  }
41
41
 
42
42
  export interface RateLimitStore {
43
43
  readonly _: unique symbol
44
44
  }
45
45
 
46
- export const RateLimitStore = Tag<RateLimitStore, RateLimitStoreService>(
46
+ export const RateLimitStore = GenericTag<RateLimitStore, RateLimitStoreService>(
47
47
  "dfx/RateLimit/RateLimitStore",
48
48
  )
49
49
  export const MemoryRateLimitStoreLive = Layer.sync(RateLimitStore, Memory.make)
@@ -84,7 +84,7 @@ const makeLimiter = Effect.gen(function* (_) {
84
84
  export interface RateLimiter {
85
85
  readonly _: unique symbol
86
86
  }
87
- export const RateLimiter = Tag<
87
+ export const RateLimiter = GenericTag<
88
88
  RateLimiter,
89
89
  Effect.Effect.Success<typeof makeLimiter>
90
90
  >("dfx/RateLimit/RateLimiter")
@@ -7,9 +7,9 @@ import * as Queue from "effect/Queue"
7
7
 
8
8
  export const subscribeForEachPar = <R, E, A, X>(
9
9
  self: PubSub.PubSub<A>,
10
- effect: (_: A) => Effect.Effect<R, E, X>,
11
- ): Effect.Effect<R, E, never> =>
12
- Effect.flatMap(Deferred.make<E, never>(), deferred => {
10
+ effect: (_: A) => Effect.Effect<X, E, R>,
11
+ ): Effect.Effect<never, E, R> =>
12
+ Effect.flatMap(Deferred.make<never, E>(), deferred => {
13
13
  const run = pipe(
14
14
  PubSub.subscribe(self),
15
15
  Effect.flatMap(queue =>
@@ -29,15 +29,15 @@ export const subscribeForEachPar = <R, E, A, X>(
29
29
  return Effect.all([run, Deferred.await(deferred)], {
30
30
  concurrency: "unbounded",
31
31
  discard: true,
32
- }) as Effect.Effect<R, E, never>
32
+ }) as Effect.Effect<never, E, R>
33
33
  })
34
34
 
35
35
  export const foreverSwitch = <R, E, A, R1, E1, X>(
36
- self: Effect.Effect<R, E, A>,
37
- f: (_: A) => Effect.Effect<R1, E1, X>,
38
- ): Effect.Effect<R | R1, E | E1, never> =>
36
+ self: Effect.Effect<A, E, R>,
37
+ f: (_: A) => Effect.Effect<X, E1, R1>,
38
+ ): Effect.Effect<never, E | E1, R | R1> =>
39
39
  pipe(
40
- Effect.all([Deferred.make<E1, never>(), Effect.fiberId]),
40
+ Effect.all([Deferred.make<never, E1>(), Effect.fiberId]),
41
41
  Effect.flatMap(([causeDeferred, fiberId]) => {
42
42
  let fiber: Fiber.RuntimeFiber<unknown, unknown> | undefined
43
43
 
@@ -64,6 +64,6 @@ export const foreverSwitch = <R, E, A, R1, E1, X>(
64
64
  return Effect.all([run, Deferred.await(causeDeferred)], {
65
65
  concurrency: "unbounded",
66
66
  discard: true,
67
- }) as Effect.Effect<R | R1, E | E1, never>
67
+ }) as Effect.Effect<never, E | E1, R | R1>
68
68
  }),
69
69
  )
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "0.86.0";
1
+ export const LIB_VERSION = "0.88.0";
package/utils/Effect.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as Effect from "effect/Effect";
2
2
  import * as PubSub from "effect/PubSub";
3
- export declare const subscribeForEachPar: <R, E, A, X>(self: PubSub.PubSub<A>, effect: (_: A) => Effect.Effect<R, E, X>) => Effect.Effect<R, E, never>;
4
- export declare const foreverSwitch: <R, E, A, R1, E1, X>(self: Effect.Effect<R, E, A>, f: (_: A) => Effect.Effect<R1, E1, X>) => Effect.Effect<R | R1, E | E1, never>;
3
+ export declare const subscribeForEachPar: <R, E, A, X>(self: PubSub.PubSub<A>, effect: (_: A) => Effect.Effect<X, E, R>) => Effect.Effect<never, E, R>;
4
+ export declare const foreverSwitch: <R, E, A, R1, E1, X>(self: Effect.Effect<A, E, R>, f: (_: A) => Effect.Effect<X, E1, R1>) => Effect.Effect<never, E | E1, R | R1>;
5
5
  //# sourceMappingURL=Effect.d.ts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const LIB_VERSION = "0.86.0";
1
+ export declare const LIB_VERSION = "0.88.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.86.0";
7
+ const LIB_VERSION = exports.LIB_VERSION = "0.88.0";
8
8
  //# sourceMappingURL=version.js.map
package/webhooks.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import * as Layer from "effect/Layer";
2
2
  export { BadWebhookSignature, WebhookConfig, WebhookParseError, makeHandler, makeSimpleHandler, layer as webhookLayer, layerConfig as webhookLayerConfig, } from "dfx/Interactions/webhook";
3
- export declare const DiscordLive: Layer.Layer<import("./DiscordConfig").DiscordConfig, never, import("dfx/RateLimit").RateLimiter | import("dfx/DiscordREST").DiscordREST>;
3
+ export declare const DiscordLive: Layer.Layer<import("dfx/RateLimit").RateLimiter | import("dfx/DiscordREST").DiscordREST, never, import("./DiscordConfig").DiscordConfig>;
4
4
  //# sourceMappingURL=webhooks.d.ts.map