@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,1007 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client logger: Levels, categories, record building, formats, sinks, deduplication and counters.
|
|
3
|
+
* Invariant: A configured sink or format replaces the Effect logger, and the default API writes readable lines to a terminal and
|
|
4
|
+
* JSON lines otherwise, deciding separately for standard output and standard error. Effect's cause printer shows raw messages,
|
|
5
|
+
* stacks and own properties, so native records carry masked copies. Deduplication keeps a bounded key set, and sink failures are
|
|
6
|
+
* counted and reported once to standard error without altering outcomes or recursing. Implements [SDK contracts: Logging](/docs/SDK-CONTRACTS.md#logging)
|
|
7
|
+
*/
|
|
8
|
+
import { readFileSync } from "node:fs"
|
|
9
|
+
import { fileURLToPath } from "node:url"
|
|
10
|
+
import * as Cause from "effect/Cause"
|
|
11
|
+
import * as Context from "effect/Context"
|
|
12
|
+
import * as Effect from "effect/Effect"
|
|
13
|
+
import * as Logger from "effect/Logger"
|
|
14
|
+
import * as References from "effect/References"
|
|
15
|
+
import type { ClientCounters, ErrorInfo, LogCategory, LogLevel, LogRecord, LogSink, LogThreshold } from "#sdk/logging"
|
|
16
|
+
import { ConfigurationError, FluxerlyError } from "#sdk/errors"
|
|
17
|
+
import { record } from "./decode/primitives.js"
|
|
18
|
+
import { readCaller, suspendMarked } from "./defects.js"
|
|
19
|
+
import { metrics } from "./metrics.js"
|
|
20
|
+
import { describeValue, errorSummary, maskPayload, maskText } from "./masking.js"
|
|
21
|
+
import { unsupportedKeyHint } from "./suggest.js"
|
|
22
|
+
import type { LogCode } from "./code-catalogue.js"
|
|
23
|
+
|
|
24
|
+
const logCategories = [
|
|
25
|
+
"lifecycle",
|
|
26
|
+
"gateway",
|
|
27
|
+
"rest",
|
|
28
|
+
"ratelimit",
|
|
29
|
+
"cache",
|
|
30
|
+
"events",
|
|
31
|
+
"commands",
|
|
32
|
+
"collectors",
|
|
33
|
+
"supervisor",
|
|
34
|
+
"sdk",
|
|
35
|
+
] as const satisfies readonly LogCategory[]
|
|
36
|
+
|
|
37
|
+
const levels = ["trace", "debug", "info", "warn", "error", "fatal"] as const satisfies readonly LogLevel[]
|
|
38
|
+
const rank: Record<LogThreshold, number> = { trace: 0, debug: 1, info: 2, warn: 3, error: 4, fatal: 5, silent: 6 }
|
|
39
|
+
/** Distinct Warn-or-higher records whose repeats are tracked at once */
|
|
40
|
+
const dedupeCapacity = 512
|
|
41
|
+
const effectLevels = {
|
|
42
|
+
trace: "Trace",
|
|
43
|
+
debug: "Debug",
|
|
44
|
+
info: "Info",
|
|
45
|
+
warn: "Warn",
|
|
46
|
+
error: "Error",
|
|
47
|
+
fatal: "Fatal",
|
|
48
|
+
} as const
|
|
49
|
+
|
|
50
|
+
let cachedVersion: string | undefined
|
|
51
|
+
/** The installed SDK version from the package manifest next to the compiled or source directory */
|
|
52
|
+
export function sdkVersion(): string {
|
|
53
|
+
if (cachedVersion !== undefined) return cachedVersion
|
|
54
|
+
try {
|
|
55
|
+
const manifest = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8")) as unknown
|
|
56
|
+
cachedVersion = record(manifest) && typeof manifest.version === "string" ? manifest.version : "unknown"
|
|
57
|
+
} catch {
|
|
58
|
+
// allow-silent: A missing manifest only removes the version from the startup record
|
|
59
|
+
cachedVersion = "unknown"
|
|
60
|
+
}
|
|
61
|
+
return cachedVersion
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Record fields accepted from SDK call sites. The error is converted to ErrorInfo and cause keeps native Cause detail */
|
|
65
|
+
export interface LogInput {
|
|
66
|
+
readonly level: LogLevel
|
|
67
|
+
readonly category: LogCategory
|
|
68
|
+
/** A catalogued code, so every emitted code has an entry on the error and log codes page */
|
|
69
|
+
readonly code: LogCode
|
|
70
|
+
readonly message: string
|
|
71
|
+
readonly shardId?: number | undefined
|
|
72
|
+
readonly route?: string | undefined
|
|
73
|
+
readonly event?: string | undefined
|
|
74
|
+
readonly command?: string | undefined
|
|
75
|
+
readonly subscriptionId?: string | undefined
|
|
76
|
+
readonly durationMs?: number | undefined
|
|
77
|
+
readonly attempt?: number | undefined
|
|
78
|
+
readonly delayMs?: number | undefined
|
|
79
|
+
readonly status?: number | undefined
|
|
80
|
+
readonly closeCode?: number | undefined
|
|
81
|
+
readonly fields?: Readonly<Record<string, string | number | boolean | null | undefined>> | undefined
|
|
82
|
+
readonly error?: unknown
|
|
83
|
+
readonly origin?: ErrorInfo["origin"] | undefined
|
|
84
|
+
readonly cause?: Cause.Cause<unknown> | undefined
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
type Counters = {
|
|
88
|
+
-readonly [K in keyof ClientCounters]: ClientCounters[K] extends number
|
|
89
|
+
? number
|
|
90
|
+
: { -readonly [R in keyof ClientCounters[K]]: number }
|
|
91
|
+
}
|
|
92
|
+
export type CounterName = Exclude<keyof ClientCounters, "eventsDropped">
|
|
93
|
+
export type DropReason = keyof ClientCounters["eventsDropped"]
|
|
94
|
+
|
|
95
|
+
/** Guarded text for any value, used for thrown non-Error values and dedupe keys */
|
|
96
|
+
const valueText = describeValue
|
|
97
|
+
|
|
98
|
+
/** ErrorInfo values built from SDK errors, whose stacks only show SDK internals */
|
|
99
|
+
const sdkInfos = new WeakSet<ErrorInfo>()
|
|
100
|
+
|
|
101
|
+
/** Convert any thrown or failed value to masked ErrorInfo, following the cause chain a few levels.
|
|
102
|
+
* Never throws: Getters, proxies and null-prototype objects that reject inspection get a guarded description
|
|
103
|
+
*/
|
|
104
|
+
export function errorInfo(
|
|
105
|
+
value: unknown,
|
|
106
|
+
origin: ErrorInfo["origin"],
|
|
107
|
+
secrets: readonly string[] = [],
|
|
108
|
+
depth = 0,
|
|
109
|
+
): ErrorInfo {
|
|
110
|
+
try {
|
|
111
|
+
if (value instanceof Error) {
|
|
112
|
+
const sdk = value instanceof FluxerlyError
|
|
113
|
+
const code = sdk
|
|
114
|
+
? value.code
|
|
115
|
+
: typeof (value as unknown as { code?: unknown }).code === "string"
|
|
116
|
+
? (value as unknown as { code: string }).code
|
|
117
|
+
: undefined
|
|
118
|
+
const apiError = sdk && (value as { apiError?: unknown }).apiError
|
|
119
|
+
const cause = (value as { cause?: unknown }).cause
|
|
120
|
+
const stack: unknown = value.stack
|
|
121
|
+
const info: ErrorInfo = Object.freeze({
|
|
122
|
+
origin: sdk ? (apiError ? "provider" : origin === "application" ? "application" : "sdk") : origin,
|
|
123
|
+
name: maskText(String(value.name), secrets),
|
|
124
|
+
message: maskText(String(value.message), secrets),
|
|
125
|
+
...(code === undefined ? {} : { code: sdk ? code : maskText(code, secrets) }),
|
|
126
|
+
...(sdk && value.hint !== undefined ? { hint: value.hint } : {}),
|
|
127
|
+
...(typeof stack === "string" ? { stack: maskText(stack, secrets) } : {}),
|
|
128
|
+
...(cause === undefined || depth >= 4 ? {} : { cause: errorInfo(cause, origin, secrets, depth + 1) }),
|
|
129
|
+
...(sdk && Object.keys(value.details).length ? { details: value.details } : {}),
|
|
130
|
+
})
|
|
131
|
+
if (sdk) sdkInfos.add(info)
|
|
132
|
+
return info
|
|
133
|
+
}
|
|
134
|
+
} catch {
|
|
135
|
+
// allow-silent: An Error-like value whose properties throw is described below instead of failing the record
|
|
136
|
+
}
|
|
137
|
+
let kind: string
|
|
138
|
+
try {
|
|
139
|
+
kind = value === null ? "null" : typeof value
|
|
140
|
+
} catch {
|
|
141
|
+
// allow-silent: The typeof operator never throws, but keep the description total
|
|
142
|
+
kind = "unknown"
|
|
143
|
+
}
|
|
144
|
+
return Object.freeze({ origin, name: `Non-Error value (${kind})`, message: maskText(valueText(value), secrets) })
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** A copy of an error with its masked name, message, stack and cause chain, and only its code as another own property.
|
|
148
|
+
* Effect's cause printer shows own enumerable properties, so native log records never receive the original value, and
|
|
149
|
+
* the code appears next to the error name
|
|
150
|
+
*/
|
|
151
|
+
function maskedError(info: ErrorInfo): Error {
|
|
152
|
+
const error = new Error(info.message, info.cause ? { cause: maskedError(info.cause) } : undefined)
|
|
153
|
+
Object.defineProperty(error, "name", { value: info.name, configurable: true, writable: true, enumerable: false })
|
|
154
|
+
if (info.code !== undefined) Object.defineProperty(error, "code", { value: info.code, enumerable: true })
|
|
155
|
+
error.stack = info.stack ?? `${info.name}: ${info.message}`
|
|
156
|
+
return error
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** The value a native log record shows in place of a failure or defect: Masked text or a masked Error copy */
|
|
160
|
+
function maskedValue(value: unknown, secrets: readonly string[]): unknown {
|
|
161
|
+
if (typeof value === "string") return maskText(value, secrets)
|
|
162
|
+
return maskedError(errorInfo(value, "sdk", secrets))
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** A Cause with every failure and defect replaced by its masked copy, keeping interruptions and annotations */
|
|
166
|
+
function maskedCause(cause: Cause.Cause<unknown>, secrets: readonly string[]): Cause.Cause<unknown> {
|
|
167
|
+
return Cause.fromReasons(
|
|
168
|
+
cause.reasons.map((reason) => {
|
|
169
|
+
if (reason._tag === "Interrupt") return reason
|
|
170
|
+
const copy =
|
|
171
|
+
reason._tag === "Fail"
|
|
172
|
+
? Cause.makeFailReason(maskedValue(reason.error, secrets))
|
|
173
|
+
: Cause.makeDieReason(maskedValue(reason.defect, secrets))
|
|
174
|
+
return copy.annotate(Cause.reasonAnnotations(reason))
|
|
175
|
+
}),
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** Source and compiled directories of this SDK package, compared with forward slashes and, on Windows, lowercase */
|
|
180
|
+
const sdkDirectories = (() => {
|
|
181
|
+
const root = fileURLToPath(new URL("../../", import.meta.url)).replaceAll("\\", "/")
|
|
182
|
+
return [`${root}src/`, `${root}dist/`].map((directory) =>
|
|
183
|
+
process.platform === "win32" ? directory.toLowerCase() : directory,
|
|
184
|
+
)
|
|
185
|
+
})()
|
|
186
|
+
|
|
187
|
+
/** A stack frame with percent escapes decoded, or the frame unchanged when it has none or a malformed one */
|
|
188
|
+
function decodedFrame(frame: string): string {
|
|
189
|
+
if (!frame.includes("%")) return frame
|
|
190
|
+
try {
|
|
191
|
+
return decodeURIComponent(frame)
|
|
192
|
+
} catch {
|
|
193
|
+
// allow-silent: A literal % in a plain file path is not an escape, so the frame is compared as written
|
|
194
|
+
return frame
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Whether a stack frame runs inside this SDK or the Effect runtime rather than application code.
|
|
199
|
+
* ESM frames print file URLs, which percent-encode spaces and non-ASCII characters in the install path, so both the
|
|
200
|
+
* written and the decoded frame are compared with the decoded SDK directories
|
|
201
|
+
*/
|
|
202
|
+
function internalFrame(frame: string): boolean {
|
|
203
|
+
return [frame, decodedFrame(frame)].some((form) => {
|
|
204
|
+
let path = form.replaceAll("\\", "/")
|
|
205
|
+
if (process.platform === "win32") path = path.toLowerCase()
|
|
206
|
+
return (
|
|
207
|
+
sdkDirectories.some((directory) => path.includes(directory)) ||
|
|
208
|
+
/\/node_modules\/(?:\.pnpm\/)?effect[@/]/.test(path)
|
|
209
|
+
)
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** Whether a stack shows only where the SDK created an expected error. SdkDefect and ConfigurationError keep theirs,
|
|
214
|
+
* since a defect needs its origin and a thrown configuration error points at the caller's line
|
|
215
|
+
*/
|
|
216
|
+
function internalStack(info: ErrorInfo): boolean {
|
|
217
|
+
return sdkInfos.has(info) && info.name !== "SdkDefect" && info.name !== "ConfigurationError"
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function detailText(value: unknown): string {
|
|
221
|
+
if (typeof value === "string") return value
|
|
222
|
+
try {
|
|
223
|
+
return JSON.stringify(value) ?? String(value)
|
|
224
|
+
} catch {
|
|
225
|
+
// allow-silent: Details are frozen SDK facts, but a guarded description keeps the text total
|
|
226
|
+
return describeValue(value)
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** Readable multi-line text for an ErrorInfo, indented for console output: Title, hint, safe details and stack frames
|
|
231
|
+
* for each error in the cause chain. Consecutive frames inside the SDK and Effect collapse into one line, and SDK
|
|
232
|
+
* errors other than SdkDefect and ConfigurationError print no frames. JSON output keeps the full stack
|
|
233
|
+
*/
|
|
234
|
+
export function errorText(info: ErrorInfo, indent = " ", stack = true): string {
|
|
235
|
+
const lines: string[] = []
|
|
236
|
+
let current: ErrorInfo | undefined = info
|
|
237
|
+
let first = true
|
|
238
|
+
while (current) {
|
|
239
|
+
const title = `${current.name}${current.code === undefined ? "" : ` [${current.code}]`}: ${current.message}`
|
|
240
|
+
lines.push(`${indent}${first ? "" : "Caused by: "}${title}`)
|
|
241
|
+
if (current.hint) lines.push(`${indent} Hint: ${current.hint}`)
|
|
242
|
+
const details = Object.entries(current.details ?? {})
|
|
243
|
+
if (details.length)
|
|
244
|
+
lines.push(`${indent} Details: ${details.map(([key, value]) => `${key}=${detailText(value)}`).join(" ")}`)
|
|
245
|
+
if (stack && current.stack && !internalStack(current)) {
|
|
246
|
+
let hidden = 0
|
|
247
|
+
const flush = () => {
|
|
248
|
+
if (hidden > 0)
|
|
249
|
+
lines.push(`${indent} ... ${hidden} SDK and Effect frame${hidden === 1 ? "" : "s"} hidden`)
|
|
250
|
+
hidden = 0
|
|
251
|
+
}
|
|
252
|
+
for (const frame of current.stack.split("\n").filter((line) => /^\s+at /.test(line))) {
|
|
253
|
+
if (internalFrame(frame)) {
|
|
254
|
+
hidden++
|
|
255
|
+
continue
|
|
256
|
+
}
|
|
257
|
+
flush()
|
|
258
|
+
lines.push(`${indent} ${frame.trim()}`)
|
|
259
|
+
}
|
|
260
|
+
flush()
|
|
261
|
+
}
|
|
262
|
+
first = false
|
|
263
|
+
current = current.cause
|
|
264
|
+
}
|
|
265
|
+
return lines.join("\n")
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function formatTime(date: Date) {
|
|
269
|
+
const pad = (value: number, width = 2) => String(value).padStart(width, "0")
|
|
270
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}.${pad(date.getMilliseconds(), 3)}`
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const colors: Record<LogLevel, string> = {
|
|
274
|
+
trace: "\u001b[90m",
|
|
275
|
+
debug: "\u001b[36m",
|
|
276
|
+
info: "\u001b[32m",
|
|
277
|
+
warn: "\u001b[33m",
|
|
278
|
+
error: "\u001b[31m",
|
|
279
|
+
fatal: "\u001b[35m",
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const recordKeys = [
|
|
283
|
+
"shardId",
|
|
284
|
+
"route",
|
|
285
|
+
"event",
|
|
286
|
+
"command",
|
|
287
|
+
"subscriptionId",
|
|
288
|
+
"status",
|
|
289
|
+
"closeCode",
|
|
290
|
+
"attempt",
|
|
291
|
+
"delayMs",
|
|
292
|
+
"durationMs",
|
|
293
|
+
] as const
|
|
294
|
+
|
|
295
|
+
/** One readable line per record, with key facts and an indented error */
|
|
296
|
+
function prettyLine(entry: LogRecord, color: boolean): string {
|
|
297
|
+
const facts: string[] = []
|
|
298
|
+
for (const key of recordKeys) {
|
|
299
|
+
const value = entry[key]
|
|
300
|
+
if (value === undefined) continue
|
|
301
|
+
facts.push(`${key}=${typeof value === "number" && !Number.isInteger(value) ? value.toFixed(1) : value}`)
|
|
302
|
+
}
|
|
303
|
+
for (const [key, value] of Object.entries(entry.fields ?? {}))
|
|
304
|
+
facts.push(`${key}=${typeof value === "string" && /\s/.test(value) ? JSON.stringify(value) : value}`)
|
|
305
|
+
const level = entry.level.toUpperCase().padEnd(5)
|
|
306
|
+
const code = color ? `\u001b[90m[${entry.code}]\u001b[0m` : `[${entry.code}]`
|
|
307
|
+
const head = `${formatTime(new Date(entry.time))} ${color ? `${colors[entry.level]}${level}\u001b[0m` : level} ${entry.category.padEnd(10)} ${code} ${entry.message}`
|
|
308
|
+
const line = facts.length
|
|
309
|
+
? `${head} ${color ? "\u001b[90m" : ""}${facts.join(" ")}${color ? "\u001b[0m" : ""}`
|
|
310
|
+
: head
|
|
311
|
+
return entry.error ? `${line}\n${errorText(entry.error)}` : line
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function jsonLine(entry: LogRecord): string {
|
|
315
|
+
return JSON.stringify(entry, (_, value) => (typeof value === "bigint" ? value.toString() : value))
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function isThenable(value: unknown): value is PromiseLike<unknown> {
|
|
319
|
+
return (
|
|
320
|
+
(typeof value === "object" || typeof value === "function") &&
|
|
321
|
+
value !== null &&
|
|
322
|
+
typeof (value as { then?: unknown }).then === "function"
|
|
323
|
+
)
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
type Settings = {
|
|
327
|
+
readonly thresholds: Readonly<Record<LogCategory, number>>
|
|
328
|
+
readonly sinks: readonly LogSink[] | undefined
|
|
329
|
+
readonly format: "pretty" | "json" | undefined
|
|
330
|
+
/** FLUXERLY_LOG_FORMAT read at creation, used by the built-in console output when format is not set */
|
|
331
|
+
readonly environmentFormat: "pretty" | "json" | undefined
|
|
332
|
+
/** FLUXERLY_LOG_COLOR read at creation: `true` forces color, `false` disables it, `undefined` follows the terminal */
|
|
333
|
+
readonly environmentColor: boolean | undefined
|
|
334
|
+
readonly dedupeMs: number | undefined
|
|
335
|
+
readonly unsafe: ReadonlySet<LogCategory> | undefined
|
|
336
|
+
readonly debugCategories: ReadonlySet<LogCategory>
|
|
337
|
+
readonly unknownDebug: readonly string[]
|
|
338
|
+
/** Logging environment variables whose values were not recognized and are ignored */
|
|
339
|
+
readonly unknownEnvironment: readonly { readonly variable: string; readonly accepted: string }[]
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
type Dedupe = { shownAt: number; suppressed: number; last: LogInput | undefined }
|
|
343
|
+
|
|
344
|
+
/** One client's logging configuration, counters and output. Emission is synchronous and never fails its caller */
|
|
345
|
+
export class ClientLogger {
|
|
346
|
+
readonly #settings: Settings
|
|
347
|
+
/** Category thresholds, replaced by configure while the client runs */
|
|
348
|
+
#thresholds: Readonly<Record<LogCategory, number>>
|
|
349
|
+
/** Categories lowered to Debug: The debug setting and FLUXERLY_DEBUG at creation, until configure replaces them */
|
|
350
|
+
#debugCategories: ReadonlySet<LogCategory>
|
|
351
|
+
#secrets: string[] = []
|
|
352
|
+
readonly #counters: Counters = {
|
|
353
|
+
handlerFailures: 0,
|
|
354
|
+
hookFailures: 0,
|
|
355
|
+
reportsDropped: 0,
|
|
356
|
+
eventsDropped: { overflow: 0, malformed: 0, collector: 0, closed: 0 },
|
|
357
|
+
cacheChangesDropped: 0,
|
|
358
|
+
protocolFailures: 0,
|
|
359
|
+
unknownDispatches: 0,
|
|
360
|
+
unknownOpcodes: 0,
|
|
361
|
+
restRetries: 0,
|
|
362
|
+
rateLimitWaits: 0,
|
|
363
|
+
restBusy: 0,
|
|
364
|
+
reconnects: 0,
|
|
365
|
+
resumes: 0,
|
|
366
|
+
sinkFailures: 0,
|
|
367
|
+
cleanupFailures: 0,
|
|
368
|
+
commandRejections: 0,
|
|
369
|
+
unmatchedCommands: 0,
|
|
370
|
+
}
|
|
371
|
+
readonly #dedupe = new Map<string, Dedupe>()
|
|
372
|
+
/** Error values already shown in an Error or Fatal record, so the bot runner does not print a final failure twice */
|
|
373
|
+
readonly #loggedErrors = new WeakSet<object>()
|
|
374
|
+
#sinkFailureReported = false
|
|
375
|
+
#bannerShown = false
|
|
376
|
+
#unsafeBannerShown = false
|
|
377
|
+
/** Native context used when a record is emitted outside a fiber, normally the client's creation context */
|
|
378
|
+
context: Context.Context<never> | undefined
|
|
379
|
+
/** Receives every Error and Fatal record before level thresholds and deduplication. The test kit sets it, so its
|
|
380
|
+
* failure checks see unhandled failures however quiet the test client's logging is
|
|
381
|
+
*/
|
|
382
|
+
errorTap: ((record: LogRecord) => void) | undefined
|
|
383
|
+
|
|
384
|
+
constructor(
|
|
385
|
+
settings: Settings,
|
|
386
|
+
readonly native: boolean,
|
|
387
|
+
) {
|
|
388
|
+
this.#settings = settings
|
|
389
|
+
this.#thresholds = settings.thresholds
|
|
390
|
+
this.#debugCategories = settings.debugCategories
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Replace the level and category thresholds from caller settings. A debug setting replaces the Debug categories,
|
|
395
|
+
* including those from FLUXERLY_DEBUG, and an omitted one keeps the current categories. Invalid settings return
|
|
396
|
+
* ConfigurationError and change nothing. Caller reads are marked, so the caller must run this under a defect boundary
|
|
397
|
+
*/
|
|
398
|
+
configure(value: unknown): ConfigurationError | undefined {
|
|
399
|
+
const settings = readCaller(() => {
|
|
400
|
+
if (!record(value)) return new ConfigurationError("logging", "Logging level settings must be an object")
|
|
401
|
+
const keys = ["level", "categories", "debug"]
|
|
402
|
+
const unsupported = Object.keys(value).find((key) => !keys.includes(key))
|
|
403
|
+
if (unsupported !== undefined)
|
|
404
|
+
return new ConfigurationError(
|
|
405
|
+
"logging",
|
|
406
|
+
`Unsupported logging level setting ${JSON.stringify(unsupported)}`,
|
|
407
|
+
{
|
|
408
|
+
hint: `${unsupportedKeyHint(unsupported, keys, "settings")}. Other logging settings are fixed at creation`,
|
|
409
|
+
},
|
|
410
|
+
)
|
|
411
|
+
const thresholds = levelThresholds(value)
|
|
412
|
+
if (thresholds instanceof ConfigurationError) return thresholds
|
|
413
|
+
const debug = value.debug
|
|
414
|
+
const debugCategories = debug === undefined ? undefined : debugSetting(debug)
|
|
415
|
+
if (debugCategories instanceof ConfigurationError) return debugCategories
|
|
416
|
+
return { thresholds, debugCategories }
|
|
417
|
+
})
|
|
418
|
+
if (settings instanceof ConfigurationError) return settings
|
|
419
|
+
const { thresholds, debugCategories } = settings
|
|
420
|
+
if (debugCategories !== undefined) this.#debugCategories = new Set(debugCategories)
|
|
421
|
+
for (const category of this.#debugCategories) thresholds[category] = Math.min(thresholds[category], rank.debug)
|
|
422
|
+
this.#thresholds = Object.freeze(thresholds)
|
|
423
|
+
return undefined
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** Mask this credential in every later record */
|
|
427
|
+
addSecret(secret: string) {
|
|
428
|
+
if (secret.length >= 6 && !this.#secrets.includes(secret)) this.#secrets.push(secret)
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
get secrets(): readonly string[] {
|
|
432
|
+
return this.#secrets
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
enabled(level: LogLevel, category: LogCategory): boolean {
|
|
436
|
+
return rank[level] >= this.#thresholds[category]
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
unsafePayloads(category: LogCategory): boolean {
|
|
440
|
+
return this.#settings.unsafe?.has(category) === true
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
count(name: CounterName, amount = 1) {
|
|
444
|
+
this.#counters[name] += amount
|
|
445
|
+
try {
|
|
446
|
+
if (name === "reconnects") metrics.reconnect(this.context)
|
|
447
|
+
} catch (error) {
|
|
448
|
+
this.#sinkFailure(error)
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
countDrop(reason: DropReason, amount = 1) {
|
|
453
|
+
this.#counters.eventsDropped[reason] += amount
|
|
454
|
+
try {
|
|
455
|
+
metrics.dropped(reason, amount, this.context)
|
|
456
|
+
} catch (error) {
|
|
457
|
+
this.#sinkFailure(error)
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
counters(): ClientCounters {
|
|
462
|
+
return Object.freeze({ ...this.#counters, eventsDropped: Object.freeze({ ...this.#counters.eventsDropped }) })
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/** Record an intentionally discarded item: Count it, then log at Debug for expected drops or Warn for anomalies */
|
|
466
|
+
drop(
|
|
467
|
+
counter: CounterName | { readonly event: DropReason; readonly amount?: number } | undefined,
|
|
468
|
+
input: LogInput & { readonly level: "debug" | "warn" | "error" },
|
|
469
|
+
context?: Context.Context<never>,
|
|
470
|
+
) {
|
|
471
|
+
if (typeof counter === "string") this.count(counter)
|
|
472
|
+
else if (counter) this.countDrop(counter.event, counter.amount)
|
|
473
|
+
this.log(input, context)
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/** Emit the startup banners once per client, including the unsafe payload warning and unknown debug categories */
|
|
477
|
+
banners(context?: Context.Context<never>) {
|
|
478
|
+
if (this.#bannerShown) return
|
|
479
|
+
this.#bannerShown = true
|
|
480
|
+
this.#unsafeBanner(context)
|
|
481
|
+
if (this.#settings.unknownDebug.length)
|
|
482
|
+
this.log(
|
|
483
|
+
{
|
|
484
|
+
level: "warn",
|
|
485
|
+
category: "sdk",
|
|
486
|
+
code: "sdk.unknownDebugCategory",
|
|
487
|
+
message: `FLUXERLY_DEBUG names unknown categories, which are ignored: ${this.#settings.unknownDebug.join(", ")}. Known categories are ${logCategories.join(", ")}`,
|
|
488
|
+
fields: { known: logCategories.join(",") },
|
|
489
|
+
},
|
|
490
|
+
context,
|
|
491
|
+
)
|
|
492
|
+
for (const { variable, accepted } of this.#settings.unknownEnvironment)
|
|
493
|
+
this.log(
|
|
494
|
+
{
|
|
495
|
+
level: "warn",
|
|
496
|
+
category: "sdk",
|
|
497
|
+
code: "sdk.unknownEnvironmentValue",
|
|
498
|
+
message: `${variable} has an unrecognized value and is ignored. Accepted values are ${accepted}`,
|
|
499
|
+
fields: { variable, accepted },
|
|
500
|
+
},
|
|
501
|
+
context,
|
|
502
|
+
)
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/** Whether any unsafe payload category can print, so the unsafe banner is due */
|
|
506
|
+
#unsafeVisible(): boolean {
|
|
507
|
+
const unsafe = this.#settings.unsafe
|
|
508
|
+
if (!unsafe) return false
|
|
509
|
+
for (const category of unsafe) if (this.#thresholds[category] < rank.silent) return true
|
|
510
|
+
return false
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/** Warn once that payload printing is on, at startup or before the first payload record, whichever comes first.
|
|
514
|
+
* It bypasses level thresholds so a Warn-or-higher level cannot hide it, while silent payload categories print nothing
|
|
515
|
+
*/
|
|
516
|
+
#unsafeBanner(context: Context.Context<never> | undefined) {
|
|
517
|
+
if (this.#unsafeBannerShown || !this.#unsafeVisible()) return
|
|
518
|
+
this.#unsafeBannerShown = true
|
|
519
|
+
this.#emit(
|
|
520
|
+
{
|
|
521
|
+
level: "warn",
|
|
522
|
+
category: "sdk",
|
|
523
|
+
code: "sdk.unsafePayloads",
|
|
524
|
+
message:
|
|
525
|
+
"Unsafe payload logging is enabled. Trace records include gateway and REST payloads, which can contain private message content. Bot tokens and other secrets stay masked",
|
|
526
|
+
fields: { categories: [...this.#settings.unsafe!].join(",") },
|
|
527
|
+
},
|
|
528
|
+
context,
|
|
529
|
+
)
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/** Print a masked payload body at Trace when unsafe payload logging covers this category.
|
|
533
|
+
* A silent category prints nothing. Otherwise the unsafe banner precedes the first payload record
|
|
534
|
+
*/
|
|
535
|
+
payload(category: LogCategory, code: LogCode, message: string, value: unknown, extra?: Partial<LogInput>) {
|
|
536
|
+
if (!this.unsafePayloads(category) || this.#thresholds[category] >= rank.silent) return
|
|
537
|
+
this.#unsafeBanner(undefined)
|
|
538
|
+
this.#emit(
|
|
539
|
+
{
|
|
540
|
+
...extra,
|
|
541
|
+
level: "trace",
|
|
542
|
+
category,
|
|
543
|
+
code,
|
|
544
|
+
message,
|
|
545
|
+
fields: { ...extra?.fields, payload: maskPayload(value, this.#secrets) },
|
|
546
|
+
},
|
|
547
|
+
undefined,
|
|
548
|
+
)
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/** Emit a record synchronously when its category threshold allows it. Output failures never reach the caller */
|
|
552
|
+
log(input: LogInput, context?: Context.Context<never>) {
|
|
553
|
+
if (this.errorTap !== undefined && rank[input.level] >= rank.error)
|
|
554
|
+
try {
|
|
555
|
+
this.errorTap(this.#record(input))
|
|
556
|
+
} catch (error) {
|
|
557
|
+
this.#sinkFailure(error)
|
|
558
|
+
}
|
|
559
|
+
if (!this.enabled(input.level, input.category)) return
|
|
560
|
+
if (rank[input.level] >= rank.error && typeof input.error === "object" && input.error !== null)
|
|
561
|
+
this.#loggedErrors.add(input.error)
|
|
562
|
+
if (rank[input.level] >= rank.warn && this.#settings.dedupeMs !== undefined) {
|
|
563
|
+
// The shard and subscription keep the same fault on different shards or subscriptions apart
|
|
564
|
+
const key = `${input.level}|${input.code}|${input.shardId ?? ""}|${input.subscriptionId ?? ""}|${input.message}|${this.#errorKey(input.error)}`
|
|
565
|
+
const now = Date.now()
|
|
566
|
+
const entry = this.#dedupe.get(key)
|
|
567
|
+
if (entry && now - entry.shownAt < this.#settings.dedupeMs) {
|
|
568
|
+
entry.suppressed++
|
|
569
|
+
entry.last = input
|
|
570
|
+
return
|
|
571
|
+
}
|
|
572
|
+
const suppressed = entry?.suppressed ?? 0
|
|
573
|
+
this.#dedupe.delete(key)
|
|
574
|
+
this.#dedupe.set(key, { shownAt: now, suppressed: 0, last: undefined })
|
|
575
|
+
if (this.#dedupe.size > dedupeCapacity) {
|
|
576
|
+
const [evicted, oldest] = this.#dedupe.entries().next().value!
|
|
577
|
+
this.#dedupe.delete(evicted)
|
|
578
|
+
// Eviction ends that key's window early, so announce what it suppressed instead of losing the count,
|
|
579
|
+
// unless configure has since silenced that level
|
|
580
|
+
if (oldest.suppressed > 0 && oldest.last && this.enabled(oldest.last.level, oldest.last.category))
|
|
581
|
+
this.#emit(this.#repeated(oldest.last, oldest.suppressed), context)
|
|
582
|
+
}
|
|
583
|
+
if (suppressed > 0) input = this.#repeated(input, suppressed)
|
|
584
|
+
}
|
|
585
|
+
this.#emit(input, context)
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/** Whether this error value already appeared in an Error or Fatal record of this logger */
|
|
589
|
+
loggedError(error: unknown): boolean {
|
|
590
|
+
return typeof error === "object" && error !== null && this.#loggedErrors.has(error)
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/** Emit through the current fiber's context, so native records keep the caller's logger, annotations and spans */
|
|
594
|
+
logEffect(input: LogInput): Effect.Effect<void> {
|
|
595
|
+
return Effect.withFiber((fiber) => {
|
|
596
|
+
this.log(input, fiber.context)
|
|
597
|
+
return Effect.void
|
|
598
|
+
})
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/** Report suppressed duplicates that no later record announced and the current thresholds allow, normally during shutdown */
|
|
602
|
+
flush(context?: Context.Context<never>) {
|
|
603
|
+
for (const [key, entry] of this.#dedupe) {
|
|
604
|
+
if (entry.suppressed > 0 && entry.last && this.enabled(entry.last.level, entry.last.category))
|
|
605
|
+
this.#emit(this.#repeated(entry.last, entry.suppressed), context)
|
|
606
|
+
this.#dedupe.delete(key)
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
#repeated(input: LogInput, suppressed: number): LogInput {
|
|
611
|
+
return {
|
|
612
|
+
...input,
|
|
613
|
+
message: `${input.message} (repeated ${suppressed}× since last shown)`,
|
|
614
|
+
fields: { ...input.fields, repeated: suppressed },
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
#errorKey(error: unknown) {
|
|
619
|
+
return error === undefined ? "" : errorSummary(error)
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
#record(input: LogInput): LogRecord {
|
|
623
|
+
const fields: Record<string, string | number | boolean | null> = {}
|
|
624
|
+
for (const [key, value] of Object.entries(input.fields ?? {}))
|
|
625
|
+
if (value !== undefined) fields[key] = typeof value === "string" ? maskText(value, this.#secrets) : value
|
|
626
|
+
const entry: Record<string, unknown> = {
|
|
627
|
+
time: new Date().toISOString(),
|
|
628
|
+
level: input.level,
|
|
629
|
+
category: input.category,
|
|
630
|
+
code: input.code,
|
|
631
|
+
message: maskText(input.message, this.#secrets),
|
|
632
|
+
}
|
|
633
|
+
for (const key of recordKeys) if (input[key] !== undefined) entry[key] = input[key]
|
|
634
|
+
if (Object.keys(fields).length) entry.fields = Object.freeze(fields)
|
|
635
|
+
if (input.error !== undefined) entry.error = errorInfo(input.error, input.origin ?? "sdk", this.#secrets)
|
|
636
|
+
return Object.freeze(entry) as unknown as LogRecord
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
#emit(input: LogInput, context: Context.Context<never> | undefined) {
|
|
640
|
+
let entry: LogRecord
|
|
641
|
+
try {
|
|
642
|
+
entry = this.#record(input)
|
|
643
|
+
} catch (error) {
|
|
644
|
+
this.#sinkFailure(error)
|
|
645
|
+
return
|
|
646
|
+
}
|
|
647
|
+
const sinks = this.#settings.sinks
|
|
648
|
+
if (sinks) {
|
|
649
|
+
for (const sink of sinks) {
|
|
650
|
+
try {
|
|
651
|
+
const result: unknown = sink(entry)
|
|
652
|
+
if (isThenable(result))
|
|
653
|
+
void Promise.resolve(result).then(undefined, (error: unknown) => this.#sinkFailure(error))
|
|
654
|
+
} catch (error) {
|
|
655
|
+
this.#sinkFailure(error)
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return
|
|
659
|
+
}
|
|
660
|
+
if (this.native && this.#settings.format === undefined) {
|
|
661
|
+
this.#effectLog(entry, input, context ?? this.context)
|
|
662
|
+
return
|
|
663
|
+
}
|
|
664
|
+
this.#console(entry)
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/** The built-in console format and color for one output stream, which decides from its own terminal state.
|
|
668
|
+
* Warn and higher records go to standard error. Supervisors pass the parent's choice to their children
|
|
669
|
+
*/
|
|
670
|
+
consoleFormat(stream: "stdout" | "stderr"): { readonly format: "pretty" | "json"; readonly color: boolean } {
|
|
671
|
+
const terminal = (stream === "stderr" ? process.stderr : process.stdout).isTTY === true
|
|
672
|
+
const format = this.#settings.format ?? this.#settings.environmentFormat ?? (terminal ? "pretty" : "json")
|
|
673
|
+
const color =
|
|
674
|
+
format === "pretty" && process.env.NO_COLOR === undefined && (this.#settings.environmentColor ?? terminal)
|
|
675
|
+
return { format, color }
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
#console(entry: LogRecord) {
|
|
679
|
+
try {
|
|
680
|
+
const error = rank[entry.level] >= rank.warn
|
|
681
|
+
const { format, color } = this.consoleFormat(error ? "stderr" : "stdout")
|
|
682
|
+
const text = format === "pretty" ? prettyLine(entry, color) : jsonLine(entry)
|
|
683
|
+
if (error) console.error(text)
|
|
684
|
+
else console.log(text)
|
|
685
|
+
} catch (error) {
|
|
686
|
+
this.#sinkFailure(error)
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
#effectLog(entry: LogRecord, input: LogInput, context: Context.Context<never> | undefined) {
|
|
691
|
+
const annotations: Record<string, unknown> = {
|
|
692
|
+
"fluxerly.category": entry.category,
|
|
693
|
+
"fluxerly.code": entry.code,
|
|
694
|
+
}
|
|
695
|
+
for (const key of recordKeys) if (entry[key] !== undefined) annotations[`fluxerly.${key}`] = entry[key]
|
|
696
|
+
for (const [key, value] of Object.entries(entry.fields ?? {})) annotations[`fluxerly.${key}`] = value
|
|
697
|
+
// The code, hint and safe details of each error in the cause chain, which the default console output prints too.
|
|
698
|
+
// The first cause uses the prefix fluxerly.error.cause., its cause fluxerly.error.cause.cause., and so on
|
|
699
|
+
for (let error = entry.error, prefix = "fluxerly.error."; error; error = error.cause, prefix += "cause.") {
|
|
700
|
+
if (error.code !== undefined) annotations[`${prefix}code`] = error.code
|
|
701
|
+
if (error.hint !== undefined) annotations[`${prefix}hint`] = error.hint
|
|
702
|
+
for (const [key, value] of Object.entries(error.details ?? {}))
|
|
703
|
+
annotations[`${prefix}${key}`] = typeof value === "object" && value !== null ? detailText(value) : value
|
|
704
|
+
}
|
|
705
|
+
let cause: Cause.Cause<unknown> | undefined
|
|
706
|
+
try {
|
|
707
|
+
const original =
|
|
708
|
+
input.cause ??
|
|
709
|
+
(input.error === undefined
|
|
710
|
+
? undefined
|
|
711
|
+
: input.error instanceof FluxerlyError
|
|
712
|
+
? Cause.fail(input.error)
|
|
713
|
+
: Cause.die(input.error))
|
|
714
|
+
// Effect's cause printer shows raw messages, stacks and own properties, so it only receives masked copies
|
|
715
|
+
cause = original && maskedCause(original, this.#secrets)
|
|
716
|
+
} catch (error) {
|
|
717
|
+
this.#sinkFailure(error)
|
|
718
|
+
cause = undefined
|
|
719
|
+
}
|
|
720
|
+
let log: Effect.Effect<void> = Effect.logWithLevel(effectLevels[entry.level])(
|
|
721
|
+
entry.message,
|
|
722
|
+
...(cause ? [cause] : []),
|
|
723
|
+
).pipe(Effect.annotateLogs(annotations))
|
|
724
|
+
// SDK settings already chose this Debug or Trace record, so the Effect minimum level must not hide it again
|
|
725
|
+
if (rank[entry.level] < rank.info)
|
|
726
|
+
log = log.pipe(Effect.provideService(References.MinimumLogLevel, effectLevels[entry.level]))
|
|
727
|
+
try {
|
|
728
|
+
const exit = context ? Effect.runSyncExitWith(context)(log) : Effect.runSyncExit(log)
|
|
729
|
+
if (exit._tag === "Failure") this.#sinkFailure(Cause.squash(exit.cause))
|
|
730
|
+
} catch (error) {
|
|
731
|
+
this.#sinkFailure(error)
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/** Count a log output or failure-reporting fault and describe the first one on standard error. Never throws */
|
|
736
|
+
outputFailure(error: unknown) {
|
|
737
|
+
this.#sinkFailure(error)
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
#sinkFailure(error: unknown) {
|
|
741
|
+
this.#counters.sinkFailures++
|
|
742
|
+
if (this.#sinkFailureReported) return
|
|
743
|
+
this.#sinkFailureReported = true
|
|
744
|
+
try {
|
|
745
|
+
process.stderr.write(
|
|
746
|
+
`Fluxerly log output failed: ${maskText(errorSummary(error), this.#secrets)}. Later failures are counted in diagnostics().counters.sinkFailures\n`,
|
|
747
|
+
)
|
|
748
|
+
} catch {
|
|
749
|
+
// allow-silent: Standard error itself failed, and the counter still records the sink failure
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
/** A default-runtime Effect logger that turns stray Effect log calls from SDK internals into SDK records */
|
|
754
|
+
bridge(): Logger.Logger<unknown, void> {
|
|
755
|
+
return Logger.make((options) => {
|
|
756
|
+
const level = (Object.entries(effectLevels).find(([, value]) => value === options.logLevel)?.[0] ??
|
|
757
|
+
"info") as LogLevel
|
|
758
|
+
const message = Array.isArray(options.message)
|
|
759
|
+
? options.message.map((part) => valueText(part)).join(" ")
|
|
760
|
+
: valueText(options.message)
|
|
761
|
+
const failure =
|
|
762
|
+
Cause.isCause(options.cause) && options.cause.reasons.length ? Cause.squash(options.cause) : undefined
|
|
763
|
+
this.log({
|
|
764
|
+
level,
|
|
765
|
+
category: "sdk",
|
|
766
|
+
code: "sdk.effectLog",
|
|
767
|
+
message,
|
|
768
|
+
...(failure === undefined ? {} : { error: failure }),
|
|
769
|
+
})
|
|
770
|
+
})
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
/** Run default-API work with SDK-internal Effect logs routed into this client's records */
|
|
774
|
+
provide<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> {
|
|
775
|
+
return this.native
|
|
776
|
+
? effect
|
|
777
|
+
: effect.pipe(
|
|
778
|
+
Effect.provideService(Logger.CurrentLoggers, new Set([this.bridge()])),
|
|
779
|
+
Effect.provideService(References.MinimumLogLevel, "Trace"),
|
|
780
|
+
)
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/** A validated threshold. The option names the setting as typed, such as logging.level or logging.categories.rest */
|
|
785
|
+
function threshold(value: unknown, field: "level" | "categories", option: string): LogThreshold | ConfigurationError {
|
|
786
|
+
if (typeof value === "string" && (value === "silent" || (levels as readonly string[]).includes(value)))
|
|
787
|
+
return value as LogThreshold
|
|
788
|
+
return new ConfigurationError(
|
|
789
|
+
field,
|
|
790
|
+
`The option ${JSON.stringify(option)} must be trace, debug, info, warn, error, fatal or silent`,
|
|
791
|
+
)
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/** FLUXERLY_LOG_COLOR values, compared after trimming and lowercasing */
|
|
795
|
+
const colorValues = { 1: true, true: true, yes: true, on: true, 0: false, false: false, no: false, off: false } as const
|
|
796
|
+
|
|
797
|
+
/** Parse FLUXERLY_DEBUG: 1, true or * enable every category, otherwise a comma-separated category list */
|
|
798
|
+
function debugEnvironment(value: string | undefined): { categories: LogCategory[]; unknown: string[] } {
|
|
799
|
+
if (value === undefined || value.trim() === "" || value.trim() === "0" || value.trim().toLowerCase() === "false")
|
|
800
|
+
return { categories: [], unknown: [] }
|
|
801
|
+
const parts = value
|
|
802
|
+
.split(",")
|
|
803
|
+
.map((part) => part.trim())
|
|
804
|
+
.filter(Boolean)
|
|
805
|
+
if (parts.some((part) => part === "1" || part === "*" || part.toLowerCase() === "true"))
|
|
806
|
+
return { categories: [...logCategories], unknown: [] }
|
|
807
|
+
return {
|
|
808
|
+
categories: parts.filter((part): part is LogCategory => (logCategories as readonly string[]).includes(part)),
|
|
809
|
+
unknown: parts.filter((part) => !(logCategories as readonly string[]).includes(part)),
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/** Caller logging settings after validation, before the logger combines them with the environment */
|
|
814
|
+
interface LoggingInput {
|
|
815
|
+
readonly thresholds: Record<LogCategory, number>
|
|
816
|
+
readonly debugCategories: readonly LogCategory[]
|
|
817
|
+
readonly format: "pretty" | "json" | undefined
|
|
818
|
+
readonly sinks: LogSink[] | undefined
|
|
819
|
+
readonly dedupeMs: number | undefined
|
|
820
|
+
readonly unsafe: Set<LogCategory> | undefined
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/** Validate the level and categories settings into category thresholds, reading each setting once */
|
|
824
|
+
function levelThresholds(settings: Record<string, unknown>): Record<LogCategory, number> | ConfigurationError {
|
|
825
|
+
const level = settings.level
|
|
826
|
+
const base = level === undefined ? "info" : threshold(level, "level", "logging.level")
|
|
827
|
+
if (base instanceof ConfigurationError) return base
|
|
828
|
+
const thresholds = Object.fromEntries(logCategories.map((category) => [category, rank[base]])) as Record<
|
|
829
|
+
LogCategory,
|
|
830
|
+
number
|
|
831
|
+
>
|
|
832
|
+
const categories = settings.categories
|
|
833
|
+
if (categories !== undefined) {
|
|
834
|
+
if (!record(categories))
|
|
835
|
+
return new ConfigurationError(
|
|
836
|
+
"categories",
|
|
837
|
+
'The option "logging.categories" must be an object of category levels',
|
|
838
|
+
)
|
|
839
|
+
for (const [category, level] of Object.entries(categories)) {
|
|
840
|
+
if (!(logCategories as readonly string[]).includes(category))
|
|
841
|
+
return new ConfigurationError("categories", `Unknown log category ${JSON.stringify(category)}`, {
|
|
842
|
+
hint: unsupportedKeyHint(category, logCategories, "categories"),
|
|
843
|
+
})
|
|
844
|
+
if (level === undefined) continue
|
|
845
|
+
const parsed = threshold(level, "categories", `logging.categories.${category}`)
|
|
846
|
+
if (parsed instanceof ConfigurationError) return parsed
|
|
847
|
+
thresholds[category as LogCategory] = rank[parsed]
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
return thresholds
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/** Validate a debug setting into its categories: True for every category, false for none or a list of categories */
|
|
854
|
+
function debugSetting(debug: unknown): LogCategory[] | ConfigurationError {
|
|
855
|
+
if (debug === true) return [...logCategories]
|
|
856
|
+
if (debug === false) return []
|
|
857
|
+
if (!Array.isArray(debug))
|
|
858
|
+
return new ConfigurationError(
|
|
859
|
+
"debug",
|
|
860
|
+
'The option "logging.debug" must be true, false or an array of categories',
|
|
861
|
+
)
|
|
862
|
+
const categories: LogCategory[] = []
|
|
863
|
+
for (const category of debug) {
|
|
864
|
+
if (!(logCategories as readonly unknown[]).includes(category))
|
|
865
|
+
return new ConfigurationError(
|
|
866
|
+
"debug",
|
|
867
|
+
typeof category === "string"
|
|
868
|
+
? `Unknown log category ${JSON.stringify(category)} in logging.debug`
|
|
869
|
+
: 'The option "logging.debug" must list log category names',
|
|
870
|
+
{
|
|
871
|
+
hint:
|
|
872
|
+
typeof category === "string"
|
|
873
|
+
? unsupportedKeyHint(category, logCategories, "categories")
|
|
874
|
+
: `Known categories are ${logCategories.join(", ")}`,
|
|
875
|
+
},
|
|
876
|
+
)
|
|
877
|
+
categories.push(category as LogCategory)
|
|
878
|
+
}
|
|
879
|
+
return categories
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
/** Validate caller logging settings, reading each setting once so the validated value is the one used */
|
|
883
|
+
function loggingInput(value: unknown): LoggingInput | ConfigurationError {
|
|
884
|
+
if (value !== undefined && !record(value))
|
|
885
|
+
return new ConfigurationError("logging", "Logging settings must be an object")
|
|
886
|
+
const settings = (value ?? {}) as Record<string, unknown>
|
|
887
|
+
const keys = ["level", "categories", "debug", "format", "sink", "dedupe", "unsafe"]
|
|
888
|
+
const unsupported = Object.keys(settings).filter((key) => !keys.includes(key))
|
|
889
|
+
if (unsupported.length)
|
|
890
|
+
return new ConfigurationError("logging", `Unsupported logging setting ${JSON.stringify(unsupported[0])}`, {
|
|
891
|
+
hint: unsupported.some((key) => ["development", "measurements", "minimumLevel", "logger"].includes(key))
|
|
892
|
+
? "The settings development, measurements, minimumLevel and logger no longer exist. Use level, categories, debug, format and sink instead"
|
|
893
|
+
: unsupportedKeyHint(unsupported[0]!, keys, "settings"),
|
|
894
|
+
})
|
|
895
|
+
const thresholds = levelThresholds(settings)
|
|
896
|
+
if (thresholds instanceof ConfigurationError) return thresholds
|
|
897
|
+
const debug = settings.debug
|
|
898
|
+
const debugCategories = debug === undefined ? [] : debugSetting(debug)
|
|
899
|
+
if (debugCategories instanceof ConfigurationError) return debugCategories
|
|
900
|
+
const format = settings.format
|
|
901
|
+
if (format !== undefined && format !== "pretty" && format !== "json")
|
|
902
|
+
return new ConfigurationError("format", 'The option "logging.format" must be "pretty" or "json"')
|
|
903
|
+
let sinks: LogSink[] | undefined
|
|
904
|
+
const sink = settings.sink
|
|
905
|
+
if (sink !== undefined) {
|
|
906
|
+
const list = Array.isArray(sink) ? [...(sink as unknown[])] : [sink]
|
|
907
|
+
if (list.length === 0 || list.some((entry) => typeof entry !== "function"))
|
|
908
|
+
return new ConfigurationError(
|
|
909
|
+
"sink",
|
|
910
|
+
'The option "logging.sink" must be a function or a non-empty array of functions',
|
|
911
|
+
)
|
|
912
|
+
sinks = list as LogSink[]
|
|
913
|
+
}
|
|
914
|
+
let dedupeMs: number | undefined = 60_000
|
|
915
|
+
const dedupe = settings.dedupe
|
|
916
|
+
if (dedupe === false) dedupeMs = undefined
|
|
917
|
+
else if (dedupe !== undefined) {
|
|
918
|
+
if (!record(dedupe) || Object.keys(dedupe).some((key) => key !== "windowMs"))
|
|
919
|
+
return new ConfigurationError(
|
|
920
|
+
"dedupe",
|
|
921
|
+
'The option "logging.dedupe" must be false or an object with windowMs',
|
|
922
|
+
)
|
|
923
|
+
const windowMs = dedupe.windowMs
|
|
924
|
+
if (windowMs !== undefined && (typeof windowMs !== "number" || !Number.isSafeInteger(windowMs) || windowMs < 0))
|
|
925
|
+
return new ConfigurationError(
|
|
926
|
+
"dedupe",
|
|
927
|
+
'The option "logging.dedupe.windowMs" must be a nonnegative safe integer of milliseconds',
|
|
928
|
+
)
|
|
929
|
+
dedupeMs = windowMs === 0 ? undefined : (windowMs ?? 60_000)
|
|
930
|
+
}
|
|
931
|
+
let unsafe: Set<LogCategory> | undefined
|
|
932
|
+
const option = settings.unsafe
|
|
933
|
+
if (option !== undefined) {
|
|
934
|
+
if (
|
|
935
|
+
!record(option) ||
|
|
936
|
+
option.payloads !== true ||
|
|
937
|
+
Object.keys(option).some((key) => key !== "payloads" && key !== "categories")
|
|
938
|
+
)
|
|
939
|
+
return new ConfigurationError(
|
|
940
|
+
"unsafe",
|
|
941
|
+
'The option "logging.unsafe" must be { payloads: true }, with optional categories',
|
|
942
|
+
)
|
|
943
|
+
const unsafeCategories = option.categories
|
|
944
|
+
if (unsafeCategories === undefined) unsafe = new Set(logCategories)
|
|
945
|
+
else if (
|
|
946
|
+
!Array.isArray(unsafeCategories) ||
|
|
947
|
+
unsafeCategories.some((category) => !(logCategories as readonly unknown[]).includes(category))
|
|
948
|
+
)
|
|
949
|
+
return new ConfigurationError(
|
|
950
|
+
"unsafe",
|
|
951
|
+
'The option "logging.unsafe.categories" must be an array of log category names',
|
|
952
|
+
{ hint: `Known categories are ${logCategories.join(", ")}` },
|
|
953
|
+
)
|
|
954
|
+
else unsafe = new Set(unsafeCategories as LogCategory[])
|
|
955
|
+
}
|
|
956
|
+
return { thresholds, debugCategories, format, sinks, dedupeMs, unsafe }
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/** Run client.logging.configure: Replace the logger's thresholds and, when given, its Debug categories, failing with ConfigurationError for invalid settings */
|
|
960
|
+
export const configureLogging = (logger: ClientLogger, settings: unknown): Effect.Effect<void, ConfigurationError> =>
|
|
961
|
+
suspendMarked(() => {
|
|
962
|
+
const failure = logger.configure(settings)
|
|
963
|
+
return failure === undefined ? Effect.void : Effect.fail(failure)
|
|
964
|
+
})
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* Validate and copy logging settings, then create the logger. Both entry points accept the same keys.
|
|
968
|
+
* Only reading the caller settings is marked as application input, so the caller must run this under a defect boundary
|
|
969
|
+
*/
|
|
970
|
+
export function loggingConfiguration(value: unknown, native: boolean): ClientLogger | ConfigurationError {
|
|
971
|
+
const input = readCaller(() => loggingInput(value))
|
|
972
|
+
if (input instanceof ConfigurationError) return input
|
|
973
|
+
const { thresholds, format, sinks, dedupeMs, unsafe } = input
|
|
974
|
+
const debugCategories = new Set<LogCategory>(input.debugCategories)
|
|
975
|
+
const environment = debugEnvironment(process.env.FLUXERLY_DEBUG)
|
|
976
|
+
const formatVariable = process.env.FLUXERLY_LOG_FORMAT?.trim().toLowerCase()
|
|
977
|
+
const colorVariable = process.env.FLUXERLY_LOG_COLOR?.trim().toLowerCase()
|
|
978
|
+
const environmentFormat = formatVariable === "pretty" || formatVariable === "json" ? formatVariable : undefined
|
|
979
|
+
const environmentColor =
|
|
980
|
+
colorVariable === undefined ? undefined : colorValues[colorVariable as keyof typeof colorValues]
|
|
981
|
+
// An empty variable counts as unset, and any other value that is not recognized gets one startup Warn
|
|
982
|
+
const unknownEnvironment = [
|
|
983
|
+
...(formatVariable && environmentFormat === undefined
|
|
984
|
+
? [{ variable: "FLUXERLY_LOG_FORMAT", accepted: "pretty, json" }]
|
|
985
|
+
: []),
|
|
986
|
+
...(colorVariable && environmentColor === undefined
|
|
987
|
+
? [{ variable: "FLUXERLY_LOG_COLOR", accepted: Object.keys(colorValues).join(", ") }]
|
|
988
|
+
: []),
|
|
989
|
+
]
|
|
990
|
+
for (const category of environment.categories) debugCategories.add(category)
|
|
991
|
+
for (const category of debugCategories) thresholds[category] = Math.min(thresholds[category], rank.debug)
|
|
992
|
+
return new ClientLogger(
|
|
993
|
+
{
|
|
994
|
+
thresholds: Object.freeze(thresholds),
|
|
995
|
+
sinks: sinks && Object.freeze(sinks),
|
|
996
|
+
format,
|
|
997
|
+
environmentFormat,
|
|
998
|
+
environmentColor,
|
|
999
|
+
dedupeMs,
|
|
1000
|
+
unsafe,
|
|
1001
|
+
debugCategories,
|
|
1002
|
+
unknownDebug: environment.unknown,
|
|
1003
|
+
unknownEnvironment,
|
|
1004
|
+
},
|
|
1005
|
+
native,
|
|
1006
|
+
)
|
|
1007
|
+
}
|