dfx 0.74.0 → 0.75.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/Cache/prelude.d.ts +4 -3
- package/Cache/prelude.d.ts.map +1 -1
- package/Cache/prelude.js +6 -6
- package/Cache/prelude.js.map +1 -1
- package/Cache.d.ts +5 -6
- package/Cache.d.ts.map +1 -1
- package/Cache.js +20 -18
- package/Cache.js.map +1 -1
- package/DiscordGateway.d.ts +2 -4
- package/DiscordGateway.d.ts.map +1 -1
- package/DiscordGateway.js +7 -4
- package/DiscordGateway.js.map +1 -1
- package/Interactions/gateway.d.ts +2 -4
- package/Interactions/gateway.d.ts.map +1 -1
- package/Interactions/gateway.js +10 -6
- package/Interactions/gateway.js.map +1 -1
- package/gateway.d.ts +2 -3
- package/gateway.d.ts.map +1 -1
- package/gateway.js +5 -6
- package/gateway.js.map +1 -1
- package/mjs/Cache/prelude.mjs +6 -6
- package/mjs/Cache/prelude.mjs.map +1 -1
- package/mjs/Cache.mjs +20 -18
- package/mjs/Cache.mjs.map +1 -1
- package/mjs/DiscordGateway.mjs +7 -4
- package/mjs/DiscordGateway.mjs.map +1 -1
- package/mjs/Interactions/gateway.mjs +9 -6
- package/mjs/Interactions/gateway.mjs.map +1 -1
- package/mjs/gateway.mjs +1 -2
- package/mjs/gateway.mjs.map +1 -1
- package/mjs/version.mjs +1 -1
- package/package.json +2 -2
- package/src/Cache/prelude.ts +92 -92
- package/src/Cache.ts +136 -100
- package/src/DiscordGateway.ts +19 -11
- package/src/Interactions/gateway.ts +40 -40
- package/src/gateway.ts +0 -4
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -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 =
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
pipe(
|
|
138
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
|
|
@@ -43,7 +41,6 @@ export const MemoryBot = Layer.provide(
|
|
|
43
41
|
Layer.mergeAll(
|
|
44
42
|
Layer.provideMerge(LiveDiscordREST, LiveDiscordGateway),
|
|
45
43
|
MemoryRateLimit,
|
|
46
|
-
InteractionsRegistryLive,
|
|
47
44
|
),
|
|
48
45
|
)
|
|
49
46
|
|
|
@@ -54,7 +51,6 @@ export const gatewayLayer = (
|
|
|
54
51
|
ConfigError.ConfigError,
|
|
55
52
|
| RateLimiter
|
|
56
53
|
| Log.Log
|
|
57
|
-
| InteractionsRegistry
|
|
58
54
|
| DiscordREST
|
|
59
55
|
| DiscordGateway
|
|
60
56
|
| DiscordConfig.DiscordConfig
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "0.
|
|
1
|
+
export const LIB_VERSION = "0.75.0";
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "0.
|
|
1
|
+
export declare const LIB_VERSION = "0.75.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED