@seedcord/core 0.3.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/{Bus-BvF4VShN.mjs → Bus-yJGE6Fs2.mjs} +111 -92
  2. package/dist/Bus-yJGE6Fs2.mjs.map +1 -0
  3. package/dist/Pluggable-BI_LQuPm.mjs +280 -0
  4. package/dist/Pluggable-BI_LQuPm.mjs.map +1 -0
  5. package/dist/Pluggable-bFCmT4oB.d.mts +148 -0
  6. package/dist/{Plugin-D9ykXA5g.mjs → Plugin-B0SRHzMX.mjs} +7 -3
  7. package/dist/Plugin-B0SRHzMX.mjs.map +1 -0
  8. package/dist/{Plugin-CQ9IEj5X.d.mts → Plugin-BW2JH2_h.d.mts} +2 -2
  9. package/dist/{cursor-BANzac53.d.mts → cursor-CO_MTgdZ.d.mts} +8 -252
  10. package/dist/{cursor-CuoA9cRh.mjs → cursor-CaT051ii.mjs} +307 -425
  11. package/dist/cursor-CaT051ii.mjs.map +1 -0
  12. package/dist/{index-rt8rZg4d.d.mts → index-CvneCObW.d.mts} +2 -2
  13. package/dist/index.d.mts +78 -19
  14. package/dist/index.mjs +223 -21
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/internal.index.d.mts +13 -6
  17. package/dist/internal.index.mjs +8 -455
  18. package/dist/internal.index.mjs.map +1 -1
  19. package/dist/node-internal.index.d.mts +6 -133
  20. package/dist/node-internal.index.mjs +16 -473
  21. package/dist/node-internal.index.mjs.map +1 -1
  22. package/dist/node.index.d.mts +2 -0
  23. package/dist/node.index.mjs +256 -0
  24. package/dist/node.index.mjs.map +1 -0
  25. package/dist/{phases-hBxMCD2V.d.mts → phases-C5Steaa2.d.mts} +151 -119
  26. package/dist/plugin.index.d.mts +1 -1
  27. package/dist/plugin.index.mjs +1 -1
  28. package/dist/publishDefault-D826XXDQ.mjs +14 -0
  29. package/dist/publishDefault-D826XXDQ.mjs.map +1 -0
  30. package/dist/{slashRouteLeaves-De1SxqnX.mjs → slashRouteLeaves-BQmbFm-S.mjs} +10 -2
  31. package/dist/slashRouteLeaves-BQmbFm-S.mjs.map +1 -0
  32. package/dist/{subscribers-wnMyNYZd.mjs → subscribers-DVa-Pr45.mjs} +3 -3
  33. package/dist/{subscribers-wnMyNYZd.mjs.map → subscribers-DVa-Pr45.mjs.map} +1 -1
  34. package/package.json +19 -12
  35. package/dist/Bus-BvF4VShN.mjs.map +0 -1
  36. package/dist/Plugin-D9ykXA5g.mjs.map +0 -1
  37. package/dist/cursor-CuoA9cRh.mjs.map +0 -1
  38. package/dist/slashRouteLeaves-De1SxqnX.mjs.map +0 -1
@@ -1,9 +1,10 @@
1
+ import { H as Notice, R as InteractionRoutes, r as CoreBase } from "./phases-C5Steaa2.mjs";
1
2
  import { t as Constructor } from "./basic-Dng__Ena.mjs";
2
- import { g as ReplyTelemetry, h as Notice, k as InteractionRoutes, r as CoreBase, v as AckState } from "./phases-hBxMCD2V.mjs";
3
3
  import "reflect-metadata";
4
+ import { AnyCustomId, CustomId, CustomIdField } from "@seedcord/custom-id";
4
5
  import { ActionRowBuilder, ButtonBuilder, ChannelSelectMenuBuilder, CheckboxBuilder, CheckboxGroupBuilder, CheckboxGroupOptionBuilder, ContainerBuilder, ContextMenuCommandBuilder, EmbedBuilder, FileBuilder, FileUploadBuilder, LabelBuilder, MediaGalleryBuilder, MentionableSelectMenuBuilder, ModalBuilder, RadioGroupBuilder, RadioGroupOptionBuilder, RoleSelectMenuBuilder, SectionBuilder, SeparatorBuilder, SlashCommandBuilder, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, TextDisplayBuilder, TextInputBuilder, UserSelectMenuBuilder } from "@discordjs/builders";
5
- import { APIMessageTopLevelComponent, APIModalInteractionResponseCallbackData, ApplicationCommandType, ChannelType, Snowflake } from "discord-api-types/v10";
6
- import { DeferOpts, ReplyResponse, SendOpts } from "@seedcord/types";
6
+ import { APIMessageTopLevelComponent, ApplicationCommandType, ChannelType } from "discord-api-types/v10";
7
+ import { ReplyResponse } from "@seedcord/types";
7
8
  //#region src/registries/ContextMenuRegistry.d.ts
8
9
  /** The two context-menu command kinds Discord defines. */
9
10
  type ContextMenuKind = ApplicationCommandType.User | ApplicationCommandType.Message;
@@ -263,30 +264,6 @@ type B = IsTrueFixed<never>;
263
264
  */
264
265
  type IsNever<T> = [T] extends [never] ? true : false;
265
266
  //#endregion
266
- //#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/non-empty-tuple.d.ts
267
- /**
268
- Matches any non-empty tuple.
269
-
270
- @example
271
- ```
272
- import type {NonEmptyTuple} from 'type-fest';
273
-
274
- const sum = (...numbers: NonEmptyTuple<number>) => numbers.reduce((total, value) => total + value, 0);
275
-
276
- sum(1, 2, 3);
277
- // Ok
278
-
279
- // @ts-expect-error
280
- sum();
281
- // Error: Expected at least 1 arguments, but got 0.
282
- ```
283
-
284
- @see {@link RequireAtLeastOne} for objects
285
-
286
- @category Array
287
- */
288
- type NonEmptyTuple<T = unknown> = readonly [T, ...T[]];
289
- //#endregion
290
267
  //#region ../../node_modules/.pnpm/type-fest@5.8.0/node_modules/type-fest/source/promisable.d.ts
291
268
  /**
292
269
  Create a type that represents either the value or the value wrapped in `PromiseLike`.
@@ -348,169 +325,6 @@ declare function RegisterCommand(scope: 'global'): (ctor: CommandCtor) => void;
348
325
  */
349
326
  declare function RegisterCommand(scope: 'guild', guilds: string[]): (ctor: CommandCtor) => void;
350
327
  //#endregion
351
- //#region src/customId/Field.d.ts
352
- /**
353
- * One field in a customId shape, its wire kind plus the type it decodes to.
354
- *
355
- * @internal
356
- */
357
- interface CustomIdField<Decoded> {
358
- /** Which wire encoding this field uses. */
359
- readonly kind: 'snowflake' | 'uuid' | 'int' | 'bool' | 'oneOf' | 'string';
360
- /** Lower bound, for a bounded int field. */
361
- readonly min?: number;
362
- /** Upper bound, for a bounded int field. */
363
- readonly max?: number;
364
- /** The allowed values, for a oneOf field. */
365
- readonly choices?: readonly string[];
366
- /** Phantom only, carries the decoded type and is never set at runtime. */
367
- readonly decoded?: Decoded;
368
- }
369
- /**
370
- * The set of fields a customId carries, keyed by name.
371
- *
372
- * @internal
373
- */
374
- type CustomIdShape = Record<string, CustomIdField<unknown>>;
375
- /**
376
- * The decoded result, each field name mapped to its decoded type.
377
- *
378
- * @internal
379
- */
380
- type DecodedParams<Shape extends CustomIdShape> = { [Name in keyof Shape]: Shape[Name] extends CustomIdField<infer Decoded> ? Decoded : never; };
381
- //#endregion
382
- //#region src/customId/CustomId.d.ts
383
- /** Strip the layout hash off the routeKey to recover the stable prefix the controller routes by. @internal */
384
- declare function prefixOf(wire: string): string;
385
- /**
386
- * A typed customId. The single source of truth shared by the component that mints it and the handler
387
- * that reads it. This gives you typed reads on the `.customId` field in components. Values are packed
388
- * into a compact wire string, which fits more of them inside Discord's 100-char limit.
389
- *
390
- * @typeParam Prefix - The stable route prefix, e.g. 'approve'.
391
- * @typeParam Shape - The accumulated fields, filled in by the chain.
392
- *
393
- * @example
394
- * ```ts
395
- * const ApproveId = new CustomId('approve')
396
- * .snowflake('userId')
397
- * .oneOf('action', ['approve', 'deny']);
398
- *
399
- * // Set the custom id on a button when creating it.
400
- * new ButtonBuilder().setCustomId(ApproveId.encode({ userId: '123', action: 'approve' }));
401
- *
402
- * // in the handler, userId comes back a string
403
- * const { userId, action } = this.params; // userId: string, action: 'approve' | 'deny'
404
- * await this.event.guild?.members.fetch(userId);
405
- * ```
406
- */
407
- declare class CustomId<Prefix extends string, Shape extends CustomIdShape = {}> {
408
- /** The stable route prefix, e.g. 'approve'. */
409
- readonly prefix: Prefix;
410
- /** The field definitions accumulated by the chain, keyed by name. */
411
- readonly shape: Shape;
412
- /** The prefix plus a short hash of the shape, the part of the wire before the colon. */
413
- readonly routeKey: string;
414
- constructor(prefix: Prefix, shape?: Shape);
415
- private add;
416
- /**
417
- * Add a Discord ID field, decoded as a string (the `Snowflake` type from discord-api-types).
418
- *
419
- * @example
420
- * ```ts
421
- * new CustomId('ban').snowflake('userId');
422
- * ```
423
- */
424
- snowflake<Name extends string>(name: Name): CustomId<Prefix, Shape & Record<Name, CustomIdField<Snowflake>>>;
425
- /**
426
- * Add a UUID field, decoded as a lowercase uuid string.
427
- *
428
- * @example
429
- * ```ts
430
- * new CustomId('ticket').uuid('ticketId');
431
- * ```
432
- */
433
- uuid<Name extends string>(name: Name): CustomId<Prefix, Shape & Record<Name, CustomIdField<string>>>;
434
- /**
435
- * Add an integer field with no bounds, for a value up to 2^53.
436
- *
437
- * @example
438
- * ```ts
439
- * new CustomId('shop').int('amount');
440
- * ```
441
- */
442
- int<Name extends string>(name: Name): CustomId<Prefix, Shape & Record<Name, CustomIdField<number>>>;
443
- /**
444
- * Add an integer field bounded by min and max, so it packs into fewer characters on the wire.
445
- *
446
- * @example
447
- * ```ts
448
- * new CustomId('paginate').int('page', 1, 50);
449
- * ```
450
- */
451
- int<Name extends string>(name: Name, min: number, max: number): CustomId<Prefix, Shape & Record<Name, CustomIdField<number>>>;
452
- /**
453
- * Add a boolean flag.
454
- *
455
- * @example
456
- * ```ts
457
- * new CustomId('settings').bool('silent');
458
- * ```
459
- */
460
- bool<Name extends string>(name: Name): CustomId<Prefix, Shape & Record<Name, CustomIdField<boolean>>>;
461
- /**
462
- * Add a field that is one value from a fixed list, decoded as the literal union. No `as const` needed.
463
- *
464
- * @example
465
- * ```ts
466
- * new CustomId('poll').oneOf('choice', ['yes', 'no', 'abstain']);
467
- * ```
468
- */
469
- oneOf<Name extends string, const Choices extends NonEmptyTuple<string>>(name: Name, choices: Choices): CustomId<Prefix, Shape & Record<Name, CustomIdField<Choices[number]>>>;
470
- /**
471
- * Add a free short text field. Avoid it where possible. It cannot be packed, which makes it the most
472
- * expensive field on the wire.
473
- *
474
- * @example
475
- * ```ts
476
- * new CustomId('note').str('message');
477
- * ```
478
- */
479
- str<Name extends string>(name: Name): CustomId<Prefix, Shape & Record<Name, CustomIdField<string>>>;
480
- /**
481
- * Mint a wire string from values. Throws if a value is out of its field's range or the wire is over 100 chars.
482
- *
483
- * @param values - One value per field, typed by the chain.
484
- * @returns The wire string to put on the component's customId.
485
- */
486
- encode(values: DecodedParams<Shape>): string;
487
- /**
488
- * Read a wire string back into values.
489
- *
490
- * - This will refuse with a default Notice when the shape changed since the wire was minted.
491
- * - Or refuse with a different default Notice on a corrupt or foreign wire.
492
- *
493
- * @param wire - The customId string from the interaction.
494
- * @returns The decoded values, typed by the chain.
495
- */
496
- decode(wire: string): DecodedParams<Shape>;
497
- /** True if this wire was minted from this customId's prefix, ignoring the shape hash. */
498
- owns(wire: string): boolean;
499
- }
500
- /** @internal */
501
- type AnyCustomId = CustomId<string, CustomIdShape>;
502
- /**
503
- * The outcome of decoding a wire against several customIds, the matched prefix paired with its values.
504
- *
505
- * @internal
506
- */
507
- type DecodedRoute<Defs extends readonly AnyCustomId[]> = { [Index in keyof Defs]: Defs[Index] extends AnyCustomId ? {
508
- readonly prefix: Defs[Index]['prefix'];
509
- readonly params: DecodedParams<Defs[Index]['shape']>;
510
- } : never; }[number];
511
- /** @internal */
512
- declare function decodeFor<Defs extends readonly AnyCustomId[]>(defs: Defs, wire: string): DecodedRoute<Defs>;
513
- //#endregion
514
328
  //#region src/decorators/interactionRoutes.d.ts
515
329
  /** The select menu kinds the select route decorators take. */
516
330
  declare enum SelectMenuKind {
@@ -548,65 +362,6 @@ interface SerializedReply<TNative = never> {
548
362
  }
549
363
  declare function serializeReply<TNative>(response: ReplyResponse<TNative> | string, routeId: string): SerializedReply<TNative>;
550
364
  //#endregion
551
- //#region src/reply/BaseReplySender.d.ts
552
- /** The shape djs modal builders emit from `toJSON()`. */
553
- interface ModalLike {
554
- toJSON(): APIModalInteractionResponseCallbackData;
555
- }
556
- /**
557
- * Tracks acknowledgement state and throws a translated `SeedcordError` on an illegal verb before any
558
- * transport call. Every verb runs the legality check, calls the transport's wire writer, then updates
559
- * the state and the ack trace. Each transport binds `TMessage` to its own created-message type and
560
- * supplies the writers.
561
- */
562
- declare abstract class BaseReplySender<TMessage extends {
563
- id: string;
564
- }, TNative = never> {
565
- protected readonly routeId: string;
566
- private readonly telemetry;
567
- private state;
568
- private readonly sent;
569
- private ackedBy?;
570
- protected constructor(routeId: string, telemetry: ReplyTelemetry, initialState?: AckState);
571
- private report;
572
- private attempt;
573
- reply(response: ReplyResponse<TNative> | string, opts?: SendOpts): Promise<TMessage>;
574
- defer(opts?: DeferOpts): Promise<void>;
575
- deferUpdate(): Promise<void>;
576
- /**
577
- * After a deferUpdate the state stays deferred-update. Calling this again rewrites. The returned message
578
- * is the source message, editable only through a bare `update` or `edit`. A targeted `edit` or `delete`
579
- * of it throws the foreign-target error.
580
- */
581
- update(response: ReplyResponse<TNative> | string): Promise<TMessage>;
582
- followUp(response: ReplyResponse<TNative> | string, opts?: SendOpts): Promise<TMessage>;
583
- edit(response: ReplyResponse<TNative> | string): Promise<TMessage>;
584
- edit(target: TMessage, response: ReplyResponse<TNative> | string): Promise<TMessage>;
585
- delete(): Promise<void>;
586
- delete(target: TMessage): Promise<void>;
587
- /** Routes to the verb the current ack state permits. Every state has a route, so the illegal-ack throw is unreachable. */
588
- send(response: ReplyResponse<TNative> | string, opts?: SendOpts): Promise<TMessage>;
589
- /** Must be the initial response. */
590
- showModal(modal: ModalLike): Promise<void>;
591
- protected serialize(response: ReplyResponse<TNative> | string): SerializedReply<TNative>;
592
- protected remember(created: TMessage): TMessage;
593
- private requireMessage;
594
- private editOriginal;
595
- private checkLegality;
596
- private transition;
597
- protected guardModalSource(): void;
598
- protected abstract writeReply(response: ReplyResponse<TNative> | string, opts?: SendOpts): Promise<TMessage | undefined>;
599
- protected abstract writeDefer(opts?: DeferOpts): Promise<void>;
600
- protected abstract writeDeferUpdate(): Promise<void>;
601
- protected abstract writeUpdate(response: ReplyResponse<TNative> | string): Promise<TMessage | undefined>;
602
- protected abstract writeFollowUp(response: ReplyResponse<TNative> | string, opts?: SendOpts): Promise<TMessage>;
603
- protected abstract writeEditOriginal(response: ReplyResponse<TNative> | string): Promise<TMessage>;
604
- protected abstract writeEditTarget(targetId: string, response: ReplyResponse<TNative> | string): Promise<TMessage>;
605
- protected abstract writeDeleteOriginal(): Promise<void>;
606
- protected abstract writeDeleteTarget(targetId: string): Promise<void>;
607
- protected abstract writeModal(data: APIModalInteractionResponseCallbackData): Promise<void>;
608
- }
609
- //#endregion
610
365
  //#region src/gates/Gate.d.ts
611
366
  /**
612
367
  * The transport-agnostic gate context, the scalar identity of the acting user resolvable from any
@@ -821,7 +576,8 @@ type RequiredOf<TGate> = TGate extends Gate<infer Ctx> ? Ctx : never;
821
576
  type IntersectRequired<Gates extends readonly Gate<GateContextBase>[]> = Gates extends readonly [infer First extends Gate<GateContextBase>, ...infer Rest extends readonly Gate<GateContextBase>[]] ? RequiredOf<First> & IntersectRequired<Rest> : unknown;
822
577
  type TwoOrMore<Item> = readonly [Item, Item, ...Item[]];
823
578
  type GateName<TGate> = TGate extends Gate<GateContextBase, infer Name> ? Name : string;
824
- type JoinNames<Gates extends readonly Gate<GateContextBase>[], Sep extends string> = Gates extends readonly [infer Only extends Gate<GateContextBase>] ? GateName<Only> : Gates extends readonly [infer First extends Gate<GateContextBase>, ...infer Rest extends readonly Gate<GateContextBase>[]] ? `${GateName<First>}${Sep}${JoinNames<Rest, Sep>}` : string;
579
+ type Grouped<Name extends string> = Name extends `${string} & ${string}` | `${string} | ${string}` ? `(${Name})` : Name;
580
+ type JoinNames<Gates extends readonly Gate<GateContextBase>[], Sep extends string> = Gates extends readonly [infer Only extends Gate<GateContextBase>] ? Grouped<GateName<Only>> : Gates extends readonly [infer First extends Gate<GateContextBase>, ...infer Rest extends readonly Gate<GateContextBase>[]] ? `${Grouped<GateName<First>>}${Sep}${JoinNames<Rest, Sep>}` : string;
825
581
  type GateMismatch<Name extends string, Want extends string, Got extends string> = `gate '${Name}' requires a ${Want} handler, and this handler is ${Got}`;
826
582
  type GateFitsWith<Provided, ProvidedLabel extends string, TGate, ReqLabel extends string> = [Provided] extends [RequiredOf<TGate>] ? TGate : Constructor<[GateMismatch<GateName<TGate>, ReqLabel, ProvidedLabel>]>;
827
583
  //#endregion
@@ -1029,5 +785,5 @@ type PageCursor<Prefix extends string> = CustomId<Prefix, {
1029
785
  /** Build the page cursor for a paginator. */
1030
786
  declare function pageCursor<Prefix extends string>(prefix: Prefix): PageCursor<Prefix>;
1031
787
  //#endregion
1032
- export { RegisterCommand as $, ModalLike as A, SelectMenuKind as B, Gate as C, defineEffectGate as D, RequiredOf as E, ComponentKindBrand as F, storeComponentRoute as G, contextMenuRouteOf as H, ContextMenuKindBrand as I, CustomId as J, storeInteractionRoute as K, ContextMenuNamesBrand as L, serializeReply as M, AutocompleteRouteBrand as N, defineGate as O, ComponentDefsBrand as P, CommandMeta as Q, SlashRouteBrand as R, EffectGate as S, GuildPermissionsContext as T, interactionRoutesOf as U, areRoutes as V, selectMenuRouteOf as W, prefixOf as X, decodeFor as Y, DecodedParams as Z, pickNotice as _, AutocompleteOptions as a, RowType as at, JoinNames as b, FocusedField as c, RouteCache as ct, RequirePermissionsOptions as d, SlashRouteEntry as dt, Promisable as et, RequireRole as f, ContextMenuKind as ft, GateNoticeOptions as g, UserContextMenuRegistry as gt, PermissionScope as h, NamesFor as ht, AutocompletableNames as i, BuilderType as it, SerializedReply as j, BaseReplySender as k, RequireBotPermissions as l, SlashOption as lt, PermissionNames as m, MessageContextMenuRegistry as mt, PageCursor as n, BuilderComponent as nt, ChoiceValueOf as o, CacheFor as ot, RequireRoleOptions as p, MenuCacheFor as pt, AnyCustomId as q, pageCursor as r, RowComponent as rt, EntryFor as s, OptionKind as st, PAGE_MAX as t, IsNever as tt, RequirePermissions as u, SlashRegistry as ut, GateFitsWith as v, GateContextBase as w, TwoOrMore as x, IntersectRequired as y, RoutableConstructor as z };
1033
- //# sourceMappingURL=cursor-BANzac53.d.mts.map
788
+ export { CacheFor as $, serializeReply as A, contextMenuRouteOf as B, Gate as C, defineEffectGate as D, RequiredOf as E, ContextMenuNamesBrand as F, CommandMeta as G, selectMenuRouteOf as H, SlashRouteBrand as I, IsNever as J, RegisterCommand as K, RoutableConstructor as L, ComponentDefsBrand as M, ComponentKindBrand as N, defineGate as O, ContextMenuKindBrand as P, RowType as Q, SelectMenuKind as R, EffectGate as S, GuildPermissionsContext as T, storeComponentRoute as U, interactionRoutesOf as V, storeInteractionRoute as W, RowComponent as X, BuilderComponent as Y, BuilderType as Z, pickNotice as _, AutocompleteOptions as a, ContextMenuKind as at, JoinNames as b, FocusedField as c, NamesFor as ct, RequirePermissionsOptions as d, OptionKind as et, RequireRole as f, GateNoticeOptions as g, PermissionScope as h, AutocompletableNames as i, SlashRouteEntry as it, AutocompleteRouteBrand as j, SerializedReply as k, RequireBotPermissions as l, UserContextMenuRegistry as lt, PermissionNames as m, PageCursor as n, SlashOption as nt, ChoiceValueOf as o, MenuCacheFor as ot, RequireRoleOptions as p, Promisable as q, pageCursor as r, SlashRegistry as rt, EntryFor as s, MessageContextMenuRegistry as st, PAGE_MAX as t, RouteCache as tt, RequirePermissions as u, GateFitsWith as v, GateContextBase as w, TwoOrMore as x, IntersectRequired as y, areRoutes as z };
789
+ //# sourceMappingURL=cursor-CO_MTgdZ.d.mts.map