dfx 0.20.5 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/Cache/driver.d.ts +16 -16
  2. package/Cache/driver.js.map +1 -1
  3. package/Cache/index.d.ts +21 -21
  4. package/Cache/index.js +12 -13
  5. package/Cache/index.js.map +1 -1
  6. package/Cache/memory.d.ts +3 -3
  7. package/Cache/memory.js +19 -20
  8. package/Cache/memory.js.map +1 -1
  9. package/Cache/memoryTTL.d.ts +5 -5
  10. package/Cache/memoryTTL.js +16 -16
  11. package/Cache/memoryTTL.js.map +1 -1
  12. package/Cache/prelude.d.ts +41 -41
  13. package/Cache/prelude.js +39 -41
  14. package/Cache/prelude.js.map +1 -1
  15. package/DiscordConfig/index.d.ts +4 -19
  16. package/DiscordConfig/index.js +5 -12
  17. package/DiscordConfig/index.js.map +1 -1
  18. package/DiscordGateway/DiscordWS/index.d.ts +9 -9
  19. package/DiscordGateway/DiscordWS/index.js +16 -20
  20. package/DiscordGateway/DiscordWS/index.js.map +1 -1
  21. package/DiscordGateway/Shard/heartbeats.d.ts +3 -4
  22. package/DiscordGateway/Shard/heartbeats.js +9 -16
  23. package/DiscordGateway/Shard/heartbeats.js.map +1 -1
  24. package/DiscordGateway/Shard/identify.d.ts +4 -4
  25. package/DiscordGateway/Shard/identify.js +5 -4
  26. package/DiscordGateway/Shard/identify.js.map +1 -1
  27. package/DiscordGateway/Shard/index.d.ts +8 -7
  28. package/DiscordGateway/Shard/index.js +17 -20
  29. package/DiscordGateway/Shard/index.js.map +1 -1
  30. package/DiscordGateway/Shard/invalidSession.d.ts +2 -3
  31. package/DiscordGateway/Shard/invalidSession.js +5 -8
  32. package/DiscordGateway/Shard/invalidSession.js.map +1 -1
  33. package/DiscordGateway/Shard/sendEvents.d.ts +1 -1
  34. package/DiscordGateway/Shard/sendEvents.js +7 -7
  35. package/DiscordGateway/Shard/sendEvents.js.map +1 -1
  36. package/DiscordGateway/Shard/utils.d.ts +3 -4
  37. package/DiscordGateway/Shard/utils.js +6 -6
  38. package/DiscordGateway/Shard/utils.js.map +1 -1
  39. package/DiscordGateway/ShardStore/index.d.ts +6 -6
  40. package/DiscordGateway/ShardStore/index.js +7 -10
  41. package/DiscordGateway/ShardStore/index.js.map +1 -1
  42. package/DiscordGateway/Sharder/index.d.ts +11 -11
  43. package/DiscordGateway/Sharder/index.js +21 -42
  44. package/DiscordGateway/Sharder/index.js.map +1 -1
  45. package/DiscordGateway/WS/index.d.ts +3 -2
  46. package/DiscordGateway/WS/index.js +30 -40
  47. package/DiscordGateway/WS/index.js.map +1 -1
  48. package/DiscordGateway/index.d.ts +8 -9
  49. package/DiscordGateway/index.js +10 -15
  50. package/DiscordGateway/index.js.map +1 -1
  51. package/DiscordREST/index.d.ts +132 -132
  52. package/DiscordREST/index.js +37 -40
  53. package/DiscordREST/index.js.map +1 -1
  54. package/DiscordREST/types.d.ts +6 -6
  55. package/DiscordREST/utils.d.ts +5 -4
  56. package/DiscordREST/utils.js +5 -5
  57. package/DiscordREST/utils.js.map +1 -1
  58. package/Helpers/intents.js +8 -8
  59. package/Helpers/intents.js.map +1 -1
  60. package/Helpers/interactions.d.ts +18 -19
  61. package/Helpers/interactions.js +22 -23
  62. package/Helpers/interactions.js.map +1 -1
  63. package/Helpers/members.d.ts +2 -2
  64. package/Helpers/members.js.map +1 -1
  65. package/Helpers/permissions.d.ts +4 -4
  66. package/Helpers/permissions.js +13 -13
  67. package/Helpers/permissions.js.map +1 -1
  68. package/Http/index.d.ts +10 -9
  69. package/Http/index.js +7 -8
  70. package/Http/index.js.map +1 -1
  71. package/Interactions/context.d.ts +22 -23
  72. package/Interactions/context.js +21 -21
  73. package/Interactions/context.js.map +1 -1
  74. package/Interactions/definitions.d.ts +31 -31
  75. package/Interactions/definitions.js +1 -2
  76. package/Interactions/definitions.js.map +1 -1
  77. package/Interactions/gateway.d.ts +4 -3
  78. package/Interactions/gateway.js +6 -6
  79. package/Interactions/gateway.js.map +1 -1
  80. package/Interactions/handlers.d.ts +3 -4
  81. package/Interactions/handlers.js +23 -23
  82. package/Interactions/handlers.js.map +1 -1
  83. package/Interactions/index.d.ts +11 -11
  84. package/Interactions/index.js +11 -10
  85. package/Interactions/index.js.map +1 -1
  86. package/Interactions/webhook.d.ts +7 -8
  87. package/Interactions/webhook.js +11 -12
  88. package/Interactions/webhook.js.map +1 -1
  89. package/Log/index.d.ts +8 -7
  90. package/Log/index.js +9 -11
  91. package/Log/index.js.map +1 -1
  92. package/RateLimit/index.d.ts +13 -12
  93. package/RateLimit/index.js +11 -12
  94. package/RateLimit/index.js.map +1 -1
  95. package/RateLimit/memory.d.ts +1 -1
  96. package/RateLimit/memory.js +7 -7
  97. package/RateLimit/memory.js.map +1 -1
  98. package/RateLimit/utils.d.ts +2 -2
  99. package/RateLimit/utils.js.map +1 -1
  100. package/_common.d.ts +19 -0
  101. package/_common.js +20 -0
  102. package/_common.js.map +1 -0
  103. package/gateway.d.ts +11 -10
  104. package/gateway.js +17 -14
  105. package/gateway.js.map +1 -1
  106. package/package.json +5 -15
  107. package/utils/effect.d.ts +8 -8
  108. package/utils/effect.js +4 -4
  109. package/utils/effect.js.map +1 -1
  110. package/webhooks.d.ts +6 -5
  111. package/webhooks.js +12 -8
  112. package/webhooks.js.map +1 -1
  113. package/global.d.ts +0 -21
  114. package/global.js +0 -2
  115. package/global.js.map +0 -1
  116. package/utils/common.d.ts +0 -18
  117. package/utils/common.js +0 -3
  118. package/utils/common.js.map +0 -1
@@ -1,5 +1,4 @@
1
- import { Discord } from "dfx";
2
- import { Effect, Cause } from "dfx/utils/common";
1
+ import { Cause, Context, Discord, Effect, Layer } from "dfx/_common";
3
2
  import { DefinitionNotFound } from "./handlers.js";
4
3
  import { InteractionBuilder } from "./index.js";
5
4
  export declare class BadWebhookSignature {
@@ -16,8 +15,8 @@ declare const makeConfig: ({ applicationId, publicKey }: MakeConfigOpts) => {
16
15
  };
17
16
  export interface WebhookConfig extends ReturnType<typeof makeConfig> {
18
17
  }
19
- export declare const WebhookConfig: import("../utils/common.js").Tag<WebhookConfig>;
20
- export declare const makeConfigLayer: (a_0: MakeConfigOpts) => import("../utils/common.js").Layer<never, never, WebhookConfig>;
18
+ export declare const WebhookConfig: Context.Tag<WebhookConfig>;
19
+ export declare const makeConfigLayer: (a_0: MakeConfigOpts) => Layer.Layer<never, never, WebhookConfig>;
21
20
  export declare class WebhookParseError {
22
21
  readonly reason: unknown;
23
22
  readonly _tag = "WebhookParseError";
@@ -26,14 +25,14 @@ export declare class WebhookParseError {
26
25
  export interface HandleWebhookOpts<E> {
27
26
  headers: Headers;
28
27
  body: string;
29
- success: (a: Discord.InteractionResponse) => Effect<never, never, void>;
30
- error: (e: Cause<E>) => Effect<never, never, void>;
28
+ success: (a: Discord.InteractionResponse) => Effect.Effect<never, never, void>;
29
+ error: (e: Cause.Cause<E>) => Effect.Effect<never, never, void>;
31
30
  }
32
31
  /**
33
32
  * @tsplus getter dfx/InteractionBuilder webhookHandler
34
33
  * @tsplus location "dfx/Interactions/webhook"
35
34
  */
36
- export declare const makeHandler: <R, E>(ix: InteractionBuilder<R, E>) => ({ headers, body, success, error, }: HandleWebhookOpts<DefinitionNotFound | BadWebhookSignature | WebhookParseError | E>) => import("../utils/common.js").Effect<WebhookConfig | Exclude<R, import("../types.js").Interaction>, never, void>;
35
+ export declare const makeHandler: <R, E>(ix: InteractionBuilder<R, E>) => ({ headers, body, success, error, }: HandleWebhookOpts<DefinitionNotFound | BadWebhookSignature | WebhookParseError | E>) => Effect.Effect<WebhookConfig | Exclude<R, Discord.Interaction>, never, void>;
37
36
  /**
38
37
  * @tsplus getter dfx/InteractionBuilder simpleWebhookHandler
39
38
  * @tsplus location "dfx/Interactions/webhook"
@@ -41,5 +40,5 @@ export declare const makeHandler: <R, E>(ix: InteractionBuilder<R, E>) => ({ hea
41
40
  export declare const makeSimpleHandler: <R, E>(ix: InteractionBuilder<R, E>) => ({ headers, body }: {
42
41
  headers: Headers;
43
42
  body: string;
44
- }) => import("../utils/common.js").Effect<WebhookConfig | Exclude<R, import("../types.js").Interaction>, DefinitionNotFound | BadWebhookSignature | WebhookParseError | E, import("../types.js").InteractionResponse>;
43
+ }) => Effect.Effect<WebhookConfig | Exclude<R, Discord.Interaction>, DefinitionNotFound | BadWebhookSignature | WebhookParseError | E, Discord.InteractionResponse>;
45
44
  export {};
@@ -1,8 +1,7 @@
1
1
  import * as tsplus_module_1 from "@fp-ts/data/Option";
2
2
  import * as tsplus_module_2 from "@fp-ts/data/Either";
3
- import * as tsplus_module_3 from "dfx/utils/common";
4
- import * as tsplus_module_4 from "@effect/io/Layer";
5
- import * as tsplus_module_5 from "@effect/io/Effect";
3
+ import * as tsplus_module_3 from "@effect/io/Effect";
4
+ import { Context, Effect, flow, Layer, Option, } from "dfx/_common";
6
5
  import Nacl from "tweetnacl";
7
6
  import { handlers } from "./handlers.js";
8
7
  import { InteractionContext } from "./index.js";
@@ -13,16 +12,16 @@ export class BadWebhookSignature {
13
12
  const checkSignature = (publicKey, headers, body) => tsplus_module_2.asUnit(tsplus_module_1.toEither(() => new BadWebhookSignature())(tsplus_module_1.filter((a) => {
14
13
  const enc = new TextEncoder();
15
14
  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"]),
15
+ })(Option.struct({
16
+ signature: Option.fromNullable(headers["x-signature-ed25519"]),
17
+ timestamp: Option.fromNullable(headers["x-signature-timestamp"]),
19
18
  }))));
20
19
  const makeConfig = ({ applicationId, publicKey }) => ({
21
20
  applicationId,
22
21
  publicKey: fromHex(publicKey),
23
22
  });
24
- export const WebhookConfig = tsplus_module_3.Tag();
25
- export const makeConfigLayer = tsplus_module_3.flow(makeConfig, tsplus_module_4.succeed(WebhookConfig));
23
+ export const WebhookConfig = Context.Tag();
24
+ export const makeConfigLayer = flow(makeConfig, Layer.succeed(WebhookConfig));
26
25
  export class WebhookParseError {
27
26
  reason;
28
27
  _tag = "WebhookParseError";
@@ -30,11 +29,11 @@ export class WebhookParseError {
30
29
  this.reason = reason;
31
30
  }
32
31
  }
33
- const fromHeadersAndBody = (headers, body) => tsplus_module_5.flatMap(({ publicKey }) => tsplus_module_5.flatMap(() => tsplus_module_5.tryCatch(() => JSON.parse(body), (reason) => new WebhookParseError(reason)))(tsplus_module_5.fromEither(checkSignature(publicKey, headers, body))))(tsplus_module_5.service(WebhookConfig));
32
+ const fromHeadersAndBody = (headers, body) => tsplus_module_3.flatMap(({ publicKey }) => tsplus_module_3.flatMap(() => Effect.tryCatch(() => JSON.parse(body), (reason) => new WebhookParseError(reason)))(Effect.fromEither(checkSignature(publicKey, headers, body))))(Effect.service(WebhookConfig));
34
33
  const run = (definitions) => {
35
34
  const handler = handlers(definitions);
36
- return (headers, body) => tsplus_module_5.flatMap(interaction => {
37
- const provide = tsplus_module_5.provideService(InteractionContext)(interaction);
35
+ return (headers, body) => tsplus_module_3.flatMap(interaction => {
36
+ const provide = Effect.provideService(InteractionContext)(interaction);
38
37
  return provide(handler[interaction.type](interaction));
39
38
  })(fromHeadersAndBody(headers, body));
40
39
  };
@@ -43,7 +42,7 @@ const run = (definitions) => {
43
42
  */
44
43
  export const makeHandler = (ix) => {
45
44
  const handle = run(ix.definitions);
46
- return ({ headers, body, success, error, }) => tsplus_module_5.catchAllCause(error)(tsplus_module_5.flatMap(success)(handle(headers, body)));
45
+ return ({ headers, body, success, error, }) => tsplus_module_3.catchAllCause(error)(tsplus_module_3.flatMap(success)(handle(headers, body)));
47
46
  };
48
47
  /**
49
48
  * @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,CAA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AGvD,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,8BAAqD,KAAK,EAA1D,wBAA8B,OAAO,EAArC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAiB,CAAqB,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/index.d.ts CHANGED
@@ -1,12 +1,13 @@
1
+ import { Context, Effect, Layer } from "dfx/_common";
1
2
  declare const make: (debug?: boolean) => {
2
- info: (...args: any[]) => import("../utils/common.js").Effect<never, never, void>;
3
- debug: (...args: any[]) => import("../utils/common.js").Effect<never, never, void>;
3
+ info: (...args: any[]) => Effect.Effect<never, never, void>;
4
+ debug: (...args: any[]) => Effect.Effect<never, never, void>;
4
5
  };
5
6
  export interface Log extends ReturnType<typeof make> {
6
7
  }
7
- export declare const Log: import("../utils/common.js").Tag<Log>;
8
- export declare const LiveLog: import("../utils/common.js").Layer<never, never, Log>;
9
- export declare const LiveLogDebug: import("../utils/common.js").Layer<never, never, Log>;
10
- export declare const info: (...args: any[]) => import("../utils/common.js").Effect<Log, never, void>;
11
- export declare const debug: (...args: any[]) => import("../utils/common.js").Effect<Log, never, void>;
8
+ export declare const Log: Context.Tag<Log>;
9
+ export declare const LiveLog: Layer.Layer<never, never, Log>;
10
+ export declare const LiveLogDebug: Layer.Layer<never, never, Log>;
11
+ export declare const info: (...args: any[]) => Effect.Effect<Log, never, void>;
12
+ export declare const debug: (...args: any[]) => Effect.Effect<Log, never, void>;
12
13
  export {};
package/Log/index.js CHANGED
@@ -1,19 +1,17 @@
1
- import * as tsplus_module_1 from "@effect/io/Effect";
2
- import * as tsplus_module_2 from "dfx/utils/common";
3
- import * as tsplus_module_3 from "@effect/io/Layer";
1
+ import { Context, Effect, Layer } from "dfx/_common";
4
2
  const make = (debug = false) => ({
5
- info: (...args) => tsplus_module_1.sync(() => {
3
+ info: (...args) => Effect.sync(() => {
6
4
  console.error("INFO", ...args);
7
5
  }),
8
6
  debug: (...args) => debug
9
- ? tsplus_module_1.sync(() => {
7
+ ? Effect.sync(() => {
10
8
  console.error("DEBUG", ...args);
11
9
  })
12
- : tsplus_module_1.unit(),
10
+ : Effect.unit(),
13
11
  });
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));
12
+ export const Log = Context.Tag();
13
+ export const LiveLog = Layer.succeed(Log)(make(false));
14
+ export const LiveLogDebug = Layer.succeed(Log)(make(true));
15
+ export const info = (...args) => Effect.serviceWithEffect(Log)(({ info: log }) => log(...args));
16
+ export const debug = (...args) => Effect.serviceWithEffect(Log)(({ debug }) => debug(...args));
19
17
  //# sourceMappingURL=index.js.map
package/Log/index.js.map CHANGED
@@ -1 +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,I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AAW,EAAE,EAAE,CACvB,MAAM,CAAC,IAAI,CAAC,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,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;YACf,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;QACjC,CAAC,CAAC;QACJ,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE;CACpB,CAAC,CAAA;AAGF,MAAM,CAAC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAO,CAAA;AACrC,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;AAE1D,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE,CACrC,MAAM,CAAC,iBAAiB,CAAC,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,MAAM,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA"}
@@ -1,4 +1,5 @@
1
- import { Effect, Maybe, Duration } from "dfx/utils/common";
1
+ import { Context, Duration, Effect, Layer, Option } from "dfx/_common";
2
+ import { Log } from "dfx";
2
3
  import { Success } from "dfx/utils/effect";
3
4
  export type BucketDetails = {
4
5
  key: "global" | string;
@@ -6,19 +7,19 @@ export type BucketDetails = {
6
7
  limit: number;
7
8
  };
8
9
  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]>;
10
+ hasBucket: (bucketKey: string) => Effect.Effect<never, never, boolean>;
11
+ putBucket: (bucket: BucketDetails) => Effect.Effect<never, never, void>;
12
+ getBucketForRoute: (route: string) => Effect.Effect<never, never, Option.Option<BucketDetails>>;
13
+ putBucketRoute: (route: string, bucketKey: string) => Effect.Effect<never, never, void>;
14
+ incrementCounter: (key: string, window: number, limit: number) => Effect.Effect<never, never, readonly [count: number, ttl: number]>;
14
15
  }
15
- export declare const RateLimitStore: import("../utils/common.js").Tag<RateLimitStore>;
16
- export declare const LiveMemoryRateLimitStore: import("../utils/common.js").Layer<never, never, RateLimitStore>;
17
- declare const makeLimiter: import("../utils/common.js").Effect<import("../Log/index.js").Log | RateLimitStore, never, {
18
- maybeWait: (key: string, window: Duration, limit: number, multiplier?: number) => import("../utils/common.js").Effect<never, never, void>;
16
+ export declare const RateLimitStore: Context.Tag<RateLimitStore>;
17
+ export declare const LiveMemoryRateLimitStore: Layer.Layer<never, never, RateLimitStore>;
18
+ declare const makeLimiter: Effect.Effect<Log.Log | RateLimitStore, never, {
19
+ maybeWait: (key: string, window: Duration.Duration, limit: number, multiplier?: number) => Effect.Effect<never, never, void>;
19
20
  }>;
20
21
  export interface RateLimiter extends Success<typeof makeLimiter> {
21
22
  }
22
- export declare const RateLimiter: import("../utils/common.js").Tag<RateLimiter>;
23
- export declare const LiveRateLimiter: import("../utils/common.js").Layer<import("../Log/index.js").Log | RateLimitStore, never, RateLimiter>;
23
+ export declare const RateLimiter: Context.Tag<RateLimiter>;
24
+ export declare const LiveRateLimiter: Layer.Layer<Log.Log | RateLimitStore, never, RateLimiter>;
24
25
  export {};
@@ -1,25 +1,24 @@
1
- import * as tsplus_module_1 from "dfx/utils/common";
2
- import * as tsplus_module_2 from "@effect/io/Layer";
3
- import * as tsplus_module_3 from "@effect/io/Effect";
4
- import * as tsplus_module_4 from "dfx";
1
+ import * as tsplus_module_1 from "@effect/io/Effect";
5
2
  import { delayFrom } from "./utils.js";
6
3
  import * as Memory from "./memory.js";
7
- export const RateLimitStore = tsplus_module_1.Tag();
8
- export const LiveMemoryRateLimitStore = tsplus_module_2.sync(RateLimitStore)(Memory.make);
9
- const makeLimiter = tsplus_module_3.flatMap(store => tsplus_module_3.map(log => {
4
+ import { Context, Effect, Layer } from "dfx/_common";
5
+ import { Log } from "dfx";
6
+ export const RateLimitStore = Context.Tag();
7
+ export const LiveMemoryRateLimitStore = Layer.sync(RateLimitStore)(Memory.make);
8
+ const makeLimiter = tsplus_module_1.flatMap(store => tsplus_module_1.map(log => {
10
9
  const maybeWait = (key, window, limit, multiplier = 1.05) => {
11
10
  const windowMs = window.millis * multiplier;
12
- return tsplus_module_3.asUnit(tsplus_module_3.tap(tsplus_module_3.sleep)(tsplus_module_3.tap((d) => log.debug("RateLimitStore maybeWait", {
11
+ return tsplus_module_1.asUnit(tsplus_module_1.tap(Effect.sleep)(tsplus_module_1.tap((d) => log.debug("RateLimitStore maybeWait", {
13
12
  key,
14
13
  window: window.millis,
15
14
  windowMs,
16
15
  limit,
17
16
  delay: d.millis,
18
- }))(tsplus_module_3.map(([count, ttl]) => delayFrom(windowMs, limit, count, ttl))(store
17
+ }))(tsplus_module_1.map(([count, ttl]) => delayFrom(windowMs, limit, count, ttl))(store
19
18
  .incrementCounter(key, windowMs, limit)))));
20
19
  };
21
20
  return { maybeWait };
22
- })(tsplus_module_3.service(tsplus_module_4.Log.Log)))(tsplus_module_3.service(RateLimitStore));
23
- export const RateLimiter = tsplus_module_1.Tag();
24
- export const LiveRateLimiter = tsplus_module_2.fromEffect(RateLimiter)(makeLimiter);
21
+ })(Effect.service(Log.Log)))(Effect.service(RateLimitStore));
22
+ export const RateLimiter = Context.Tag();
23
+ export const LiveRateLimiter = Layer.fromEffect(RateLimiter)(makeLimiter);
25
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/RateLimit/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;QAE3C,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,CAA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E,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;GAzBN,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GADrB,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CA2B9C,CAAA;AAGF,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAe,CAAA;AACrD,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,CAAA"}
@@ -1,2 +1,2 @@
1
- import { RateLimitStore, BucketDetails } from "dfx";
1
+ import { RateLimitStore } from "./index.js";
2
2
  export declare const make: () => RateLimitStore;
@@ -1,20 +1,20 @@
1
1
  import * as tsplus_module_1 from "@fp-ts/data/Option";
2
- import * as tsplus_module_2 from "@effect/io/Effect";
2
+ import { Effect, Option } from "dfx/_common";
3
3
  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((c) => c.expires > Date.now())(tsplus_module_1.fromNullable(counters.get(key)));
7
+ const getCounter = (key) => tsplus_module_1.filter((c) => c.expires > Date.now())(Option.fromNullable(counters.get(key)));
8
8
  return {
9
- hasBucket: (key) => tsplus_module_2.sync(() => buckets.has(key)),
10
- putBucket: (bucket) => tsplus_module_2.sync(() => {
9
+ hasBucket: (key) => Effect.sync(() => buckets.has(key)),
10
+ putBucket: (bucket) => Effect.sync(() => {
11
11
  buckets.set(bucket.key, bucket);
12
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(() => {
13
+ getBucketForRoute: (route) => Effect.sync(() => Option.fromNullable(buckets.get(routes.get(route)))),
14
+ putBucketRoute: (route, bucket) => Effect.sync(() => {
15
15
  routes.set(route, bucket);
16
16
  }),
17
- incrementCounter: (key, window, limit) => tsplus_module_2.sync(() => {
17
+ incrementCounter: (key, window, limit) => Effect.sync(() => {
18
18
  const now = Date.now();
19
19
  const perRequest = Math.ceil(window / limit);
20
20
  const counter = tsplus_module_1.getOrElse(() => ({
@@ -1 +1 @@
1
- {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/RateLimit/memory.ts"],"names":[],"mappings":";;AAKA,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,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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AAE,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"}
@@ -1,2 +1,2 @@
1
- import { Duration } from "dfx/utils/common";
2
- export declare const delayFrom: (window: number, limit: number, count: number, ttl: number) => Duration;
1
+ import { Duration } from "dfx/_common";
2
+ export declare const delayFrom: (window: number, limit: number, count: number, ttl: number) => Duration.Duration;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/RateLimit/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,K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;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"}
package/_common.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ export * as Cause from "@effect/io/Cause";
2
+ export * as Effect from "@effect/io/Effect";
3
+ export * as Exit from "@effect/io/Exit";
4
+ export * as Layer from "@effect/io/Layer";
5
+ export * as Queue from "@effect/io/Queue";
6
+ export * as Schedule from "@effect/io/Schedule";
7
+ export * as Scope from "@effect/io/Scope";
8
+ export * as Stream from "@effect/stream/Stream";
9
+ export * as Chunk from "@fp-ts/data/Chunk";
10
+ export * as Context from "@fp-ts/data/Context";
11
+ export * as Duration from "@fp-ts/data/Duration";
12
+ export * as Equal from "@fp-ts/data/Equal";
13
+ export * as Either from "@fp-ts/data/Either";
14
+ export * as HashMap from "@fp-ts/data/HashMap";
15
+ export * as Option from "@fp-ts/data/Option";
16
+ export * as Ref from "@effect/io/Ref";
17
+ export * as HashSet from "@fp-ts/data/HashSet";
18
+ export { pipe, flow, identity } from "@fp-ts/data/Function";
19
+ export * as Discord from "./types.js";
package/_common.js ADDED
@@ -0,0 +1,20 @@
1
+ export * as Cause from "@effect/io/Cause";
2
+ export * as Effect from "@effect/io/Effect";
3
+ export * as Exit from "@effect/io/Exit";
4
+ export * as Layer from "@effect/io/Layer";
5
+ export * as Queue from "@effect/io/Queue";
6
+ export * as Schedule from "@effect/io/Schedule";
7
+ export * as Scope from "@effect/io/Scope";
8
+ export * as Stream from "@effect/stream/Stream";
9
+ export * as Chunk from "@fp-ts/data/Chunk";
10
+ export * as Context from "@fp-ts/data/Context";
11
+ export * as Duration from "@fp-ts/data/Duration";
12
+ export * as Equal from "@fp-ts/data/Equal";
13
+ export * as Either from "@fp-ts/data/Either";
14
+ export * as HashMap from "@fp-ts/data/HashMap";
15
+ export * as Option from "@fp-ts/data/Option";
16
+ export * as Ref from "@effect/io/Ref";
17
+ export * as HashSet from "@fp-ts/data/HashSet";
18
+ export { pipe, flow, identity } from "@fp-ts/data/Function";
19
+ export * as Discord from "./types.js";
20
+ //# 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,KAAK,KAAK,MAAM,kBAAkB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA;AACzC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA;AACzC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA;AAEzC,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAA;AAE/C,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAC1C,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAA;AAC9C,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAA;AAChD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAC1C,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAA;AAC5C,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAA;AAC9C,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAA;AAC5C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAE3D,OAAO,KAAK,OAAO,MAAM,YAAY,CAAA"}
package/gateway.d.ts CHANGED
@@ -1,14 +1,15 @@
1
- import { Config } from "dfx";
2
- export * as WS from "./DiscordGateway/WS/index.js";
1
+ import { Config, Log } from "dfx";
2
+ import { Layer } from "./_common.js";
3
+ export * as CachePrelude from "./Cache/prelude.js";
3
4
  export * as DiscordWS from "./DiscordGateway/DiscordWS/index.js";
5
+ export * as Gateway from "./DiscordGateway/index.js";
4
6
  export * as Shard from "./DiscordGateway/Shard/index.js";
5
7
  export * as ShardStore from "./DiscordGateway/ShardStore/index.js";
6
- export * as Gateway from "./DiscordGateway/index.js";
7
- export * as CachePrelude from "./Cache/prelude.js";
8
+ export * as WS from "./DiscordGateway/WS/index.js";
8
9
  export { run as runIx } from "./Interactions/gateway.js";
9
- export declare const MemoryRateLimit: import("./utils/common.js").Layer<import("./Log/index.js").Log, never, import("./index.js").RateLimitStore | import("./index.js").RateLimiter>;
10
- export declare const MemoryREST: import("./utils/common.js").Layer<import("./Log/index.js").Log | import("./DiscordConfig/index.js").DiscordConfig, never, import("./index.js").DiscordREST>;
11
- export declare const MemorySharder: import("./utils/common.js").Layer<import("./Log/index.js").Log | import("./DiscordConfig/index.js").DiscordConfig, never, import("./DiscordGateway/Sharder/index.js").Sharder>;
12
- export declare const MemoryGateway: import("./utils/common.js").Layer<import("./Log/index.js").Log | import("./DiscordConfig/index.js").DiscordConfig, never, import("./DiscordGateway/index.js").DiscordGateway>;
13
- export declare const MemoryBot: import("./utils/common.js").Layer<import("./Log/index.js").Log | import("./DiscordConfig/index.js").DiscordConfig, never, import("./index.js").DiscordREST | import("./index.js").RateLimitStore | import("./index.js").RateLimiter | import("./DiscordGateway/index.js").DiscordGateway>;
14
- export declare const make: (config: Config.MakeOpts, debug?: boolean) => import("./utils/common.js").Layer<never, never, import("./index.js").DiscordREST | import("./Log/index.js").Log | import("./DiscordConfig/index.js").DiscordConfig | import("./index.js").RateLimitStore | import("./index.js").RateLimiter | import("./DiscordGateway/index.js").DiscordGateway>;
10
+ export declare const MemoryRateLimit: Layer.Layer<Log.Log, never, import("dfx").RateLimitStore | import("dfx").RateLimiter>;
11
+ export declare const MemoryREST: Layer.Layer<Config.DiscordConfig | Log.Log, never, import("dfx").DiscordREST>;
12
+ export declare const MemorySharder: Layer.Layer<Config.DiscordConfig | Log.Log, never, import("./DiscordGateway/Sharder/index.js").Sharder>;
13
+ export declare const MemoryGateway: Layer.Layer<Config.DiscordConfig | Log.Log, never, import("./DiscordGateway/index.js").DiscordGateway>;
14
+ export declare const MemoryBot: Layer.Layer<Config.DiscordConfig | Log.Log, never, import("dfx").DiscordREST | import("dfx").RateLimitStore | import("dfx").RateLimiter | import("./DiscordGateway/index.js").DiscordGateway>;
15
+ export declare const make: (config: Config.MakeOpts, debug?: boolean) => Layer.Layer<never, never, import("dfx").DiscordREST | Config.DiscordConfig | Log.Log | import("dfx").RateLimitStore | import("dfx").RateLimiter | import("./DiscordGateway/index.js").DiscordGateway>;
package/gateway.js CHANGED
@@ -1,26 +1,29 @@
1
- import * as tsplus_module_1 from "dfx";
2
- import * as tsplus_module_2 from "@effect/io/Layer";
3
- import * as tsplus_module_3 from "dfx/gateway";
1
+ import * as tsplus_module_1 from "@effect/io/Layer";
2
+ import { Config, LiveDiscordREST, Log } from "dfx";
4
3
  import { LiveJsonDiscordWSCodec } from "./DiscordGateway/DiscordWS/index.js";
4
+ import { LiveDiscordGateway } from "./DiscordGateway/index.js";
5
5
  import { LiveSharder } from "./DiscordGateway/Sharder/index.js";
6
6
  import { LiveMemoryShardStore } from "./DiscordGateway/ShardStore/index.js";
7
7
  import { LiveHttp } from "./Http/index.js";
8
- export * as WS from "./DiscordGateway/WS/index.js";
8
+ import { LiveMemoryRateLimitStore, LiveRateLimiter } from "./RateLimit/index.js";
9
+ import { Layer } from "./_common.js";
10
+ export * as CachePrelude from "./Cache/prelude.js";
9
11
  export * as DiscordWS from "./DiscordGateway/DiscordWS/index.js";
12
+ export * as Gateway from "./DiscordGateway/index.js";
10
13
  export * as Shard from "./DiscordGateway/Shard/index.js";
11
14
  export * as ShardStore from "./DiscordGateway/ShardStore/index.js";
12
- export * as Gateway from "./DiscordGateway/index.js";
13
- export * as CachePrelude from "./Cache/prelude.js";
15
+ export * as WS from "./DiscordGateway/WS/index.js";
14
16
  export { run as runIx } from "./Interactions/gateway.js";
15
- export const MemoryRateLimit = tsplus_module_2.provideToAndMerge(tsplus_module_1.LiveRateLimiter)(tsplus_module_1.LiveMemoryRateLimitStore);
16
- export const MemoryREST = tsplus_module_2.provideTo(tsplus_module_1.LiveDiscordREST)((tsplus_module_2.merge(MemoryRateLimit)(LiveHttp)));
17
- export const MemorySharder = tsplus_module_2.provideTo(LiveSharder)((tsplus_module_2.merge(LiveJsonDiscordWSCodec)(tsplus_module_2.merge(MemoryRateLimit)(tsplus_module_2.merge(LiveMemoryShardStore)(MemoryREST)))));
18
- export const MemoryGateway = tsplus_module_2.provideTo(tsplus_module_3.Gateway.LiveDiscordGateway)(MemorySharder);
19
- export const MemoryBot = tsplus_module_2.provideToAndMerge(tsplus_module_2.merge(MemoryRateLimit)(MemoryGateway))(MemoryREST);
17
+ const _layer = Layer.LayerTypeId;
18
+ export const MemoryRateLimit = tsplus_module_1.provideToAndMerge(LiveRateLimiter)(LiveMemoryRateLimitStore);
19
+ export const MemoryREST = tsplus_module_1.provideTo(LiveDiscordREST)((tsplus_module_1.merge(MemoryRateLimit)(LiveHttp)));
20
+ export const MemorySharder = tsplus_module_1.provideTo(LiveSharder)((tsplus_module_1.merge(LiveJsonDiscordWSCodec)(tsplus_module_1.merge(MemoryRateLimit)(tsplus_module_1.merge(LiveMemoryShardStore)(MemoryREST)))));
21
+ export const MemoryGateway = tsplus_module_1.provideTo(LiveDiscordGateway)(MemorySharder);
22
+ export const MemoryBot = tsplus_module_1.provideToAndMerge(tsplus_module_1.merge(MemoryRateLimit)(MemoryGateway))(MemoryREST);
20
23
  export const make = (config, debug = false) => {
21
- const LiveLog = debug ? tsplus_module_1.Log.LiveLogDebug : tsplus_module_1.Log.LiveLog;
22
- const LiveConfig = tsplus_module_1.Config.makeLayer(config);
23
- const LiveEnv = tsplus_module_2.provideToAndMerge(MemoryBot)(tsplus_module_2.merge(LiveConfig)(LiveLog));
24
+ const LiveLog = debug ? Log.LiveLogDebug : Log.LiveLog;
25
+ const LiveConfig = Config.makeLayer(config);
26
+ const LiveEnv = tsplus_module_1.provideToAndMerge(MemoryBot)(tsplus_module_1.merge(LiveConfig)(LiveLog));
24
27
  return LiveEnv;
25
28
  };
26
29
  //# sourceMappingURL=gateway.js.map
package/gateway.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"gateway.js","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAA;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAA;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE1C,OAAO,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAClD,OAAO,KAAK,SAAS,MAAM,qCAAqC,CAAA;AAChE,OAAO,KAAK,KAAK,MAAM,iCAAiC,CAAA;AACxD,OAAO,KAAK,UAAU,MAAM,sCAAsC,CAAA;AAClE,OAAO,KAAK,OAAO,MAAM,2BAA2B,CAAA;AACpD,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,GAAG,IAAI,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAExD,MAAM,CAAC,MAAM,eAAe,qDAA8B,eAAe,kBAA1C,wBAAwB,CAAkB,CAAA;AAEzE,MAAM,CAAC,MAAM,UAAU,6CAAmC,eAAe,EAA/C,uBAAY,eAAe,EAA1B,QAAQ,EAAmB,CAAmB,CAAA;AAEzE,MAAM,CAAC,MAAM,aAAa,6BAKxB,WAAW,EAJX,uBAGE,sBAAsB,wBADtB,eAAe,wBADf,oBAAoB,EADrB,UAAU,IAGc,CACd,CAAA;AAEb,MAAM,CAAC,MAAM,aAAa,6BAAoB,gBAAA,OAA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,OAAO,KAAK,UAAU,MAAM,sCAAsC,CAAA;AAClE,OAAO,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAClD,OAAO,EAAE,GAAG,IAAI,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAExD,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAAA;AAEhC,MAAM,CAAC,MAAM,eAAe,qCAA8B,eAAe,EAA1C,wBAAwB,CAAkB,CAAA;AAEzE,MAAM,CAAC,MAAM,UAAU,6BAAmC,eAAe,EAA/C,uBAAY,eAAe,EAA1B,QAAQ,EAAmB,CAAmB,CAAA;AAEzE,MAAM,CAAC,MAAM,aAAa,6BAKxB,WAAW,EAJX,uBAGE,sBAAsB,wBADtB,eAAe,wBADf,oBAAoB,EADrB,UAAU,IAGc,CACd,CAAA;AAEb,MAAM,CAAC,MAAM,aAAa,6BAAoB,kBAAkB,EAAnC,aAAa,CAAsB,CAAA;AAEhE,MAAM,CAAC,MAAM,SAAS,2DAAgC,eAAe,EAA/B,aAAa,GAA1B,UAAU,CAAkC,CAAA;AAErE,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,MAAuB,EAAE,KAAK,GAAG,KAAK,EAAE,EAAE;IAC7D,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAA;IACtD,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IAC3C,MAAM,OAAO,qCAA0B,SAAS,wBAAtB,UAAU,EAApB,OAAO,EAAyB,CAAA;IAEhD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dfx",
3
- "version": "0.20.5",
3
+ "version": "0.21.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -24,22 +24,18 @@
24
24
  "./*": "./*.js"
25
25
  },
26
26
  "devDependencies": {
27
- "@effect/io": "^0.0.33",
28
- "@fp-ts/data": "^0.0.25",
29
27
  "@tim-smart/discord-api-docs-parser": "^0.4.1",
30
28
  "@types/ws": "^8.5.3",
31
29
  "lerna": "^6.1.0",
32
30
  "typescript": "https://cdn.jsdelivr.net/npm/@tsplus/installer/compiler/typescript.tgz"
33
31
  },
34
32
  "dependencies": {
35
- "callbag-effect-ts": "1.0.0-alpha.22",
33
+ "@effect/io": "~0.0.41",
34
+ "@effect/stream": "~0.0.3",
35
+ "@fp-ts/data": "~0.0.30",
36
36
  "ts-toolbelt": "^9.6.0",
37
37
  "tweetnacl": "^1.0.3"
38
38
  },
39
- "peerDependencies": {
40
- "@effect/io": "*",
41
- "@fp-ts/data": "*"
42
- },
43
39
  "optionalDependencies": {
44
40
  "bufferutil": "^4.0.7",
45
41
  "isomorphic-ws": "^5.0.0",
@@ -47,11 +43,5 @@
47
43
  "ws": "^8.11.0"
48
44
  },
49
45
  "sideEffects": false,
50
- "pnpm": {
51
- "overrides": {
52
- "@effect/io": "^0.0.33",
53
- "@fp-ts/data": "^0.0.25"
54
- }
55
- },
56
- "gitHead": "3e828b3e5d97ed8c543783969468e0cda3a7270f"
46
+ "gitHead": "7ee1a7233c14362dc49ec46e30abafe7cb74a90b"
57
47
  }
package/utils/effect.d.ts CHANGED
@@ -1,20 +1,20 @@
1
- import { Effect, Tag } from "dfx/utils/common";
2
- export type Success<A extends Effect<any, any, any>> = A extends Effect<any, any, infer R> ? R : never;
1
+ import { Context, Effect } from "dfx/_common";
2
+ export type Success<A extends Effect.Effect<any, any, any>> = A extends Effect.Effect<any, any, infer R> ? R : never;
3
3
  export type ShapeFn<T> = Pick<T, {
4
- [k in keyof T]: T[k] extends (...args: infer ARGS) => Effect<infer R, infer E, infer A> ? ((...args: ARGS) => Effect<R, E, A>) extends T[k] ? k : never : never;
4
+ [k in keyof T]: T[k] extends (...args: infer ARGS) => Effect.Effect<infer R, infer E, infer A> ? ((...args: ARGS) => Effect.Effect<R, E, A>) extends T[k] ? k : never : never;
5
5
  }[keyof T]>;
6
6
  export type ShapeCn<T> = Pick<T, {
7
- [k in keyof T]: T[k] extends Effect<any, any, any> ? k : never;
7
+ [k in keyof T]: T[k] extends Effect.Effect<any, any, any> ? k : never;
8
8
  }[keyof T]>;
9
9
  export type DerivedLifted<T, Fns extends keyof ShapeFn<T>, Cns extends keyof ShapeCn<T>, Values extends keyof T> = {
10
- [k in Fns]: T[k] extends (...args: infer ARGS) => Effect<infer R, infer E, infer A> ? (...args: ARGS) => Effect<R | T, E, A> : never;
10
+ [k in Fns]: T[k] extends (...args: infer ARGS) => Effect.Effect<infer R, infer E, infer A> ? (...args: ARGS) => Effect.Effect<R | T, E, A> : never;
11
11
  } & {
12
- [k in Cns]: T[k] extends Effect<infer R, infer E, infer A> ? Effect<R | T, E, A> : never;
12
+ [k in Cns]: T[k] extends Effect.Effect<infer R, infer E, infer A> ? Effect.Effect<R | T, E, A> : never;
13
13
  } & {
14
- [k in Values]: Effect<T, never, T[k]>;
14
+ [k in Values]: Effect.Effect<T, never, T[k]>;
15
15
  };
16
16
  /**
17
17
  * @tsplus static effect/io/Effect.Ops deriveLifted
18
18
  * @tsplus location "dfx/utils/effect"
19
19
  */
20
- export declare function deriveLifted<T>(S: Tag<T>): <Fns extends keyof ShapeFn<T> = never, Cns extends keyof ShapeCn<T> = never, Values extends keyof T = never>(functions: Fns[], effects: Cns[], values: Values[]) => DerivedLifted<T, Fns, Cns, Values>;
20
+ export declare function deriveLifted<T>(S: Context.Tag<T>): <Fns extends keyof ShapeFn<T> = never, Cns extends keyof ShapeCn<T> = never, Values extends keyof T = never>(functions: Fns[], effects: Cns[], values: Values[]) => DerivedLifted<T, Fns, Cns, Values>;
package/utils/effect.js CHANGED
@@ -1,4 +1,4 @@
1
- import * as tsplus_module_1 from "@effect/io/Effect";
1
+ import { Effect } from "dfx/_common";
2
2
  /**
3
3
  * @tsplus static effect/io/Effect.Ops deriveLifted
4
4
  */
@@ -6,13 +6,13 @@ export function deriveLifted(S) {
6
6
  return (functions, constants, values) => {
7
7
  const ret = {};
8
8
  for (const k of functions) {
9
- ret[k] = (...args) => tsplus_module_1.serviceWithEffect(S)((h) => h[k](...args));
9
+ ret[k] = (...args) => Effect.serviceWithEffect(S)((h) => h[k](...args));
10
10
  }
11
11
  for (const k of constants) {
12
- ret[k] = tsplus_module_1.serviceWithEffect(S)((h) => h[k]);
12
+ ret[k] = Effect.serviceWithEffect(S)((h) => h[k]);
13
13
  }
14
14
  for (const k of values) {
15
- ret[k] = tsplus_module_1.serviceWith(S)((h) => h[k]);
15
+ ret[k] = Effect.serviceWith(S)((h) => h[k]);
16
16
  }
17
17
  return ret;
18
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"effect.js","sourceRoot":"","sources":["../../src/utils/effect.ts"],"names":[],"mappings":";AA+CA;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,CAAS;IAUT,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE;QACtC,MAAM,GAAG,GAAG,EAAS,CAAA;QAErB,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE;YACzB,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE,CAC1B,kCAAyB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAE,CAAC,CAAC,CAAC,CAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;SAC7D;QAED,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE;YACzB,GAAG,CAAC,CAAC,CAAC,GAAG,kCAAyB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAQ,CAAC,CAAA;SACzD;QAED,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE;YACtB,GAAG,CAAC,CAAC,CAAC,GAAG,4BAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;SAC5C;QAED,OAAO,GAAU,CAAA;IACnB,CAAC,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"effect.js","sourceRoot":"","sources":["../../src/utils/effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAE,MAAM,aAAa,CAAA;AA4C7C;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,CAAiB;IAUjB,OAAO,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE;QACtC,MAAM,GAAG,GAAG,EAAS,CAAA;QAErB,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE;YACzB,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE,CAC1B,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAE,CAAC,CAAC,CAAC,CAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;SAC7D;QAED,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE;YACzB,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAQ,CAAC,CAAA;SACzD;QAED,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE;YACtB,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;SAC5C;QAED,OAAO,GAAU,CAAA;IACnB,CAAC,CAAA;AACH,CAAC"}
package/webhooks.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { Config } from "dfx";
1
+ import { Config, Log } from "dfx";
2
2
  import { MakeConfigOpts } from "./Interactions/webhook.js";
3
- export { makeConfigLayer, makeHandler, makeSimpleHandler, WebhookConfig, WebhookParseError, BadWebhookSignature, } from "./Interactions/webhook.js";
4
- export declare const MemoryRateLimit: import("./utils/common.js").Layer<import("./Log/index.js").Log, never, import("./index.js").RateLimitStore | import("./index.js").RateLimiter>;
5
- export declare const MemoryREST: import("./utils/common.js").Layer<import("./Log/index.js").Log | import("./DiscordConfig/index.js").DiscordConfig, never, import("./index.js").DiscordREST>;
6
- export declare const make: (config: Config.MakeOpts & MakeConfigOpts, debug?: boolean) => import("./utils/common.js").Layer<never, never, import("./index.js").DiscordREST | import("./index.js").RateLimitStore | import("./index.js").RateLimiter | import("./Interactions/webhook.js").WebhookConfig>;
3
+ import { Layer } from "./_common.js";
4
+ export { BadWebhookSignature, makeConfigLayer, makeHandler, makeSimpleHandler, WebhookConfig, WebhookParseError, } from "./Interactions/webhook.js";
5
+ export declare const MemoryRateLimit: Layer.Layer<Log.Log, never, import("dfx").RateLimitStore | import("dfx").RateLimiter>;
6
+ export declare const MemoryREST: Layer.Layer<Config.DiscordConfig | Log.Log, never, import("dfx").DiscordREST>;
7
+ export declare const make: (config: Config.MakeOpts & MakeConfigOpts, debug?: boolean) => Layer.Layer<never, never, import("dfx").DiscordREST | import("dfx").RateLimitStore | import("dfx").RateLimiter | import("./Interactions/webhook.js").WebhookConfig>;