@seedcord/core 0.3.0 → 0.4.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.
Files changed (39) hide show
  1. package/dist/{Bus-DcuUtOEL.mjs → Bus-BVwmKc-A.mjs} +51 -17
  2. package/dist/Bus-BVwmKc-A.mjs.map +1 -0
  3. package/dist/Pluggable-Cf5-WWmW.mjs +280 -0
  4. package/dist/Pluggable-Cf5-WWmW.mjs.map +1 -0
  5. package/dist/Pluggable-DFNUIlJM.d.mts +148 -0
  6. package/dist/{Plugin-Bkeqcjy6.mjs → Plugin-C6oMqWf8.mjs} +32 -7
  7. package/dist/Plugin-C6oMqWf8.mjs.map +1 -0
  8. package/dist/Plugin-CG9pWbPF.d.mts +193 -0
  9. package/dist/{cursor-DKKKUa_7.d.mts → cursor-BcRfmTSo.d.mts} +27 -140
  10. package/dist/{cursor-Cv1Ui6gZ.mjs → cursor-GBUYz3jk.mjs} +377 -176
  11. package/dist/cursor-GBUYz3jk.mjs.map +1 -0
  12. package/dist/{index-uBwh8r7x.d.mts → index-ZzdQafFv.d.mts} +2 -2
  13. package/dist/index.d.mts +132 -19
  14. package/dist/index.mjs +186 -19
  15. package/dist/index.mjs.map +1 -1
  16. package/dist/internal.index.d.mts +11 -4
  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 +10 -146
  20. package/dist/node-internal.index.mjs +43 -470
  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/{Plugin-B6iRzm3g.d.mts → phases-F8yvPd60.d.mts} +111 -207
  26. package/dist/plugin.index.d.mts +2 -2
  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-CbYRwqMY.mjs} +10 -2
  31. package/dist/slashRouteLeaves-CbYRwqMY.mjs.map +1 -0
  32. package/dist/subscribers-CGGQkUfM.mjs +139 -0
  33. package/dist/subscribers-CGGQkUfM.mjs.map +1 -0
  34. package/package.json +14 -8
  35. package/dist/Bus-DcuUtOEL.mjs.map +0 -1
  36. package/dist/Plugin-Bkeqcjy6.mjs.map +0 -1
  37. package/dist/cursor-Cv1Ui6gZ.mjs.map +0 -1
  38. package/dist/slashRouteLeaves-De1SxqnX.mjs.map +0 -1
  39. package/dist/subscribers-DuHg-bGT.mjs +0 -3
@@ -1,75 +1,12 @@
1
1
  import { n as CommandBuilder, r as DeployResult } from "./basic-Dng__Ena.mjs";
2
- import { _ as Bus, a as PluginCtor, d as Transport, f as TransportAssert, g as CoreBase, h as StartupPhase, i as PluginArgs, l as Runtime, m as ShutdownPhase, n as Initializeable, o as PluginLike, s as ChannelKeyAssert, t as CoreParamAssert, u as RuntimeAssert } from "./Plugin-B6iRzm3g.mjs";
3
- import "./index-uBwh8r7x.mjs";
2
+ import { i as Bus, n as StartupPhase, r as CoreBase, t as ShutdownPhase } from "./phases-F8yvPd60.mjs";
3
+ import "./index-ZzdQafFv.mjs";
4
+ import { n as Initializeable } from "./Plugin-CG9pWbPF.mjs";
4
5
  import { t as ContextMenuLeaves } from "./contextMenuLeaves-COzDYa6c.mjs";
6
+ import { a as LifecycleTask, i as CoordinatedShutdown, n as shutdownOf } from "./Pluggable-DFNUIlJM.mjs";
5
7
  import { Logger } from "@seedcord/logger";
6
- import { REST } from "@discordjs/rest";
7
8
  import { IncomingMessage, ServerResponse } from "node:http";
8
- import { Config, HealthCheckConfig, HealthCheckOption, HmrAware, HmrUpdateEvent, IRateLimiter } from "@seedcord/types";
9
- //#region src/node/Lifecycle/LifecycleTypes.d.ts
10
- interface LifecycleTask {
11
- name: string;
12
- task: () => Promise<void>;
13
- timeout: number;
14
- }
15
- //#endregion
16
- //#region src/node/Lifecycle/CoordinatedLifecycle.d.ts
17
- declare abstract class CoordinatedLifecycle<TPhase extends number> {
18
- protected readonly phaseOrder: TPhase[];
19
- protected readonly phaseEnum: Record<number, string>;
20
- protected readonly logger: Logger;
21
- protected readonly tasksMap: Map<TPhase, LifecycleTask[]>;
22
- protected constructor(loggerName: string, phaseOrder: TPhase[], phaseEnum: Record<number, string>);
23
- addTask(phase: TPhase, taskName: string, task: () => Promise<void>, timeoutMs: number): void;
24
- removeTask(phase: TPhase, taskName: string): boolean;
25
- protected runPhase(phase: TPhase): Promise<void>;
26
- protected runTaskWithTimeout(phase: TPhase, task: LifecycleTask): Promise<void>;
27
- protected isAborted(): boolean;
28
- protected abstract canAddTask(): boolean;
29
- protected abstract canRemoveTask(): boolean;
30
- protected abstract getTaskType(): string;
31
- protected abstract executeTasksInPhase(phase: TPhase, tasks: LifecycleTask[]): Promise<PromiseSettledResult<void>[]>;
32
- }
33
- //#endregion
34
- //#region src/node/Lifecycle/CoordinatedShutdown.d.ts
35
- declare class CoordinatedShutdown extends CoordinatedLifecycle<ShutdownPhase> {
36
- private isShuttingDown;
37
- private hasShutdown;
38
- private exitCode;
39
- private onSigTerm;
40
- private onSigInt;
41
- private startupGate?;
42
- constructor();
43
- protected canAddTask(): boolean;
44
- protected canRemoveTask(): boolean;
45
- protected getTaskType(): string;
46
- protected executeTasksInPhase(phase: ShutdownPhase, tasks: LifecycleTask[]): Promise<PromiseSettledResult<void>[]>;
47
- private registerSignalHandlers;
48
- /** @internal */
49
- removeSignalHandlers(): void;
50
- /** @internal run() awaits this so boot finishes registering its dispose tasks first */
51
- gateOnStartup(settled: Promise<void>): void;
52
- addTask(phase: ShutdownPhase, taskName: string, task: () => Promise<void>, timeoutMs?: number): void;
53
- removeTask(phase: ShutdownPhase, taskName: string): boolean;
54
- run(exitCode?: number, exitProcess?: boolean): Promise<void>;
55
- }
56
- //#endregion
57
- //#region src/node/Lifecycle/CoordinatedStartup.d.ts
58
- declare class CoordinatedStartup extends CoordinatedLifecycle<StartupPhase> {
59
- private isStartingUp;
60
- private hasStarted;
61
- constructor();
62
- addTask(phase: StartupPhase, taskName: string, task: () => Promise<void>, timeoutMs?: number): void;
63
- protected canAddTask(): boolean;
64
- protected canRemoveTask(): boolean;
65
- protected getTaskType(): string;
66
- protected executeTasksInPhase(phase: StartupPhase, tasks: LifecycleTask[]): Promise<PromiseSettledResult<void>[]>;
67
- run(): Promise<void>;
68
- protected isAborted(): boolean;
69
- abort(): void;
70
- get isReady(): boolean;
71
- }
72
- //#endregion
9
+ import { HealthCheckConfig, HealthCheckOption, HmrAware, HmrUpdateEvent } from "@seedcord/types";
73
10
  //#region src/node/HealthCheck.d.ts
74
11
  declare class HealthCheck {
75
12
  readonly logger: Logger;
@@ -93,72 +30,6 @@ declare class HealthResponder {
93
30
  tryRespond(req: IncomingMessage, res: ServerResponse): boolean;
94
31
  }
95
32
  //#endregion
96
- //#region src/node/Pluggable.d.ts
97
- /**
98
- * Base class for a plugin host, a transport `Seedcord` class.
99
- *
100
- * Plugins are attached during configuration and initialized during startup, sequentially in attach
101
- * order within each phase.
102
- */
103
- declare abstract class Pluggable<BotT extends Transport, BotRt extends Runtime> implements CoreBase {
104
- abstract readonly config: Config;
105
- abstract readonly rest: REST;
106
- abstract readonly rateLimiter: IRateLimiter;
107
- abstract readonly bus: Bus;
108
- /** @see {@link CoordinatedShutdown} */
109
- readonly shutdown: CoordinatedShutdown;
110
- /** @see {@link CoordinatedStartup} */
111
- readonly startup: CoordinatedStartup;
112
- protected isInitialized: boolean;
113
- protected startFailed: boolean;
114
- protected readonly plugins: PluginLike[];
115
- private readonly pluginLogger;
116
- private readonly attachments;
117
- private readonly completedInits;
118
- private readonly disposePhases;
119
- private pluginTasksRegistered;
120
- private static isInstantiated;
121
- private static liveShutdown?;
122
- constructor(shutdown: CoordinatedShutdown, startup: CoordinatedStartup);
123
- /** @internal */
124
- protected init(): Promise<this>;
125
- /** @internal codegen reads these to emit the `Core` augmentation */
126
- get pluginKeys(): readonly string[];
127
- /** @internal so the next host can construct */
128
- protected static reset(): void;
129
- /**
130
- * Attaches a plugin to this instance.
131
- *
132
- * The plugin initializes during startup, after every plugin attached before it, and becomes
133
- * available as a property on `core`. `seedcord codegen` writes the `Core` augmentation that
134
- * types it.
135
- *
136
- * A plugin declaring a `transport` or `runtime` this host does not run is a compile error on
137
- * this call. An edge host takes no plugins at all. A plugin constructor narrowing its first
138
- * parameter past `CoreBase` is a compile error here too. Read the transport `Core` off `this.core`.
139
- *
140
- * @typeParam Key - The property name for accessing the plugin
141
- * @typeParam Ctor - The plugin constructor type
142
- * @param key - Property name to access the plugin instance
143
- * @param Plugin - Plugin constructor class
144
- * @param args - Additional arguments to pass to the plugin constructor
145
- * @returns This instance with the plugin attached as a typed property
146
- * @throws A **SeedcordError** When called after initialization or if key already exists or is reserved
147
- * @example
148
- * ```typescript
149
- * seedcord.attach('db', Mongoose, { uri: 'mongodb://...', name: 'seedcord', dir: ... })
150
- * ```
151
- */
152
- attach<Key extends string, Ctor extends PluginCtor>(this: this, key: ChannelKeyAssert<Key>, Plugin: Ctor & TransportAssert<InstanceType<Ctor>, BotT> & RuntimeAssert<InstanceType<Ctor>, BotRt> & CoreParamAssert<Ctor>, ...args: PluginArgs<Ctor>): this & Record<Key, InstanceType<Ctor>>;
153
- private registerPluginTasks;
154
- private runInits;
155
- private registerReadyTask;
156
- private registerDisposeTask;
157
- private runDisposals;
158
- private disposeCompleted;
159
- private rollback;
160
- }
161
- //#endregion
162
33
  //#region src/node/Lifecycle/withTimeout.d.ts
163
34
  declare function settleWithin(work: Promise<unknown>, timeoutMs: number): Promise<void>;
164
35
  //#endregion
@@ -181,21 +52,13 @@ declare class SubscriberLoader implements Initializeable, HmrAware {
181
52
  }
182
53
  //#endregion
183
54
  //#region src/node/commands/CommandRegistry.d.ts
184
- /** @internal */
185
- interface CommandRegistryOptions {
186
- readonly dir: string;
187
- readonly rest: REST;
188
- /** Called at deploy time, because the application id only resolves after login. */
189
- readonly applicationId: () => string;
190
- readonly onDeployed?: (result: DeployResult) => void;
191
- }
192
55
  /**
193
56
  * Scans the command directory, builds each command, and PUTs the global and guild scopes to Discord.
194
57
  *
195
58
  * @internal
196
59
  */
197
60
  declare class CommandRegistry implements Initializeable, HmrAware {
198
- private readonly options;
61
+ private readonly core;
199
62
  private readonly logger;
200
63
  private isInitialised;
201
64
  readonly globalCommands: CommandBuilder[];
@@ -205,7 +68,9 @@ declare class CommandRegistry implements Initializeable, HmrAware {
205
68
  private readonly loadedCommands;
206
69
  private readonly hmrHandler?;
207
70
  private readonly pendingEvents;
208
- constructor(options: CommandRegistryOptions);
71
+ private readonly injector;
72
+ private readonly dir;
73
+ constructor(core: CoreBase);
209
74
  private getArtifacts;
210
75
  /** @internal */
211
76
  init(): Promise<void>;
@@ -215,7 +80,6 @@ declare class CommandRegistry implements Initializeable, HmrAware {
215
80
  /** @internal */
216
81
  onHmr(event: HmrUpdateEvent): Promise<void>;
217
82
  private loadCommands;
218
- private isCommandClass;
219
83
  private registerCommand;
220
84
  private unregisterCommand;
221
85
  /** @internal */
@@ -229,5 +93,5 @@ declare class CommandRegistry implements Initializeable, HmrAware {
229
93
  contextMenuLeaves(): ContextMenuLeaves;
230
94
  }
231
95
  //#endregion
232
- export { CommandRegistry, type CommandRegistryOptions, CoordinatedShutdown, CoordinatedStartup, HealthCheck, HealthResponder, type LifecycleTask, Pluggable, ShutdownPhase, StartupPhase, SubscriberLoader, settleWithin };
96
+ export { CommandRegistry, HealthCheck, HealthResponder, type LifecycleTask, ShutdownPhase, StartupPhase, SubscriberLoader, settleWithin, shutdownOf };
233
97
  //# sourceMappingURL=node-internal.index.d.mts.map