dfx 0.21.22 → 0.22.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/memory.d.ts +2 -2
- package/Cache/memoryTTL.d.ts +2 -2
- package/Cache/memoryTTL.js +11 -11
- package/Cache/memoryTTL.js.map +1 -1
- package/Cache/prelude.d.ts +5 -5
- package/Cache/prelude.js +52 -52
- package/Cache/prelude.js.map +1 -1
- package/Cache.d.ts +69 -0
- package/{Cache/index.js → Cache.js} +15 -15
- package/Cache.js.map +1 -0
- package/{DiscordConfig/index.d.ts → DiscordConfig.d.ts} +3 -3
- package/{DiscordConfig/index.js → DiscordConfig.js} +2 -2
- package/DiscordConfig.js.map +1 -0
- package/DiscordGateway/{DiscordWS/index.d.ts → DiscordWS.d.ts} +5 -5
- package/DiscordGateway/{DiscordWS/index.js → DiscordWS.js} +9 -9
- package/DiscordGateway/DiscordWS.js.map +1 -0
- package/DiscordGateway/Shard/heartbeats.d.ts +1 -1
- package/DiscordGateway/Shard/heartbeats.js +7 -7
- package/DiscordGateway/Shard/heartbeats.js.map +1 -1
- package/DiscordGateway/Shard/identify.d.ts +1 -1
- package/DiscordGateway/Shard/identify.js +3 -3
- package/DiscordGateway/Shard/identify.js.map +1 -1
- package/DiscordGateway/Shard/invalidSession.d.ts +1 -1
- package/DiscordGateway/Shard/invalidSession.js +1 -1
- package/DiscordGateway/Shard/invalidSession.js.map +1 -1
- package/DiscordGateway/Shard/utils.d.ts +2 -2
- package/DiscordGateway/Shard/utils.js +3 -3
- package/DiscordGateway/Shard/utils.js.map +1 -1
- package/DiscordGateway/Shard.d.ts +9 -0
- package/DiscordGateway/Shard.js +44 -0
- package/DiscordGateway/Shard.js.map +1 -0
- package/DiscordGateway/{ShardStore/index.d.ts → ShardStore.d.ts} +2 -2
- package/DiscordGateway/{ShardStore/index.js → ShardStore.js} +1 -1
- package/DiscordGateway/ShardStore.js.map +1 -0
- package/DiscordGateway/Sharder.d.ts +16 -0
- package/DiscordGateway/Sharder.js +42 -0
- package/DiscordGateway/Sharder.js.map +1 -0
- package/DiscordGateway/{WS/index.d.ts → WS.d.ts} +1 -1
- package/DiscordGateway/{WS/index.js → WS.js} +10 -10
- package/DiscordGateway/WS.js.map +1 -0
- package/DiscordGateway.d.ts +12 -0
- package/DiscordGateway.js +20 -0
- package/DiscordGateway.js.map +1 -0
- package/DiscordREST/types.d.ts +5 -7
- package/DiscordREST/utils.d.ts +1 -1
- package/DiscordREST/utils.js +3 -4
- package/DiscordREST/utils.js.map +1 -1
- package/DiscordREST.d.ts +194 -0
- package/DiscordREST.js +120 -0
- package/DiscordREST.js.map +1 -0
- package/Helpers/interactions.js +10 -10
- package/Helpers/interactions.js.map +1 -1
- package/Helpers/permissions.d.ts +2 -2
- package/Helpers/permissions.js +4 -4
- package/Helpers/permissions.js.map +1 -1
- package/Interactions/context.d.ts +6 -6
- package/Interactions/context.js +6 -6
- package/Interactions/context.js.map +1 -1
- package/Interactions/gateway.d.ts +4 -2
- package/Interactions/gateway.js +6 -7
- package/Interactions/gateway.js.map +1 -1
- package/Interactions/handlers.js +6 -6
- package/Interactions/handlers.js.map +1 -1
- package/Interactions/index.d.ts +3 -2
- package/Interactions/index.js +5 -4
- package/Interactions/index.js.map +1 -1
- package/Interactions/webhook.d.ts +3 -3
- package/Interactions/webhook.js +9 -9
- package/Interactions/webhook.js.map +1 -1
- package/Log.d.ts +12 -0
- package/{Log/index.js → Log.js} +1 -1
- package/Log.js.map +1 -0
- package/RateLimit/memory.d.ts +1 -1
- package/RateLimit/memory.js +3 -3
- package/RateLimit/memory.js.map +1 -1
- package/{RateLimit/index.d.ts → RateLimit.d.ts} +6 -6
- package/{RateLimit/index.js → RateLimit.js} +8 -8
- package/RateLimit.js.map +1 -0
- package/gateway.d.ts +10 -10
- package/gateway.js +11 -12
- package/gateway.js.map +1 -1
- package/global.d.ts +1 -1
- package/index.d.ts +5 -6
- package/index.js +5 -6
- package/index.js.map +1 -1
- package/package.json +8 -6
- package/webhooks.d.ts +4 -4
- package/webhooks.js +3 -4
- package/webhooks.js.map +1 -1
- package/Cache/index.d.ts +0 -69
- package/Cache/index.js.map +0 -1
- package/DiscordConfig/index.js.map +0 -1
- package/DiscordGateway/DiscordWS/index.js.map +0 -1
- package/DiscordGateway/Shard/index.d.ts +0 -9
- package/DiscordGateway/Shard/index.js +0 -44
- package/DiscordGateway/Shard/index.js.map +0 -1
- package/DiscordGateway/ShardStore/index.js.map +0 -1
- package/DiscordGateway/Sharder/index.d.ts +0 -16
- package/DiscordGateway/Sharder/index.js +0 -42
- package/DiscordGateway/Sharder/index.js.map +0 -1
- package/DiscordGateway/WS/index.js.map +0 -1
- package/DiscordGateway/index.d.ts +0 -12
- package/DiscordGateway/index.js +0 -20
- package/DiscordGateway/index.js.map +0 -1
- package/DiscordREST/index.d.ts +0 -188
- package/DiscordREST/index.js +0 -122
- package/DiscordREST/index.js.map +0 -1
- package/Http/index.d.ts +0 -37
- package/Http/index.js +0 -51
- package/Http/index.js.map +0 -1
- package/Log/index.d.ts +0 -12
- package/Log/index.js.map +0 -1
- package/RateLimit/index.js.map +0 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Effect, Discord } from "dfx/_common";
|
|
2
|
-
import { DiscordREST
|
|
2
|
+
import { DiscordREST } from "dfx";
|
|
3
|
+
import * as Http from "@effect-http/client";
|
|
3
4
|
import { DefinitionNotFound } from "./handlers.js";
|
|
4
5
|
import { InteractionBuilder } from "./index.js";
|
|
6
|
+
import { DiscordRESTError } from "dfx/DiscordREST";
|
|
5
7
|
export interface RunOpts {
|
|
6
8
|
sync?: boolean;
|
|
7
9
|
}
|
|
@@ -9,4 +11,4 @@ export interface RunOpts {
|
|
|
9
11
|
* @tsplus pipeable dfx/InteractionBuilder runGateway
|
|
10
12
|
* @tsplus location "dfx/Interactions/gateway"
|
|
11
13
|
*/
|
|
12
|
-
export declare const run: <R, R2, E, E2>(postHandler: (effect: import("
|
|
14
|
+
export declare const run: <R, R2, E, E2>(postHandler: (effect: import("@effect-http/client/_common").Effect<R | import("dfx/DiscordREST").DiscordREST | import("../types.js").Interaction, E | DiscordRESTError | DefinitionNotFound, void>) => import("@effect-http/client/_common").Effect<R2, E2, void>, { sync }?: RunOpts) => (ix: InteractionBuilder<R, E>) => import("@effect-http/client/_common").Effect<import("dfx/DiscordREST").DiscordREST | import("../DiscordGateway.js").DiscordGateway | Exclude<R2, import("../types.js").Interaction>, E2 | DiscordRESTError | Http.HttpClientError, void>;
|
package/Interactions/gateway.js
CHANGED
|
@@ -2,6 +2,7 @@ import * as tsplus_module_1 from "@effect/io/Effect";
|
|
|
2
2
|
import * as tsplus_module_2 from "@fp-ts/core/Function";
|
|
3
3
|
import * as tsplus_module_3 from "dfx";
|
|
4
4
|
import * as tsplus_module_4 from "dfx/gateway";
|
|
5
|
+
import * as Http from "@effect-http/client";
|
|
5
6
|
import { handlers } from "./handlers.js";
|
|
6
7
|
import { InteractionContext } from "./index.js";
|
|
7
8
|
import { splitDefinitions } from "./utils.js";
|
|
@@ -10,16 +11,14 @@ import { splitDefinitions } from "./utils.js";
|
|
|
10
11
|
*/
|
|
11
12
|
export const run = (postHandler, { sync = true } = {}) => (ix) => (() => {
|
|
12
13
|
const { GlobalApplicationCommand, GuildApplicationCommand } = splitDefinitions(ix.definitions);
|
|
13
|
-
return tsplus_module_1.flatMap(gateway => tsplus_module_1.flatMap(rest => tsplus_module_1.flatMap(application => {
|
|
14
|
-
const globalSync = rest.bulkOverwriteGlobalApplicationCommands(application.id, {
|
|
15
|
-
body: JSON.stringify(GlobalApplicationCommand.map(a => a.command)),
|
|
16
|
-
});
|
|
14
|
+
return tsplus_module_1.flatMap(tsplus_module_1.service(tsplus_module_4.Gateway.DiscordGateway), gateway => tsplus_module_1.flatMap(tsplus_module_1.service(tsplus_module_3.DiscordREST), rest => tsplus_module_1.flatMap(tsplus_module_1.flatMap(rest.getCurrentBotApplicationInformation(), a => a.json), application => {
|
|
15
|
+
const globalSync = rest.bulkOverwriteGlobalApplicationCommands(application.id, { body: Http.body.json(GlobalApplicationCommand.map(a => a.command)) });
|
|
17
16
|
const guildSync = GuildApplicationCommand.length
|
|
18
17
|
? gateway.handleDispatch("GUILD_CREATE", a => rest.bulkOverwriteGuildApplicationCommands(application.id, a.id, GuildApplicationCommand.map(a => a.command)))
|
|
19
18
|
: tsplus_module_1.unit();
|
|
20
19
|
const handle = handlers(ix.definitions);
|
|
21
|
-
const run = gateway.handleDispatch("INTERACTION_CREATE", i => tsplus_module_1.provideService(
|
|
22
|
-
return tsplus_module_1.map(
|
|
23
|
-
})
|
|
20
|
+
const run = gateway.handleDispatch("INTERACTION_CREATE", i => tsplus_module_1.provideService(tsplus_module_2.pipe(tsplus_module_1.tap(handle[i.type](i), r => rest.createInteractionResponse(i.id, i.token, r)), postHandler), InteractionContext, i));
|
|
21
|
+
return tsplus_module_1.map(sync ? tsplus_module_1.zipPar(tsplus_module_1.zipPar(run, globalSync), guildSync) : run, () => void 0);
|
|
22
|
+
})));
|
|
24
23
|
})();
|
|
25
24
|
//# sourceMappingURL=gateway.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../src/Interactions/gateway.ts"],"names":[],"mappings":";;;;AAAA,OAAO,EAAsB,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAsB,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../src/Interactions/gateway.ts"],"names":[],"mappings":";;;;AAAA,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAsB,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAsB,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAO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,EAAK,CAAC,CAAC,EAAE,CACxB,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CACjD,EACD,WAAW,CACZ,EAAgB,kBAAkB,EAAE,CAAC,CAAC,CACxC,CAAA;mCAEC,IAAI,CAAC,CAAC,CAAC,uBAAA,uBAAA,GAAG,EAAQ,UAAU,CAAC,EAAQ,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG;;IACvD,CAAA"}
|
package/Interactions/handlers.js
CHANGED
|
@@ -29,30 +29,30 @@ export const handlers = (definitions) => {
|
|
|
29
29
|
}),
|
|
30
30
|
[2 /* Discord.InteractionType.APPLICATION_COMMAND */]: i => {
|
|
31
31
|
const data = i.data;
|
|
32
|
-
return tsplus_module_2.provideService(
|
|
32
|
+
return tsplus_module_2.provideService(tsplus_module_3.match(tsplus_module_3.fromNullable(Commands[data.name]), () => tsplus_module_2.fail(new DefinitionNotFound(i)), command => tsplus_module_2.isEffect(command.handle)
|
|
33
33
|
? command.handle
|
|
34
|
-
: command.handle(context))
|
|
34
|
+
: command.handle(context)), Ctx.ApplicationCommandContext, data);
|
|
35
35
|
},
|
|
36
36
|
[5 /* Discord.InteractionType.MODAL_SUBMIT */]: (i) => {
|
|
37
37
|
const data = i.data;
|
|
38
38
|
return tsplus_module_5.pipe(ModalSubmit, Arr.map(a => tsplus_module_2.struct({
|
|
39
39
|
command: tsplus_module_2.succeed(a),
|
|
40
40
|
match: a.predicate(data.custom_id),
|
|
41
|
-
})), _ => tsplus_module_2.provideService(
|
|
41
|
+
})), _ => tsplus_module_2.provideService(tsplus_module_2.flatMap(tsplus_module_2.collectAllPar(_), a => tsplus_module_3.match(tsplus_module_4.findFirst(a, a => a.match), () => tsplus_module_2.fail(new DefinitionNotFound(i)), a => a.command.handle)), Ctx.ModalSubmitContext, data));
|
|
42
42
|
},
|
|
43
43
|
[3 /* Discord.InteractionType.MESSAGE_COMPONENT */]: i => {
|
|
44
44
|
const data = i.data;
|
|
45
45
|
return tsplus_module_5.pipe(MessageComponent, Arr.map(a => tsplus_module_2.struct({
|
|
46
46
|
command: tsplus_module_2.succeed(a),
|
|
47
47
|
match: a.predicate(data.custom_id),
|
|
48
|
-
})), a => tsplus_module_2.provideService(
|
|
48
|
+
})), a => tsplus_module_2.provideService(tsplus_module_2.flatMap(tsplus_module_2.collectAllPar(a), a => tsplus_module_3.match(tsplus_module_4.findFirst(a, a => a.match), () => tsplus_module_2.fail(new DefinitionNotFound(i)), a => a.command.handle)), Ctx.MessageComponentContext, data));
|
|
49
49
|
},
|
|
50
50
|
[4 /* Discord.InteractionType.APPLICATION_COMMAND_AUTOCOMPLETE */]: i => {
|
|
51
51
|
const data = i.data;
|
|
52
|
-
return tsplus_module_3.getOrElse(
|
|
52
|
+
return tsplus_module_3.getOrElse(tsplus_module_3.map(tsplus_module_6.IxHelpers.focusedOption(data), focusedOption => tsplus_module_5.pipe(Autocomplete, Arr.map(_ => tsplus_module_2.struct({
|
|
53
53
|
command: tsplus_module_2.succeed(_),
|
|
54
54
|
match: _.predicate(data, focusedOption),
|
|
55
|
-
})), a => tsplus_module_2.provideService(
|
|
55
|
+
})), a => tsplus_module_2.provideService(tsplus_module_2.provideService(tsplus_module_2.flatMap(tsplus_module_2.collectAllPar(a), _ => tsplus_module_3.match(tsplus_module_4.findFirst(_, _ => _.match), () => tsplus_module_2.fail(new DefinitionNotFound(i)), _ => _.command.handle)), Ctx.ApplicationCommandContext, data), Ctx.FocusedOptionContext, { focusedOption }))), () => tsplus_module_2.fail(new DefinitionNotFound(i)));
|
|
56
56
|
},
|
|
57
57
|
};
|
|
58
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../src/Interactions/handlers.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAA;AAChD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAEnC,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,EAAE,CACV,uBAAc;gBACZ,OAAO,EAAE,wBAAe,CAAC,CAAC;gBAC1B,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,aAAa,CAAC;aACxC,CAAC,CACH,EACD,CAAC,CAAC,EAAE,CACF,+BAAA,+BAAA,sDAAA,CAAC,GACU,CAAC,CAAC,EAAE,CACX,sBAAA,0BAAA,CAAC,EAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EACvB,GAAG,EAAE,CACH,qBAAY,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAkB,EACzD,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CACtB,CACF,EACe,GAAG,CAAC,yBAAyB,EAAE,IAAI,CAAC,EACpC,GAAG,CAAC,oBAAoB,EAAE,EAAE,aAAa,EAAE,CAAC,CACjE,CACF,EACU,GAAG,EAAE,CAAC,qBAAY,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC5D,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
package/Interactions/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DiscordREST } from "dfx";
|
|
2
2
|
import { Discord, Effect } from "dfx/_common";
|
|
3
3
|
import * as D from "./definitions.js";
|
|
4
|
+
import * as Http from "@effect-http/client";
|
|
4
5
|
export { response as r } from "../Helpers/interactions.js";
|
|
5
6
|
export * from "./context.js";
|
|
6
7
|
export { autocomplete, global, guild, InteractionDefinition, messageComponent, modalSubmit, } from "./definitions.js";
|
|
@@ -12,8 +13,8 @@ export declare class InteractionBuilder<R, E> {
|
|
|
12
13
|
constructor(definitions: D.InteractionDefinition<R, E>[]);
|
|
13
14
|
add<R1, E1>(definition: D.InteractionDefinition<R1, E1>): InteractionBuilder<R | R1, E | E1>;
|
|
14
15
|
concat<R1, E1>(builder: InteractionBuilder<R1, E1>): InteractionBuilder<R | R1, E | E1>;
|
|
15
|
-
get syncGlobal(): Effect<DiscordREST, import("
|
|
16
|
-
syncGuild(appId: Discord.Snowflake, guildId: Discord.Snowflake): Effect<DiscordREST, import("
|
|
16
|
+
get syncGlobal(): Effect<DiscordREST, import("../DiscordREST.js").DiscordRESTError | Http.HttpClientError, import("../DiscordREST/types.js").ResponseWithData<Discord.ApplicationCommand[]>>;
|
|
17
|
+
syncGuild(appId: Discord.Snowflake, guildId: Discord.Snowflake): Effect<DiscordREST, import("../DiscordREST.js").DiscordRESTError, import("../DiscordREST/types.js").ResponseWithData<Discord.ApplicationCommand[]>>;
|
|
17
18
|
}
|
|
18
19
|
export declare const builder: InteractionBuilder<never, never>;
|
|
19
20
|
export declare const id: (query: string) => (customId: string) => Effect<never, never, boolean>;
|
package/Interactions/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as tsplus_module_1 from "@effect/io/Effect";
|
|
2
2
|
import { DiscordREST } from "dfx";
|
|
3
|
+
import * as Http from "@effect-http/client";
|
|
3
4
|
export { response as r } from "../Helpers/interactions.js";
|
|
4
5
|
export * from "./context.js";
|
|
5
6
|
export { autocomplete, global, guild, messageComponent, modalSubmit, } from "./definitions.js";
|
|
@@ -27,10 +28,10 @@ export class InteractionBuilder {
|
|
|
27
28
|
const commands = this.definitions
|
|
28
29
|
.filter((c) => c._tag === "GlobalApplicationCommand")
|
|
29
30
|
.map(c => c.command);
|
|
30
|
-
return tsplus_module_1.serviceWithEffect(DiscordREST, rest => tsplus_module_1.flatMap(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
return tsplus_module_1.serviceWithEffect(DiscordREST, rest => tsplus_module_1.flatMap(tsplus_module_1.flatMap(rest
|
|
32
|
+
.getCurrentBotApplicationInformation(), r => r.json), app => rest.bulkOverwriteGlobalApplicationCommands(app.id, {
|
|
33
|
+
body: Http.body.json(commands),
|
|
34
|
+
})));
|
|
34
35
|
}
|
|
35
36
|
syncGuild(appId, guildId) {
|
|
36
37
|
const commands = this.definitions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Interactions/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Interactions/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AAGjC,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAA;AAE3C,OAAO,EAAE,QAAQ,IAAI,CAAC,EAAE,MAAM,4BAA4B,CAAA;AAC1D,cAAc,cAAc,CAAA;AAC5B,OAAO,EACL,YAAY,EACZ,MAAM,EACN,KAAK,EAEL,gBAAgB,EAChB,WAAW,GACZ,MAAM,kBAAkB,CAAA;AAEzB;;GAEG;AACH,MAAM,OAAO,kBAAkB;IACR;IAArB,YAAqB,WAA4C;QAA5C,gBAAW,GAAX,WAAW,CAAiC;IAAG,CAAC;IAErE,GAAG,CAAS,UAA2C;QACrD,OAAO,IAAI,kBAAkB,CAAiB;YAC5C,GAAG,IAAI,CAAC,WAAW;YACnB,UAAU;SACX,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,CAAS,OAAmC;QAChD,OAAO,IAAI,kBAAkB,CAAiB;YAC5C,GAAG,IAAI,CAAC,WAAW;YACnB,GAAG,OAAO,CAAC,WAAW;SACvB,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,UAAU;QACZ,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW;aAC9B,MAAM,CACL,CAAC,CAAC,EAAyC,EAAE,CAC3C,CAAC,CAAC,IAAI,KAAK,0BAA0B,CACxC;aACA,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;QAEtB,OAAO,kCAAyB,WAAW,EAAE,IAAI,CAAC,EAAE,CAClD,wBAAA,wBAAA,IAAI;aACD,mCAAmC,EAAE,EAC7B,CA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,CACE,IAAmD,EACnD,aAGC,EACD,EAAE,CACF,wBAAe,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,aAAa,CAAC,IAAI,KAAK,UAAU,CAAC,CAAA;AAE9E,MAAM,CAAC,MAAM,UAAU,GACrB,CAAC,UAAkB,EAAE,EAAE,CACvB,CACE,CAAU,EACV,aAGC,EACD,EAAE,CACF,wBAAe,aAAa,CAAC,IAAI,KAAK,UAAU,CAAC,CAAA"}
|
|
@@ -15,7 +15,7 @@ declare const makeConfig: ({ applicationId, publicKey }: MakeConfigOpts) => {
|
|
|
15
15
|
};
|
|
16
16
|
export interface WebhookConfig extends ReturnType<typeof makeConfig> {
|
|
17
17
|
}
|
|
18
|
-
export declare const WebhookConfig: import("
|
|
18
|
+
export declare const WebhookConfig: import("@effect-http/client/_common").Tag<WebhookConfig>;
|
|
19
19
|
export declare const makeConfigLayer: (a_0: MakeConfigOpts) => import("../_common.js").Layer<never, never, WebhookConfig>;
|
|
20
20
|
export declare const makeFromConfig: (a: Config<MakeConfigOpts>) => import("../_common.js").Layer<never, import("../_common.js").ConfigError, WebhookConfig>;
|
|
21
21
|
export declare class WebhookParseError {
|
|
@@ -33,7 +33,7 @@ export interface HandleWebhookOpts<E> {
|
|
|
33
33
|
* @tsplus getter dfx/InteractionBuilder webhookHandler
|
|
34
34
|
* @tsplus location "dfx/Interactions/webhook"
|
|
35
35
|
*/
|
|
36
|
-
export declare const makeHandler: <R, E>(ix: InteractionBuilder<R, E>) => ({ headers, body, success, error, }: HandleWebhookOpts<DefinitionNotFound | BadWebhookSignature | WebhookParseError | E>) => import("
|
|
36
|
+
export declare const makeHandler: <R, E>(ix: InteractionBuilder<R, E>) => ({ headers, body, success, error, }: HandleWebhookOpts<DefinitionNotFound | BadWebhookSignature | WebhookParseError | E>) => import("@effect-http/client/_common").Effect<WebhookConfig | Exclude<R, import("../types.js").Interaction>, never, void>;
|
|
37
37
|
/**
|
|
38
38
|
* @tsplus getter dfx/InteractionBuilder simpleWebhookHandler
|
|
39
39
|
* @tsplus location "dfx/Interactions/webhook"
|
|
@@ -41,5 +41,5 @@ export declare const makeHandler: <R, E>(ix: InteractionBuilder<R, E>) => ({ hea
|
|
|
41
41
|
export declare const makeSimpleHandler: <R, E>(ix: InteractionBuilder<R, E>) => ({ headers, body }: {
|
|
42
42
|
headers: Headers;
|
|
43
43
|
body: string;
|
|
44
|
-
}) => import("
|
|
44
|
+
}) => import("@effect-http/client/_common").Effect<WebhookConfig | Exclude<R, import("../types.js").Interaction>, DefinitionNotFound | BadWebhookSignature | WebhookParseError | E, import("../types.js").InteractionResponse>;
|
|
45
45
|
export {};
|
package/Interactions/webhook.js
CHANGED
|
@@ -12,20 +12,20 @@ import { fromHex } from "./utils.js";
|
|
|
12
12
|
export class BadWebhookSignature {
|
|
13
13
|
_tag = "BadWebhookSignature";
|
|
14
14
|
}
|
|
15
|
-
const checkSignature = (publicKey, headers, body) => tsplus_module_2.asUnit(tsplus_module_1.toEither(tsplus_module_1.filter(
|
|
16
|
-
signature: tsplus_module_1.fromNullable(headers["x-signature-ed25519"]),
|
|
17
|
-
timestamp: tsplus_module_1.fromNullable(headers["x-signature-timestamp"]),
|
|
18
|
-
}), a => {
|
|
15
|
+
const checkSignature = (publicKey, headers, body) => tsplus_module_2.asUnit(tsplus_module_1.toEither(() => new BadWebhookSignature())(tsplus_module_1.filter(a => {
|
|
19
16
|
const enc = new TextEncoder();
|
|
20
17
|
return Nacl.sign.detached.verify(enc.encode(a.timestamp + body), fromHex(`${a.signature}`), publicKey);
|
|
21
|
-
})
|
|
18
|
+
})(tsplus_module_1.struct({
|
|
19
|
+
signature: tsplus_module_1.fromNullable(headers["x-signature-ed25519"]),
|
|
20
|
+
timestamp: tsplus_module_1.fromNullable(headers["x-signature-timestamp"]),
|
|
21
|
+
}))));
|
|
22
22
|
const makeConfig = ({ applicationId, publicKey }) => ({
|
|
23
23
|
applicationId,
|
|
24
24
|
publicKey: fromHex(tsplus_module_3.value(publicKey)),
|
|
25
25
|
});
|
|
26
26
|
export const WebhookConfig = tsplus_module_4.Tag();
|
|
27
27
|
export const makeConfigLayer = tsplus_module_6.flow(makeConfig, _ => tsplus_module_5.succeed(WebhookConfig, _));
|
|
28
|
-
export const makeFromConfig = (a) => tsplus_module_7.toLayer(
|
|
28
|
+
export const makeFromConfig = (a) => tsplus_module_7.toLayer(tsplus_module_7.map(tsplus_module_7.config(a), makeConfig), WebhookConfig);
|
|
29
29
|
export class WebhookParseError {
|
|
30
30
|
reason;
|
|
31
31
|
_tag = "WebhookParseError";
|
|
@@ -33,17 +33,17 @@ export class WebhookParseError {
|
|
|
33
33
|
this.reason = reason;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
const fromHeadersAndBody = (headers, body) => tsplus_module_7.flatMap(({ publicKey }) => tsplus_module_7.flatMap(() => tsplus_module_7.tryCatch(() => JSON.parse(body), reason => new WebhookParseError(reason)))
|
|
36
|
+
const fromHeadersAndBody = (headers, body) => tsplus_module_7.flatMap(tsplus_module_7.service(WebhookConfig), ({ publicKey }) => tsplus_module_7.flatMap(tsplus_module_7.fromEither(checkSignature(publicKey, headers, body)), () => tsplus_module_7.tryCatch(() => JSON.parse(body), reason => new WebhookParseError(reason))));
|
|
37
37
|
const run = (definitions) => {
|
|
38
38
|
const handler = handlers(definitions);
|
|
39
|
-
return (headers, body) => tsplus_module_7.flatMap(interaction => tsplus_module_7.provideService(
|
|
39
|
+
return (headers, body) => tsplus_module_7.flatMap(fromHeadersAndBody(headers, body), interaction => tsplus_module_7.provideService(handler[interaction.type](interaction), InteractionContext, interaction));
|
|
40
40
|
};
|
|
41
41
|
/**
|
|
42
42
|
* @tsplus getter dfx/InteractionBuilder webhookHandler
|
|
43
43
|
*/
|
|
44
44
|
export const makeHandler = (ix) => {
|
|
45
45
|
const handle = run(ix.definitions);
|
|
46
|
-
return ({ headers, body, success, error, }) => tsplus_module_7.catchAllCause(
|
|
46
|
+
return ({ headers, body, success, error, }) => tsplus_module_7.catchAllCause(tsplus_module_7.flatMap(handle(headers, body), success), error);
|
|
47
47
|
};
|
|
48
48
|
/**
|
|
49
49
|
* @tsplus getter dfx/InteractionBuilder simpleWebhookHandler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../src/Interactions/webhook.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAsB,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAsB,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,MAAM,OAAO,mBAAmB;IACrB,IAAI,GAAG,qBAAqB,CAAA;CACtC;AAID,MAAM,cAAc,GAAG,CACrB,SAAqB,EACrB,OAAgB,EAChB,IAAY,EACZ,EAAE,wBACF,
|
|
1
|
+
{"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../src/Interactions/webhook.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAsB,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAsB,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,MAAM,OAAO,mBAAmB;IACrB,IAAI,GAAG,qBAAqB,CAAA;CACtC;AAID,MAAM,cAAc,GAAG,CACrB,SAAqB,EACrB,OAAgB,EAChB,IAAY,EACZ,EAAE,wBACF,yBAYY,GAAG,EAAE,CAAC,IAAI,mBAAmB,EAAE,EAZ3C,uBAIU,CAAC,CAAC,EAAE;IACV,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;IAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAC9B,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC,EAC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CAAO,WAA4C,EAAE,EAAE;IACjE,MAAM,OAAO,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAA;IACrC,OAAO,CAAC,OAAgB,EAAE,IAAY,EAAE,EAAE,yBAEhB,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,EAAjD,WAAW,IAEf,+BAAA,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,EACpC,kBAAkB,EAClB,WAAW,CACZ,CAEH,CAAA;AACN,CAAC,CAAA;AASD;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAO,EAA4B,EAAE,EAAE;IAChE,MAAM,MAAM,GAAG,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;IAElC,OAAO,CAAC,EACN,OAAO,EACP,IAAI,EACJ,OAAO,EACP,KAAK,GAGN,EAAE,EAAE,CAAC,8BAAA,wBAAA,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,EAAS,OAAO,CAAC,EAAe,KAAK,CAAC,CAAA;AACnE,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAO,EAA4B,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;IAElC,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAsC,EAAE,EAAE,CAC/D,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACzB,CAAC,CAAA"}
|
package/Log.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const make: (debug?: boolean) => {
|
|
2
|
+
info: (...args: any[]) => import("@effect-http/client/_common").Effect<never, never, void>;
|
|
3
|
+
debug: (...args: any[]) => import("@effect-http/client/_common").Effect<never, never, void>;
|
|
4
|
+
};
|
|
5
|
+
export interface Log extends ReturnType<typeof make> {
|
|
6
|
+
}
|
|
7
|
+
export declare const Log: import("@effect-http/client/_common").Tag<Log>;
|
|
8
|
+
export declare const LiveLog: import("./_common.js").Layer<never, never, Log>;
|
|
9
|
+
export declare const LiveLogDebug: import("./_common.js").Layer<never, never, Log>;
|
|
10
|
+
export declare const info: (...args: any[]) => import("@effect-http/client/_common").Effect<Log, never, void>;
|
|
11
|
+
export declare const debug: (...args: any[]) => import("@effect-http/client/_common").Effect<Log, never, void>;
|
|
12
|
+
export {};
|
package/{Log/index.js → Log.js}
RENAMED
|
@@ -16,4 +16,4 @@ export const LiveLog = tsplus_module_3.succeed(Log, make(false));
|
|
|
16
16
|
export const LiveLogDebug = tsplus_module_3.succeed(Log, make(true));
|
|
17
17
|
export const info = (...args) => tsplus_module_1.serviceWithEffect(Log, ({ info: log }) => log(...args));
|
|
18
18
|
export const debug = (...args) => tsplus_module_1.serviceWithEffect(Log, ({ debug }) => debug(...args));
|
|
19
|
-
//# sourceMappingURL=
|
|
19
|
+
//# sourceMappingURL=Log.js.map
|
package/Log.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Log.js","sourceRoot":"","sources":["../src/Log.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,CAAC,KAAK,GAAG,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/B,IAAI,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE,CACvB,qBAAY,GAAG,EAAE;QACf,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAA;IAChC,CAAC,CAAC;IACJ,KAAK,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE,CACxB,KAAK;QACH,CAAC,CAAC,qBAAY,GAAG,EAAE;YACf,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;QACjC,CAAC,CAAC;QACJ,CAAC,CAAC,sBAAa;CACpB,CAAC,CAAA;AAGF,MAAM,CAAC,MAAM,GAAG,GAAG,gBAAA,GAAG,EAAO,CAAA;AAC7B,MAAM,CAAC,MAAM,OAAO,GAAG,wBAAc,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,wBAAc,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;AAE1D,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE,CACrC,kCAAyB,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;AAEhE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE,CACtC,kCAAyB,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA"}
|
package/RateLimit/memory.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RateLimitStore } from "
|
|
1
|
+
import { RateLimitStore } from "../RateLimit.js";
|
|
2
2
|
export declare const make: () => RateLimitStore;
|
package/RateLimit/memory.js
CHANGED
|
@@ -4,7 +4,7 @@ export const make = () => {
|
|
|
4
4
|
const buckets = new Map();
|
|
5
5
|
const routes = new Map();
|
|
6
6
|
const counters = new Map();
|
|
7
|
-
const getCounter = (key) => tsplus_module_1.filter(
|
|
7
|
+
const getCounter = (key) => tsplus_module_1.filter(c => c.expires > Date.now())(tsplus_module_1.fromNullable(counters.get(key)));
|
|
8
8
|
const getBucketForRoute = (route) => tsplus_module_2.sync(() => tsplus_module_1.fromNullable(buckets.get(routes.get(route))));
|
|
9
9
|
return {
|
|
10
10
|
hasBucket: key => tsplus_module_2.sync(() => buckets.has(key)),
|
|
@@ -21,10 +21,10 @@ export const make = () => {
|
|
|
21
21
|
incrementCounter: (key, window, limit) => tsplus_module_2.sync(() => {
|
|
22
22
|
const now = Date.now();
|
|
23
23
|
const perRequest = Math.ceil(window / limit);
|
|
24
|
-
const counter = tsplus_module_1.getOrElse(() => ({
|
|
24
|
+
const counter = tsplus_module_1.getOrElse(getCounter(key), () => ({
|
|
25
25
|
expires: now,
|
|
26
26
|
count: 0,
|
|
27
|
-
}))
|
|
27
|
+
}));
|
|
28
28
|
const count = counter.count + 1;
|
|
29
29
|
const expires = counter.expires + perRequest;
|
|
30
30
|
counters.set(key, { ...counter, count, expires });
|
package/RateLimit/memory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/RateLimit/memory.ts"],"names":[],"mappings":";;AAOA,MAAM,CAAC,MAAM,IAAI,GAAG,GAAmB,EAAE;IACvC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAA;IAChD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAA;IACxC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAA;IAE3C,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,EAAE,CACjC,
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/RateLimit/memory.ts"],"names":[],"mappings":";;AAOA,MAAM,CAAC,MAAM,IAAI,GAAG,GAAmB,EAAE;IACvC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAyB,CAAA;IAChD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAA;IACxC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAA;IAE3C,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,EAAE,CACjC,uBAA6C,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,EAAxE,6BAAmB,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAoC,CAAA;IAE3E,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAE,EAAE,CAC1C,qBAAY,GAAG,EAAE,CAAC,6BAAmB,OAAO,CAAC,GAAG,CAAC,MAAM,CA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AA;YAEjD,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,CAAC,CAAA;QAC/B,CAAC,CAAC;KACL,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -12,13 +12,13 @@ export interface RateLimitStore {
|
|
|
12
12
|
incrementCounter: (key: string, window: number, limit: number) => Effect<never, never, readonly [count: number, ttl: number]>;
|
|
13
13
|
removeCounter: (key: string) => Effect<never, never, void>;
|
|
14
14
|
}
|
|
15
|
-
export declare const RateLimitStore: import("
|
|
16
|
-
export declare const LiveMemoryRateLimitStore: import("
|
|
17
|
-
declare const makeLimiter: import("
|
|
18
|
-
maybeWait: (key: string, window: Duration, limit: number, multiplier?: number) => import("
|
|
15
|
+
export declare const RateLimitStore: import("@effect-http/client/_common").Tag<RateLimitStore>;
|
|
16
|
+
export declare const LiveMemoryRateLimitStore: import("./_common.js").Layer<never, never, RateLimitStore>;
|
|
17
|
+
declare const makeLimiter: import("@effect-http/client/_common").Effect<import("./Log.js").Log | RateLimitStore, never, {
|
|
18
|
+
maybeWait: (key: string, window: Duration, limit: number, multiplier?: number) => import("@effect-http/client/_common").Effect<never, never, void>;
|
|
19
19
|
}>;
|
|
20
20
|
export interface RateLimiter extends Effect.Success<typeof makeLimiter> {
|
|
21
21
|
}
|
|
22
|
-
export declare const RateLimiter: import("
|
|
23
|
-
export declare const LiveRateLimiter: import("
|
|
22
|
+
export declare const RateLimiter: import("@effect-http/client/_common").Tag<RateLimiter>;
|
|
23
|
+
export declare const LiveRateLimiter: import("./_common.js").Layer<import("./Log.js").Log | RateLimitStore, never, RateLimiter>;
|
|
24
24
|
export {};
|
|
@@ -2,24 +2,24 @@ import * as tsplus_module_1 from "dfx/_common";
|
|
|
2
2
|
import * as tsplus_module_2 from "@effect/io/Layer";
|
|
3
3
|
import * as tsplus_module_3 from "@effect/io/Effect";
|
|
4
4
|
import * as tsplus_module_4 from "dfx";
|
|
5
|
-
import { delayFrom } from "./utils.js";
|
|
6
|
-
import * as Memory from "./memory.js";
|
|
5
|
+
import { delayFrom } from "./RateLimit/utils.js";
|
|
6
|
+
import * as Memory from "./RateLimit/memory.js";
|
|
7
7
|
export const RateLimitStore = tsplus_module_1.Tag();
|
|
8
8
|
export const LiveMemoryRateLimitStore = tsplus_module_2.sync(RateLimitStore, Memory.make);
|
|
9
|
-
const makeLimiter = tsplus_module_3.flatMap(store => tsplus_module_3.map(log => {
|
|
9
|
+
const makeLimiter = tsplus_module_3.flatMap(tsplus_module_3.service(RateLimitStore), store => tsplus_module_3.map(tsplus_module_3.service(tsplus_module_4.Log.Log), log => {
|
|
10
10
|
const maybeWait = (key, window, limit, multiplier = 1.05) => {
|
|
11
11
|
const windowMs = window.millis * multiplier;
|
|
12
|
-
return tsplus_module_3.asUnit(tsplus_module_3.tap(tsplus_module_3.
|
|
12
|
+
return tsplus_module_3.asUnit(tsplus_module_3.tap(tsplus_module_3.tap(tsplus_module_3.map(store
|
|
13
|
+
.incrementCounter(key, windowMs, limit), ([count, ttl]) => delayFrom(windowMs, limit, count, ttl)), d => log.debug("RateLimitStore maybeWait", {
|
|
13
14
|
key,
|
|
14
15
|
window: window.millis,
|
|
15
16
|
windowMs,
|
|
16
17
|
limit,
|
|
17
18
|
delay: d.millis,
|
|
18
|
-
}))
|
|
19
|
-
.incrementCounter(key, windowMs, limit)))));
|
|
19
|
+
})), tsplus_module_3.sleep));
|
|
20
20
|
};
|
|
21
21
|
return { maybeWait };
|
|
22
|
-
})
|
|
22
|
+
}));
|
|
23
23
|
export const RateLimiter = tsplus_module_1.Tag();
|
|
24
24
|
export const LiveRateLimiter = tsplus_module_2.effect(RateLimiter, makeLimiter);
|
|
25
|
-
//# sourceMappingURL=
|
|
25
|
+
//# sourceMappingURL=RateLimit.js.map
|
package/RateLimit.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RateLimit.js","sourceRoot":"","sources":["../src/RateLimit.ts"],"names":[],"mappings":";;;;AAAA,OAAO,EAAE,SAAS,EAAE,MA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dfx";
|
|
3
3
|
export * as CachePrelude from "./Cache/prelude.js";
|
|
4
|
-
export * as DiscordWS from "./DiscordGateway/DiscordWS
|
|
5
|
-
export * as Gateway from "./DiscordGateway
|
|
6
|
-
export * as Shard from "./DiscordGateway/Shard
|
|
7
|
-
export * as ShardStore from "./DiscordGateway/ShardStore
|
|
8
|
-
export * as WS from "./DiscordGateway/WS
|
|
4
|
+
export * as DiscordWS from "./DiscordGateway/DiscordWS.js";
|
|
5
|
+
export * as Gateway from "./DiscordGateway.js";
|
|
6
|
+
export * as Shard from "./DiscordGateway/Shard.js";
|
|
7
|
+
export * as ShardStore from "./DiscordGateway/ShardStore.js";
|
|
8
|
+
export * as WS from "./DiscordGateway/WS.js";
|
|
9
9
|
export { run as runIx } from "./Interactions/gateway.js";
|
|
10
10
|
export declare const MemoryRateLimit: import("./_common.js").Layer<Log.Log, never, import("dfx").RateLimitStore | import("dfx").RateLimiter>;
|
|
11
11
|
export declare const MemoryREST: import("./_common.js").Layer<DiscordConfig.DiscordConfig | Log.Log, never, import("dfx").DiscordREST>;
|
|
12
|
-
export declare const MemorySharder: import("./_common.js").Layer<DiscordConfig.DiscordConfig | Log.Log, never, import("./DiscordGateway/Sharder
|
|
13
|
-
export declare const MemoryGateway: import("./_common.js").Layer<DiscordConfig.DiscordConfig | Log.Log, never, import("./DiscordGateway
|
|
14
|
-
export declare const MemoryBot: import("./_common.js").Layer<DiscordConfig.DiscordConfig | Log.Log, never, import("dfx").DiscordREST | import("dfx").RateLimitStore | import("dfx").RateLimiter | import("./DiscordGateway
|
|
15
|
-
export declare const make: (config: DiscordConfig.MakeOpts, debug?: boolean) => import("./_common.js").Layer<never, never, import("dfx").DiscordREST | DiscordConfig.DiscordConfig | Log.Log | import("dfx").RateLimitStore | import("dfx").RateLimiter | import("./DiscordGateway
|
|
16
|
-
export declare const makeFromConfig: (config: ConfigWrap.Wrap<DiscordConfig.MakeOpts>, debug?: boolean) => import("./_common.js").Layer<never, import("./_common.js").ConfigError, import("dfx").DiscordREST | DiscordConfig.DiscordConfig | Log.Log | import("dfx").RateLimitStore | import("dfx").RateLimiter | import("./DiscordGateway
|
|
12
|
+
export declare const MemorySharder: import("./_common.js").Layer<DiscordConfig.DiscordConfig | Log.Log, never, import("./DiscordGateway/Sharder.js").Sharder>;
|
|
13
|
+
export declare const MemoryGateway: import("./_common.js").Layer<DiscordConfig.DiscordConfig | Log.Log, never, import("./DiscordGateway.js").DiscordGateway>;
|
|
14
|
+
export declare const MemoryBot: import("./_common.js").Layer<DiscordConfig.DiscordConfig | Log.Log, never, import("dfx").DiscordREST | import("dfx").RateLimitStore | import("dfx").RateLimiter | import("./DiscordGateway.js").DiscordGateway>;
|
|
15
|
+
export declare const make: (config: DiscordConfig.MakeOpts, debug?: boolean) => import("./_common.js").Layer<never, never, import("dfx").DiscordREST | DiscordConfig.DiscordConfig | Log.Log | import("dfx").RateLimitStore | import("dfx").RateLimiter | import("./DiscordGateway.js").DiscordGateway>;
|
|
16
|
+
export declare const makeFromConfig: (config: ConfigWrap.Wrap<DiscordConfig.MakeOpts>, debug?: boolean) => import("./_common.js").Layer<never, import("./_common.js").ConfigError, import("dfx").DiscordREST | DiscordConfig.DiscordConfig | Log.Log | import("dfx").RateLimitStore | import("dfx").RateLimiter | import("./DiscordGateway.js").DiscordGateway>;
|
package/gateway.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import * as tsplus_module_1 from "@effect/io/Layer";
|
|
2
2
|
import * as tsplus_module_2 from "dfx/_common";
|
|
3
3
|
import { DiscordConfig, LiveDiscordREST, Log } from "dfx";
|
|
4
|
-
import { LiveJsonDiscordWSCodec } from "./DiscordGateway/DiscordWS
|
|
5
|
-
import { LiveDiscordGateway } from "./DiscordGateway
|
|
6
|
-
import { LiveSharder } from "./DiscordGateway/Sharder
|
|
7
|
-
import { LiveMemoryShardStore } from "./DiscordGateway/ShardStore
|
|
8
|
-
import {
|
|
9
|
-
import { LiveMemoryRateLimitStore, LiveRateLimiter } from "./RateLimit/index.js";
|
|
4
|
+
import { LiveJsonDiscordWSCodec } from "./DiscordGateway/DiscordWS.js";
|
|
5
|
+
import { LiveDiscordGateway } from "./DiscordGateway.js";
|
|
6
|
+
import { LiveSharder } from "./DiscordGateway/Sharder.js";
|
|
7
|
+
import { LiveMemoryShardStore } from "./DiscordGateway/ShardStore.js";
|
|
8
|
+
import { LiveMemoryRateLimitStore, LiveRateLimiter } from "./RateLimit.js";
|
|
10
9
|
export * as CachePrelude from "./Cache/prelude.js";
|
|
11
|
-
export * as DiscordWS from "./DiscordGateway/DiscordWS
|
|
12
|
-
export * as Gateway from "./DiscordGateway
|
|
13
|
-
export * as Shard from "./DiscordGateway/Shard
|
|
14
|
-
export * as ShardStore from "./DiscordGateway/ShardStore
|
|
15
|
-
export * as WS from "./DiscordGateway/WS
|
|
10
|
+
export * as DiscordWS from "./DiscordGateway/DiscordWS.js";
|
|
11
|
+
export * as Gateway from "./DiscordGateway.js";
|
|
12
|
+
export * as Shard from "./DiscordGateway/Shard.js";
|
|
13
|
+
export * as ShardStore from "./DiscordGateway/ShardStore.js";
|
|
14
|
+
export * as WS from "./DiscordGateway/WS.js";
|
|
16
15
|
export { run as runIx } from "./Interactions/gateway.js";
|
|
17
16
|
export const MemoryRateLimit = tsplus_module_1.provideMerge(LiveRateLimiter)(LiveMemoryRateLimitStore);
|
|
18
|
-
export const MemoryREST = tsplus_module_1.provide(LiveDiscordREST)(
|
|
17
|
+
export const MemoryREST = tsplus_module_1.provide(LiveDiscordREST)(MemoryRateLimit);
|
|
19
18
|
export const MemorySharder = tsplus_module_1.provide(LiveSharder)((tsplus_module_1.merge(LiveJsonDiscordWSCodec)(tsplus_module_1.merge(MemoryRateLimit)(tsplus_module_1.merge(LiveMemoryShardStore)(MemoryREST)))));
|
|
20
19
|
export const MemoryGateway = tsplus_module_1.provide(LiveDiscordGateway)(MemorySharder);
|
|
21
20
|
export const MemoryBot = tsplus_module_1.provideMerge(tsplus_module_1.merge(MemoryRateLimit)(MemoryGateway))(MemoryREST);
|
package/gateway.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAA;AACrE,OAAO,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE1E,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAC1D,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAA;AAC9C,OAAO,KAAK,KAAK,MAAM,2BAA2B,CAAA;AAClD,OAAO,KAAK,UAAU,MAAM,gCAAgC,CAAA;AAC5D,OAAO,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAC5C,OAAO,EAAE,GAAG,IAAI,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAExD,MAAM,CAAC,MAAM,eAAe,gCAA8B,eAAe,EAA1C,wBAAwB,CAAkB,CAAA;AAEzE,MAAM,CAAC,MAAM,UAAU,2BAAsB,eAAe,EAAlC,eAAe,CAAmB,CAAA;AAE5D,MAAM,CAAC,MAAM,aAAa,2BAKxB,WAAW,EAJX,uBAGE,sBAAsB,wBADtB,eAAe,wBADf,oBAAoB,EADrB,UAAU,IAGc,CACd,CAAA;AAEb,MAAM,CAAC,MAAM,aAAa,2BAAoB,kBAAkB,EAAnC,aAAa,CAAsB,CAAA;AAEhE,MAAM,CAAC,MAAM,SAAS,sDAAgC,eAAe,EAA/B,aAAa,GAA1B,UAAU,CAAkC,CAAA;AAErE,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,MAA8B,EAAE,KAAK,GAAG,KAAK,EAAE,EAAE;IACpE,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAA;IACtD,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IAClD,MAAM,OAAO,gCAA0B,SAAS,wBAAtB,UAAU,EAApB,OAAO,EAAyB,CAAA;IAEhD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,MAA+C,EAC/C,KAAK,GAAG,KAAK,EACb,EAAE;IACF,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAA;IACtD,MAAM,UAAU,GAAG,aAAa,CAAC,cAAc,CAAC,gBAAA,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;IAC1E,MAAM,OAAO,gCAA0B,SAAS,wBAAtB,UAAU,EAApB,OAAO,EAAyB,CAAA;IAEhD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
package/global.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { pipe, flow, identity } from "@fp-ts/core/Function";
|
|
|
13
13
|
/**
|
|
14
14
|
* @tsplus global
|
|
15
15
|
*/
|
|
16
|
-
import { DiscordConfig, RateLimiter, Log, DiscordREST, BucketDetails,
|
|
16
|
+
import { DiscordConfig, RateLimiter, Log, DiscordREST, BucketDetails, Intents, Ix, RateLimitStore, LiveDiscordREST, LiveMemoryRateLimitStore, LiveRateLimiter, Flags, Members, IxHelpers, Perms, } from "dfx";
|
|
17
17
|
/**
|
|
18
18
|
* @tsplus global
|
|
19
19
|
*/
|
package/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
export * as Discord from "./types.js";
|
|
2
|
-
export * as DiscordConfig from "./DiscordConfig
|
|
3
|
-
export {
|
|
4
|
-
export { DiscordREST, LiveDiscordREST } from "./DiscordREST/index.js";
|
|
2
|
+
export * as DiscordConfig from "./DiscordConfig.js";
|
|
3
|
+
export { DiscordREST, LiveDiscordREST } from "./DiscordREST.js";
|
|
5
4
|
export * as Ix from "./Interactions/index.js";
|
|
6
|
-
export * as Log from "./Log
|
|
7
|
-
export { BucketDetails, RateLimitStore, LiveMemoryRateLimitStore, RateLimiter, LiveRateLimiter, } from "./RateLimit
|
|
8
|
-
export * as Cache from "./Cache
|
|
5
|
+
export * as Log from "./Log.js";
|
|
6
|
+
export { BucketDetails, RateLimitStore, LiveMemoryRateLimitStore, RateLimiter, LiveRateLimiter, } from "./RateLimit.js";
|
|
7
|
+
export * as Cache from "./Cache.js";
|
|
9
8
|
export * as Flags from "./Helpers/flags.js";
|
|
10
9
|
export * as Intents from "./Helpers/intents.js";
|
|
11
10
|
export * as IxHelpers from "./Helpers/interactions.js";
|
package/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
export * as Discord from "./types.js";
|
|
2
|
-
export * as DiscordConfig from "./DiscordConfig
|
|
3
|
-
export {
|
|
4
|
-
export { DiscordREST, LiveDiscordREST } from "./DiscordREST/index.js";
|
|
2
|
+
export * as DiscordConfig from "./DiscordConfig.js";
|
|
3
|
+
export { DiscordREST, LiveDiscordREST } from "./DiscordREST.js";
|
|
5
4
|
export * as Ix from "./Interactions/index.js";
|
|
6
|
-
export * as Log from "./Log
|
|
7
|
-
export { RateLimitStore, LiveMemoryRateLimitStore, RateLimiter, LiveRateLimiter, } from "./RateLimit
|
|
8
|
-
export * as Cache from "./Cache
|
|
5
|
+
export * as Log from "./Log.js";
|
|
6
|
+
export { RateLimitStore, LiveMemoryRateLimitStore, RateLimiter, LiveRateLimiter, } from "./RateLimit.js";
|
|
7
|
+
export * as Cache from "./Cache.js";
|
|
9
8
|
export * as Flags from "./Helpers/flags.js";
|
|
10
9
|
export * as Intents from "./Helpers/intents.js";
|
|
11
10
|
export * as IxHelpers from "./Helpers/interactions.js";
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAA;AACrC,OAAO,KAAK,aAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAA;AACrC,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAC7C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,EAEL,cAAc,EACd,wBAAwB,EACxB,WAAW,EACX,eAAe,GAChB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AAEnC,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAC3C,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAA;AAC/C,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,iBAAiB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dfx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -27,16 +27,18 @@
|
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@tim-smart/discord-api-docs-parser": "^0.5.0",
|
|
30
|
-
"@tsplus-types/effect__data": "0.1.0-
|
|
31
|
-
"@tsplus-types/effect__io": "0.1.11-
|
|
32
|
-
"@tsplus-types/effect__stream": "0.3.0-
|
|
33
|
-
"@tsplus-types/fp-ts__core": "0.2.
|
|
30
|
+
"@tsplus-types/effect__data": "0.1.0-bbebbef",
|
|
31
|
+
"@tsplus-types/effect__io": "0.1.11-bbebbef",
|
|
32
|
+
"@tsplus-types/effect__stream": "0.3.0-bbebbef",
|
|
33
|
+
"@tsplus-types/fp-ts__core": "0.2.1-bbebbef",
|
|
34
|
+
"@tsplus-types/fp-ts__schema": "0.1.3-bbebbef",
|
|
34
35
|
"@types/ws": "^8.5.4",
|
|
35
36
|
"dotenv": "^16.0.3",
|
|
36
37
|
"lerna": "^6.4.1",
|
|
37
38
|
"typescript": "https://cdn.jsdelivr.net/npm/@tsplus/installer@0.0.168/compiler/typescript.tgz"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
41
|
+
"@effect-http/client": "^0.1.16",
|
|
40
42
|
"@effect/data": "^0.1.0",
|
|
41
43
|
"@effect/io": "~0.1.11",
|
|
42
44
|
"@effect/stream": "~0.3.0",
|
|
@@ -50,5 +52,5 @@
|
|
|
50
52
|
"ws": "^8.12.0"
|
|
51
53
|
},
|
|
52
54
|
"sideEffects": false,
|
|
53
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "f55e7b932853fcca59ed727bf537f53d06d14ca2"
|
|
54
56
|
}
|