@seedcord/http 0.1.0-next.1 → 0.1.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.
@@ -1,60 +1,65 @@
1
- import { SelectMenuKind } from "@seedcord/core";
1
+ import { SelectMenuKind, SubscriptionKey } from "@seedcord/core";
2
2
  import { ApplicationCommandType } from "discord-api-types/v10";
3
+ import { EventFrequency } from "@seedcord/types";
3
4
 
4
5
  //#region src/manifest/RouteManifest.d.ts
5
6
  /** The command kinds a manifest row registers, the wire enum's other members have no handler base. */
6
7
  type RegistrableCommandType = ApplicationCommandType.ChatInput | ApplicationCommandType.User | ApplicationCommandType.Message;
8
+ /** One file may export several handlers, so the row states which export it registers. */
9
+ interface RouteModule {
10
+ /** The exported binding inside the loaded module. */
11
+ readonly exportName: string;
12
+ /** The source file the row came from, reported when the export is missing. */
13
+ readonly from: string;
14
+ /** Lazy import of the module, evaluated on first hit. */
15
+ readonly load: () => Promise<Record<string, unknown>>;
16
+ }
7
17
  /**
8
18
  * A slash or context-menu command row. `type` picks the per-kind map, `name` is the lookup key. For a
9
19
  * chat-input command with subcommands, `name` is the full route path (`'config/set'`), the same key
10
20
  * `@SlashRoute` registers.
11
21
  */
12
- interface CommandRoute {
22
+ interface CommandRoute extends RouteModule {
13
23
  readonly name: string;
14
24
  readonly type: RegistrableCommandType;
15
- /** Lazy import of the handler module, evaluated on first hit. */
16
- readonly load: () => Promise<unknown>;
17
25
  }
18
26
  /**
19
27
  * A button, select, or modal row. `kind` picks the per-kind map, `prefix` is the stable customId prefix
20
28
  * the receiver routes by (the routeKey minus its layout hash).
21
29
  */
22
- interface ComponentRoute {
30
+ interface ComponentRoute extends RouteModule {
23
31
  readonly kind: 'button' | `${SelectMenuKind}Select` | 'modal';
24
32
  readonly prefix: string;
25
- /** Lazy import of the handler module, evaluated on first hit. */
26
- readonly load: () => Promise<unknown>;
27
33
  }
28
34
  /**
29
35
  * An autocomplete row, its own route keyed by the command's route path, separate from the slash row.
30
36
  */
31
- interface AutocompleteRoute {
37
+ interface AutocompleteRoute extends RouteModule {
32
38
  readonly name: string;
33
- /** Lazy import of the handler module, evaluated on first hit. */
34
- readonly load: () => Promise<unknown>;
35
39
  }
36
40
  /**
37
- * A bus subscriber row. The Bus routes off it without importing the subscriber module. The HTTP engine
38
- * ignores these rows until the Bus ships on this transport.
41
+ * A bus subscriber row. The Bus registers it without importing the subscriber module, and resolves the
42
+ * class on the first publish of one of its keys.
39
43
  */
40
- interface SubscriberRoute {
44
+ interface SubscriberRoute extends RouteModule {
41
45
  /** The subscription keys this subscriber registers for. */
42
- readonly keys: readonly string[];
46
+ readonly keys: readonly SubscriptionKey[];
43
47
  /** Mirrors the `@Subscribe` frequency metadata. */
44
- readonly frequency: 'on' | 'once';
45
- /** Lazy import of the subscriber module. */
46
- readonly load: () => Promise<unknown>;
48
+ readonly frequency: EventFrequency;
47
49
  }
50
+ /** A middleware row. Middleware runs on every dispatch, so it carries no lookup key. */
51
+ type MiddlewareRoute = RouteModule;
48
52
  /**
49
53
  * The static route table the HTTP engine dispatches through, replacing the filesystem handler scan that
50
54
  * cannot run in a bundled isolate. `seedcord build` emits it, the mount path authors it by hand.
51
55
  */
52
56
  interface RouteManifest {
53
- readonly commands: readonly CommandRoute[];
54
- readonly components: readonly ComponentRoute[];
55
- readonly autocomplete: readonly AutocompleteRoute[];
56
- readonly subscribers: readonly SubscriberRoute[];
57
+ readonly commandRoutes: readonly CommandRoute[];
58
+ readonly componentRoutes: readonly ComponentRoute[];
59
+ readonly autocompleteRoutes: readonly AutocompleteRoute[];
60
+ readonly subscriberRoutes: readonly SubscriberRoute[];
61
+ readonly middlewareRoutes: readonly MiddlewareRoute[];
57
62
  }
58
63
  //#endregion
59
64
  export { RouteManifest as t };
60
- //# sourceMappingURL=RouteManifest-BHdAeyLG.d.mts.map
65
+ //# sourceMappingURL=RouteManifest-DE-HCMwd.d.mts.map