dfx 0.90.2 → 0.91.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/Cache/prelude.d.ts.map +1 -1
  2. package/Cache/prelude.js +8 -2
  3. package/Cache/prelude.js.map +1 -1
  4. package/Cache.d.ts +11 -7
  5. package/Cache.d.ts.map +1 -1
  6. package/Cache.js +8 -9
  7. package/Cache.js.map +1 -1
  8. package/DiscordGateway/Shard.d.ts +2 -2
  9. package/DiscordGateway/Sharder.d.ts +1 -1
  10. package/DiscordGateway/Sharder.d.ts.map +1 -1
  11. package/DiscordGateway.d.ts +1 -1
  12. package/DiscordGateway.d.ts.map +1 -1
  13. package/DiscordREST.d.ts +11 -6
  14. package/DiscordREST.d.ts.map +1 -1
  15. package/DiscordREST.js +16 -10
  16. package/DiscordREST.js.map +1 -1
  17. package/Interactions/context.d.ts +15 -22
  18. package/Interactions/context.d.ts.map +1 -1
  19. package/Interactions/context.js +12 -34
  20. package/Interactions/context.js.map +1 -1
  21. package/Interactions/definitions.d.ts +3 -2
  22. package/Interactions/definitions.d.ts.map +1 -1
  23. package/Interactions/error.d.ts +2 -0
  24. package/Interactions/error.d.ts.map +1 -0
  25. package/Interactions/error.js +8 -0
  26. package/Interactions/error.js.map +1 -0
  27. package/Interactions/webhook.d.ts +9 -4
  28. package/Interactions/webhook.d.ts.map +1 -1
  29. package/Interactions/webhook.js +6 -8
  30. package/Interactions/webhook.js.map +1 -1
  31. package/gateway.d.ts +2 -2
  32. package/gateway.d.ts.map +1 -1
  33. package/index.d.ts +3 -1
  34. package/index.d.ts.map +1 -1
  35. package/index.js +5 -3
  36. package/index.js.map +1 -1
  37. package/mjs/Cache/prelude.mjs +8 -2
  38. package/mjs/Cache/prelude.mjs.map +1 -1
  39. package/mjs/Cache.mjs +6 -8
  40. package/mjs/Cache.mjs.map +1 -1
  41. package/mjs/DiscordREST.mjs +15 -9
  42. package/mjs/DiscordREST.mjs.map +1 -1
  43. package/mjs/Interactions/context.mjs +11 -31
  44. package/mjs/Interactions/context.mjs.map +1 -1
  45. package/mjs/Interactions/error.mjs +2 -0
  46. package/mjs/Interactions/error.mjs.map +1 -0
  47. package/mjs/Interactions/webhook.mjs +6 -8
  48. package/mjs/Interactions/webhook.mjs.map +1 -1
  49. package/mjs/index.mjs +5 -1
  50. package/mjs/index.mjs.map +1 -1
  51. package/mjs/version.mjs +1 -1
  52. package/package.json +2 -2
  53. package/src/Cache/prelude.ts +6 -2
  54. package/src/Cache.ts +15 -8
  55. package/src/DiscordREST.ts +21 -10
  56. package/src/Interactions/context.ts +24 -45
  57. package/src/Interactions/definitions.ts +2 -2
  58. package/src/Interactions/error.ts +3 -0
  59. package/src/Interactions/webhook.ts +7 -5
  60. package/src/index.ts +9 -2
  61. package/src/version.ts +1 -1
  62. package/version.d.ts +1 -1
  63. package/version.js +1 -1
  64. package/webhooks.d.ts +1 -1
  65. package/webhooks.d.ts.map +1 -1
@@ -1,34 +1,23 @@
1
+ import { TypeIdError } from "@effect/platform/Error";
2
+ import * as IxHelpers from "dfx/Helpers/interactions";
3
+ import { InteractionsErrorTypeId } from "dfx/Interactions/error";
1
4
  import { GenericTag } from "effect/Context";
5
+ import * as Effect from "effect/Effect";
2
6
  import * as Option from "effect/Option";
3
7
  import * as Arr from "effect/ReadonlyArray";
4
- import * as Effect from "effect/Effect";
5
- import * as IxHelpers from "dfx/Helpers/interactions";
6
8
  export const Interaction = /*#__PURE__*/GenericTag("dfx/Interactions/Interaction");
7
9
  export const ApplicationCommand = /*#__PURE__*/GenericTag("dfx/Interactions/ApplicationCommand");
8
10
  export const MessageComponentData = /*#__PURE__*/GenericTag("dfx/Interactions/MessageComponentData");
9
11
  export const ModalSubmitData = /*#__PURE__*/GenericTag("dfx/Interactions/ModalSubmitData");
10
12
  export const FocusedOptionContext = /*#__PURE__*/GenericTag("dfx/Interactions/FocusedOptionContext");
11
13
  export const SubCommandContext = /*#__PURE__*/GenericTag("dfx/Interactions/SubCommandContext");
12
- export class ResolvedDataNotFound {
13
- data;
14
- name;
15
- _tag = "ResolvedDataNotFound";
16
- constructor(data, name) {
17
- this.data = data;
18
- this.name = name;
19
- }
20
- }
21
- export const resolvedValues = f => Effect.flatMap(Interaction, ix => Effect.mapError(IxHelpers.resolveValues(f)(ix), () => new ResolvedDataNotFound(ix)));
22
- export const resolved = (name, f) => Effect.flatMap(Interaction, ix => Effect.mapError(IxHelpers.resolveOptionValue(name, f)(ix), () => new ResolvedDataNotFound(ix, name)));
14
+ export const resolvedValues = f => Effect.flatMap(Interaction, ix => IxHelpers.resolveValues(f)(ix));
15
+ export const resolved = (name, f) => Effect.flatMap(Interaction, ix => IxHelpers.resolveOptionValue(name, f)(ix));
23
16
  export const focusedOptionValue = /*#__PURE__*/Effect.map(FocusedOptionContext, _ => _.focusedOption.value ?? "");
24
- export class SubCommandNotFound {
25
- data;
26
- _tag = "SubCommandNotFound";
27
- constructor(data) {
28
- this.data = data;
29
- }
30
- }
31
- export const handleSubCommands = commands => ApplicationCommand.pipe(Effect.flatMap(data => Effect.mapError(Arr.findFirst(IxHelpers.allSubCommands(data), _ => !!commands[_.name]), () => new SubCommandNotFound(data))), Effect.flatMap(command => Effect.provideService(commands[command.name], SubCommandContext, {
17
+ export class SubCommandNotFound extends TypeIdError(InteractionsErrorTypeId, "SubCommandNotFound") {}
18
+ export const handleSubCommands = commands => ApplicationCommand.pipe(Effect.flatMap(data => Effect.mapError(Arr.findFirst(IxHelpers.allSubCommands(data), _ => !!commands[_.name]), () => new SubCommandNotFound({
19
+ data
20
+ }))), Effect.flatMap(command => Effect.provideService(commands[command.name], SubCommandContext, {
32
21
  command
33
22
  })));
34
23
  export const currentSubCommand = /*#__PURE__*/Effect.map(SubCommandContext, _ => _.command);
@@ -50,14 +39,5 @@ export const optionValue = name => Effect.flatMap(option(name), _ => Option.matc
50
39
  export const optionValueOptional = name => Effect.map(option(name), Option.flatMapNullable(o => o.value));
51
40
  export const modalValues = /*#__PURE__*/Effect.map(ModalSubmitData, IxHelpers.componentsMap);
52
41
  export const modalValueOption = name => Effect.map(ModalSubmitData, IxHelpers.componentValue(name));
53
- export class ModalValueNotFound {
54
- data;
55
- name;
56
- _tag = "ModalValueNotFound";
57
- constructor(data, name) {
58
- this.data = data;
59
- this.name = name;
60
- }
61
- }
62
- export const modalValue = name => Effect.flatMap(ModalSubmitData, data => Effect.mapError(IxHelpers.componentValue(name)(data), () => new ModalValueNotFound(data, name)));
42
+ export const modalValue = name => Effect.flatMap(ModalSubmitData, data => IxHelpers.componentValue(name)(data));
63
43
  //# sourceMappingURL=context.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.mjs","names":["GenericTag","Option","Arr","Effect","IxHelpers","Interaction","ApplicationCommand","MessageComponentData","ModalSubmitData","FocusedOptionContext","SubCommandContext","ResolvedDataNotFound","data","name","_tag","constructor","resolvedValues","f","flatMap","ix","mapError","resolveValues","resolved","resolveOptionValue","focusedOptionValue","map","_","focusedOption","value","SubCommandNotFound","handleSubCommands","commands","pipe","findFirst","allSubCommands","command","provideService","currentSubCommand","optionsMap","RequiredOptionNotFound","option","getOption","optionValue","match","flatMapNullable","a","onNone","fail","onSome","succeed","optionValueOptional","o","modalValues","componentsMap","modalValueOption","componentValue","ModalValueNotFound","modalValue"],"sources":["../../src/Interactions/context.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,UAAU,QAAQ,gBAAgB;AAE3C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,GAAG,MAAM,sBAAsB;AAC3C,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,SAAS,MAAM,0BAA0B;AAMrD,OAAO,MAAMC,WAAW,gBAAGL,UAAU,CACnC,8BAA8B,CAC/B;AAKD,OAAO,MAAMM,kBAAkB,gBAAGN,UAAU,CAG1C,qCAAqC,CAAC;AAKxC,OAAO,MAAMO,oBAAoB,gBAAGP,UAAU,CAG5C,uCAAuC,CAA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C,CAACjB,KAAK,CAAC,EACvC;EACEkB,MAAM,EAAEA,CAAA,KACN3C,MAAM,CAACe,OAAO,CAACZ,kBAAkB,EAAEM,IAAI,IACrCT,MAAM,CAAC4C,IAAI,CAAC,IAAIR,sBAAsB,CAAC3B,IAAI,EAAEC,IAAI,CAAC,CAAC,CACpD;EACHmC,MAAM,EAAE7C,MAAM,CAAC8C;CAChB,CACF,CACF;AAEH,OAAO,MAAMC,mBAAmB,GAAIrC,IAAY,IAC9CV,MAAM,CAACsB,GAAG,CACRe,MAAM,CAAC3B,IAAI,CAAC,EACZZ,MAAM,CAAC2C,eAAe,CAACO,CAAC,IAAIA,CAAC,CAACvB,KAAK,CAAC,CACrC;AAEH,OAAO,MAAMwB,WAAW,gBAAGjD,MAAM,CAACsB,GAAG,CAACjB,eAAe,EAAEJ,SAAS,CAACiD,aAAa,CAAC;AAE/E,OAAO,MAAMC,gBAAgB,GAAIzC,IAAY,IAC3CV,MAAM,CAACsB,GAAG,CAACjB,eAAe,EAAEJ,SAAS,CAACmD,cAAc,CAAC1C,IAAI,CAAC,CAAC;AAE7D,OAAM,MAAO2C,kBAAkB;EAGlB5C,IAAA;EACAC,IAAA;EAHFC,IAAI,GAAG,oBAAoB;EACpCC,YACWH,IAA8B,EAC9BC,IAAY;IADZ,KAAAD,IAAI,GAAJA,IAAI;IACJ,KAAAC,IAAI,GAAJA,IAAI;EACZ;;AAGL,OAAO,MAAM4C,UAAU,GAAI5C,IAAY,IACrCV,MAAM,CAACe,OAAO,CAACV,eAAe,EAAEI,IAAI,IAClCT,MAAM,CAACiB,QAAQ,CACbhB,SAAS,CAACmD,cAAc,CAAC1C,IAAI,CAAC,CAACD,IAAI,CAAC,EACpC,MAAM,IAAI4C,kBAAkB,CAAC5C,IAAI,EAAEC,IAAI,CAAC,CACzC,CACF","ignoreList":[]}
1
+ {"version":3,"file":"context.mjs","names":["TypeIdError","IxHelpers","InteractionsErrorTypeId","GenericTag","Effect","Option","Arr","Interaction","ApplicationCommand","MessageComponentData","ModalSubmitData","FocusedOptionContext","SubCommandContext","resolvedValues","f","flatMap","ix","resolveValues","resolved","name","resolveOptionValue","focusedOptionValue","map","_","focusedOption","value","SubCommandNotFound","handleSubCommands","commands","pipe","data","mapError","findFirst","allSubCommands","command","provideService","currentSubCommand","optionsMap","RequiredOptionNotFound","_tag","constructor","option","getOption","optionValue","match","flatMapNullable","a","onNone","fail","onSome","succeed","optionValueOptional","o","modalValues","componentsMap","modalValueOption","componentValue","modalValue"],"sources":["../../src/Interactions/context.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,WAAW,QAAQ,wBAAwB;AACpD,OAAO,KAAKC,SAAS,MAAM,0BAA0B;AACrD,SAASC,uBAAuB,QAAQ,wBAAwB;AAGhE,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,GAAG,MAAM,sBAAsB;AAK3C,OAAO,MAAMC,WAAW,gBAAGJ,UAAU,CACnC,8BAA8B,CAC/B;AAKD,OAAO,MAAMK,kBAAkB,gBAAGL,UAAU,CAG1C,qCAAqC,CAAC;AAKxC,OAAO,MAAMM,oBAAoB,gBAAGN,UAAU,CAG5C,uCAAuC,CAAC;AAK1C,OAAO,MAAMO,eAAe,gBAAGP,UAAU,CAGvC,kCAAkC,CAAC;AAQrC,OAAO,MAAMQ,oBAAoB,gBAAGR,UAAU,CAG5C,uCAAuC,CAAC;AAQ1C,OAAO,MAAMS,iBAAiB,gBAAGT,UAAU,CAGzC,oCAAoC,CAAC;AAEvC,OAAO,MAAMU,cAAc,GACzBC,CAAwE,IAKrEV,MAAM,CAACW,OAAO,CAACR,WAAW,EAAES,EAAE,IAAIf,SAAS,CAACgB,aAAa,CAACH,CAAC,CAAC,CAACE,EAAE,CAAC,CAAC;AAEtE,OAAO,MAAME,QAAQ,GAAGA,CACtBC,IAAY,EACZL,CAAwE,KAExEV,MA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[]}
@@ -0,0 +1,2 @@
1
+ export const InteractionsErrorTypeId = /*#__PURE__*/Symbol.for("dfx/Interactions/InteractionsError");
2
+ //# sourceMappingURL=error.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.mjs","names":["InteractionsErrorTypeId","Symbol","for"],"sources":["../../src/Interactions/error.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,MAAMA,uBAAuB,gBAAGC,MAAM,CAACC,GAAG,CAC/C,oCAAoC,CACrC","ignoreList":[]}
@@ -8,6 +8,8 @@ import * as Layer from "effect/Layer";
8
8
  import { handlers } from "dfx/Interactions/handlers";
9
9
  import { Interaction } from "dfx/Interactions/index";
10
10
  import * as Verify from "discord-verify";
11
+ import { RefailError } from "@effect/platform/Error";
12
+ import { InteractionsErrorTypeId } from "dfx/Interactions/error";
11
13
  export class BadWebhookSignature {
12
14
  _tag = "BadWebhookSignature";
13
15
  }
@@ -29,20 +31,16 @@ const makeConfig = ({
29
31
  export const WebhookConfig = /*#__PURE__*/GenericTag("dfx/Interactions/WebhookConfig");
30
32
  export const layer = opts => Layer.succeed(WebhookConfig, makeConfig(opts));
31
33
  export const layerConfig = config => Layer.effect(WebhookConfig, Effect.map(config, makeConfig));
32
- export class WebhookParseError {
33
- reason;
34
- _tag = "WebhookParseError";
35
- constructor(reason) {
36
- this.reason = reason;
37
- }
38
- }
34
+ export class WebhookParseError extends RefailError(InteractionsErrorTypeId, "WebhookParseError") {}
39
35
  const fromHeadersAndBody = (headers, body) => Effect.tap(WebhookConfig, ({
40
36
  algorithm,
41
37
  crypto,
42
38
  publicKey
43
39
  }) => checkSignature(publicKey, headers, body, crypto, algorithm)).pipe(Effect.flatMap(() => Effect.try({
44
40
  try: () => JSON.parse(body),
45
- catch: reason => new WebhookParseError(reason)
41
+ catch: error => new WebhookParseError({
42
+ error
43
+ })
46
44
  })));
47
45
  const run = (definitions, handleResponse) => {
48
46
  const handler = handlers(definitions, handleResponse);
@@ -1 +1 @@
1
- {"version":3,"file":"webhook.mjs","names":["Chunk","GenericTag","identity","Option","Secret","Effect","Layer","handlers","Interaction","Verify","BadWebhookSignature","_tag","checkSignature","publicKey","headers","body","crypto","algorithm","all","signature","fromNullable","timestamp","pipe","flatMap","_","promise","verify","filterOrFail","catchAllCause","fail","asUnit","makeConfig","applicationId","value","PlatformAlgorithm","WebhookConfig","layer","opts","succeed","layerConfig","config","effect","map","WebhookParseError","reason","constructor","fromHeadersAndBody","tap","try","JSON","parse","catch","run","definitions","handleResponse","handler","interaction","provideService","type","makeHandler","ix","handle","d","_i","r","error","success","makeSimpleHandler"],"sources":["../../src/Interactions/webhook.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,OAAO,KAAKC,MAAM,MAAM,eAAe;AAIvC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AAGrC,SAASC,QAAQ,QAAQ,2BAA2B;AAKpD,SAASC,WAAW,QAAQ,wBAAwB;AAEpD,OAAO,KAAKC,MAAM,MAAM,gBAAgB;AAExC,OAAM,MAAOC,mBAAmB;EACrBC,IAAI,GAAG,qBAAqB;;AAKvC,MAAMC,cAAc,GAAGA,CACrBC,SAAiB,EACjBC,OAAgB,EAChBC,IAAY,EACZC,MAAoB,EACpBC,SAAc,KAEdd,MAAM,CAACe,GAAG,CAAC;EACTC,SAAS,EAAEhB,MAAM,CAACiB,YAAY,CAACN,OAAO,CAAC,qBAAqB,CAAC,CAAC;EAC9DO,SAAS,EAAElB,MAAM,CAACiB,YAAY,CAACN,OAAO,CAAC,uBAAuB,CAAC;CAChE,CAAC,CAACQ,IAAI,CACLjB,MAAM,CAACkB,OAAO,CAACC,CAAC,IACdnB,MAAM,CAACoB,OAAO,CAAC,MACbhB,MAAM,C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CAAC;AAED;;;AAGA,OAAO,MAAME,iBAAiB,GAC5BP,EAAgC,IAW7B;EACH,MAAMC,MAAM,GAAGT,GAAG,CAChBpD,KAAK,CAAC0C,GAAG,CAACkB,EAAE,CAACP,WAAW,EAAE,CAAC,CAACS,CAAC,CAAC,KAAK,CAACA,CAAC,EAAE5D,QAAQ,CAAQ,CAAC,EACxD,CAAC6D,EAAE,EAAEC,CAAC,KAAK3D,MAAM,CAACiC,OAAO,CAAC0B,CAAC,CAAC,CAC7B;EAED,OAAO,CAAC;IAAEjD,IAAI;IAAED;EAAO,CAAsC,KAC3D+C,MAAM,CAAC/C,OAAO,EAAEC,IAAI,CAAC;AACzB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"webhook.mjs","names":["Chunk","GenericTag","identity","Option","Secret","Effect","Layer","handlers","Interaction","Verify","RefailError","InteractionsErrorTypeId","BadWebhookSignature","_tag","checkSignature","publicKey","headers","body","crypto","algorithm","all","signature","fromNullable","timestamp","pipe","flatMap","_","promise","verify","filterOrFail","catchAllCause","fail","asUnit","makeConfig","applicationId","value","PlatformAlgorithm","WebhookConfig","layer","opts","succeed","layerConfig","config","effect","map","WebhookParseError","fromHeadersAndBody","tap","try","JSON","parse","catch","error","run","definitions","handleResponse","handler","interaction","provideService","type","makeHandler","ix","handle","d","_i","r","success","makeSimpleHandler"],"sources":["../../src/Interactions/webhook.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,cAAc;AACrC,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,OAAO,KAAKC,MAAM,MAAM,eAAe;AAIvC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,KAAK,MAAM,cAAc;AAGrC,SAASC,QAAQ,QAAQ,2BAA2B;AAKpD,SAASC,WAAW,QAAQ,wBAAwB;AAEpD,OAAO,KAAKC,MAA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,EAAgC,IAQiB;EACjD,MAAMC,MAAM,GAAGT,GAAG,CAChBrD,KAAK,CAAC4C,GAAG,CAACiB,EAAE,CAACP,WAAW,EAAE,CAAC,CAACS,CAAC,CAAC,KAAK,CAACA,CAAC,EAAE7D,QAAQ,CAAQ,CAAC,EACxD,CAAC8D,EAAE,EAAEC,CAAC,KAAK5D,MAAM,CAACmC,OAAO,CAACyB,CAAC,CAAC,CAC7B;EAED,OAAO,CAAC;IACNhD,IAAI;IACJmC,KAAK;IACLpC,OAAO;IACPkD;EAAO,CAGR,KACCJ,MAAM,CAAC9C,OAAO,EAAEC,IAAI,CAAC,CAACO,IAAI,CACxBnB,MAAM,CAACoB,OAAO,CAACyC,OAAO,CAAC,EACvB7D,MAAM,CAACyB,aAAa,CAACsB,KAAK,CAAC,CAC5B;AACL,CAAC;AAED;;;AAGA,OAAO,MAAMe,iBAAiB,GAC5BN,EAAgC,IAW7B;EACH,MAAMC,MAAM,GAAGT,GAAG,CAChBrD,KAAK,CAAC4C,GAAG,CAACiB,EAAE,CAACP,WAAW,EAAE,CAAC,CAACS,CAAC,CAAC,KAAK,CAACA,CAAC,EAAE7D,QAAQ,CAAQ,CAAC,EACxD,CAAC8D,EAAE,EAAEC,CAAC,KAAK5D,MAAM,CAACmC,OAAO,CAACyB,CAAC,CAAC,CAC7B;EAED,OAAO,CAAC;IAAEhD,IAAI;IAAED;EAAO,CAAsC,KAC3D8C,MAAM,CAAC9C,OAAO,EAAEC,IAAI,CAAC;AACzB,CAAC","ignoreList":[]}
package/mjs/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as Cache from "dfx/Cache";
2
2
  import * as DiscordConfig from "dfx/DiscordConfig";
3
+ import { DiscordRESTLive } from "dfx/DiscordREST";
3
4
  import * as Flags from "dfx/Helpers/flags";
4
5
  import * as Intents from "dfx/Helpers/intents";
5
6
  import * as IxHelpers from "dfx/Helpers/interactions";
@@ -7,8 +8,11 @@ import * as Members from "dfx/Helpers/members";
7
8
  import * as Perms from "dfx/Helpers/permissions";
8
9
  import * as UI from "dfx/Helpers/ui";
9
10
  import * as Ix from "dfx/Interactions/index";
11
+ import { MemoryRateLimitStoreLive } from "dfx/RateLimit";
10
12
  import * as Discord from "dfx/types";
13
+ import * as Layer from "effect/Layer";
11
14
  export { DiscordREST, DiscordRESTLive } from "dfx/DiscordREST";
12
- export { MemoryRateLimitStoreLive, RateLimiterLive, RateLimiter, RateLimitStore } from "dfx/RateLimit";
15
+ export { MemoryRateLimitStoreLive, RateLimitStore, RateLimiter, RateLimiterLive } from "dfx/RateLimit";
13
16
  export { Cache, Discord, DiscordConfig, Flags, Intents, Ix, IxHelpers, Members, Perms, UI };
17
+ export const DiscordRESTMemoryLive = /*#__PURE__*/DiscordRESTLive.pipe( /*#__PURE__*/Layer.provide(MemoryRateLimitStoreLive));
14
18
  //# sourceMappingURL=index.mjs.map
package/mjs/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["Cache","DiscordConfig","Flags","Intents","IxHelpers","Members","Perms","UI","Ix","Discord","DiscordREST","DiscordRESTLive","MemoryRateLimitStoreLive","RateLimiterLive","RateLimiter","RateLimitStore"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,WAAW;AAClC,OAAO,KAAKC,aAAa,MAAM,mBAAmB;AAClD,OAAO,KAAKC,KAAK,MAAM,mBAAmB;AAC1C,OAAO,KAAKC,OAAO,MAAM,qBAAqB;AAC9C,OAAO,KAAKC,SAAS,MAAM,0BAA0B;AACrD,OAAO,KAAKC,OAAO,MAAM,qBAAqB;AAC9C,OAAO,KAAKC,KAAK,MAAM,yBAAyB;AAChD,OAAO,KAAKC,EAAE,MAAM,gBAAgB;AACpC,OAAO,KAAKC,EAAE,MAAM,wBAAwB;AAC5C,OAAO,KAAKC,OAAO,MAAM,WAAW;AAEpC,SAASC,WAAW,EAAEC,eAAe,QAAQ,iBAAiB;AAE9D,SAEEC,wBAAwB,EACxBC,eAAe,EACfC,WAAW,EACXC,cAAc,QACT,eAAe;AAEtB,SACEf,KAAK,EACLS,OAAO,EACPR,aAAa,EACbC,KAAK,EACLC,OAAO,EACPK,EAAE,EACFJ,SAAS,EACTC,OAAO,EACPC,KAAK,EACLC,EAAE","ignoreList":[]}
1
+ {"version":3,"file":"index.mjs","names":["Cache","DiscordConfig","DiscordRESTLive","Flags","Intents","IxHelpers","Members","Perms","UI","Ix","MemoryRateLimitStoreLive","Discord","Layer","DiscordREST","RateLimitStore","RateLimiter","RateLimiterLive","DiscordRESTMemoryLive","pipe","provide"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,WAAW;AAClC,OAAO,KAAKC,aAAa,MAAM,mBAAmB;AAClD,SAASC,eAAe,QAAQ,iBAAiB;AACjD,OAAO,KAAKC,KAAK,MAAM,mBAAmB;AAC1C,OAAO,KAAKC,OAAO,MAAM,qBAAqB;AAC9C,OAAO,KAAKC,SAAS,MAAM,0BAA0B;AACrD,OAAO,KAAKC,OAAO,MAAM,qBAAqB;AAC9C,OAAO,KAAKC,KAAK,MAAM,yBAAyB;AAChD,OAAO,KAAKC,EAAE,MAAM,gBAAgB;AACpC,OAAO,KAAKC,EAAE,MAAM,wBAAwB;AAC5C,SAASC,wBAAwB,QAAQ,eAAe;AACxD,OAAO,KAAKC,OAAO,MAAM,WAAW;AACpC,OAAO,KAAKC,KAAK,MAAM,cAAc;AAErC,SAASC,WAAW,EAAEX,eAAe,QAAQ,iBAAiB;AAE9D,SAEEQ,wBAAwB,EACxBI,cAAc,EACdC,WAAW,EACXC,eAAe,QACV,eAAe;AAEtB,SACEhB,KAAK,EACLW,OAAO,EACPV,aAAa,EACbE,KAAK,EACLC,OAAO,EACPK,EAAE,EACFJ,SAAS,EACTC,OAAO,EACPC,KAAK,EACLC,EAAE;AAGJ,OAAO,MAAMS,qBAAqB,gBAAGf,eAAe,CAACgB,IAAI,eACvDN,KAAK,CAACO,OAAO,CAACT,wBAAwB,CAAC,CACxC","ignoreList":[]}
package/mjs/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const LIB_VERSION = "0.90.2";
1
+ export const LIB_VERSION = "0.91.0";
2
2
  //# sourceMappingURL=version.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dfx",
3
- "version": "0.90.2",
3
+ "version": "0.91.0",
4
4
  "description": "Effect-TS discord library",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -44,6 +44,6 @@
44
44
  "utf-8-validate": "^6.0.3",
45
45
  "zlib-sync": "^0.1.9"
46
46
  },
47
- "gitHead": "cc6d6a52e49ceadabeef9cb17065dd55fe842d12",
47
+ "gitHead": "2707397ecfb7f30c500cd27abbb45f6d3cac4057",
48
48
  "main": "./index.js"
49
49
  }
@@ -238,7 +238,10 @@ export const roles = <RM, EM, E>(
238
238
  return yield* _(
239
239
  makeWithParent({
240
240
  driver,
241
- id: _ => Effect.fail(new CacheMissError("RolesCache/id", _.id)),
241
+ id: _ =>
242
+ Effect.fail(
243
+ new CacheMissError({ cacheName: "RolesCache/id", id: _.id }),
244
+ ),
242
245
  ops: opsWithParent({
243
246
  id: (a: Discord.Role) => a.id,
244
247
  fromParent: Stream.map(gateway.fromDispatch("GUILD_CREATE"), g => [
@@ -262,7 +265,8 @@ export const roles = <RM, EM, E>(
262
265
  g => g.id,
263
266
  ),
264
267
  }),
265
- onMiss: (_, id) => Effect.fail(new CacheMissError("RolesCache", id)),
268
+ onMiss: (_, id) =>
269
+ Effect.fail(new CacheMissError({ cacheName: "RolesCache", id })),
266
270
  onParentMiss: guildId =>
267
271
  rest
268
272
  .getGuildRoles(guildId)
package/src/Cache.ts CHANGED
@@ -1,9 +1,10 @@
1
+ import { TypeIdError } from "@effect/platform/Error"
2
+ import type { CacheDriver, ParentCacheDriver } from "dfx/Cache/driver"
3
+ import * as Effect from "effect/Effect"
1
4
  import * as Option from "effect/Option"
2
5
  import * as Schedule from "effect/Schedule"
3
6
  import type * as Scope from "effect/Scope"
4
- import * as Effect from "effect/Effect"
5
7
  import * as Stream from "effect/Stream"
6
- import type { CacheDriver, ParentCacheDriver } from "dfx/Cache/driver"
7
8
 
8
9
  export * from "dfx/Cache/driver"
9
10
  export {
@@ -253,10 +254,16 @@ export const make = <EOps, EDriver, EMiss, A>({
253
254
  }),
254
255
  )
255
256
 
256
- export class CacheMissError {
257
- readonly _tag = "CacheMissError"
258
- constructor(
259
- readonly cacheName: string,
260
- readonly id: string,
261
- ) {}
257
+ export const CacheErrorTypeId = Symbol.for("dfx/Cache/CacheError")
258
+
259
+ export class CacheMissError extends TypeIdError(
260
+ CacheErrorTypeId,
261
+ "CacheMissError",
262
+ )<{
263
+ cacheName: string
264
+ id: string
265
+ }> {
266
+ get message() {
267
+ return `Cache miss for "${this.cacheName}" with id: ${this.id}`
268
+ }
262
269
  }
@@ -21,13 +21,25 @@ import * as Discord from "dfx/types"
21
21
  import { LIB_VERSION } from "dfx/version"
22
22
  import type { Scope } from "effect/Scope"
23
23
  import * as Effectable from "effect/Effectable"
24
+ import { TypeIdError } from "@effect/platform/Error"
24
25
 
25
- export class DiscordRESTError {
26
- readonly _tag = "DiscordRESTError"
27
- constructor(
28
- readonly error: Http.error.HttpClientError,
29
- readonly body?: unknown,
30
- ) {}
26
+ export const DiscordRESTErrorTypeId = Symbol.for(
27
+ "dfx/DiscordREST/DiscordRESTError",
28
+ )
29
+
30
+ export class DiscordRESTError extends TypeIdError(
31
+ DiscordRESTErrorTypeId,
32
+ "DiscordRESTError",
33
+ )<{
34
+ error: Http.error.HttpClientError
35
+ body?: unknown
36
+ }> {
37
+ get message() {
38
+ const httpMessage = this.error.message
39
+ return this.body !== undefined
40
+ ? `${httpMessage}: ${JSON.stringify(this.body)}`
41
+ : httpMessage
42
+ }
31
43
  }
32
44
 
33
45
  const make = Effect.gen(function* (_) {
@@ -146,12 +158,12 @@ const make = Effect.gen(function* (_) {
146
158
  Http.client.catchAll(error =>
147
159
  error.reason === "StatusCode"
148
160
  ? error.response.json.pipe(
149
- Effect.mapError(_ => new DiscordRESTError(_)),
161
+ Effect.mapError(_ => new DiscordRESTError({ error })),
150
162
  Effect.flatMap(body =>
151
- Effect.fail(new DiscordRESTError(error, body)),
163
+ Effect.fail(new DiscordRESTError({ error, body })),
152
164
  ),
153
165
  )
154
- : Effect.fail(new DiscordRESTError(error)),
166
+ : Effect.fail(new DiscordRESTError({ error })),
155
167
  ),
156
168
  )
157
169
 
@@ -298,5 +310,4 @@ export const DiscordREST = GenericTag<DiscordREST, DiscordRESTService>(
298
310
  )
299
311
  export const DiscordRESTLive = Layer.effect(DiscordREST, make).pipe(
300
312
  Layer.provide(RateLimiterLive),
301
- Layer.provide(Http.client.layer),
302
313
  )
@@ -1,10 +1,13 @@
1
+ import { TypeIdError } from "@effect/platform/Error"
2
+ import * as IxHelpers from "dfx/Helpers/interactions"
3
+ import { InteractionsErrorTypeId } from "dfx/Interactions/error"
4
+ import type * as Discord from "dfx/types"
5
+ import type { NoSuchElementException } from "effect/Cause"
1
6
  import { GenericTag } from "effect/Context"
7
+ import * as Effect from "effect/Effect"
2
8
  import type * as HashMap from "effect/HashMap"
3
9
  import * as Option from "effect/Option"
4
10
  import * as Arr from "effect/ReadonlyArray"
5
- import * as Effect from "effect/Effect"
6
- import * as IxHelpers from "dfx/Helpers/interactions"
7
- import type * as Discord from "dfx/types"
8
11
 
9
12
  export interface DiscordInteraction {
10
13
  readonly _: unique symbol
@@ -59,44 +62,31 @@ export const SubCommandContext = GenericTag<
59
62
  SubCommandContext
60
63
  >("dfx/Interactions/SubCommandContext")
61
64
 
62
- export class ResolvedDataNotFound {
63
- readonly _tag = "ResolvedDataNotFound"
64
- constructor(
65
- readonly data: Discord.Interaction,
66
- readonly name?: string,
67
- ) {}
68
- }
69
-
70
65
  export const resolvedValues = <A>(
71
66
  f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => A | undefined,
72
- ): Effect.Effect<ReadonlyArray<A>, ResolvedDataNotFound, DiscordInteraction> =>
73
- Effect.flatMap(Interaction, ix =>
74
- Effect.mapError(
75
- IxHelpers.resolveValues(f)(ix),
76
- () => new ResolvedDataNotFound(ix),
77
- ),
78
- )
67
+ ): Effect.Effect<
68
+ ReadonlyArray<A>,
69
+ NoSuchElementException,
70
+ DiscordInteraction
71
+ > => Effect.flatMap(Interaction, ix => IxHelpers.resolveValues(f)(ix))
79
72
 
80
73
  export const resolved = <A>(
81
74
  name: string,
82
75
  f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => A | undefined,
83
- ): Effect.Effect<A, ResolvedDataNotFound, DiscordInteraction> =>
84
- Effect.flatMap(Interaction, ix =>
85
- Effect.mapError(
86
- IxHelpers.resolveOptionValue(name, f)(ix),
87
- () => new ResolvedDataNotFound(ix, name),
88
- ),
89
- )
76
+ ): Effect.Effect<A, NoSuchElementException, DiscordInteraction> =>
77
+ Effect.flatMap(Interaction, ix => IxHelpers.resolveOptionValue(name, f)(ix))
90
78
 
91
79
  export const focusedOptionValue = Effect.map(
92
80
  FocusedOptionContext,
93
81
  _ => _.focusedOption.value ?? "",
94
82
  )
95
83
 
96
- export class SubCommandNotFound {
97
- readonly _tag = "SubCommandNotFound"
98
- constructor(readonly data: Discord.ApplicationCommandDatum) {}
99
- }
84
+ export class SubCommandNotFound extends TypeIdError(
85
+ InteractionsErrorTypeId,
86
+ "SubCommandNotFound",
87
+ )<{
88
+ data: Discord.ApplicationCommandDatum
89
+ }> {}
100
90
 
101
91
  export const handleSubCommands = <
102
92
  NER extends Record<
@@ -128,7 +118,7 @@ export const handleSubCommands = <
128
118
  Effect.flatMap(data =>
129
119
  Effect.mapError(
130
120
  Arr.findFirst(IxHelpers.allSubCommands(data), _ => !!commands[_.name]),
131
- () => new SubCommandNotFound(data),
121
+ () => new SubCommandNotFound({ data }),
132
122
  ),
133
123
  ),
134
124
  Effect.flatMap(command =>
@@ -188,18 +178,7 @@ export const modalValues = Effect.map(ModalSubmitData, IxHelpers.componentsMap)
188
178
  export const modalValueOption = (name: string) =>
189
179
  Effect.map(ModalSubmitData, IxHelpers.componentValue(name))
190
180
 
191
- export class ModalValueNotFound {
192
- readonly _tag = "ModalValueNotFound"
193
- constructor(
194
- readonly data: Discord.ModalSubmitDatum,
195
- readonly name: string,
196
- ) {}
197
- }
198
-
199
- export const modalValue = (name: string) =>
200
- Effect.flatMap(ModalSubmitData, data =>
201
- Effect.mapError(
202
- IxHelpers.componentValue(name)(data),
203
- () => new ModalValueNotFound(data, name),
204
- ),
205
- )
181
+ export const modalValue = (
182
+ name: string,
183
+ ): Effect.Effect<string, NoSuchElementException, DiscordModalSubmit> =>
184
+ Effect.flatMap(ModalSubmitData, data => IxHelpers.componentValue(name)(data))
@@ -6,10 +6,10 @@ import type {
6
6
  DiscordInteraction,
7
7
  DiscordMessageComponent,
8
8
  DiscordModalSubmit,
9
- ResolvedDataNotFound,
10
9
  SubCommandContext,
11
10
  } from "dfx/Interactions/context"
12
11
  import type * as Discord from "dfx/types"
12
+ import type { NoSuchElementException } from "effect/Cause"
13
13
 
14
14
  export type InteractionDefinition<R, E> =
15
15
  | GlobalApplicationCommand<R, E>
@@ -143,7 +143,7 @@ export interface CommandHelper<A> {
143
143
  resolve: <T>(
144
144
  name: AllResolvables<A>["name"],
145
145
  f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => T | undefined,
146
- ) => Effect.Effect<T, ResolvedDataNotFound, DiscordInteraction>
146
+ ) => Effect.Effect<T, NoSuchElementException, DiscordInteraction>
147
147
 
148
148
  option: (
149
149
  name: AllCommandOptions<A>["name"],
@@ -0,0 +1,3 @@
1
+ export const InteractionsErrorTypeId = Symbol.for(
2
+ "dfx/Interactions/InteractionsError",
3
+ )
@@ -18,6 +18,8 @@ import type {
18
18
  import { Interaction } from "dfx/Interactions/index"
19
19
  import type * as Discord from "dfx/types"
20
20
  import * as Verify from "discord-verify"
21
+ import { RefailError } from "@effect/platform/Error"
22
+ import { InteractionsErrorTypeId } from "dfx/Interactions/error"
21
23
 
22
24
  export class BadWebhookSignature {
23
25
  readonly _tag = "BadWebhookSignature"
@@ -88,10 +90,10 @@ export const layerConfig: (
88
90
  config: Config.Config<MakeConfigOpts>,
89
91
  ) => Layer.effect(WebhookConfig, Effect.map(config, makeConfig))
90
92
 
91
- export class WebhookParseError {
92
- readonly _tag = "WebhookParseError"
93
- constructor(readonly reason: unknown) {}
94
- }
93
+ export class WebhookParseError extends RefailError(
94
+ InteractionsErrorTypeId,
95
+ "WebhookParseError",
96
+ )<{}> {}
95
97
 
96
98
  const fromHeadersAndBody = (headers: Headers, body: string) =>
97
99
  Effect.tap(WebhookConfig, ({ algorithm, crypto, publicKey }) =>
@@ -100,7 +102,7 @@ const fromHeadersAndBody = (headers: Headers, body: string) =>
100
102
  Effect.flatMap(() =>
101
103
  Effect.try({
102
104
  try: () => JSON.parse(body) as Discord.Interaction,
103
- catch: reason => new WebhookParseError(reason),
105
+ catch: error => new WebhookParseError({ error }),
104
106
  }),
105
107
  ),
106
108
  )
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as Cache from "dfx/Cache"
2
2
  import * as DiscordConfig from "dfx/DiscordConfig"
3
+ import { DiscordRESTLive } from "dfx/DiscordREST"
3
4
  import * as Flags from "dfx/Helpers/flags"
4
5
  import * as Intents from "dfx/Helpers/intents"
5
6
  import * as IxHelpers from "dfx/Helpers/interactions"
@@ -7,16 +8,18 @@ import * as Members from "dfx/Helpers/members"
7
8
  import * as Perms from "dfx/Helpers/permissions"
8
9
  import * as UI from "dfx/Helpers/ui"
9
10
  import * as Ix from "dfx/Interactions/index"
11
+ import { MemoryRateLimitStoreLive } from "dfx/RateLimit"
10
12
  import * as Discord from "dfx/types"
13
+ import * as Layer from "effect/Layer"
11
14
 
12
15
  export { DiscordREST, DiscordRESTLive } from "dfx/DiscordREST"
13
16
 
14
17
  export {
15
18
  BucketDetails,
16
19
  MemoryRateLimitStoreLive,
17
- RateLimiterLive,
18
- RateLimiter,
19
20
  RateLimitStore,
21
+ RateLimiter,
22
+ RateLimiterLive,
20
23
  } from "dfx/RateLimit"
21
24
 
22
25
  export {
@@ -31,3 +34,7 @@ export {
31
34
  Perms,
32
35
  UI,
33
36
  }
37
+
38
+ export const DiscordRESTMemoryLive = DiscordRESTLive.pipe(
39
+ Layer.provide(MemoryRateLimitStoreLive),
40
+ )
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "0.90.2";
1
+ export const LIB_VERSION = "0.91.0";
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const LIB_VERSION = "0.90.2";
1
+ export declare const LIB_VERSION = "0.91.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.LIB_VERSION = void 0;
7
- const LIB_VERSION = exports.LIB_VERSION = "0.90.2";
7
+ const LIB_VERSION = exports.LIB_VERSION = "0.91.0";
8
8
  //# sourceMappingURL=version.js.map
package/webhooks.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import * as Layer from "effect/Layer";
2
2
  export { BadWebhookSignature, WebhookConfig, WebhookParseError, makeHandler, makeSimpleHandler, layer as webhookLayer, layerConfig as webhookLayerConfig, } from "dfx/Interactions/webhook";
3
- export declare const DiscordLive: Layer.Layer<import("dfx/RateLimit").RateLimiter | import("dfx/DiscordREST").DiscordREST, never, import("./DiscordConfig").DiscordConfig>;
3
+ export declare const DiscordLive: Layer.Layer<import("dfx/RateLimit").RateLimiter | import("dfx/DiscordREST").DiscordREST, never, import("./DiscordConfig").DiscordConfig | import("@effect/platform/Http/Client").Client.Default>;
4
4
  //# sourceMappingURL=webhooks.d.ts.map
package/webhooks.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["./src/webhooks.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,KAAK,IAAI,YAAY,EACrB,WAAW,IAAI,kBAAkB,GAClC,MAAM,0BAA0B,CAAA;AAEjC,eAAO,MAAM,WAAW,0IAGuB,CAAA"}
1
+ {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["./src/webhooks.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,KAAK,IAAI,YAAY,EACrB,WAAW,IAAI,kBAAkB,GAClC,MAAM,0BAA0B,CAAA;AAEjC,eAAO,MAAM,WAAW,kMAGuB,CAAA"}