dfx 0.3.1 → 0.5.1

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 (307) hide show
  1. package/dist/DiscordConfig/index.d.ts +40 -0
  2. package/dist/DiscordConfig/index.d.ts.map +1 -0
  3. package/dist/DiscordConfig/index.js +29 -0
  4. package/dist/DiscordConfig/index.js.map +1 -0
  5. package/dist/DiscordGateway/DiscordWS/index.d.ts +23 -0
  6. package/dist/DiscordGateway/DiscordWS/index.d.ts.map +1 -0
  7. package/dist/DiscordGateway/DiscordWS/index.js +25 -0
  8. package/dist/DiscordGateway/DiscordWS/index.js.map +1 -0
  9. package/dist/DiscordGateway/Shard/heartbeats.d.ts +3 -0
  10. package/dist/DiscordGateway/Shard/heartbeats.d.ts.map +1 -0
  11. package/dist/DiscordGateway/Shard/heartbeats.js +23 -0
  12. package/dist/DiscordGateway/Shard/heartbeats.js.map +1 -0
  13. package/dist/DiscordGateway/Shard/identify.d.ts +13 -0
  14. package/dist/DiscordGateway/Shard/identify.d.ts.map +1 -0
  15. package/dist/DiscordGateway/Shard/identify.js +30 -0
  16. package/dist/DiscordGateway/Shard/identify.js.map +1 -0
  17. package/dist/DiscordGateway/Shard/index.d.ts +9 -0
  18. package/dist/DiscordGateway/Shard/index.d.ts.map +1 -0
  19. package/dist/DiscordGateway/Shard/index.js +51 -0
  20. package/dist/DiscordGateway/Shard/index.js.map +1 -0
  21. package/dist/DiscordGateway/Shard/invalidSession.d.ts +3 -0
  22. package/dist/DiscordGateway/Shard/invalidSession.d.ts.map +1 -0
  23. package/dist/DiscordGateway/Shard/invalidSession.js +9 -0
  24. package/dist/DiscordGateway/Shard/invalidSession.js.map +1 -0
  25. package/dist/DiscordGateway/Shard/sendEvents.d.ts +8 -0
  26. package/dist/DiscordGateway/Shard/sendEvents.d.ts.map +1 -0
  27. package/dist/DiscordGateway/Shard/sendEvents.js +26 -0
  28. package/dist/DiscordGateway/Shard/sendEvents.js.map +1 -0
  29. package/dist/DiscordGateway/Shard/utils.d.ts +4 -0
  30. package/dist/DiscordGateway/Shard/utils.d.ts.map +1 -0
  31. package/dist/DiscordGateway/Shard/utils.js +9 -0
  32. package/dist/DiscordGateway/Shard/utils.js.map +1 -0
  33. package/dist/DiscordGateway/ShardStore/index.d.ts +13 -0
  34. package/dist/DiscordGateway/ShardStore/index.d.ts.map +1 -0
  35. package/dist/DiscordGateway/ShardStore/index.js +22 -0
  36. package/dist/DiscordGateway/ShardStore/index.js.map +1 -0
  37. package/dist/DiscordGateway/Sharder/index.d.ts +10 -0
  38. package/dist/DiscordGateway/Sharder/index.d.ts.map +1 -0
  39. package/dist/DiscordGateway/Sharder/index.js +60 -0
  40. package/dist/DiscordGateway/Sharder/index.js.map +1 -0
  41. package/dist/DiscordGateway/WS/index.d.ts +28 -0
  42. package/dist/DiscordGateway/WS/index.d.ts.map +1 -0
  43. package/dist/DiscordGateway/WS/index.js +82 -0
  44. package/dist/DiscordGateway/WS/index.js.map +1 -0
  45. package/dist/DiscordGateway/index.d.ts +21 -0
  46. package/dist/DiscordGateway/index.d.ts.map +1 -0
  47. package/dist/DiscordGateway/index.js +27 -0
  48. package/dist/DiscordGateway/index.js.map +1 -0
  49. package/dist/DiscordREST/index.d.ts +13 -0
  50. package/dist/DiscordREST/index.d.ts.map +1 -0
  51. package/dist/DiscordREST/index.js +85 -0
  52. package/dist/DiscordREST/index.js.map +1 -0
  53. package/dist/DiscordREST/types.d.ts +10 -0
  54. package/dist/DiscordREST/types.d.ts.map +1 -0
  55. package/dist/DiscordREST/types.js +2 -0
  56. package/{esm → dist}/DiscordREST/types.js.map +1 -1
  57. package/dist/DiscordREST/utils.d.ts +11 -0
  58. package/dist/DiscordREST/utils.d.ts.map +1 -0
  59. package/dist/DiscordREST/utils.js +22 -0
  60. package/dist/DiscordREST/utils.js.map +1 -0
  61. package/dist/Helpers/flags.d.ts +28 -0
  62. package/dist/Helpers/flags.d.ts.map +1 -0
  63. package/dist/Helpers/flags.js +36 -0
  64. package/dist/Helpers/flags.js.map +1 -0
  65. package/dist/Helpers/intents.d.ts +25 -0
  66. package/dist/Helpers/intents.d.ts.map +1 -0
  67. package/dist/Helpers/intents.js +28 -0
  68. package/dist/Helpers/intents.js.map +1 -0
  69. package/dist/Helpers/interactions.d.ts +74 -0
  70. package/dist/Helpers/interactions.d.ts.map +1 -0
  71. package/dist/Helpers/interactions.js +93 -0
  72. package/dist/Helpers/interactions.js.map +1 -0
  73. package/dist/Helpers/members.d.ts +10 -0
  74. package/dist/Helpers/members.d.ts.map +1 -0
  75. package/dist/Helpers/members.js +10 -0
  76. package/dist/Helpers/members.js.map +1 -0
  77. package/dist/Helpers/permissions.d.ts +35 -0
  78. package/dist/Helpers/permissions.d.ts.map +1 -0
  79. package/dist/Helpers/permissions.js +69 -0
  80. package/dist/Helpers/permissions.js.map +1 -0
  81. package/dist/Helpers/ui.d.ts +48 -0
  82. package/dist/Helpers/ui.d.ts.map +1 -0
  83. package/dist/Helpers/ui.js +67 -0
  84. package/dist/Helpers/ui.js.map +1 -0
  85. package/dist/Http/index.d.ts +31 -0
  86. package/dist/Http/index.d.ts.map +1 -0
  87. package/dist/Http/index.js +54 -0
  88. package/dist/Http/index.js.map +1 -0
  89. package/dist/Interactions/context.d.ts +29 -0
  90. package/dist/Interactions/context.d.ts.map +1 -0
  91. package/dist/Interactions/context.js +23 -0
  92. package/dist/Interactions/context.js.map +1 -0
  93. package/dist/Interactions/definitions.d.ts +55 -0
  94. package/dist/Interactions/definitions.d.ts.map +1 -0
  95. package/dist/Interactions/definitions.js +52 -0
  96. package/dist/Interactions/definitions.js.map +1 -0
  97. package/dist/Interactions/gateway.d.ts +6 -0
  98. package/dist/Interactions/gateway.d.ts.map +1 -0
  99. package/dist/Interactions/gateway.js +17 -0
  100. package/dist/Interactions/gateway.js.map +1 -0
  101. package/dist/Interactions/handlers.d.ts +9 -0
  102. package/dist/Interactions/handlers.d.ts.map +1 -0
  103. package/dist/Interactions/handlers.js +49 -0
  104. package/dist/Interactions/handlers.js.map +1 -0
  105. package/dist/Interactions/index.d.ts +20 -0
  106. package/dist/Interactions/index.d.ts.map +1 -0
  107. package/dist/Interactions/index.js +31 -0
  108. package/dist/Interactions/index.js.map +1 -0
  109. package/dist/Interactions/utils.d.ts +10 -0
  110. package/dist/Interactions/utils.d.ts.map +1 -0
  111. package/dist/Interactions/utils.js +20 -0
  112. package/dist/Interactions/utils.js.map +1 -0
  113. package/dist/Interactions/webhook.d.ts +18 -0
  114. package/dist/Interactions/webhook.d.ts.map +1 -0
  115. package/dist/Interactions/webhook.js +26 -0
  116. package/dist/Interactions/webhook.js.map +1 -0
  117. package/dist/Log/index.d.ts +13 -0
  118. package/dist/Log/index.d.ts.map +1 -0
  119. package/dist/Log/index.js +19 -0
  120. package/dist/Log/index.js.map +1 -0
  121. package/dist/RateLimitStore/index.d.ts +25 -0
  122. package/dist/RateLimitStore/index.d.ts.map +1 -0
  123. package/dist/RateLimitStore/index.js +24 -0
  124. package/dist/RateLimitStore/index.js.map +1 -0
  125. package/dist/RateLimitStore/memory.d.ts +3 -0
  126. package/dist/RateLimitStore/memory.d.ts.map +1 -0
  127. package/dist/RateLimitStore/memory.js +31 -0
  128. package/dist/RateLimitStore/memory.js.map +1 -0
  129. package/dist/RateLimitStore/utils.d.ts +3 -0
  130. package/dist/RateLimitStore/utils.d.ts.map +1 -0
  131. package/dist/RateLimitStore/utils.js +18 -0
  132. package/dist/RateLimitStore/utils.js.map +1 -0
  133. package/dist/common.d.ts +34 -0
  134. package/dist/common.d.ts.map +1 -0
  135. package/dist/common.js +21 -0
  136. package/dist/common.js.map +1 -0
  137. package/dist/global.d.ts +14 -0
  138. package/dist/global.d.ts.map +1 -0
  139. package/dist/global.js +2 -0
  140. package/dist/global.js.map +1 -0
  141. package/dist/index.d.ts +21 -0
  142. package/dist/index.d.ts.map +1 -0
  143. package/dist/index.js +33 -0
  144. package/dist/index.js.map +1 -0
  145. package/{types.d.ts → dist/types.d.ts} +1455 -824
  146. package/dist/types.d.ts.map +1 -0
  147. package/{esm → dist}/types.js +283 -46
  148. package/dist/types.js.map +1 -0
  149. package/dist/utils/effect.d.ts +3 -0
  150. package/dist/utils/effect.d.ts.map +1 -0
  151. package/dist/utils/effect.js +2 -0
  152. package/dist/utils/effect.js.map +1 -0
  153. package/dist/utils/tsplus.d.ts +14 -0
  154. package/dist/utils/tsplus.d.ts.map +1 -0
  155. package/dist/utils/tsplus.js +2 -0
  156. package/dist/utils/tsplus.js.map +1 -0
  157. package/package.json +34 -51
  158. package/src/DiscordConfig/index.ts +52 -0
  159. package/src/DiscordGateway/DiscordWS/index.ts +50 -0
  160. package/src/DiscordGateway/Shard/heartbeats.ts +39 -0
  161. package/src/DiscordGateway/Shard/identify.ts +61 -0
  162. package/src/DiscordGateway/Shard/index.ts +90 -0
  163. package/src/DiscordGateway/Shard/invalidSession.ts +11 -0
  164. package/src/DiscordGateway/Shard/sendEvents.ts +35 -0
  165. package/src/DiscordGateway/Shard/utils.ts +14 -0
  166. package/src/DiscordGateway/ShardStore/index.ts +33 -0
  167. package/src/DiscordGateway/Sharder/index.ts +95 -0
  168. package/src/DiscordGateway/WS/index.ts +99 -0
  169. package/src/DiscordGateway/index.ts +55 -0
  170. package/src/DiscordREST/index.ts +132 -0
  171. package/src/DiscordREST/types.ts +14 -0
  172. package/src/DiscordREST/utils.ts +35 -0
  173. package/src/Helpers/flags.ts +68 -0
  174. package/src/Helpers/intents.ts +32 -0
  175. package/src/Helpers/interactions.ts +180 -0
  176. package/src/Helpers/members.ts +14 -0
  177. package/src/Helpers/permissions.ts +102 -0
  178. package/src/Helpers/ui.ts +103 -0
  179. package/src/Http/index.ts +65 -0
  180. package/src/Interactions/context.ts +76 -0
  181. package/src/Interactions/definitions.ts +124 -0
  182. package/src/Interactions/gateway.ts +44 -0
  183. package/src/Interactions/handlers.ts +139 -0
  184. package/src/Interactions/index.ts +57 -0
  185. package/src/Interactions/utils.ts +47 -0
  186. package/src/Interactions/webhook.ts +59 -0
  187. package/src/Log/index.ts +23 -0
  188. package/src/RateLimitStore/index.ts +65 -0
  189. package/src/RateLimitStore/memory.ts +48 -0
  190. package/src/RateLimitStore/utils.ts +27 -0
  191. package/src/common.ts +35 -0
  192. package/src/global.ts +50 -0
  193. package/src/index.ts +45 -0
  194. package/src/json.d.ts +1 -0
  195. package/{types.ts → src/types.ts} +1615 -875
  196. package/src/utils/effect.ts +7 -0
  197. package/src/utils/tsplus.ts +11 -0
  198. package/DiscordConfig/index.d.ts +0 -29
  199. package/DiscordConfig/index.js +0 -31
  200. package/DiscordConfig/index.js.map +0 -1
  201. package/DiscordConfig/index.ts +0 -45
  202. package/DiscordGateway/index.d.ts +0 -23
  203. package/DiscordGateway/index.js +0 -25
  204. package/DiscordGateway/index.js.map +0 -1
  205. package/DiscordGateway/index.ts +0 -34
  206. package/DiscordGateway/utils.d.ts +0 -3
  207. package/DiscordGateway/utils.js +0 -12
  208. package/DiscordGateway/utils.js.map +0 -1
  209. package/DiscordGateway/utils.ts +0 -17
  210. package/DiscordREST/http.d.ts +0 -3
  211. package/DiscordREST/http.js +0 -20
  212. package/DiscordREST/http.js.map +0 -1
  213. package/DiscordREST/http.ts +0 -21
  214. package/DiscordREST/index.d.ts +0 -15
  215. package/DiscordREST/index.js +0 -63
  216. package/DiscordREST/index.js.map +0 -1
  217. package/DiscordREST/index.ts +0 -79
  218. package/DiscordREST/types.d.ts +0 -14
  219. package/DiscordREST/types.js +0 -6
  220. package/DiscordREST/types.js.map +0 -1
  221. package/DiscordREST/types.ts +0 -15
  222. package/DiscordShard/commands.d.ts +0 -7
  223. package/DiscordShard/commands.js +0 -38
  224. package/DiscordShard/commands.js.map +0 -1
  225. package/DiscordShard/commands.ts +0 -40
  226. package/DiscordShard/heartbeats.d.ts +0 -6
  227. package/DiscordShard/heartbeats.js +0 -29
  228. package/DiscordShard/heartbeats.js.map +0 -1
  229. package/DiscordShard/heartbeats.ts +0 -65
  230. package/DiscordShard/identify.d.ts +0 -15
  231. package/DiscordShard/identify.js +0 -35
  232. package/DiscordShard/identify.js.map +0 -1
  233. package/DiscordShard/identify.ts +0 -75
  234. package/DiscordShard/index.d.ts +0 -32
  235. package/DiscordShard/index.js +0 -65
  236. package/DiscordShard/index.js.map +0 -1
  237. package/DiscordShard/index.ts +0 -124
  238. package/DiscordShard/invalidSession.d.ts +0 -6
  239. package/DiscordShard/invalidSession.js +0 -17
  240. package/DiscordShard/invalidSession.js.map +0 -1
  241. package/DiscordShard/invalidSession.ts +0 -24
  242. package/DiscordShard/utils.d.ts +0 -7
  243. package/DiscordShard/utils.js +0 -17
  244. package/DiscordShard/utils.js.map +0 -1
  245. package/DiscordShard/utils.ts +0 -32
  246. package/DiscordWS/index.d.ts +0 -36
  247. package/DiscordWS/index.js +0 -33
  248. package/DiscordWS/index.js.map +0 -1
  249. package/DiscordWS/index.ts +0 -78
  250. package/Log/index.d.ts +0 -15
  251. package/Log/index.js +0 -28
  252. package/Log/index.js.map +0 -1
  253. package/Log/index.ts +0 -30
  254. package/Utils/memoize.d.ts +0 -3
  255. package/Utils/memoize.js +0 -16
  256. package/Utils/memoize.js.map +0 -1
  257. package/Utils/memoize.ts +0 -15
  258. package/WS/index.d.ts +0 -30
  259. package/WS/index.js +0 -70
  260. package/WS/index.js.map +0 -1
  261. package/WS/index.ts +0 -106
  262. package/bot.d.ts +0 -1
  263. package/bot.js +0 -28
  264. package/bot.js.map +0 -1
  265. package/bot.ts +0 -48
  266. package/esm/DiscordConfig/index.js +0 -26
  267. package/esm/DiscordConfig/index.js.map +0 -1
  268. package/esm/DiscordGateway/index.js +0 -20
  269. package/esm/DiscordGateway/index.js.map +0 -1
  270. package/esm/DiscordGateway/utils.js +0 -7
  271. package/esm/DiscordGateway/utils.js.map +0 -1
  272. package/esm/DiscordREST/http.js +0 -15
  273. package/esm/DiscordREST/http.js.map +0 -1
  274. package/esm/DiscordREST/index.js +0 -59
  275. package/esm/DiscordREST/index.js.map +0 -1
  276. package/esm/DiscordREST/types.js +0 -3
  277. package/esm/DiscordShard/commands.js +0 -28
  278. package/esm/DiscordShard/commands.js.map +0 -1
  279. package/esm/DiscordShard/heartbeats.js +0 -24
  280. package/esm/DiscordShard/heartbeats.js.map +0 -1
  281. package/esm/DiscordShard/identify.js +0 -30
  282. package/esm/DiscordShard/identify.js.map +0 -1
  283. package/esm/DiscordShard/index.js +0 -60
  284. package/esm/DiscordShard/index.js.map +0 -1
  285. package/esm/DiscordShard/invalidSession.js +0 -12
  286. package/esm/DiscordShard/invalidSession.js.map +0 -1
  287. package/esm/DiscordShard/utils.js +0 -11
  288. package/esm/DiscordShard/utils.js.map +0 -1
  289. package/esm/DiscordWS/index.js +0 -28
  290. package/esm/DiscordWS/index.js.map +0 -1
  291. package/esm/Log/index.js +0 -22
  292. package/esm/Log/index.js.map +0 -1
  293. package/esm/Utils/memoize.js +0 -12
  294. package/esm/Utils/memoize.js.map +0 -1
  295. package/esm/WS/index.js +0 -65
  296. package/esm/WS/index.js.map +0 -1
  297. package/esm/bot.js +0 -25
  298. package/esm/bot.js.map +0 -1
  299. package/esm/mod.js +0 -16
  300. package/esm/mod.js.map +0 -1
  301. package/esm/types.js.map +0 -1
  302. package/mod.d.ts +0 -7
  303. package/mod.js +0 -25
  304. package/mod.js.map +0 -1
  305. package/mod.ts +0 -19
  306. package/types.js +0 -1564
  307. package/types.js.map +0 -1
@@ -0,0 +1,52 @@
1
+ import * as tsplus_module_1 from "dfx/common";
2
+ export class GlobalApplicationCommand {
3
+ command;
4
+ handle;
5
+ _tag = "GlobalApplicationCommand";
6
+ constructor(command, handle) {
7
+ this.command = command;
8
+ this.handle = handle;
9
+ }
10
+ }
11
+ export const global = (command, handle) => new GlobalApplicationCommand(command, handle);
12
+ export class GuildApplicationCommand {
13
+ command;
14
+ handle;
15
+ _tag = "GuildApplicationCommand";
16
+ constructor(command, handle) {
17
+ this.command = command;
18
+ this.handle = handle;
19
+ }
20
+ }
21
+ export const guild = (command, handle) => new GuildApplicationCommand(command, handle);
22
+ export class MessageComponent {
23
+ predicate;
24
+ handle;
25
+ _tag = "MessageComponent";
26
+ constructor(predicate, handle) {
27
+ this.predicate = predicate;
28
+ this.handle = handle;
29
+ }
30
+ }
31
+ export const messageComponent = (pred, handle) => new MessageComponent(pred, handle);
32
+ export class ModalSubmit {
33
+ predicate;
34
+ handle;
35
+ _tag = "ModalSubmit";
36
+ constructor(predicate, handle) {
37
+ this.predicate = predicate;
38
+ this.handle = handle;
39
+ }
40
+ }
41
+ export const modalSubmit = (pred, handle) => new ModalSubmit(pred, handle);
42
+ export class Autocomplete {
43
+ predicate;
44
+ handle;
45
+ _tag = "Autocomplete";
46
+ constructor(predicate, handle) {
47
+ this.predicate = predicate;
48
+ this.handle = handle;
49
+ }
50
+ }
51
+ export const autocomplete = (pred, handle) => new Autocomplete(pred, handle);
52
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/Interactions/definitions.ts"],"names":[],"mappings":";AA+BA,MAAM,OAAO,wBAAwB;IAGxB;IACA;IAHF,IAAI,GAAG,0BAA0B,CAAA;IAC1C,YACW,OAAqD,EACrD,MAAyC;QADzC,YAAO,GAAP,OAAO,CAA8C;QACrD,WAAM,GAAN,MAAM,CAAmC;IACjD,CAAC;CACL;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,OAAqD,EACrD,MAAyC,EACzC,EAAE,CACF,IAAI,wBAAwB,CAG1B,OAAO,EAAE,MAAa,CAAC,CAAA;AAE3B,MAAM,OAAO,uBAAuB;IAGvB;IACA;IAHF,IAAI,GAAG,yBAAyB,CAAA;IACzC,YACW,OAAoD,EACpD,MAAyC;QADzC,YAAO,GAAP,OAAO,CAA6C;QACpD,WAAM,GAAN,MAAM,CAAmC;IACjD,CAAC;CACL;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,OAAoD,EACpD,MAAyC,EACzC,EAAE,CACF,IAAI,uBAAuB,CAGzB,OAAO,EAAE,MAAa,CAAC,CAAA;AAE3B,MAAM,OAAO,gBAAgB;IAGhB;IACA;IAHF,IAAI,GAAG,kBAAkB,CAAA;IAClC,YACW,SAAsD,EACtD,MAAyC;QADzC,cAAS,GAAT,SAAS,CAA6C;QACtD,WAAM,GAAN,MAAM,CAAmC;IACjD,CAAC;CACL;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,IAAmD,EACnD,MAA2C,EAC3C,EAAE,CACF,IAAI,gBAAgB,CAGlB,IAAW,EAAE,MAAa,CAAC,CAAA;AAE/B,MAAM,OAAO,WAAW;IAGX;IACA;IAHF,IAAI,GAAG,aAAa,CAAA;IAC7B,YACW,SAAsD,EACtD,MAAyC;QADzC,cAAS,GAAT,SAAS,CAA6C;QACtD,WAAM,GAAN,MAAM,CAAmC;IACjD,CAAC;CACL;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,IAAmD,EACnD,MAA2C,EAC3C,EAAE,CACF,IAAI,WAAW,CAGb,IAAW,EAAE,MAAa,CAAC,CAAA;AAE/B,MAAM,OAAO,YAAY;IAGZ;IAGA;IALF,IAAI,GAAG,cAAc,CAAA;IAC9B,YACW,SAEiB,EACjB,MAAyC;QAHzC,cAAS,GAAT,SAAS,CAEQ;QACjB,WAAM,GAAN,MAAM,CAAmC;IACjD,CAAC;CACL;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,IAE4B,EAC5B,MAA2C,EAC3C,EAAE,CACF,IAAI,YAAY,CAQd,IAAW,EAAE,MAAa,CAAC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import * as D from "./definitions.js";
2
+ export interface RunOpts {
3
+ sync?: boolean;
4
+ }
5
+ export declare const run: <R, E>(definitions: D.InteractionDefinition<R, E>[], { sync }?: RunOpts) => import("../common.js").Effect<import("../index.js").DiscordREST | import("../DiscordGateway/index.js").DiscordGateway | R, import("../Http/index.js").FetchError | import("../Http/index.js").StatusCodeError | import("../Http/index.js").JsonParseError | E, void>;
6
+ //# sourceMappingURL=gateway.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/Interactions/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,kBAAkB,CAAA;AAIrC,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,eAAO,MAAM,GAAG,kEAEG,OAAO,yQAiCtB,CAAA"}
@@ -0,0 +1,17 @@
1
+ import * as tsplus_module_1 from "@effect/io/Effect";
2
+ import * as tsplus_module_2 from "dfx/common";
3
+ import { handlers } from "./handlers.js";
4
+ import { splitDefinitions } from "./utils.js";
5
+ export const run = (definitions, { sync = true } = {}) => (() => {
6
+ const { globalCommands, guildCommands } = splitDefinitions(definitions);
7
+ return tsplus_module_1.flatMap(application => {
8
+ const globalSync = tsplus_module_2.Rest.rest.bulkOverwriteGlobalApplicationCommands(application.id, {
9
+ body: JSON.stringify(globalCommands.map((a) => a.command)),
10
+ });
11
+ const guildSync = tsplus_module_2.Gateway.handleDispatch("GUILD_CREATE", (a) => tsplus_module_2.Rest.rest.bulkOverwriteGuildApplicationCommands(application.id, a.id, guildCommands.map((a) => a.command)));
12
+ const handle = handlers(definitions);
13
+ const run = tsplus_module_2.Gateway.handleDispatch("INTERACTION_CREATE", (i) => tsplus_module_1.tap((r) => tsplus_module_2.Rest.rest.createInteractionResponse(i.id, i.token, r))(handle[i.type](i)));
14
+ return tsplus_module_1.map(() => void 0)(sync ? tsplus_module_1.zipPar(guildSync)(tsplus_module_1.zipPar(globalSync)(run)) : run);
15
+ })(tsplus_module_1.flatMap((a) => a.json)(tsplus_module_2.Rest.rest.getCurrentBotApplicationInformation()));
16
+ })();
17
+ //# sourceMappingURL=gateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../src/Interactions/gateway.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,e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AU,EAArB,GAAG,CAAmB,CAAkB,CAAC,CAAC,CAAC,GAAG;OA1BrD,wBAAwD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAArE,gBAAA,IAAI,CAAC,IAAI,CAAC,mCAAmC,EAAE,CAAuB;IA2BxE,CAAA"}
@@ -0,0 +1,9 @@
1
+ import { Discord, Effect } from "dfx/common";
2
+ import * as D from "./definitions.js";
3
+ export declare class InteractionNotFound {
4
+ readonly interaction: Discord.Interaction;
5
+ readonly _tag = "InteractionNotFound";
6
+ constructor(interaction: Discord.Interaction);
7
+ }
8
+ export declare const handlers: <R, E>(definitions: D.InteractionDefinition<R, E>[]) => Record<import("../types.js").InteractionType, (i: Discord.Interaction) => import("../common.js").Effect<R, E, import("../types.js").InteractionResponse>>;
9
+ //# sourceMappingURL=handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/Interactions/handlers.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,CAAC,MAAM,kBAAkB,CAAA;AAIrC,qBAAa,mBAAmB;IAElB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,WAAW;IADrD,QAAQ,CAAC,IAAI,yBAAwB;gBAChB,WAAW,EAAE,OAAO,CAAC,WAAW;CACtD;AAED,eAAO,MAAM,QAAQ,4GAIf,QAAQ,WAAW,oFA4HxB,CAAA"}
@@ -0,0 +1,49 @@
1
+ import * as tsplus_module_1 from "dfx/common";
2
+ import * as tsplus_module_2 from "@effect/io/Effect";
3
+ import * as tsplus_module_3 from "@fp-ts/data/Option";
4
+ import * as tsplus_module_4 from "@fp-ts/data/Function";
5
+ import * as tsplus_module_5 from "@fp-ts/data/Chunk";
6
+ import * as Ctx from "./context.js";
7
+ import * as Arr from "@fp-ts/data/ReadonlyArray";
8
+ import { splitDefinitions } from "./utils.js";
9
+ export class InteractionNotFound {
10
+ interaction;
11
+ _tag = "InteractionNotFound";
12
+ constructor(interaction) {
13
+ this.interaction = interaction;
14
+ }
15
+ }
16
+ export const handlers = (definitions) => {
17
+ const { allCommands, autocompletes, messageComponents, modalSubmits } = splitDefinitions(definitions);
18
+ return {
19
+ [tsplus_module_1.Discord.InteractionType.PING]: () => tsplus_module_2.succeed({
20
+ type: tsplus_module_1.Discord.InteractionCallbackType.PONG,
21
+ }),
22
+ [tsplus_module_1.Discord.InteractionType.APPLICATION_COMMAND]: (i) => {
23
+ const data = i.data;
24
+ return tsplus_module_4.pipe(tsplus_module_3.match(() => tsplus_module_2.fail(new InteractionNotFound(i)), (command) => command.handle)(tsplus_module_3.fromNullable(allCommands[data.name])), tsplus_module_2.provideService(Ctx.InteractionContext)(i), tsplus_module_2.provideService(Ctx.ApplicationCommandContext)(data));
25
+ },
26
+ [tsplus_module_1.Discord.InteractionType.MODAL_SUBMIT]: (i) => {
27
+ const data = i.data;
28
+ return tsplus_module_4.pipe(modalSubmits, Arr.map((a) => tsplus_module_2.struct({
29
+ command: tsplus_module_2.succeed(a),
30
+ match: a.predicate(data.custom_id),
31
+ })), (a) => tsplus_module_2.flatMap((a) => tsplus_module_3.match(() => tsplus_module_2.fail(new InteractionNotFound(i)), (a) => a.command.handle)(tsplus_module_5.findFirst((a) => a.match)(a)))(tsplus_module_2.collectAllPar(a)), tsplus_module_2.provideService(Ctx.InteractionContext)(i), tsplus_module_2.provideService(Ctx.ModalSubmitContext)(data));
32
+ },
33
+ [tsplus_module_1.Discord.InteractionType.MESSAGE_COMPONENT]: (i) => {
34
+ const data = i.data;
35
+ return tsplus_module_4.pipe(messageComponents, Arr.map((a) => tsplus_module_2.struct({
36
+ command: tsplus_module_2.succeed(a),
37
+ match: a.predicate(data.custom_id),
38
+ })), (a) => tsplus_module_2.flatMap((a) => tsplus_module_3.match(() => tsplus_module_2.fail(new InteractionNotFound(i)), (a) => a.command.handle)(tsplus_module_5.findFirst((a) => a.match)(a)))(tsplus_module_2.collectAllPar(a)), tsplus_module_2.provideService(Ctx.InteractionContext)(i), tsplus_module_2.provideService(Ctx.MessageComponentContext)(data));
39
+ },
40
+ [tsplus_module_1.Discord.InteractionType.APPLICATION_COMMAND_AUTOCOMPLETE]: (i) => {
41
+ const data = i.data;
42
+ return tsplus_module_3.getOrElse(() => tsplus_module_2.fail(new InteractionNotFound(i)))(tsplus_module_3.map((focusedOption) => tsplus_module_4.pipe(autocompletes, Arr.map((a) => tsplus_module_2.struct({
43
+ command: tsplus_module_2.succeed(a),
44
+ match: a.predicate(focusedOption),
45
+ })), (a) => tsplus_module_2.flatMap((a) => tsplus_module_3.match(() => tsplus_module_2.fail(new InteractionNotFound(i)), (a) => a.command.handle)(tsplus_module_5.findFirst((a) => a.match)(a)))(tsplus_module_2.collectAllPar(a)), tsplus_module_2.provideService(Ctx.InteractionContext)(i), tsplus_module_2.provideService(Ctx.ApplicationCommandContext)(data), tsplus_module_2.provideService(Ctx.FocusedOptionContext)({ focusedOption })))(tsplus_module_1.IxHelpers.focusedOption(data)));
46
+ },
47
+ };
48
+ };
49
+ //# sourceMappingURL=handlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../src/Interactions/handlers.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAEnC,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAA;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAE7C,MAAM,OAAO,mBAAmB;IAET;IADZ,IAAI,GAAG,qBAAqB,CAAA;IACrC,YAAqB,WAAgC;QAAhC,gBAAW,GAAX,WAAW,CAAqB;IAAG,CAAC;CAC1D;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,WAA4C,EAI5C,EAAE;IACF,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,iBAAiB,EAAE,YAAY,EAAE,GACnE,gBAAgB,CAAC,WAAW,CAAC,CAAA;IAE/B,OAAO;QACL,CAAC,gBAAA,OAAO,CAAC,eA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AAC,CAAC,CAAC,CAAQ,EA7B1D,oBACA,CAAC,aAAa,EAAE,EAAE,CACrB,gBAAA,IAAI,CACF,aAAa,EACb,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACZ,uBAAc;gBACZ,OAAO,EAAE,wBAAe,CAAC,CAAC;gBAC1B,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC;aAClC,CAAC,CACH,EACD,CAAC,CAAC,EAAE,EAAE,CACJ,wBAAwB,CAAC,CAAC,EAAE,EAAE,CAC5B,sBAGI,GAAG,EAAE,CACH,qBAAY,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAIrC,EACH,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAT3B,0BACa,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAD3B,CAAC,CAC2B,CASzB,gCAXL,CAAC,EAYA,EACH,+BAAsB,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAChD,+BAAsB,GAAG,CAAC,yBAAyB,CAAC,CAAC,IAAI,CAAC,EAC1D,+BAAsB,GAAG,CAAC,oBAAoB,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,CACnE,EA3BE,gBAAA,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,CA4BjC,CAC+D,CAAA;QACpE,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,20 @@
1
+ import { Discord } from "dfx/common";
2
+ import * as D from "./definitions.js";
3
+ import * as Gateway from "./gateway.js";
4
+ import * as Webhook from "./webhook.js";
5
+ export * from "./context.js";
6
+ export { global, guild, messageComponent, modalSubmit, autocomplete, InteractionDefinition, } from "./definitions.js";
7
+ export { makeConfig as makeWebhookConfig, WebhookConfig, WebhookParseError, BadWebhookSignature, } from "./webhook.js";
8
+ declare class InteractionBuilder<R, E> {
9
+ readonly definitions: D.InteractionDefinition<R, E>[];
10
+ constructor(definitions: D.InteractionDefinition<R, E>[]);
11
+ add<R1, E1>(definition: D.InteractionDefinition<R1, E1>): InteractionBuilder<R | R1, E | E1>;
12
+ runGateway(opts?: Gateway.RunOpts): import("../common.js").Effect<import("../index.js").DiscordREST | import("../DiscordGateway/index.js").DiscordGateway | R, import("../Http/index.js").FetchError | import("../Http/index.js").StatusCodeError | import("../Http/index.js").JsonParseError | E, void>;
13
+ handleWebhook(headers: Record<string, string>, rawBody: string): import("../common.js").Effect<Webhook.WebhookConfig | R, Webhook.BadWebhookSignature | Webhook.WebhookParseError | E, import("../types.js").InteractionResponse>;
14
+ }
15
+ export declare const builder: InteractionBuilder<never, never>;
16
+ export declare const id: (query: string) => (customId: string) => import("../common.js").Effect<never, never, boolean>;
17
+ export declare const idStartsWith: (query: string) => (customId: string) => import("../common.js").Effect<never, never, boolean>;
18
+ export declare const regex: (query: RegExp) => (customId: string) => import("../common.js").Effect<never, never, boolean>;
19
+ export declare const option: (name: string) => (focusedOption: Discord.ApplicationCommandInteractionDataOption) => import("../common.js").Effect<never, never, boolean>;
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Interactions/index.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,CAAC,MAAM,kBAAkB,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC,cAAc,cAAc,CAAA;AAE5B,OAAO,EACL,MAAM,EACN,KAAK,EACL,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,qBAAqB,GACtB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EACL,UAAU,IAAI,iBAAiB,EAC/B,aAAa,EACb,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,cAAc,CAAA;AAErB,cAAM,kBAAkB,CAAC,CAAC,EAAE,CAAC;IACf,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,qBAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;gBAA5C,WAAW,EAAE,CAAC,CAAC,qBAAqB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;IAEjE,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,qBAAqB,CAAC,EAAE,EAAE,EAAE,CAAC;IAOvD,UAAU,CAAC,IAAI,GAAE,OAAO,CAAC,OAAY;IAIrC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM;CAG/D;AAED,eAAO,MAAM,OAAO,kCAA2C,CAAA;AAG/D,eAAO,MAAM,EAAE,UAAW,MAAM,gBAAgB,MAAM,yDAClB,CAAA;AAEpC,eAAO,MAAM,YAAY,UAAW,MAAM,gBAAgB,MAAM,yDACpB,CAAA;AAE5C,eAAO,MAAM,KAAK,UAAW,MAAM,gBAAgB,MAAM,yDACnB,CAAA;AAEtC,eAAO,MAAM,MAAM,SACV,MAAM,qBACG,QAAQ,uCAAuC,yDAClB,CAAA"}
@@ -0,0 +1,31 @@
1
+ import * as tsplus_module_1 from "@effect/io/Effect";
2
+ import * as Gateway from "./gateway.js";
3
+ import * as Webhook from "./webhook.js";
4
+ export * from "./context.js";
5
+ export { global, guild, messageComponent, modalSubmit, autocomplete, } from "./definitions.js";
6
+ export { makeConfig as makeWebhookConfig, WebhookConfig, WebhookParseError, BadWebhookSignature, } from "./webhook.js";
7
+ class InteractionBuilder {
8
+ definitions;
9
+ constructor(definitions) {
10
+ this.definitions = definitions;
11
+ }
12
+ add(definition) {
13
+ return new InteractionBuilder([
14
+ ...this.definitions,
15
+ definition,
16
+ ]);
17
+ }
18
+ runGateway(opts = {}) {
19
+ return Gateway.run(this.definitions, opts);
20
+ }
21
+ handleWebhook(headers, rawBody) {
22
+ return Webhook.run(this.definitions, headers, rawBody);
23
+ }
24
+ }
25
+ export const builder = new InteractionBuilder([]);
26
+ // Filters
27
+ export const id = (query) => (customId) => tsplus_module_1.succeed(query === customId);
28
+ export const idStartsWith = (query) => (customId) => tsplus_module_1.succeed(customId.startsWith(query));
29
+ export const regex = (query) => (customId) => tsplus_module_1.succeed(query.test(customId));
30
+ export const option = (name) => (focusedOption) => tsplus_module_1.succeed(focusedOption.name === name);
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Interactions/index.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC,cAAc,cAAc,CAAA;AAE5B,OAAO,EACL,MAAM,EACN,KAAK,EACL,gBAAgB,EAChB,WAAW,EACX,YAAY,GAEb,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EACL,UAAU,IAAI,iBAAiB,EAC/B,aAAa,EACb,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,cAAc,CAAA;AAErB,MAAM,kBAAkB;IACD;IAArB,YAAqB,WAA4C;QAA5C,gBAAW,GAAX,WAAW,CAAiC;IAAG,CAAC;IAErE,GAAG,CAAS,UAA2C;QACrD,OAAO,IAAI,kBAAkB,CAAiB;YAC5C,GAAG,IAAI,CAAC,WAAW;YACnB,UAAU;SACX,CAAC,CAAA;IACJ,CAAC;IAED,UAAU,CAAC,OAAwB,EAAE;QACnC,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAA;IAC5C,CAAC;IAED,aAAa,CAAC,OAA+B,EAAE,OAAe;QAC5D,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IACxD,CAAC;CACF;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAe,EAAE,CAAC,CAAA;AAE/D,UAAU;AACV,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,QAAgB,EAAE,EAAE,CACxD,wBAAe,KAAK,KAAK,QAAQ,CAAC,CAAA;AAEpC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,QAAgB,EAAE,EAAE,CAClE,wBAAe,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAA;AAE5C,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,QAAgB,EAAE,EAAE,CAC3D,wBAAe,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAA;AAEtC,MAAM,CAAC,MAAM,MAAM,GACjB,CAAC,IAAY,EAAE,EAAE,CACjB,CAAC,aAA8D,EAAE,EAAE,CACjE,wBAAe,aAAa,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA"}
@@ -0,0 +1,10 @@
1
+ import * as D from "./definitions.js";
2
+ export declare const splitDefinitions: <R, E>(definitions: D.InteractionDefinition<R, E>[]) => {
3
+ globalCommands: D.GlobalApplicationCommand<R, E>[];
4
+ guildCommands: D.GuildApplicationCommand<R, E>[];
5
+ messageComponents: D.MessageComponent<R, E>[];
6
+ modalSubmits: D.ModalSubmit<R, E>[];
7
+ autocompletes: D.Autocomplete<R, E>[];
8
+ allCommands: Record<string, D.GlobalApplicationCommand<R, E> | D.GuildApplicationCommand<R, E>>;
9
+ };
10
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/Interactions/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,kBAAkB,CAAA;AAErC,eAAO,MAAM,gBAAgB;;;;;;;CA4C5B,CAAA"}
@@ -0,0 +1,20 @@
1
+ export const splitDefinitions = (definitions) => {
2
+ const globalCommands = definitions.filter((a) => a._tag === "GlobalApplicationCommand");
3
+ const guildCommands = definitions.filter((a) => a._tag === "GuildApplicationCommand");
4
+ const messageComponents = definitions.filter((a) => a._tag === "MessageComponent");
5
+ const modalSubmits = definitions.filter((a) => a._tag === "ModalSubmit");
6
+ const autocompletes = definitions.filter((a) => a._tag === "Autocomplete");
7
+ const allCommands = [...globalCommands, ...guildCommands].reduce((acc, a) => ({
8
+ ...acc,
9
+ [a.command.name]: a,
10
+ }), {});
11
+ return {
12
+ globalCommands,
13
+ guildCommands,
14
+ messageComponents,
15
+ modalSubmits,
16
+ autocompletes,
17
+ allCommands,
18
+ };
19
+ };
20
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/Interactions/utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,WAA4C,EAC5C,EAAE;IACF,MAAM,cAAc,GAAG,WAAW,CAAC,MAAM,CACvC,CAAC,CAAC,EAAyC,EAAE,CAC3C,CAAC,CAAC,IAAI,KAAK,0BAA0B,CACxC,CAAA;IAED,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CACtC,CAAC,CAAC,EAAwC,EAAE,CAC1C,CAAC,CAAC,IAAI,KAAK,yBAAyB,CACvC,CAAA;IAED,MAAM,iBAAiB,GAAG,WAAW,CAAC,MAAM,CAC1C,CAAC,CAAC,EAAiC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,kBAAkB,CACpE,CAAA;IAED,MAAM,YAAY,GAAG,WAAW,CAAC,MAAM,CACrC,CAAC,CAAC,EAA4B,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CAC1D,CAAA;IAED,MAAM,aAAa,GAAG,WAAW,CAAC,MAAM,CACtC,CAAC,CAAC,EAA6B,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,CAC5D,CAAA;IAED,MAAM,WAAW,GAAG,CAAC,GAAG,cAAc,EAAE,GAAG,aAAa,CAAC,CAAC,MAAM,CAC9D,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACX,GAAG,GAAG;QACN,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;KACpB,CAAC,EACF,EAGC,CACF,CAAA;IAED,OAAO;QACL,cAAc;QACd,aAAa;QACb,iBAAiB;QACjB,YAAY;QACZ,aAAa;QACb,WAAW;KACZ,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { Discord } from "dfx/common";
2
+ import * as D from "./definitions.js";
3
+ export declare class BadWebhookSignature {
4
+ readonly _tag = "BadWebhookSignature";
5
+ }
6
+ export interface WebhookConfig {
7
+ applicationId: string;
8
+ publicKey: string;
9
+ }
10
+ export declare const WebhookConfig: import("../common.js").Tag<WebhookConfig>;
11
+ export declare const makeConfig: (a: WebhookConfig) => import("../common.js").Layer<never, never, WebhookConfig>;
12
+ export declare class WebhookParseError {
13
+ readonly reason: unknown;
14
+ readonly _tag = "WebhookParseError";
15
+ constructor(reason: unknown);
16
+ }
17
+ export declare const run: <R, E>(definitions: D.InteractionDefinition<R, E>[], headers: Record<string, string>, body: string) => import("../common.js").Effect<WebhookConfig | R, BadWebhookSignature | WebhookParseError | E, import("../types.js").InteractionResponse>;
18
+ //# sourceMappingURL=webhook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook.d.ts","sourceRoot":"","sources":["../../src/Interactions/webhook.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,CAAC,MAAM,kBAAkB,CAAA;AAGrC,qBAAa,mBAAmB;IAC9B,QAAQ,CAAC,IAAI,yBAAwB;CACtC;AAoBD,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;CAClB;AACD,eAAO,MAAM,aAAa,2CAAuB,CAAA;AACjD,eAAO,MAAM,UAAU,MAAO,aAAa,8DAAoC,CAAA;AAE/E,qBAAa,iBAAiB;IAEhB,QAAQ,CAAC,MAAM,EAAE,OAAO;IADpC,QAAQ,CAAC,IAAI,uBAAsB;gBACd,MAAM,EAAE,OAAO;CACrC;AAcD,eAAO,MAAM,GAAG,gEAEL,OAAO,MAAM,EAAE,MAAM,CAAC,QACzB,MAAM,6IAKV,CAAA"}
@@ -0,0 +1,26 @@
1
+ import * as tsplus_module_1 from "@fp-ts/data/Option";
2
+ import * as tsplus_module_2 from "@fp-ts/data/Either";
3
+ import * as tsplus_module_3 from "dfx/common";
4
+ import * as tsplus_module_4 from "@effect/io/Layer";
5
+ import * as tsplus_module_5 from "@effect/io/Effect";
6
+ import Nacl from "tweetnacl";
7
+ import { handlers } from "./handlers.js";
8
+ export class BadWebhookSignature {
9
+ _tag = "BadWebhookSignature";
10
+ }
11
+ const checkSignature = (publicKey, headers, body) => tsplus_module_2.asUnit(tsplus_module_1.toEither(() => new BadWebhookSignature())(tsplus_module_1.filter((a) => Nacl.sign.detached.verify(Buffer.from(a.timestamp + body), Buffer.from(a.signature, "hex"), Buffer.from(publicKey, "hex")))(tsplus_module_1.struct({
12
+ signature: tsplus_module_1.fromNullable(headers["x-signature-ed25519"]),
13
+ timestamp: tsplus_module_1.fromNullable(headers["x-signature-timestamp"]),
14
+ }))));
15
+ export const WebhookConfig = tsplus_module_3.Tag();
16
+ export const makeConfig = (a) => tsplus_module_4.succeed(WebhookConfig)(a);
17
+ export class WebhookParseError {
18
+ reason;
19
+ _tag = "WebhookParseError";
20
+ constructor(reason) {
21
+ this.reason = reason;
22
+ }
23
+ }
24
+ 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));
25
+ export const run = (definitions, headers, body) => tsplus_module_5.flatMap(interaction => handlers(definitions)[interaction.type](interaction))(fromHeadersAndBody(headers, body));
26
+ //# sourceMappingURL=webhook.js.map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ACE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAwB,EAC7C,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAC1C,EALD,2BAAkB,cAAc,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,GADrC,wBAAe,aAAa,CAAC,CAQrD,CAAA;AAEJ,MAAM,CAAC,MAAM,GAAG,GAAG,CACjB,WAA4C,EAC5C,OAA+B,EAC/B,IAAY,EACZ,EAAE,yBAEM,WAAW,IACR,QAAQ,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,EADvC,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,CAEvD,CAAA"}
@@ -0,0 +1,13 @@
1
+ declare const make: (debug?: boolean) => {
2
+ info: (...args: any[]) => import("../common.js").Effect<never, never, void>;
3
+ debug: (...args: any[]) => import("../common.js").Effect<never, never, void>;
4
+ };
5
+ export interface Log extends ReturnType<typeof make> {
6
+ }
7
+ export declare const Log: import("../common.js").Tag<Log>;
8
+ export declare const LiveLog: import("../common.js").Layer<never, never, Log>;
9
+ export declare const LiveLogDebug: import("../common.js").Layer<never, never, Log>;
10
+ export declare const info: (...args: any[]) => import("../common.js").Effect<Log, never, void>;
11
+ export declare const debug: (...args: any[]) => import("../common.js").Effect<Log, never, void>;
12
+ export {};
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Log/index.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,IAAI;oBACQ,GAAG,EAAE;qBAIJ,GAAG,EAAE;CAMtB,CAAA;AAEF,MAAM,WAAW,GAAI,SAAQ,UAAU,CAAC,OAAO,IAAI,CAAC;CAAG;AACvD,eAAO,MAAM,GAAG,iCAAa,CAAA;AAC7B,eAAO,MAAM,OAAO,iDAAkC,CAAA;AACtD,eAAO,MAAM,YAAY,iDAAiC,CAAA;AAE1D,eAAO,MAAM,IAAI,YAAa,GAAG,EAAE,oDAC6B,CAAA;AAEhE,eAAO,MAAM,KAAK,YAAa,GAAG,EAAE,oDAC0B,CAAA"}
@@ -0,0 +1,19 @@
1
+ import * as tsplus_module_1 from "@effect/io/Effect";
2
+ import * as tsplus_module_2 from "dfx/common";
3
+ import * as tsplus_module_3 from "@effect/io/Layer";
4
+ const make = (debug = false) => ({
5
+ info: (...args) => tsplus_module_1.sync(() => {
6
+ console.error("INFO", ...args);
7
+ }),
8
+ debug: (...args) => debug
9
+ ? tsplus_module_1.sync(() => {
10
+ console.error("DEBUG", ...args);
11
+ })
12
+ : tsplus_module_1.unit(),
13
+ });
14
+ export const Log = tsplus_module_2.Tag();
15
+ export const LiveLog = tsplus_module_3.succeed(Log)(make(false));
16
+ export const LiveLogDebug = tsplus_module_3.succeed(Log)(make(true));
17
+ export const info = (...args) => tsplus_module_1.serviceWithEffect(Log)(({ info: log }) => log(...args));
18
+ export const debug = (...args) => tsplus_module_1.serviceWithEffect(Log)(({ debug }) => debug(...args));
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Log/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,CAAC,KAAK,GAAG,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/B,IAAI,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE,CACvB,qBAAY,GAAG,EAAE;QACf,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAA;IAChC,CAAC,CAAC;IACJ,KAAK,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE,CACxB,KAAK;QACH,CAAC,CAAC,qBAAY,GAAG,EAAE;YACf,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;QACjC,CAAC,CAAC;QACJ,CAAC,CAAC,sBAAa;CACpB,CAAC,CAAA;AAGF,MAAM,CAAC,MAAM,GAAG,GAAG,gBAAA,GAAG,EAAO,CAAA;AAC7B,MAAM,CAAC,MAAM,OAAO,GAAG,wBAAc,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,wBAAc,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;AAE1D,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE,CACrC,kCAAyB,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;AAEhE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE,CACtC,kCAAyB,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA"}
@@ -0,0 +1,25 @@
1
+ import { Effect, Maybe, Duration } from "dfx/common";
2
+ import { Success } from "dfx/utils/effect";
3
+ export type BucketDetails = {
4
+ key: "global" | string;
5
+ resetAfter: number;
6
+ limit: number;
7
+ };
8
+ export interface RateLimitStore {
9
+ hasBucket: (bucketKey: string) => Effect<never, never, boolean>;
10
+ putBucket: (bucket: BucketDetails) => Effect<never, never, void>;
11
+ getBucketForRoute: (route: string) => Effect<never, never, Maybe<BucketDetails>>;
12
+ putBucketRoute: (route: string, bucketKey: string) => Effect<never, never, void>;
13
+ incrementCounter: (key: string, window: number, limit: number) => Effect<never, never, readonly [count: number, ttl: number]>;
14
+ }
15
+ export declare const RateLimitStore: import("../common.js").Tag<RateLimitStore>;
16
+ export declare const LiveMemoryRateLimitStore: import("../common.js").Layer<never, never, RateLimitStore>;
17
+ declare const makeLimiter: import("../common.js").Effect<RateLimitStore | import("../Log/index.js").Log, never, {
18
+ maybeWait: (key: string, window: Duration, limit: number, multiplier?: number) => import("../common.js").Effect<never, never, void>;
19
+ }>;
20
+ export interface RateLimiter extends Success<typeof makeLimiter> {
21
+ }
22
+ export declare const RateLimiter: import("../common.js").Tag<RateLimiter>;
23
+ export declare const LiveRateLimiter: import("../common.js").Layer<RateLimitStore | import("../Log/index.js").Log, never, RateLimiter>;
24
+ export {};
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/RateLimitStore/index.ts"],"names":[],"mappings":";;AAGA,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,QAAQ,GAAG,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;IAE/D,SAAS,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;IAEhE,iBAAiB,EAAE,CACjB,KAAK,EAAE,MAAM,KACV,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAA;IAE/C,cAAc,EAAE,CACd,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,KACd,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;IAE/B,gBAAgB,EAAE,CAChB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,KACV,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAA;CACjE;AAED,eAAO,MAAM,cAAc,4CAAwB,CAAA;AACnD,eAAO,MAAM,wBAAwB,4DAA0C,CAAA;AAE/E,QAAA,MAAM,WAAW;qBAKR,MAAM,UACH,QAAQ,SACT,MAAM;EAoBf,CAAA;AAEF,MAAM,WAAW,WAAY,SAAQ,OAAO,CAAC,OAAO,WAAW,CAAC;CAAG;AACnE,eAAO,MAAM,WAAW,yCAAqB,CAAA;AAC7C,eAAO,MAAM,eAAe,kGAA6C,CAAA"}
@@ -0,0 +1,24 @@
1
+ import * as tsplus_module_1 from "dfx/common";
2
+ import * as tsplus_module_2 from "@effect/io/Layer";
3
+ import * as tsplus_module_3 from "@effect/io/Effect";
4
+ import { delayFrom } from "./utils.js";
5
+ import * as Memory from "./memory.js";
6
+ export const RateLimitStore = tsplus_module_1.Tag();
7
+ export const LiveMemoryRateLimitStore = tsplus_module_2.sync(RateLimitStore)(Memory.make);
8
+ const makeLimiter = tsplus_module_3.flatMap(store => tsplus_module_3.map(log => {
9
+ const maybeWait = (key, window, limit, multiplier = 1.05) => {
10
+ const windowMs = window.millis * multiplier;
11
+ return tsplus_module_3.asUnit(tsplus_module_3.tap(tsplus_module_3.sleep)(tsplus_module_3.tap((d) => log.debug("RateLimitStore maybeWait", {
12
+ key,
13
+ window: window.millis,
14
+ windowMs,
15
+ limit,
16
+ delay: d.millis,
17
+ }))(tsplus_module_3.map(([count, ttl]) => delayFrom(windowMs, limit, count, ttl))(store
18
+ .incrementCounter(key, windowMs, limit)))));
19
+ };
20
+ return { maybeWait };
21
+ })(tsplus_module_3.service(tsplus_module_1.Log.Log)))(tsplus_module_3.service(RateLimitStore));
22
+ export const RateLimiter = tsplus_module_1.Tag();
23
+ export const LiveRateLimiter = tsplus_module_2.fromEffect(RateLimiter)(makeLimiter);
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/RateLimitStore/index.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAA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 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/RateLimitStore/memory.ts"],"names":[],"mappings":";AAKA,eAAO,MAAM,IAAI,QAAO,6BA0CvB,CAAA"}
@@ -0,0 +1,31 @@
1
+ import * as tsplus_module_1 from "@fp-ts/data/Option";
2
+ import * as tsplus_module_2 from "@effect/io/Effect";
3
+ export const make = () => {
4
+ const buckets = new Map();
5
+ const routes = new Map();
6
+ const counters = new Map();
7
+ const getCounter = (key) => tsplus_module_1.filter((c) => c.expires > Date.now())(tsplus_module_1.fromNullable(counters.get(key)));
8
+ return {
9
+ hasBucket: (key) => tsplus_module_2.sync(() => buckets.has(key)),
10
+ putBucket: (bucket) => tsplus_module_2.sync(() => {
11
+ buckets.set(bucket.key, bucket);
12
+ }),
13
+ getBucketForRoute: (route) => tsplus_module_2.sync(() => tsplus_module_1.fromNullable(buckets.get(routes.get(route)))),
14
+ putBucketRoute: (route, bucket) => tsplus_module_2.sync(() => {
15
+ routes.set(route, bucket);
16
+ }),
17
+ incrementCounter: (key, window, limit) => tsplus_module_2.sync(() => {
18
+ const now = Date.now();
19
+ const perRequest = Math.ceil(window / limit);
20
+ const counter = tsplus_module_1.getOrElse(() => ({
21
+ expires: now,
22
+ count: 0,
23
+ }))(getCounter(key));
24
+ const count = counter.count + 1;
25
+ const expires = counter.expires + perRequest;
26
+ counters.set(key, { ...counter, count, expires });
27
+ return [count, expires - now];
28
+ }),
29
+ };
30
+ };
31
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/RateLimitStore/memory.ts"],"names":[],"mappings":";;AAKA,MAAM,CAAC,MAAM,IAAI,GAAG,GAAkC,EAAE;IACtD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAwC,CAAA;IAC/D,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAA;IACxC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAA;IAE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CAAC,KAAK,GAAG,CAAC,CAAA;YAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,GAAG,UAAU,CAAA;YAC5C,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;YAEjD,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,CAAC,CAAA;QAC/B,CAAC,CAAC;KACL,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { Duration } from "dfx/common";
2
+ export declare const delayFrom: (window: number, limit: number, count: number, ttl: number) => Duration;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/RateLimitStore/utils.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,SAAS,WACZ,MAAM,SACP,MAAM,SACN,MAAM,OACR,MAAM,KACV,QAmBF,CAAA"}
@@ -0,0 +1,18 @@
1
+ import { millis, zero } from "@fp-ts/data/Duration";
2
+ export const delayFrom = (window, limit, count, ttl) => {
3
+ const perRequest = Math.ceil(window / limit);
4
+ const totalTime = count * perRequest;
5
+ const elapsedTime = totalTime - ttl;
6
+ const elapsedWindows = Math.floor(elapsedTime / window);
7
+ const completedRequests = elapsedWindows * limit;
8
+ const remainingRequests = count - completedRequests;
9
+ const remainingWindows = Math.floor((remainingRequests - 1) / limit);
10
+ const delayRemainder = elapsedTime % window;
11
+ const requestRemainder = count % limit;
12
+ const staggerDelay = requestRemainder * 50;
13
+ if (remainingWindows === 0) {
14
+ return zero;
15
+ }
16
+ return millis(remainingWindows * window - delayRemainder + staggerDelay);
17
+ };
18
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/RateLimitStore/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAEnD,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,MAAc,EACd,KAAa,EACb,KAAa,EACb,GAAW,EACD,EAAE;IACZ,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAA;IAE5C,MAAM,SAAS,GAAG,KAAK,GAAG,UAAU,CAAA;IACpC,MAAM,WAAW,GAAG,SAAS,GAAG,GAAG,CAAA;IACnC,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC,CAAA;IACvD,MAAM,iBAAiB,GAAG,cAAc,GAAG,KAAK,CAAA;IAChD,MAAM,iBAAiB,GAAG,KAAK,GAAG,iBAAiB,CAAA;IACnD,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,iBAAiB,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAA;IACpE,MAAM,cAAc,GAAG,WAAW,GAAG,MAAM,CAAA;IAE3C,MAAM,gBAAgB,GAAG,KAAK,GAAG,KAAK,CAAA;IACtC,MAAM,YAAY,GAAG,gBAAgB,GAAG,EAAE,CAAA;IAE1C,IAAI,gBAAgB,KAAK,CAAC,EAAE;QAC1B,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,MAAM,CAAC,gBAAgB,GAAG,MAAM,GAAG,cAAc,GAAG,YAAY,CAAC,CAAA;AAC1E,CAAC,CAAA"}
@@ -0,0 +1,34 @@
1
+ export { Effect, EffectTypeId } from "@effect/io/Effect";
2
+ export type { Layer } from "@effect/io/Layer";
3
+ export type { Schedule } from "@effect/io/Schedule";
4
+ export type { Cause } from "@effect/io/Cause";
5
+ export type { Chunk } from "@fp-ts/data/Chunk";
6
+ export { Context, Tag } from "@fp-ts/data/Context";
7
+ export type { Duration } from "@fp-ts/data/Duration";
8
+ export type { Equal } from "@fp-ts/data/Equal";
9
+ export type { Option as Maybe } from "@fp-ts/data/Option";
10
+ export type { Either } from "@fp-ts/data/Either";
11
+ export type { Exit } from "@effect/io/Exit";
12
+ export type { EffectSource } from "callbag-effect-ts/Source";
13
+ export type { EffectSink } from "callbag-effect-ts/Sink";
14
+ export type { HashMap } from "@fp-ts/data/HashMap";
15
+ export type { Ref } from "@effect/io/Ref";
16
+ export * as Config from "dfx/DiscordConfig/index";
17
+ export * as Discord from "dfx/types";
18
+ export * as Http from "dfx/Http/index";
19
+ export * as Log from "dfx/Log/index";
20
+ export * as RateLimitStore from "dfx/RateLimitStore/index";
21
+ export * as Rest from "dfx/DiscordREST/index";
22
+ export * as Gateway from "dfx/DiscordGateway/index";
23
+ export * as WS from "dfx/DiscordGateway/WS/index";
24
+ export * as DWS from "dfx/DiscordGateway/DiscordWS/index";
25
+ export * as Shard from "dfx/DiscordGateway/Shard/index";
26
+ export * as ShardStore from "dfx/DiscordGateway/ShardStore/index";
27
+ export * as Ix from "dfx/Interactions/index";
28
+ export * as Flags from "./Helpers/flags.js";
29
+ export * as Intents from "./Helpers/intents.js";
30
+ export * as IxHelpers from "./Helpers/interactions.js";
31
+ export * as Members from "./Helpers/members.js";
32
+ export * as Perms from "./Helpers/permissions.js";
33
+ export * as UI from "./Helpers/ui.js";
34
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACxD,YAAY,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAC7C,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,YAAY,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAC7C,YAAY,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AAClD,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD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ADDED
@@ -0,0 +1,21 @@
1
+ export { EffectTypeId } from "@effect/io/Effect";
2
+ export { Tag } from "@fp-ts/data/Context";
3
+ export * as Config from "dfx/DiscordConfig/index";
4
+ export * as Discord from "dfx/types";
5
+ export * as Http from "dfx/Http/index";
6
+ export * as Log from "dfx/Log/index";
7
+ export * as RateLimitStore from "dfx/RateLimitStore/index";
8
+ export * as Rest from "dfx/DiscordREST/index";
9
+ export * as Gateway from "dfx/DiscordGateway/index";
10
+ export * as WS from "dfx/DiscordGateway/WS/index";
11
+ export * as DWS from "dfx/DiscordGateway/DiscordWS/index";
12
+ export * as Shard from "dfx/DiscordGateway/Shard/index";
13
+ export * as ShardStore from "dfx/DiscordGateway/ShardStore/index";
14
+ export * as Ix from "dfx/Interactions/index";
15
+ export * as Flags from "./Helpers/flags.js";
16
+ export * as Intents from "./Helpers/intents.js";
17
+ export * as IxHelpers from "./Helpers/interactions.js";
18
+ export * as Members from "./Helpers/members.js";
19
+ export * as Perms from "./Helpers/permissions.js";
20
+ export * as UI from "./Helpers/ui.js";
21
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAKxD,OAAO,EAAW,GAAG,EAAE,MAAM,qBAAqB,CAAA;AAWlD,OAAO,KAAK,MAAM,MAAM,yBAAyB,CAAA;AACjD,OAAO,KAAK,OAAO,MAAM,WAAW,CAAA;AACpC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,GAAG,MAAM,eAAe,CAAA;AACpC,OAAO,KAAK,cAAc,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAA;AAC7C,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AACnD,OAAO,KAAK,EAAE,MAAM,6BAA6B,CAAA;AACjD,OAAO,KAAK,GAAG,MAAM,oCAAoC,CAAA;AACzD,OAAO,KAAK,KAAK,MAAM,gCAAgC,CAAA;AACvD,OAAO,KAAK,UAAU,MAAM,qCAAqC,CAAA;AACjE,OAAO,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAE5C,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAA;AAC3C,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAA;AAC/C,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @tsplus global
3
+ */
4
+ import type { Effect, EffectTypeId, Layer, Either, Maybe, Tag, Context, Cause, Chunk, Duration, Equal, Exit, HashMap, Schedule, EffectSource, EffectSink, Ref, Config, Discord, Http, Log, RateLimitStore, Rest, Gateway, WS, DWS, Shard, ShardStore, Ix, Flags, Intents, IxHelpers, Members, Perms, UI, } from "dfx/common";
5
+ /**
6
+ * @tsplus global
7
+ */
8
+ import type { Success } from "dfx/utils/effect";
9
+ /**
10
+ * @tsplus global
11
+ */
12
+ import { pipe, flow, identity } from "@fp-ts/data/Function";
13
+ export {};
14
+ //# sourceMappingURL=global.d.ts.map