@neontechspace/fluxerly 1000.0.0-nightly.12
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.
- package/CHANGELOG.md +833 -0
- package/LICENSE +201 -0
- package/README.md +129 -0
- package/agents/AGENTS.md +195 -0
- package/dist/api/default/application.d.ts +34 -0
- package/dist/api/default/application.d.ts.map +1 -0
- package/dist/api/default/application.js +2 -0
- package/dist/api/default/application.js.map +1 -0
- package/dist/api/default/attachments.d.ts +89 -0
- package/dist/api/default/attachments.d.ts.map +1 -0
- package/dist/api/default/attachments.js +2 -0
- package/dist/api/default/attachments.js.map +1 -0
- package/dist/api/default/audit-logs.d.ts +48 -0
- package/dist/api/default/audit-logs.d.ts.map +1 -0
- package/dist/api/default/audit-logs.js +2 -0
- package/dist/api/default/audit-logs.js.map +1 -0
- package/dist/api/default/bot.d.ts +200 -0
- package/dist/api/default/bot.d.ts.map +1 -0
- package/dist/api/default/bot.js +309 -0
- package/dist/api/default/bot.js.map +1 -0
- package/dist/api/default/cache.d.ts +105 -0
- package/dist/api/default/cache.d.ts.map +1 -0
- package/dist/api/default/cache.js +2 -0
- package/dist/api/default/cache.js.map +1 -0
- package/dist/api/default/channels.d.ts +249 -0
- package/dist/api/default/channels.d.ts.map +1 -0
- package/dist/api/default/channels.js +2 -0
- package/dist/api/default/channels.js.map +1 -0
- package/dist/api/default/client.d.ts +528 -0
- package/dist/api/default/client.d.ts.map +1 -0
- package/dist/api/default/client.js +301 -0
- package/dist/api/default/client.js.map +1 -0
- package/dist/api/default/collectors.d.ts +76 -0
- package/dist/api/default/collectors.d.ts.map +1 -0
- package/dist/api/default/collectors.js +2 -0
- package/dist/api/default/collectors.js.map +1 -0
- package/dist/api/default/commands.d.ts +91 -0
- package/dist/api/default/commands.d.ts.map +1 -0
- package/dist/api/default/commands.js +92 -0
- package/dist/api/default/commands.js.map +1 -0
- package/dist/api/default/direct-messages.d.ts +111 -0
- package/dist/api/default/direct-messages.d.ts.map +1 -0
- package/dist/api/default/direct-messages.js +2 -0
- package/dist/api/default/direct-messages.js.map +1 -0
- package/dist/api/default/discovery.d.ts +76 -0
- package/dist/api/default/discovery.d.ts.map +1 -0
- package/dist/api/default/discovery.js +2 -0
- package/dist/api/default/discovery.js.map +1 -0
- package/dist/api/default/emojis.d.ts +88 -0
- package/dist/api/default/emojis.d.ts.map +1 -0
- package/dist/api/default/emojis.js +2 -0
- package/dist/api/default/emojis.js.map +1 -0
- package/dist/api/default/events.d.ts +127 -0
- package/dist/api/default/events.d.ts.map +1 -0
- package/dist/api/default/events.js +2 -0
- package/dist/api/default/events.js.map +1 -0
- package/dist/api/default/gateway.d.ts +62 -0
- package/dist/api/default/gateway.d.ts.map +1 -0
- package/dist/api/default/gateway.js +2 -0
- package/dist/api/default/gateway.js.map +1 -0
- package/dist/api/default/guards.d.ts +87 -0
- package/dist/api/default/guards.d.ts.map +1 -0
- package/dist/api/default/guards.js +78 -0
- package/dist/api/default/guards.js.map +1 -0
- package/dist/api/default/guilds.d.ts +230 -0
- package/dist/api/default/guilds.d.ts.map +1 -0
- package/dist/api/default/guilds.js +2 -0
- package/dist/api/default/guilds.js.map +1 -0
- package/dist/api/default/helpers.d.ts +79 -0
- package/dist/api/default/helpers.d.ts.map +1 -0
- package/dist/api/default/helpers.js +79 -0
- package/dist/api/default/helpers.js.map +1 -0
- package/dist/api/default/instance.d.ts +47 -0
- package/dist/api/default/instance.d.ts.map +1 -0
- package/dist/api/default/instance.js +2 -0
- package/dist/api/default/instance.js.map +1 -0
- package/dist/api/default/invites.d.ts +57 -0
- package/dist/api/default/invites.d.ts.map +1 -0
- package/dist/api/default/invites.js +2 -0
- package/dist/api/default/invites.js.map +1 -0
- package/dist/api/default/logging.d.ts +37 -0
- package/dist/api/default/logging.d.ts.map +1 -0
- package/dist/api/default/logging.js +2 -0
- package/dist/api/default/logging.js.map +1 -0
- package/dist/api/default/members.d.ts +442 -0
- package/dist/api/default/members.d.ts.map +1 -0
- package/dist/api/default/members.js +2 -0
- package/dist/api/default/members.js.map +1 -0
- package/dist/api/default/messages.d.ts +898 -0
- package/dist/api/default/messages.d.ts.map +1 -0
- package/dist/api/default/messages.js +2 -0
- package/dist/api/default/messages.js.map +1 -0
- package/dist/api/default/oauth.d.ts +168 -0
- package/dist/api/default/oauth.d.ts.map +1 -0
- package/dist/api/default/oauth.js +84 -0
- package/dist/api/default/oauth.js.map +1 -0
- package/dist/api/default/permissions.d.ts +44 -0
- package/dist/api/default/permissions.d.ts.map +1 -0
- package/dist/api/default/permissions.js +2 -0
- package/dist/api/default/permissions.js.map +1 -0
- package/dist/api/default/presence.d.ts +88 -0
- package/dist/api/default/presence.d.ts.map +1 -0
- package/dist/api/default/presence.js +2 -0
- package/dist/api/default/presence.js.map +1 -0
- package/dist/api/default/rest.d.ts +28 -0
- package/dist/api/default/rest.d.ts.map +1 -0
- package/dist/api/default/rest.js +2 -0
- package/dist/api/default/rest.js.map +1 -0
- package/dist/api/default/results.d.ts +31 -0
- package/dist/api/default/results.d.ts.map +1 -0
- package/dist/api/default/results.js +14 -0
- package/dist/api/default/results.js.map +1 -0
- package/dist/api/default/roles.d.ts +119 -0
- package/dist/api/default/roles.d.ts.map +1 -0
- package/dist/api/default/roles.js +2 -0
- package/dist/api/default/roles.js.map +1 -0
- package/dist/api/default/stickers.d.ts +92 -0
- package/dist/api/default/stickers.d.ts.map +1 -0
- package/dist/api/default/stickers.js +2 -0
- package/dist/api/default/stickers.js.map +1 -0
- package/dist/api/default/supervisor.d.ts +51 -0
- package/dist/api/default/supervisor.d.ts.map +1 -0
- package/dist/api/default/supervisor.js +53 -0
- package/dist/api/default/supervisor.js.map +1 -0
- package/dist/api/default/threads.d.ts +158 -0
- package/dist/api/default/threads.d.ts.map +1 -0
- package/dist/api/default/threads.js +2 -0
- package/dist/api/default/threads.js.map +1 -0
- package/dist/api/default/users.d.ts +73 -0
- package/dist/api/default/users.d.ts.map +1 -0
- package/dist/api/default/users.js +2 -0
- package/dist/api/default/users.js.map +1 -0
- package/dist/api/default/webhook-client.d.ts +149 -0
- package/dist/api/default/webhook-client.d.ts.map +1 -0
- package/dist/api/default/webhook-client.js +69 -0
- package/dist/api/default/webhook-client.js.map +1 -0
- package/dist/api/default/webhooks.d.ts +62 -0
- package/dist/api/default/webhooks.d.ts.map +1 -0
- package/dist/api/default/webhooks.js +2 -0
- package/dist/api/default/webhooks.js.map +1 -0
- package/dist/api/effect/application.d.ts +29 -0
- package/dist/api/effect/application.d.ts.map +1 -0
- package/dist/api/effect/application.js +2 -0
- package/dist/api/effect/application.js.map +1 -0
- package/dist/api/effect/attachments.d.ts +84 -0
- package/dist/api/effect/attachments.d.ts.map +1 -0
- package/dist/api/effect/attachments.js +2 -0
- package/dist/api/effect/attachments.js.map +1 -0
- package/dist/api/effect/audit-logs.d.ts +42 -0
- package/dist/api/effect/audit-logs.d.ts.map +1 -0
- package/dist/api/effect/audit-logs.js +2 -0
- package/dist/api/effect/audit-logs.js.map +1 -0
- package/dist/api/effect/bot.d.ts +233 -0
- package/dist/api/effect/bot.d.ts.map +1 -0
- package/dist/api/effect/bot.js +230 -0
- package/dist/api/effect/bot.js.map +1 -0
- package/dist/api/effect/cache.d.ts +103 -0
- package/dist/api/effect/cache.d.ts.map +1 -0
- package/dist/api/effect/cache.js +2 -0
- package/dist/api/effect/cache.js.map +1 -0
- package/dist/api/effect/channels.d.ts +231 -0
- package/dist/api/effect/channels.d.ts.map +1 -0
- package/dist/api/effect/channels.js +2 -0
- package/dist/api/effect/channels.js.map +1 -0
- package/dist/api/effect/client.d.ts +622 -0
- package/dist/api/effect/client.d.ts.map +1 -0
- package/dist/api/effect/client.js +191 -0
- package/dist/api/effect/client.js.map +1 -0
- package/dist/api/effect/collectors.d.ts +90 -0
- package/dist/api/effect/collectors.d.ts.map +1 -0
- package/dist/api/effect/collectors.js +2 -0
- package/dist/api/effect/collectors.js.map +1 -0
- package/dist/api/effect/commands.d.ts +86 -0
- package/dist/api/effect/commands.d.ts.map +1 -0
- package/dist/api/effect/commands.js +87 -0
- package/dist/api/effect/commands.js.map +1 -0
- package/dist/api/effect/direct-messages.d.ts +102 -0
- package/dist/api/effect/direct-messages.d.ts.map +1 -0
- package/dist/api/effect/direct-messages.js +2 -0
- package/dist/api/effect/direct-messages.js.map +1 -0
- package/dist/api/effect/discovery.d.ts +68 -0
- package/dist/api/effect/discovery.d.ts.map +1 -0
- package/dist/api/effect/discovery.js +2 -0
- package/dist/api/effect/discovery.js.map +1 -0
- package/dist/api/effect/emojis.d.ts +77 -0
- package/dist/api/effect/emojis.d.ts.map +1 -0
- package/dist/api/effect/emojis.js +2 -0
- package/dist/api/effect/emojis.js.map +1 -0
- package/dist/api/effect/events.d.ts +78 -0
- package/dist/api/effect/events.d.ts.map +1 -0
- package/dist/api/effect/events.js +12 -0
- package/dist/api/effect/events.js.map +1 -0
- package/dist/api/effect/failures.d.ts +14 -0
- package/dist/api/effect/failures.d.ts.map +1 -0
- package/dist/api/effect/failures.js +2 -0
- package/dist/api/effect/failures.js.map +1 -0
- package/dist/api/effect/gateway.d.ts +63 -0
- package/dist/api/effect/gateway.d.ts.map +1 -0
- package/dist/api/effect/gateway.js +2 -0
- package/dist/api/effect/gateway.js.map +1 -0
- package/dist/api/effect/guards.d.ts +91 -0
- package/dist/api/effect/guards.d.ts.map +1 -0
- package/dist/api/effect/guards.js +94 -0
- package/dist/api/effect/guards.js.map +1 -0
- package/dist/api/effect/guilds.d.ts +221 -0
- package/dist/api/effect/guilds.d.ts.map +1 -0
- package/dist/api/effect/guilds.js +2 -0
- package/dist/api/effect/guilds.js.map +1 -0
- package/dist/api/effect/helpers.d.ts +300 -0
- package/dist/api/effect/helpers.d.ts.map +1 -0
- package/dist/api/effect/helpers.js +156 -0
- package/dist/api/effect/helpers.js.map +1 -0
- package/dist/api/effect/hierarchy.d.ts +26 -0
- package/dist/api/effect/hierarchy.d.ts.map +1 -0
- package/dist/api/effect/hierarchy.js +26 -0
- package/dist/api/effect/hierarchy.js.map +1 -0
- package/dist/api/effect/instance.d.ts +46 -0
- package/dist/api/effect/instance.d.ts.map +1 -0
- package/dist/api/effect/instance.js +8 -0
- package/dist/api/effect/instance.js.map +1 -0
- package/dist/api/effect/invites.d.ts +49 -0
- package/dist/api/effect/invites.d.ts.map +1 -0
- package/dist/api/effect/invites.js +2 -0
- package/dist/api/effect/invites.js.map +1 -0
- package/dist/api/effect/logging.d.ts +37 -0
- package/dist/api/effect/logging.d.ts.map +1 -0
- package/dist/api/effect/logging.js +2 -0
- package/dist/api/effect/logging.js.map +1 -0
- package/dist/api/effect/members.d.ts +433 -0
- package/dist/api/effect/members.d.ts.map +1 -0
- package/dist/api/effect/members.js +2 -0
- package/dist/api/effect/members.js.map +1 -0
- package/dist/api/effect/messages.d.ts +877 -0
- package/dist/api/effect/messages.d.ts.map +1 -0
- package/dist/api/effect/messages.js +2 -0
- package/dist/api/effect/messages.js.map +1 -0
- package/dist/api/effect/oauth.d.ts +148 -0
- package/dist/api/effect/oauth.d.ts.map +1 -0
- package/dist/api/effect/oauth.js +51 -0
- package/dist/api/effect/oauth.js.map +1 -0
- package/dist/api/effect/permissions.d.ts +41 -0
- package/dist/api/effect/permissions.d.ts.map +1 -0
- package/dist/api/effect/permissions.js +2 -0
- package/dist/api/effect/permissions.js.map +1 -0
- package/dist/api/effect/presence.d.ts +83 -0
- package/dist/api/effect/presence.d.ts.map +1 -0
- package/dist/api/effect/presence.js +2 -0
- package/dist/api/effect/presence.js.map +1 -0
- package/dist/api/effect/rest.d.ts +27 -0
- package/dist/api/effect/rest.d.ts.map +1 -0
- package/dist/api/effect/rest.js +2 -0
- package/dist/api/effect/rest.js.map +1 -0
- package/dist/api/effect/roles.d.ts +104 -0
- package/dist/api/effect/roles.d.ts.map +1 -0
- package/dist/api/effect/roles.js +2 -0
- package/dist/api/effect/roles.js.map +1 -0
- package/dist/api/effect/service.d.ts +76 -0
- package/dist/api/effect/service.d.ts.map +1 -0
- package/dist/api/effect/service.js +79 -0
- package/dist/api/effect/service.js.map +1 -0
- package/dist/api/effect/stickers.d.ts +81 -0
- package/dist/api/effect/stickers.d.ts.map +1 -0
- package/dist/api/effect/stickers.js +2 -0
- package/dist/api/effect/stickers.js.map +1 -0
- package/dist/api/effect/supervisor.d.ts +56 -0
- package/dist/api/effect/supervisor.d.ts.map +1 -0
- package/dist/api/effect/supervisor.js +58 -0
- package/dist/api/effect/supervisor.js.map +1 -0
- package/dist/api/effect/threads.d.ts +154 -0
- package/dist/api/effect/threads.d.ts.map +1 -0
- package/dist/api/effect/threads.js +2 -0
- package/dist/api/effect/threads.js.map +1 -0
- package/dist/api/effect/users.d.ts +62 -0
- package/dist/api/effect/users.d.ts.map +1 -0
- package/dist/api/effect/users.js +2 -0
- package/dist/api/effect/users.js.map +1 -0
- package/dist/api/effect/webhook-client.d.ts +140 -0
- package/dist/api/effect/webhook-client.d.ts.map +1 -0
- package/dist/api/effect/webhook-client.js +50 -0
- package/dist/api/effect/webhook-client.js.map +1 -0
- package/dist/api/effect/webhooks.d.ts +54 -0
- package/dist/api/effect/webhooks.d.ts.map +1 -0
- package/dist/api/effect/webhooks.js +2 -0
- package/dist/api/effect/webhooks.js.map +1 -0
- package/dist/api-errors.d.ts +609 -0
- package/dist/api-errors.d.ts.map +1 -0
- package/dist/api-errors.js +589 -0
- package/dist/api-errors.js.map +1 -0
- package/dist/application.d.ts +85 -0
- package/dist/application.d.ts.map +1 -0
- package/dist/application.js +44 -0
- package/dist/application.js.map +1 -0
- package/dist/assets.d.ts +197 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/assets.js +419 -0
- package/dist/assets.js.map +1 -0
- package/dist/attachments.d.ts +400 -0
- package/dist/attachments.d.ts.map +1 -0
- package/dist/attachments.js +88 -0
- package/dist/attachments.js.map +1 -0
- package/dist/audit-logs.d.ts +292 -0
- package/dist/audit-logs.d.ts.map +1 -0
- package/dist/audit-logs.js +46 -0
- package/dist/audit-logs.js.map +1 -0
- package/dist/bot-runner.d.ts +69 -0
- package/dist/bot-runner.d.ts.map +1 -0
- package/dist/bot-runner.js +41 -0
- package/dist/bot-runner.js.map +1 -0
- package/dist/builders.d.ts +153 -0
- package/dist/builders.d.ts.map +1 -0
- package/dist/builders.js +326 -0
- package/dist/builders.js.map +1 -0
- package/dist/cache.d.ts +187 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +2 -0
- package/dist/cache.js.map +1 -0
- package/dist/channels.d.ts +903 -0
- package/dist/channels.d.ts.map +1 -0
- package/dist/channels.js +125 -0
- package/dist/channels.js.map +1 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +65 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +645 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -0
- package/dist/collectors.d.ts +205 -0
- package/dist/collectors.d.ts.map +1 -0
- package/dist/collectors.js +71 -0
- package/dist/collectors.js.map +1 -0
- package/dist/colors.d.ts +55 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/colors.js +40 -0
- package/dist/colors.js.map +1 -0
- package/dist/command-arguments.d.ts +353 -0
- package/dist/command-arguments.d.ts.map +1 -0
- package/dist/command-arguments.js +2 -0
- package/dist/command-arguments.js.map +1 -0
- package/dist/command-help.d.ts +54 -0
- package/dist/command-help.d.ts.map +1 -0
- package/dist/command-help.js +2 -0
- package/dist/command-help.js.map +1 -0
- package/dist/commands.d.ts +328 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +62 -0
- package/dist/commands.js.map +1 -0
- package/dist/counts.d.ts +124 -0
- package/dist/counts.d.ts.map +1 -0
- package/dist/counts.js +52 -0
- package/dist/counts.js.map +1 -0
- package/dist/default-commands.d.ts +400 -0
- package/dist/default-commands.d.ts.map +1 -0
- package/dist/default-commands.js +488 -0
- package/dist/default-commands.js.map +1 -0
- package/dist/default-supervisor.d.ts +111 -0
- package/dist/default-supervisor.d.ts.map +1 -0
- package/dist/default-supervisor.js +277 -0
- package/dist/default-supervisor.js.map +1 -0
- package/dist/discovery.d.ts +223 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +18 -0
- package/dist/discovery.js.map +1 -0
- package/dist/effect-testing.d.ts +388 -0
- package/dist/effect-testing.d.ts.map +1 -0
- package/dist/effect-testing.js +261 -0
- package/dist/effect-testing.js.map +1 -0
- package/dist/effect.d.ts +220 -0
- package/dist/effect.d.ts.map +1 -0
- package/dist/effect.js +101 -0
- package/dist/effect.js.map +1 -0
- package/dist/embeds.d.ts +243 -0
- package/dist/embeds.d.ts.map +1 -0
- package/dist/embeds.js +2 -0
- package/dist/embeds.js.map +1 -0
- package/dist/error-tools.d.ts +101 -0
- package/dist/error-tools.d.ts.map +1 -0
- package/dist/error-tools.js +125 -0
- package/dist/error-tools.js.map +1 -0
- package/dist/errors.d.ts +386 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +440 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +798 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +2 -0
- package/dist/events.js.map +1 -0
- package/dist/expressions.d.ts +188 -0
- package/dist/expressions.d.ts.map +1 -0
- package/dist/expressions.js +2 -0
- package/dist/expressions.js.map +1 -0
- package/dist/failures.d.ts +53 -0
- package/dist/failures.d.ts.map +1 -0
- package/dist/failures.js +2 -0
- package/dist/failures.js.map +1 -0
- package/dist/gateway.d.ts +48 -0
- package/dist/gateway.d.ts.map +1 -0
- package/dist/gateway.js +60 -0
- package/dist/gateway.js.map +1 -0
- package/dist/guilds.d.ts +923 -0
- package/dist/guilds.d.ts.map +1 -0
- package/dist/guilds.js +204 -0
- package/dist/guilds.js.map +1 -0
- package/dist/helpers.d.ts +423 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +434 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +228 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +109 -0
- package/dist/index.js.map +1 -0
- package/dist/input-validation.d.ts +51 -0
- package/dist/input-validation.d.ts.map +1 -0
- package/dist/input-validation.js +34 -0
- package/dist/input-validation.js.map +1 -0
- package/dist/instance.d.ts +101 -0
- package/dist/instance.d.ts.map +1 -0
- package/dist/instance.js +2 -0
- package/dist/instance.js.map +1 -0
- package/dist/internal/agents-section.d.ts +22 -0
- package/dist/internal/agents-section.d.ts.map +1 -0
- package/dist/internal/agents-section.js +101 -0
- package/dist/internal/agents-section.js.map +1 -0
- package/dist/internal/application.d.ts +16 -0
- package/dist/internal/application.d.ts.map +1 -0
- package/dist/internal/application.js +33 -0
- package/dist/internal/application.js.map +1 -0
- package/dist/internal/attachment-refresh.d.ts +18 -0
- package/dist/internal/attachment-refresh.d.ts.map +1 -0
- package/dist/internal/attachment-refresh.js +39 -0
- package/dist/internal/attachment-refresh.js.map +1 -0
- package/dist/internal/attachments.d.ts +45 -0
- package/dist/internal/attachments.d.ts.map +1 -0
- package/dist/internal/attachments.js +230 -0
- package/dist/internal/attachments.js.map +1 -0
- package/dist/internal/audit-logs.d.ts +13 -0
- package/dist/internal/audit-logs.d.ts.map +1 -0
- package/dist/internal/audit-logs.js +295 -0
- package/dist/internal/audit-logs.js.map +1 -0
- package/dist/internal/audit.d.ts +12 -0
- package/dist/internal/audit.d.ts.map +1 -0
- package/dist/internal/audit.js +22 -0
- package/dist/internal/audit.js.map +1 -0
- package/dist/internal/binding/default-adapters.d.ts +22 -0
- package/dist/internal/binding/default-adapters.d.ts.map +1 -0
- package/dist/internal/binding/default-adapters.js +304 -0
- package/dist/internal/binding/default-adapters.js.map +1 -0
- package/dist/internal/binding/default.d.ts +45 -0
- package/dist/internal/binding/default.d.ts.map +1 -0
- package/dist/internal/binding/default.js +86 -0
- package/dist/internal/binding/default.js.map +1 -0
- package/dist/internal/binding/execute.d.ts +51 -0
- package/dist/internal/binding/execute.d.ts.map +1 -0
- package/dist/internal/binding/execute.js +123 -0
- package/dist/internal/binding/execute.js.map +1 -0
- package/dist/internal/binding/native-adapters.d.ts +23 -0
- package/dist/internal/binding/native-adapters.d.ts.map +1 -0
- package/dist/internal/binding/native-adapters.js +90 -0
- package/dist/internal/binding/native-adapters.js.map +1 -0
- package/dist/internal/binding/native.d.ts +41 -0
- package/dist/internal/binding/native.d.ts.map +1 -0
- package/dist/internal/binding/native.js +34 -0
- package/dist/internal/binding/native.js.map +1 -0
- package/dist/internal/binding/operations.d.ts +361 -0
- package/dist/internal/binding/operations.d.ts.map +1 -0
- package/dist/internal/binding/operations.js +272 -0
- package/dist/internal/binding/operations.js.map +1 -0
- package/dist/internal/bot-runner.d.ts +65 -0
- package/dist/internal/bot-runner.d.ts.map +1 -0
- package/dist/internal/bot-runner.js +363 -0
- package/dist/internal/bot-runner.js.map +1 -0
- package/dist/internal/cache-changes.d.ts +43 -0
- package/dist/internal/cache-changes.d.ts.map +1 -0
- package/dist/internal/cache-changes.js +320 -0
- package/dist/internal/cache-changes.js.map +1 -0
- package/dist/internal/cache.d.ts +57 -0
- package/dist/internal/cache.d.ts.map +1 -0
- package/dist/internal/cache.js +318 -0
- package/dist/internal/cache.js.map +1 -0
- package/dist/internal/calls.d.ts +16 -0
- package/dist/internal/calls.d.ts.map +1 -0
- package/dist/internal/calls.js +108 -0
- package/dist/internal/calls.js.map +1 -0
- package/dist/internal/channel-cache.d.ts +69 -0
- package/dist/internal/channel-cache.d.ts.map +1 -0
- package/dist/internal/channel-cache.js +413 -0
- package/dist/internal/channel-cache.js.map +1 -0
- package/dist/internal/channel-decode.d.ts +44 -0
- package/dist/internal/channel-decode.d.ts.map +1 -0
- package/dist/internal/channel-decode.js +377 -0
- package/dist/internal/channel-decode.js.map +1 -0
- package/dist/internal/channels.d.ts +60 -0
- package/dist/internal/channels.d.ts.map +1 -0
- package/dist/internal/channels.js +605 -0
- package/dist/internal/channels.js.map +1 -0
- package/dist/internal/client/backoff.d.ts +42 -0
- package/dist/internal/client/backoff.d.ts.map +1 -0
- package/dist/internal/client/backoff.js +36 -0
- package/dist/internal/client/backoff.js.map +1 -0
- package/dist/internal/client/configuration-fields.d.ts +14 -0
- package/dist/internal/client/configuration-fields.d.ts.map +1 -0
- package/dist/internal/client/configuration-fields.js +11 -0
- package/dist/internal/client/configuration-fields.js.map +1 -0
- package/dist/internal/client/drain.d.ts +33 -0
- package/dist/internal/client/drain.d.ts.map +1 -0
- package/dist/internal/client/drain.js +109 -0
- package/dist/internal/client/drain.js.map +1 -0
- package/dist/internal/client/intake.d.ts +27 -0
- package/dist/internal/client/intake.d.ts.map +1 -0
- package/dist/internal/client/intake.js +198 -0
- package/dist/internal/client/intake.js.map +1 -0
- package/dist/internal/client/lifetime.d.ts +35 -0
- package/dist/internal/client/lifetime.d.ts.map +1 -0
- package/dist/internal/client/lifetime.js +109 -0
- package/dist/internal/client/lifetime.js.map +1 -0
- package/dist/internal/client/shard-loop.d.ts +93 -0
- package/dist/internal/client/shard-loop.d.ts.map +1 -0
- package/dist/internal/client/shard-loop.js +452 -0
- package/dist/internal/client/shard-loop.js.map +1 -0
- package/dist/internal/client-registry.d.ts +26 -0
- package/dist/internal/client-registry.d.ts.map +1 -0
- package/dist/internal/client-registry.js +11 -0
- package/dist/internal/client-registry.js.map +1 -0
- package/dist/internal/client.d.ts +189 -0
- package/dist/internal/client.d.ts.map +1 -0
- package/dist/internal/client.js +1935 -0
- package/dist/internal/client.js.map +1 -0
- package/dist/internal/clock.d.ts +9 -0
- package/dist/internal/clock.d.ts.map +1 -0
- package/dist/internal/clock.js +5 -0
- package/dist/internal/clock.js.map +1 -0
- package/dist/internal/code-catalogue.d.ts +712 -0
- package/dist/internal/code-catalogue.d.ts.map +1 -0
- package/dist/internal/code-catalogue.js +655 -0
- package/dist/internal/code-catalogue.js.map +1 -0
- package/dist/internal/collector.d.ts +34 -0
- package/dist/internal/collector.d.ts.map +1 -0
- package/dist/internal/collector.js +400 -0
- package/dist/internal/collector.js.map +1 -0
- package/dist/internal/command-arguments.d.ts +29 -0
- package/dist/internal/command-arguments.d.ts.map +1 -0
- package/dist/internal/command-arguments.js +484 -0
- package/dist/internal/command-arguments.js.map +1 -0
- package/dist/internal/command-guards.d.ts +57 -0
- package/dist/internal/command-guards.d.ts.map +1 -0
- package/dist/internal/command-guards.js +81 -0
- package/dist/internal/command-guards.js.map +1 -0
- package/dist/internal/command-help.d.ts +15 -0
- package/dist/internal/command-help.d.ts.map +1 -0
- package/dist/internal/command-help.js +121 -0
- package/dist/internal/command-help.js.map +1 -0
- package/dist/internal/commands.d.ts +212 -0
- package/dist/internal/commands.d.ts.map +1 -0
- package/dist/internal/commands.js +1004 -0
- package/dist/internal/commands.js.map +1 -0
- package/dist/internal/configuration.d.ts +86 -0
- package/dist/internal/configuration.d.ts.map +1 -0
- package/dist/internal/configuration.js +401 -0
- package/dist/internal/configuration.js.map +1 -0
- package/dist/internal/counts.d.ts +33 -0
- package/dist/internal/counts.d.ts.map +1 -0
- package/dist/internal/counts.js +348 -0
- package/dist/internal/counts.js.map +1 -0
- package/dist/internal/decode/primitives.d.ts +30 -0
- package/dist/internal/decode/primitives.d.ts.map +1 -0
- package/dist/internal/decode/primitives.js +56 -0
- package/dist/internal/decode/primitives.js.map +1 -0
- package/dist/internal/decode/timestamp.d.ts +13 -0
- package/dist/internal/decode/timestamp.d.ts.map +1 -0
- package/dist/internal/decode/timestamp.js +27 -0
- package/dist/internal/decode/timestamp.js.map +1 -0
- package/dist/internal/decode/trace.d.ts +11 -0
- package/dist/internal/decode/trace.d.ts.map +1 -0
- package/dist/internal/decode/trace.js +69 -0
- package/dist/internal/decode/trace.js.map +1 -0
- package/dist/internal/defects.d.ts +48 -0
- package/dist/internal/defects.d.ts.map +1 -0
- package/dist/internal/defects.js +100 -0
- package/dist/internal/defects.js.map +1 -0
- package/dist/internal/effect-failures.d.ts +12 -0
- package/dist/internal/effect-failures.d.ts.map +1 -0
- package/dist/internal/effect-failures.js +45 -0
- package/dist/internal/effect-failures.js.map +1 -0
- package/dist/internal/embeds.d.ts +12 -0
- package/dist/internal/embeds.d.ts.map +1 -0
- package/dist/internal/embeds.js +308 -0
- package/dist/internal/embeds.js.map +1 -0
- package/dist/internal/events.d.ts +156 -0
- package/dist/internal/events.d.ts.map +1 -0
- package/dist/internal/events.js +1071 -0
- package/dist/internal/events.js.map +1 -0
- package/dist/internal/expiry-queue.d.ts +42 -0
- package/dist/internal/expiry-queue.d.ts.map +1 -0
- package/dist/internal/expiry-queue.js +138 -0
- package/dist/internal/expiry-queue.js.map +1 -0
- package/dist/internal/expressions.d.ts +35 -0
- package/dist/internal/expressions.d.ts.map +1 -0
- package/dist/internal/expressions.js +311 -0
- package/dist/internal/expressions.js.map +1 -0
- package/dist/internal/failures.d.ts +107 -0
- package/dist/internal/failures.d.ts.map +1 -0
- package/dist/internal/failures.js +416 -0
- package/dist/internal/failures.js.map +1 -0
- package/dist/internal/field-text.d.ts +10 -0
- package/dist/internal/field-text.d.ts.map +1 -0
- package/dist/internal/field-text.js +37 -0
- package/dist/internal/field-text.js.map +1 -0
- package/dist/internal/gateway/commands.d.ts +92 -0
- package/dist/internal/gateway/commands.d.ts.map +1 -0
- package/dist/internal/gateway/commands.js +223 -0
- package/dist/internal/gateway/commands.js.map +1 -0
- package/dist/internal/gateway/dispatch-table.d.ts +42 -0
- package/dist/internal/gateway/dispatch-table.d.ts.map +1 -0
- package/dist/internal/gateway/dispatch-table.js +288 -0
- package/dist/internal/gateway/dispatch-table.js.map +1 -0
- package/dist/internal/gateway/event-dispatches.d.ts +97 -0
- package/dist/internal/gateway/event-dispatches.d.ts.map +1 -0
- package/dist/internal/gateway/event-dispatches.js +172 -0
- package/dist/internal/gateway/event-dispatches.js.map +1 -0
- package/dist/internal/gateway/frames.d.ts +45 -0
- package/dist/internal/gateway/frames.d.ts.map +1 -0
- package/dist/internal/gateway/frames.js +121 -0
- package/dist/internal/gateway/frames.js.map +1 -0
- package/dist/internal/gateway/options.d.ts +24 -0
- package/dist/internal/gateway/options.d.ts.map +1 -0
- package/dist/internal/gateway/options.js +103 -0
- package/dist/internal/gateway/options.js.map +1 -0
- package/dist/internal/gateway/session.d.ts +104 -0
- package/dist/internal/gateway/session.d.ts.map +1 -0
- package/dist/internal/gateway/session.js +420 -0
- package/dist/internal/gateway/session.js.map +1 -0
- package/dist/internal/gateway-requests.d.ts +10 -0
- package/dist/internal/gateway-requests.d.ts.map +1 -0
- package/dist/internal/gateway-requests.js +26 -0
- package/dist/internal/gateway-requests.js.map +1 -0
- package/dist/internal/gateway.d.ts +19 -0
- package/dist/internal/gateway.d.ts.map +1 -0
- package/dist/internal/gateway.js +11 -0
- package/dist/internal/gateway.js.map +1 -0
- package/dist/internal/guild-cache.d.ts +69 -0
- package/dist/internal/guild-cache.d.ts.map +1 -0
- package/dist/internal/guild-cache.js +402 -0
- package/dist/internal/guild-cache.js.map +1 -0
- package/dist/internal/guild-discovery.d.ts +15 -0
- package/dist/internal/guild-discovery.d.ts.map +1 -0
- package/dist/internal/guild-discovery.js +258 -0
- package/dist/internal/guild-discovery.js.map +1 -0
- package/dist/internal/guild-lifecycle.d.ts +18 -0
- package/dist/internal/guild-lifecycle.d.ts.map +1 -0
- package/dist/internal/guild-lifecycle.js +119 -0
- package/dist/internal/guild-lifecycle.js.map +1 -0
- package/dist/internal/guild-settings.d.ts +11 -0
- package/dist/internal/guild-settings.d.ts.map +1 -0
- package/dist/internal/guild-settings.js +150 -0
- package/dist/internal/guild-settings.js.map +1 -0
- package/dist/internal/guilds.d.ts +94 -0
- package/dist/internal/guilds.d.ts.map +1 -0
- package/dist/internal/guilds.js +785 -0
- package/dist/internal/guilds.js.map +1 -0
- package/dist/internal/init-command.d.ts +54 -0
- package/dist/internal/init-command.d.ts.map +1 -0
- package/dist/internal/init-command.js +248 -0
- package/dist/internal/init-command.js.map +1 -0
- package/dist/internal/instance.d.ts +69 -0
- package/dist/internal/instance.d.ts.map +1 -0
- package/dist/internal/instance.js +455 -0
- package/dist/internal/instance.js.map +1 -0
- package/dist/internal/invalid-callback-return.d.ts +3 -0
- package/dist/internal/invalid-callback-return.d.ts.map +1 -0
- package/dist/internal/invalid-callback-return.js +26 -0
- package/dist/internal/invalid-callback-return.js.map +1 -0
- package/dist/internal/invites.d.ts +19 -0
- package/dist/internal/invites.d.ts.map +1 -0
- package/dist/internal/invites.js +182 -0
- package/dist/internal/invites.js.map +1 -0
- package/dist/internal/logging.d.ts +129 -0
- package/dist/internal/logging.d.ts.map +1 -0
- package/dist/internal/logging.js +868 -0
- package/dist/internal/logging.js.map +1 -0
- package/dist/internal/logical-scheduler.d.ts +27 -0
- package/dist/internal/logical-scheduler.d.ts.map +1 -0
- package/dist/internal/logical-scheduler.js +102 -0
- package/dist/internal/logical-scheduler.js.map +1 -0
- package/dist/internal/masking.d.ts +13 -0
- package/dist/internal/masking.d.ts.map +1 -0
- package/dist/internal/masking.js +235 -0
- package/dist/internal/masking.js.map +1 -0
- package/dist/internal/member-chunks.d.ts +96 -0
- package/dist/internal/member-chunks.d.ts.map +1 -0
- package/dist/internal/member-chunks.js +557 -0
- package/dist/internal/member-chunks.js.map +1 -0
- package/dist/internal/member-search-workflow.d.ts +19 -0
- package/dist/internal/member-search-workflow.d.ts.map +1 -0
- package/dist/internal/member-search-workflow.js +143 -0
- package/dist/internal/member-search-workflow.js.map +1 -0
- package/dist/internal/member-search.d.ts +20 -0
- package/dist/internal/member-search.d.ts.map +1 -0
- package/dist/internal/member-search.js +201 -0
- package/dist/internal/member-search.js.map +1 -0
- package/dist/internal/message-cleanup.d.ts +9 -0
- package/dist/internal/message-cleanup.d.ts.map +1 -0
- package/dist/internal/message-cleanup.js +368 -0
- package/dist/internal/message-cleanup.js.map +1 -0
- package/dist/internal/message-fields.d.ts +9 -0
- package/dist/internal/message-fields.d.ts.map +1 -0
- package/dist/internal/message-fields.js +55 -0
- package/dist/internal/message-fields.js.map +1 -0
- package/dist/internal/message-search-workflow.d.ts +14 -0
- package/dist/internal/message-search-workflow.d.ts.map +1 -0
- package/dist/internal/message-search-workflow.js +101 -0
- package/dist/internal/message-search-workflow.js.map +1 -0
- package/dist/internal/message-search.d.ts +19 -0
- package/dist/internal/message-search.d.ts.map +1 -0
- package/dist/internal/message-search.js +317 -0
- package/dist/internal/message-search.js.map +1 -0
- package/dist/internal/message.d.ts +34 -0
- package/dist/internal/message.d.ts.map +1 -0
- package/dist/internal/message.js +723 -0
- package/dist/internal/message.js.map +1 -0
- package/dist/internal/metrics.d.ts +16 -0
- package/dist/internal/metrics.d.ts.map +1 -0
- package/dist/internal/metrics.js +49 -0
- package/dist/internal/metrics.js.map +1 -0
- package/dist/internal/moderation.d.ts +20 -0
- package/dist/internal/moderation.d.ts.map +1 -0
- package/dist/internal/moderation.js +219 -0
- package/dist/internal/moderation.js.map +1 -0
- package/dist/internal/multipart.d.ts +10 -0
- package/dist/internal/multipart.d.ts.map +1 -0
- package/dist/internal/multipart.js +156 -0
- package/dist/internal/multipart.js.map +1 -0
- package/dist/internal/node-version.d.ts +10 -0
- package/dist/internal/node-version.d.ts.map +1 -0
- package/dist/internal/node-version.js +21 -0
- package/dist/internal/node-version.js.map +1 -0
- package/dist/internal/oauth.d.ts +29 -0
- package/dist/internal/oauth.d.ts.map +1 -0
- package/dist/internal/oauth.js +721 -0
- package/dist/internal/oauth.js.map +1 -0
- package/dist/internal/observer.d.ts +21 -0
- package/dist/internal/observer.d.ts.map +1 -0
- package/dist/internal/observer.js +48 -0
- package/dist/internal/observer.js.map +1 -0
- package/dist/internal/operation-signal.d.ts +9 -0
- package/dist/internal/operation-signal.d.ts.map +1 -0
- package/dist/internal/operation-signal.js +19 -0
- package/dist/internal/operation-signal.js.map +1 -0
- package/dist/internal/pagination.d.ts +67 -0
- package/dist/internal/pagination.d.ts.map +1 -0
- package/dist/internal/pagination.js +306 -0
- package/dist/internal/pagination.js.map +1 -0
- package/dist/internal/permission-requirements.d.ts +34 -0
- package/dist/internal/permission-requirements.d.ts.map +1 -0
- package/dist/internal/permission-requirements.js +204 -0
- package/dist/internal/permission-requirements.js.map +1 -0
- package/dist/internal/permissions.d.ts +28 -0
- package/dist/internal/permissions.d.ts.map +1 -0
- package/dist/internal/permissions.js +314 -0
- package/dist/internal/permissions.js.map +1 -0
- package/dist/internal/pins.d.ts +24 -0
- package/dist/internal/pins.d.ts.map +1 -0
- package/dist/internal/pins.js +83 -0
- package/dist/internal/pins.js.map +1 -0
- package/dist/internal/presence.d.ts +101 -0
- package/dist/internal/presence.d.ts.map +1 -0
- package/dist/internal/presence.js +581 -0
- package/dist/internal/presence.js.map +1 -0
- package/dist/internal/protocol/gateway.d.ts +116 -0
- package/dist/internal/protocol/gateway.d.ts.map +1 -0
- package/dist/internal/protocol/gateway.js +258 -0
- package/dist/internal/protocol/gateway.js.map +1 -0
- package/dist/internal/rate-limit-templates.d.ts +2 -0
- package/dist/internal/rate-limit-templates.d.ts.map +1 -0
- package/dist/internal/rate-limit-templates.js +132 -0
- package/dist/internal/rate-limit-templates.js.map +1 -0
- package/dist/internal/rate-limits.d.ts +32 -0
- package/dist/internal/rate-limits.d.ts.map +1 -0
- package/dist/internal/rate-limits.js +306 -0
- package/dist/internal/rate-limits.js.map +1 -0
- package/dist/internal/reaction-collector.d.ts +39 -0
- package/dist/internal/reaction-collector.d.ts.map +1 -0
- package/dist/internal/reaction-collector.js +441 -0
- package/dist/internal/reaction-collector.js.map +1 -0
- package/dist/internal/reaction-pages.d.ts +18 -0
- package/dist/internal/reaction-pages.d.ts.map +1 -0
- package/dist/internal/reaction-pages.js +213 -0
- package/dist/internal/reaction-pages.js.map +1 -0
- package/dist/internal/reactions.d.ts +30 -0
- package/dist/internal/reactions.d.ts.map +1 -0
- package/dist/internal/reactions.js +160 -0
- package/dist/internal/reactions.js.map +1 -0
- package/dist/internal/rejection-scope.d.ts +25 -0
- package/dist/internal/rejection-scope.d.ts.map +1 -0
- package/dist/internal/rejection-scope.js +103 -0
- package/dist/internal/rejection-scope.js.map +1 -0
- package/dist/internal/response-json.d.ts +12 -0
- package/dist/internal/response-json.d.ts.map +1 -0
- package/dist/internal/response-json.js +74 -0
- package/dist/internal/response-json.js.map +1 -0
- package/dist/internal/rest/admission.d.ts +77 -0
- package/dist/internal/rest/admission.d.ts.map +1 -0
- package/dist/internal/rest/admission.js +178 -0
- package/dist/internal/rest/admission.js.map +1 -0
- package/dist/internal/rest/attempt.d.ts +124 -0
- package/dist/internal/rest/attempt.d.ts.map +1 -0
- package/dist/internal/rest/attempt.js +410 -0
- package/dist/internal/rest/attempt.js.map +1 -0
- package/dist/internal/rest/classify.d.ts +93 -0
- package/dist/internal/rest/classify.d.ts.map +1 -0
- package/dist/internal/rest/classify.js +304 -0
- package/dist/internal/rest/classify.js.map +1 -0
- package/dist/internal/rest/download.d.ts +66 -0
- package/dist/internal/rest/download.d.ts.map +1 -0
- package/dist/internal/rest/download.js +552 -0
- package/dist/internal/rest/download.js.map +1 -0
- package/dist/internal/rest/options.d.ts +42 -0
- package/dist/internal/rest/options.d.ts.map +1 -0
- package/dist/internal/rest/options.js +99 -0
- package/dist/internal/rest/options.js.map +1 -0
- package/dist/internal/rest/owner.d.ts +154 -0
- package/dist/internal/rest/owner.d.ts.map +1 -0
- package/dist/internal/rest/owner.js +1292 -0
- package/dist/internal/rest/owner.js.map +1 -0
- package/dist/internal/rest/request.d.ts +31 -0
- package/dist/internal/rest/request.d.ts.map +1 -0
- package/dist/internal/rest/request.js +227 -0
- package/dist/internal/rest/request.js.map +1 -0
- package/dist/internal/rest.d.ts +10 -0
- package/dist/internal/rest.d.ts.map +1 -0
- package/dist/internal/rest.js +9 -0
- package/dist/internal/rest.js.map +1 -0
- package/dist/internal/retention-age.d.ts +11 -0
- package/dist/internal/retention-age.d.ts.map +1 -0
- package/dist/internal/retention-age.js +29 -0
- package/dist/internal/retention-age.js.map +1 -0
- package/dist/internal/role-hierarchy-workflow.d.ts +15 -0
- package/dist/internal/role-hierarchy-workflow.d.ts.map +1 -0
- package/dist/internal/role-hierarchy-workflow.js +122 -0
- package/dist/internal/role-hierarchy-workflow.js.map +1 -0
- package/dist/internal/role-hierarchy.d.ts +11 -0
- package/dist/internal/role-hierarchy.d.ts.map +1 -0
- package/dist/internal/role-hierarchy.js +87 -0
- package/dist/internal/role-hierarchy.js.map +1 -0
- package/dist/internal/scheduled-tasks.d.ts +46 -0
- package/dist/internal/scheduled-tasks.d.ts.map +1 -0
- package/dist/internal/scheduled-tasks.js +190 -0
- package/dist/internal/scheduled-tasks.js.map +1 -0
- package/dist/internal/sharding.d.ts +62 -0
- package/dist/internal/sharding.d.ts.map +1 -0
- package/dist/internal/sharding.js +205 -0
- package/dist/internal/sharding.js.map +1 -0
- package/dist/internal/starter-project.d.ts +27 -0
- package/dist/internal/starter-project.d.ts.map +1 -0
- package/dist/internal/starter-project.js +224 -0
- package/dist/internal/starter-project.js.map +1 -0
- package/dist/internal/suggest.d.ts +12 -0
- package/dist/internal/suggest.d.ts.map +1 -0
- package/dist/internal/suggest.js +51 -0
- package/dist/internal/suggest.js.map +1 -0
- package/dist/internal/supervisor.d.ts +95 -0
- package/dist/internal/supervisor.d.ts.map +1 -0
- package/dist/internal/supervisor.js +1829 -0
- package/dist/internal/supervisor.js.map +1 -0
- package/dist/internal/testing/discovery.d.ts +24 -0
- package/dist/internal/testing/discovery.d.ts.map +1 -0
- package/dist/internal/testing/discovery.js +22 -0
- package/dist/internal/testing/discovery.js.map +1 -0
- package/dist/internal/testing/errors.d.ts +43 -0
- package/dist/internal/testing/errors.d.ts.map +1 -0
- package/dist/internal/testing/errors.js +63 -0
- package/dist/internal/testing/errors.js.map +1 -0
- package/dist/internal/testing/fixtures.d.ts +477 -0
- package/dist/internal/testing/fixtures.d.ts.map +1 -0
- package/dist/internal/testing/fixtures.js +233 -0
- package/dist/internal/testing/fixtures.js.map +1 -0
- package/dist/internal/testing/gateway.d.ts +51 -0
- package/dist/internal/testing/gateway.d.ts.map +1 -0
- package/dist/internal/testing/gateway.js +265 -0
- package/dist/internal/testing/gateway.js.map +1 -0
- package/dist/internal/testing/harness.d.ts +60 -0
- package/dist/internal/testing/harness.d.ts.map +1 -0
- package/dist/internal/testing/harness.js +280 -0
- package/dist/internal/testing/harness.js.map +1 -0
- package/dist/internal/testing/http.d.ts +31 -0
- package/dist/internal/testing/http.d.ts.map +1 -0
- package/dist/internal/testing/http.js +347 -0
- package/dist/internal/testing/http.js.map +1 -0
- package/dist/internal/testing/types.d.ts +222 -0
- package/dist/internal/testing/types.d.ts.map +1 -0
- package/dist/internal/testing/types.js +2 -0
- package/dist/internal/testing/types.js.map +1 -0
- package/dist/internal/testing/wait.d.ts +16 -0
- package/dist/internal/testing/wait.d.ts.map +1 -0
- package/dist/internal/testing/wait.js +55 -0
- package/dist/internal/testing/wait.js.map +1 -0
- package/dist/internal/thread-events.d.ts +40 -0
- package/dist/internal/thread-events.d.ts.map +1 -0
- package/dist/internal/thread-events.js +121 -0
- package/dist/internal/thread-events.js.map +1 -0
- package/dist/internal/threads.d.ts +47 -0
- package/dist/internal/threads.d.ts.map +1 -0
- package/dist/internal/threads.js +587 -0
- package/dist/internal/threads.js.map +1 -0
- package/dist/internal/transfer-source.d.ts +29 -0
- package/dist/internal/transfer-source.d.ts.map +1 -0
- package/dist/internal/transfer-source.js +347 -0
- package/dist/internal/transfer-source.js.map +1 -0
- package/dist/internal/transport/http.d.ts +12 -0
- package/dist/internal/transport/http.d.ts.map +1 -0
- package/dist/internal/transport/http.js +44 -0
- package/dist/internal/transport/http.js.map +1 -0
- package/dist/internal/transport/index.d.ts +21 -0
- package/dist/internal/transport/index.d.ts.map +1 -0
- package/dist/internal/transport/index.js +15 -0
- package/dist/internal/transport/index.js.map +1 -0
- package/dist/internal/transport/socket.d.ts +51 -0
- package/dist/internal/transport/socket.d.ts.map +1 -0
- package/dist/internal/transport/socket.js +27 -0
- package/dist/internal/transport/socket.js.map +1 -0
- package/dist/internal/transport/user-agent.d.ts +7 -0
- package/dist/internal/transport/user-agent.d.ts.map +1 -0
- package/dist/internal/transport/user-agent.js +42 -0
- package/dist/internal/transport/user-agent.js.map +1 -0
- package/dist/internal/uploads.d.ts +23 -0
- package/dist/internal/uploads.d.ts.map +1 -0
- package/dist/internal/uploads.js +89 -0
- package/dist/internal/uploads.js.map +1 -0
- package/dist/internal/user-cache.d.ts +50 -0
- package/dist/internal/user-cache.d.ts.map +1 -0
- package/dist/internal/user-cache.js +273 -0
- package/dist/internal/user-cache.js.map +1 -0
- package/dist/internal/users.d.ts +41 -0
- package/dist/internal/users.d.ts.map +1 -0
- package/dist/internal/users.js +333 -0
- package/dist/internal/users.js.map +1 -0
- package/dist/internal/vanity-url.d.ts +11 -0
- package/dist/internal/vanity-url.d.ts.map +1 -0
- package/dist/internal/vanity-url.js +58 -0
- package/dist/internal/vanity-url.js.map +1 -0
- package/dist/internal/webhooks.d.ts +58 -0
- package/dist/internal/webhooks.d.ts.map +1 -0
- package/dist/internal/webhooks.js +490 -0
- package/dist/internal/webhooks.js.map +1 -0
- package/dist/invites.d.ts +86 -0
- package/dist/invites.d.ts.map +1 -0
- package/dist/invites.js +2 -0
- package/dist/invites.js.map +1 -0
- package/dist/logging.d.ts +228 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +2 -0
- package/dist/logging.js.map +1 -0
- package/dist/member-chunks.d.ts +145 -0
- package/dist/member-chunks.d.ts.map +1 -0
- package/dist/member-chunks.js +68 -0
- package/dist/member-chunks.js.map +1 -0
- package/dist/member-search.d.ts +140 -0
- package/dist/member-search.d.ts.map +1 -0
- package/dist/member-search.js +14 -0
- package/dist/member-search.js.map +1 -0
- package/dist/message-cleanup.d.ts +227 -0
- package/dist/message-cleanup.d.ts.map +1 -0
- package/dist/message-cleanup.js +101 -0
- package/dist/message-cleanup.js.map +1 -0
- package/dist/message-errors.d.ts +172 -0
- package/dist/message-errors.d.ts.map +1 -0
- package/dist/message-errors.js +173 -0
- package/dist/message-errors.js.map +1 -0
- package/dist/message-search.d.ts +201 -0
- package/dist/message-search.d.ts.map +1 -0
- package/dist/message-search.js +2 -0
- package/dist/message-search.js.map +1 -0
- package/dist/messages.d.ts +694 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +37 -0
- package/dist/messages.js.map +1 -0
- package/dist/native-commands.d.ts +451 -0
- package/dist/native-commands.d.ts.map +1 -0
- package/dist/native-commands.js +432 -0
- package/dist/native-commands.js.map +1 -0
- package/dist/native-supervisor.d.ts +125 -0
- package/dist/native-supervisor.d.ts.map +1 -0
- package/dist/native-supervisor.js +126 -0
- package/dist/native-supervisor.js.map +1 -0
- package/dist/oauth.d.ts +298 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +128 -0
- package/dist/oauth.js.map +1 -0
- package/dist/observer.d.ts +111 -0
- package/dist/observer.d.ts.map +1 -0
- package/dist/observer.js +2 -0
- package/dist/observer.js.map +1 -0
- package/dist/pagination.d.ts +117 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +61 -0
- package/dist/pagination.js.map +1 -0
- package/dist/permissions.d.ts +73 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +2 -0
- package/dist/permissions.js.map +1 -0
- package/dist/pins.d.ts +62 -0
- package/dist/pins.d.ts.map +1 -0
- package/dist/pins.js +2 -0
- package/dist/pins.js.map +1 -0
- package/dist/presence.d.ts +84 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +46 -0
- package/dist/presence.js.map +1 -0
- package/dist/reaction-pages.d.ts +99 -0
- package/dist/reaction-pages.d.ts.map +1 -0
- package/dist/reaction-pages.js +2 -0
- package/dist/reaction-pages.js.map +1 -0
- package/dist/reactions.d.ts +118 -0
- package/dist/reactions.d.ts.map +1 -0
- package/dist/reactions.js +2 -0
- package/dist/reactions.js.map +1 -0
- package/dist/rest.d.ts +260 -0
- package/dist/rest.d.ts.map +1 -0
- package/dist/rest.js +46 -0
- package/dist/rest.js.map +1 -0
- package/dist/role-hierarchy.d.ts +81 -0
- package/dist/role-hierarchy.d.ts.map +1 -0
- package/dist/role-hierarchy.js +53 -0
- package/dist/role-hierarchy.js.map +1 -0
- package/dist/sharding.d.ts +219 -0
- package/dist/sharding.d.ts.map +1 -0
- package/dist/sharding.js +86 -0
- package/dist/sharding.js.map +1 -0
- package/dist/supervisor.d.ts +392 -0
- package/dist/supervisor.d.ts.map +1 -0
- package/dist/supervisor.js +101 -0
- package/dist/supervisor.js.map +1 -0
- package/dist/testing.d.ts +258 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +202 -0
- package/dist/testing.js.map +1 -0
- package/dist/text.d.ts +38 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +46 -0
- package/dist/text.js.map +1 -0
- package/dist/threads.d.ts +258 -0
- package/dist/threads.d.ts.map +1 -0
- package/dist/threads.js +2 -0
- package/dist/threads.js.map +1 -0
- package/dist/users.d.ts +204 -0
- package/dist/users.d.ts.map +1 -0
- package/dist/users.js +44 -0
- package/dist/users.js.map +1 -0
- package/dist/webhooks.d.ts +423 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +68 -0
- package/dist/webhooks.js.map +1 -0
- package/esm-only.cjs +3 -0
- package/examples/starter/bot-effect.ts +17 -0
- package/examples/starter/bot.js +13 -0
- package/examples/starter/bot.ts +13 -0
- package/package.json +82 -0
- package/src/api/default/application.ts +40 -0
- package/src/api/default/attachments.ts +106 -0
- package/src/api/default/audit-logs.ts +58 -0
- package/src/api/default/bot.ts +586 -0
- package/src/api/default/cache.ts +106 -0
- package/src/api/default/channels.ts +317 -0
- package/src/api/default/client.ts +829 -0
- package/src/api/default/collectors.ts +81 -0
- package/src/api/default/commands.ts +92 -0
- package/src/api/default/direct-messages.ts +143 -0
- package/src/api/default/discovery.ts +103 -0
- package/src/api/default/emojis.ts +125 -0
- package/src/api/default/events.ts +144 -0
- package/src/api/default/gateway.ts +67 -0
- package/src/api/default/guards.ts +173 -0
- package/src/api/default/guilds.ts +271 -0
- package/src/api/default/helpers.ts +97 -0
- package/src/api/default/instance.ts +49 -0
- package/src/api/default/invites.ts +73 -0
- package/src/api/default/logging.ts +37 -0
- package/src/api/default/members.ts +550 -0
- package/src/api/default/messages.ts +1053 -0
- package/src/api/default/oauth.ts +293 -0
- package/src/api/default/permissions.ts +47 -0
- package/src/api/default/presence.ts +88 -0
- package/src/api/default/rest.ts +30 -0
- package/src/api/default/results.ts +44 -0
- package/src/api/default/roles.ts +154 -0
- package/src/api/default/stickers.ts +129 -0
- package/src/api/default/supervisor.ts +53 -0
- package/src/api/default/threads.ts +233 -0
- package/src/api/default/users.ts +82 -0
- package/src/api/default/webhook-client.ts +266 -0
- package/src/api/default/webhooks.ts +89 -0
- package/src/api/effect/application.ts +29 -0
- package/src/api/effect/attachments.ts +100 -0
- package/src/api/effect/audit-logs.ts +50 -0
- package/src/api/effect/bot.ts +546 -0
- package/src/api/effect/cache.ts +110 -0
- package/src/api/effect/channels.ts +293 -0
- package/src/api/effect/client.ts +792 -0
- package/src/api/effect/collectors.ts +103 -0
- package/src/api/effect/commands.ts +87 -0
- package/src/api/effect/direct-messages.ts +119 -0
- package/src/api/effect/discovery.ts +87 -0
- package/src/api/effect/emojis.ts +108 -0
- package/src/api/effect/events.ts +92 -0
- package/src/api/effect/failures.ts +14 -0
- package/src/api/effect/gateway.ts +63 -0
- package/src/api/effect/guards.ts +194 -0
- package/src/api/effect/guilds.ts +247 -0
- package/src/api/effect/helpers.ts +359 -0
- package/src/api/effect/hierarchy.ts +26 -0
- package/src/api/effect/instance.ts +50 -0
- package/src/api/effect/invites.ts +59 -0
- package/src/api/effect/logging.ts +37 -0
- package/src/api/effect/members.ts +521 -0
- package/src/api/effect/messages.ts +1003 -0
- package/src/api/effect/oauth.ts +208 -0
- package/src/api/effect/permissions.ts +44 -0
- package/src/api/effect/presence.ts +83 -0
- package/src/api/effect/rest.ts +27 -0
- package/src/api/effect/roles.ts +136 -0
- package/src/api/effect/service.ts +104 -0
- package/src/api/effect/stickers.ts +112 -0
- package/src/api/effect/supervisor.ts +58 -0
- package/src/api/effect/threads.ts +221 -0
- package/src/api/effect/users.ts +66 -0
- package/src/api/effect/webhook-client.ts +206 -0
- package/src/api/effect/webhooks.ts +75 -0
- package/src/api-errors.ts +985 -0
- package/src/application.ts +103 -0
- package/src/assets.ts +731 -0
- package/src/attachments.ts +469 -0
- package/src/audit-logs.ts +355 -0
- package/src/bot-runner.ts +91 -0
- package/src/builders.ts +390 -0
- package/src/cache.ts +190 -0
- package/src/channels.ts +1051 -0
- package/src/cli.ts +60 -0
- package/src/client.ts +663 -0
- package/src/collectors.ts +248 -0
- package/src/colors.ts +91 -0
- package/src/command-arguments.ts +432 -0
- package/src/command-help.ts +55 -0
- package/src/commands.ts +403 -0
- package/src/counts.ts +160 -0
- package/src/default-commands.ts +1147 -0
- package/src/default-supervisor.ts +484 -0
- package/src/discovery.ts +241 -0
- package/src/effect-testing.ts +603 -0
- package/src/effect.ts +751 -0
- package/src/embeds.ts +253 -0
- package/src/error-tools.ts +191 -0
- package/src/errors.ts +849 -0
- package/src/events.ts +830 -0
- package/src/expressions.ts +198 -0
- package/src/failures.ts +55 -0
- package/src/gateway.ts +86 -0
- package/src/guilds.ts +1108 -0
- package/src/helpers.ts +836 -0
- package/src/index.ts +796 -0
- package/src/input-validation.ts +94 -0
- package/src/instance.ts +111 -0
- package/src/internal/agents-section.ts +114 -0
- package/src/internal/application.ts +51 -0
- package/src/internal/attachment-refresh.ts +57 -0
- package/src/internal/attachments.ts +313 -0
- package/src/internal/audit-logs.ts +336 -0
- package/src/internal/audit.ts +33 -0
- package/src/internal/binding/default-adapters.ts +482 -0
- package/src/internal/binding/default.ts +155 -0
- package/src/internal/binding/execute.ts +221 -0
- package/src/internal/binding/native-adapters.ts +199 -0
- package/src/internal/binding/native.ts +72 -0
- package/src/internal/binding/operations.ts +1171 -0
- package/src/internal/bot-runner.ts +480 -0
- package/src/internal/cache-changes.ts +363 -0
- package/src/internal/cache.ts +323 -0
- package/src/internal/calls.ts +119 -0
- package/src/internal/channel-cache.ts +435 -0
- package/src/internal/channel-decode.ts +399 -0
- package/src/internal/channels.ts +874 -0
- package/src/internal/client/backoff.ts +69 -0
- package/src/internal/client/configuration-fields.ts +18 -0
- package/src/internal/client/drain.ts +150 -0
- package/src/internal/client/intake.ts +228 -0
- package/src/internal/client/lifetime.ts +165 -0
- package/src/internal/client/shard-loop.ts +586 -0
- package/src/internal/client-registry.ts +35 -0
- package/src/internal/client.ts +2448 -0
- package/src/internal/clock.ts +11 -0
- package/src/internal/code-catalogue.ts +739 -0
- package/src/internal/collector.ts +452 -0
- package/src/internal/command-arguments.ts +585 -0
- package/src/internal/command-guards.ts +96 -0
- package/src/internal/command-help.ts +156 -0
- package/src/internal/commands.ts +1319 -0
- package/src/internal/configuration.ts +529 -0
- package/src/internal/counts.ts +471 -0
- package/src/internal/decode/primitives.ts +67 -0
- package/src/internal/decode/timestamp.ts +29 -0
- package/src/internal/decode/trace.ts +65 -0
- package/src/internal/defects.ts +115 -0
- package/src/internal/effect-failures.ts +65 -0
- package/src/internal/embeds.ts +355 -0
- package/src/internal/events.ts +1345 -0
- package/src/internal/expiry-queue.ts +148 -0
- package/src/internal/expressions.ts +415 -0
- package/src/internal/failures.ts +492 -0
- package/src/internal/field-text.ts +40 -0
- package/src/internal/gateway/commands.ts +328 -0
- package/src/internal/gateway/dispatch-table.ts +383 -0
- package/src/internal/gateway/event-dispatches.ts +201 -0
- package/src/internal/gateway/frames.ts +176 -0
- package/src/internal/gateway/options.ts +144 -0
- package/src/internal/gateway/session.ts +625 -0
- package/src/internal/gateway-requests.ts +26 -0
- package/src/internal/gateway.ts +22 -0
- package/src/internal/guild-cache.ts +424 -0
- package/src/internal/guild-discovery.ts +332 -0
- package/src/internal/guild-lifecycle.ts +128 -0
- package/src/internal/guild-settings.ts +209 -0
- package/src/internal/guilds.ts +949 -0
- package/src/internal/init-command.ts +305 -0
- package/src/internal/instance.ts +645 -0
- package/src/internal/invalid-callback-return.ts +28 -0
- package/src/internal/invites.ts +234 -0
- package/src/internal/logging.ts +1007 -0
- package/src/internal/logical-scheduler.ts +139 -0
- package/src/internal/masking.ts +224 -0
- package/src/internal/member-chunks.ts +649 -0
- package/src/internal/member-search-workflow.ts +237 -0
- package/src/internal/member-search.ts +272 -0
- package/src/internal/message-cleanup.ts +515 -0
- package/src/internal/message-fields.ts +71 -0
- package/src/internal/message-search-workflow.ts +166 -0
- package/src/internal/message-search.ts +476 -0
- package/src/internal/message.ts +879 -0
- package/src/internal/metrics.ts +55 -0
- package/src/internal/moderation.ts +288 -0
- package/src/internal/multipart.ts +171 -0
- package/src/internal/node-version.ts +22 -0
- package/src/internal/oauth.ts +1146 -0
- package/src/internal/observer.ts +62 -0
- package/src/internal/operation-signal.ts +26 -0
- package/src/internal/pagination.ts +494 -0
- package/src/internal/permission-requirements.ts +359 -0
- package/src/internal/permissions.ts +417 -0
- package/src/internal/pins.ts +115 -0
- package/src/internal/presence.ts +745 -0
- package/src/internal/protocol/gateway.ts +299 -0
- package/src/internal/rate-limit-templates.ts +138 -0
- package/src/internal/rate-limits.ts +346 -0
- package/src/internal/reaction-collector.ts +499 -0
- package/src/internal/reaction-pages.ts +260 -0
- package/src/internal/reactions.ts +174 -0
- package/src/internal/rejection-scope.ts +119 -0
- package/src/internal/response-json.ts +76 -0
- package/src/internal/rest/admission.ts +210 -0
- package/src/internal/rest/attempt.ts +617 -0
- package/src/internal/rest/classify.ts +391 -0
- package/src/internal/rest/download.ts +658 -0
- package/src/internal/rest/options.ts +145 -0
- package/src/internal/rest/owner.ts +1828 -0
- package/src/internal/rest/request.ts +289 -0
- package/src/internal/rest.ts +9 -0
- package/src/internal/retention-age.ts +33 -0
- package/src/internal/role-hierarchy-workflow.ts +150 -0
- package/src/internal/role-hierarchy.ts +93 -0
- package/src/internal/scheduled-tasks.ts +217 -0
- package/src/internal/sharding.ts +270 -0
- package/src/internal/starter-project.ts +251 -0
- package/src/internal/suggest.ts +50 -0
- package/src/internal/supervisor.ts +2253 -0
- package/src/internal/testing/discovery.ts +23 -0
- package/src/internal/testing/errors.ts +67 -0
- package/src/internal/testing/fixtures.ts +714 -0
- package/src/internal/testing/gateway.ts +305 -0
- package/src/internal/testing/harness.ts +328 -0
- package/src/internal/testing/http.ts +395 -0
- package/src/internal/testing/types.ts +240 -0
- package/src/internal/testing/wait.ts +63 -0
- package/src/internal/thread-events.ts +128 -0
- package/src/internal/threads.ts +718 -0
- package/src/internal/transfer-source.ts +359 -0
- package/src/internal/transport/http.ts +46 -0
- package/src/internal/transport/index.ts +23 -0
- package/src/internal/transport/socket.ts +71 -0
- package/src/internal/transport/user-agent.ts +46 -0
- package/src/internal/uploads.ts +111 -0
- package/src/internal/user-cache.ts +294 -0
- package/src/internal/users.ts +402 -0
- package/src/internal/vanity-url.ts +80 -0
- package/src/internal/webhooks.ts +690 -0
- package/src/invites.ts +87 -0
- package/src/logging.ts +247 -0
- package/src/member-chunks.ts +195 -0
- package/src/member-search.ts +152 -0
- package/src/message-cleanup.ts +308 -0
- package/src/message-errors.ts +245 -0
- package/src/message-search.ts +213 -0
- package/src/messages.ts +768 -0
- package/src/native-commands.ts +1249 -0
- package/src/native-supervisor.ts +345 -0
- package/src/oauth.ts +413 -0
- package/src/observer.ts +118 -0
- package/src/pagination.ts +172 -0
- package/src/permissions.ts +74 -0
- package/src/pins.ts +65 -0
- package/src/presence.ts +124 -0
- package/src/reaction-pages.ts +106 -0
- package/src/reactions.ts +126 -0
- package/src/rest.ts +282 -0
- package/src/role-hierarchy.ts +127 -0
- package/src/sharding.ts +272 -0
- package/src/supervisor.ts +460 -0
- package/src/testing.ts +424 -0
- package/src/text.ts +76 -0
- package/src/threads.ts +274 -0
- package/src/users.ts +237 -0
- package/src/webhooks.ts +512 -0
|
@@ -0,0 +1,1292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One client's REST owner: Request validation per operation group, instance resolution, uploads, bounded read retries,
|
|
3
|
+
* rate-limit waits and cache guards around each operation.
|
|
4
|
+
* Invariant: Every operation registers its cache guards before discovery and queue or rate waits, releases upload
|
|
5
|
+
* reservations and transfer sources however it ends, and no rate-limit learning crosses REST owners, credentials or
|
|
6
|
+
* instance selections. Reads retry only under the bounded read policy, and mutations retry only after a confirmed
|
|
7
|
+
* rate-limit rejection. Implements
|
|
8
|
+
* [SDK contracts: Delivery, requests and caches](/docs/SDK-CONTRACTS.md#delivery-requests-and-caches)
|
|
9
|
+
*/
|
|
10
|
+
import { randomUUID } from "node:crypto";
|
|
11
|
+
import * as Cause from "effect/Cause";
|
|
12
|
+
import * as Clock from "effect/Clock";
|
|
13
|
+
import * as Deferred from "effect/Deferred";
|
|
14
|
+
import * as Effect from "effect/Effect";
|
|
15
|
+
import * as Exit from "effect/Exit";
|
|
16
|
+
import * as Random from "effect/Random";
|
|
17
|
+
import { ClientClosedError } from "#sdk/errors";
|
|
18
|
+
import { responseFieldText } from "#sdk/api-errors";
|
|
19
|
+
import { MessageError, MessageOperationError } from "#sdk/message-errors";
|
|
20
|
+
import { InputValidationFailure, unsupportedKeyFailure } from "#sdk/input-validation";
|
|
21
|
+
import { AttachmentRefreshError } from "#sdk/attachments";
|
|
22
|
+
import { GuildOperationError } from "#sdk/guilds";
|
|
23
|
+
import { ChannelOperationError } from "#sdk/channels";
|
|
24
|
+
import { WebhookOperationError } from "#sdk/webhooks";
|
|
25
|
+
import { UserOperationError } from "#sdk/users";
|
|
26
|
+
import { BotApplicationOperationError, } from "#sdk/application";
|
|
27
|
+
import { identifier, record, snapshotArray } from "../decode/primitives.js";
|
|
28
|
+
import { failingFieldPath } from "../decode/trace.js";
|
|
29
|
+
import { inputDefect, suspendInput } from "../defects.js";
|
|
30
|
+
import { mapFailureCause, withDeadline } from "../effect-failures.js";
|
|
31
|
+
import { decodeCrosspostSource, encodeEdit, encodeForward, encodeHistory, encodeMessage, snapshotReference, } from "../message.js";
|
|
32
|
+
import { decodeUploadPlans } from "../uploads.js";
|
|
33
|
+
import { readResponseJson } from "../response-json.js";
|
|
34
|
+
import { AttachmentTransferSource } from "../transfer-source.js";
|
|
35
|
+
import { encodeReactionEmoji, encodeReactionUsersQuery, decodeReactionUsersPage } from "../reactions.js";
|
|
36
|
+
import { decodePinsPage, encodePinsQuery } from "../pins.js";
|
|
37
|
+
import { decodeMessageSearchPage, encodeMessageSearch } from "../message-search.js";
|
|
38
|
+
import { auditSettings } from "../audit.js";
|
|
39
|
+
import { directMessageOpen } from "../users.js";
|
|
40
|
+
import { attachmentRefresh } from "../attachment-refresh.js";
|
|
41
|
+
import { metrics } from "../metrics.js";
|
|
42
|
+
import { emitObservation } from "../observer.js";
|
|
43
|
+
import { linkRejectionError } from "../rejection-scope.js";
|
|
44
|
+
import { rateRoute, routeTemplate } from "../rate-limits.js";
|
|
45
|
+
import { defaultHttpTransport } from "../transport/index.js";
|
|
46
|
+
import { RestAdmission } from "./admission.js";
|
|
47
|
+
import { defaultRestConfiguration } from "./options.js";
|
|
48
|
+
import { RestRequestError, } from "#sdk/rest";
|
|
49
|
+
import { completeCleanup, runAttempt } from "./attempt.js";
|
|
50
|
+
import { encodeRestRequest, readRestResponse } from "./request.js";
|
|
51
|
+
import { inputFailure, instanceFailure, localInputFailure, operationFailure, RestFailure, } from "./classify.js";
|
|
52
|
+
import { UnobservedDownloadDefects, downloadAttachment, openAttachmentStream, } from "./download.js";
|
|
53
|
+
/** Longest single timer delay, and the largest accepted timeoutMs */
|
|
54
|
+
const maximumTimerMs = 2_147_483_647;
|
|
55
|
+
/** Bounded retries for a GET after a transient failure */
|
|
56
|
+
const maximumReadRetries = 2;
|
|
57
|
+
/** Minimum backoff before the first and later read retries, before jitter */
|
|
58
|
+
const firstReadRetryMs = 125;
|
|
59
|
+
const laterReadRetryMs = 250;
|
|
60
|
+
/** Rate-limit waits of at least this long are logged at Warn */
|
|
61
|
+
const longRateLimitWaitMs = 1_000;
|
|
62
|
+
/** Largest upload-planning and upload-completion response */
|
|
63
|
+
const uploadResponseMaxBytes = 1_048_576;
|
|
64
|
+
/** Least time between two rest.busy Warn records of one client */
|
|
65
|
+
const busyWarnIntervalMs = 60_000;
|
|
66
|
+
/** Mutable state shared by one owner's operations, attempts and downloads */
|
|
67
|
+
export class RestRuntime {
|
|
68
|
+
/** Set by stop. No operation starts or continues its request after closure */
|
|
69
|
+
closed = false;
|
|
70
|
+
/** The owner's resolved instance, kept after the first successful discovery */
|
|
71
|
+
instance;
|
|
72
|
+
/** Attachment file bytes reserved by running operations */
|
|
73
|
+
uploadBytes = 0;
|
|
74
|
+
/** Stream cleanup failures that no caller observed, surfaced by shutdown */
|
|
75
|
+
unobservedDownloadDefects = new UnobservedDownloadDefects();
|
|
76
|
+
controllers = new Set();
|
|
77
|
+
downloads = new Set();
|
|
78
|
+
/** Completion signals for every running operation, awaited by shutdown */
|
|
79
|
+
operations = new Set();
|
|
80
|
+
admission;
|
|
81
|
+
http;
|
|
82
|
+
/** Scheduling limits and the default deadline for operations and downloads that omit timeoutMs */
|
|
83
|
+
settings;
|
|
84
|
+
cache;
|
|
85
|
+
resources;
|
|
86
|
+
channels;
|
|
87
|
+
users;
|
|
88
|
+
logical;
|
|
89
|
+
logging;
|
|
90
|
+
resolveInstance;
|
|
91
|
+
/** Logical time of the last rest.busy Warn, repeated at most once per busyWarnIntervalMs */
|
|
92
|
+
#busyWarnedAt;
|
|
93
|
+
/**
|
|
94
|
+
* Logical time of the last ratelimit.deadline Warn for requests refused before dispatch, per route template.
|
|
95
|
+
* Each new Warn first removes entries older than busyWarnIntervalMs, which no longer hold back a Warn, so the map
|
|
96
|
+
* holds only routes warned within one interval of the latest Warn
|
|
97
|
+
*/
|
|
98
|
+
deadlineWarnedAt = new Map();
|
|
99
|
+
constructor(options) {
|
|
100
|
+
this.settings = options.settings ?? defaultRestConfiguration;
|
|
101
|
+
this.admission = new RestAdmission(options.logical, this.settings, () => this.busy("queue"), options.shareGlobalPause);
|
|
102
|
+
this.http = options.http ?? defaultHttpTransport;
|
|
103
|
+
this.cache = options.cache;
|
|
104
|
+
this.resources = options.resources;
|
|
105
|
+
this.channels = options.channels;
|
|
106
|
+
this.users = options.users;
|
|
107
|
+
this.logical = options.logical;
|
|
108
|
+
this.logging = options.logging;
|
|
109
|
+
this.resolveInstance = options.resolveInstance;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Count a request that failed with busy, and warn at most once a minute that a REST budget is full, naming the full
|
|
113
|
+
* budget. Busy failures are returned to the caller, so the Warn exists only to make a saturated client visible
|
|
114
|
+
*/
|
|
115
|
+
busy(budget) {
|
|
116
|
+
this.logging?.count("restBusy");
|
|
117
|
+
const now = this.logical.now();
|
|
118
|
+
if (this.#busyWarnedAt !== undefined && now - this.#busyWarnedAt < busyWarnIntervalMs)
|
|
119
|
+
return;
|
|
120
|
+
this.#busyWarnedAt = now;
|
|
121
|
+
const queue = this.admission.diagnostics();
|
|
122
|
+
const full = budget === "uploads"
|
|
123
|
+
? "attachments reserved by running uploads reached uploads.maxBytes"
|
|
124
|
+
: queue.queuedRequests >= queue.queuedCapacity
|
|
125
|
+
? `${queue.queuedRequests} requests already wait for a slot (rest.maxQueued)`
|
|
126
|
+
: "the bodies of waiting requests reached rest.queuedJsonMaxBytes";
|
|
127
|
+
this.logging?.log({
|
|
128
|
+
level: "warn",
|
|
129
|
+
category: "rest",
|
|
130
|
+
code: "rest.busy",
|
|
131
|
+
message: `The REST queue is full because ${full}, so new requests fail with reason busy until it drains. Send fewer requests at once, or raise that limit. Further busy failures within a minute are counted in diagnostics().counters.restBusy without another record`,
|
|
132
|
+
fields: {
|
|
133
|
+
budget,
|
|
134
|
+
activeRequests: queue.activeRequests,
|
|
135
|
+
queuedRequests: queue.queuedRequests,
|
|
136
|
+
queuedCapacity: queue.queuedCapacity,
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async function readMessage(response, channel, id, signal, decode) {
|
|
142
|
+
const decoded = await readDecoded(response, signal, decode);
|
|
143
|
+
if (decoded.channelId !== channel)
|
|
144
|
+
throw responseFailure(response, "channelMismatch");
|
|
145
|
+
if (id !== undefined && decoded.id !== id)
|
|
146
|
+
throw responseFailure(response, "idMismatch");
|
|
147
|
+
return decoded;
|
|
148
|
+
}
|
|
149
|
+
async function readHistory(response, channel, query, signal, decode) {
|
|
150
|
+
const body = await readResponseJson(response, undefined, signal);
|
|
151
|
+
const invalid = (field) => responseFailure(response, field);
|
|
152
|
+
if (!Array.isArray(body))
|
|
153
|
+
throw invalid("body");
|
|
154
|
+
if (body.length > query.limit)
|
|
155
|
+
throw invalid("tooMany");
|
|
156
|
+
const messages = [];
|
|
157
|
+
const before = query.params.get("before");
|
|
158
|
+
const after = query.params.get("after");
|
|
159
|
+
let previous;
|
|
160
|
+
for (const [index, item] of body.entries()) {
|
|
161
|
+
const message = decode(item);
|
|
162
|
+
if (!message)
|
|
163
|
+
throw invalid(`${index}.${failingFieldPath(decode, item) ?? "message"}`);
|
|
164
|
+
if (message.channelId !== channel)
|
|
165
|
+
throw invalid("channelMismatch");
|
|
166
|
+
const id = BigInt(message.id);
|
|
167
|
+
if ((previous !== undefined && id >= previous) ||
|
|
168
|
+
(before !== null && id >= BigInt(before)) ||
|
|
169
|
+
(after !== null && id <= BigInt(after)))
|
|
170
|
+
throw invalid("order");
|
|
171
|
+
previous = id;
|
|
172
|
+
messages.push(message);
|
|
173
|
+
}
|
|
174
|
+
return Object.freeze(messages);
|
|
175
|
+
}
|
|
176
|
+
/** A response failure for a decoded value that did not match the operation's expected shape. The field names the
|
|
177
|
+
* response field path or check that failed, never a value
|
|
178
|
+
*/
|
|
179
|
+
const responseFailure = (response, field) => new RestFailure({ reason: "response", outcome: "unknown", status: response.status, responseField: field ?? null });
|
|
180
|
+
/** Read and decode a JSON response with a pure decoder, failing with the field where the decoder stopped */
|
|
181
|
+
async function readDecoded(response, signal, decode) {
|
|
182
|
+
const value = await readResponseJson(response, undefined, signal);
|
|
183
|
+
const decoded = decode(value);
|
|
184
|
+
if (decoded === undefined)
|
|
185
|
+
throw responseFailure(response, failingFieldPath(decode, value));
|
|
186
|
+
return decoded;
|
|
187
|
+
}
|
|
188
|
+
/** Read operation options and their requested deadline once. Only an application getter or proxy can throw here */
|
|
189
|
+
function deadlineOption(options) {
|
|
190
|
+
if (options !== undefined && !record(options))
|
|
191
|
+
return { valid: false, timeoutMs: undefined };
|
|
192
|
+
return { valid: true, timeoutMs: options?.timeoutMs };
|
|
193
|
+
}
|
|
194
|
+
/** Options every REST operation accepts. The Effect API has no signal, but accepting it keeps both APIs' checks equal */
|
|
195
|
+
const operationOptionKeys = ["timeoutMs", "signal"];
|
|
196
|
+
/** Reject the first options key outside keys, naming it with the closest supported key */
|
|
197
|
+
function unsupportedOptionFailure(options, keys) {
|
|
198
|
+
const unsupported = record(options)
|
|
199
|
+
? unsupportedKeyFailure(options, keys, "options", "the operation options")
|
|
200
|
+
: undefined;
|
|
201
|
+
return unsupported && inputFailure(unsupported.detail);
|
|
202
|
+
}
|
|
203
|
+
/** Reject options that are not an object or contain fields other than timeoutMs and signal */
|
|
204
|
+
function timeoutOptionsFailure(options) {
|
|
205
|
+
if (options !== undefined && !record(options))
|
|
206
|
+
return localInputFailure("options", "type", "the operation options must be an object");
|
|
207
|
+
return unsupportedOptionFailure(options, operationOptionKeys);
|
|
208
|
+
}
|
|
209
|
+
/** One client's transient REST scheduler, without shared-token coordination or durable delivery */
|
|
210
|
+
export class RestOwner {
|
|
211
|
+
#runtime;
|
|
212
|
+
#uploadMaxBytes;
|
|
213
|
+
#decodeMessage;
|
|
214
|
+
constructor(options) {
|
|
215
|
+
this.#runtime = new RestRuntime(options);
|
|
216
|
+
this.#uploadMaxBytes = options.uploadMaxBytes;
|
|
217
|
+
this.#decodeMessage = options.decodeMessage;
|
|
218
|
+
}
|
|
219
|
+
/** The client's default operation deadline in milliseconds, from rest.defaultTimeoutMs */
|
|
220
|
+
get defaultTimeoutMs() {
|
|
221
|
+
return this.#runtime.settings.defaultTimeoutMs;
|
|
222
|
+
}
|
|
223
|
+
/** Size the default API request slots for the client's local shard count */
|
|
224
|
+
scaleConcurrency(localShards) {
|
|
225
|
+
this.#runtime.admission.scaleConcurrency(localShards);
|
|
226
|
+
}
|
|
227
|
+
/** Apply a global pause another process learned, lasting waitMs from now, without sharing it again */
|
|
228
|
+
pauseGlobal(waitMs) {
|
|
229
|
+
this.#runtime.admission.pauseGlobal(this.#runtime.logical.now() + waitMs, true);
|
|
230
|
+
}
|
|
231
|
+
/** Completion signals of the operations and downloads running now, queued ones included, for a draining shutdown */
|
|
232
|
+
inFlight() {
|
|
233
|
+
return [...this.#runtime.operations];
|
|
234
|
+
}
|
|
235
|
+
diagnostics() {
|
|
236
|
+
return {
|
|
237
|
+
...this.#runtime.admission.diagnostics(),
|
|
238
|
+
reservedUploadBytes: this.#runtime.uploadBytes,
|
|
239
|
+
uploadByteCapacity: this.#uploadMaxBytes,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
refreshAttachmentUrls(token, urls, options) {
|
|
243
|
+
return suspendInput(() => {
|
|
244
|
+
if (this.#runtime.closed)
|
|
245
|
+
return Effect.fail(new ClientClosedError());
|
|
246
|
+
const input = attachmentRefresh(urls);
|
|
247
|
+
if (input instanceof InputValidationFailure)
|
|
248
|
+
return Effect.fail(inputFailure(input.detail));
|
|
249
|
+
const invalid = timeoutOptionsFailure(options);
|
|
250
|
+
if (invalid)
|
|
251
|
+
return Effect.fail(invalid);
|
|
252
|
+
return this.#execute(token, {
|
|
253
|
+
channel: "attachments",
|
|
254
|
+
bucket: "attachments:refresh",
|
|
255
|
+
cache: false,
|
|
256
|
+
path: input.path,
|
|
257
|
+
method: input.method,
|
|
258
|
+
status: input.status,
|
|
259
|
+
body: { json: input.json, files: [] },
|
|
260
|
+
decode: async (response, _instance, signal) => {
|
|
261
|
+
return readDecoded(response, signal, (value) => input.decode(value));
|
|
262
|
+
},
|
|
263
|
+
}, options);
|
|
264
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, AttachmentRefreshError, "attachments.refreshUrls")));
|
|
265
|
+
}
|
|
266
|
+
openDownload(attachment, options) {
|
|
267
|
+
return openAttachmentStream(this.#runtime, attachment, options);
|
|
268
|
+
}
|
|
269
|
+
download(attachment, options) {
|
|
270
|
+
return downloadAttachment(this.#runtime, attachment, options);
|
|
271
|
+
}
|
|
272
|
+
reply(token, target, input, options) {
|
|
273
|
+
return this.#send(token, target.channelId, () => encodeMessage(target.channelId, input, randomUUID().replaceAll("-", ""), target), options);
|
|
274
|
+
}
|
|
275
|
+
send(token, channel, input, options, directMessageUser) {
|
|
276
|
+
return this.#send(token, channel, () => encodeMessage(channel, input, randomUUID().replaceAll("-", ""), undefined, directMessageUser !== undefined), options, directMessageUser);
|
|
277
|
+
}
|
|
278
|
+
forward(token, channel, input, options) {
|
|
279
|
+
return this.#send(token, channel, () => encodeForward(channel, input, randomUUID().replaceAll("-", "")), options);
|
|
280
|
+
}
|
|
281
|
+
#send(token, channel, encode, options, directMessageUser) {
|
|
282
|
+
return suspendInput(() => {
|
|
283
|
+
if (this.#runtime.closed)
|
|
284
|
+
return Effect.fail(new ClientClosedError());
|
|
285
|
+
const body = encode();
|
|
286
|
+
if (body instanceof MessageError)
|
|
287
|
+
return Effect.fail(body);
|
|
288
|
+
return this.#execute(token, {
|
|
289
|
+
method: "POST",
|
|
290
|
+
channel,
|
|
291
|
+
body,
|
|
292
|
+
path: `/channels/${channel}/messages`,
|
|
293
|
+
...(directMessageUser === undefined ? {} : { directMessageUser }),
|
|
294
|
+
decodeDirectMessage: (response, channelId, signal) => readMessage(response, channelId, undefined, signal, this.#decodeMessage),
|
|
295
|
+
observe: (message, guard) => this.#runtime.cache.complete(guard, [message]),
|
|
296
|
+
decode: (response, _instance, signal) => readMessage(response, channel, undefined, signal, this.#decodeMessage),
|
|
297
|
+
}, options).pipe(mapFailureCause((error) => error instanceof RestFailure
|
|
298
|
+
? linkRejectionError(new MessageError({
|
|
299
|
+
reason: error.reason === "notFound" ? "rejected" : error.reason,
|
|
300
|
+
outcome: error.outcome,
|
|
301
|
+
status: error.status,
|
|
302
|
+
retryAfterMs: error.retryAfterMs,
|
|
303
|
+
apiError: error.apiError,
|
|
304
|
+
inputValidation: error.inputValidation,
|
|
305
|
+
providerCode: error.providerCode,
|
|
306
|
+
responseField: error.responseField,
|
|
307
|
+
// Keep the transport failure visible, as the other operation errors do
|
|
308
|
+
...(error.cause === undefined ? {} : { cause: error.cause }),
|
|
309
|
+
}), error)
|
|
310
|
+
: error));
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
fetch(token, target, options) {
|
|
314
|
+
return this.#manage(token, "fetch", target, undefined, options, (response, ref, signal) => readMessage(response, ref.channelId, ref.id, signal, this.#decodeMessage), (message, guard) => this.#runtime.cache.complete(guard, [message]));
|
|
315
|
+
}
|
|
316
|
+
publish(token, target, options) {
|
|
317
|
+
return this.#manage(token, "publish", target, undefined, options, (response, ref, signal) => readMessage(response, ref.channelId, ref.id, signal, this.#decodeMessage), (message, guard) => this.#runtime.cache.complete(guard, [message]));
|
|
318
|
+
}
|
|
319
|
+
fetchCrosspostSource(token, target, options) {
|
|
320
|
+
return this.#manage(token, "fetchCrosspostSource", target, undefined, options, (response, _ref, signal) => readDecoded(response, signal, decodeCrosspostSource));
|
|
321
|
+
}
|
|
322
|
+
typing(token, channel, options) {
|
|
323
|
+
return suspendInput(() => {
|
|
324
|
+
if (this.#runtime.closed)
|
|
325
|
+
return Effect.fail(new ClientClosedError());
|
|
326
|
+
if (!identifier(channel))
|
|
327
|
+
return Effect.fail(localInputFailure("channelId", "format", "Channel IDs must be decimal strings"));
|
|
328
|
+
const invalid = timeoutOptionsFailure(options);
|
|
329
|
+
if (invalid)
|
|
330
|
+
return Effect.fail(invalid);
|
|
331
|
+
return this.#execute(token, {
|
|
332
|
+
method: "POST",
|
|
333
|
+
channel,
|
|
334
|
+
bucket: "typing",
|
|
335
|
+
cache: false,
|
|
336
|
+
path: `/channels/${channel}/typing`,
|
|
337
|
+
body: undefined,
|
|
338
|
+
status: 204,
|
|
339
|
+
decode: async () => { },
|
|
340
|
+
}, options);
|
|
341
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, MessageOperationError, "typing")));
|
|
342
|
+
}
|
|
343
|
+
fetchHistory(token, channel, query, options) {
|
|
344
|
+
return suspendInput(() => {
|
|
345
|
+
if (this.#runtime.closed)
|
|
346
|
+
return Effect.fail(new ClientClosedError());
|
|
347
|
+
const encoded = encodeHistory(channel, query);
|
|
348
|
+
if (encoded instanceof InputValidationFailure)
|
|
349
|
+
return Effect.fail(inputFailure(encoded.detail));
|
|
350
|
+
return this.#execute(token, {
|
|
351
|
+
method: "GET",
|
|
352
|
+
channel,
|
|
353
|
+
bucket: "history",
|
|
354
|
+
path: `/channels/${channel}/messages?${encoded.params}`,
|
|
355
|
+
body: undefined,
|
|
356
|
+
status: 200,
|
|
357
|
+
decode: (response, _instance, signal) => readHistory(response, channel, encoded, signal, this.#decodeMessage),
|
|
358
|
+
observe: (messages, guard) => this.#runtime.cache.complete(guard, messages),
|
|
359
|
+
}, options);
|
|
360
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, MessageOperationError, "fetchHistory")));
|
|
361
|
+
}
|
|
362
|
+
search(token, context, query, options) {
|
|
363
|
+
return suspendInput(() => {
|
|
364
|
+
if (this.#runtime.closed)
|
|
365
|
+
return Effect.fail(new ClientClosedError());
|
|
366
|
+
const encoded = encodeMessageSearch(context, query);
|
|
367
|
+
if (encoded instanceof InputValidationFailure)
|
|
368
|
+
return Effect.fail(inputFailure(encoded.detail));
|
|
369
|
+
return this.#execute(token, {
|
|
370
|
+
method: "POST",
|
|
371
|
+
channel: encoded.context.channelId ?? encoded.context.guildId,
|
|
372
|
+
bucket: "search",
|
|
373
|
+
cache: false,
|
|
374
|
+
path: "/search/messages",
|
|
375
|
+
body: { json: encoded.json, files: [] },
|
|
376
|
+
status: 200,
|
|
377
|
+
decode: async (response, _instance, signal) => {
|
|
378
|
+
return readDecoded(response, signal, (value) => decodeMessageSearchPage(value, this.#decodeMessage));
|
|
379
|
+
},
|
|
380
|
+
}, options);
|
|
381
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, MessageOperationError, "search")));
|
|
382
|
+
}
|
|
383
|
+
edit(token, target, input, options) {
|
|
384
|
+
return this.#manage(token, "edit", target, input, options, (response, ref, signal) => readMessage(response, ref.channelId, ref.id, signal, this.#decodeMessage), (message, guard) => this.#runtime.cache.complete(guard, [message]));
|
|
385
|
+
}
|
|
386
|
+
delete(token, target, options) {
|
|
387
|
+
return this.#manage(token, "delete", target, undefined, options, async () => { });
|
|
388
|
+
}
|
|
389
|
+
deleteAttachment(token, target, attachmentId, options) {
|
|
390
|
+
return suspendInput(() => {
|
|
391
|
+
if (this.#runtime.closed)
|
|
392
|
+
return Effect.fail(new ClientClosedError());
|
|
393
|
+
const ref = snapshotReference(target);
|
|
394
|
+
if (ref === undefined)
|
|
395
|
+
return Effect.fail(localInputFailure("target", "format", "Message targets require decimal id and channelId strings"));
|
|
396
|
+
if (!identifier(attachmentId))
|
|
397
|
+
return Effect.fail(localInputFailure("attachmentId", "format", "Attachment IDs must be decimal strings"));
|
|
398
|
+
return this.#execute(token, {
|
|
399
|
+
method: "DELETE",
|
|
400
|
+
channel: ref.channelId,
|
|
401
|
+
target: ref.id,
|
|
402
|
+
path: `/channels/${ref.channelId}/messages/${ref.id}/attachments/${attachmentId}`,
|
|
403
|
+
body: undefined,
|
|
404
|
+
status: 204,
|
|
405
|
+
decode: async () => { },
|
|
406
|
+
}, options);
|
|
407
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, MessageOperationError, "deleteAttachment")));
|
|
408
|
+
}
|
|
409
|
+
deleteMany(token, channelId, ids, options) {
|
|
410
|
+
return suspendInput(() => {
|
|
411
|
+
if (this.#runtime.closed)
|
|
412
|
+
return Effect.fail(new ClientClosedError());
|
|
413
|
+
if (!identifier(channelId))
|
|
414
|
+
return Effect.fail(localInputFailure("channelId", "format", "Channel IDs must be decimal strings"));
|
|
415
|
+
if (!Array.isArray(ids))
|
|
416
|
+
return Effect.fail(localInputFailure("messageIds", "type", "Message IDs must be an array"));
|
|
417
|
+
// Copy the caller array once and validate the copy, so the validated IDs are the ones sent
|
|
418
|
+
const snapshot = snapshotArray(ids, 100);
|
|
419
|
+
if (snapshot === undefined || snapshot.length < 1)
|
|
420
|
+
return Effect.fail(localInputFailure("messageIds", "length", "Bulk deletion requires 1 through 100 message IDs"));
|
|
421
|
+
if (!snapshot.every(identifier))
|
|
422
|
+
return Effect.fail(localInputFailure("messageIds[]", "format", "Message IDs must be decimal strings"));
|
|
423
|
+
if (new Set(snapshot).size !== snapshot.length)
|
|
424
|
+
return Effect.fail(localInputFailure("messageIds", "unique", "Message IDs must be unique"));
|
|
425
|
+
const audit = auditSettings(options);
|
|
426
|
+
if (audit instanceof InputValidationFailure)
|
|
427
|
+
return Effect.fail(inputFailure(audit.detail));
|
|
428
|
+
return this.#execute(token, {
|
|
429
|
+
method: "POST",
|
|
430
|
+
channel: channelId,
|
|
431
|
+
bucket: "bulk-delete",
|
|
432
|
+
...(audit.auditReason === undefined ? {} : { auditReason: audit.auditReason }),
|
|
433
|
+
cache: false,
|
|
434
|
+
deleteIds: snapshot,
|
|
435
|
+
path: `/channels/${channelId}/messages/bulk-delete`,
|
|
436
|
+
body: { json: JSON.stringify({ message_ids: snapshot }), files: [] },
|
|
437
|
+
status: 204,
|
|
438
|
+
decode: async () => { },
|
|
439
|
+
}, options, [...operationOptionKeys, "auditReason"]);
|
|
440
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, MessageOperationError, "deleteMany")));
|
|
441
|
+
}
|
|
442
|
+
deleteOwnMessages(token, channelId, options) {
|
|
443
|
+
return suspendInput(() => {
|
|
444
|
+
if (this.#runtime.closed)
|
|
445
|
+
return Effect.fail(new ClientClosedError());
|
|
446
|
+
if (!identifier(channelId))
|
|
447
|
+
return Effect.fail(localInputFailure("channelId", "format", "Channel IDs must be decimal strings"));
|
|
448
|
+
const invalid = timeoutOptionsFailure(options);
|
|
449
|
+
if (invalid)
|
|
450
|
+
return Effect.fail(invalid);
|
|
451
|
+
return this.#execute(token, {
|
|
452
|
+
method: "POST",
|
|
453
|
+
channel: channelId,
|
|
454
|
+
bucket: "bulk-delete-mine",
|
|
455
|
+
cache: false,
|
|
456
|
+
invalidateMessages: true,
|
|
457
|
+
path: `/channels/${channelId}/messages/bulk-delete-mine`,
|
|
458
|
+
body: undefined,
|
|
459
|
+
status: 202,
|
|
460
|
+
decode: async () => { },
|
|
461
|
+
}, options);
|
|
462
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, MessageOperationError, "deleteOwnMessages")));
|
|
463
|
+
}
|
|
464
|
+
fetchReactionUsers(token, target, emoji, query, options) {
|
|
465
|
+
return suspendInput(() => {
|
|
466
|
+
if (this.#runtime.closed)
|
|
467
|
+
return Effect.fail(new ClientClosedError());
|
|
468
|
+
const encoded = encodeReactionEmoji(emoji);
|
|
469
|
+
const page = encodeReactionUsersQuery(query);
|
|
470
|
+
const ref = snapshotReference(target);
|
|
471
|
+
if (ref === undefined)
|
|
472
|
+
return Effect.fail(localInputFailure("target", "format", "Message targets require decimal id and channelId strings"));
|
|
473
|
+
if (encoded === undefined)
|
|
474
|
+
return Effect.fail(localInputFailure("emoji", "format", "Reaction emoji must be Unicode text or a custom emoji with a decimal ID"));
|
|
475
|
+
if (page instanceof InputValidationFailure)
|
|
476
|
+
return Effect.fail(inputFailure(page.detail));
|
|
477
|
+
return this.#execute(token, {
|
|
478
|
+
method: "GET",
|
|
479
|
+
channel: ref.channelId,
|
|
480
|
+
bucket: "reaction",
|
|
481
|
+
path: `/channels/${ref.channelId}/messages/${ref.id}/reactions/${encoded}/users?${page.params}`,
|
|
482
|
+
body: undefined,
|
|
483
|
+
status: 200,
|
|
484
|
+
decode: async (response, _instance, signal) => {
|
|
485
|
+
return readDecoded(response, signal, (value) => decodeReactionUsersPage(value, page));
|
|
486
|
+
},
|
|
487
|
+
}, options);
|
|
488
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, MessageOperationError, "fetchReactionUsers")));
|
|
489
|
+
}
|
|
490
|
+
fetchPins(token, channel, query, options) {
|
|
491
|
+
return suspendInput(() => {
|
|
492
|
+
if (this.#runtime.closed)
|
|
493
|
+
return Effect.fail(new ClientClosedError());
|
|
494
|
+
const page = encodePinsQuery(channel, query);
|
|
495
|
+
if (page instanceof InputValidationFailure)
|
|
496
|
+
return Effect.fail(inputFailure(page.detail));
|
|
497
|
+
return this.#execute(token, {
|
|
498
|
+
method: "GET",
|
|
499
|
+
channel,
|
|
500
|
+
bucket: "pins",
|
|
501
|
+
path: `/channels/${channel}/messages/pins?${page.params}`,
|
|
502
|
+
body: undefined,
|
|
503
|
+
status: 200,
|
|
504
|
+
decode: async (response, _instance, signal) => {
|
|
505
|
+
return readDecoded(response, signal, (value) => decodePinsPage(value, channel, page, this.#decodeMessage));
|
|
506
|
+
},
|
|
507
|
+
}, options);
|
|
508
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, MessageOperationError, "fetchPins")));
|
|
509
|
+
}
|
|
510
|
+
pin(token, operation, target, options) {
|
|
511
|
+
return suspendInput(() => {
|
|
512
|
+
if (this.#runtime.closed)
|
|
513
|
+
return Effect.fail(new ClientClosedError());
|
|
514
|
+
const ref = snapshotReference(target);
|
|
515
|
+
if (ref === undefined)
|
|
516
|
+
return Effect.fail(localInputFailure("target", "format", "Message targets require decimal id and channelId strings"));
|
|
517
|
+
const audit = auditSettings(options);
|
|
518
|
+
if (audit instanceof InputValidationFailure)
|
|
519
|
+
return Effect.fail(inputFailure(audit.detail));
|
|
520
|
+
return this.#execute(token, {
|
|
521
|
+
method: operation === "pin" ? "PUT" : "DELETE",
|
|
522
|
+
...(audit.auditReason === undefined ? {} : { auditReason: audit.auditReason }),
|
|
523
|
+
channel: ref.channelId,
|
|
524
|
+
target: ref.id,
|
|
525
|
+
bucket: "pins",
|
|
526
|
+
path: `/channels/${ref.channelId}/pins/${ref.id}`,
|
|
527
|
+
body: undefined,
|
|
528
|
+
status: 204,
|
|
529
|
+
decode: async () => { },
|
|
530
|
+
}, options, [...operationOptionKeys, "auditReason"]);
|
|
531
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, MessageOperationError, operation)));
|
|
532
|
+
}
|
|
533
|
+
reaction(token, operation, target, emoji, options, userId) {
|
|
534
|
+
return suspendInput(() => {
|
|
535
|
+
if (this.#runtime.closed)
|
|
536
|
+
return Effect.fail(new ClientClosedError());
|
|
537
|
+
const encoded = operation === "clearReactions" ? "" : encodeReactionEmoji(emoji);
|
|
538
|
+
const ref = snapshotReference(target);
|
|
539
|
+
if (ref === undefined)
|
|
540
|
+
return Effect.fail(localInputFailure("target", "format", "Message targets require decimal id and channelId strings"));
|
|
541
|
+
if (encoded === undefined)
|
|
542
|
+
return Effect.fail(localInputFailure("emoji", "format", "Reaction emoji must be Unicode text or a custom emoji with a decimal ID"));
|
|
543
|
+
if (operation === "removeUserReaction" && !identifier(userId))
|
|
544
|
+
return Effect.fail(localInputFailure("userId", "format", "User IDs must be decimal strings"));
|
|
545
|
+
const suffix = operation === "clearReactions"
|
|
546
|
+
? ""
|
|
547
|
+
: operation === "clearReaction"
|
|
548
|
+
? `/${encoded}`
|
|
549
|
+
: `/${encoded}/${operation === "removeUserReaction" ? userId : "@me"}`;
|
|
550
|
+
return this.#execute(token, {
|
|
551
|
+
method: operation === "addReaction" ? "PUT" : "DELETE",
|
|
552
|
+
channel: ref.channelId,
|
|
553
|
+
bucket: "reaction",
|
|
554
|
+
path: `/channels/${ref.channelId}/messages/${ref.id}/reactions${suffix}`,
|
|
555
|
+
body: undefined,
|
|
556
|
+
status: 204,
|
|
557
|
+
decode: async () => { },
|
|
558
|
+
}, options);
|
|
559
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, MessageOperationError, operation)));
|
|
560
|
+
}
|
|
561
|
+
#manage(token, operation, target, input, options, decode, observe) {
|
|
562
|
+
return suspendInput(() => {
|
|
563
|
+
if (this.#runtime.closed)
|
|
564
|
+
return Effect.fail(new ClientClosedError());
|
|
565
|
+
const ref = snapshotReference(target);
|
|
566
|
+
if (ref === undefined)
|
|
567
|
+
return Effect.fail(localInputFailure("target", "format", "Message targets require decimal id and channelId strings"));
|
|
568
|
+
const body = operation === "edit" ? encodeEdit(input) : undefined;
|
|
569
|
+
if (body instanceof InputValidationFailure)
|
|
570
|
+
return Effect.fail(inputFailure(body.detail));
|
|
571
|
+
const audit = operation === "delete" ? auditSettings(options) : undefined;
|
|
572
|
+
if (audit instanceof InputValidationFailure)
|
|
573
|
+
return Effect.fail(inputFailure(audit.detail));
|
|
574
|
+
return this.#execute(token, {
|
|
575
|
+
method: operation === "fetch" || operation === "fetchCrosspostSource"
|
|
576
|
+
? "GET"
|
|
577
|
+
: operation === "publish"
|
|
578
|
+
? "POST"
|
|
579
|
+
: operation === "edit"
|
|
580
|
+
? "PATCH"
|
|
581
|
+
: "DELETE",
|
|
582
|
+
channel: ref.channelId,
|
|
583
|
+
target: ref.id,
|
|
584
|
+
...(operation === "publish"
|
|
585
|
+
? { bucket: "channel:message:crosspost", messageMutation: true }
|
|
586
|
+
: operation === "fetchCrosspostSource"
|
|
587
|
+
? { bucket: "channel:message:crosspost_source", cache: false }
|
|
588
|
+
: {}),
|
|
589
|
+
path: `/channels/${ref.channelId}/messages/${ref.id}${operation === "publish"
|
|
590
|
+
? "/crosspost"
|
|
591
|
+
: operation === "fetchCrosspostSource"
|
|
592
|
+
? "/crosspost-source"
|
|
593
|
+
: ""}`,
|
|
594
|
+
body,
|
|
595
|
+
status: operation === "delete" ? 204 : 200,
|
|
596
|
+
...(audit?.auditReason === undefined ? {} : { auditReason: audit.auditReason }),
|
|
597
|
+
decode: (response, _instance, signal) => decode(response, ref, signal),
|
|
598
|
+
...(observe === undefined ? {} : { observe }),
|
|
599
|
+
}, options, operation === "delete" ? [...operationOptionKeys, "auditReason"] : operationOptionKeys);
|
|
600
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, MessageOperationError, operation)));
|
|
601
|
+
}
|
|
602
|
+
/** Run attempts for one request until it succeeds, fails permanently, runs out of read retries or passes its deadline */
|
|
603
|
+
#exchange(token, options) {
|
|
604
|
+
const runtime = this.#runtime;
|
|
605
|
+
const { request, progress, generation, deadline, retainedBytes = 0 } = options;
|
|
606
|
+
// A long pause can refuse every request on a route, so only the first refusal per route and minute is a Warn
|
|
607
|
+
const deadlineLevel = (template, retryAfterMs) => {
|
|
608
|
+
if (retryAfterMs < longRateLimitWaitMs)
|
|
609
|
+
return "debug";
|
|
610
|
+
const now = runtime.logical.now();
|
|
611
|
+
const last = runtime.deadlineWarnedAt.get(template);
|
|
612
|
+
if (last !== undefined && now - last < busyWarnIntervalMs)
|
|
613
|
+
return "debug";
|
|
614
|
+
for (const [warned, at] of runtime.deadlineWarnedAt)
|
|
615
|
+
if (now - at >= busyWarnIntervalMs)
|
|
616
|
+
runtime.deadlineWarnedAt.delete(warned);
|
|
617
|
+
runtime.deadlineWarnedAt.set(template, now);
|
|
618
|
+
return "warn";
|
|
619
|
+
};
|
|
620
|
+
const route = rateRoute(request.method, request.path, request.channel, request.bucket, request.webhookId);
|
|
621
|
+
const template = request.template ?? routeTemplate(request.put ? "/attachments/upload" : request.path, request.webhookId);
|
|
622
|
+
const bytes = retainedBytes + Buffer.byteLength(request.body?.json ?? "");
|
|
623
|
+
return Effect.gen(function* () {
|
|
624
|
+
const fiber = yield* Effect.withFiber((fiber) => Effect.succeed(fiber));
|
|
625
|
+
let retries = 0;
|
|
626
|
+
let attempts = 0;
|
|
627
|
+
let until = 0;
|
|
628
|
+
while (true) {
|
|
629
|
+
const retryCount = attempts++;
|
|
630
|
+
const attempt = yield* Effect.uninterruptibleMask((restore) => Effect.exit(restore(Effect.acquireUseRelease(Effect.interruptible(runtime.admission.acquire({ route: route.key, bytes, until, deadline })).pipe(mapFailureCause((error) => error instanceof RestFailure ? error.withOutcome(progress.outcome) : error)), () => runtime.logical.now() >= deadline
|
|
631
|
+
? Effect.fail(new RestFailure({ reason: "timeout", outcome: progress.outcome }))
|
|
632
|
+
: runAttempt({
|
|
633
|
+
runtime,
|
|
634
|
+
token,
|
|
635
|
+
request,
|
|
636
|
+
route,
|
|
637
|
+
progress,
|
|
638
|
+
generation,
|
|
639
|
+
fiber,
|
|
640
|
+
retryCount,
|
|
641
|
+
}), (release) => Effect.sync(release)))).pipe(Effect.flatMap((exit) => Exit.isFailure(exit) && (Cause.hasDies(exit.cause) || Cause.hasInterrupts(exit.cause))
|
|
642
|
+
? Effect.failCause(exit.cause)
|
|
643
|
+
: Effect.succeed(exit))));
|
|
644
|
+
if (Exit.isFailure(attempt)) {
|
|
645
|
+
const reason = attempt.cause.reasons.find((reason) => reason._tag === "Fail");
|
|
646
|
+
if (reason?._tag !== "Fail")
|
|
647
|
+
return yield* Effect.die(new Error("REST request failed without a cause"));
|
|
648
|
+
const error = reason.error;
|
|
649
|
+
// Admission fails a request whose learned wait outlasts its deadline. That is the only rate-limit
|
|
650
|
+
// failure without an HTTP status, and it is logged like a 429 whose wait passes the deadline
|
|
651
|
+
if (error instanceof RestFailure &&
|
|
652
|
+
error.reason === "rateLimit" &&
|
|
653
|
+
error.status === null &&
|
|
654
|
+
error.retryAfterMs !== null)
|
|
655
|
+
runtime.logging?.log({
|
|
656
|
+
level: deadlineLevel(template, error.retryAfterMs),
|
|
657
|
+
category: "ratelimit",
|
|
658
|
+
code: "ratelimit.deadline",
|
|
659
|
+
message: `${request.method} ${template} is rate-limited for another ${error.retryAfterMs} ms, which is past its timeout, so it fails without waiting`,
|
|
660
|
+
route: template,
|
|
661
|
+
delayMs: error.retryAfterMs,
|
|
662
|
+
fields: { method: request.method },
|
|
663
|
+
}, fiber.context);
|
|
664
|
+
// An unusable success response usually means a Fluxer schema change or a wrong test fixture,
|
|
665
|
+
// so it is logged once per route and field, mirroring gateway.dispatchRejected. A caller-described
|
|
666
|
+
// route has no expected shape, so its failure is only returned to the caller
|
|
667
|
+
if (error instanceof RestFailure && error.reason === "response" && !request.callerDescribed)
|
|
668
|
+
runtime.logging?.log({
|
|
669
|
+
level: "warn",
|
|
670
|
+
category: "rest",
|
|
671
|
+
code: "rest.responseRejected",
|
|
672
|
+
message: `${request.method} ${template} returned an answer in an unexpected format${error.responseField === null ? "" : `: ${responseFieldText(error.responseField)}`}`,
|
|
673
|
+
route: template,
|
|
674
|
+
...(error.status === null ? {} : { status: error.status }),
|
|
675
|
+
fields: { method: request.method, field: error.responseField ?? undefined },
|
|
676
|
+
}, fiber.context);
|
|
677
|
+
if (request.method !== "GET" ||
|
|
678
|
+
!(error instanceof RestFailure) ||
|
|
679
|
+
!error.retryableRead ||
|
|
680
|
+
retries === maximumReadRetries)
|
|
681
|
+
return yield* Effect.fail(error);
|
|
682
|
+
const minimum = retries++ === 0 ? firstReadRetryMs : laterReadRetryMs;
|
|
683
|
+
const delay = Math.max(minimum * (1 + (yield* Random.next)), error.retryAfterMs ?? 0);
|
|
684
|
+
// A retry that cannot start before the deadline would only end as a timeout, so the received failure is returned now
|
|
685
|
+
if (runtime.logical.now() + Math.ceil(delay) >= deadline)
|
|
686
|
+
return yield* Effect.fail(error);
|
|
687
|
+
until = runtime.logical.now() + Math.ceil(delay);
|
|
688
|
+
runtime.logging?.drop("restRetries", {
|
|
689
|
+
level: "debug",
|
|
690
|
+
category: "rest",
|
|
691
|
+
code: "rest.retry",
|
|
692
|
+
message: `Retrying ${request.method} ${template} after ${error.status === null ? `a ${error.reason} failure` : `HTTP ${error.status}`} in ${Math.ceil(delay)} ms`,
|
|
693
|
+
route: template,
|
|
694
|
+
attempt: attempts + 1,
|
|
695
|
+
delayMs: Math.ceil(delay),
|
|
696
|
+
...(error.status === null ? {} : { status: error.status }),
|
|
697
|
+
fields: { method: request.method, reason: error.reason },
|
|
698
|
+
}, fiber.context);
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
701
|
+
const response = attempt.value;
|
|
702
|
+
if (response.kind === "success")
|
|
703
|
+
return response.value;
|
|
704
|
+
if ((request.inlineAttachments || request.webhookId) &&
|
|
705
|
+
request.sources?.some((source) => !source.replayable))
|
|
706
|
+
return yield* Effect.fail(new RestFailure({
|
|
707
|
+
reason: "rateLimit",
|
|
708
|
+
outcome: progress.outcome,
|
|
709
|
+
status: 429,
|
|
710
|
+
retryAfterMs: response.retry,
|
|
711
|
+
apiError: response.apiError,
|
|
712
|
+
providerCode: response.providerCode ?? null,
|
|
713
|
+
}));
|
|
714
|
+
until = runtime.logical.now() + response.retry;
|
|
715
|
+
if (response.global)
|
|
716
|
+
runtime.admission.pauseGlobal(until);
|
|
717
|
+
if (until >= deadline) {
|
|
718
|
+
// No wait happens: The request fails now, so this is not counted as a rate-limit wait
|
|
719
|
+
runtime.logging?.log({
|
|
720
|
+
level: response.retry >= longRateLimitWaitMs ? "warn" : "debug",
|
|
721
|
+
category: "ratelimit",
|
|
722
|
+
code: "ratelimit.deadline",
|
|
723
|
+
message: `${request.method} ${template} was rate-limited${response.global ? " globally" : ""} for ${response.retry} ms, which is past its timeout, so it fails without waiting`,
|
|
724
|
+
route: template,
|
|
725
|
+
status: 429,
|
|
726
|
+
delayMs: response.retry,
|
|
727
|
+
attempt: attempts,
|
|
728
|
+
fields: { method: request.method, global: response.global },
|
|
729
|
+
}, fiber.context);
|
|
730
|
+
return yield* Effect.fail(new RestFailure({
|
|
731
|
+
reason: "rateLimit",
|
|
732
|
+
outcome: progress.outcome,
|
|
733
|
+
status: 429,
|
|
734
|
+
retryAfterMs: response.retry,
|
|
735
|
+
apiError: response.apiError,
|
|
736
|
+
providerCode: response.providerCode ?? null,
|
|
737
|
+
}));
|
|
738
|
+
}
|
|
739
|
+
metrics.rateLimitWait(response.retry, fiber.context);
|
|
740
|
+
emitObservation(runtime.logging, {
|
|
741
|
+
type: "rateLimit",
|
|
742
|
+
method: request.method,
|
|
743
|
+
route: template,
|
|
744
|
+
waitMs: response.retry,
|
|
745
|
+
global: response.global,
|
|
746
|
+
});
|
|
747
|
+
runtime.logging?.drop("rateLimitWaits", {
|
|
748
|
+
level: response.retry >= longRateLimitWaitMs ? "warn" : "debug",
|
|
749
|
+
category: "ratelimit",
|
|
750
|
+
code: "ratelimit.wait",
|
|
751
|
+
message: `${request.method} ${template} was rate-limited${response.global ? " globally" : ""}, so it waits ${response.retry} ms before retrying`,
|
|
752
|
+
route: template,
|
|
753
|
+
status: 429,
|
|
754
|
+
delayMs: response.retry,
|
|
755
|
+
attempt: attempts,
|
|
756
|
+
fields: { method: request.method, global: response.global },
|
|
757
|
+
}, fiber.context);
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
/** Plan and upload attachment files through presigned destinations, or fall back to inline multipart */
|
|
762
|
+
#prepareUploads(token, body, sources, context) {
|
|
763
|
+
const owner = this;
|
|
764
|
+
const { channel, instance, progress, generation, deadline } = context;
|
|
765
|
+
return Effect.gen(function* () {
|
|
766
|
+
const inline = () => {
|
|
767
|
+
const payload = JSON.parse(body.json);
|
|
768
|
+
payload.attachments = payload.attachments.map((item) => {
|
|
769
|
+
const file = body.files.find((file) => file.id === item.id);
|
|
770
|
+
if (!file)
|
|
771
|
+
return item;
|
|
772
|
+
return { ...item, filename: file.filename, content_type: file.contentType };
|
|
773
|
+
});
|
|
774
|
+
body.json = JSON.stringify(payload);
|
|
775
|
+
return "inline";
|
|
776
|
+
};
|
|
777
|
+
if (!instance.presignedAttachmentUploads)
|
|
778
|
+
return inline();
|
|
779
|
+
const retainedBytes = Buffer.byteLength(body.json);
|
|
780
|
+
const attachments = body.files.map((file) => ({
|
|
781
|
+
id: file.id,
|
|
782
|
+
filename: file.filename,
|
|
783
|
+
file_size: file.size,
|
|
784
|
+
content_type: file.contentType,
|
|
785
|
+
}));
|
|
786
|
+
const planned = yield* owner.#exchange(token, {
|
|
787
|
+
request: {
|
|
788
|
+
method: "POST",
|
|
789
|
+
channel,
|
|
790
|
+
bucket: "upload",
|
|
791
|
+
preparation: true,
|
|
792
|
+
instance,
|
|
793
|
+
path: `/channels/${channel}/attachments`,
|
|
794
|
+
body: { json: JSON.stringify({ attachments }), files: [] },
|
|
795
|
+
decode: async (response, _instance, signal) => {
|
|
796
|
+
const plans = decodeUploadPlans(await readResponseJson(response, uploadResponseMaxBytes, signal), body.files, instance.allowInsecure);
|
|
797
|
+
if (!plans)
|
|
798
|
+
throw new RestFailure({
|
|
799
|
+
reason: "response",
|
|
800
|
+
outcome: "notDispatched",
|
|
801
|
+
status: response.status,
|
|
802
|
+
});
|
|
803
|
+
return { kind: "plans", plans };
|
|
804
|
+
},
|
|
805
|
+
featureDisabled: () => ({ kind: "disabled" }),
|
|
806
|
+
},
|
|
807
|
+
progress,
|
|
808
|
+
generation,
|
|
809
|
+
deadline,
|
|
810
|
+
retainedBytes,
|
|
811
|
+
});
|
|
812
|
+
if (planned.kind === "disabled")
|
|
813
|
+
return inline();
|
|
814
|
+
const plans = planned.plans;
|
|
815
|
+
// Charge retained plan capabilities too while queued. They are never exposed as diagnostics
|
|
816
|
+
const queuedBytes = retainedBytes + Buffer.byteLength(JSON.stringify(plans));
|
|
817
|
+
for (const plan of plans) {
|
|
818
|
+
const file = body.files.find((file) => file.id === plan.id);
|
|
819
|
+
const source = sources[body.files.indexOf(file)];
|
|
820
|
+
if (!source)
|
|
821
|
+
return yield* Effect.fail(new RestFailure({ reason: "response", outcome: "notDispatched" }));
|
|
822
|
+
for (const part of plan.parts) {
|
|
823
|
+
yield* owner.#exchange(token, {
|
|
824
|
+
request: {
|
|
825
|
+
method: "PUT",
|
|
826
|
+
channel,
|
|
827
|
+
preparation: true,
|
|
828
|
+
instance,
|
|
829
|
+
path: "",
|
|
830
|
+
body: undefined,
|
|
831
|
+
put: {
|
|
832
|
+
...part,
|
|
833
|
+
source,
|
|
834
|
+
...(plan.uploadId ? {} : { contentType: plan.contentType }),
|
|
835
|
+
},
|
|
836
|
+
decode: async () => { },
|
|
837
|
+
},
|
|
838
|
+
progress,
|
|
839
|
+
generation,
|
|
840
|
+
deadline,
|
|
841
|
+
retainedBytes: queuedBytes,
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
const uploads = plans
|
|
846
|
+
.filter((plan) => plan.uploadId !== undefined)
|
|
847
|
+
.map((plan) => ({ upload_filename: plan.key, upload_id: plan.uploadId }));
|
|
848
|
+
if (uploads.length)
|
|
849
|
+
yield* owner.#exchange(token, {
|
|
850
|
+
request: {
|
|
851
|
+
method: "POST",
|
|
852
|
+
channel,
|
|
853
|
+
bucket: "upload",
|
|
854
|
+
preparation: true,
|
|
855
|
+
instance,
|
|
856
|
+
path: `/channels/${channel}/attachments/complete`,
|
|
857
|
+
body: { json: JSON.stringify({ uploads }), files: [] },
|
|
858
|
+
decode: async (response, _instance, signal) => {
|
|
859
|
+
const value = await readResponseJson(response, uploadResponseMaxBytes, signal);
|
|
860
|
+
if (!record(value) ||
|
|
861
|
+
!Array.isArray(value.uploads) ||
|
|
862
|
+
value.uploads.length !== uploads.length ||
|
|
863
|
+
uploads.some((upload) => !Array.isArray(value.uploads) ||
|
|
864
|
+
value.uploads.filter((item) => record(item) && item.upload_filename === upload.upload_filename).length !== 1))
|
|
865
|
+
throw new RestFailure({
|
|
866
|
+
reason: "response",
|
|
867
|
+
outcome: "notDispatched",
|
|
868
|
+
status: response.status,
|
|
869
|
+
});
|
|
870
|
+
},
|
|
871
|
+
},
|
|
872
|
+
progress,
|
|
873
|
+
generation,
|
|
874
|
+
deadline,
|
|
875
|
+
retainedBytes: queuedBytes,
|
|
876
|
+
});
|
|
877
|
+
const payload = JSON.parse(body.json);
|
|
878
|
+
payload.attachments = payload.attachments.map((item) => {
|
|
879
|
+
const plan = plans.find((plan) => plan.id === item.id);
|
|
880
|
+
if (!plan)
|
|
881
|
+
return item;
|
|
882
|
+
const file = body.files.find((file) => file.id === plan.id);
|
|
883
|
+
return {
|
|
884
|
+
...item,
|
|
885
|
+
filename: plan.filename,
|
|
886
|
+
content_type: plan.contentType,
|
|
887
|
+
file_size: file.size,
|
|
888
|
+
upload_filename: plan.key,
|
|
889
|
+
};
|
|
890
|
+
});
|
|
891
|
+
body.json = JSON.stringify(payload);
|
|
892
|
+
return "preuploaded";
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
guild(token, operation, build, options) {
|
|
896
|
+
return suspendInput(() => {
|
|
897
|
+
if (this.#runtime.closed)
|
|
898
|
+
return Effect.fail(new ClientClosedError());
|
|
899
|
+
const input = build();
|
|
900
|
+
if (input instanceof InputValidationFailure)
|
|
901
|
+
return Effect.fail(inputFailure(input.detail));
|
|
902
|
+
if (options !== undefined && !record(options))
|
|
903
|
+
return Effect.fail(localInputFailure("options", "type", "Operation options must be an object"));
|
|
904
|
+
const audit = input.audited ? auditSettings(options) : undefined;
|
|
905
|
+
if (audit instanceof InputValidationFailure)
|
|
906
|
+
return Effect.fail(inputFailure(audit.detail));
|
|
907
|
+
const auditReason = input.auditReason ?? audit?.auditReason;
|
|
908
|
+
const acceptedOptions = [
|
|
909
|
+
"timeoutMs",
|
|
910
|
+
"signal",
|
|
911
|
+
...(input.moderation || input.audited ? ["auditReason"] : []),
|
|
912
|
+
...(input.timeoutReason ? ["timeoutReason"] : []),
|
|
913
|
+
...(input.method === "DELETE" && ["guild:emojis", "guild:stickers"].includes(input.bucket)
|
|
914
|
+
? ["purge"]
|
|
915
|
+
: []),
|
|
916
|
+
];
|
|
917
|
+
return this.#execute(token, {
|
|
918
|
+
// The scheduler's major-resource key is the guild here, never a message-cache channel
|
|
919
|
+
channel: input.guildId,
|
|
920
|
+
bucket: input.bucket,
|
|
921
|
+
cache: false,
|
|
922
|
+
...(input.cache === undefined ? {} : { resourceCache: input.cache }),
|
|
923
|
+
...(input.channelCache === undefined ? {} : { channelCache: input.channelCache }),
|
|
924
|
+
...(input.moderation === undefined ? {} : { moderation: input.moderation }),
|
|
925
|
+
...(auditReason === undefined ? {} : { auditReason }),
|
|
926
|
+
...(input.deleteAuthorId === undefined ? {} : { deleteAuthorId: input.deleteAuthorId }),
|
|
927
|
+
...(input.invalidateMessages === undefined ? {} : { invalidateMessages: input.invalidateMessages }),
|
|
928
|
+
...(input.features === undefined ? {} : { features: input.features }),
|
|
929
|
+
path: input.path,
|
|
930
|
+
method: input.method,
|
|
931
|
+
status: input.status,
|
|
932
|
+
body: input.json === undefined ? undefined : { json: input.json, files: [] },
|
|
933
|
+
decode: async (response, instance, signal) => {
|
|
934
|
+
if (input.status === 202 || input.status === 204)
|
|
935
|
+
return undefined;
|
|
936
|
+
return readDecoded(response, signal, (value) => input.decode(value, instance));
|
|
937
|
+
},
|
|
938
|
+
}, options, acceptedOptions);
|
|
939
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, GuildOperationError, operation)));
|
|
940
|
+
}
|
|
941
|
+
channel(token, operation, build, options) {
|
|
942
|
+
return suspendInput(() => {
|
|
943
|
+
if (this.#runtime.closed)
|
|
944
|
+
return Effect.fail(new ClientClosedError());
|
|
945
|
+
const input = build();
|
|
946
|
+
if (input instanceof InputValidationFailure)
|
|
947
|
+
return Effect.fail(inputFailure(input.detail));
|
|
948
|
+
if (options !== undefined && !record(options))
|
|
949
|
+
return Effect.fail(localInputFailure("options", "type", "Operation options must be an object"));
|
|
950
|
+
const audit = input.audited ? auditSettings(options) : undefined;
|
|
951
|
+
if (audit instanceof InputValidationFailure)
|
|
952
|
+
return Effect.fail(inputFailure(audit.detail));
|
|
953
|
+
const acceptedOptions = input.audited ? [...operationOptionKeys, "auditReason"] : operationOptionKeys;
|
|
954
|
+
const accepted = input.accepted;
|
|
955
|
+
return this.#execute(token, {
|
|
956
|
+
channel: input.majorId,
|
|
957
|
+
bucket: input.bucket,
|
|
958
|
+
cache: false,
|
|
959
|
+
...(input.cache === undefined ? {} : { channelCache: input.cache }),
|
|
960
|
+
...(audit?.auditReason === undefined ? {} : { auditReason: audit.auditReason }),
|
|
961
|
+
...(input.features === undefined ? {} : { features: input.features }),
|
|
962
|
+
path: input.path,
|
|
963
|
+
method: input.method,
|
|
964
|
+
// A route that can also answer 202 has its status checked here instead
|
|
965
|
+
...(accepted === undefined ? { status: input.status } : {}),
|
|
966
|
+
body: input.body ?? (input.json === undefined ? undefined : { json: input.json, files: [] }),
|
|
967
|
+
// Presigned uploads rewrite top-level attachments, while a forum post nests them in its message
|
|
968
|
+
...(input.body?.files.length ? { inlineAttachments: true } : {}),
|
|
969
|
+
decode: async (response, _instance, signal) => {
|
|
970
|
+
if (input.status === 204)
|
|
971
|
+
return undefined;
|
|
972
|
+
if (accepted !== undefined && response.status === 202)
|
|
973
|
+
return readDecoded(response, signal, (value) => accepted(value));
|
|
974
|
+
if (response.status !== input.status)
|
|
975
|
+
throw responseFailure(response, "status");
|
|
976
|
+
return readDecoded(response, signal, (value) => input.decode(value));
|
|
977
|
+
},
|
|
978
|
+
}, options, acceptedOptions);
|
|
979
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, ChannelOperationError, operation)));
|
|
980
|
+
}
|
|
981
|
+
user(token, operation, build, options) {
|
|
982
|
+
return suspendInput(() => {
|
|
983
|
+
if (this.#runtime.closed)
|
|
984
|
+
return Effect.fail(new ClientClosedError());
|
|
985
|
+
const input = build();
|
|
986
|
+
if (input instanceof InputValidationFailure)
|
|
987
|
+
return Effect.fail(inputFailure(input.detail));
|
|
988
|
+
const invalid = timeoutOptionsFailure(options);
|
|
989
|
+
if (invalid)
|
|
990
|
+
return Effect.fail(invalid);
|
|
991
|
+
return this.#execute(token, {
|
|
992
|
+
channel: input.majorId,
|
|
993
|
+
bucket: `user:${operation}`,
|
|
994
|
+
cache: false,
|
|
995
|
+
path: input.path,
|
|
996
|
+
method: input.method,
|
|
997
|
+
status: input.status,
|
|
998
|
+
body: input.json === undefined ? undefined : { json: input.json, files: [] },
|
|
999
|
+
decode: async (response, _instance, signal) => {
|
|
1000
|
+
if (input.status === 204)
|
|
1001
|
+
return undefined;
|
|
1002
|
+
return readDecoded(response, signal, (value) => input.decode(value));
|
|
1003
|
+
},
|
|
1004
|
+
}, options);
|
|
1005
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, UserOperationError, operation)));
|
|
1006
|
+
}
|
|
1007
|
+
application(token, operation, build, options) {
|
|
1008
|
+
return suspendInput(() => {
|
|
1009
|
+
if (this.#runtime.closed)
|
|
1010
|
+
return Effect.fail(new ClientClosedError());
|
|
1011
|
+
const input = build();
|
|
1012
|
+
const invalid = timeoutOptionsFailure(options);
|
|
1013
|
+
if (invalid)
|
|
1014
|
+
return Effect.fail(invalid);
|
|
1015
|
+
return this.#execute(token, {
|
|
1016
|
+
channel: "application",
|
|
1017
|
+
bucket: "application:current",
|
|
1018
|
+
cache: false,
|
|
1019
|
+
path: input.path,
|
|
1020
|
+
method: input.method,
|
|
1021
|
+
status: input.status,
|
|
1022
|
+
body: undefined,
|
|
1023
|
+
decode: async (response, _instance, signal) => {
|
|
1024
|
+
return readDecoded(response, signal, (value) => input.decode(value));
|
|
1025
|
+
},
|
|
1026
|
+
}, options);
|
|
1027
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, BotApplicationOperationError, operation)));
|
|
1028
|
+
}
|
|
1029
|
+
webhook(token, operation, build, options) {
|
|
1030
|
+
return suspendInput(() => {
|
|
1031
|
+
if (this.#runtime.closed)
|
|
1032
|
+
return Effect.fail(new ClientClosedError());
|
|
1033
|
+
const input = build();
|
|
1034
|
+
if (input instanceof InputValidationFailure)
|
|
1035
|
+
return Effect.fail(inputFailure(input.detail));
|
|
1036
|
+
if (options !== undefined && !record(options))
|
|
1037
|
+
return Effect.fail(localInputFailure("options", "type", "Operation options must be an object"));
|
|
1038
|
+
const acceptedOptions = input.method !== "GET" && !input.tokenAuth
|
|
1039
|
+
? [...operationOptionKeys, "auditReason"]
|
|
1040
|
+
: input.threadOption
|
|
1041
|
+
? [...operationOptionKeys, "threadId"]
|
|
1042
|
+
: operationOptionKeys;
|
|
1043
|
+
return this.#execute(token, {
|
|
1044
|
+
channel: input.majorId,
|
|
1045
|
+
bucket: `webhook:${input.tokenAuth ? "token" : operation}`,
|
|
1046
|
+
cache: false,
|
|
1047
|
+
...(input.tokenAuth ? { webhookId: input.majorId } : {}),
|
|
1048
|
+
...(input.auditReason === undefined ? {} : { auditReason: input.auditReason }),
|
|
1049
|
+
path: input.path,
|
|
1050
|
+
method: input.method,
|
|
1051
|
+
status: input.status,
|
|
1052
|
+
body: input.body,
|
|
1053
|
+
decode: async (response, _instance, signal) => {
|
|
1054
|
+
if (input.status === 204)
|
|
1055
|
+
return undefined;
|
|
1056
|
+
return readDecoded(response, signal, (value) => input.decode(value));
|
|
1057
|
+
},
|
|
1058
|
+
}, options, acceptedOptions);
|
|
1059
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, WebhookOperationError, operation)));
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* Validate the options and deadline, reserve upload bytes, register cache guards and run the operation to completion.
|
|
1063
|
+
* The options may contain only optionKeys, which each operation family lists beside its own validation
|
|
1064
|
+
*/
|
|
1065
|
+
#execute(token, request, options, optionKeys = operationOptionKeys) {
|
|
1066
|
+
const owner = this;
|
|
1067
|
+
const runtime = this.#runtime;
|
|
1068
|
+
return Effect.suspend(() => {
|
|
1069
|
+
if (runtime.closed)
|
|
1070
|
+
return Effect.fail(new ClientClosedError());
|
|
1071
|
+
let requested;
|
|
1072
|
+
let unsupported;
|
|
1073
|
+
try {
|
|
1074
|
+
requested = deadlineOption(options);
|
|
1075
|
+
unsupported = unsupportedOptionFailure(options, optionKeys);
|
|
1076
|
+
}
|
|
1077
|
+
catch (error) {
|
|
1078
|
+
return Effect.failCause(inputDefect(error));
|
|
1079
|
+
}
|
|
1080
|
+
if (!requested.valid)
|
|
1081
|
+
return Effect.fail(localInputFailure("options", "type", "Operation options must be an object"));
|
|
1082
|
+
if (unsupported)
|
|
1083
|
+
return Effect.fail(unsupported);
|
|
1084
|
+
const timeout = requested.timeoutMs === undefined ? runtime.settings.defaultTimeoutMs : requested.timeoutMs;
|
|
1085
|
+
if (typeof timeout !== "number" ||
|
|
1086
|
+
!Number.isSafeInteger(timeout) ||
|
|
1087
|
+
timeout <= 0 ||
|
|
1088
|
+
timeout > maximumTimerMs)
|
|
1089
|
+
return Effect.fail(localInputFailure("options.timeoutMs", "range", "Operation timeoutMs must be an integer from 1 through 2,147,483,647 ms"));
|
|
1090
|
+
const bytes = Buffer.byteLength(request.body?.json ?? "");
|
|
1091
|
+
const uploadBytes = request.body?.files.reduce((sum, file) => sum + file.size, 0) ?? 0;
|
|
1092
|
+
if (!Number.isSafeInteger(uploadBytes) || uploadBytes > owner.#uploadMaxBytes - runtime.uploadBytes) {
|
|
1093
|
+
runtime.busy("uploads");
|
|
1094
|
+
return Effect.fail(new RestFailure({ reason: "busy", outcome: "notDispatched" }));
|
|
1095
|
+
}
|
|
1096
|
+
// Check JSON/count admission before allocating binary snapshots, then reserve before any wait
|
|
1097
|
+
if (!runtime.admission.hasRoom(bytes)) {
|
|
1098
|
+
runtime.busy("queue");
|
|
1099
|
+
return Effect.fail(new RestFailure({ reason: "busy", outcome: "notDispatched" }));
|
|
1100
|
+
}
|
|
1101
|
+
runtime.uploadBytes += uploadBytes;
|
|
1102
|
+
try {
|
|
1103
|
+
if (request.body) {
|
|
1104
|
+
request.body.files = request.body.files.map((file) => ({
|
|
1105
|
+
...file,
|
|
1106
|
+
source: file.source.kind === "bytes"
|
|
1107
|
+
? { kind: "bytes", data: new Uint8Array(file.source.data) }
|
|
1108
|
+
: file.source,
|
|
1109
|
+
}));
|
|
1110
|
+
request.sources = request.body.files.map((file) => new AttachmentTransferSource(file));
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
catch {
|
|
1114
|
+
// allow-silent: An unreadable caller source becomes the typed input failure returned below
|
|
1115
|
+
runtime.uploadBytes -= uploadBytes;
|
|
1116
|
+
return Effect.fail(localInputFailure("attachments[].data", "type", "Attachment byte data must stay readable until the operation has copied it"));
|
|
1117
|
+
}
|
|
1118
|
+
const deadline = runtime.logical.now() + timeout;
|
|
1119
|
+
const generation = runtime.cache?.generation ?? 0;
|
|
1120
|
+
const progress = { outcome: "notDispatched" };
|
|
1121
|
+
const deletionGuard = request.deleteIds && runtime.cache?.begin(request.channel, undefined, true, generation);
|
|
1122
|
+
// Register before discovery and queue/rate waits so events, writes and gaps invalidate the whole operation
|
|
1123
|
+
const resourceGuard = request.resourceCache && runtime.resources?.begin(request.resourceCache);
|
|
1124
|
+
if (resourceGuard)
|
|
1125
|
+
request = { ...request, resourceGuard };
|
|
1126
|
+
const channelGuard = request.channelCache && runtime.channels?.begin(request.channelCache);
|
|
1127
|
+
if (channelGuard)
|
|
1128
|
+
request = { ...request, channelGuard };
|
|
1129
|
+
const operation = Deferred.makeUnsafe();
|
|
1130
|
+
runtime.operations.add(operation);
|
|
1131
|
+
return Effect.gen(function* () {
|
|
1132
|
+
const resolved = runtime.instance;
|
|
1133
|
+
const instance = resolved ??
|
|
1134
|
+
(yield* Effect.acquireUseRelease(
|
|
1135
|
+
// Discovery is not an API request, so a global pause, such as one another child learned,
|
|
1136
|
+
// cannot hold it past the operation's deadline
|
|
1137
|
+
Effect.interruptible(runtime.admission.acquire({ route: "discovery", bytes, rateLimited: false })), () => runtime.resolveInstance(), (release) => Effect.sync(release)).pipe(mapFailureCause(instanceFailure)));
|
|
1138
|
+
if (!resolved)
|
|
1139
|
+
runtime.instance = instance;
|
|
1140
|
+
request = { ...request, instance };
|
|
1141
|
+
if (request.directMessageUser !== undefined) {
|
|
1142
|
+
const open = directMessageOpen(request.directMessageUser);
|
|
1143
|
+
if (open instanceof InputValidationFailure)
|
|
1144
|
+
return yield* Effect.fail(inputFailure(open.detail));
|
|
1145
|
+
const userGuard = runtime.users?.begin("directMessages", { mutation: true });
|
|
1146
|
+
const channel = yield* owner
|
|
1147
|
+
.#exchange(token, {
|
|
1148
|
+
request: {
|
|
1149
|
+
method: "POST",
|
|
1150
|
+
channel: "@me",
|
|
1151
|
+
bucket: "user:directMessages.open",
|
|
1152
|
+
cache: false,
|
|
1153
|
+
instance,
|
|
1154
|
+
path: open.path,
|
|
1155
|
+
body: { json: open.json, files: [] },
|
|
1156
|
+
status: 200,
|
|
1157
|
+
preparation: true,
|
|
1158
|
+
decode: async (response, _instance, signal) => {
|
|
1159
|
+
const channel = open.decode(await readResponseJson(response, undefined, signal));
|
|
1160
|
+
if (!channel)
|
|
1161
|
+
throw new RestFailure({
|
|
1162
|
+
reason: "response",
|
|
1163
|
+
outcome: "notDispatched",
|
|
1164
|
+
status: response.status,
|
|
1165
|
+
});
|
|
1166
|
+
return channel;
|
|
1167
|
+
},
|
|
1168
|
+
},
|
|
1169
|
+
progress: { outcome: "notDispatched" },
|
|
1170
|
+
generation,
|
|
1171
|
+
deadline,
|
|
1172
|
+
retainedBytes: bytes,
|
|
1173
|
+
})
|
|
1174
|
+
.pipe(mapFailureCause((error) => error instanceof RestFailure ? error.withOutcome("notDispatched") : error), Effect.onExit((exit) => Effect.sync(() => {
|
|
1175
|
+
if (exit._tag === "Failure" && userGuard !== undefined)
|
|
1176
|
+
runtime.users.failed(userGuard);
|
|
1177
|
+
})));
|
|
1178
|
+
if (userGuard !== undefined)
|
|
1179
|
+
runtime.users.complete(userGuard, [channel]);
|
|
1180
|
+
request = {
|
|
1181
|
+
...request,
|
|
1182
|
+
channel: channel.id,
|
|
1183
|
+
path: `/channels/${channel.id}/messages`,
|
|
1184
|
+
decode: (response, _instance, signal) => request.decodeDirectMessage(response, channel.id, signal),
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
if (request.body?.files.length && !request.webhookId && !request.inlineAttachments) {
|
|
1188
|
+
const uploadMode = yield* owner.#prepareUploads(token, request.body, request.sources ?? [], {
|
|
1189
|
+
channel: request.channel,
|
|
1190
|
+
instance,
|
|
1191
|
+
progress,
|
|
1192
|
+
generation,
|
|
1193
|
+
deadline,
|
|
1194
|
+
});
|
|
1195
|
+
if (uploadMode === "inline")
|
|
1196
|
+
request = { ...request, inlineAttachments: true };
|
|
1197
|
+
}
|
|
1198
|
+
return yield* owner.#exchange(token, { request, progress, generation, deadline });
|
|
1199
|
+
}).pipe(withDeadline(timeout, () => new RestFailure({ reason: "timeout", outcome: progress.outcome })), Effect.provideService(Clock.Clock, runtime.logical.clock), Effect.ensuring(Effect.promise(() => completeCleanup((request.sources ?? []).map((source) => () => source.close()))).pipe(Effect.ensuring(Effect.sync(() => {
|
|
1200
|
+
if (request.deleteIds && progress.outcome !== "notDispatched")
|
|
1201
|
+
runtime.cache?.deleteMany(request.channel, request.deleteIds);
|
|
1202
|
+
if (deletionGuard)
|
|
1203
|
+
runtime.cache.end(deletionGuard);
|
|
1204
|
+
if (resourceGuard)
|
|
1205
|
+
runtime.resources.end(resourceGuard, request.moderation
|
|
1206
|
+
? progress.outcome !== "notDispatched"
|
|
1207
|
+
: progress.outcome === "unknown");
|
|
1208
|
+
if (request.deleteAuthorId && progress.outcome !== "notDispatched")
|
|
1209
|
+
runtime.cache?.deleteAuthor(request.deleteAuthorId);
|
|
1210
|
+
// A read begun after deletion dispatch can still observe pre-deletion data, so clear again at completion
|
|
1211
|
+
if (request.invalidateMessages && progress.outcome !== "notDispatched")
|
|
1212
|
+
runtime.cache?.gap();
|
|
1213
|
+
// A rejected multi-entry reorder can have applied earlier entries before its failure
|
|
1214
|
+
if (channelGuard)
|
|
1215
|
+
runtime.channels.end(channelGuard, progress.outcome !== "notDispatched");
|
|
1216
|
+
if (request.channelCache?.mutation &&
|
|
1217
|
+
request.method === "DELETE" &&
|
|
1218
|
+
request.bucket === "channel:delete" &&
|
|
1219
|
+
progress.outcome === "unknown")
|
|
1220
|
+
runtime.cache?.deleteChannel(request.channel);
|
|
1221
|
+
if (request.body)
|
|
1222
|
+
request.body.files.length = 0;
|
|
1223
|
+
runtime.uploadBytes -= uploadBytes;
|
|
1224
|
+
runtime.operations.delete(operation);
|
|
1225
|
+
Deferred.doneUnsafe(operation, Effect.void);
|
|
1226
|
+
})))));
|
|
1227
|
+
}).pipe(
|
|
1228
|
+
// A read that failed after dispatch cannot have changed remote state, so its unknown outcome stays retryable.
|
|
1229
|
+
// Mark it in place: The failure's Cause, including any cleanup defects beside it, stays unchanged
|
|
1230
|
+
Effect.onExit((exit) => Effect.sync(() => {
|
|
1231
|
+
if (request.method !== "GET" || Exit.isSuccess(exit))
|
|
1232
|
+
return;
|
|
1233
|
+
for (const reason of exit.cause.reasons)
|
|
1234
|
+
if (reason._tag === "Fail" && reason.error instanceof RestFailure)
|
|
1235
|
+
reason.error.read = true;
|
|
1236
|
+
})));
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Send one caller-described request through the same discovery, admission, rate-limit learning, 429 waits,
|
|
1240
|
+
* deadline, logging and retry rules as wrapped operations, without message or resource cache coordination.
|
|
1241
|
+
* Files are always sent inline as multipart, never through presigned uploads, because the route is unknown
|
|
1242
|
+
*/
|
|
1243
|
+
request(token, input) {
|
|
1244
|
+
return suspendInput(() => {
|
|
1245
|
+
if (this.#runtime.closed)
|
|
1246
|
+
return Effect.fail(new ClientClosedError());
|
|
1247
|
+
const encoded = encodeRestRequest(input);
|
|
1248
|
+
if (encoded instanceof InputValidationFailure)
|
|
1249
|
+
return Effect.fail(inputFailure(encoded.detail));
|
|
1250
|
+
return this.#execute(token, {
|
|
1251
|
+
method: encoded.method,
|
|
1252
|
+
channel: encoded.major,
|
|
1253
|
+
// Requests to one caller route share provisional rate-limit state until Fluxer names its bucket
|
|
1254
|
+
bucket: `rest:${encoded.method} ${encoded.template}`,
|
|
1255
|
+
cache: false,
|
|
1256
|
+
callerDescribed: true,
|
|
1257
|
+
path: encoded.path,
|
|
1258
|
+
template: encoded.template,
|
|
1259
|
+
body: encoded.body,
|
|
1260
|
+
...(encoded.body?.files.length ? { inlineAttachments: true } : {}),
|
|
1261
|
+
...(encoded.auditReason === undefined ? {} : { auditReason: encoded.auditReason }),
|
|
1262
|
+
decode: (response, _instance, signal) => readRestResponse(response, signal),
|
|
1263
|
+
}, encoded.timeoutMs === undefined ? undefined : { timeoutMs: encoded.timeoutMs });
|
|
1264
|
+
}).pipe(mapFailureCause((error) => operationFailure(error, RestRequestError, "rest.request")));
|
|
1265
|
+
}
|
|
1266
|
+
/** Close admission and abort every request and download without waiting */
|
|
1267
|
+
stop() {
|
|
1268
|
+
const runtime = this.#runtime;
|
|
1269
|
+
runtime.closed = true;
|
|
1270
|
+
runtime.instance = undefined;
|
|
1271
|
+
runtime.admission.close();
|
|
1272
|
+
for (const source of runtime.downloads)
|
|
1273
|
+
source.fail(new ClientClosedError());
|
|
1274
|
+
for (const controller of runtime.controllers)
|
|
1275
|
+
controller.abort();
|
|
1276
|
+
}
|
|
1277
|
+
/** Stop, then wait for every running operation and surface unobserved stream cleanup failures */
|
|
1278
|
+
shutdown() {
|
|
1279
|
+
return Effect.suspend(() => {
|
|
1280
|
+
this.stop();
|
|
1281
|
+
const runtime = this.#runtime;
|
|
1282
|
+
return Effect.forEach([...runtime.operations], (operation) => Deferred.await(operation), {
|
|
1283
|
+
discard: true,
|
|
1284
|
+
concurrency: "unbounded",
|
|
1285
|
+
}).pipe(Effect.andThen(Effect.suspend(() => {
|
|
1286
|
+
const defects = runtime.unobservedDownloadDefects.take();
|
|
1287
|
+
return defects ? Effect.failCause(defects) : Effect.void;
|
|
1288
|
+
})));
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
//# sourceMappingURL=owner.js.map
|