@seedcord/core 0.11.0 → 0.12.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +3 -3
  2. package/dist/Bus-VJw-QpoY.mjs +986 -0
  3. package/dist/Bus-VJw-QpoY.mjs.map +1 -0
  4. package/dist/{CoordinatedShutdown-H5YjZn8A.d.mts → CoordinatedShutdown-fPKLWjc5.d.mts} +13 -4
  5. package/dist/{CoordinatedStartup-CGnJrqcl.mjs → CoordinatedStartup-Zw_Lk7Zk.mjs} +22 -20
  6. package/dist/CoordinatedStartup-Zw_Lk7Zk.mjs.map +1 -0
  7. package/dist/Generated-ByC53_A2.d.mts +26 -0
  8. package/dist/HmrModuleHandler-Btgu8r96.mjs +165 -0
  9. package/dist/HmrModuleHandler-Btgu8r96.mjs.map +1 -0
  10. package/dist/{PluginHost-DB4j8unu.d.mts → PluginHost-DFnkIldj.d.mts} +43 -15
  11. package/dist/PluginHost-DTtxWRiL.mjs +552 -0
  12. package/dist/PluginHost-DTtxWRiL.mjs.map +1 -0
  13. package/dist/{PluginLifecycle-AhQ46NIr.mjs → PluginLifecycle-hx5zUc-P.mjs} +4 -4
  14. package/dist/PluginLifecycle-hx5zUc-P.mjs.map +1 -0
  15. package/dist/{ServerHost-DYeh0KTk.d.mts → ServerHost-B5o3ScCF.d.mts} +7 -6
  16. package/dist/{ServerHost-CtmAhEXn.mjs → ServerHost-CDaEDR4C.mjs} +17 -6
  17. package/dist/{ServerHost-CtmAhEXn.mjs.map → ServerHost-CDaEDR4C.mjs.map} +1 -1
  18. package/dist/bindViteEnv-NFzvdqlT.mjs +32 -0
  19. package/dist/{bindViteEnv-DWq5rftJ.mjs.map → bindViteEnv-NFzvdqlT.mjs.map} +1 -1
  20. package/dist/env-internal.index.mjs +1 -1
  21. package/dist/hmr.index.d.mts +20 -20
  22. package/dist/hmr.index.mjs +1 -1
  23. package/dist/{index-Du71Xx69.d.mts → index-DGHng1IN.d.mts} +115 -201
  24. package/dist/index.d.mts +321 -74
  25. package/dist/index.mjs +323 -102
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/internal.index.d.mts +223 -83
  28. package/dist/internal.index.mjs +573 -74
  29. package/dist/internal.index.mjs.map +1 -1
  30. package/dist/node-internal.index.d.mts +8 -4
  31. package/dist/node-internal.index.mjs +19 -6
  32. package/dist/node-internal.index.mjs.map +1 -1
  33. package/dist/node.index.d.mts +3 -3
  34. package/dist/node.index.mjs +22 -28
  35. package/dist/node.index.mjs.map +1 -1
  36. package/dist/{phases-FTM69J3a.d.mts → phases-C2QCSqRu.d.mts} +164 -55
  37. package/dist/plugin.index.d.mts +3 -2
  38. package/dist/plugin.index.mjs +1 -1
  39. package/dist/subscribers-CGuVjbrg.mjs +982 -0
  40. package/dist/subscribers-CGuVjbrg.mjs.map +1 -0
  41. package/dist/{bindViteEnv-DWq5rftJ.mjs → usingCtx-Cf2cZi96.mjs} +1 -31
  42. package/package.json +14 -11
  43. package/dist/CoordinatedStartup-CGnJrqcl.mjs.map +0 -1
  44. package/dist/HmrModuleHandler-8ZC-UuZh.mjs +0 -162
  45. package/dist/HmrModuleHandler-8ZC-UuZh.mjs.map +0 -1
  46. package/dist/PluginHost-B8kxLOeb.mjs +0 -245
  47. package/dist/PluginHost-B8kxLOeb.mjs.map +0 -1
  48. package/dist/PluginLifecycle-AhQ46NIr.mjs.map +0 -1
  49. package/dist/phases-BauKJOTT.mjs +0 -31
  50. package/dist/phases-BauKJOTT.mjs.map +0 -1
  51. package/dist/publishDefault-D3dAyzZ9.mjs +0 -7
  52. package/dist/publishDefault-D3dAyzZ9.mjs.map +0 -1
  53. package/dist/subscribers-Ce3SWy23.mjs +0 -1913
  54. package/dist/subscribers-Ce3SWy23.mjs.map +0 -1
@@ -1,19 +1,19 @@
1
1
  import { t as bindEnv } from "./bindViteEnv-BgFewlZ0.mjs";
2
- import { A as RegisteredCount, B as InteractionMetadataKey, C as AckState, D as AckTrace, E as sendTarget, F as CommandMetadataKey, G as WebhookUrlMetadataKey, H as InteractionRouteKeys, I as EventMetadataKey, K as Notice, L as EventMiddlewareMetadataKey, M as VerifyWebhooks, N as PublishDefault, O as RegisterDefaults, R as GatedMetadataKey, S as reportedWrite, T as checkAckLegality, U as MiddlewareKind, V as InteractionMiddlewareMetadataKey, W as SubscribeMetadataKey, a as StoredSubscriberCtor, c as registrationFor, d as DefaultSubscriptions, f as DispatchOutcome, i as Bus, j as UnregisterSubscriber, k as RegisterSubscriber, o as SubscriberRegistration, r as CoreBase, s as busLoggerOf, w as ReplyMethod, x as ReplyTelemetry, z as InteractionKind } from "./phases-FTM69J3a.mjs";
3
- import { $ as SlashRouteBrand, A as Gate, At as CacheFor, Ct as CommandMeta, Et as BuilderComponent, Ft as SlashRouteEntry, H as AnyMiddlewareCtor, I as SerializedReply, It as ContextMenuKind, J as ComponentDefsBrand, K as interactionMiddlewareMetaOf, L as serializeReply, Lt as MenuCacheFor, Mt as RouteCache, Nt as SlashOption, Pt as SlashRegistry, Q as MiddlewareKindsBrand, R as DispatchResult, St as resolveDeployTarget, T as GateFitsWith, U as InteractionMiddlewareMetadata, V as HandlerResult, X as ContextMenuKindBrand, Y as ComponentKindBrand, Z as ContextMenuNamesBrand, _t as ScopeId, bt as scopeIdsOf, c as PageCursor, ct as CommandRef, dt as commandRefOf, f as ChoiceValueOf, ft as indexById, gt as GLOBAL_ID, h as ResolvedEmoji, ht as DeployResult, j as GateContextBase, jt as OptionKind, l as pageCursor, lt as LinkedCommands, m as FocusedField, mt as CommandBuilder, ot as installLinks, p as EntryFor, pt as linkCommands, q as AutocompleteRouteBrand, s as PAGE_MAX, st as warnLinks, u as AutocompletableNames, ut as commandKey, vt as commandsRoute, w as pickNotice, x as PermissionNames, xt as skippedNote, yt as globalFirst, z as EventDispatchResult, zt as NamesFor } from "./index-Du71Xx69.mjs";
4
- import { a as FixedScope, c as PluginArgs, i as sealAttachments, l as PluginCtor, o as Initializeable, r as attachmentsOf, t as Attachment } from "./PluginHost-DB4j8unu.mjs";
5
- import { n as CoordinatedStartup, t as CoordinatedShutdown } from "./CoordinatedShutdown-H5YjZn8A.mjs";
2
+ import { A as RegisteredCount, B as EventMiddlewareMetadataKey, C as AckState, D as AckTrace, E as sendTarget, G as InteractionRouteKeys, H as InteractionKind, I as DispatchContext, J as WebhookUrlMetadataKey, K as MiddlewareKind, L as InteractionDispatch, M as VerifyWebhooks, N as PublishDefault, O as RegisterDefaults, R as CommandMetadataKey, S as reportedWrite, T as checkAckLegality, U as InteractionMetadataKey, V as GatedMetadataKey, W as InteractionMiddlewareMetadataKey, Y as Notice, a as Bus, f as FaultSource, i as CoreBase, j as UnregisterSubscriber, k as RegisterSubscriber, o as StoredSubscriberCtor, p as InteractionFaultSource, q as SubscribeMetadataKey, s as busLoggerOf, u as DefaultSubscriptions, v as SubscriptionData, w as ReplyMethod, x as ReplyTelemetry, z as EventMetadataKey } from "./phases-C2QCSqRu.mjs";
3
+ import { At as SlashOption, B as InteractionMiddlewareMetadata, Ct as BuilderComponent, Dt as CacheFor, F as DispatchResult, G as ComponentDefsBrand, I as EventDispatchResult, It as NamesFor, J as ContextMenuNamesBrand, K as ComponentKindBrand, Mt as SlashRouteEntry, N as SerializedReply, Nt as ContextMenuKind, O as GateContextBase, Ot as OptionKind, P as serializeReply, Pt as MenuCacheFor, R as HandlerResult, U as interactionMiddlewareMetaOf, W as AutocompleteRouteBrand, X as SlashRouteBrand, Y as MiddlewareKindsBrand, _ as ChoiceValueOf, _t as scopeIdsOf, at as CommandRef, b as ResolvedEmoji, bt as CommandMeta, c as CaseReturn, ct as commandRefOf, d as runCase, dt as CommandBuilder, f as PAGE_MAX, ft as DeployResult, gt as globalFirst, h as AutocompletableNames, ht as commandsRoute, it as warnLinks, jt as SlashRegistry, kt as RouteCache, l as MatchResult, lt as indexById, m as pageCursor, mt as ScopeId, ot as LinkedCommands, p as PageCursor, pt as GLOBAL_ID, q as ContextMenuKindBrand, rt as installLinks, st as commandKey, u as OnlyCases, ut as linkCommands, v as EntryFor, vt as skippedNote, x as GateFitsWith, y as FocusedField, yt as resolveDeployTarget, z as AnyMiddlewareCtor } from "./index-DGHng1IN.mjs";
4
+ import { a as FixedScope, c as PluginArgs, d as Runtime, f as Transport, i as sealAttachments, l as PluginCtor, o as Initializeable, r as attachmentsOf, t as Attachment } from "./PluginHost-DFnkIldj.mjs";
5
+ import { i as StartupTasks, n as ShutdownTasks, r as CoordinatedStartup } from "./CoordinatedShutdown-fPKLWjc5.mjs";
6
6
  import "reflect-metadata";
7
7
  import { AnyCustomId, DecodedParams } from "@seedcord/custom-id";
8
8
  import { ContextMenuCommandBuilder, SlashCommandBuilder } from "@discordjs/builders";
9
- import { APIApplicationCommand, ChannelType, RESTGetCurrentApplicationResult, RESTPostAPIApplicationCommandsJSONBody } from "discord-api-types/v10";
9
+ import { APIApplicationCommand, ApplicationCommandType, ChannelType, ComponentType, RESTGetCurrentApplicationResult, RESTPostAPIApplicationCommandsJSONBody } from "discord-api-types/v10";
10
10
  import { SeedcordErrorCode } from "@seedcord/errors";
11
11
  import { BotToken, SeedcordError } from "@seedcord/errors/internal";
12
- import { Logger } from "@seedcord/logger";
12
+ import { Logger, LoggerOptions } from "@seedcord/logger";
13
13
  import { REST } from "@discordjs/rest";
14
14
  import { DeployedHashes, DevChannel, SeedcordCliEvents, SeedcordFrameworkEvents, WireError } from "@seedcord/types/internal";
15
- import { BotColor, DeferOpts, EpochMs, ErrorsConfig, HmrAware, HmrUpdateEvent, ILogger, LogRecord, ReplyResponse, SendOpts } from "@seedcord/types";
16
- import { Constructor, IsNever, Promisable } from "type-fest";
15
+ import { BotColor, DeferOpts, EpochMs, EventFrequency, HmrAware, HmrUpdateEvent, ILogger, LogRecord, RenderContext, ReplyResponse, SendOpts, TypedOmit } from "@seedcord/types";
16
+ import { Constructor, IsNever, LiteralUnion, Promisable } from "type-fest";
17
17
  //#region src/subscribers/SubscriberLoader.d.ts
18
18
  export declare class SubscriberLoader implements Initializeable, HmrAware {
19
19
  private readonly bus;
@@ -78,8 +78,48 @@ export declare class MiddlewareRegistry<Ctor extends AnyMiddlewareCtor, Key exte
78
78
  //#region src/components/botColorHolder.d.ts
79
79
  export declare function bindBotColor(read: () => BotColor | undefined): void;
80
80
  //#endregion
81
- //#region src/notices/logUnknownFault.d.ts
82
- export declare function logUnknownFault(logger: Logger, uuid: string, error: Error, errors: ErrorsConfig | undefined): void;
81
+ //#region src/notices/FaultBoundary.d.ts
82
+ type ApiErrorClass = abstract new (...args: never[]) => {
83
+ readonly code: number | string;
84
+ };
85
+ interface FaultDetails extends Pick<SubscriptionData<'unknownException'>, 'guild' | 'user'> {
86
+ readonly origin: string;
87
+ readonly source: FaultSource | null;
88
+ readonly metadata: unknown;
89
+ }
90
+ interface FaultSender {
91
+ send(response: ReplyResponse, options: {
92
+ ephemeral: boolean;
93
+ }): Promise<unknown>;
94
+ }
95
+ interface ReportedFault {
96
+ readonly error: Error;
97
+ readonly uuid: RenderContext['uuid'];
98
+ }
99
+ export declare class FaultBoundary {
100
+ private readonly core;
101
+ private readonly apiError;
102
+ private readonly dispatch;
103
+ private readonly detailsOf;
104
+ private readonly ignoredCodes;
105
+ constructor(core: CoreBase, ignoredCodes: readonly (number | string)[] | undefined, apiError: ApiErrorClass, dispatch: DispatchContext, detailsOf: () => FaultDetails);
106
+ report(caught: unknown): ReportedFault | null;
107
+ answerWithReply(caught: unknown, sender: FaultSender): Promise<void>;
108
+ answerWithEmptyChoices(caught: unknown, clearChoices: () => Promise<unknown>): Promise<void>;
109
+ private publish;
110
+ private rendered;
111
+ private fallbackReply;
112
+ private render;
113
+ private renderContext;
114
+ private sendGuarded;
115
+ }
116
+ //#endregion
117
+ //#region src/plugin/splitPluginKey.d.ts
118
+ interface PluginKeyParts {
119
+ readonly head: string;
120
+ readonly leaf: string | undefined;
121
+ }
122
+ export declare function splitPluginKey(key: string): PluginKeyParts;
83
123
  //#endregion
84
124
  //#region src/lifecycle/PluginLifecycle.d.ts
85
125
  export declare class PluginLifecycle {
@@ -91,7 +131,7 @@ export declare class PluginLifecycle {
91
131
  private readonly timedOutInits;
92
132
  private attachments;
93
133
  private registered;
94
- constructor(startup: Pick<CoordinatedStartup, 'addTask'>, shutdown: Pick<CoordinatedShutdown, 'addTask'>);
134
+ constructor(startup: StartupTasks, shutdown: ShutdownTasks);
95
135
  register(attachments: readonly Attachment[]): void;
96
136
  rollback(): Promise<void>;
97
137
  afterTimedOutInits(run: () => void): void;
@@ -106,25 +146,13 @@ export declare class PluginLifecycle {
106
146
  //#region src/decorators/interactionRoutes.d.ts
107
147
  type RoutableConstructor = new (...args: never[]) => unknown;
108
148
  export declare function interactionRoutesOf(constructor: RoutableConstructor): [InteractionKind, string[]][];
109
- export declare function storeInteractionRoute(route: InteractionKind, routes: string | readonly string[], constructor: RoutableConstructor): void;
149
+ export declare function storeInteractionRoute(route: InteractionKind, routes: string | readonly string[], constructor: RoutableConstructor, fix?: string): void;
110
150
  export declare function storeComponentRoute(route: InteractionKind, defs: readonly AnyCustomId[], constructor: RoutableConstructor): void;
111
151
  export declare function contextMenuRouteOf(kind: ContextMenuKind): InteractionKind;
112
152
  //#endregion
113
153
  //#region src/gates/runGates.d.ts
114
154
  type GateObserver = (gateName: string, elapsedMs: number) => void;
115
- export declare function runGates(gates: readonly Gate<GateContextBase>[], ctx: GateContextBase, observe?: GateObserver): Promise<void>;
116
- export declare function runHandlerGates(handlerCtor: object, ctx: GateContextBase, declaredRoute?: string, observe?: GateObserver): Promise<void>;
117
- //#endregion
118
- //#region src/gates/slowGate.d.ts
119
- /**
120
- * collects each gate check's elapsed time for one dispatch. `report` warns once when the checks sum
121
- * past the threshold, naming the total, the route, and each gate's share.
122
- */
123
- interface SlowGateMonitor {
124
- readonly observe: GateObserver;
125
- report(declaredRoute: string | null): void;
126
- }
127
- export declare function slowGateMonitor(): SlowGateMonitor | undefined;
155
+ export declare function runHandlerGates(handlerCtor: object, ctx: GateContextBase, observe?: GateObserver): Promise<void>;
128
156
  //#endregion
129
157
  //#region src/miscellaneous/guarded.d.ts
130
158
  export declare function accessorStore<Value>(): Record<string, Value>;
@@ -134,6 +162,9 @@ export declare function guardedAccessor<Value>(accessor: string, storage: Record
134
162
  //#region src/miscellaneous/emojiConfig.d.ts
135
163
  export declare function isEmojiTuple(value: unknown): value is readonly [string, string];
136
164
  //#endregion
165
+ //#region src/miscellaneous/lazyLogger.d.ts
166
+ export declare function lazyLogger(label: string, options: LoggerOptions): () => Logger;
167
+ //#endregion
137
168
  //#region src/miscellaneous/currentApplication.d.ts
138
169
  export declare function currentApplication(rest: Pick<REST, 'get'>): Promise<RESTGetCurrentApplicationResult>;
139
170
  //#endregion
@@ -185,6 +216,7 @@ export declare class CommandRegistry implements Initializeable, HmrAware {
185
216
  private readonly loadedCommands;
186
217
  private readonly hmrHandler?;
187
218
  private readonly pendingEvents;
219
+ private readonly deploys;
188
220
  private readonly injector;
189
221
  private readonly lastDeploy;
190
222
  private readonly reporter;
@@ -197,6 +229,8 @@ export declare class CommandRegistry implements Initializeable, HmrAware {
197
229
  private reportLoad;
198
230
  /** @internal */
199
231
  refresh(shouldRefresh?: boolean): Promise<void>;
232
+ private afterRunningDeploy;
233
+ private applyEvents;
200
234
  /** @internal */
201
235
  onHmr(event: HmrUpdateEvent): Promise<void>;
202
236
  private loadCommands;
@@ -268,6 +302,19 @@ export declare function isCommandClass(value: unknown): value is CommandCtor;
268
302
  */
269
303
  export declare function slashRouteLeaves(commands: Iterable<SlashCommandBuilder | ContextMenuCommandBuilder>): Set<string>;
270
304
  //#endregion
305
+ //#region src/decorators/assertUniqueKeys.d.ts
306
+ export declare function assertUniqueKeys(decorator: string, ctor: {
307
+ name: string;
308
+ }, keys: readonly string[], fix?: string): void;
309
+ //#endregion
310
+ //#region src/handlers/MiddlewareRoute.d.ts
311
+ interface RegisteredRoutes {
312
+ [InteractionKind.Slash]: keyof SlashRegistry;
313
+ [InteractionKind.UserContextMenu]: NamesFor<ApplicationCommandType.User>;
314
+ [InteractionKind.MessageContextMenu]: NamesFor<ApplicationCommandType.Message>;
315
+ }
316
+ type MiddlewareRoute<Kind extends MiddlewareKind> = Kind extends keyof RegisteredRoutes ? LiteralUnion<RegisteredRoutes[Kind], string> : string;
317
+ //#endregion
271
318
  //#region src/hmr/devChannel.d.ts
272
319
  type CliChannel = DevChannel<SeedcordFrameworkEvents, SeedcordCliEvents>;
273
320
  /** @internal */
@@ -303,21 +350,18 @@ export declare function fromDevLogLine(line: string): LogRecord | undefined;
303
350
  export declare function forwardLogsToCli(): void;
304
351
  //#endregion
305
352
  //#region src/notices/index.d.ts
306
- export declare abstract class GateNotice extends Notice {
307
- render(): ReplyResponse;
308
- }
309
- export declare class NotOwner extends GateNotice {
310
- constructor(message?: string);
353
+ export declare class NotOwner extends Notice {
354
+ constructor();
311
355
  }
312
- export declare class NotInGuild extends GateNotice {
313
- constructor(message?: string);
356
+ export declare class NotInGuild extends Notice {
357
+ constructor();
314
358
  }
315
- export declare class NotInDm extends GateNotice {
316
- constructor(message?: string);
359
+ export declare class NotInDm extends Notice {
360
+ constructor();
317
361
  }
318
- export declare class OnCooldown extends GateNotice {
362
+ export declare class OnCooldown extends Notice {
319
363
  readonly resetAt: EpochMs;
320
- constructor(resetAt: EpochMs, message?: string);
364
+ constructor(resetAt: EpochMs);
321
365
  }
322
366
  export declare class NotAllowed extends Notice {
323
367
  constructor();
@@ -328,22 +372,8 @@ export declare class NeedsAny extends Notice {
328
372
  constructor(summaries: readonly string[]);
329
373
  render(): ReplyResponse;
330
374
  }
331
- export declare class MissingRole extends GateNotice {
332
- constructor(message: string | undefined, roleId: string | null);
333
- }
334
- export declare class MissingPermissions extends Notice {
335
- private readonly subject;
336
- private readonly missingPerms;
337
- private readonly customLead;
338
- constructor(message: string | undefined, subject: string | null, missingPerms: readonly string[]);
339
- render(): ReplyResponse;
340
- }
341
- export declare class HasDangerousPermissions extends Notice {
342
- private readonly subject;
343
- private readonly dangerousPerms;
344
- private readonly customLead;
345
- constructor(message: string | undefined, subject: string, dangerousPerms: readonly string[]);
346
- render(): ReplyResponse;
375
+ export declare class MissingRole extends Notice {
376
+ constructor(roleId: string);
347
377
  }
348
378
  //#endregion
349
379
  //#region src/stops/NoticeCard.d.ts
@@ -386,7 +416,7 @@ export declare function decodeComponentRoute(handlerClass: {
386
416
  /** @internal */
387
417
  type SingleParams<Defs extends readonly AnyCustomId[]> = Defs extends readonly [infer One extends AnyCustomId] ? DecodedParams<One['shape']> : never;
388
418
  /** @internal */
389
- type MatchArms<Defs extends readonly AnyCustomId[], Ret> = { [Def in Defs[number] as Def['prefix']]: (params: DecodedParams<Def['shape']>) => Promisable<Ret>; };
419
+ type MatchCases<Defs extends readonly AnyCustomId[], Ret> = { [Def in Defs[number] as Def['prefix']]: (params: DecodedParams<Def['shape']>) => CaseReturn<Ret>; };
390
420
  //#endregion
391
421
  //#region src/inputs/OptionLens.d.ts
392
422
  interface OptionLens {
@@ -441,6 +471,16 @@ type SlashOptions<Route extends keyof SlashRegistry, Lens extends OptionLens> =
441
471
  export declare function sendFlags(opts?: SendOpts): number;
442
472
  export declare function deferFlags(opts?: DeferOpts): number;
443
473
  //#endregion
474
+ //#region src/reply/AutocompleteResponder.d.ts
475
+ export declare class AutocompleteResponder<Choice> {
476
+ private readonly telemetry;
477
+ private readonly post;
478
+ private attempt?;
479
+ constructor(telemetry: ReplyTelemetry, post: (choices: readonly Choice[]) => Promise<unknown>);
480
+ respond(choices: readonly Choice[]): Promise<void>;
481
+ clear(): Promise<void>;
482
+ }
483
+ //#endregion
444
484
  //#region src/reply/translateSerialization.d.ts
445
485
  export declare function translateSerializationError(error: unknown, componentClass: string, index: number, routeId: string): SeedcordError<SeedcordErrorCode.ReplyComponentSerialization>;
446
486
  //#endregion
@@ -456,41 +496,127 @@ export declare class ReportThrottle {
456
496
  restore(key: string, suppressed: number): void;
457
497
  }
458
498
  //#endregion
459
- //#region src/dispatch/dispatchReport.d.ts
460
- /**
461
- * Classifies a caught stop for `interactionDispatched` so a gate and a
462
- * handler label the same stop identically.
463
- *
464
- * @internal
465
- */
466
- export declare function outcomeFor(caught: unknown): Exclude<DispatchOutcome, 'handled'>;
467
- interface DispatchReport {
468
- readonly dispatchId: string;
469
- readonly routeId: string;
499
+ //#region src/dispatch/InteractionRun.d.ts
500
+ interface RunnableHandler {
501
+ execute(): Promisable<void>;
502
+ }
503
+ interface RunnableMiddleware extends RunnableHandler {
504
+ after?(result: DispatchResult): Promisable<void>;
505
+ }
506
+ type PreparedRun = (() => Promise<void>) | null;
507
+ interface RepliableTarget {
508
+ readonly sender: FaultSender;
509
+ gateContext(): GateContextBase;
510
+ }
511
+ interface AutocompleteTarget {
512
+ readonly responder: {
513
+ clear(): Promise<void>;
514
+ };
515
+ }
516
+ interface InteractionRunConfig {
517
+ readonly dispatch: InteractionDispatch;
518
+ readonly core: CoreBase;
519
+ readonly event: unknown;
520
+ readonly customId: string | null;
521
+ readonly HandlerCtor: Constructor<RunnableHandler, never[]>;
522
+ readonly middlewares: {
523
+ chainFor(kind: MiddlewareKind): readonly Constructor<RunnableMiddleware, never[]>[];
524
+ };
525
+ readonly apiError: ApiErrorClass;
526
+ readonly logger: Logger;
470
527
  readonly interactionId: string;
471
- readonly kind: `${InteractionKind}`;
472
- readonly outcome: DispatchOutcome;
473
- /** True when no route matched and the unhandled default ran. */
474
- readonly fallback: boolean;
475
- readonly userId: string | null;
528
+ readonly userId: string;
476
529
  readonly guildId: string | null;
477
- /** `performance.now()` captured as the dispatch began. */
478
- readonly startedAt: number;
479
- /** {@link queuedMsFor} read at the same moment as `startedAt`. */
480
- readonly queuedMs: number;
530
+ readonly target: RepliableTarget | AutocompleteTarget;
531
+ faultDetails(): FaultDetails;
532
+ }
533
+ export declare class InteractionRun {
534
+ private readonly config;
535
+ private readonly ran;
536
+ private readonly startedAt;
537
+ private readonly queuedMs;
538
+ private readonly boundary;
539
+ constructor(config: InteractionRunConfig);
540
+ prepare(): Promise<PreparedRun>;
541
+ private warnIfUnhandled;
542
+ private prepareAutocomplete;
543
+ private prepareRepliable;
544
+ private builtHandler;
545
+ private refusal;
546
+ private runMiddlewares;
547
+ private start;
548
+ private finish;
549
+ private report;
550
+ }
551
+ //#endregion
552
+ //#region src/dispatch/componentKindOf.d.ts
553
+ export declare function componentKindOf(type: ComponentType): InteractionKind | null;
554
+ //#endregion
555
+ //#region src/dispatch/HandlerLoader.d.ts
556
+ interface LoadedUnit {
557
+ readonly name: string;
558
+ readonly from: string;
559
+ }
560
+ interface HandlerLoaderOptions<Handler, Middleware extends AnyMiddlewareCtor, Key extends string, Artifacts> {
561
+ readonly handlersDir: string;
562
+ readonly middlewaresDir: string | undefined;
563
+ readonly middlewares: MiddlewareRegistry<Middleware, Key>;
564
+ readonly logger: Logger;
565
+ isHandler(value: unknown): value is Handler;
566
+ isMiddleware(value: unknown): value is Middleware;
567
+ storeHandler(handler: Handler, from: string): boolean;
568
+ removeHandler(handler: Handler, artifacts?: Artifacts): void;
569
+ artifactsOf(handler: Handler): Artifacts;
570
+ }
571
+ export declare class HandlerLoader<Handler extends {
572
+ name: string;
573
+ }, Middleware extends AnyMiddlewareCtor, Key extends string, Artifacts> {
574
+ private readonly options;
575
+ readonly loadedHandlers: LoadedUnit[];
576
+ readonly loadedMiddlewares: LoadedUnit[];
577
+ private initialLoad;
578
+ private readonly hmr?;
579
+ constructor(options: HandlerLoaderOptions<Handler, Middleware, Key, Artifacts>);
580
+ load(): Promise<void>;
581
+ onHmr(event: HmrUpdateEvent): Promise<void>;
582
+ private loadHandlers;
583
+ private loadMiddlewares;
584
+ private registerHandler;
585
+ private registerMiddleware;
586
+ }
587
+ //#endregion
588
+ //#region src/dispatch/RouteRegistry.d.ts
589
+ interface RegisteredRoute<Ctor> {
590
+ readonly kind: InteractionKind;
591
+ readonly route: string;
592
+ readonly fallback: boolean;
593
+ readonly ctor: Ctor;
594
+ }
595
+ type KindMaps<Entry> = Readonly<Record<InteractionKind, Map<string, Entry>>>;
596
+ type RouteMaps<Ctor> = KindMaps<RegisteredRoute<Ctor>>;
597
+ export declare function emptyRouteMaps<Entry>(): KindMaps<Entry>;
598
+ export declare function matchRoute<Ctor>(maps: RouteMaps<Ctor>, kind: InteractionKind, route: string, unhandled: {
599
+ readonly repliable: Ctor;
600
+ readonly autocomplete: Ctor;
601
+ }): RegisteredRoute<Ctor>;
602
+ interface LoadedRoute<Ctor> extends RegisteredRoute<Ctor> {
603
+ readonly from: string;
604
+ }
605
+ export declare class RouteRegistry<Ctor extends RoutableConstructor> {
606
+ readonly maps: KindMaps<LoadedRoute<Ctor>>;
607
+ private get allRoutes();
608
+ get size(): number;
609
+ register(ctor: Ctor, from: string): boolean;
610
+ unregister(ctor: Ctor, routes?: readonly RegisteredRoute<Ctor>[]): void;
611
+ routesOf(ctor: Ctor): RegisteredRoute<Ctor>[];
612
+ warnUnhandledRoutes(logger: Logger, leaves: Iterable<string>): void;
613
+ warnUnhandledContextMenuRoutes(logger: Logger, leaves: ContextMenuLeaves): void;
614
+ private warnMissing;
481
615
  }
482
- /**
483
- * Discord's interaction creation to now, read from the snowflake. Called at dispatch entry, since
484
- * a later read would count the handler run into the queue time as well.
485
- *
486
- * @internal
487
- */
488
- export declare function queuedMsFor(interactionId: string): number;
489
- export declare function reportDispatch(bus: Bus, report: DispatchReport): void;
490
616
  //#endregion
491
617
  //#region src/dispatch/runAfter.d.ts
492
618
  interface Afterable<Result> {
493
- after?(result: Result): Promise<void>;
619
+ after?(result: Result): Promisable<void>;
494
620
  }
495
621
  /** @internal */
496
622
  export declare function resultFor(caught: unknown): DispatchResult;
@@ -511,5 +637,19 @@ export declare function eventResultFor(stopped: {
511
637
  */
512
638
  export declare function runAfter<Result>(ran: readonly Afterable<Result>[], result: Result, logger: Logger): Promise<void>;
513
639
  //#endregion
514
- export { type AckState, AckTrace, type AutocompletableNames, AutocompleteRouteBrand, type BakedIds, type CacheFor, type ChoiceValueOf, type CommandBody, type CommandBuilder, type CommandCtor, type CommandMeta, CommandMetadataKey, type CommandRef, type CommandScopes, ComponentDefsBrand, ComponentKindBrand, ContextMenuKindBrand, type ContextMenuLeaves, ContextMenuNamesBrand, CoordinatedStartup, type DecodedComponentRoute, type DefaultSubscriptions, type DeployResult, type EntryFor, EventMetadataKey, EventMiddlewareMetadataKey, FixedScope, type FocusedField, GLOBAL_ID, type GateFitsWith, type GateObserver, GatedMetadataKey, type GuildSummary, type HasComponentDefs, type Initializeable, InteractionMetadataKey, type InteractionMiddlewareMetadata, InteractionMiddlewareMetadataKey, InteractionRouteKeys, type LinkedCommands, type MatchArms, type MenuCacheFor, MiddlewareKindsBrand, type MiddlewareRegistration, type MiddlewareRegistrationOf, type NamesFor, type OptionKind, type OptionLens, PAGE_MAX, type PageCursor, PermissionNames, type PluginArgs, type PluginCtor, PublishDefault, RegisterDefaults, RegisterSubscriber, RegisteredCount, type ReplyMethod, type ReplyTelemetry, type RoutableConstructor, type RouteCache, type ScopeId, type SerializedReply, type SingleParams, type SlashOption, type SlashOptions, SlashRouteBrand, type SlashRouteEntry, type SlowGateMonitor, type StoredSubscriberCtor, SubscribeMetadataKey, type SubscriberRegistration, UnregisterSubscriber, VerifyWebhooks, WebhookUrlMetadataKey, attachmentsOf, bindEnv, busLoggerOf, checkAckLegality, commandKey, commandRefOf, commandsRoute, globalFirst, indexById, installLinks, interactionMiddlewareMetaOf, linkCommands, pageCursor, pickNotice, registrationFor, reportedWrite, resolveDeployTarget, scopeIdsOf, sealAttachments, sendTarget, serializeReply, skippedNote, warnLinks };
640
+ //#region src/dispatch/OnceTracker.d.ts
641
+ interface Registered {
642
+ readonly ctor: object;
643
+ readonly frequency: EventFrequency;
644
+ }
645
+ export declare class OnceTracker {
646
+ private readonly spent;
647
+ isSpent(entry: Registered, key: string): boolean;
648
+ claim(entry: Registered, key: string): boolean;
649
+ }
650
+ //#endregion
651
+ //#region src/subscribers/interactionFaultSource.d.ts
652
+ export declare function interactionFaultSource(dispatch: InteractionDispatch, fields: TypedOmit<InteractionFaultSource, 'kind' | 'interactionKind' | 'command'>): InteractionFaultSource | null;
653
+ //#endregion
654
+ export { type AckState, AckTrace, type AutocompletableNames, AutocompleteRouteBrand, type BakedIds, type CacheFor, type CaseReturn, type ChoiceValueOf, type CommandBody, type CommandBuilder, type CommandCtor, type CommandMeta, CommandMetadataKey, type CommandRef, type CommandScopes, ComponentDefsBrand, ComponentKindBrand, ContextMenuKindBrand, type ContextMenuLeaves, ContextMenuNamesBrand, CoordinatedStartup, type DecodedComponentRoute, type DefaultSubscriptions, type DeployResult, DispatchContext, type EntryFor, EventMetadataKey, EventMiddlewareMetadataKey, type FaultDetails, FixedScope, type FocusedField, GLOBAL_ID, type GateFitsWith, GatedMetadataKey, type GuildSummary, type HasComponentDefs, type Initializeable, type InteractionDispatch, InteractionMetadataKey, type InteractionMiddlewareMetadata, InteractionMiddlewareMetadataKey, InteractionRouteKeys, type InteractionRunConfig, type LinkedCommands, type MatchCases, type MatchResult, type MenuCacheFor, MiddlewareKindsBrand, type MiddlewareRegistration, type MiddlewareRegistrationOf, type MiddlewareRoute, type NamesFor, type OnlyCases, type OptionKind, type OptionLens, PAGE_MAX, type PageCursor, type PluginArgs, type PluginCtor, PublishDefault, RegisterDefaults, RegisterSubscriber, RegisteredCount, type RegisteredRoute, type ReplyMethod, type ReplyTelemetry, type RoutableConstructor, type RouteCache, type RouteMaps, type Runtime, type ScopeId, type SerializedReply, type SingleParams, type SlashOption, type SlashOptions, SlashRouteBrand, type SlashRouteEntry, type StartupTasks, type StoredSubscriberCtor, SubscribeMetadataKey, type Transport, UnregisterSubscriber, VerifyWebhooks, WebhookUrlMetadataKey, attachmentsOf, bindEnv, busLoggerOf, checkAckLegality, commandKey, commandRefOf, commandsRoute, globalFirst, indexById, installLinks, interactionMiddlewareMetaOf, linkCommands, pageCursor, reportedWrite, resolveDeployTarget, runCase, scopeIdsOf, sealAttachments, sendTarget, serializeReply, skippedNote, warnLinks };
515
655
  //# sourceMappingURL=internal.index.d.mts.map