@seedcord/services 0.6.0 → 0.7.0-next.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/README.md +1 -1
- package/dist/SeedcordError-BuWVIe6m.d.mts +302 -0
- package/dist/SeedcordError-wt7_KePP.cjs +376 -0
- package/dist/SeedcordError-wt7_KePP.cjs.map +1 -0
- package/dist/SeedcordError-xd-Ib_-z.mjs +313 -0
- package/dist/SeedcordError-xd-Ib_-z.mjs.map +1 -0
- package/dist/index.cjs +1485 -1103
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -656
- package/dist/index.d.mts +2930 -0
- package/dist/index.mjs +1474 -1090
- package/dist/index.mjs.map +1 -1
- package/dist/internal.index.cjs +6 -0
- package/dist/internal.index.d.cts +1 -0
- package/dist/internal.index.d.mts +2 -0
- package/dist/internal.index.mjs +3 -0
- package/package.json +44 -25
- package/dist/index.d.ts +0 -656
package/README.md
CHANGED
|
@@ -10,4 +10,4 @@ _This repository is a work in progress._
|
|
|
10
10
|
- Till a major v1.0.0 release for seedcord, expect breaking changes in minor versions.
|
|
11
11
|
- Documentation will come soon as well!
|
|
12
12
|
|
|
13
|
-
I'm planning to release the first major version by
|
|
13
|
+
I'm planning to release the first major version by Q1 2026. But till then, if you'd like to try using it, you can check out the code in `mock`
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
//#region src/Errors/ErrorCodes.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* All Seedcord error codes.
|
|
4
|
+
*/
|
|
5
|
+
declare enum SeedcordErrorCode {
|
|
6
|
+
/** DISCORD_BOT_TOKEN is not present in the environment. */
|
|
7
|
+
ConfigMissingDiscordToken = 1001,
|
|
8
|
+
/** DISCORD_BOT_TOKEN is present but fails validation. */
|
|
9
|
+
ConfigIncorrectDiscordToken = 1004,
|
|
10
|
+
/** UNKNOWN_EXCEPTION_WEBHOOK_URL is missing when configuring the reporter. */
|
|
11
|
+
ConfigUnknownExceptionWebhookMissing = 1002,
|
|
12
|
+
/** UNKNOWN_EXCEPTION_WEBHOOK_URL is present but fails URL validation. */
|
|
13
|
+
ConfigUnknownExceptionWebhookInvalid = 1003,
|
|
14
|
+
/** Attempted to add lifecycle tasks after startup already completed. */
|
|
15
|
+
LifecycleAddAfterCompletion = 1101,
|
|
16
|
+
/** Attempted to add lifecycle tasks while startup is still running. */
|
|
17
|
+
LifecycleAddDuringRun = 1102,
|
|
18
|
+
/** Attempted to remove lifecycle tasks while startup is still running. */
|
|
19
|
+
LifecycleRemoveDuringRun = 1103,
|
|
20
|
+
/** Provided lifecycle phase identifier is not recognized. */
|
|
21
|
+
LifecycleUnknownPhase = 1104,
|
|
22
|
+
/** Startup phase completed with one or more task failures. */
|
|
23
|
+
LifecyclePhaseFailures = 1105,
|
|
24
|
+
/** A lifecycle task exceeded its configured timeout. */
|
|
25
|
+
LifecycleTaskTimeout = 1106,
|
|
26
|
+
/** Multiple Seedcord instances were created simultaneously. */
|
|
27
|
+
CoreSingletonViolation = 1201,
|
|
28
|
+
/** Plugins cannot be mutated after the core has finished initializing. */
|
|
29
|
+
CorePluginAfterInit = 1202,
|
|
30
|
+
/** A plugin tried to register with a key that already exists. */
|
|
31
|
+
CorePluginKeyExists = 1203,
|
|
32
|
+
/** Bot role lookup failed within the provided guild. */
|
|
33
|
+
CoreBotRoleMissing = 1204,
|
|
34
|
+
/** A bot controller was constructed without its required handlers directory. */
|
|
35
|
+
CoreControllerPathMissing = 1205,
|
|
36
|
+
/** Interaction middleware decorated with disallowed event filters. */
|
|
37
|
+
DecoratorInteractionEventFilter = 1301,
|
|
38
|
+
/** A decorator could not find the original method being decorated. */
|
|
39
|
+
DecoratorMethodNotFound = 1302,
|
|
40
|
+
/** A command decorator attempted to re-register an existing command scope. */
|
|
41
|
+
DecoratorCommandAlreadyRegistered = 1303,
|
|
42
|
+
/** A global command decorator specified guild IDs, which is not allowed. */
|
|
43
|
+
DecoratorCommandGlobalWithGuilds = 1304,
|
|
44
|
+
/** A guild command decorator omitted the required guild ID list. */
|
|
45
|
+
DecoratorCommandGuildWithoutGuilds = 1305,
|
|
46
|
+
/** Middleware priority provided by the decorator was not a finite number. */
|
|
47
|
+
DecoratorInvalidMiddlewarePriority = 1306,
|
|
48
|
+
/** buildSlashRoute received an invalid argument. */
|
|
49
|
+
UtilInvalidSlashRouteArgument = 1403,
|
|
50
|
+
/** StrictEventEmitter.waitFor was aborted via its AbortSignal. */
|
|
51
|
+
EventEmitterWaitForAborted = 1501,
|
|
52
|
+
/** StrictEventEmitter.waitFor exceeded its configured timeout. */
|
|
53
|
+
EventEmitterWaitForTimeout = 1502,
|
|
54
|
+
/** Mongo service class is missing the `@RegisterMongoService` decorator. */
|
|
55
|
+
PluginMongoServiceDecoratorMissing = 2101,
|
|
56
|
+
/** Mongo model class is missing the `@RegisterMongoModel` decorator. */
|
|
57
|
+
PluginMongoModelDecoratorMissing = 2102,
|
|
58
|
+
/** Mongo client failed to establish a connection. */
|
|
59
|
+
PluginMongoConnectionFailed = 2103,
|
|
60
|
+
/** Mongo client failed to disconnect cleanly during shutdown. */
|
|
61
|
+
PluginMongoDisconnectFailed = 2104,
|
|
62
|
+
/** Mongo `services` was accessed before the plugin finished initializing. */
|
|
63
|
+
PluginMongoServicesNotReady = 2105,
|
|
64
|
+
/** KPG service class is missing the `@RegisterKpgService` decorator. */
|
|
65
|
+
PluginKpgServiceDecoratorMissing = 2201,
|
|
66
|
+
/** KPG service class is missing its table metadata. */
|
|
67
|
+
PluginKpgServiceTableMissing = 2202,
|
|
68
|
+
/** Migration manager received an invalid step count. */
|
|
69
|
+
PluginKpgInvalidStepCount = 2203,
|
|
70
|
+
/** Migration direction was not recognized. */
|
|
71
|
+
PluginKpgUnknownDirection = 2204,
|
|
72
|
+
/** Provided migrations path could not be resolved. */
|
|
73
|
+
PluginKpgUnresolvedMigrationsPath = 2205,
|
|
74
|
+
/** No migration files were found for execution. */
|
|
75
|
+
PluginKpgNoMigrationFiles = 2206,
|
|
76
|
+
/** A migration module failed to export the expected functions. */
|
|
77
|
+
PluginKpgInvalidMigrationModule = 2207,
|
|
78
|
+
/** An arbitrary (non-Error) failure was reported by a migration. */
|
|
79
|
+
PluginKpgNonErrorFailure = 2208,
|
|
80
|
+
/** Postgres pool failed to close cleanly during shutdown. */
|
|
81
|
+
PluginKpgDisconnectFailed = 2209,
|
|
82
|
+
/** KPG `services` was accessed before the plugin finished initializing. */
|
|
83
|
+
PluginKpgServicesNotReady = 2210,
|
|
84
|
+
/** Config file default export was not an object. */
|
|
85
|
+
CliConfigInvalidExport = 3101,
|
|
86
|
+
/** Config is missing the required instance string. */
|
|
87
|
+
CliConfigMissingInstance = 3102,
|
|
88
|
+
/** Config root was provided but not a string. */
|
|
89
|
+
CliConfigInvalidRoot = 3103,
|
|
90
|
+
/** Unable to locate a Seedcord config file. */
|
|
91
|
+
CliConfigNotFound = 3104,
|
|
92
|
+
/** CLI entry file does not exist. */
|
|
93
|
+
CliEntryNotFound = 3105,
|
|
94
|
+
/** tsx failed to import the provided entry file. */
|
|
95
|
+
CliTsxImportFailed = 3106,
|
|
96
|
+
/** Native import and jiti fallback both failed. */
|
|
97
|
+
CliImportFailed = 3107,
|
|
98
|
+
/** Seedcord instance export is missing a start() method. */
|
|
99
|
+
CliInstanceInvalid = 3108,
|
|
100
|
+
/** Seedcord instance threw during startup. */
|
|
101
|
+
CliStartFailed = 3109,
|
|
102
|
+
/** Config is missing the required entry string. */
|
|
103
|
+
CliConfigMissingEntry = 3110,
|
|
104
|
+
/** Config build options must be an object when provided. */
|
|
105
|
+
CliConfigInvalidBuild = 3111,
|
|
106
|
+
/** Config build outDir must be a string when provided. */
|
|
107
|
+
CliConfigInvalidBuildOutDir = 3112,
|
|
108
|
+
/** Config build tsconfig must be a string when provided. */
|
|
109
|
+
CliConfigInvalidBuildTsconfig = 3113,
|
|
110
|
+
/** Config build bootstrap must be a string when provided. */
|
|
111
|
+
CliConfigInvalidBuildBootstrap = 3114,
|
|
112
|
+
/** Entry file must be inside the configured root directory. */
|
|
113
|
+
CliConfigEntryOutsideRoot = 3115,
|
|
114
|
+
/** Unable to locate a TypeScript config file for builds. */
|
|
115
|
+
CliBuildTsconfigNotFound = 3116,
|
|
116
|
+
/** TypeScript reported diagnostics during emit. */
|
|
117
|
+
CliBuildFailed = 3117,
|
|
118
|
+
/** Unable to write the generated bootstrap file. */
|
|
119
|
+
CliBootstrapWriteFailed = 3118,
|
|
120
|
+
/** Config tsconfig must be a string when provided. */
|
|
121
|
+
CliConfigInvalidTsconfig = 3119,
|
|
122
|
+
/** Config hmr options must be an object when provided. */
|
|
123
|
+
CliConfigInvalidHmr = 3120,
|
|
124
|
+
/** Config hmr restart patterns must be an array of strings when provided. */
|
|
125
|
+
CliConfigInvalidHmrRestart = 3121
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/Errors/ErrorMessages.d.ts
|
|
129
|
+
/**
|
|
130
|
+
* Mapping of Seedcord error codes to their corresponding message formatters.
|
|
131
|
+
*
|
|
132
|
+
* @internal
|
|
133
|
+
*/
|
|
134
|
+
declare const messages: {
|
|
135
|
+
1001: () => string;
|
|
136
|
+
1004: () => string;
|
|
137
|
+
1002: () => string;
|
|
138
|
+
1003: () => string;
|
|
139
|
+
1101: () => string;
|
|
140
|
+
1102: () => string;
|
|
141
|
+
1103: () => string;
|
|
142
|
+
1104: (phase: unknown) => string;
|
|
143
|
+
1105: (phase: string, failures: number) => string;
|
|
144
|
+
1106: (taskName: string, timeout: number) => string;
|
|
145
|
+
1201: () => string;
|
|
146
|
+
1202: () => string;
|
|
147
|
+
1203: (key: string) => string;
|
|
148
|
+
1204: (guildId?: string) => string;
|
|
149
|
+
1205: (controllerName: string, pathKind: string) => string;
|
|
150
|
+
1301: () => string;
|
|
151
|
+
1302: () => string;
|
|
152
|
+
1303: (commandName: string, existingScope: string, requestedScope: string) => string;
|
|
153
|
+
1304: () => string;
|
|
154
|
+
1305: () => string;
|
|
155
|
+
1306: () => string;
|
|
156
|
+
1403: () => string;
|
|
157
|
+
1501: () => string;
|
|
158
|
+
1502: (timeout: number) => string;
|
|
159
|
+
2101: (className: string) => string;
|
|
160
|
+
2102: (className: string) => string;
|
|
161
|
+
2103: (databaseName?: string) => string;
|
|
162
|
+
2104: () => string;
|
|
163
|
+
2105: () => string;
|
|
164
|
+
2201: (className: string) => string;
|
|
165
|
+
2202: (className: string) => string;
|
|
166
|
+
2203: () => string;
|
|
167
|
+
2204: (direction: unknown) => string;
|
|
168
|
+
2205: (label: string) => string;
|
|
169
|
+
2206: () => string;
|
|
170
|
+
2207: (filePath: string) => string;
|
|
171
|
+
2208: (message: string) => string;
|
|
172
|
+
2209: () => string;
|
|
173
|
+
2210: () => string;
|
|
174
|
+
3101: () => string;
|
|
175
|
+
3102: () => string;
|
|
176
|
+
3103: () => string;
|
|
177
|
+
3104: (baseDir: string, candidates: readonly string[]) => string;
|
|
178
|
+
3110: () => string;
|
|
179
|
+
3111: () => string;
|
|
180
|
+
3112: () => string;
|
|
181
|
+
3113: () => string;
|
|
182
|
+
3114: () => string;
|
|
183
|
+
3115: (entryPath: string, root: string) => string;
|
|
184
|
+
3105: (entryPath: string) => string;
|
|
185
|
+
3106: (entryPath: string, reason: string) => string;
|
|
186
|
+
3107: (entryPath: string, nativeReason: string, fallbackReason: string) => string;
|
|
187
|
+
3108: () => string;
|
|
188
|
+
3109: (instancePath: string, reason: string) => string;
|
|
189
|
+
3116: (hint: string) => string;
|
|
190
|
+
3117: (diagnostics: string) => string;
|
|
191
|
+
3118: (targetPath: string, reason: string) => string;
|
|
192
|
+
3119: () => string;
|
|
193
|
+
3120: () => string;
|
|
194
|
+
3121: () => string;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Argument types for Seedcord error messages.
|
|
198
|
+
*
|
|
199
|
+
* @internal
|
|
200
|
+
*/
|
|
201
|
+
type SeedcordErrorArguments<Code extends SeedcordErrorCode> = Parameters<(typeof messages)[Code]>;
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/Errors/SeedcordError.d.ts
|
|
204
|
+
/**
|
|
205
|
+
* String literal type for Seedcord error identifiers.
|
|
206
|
+
*
|
|
207
|
+
* @internal
|
|
208
|
+
*/
|
|
209
|
+
type SeedcordErrorIdentifier = keyof typeof SeedcordErrorCode;
|
|
210
|
+
/**
|
|
211
|
+
* Options for Seedcord errors.
|
|
212
|
+
*
|
|
213
|
+
* @internal
|
|
214
|
+
*/
|
|
215
|
+
interface SeedcordErrorOptions extends ErrorOptions {}
|
|
216
|
+
type SeedcordErrorCtorRest<Code extends SeedcordErrorCode> = SeedcordErrorArguments<Code> extends [] ? [options?: SeedcordErrorOptions] : [args: SeedcordErrorArguments<Code>, options?: SeedcordErrorOptions];
|
|
217
|
+
/**
|
|
218
|
+
* String literal type for Seedcord error class names.
|
|
219
|
+
*
|
|
220
|
+
* @internal
|
|
221
|
+
*/
|
|
222
|
+
type SeedcordErrorTypeString = `Seedcord${'Error' | 'TypeError' | 'RangeError'}`;
|
|
223
|
+
/**
|
|
224
|
+
* Base interface for Seedcord error instances.
|
|
225
|
+
*
|
|
226
|
+
* @internal
|
|
227
|
+
*/
|
|
228
|
+
interface BaseSeedcordError {
|
|
229
|
+
readonly code: SeedcordErrorCode;
|
|
230
|
+
readonly identifier: SeedcordErrorIdentifier;
|
|
231
|
+
readonly type: SeedcordErrorTypeString;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Base class for Seedcord errors.
|
|
235
|
+
*
|
|
236
|
+
* @internal
|
|
237
|
+
*/
|
|
238
|
+
declare class SeedcordError<Code extends SeedcordErrorCode = SeedcordErrorCode> extends Error implements BaseSeedcordError {
|
|
239
|
+
readonly code: Code;
|
|
240
|
+
readonly identifier: SeedcordErrorIdentifier;
|
|
241
|
+
readonly type = "SeedcordError";
|
|
242
|
+
constructor(code: Code, ...rest: SeedcordErrorCtorRest<Code>);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* TypeError class for Seedcord errors.
|
|
246
|
+
*
|
|
247
|
+
* @internal
|
|
248
|
+
*/
|
|
249
|
+
declare class SeedcordTypeError<Code extends SeedcordErrorCode = SeedcordErrorCode> extends TypeError implements BaseSeedcordError {
|
|
250
|
+
readonly code: Code;
|
|
251
|
+
readonly identifier: SeedcordErrorIdentifier;
|
|
252
|
+
readonly type = "SeedcordTypeError";
|
|
253
|
+
constructor(code: Code, ...rest: SeedcordErrorCtorRest<Code>);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* RangeError class for Seedcord errors.
|
|
257
|
+
*
|
|
258
|
+
* @internal
|
|
259
|
+
*/
|
|
260
|
+
declare class SeedcordRangeError<Code extends SeedcordErrorCode = SeedcordErrorCode> extends RangeError implements BaseSeedcordError {
|
|
261
|
+
readonly code: Code;
|
|
262
|
+
readonly identifier: SeedcordErrorIdentifier;
|
|
263
|
+
readonly type = "SeedcordRangeError";
|
|
264
|
+
constructor(code: Code, ...rest: SeedcordErrorCtorRest<Code>);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Variant type for Seedcord error classes.
|
|
268
|
+
*
|
|
269
|
+
* @internal
|
|
270
|
+
*/
|
|
271
|
+
type SeedcordErrorVariant<Type extends SeedcordErrorTypeString, Code extends SeedcordErrorCode> = Type extends 'SeedcordError' ? SeedcordError<Code> : Type extends 'SeedcordTypeError' ? SeedcordTypeError<Code> : SeedcordRangeError<Code>;
|
|
272
|
+
/**
|
|
273
|
+
* Union type of all Seedcord error variants for a specific error code.
|
|
274
|
+
*
|
|
275
|
+
* @internal
|
|
276
|
+
*/
|
|
277
|
+
type AnySeedcordErrorForCode<Code extends SeedcordErrorCode> = { [Variant in SeedcordErrorTypeString]: SeedcordErrorVariant<Variant, Code> }[SeedcordErrorTypeString];
|
|
278
|
+
/**
|
|
279
|
+
* Union type of all Seedcord errors filtered by error class.
|
|
280
|
+
*
|
|
281
|
+
* @internal
|
|
282
|
+
*/
|
|
283
|
+
type ErrorTypeFilter<Type extends SeedcordErrorTypeString | undefined> = Type extends SeedcordErrorTypeString ? { [Code in SeedcordErrorCode]: SeedcordErrorVariant<Type, Code> }[SeedcordErrorCode] : AnySeedcordErrorForCode<SeedcordErrorCode>;
|
|
284
|
+
/**
|
|
285
|
+
* Union type of all Seedcord errors filtered by error class and error code.
|
|
286
|
+
*
|
|
287
|
+
* @internal
|
|
288
|
+
*/
|
|
289
|
+
type ErrorCodeFilter<Type extends SeedcordErrorTypeString | undefined, Code extends SeedcordErrorCode | undefined> = Code extends SeedcordErrorCode ? Type extends SeedcordErrorTypeString ? SeedcordErrorVariant<Type, Code> : AnySeedcordErrorForCode<Code> : ErrorTypeFilter<Type>;
|
|
290
|
+
/**
|
|
291
|
+
* Determines whether an unknown value is a Seedcord error, with optional narrowing by class and error code.
|
|
292
|
+
*
|
|
293
|
+
* @param error - The value to inspect.
|
|
294
|
+
* @param type - Optional error class discriminator (Error, TypeError, or RangeError).
|
|
295
|
+
* @param code - Optional {@link SeedcordErrorCode} discriminator to narrow by code.
|
|
296
|
+
* @typeParam Type - What kind of {@link SeedcordErrorTypeString} to filter by.
|
|
297
|
+
* @typeParam Code - The specific {@link SeedcordErrorCode} to filter by.
|
|
298
|
+
*/
|
|
299
|
+
declare function isSeedcordError<Type extends SeedcordErrorTypeString | undefined, Code extends SeedcordErrorCode | undefined>(error: unknown, type?: Type, code?: Code): error is ErrorCodeFilter<Type, Code>;
|
|
300
|
+
//#endregion
|
|
301
|
+
export { SeedcordTypeError as a, SeedcordRangeError as i, SeedcordError as n, isSeedcordError as o, SeedcordErrorTypeString as r, SeedcordErrorCode as s, BaseSeedcordError as t };
|
|
302
|
+
//# sourceMappingURL=SeedcordError-BuWVIe6m.d.mts.map
|