dfx 0.58.0 → 0.58.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 (106) hide show
  1. package/Cache/driver.d.ts +2 -2
  2. package/Cache/driver.d.ts.map +1 -1
  3. package/DiscordConfig.d.ts +3 -3
  4. package/DiscordConfig.d.ts.map +1 -1
  5. package/DiscordConfig.js +2 -2
  6. package/DiscordConfig.js.map +1 -1
  7. package/DiscordGateway/DiscordWS.d.ts +3 -3
  8. package/DiscordGateway/DiscordWS.d.ts.map +1 -1
  9. package/DiscordGateway/DiscordWS.js +3 -3
  10. package/DiscordGateway/DiscordWS.js.map +1 -1
  11. package/DiscordGateway/Shard/invalidSession.d.ts +2 -2
  12. package/DiscordGateway/Shard/invalidSession.d.ts.map +1 -1
  13. package/DiscordGateway/Shard/utils.d.ts +1 -1
  14. package/DiscordGateway/Shard/utils.d.ts.map +1 -1
  15. package/DiscordGateway/WS.d.ts +0 -1
  16. package/DiscordGateway/WS.d.ts.map +1 -1
  17. package/DiscordGateway.d.ts +4 -4
  18. package/DiscordGateway.d.ts.map +1 -1
  19. package/Helpers/flags.d.ts +2 -2
  20. package/Helpers/flags.d.ts.map +1 -1
  21. package/Helpers/flags.js.map +1 -1
  22. package/Helpers/interactions.d.ts +4 -4
  23. package/Helpers/interactions.d.ts.map +1 -1
  24. package/Helpers/interactions.js +2 -2
  25. package/Helpers/interactions.js.map +1 -1
  26. package/Helpers/members.d.ts +2 -2
  27. package/Helpers/members.d.ts.map +1 -1
  28. package/Helpers/members.js.map +1 -1
  29. package/Helpers/permissions.d.ts +4 -4
  30. package/Helpers/permissions.d.ts.map +1 -1
  31. package/Helpers/permissions.js.map +1 -1
  32. package/Helpers/ui.d.ts +5 -4
  33. package/Helpers/ui.d.ts.map +1 -1
  34. package/Helpers/ui.js.map +1 -1
  35. package/Interactions/context.d.ts +5 -6
  36. package/Interactions/context.d.ts.map +1 -1
  37. package/Interactions/context.js.map +1 -1
  38. package/Interactions/definitions.d.ts +8 -8
  39. package/Interactions/definitions.d.ts.map +1 -1
  40. package/Interactions/handlers.d.ts +2 -2
  41. package/Interactions/handlers.d.ts.map +1 -1
  42. package/Interactions/handlers.js +1 -1
  43. package/Interactions/handlers.js.map +1 -1
  44. package/Interactions/utils.d.ts +2 -2
  45. package/Interactions/utils.d.ts.map +1 -1
  46. package/Interactions/webhook.d.ts +10 -10
  47. package/Interactions/webhook.d.ts.map +1 -1
  48. package/Interactions/webhook.js +9 -9
  49. package/Interactions/webhook.js.map +1 -1
  50. package/Log.d.ts +2 -2
  51. package/Log.d.ts.map +1 -1
  52. package/Log.js.map +1 -1
  53. package/RateLimit/memory.d.ts +1 -1
  54. package/RateLimit/memory.d.ts.map +1 -1
  55. package/RateLimit/utils.d.ts +1 -1
  56. package/RateLimit/utils.d.ts.map +1 -1
  57. package/RateLimit/utils.js.map +1 -1
  58. package/RateLimit.d.ts +1 -1
  59. package/RateLimit.d.ts.map +1 -1
  60. package/mjs/DiscordConfig.mjs +2 -2
  61. package/mjs/DiscordConfig.mjs.map +1 -1
  62. package/mjs/DiscordGateway/DiscordWS.mjs +3 -3
  63. package/mjs/DiscordGateway/DiscordWS.mjs.map +1 -1
  64. package/mjs/Helpers/flags.mjs.map +1 -1
  65. package/mjs/Helpers/interactions.mjs +2 -2
  66. package/mjs/Helpers/interactions.mjs.map +1 -1
  67. package/mjs/Helpers/members.mjs.map +1 -1
  68. package/mjs/Helpers/permissions.mjs.map +1 -1
  69. package/mjs/Helpers/ui.mjs.map +1 -1
  70. package/mjs/Interactions/context.mjs.map +1 -1
  71. package/mjs/Interactions/handlers.mjs +1 -1
  72. package/mjs/Interactions/handlers.mjs.map +1 -1
  73. package/mjs/Interactions/webhook.mjs +9 -9
  74. package/mjs/Interactions/webhook.mjs.map +1 -1
  75. package/mjs/Log.mjs.map +1 -1
  76. package/mjs/RateLimit/utils.mjs.map +1 -1
  77. package/mjs/types.mjs.map +1 -1
  78. package/mjs/version.mjs +1 -1
  79. package/package.json +2 -2
  80. package/src/Cache/driver.ts +2 -2
  81. package/src/DiscordConfig.ts +4 -4
  82. package/src/DiscordGateway/DiscordWS.ts +4 -4
  83. package/src/DiscordGateway/Shard/invalidSession.ts +2 -2
  84. package/src/DiscordGateway/Shard/utils.ts +1 -1
  85. package/src/DiscordGateway.ts +4 -4
  86. package/src/Helpers/flags.ts +6 -6
  87. package/src/Helpers/interactions.ts +10 -10
  88. package/src/Helpers/members.ts +6 -5
  89. package/src/Helpers/permissions.ts +5 -5
  90. package/src/Helpers/ui.ts +5 -7
  91. package/src/Interactions/context.ts +4 -5
  92. package/src/Interactions/definitions.ts +5 -5
  93. package/src/Interactions/handlers.ts +3 -3
  94. package/src/Interactions/utils.ts +2 -2
  95. package/src/Interactions/webhook.ts +19 -17
  96. package/src/Log.ts +2 -2
  97. package/src/RateLimit/memory.ts +1 -1
  98. package/src/RateLimit/utils.ts +2 -1
  99. package/src/RateLimit.ts +1 -1
  100. package/src/types.ts +218 -202
  101. package/src/version.ts +1 -1
  102. package/types.d.ts +202 -202
  103. package/types.d.ts.map +1 -1
  104. package/types.js.map +1 -1
  105. package/version.d.ts +1 -1
  106. package/version.js +1 -1
@@ -27,7 +27,7 @@ export const fromList = Flags.fromListBigint(Discord.PermissionFlag)
27
27
  /**
28
28
  * Reduce a list of roles to a bitfield of all the permissions added together.
29
29
  */
30
- export const forRoles = (roles: Discord.Role[]) =>
30
+ export const forRoles = (roles: Array<Discord.Role>) =>
31
31
  roles.reduce(
32
32
  (permissions, role) => permissions | BigInt(role.permissions),
33
33
  BigInt(0),
@@ -37,7 +37,7 @@ export const forRoles = (roles: Discord.Role[]) =>
37
37
  * From a list of roles, calculate the permissions bitfield for the member.
38
38
  */
39
39
  export const forMember =
40
- (roles: Discord.Role[]) => (member: Discord.GuildMember) =>
40
+ (roles: Array<Discord.Role>) => (member: Discord.GuildMember) =>
41
41
  pipe(Members.roles(roles)(member), forRoles)
42
42
 
43
43
  const overwriteIsForMember =
@@ -66,12 +66,12 @@ const overwriteIsForRole =
66
66
  * the guild member or role for that channel.
67
67
  */
68
68
  export const forChannel =
69
- (roles: Discord.Role[]) =>
69
+ (roles: Array<Discord.Role>) =>
70
70
  ({ guild_id, permission_overwrites: overwrites = [] }: Discord.Channel) =>
71
71
  (memberOrRole: Discord.GuildMember | Discord.Role) => {
72
72
  const hasAdmin = has(Discord.PermissionFlag.ADMINISTRATOR)
73
73
  let basePermissions: bigint
74
- let filteredOverwrites: Discord.Overwrite[]
74
+ let filteredOverwrites: Array<Discord.Overwrite>
75
75
 
76
76
  if (Members.is(memberOrRole)) {
77
77
  if (memberOrRole.permissions) return BigInt(memberOrRole.permissions)
@@ -102,7 +102,7 @@ export const forChannel =
102
102
  * Apply permission overwrites to a bitfield.
103
103
  */
104
104
  export const applyOverwrites =
105
- (permissions: bigint) => (overwrites: Discord.Overwrite[]) =>
105
+ (permissions: bigint) => (overwrites: Array<Discord.Overwrite>) =>
106
106
  overwrites.reduce(
107
107
  (permissions, overwrite) =>
108
108
  (permissions & ~BigInt(overwrite.deny)) | BigInt(overwrite.allow),
package/src/Helpers/ui.ts CHANGED
@@ -1,21 +1,19 @@
1
- import {
1
+ import type {
2
2
  ActionRow,
3
3
  Button,
4
- ButtonStyle,
5
4
  Component,
6
- ComponentType,
7
5
  SelectMenu,
8
6
  SelectOption,
9
7
  TextInput,
10
- TextInputStyle,
11
8
  } from "dfx/types"
9
+ import { ButtonStyle, ComponentType, TextInputStyle } from "dfx/types"
12
10
 
13
11
  export type UIComponent = Exclude<Component, ActionRow>
14
12
 
15
13
  /**
16
14
  * Helper to create an Action Row grid.
17
15
  */
18
- export const grid = (items: UIComponent[][]): ActionRow[] =>
16
+ export const grid = (items: Array<Array<UIComponent>>): Array<ActionRow> =>
19
17
  items.map(
20
18
  (components): ActionRow => ({
21
19
  type: ComponentType.ACTION_ROW,
@@ -26,7 +24,7 @@ export const grid = (items: UIComponent[][]): ActionRow[] =>
26
24
  /**
27
25
  * Helper to create a single column of components
28
26
  */
29
- export const singleColumn = (items: UIComponent[]): ActionRow[] =>
27
+ export const singleColumn = (items: Array<UIComponent>): Array<ActionRow> =>
30
28
  items.map(c => ({
31
29
  type: ComponentType.ACTION_ROW,
32
30
  components: [c],
@@ -44,7 +42,7 @@ export const button = (button: Partial<Button>): Button => ({
44
42
  type BasicSelect = Omit<SelectMenu, "type" | "channel_types" | "options">
45
43
 
46
44
  type StringSelect = BasicSelect & {
47
- options: SelectOption[]
45
+ options: Array<SelectOption>
48
46
  }
49
47
 
50
48
  type ChannelSelect = Omit<SelectMenu, "type" | "options">
@@ -1,11 +1,10 @@
1
1
  import { Tag } from "@effect/data/Context"
2
- import * as HashMap from "@effect/data/HashMap"
2
+ import type * as HashMap from "@effect/data/HashMap"
3
3
  import * as Option from "@effect/data/Option"
4
4
  import * as Arr from "@effect/data/ReadonlyArray"
5
5
  import * as Effect from "@effect/io/Effect"
6
6
  import * as IxHelpers from "dfx/Helpers/interactions"
7
- import * as Discord from "dfx/types"
8
- import { ModalSubmitDatum } from "dfx/types"
7
+ import type * as Discord from "dfx/types"
9
8
 
10
9
  export const Interaction = Tag<Discord.Interaction>()
11
10
  export const ApplicationCommand = Tag<Discord.ApplicationCommandDatum>()
@@ -29,7 +28,7 @@ export class ResolvedDataNotFound {
29
28
 
30
29
  export const resolvedValues = <A>(
31
30
  f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => A | undefined,
32
- ): Effect.Effect<Discord.Interaction, ResolvedDataNotFound, readonly A[]> =>
31
+ ): Effect.Effect<Discord.Interaction, ResolvedDataNotFound, ReadonlyArray<A>> =>
33
32
  Effect.flatMap(Interaction, ix =>
34
33
  Effect.mapError(
35
34
  IxHelpers.resolveValues(f)(ix),
@@ -150,7 +149,7 @@ export const modalValueOption = (name: string) =>
150
149
 
151
150
  export class ModalValueNotFound {
152
151
  readonly _tag = "ModalValueNotFound"
153
- constructor(readonly data: ModalSubmitDatum, readonly name: string) {}
152
+ constructor(readonly data: Discord.ModalSubmitDatum, readonly name: string) {}
154
153
  }
155
154
 
156
155
  export const modalValue = (name: string) =>
@@ -1,11 +1,11 @@
1
- import * as Option from "@effect/data/Option"
2
- import * as Effect from "@effect/io/Effect"
3
- import {
1
+ import type * as Option from "@effect/data/Option"
2
+ import type * as Effect from "@effect/io/Effect"
3
+ import type {
4
4
  FocusedOptionContext,
5
5
  ResolvedDataNotFound,
6
6
  SubCommandContext,
7
7
  } from "dfx/Interactions/context"
8
- import * as Discord from "dfx/types"
8
+ import type * as Discord from "dfx/types"
9
9
 
10
10
  export type InteractionDefinition<R, E> =
11
11
  | GlobalApplicationCommand<R, E>
@@ -119,7 +119,7 @@ export const autocomplete = <R1, R2, E1, E2>(
119
119
  >(pred as any, handle as any)
120
120
 
121
121
  // ==== Command handler helpers
122
- type DeepReadonly<T> = T extends (infer R)[]
122
+ type DeepReadonly<T> = T extends Array<infer R>
123
123
  ? ReadonlyArray<DeepReadonly<R>>
124
124
  : T extends Function
125
125
  ? T
@@ -1,9 +1,9 @@
1
- import * as Chunk from "@effect/data/Chunk"
1
+ import type * as Chunk from "@effect/data/Chunk"
2
2
  import * as Option from "@effect/data/Option"
3
3
  import * as Effect from "@effect/io/Effect"
4
4
  import * as IxHelpers from "dfx/Helpers/interactions"
5
5
  import * as Ctx from "dfx/Interactions/context"
6
- import * as D from "dfx/Interactions/definitions"
6
+ import type * as D from "dfx/Interactions/definitions"
7
7
  import { flattenDefinitions, splitDefinitions } from "dfx/Interactions/utils"
8
8
  import * as Discord from "dfx/types"
9
9
 
@@ -35,7 +35,7 @@ export const handlers = <R, E, TE, A, B>(
35
35
  > => {
36
36
  const flattened = flattenDefinitions(definitions, handleResponse)
37
37
 
38
- const { Commands, Autocomplete, MessageComponent, ModalSubmit } =
38
+ const { Autocomplete, Commands, MessageComponent, ModalSubmit } =
39
39
  splitDefinitions(flattened)
40
40
 
41
41
  return {
@@ -1,8 +1,8 @@
1
1
  import * as Chunk from "@effect/data/Chunk"
2
2
  import * as Effect from "@effect/io/Effect"
3
3
  import * as Ctx from "dfx/Interactions/context"
4
- import * as D from "dfx/Interactions/definitions"
5
- import * as Discord from "dfx/types"
4
+ import type * as D from "dfx/Interactions/definitions"
5
+ import type * as Discord from "dfx/types"
6
6
 
7
7
  export type DefinitionFlattened<R, E, TE, A> = D.InteractionDefinition<
8
8
  R,
@@ -2,23 +2,25 @@ import * as Chunk from "@effect/data/Chunk"
2
2
  import { Tag } from "@effect/data/Context"
3
3
  import { identity } from "@effect/data/Function"
4
4
  import * as Option from "@effect/data/Option"
5
- import * as Cause from "@effect/io/Cause"
6
- import * as Config from "@effect/io/Config"
7
- import * as ConfigError from "@effect/io/Config/Error"
5
+ import type * as Cause from "@effect/io/Cause"
6
+ import type * as Config from "@effect/io/Config"
7
+ import type * as ConfigError from "@effect/io/Config/Error"
8
8
  import * as ConfigSecret from "@effect/io/Config/Secret"
9
9
  import * as Effect from "@effect/io/Effect"
10
10
  import * as Layer from "@effect/io/Layer"
11
- import * as D from "dfx/Interactions/definitions"
12
- import { DefinitionNotFound, handlers } from "dfx/Interactions/handlers"
13
- import { Interaction, InteractionBuilder } from "dfx/Interactions/index"
14
- import * as Discord from "dfx/types"
11
+ import type * as D from "dfx/Interactions/definitions"
12
+ import type { DefinitionNotFound } from "dfx/Interactions/handlers"
13
+ import { handlers } from "dfx/Interactions/handlers"
14
+ import type { InteractionBuilder } from "dfx/Interactions/index"
15
+ import { Interaction } from "dfx/Interactions/index"
16
+ import type * as Discord from "dfx/types"
15
17
  import * as Verify from "discord-verify"
16
18
 
17
19
  export class BadWebhookSignature {
18
20
  readonly _tag = "BadWebhookSignature"
19
21
  }
20
22
 
21
- export type Headers = Record<string, string | string[] | undefined>
23
+ export type Headers = Record<string, string | Array<string> | undefined>
22
24
 
23
25
  const checkSignature = (
24
26
  publicKey: string,
@@ -55,10 +57,10 @@ export interface MakeConfigOpts {
55
57
  readonly algorithm: keyof typeof Verify.PlatformAlgorithm
56
58
  }
57
59
  const makeConfig = ({
60
+ algorithm,
58
61
  applicationId,
59
- publicKey,
60
62
  crypto,
61
- algorithm,
63
+ publicKey,
62
64
  }: MakeConfigOpts) => ({
63
65
  applicationId,
64
66
  publicKey: ConfigSecret.value(publicKey),
@@ -84,7 +86,7 @@ export class WebhookParseError {
84
86
  }
85
87
 
86
88
  const fromHeadersAndBody = (headers: Headers, body: string) =>
87
- Effect.tap(WebhookConfig, ({ publicKey, crypto, algorithm }) =>
89
+ Effect.tap(WebhookConfig, ({ algorithm, crypto, publicKey }) =>
88
90
  checkSignature(publicKey, headers, body, crypto, algorithm),
89
91
  ).pipe(
90
92
  Effect.flatMap(() =>
@@ -133,10 +135,10 @@ export interface HandleWebhookOpts<E> {
133
135
  export const makeHandler = <R, E, TE>(
134
136
  ix: InteractionBuilder<R, E, TE>,
135
137
  ): (({
136
- headers,
137
138
  body,
138
- success,
139
139
  error,
140
+ headers,
141
+ success,
140
142
  }: HandleWebhookOpts<
141
143
  E | WebhookParseError | BadWebhookSignature | DefinitionNotFound
142
144
  >) => Effect.Effect<WebhookConfig, never, void>) => {
@@ -146,10 +148,10 @@ export const makeHandler = <R, E, TE>(
146
148
  )
147
149
 
148
150
  return ({
149
- headers,
150
151
  body,
151
- success,
152
152
  error,
153
+ headers,
154
+ success,
153
155
  }: HandleWebhookOpts<
154
156
  E | WebhookParseError | BadWebhookSignature | DefinitionNotFound
155
157
  >): Effect.Effect<WebhookConfig, never, void> =>
@@ -165,8 +167,8 @@ export const makeHandler = <R, E, TE>(
165
167
  export const makeSimpleHandler = <R, E, TE>(
166
168
  ix: InteractionBuilder<R, E, TE>,
167
169
  ): (({
168
- headers,
169
170
  body,
171
+ headers,
170
172
  }: {
171
173
  headers: Headers
172
174
  body: string
@@ -180,6 +182,6 @@ export const makeSimpleHandler = <R, E, TE>(
180
182
  (_i, r) => Effect.succeed(r),
181
183
  )
182
184
 
183
- return ({ headers, body }: { headers: Headers; body: string }) =>
185
+ return ({ body, headers }: { headers: Headers; body: string }) =>
184
186
  handle(headers, body)
185
187
  }
package/src/Log.ts CHANGED
@@ -3,11 +3,11 @@ import * as Layer from "@effect/io/Layer"
3
3
  import { Tag } from "@effect/data/Context"
4
4
 
5
5
  const make = (debug = false) => ({
6
- info: (...args: any[]) =>
6
+ info: (...args: Array<any>) =>
7
7
  Effect.sync(() => {
8
8
  console.error("INFO", ...args)
9
9
  }),
10
- debug: (...args: any[]) =>
10
+ debug: (...args: Array<any>) =>
11
11
  debug
12
12
  ? Effect.sync(() => {
13
13
  console.error("DEBUG", ...args)
@@ -1,6 +1,6 @@
1
1
  import * as Option from "@effect/data/Option"
2
2
  import * as Effect from "@effect/io/Effect"
3
- import { BucketDetails, RateLimitStore } from "dfx/RateLimit"
3
+ import type { BucketDetails, RateLimitStore } from "dfx/RateLimit"
4
4
 
5
5
  interface Counter {
6
6
  count: number
@@ -1,4 +1,5 @@
1
- import { Duration, millis, zero } from "@effect/data/Duration"
1
+ import type { Duration } from "@effect/data/Duration"
2
+ import { millis, zero } from "@effect/data/Duration"
2
3
 
3
4
  export const delayFrom = (
4
5
  window: number,
package/src/RateLimit.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Tag } from "@effect/data/Context"
2
2
  import * as Duration from "@effect/data/Duration"
3
- import * as Option from "@effect/data/Option"
3
+ import type * as Option from "@effect/data/Option"
4
4
  import * as Effect from "@effect/io/Effect"
5
5
  import * as Layer from "@effect/io/Layer"
6
6
  import { Log } from "dfx/Log"