dfx 0.9.8 → 0.9.9

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 (124) hide show
  1. package/DiscordConfig/index.d.ts +39 -0
  2. package/DiscordConfig/index.js +29 -0
  3. package/DiscordConfig/index.js.map +1 -0
  4. package/DiscordGateway/DiscordWS/index.d.ts +23 -0
  5. package/DiscordGateway/DiscordWS/index.js +26 -0
  6. package/DiscordGateway/DiscordWS/index.js.map +1 -0
  7. package/DiscordGateway/Shard/heartbeats.d.ts +3 -0
  8. package/DiscordGateway/Shard/heartbeats.js +24 -0
  9. package/DiscordGateway/Shard/heartbeats.js.map +1 -0
  10. package/DiscordGateway/Shard/identify.d.ts +12 -0
  11. package/DiscordGateway/Shard/identify.js +30 -0
  12. package/DiscordGateway/Shard/identify.js.map +1 -0
  13. package/DiscordGateway/Shard/index.d.ts +9 -0
  14. package/DiscordGateway/Shard/index.js +52 -0
  15. package/DiscordGateway/Shard/index.js.map +1 -0
  16. package/DiscordGateway/Shard/invalidSession.d.ts +3 -0
  17. package/DiscordGateway/Shard/invalidSession.js +10 -0
  18. package/DiscordGateway/Shard/invalidSession.js.map +1 -0
  19. package/DiscordGateway/Shard/sendEvents.d.ts +7 -0
  20. package/DiscordGateway/Shard/sendEvents.js +26 -0
  21. package/DiscordGateway/Shard/sendEvents.js.map +1 -0
  22. package/DiscordGateway/Shard/utils.d.ts +3 -0
  23. package/DiscordGateway/Shard/utils.js +9 -0
  24. package/DiscordGateway/Shard/utils.js.map +1 -0
  25. package/DiscordGateway/ShardStore/index.d.ts +12 -0
  26. package/DiscordGateway/ShardStore/index.js +22 -0
  27. package/DiscordGateway/ShardStore/index.js.map +1 -0
  28. package/DiscordGateway/Sharder/index.d.ts +9 -0
  29. package/DiscordGateway/Sharder/index.js +61 -0
  30. package/DiscordGateway/Sharder/index.js.map +1 -0
  31. package/DiscordGateway/WS/index.d.ts +27 -0
  32. package/DiscordGateway/WS/index.js +82 -0
  33. package/DiscordGateway/WS/index.js.map +1 -0
  34. package/DiscordGateway/index.d.ts +20 -0
  35. package/DiscordGateway/index.js +27 -0
  36. package/DiscordGateway/index.js.map +1 -0
  37. package/DiscordREST/index.d.ts +12 -0
  38. package/DiscordREST/index.js +85 -0
  39. package/DiscordREST/index.js.map +1 -0
  40. package/DiscordREST/types.d.ts +9 -0
  41. package/DiscordREST/types.js +2 -0
  42. package/DiscordREST/types.js.map +1 -0
  43. package/DiscordREST/utils.d.ts +10 -0
  44. package/DiscordREST/utils.js +22 -0
  45. package/DiscordREST/utils.js.map +1 -0
  46. package/Helpers/flags.d.ts +27 -0
  47. package/Helpers/flags.js +36 -0
  48. package/Helpers/flags.js.map +1 -0
  49. package/Helpers/intents.d.ts +24 -0
  50. package/Helpers/intents.js +28 -0
  51. package/Helpers/intents.js.map +1 -0
  52. package/Helpers/interactions.d.ts +73 -0
  53. package/Helpers/interactions.js +93 -0
  54. package/Helpers/interactions.js.map +1 -0
  55. package/Helpers/members.d.ts +9 -0
  56. package/Helpers/members.js +10 -0
  57. package/Helpers/members.js.map +1 -0
  58. package/Helpers/permissions.d.ts +34 -0
  59. package/Helpers/permissions.js +69 -0
  60. package/Helpers/permissions.js.map +1 -0
  61. package/Helpers/ui.d.ts +47 -0
  62. package/Helpers/ui.js +67 -0
  63. package/Helpers/ui.js.map +1 -0
  64. package/Http/index.d.ts +30 -0
  65. package/Http/index.js +53 -0
  66. package/Http/index.js.map +1 -0
  67. package/Interactions/context.d.ts +36 -0
  68. package/Interactions/context.js +34 -0
  69. package/Interactions/context.js.map +1 -0
  70. package/Interactions/definitions.d.ts +60 -0
  71. package/Interactions/definitions.js +52 -0
  72. package/Interactions/definitions.js.map +1 -0
  73. package/Interactions/gateway.d.ts +6 -0
  74. package/Interactions/gateway.js +21 -0
  75. package/Interactions/gateway.js.map +1 -0
  76. package/Interactions/handlers.d.ts +8 -0
  77. package/Interactions/handlers.js +49 -0
  78. package/Interactions/handlers.js.map +1 -0
  79. package/Interactions/index.d.ts +17 -0
  80. package/Interactions/index.js +39 -0
  81. package/Interactions/index.js.map +1 -0
  82. package/Interactions/utils.d.ts +10 -0
  83. package/Interactions/utils.js +61 -0
  84. package/Interactions/utils.js.map +1 -0
  85. package/Interactions/webhook.d.ts +32 -0
  86. package/Interactions/webhook.js +42 -0
  87. package/Interactions/webhook.js.map +1 -0
  88. package/Log/index.d.ts +12 -0
  89. package/Log/index.js +19 -0
  90. package/Log/index.js.map +1 -0
  91. package/RateLimitStore/index.d.ts +24 -0
  92. package/RateLimitStore/index.js +24 -0
  93. package/RateLimitStore/index.js.map +1 -0
  94. package/RateLimitStore/memory.d.ts +2 -0
  95. package/RateLimitStore/memory.js +31 -0
  96. package/RateLimitStore/memory.js.map +1 -0
  97. package/RateLimitStore/utils.d.ts +2 -0
  98. package/RateLimitStore/utils.js +18 -0
  99. package/RateLimitStore/utils.js.map +1 -0
  100. package/common-gateway.d.ts +5 -0
  101. package/common-gateway.js +6 -0
  102. package/common-gateway.js.map +1 -0
  103. package/common.d.ts +28 -0
  104. package/common.js +16 -0
  105. package/common.js.map +1 -0
  106. package/global.d.ts +17 -0
  107. package/global.js +2 -0
  108. package/global.js.map +1 -0
  109. package/index.d.ts +21 -0
  110. package/index.js +29 -0
  111. package/index.js.map +1 -0
  112. package/package.json +2 -6
  113. package/types.d.ts +4228 -0
  114. package/types.js +1796 -0
  115. package/types.js.map +1 -0
  116. package/utils/effect.d.ts +2 -0
  117. package/utils/effect.js +2 -0
  118. package/utils/effect.js.map +1 -0
  119. package/utils/tsplus.d.ts +13 -0
  120. package/utils/tsplus.js +2 -0
  121. package/utils/tsplus.js.map +1 -0
  122. package/webhooks.d.ts +15 -0
  123. package/webhooks.js +23 -0
  124. package/webhooks.js.map +1 -0
@@ -0,0 +1,39 @@
1
+ import * as tsplus_module_1 from "dfx/common";
2
+ import * as tsplus_module_2 from "@effect/io/Effect";
3
+ export * from "./context.js";
4
+ export { global, guild, messageComponent, modalSubmit, autocomplete, } from "./definitions.js";
5
+ export { makeConfigLayer as makeWebhookConfig, makeHandler as makeWebhookHandler, WebhookConfig, WebhookParseError, BadWebhookSignature, } from "./webhook.js";
6
+ export class InteractionBuilder {
7
+ definitions;
8
+ constructor(definitions) {
9
+ this.definitions = definitions;
10
+ }
11
+ add(definition) {
12
+ return new InteractionBuilder([
13
+ ...this.definitions,
14
+ definition,
15
+ ]);
16
+ }
17
+ get syncGlobal() {
18
+ const commands = this.definitions
19
+ .filter((c) => c._tag === "GlobalApplicationCommand")
20
+ .map((c) => c.command);
21
+ return tsplus_module_2.flatMap((app) => tsplus_module_1.Rest.rest.bulkOverwriteGlobalApplicationCommands(app.id, {
22
+ body: JSON.stringify(commands),
23
+ }))(tsplus_module_2.flatMap((r) => r.json)(tsplus_module_1.Rest.rest
24
+ .getCurrentBotApplicationInformation()));
25
+ }
26
+ syncGuild(appId, guildId) {
27
+ const commands = this.definitions
28
+ .filter((c) => c._tag === "GuildApplicationCommand")
29
+ .map((c) => c.command);
30
+ return tsplus_module_1.Rest.rest.bulkOverwriteGuildApplicationCommands(appId, guildId, commands);
31
+ }
32
+ }
33
+ export const builder = new InteractionBuilder([]);
34
+ // Filters
35
+ export const id = (query) => (customId) => tsplus_module_2.succeed(query === customId);
36
+ export const idStartsWith = (query) => (customId) => tsplus_module_2.succeed(customId.startsWith(query));
37
+ export const regex = (query) => (customId) => tsplus_module_2.succeed(query.test(customId));
38
+ export const option = (name) => (focusedOption) => tsplus_module_2.succeed(focusedOption.name === name);
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Interactions/index.ts"],"names":[],"mappings":";;AAEA,cAAc,cAAc,CAAA;AAE5B,OAAO,EACL,MAAM,EACN,KAAK,EACL,gBAAgB,EAChB,WAAW,EACX,YAAY,GAGb,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EACL,eAAe,IAAI,iBAAiB,EACpC,WAAW,IAAI,kBAA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M,OAAO,GAAG,IAAI,kBAAkB,CAAe,EAAE,CAAC,CAAA;AAE/D,UAAU;AACV,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,QAAgB,EAAE,EAAE,CACxD,wBAAe,KAAK,KAAK,QAAQ,CAAC,CAAA;AAEpC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,QAAgB,EAAE,EAAE,CAClE,wBAAe,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAA;AAE5C,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,QAAgB,EAAE,EAAE,CAC3D,wBAAe,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEtC,MAAM,CAAC,MAAM,MAAM,GACjB,CAAC,IAAY,EAAE,EAAE,CACjB,CAAC,aAA8D,EAAE,EAAE,CACjE,wBAAe,aAAa,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA"}
@@ -0,0 +1,10 @@
1
+ import * as D from "./definitions.js";
2
+ export declare const splitDefinitions: <R, E>(definitions: D.InteractionDefinition<R, E>[]) => {
3
+ Commands: Record<string, D.GlobalApplicationCommand<R, E> | D.GuildApplicationCommand<R, E>>;
4
+ GlobalApplicationCommand: D.GlobalApplicationCommand<R, E>[];
5
+ GuildApplicationCommand: D.GuildApplicationCommand<R, E>[];
6
+ MessageComponent: D.MessageComponent<R, E>[];
7
+ ModalSubmit: D.ModalSubmit<R, E>[];
8
+ Autocomplete: D.Autocomplete<R, E>[];
9
+ };
10
+ export declare function fromHex(hexString: string): Uint8Array;
@@ -0,0 +1,61 @@
1
+ export const splitDefinitions = (definitions) => {
2
+ const grouped = definitions.reduce((acc, a) => ({
3
+ ...acc,
4
+ [a._tag]: [...(acc[a._tag] ?? []), a],
5
+ }), {
6
+ Autocomplete: [],
7
+ GlobalApplicationCommand: [],
8
+ GuildApplicationCommand: [],
9
+ MessageComponent: [],
10
+ ModalSubmit: [],
11
+ });
12
+ const Commands = [
13
+ ...grouped.GlobalApplicationCommand,
14
+ ...grouped.GuildApplicationCommand,
15
+ ].reduce((acc, a) => ({
16
+ ...acc,
17
+ [a.command.name]: a,
18
+ }), {});
19
+ return {
20
+ ...grouped,
21
+ Commands,
22
+ };
23
+ };
24
+ const MAP_HEX = {
25
+ 0: 0,
26
+ 1: 1,
27
+ 2: 2,
28
+ 3: 3,
29
+ 4: 4,
30
+ 5: 5,
31
+ 6: 6,
32
+ 7: 7,
33
+ 8: 8,
34
+ 9: 9,
35
+ a: 10,
36
+ b: 11,
37
+ c: 12,
38
+ d: 13,
39
+ e: 14,
40
+ f: 15,
41
+ A: 10,
42
+ B: 11,
43
+ C: 12,
44
+ D: 13,
45
+ E: 14,
46
+ F: 15,
47
+ };
48
+ export function fromHex(hexString) {
49
+ const bytes = new Uint8Array(Math.floor((hexString || "").length / 2));
50
+ let i;
51
+ for (i = 0; i < bytes.length; i++) {
52
+ const a = MAP_HEX[hexString[i * 2]];
53
+ const b = MAP_HEX[hexString[i * 2 + 1]];
54
+ if (a === undefined || b === undefined) {
55
+ break;
56
+ }
57
+ bytes[i] = (a << 4) | b;
58
+ }
59
+ return i === bytes.length ? bytes : bytes.slice(0, i);
60
+ }
61
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/Interactions/utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,WAA4C,EAC5C,EAAE;IACF,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAMhC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACX,GAAG,GAAG;QACN,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,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AA;IACtE,IAAI,CAAC,CAAA;IACL,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACjC,MAAM,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;QACnC,MAAM,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;QACvC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,EAAE;YACtC,MAAK;SACN;QACD,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;KACxB;IACD,OAAO,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AACvD,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { Discord, Effect, Cause } from "dfx/common";
2
+ import { InteractionBuilder } from "./index.js";
3
+ export declare class BadWebhookSignature {
4
+ readonly _tag = "BadWebhookSignature";
5
+ }
6
+ export type Headers = Record<string, string | string[] | undefined>;
7
+ export interface MakeConfigOpts {
8
+ applicationId: string;
9
+ publicKey: string;
10
+ }
11
+ declare const makeConfig: ({ applicationId, publicKey }: MakeConfigOpts) => {
12
+ applicationId: string;
13
+ publicKey: Uint8Array;
14
+ };
15
+ export interface WebhookConfig extends ReturnType<typeof makeConfig> {
16
+ }
17
+ export declare const WebhookConfig: import("../common.js").Tag<WebhookConfig>;
18
+ export declare const makeConfigLayer: (a_0: MakeConfigOpts) => import("../common.js").Layer<never, never, WebhookConfig>;
19
+ export declare class WebhookParseError {
20
+ readonly reason: unknown;
21
+ readonly _tag = "WebhookParseError";
22
+ constructor(reason: unknown);
23
+ }
24
+ export interface HandleWebhookOpts<E> {
25
+ headers: Headers;
26
+ body: string;
27
+ success: (a: Discord.InteractionResponse) => Effect<never, never, void>;
28
+ error: (e: Cause<E>) => Effect<never, never, void>;
29
+ empty: Effect<never, never, void>;
30
+ }
31
+ export declare const makeHandler: <R, E>(ix: InteractionBuilder<R, E>) => ({ headers, body, success, empty, error, }: HandleWebhookOpts<BadWebhookSignature | WebhookParseError | E>) => import("../common.js").Effect<WebhookConfig | R, never, void>;
32
+ export {};
@@ -0,0 +1,42 @@
1
+ import * as tsplus_module_1 from "@fp-ts/data/Option";
2
+ import * as tsplus_module_2 from "@fp-ts/data/Either";
3
+ import * as tsplus_module_3 from "dfx/common";
4
+ import * as tsplus_module_4 from "@effect/io/Layer";
5
+ import * as tsplus_module_5 from "@fp-ts/data/Function";
6
+ import * as tsplus_module_6 from "@effect/io/Effect";
7
+ import Nacl from "tweetnacl";
8
+ import { handlers } from "./handlers.js";
9
+ import { fromHex } from "./utils.js";
10
+ export class BadWebhookSignature {
11
+ _tag = "BadWebhookSignature";
12
+ }
13
+ const checkSignature = (publicKey, headers, body) => tsplus_module_2.asUnit(tsplus_module_1.toEither(() => new BadWebhookSignature())(tsplus_module_1.filter((a) => {
14
+ const enc = new TextEncoder();
15
+ return Nacl.sign.detached.verify(enc.encode(a.timestamp + body), fromHex(`${a.signature}`), publicKey);
16
+ })(tsplus_module_1.struct({
17
+ signature: tsplus_module_1.fromNullable(headers["x-signature-ed25519"]),
18
+ timestamp: tsplus_module_1.fromNullable(headers["x-signature-timestamp"]),
19
+ }))));
20
+ const makeConfig = ({ applicationId, publicKey }) => ({
21
+ applicationId,
22
+ publicKey: fromHex(publicKey),
23
+ });
24
+ export const WebhookConfig = tsplus_module_3.Tag();
25
+ export const makeConfigLayer = tsplus_module_5.flow(makeConfig, tsplus_module_4.succeed(WebhookConfig));
26
+ export class WebhookParseError {
27
+ reason;
28
+ _tag = "WebhookParseError";
29
+ constructor(reason) {
30
+ this.reason = reason;
31
+ }
32
+ }
33
+ const fromHeadersAndBody = (headers, body) => tsplus_module_6.flatMap(({ publicKey }) => tsplus_module_6.flatMap(() => tsplus_module_6.tryCatch(() => JSON.parse(body), (reason) => new WebhookParseError(reason)))(tsplus_module_6.fromEither(checkSignature(publicKey, headers, body))))(tsplus_module_6.service(WebhookConfig));
34
+ const run = (definitions) => {
35
+ const handler = handlers(definitions);
36
+ return (headers, body) => tsplus_module_6.flatMap(interaction => handler[interaction.type](interaction))(fromHeadersAndBody(headers, body));
37
+ };
38
+ export const makeHandler = (ix) => {
39
+ const handle = run(ix.definitions);
40
+ return ({ headers, body, success, empty, error, }) => tsplus_module_6.catchAllCause(error)(tsplus_module_6.flatMap((o) => tsplus_module_1.match(() => empty, (a) => success(a))(o))(handle(headers, body)));
41
+ };
42
+ //# sourceMappingURL=webhook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook.js","sourceRoot":"","sources":["../../src/Interactions/webhook.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,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,EAAE;IACZ,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,EAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC,EACzB,SAAS,CACV,CAAA;AACH,CAAC,EAXH,uBAAa;IACX,SAAS,EAAE,6BAAmB,OA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AAM,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,EACL,KAAK,GAC0D,EAAE,EAAE,CACnE,8BAOiB,KAAK,EAPtB,wBACW,CAAC,CAAC,EAAE,EAAE,CACb,sBACE,GAAG,EAAE,CAAC,KAAK,EACX,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAFnB,CAAC,CAGA,EALL,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAMlB,CACoB,CAAA;AAC3B,CAAC,CAAA"}
package/Log/index.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ declare const make: (debug?: boolean) => {
2
+ info: (...args: any[]) => import("../common.js").Effect<never, never, void>;
3
+ debug: (...args: any[]) => import("../common.js").Effect<never, never, void>;
4
+ };
5
+ export interface Log extends ReturnType<typeof make> {
6
+ }
7
+ export declare const Log: import("../common.js").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("../common.js").Effect<Log, never, void>;
11
+ export declare const debug: (...args: any[]) => import("../common.js").Effect<Log, never, void>;
12
+ export {};
package/Log/index.js ADDED
@@ -0,0 +1,19 @@
1
+ import * as tsplus_module_1 from "@effect/io/Effect";
2
+ import * as tsplus_module_2 from "dfx/common";
3
+ import * as tsplus_module_3 from "@effect/io/Layer";
4
+ const make = (debug = false) => ({
5
+ info: (...args) => tsplus_module_1.sync(() => {
6
+ console.error("INFO", ...args);
7
+ }),
8
+ debug: (...args) => debug
9
+ ? tsplus_module_1.sync(() => {
10
+ console.error("DEBUG", ...args);
11
+ })
12
+ : tsplus_module_1.unit(),
13
+ });
14
+ export const Log = tsplus_module_2.Tag();
15
+ export const LiveLog = tsplus_module_3.succeed(Log)(make(false));
16
+ export const LiveLogDebug = tsplus_module_3.succeed(Log)(make(true));
17
+ export const info = (...args) => tsplus_module_1.serviceWithEffect(Log)(({ info: log }) => log(...args));
18
+ export const debug = (...args) => tsplus_module_1.serviceWithEffect(Log)(({ debug }) => debug(...args));
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Log/index.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,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,wBAAc,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;AAE1D,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE,CACrC,kCAAyB,GAAG,CAAC,CAAC,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,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA"}
@@ -0,0 +1,24 @@
1
+ import { Effect, Maybe, Duration } from "dfx/common";
2
+ import { Success } from "dfx/utils/effect";
3
+ export type BucketDetails = {
4
+ key: "global" | string;
5
+ resetAfter: number;
6
+ limit: number;
7
+ };
8
+ export interface RateLimitStore {
9
+ hasBucket: (bucketKey: string) => Effect<never, never, boolean>;
10
+ putBucket: (bucket: BucketDetails) => Effect<never, never, void>;
11
+ getBucketForRoute: (route: string) => Effect<never, never, Maybe<BucketDetails>>;
12
+ putBucketRoute: (route: string, bucketKey: string) => Effect<never, never, void>;
13
+ incrementCounter: (key: string, window: number, limit: number) => Effect<never, never, readonly [count: number, ttl: number]>;
14
+ }
15
+ export declare const RateLimitStore: import("../common.js").Tag<RateLimitStore>;
16
+ export declare const LiveMemoryRateLimitStore: import("../common.js").Layer<never, never, RateLimitStore>;
17
+ declare const makeLimiter: import("../common.js").Effect<import("../Log/index.js").Log | RateLimitStore, never, {
18
+ maybeWait: (key: string, window: Duration, limit: number, multiplier?: number) => import("../common.js").Effect<never, never, void>;
19
+ }>;
20
+ export interface RateLimiter extends Success<typeof makeLimiter> {
21
+ }
22
+ export declare const RateLimiter: import("../common.js").Tag<RateLimiter>;
23
+ export declare const LiveRateLimiter: import("../common.js").Layer<import("../Log/index.js").Log | RateLimitStore, never, RateLimiter>;
24
+ export {};
@@ -0,0 +1,24 @@
1
+ import * as tsplus_module_1 from "dfx/common";
2
+ import * as tsplus_module_2 from "@effect/io/Layer";
3
+ import * as tsplus_module_3 from "@effect/io/Effect";
4
+ import { delayFrom } from "./utils.js";
5
+ import * as Memory from "./memory.js";
6
+ export const RateLimitStore = tsplus_module_1.Tag();
7
+ export const LiveMemoryRateLimitStore = tsplus_module_2.sync(RateLimitStore)(Memory.make);
8
+ const makeLimiter = tsplus_module_3.flatMap(store => tsplus_module_3.map(log => {
9
+ const maybeWait = (key, window, limit, multiplier = 1.05) => {
10
+ const windowMs = window.millis * multiplier;
11
+ return tsplus_module_3.asUnit(tsplus_module_3.tap(tsplus_module_3.sleep)(tsplus_module_3.tap((d) => log.debug("RateLimitStore maybeWait", {
12
+ key,
13
+ window: window.millis,
14
+ windowMs,
15
+ limit,
16
+ delay: d.millis,
17
+ }))(tsplus_module_3.map(([count, ttl]) => delayFrom(windowMs, limit, count, ttl))(store
18
+ .incrementCounter(key, windowMs, limit)))));
19
+ };
20
+ return { maybeWait };
21
+ })(tsplus_module_3.service(tsplus_module_1.Log.Log)))(tsplus_module_3.service(RateLimitStore));
22
+ export const RateLimiter = tsplus_module_1.Tag();
23
+ export const LiveRateLimiter = tsplus_module_2.fromEffect(RateLimiter)(makeLimiter);
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/RateLimitStore/index.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AA6BrC,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAA,GAAG,EAAkB,CAAA;AACnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAAW,cAAc,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAE/E,MAAM,WAAW,2BACT,KAAK,wBACL,GAAG;IAET,MAAM,SAAS,GAAG,CAChB,GAAW,EACX,MAAgB,EAChB,KAAa,EACb,UAAU,GAAG,IAAI,EACjB,EAAE;QACF,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,GAAG,UAAU,CAAA;QAC3C,8BAAO,2CAAA,oBAGA,CAAC,CAAC,EAAE,EAAE,CACT,GAAG,CAAC,KAAK,CAAC,0BAA0B,EAAE;YACpC,GAAG;YACH,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ;YACR,KAAK;YACL,KAAK,EAAE,CAAC,CAAC,MAAM;SAChB,CAAC,EAVC,oBAEA,CAAC,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,EAFxD,KAAK;aACT,gBAAgB,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,CACuB,CAS7D,CACiB,EAAO;IAC7B,CAAC,CAAA;IAED,OAAO,EAAE,SAAS,EAAE,CAAA;GAxBN,wBAAe,gBAAA,GAAG,CAAC,GAAG,CAAC,GADrB,wBAAe,cAAc,CAAC,CA0B9C,CAAA;AAGF,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAA,GAAG,EAAe,CAAA;AAC7C,MAAM,CAAC,MAAM,eAAe,GAAG,2BAAiB,WAAW,CAAC,CAAC,WAAW,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { RateLimitStore } from "dfx/common";
2
+ export declare const make: () => RateLimitStore.RateLimitStore;
@@ -0,0 +1,31 @@
1
+ import * as tsplus_module_1 from "@fp-ts/data/Option";
2
+ import * as tsplus_module_2 from "@effect/io/Effect";
3
+ export const make = () => {
4
+ const buckets = new Map();
5
+ const routes = new Map();
6
+ const counters = new Map();
7
+ const getCounter = (key) => tsplus_module_1.filter((c) => c.expires > Date.now())(tsplus_module_1.fromNullable(counters.get(key)));
8
+ return {
9
+ hasBucket: (key) => tsplus_module_2.sync(() => buckets.has(key)),
10
+ putBucket: (bucket) => tsplus_module_2.sync(() => {
11
+ buckets.set(bucket.key, bucket);
12
+ }),
13
+ getBucketForRoute: (route) => tsplus_module_2.sync(() => tsplus_module_1.fromNullable(buckets.get(routes.get(route)))),
14
+ putBucketRoute: (route, bucket) => tsplus_module_2.sync(() => {
15
+ routes.set(route, bucket);
16
+ }),
17
+ incrementCounter: (key, window, limit) => tsplus_module_2.sync(() => {
18
+ const now = Date.now();
19
+ const perRequest = Math.ceil(window / limit);
20
+ const counter = tsplus_module_1.getOrElse(() => ({
21
+ expires: now,
22
+ count: 0,
23
+ }))(getCounter(key));
24
+ const count = counter.count + 1;
25
+ const expires = counter.expires + perRequest;
26
+ counters.set(key, { ...counter, count, expires });
27
+ return [count, expires - now];
28
+ }),
29
+ };
30
+ };
31
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/RateLimitStore/memory.ts"],"names":[],"mappings":";;AAKA,MAAM,CAAC,MAAM,IAAI,GAAG,GAAkC,EAAE;IACtD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAwC,CAAA;IAC/D,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,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,EAA1E,6BAAmB,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAsC,CAAA;IAE7E,OAAO;QACL,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,qBAAY,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEvD,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CACpB,qBAAY,GAAG,EAAE;YACf,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACjC,CAAC,CAAC;QAEJ,iBAAiB,EAAE,CAAC,KAAK,EAAE,EAAE,CAC3B,qBAAY,GAAG,EAAE,CAAC,6BAAmB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC,CAAC,CAAC;QAExE,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAChC,qBAAY,GAAG,EAAE;YACf,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAC3B,CAAC,CAAC;QAEJ,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CACvC,qBAAY,GAAG,EAAE;YACf,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;YACtB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAA;YAC5C,MAAM,OAAO,GAAG,0BACd,GAAY,EAAE,CAAC,CAAC;gBACd,OAAO,EAAE,GAAG;gBACZ,KAAK,EAAE,CAAC;aACT,CAAC,EAJY,UAAU,CAAC,GAAG,CAAC,CAK9B,CAAA;YAED,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,GAAG,CAAC,CAAA;YAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,GAAG,UAAU,CAAA;YAC5C,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;YAEjD,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,CAAC,CAAA;QAC/B,CAAC,CAAC;KACL,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { Duration } from "dfx/common";
2
+ export declare const delayFrom: (window: number, limit: number, count: number, ttl: number) => Duration;
@@ -0,0 +1,18 @@
1
+ import { millis, zero } from "@fp-ts/data/Duration";
2
+ export const delayFrom = (window, limit, count, ttl) => {
3
+ const perRequest = Math.ceil(window / limit);
4
+ const totalTime = count * perRequest;
5
+ const elapsedTime = totalTime - ttl;
6
+ const elapsedWindows = Math.floor(elapsedTime / window);
7
+ const completedRequests = elapsedWindows * limit;
8
+ const remainingRequests = count - completedRequests;
9
+ const remainingWindows = Math.floor((remainingRequests - 1) / limit);
10
+ const delayRemainder = elapsedTime % window;
11
+ const requestRemainder = count % limit;
12
+ const staggerDelay = requestRemainder * 50;
13
+ if (remainingWindows === 0) {
14
+ return zero;
15
+ }
16
+ return millis(remainingWindows * window - delayRemainder + staggerDelay);
17
+ };
18
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/RateLimitStore/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAEnD,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,MAAc,EACd,KAAa,EACb,KAAa,EACb,GAAW,EACD,EAAE;IACZ,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAA;IAE5C,MAAM,SAAS,GAAG,KAAK,GAAG,UAAU,CAAA;IACpC,MAAM,WAAW,GAAG,SAAS,GAAG,GAAG,CAAA;IACnC,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC,CAAA;IACvD,MAAM,iBAAiB,GAAG,cAAc,GAAG,KAAK,CAAA;IAChD,MAAM,iBAAiB,GAAG,KAAK,GAAG,iBAAiB,CAAA;IACnD,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,iBAAiB,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAA;IACpE,MAAM,cAAc,GAAG,WAAW,GAAG,MAAM,CAAA;IAE3C,MAAM,gBAAgB,GAAG,KAAK,GAAG,KAAK,CAAA;IACtC,MAAM,YAAY,GAAG,gBAAgB,GAAG,EAAE,CAAA;IAE1C,IAAI,gBAAgB,KAAK,CAAC,EAAE;QAC1B,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,MAAM,CAAC,gBAAgB,GAAG,MAAM,GAAG,cAAc,GAAG,YAAY,CAAC,CAAA;AAC1E,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ export * as Gateway from "dfx/DiscordGateway/index";
2
+ export * as WS from "dfx/DiscordGateway/WS/index";
3
+ export * as DWS from "dfx/DiscordGateway/DiscordWS/index";
4
+ export * as Shard from "dfx/DiscordGateway/Shard/index";
5
+ export * as ShardStore from "dfx/DiscordGateway/ShardStore/index";
@@ -0,0 +1,6 @@
1
+ export * as Gateway from "dfx/DiscordGateway/index";
2
+ export * as WS from "dfx/DiscordGateway/WS/index";
3
+ export * as DWS from "dfx/DiscordGateway/DiscordWS/index";
4
+ export * as Shard from "dfx/DiscordGateway/Shard/index";
5
+ export * as ShardStore from "dfx/DiscordGateway/ShardStore/index";
6
+ //# sourceMappingURL=common-gateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common-gateway.js","sourceRoot":"","sources":["../src/common-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AACnD,OAAO,KAAK,EAAE,MAAM,6BAA6B,CAAA;AACjD,OAAO,KAAK,GAAG,MAAM,oCAAoC,CAAA;AACzD,OAAO,KAAK,KAAK,MAAM,gCAAgC,CAAA;AACvD,OAAO,KAAK,UAAU,MAAM,qCAAqC,CAAA"}
package/common.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ export { Effect, EffectTypeId } from "@effect/io/Effect";
2
+ export type { Layer } from "@effect/io/Layer";
3
+ export type { Schedule } from "@effect/io/Schedule";
4
+ export type { Cause } from "@effect/io/Cause";
5
+ export type { Chunk } from "@fp-ts/data/Chunk";
6
+ export { Context, Tag } from "@fp-ts/data/Context";
7
+ export type { Duration } from "@fp-ts/data/Duration";
8
+ export type { Equal } from "@fp-ts/data/Equal";
9
+ export type { Option as Maybe } from "@fp-ts/data/Option";
10
+ export type { Either } from "@fp-ts/data/Either";
11
+ export type { Exit } from "@effect/io/Exit";
12
+ export type { EffectSource } from "callbag-effect-ts/Source";
13
+ export type { EffectSink } from "callbag-effect-ts/Sink";
14
+ export type { HashMap } from "@fp-ts/data/HashMap";
15
+ export type { Ref } from "@effect/io/Ref";
16
+ export * as Config from "dfx/DiscordConfig/index";
17
+ export * as Discord from "dfx/types";
18
+ export * as Http from "dfx/Http/index";
19
+ export * as Log from "dfx/Log/index";
20
+ export * as RateLimitStore from "dfx/RateLimitStore/index";
21
+ export * as Rest from "dfx/DiscordREST/index";
22
+ export * as Ix from "dfx/Interactions/index";
23
+ export * as Flags from "./Helpers/flags.js";
24
+ export * as IxHelpers from "./Helpers/interactions.js";
25
+ export * as Intents from "./Helpers/intents.js";
26
+ export * as Members from "./Helpers/members.js";
27
+ export * as Perms from "./Helpers/permissions.js";
28
+ export * as UI from "./Helpers/ui.js";
package/common.js ADDED
@@ -0,0 +1,16 @@
1
+ export { EffectTypeId } from "@effect/io/Effect";
2
+ export { Tag } from "@fp-ts/data/Context";
3
+ export * as Config from "dfx/DiscordConfig/index";
4
+ export * as Discord from "dfx/types";
5
+ export * as Http from "dfx/Http/index";
6
+ export * as Log from "dfx/Log/index";
7
+ export * as RateLimitStore from "dfx/RateLimitStore/index";
8
+ export * as Rest from "dfx/DiscordREST/index";
9
+ export * as Ix from "dfx/Interactions/index";
10
+ export * as Flags from "./Helpers/flags.js";
11
+ export * as IxHelpers from "./Helpers/interactions.js";
12
+ export * as Intents from "./Helpers/intents.js";
13
+ export * as Members from "./Helpers/members.js";
14
+ export * as Perms from "./Helpers/permissions.js";
15
+ export * as UI from "./Helpers/ui.js";
16
+ //# sourceMappingURL=common.js.map
package/common.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAKxD,OAAO,EAAW,GAAG,EAAE,MAAM,qBAAqB,CAAA;AAWlD,OAAO,KAAK,MAAM,MAAM,yBAAyB,CAAA;AACjD,OAAO,KAAK,OAAO,MAAM,WAAW,CAAA;AACpC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,GAAG,MAAM,eAAe,CAAA;AACpC,OAAO,KAAK,cAAc,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAA;AAC7C,OAAO,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAE5C,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAC3C,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAA;AAC/C,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,iBAAiB,CAAA"}
package/global.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @tsplus global
3
+ */
4
+ import type { Effect, EffectTypeId, Layer, Either, Maybe, Tag, Context, Cause, Chunk, Duration, Equal, Exit, HashMap, Schedule, EffectSource, EffectSink, Ref, Config, Discord, Http, Log, RateLimitStore, Rest, Ix, Flags, Intents, IxHelpers, Members, Perms, UI, } from "dfx/common";
5
+ /**
6
+ * @tsplus global
7
+ */
8
+ import type { Gateway, WS, DWS, Shard, ShardStore } from "dfx/common-gateway";
9
+ /**
10
+ * @tsplus global
11
+ */
12
+ import type { Success } from "dfx/utils/effect";
13
+ /**
14
+ * @tsplus global
15
+ */
16
+ import { pipe, flow, identity } from "@fp-ts/data/Function";
17
+ export {};
package/global.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=global.js.map
package/global.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global.js","sourceRoot":"","sources":["../src/global.ts"],"names":[],"mappings":""}
package/index.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import { Config } from "dfx/common";
2
+ export * as Discord from "./types.js";
3
+ export * as Config from "./DiscordConfig/index.js";
4
+ export * as DiscordWS from "./DiscordGateway/DiscordWS/index.js";
5
+ export * as Gateway from "./DiscordGateway/index.js";
6
+ export { DiscordREST, LiveDiscordREST, rest } from "./DiscordREST/index.js";
7
+ export * as Ix from "./Interactions/index.js";
8
+ export { run as runIxGateway } from "./Interactions/gateway.js";
9
+ export * as Log from "./Log/index.js";
10
+ export * as RateLimitStore from "./RateLimitStore/index.js";
11
+ export * as Flags from "./Helpers/flags.js";
12
+ export * as Intents from "./Helpers/intents.js";
13
+ export * as IxHelpers from "./Helpers/interactions.js";
14
+ export * as Members from "./Helpers/members.js";
15
+ export * as Perms from "./Helpers/permissions.js";
16
+ export * as UI from "./Helpers/ui.js";
17
+ export declare const LiveRateLimit: import("./common.js").Layer<import("./Log/index.js").Log, never, import("./RateLimitStore/index.js").RateLimitStore | import("./RateLimitStore/index.js").RateLimiter>;
18
+ export declare const LiveREST: import("./common.js").Layer<import("./DiscordConfig/index.js").DiscordConfig | import("./Log/index.js").Log, never, import("./DiscordREST/index.js").DiscordREST | import("./RateLimitStore/index.js").RateLimitStore | import("./RateLimitStore/index.js").RateLimiter>;
19
+ export declare const LiveGateway: import("./common.js").Layer<import("./DiscordREST/index.js").DiscordREST | import("./DiscordConfig/index.js").DiscordConfig | import("./Log/index.js").Log | import("./RateLimitStore/index.js").RateLimiter, never, import("./DiscordGateway/ShardStore/index.js").ShardStore | import("./DiscordGateway/DiscordWS/index.js").DiscordWSCodec | import("./DiscordGateway/index.js").DiscordGateway>;
20
+ export declare const LiveBot: import("./common.js").Layer<import("./DiscordConfig/index.js").DiscordConfig | import("./Log/index.js").Log, never, import("./DiscordGateway/ShardStore/index.js").ShardStore | import("./DiscordREST/index.js").DiscordREST | import("./RateLimitStore/index.js").RateLimitStore | import("./RateLimitStore/index.js").RateLimiter | import("./DiscordGateway/DiscordWS/index.js").DiscordWSCodec | import("./DiscordGateway/index.js").DiscordGateway>;
21
+ export declare const makeLayer: (config: Config.MakeOpts, debug?: boolean) => import("./common.js").Layer<never, never, import("./DiscordGateway/ShardStore/index.js").ShardStore | import("./DiscordREST/index.js").DiscordREST | import("./DiscordConfig/index.js").DiscordConfig | import("./Log/index.js").Log | import("./RateLimitStore/index.js").RateLimitStore | import("./RateLimitStore/index.js").RateLimiter | import("./DiscordGateway/DiscordWS/index.js").DiscordWSCodec | import("./DiscordGateway/index.js").DiscordGateway>;
package/index.js ADDED
@@ -0,0 +1,29 @@
1
+ import * as tsplus_module_1 from "dfx/common";
2
+ import * as tsplus_module_2 from "@effect/io/Layer";
3
+ import * as tsplus_module_3 from "dfx/common-gateway";
4
+ export * as Discord from "./types.js";
5
+ export * as Config from "./DiscordConfig/index.js";
6
+ export * as DiscordWS from "./DiscordGateway/DiscordWS/index.js";
7
+ export * as Gateway from "./DiscordGateway/index.js";
8
+ export { DiscordREST, LiveDiscordREST, rest } from "./DiscordREST/index.js";
9
+ export * as Ix from "./Interactions/index.js";
10
+ export { run as runIxGateway } from "./Interactions/gateway.js";
11
+ export * as Log from "./Log/index.js";
12
+ export * as RateLimitStore from "./RateLimitStore/index.js";
13
+ export * as Flags from "./Helpers/flags.js";
14
+ export * as Intents from "./Helpers/intents.js";
15
+ export * as IxHelpers from "./Helpers/interactions.js";
16
+ export * as Members from "./Helpers/members.js";
17
+ export * as Perms from "./Helpers/permissions.js";
18
+ export * as UI from "./Helpers/ui.js";
19
+ export const LiveRateLimit = tsplus_module_2.provideToAndMerge(tsplus_module_1.RateLimitStore.LiveRateLimiter)(tsplus_module_1.RateLimitStore.LiveMemoryRateLimitStore);
20
+ export const LiveREST = tsplus_module_2.provideToAndMerge(tsplus_module_1.Rest.LiveDiscordREST)(LiveRateLimit);
21
+ export const LiveGateway = tsplus_module_2.provideToAndMerge(tsplus_module_3.Gateway.LiveDiscordGateway)(tsplus_module_2.merge(tsplus_module_3.DWS.LiveJsonDiscordWSCodec)(tsplus_module_3.ShardStore.LiveMemoryShardStore));
22
+ export const LiveBot = tsplus_module_2.provideToAndMerge(LiveGateway)(LiveREST);
23
+ export const makeLayer = (config, debug = false) => {
24
+ const LiveLog = debug ? tsplus_module_1.Log.LiveLogDebug : tsplus_module_1.Log.LiveLog;
25
+ const LiveConfig = tsplus_module_1.Config.makeLayer(config);
26
+ const LiveEnv = tsplus_module_2.provideToAndMerge(LiveBot)(tsplus_module_2.merge(LiveConfig)(LiveLog));
27
+ return LiveEnv;
28
+ };
29
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAA;AAErC,OAAO,KAAK,MAAM,MAAM,0BAA0B,CAAA;AAClD,OAAO,KAAK,SAAS,MAAM,qCAAqC,CAAA;AAChE,OAAO,KAAK,OAAO,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAC3E,OAAO,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAC7C,OAAO,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,cAAc,MAAM,2BAA2B,CAAA;AAE3D,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;AAErC,MAAM,CAAC,MAAM,aAAa,qCACkB,gBAAA,cAAc,CAAC,eAAe,EAAxE,gBAAA,cAAc,CAAC,wBAAwB,CAAiC,CAAA;AAE1E,MAAM,CAAC,MAAM,QAAQ,qCAAmB,gBAAA,IAAI,CAAC,eAAe,EAApC,aAAa,CAAuB,CAAA;AAE5D,MAAM,CAAC,MAAM,WAAW,qCAEtB,gBAAA,OAAO,CAAC,kBAAkB,wBADQ,gBAAA,GAAG,CAAC,sBAAsB,EAA5D,gBAAA,UAAU,CAAC,oBAAoB,EACL,CAAA;AAE5B,MAAM,CAAC,MAAM,OAAO,qCAAc,WAAW,EAAtB,QAAQ,CAAc,CAAA;AAE7C,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAuB,EAAE,KAAK,GAAG,KAAK,EAAE,EAAE;IAClE,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,gBAAA,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,gBAAA,GAAG,CAAC,OAAO,CAAA;IACtD,MAAM,UAAU,GAAG,gBAAA,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IAC3C,MAAM,OAAO,qCAA0B,OAAO,wBAApB,UAAU,EAApB,OAAO,EAAuB,CAAA;IAE9C,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,15 +1,11 @@
1
1
  {
2
2
  "name": "dfx",
3
- "version": "0.9.8",
3
+ "version": "0.9.9",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "directory": "dist"
8
8
  },
9
- "files": [
10
- "dist/**/*",
11
- "src/**/*"
12
- ],
13
9
  "description": "Effect-TS discord library",
14
10
  "author": "Tim Smart <hello@timsmart.co>",
15
11
  "license": "MIT",
@@ -51,5 +47,5 @@
51
47
  "@fp-ts/data": "^0.0.20"
52
48
  }
53
49
  },
54
- "gitHead": "0ab77f759cddf4f9a2ac80dda27618ec436f931a"
50
+ "gitHead": "b94a1fc4fe18fd53b8188a9154cc4bebff14b9a6"
55
51
  }