dfx 0.9.7 → 0.9.8

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 (208) hide show
  1. package/package.json +7 -6
  2. package/README.md +0 -41
  3. package/dist/DiscordConfig/index.d.ts +0 -40
  4. package/dist/DiscordConfig/index.d.ts.map +0 -1
  5. package/dist/DiscordConfig/index.js +0 -29
  6. package/dist/DiscordConfig/index.js.map +0 -1
  7. package/dist/DiscordGateway/DiscordWS/index.d.ts +0 -24
  8. package/dist/DiscordGateway/DiscordWS/index.d.ts.map +0 -1
  9. package/dist/DiscordGateway/DiscordWS/index.js +0 -26
  10. package/dist/DiscordGateway/DiscordWS/index.js.map +0 -1
  11. package/dist/DiscordGateway/Shard/heartbeats.d.ts +0 -4
  12. package/dist/DiscordGateway/Shard/heartbeats.d.ts.map +0 -1
  13. package/dist/DiscordGateway/Shard/heartbeats.js +0 -24
  14. package/dist/DiscordGateway/Shard/heartbeats.js.map +0 -1
  15. package/dist/DiscordGateway/Shard/identify.d.ts +0 -13
  16. package/dist/DiscordGateway/Shard/identify.d.ts.map +0 -1
  17. package/dist/DiscordGateway/Shard/identify.js +0 -30
  18. package/dist/DiscordGateway/Shard/identify.js.map +0 -1
  19. package/dist/DiscordGateway/Shard/index.d.ts +0 -10
  20. package/dist/DiscordGateway/Shard/index.d.ts.map +0 -1
  21. package/dist/DiscordGateway/Shard/index.js +0 -52
  22. package/dist/DiscordGateway/Shard/index.js.map +0 -1
  23. package/dist/DiscordGateway/Shard/invalidSession.d.ts +0 -4
  24. package/dist/DiscordGateway/Shard/invalidSession.d.ts.map +0 -1
  25. package/dist/DiscordGateway/Shard/invalidSession.js +0 -10
  26. package/dist/DiscordGateway/Shard/invalidSession.js.map +0 -1
  27. package/dist/DiscordGateway/Shard/sendEvents.d.ts +0 -8
  28. package/dist/DiscordGateway/Shard/sendEvents.d.ts.map +0 -1
  29. package/dist/DiscordGateway/Shard/sendEvents.js +0 -26
  30. package/dist/DiscordGateway/Shard/sendEvents.js.map +0 -1
  31. package/dist/DiscordGateway/Shard/utils.d.ts +0 -4
  32. package/dist/DiscordGateway/Shard/utils.d.ts.map +0 -1
  33. package/dist/DiscordGateway/Shard/utils.js +0 -9
  34. package/dist/DiscordGateway/Shard/utils.js.map +0 -1
  35. package/dist/DiscordGateway/ShardStore/index.d.ts +0 -13
  36. package/dist/DiscordGateway/ShardStore/index.d.ts.map +0 -1
  37. package/dist/DiscordGateway/ShardStore/index.js +0 -22
  38. package/dist/DiscordGateway/ShardStore/index.js.map +0 -1
  39. package/dist/DiscordGateway/Sharder/index.d.ts +0 -10
  40. package/dist/DiscordGateway/Sharder/index.d.ts.map +0 -1
  41. package/dist/DiscordGateway/Sharder/index.js +0 -61
  42. package/dist/DiscordGateway/Sharder/index.js.map +0 -1
  43. package/dist/DiscordGateway/WS/index.d.ts +0 -28
  44. package/dist/DiscordGateway/WS/index.d.ts.map +0 -1
  45. package/dist/DiscordGateway/WS/index.js +0 -82
  46. package/dist/DiscordGateway/WS/index.js.map +0 -1
  47. package/dist/DiscordGateway/index.d.ts +0 -21
  48. package/dist/DiscordGateway/index.d.ts.map +0 -1
  49. package/dist/DiscordGateway/index.js +0 -27
  50. package/dist/DiscordGateway/index.js.map +0 -1
  51. package/dist/DiscordREST/index.d.ts +0 -13
  52. package/dist/DiscordREST/index.d.ts.map +0 -1
  53. package/dist/DiscordREST/index.js +0 -85
  54. package/dist/DiscordREST/index.js.map +0 -1
  55. package/dist/DiscordREST/types.d.ts +0 -10
  56. package/dist/DiscordREST/types.d.ts.map +0 -1
  57. package/dist/DiscordREST/types.js +0 -2
  58. package/dist/DiscordREST/types.js.map +0 -1
  59. package/dist/DiscordREST/utils.d.ts +0 -11
  60. package/dist/DiscordREST/utils.d.ts.map +0 -1
  61. package/dist/DiscordREST/utils.js +0 -22
  62. package/dist/DiscordREST/utils.js.map +0 -1
  63. package/dist/Helpers/flags.d.ts +0 -28
  64. package/dist/Helpers/flags.d.ts.map +0 -1
  65. package/dist/Helpers/flags.js +0 -36
  66. package/dist/Helpers/flags.js.map +0 -1
  67. package/dist/Helpers/intents.d.ts +0 -25
  68. package/dist/Helpers/intents.d.ts.map +0 -1
  69. package/dist/Helpers/intents.js +0 -28
  70. package/dist/Helpers/intents.js.map +0 -1
  71. package/dist/Helpers/interactions.d.ts +0 -74
  72. package/dist/Helpers/interactions.d.ts.map +0 -1
  73. package/dist/Helpers/interactions.js +0 -93
  74. package/dist/Helpers/interactions.js.map +0 -1
  75. package/dist/Helpers/members.d.ts +0 -10
  76. package/dist/Helpers/members.d.ts.map +0 -1
  77. package/dist/Helpers/members.js +0 -10
  78. package/dist/Helpers/members.js.map +0 -1
  79. package/dist/Helpers/permissions.d.ts +0 -35
  80. package/dist/Helpers/permissions.d.ts.map +0 -1
  81. package/dist/Helpers/permissions.js +0 -69
  82. package/dist/Helpers/permissions.js.map +0 -1
  83. package/dist/Helpers/ui.d.ts +0 -48
  84. package/dist/Helpers/ui.d.ts.map +0 -1
  85. package/dist/Helpers/ui.js +0 -67
  86. package/dist/Helpers/ui.js.map +0 -1
  87. package/dist/Http/index.d.ts +0 -31
  88. package/dist/Http/index.d.ts.map +0 -1
  89. package/dist/Http/index.js +0 -53
  90. package/dist/Http/index.js.map +0 -1
  91. package/dist/Interactions/context.d.ts +0 -37
  92. package/dist/Interactions/context.d.ts.map +0 -1
  93. package/dist/Interactions/context.js +0 -34
  94. package/dist/Interactions/context.js.map +0 -1
  95. package/dist/Interactions/definitions.d.ts +0 -61
  96. package/dist/Interactions/definitions.d.ts.map +0 -1
  97. package/dist/Interactions/definitions.js +0 -52
  98. package/dist/Interactions/definitions.js.map +0 -1
  99. package/dist/Interactions/gateway.d.ts +0 -7
  100. package/dist/Interactions/gateway.d.ts.map +0 -1
  101. package/dist/Interactions/gateway.js +0 -21
  102. package/dist/Interactions/gateway.js.map +0 -1
  103. package/dist/Interactions/handlers.d.ts +0 -9
  104. package/dist/Interactions/handlers.d.ts.map +0 -1
  105. package/dist/Interactions/handlers.js +0 -49
  106. package/dist/Interactions/handlers.js.map +0 -1
  107. package/dist/Interactions/index.d.ts +0 -18
  108. package/dist/Interactions/index.d.ts.map +0 -1
  109. package/dist/Interactions/index.js +0 -39
  110. package/dist/Interactions/index.js.map +0 -1
  111. package/dist/Interactions/utils.d.ts +0 -11
  112. package/dist/Interactions/utils.d.ts.map +0 -1
  113. package/dist/Interactions/utils.js +0 -61
  114. package/dist/Interactions/utils.js.map +0 -1
  115. package/dist/Interactions/webhook.d.ts +0 -33
  116. package/dist/Interactions/webhook.d.ts.map +0 -1
  117. package/dist/Interactions/webhook.js +0 -42
  118. package/dist/Interactions/webhook.js.map +0 -1
  119. package/dist/Log/index.d.ts +0 -13
  120. package/dist/Log/index.d.ts.map +0 -1
  121. package/dist/Log/index.js +0 -19
  122. package/dist/Log/index.js.map +0 -1
  123. package/dist/RateLimitStore/index.d.ts +0 -25
  124. package/dist/RateLimitStore/index.d.ts.map +0 -1
  125. package/dist/RateLimitStore/index.js +0 -24
  126. package/dist/RateLimitStore/index.js.map +0 -1
  127. package/dist/RateLimitStore/memory.d.ts +0 -3
  128. package/dist/RateLimitStore/memory.d.ts.map +0 -1
  129. package/dist/RateLimitStore/memory.js +0 -31
  130. package/dist/RateLimitStore/memory.js.map +0 -1
  131. package/dist/RateLimitStore/utils.d.ts +0 -3
  132. package/dist/RateLimitStore/utils.d.ts.map +0 -1
  133. package/dist/RateLimitStore/utils.js +0 -18
  134. package/dist/RateLimitStore/utils.js.map +0 -1
  135. package/dist/common-gateway.d.ts +0 -6
  136. package/dist/common-gateway.d.ts.map +0 -1
  137. package/dist/common-gateway.js +0 -6
  138. package/dist/common-gateway.js.map +0 -1
  139. package/dist/common.d.ts +0 -29
  140. package/dist/common.d.ts.map +0 -1
  141. package/dist/common.js +0 -16
  142. package/dist/common.js.map +0 -1
  143. package/dist/global.d.ts +0 -18
  144. package/dist/global.d.ts.map +0 -1
  145. package/dist/global.js +0 -2
  146. package/dist/global.js.map +0 -1
  147. package/dist/index.d.ts +0 -22
  148. package/dist/index.d.ts.map +0 -1
  149. package/dist/index.js +0 -29
  150. package/dist/index.js.map +0 -1
  151. package/dist/types.d.ts +0 -4229
  152. package/dist/types.d.ts.map +0 -1
  153. package/dist/types.js +0 -1796
  154. package/dist/types.js.map +0 -1
  155. package/dist/utils/effect.d.ts +0 -3
  156. package/dist/utils/effect.d.ts.map +0 -1
  157. package/dist/utils/effect.js +0 -2
  158. package/dist/utils/effect.js.map +0 -1
  159. package/dist/utils/tsplus.d.ts +0 -14
  160. package/dist/utils/tsplus.d.ts.map +0 -1
  161. package/dist/utils/tsplus.js +0 -2
  162. package/dist/utils/tsplus.js.map +0 -1
  163. package/dist/webhooks.d.ts +0 -16
  164. package/dist/webhooks.d.ts.map +0 -1
  165. package/dist/webhooks.js +0 -23
  166. package/dist/webhooks.js.map +0 -1
  167. package/src/DiscordConfig/index.ts +0 -52
  168. package/src/DiscordGateway/DiscordWS/index.ts +0 -50
  169. package/src/DiscordGateway/Shard/heartbeats.ts +0 -39
  170. package/src/DiscordGateway/Shard/identify.ts +0 -61
  171. package/src/DiscordGateway/Shard/index.ts +0 -90
  172. package/src/DiscordGateway/Shard/invalidSession.ts +0 -11
  173. package/src/DiscordGateway/Shard/sendEvents.ts +0 -35
  174. package/src/DiscordGateway/Shard/utils.ts +0 -14
  175. package/src/DiscordGateway/ShardStore/index.ts +0 -33
  176. package/src/DiscordGateway/Sharder/index.ts +0 -95
  177. package/src/DiscordGateway/WS/index.ts +0 -99
  178. package/src/DiscordGateway/index.ts +0 -55
  179. package/src/DiscordREST/index.ts +0 -132
  180. package/src/DiscordREST/types.ts +0 -14
  181. package/src/DiscordREST/utils.ts +0 -35
  182. package/src/Helpers/flags.ts +0 -68
  183. package/src/Helpers/intents.ts +0 -32
  184. package/src/Helpers/interactions.ts +0 -180
  185. package/src/Helpers/members.ts +0 -14
  186. package/src/Helpers/permissions.ts +0 -102
  187. package/src/Helpers/ui.ts +0 -103
  188. package/src/Http/index.ts +0 -65
  189. package/src/Interactions/context.ts +0 -100
  190. package/src/Interactions/definitions.ts +0 -144
  191. package/src/Interactions/gateway.ts +0 -55
  192. package/src/Interactions/handlers.ts +0 -139
  193. package/src/Interactions/index.ts +0 -83
  194. package/src/Interactions/utils.ts +0 -81
  195. package/src/Interactions/webhook.ts +0 -96
  196. package/src/Log/index.ts +0 -23
  197. package/src/RateLimitStore/index.ts +0 -65
  198. package/src/RateLimitStore/memory.ts +0 -48
  199. package/src/RateLimitStore/utils.ts +0 -27
  200. package/src/common-gateway.ts +0 -5
  201. package/src/common.ts +0 -30
  202. package/src/global.ts +0 -50
  203. package/src/index.ts +0 -36
  204. package/src/json.d.ts +0 -1
  205. package/src/types.ts +0 -6095
  206. package/src/utils/effect.ts +0 -7
  207. package/src/utils/tsplus.ts +0 -11
  208. package/src/webhooks.ts +0 -30
@@ -1,61 +0,0 @@
1
- import * as tsplus_module_1 from "callbag-effect-ts/Source/fromEffect";
2
- import * as tsplus_module_2 from "callbag-effect-ts/Source/resource";
3
- import * as tsplus_module_3 from "callbag-effect-ts/Source/map";
4
- import * as tsplus_module_4 from "@fp-ts/data/Duration";
5
- import * as tsplus_module_5 from "@fp-ts/data/Option";
6
- import * as tsplus_module_6 from "callbag-effect-ts/Source/empty";
7
- import * as tsplus_module_7 from "@effect/io/Effect";
8
- import * as tsplus_module_8 from "callbag-effect-ts/Source/of";
9
- import * as tsplus_module_9 from "dfx/common-gateway";
10
- import * as tsplus_module_10 from "callbag-effect-ts/Source/tap";
11
- import * as tsplus_module_11 from "callbag-effect-ts/Source/mapEffect";
12
- import * as tsplus_module_12 from "callbag-effect-ts/Source/groupBy";
13
- import * as tsplus_module_13 from "callbag-effect-ts/Source/chainPar";
14
- import * as tsplus_module_14 from "dfx/common";
15
- import * as tsplus_module_15 from "callbag-effect-ts/Source/drain";
16
- import * as tsplus_module_16 from "callbag-effect-ts/Source/merge";
17
- import * as tsplus_module_17 from "callbag-effect-ts/Source/unwrap";
18
- import { millis } from "@fp-ts/data/Duration";
19
- import { overridePull } from "callbag-effect-ts/Source";
20
- import { ShardStore } from "../ShardStore/index.js";
21
- const configs = (totalCount) => tsplus_module_7.map(store => {
22
- const claimId = (sharderCount) => tsplus_module_7.flatMap((a) => tsplus_module_5.match(() => tsplus_module_7.delay(tsplus_module_4.minutes(3))(tsplus_module_7.succeed([
23
- tsplus_module_5.some(sharderCount),
24
- tsplus_module_6.empty,
25
- ])), (id) => tsplus_module_7.succeed([
26
- tsplus_module_5.some(sharderCount + 1),
27
- tsplus_module_8.of(id),
28
- ]))(a))(store
29
- .claimId({
30
- totalCount,
31
- sharderCount,
32
- }));
33
- return tsplus_module_3.map((id) => ({
34
- id,
35
- totalCount,
36
- }))(tsplus_module_2.resource(0, (sharderCount) => tsplus_module_1.fromEffect(claimId(sharderCount))));
37
- })(tsplus_module_7.service(ShardStore));
38
- const spawnEffect = tsplus_module_7.map(({ gateway, config, configs, limiter }) => {
39
- const [source, pull] = overridePull(configs, gateway.session_start_limit.max_concurrency);
40
- return tsplus_module_10.tap(() => tsplus_module_7.sync(pull))(tsplus_module_13.chainPar(([shardConfig, key]) => tsplus_module_11.mapEffect((c) => tsplus_module_9.Shard.make([c.id, c.totalCount]))(tsplus_module_10.tap(() => limiter.maybeWait(`gateway.sharder.${key}`, millis(config.identifyRateLimit[0]), config.identifyRateLimit[1]))(shardConfig)))(tsplus_module_12.groupBy((c) => c.id % c.concurrency)(tsplus_module_3.map((config) => ({
41
- ...config,
42
- url: gateway.url,
43
- concurrency: gateway.session_start_limit.max_concurrency,
44
- }))(source))));
45
- })(tsplus_module_7.bind("configs", ({ gateway, config }) => configs(config.shardCount ?? gateway.shards))(tsplus_module_7.structPar({
46
- gateway: tsplus_module_7.catchAll(() => tsplus_module_7.succeed({
47
- url: "wss://gateway.discord.gg/",
48
- shards: 1,
49
- session_start_limit: {
50
- total: 0,
51
- remaining: 0,
52
- reset_after: 0,
53
- max_concurrency: 1,
54
- },
55
- }))(tsplus_module_7.flatMap((r) => r.json)(tsplus_module_14.Rest.rest
56
- .getGatewayBot())),
57
- config: tsplus_module_14.Config.gateway,
58
- limiter: tsplus_module_7.service(tsplus_module_14.RateLimitStore.RateLimiter),
59
- })));
60
- export const spawn = tsplus_module_13.chainPar((shard) => tsplus_module_16.merge(tsplus_module_15.drain(tsplus_module_1.fromEffect(shard.run)))(tsplus_module_8.of(shard)))(tsplus_module_17.unwrap(spawnEffect));
61
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/DiscordGateway/Sharder/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAEnD,MAAM,OAAO,GAAG,CAAC,UAAkB,EAAE,EAAE,qBAE7B,KAAK;IACX,MAAM,OAAO,GAAG,CAAC,YAAoB,EAAE,EAAE,CACvC,wBAMI,CACE,CAAC,EAKD,EAAE,CACF,sBACE,GAAG,EAAE,CACH,sBAGkB,wBAAiB,CAAC,CAAC,EAHrC,wBAAe;QACb,qBAAW,YAAY,CAAC;;KAEhB,CAAC,CAA2B,EACxC,CAAC,EAAE,EAAE,EAAE,CACL,wBAAe;QACb,qBAAW,YAAY,GAAG,CAAC,CAAC;QAC5B,mBAAgB,EAAE,CAAC;KACpB,CAAC,EAVN,CAAC,CAWA,EAxBP,KAAK;SACF,OAAO,CAAC;QACP,UAAU;QACV,YAAY;KACb,CAAC,CAqBD,CAAA;IAEL,OAAO,oBAED,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACb,EAAE;QACF,UAAU;KACX,CAAC,EALK,yBAAsB,CAAC,EAAE,CAAC,YAAY,EAAE,EAAE,CAC/C,2BAAwB,OAAO,CAAC,YAAY,CAAC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AAO,EAAE,yBAGG,GAAG,EAAE,CACb,wBAA8C;QAC5C,GAAG,EAAE,2BAA2B;QAChC,MAAM,EAAE,CAAC;QACT,mBAAmB,EAAE;YACnB,KAAK,EAAE,CAAC;YACR,SAAS,EAAE,CAAC;YACZ,WAAW,EAAE,CAAC;YACd,eAAe,EAAE,CAAC;SACnB;KACF,CAAC,EAbG,wBAEE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAFf,iBAAA,IAAI,CAAC,IAAI;SACf,aAAa,EAAE,CACO,CAYtB;IACH,MAAM,EAAE,iBAAA,MAAM,CAAC,OAAO;IACtB,OAAO,EAAE,wBAAe,iBAAA,cAAc,CAAC,WAAW,CAAC;CACpD,CAAC,CAGC,CA0BC,CAAA;AAEJ,MAAM,CAAC,MAAM,KAAK,GAAG,0BAA4B,CAAC,KAAK,EAAE,EAAE,CACzD,8CAA6B,2BAAwB,KAAK,CAAC,GAAG,CAAC,GAA/D,mBAAgB,KAAK,CAAC,CAAgD,0BADnD,WAAW,EAE/B,CAAA"}
@@ -1,28 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="ws" />
3
- import { Ref, EffectSource } from "dfx/common";
4
- import WebSocket from "isomorphic-ws";
5
- export declare const Reconnect: unique symbol;
6
- export type Reconnect = typeof Reconnect;
7
- export type Message = string | Buffer | ArrayBuffer | Reconnect;
8
- export declare class WebSocketError {
9
- readonly reason: unknown;
10
- readonly _tag = "WebSocketError";
11
- constructor(reason: unknown);
12
- }
13
- export declare class WebSocketCloseError {
14
- readonly code: number;
15
- readonly reason: string;
16
- readonly _tag = "WebSocketCloseError";
17
- constructor(code: number, reason: string);
18
- }
19
- export declare class WebSocketWriteError {
20
- readonly reason: Error;
21
- readonly _tag = "WebSocketWriteError";
22
- constructor(reason: Error);
23
- }
24
- export declare const make: (url: Ref<string>, options?: WebSocket.ClientOptions) => import("../../common.js").Effect<import("../../Log/index.js").Log, never, {
25
- source: import("callbag-effect-ts/Source").EffectSource<never, WebSocketError | WebSocketCloseError | WebSocketWriteError, WebSocket.RawData>;
26
- sink: import("callbag-effect-ts/Sink").EffectSink<never, never, never, Message>;
27
- }>;
28
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/DiscordGateway/WS/index.ts"],"names":[],"mappings":";;;AAAA,OAAO,SAAS,MAAM,eAAe,CAAA;AAErC,eAAO,MAAM,SAAS,eAAW,CAAA;AACjC,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAA;AACxC,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,CAAA;AAa/D,qBAAa,cAAc;IAEb,QAAQ,CAAC,MAAM,EAAE,OAAO;IADpC,QAAQ,CAAC,IAAI,oBAAmB;gBACX,MAAM,EAAE,OAAO;CACrC;AAED,qBAAa,mBAAmB;IAElB,QAAQ,CAAC,IAAI,EAAE,MAAM;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM;IAD1D,QAAQ,CAAC,IAAI,yBAAwB;gBAChB,IAAI,EAAE,MAAM,EAAW,MAAM,EAAE,MAAM;CAC3D;AAmBD,qBAAa,mBAAmB;IAElB,QAAQ,CAAC,MAAM,EAAE,KAAK;IADlC,QAAQ,CAAC,IAAI,yBAAwB;gBAChB,MAAM,EAAE,KAAK;CACnC;AAkCD,eAAO,MAAM,IAAI,QAAS,IAAI,MAAM,CAAC,YAAY,UAAU,aAAa;;;EAiBpE,CAAA"}
@@ -1,82 +0,0 @@
1
- import * as tsplus_module_1 from "@effect/io/Effect";
2
- import * as tsplus_module_2 from "@effect/io/Ref";
3
- import * as tsplus_module_3 from "callbag-effect-ts/Source/async";
4
- import * as tsplus_module_4 from "callbag-effect-ts/Source/unwrap";
5
- import * as tsplus_module_5 from "callbag-effect-ts/Source/tap";
6
- import * as tsplus_module_6 from "callbag-effect-ts/Source/drain";
7
- import * as tsplus_module_7 from "dfx/common";
8
- import * as tsplus_module_8 from "@effect/io/Schedule";
9
- import * as tsplus_module_9 from "callbag-effect-ts/Source/merge";
10
- import * as tsplus_module_10 from "callbag-effect-ts/Source/unwrapScope";
11
- import * as tsplus_module_11 from "callbag-effect-ts/Source/retry";
12
- import WebSocket from "isomorphic-ws";
13
- export const Reconnect = Symbol();
14
- const socket = (urlRef, options) => tsplus_module_1.acquireRelease(tsplus_module_1.map(url => new WebSocket(url, options))(tsplus_module_2.get(urlRef)), (ws) => tsplus_module_1.sync(() => {
15
- ws.close();
16
- ws.removeAllListeners();
17
- }));
18
- export class WebSocketError {
19
- reason;
20
- _tag = "WebSocketError";
21
- constructor(reason) {
22
- this.reason = reason;
23
- }
24
- }
25
- export class WebSocketCloseError {
26
- code;
27
- reason;
28
- _tag = "WebSocketCloseError";
29
- constructor(code, reason) {
30
- this.code = code;
31
- this.reason = reason;
32
- }
33
- }
34
- const recv = (ws) => tsplus_module_3.async((emit) => {
35
- ws.on("message", (message) => {
36
- emit.data(message);
37
- });
38
- ws.on("error", (cause) => {
39
- emit.fail(new WebSocketError(cause));
40
- });
41
- ws.on("close", (code, reason) => {
42
- emit.fail(new WebSocketCloseError(code, reason.toString("utf8")));
43
- });
44
- });
45
- export class WebSocketWriteError {
46
- reason;
47
- _tag = "WebSocketWriteError";
48
- constructor(reason) {
49
- this.reason = reason;
50
- }
51
- }
52
- const send = (ws, out) => tsplus_module_1.map(log => tsplus_module_6.drain(tsplus_module_5.tap((data) => tsplus_module_1.async((resume) => {
53
- if (data === Reconnect) {
54
- ws.close(1012, "reconnecting");
55
- resume(tsplus_module_1.unit());
56
- }
57
- else {
58
- ws.send(data, (err) => {
59
- resume(err
60
- ? tsplus_module_1.fail(new WebSocketWriteError(err))
61
- : tsplus_module_1.unit());
62
- });
63
- }
64
- }))(tsplus_module_5.tap((p) => log.debug("WS", "send", p))(tsplus_module_4.unwrap(tsplus_module_1.map(() => out)(tsplus_module_1.async((resume) => {
65
- if (ws.readyState & ws.OPEN) {
66
- resume(tsplus_module_1.unit());
67
- }
68
- else {
69
- ws.once("open", () => {
70
- resume(tsplus_module_1.unit());
71
- });
72
- }
73
- })))))))(tsplus_module_1.service(tsplus_module_7.Log.Log));
74
- export const make = (url, options) => (() => {
75
- const [sink, outbound] = tsplus_module_3.asyncSink();
76
- return tsplus_module_1.map(log => {
77
- const withLog = tsplus_module_1.provideService(tsplus_module_7.Log.Log)(log);
78
- const source = tsplus_module_11.retry(tsplus_module_8.recurWhile((e) => e._tag === "WebSocketCloseError" && e.code === 1012))(tsplus_module_10.unwrapScope(tsplus_module_1.flatMap(ws => tsplus_module_1.map(sendEffect => tsplus_module_9.merge(sendEffect)(recv(ws)))(withLog(send(ws, outbound))))(socket(url, options))));
79
- return { source, sink };
80
- })(tsplus_module_1.service(tsplus_module_7.Log.Log));
81
- })();
82
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/DiscordGateway/WS/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,SAAS,MAAM,eAAe,CAAA;AAErC,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,EAAE,CAAA;AAIjC,MAAM,MAAM,GAAG,CAAC,MAAmB,EAAE,OAAiC,EAAE,EAAE,CACxE,mDACQ,GAAG,IACF,IAAI,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,sBADpB,MAAM,IAEJ,CAAC,EAAE,EAAE,EAAE,CACvB,qBAAY,GAAG,EAAE;IACf,EAAE,CAAC,KAAK,EAAE,CAAA;IACV,EAAE,CAAC,kBAAkB,EAAE,CAAA;AACzB,CAAC,CAAC,CACH,CAAA;AAEH,MAAM,OAAO,cAAc;IAEJ;IADZ,IAAI,GAAG,gBAAgB,CAAA;IAChC,YAAqB,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;IAAG,CAAC;CACzC;AAED,MAAM,OAAO,mBAAmB;IAET;IAAuB;IADnC,IAAI,GAAG,q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AAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAOlC,CAAA;QAED,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;OAbT,wBAAe,gBAAA,GAAG,CAAC,GAAG,CAAC;IAcrC,CAAA"}
@@ -1,21 +0,0 @@
1
- import { EffectSource, Discord, Effect } from "dfx/common";
2
- import { Success } from "dfx/utils/effect";
3
- export declare const make: import("../common.js").Effect<import("./ShardStore/index.js").ShardStore | import("../index.js").DiscordREST | import("../DiscordConfig/index.js").DiscordConfig | import("../Log/index.js").Log | import("../RateLimitStore/index.js").RateLimiter | import("./DiscordWS/index.js").DiscordWSCodec, never, {
4
- shards: import("callbag-effect-ts/Source").EffectSource<never, never, {
5
- run: import("../common.js").Effect<never, never, readonly [readonly [readonly [readonly [void, void], void], void], void]>;
6
- raw: import("callbag-effect-ts/Source").EffectSource<never, never, import("../types.js").GatewayPayload<any>>;
7
- dispatch: import("callbag-effect-ts/Source").EffectSource<never, never, import("../types.js").GatewayPayload<import("../types.js").ReceiveEvent>>;
8
- send: (p: import("../types.js").GatewayPayload<any>) => void;
9
- reconnect: () => void;
10
- }>;
11
- raw: import("callbag-effect-ts/Source").EffectSource<never, never, import("../types.js").GatewayPayload<any>>;
12
- dispatch: import("callbag-effect-ts/Source").EffectSource<never, never, import("../types.js").GatewayPayload<import("../types.js").ReceiveEvent>>;
13
- fromDispatch: <K extends keyof import("../types.js").ReceiveEvents>(event: K) => import("callbag-effect-ts/Source").EffectSource<never, never, import("../types.js").ReceiveEvents[K]>;
14
- handleDispatch: <K_1 extends keyof import("../types.js").ReceiveEvents, R1, E1, A>(event: K_1, handle: (event: import("../types.js").ReceiveEvents[K_1]) => import("../common.js").Effect<R1, E1, A>) => import("../common.js").Effect<R1, E1, void>;
15
- }>;
16
- export interface DiscordGateway extends Success<typeof make> {
17
- }
18
- export declare const DiscordGateway: import("../common.js").Tag<DiscordGateway>;
19
- export declare const LiveDiscordGateway: import("../common.js").Layer<import("./ShardStore/index.js").ShardStore | import("../index.js").DiscordREST | import("../DiscordConfig/index.js").DiscordConfig | import("../Log/index.js").Log | import("../RateLimitStore/index.js").RateLimiter | import("./DiscordWS/index.js").DiscordWSCodec, never, DiscordGateway>;
20
- export declare const handleDispatch: <K extends keyof import("../types.js").ReceiveEvents, R1, E1, A>(event: K, handle: (event: import("../types.js").ReceiveEvents[K]) => import("../common.js").Effect<R1, E1, A>) => import("../common.js").Effect<DiscordGateway | R1, E1, void>;
21
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/DiscordGateway/index.ts"],"names":[],"mappings":";;AAuBA,eAAO,MAAM,IAAI;;;;;;;;;;;;EAcf,CAAA;AAEF,MAAM,WAAW,cAAe,SAAQ,OAAO,CAAC,OAAO,IAAI,CAAC;CAAG;AAC/D,eAAO,MAAM,cAAc,4CAAwB,CAAA;AACnD,eAAO,MAAM,kBAAkB,4TAAyC,CAAA;AAExE,eAAO,MAAM,cAAc,iPAWxB,CAAA"}
@@ -1,27 +0,0 @@
1
- import * as tsplus_module_1 from "callbag-effect-ts/Source/filter";
2
- import * as tsplus_module_2 from "callbag-effect-ts/Source/map";
3
- import * as tsplus_module_3 from "callbag-effect-ts/Source/fromEffect";
4
- import * as tsplus_module_4 from "callbag-effect-ts/Source/chainPar";
5
- import * as tsplus_module_5 from "callbag-effect-ts/Source/run";
6
- import * as tsplus_module_6 from "callbag-effect-ts/Source/share";
7
- import * as tsplus_module_7 from "@effect/io/Effect";
8
- import * as tsplus_module_8 from "dfx/common";
9
- import * as tsplus_module_9 from "@effect/io/Layer";
10
- import { spawn } from "./Sharder/index.js";
11
- const fromDispatchFactory = (source) => (event) => tsplus_module_2.map((p) => p.d)(tsplus_module_1.filter((p) => p.t === event)(source));
12
- const handleDispatchFactory = (source) => (event, handle) => tsplus_module_5.runDrain(tsplus_module_4.chainPar((a) => tsplus_module_3.fromEffect(handle(a.d)))(tsplus_module_1.filter((p) => p.t === event)(source)));
13
- export const make = tsplus_module_7.flatMap(shards => tsplus_module_7.flatMap(raw => tsplus_module_7.map(dispatch => {
14
- const fromDispatch = fromDispatchFactory(dispatch);
15
- const handleDispatch = handleDispatchFactory(dispatch);
16
- return {
17
- shards,
18
- raw,
19
- dispatch,
20
- fromDispatch,
21
- handleDispatch,
22
- };
23
- })(tsplus_module_6.share(tsplus_module_4.chainPar((s) => s.dispatch)(shards))))(tsplus_module_6.share(tsplus_module_4.chainPar((s) => s.raw)(shards))))(tsplus_module_6.share(spawn));
24
- export const DiscordGateway = tsplus_module_8.Tag();
25
- export const LiveDiscordGateway = tsplus_module_9.fromEffect(DiscordGateway)(make);
26
- export const handleDispatch = (event, handle) => tsplus_module_7.serviceWithEffect(DiscordGateway)((a) => a.handleDispatch(event, handle));
27
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/DiscordGateway/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,MAAM,mBAAmB,GACvB,CACE,MAAwE,EACxE,EAAE,CACJ,CACE,KAAQ,EACsC,EAAE,CAChD,oBAAwC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAS,EAA1D,uBAAc,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,EAAlC,MAAM,CAA6B,CAAwB,CAAA;AAE/D,MAAM,qBAAqB,GACzB,CACE,MAAwE,EACxE,EAAE,CACJ,CACE,KAAQ,EACR,MAA8D,EAChC,EAAE,0BAChC,yBAEY,CAAC,CAAC,EAAE,EAAE,CAAC,2BAAwB,MAAM,CAAC,CAAC,CAAC,CAAQ,CAAC,CAAC,EAF9D,uBACU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,EAD9B,MAAM,CACyB,CACgC,CAAS,CAAA;AAE5E,MAAM,CAAC,MAAM,IAAI,2BACT,MAAM,4BACN,GAAG,wBACH,QAAQ;IACd,MAAM,YAAY,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAA;IAClD,MAAM,cAAc,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAA;IAEtD,OAAO;QACL,MAAM;QACN,GAAG;QACH,QAAQ;QACR,YAAY;QACZ,cAAc;KACf,CAAA;yBAVkB,yBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAjC,MAAM,CAA4B,0BADvC,yBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,EAA5B,MAAM,CAAuB,0BAD1B,KAAK,EAatB,CAAA;AAGF,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAA,GAAG,EAAkB,CAAA;AACnD,MAAM,CAAC,MAAM,kBAAkB,GAAG,2BAAiB,cAAc,CAAC,CAAC,IAAI,CAAC,CAAA;AAExE,MAAM,CAAC,MAAM,cAAc,GAAG,CAM5B,KAAQ,EACR,MAA8D,EAC9D,EAAE,CACF,kCAAyB,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAC7C,CAAC,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAChC,CAAA"}
@@ -1,13 +0,0 @@
1
- import { Effect, Http } from "dfx/common";
2
- import { Success } from "dfx/utils/effect";
3
- import { ResponseWithData } from "./types.js";
4
- declare const make: import("../common.js").Effect<import("../DiscordConfig/index.js").DiscordConfig | import("../Log/index.js").Log | import("dfx/RateLimitStore/index").RateLimitStore | import("dfx/RateLimitStore/index").RateLimiter, never, {
5
- request: <A = unknown>(path: string, init?: RequestInit) => import("../common.js").Effect<never, import("../Http/index.js").FetchError | import("../Http/index.js").StatusCodeError | import("../Http/index.js").JsonParseError, ResponseWithData<A>>;
6
- }>;
7
- export interface DiscordREST extends Success<typeof make> {
8
- }
9
- export declare const DiscordREST: import("../common.js").Tag<DiscordREST>;
10
- export declare const LiveDiscordREST: import("../common.js").Layer<import("../DiscordConfig/index.js").DiscordConfig | import("../Log/index.js").Log | import("dfx/RateLimitStore/index").RateLimitStore | import("dfx/RateLimitStore/index").RateLimiter, never, DiscordREST>;
11
- export declare const rest: import("../types.js").Endpoints<RequestInit>;
12
- export {};
13
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/DiscordREST/index.ts"],"names":[],"mappings":";;AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAI7C,QAAA,MAAM,IAAI;iCAoDA,MAAM,SACN,WAAW;EA8BnB,CAAA;AAEF,MAAM,WAAW,WAAY,SAAQ,OAAO,CAAC,OAAO,IAAI,CAAC;CAAG;AAC5D,eAAO,MAAM,WAAW,yCAAqB,CAAA;AAC7C,eAAO,MAAM,eAAe,0OAAsC,CAAA;AAElE,eAAO,MAAM,IAAI,8CAoChB,CAAA"}
@@ -1,85 +0,0 @@
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 "@fp-ts/data/Equal";
4
- import * as tsplus_module_4 from "@fp-ts/data/Option";
5
- import * as tsplus_module_5 from "@effect/io/Layer";
6
- import { millis } from "@fp-ts/data/Duration";
7
- import { rateLimitFromHeaders, routeFromConfig } from "./utils.js";
8
- import Pkg from "../../package.json" assert { type: "json" };
9
- const make = tsplus_module_1.flatMap(({ token, rest }) => tsplus_module_1.flatMap(log => tsplus_module_1.flatMap(store => tsplus_module_1.map(({ maybeWait }) => {
10
- const globalRateLimit = maybeWait("rest.global", rest.globalRateLimit.window, rest.globalRateLimit.limit);
11
- const requestRateLimit = (path, init) => (() => {
12
- const route = routeFromConfig(path, init);
13
- return tsplus_module_1.flatMap(maybeBucket => {
14
- const bucket = tsplus_module_4.getOrElse(() => ({
15
- key: `?.${tsplus_module_3.hash(route)}`,
16
- resetAfter: 5000,
17
- limit: 1,
18
- }))(maybeBucket);
19
- const resetAfter = millis(bucket.resetAfter);
20
- return tsplus_module_1.map(() => void 0)(maybeWait(`rest.bucket.${bucket.key}`, resetAfter, bucket.limit));
21
- })(store.getBucketForRoute(route));
22
- })();
23
- const updateBuckets = (path, init, response) => tsplus_module_1.ignore((() => {
24
- const route = routeFromConfig(path, init);
25
- return tsplus_module_1.flatMap(({ bucket, retryAfter, limit, remaining }) => {
26
- const effectsToRun = [store.putBucketRoute(route, bucket)];
27
- return tsplus_module_1.flatMap(hasBucket => {
28
- if (!hasBucket || limit - 1 === remaining) {
29
- effectsToRun.push(store.putBucket({
30
- key: bucket,
31
- resetAfter: retryAfter.millis,
32
- limit: !hasBucket && remaining > 0 ? remaining : limit,
33
- }));
34
- }
35
- return tsplus_module_1.map(() => void 0)(tsplus_module_1.collectAllParDiscard(effectsToRun));
36
- })(store.hasBucket(bucket));
37
- })(tsplus_module_1.fromOption(rateLimitFromHeaders(response.headers)));
38
- })());
39
- const request = (path, init = {}) => tsplus_module_1.tap(({ response }) => updateBuckets(path, init, response))(tsplus_module_1.catchTag("StatusCodeError", (e) => e.code === 429
40
- ? tsplus_module_1.flatMap(() => tsplus_module_1.flatMap(() => request(path, init))(updateBuckets(path, init, e.response)))(log.debug("DiscordREST", "429", path)) : tsplus_module_1.fail(e))(tsplus_module_1.flatMap(() => tsplus_module_2.Http.requestWithJson(`${rest.baseUrl}${path}`, {
41
- ...init,
42
- headers: {
43
- ...(init?.headers ?? {}),
44
- Authorization: `Bot ${token}`,
45
- "User-Agent": `DiscordBot (https://github.com/tim-smart/dfx, ${Pkg.version})`,
46
- },
47
- }))(tsplus_module_1.tap(() => globalRateLimit)(requestRateLimit(path, init)))));
48
- return { request };
49
- })(tsplus_module_1.service(tsplus_module_2.RateLimitStore.RateLimiter)))(tsplus_module_1.service(tsplus_module_2.RateLimitStore.RateLimitStore)))(tsplus_module_1.service(tsplus_module_2.Log.Log)))(tsplus_module_1.service(tsplus_module_2.Config.DiscordConfig));
50
- export const DiscordREST = tsplus_module_2.Tag();
51
- export const LiveDiscordREST = tsplus_module_5.fromEffect(DiscordREST)(make);
52
- export const rest = tsplus_module_2.Discord.createRoutes(({ method, url, params, options = {} }) => tsplus_module_1.serviceWithEffect(DiscordREST)(({ request }) => {
53
- const hasBody = method !== "GET" && method !== "DELETE";
54
- let hasFormData = typeof options?.body?.append === "function";
55
- let body = undefined;
56
- const headers = {};
57
- if (hasBody && !hasFormData) {
58
- headers["content-type"] = "application/json";
59
- }
60
- const qs = new URLSearchParams();
61
- if (!hasBody) {
62
- Object.entries((params ?? {})).forEach(([key, value]) => {
63
- qs.append(key, value);
64
- });
65
- }
66
- else if (hasFormData) {
67
- body = options.body;
68
- if (params) {
69
- ;
70
- body.append("payload_json", JSON.stringify(params));
71
- }
72
- }
73
- else if (params) {
74
- body = JSON.stringify(params);
75
- }
76
- else {
77
- body = options.body;
78
- }
79
- return request(`${url}?${qs.toString()}`, {
80
- method,
81
- headers,
82
- body,
83
- });
84
- }));
85
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/DiscordREST/index.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAG7C,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAClE,OAAO,GAAG,MAAM,oBAAoB,CAAC,SAAS,IAAI,EAAE,MAAM,EAAE,CAAA;AAE5D,MAAM,IAAI,4BACF,EAAE,KAAK,EAAE,IAAI,EAAE,6BAEf,GAAG,4BACH,KAAK,yBACL,EAAE,SAAS,EAAE;IAEnB,MAAM,eAAe,GAAG,SAAS,CAC/B,aAAa,EACb,IAAI,CAAC,eAAe,CAAC,MAAM,EAC3B,IAAI,CAAC,eAAe,CAAC,KAAK,CAC3B,CAAA;IAED,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAE,IAAiB,EAAE,EAAE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G,OAAO,CAAC,IAAK,CAAA;KACrB;IAED,OAAO,OAAO,CAAC,GAAG,GAAG,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,EAAE;QACxC,MAAM;QACN,OAAO;QACP,IAAI;KACL,CAAC,CAAA;AACJ,CAAC,CAAC,CACL,CAAA"}
@@ -1,10 +0,0 @@
1
- import { Effect, Http } from "dfx/common";
2
- import { DiscordREST } from "./index.js";
3
- export interface ResponseWithData<A> {
4
- response: Response;
5
- json: Effect<never, Http.JsonParseError, A>;
6
- text: Effect<never, never, string>;
7
- blob: Effect<never, Http.BlobError, Blob>;
8
- }
9
- export type RestResponse<T> = Effect<DiscordREST, Http.FetchError | Http.StatusCodeError | Http.JsonParseError, ResponseWithData<T>>;
10
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/DiscordREST/types.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,QAAQ,EAAE,QAAQ,CAAA;IAClB,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAA;IAC3C,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IAClC,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;CAC1C;AAED,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,MAAM,CAClC,WAAW,EACX,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,cAAc,EAC5D,gBAAgB,CAAC,CAAC,CAAC,CACpB,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/DiscordREST/types.ts"],"names":[],"mappings":""}
@@ -1,11 +0,0 @@
1
- export declare const routeFromConfig: (path: string, init: RequestInit) => string;
2
- export declare const numberHeader: (headers: Headers) => (key: string) => import("../common.js").Maybe<number>;
3
- export declare const retryAfter: (headers: Headers) => import("../common.js").Maybe<import("../common.js").Duration>;
4
- export declare const rateLimitFromHeaders: (headers: Headers) => import("../common.js").Maybe<{
5
- readonly bucket: string;
6
- readonly retryAfter: import("../common.js").Duration;
7
- readonly limit: number;
8
- readonly remaining: number;
9
- }>;
10
- export type RateLimitDetails = ReturnType<typeof rateLimitFromHeaders>;
11
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/DiscordREST/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,SAAU,MAAM,QAAQ,WAAW,WAa9D,CAAA;AAED,eAAO,MAAM,YAAY,YAAa,OAAO,WAAW,MAAM,yCAGjC,CAAA;AAE7B,eAAO,MAAM,UAAU,YAAa,OAAO,kEAGjB,CAAA;AAE1B,eAAO,MAAM,oBAAoB,YAAa,OAAO;;;;;EAMjD,CAAA;AACJ,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
@@ -1,22 +0,0 @@
1
- import * as tsplus_module_1 from "@fp-ts/data/Option";
2
- import * as tsplus_module_2 from "@fp-ts/data/Duration";
3
- const majorResources = ["channels", "guilds", "webhooks"];
4
- export const routeFromConfig = (path, init) => {
5
- const method = (init?.method ?? "get").toLowerCase();
6
- // Only keep major ID's
7
- const routeURL = path
8
- .split("?")[0]
9
- .replace(/\/([A-Za-z]+)\/(\d{16,21}|@me)/g, (match, resource) => majorResources.includes(resource) ? match : `/${resource}`)
10
- // Strip reactions
11
- .replace(/\/reactions\/(.*)/, "/reactions");
12
- return `${method}-${routeURL}`;
13
- };
14
- export const numberHeader = (headers) => (key) => tsplus_module_1.filter((n) => !isNaN(n))(tsplus_module_1.map(parseFloat)(tsplus_module_1.fromNullable(headers.get(key))));
15
- export const retryAfter = (headers) => tsplus_module_1.map(tsplus_module_2.seconds)(tsplus_module_1.catchAll(() => numberHeader(headers)("retry-after"))(numberHeader(headers)("x-ratelimit-reset-after")));
16
- export const rateLimitFromHeaders = (headers) => tsplus_module_1.struct({
17
- bucket: tsplus_module_1.fromNullable(headers.get("x-ratelimit-bucket")),
18
- retryAfter: retryAfter(headers),
19
- limit: numberHeader(headers)("x-ratelimit-limit"),
20
- remaining: numberHeader(headers)("x-ratelimit-remaining"),
21
- });
22
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/DiscordREST/utils.ts"],"names":[],"mappings":";;AAAA,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAU,CAAA;AAElE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,IAAiB,EAAE,EAAE;IACjE,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;IAEpD,uBAAuB;IACvB,MAAM,QAAQ,GAAG,IAAI;SAClB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACb,OAAO,CAAC,iCAAiC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAC9D,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,CAC3D;QACD,kBAAkB;SACjB,OAAO,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAA;IAE7C,OAAO,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAA;AAChC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,GAAW,EAAE,EAAE,CAChE,uBAEU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAF1B,oBACO,UAAU,EADjB,6BAAmB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAClB,CACS,CAAA;AAE7B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAgB,EAAE,EAAE,CAC7C,6CAAA,yBACY,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,EADtD,YAAY,CAAC,OAAO,CAAC,CAAC,yBAAyB,CAAC,CACO,CAC/B,CAAA;AAE1B,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAgB,EAAE,EAAE,CACvD,uBAAa;IACX,MAAM,EAAE,6BAAmB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAC7D,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC;IAC/B,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC;IACjD,SAAS,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,uBAAuB,CAAC;CAC1D,CAAC,CAAA"}
@@ -1,28 +0,0 @@
1
- export type Flags<T extends number | bigint> = Record<string, T>;
2
- /**
3
- * Returns all the flags OR'ed together.
4
- */
5
- export declare function all(flags: Flags<number>): number;
6
- export declare function all(flags: Flags<bigint>): bigint;
7
- /**
8
- * Returns a function that converts a bitfield to a list of flag names.
9
- */
10
- export declare function toList<T extends Flags<number>>(flags: T): (bitfield: number) => (keyof T)[];
11
- export declare function toList<T extends Flags<bigint>>(flags: T): (bitfield: bigint) => (keyof T)[];
12
- /**
13
- * Returns a function that converts a list of flags names to a bigint bitfield.
14
- */
15
- export declare const fromListBigint: <T extends Flags<bigint>>(flags: T) => (list: (keyof T)[]) => bigint;
16
- /**
17
- * Returns a function that converts a list of flags names to a bitfield.
18
- */
19
- export declare const fromList: <T extends Flags<number>>(flags: T) => (list: (keyof T)[]) => number;
20
- /**
21
- * Checks if a bigint bitfield contains and a flag value.
22
- */
23
- export declare const hasBigInt: (flag: bigint | string) => (bits: bigint | string) => boolean;
24
- /**
25
- * Checks if a bitfield contains and a flag value.
26
- */
27
- export declare const has: (flag: number | string) => (bits: number | string) => boolean;
28
- //# sourceMappingURL=flags.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../../src/Helpers/flags.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;AAEhE;;GAEG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;AACjD,wBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;AAKjD;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,EAC5C,KAAK,EAAE,CAAC,GACP,CAAC,QAAQ,EAAE,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAA;AACpC,wBAAgB,MAAM,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,EAC5C,KAAK,EAAE,CAAC,GACP,CAAC,QAAQ,EAAE,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAA;AAYpC;;GAEG;AACH,eAAO,MAAM,cAAc,sEAG+B,CAAA;AAE1D;;GAEG;AACH,eAAO,MAAM,QAAQ,sEAG6B,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,SAAS,SAAU,MAAM,GAAG,MAAM,YAE/B,MAAM,GAAG,MAAM,YAI9B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,GAAG,SAAU,MAAM,GAAG,MAAM,YAEzB,MAAM,GAAG,MAAM,YAI9B,CAAA"}
@@ -1,36 +0,0 @@
1
- export function all(flags) {
2
- return Object.values(flags).reduce((acc, flag) => acc | flag);
3
- }
4
- export function toList(flags) {
5
- const entries = Object.entries(flags);
6
- return (val) => entries.reduce((acc, [key, flag]) => ((val & flag) === flag ? [...acc, key] : acc), []);
7
- }
8
- /**
9
- * Returns a function that converts a list of flags names to a bigint bitfield.
10
- */
11
- export const fromListBigint = (flags) => (list) => list.reduce((acc, key) => acc | flags[key], BigInt(0));
12
- /**
13
- * Returns a function that converts a list of flags names to a bitfield.
14
- */
15
- export const fromList = (flags) => (list) => list.reduce((acc, key) => acc | flags[key], 0);
16
- /**
17
- * Checks if a bigint bitfield contains and a flag value.
18
- */
19
- export const hasBigInt = (flag) => {
20
- const flagBigInt = BigInt(flag);
21
- return (bits) => {
22
- const bitsBigInt = BigInt(bits);
23
- return (bitsBigInt & flagBigInt) === flagBigInt;
24
- };
25
- };
26
- /**
27
- * Checks if a bitfield contains and a flag value.
28
- */
29
- export const has = (flag) => {
30
- const flagNumber = +flag;
31
- return (bits) => {
32
- const bitsNumber = +bits;
33
- return (bitsNumber & flagNumber) === flagNumber;
34
- };
35
- };
36
- //# sourceMappingURL=flags.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flags.js","sourceRoot":"","sources":["../../src/Helpers/flags.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,GAAG,CAAC,KAAiB;IACnC,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,CAAA;AAC/D,CAAC;AAWD,MAAM,UAAU,MAAM,CACpB,KAAQ;IAER,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IACrC,OAAO,CAAC,GAAG,EAAE,EAAE,CACb,OAAO,CAAC,MAAM,CACZ,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG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;AACH,CAAC,CAAA"}
@@ -1,25 +0,0 @@
1
- /**
2
- * All the intents
3
- */
4
- export declare const ALL: number;
5
- /**
6
- * Privileged intents
7
- */
8
- export declare const PRIVILEGED: number;
9
- /**
10
- * Un-privileged intents
11
- */
12
- export declare const UNPRIVILEGED: number;
13
- /**
14
- * Function that converts a intents bitfield value to a list of intent names.
15
- */
16
- export declare const toList: (bitfield: number) => ("GUILDS" | "GUILD_MEMBERS" | "GUILD_BANS" | "GUILD_EMOJIS_AND_STICKERS" | "GUILD_INTEGRATIONS" | "GUILD_WEBHOOKS" | "GUILD_INVITES" | "GUILD_VOICE_STATES" | "GUILD_PRESENCES" | "GUILD_MESSAGES" | "GUILD_MESSAGE_REACTIONS" | "GUILD_MESSAGE_TYPING" | "DIRECT_MESSAGES" | "DIRECT_MESSAGE_REACTIONS" | "DIRECT_MESSAGE_TYPING" | "MESSAGE_CONTENT" | "GUILD_SCHEDULED_EVENTS" | "AUTO_MODERATION_CONFIGURATION" | "AUTO_MODERATION_EXECUTION")[];
17
- /**
18
- * Function that converts a list of intent names to a bitfield value.
19
- */
20
- export declare const fromList: (list: ("GUILDS" | "GUILD_MEMBERS" | "GUILD_BANS" | "GUILD_EMOJIS_AND_STICKERS" | "GUILD_INTEGRATIONS" | "GUILD_WEBHOOKS" | "GUILD_INVITES" | "GUILD_VOICE_STATES" | "GUILD_PRESENCES" | "GUILD_MESSAGES" | "GUILD_MESSAGE_REACTIONS" | "GUILD_MESSAGE_TYPING" | "DIRECT_MESSAGES" | "DIRECT_MESSAGE_REACTIONS" | "DIRECT_MESSAGE_TYPING" | "MESSAGE_CONTENT" | "GUILD_SCHEDULED_EVENTS" | "AUTO_MODERATION_CONFIGURATION" | "AUTO_MODERATION_EXECUTION")[]) => number;
21
- /**
22
- * Check if an intent flag exists in the permissions.
23
- */
24
- export declare const has: (flag: string | number) => (bits: string | number) => boolean;
25
- //# sourceMappingURL=intents.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"intents.d.ts","sourceRoot":"","sources":["../../src/Helpers/intents.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,GAAG,QAAoC,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,UAAU,QAGiB,CAAA;AAExC;;GAEG;AACH,eAAO,MAAM,YAAY,QAAmB,CAAA;AAE5C;;GAEG;AACH,eAAO,MAAM,MAAM,4cAAuC,CAAA;AAE1D;;GAEG;AACH,eAAO,MAAM,QAAQ,wcAAyC,CAAA;AAE9D;;GAEG;AACH,eAAO,MAAM,GAAG,+DAAY,CAAA"}
@@ -1,28 +0,0 @@
1
- import * as tsplus_module_1 from "dfx/common";
2
- /**
3
- * All the intents
4
- */
5
- export const ALL = tsplus_module_1.Flags.all(tsplus_module_1.Discord.GatewayIntents);
6
- /**
7
- * Privileged intents
8
- */
9
- export const PRIVILEGED = tsplus_module_1.Discord.GatewayIntents.GUILD_PRESENCES |
10
- tsplus_module_1.Discord.GatewayIntents.GUILD_MEMBERS |
11
- tsplus_module_1.Discord.GatewayIntents.MESSAGE_CONTENT;
12
- /**
13
- * Un-privileged intents
14
- */
15
- export const UNPRIVILEGED = ALL ^ PRIVILEGED;
16
- /**
17
- * Function that converts a intents bitfield value to a list of intent names.
18
- */
19
- export const toList = tsplus_module_1.Flags.toList(tsplus_module_1.Discord.GatewayIntents);
20
- /**
21
- * Function that converts a list of intent names to a bitfield value.
22
- */
23
- export const fromList = tsplus_module_1.Flags.fromList(tsplus_module_1.Discord.GatewayIntents);
24
- /**
25
- * Check if an intent flag exists in the permissions.
26
- */
27
- export const has = tsplus_module_1.Flags.has;
28
- //# sourceMappingURL=intents.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"intents.js","sourceRoot":"","sources":["../../src/Helpers/intents.ts"],"names":[],"mappings":";AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,gBAAA,KAAK,CAAC,GAAG,CAAC,gBAAA,OAAO,CAAC,cAAc,CAAC,CAAA;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GACrB,gBAAA,OAAO,CAAC,cAAc,CAAC,eAAe;IACtC,gBAAA,OAAO,CAAC,cAAc,CAAC,aAAa;IACpC,gBAAA,OAAO,CAAC,cAAc,CAAC,eAAe,CAAA;AAExC;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,GAAG,UAAU,CAAA;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,gBAAA,KAAK,CAAC,MAAM,CAAC,gBAAA,OAAO,CAAC,cAAc,CAAC,CAAA;AAE1D;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,gBAAA,KAAK,CAAC,QAAQ,CAAC,gBAAA,OAAO,CAAC,cAAc,CAAC,CAAA;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,gBAAA,KAAK,CAAC,GAAG,CAAA"}