dfx 0.101.1 → 0.102.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 (43) hide show
  1. package/DiscordGateway/DiscordWS.d.ts +2 -1
  2. package/DiscordGateway/DiscordWS.d.ts.map +1 -1
  3. package/DiscordGateway/DiscordWS.js +11 -6
  4. package/DiscordGateway/DiscordWS.js.map +1 -1
  5. package/DiscordGateway/Messaging.d.ts +3 -3
  6. package/DiscordGateway/Messaging.d.ts.map +1 -1
  7. package/DiscordGateway/Messaging.js +4 -4
  8. package/DiscordGateway/Messaging.js.map +1 -1
  9. package/DiscordGateway/Shard/heartbeats.d.ts +2 -2
  10. package/DiscordGateway/Shard/heartbeats.d.ts.map +1 -1
  11. package/DiscordGateway/Shard/heartbeats.js +2 -3
  12. package/DiscordGateway/Shard/heartbeats.js.map +1 -1
  13. package/DiscordGateway/Shard.d.ts.map +1 -1
  14. package/DiscordGateway/Shard.js +15 -15
  15. package/DiscordGateway/Shard.js.map +1 -1
  16. package/DiscordGateway/Sharder.d.ts +1 -1
  17. package/DiscordGateway.d.ts +1 -1
  18. package/DiscordREST.d.ts +1 -1
  19. package/DiscordREST.js +3 -3
  20. package/DiscordREST.js.map +1 -1
  21. package/gateway.d.ts +2 -2
  22. package/index.d.ts +1 -1
  23. package/mjs/DiscordGateway/DiscordWS.mjs +11 -6
  24. package/mjs/DiscordGateway/DiscordWS.mjs.map +1 -1
  25. package/mjs/DiscordGateway/Messaging.mjs +4 -4
  26. package/mjs/DiscordGateway/Messaging.mjs.map +1 -1
  27. package/mjs/DiscordGateway/Shard/heartbeats.mjs +2 -3
  28. package/mjs/DiscordGateway/Shard/heartbeats.mjs.map +1 -1
  29. package/mjs/DiscordGateway/Shard.mjs +15 -15
  30. package/mjs/DiscordGateway/Shard.mjs.map +1 -1
  31. package/mjs/DiscordREST.mjs +3 -3
  32. package/mjs/DiscordREST.mjs.map +1 -1
  33. package/mjs/version.mjs +1 -1
  34. package/package.json +4 -4
  35. package/src/DiscordGateway/DiscordWS.ts +14 -10
  36. package/src/DiscordGateway/Messaging.ts +6 -6
  37. package/src/DiscordGateway/Shard/heartbeats.ts +5 -5
  38. package/src/DiscordGateway/Shard.ts +26 -23
  39. package/src/DiscordREST.ts +3 -3
  40. package/src/version.ts +1 -1
  41. package/version.d.ts +1 -1
  42. package/version.js +1 -1
  43. package/webhooks.d.ts +1 -1
@@ -20,7 +20,8 @@ import { pipe } from "effect/Function"
20
20
  import * as Layer from "effect/Layer"
21
21
  import * as Option from "effect/Option"
22
22
  import * as PubSub from "effect/PubSub"
23
- import * as Queue from "effect/Queue"
23
+ import * as Mailbox from "effect/Mailbox"
24
+
24
25
  import * as Redacted from "effect/Redacted"
25
26
  import * as Ref from "effect/Ref"
26
27
  import type * as Types from "effect/Types"
@@ -35,13 +36,13 @@ export const make = Effect.gen(function* () {
35
36
  const { gateway, token } = yield* DiscordConfig
36
37
  const limiter = yield* RateLimiter
37
38
  const dws = yield* DiscordWS
38
- const { hub, sendQueue } = yield* Messaging
39
+ const { hub, sendMailbox } = yield* Messaging
39
40
  const shardState = yield* ShardStateStore
40
41
 
41
42
  const connect = (shard: [id: number, count: number]) =>
42
43
  Effect.gen(function* (_) {
43
- const outboundQueue = yield* Queue.unbounded<Message>()
44
- const pendingQueue = yield* Queue.unbounded<Message>()
44
+ const outboundQueue = yield* Mailbox.make<Message>()
45
+ const pendingQueue = yield* Mailbox.make<Message>()
45
46
  const phase = yield* Ref.make(Phase.Connecting)
46
47
  const stateStore = shardState.forShard(shard)
47
48
  const resumeState: Types.Mutable<ShardState> = Option.getOrElse(
@@ -57,39 +58,40 @@ export const make = Effect.gen(function* () {
57
58
  Ref.set(phase, p),
58
59
  Effect.annotateLogs(Effect.logTrace("phase transition"), "phase", p),
59
60
  )
60
- const outbound = Effect.zipLeft(
61
- Queue.take(outboundQueue),
62
- limiter.maybeWait("dfx.shard.send", Duration.minutes(1), 120),
61
+ const outbound = Effect.orDie(
62
+ Effect.zipLeft(
63
+ outboundQueue.take,
64
+ limiter.maybeWait("dfx.shard.send", Duration.minutes(1), 120),
65
+ ),
63
66
  )
64
67
 
65
68
  const send = (p: Message) =>
66
69
  Effect.flatMap(Ref.get(phase), phase =>
67
70
  phase === Phase.Connected
68
- ? Queue.offer(outboundQueue, p)
69
- : Queue.offer(pendingQueue, p),
71
+ ? outboundQueue.offer(p)
72
+ : pendingQueue.offer(p),
70
73
  )
71
74
 
72
75
  const heartbeatSend = (p: Message) =>
73
76
  Effect.flatMap(Ref.get(phase), phase =>
74
77
  phase !== Phase.Connecting
75
- ? Queue.offer(outboundQueue, p)
78
+ ? outboundQueue.offer(p)
76
79
  : Effect.succeed(false),
77
80
  )
78
81
 
79
- const prioritySend = (p: Message) => Queue.offer(outboundQueue, p)
82
+ const prioritySend = (p: Message) => outboundQueue.offer(p)
80
83
 
81
84
  const resume = pipe(
82
85
  setPhase(Phase.Connected),
83
- Effect.zipRight(Queue.takeAll(pendingQueue)),
84
- Effect.tap(_ => Queue.offerAll(outboundQueue, _)),
86
+ Effect.zipRight(pendingQueue.clear),
87
+ Effect.tap(_ => outboundQueue.offerAll(_)),
85
88
  Effect.asVoid,
86
89
  )
87
90
 
88
91
  const onConnecting = pipe(
89
- Queue.takeAll(outboundQueue),
92
+ outboundQueue.clear,
90
93
  Effect.tap(msgs =>
91
- Queue.offerAll(
92
- pendingQueue,
94
+ pendingQueue.offerAll(
93
95
  Chunk.filter(
94
96
  msgs,
95
97
  msg =>
@@ -106,12 +108,12 @@ export const make = Effect.gen(function* () {
106
108
  const socket = yield* dws.connect({ outbound, onConnecting })
107
109
 
108
110
  const hellos = yield* Effect.acquireRelease(
109
- Queue.unbounded<Discord.GatewayPayload>(),
110
- Queue.shutdown,
111
+ Mailbox.make<Discord.GatewayPayload>(),
112
+ _ => _.shutdown,
111
113
  )
112
114
  const acks = yield* Effect.acquireRelease(
113
- Queue.unbounded<Discord.GatewayPayload>(),
114
- Queue.shutdown,
115
+ Mailbox.make<Discord.GatewayPayload>(),
116
+ _ => _.shutdown,
115
117
  )
116
118
 
117
119
  // heartbeats
@@ -157,11 +159,11 @@ export const make = Effect.gen(function* () {
157
159
  return pipe(
158
160
  Effect.tap(identify, prioritySend),
159
161
  Effect.zipRight(setPhase(Phase.Handshake)),
160
- Effect.zipRight(Queue.offer(hellos, p)),
162
+ Effect.zipRight(hellos.offer(p)),
161
163
  )
162
164
  }
163
165
  case Discord.GatewayOpcode.HEARTBEAT_ACK: {
164
- return Queue.offer(acks, p)
166
+ return acks.offer(p)
165
167
  }
166
168
  case Discord.GatewayOpcode.INVALID_SESSION: {
167
169
  if (p.d) {
@@ -186,7 +188,7 @@ export const make = Effect.gen(function* () {
186
188
  }),
187
189
  )
188
190
 
189
- yield* Queue.take(sendQueue).pipe(
191
+ yield* sendMailbox.take.pipe(
190
192
  Effect.tap(send),
191
193
  Effect.forever,
192
194
  Effect.forkScoped,
@@ -224,5 +226,6 @@ export const ShardLive = Layer.effect(Shard, make).pipe(
224
226
  Layer.provide(RateLimiterLive),
225
227
  )
226
228
 
229
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
227
230
  export interface RunningShard
228
231
  extends Effect.Effect.Success<ReturnType<ShardService["connect"]>> {}
@@ -147,7 +147,7 @@ const make = Effect.gen(function* () {
147
147
  Effect.ignore,
148
148
  )
149
149
 
150
- const httpExecutor = pipe(
150
+ const httpClient = pipe(
151
151
  HttpClient.filterStatusOk(http),
152
152
  HttpClient.mapRequest(req =>
153
153
  pipe(
@@ -176,7 +176,7 @@ const make = Effect.gen(function* () {
176
176
  requestRateLimit(request.url, request).pipe(
177
177
  Effect.zipLeft(globalRateLimit),
178
178
  Effect.zipRight(
179
- httpExecutor(request) as Effect.Effect<
179
+ httpClient.execute(request) as Effect.Effect<
180
180
  ResponseWithData<A>,
181
181
  DiscordRESTError,
182
182
  Scope
@@ -257,7 +257,7 @@ const make = Effect.gen(function* () {
257
257
  } else if (params && request.body._tag === "FormData") {
258
258
  request.body.formData.append("payload_json", JSON.stringify(params))
259
259
  } else if (params) {
260
- request = HttpRequest.unsafeJsonBody(request, params)
260
+ request = HttpRequest.bodyUnsafeJson(request, params)
261
261
  }
262
262
 
263
263
  return new RestResponseImpl(executor(request))
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "0.101.1";
1
+ export const LIB_VERSION = "0.102.0";
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const LIB_VERSION = "0.101.1";
1
+ export declare const LIB_VERSION = "0.102.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.101.1";
7
+ const LIB_VERSION = exports.LIB_VERSION = "0.102.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("dfx/DiscordREST").DiscordREST | import("dfx/RateLimit").RateLimiter, never, import("./DiscordConfig").DiscordConfig | import("@effect/platform/HttpClient").HttpClient.Default>;
3
+ export declare const DiscordLive: Layer.Layer<import("dfx/DiscordREST").DiscordREST | import("dfx/RateLimit").RateLimiter, never, import("./DiscordConfig").DiscordConfig | import("@effect/platform/HttpClient").HttpClient.Service>;
4
4
  //# sourceMappingURL=webhooks.d.ts.map