dfx 0.74.0 → 0.76.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 (85) hide show
  1. package/Cache/prelude.d.ts +4 -3
  2. package/Cache/prelude.d.ts.map +1 -1
  3. package/Cache/prelude.js +6 -6
  4. package/Cache/prelude.js.map +1 -1
  5. package/Cache.d.ts +5 -6
  6. package/Cache.d.ts.map +1 -1
  7. package/Cache.js +20 -18
  8. package/Cache.js.map +1 -1
  9. package/DiscordGateway/DiscordWS.js +1 -1
  10. package/DiscordGateway/DiscordWS.js.map +1 -1
  11. package/DiscordGateway/Shard.d.ts +2 -2
  12. package/DiscordGateway/Shard.js +1 -1
  13. package/DiscordGateway/Shard.js.map +1 -1
  14. package/DiscordGateway/Sharder.js +1 -1
  15. package/DiscordGateway/Sharder.js.map +1 -1
  16. package/DiscordGateway/WS.d.ts +0 -1
  17. package/DiscordGateway/WS.d.ts.map +1 -1
  18. package/DiscordGateway.d.ts +1 -3
  19. package/DiscordGateway.d.ts.map +1 -1
  20. package/DiscordGateway.js +7 -4
  21. package/DiscordGateway.js.map +1 -1
  22. package/DiscordREST.js +1 -1
  23. package/DiscordREST.js.map +1 -1
  24. package/Helpers/interactions.js +1 -1
  25. package/Helpers/interactions.js.map +1 -1
  26. package/Helpers/permissions.d.ts +2 -2
  27. package/Helpers/permissions.d.ts.map +1 -1
  28. package/Interactions/context.d.ts +1 -1
  29. package/Interactions/definitions.d.ts +3 -3
  30. package/Interactions/gateway.d.ts +1 -3
  31. package/Interactions/gateway.d.ts.map +1 -1
  32. package/Interactions/gateway.js +10 -6
  33. package/Interactions/gateway.js.map +1 -1
  34. package/RateLimit.d.ts +2 -2
  35. package/gateway.d.ts +2 -3
  36. package/gateway.d.ts.map +1 -1
  37. package/gateway.js +7 -8
  38. package/gateway.js.map +1 -1
  39. package/mjs/Cache/prelude.mjs +6 -6
  40. package/mjs/Cache/prelude.mjs.map +1 -1
  41. package/mjs/Cache.mjs +20 -18
  42. package/mjs/Cache.mjs.map +1 -1
  43. package/mjs/DiscordGateway/DiscordWS.mjs +1 -1
  44. package/mjs/DiscordGateway/DiscordWS.mjs.map +1 -1
  45. package/mjs/DiscordGateway/Shard.mjs +1 -1
  46. package/mjs/DiscordGateway/Shard.mjs.map +1 -1
  47. package/mjs/DiscordGateway/Sharder.mjs +1 -1
  48. package/mjs/DiscordGateway/Sharder.mjs.map +1 -1
  49. package/mjs/DiscordGateway.mjs +7 -4
  50. package/mjs/DiscordGateway.mjs.map +1 -1
  51. package/mjs/DiscordREST.mjs +1 -1
  52. package/mjs/DiscordREST.mjs.map +1 -1
  53. package/mjs/Helpers/interactions.mjs +1 -1
  54. package/mjs/Helpers/interactions.mjs.map +1 -1
  55. package/mjs/Interactions/gateway.mjs +9 -6
  56. package/mjs/Interactions/gateway.mjs.map +1 -1
  57. package/mjs/gateway.mjs +3 -4
  58. package/mjs/gateway.mjs.map +1 -1
  59. package/mjs/types.mjs +6 -2
  60. package/mjs/types.mjs.map +1 -1
  61. package/mjs/version.mjs +1 -1
  62. package/mjs/webhooks.mjs +3 -3
  63. package/mjs/webhooks.mjs.map +1 -1
  64. package/package.json +4 -4
  65. package/src/Cache/prelude.ts +92 -92
  66. package/src/Cache.ts +136 -100
  67. package/src/DiscordGateway/DiscordWS.ts +1 -1
  68. package/src/DiscordGateway/Shard.ts +1 -1
  69. package/src/DiscordGateway/Sharder.ts +1 -1
  70. package/src/DiscordGateway.ts +19 -11
  71. package/src/DiscordREST.ts +2 -2
  72. package/src/Helpers/interactions.ts +1 -1
  73. package/src/Interactions/gateway.ts +40 -40
  74. package/src/gateway.ts +10 -16
  75. package/src/types.ts +28 -18
  76. package/src/version.ts +1 -1
  77. package/src/webhooks.ts +3 -3
  78. package/types.d.ts +28 -18
  79. package/types.d.ts.map +1 -1
  80. package/types.js +6 -2
  81. package/types.js.map +1 -1
  82. package/version.d.ts +1 -1
  83. package/version.js +1 -1
  84. package/webhooks.js +3 -3
  85. package/webhooks.js.map +1 -1
package/src/Cache.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import * as Option from "effect/Option"
2
+ import * as Schedule from "effect/Schedule"
3
+ import type * as Scope from "effect/Scope"
2
4
  import * as Effect from "effect/Effect"
3
5
  import * as Stream from "effect/Stream"
4
6
  import type { CacheDriver, ParentCacheDriver } from "dfx/Cache/driver"
@@ -24,7 +26,11 @@ export type CacheOp<T> =
24
26
  | { op: "update"; resourceId: string; resource: T }
25
27
  | { op: "delete"; resourceId: string }
26
28
 
27
- export interface ParentCache<EOps, EDriver, EMiss, EPMiss, A> {
29
+ const retryPolicy = Schedule.exponential("500 millis").pipe(
30
+ Schedule.union(Schedule.spaced("10 seconds")),
31
+ )
32
+
33
+ export interface ParentCache<EDriver, EMiss, EPMiss, A> {
28
34
  readonly get: (
29
35
  parentId: string,
30
36
  id: string,
@@ -38,7 +44,6 @@ export interface ParentCache<EOps, EDriver, EMiss, EPMiss, A> {
38
44
  readonly getForParent: (
39
45
  parentId: string,
40
46
  ) => Effect.Effect<never, EDriver | EPMiss, ReadonlyMap<string, A>>
41
- readonly run: Effect.Effect<never, EOps | EDriver, void>
42
47
  readonly size: Effect.Effect<never, EDriver, number>
43
48
  readonly sizeForParent: (
44
49
  parentId: string,
@@ -77,86 +82,101 @@ export const makeWithParent = <EOps, EDriver, EMiss, EPMiss, A>({
77
82
  onParentMiss: (
78
83
  parentId: string,
79
84
  ) => Effect.Effect<never, EPMiss, Array<[id: string, resource: A]>>
80
- }): ParentCache<EOps, EDriver, EMiss, EPMiss, A> => {
81
- const sync = Stream.runDrain(
82
- Stream.tap(ops, (op): Effect.Effect<never, EDriver, void> => {
83
- switch (op.op) {
84
- case "create":
85
- case "update":
86
- return driver.set(op.parentId, op.resourceId, op.resource)
87
-
88
- case "delete":
89
- return driver.delete(op.parentId, op.resourceId)
90
-
91
- case "parentDelete":
92
- return driver.parentDelete(op.parentId)
93
- }
94
- }),
95
- )
85
+ }): Effect.Effect<Scope.Scope, never, ParentCache<EDriver, EMiss, EPMiss, A>> =>
86
+ Effect.gen(function* (_) {
87
+ yield* _(
88
+ Stream.runDrain(
89
+ Stream.tap(ops, (op): Effect.Effect<never, EDriver, void> => {
90
+ switch (op.op) {
91
+ case "create":
92
+ case "update":
93
+ return driver.set(op.parentId, op.resourceId, op.resource)
96
94
 
97
- const get = (parentId: string, id: string) =>
98
- Effect.flatMap(
99
- driver.get(parentId, id),
100
- Option.match({
101
- onNone: () =>
102
- Effect.tap(onMiss(parentId, id), a => driver.set(parentId, id, a)),
103
- onSome: Effect.succeed,
104
- }),
105
- )
106
-
107
- const put = (_: A) =>
108
- Effect.flatMap(id(_), ([parentId, id]) => driver.set(parentId, id, _))
95
+ case "delete":
96
+ return driver.delete(op.parentId, op.resourceId)
109
97
 
110
- const update = <R, E>(
111
- parentId: string,
112
- id: string,
113
- f: (_: A) => Effect.Effect<R, E, A>,
114
- ) =>
115
- get(parentId, id).pipe(
116
- Effect.flatMap(f),
117
- Effect.tap(_ => driver.set(parentId, id, _)),
98
+ case "parentDelete":
99
+ return driver.parentDelete(op.parentId)
100
+ }
101
+ }),
102
+ ),
103
+ Effect.tapErrorCause(_ => Effect.logError("ops error, restarting", _)),
104
+ Effect.retry(retryPolicy),
105
+ Effect.forkScoped,
106
+ )
107
+ yield* _(
108
+ driver.run,
109
+ Effect.tapErrorCause(_ =>
110
+ Effect.logError("cache driver error, restarting", _),
111
+ ),
112
+ Effect.retry(retryPolicy),
113
+ Effect.forkScoped,
118
114
  )
119
115
 
120
- return {
121
- ...driver,
122
-
123
- get,
124
- put,
125
- update,
126
-
127
- getForParent: (parentId: string) =>
116
+ const get = (parentId: string, id: string) =>
128
117
  Effect.flatMap(
129
- driver.getForParent(parentId),
118
+ driver.get(parentId, id),
130
119
  Option.match({
131
120
  onNone: () =>
132
- onParentMiss(parentId).pipe(
133
- Effect.tap(entries =>
134
- Effect.all(
135
- entries.map(([id, a]) => driver.set(parentId, id, a)),
136
- { concurrency: "unbounded" },
137
- ),
138
- ),
139
- Effect.map(entries => new Map(entries) as ReadonlyMap<string, A>),
140
- ),
121
+ Effect.tap(onMiss(parentId, id), a => driver.set(parentId, id, a)),
141
122
  onSome: Effect.succeed,
142
123
  }),
143
- ),
124
+ )
125
+
126
+ const put = (_: A) =>
127
+ Effect.flatMap(id(_), ([parentId, id]) => driver.set(parentId, id, _))
128
+
129
+ const update = <R, E>(
130
+ parentId: string,
131
+ id: string,
132
+ f: (_: A) => Effect.Effect<R, E, A>,
133
+ ) =>
134
+ get(parentId, id).pipe(
135
+ Effect.flatMap(f),
136
+ Effect.tap(_ => driver.set(parentId, id, _)),
137
+ )
138
+
139
+ return {
140
+ ...driver,
141
+
142
+ get,
143
+ put,
144
+ update,
144
145
 
145
- run: Effect.all([sync, driver.run], {
146
- concurrency: "unbounded",
147
- discard: true,
146
+ getForParent: (parentId: string) =>
147
+ Effect.flatMap(
148
+ driver.getForParent(parentId),
149
+ Option.match({
150
+ onNone: () =>
151
+ onParentMiss(parentId).pipe(
152
+ Effect.tap(entries =>
153
+ Effect.all(
154
+ entries.map(([id, a]) => driver.set(parentId, id, a)),
155
+ { concurrency: "unbounded" },
156
+ ),
157
+ ),
158
+ Effect.map(
159
+ entries => new Map(entries) as ReadonlyMap<string, A>,
160
+ ),
161
+ ),
162
+ onSome: Effect.succeed,
163
+ }),
164
+ ),
165
+ } as const
166
+ }).pipe(
167
+ Effect.annotateLogs({
168
+ package: "dfx",
169
+ service: "Cache",
148
170
  }),
149
- } as const
150
- }
171
+ )
151
172
 
152
- export interface Cache<EOps, EDriver, EMiss, A> {
173
+ export interface Cache<EDriver, EMiss, A> {
153
174
  readonly get: (id: string) => Effect.Effect<never, EDriver | EMiss, A>
154
175
  readonly put: (_: A) => Effect.Effect<never, EDriver, void>
155
176
  readonly update: <R, E>(
156
177
  id: string,
157
178
  f: (_: A) => Effect.Effect<R, E, A>,
158
179
  ) => Effect.Effect<R, EDriver | EMiss | E, A>
159
- readonly run: Effect.Effect<never, EOps | EDriver, void>
160
180
  readonly size: Effect.Effect<never, EDriver, number>
161
181
  readonly set: (
162
182
  resourceId: string,
@@ -178,48 +198,64 @@ export const make = <EOps, EDriver, EMiss, A>({
178
198
  ops?: Stream.Stream<never, EOps, CacheOp<A>>
179
199
  id: (_: A) => string
180
200
  onMiss: (id: string) => Effect.Effect<never, EMiss, A>
181
- }): Cache<EOps, EDriver, EMiss, A> => {
182
- const sync = Stream.runDrain(
183
- Stream.tap(ops, (op): Effect.Effect<never, EDriver, void> => {
184
- switch (op.op) {
185
- case "create":
186
- case "update":
187
- return driver.set(op.resourceId, op.resource)
188
-
189
- case "delete":
190
- return driver.delete(op.resourceId)
191
- }
192
- }),
193
- )
201
+ }): Effect.Effect<Scope.Scope, never, Cache<EDriver, EMiss, A>> =>
202
+ Effect.gen(function* (_) {
203
+ yield* _(
204
+ Stream.runDrain(
205
+ Stream.tap(ops, (op): Effect.Effect<never, EDriver, void> => {
206
+ switch (op.op) {
207
+ case "create":
208
+ case "update":
209
+ return driver.set(op.resourceId, op.resource)
194
210
 
195
- const get = (id: string) =>
196
- Effect.flatMap(
197
- driver.get(id),
198
- Option.match({
199
- onNone: () => Effect.tap(onMiss(id), a => driver.set(id, a)),
200
- onSome: Effect.succeed,
201
- }),
211
+ case "delete":
212
+ return driver.delete(op.resourceId)
213
+ }
214
+ }),
215
+ ),
216
+ Effect.tapErrorCause(_ => Effect.logError("ops error, restarting", _)),
217
+ Effect.retry(retryPolicy),
218
+ Effect.forkScoped,
202
219
  )
203
220
 
204
- const put = (_: A) => driver.set(id(_), _)
205
-
206
- const update = <R, E>(id: string, f: (_: A) => Effect.Effect<R, E, A>) =>
207
- get(id).pipe(
208
- Effect.flatMap(f),
209
- Effect.tap(_ => driver.set(id, _)),
221
+ yield* _(
222
+ driver.run,
223
+ Effect.tapErrorCause(_ =>
224
+ Effect.logError("cache driver error, restarting", _),
225
+ ),
226
+ Effect.retry(retryPolicy),
227
+ Effect.forkScoped,
210
228
  )
211
229
 
212
- return {
213
- ...driver,
214
- get,
215
- put,
216
- update,
217
- run: Effect.all([sync, driver.run], {
218
- concurrency: "unbounded",
219
- discard: true,
230
+ const get = (id: string) =>
231
+ Effect.flatMap(
232
+ driver.get(id),
233
+ Option.match({
234
+ onNone: () => Effect.tap(onMiss(id), a => driver.set(id, a)),
235
+ onSome: Effect.succeed,
236
+ }),
237
+ )
238
+
239
+ const put = (_: A) => driver.set(id(_), _)
240
+
241
+ const update = <R, E>(id: string, f: (_: A) => Effect.Effect<R, E, A>) =>
242
+ get(id).pipe(
243
+ Effect.flatMap(f),
244
+ Effect.tap(_ => driver.set(id, _)),
245
+ )
246
+
247
+ return {
248
+ ...driver,
249
+ get,
250
+ put,
251
+ update,
252
+ } as const
253
+ }).pipe(
254
+ Effect.annotateLogs({
255
+ package: "dfx",
256
+ service: "Cache",
220
257
  }),
221
- } as const
222
- }
258
+ )
223
259
 
224
260
  export class CacheMissError {
225
261
  readonly _tag = "CacheMissError"
@@ -70,6 +70,6 @@ const make = Effect.gen(function* (_) {
70
70
  export interface DiscordWS extends Effect.Effect.Success<typeof make> {}
71
71
  export const DiscordWS = Tag<DiscordWS>()
72
72
  export const LiveDiscordWS = Layer.provide(
73
- LiveWS,
74
73
  Layer.effect(DiscordWS, make),
74
+ LiveWS,
75
75
  )
@@ -192,8 +192,8 @@ export const make = Effect.gen(function* (_) {
192
192
  export interface Shard extends Effect.Effect.Success<typeof make> {}
193
193
  export const Shard = Tag<Shard>()
194
194
  export const LiveShard = Layer.provide(
195
- Layer.merge(LiveDiscordWS, LiveRateLimiter),
196
195
  Layer.effect(Shard, make),
196
+ Layer.merge(LiveDiscordWS, LiveRateLimiter),
197
197
  )
198
198
 
199
199
  export interface RunningShard
@@ -135,6 +135,6 @@ const make = Effect.gen(function* (_) {
135
135
  export interface Sharder extends Effect.Effect.Success<typeof make> {}
136
136
  export const Sharder = Tag<Sharder>()
137
137
  export const LiveSharder = Layer.provide(
138
- Layer.merge(LiveRateLimiter, LiveShard),
139
138
  Layer.effect(Sharder, make),
139
+ Layer.merge(LiveRateLimiter, LiveShard),
140
140
  )
@@ -7,9 +7,9 @@ import * as Queue from "effect/Queue"
7
7
  import * as Stream from "effect/Stream"
8
8
  import type { RunningShard } from "dfx/DiscordGateway/Shard"
9
9
  import { LiveSharder, Sharder } from "dfx/DiscordGateway/Sharder"
10
- import type { WebSocketCloseError, WebSocketError } from "dfx/DiscordGateway/WS"
11
10
  import type * as Discord from "dfx/types"
12
11
  import * as EffectUtils from "dfx/utils/Effect"
12
+ import * as Schedule from "effect/Schedule"
13
13
 
14
14
  const fromDispatchFactory =
15
15
  <R, E>(
@@ -33,15 +33,10 @@ const handleDispatchFactory =
33
33
  if (_.t === event) {
34
34
  return handle(_.d as any)
35
35
  }
36
- return Effect.unit
36
+ return Effect.unit as any
37
37
  })
38
38
 
39
39
  export interface DiscordGateway {
40
- readonly run: Effect.Effect<
41
- never,
42
- WebSocketError | WebSocketCloseError,
43
- never
44
- >
45
40
  readonly dispatch: Stream.Stream<
46
41
  never,
47
42
  never,
@@ -77,19 +72,32 @@ export const make = Effect.gen(function* (_) {
77
72
  const fromDispatch = fromDispatchFactory(dispatch)
78
73
  const handleDispatch = handleDispatchFactory(hub)
79
74
 
80
- const run = sharder.run(hub, sendQueue)
75
+ yield* _(
76
+ sharder.run(hub, sendQueue),
77
+ Effect.tapErrorCause(_ => Effect.logError("fatal error, restarting", _)),
78
+ Effect.retry(
79
+ Schedule.exponential("1 seconds").pipe(
80
+ Schedule.union(Schedule.spaced("30 seconds")),
81
+ ),
82
+ ),
83
+ Effect.forkScoped,
84
+ )
81
85
 
82
86
  return DiscordGateway.of({
83
- run,
84
87
  dispatch,
85
88
  fromDispatch,
86
89
  handleDispatch,
87
90
  send,
88
91
  shards: sharder.shards,
89
92
  })
90
- })
93
+ }).pipe(
94
+ Effect.annotateLogs({
95
+ package: "dfx",
96
+ service: "DiscordGateway",
97
+ }),
98
+ )
91
99
 
92
100
  export const LiveDiscordGateway = Layer.provide(
101
+ Layer.scoped(DiscordGateway, make),
93
102
  LiveSharder,
94
- Layer.effect(DiscordGateway, make),
95
103
  )
@@ -255,6 +255,6 @@ export interface DiscordREST
255
255
 
256
256
  export const DiscordREST = Tag<DiscordREST>()
257
257
  export const LiveDiscordREST = Layer.effect(DiscordREST, make).pipe(
258
- Layer.use(LiveRateLimiter),
259
- Layer.use(Http.client.layer),
258
+ Layer.provide(LiveRateLimiter),
259
+ Layer.provide(Http.client.layer),
260
260
  )
@@ -151,7 +151,7 @@ export const resolveValues =
151
151
  ),
152
152
  Option.bind("r", () => resolved(a)),
153
153
  Option.map(({ r, values }) =>
154
- Arr.compact(values.map(a => Option.fromNullable(f(a as any, r)))),
154
+ Arr.getSomes(values.map(a => Option.fromNullable(f(a as any, r)))),
155
155
  ),
156
156
  )
157
157
 
@@ -2,7 +2,6 @@ import * as Chunk from "effect/Chunk"
2
2
  import { Tag } from "effect/Context"
3
3
  import * as Duration from "effect/Duration"
4
4
  import { pipe } from "effect/Function"
5
- import type { Cause } from "effect/Cause"
6
5
  import * as Effect from "effect/Effect"
7
6
  import * as Layer from "effect/Layer"
8
7
  import * as Queue from "effect/Queue"
@@ -21,6 +20,7 @@ import type { InteractionBuilder } from "dfx/Interactions/index"
21
20
  import { builder, Interaction } from "dfx/Interactions/index"
22
21
  import type * as Discord from "dfx/types"
23
22
  import * as EffectUtils from "dfx/utils/Effect"
23
+ import * as Schedule from "effect/Schedule"
24
24
 
25
25
  export interface RunOpts {
26
26
  sync?: boolean
@@ -112,55 +112,55 @@ export const run =
112
112
  )
113
113
  })
114
114
 
115
- const makeRegistry = Effect.gen(function* (_) {
116
- const ref = yield* _(
117
- Ref.make(builder as InteractionBuilder<never, never, never>),
118
- )
119
- const queue = yield* _(
120
- Queue.sliding<InteractionBuilder<never, never, never>>(1),
121
- )
122
-
123
- const register = <E>(ix: InteractionBuilder<never, E, never>) =>
124
- Effect.flatMap(
125
- Ref.updateAndGet(ref, _ => _.concat(ix as any)),
126
- _ => Queue.offer(queue, _),
115
+ const makeRegistry = (options?: RunOpts) =>
116
+ Effect.gen(function* (_) {
117
+ const ref = yield* _(
118
+ Ref.make(builder as InteractionBuilder<never, never, never>),
119
+ )
120
+ const queue = yield* _(
121
+ Queue.sliding<InteractionBuilder<never, never, never>>(1),
127
122
  )
128
123
 
129
- const run_ = <R, E>(
130
- onError: (
131
- _: Cause<DiscordRESTError | DefinitionNotFound>,
132
- ) => Effect.Effect<R, E, void>,
133
- opts?: RunOpts,
134
- ) =>
135
- EffectUtils.foreverSwitch(Queue.take(queue), ix =>
136
- Effect.delay(
137
- pipe(ix, run(Effect.catchAllCause(onError), opts)),
138
- Duration.seconds(0.1),
124
+ const register = <E>(ix: InteractionBuilder<never, E, never>) =>
125
+ Effect.flatMap(
126
+ Ref.updateAndGet(ref, _ => _.concat(ix as any)),
127
+ _ => Queue.offer(queue, _),
128
+ )
129
+
130
+ yield* _(
131
+ EffectUtils.foreverSwitch(Queue.take(queue), ix =>
132
+ pipe(
133
+ ix,
134
+ run(
135
+ Effect.catchAllCause(_ => Effect.logError("unhandled error", _)),
136
+ options,
137
+ ),
138
+ Effect.delay(Duration.seconds(0.1)),
139
+ ),
140
+ ),
141
+ Effect.tapErrorCause(_ => Effect.logError("registry error", _)),
142
+ Effect.retry(
143
+ Schedule.exponential("1 seconds").pipe(
144
+ Schedule.union(Schedule.spaced("20 seconds")),
145
+ ),
139
146
  ),
147
+ Effect.forkScoped,
140
148
  )
141
149
 
142
- return { register, run: run_ } as const
143
- })
150
+ return { register } as const
151
+ }).pipe(
152
+ Effect.annotateLogs({
153
+ package: "dfx",
154
+ service: "InteractionsRegistry",
155
+ }),
156
+ )
144
157
 
145
158
  export interface InteractionsRegistry {
146
159
  readonly register: <E>(
147
160
  ix: InteractionBuilder<never, E, never>,
148
161
  ) => Effect.Effect<never, never, void>
149
-
150
- readonly run: <R, E>(
151
- onError: (
152
- _: Cause<DiscordRESTError | DefinitionNotFound>,
153
- ) => Effect.Effect<R, E, void>,
154
- opts?: RunOpts,
155
- ) => Effect.Effect<
156
- DiscordREST | DiscordGateway | Exclude<R, Discord.Interaction>,
157
- DiscordRESTError | Http.error.ResponseError | E,
158
- never
159
- >
160
162
  }
161
163
 
162
164
  export const InteractionsRegistry = Tag<InteractionsRegistry>()
163
- export const InteractionsRegistryLive = Layer.effect(
164
- InteractionsRegistry,
165
- makeRegistry,
166
- )
165
+ export const InteractionsRegistryLive = (options?: RunOpts) =>
166
+ Layer.scoped(InteractionsRegistry, makeRegistry(options))
package/src/gateway.ts CHANGED
@@ -14,8 +14,6 @@ import * as SendEvent from "dfx/DiscordGateway/Shard/sendEvents"
14
14
  import * as ShardStore from "dfx/DiscordGateway/ShardStore"
15
15
  import { LiveMemoryShardStore } from "dfx/DiscordGateway/ShardStore"
16
16
  import * as WS from "dfx/DiscordGateway/WS"
17
- import { InteractionsRegistryLive } from "dfx/gateway"
18
- import type { InteractionsRegistry } from "dfx/gateway"
19
17
  import type { RateLimiter } from "dfx/RateLimit"
20
18
  import { LiveMemoryRateLimitStore, LiveRateLimiter } from "dfx/RateLimit"
21
19
 
@@ -30,21 +28,18 @@ export {
30
28
  export { CachePrelude, DiscordWS, SendEvent, Shard, ShardStore, WS }
31
29
 
32
30
  export const MemoryRateLimit = Layer.provide(
33
- LiveMemoryRateLimitStore,
34
31
  LiveRateLimiter,
32
+ LiveMemoryRateLimitStore,
35
33
  )
36
34
 
37
- export const MemoryBot = Layer.provide(
38
- Layer.mergeAll(
39
- LiveMemoryShardStore,
40
- LiveMemoryRateLimitStore,
41
- LiveJsonDiscordWSCodec,
42
- ),
43
- Layer.mergeAll(
44
- Layer.provideMerge(LiveDiscordREST, LiveDiscordGateway),
45
- MemoryRateLimit,
46
- InteractionsRegistryLive,
47
- ),
35
+ export const MemoryBot = Layer.mergeAll(
36
+ MemoryRateLimit,
37
+ LiveDiscordGateway,
38
+ ).pipe(
39
+ Layer.provideMerge(LiveDiscordREST),
40
+ Layer.provide(LiveJsonDiscordWSCodec),
41
+ Layer.provide(LiveMemoryRateLimitStore),
42
+ Layer.provide(LiveMemoryShardStore),
48
43
  )
49
44
 
50
45
  export const gatewayLayer = (
@@ -54,7 +49,6 @@ export const gatewayLayer = (
54
49
  ConfigError.ConfigError,
55
50
  | RateLimiter
56
51
  | Log.Log
57
- | InteractionsRegistry
58
52
  | DiscordREST
59
53
  | DiscordGateway
60
54
  | DiscordConfig.DiscordConfig
@@ -65,7 +59,7 @@ export const gatewayLayer = (
65
59
  Effect.map(config => {
66
60
  const LiveLog = config.debug ? Log.LiveLogDebug : Log.LiveLog
67
61
  const LiveConfig = Layer.succeed(DiscordConfig.DiscordConfig, config)
68
- return Layer.provideMerge(Layer.merge(LiveLog, LiveConfig), MemoryBot)
62
+ return Layer.provideMerge(MemoryBot, Layer.merge(LiveLog, LiveConfig))
69
63
  }),
70
64
  ),
71
65
  )