@seedcord/http 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{edge.index-DK-Y14ge.mjs → edge.index-DwRPmkh2.mjs} +358 -36
- package/dist/edge.index-DwRPmkh2.mjs.map +1 -0
- package/dist/{edge.index-QUU3_n9k.d.mts → edge.index-tJFQMQ2q.d.mts} +198 -19
- package/dist/edge.index.d.mts +3 -3
- package/dist/edge.index.mjs +4 -4
- package/dist/index.d.mts +9 -8
- package/dist/index.mjs +17 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
- package/dist/edge.index-DK-Y14ge.mjs.map +0 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { t as RouteManifest } from "./RouteManifest-DTxI4fS0.mjs";
|
|
2
2
|
import "reflect-metadata";
|
|
3
|
+
import { AnyCustomId, AutocompletableNames, AutocompleteRouteBrand, ChoiceValueOf, ComponentDefsBrand, ComponentKindBrand, ContextMenuKindBrand, ContextMenuNamesBrand, EntryFor, FocusedField, GateFitsWith, HasComponentDefs, InteractionRoutes, MatchArms, NamesFor, PageCursor, SingleParams, SlashOptions, SlashRouteBrand } from "@seedcord/core/internal";
|
|
3
4
|
import { REST } from "@discordjs/rest";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { APIApplicationCommandAutocompleteInteraction, APIApplicationCommandOptionChoice, APIAttachment, APIChatInputApplicationCommandInteraction, APIContextMenuInteraction, APIInteraction, APIInteractionDataResolvedChannelBase, APIInteractionDataResolvedGuildMember, APIInteractionGuildMember, APIMessage, APIMessageApplicationCommandInteraction, APIMessageChannelSelectInteractionData, APIMessageComponentButtonInteraction, APIMessageComponentInteraction, APIMessageComponentSelectMenuInteraction, APIMessageMentionableSelectInteractionData, APIMessageRoleSelectInteractionData, APIMessageStringSelectInteractionData, APIMessageUserSelectInteractionData, APIModalInteractionResponseCallbackData, APIModalSubmitInteraction, APIRole, APIThreadChannel, APIUser, APIUserApplicationCommandInteraction, ApplicationCommandType, ChannelType, ThreadChannelType } from "discord-api-types/v10";
|
|
5
|
+
import { ArraySourceBase, AutocompleteOptions, BaseHandler, BaseReplySender, Bus, CoreBase, CursorSourceBase, DispatchContext, Gate, GateContextBase, GuildPermissionsContext, ModalLike, PageSourceBase, PaginatorBase, PaginatorConfig, RepliableHandler, RequiredOf, ResolvedEmoji, SelectMenuKind, SlashRegistry, Subscriber, SubscriptionKey, WebhookLog } from "@seedcord/core";
|
|
6
|
+
import { APIApplicationCommandAutocompleteInteraction, APIApplicationCommandOptionChoice, APIAttachment, APIChatInputApplicationCommandInteraction, APIContextMenuInteraction, APIInteraction, APIInteractionDataResolvedChannel, APIInteractionDataResolvedChannelBase, APIInteractionDataResolvedGuildMember, APIInteractionGuildMember, APIMessage, APIMessageApplicationCommandInteraction, APIMessageChannelSelectInteractionData, APIMessageComponentButtonInteraction, APIMessageComponentInteraction, APIMessageComponentSelectMenuInteraction, APIMessageMentionableSelectInteractionData, APIMessageRoleSelectInteractionData, APIMessageStringSelectInteractionData, APIMessageUserSelectInteractionData, APIModalInteractionResponseCallbackData, APIModalSubmission, APIModalSubmitInteraction, APIRole, APIThreadChannel, APIUser, APIUserApplicationCommandInteraction, ApplicationCommandType, ChannelType, ModalSubmitComponent, ThreadChannelType } from "discord-api-types/v10";
|
|
7
7
|
import { API } from "@discordjs/core/http-only";
|
|
8
|
+
import { CoordinatedShutdown, CoordinatedStartup } from "@seedcord/core/node";
|
|
8
9
|
import { Config, DeferOpts, EmojiMap, ReplyResponse, SendOpts } from "@seedcord/types";
|
|
9
10
|
import { NonEmptyTuple, Promisable } from "type-fest";
|
|
10
11
|
//#region src/subscriptions.d.ts
|
|
@@ -60,6 +61,8 @@ type HttpConfig = HttpServerConfig | HttpEdgeConfig;
|
|
|
60
61
|
* ```
|
|
61
62
|
*/
|
|
62
63
|
interface Core extends CoreBase {
|
|
64
|
+
readonly shutdown: Pick<CoordinatedShutdown, 'addTask'>;
|
|
65
|
+
readonly startup: Pick<CoordinatedStartup, 'addTask'>;
|
|
63
66
|
readonly config: HttpConfig;
|
|
64
67
|
}
|
|
65
68
|
//#endregion
|
|
@@ -82,6 +85,9 @@ interface EngineContext {
|
|
|
82
85
|
*
|
|
83
86
|
* Reads `DISCORD_PUBLIC_KEY` and `DISCORD_BOT_TOKEN` from the environment through envapt and throws a
|
|
84
87
|
* `SeedcordError` when either is missing or malformed.
|
|
88
|
+
*
|
|
89
|
+
* Applies `config.logger`. An omitted `logger` resets the level and the sinks to their defaults, the
|
|
90
|
+
* way `installNodeDefaults` does on the node hosts.
|
|
85
91
|
*/
|
|
86
92
|
declare function createSeedcord(config: HttpConfig, manifest: RouteManifest): (request: Request, ctx?: EngineContext) => Promise<Response>;
|
|
87
93
|
//#endregion
|
|
@@ -109,6 +115,61 @@ interface HttpLens {
|
|
|
109
115
|
*/
|
|
110
116
|
type SlashOptions$1<Route extends keyof SlashRegistry> = SlashOptions<Route, HttpLens>;
|
|
111
117
|
//#endregion
|
|
118
|
+
//#region src/inputs/ModalFields.d.ts
|
|
119
|
+
type FieldKind = ModalSubmitComponent['type'];
|
|
120
|
+
/** The users, members, and roles a mentionable select picked. */
|
|
121
|
+
interface SelectedMentionables {
|
|
122
|
+
users: Map<string, APIUser>;
|
|
123
|
+
members: Map<string, APIInteractionDataResolvedGuildMember>;
|
|
124
|
+
roles: Map<string, APIRole>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The fields a modal carries, read by custom id.
|
|
128
|
+
*
|
|
129
|
+
* Every getter throws when no field in the modal has that custom id. It also throws when the field holds a
|
|
130
|
+
* kind that getter does not read. The message names the getter that does.
|
|
131
|
+
*
|
|
132
|
+
* A select getter resolves the ids its field picked against the interaction's `resolved` data and returns a
|
|
133
|
+
* `Map` keyed by id. A field that picked nothing returns null. Pass `required` to throw there instead.
|
|
134
|
+
*/
|
|
135
|
+
declare class ModalFields {
|
|
136
|
+
private readonly entries;
|
|
137
|
+
private readonly resolved;
|
|
138
|
+
constructor(data: APIModalSubmission);
|
|
139
|
+
private entry;
|
|
140
|
+
private field;
|
|
141
|
+
private selected;
|
|
142
|
+
/**
|
|
143
|
+
* Returns the field with this custom id, as Discord sent it. Use it for a component type the typed
|
|
144
|
+
* getters do not cover.
|
|
145
|
+
*
|
|
146
|
+
* Pass a component type to get that exact type back. It throws when the field holds a different one.
|
|
147
|
+
*/
|
|
148
|
+
getField<Kind extends FieldKind>(customId: string, kind: Kind): Extract<ModalSubmitComponent, {
|
|
149
|
+
type: Kind;
|
|
150
|
+
}>;
|
|
151
|
+
getField(customId: string): ModalSubmitComponent;
|
|
152
|
+
getTextInputValue(customId: string): string;
|
|
153
|
+
getStringSelectValues(customId: string): string[];
|
|
154
|
+
getSelectedUsers(customId: string, required: true): Map<string, APIUser>;
|
|
155
|
+
getSelectedUsers(customId: string, required?: boolean): Map<string, APIUser> | null;
|
|
156
|
+
/** The guild members behind the picked users. Discord resolves these only inside a guild. */
|
|
157
|
+
getSelectedMembers(customId: string): Map<string, APIInteractionDataResolvedGuildMember> | null;
|
|
158
|
+
getSelectedRoles(customId: string, required: true): Map<string, APIRole>;
|
|
159
|
+
getSelectedRoles(customId: string, required?: boolean): Map<string, APIRole> | null;
|
|
160
|
+
/** Pass `channelTypes` to throw when a pick falls outside those types. */
|
|
161
|
+
getSelectedChannels(customId: string, required: true, channelTypes?: readonly ChannelType[]): Map<string, APIInteractionDataResolvedChannel>;
|
|
162
|
+
getSelectedChannels(customId: string, required?: boolean, channelTypes?: readonly ChannelType[]): Map<string, APIInteractionDataResolvedChannel> | null;
|
|
163
|
+
getSelectedMentionables(customId: string, required: true): SelectedMentionables;
|
|
164
|
+
getSelectedMentionables(customId: string, required?: boolean): SelectedMentionables | null;
|
|
165
|
+
getUploadedFiles(customId: string, required: true): Map<string, APIAttachment>;
|
|
166
|
+
getUploadedFiles(customId: string, required?: boolean): Map<string, APIAttachment> | null;
|
|
167
|
+
getRadioGroup(customId: string, required: true): string;
|
|
168
|
+
getRadioGroup(customId: string, required?: boolean): string | null;
|
|
169
|
+
getCheckboxGroup(customId: string): string[];
|
|
170
|
+
getCheckbox(customId: string): boolean;
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
112
173
|
//#region src/emojis/EmojiInjector.d.ts
|
|
113
174
|
/** The global {@link Emojis} accessor type. */
|
|
114
175
|
type InjectedEmojiMap = { [K in keyof EmojiMap]: ResolvedEmoji; };
|
|
@@ -212,9 +273,14 @@ declare abstract class SlashHandler<Route extends keyof SlashRegistry> extends I
|
|
|
212
273
|
readonly [SlashRouteBrand]?: Route;
|
|
213
274
|
private resolver?;
|
|
214
275
|
/**
|
|
215
|
-
* The typed options for this command's route.
|
|
216
|
-
*
|
|
217
|
-
*
|
|
276
|
+
* The typed options for this command's route. Only the getters for kinds this command declares appear.
|
|
277
|
+
* Each getter's name argument is restricted to that command's options of its kind.
|
|
278
|
+
*
|
|
279
|
+
* - A required option drops the null.
|
|
280
|
+
* - Choices narrow to their literal union.
|
|
281
|
+
* - A channel option declared with `addChannelTypes` narrows to those types.
|
|
282
|
+
*
|
|
283
|
+
* Rich kinds resolve from the interaction's `resolved` data.
|
|
218
284
|
*/
|
|
219
285
|
protected get options(): SlashOptions$1<Route>;
|
|
220
286
|
/**
|
|
@@ -232,6 +298,8 @@ declare abstract class SlashHandler<Route extends keyof SlashRegistry> extends I
|
|
|
232
298
|
}
|
|
233
299
|
//#endregion
|
|
234
300
|
//#region src/handlers/interaction/ContextMenuHandler.d.ts
|
|
301
|
+
type UserMenuArms<Names extends NamesFor<ApplicationCommandType.User>, Ret> = Record<Names, (target: APIUser, member: APIInteractionDataResolvedGuildMember | null) => Promisable<Ret>>;
|
|
302
|
+
type MessageMenuArms<Names extends NamesFor<ApplicationCommandType.Message>, Ret> = Record<Names, (target: APIMessage) => Promisable<Ret>>;
|
|
235
303
|
/**
|
|
236
304
|
* Base class for a user context-menu command handler on the HTTP transport (right-click a user).
|
|
237
305
|
*
|
|
@@ -248,6 +316,33 @@ declare abstract class UserContextMenuHandler<Names extends NamesFor<Application
|
|
|
248
316
|
protected get target(): APIUser;
|
|
249
317
|
/** The right-clicked user's guild member, null outside a guild. */
|
|
250
318
|
protected get targetMember(): APIInteractionDataResolvedGuildMember | null;
|
|
319
|
+
/** Which of the registered commands fired. */
|
|
320
|
+
protected get commandName(): Names;
|
|
321
|
+
/**
|
|
322
|
+
* Run the arm for whichever command fired. Use this only when the handler is registered for several
|
|
323
|
+
* names.
|
|
324
|
+
*
|
|
325
|
+
* Provide one arm per registered name, keyed by the name Discord shows in the right-click menu. Each
|
|
326
|
+
* arm receives the clicked user and that user's guild member. The arms must cover every name in the
|
|
327
|
+
* generic. A missing name or an unknown key is a compile error.
|
|
328
|
+
*
|
|
329
|
+
* @param arms - One handler per registered command name.
|
|
330
|
+
* @returns The result of the arm that ran.
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* ```ts
|
|
334
|
+
* \@UserContextMenuRoute('View Profile', 'Warn')
|
|
335
|
+
* class Moderation extends UserContextMenuHandler<'View Profile' | 'Warn'> {
|
|
336
|
+
* async execute() {
|
|
337
|
+
* await this.match({
|
|
338
|
+
* 'View Profile': (user) => this.reply(`Profile for ${user.username}.`),
|
|
339
|
+
* Warn: (user, member) => this.reply(`Warned ${member?.nick ?? user.username}.`)
|
|
340
|
+
* });
|
|
341
|
+
* }
|
|
342
|
+
* }
|
|
343
|
+
* ```
|
|
344
|
+
*/
|
|
345
|
+
protected match<Ret>(arms: UserMenuArms<Names, Ret>): Promise<Ret>;
|
|
251
346
|
}
|
|
252
347
|
/**
|
|
253
348
|
* Base class for a message context-menu command handler on the HTTP transport (right-click a message).
|
|
@@ -263,6 +358,33 @@ declare abstract class MessageContextMenuHandler<Names extends NamesFor<Applicat
|
|
|
263
358
|
/** @internal */
|
|
264
359
|
readonly [ContextMenuNamesBrand]?: Names;
|
|
265
360
|
protected get target(): APIMessage;
|
|
361
|
+
/** Which of the registered commands fired. */
|
|
362
|
+
protected get commandName(): Names;
|
|
363
|
+
/**
|
|
364
|
+
* Run the arm for whichever command fired. Use this only when the handler is registered for several
|
|
365
|
+
* names.
|
|
366
|
+
*
|
|
367
|
+
* Provide one arm per registered name, keyed by the name Discord shows in the right-click menu. Each
|
|
368
|
+
* arm receives the clicked message. The arms must cover every name in the generic. A missing name or
|
|
369
|
+
* an unknown key is a compile error.
|
|
370
|
+
*
|
|
371
|
+
* @param arms - One handler per registered command name.
|
|
372
|
+
* @returns The result of the arm that ran.
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* ```ts
|
|
376
|
+
* \@MessageContextMenuRoute('Report Message', 'Quote Message')
|
|
377
|
+
* class MessageTools extends MessageContextMenuHandler<'Report Message' | 'Quote Message'> {
|
|
378
|
+
* async execute() {
|
|
379
|
+
* await this.match({
|
|
380
|
+
* 'Report Message': (message) => this.report(message),
|
|
381
|
+
* 'Quote Message': (message) => this.reply(`> ${message.content}`)
|
|
382
|
+
* });
|
|
383
|
+
* }
|
|
384
|
+
* }
|
|
385
|
+
* ```
|
|
386
|
+
*/
|
|
387
|
+
protected match<Ret>(arms: MessageMenuArms<Names, Ret>): Promise<Ret>;
|
|
266
388
|
}
|
|
267
389
|
//#endregion
|
|
268
390
|
//#region src/handlers/interaction/AutocompleteHandler.d.ts
|
|
@@ -395,14 +517,29 @@ declare abstract class ButtonHandler<Defs extends readonly AnyCustomId[]> extend
|
|
|
395
517
|
* Base class for a modal submit handler on the HTTP transport.
|
|
396
518
|
*
|
|
397
519
|
* Register the customId definitions this handler decodes with `@ModalRoute` and list the same ones in the
|
|
398
|
-
* generic. Read the submitted inputs
|
|
399
|
-
* Discord forbids opening a modal in response to a modal
|
|
520
|
+
* generic. Read the submitted inputs from `this.fields`. Reply through the handler members. `showModal`
|
|
521
|
+
* fails compilation on this kind, because Discord forbids opening a modal in response to a modal.
|
|
400
522
|
*
|
|
401
523
|
* @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof ConfigId]`.
|
|
524
|
+
*
|
|
525
|
+
* @example
|
|
526
|
+
* ```ts
|
|
527
|
+
* \@ModalRoute(ConfigId)
|
|
528
|
+
* class ConfigModal extends ModalHandler<[typeof ConfigId]> {
|
|
529
|
+
* async execute() {
|
|
530
|
+
* const { guildId } = this.params;
|
|
531
|
+
* const name = this.fields.getTextInputValue('name');
|
|
532
|
+
* await this.reply(`saved ${name} for ${guildId}`);
|
|
533
|
+
* }
|
|
534
|
+
* }
|
|
535
|
+
* ```
|
|
402
536
|
*/
|
|
403
537
|
declare abstract class ModalHandler<Defs extends readonly AnyCustomId[]> extends ComponentHandler<APIModalSubmitInteraction, Defs> {
|
|
404
538
|
/** @internal */
|
|
405
539
|
readonly [ComponentKindBrand]?: 'modal';
|
|
540
|
+
private reader?;
|
|
541
|
+
/** The fields this modal submitted, read by custom id. */
|
|
542
|
+
protected get fields(): ModalFields;
|
|
406
543
|
/** Rewrite the message this modal was opened from. Throws when a command opened the modal. */
|
|
407
544
|
protected update(response: ReplyResponse | string): Promise<SentMessage>;
|
|
408
545
|
/** Acknowledge the submit without changing the source message. Throws when a command opened the modal. */
|
|
@@ -411,23 +548,51 @@ declare abstract class ModalHandler<Defs extends readonly AnyCustomId[]> extends
|
|
|
411
548
|
}
|
|
412
549
|
//#endregion
|
|
413
550
|
//#region src/handlers/interaction/components/SelectMenuHandler.d.ts
|
|
551
|
+
type UserKinds = SelectMenuKind.User | SelectMenuKind.Mentionable;
|
|
552
|
+
type RoleKinds = SelectMenuKind.Role | SelectMenuKind.Mentionable;
|
|
553
|
+
type ResolvedFor<Kind extends SelectMenuKind, Allowed extends SelectMenuKind, Value> = [Kind] extends [Allowed] ? Map<string, Value> : never;
|
|
414
554
|
type SelectMenuInteractionFor<Kind extends SelectMenuKind> = APIMessageComponentSelectMenuInteraction & {
|
|
415
555
|
data: Kind extends SelectMenuKind.String ? APIMessageStringSelectInteractionData : Kind extends SelectMenuKind.User ? APIMessageUserSelectInteractionData : Kind extends SelectMenuKind.Role ? APIMessageRoleSelectInteractionData : Kind extends SelectMenuKind.Channel ? APIMessageChannelSelectInteractionData : Kind extends SelectMenuKind.Mentionable ? APIMessageMentionableSelectInteractionData : never;
|
|
416
556
|
};
|
|
417
557
|
/**
|
|
418
558
|
* Base class for a select menu handler on the HTTP transport.
|
|
419
559
|
*
|
|
420
|
-
* Pass the select kind first and the customId definitions second, the same order as `@SelectMenuRoute
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
560
|
+
* Pass the select kind first and the customId definitions second, the same order as `@SelectMenuRoute`.
|
|
561
|
+
* Read the picked ids from `this.values`. The kind decides which of `this.users`, `this.members`,
|
|
562
|
+
* `this.roles`, and `this.channels` this handler carries. The rest are `never`.
|
|
563
|
+
*
|
|
564
|
+
* Read `this.params` for a single route or `this.match` for several. Reply through the handler members, or
|
|
565
|
+
* rewrite the source message with `this.update`.
|
|
424
566
|
*
|
|
425
567
|
* @typeParam Kind - The select kind from {@link SelectMenuKind}, e.g. `SelectMenuKind.User`.
|
|
426
568
|
* @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof AssignId]`.
|
|
569
|
+
*
|
|
570
|
+
* @example
|
|
571
|
+
* ```ts
|
|
572
|
+
* \@SelectMenuRoute(SelectMenuKind.User, AssignId)
|
|
573
|
+
* class AssignSelect extends SelectMenuHandler<SelectMenuKind.User, [typeof AssignId]> {
|
|
574
|
+
* async execute() {
|
|
575
|
+
* const { roleId } = this.params;
|
|
576
|
+
* await this.reply(`assigning ${this.users.size} member(s) to <@&${roleId}>`);
|
|
577
|
+
* }
|
|
578
|
+
* }
|
|
579
|
+
* ```
|
|
427
580
|
*/
|
|
428
581
|
declare abstract class SelectMenuHandler<Kind extends SelectMenuKind, Defs extends readonly AnyCustomId[]> extends ComponentHandler<SelectMenuInteractionFor<Kind>, Defs> {
|
|
429
582
|
/** @internal */
|
|
430
583
|
readonly [ComponentKindBrand]?: Kind;
|
|
584
|
+
private get selection();
|
|
585
|
+
private resolvedMap;
|
|
586
|
+
/** The ids this select picked. */
|
|
587
|
+
protected get values(): string[];
|
|
588
|
+
/** The users this select picked. */
|
|
589
|
+
protected get users(): ResolvedFor<Kind, UserKinds, APIUser>;
|
|
590
|
+
/** The guild members behind the picked users. Discord resolves these only inside a guild. */
|
|
591
|
+
protected get members(): ResolvedFor<Kind, UserKinds, APIInteractionDataResolvedGuildMember>;
|
|
592
|
+
/** The roles this select picked. */
|
|
593
|
+
protected get roles(): ResolvedFor<Kind, RoleKinds, APIRole>;
|
|
594
|
+
/** The channels this select picked. */
|
|
595
|
+
protected get channels(): ResolvedFor<Kind, SelectMenuKind.Channel, APIInteractionDataResolvedChannel>;
|
|
431
596
|
}
|
|
432
597
|
//#endregion
|
|
433
598
|
//#region src/subscribers/index.d.ts
|
|
@@ -488,15 +653,29 @@ declare class Paginator<Item, const Prefix extends string> extends PaginatorBase
|
|
|
488
653
|
readonly Handler: PaginatorHandlerCtor<Prefix>;
|
|
489
654
|
constructor(config: PaginatorConfig<Item, Prefix, PageContext>);
|
|
490
655
|
/**
|
|
491
|
-
* Render page
|
|
492
|
-
*
|
|
656
|
+
* Render a page as a {@link ReplyResponse} without sending anything.
|
|
657
|
+
*
|
|
658
|
+
* @param handler - The handler rendering the page, normally `this`.
|
|
659
|
+
* @param n - The zero-based page.
|
|
660
|
+
*/
|
|
661
|
+
page(handler: RepliableHandler$1<Repliables>, n: number): Promise<ReplyResponse>;
|
|
662
|
+
/**
|
|
663
|
+
* Send a page through the handler's sender. The sender picks reply, edit, or followUp from its ack state.
|
|
493
664
|
*
|
|
494
665
|
* @param handler - The handler starting the paginator, normally `this`.
|
|
666
|
+
* @param n - The zero-based page to open on.
|
|
495
667
|
*/
|
|
496
|
-
start(handler: RepliableHandler$1<Repliables
|
|
668
|
+
start(handler: RepliableHandler$1<Repliables>, n?: number): Promise<SentMessage>;
|
|
497
669
|
}
|
|
498
670
|
//#endregion
|
|
499
671
|
//#region src/pagination/sources.d.ts
|
|
672
|
+
/**
|
|
673
|
+
* The one method a paginator calls on a source, once per click. Implement it for a source neither shipped
|
|
674
|
+
* one covers.
|
|
675
|
+
*
|
|
676
|
+
* @typeParam Item - The item type the source pages over.
|
|
677
|
+
*/
|
|
678
|
+
type PageSource<Item> = PageSourceBase<Item, PageContext>;
|
|
500
679
|
/**
|
|
501
680
|
* A source for a bounded list you can load whole. It loads the full list on every click, then slices the
|
|
502
681
|
* page, so the real total is known (a real last button, "Page X of Y"). Cache inside your loader if the
|
|
@@ -504,7 +683,7 @@ declare class Paginator<Item, const Prefix extends string> extends PaginatorBase
|
|
|
504
683
|
*
|
|
505
684
|
* @typeParam Item - The item type, inferred from the loader's return.
|
|
506
685
|
*/
|
|
507
|
-
declare class ArraySource
|
|
686
|
+
declare class ArraySource<Item> extends ArraySourceBase<Item, PageContext> {}
|
|
508
687
|
/**
|
|
509
688
|
* A source for a large or unknown-length set you fetch one page at a time (SQL LIMIT/OFFSET, a paged API).
|
|
510
689
|
* The fetcher receives the page index and the page size and reports whether a next page exists. A cursor
|
|
@@ -513,7 +692,7 @@ declare class ArraySource$1<Item> extends ArraySource<Item, PageContext> {}
|
|
|
513
692
|
*
|
|
514
693
|
* @typeParam Item - The item type, inferred from the fetcher's slice.
|
|
515
694
|
*/
|
|
516
|
-
declare class CursorSource
|
|
695
|
+
declare class CursorSource<Item> extends CursorSourceBase<Item, PageContext> {}
|
|
517
696
|
//#endregion
|
|
518
697
|
//#region src/gates/Gate.d.ts
|
|
519
698
|
/**
|
|
@@ -601,5 +780,5 @@ declare function Gated<const Gates extends NonEmptyTuple<Gate<GateContextBase>>>
|
|
|
601
780
|
//#region src/version.d.ts
|
|
602
781
|
declare const version: string;
|
|
603
782
|
//#endregion
|
|
604
|
-
export {
|
|
605
|
-
//# sourceMappingURL=edge.index-
|
|
783
|
+
export { EngineContext as A, SentMessage as C, SelectedMentionables as D, ModalFields as E, HttpConfig as M, HttpEdgeConfig as N, SlashOptions$1 as O, HttpServerConfig as P, ReplySender as S, InjectedEmojiMap as T, UserContextMenuHandler as _, CursorSource as a, RepliableHandler$1 as b, PageContext as c, SelectMenuHandler as d, ModalHandler as f, MessageContextMenuHandler as g, AutocompleteHandler as h, ArraySource as i, Core as j, createSeedcord as k, Subscriber$1 as l, ComponentHandler as m, Gated as n, PageSource as o, ButtonHandler as p, InteractionGateContext as r, Paginator as s, version as t, WebhookLog$1 as u, SlashHandler as v, Emojis as w, InteractionRef as x, InteractionHandler as y };
|
|
784
|
+
//# sourceMappingURL=edge.index-tJFQMQ2q.d.mts.map
|
package/dist/edge.index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { A as EngineContext, C as SentMessage, D as SelectedMentionables, E as ModalFields, M as HttpConfig, N as HttpEdgeConfig, O as SlashOptions, P as HttpServerConfig, S as ReplySender, T as InjectedEmojiMap, _ as UserContextMenuHandler, a as CursorSource, b as RepliableHandler, c as PageContext, d as SelectMenuHandler, f as ModalHandler, g as MessageContextMenuHandler, h as AutocompleteHandler, i as ArraySource, j as Core, k as createSeedcord, l as Subscriber, m as ComponentHandler, n as Gated, o as PageSource, p as ButtonHandler, r as InteractionGateContext, s as Paginator, t as version, u as WebhookLog, v as SlashHandler, w as Emojis, x as InteractionRef, y as InteractionHandler } from "./edge.index-tJFQMQ2q.mjs";
|
|
2
2
|
import { t as RouteManifest } from "./RouteManifest-DTxI4fS0.mjs";
|
|
3
|
+
export * from "@seedcord/logger";
|
|
3
4
|
export * from "@seedcord/core";
|
|
4
5
|
export * from "@seedcord/errors";
|
|
5
|
-
export * from "@seedcord/logger";
|
|
6
6
|
export * from "@seedcord/rate-limiter";
|
|
7
7
|
export * from "@seedcord/event-emitter";
|
|
8
8
|
export * from "@seedcord/utils";
|
|
9
9
|
export type * from "@seedcord/types";
|
|
10
|
-
export { ArraySource, AutocompleteHandler, ButtonHandler, ComponentHandler, type Core, CursorSource, Emojis, type EngineContext, Gated, type HttpConfig, type HttpEdgeConfig, type HttpServerConfig, type InjectedEmojiMap, type InteractionGateContext, InteractionHandler, MessageContextMenuHandler, ModalHandler, type PageContext, Paginator, RepliableHandler, type RouteManifest, SelectMenuHandler, SlashHandler, type SlashOptions, Subscriber, UserContextMenuHandler, WebhookLog, createSeedcord, version };
|
|
10
|
+
export { ArraySource, AutocompleteHandler, ButtonHandler, ComponentHandler, type Core, CursorSource, Emojis, type EngineContext, Gated, type HttpConfig, type HttpEdgeConfig, type HttpServerConfig, type InjectedEmojiMap, type InteractionGateContext, InteractionHandler, type InteractionRef, MessageContextMenuHandler, ModalFields, ModalHandler, type PageContext, type PageSource, Paginator, RepliableHandler, ReplySender, type RouteManifest, SelectMenuHandler, type SelectedMentionables, type SentMessage, SlashHandler, type SlashOptions, Subscriber, UserContextMenuHandler, WebhookLog, createSeedcord, version };
|
package/dist/edge.index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as RepliableHandler, S as AutocompleteHandler, _ as ModalFields, a as Paginator, c as SelectMenuHandler, d as ComponentHandler, f as MessageContextMenuHandler, g as Emojis, i as CursorSource, l as ModalHandler, m as SlashHandler, n as Gated, o as Subscriber, p as UserContextMenuHandler, r as ArraySource, s as WebhookLog, t as version, u as ButtonHandler, v as createSeedcord, w as ReplySender, x as InteractionHandler } from "./edge.index-DwRPmkh2.mjs";
|
|
2
|
+
|
|
3
|
+
export * from "@seedcord/logger"
|
|
2
4
|
|
|
3
5
|
export * from "@seedcord/core"
|
|
4
6
|
|
|
5
7
|
export * from "@seedcord/errors"
|
|
6
8
|
|
|
7
|
-
export * from "@seedcord/logger"
|
|
8
|
-
|
|
9
9
|
export * from "@seedcord/rate-limiter"
|
|
10
10
|
|
|
11
11
|
export * from "@seedcord/event-emitter"
|
|
12
12
|
|
|
13
13
|
export * from "@seedcord/utils"
|
|
14
14
|
|
|
15
|
-
export { ArraySource, AutocompleteHandler, ButtonHandler, ComponentHandler, CursorSource, Emojis, Gated, InteractionHandler, MessageContextMenuHandler, ModalHandler, Paginator, RepliableHandler, SelectMenuHandler, SlashHandler, Subscriber, UserContextMenuHandler, WebhookLog, createSeedcord, version };
|
|
15
|
+
export { ArraySource, AutocompleteHandler, ButtonHandler, ComponentHandler, CursorSource, Emojis, Gated, InteractionHandler, MessageContextMenuHandler, ModalFields, ModalHandler, Paginator, RepliableHandler, ReplySender, SelectMenuHandler, SlashHandler, Subscriber, UserContextMenuHandler, WebhookLog, createSeedcord, version };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { A as EngineContext, C as SentMessage, D as SelectedMentionables, E as ModalFields, M as HttpConfig, N as HttpEdgeConfig, O as SlashOptions, P as HttpServerConfig, S as ReplySender, T as InjectedEmojiMap, _ as UserContextMenuHandler, a as CursorSource, b as RepliableHandler, c as PageContext, d as SelectMenuHandler, f as ModalHandler, g as MessageContextMenuHandler, h as AutocompleteHandler, i as ArraySource, j as Core, k as createSeedcord, l as Subscriber, m as ComponentHandler, n as Gated, o as PageSource, p as ButtonHandler, r as InteractionGateContext, s as Paginator, t as version, u as WebhookLog, v as SlashHandler, w as Emojis, x as InteractionRef, y as InteractionHandler } from "./edge.index-tJFQMQ2q.mjs";
|
|
2
2
|
import { t as RouteManifest } from "./RouteManifest-DTxI4fS0.mjs";
|
|
3
3
|
import "reflect-metadata";
|
|
4
4
|
import { REST } from "@discordjs/rest";
|
|
5
5
|
import { Bus } from "@seedcord/core";
|
|
6
|
-
import { Pluggable } from "@seedcord/core/node
|
|
7
|
-
import {
|
|
6
|
+
import { Pluggable } from "@seedcord/core/node";
|
|
7
|
+
import { WinstonConsoleSink, WinstonFileSink } from "@seedcord/logger/node";
|
|
8
|
+
import { HostAugmentTarget, HostVersion, SeedcordBrand, SeedcordInstance } from "@seedcord/types/internal";
|
|
8
9
|
import { Plugin as Plugin$1, PluginLifecycleSpec, PluginOptions, PluginOptions as PluginOptions$1 } from "@seedcord/core/plugin";
|
|
9
10
|
import { IRateLimiter, TypedOmit } from "@seedcord/types";
|
|
11
|
+
export * from "@seedcord/logger";
|
|
10
12
|
export * from "@seedcord/core";
|
|
11
13
|
export * from "@seedcord/errors";
|
|
12
|
-
export * from "@seedcord/logger";
|
|
13
14
|
export * from "@seedcord/rate-limiter";
|
|
14
15
|
export * from "@seedcord/event-emitter";
|
|
15
16
|
export * from "@seedcord/utils";
|
|
@@ -30,9 +31,9 @@ declare class Seedcord<Cfg extends HttpConfig = HttpConfig> extends Pluggable<'h
|
|
|
30
31
|
/** @internal */
|
|
31
32
|
readonly [SeedcordBrand] = true;
|
|
32
33
|
/** @internal */
|
|
33
|
-
readonly
|
|
34
|
+
readonly [HostAugmentTarget] = "@seedcord/http";
|
|
34
35
|
/** @internal */
|
|
35
|
-
readonly
|
|
36
|
+
readonly [HostVersion]: string;
|
|
36
37
|
/** Workerd-compatible Discord REST client. `start()` sets the token. */
|
|
37
38
|
readonly rest: REST;
|
|
38
39
|
/** @see {@link IRateLimiter} */
|
|
@@ -58,7 +59,7 @@ declare class Seedcord<Cfg extends HttpConfig = HttpConfig> extends Pluggable<'h
|
|
|
58
59
|
* Starts the host and runs the startup tasks.
|
|
59
60
|
*/
|
|
60
61
|
start(): Promise<this>;
|
|
61
|
-
protected static reset():
|
|
62
|
+
protected static reset(host?: object): boolean;
|
|
62
63
|
private registerStartupTasks;
|
|
63
64
|
private registerHmrAwareModules;
|
|
64
65
|
private authenticate;
|
|
@@ -86,5 +87,5 @@ declare abstract class Plugin<Opts extends HttpPluginOptions = {
|
|
|
86
87
|
transport: 'http';
|
|
87
88
|
}> extends Plugin$1<Opts, Core> {}
|
|
88
89
|
//#endregion
|
|
89
|
-
export { ArraySource, AutocompleteHandler, ButtonHandler, ComponentHandler, type Core, CursorSource, Emojis, type EngineContext, Gated, type HttpConfig, type HttpEdgeConfig, type HttpPluginOptions, type HttpServerConfig, type InjectedEmojiMap, type InteractionGateContext, InteractionHandler, MessageContextMenuHandler, ModalHandler, type PageContext, Paginator, Plugin, type PluginLifecycleSpec, type PluginOptions, RepliableHandler, type RouteManifest, Seedcord, SelectMenuHandler, SlashHandler, type SlashOptions, Subscriber, UserContextMenuHandler, WebhookLog, createSeedcord, version };
|
|
90
|
+
export { ArraySource, AutocompleteHandler, ButtonHandler, ComponentHandler, type Core, CursorSource, Emojis, type EngineContext, Gated, type HttpConfig, type HttpEdgeConfig, type HttpPluginOptions, type HttpServerConfig, type InjectedEmojiMap, type InteractionGateContext, InteractionHandler, type InteractionRef, MessageContextMenuHandler, ModalFields, ModalHandler, type PageContext, type PageSource, Paginator, Plugin, type PluginLifecycleSpec, type PluginOptions, RepliableHandler, ReplySender, type RouteManifest, Seedcord, SelectMenuHandler, type SelectedMentionables, type SentMessage, SlashHandler, type SlashOptions, Subscriber, UserContextMenuHandler, WebhookLog, WinstonConsoleSink, WinstonFileSink, createSeedcord, version };
|
|
90
91
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as RepliableHandler, S as AutocompleteHandler, _ as ModalFields, a as Paginator, b as buildRouteMaps, c as SelectMenuHandler, d as ComponentHandler, f as MessageContextMenuHandler, g as Emojis, h as EmojiInjector, i as CursorSource, l as ModalHandler, m as SlashHandler, n as Gated, o as Subscriber, p as UserContextMenuHandler, r as ArraySource, s as WebhookLog, t as version, u as ButtonHandler, v as createSeedcord, w as ReplySender, x as InteractionHandler, y as buildEngine } from "./edge.index-DwRPmkh2.mjs";
|
|
2
2
|
import "reflect-metadata";
|
|
3
|
+
import { HmrManager, InteractionMetadataKey, InteractionRoutes, busLoggerOf, getDevChannel, interactionRoutesOf, setBotColor } from "@seedcord/core/internal";
|
|
3
4
|
import { SeedcordError, applicationIdFromToken, validateDiscordToken } from "@seedcord/errors/internal";
|
|
5
|
+
import { Logger, LoggerChannelRegistry } from "@seedcord/logger";
|
|
4
6
|
import { Envapter } from "envapt";
|
|
5
7
|
import { REST } from "@discordjs/rest";
|
|
6
8
|
import { Bus } from "@seedcord/core";
|
|
7
|
-
import { HmrManager, InteractionMetadataKey, InteractionRoutes, busLoggerOf, getDevChannel, interactionRoutesOf, setBotColor } from "@seedcord/core/internal";
|
|
8
9
|
import { SeedcordErrorCode, paint } from "@seedcord/errors";
|
|
9
|
-
import { Logger, LoggerChannelRegistry } from "@seedcord/logger";
|
|
10
10
|
import { MemoryRateLimiter } from "@seedcord/rate-limiter";
|
|
11
11
|
import { Routes } from "discord-api-types/v10";
|
|
12
12
|
import { formatFilePath } from "@seedcord/utils";
|
|
13
13
|
import { once } from "node:events";
|
|
14
14
|
import { createServer } from "node:http";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
15
|
+
import { CoordinatedShutdown, CoordinatedStartup, Pluggable } from "@seedcord/core/node";
|
|
16
|
+
import { CommandRegistry, ShutdownPhase, StartupPhase, SubscriberLoader, shutdownOf } from "@seedcord/core/node/internal";
|
|
17
|
+
import { WinstonConsoleSink, WinstonFileSink, installNodeDefaults } from "@seedcord/logger/node";
|
|
18
|
+
import { HostAugmentTarget, HostVersion, SeedcordBrand } from "@seedcord/types/internal";
|
|
18
19
|
import { HmrModuleHandler } from "@seedcord/core/hmr";
|
|
19
20
|
import { traverseDirectory } from "@seedcord/utils/node";
|
|
20
21
|
import { Plugin as Plugin$1 } from "@seedcord/core/plugin";
|
|
21
22
|
|
|
23
|
+
export * from "@seedcord/logger"
|
|
24
|
+
|
|
22
25
|
export * from "@seedcord/core"
|
|
23
26
|
|
|
24
27
|
export * from "@seedcord/errors"
|
|
25
28
|
|
|
26
|
-
export * from "@seedcord/logger"
|
|
27
|
-
|
|
28
29
|
export * from "@seedcord/rate-limiter"
|
|
29
30
|
|
|
30
31
|
export * from "@seedcord/event-emitter"
|
|
@@ -258,9 +259,9 @@ var Seedcord = class Seedcord extends Pluggable {
|
|
|
258
259
|
/** @internal */
|
|
259
260
|
[SeedcordBrand] = true;
|
|
260
261
|
/** @internal */
|
|
261
|
-
|
|
262
|
+
[HostAugmentTarget] = "@seedcord/http";
|
|
262
263
|
/** @internal */
|
|
263
|
-
|
|
264
|
+
[HostVersion] = version;
|
|
264
265
|
/** Workerd-compatible Discord REST client. `start()` sets the token. */
|
|
265
266
|
rest = new REST();
|
|
266
267
|
/** @see {@link IRateLimiter} */
|
|
@@ -306,15 +307,16 @@ var Seedcord = class Seedcord extends Pluggable {
|
|
|
306
307
|
try {
|
|
307
308
|
await super.init();
|
|
308
309
|
} catch (caught) {
|
|
309
|
-
await this.
|
|
310
|
-
Seedcord.reset();
|
|
310
|
+
await shutdownOf(this).run(1, false);
|
|
311
|
+
Seedcord.reset(this);
|
|
311
312
|
throw caught;
|
|
312
313
|
}
|
|
313
314
|
return this;
|
|
314
315
|
}
|
|
315
|
-
static reset() {
|
|
316
|
-
super.reset();
|
|
316
|
+
static reset(host) {
|
|
317
|
+
if (!super.reset(host)) return false;
|
|
317
318
|
LoggerChannelRegistry.instance.configure({});
|
|
319
|
+
return true;
|
|
318
320
|
}
|
|
319
321
|
registerStartupTasks() {
|
|
320
322
|
if (Envapter.isDevelopment || Envapter.isTest) this.registerHmrAwareModules();
|
|
@@ -423,5 +425,5 @@ var Seedcord = class Seedcord extends Pluggable {
|
|
|
423
425
|
var Plugin = class extends Plugin$1 {};
|
|
424
426
|
|
|
425
427
|
//#endregion
|
|
426
|
-
export { ArraySource, AutocompleteHandler, ButtonHandler, ComponentHandler, CursorSource, Emojis, Gated, InteractionHandler, MessageContextMenuHandler, ModalHandler, Paginator, Plugin, RepliableHandler, Seedcord, SelectMenuHandler, SlashHandler, Subscriber, UserContextMenuHandler, WebhookLog, createSeedcord, version };
|
|
428
|
+
export { ArraySource, AutocompleteHandler, ButtonHandler, ComponentHandler, CursorSource, Emojis, Gated, InteractionHandler, MessageContextMenuHandler, ModalFields, ModalHandler, Paginator, Plugin, RepliableHandler, ReplySender, Seedcord, SelectMenuHandler, SlashHandler, Subscriber, UserContextMenuHandler, WebhookLog, WinstonConsoleSink, WinstonFileSink, createSeedcord, version };
|
|
427
429
|
//# sourceMappingURL=index.mjs.map
|