@guren/server 1.3.0 → 1.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/{Application-DImeY-VW.d.ts → Application-Bi-olFMF.d.ts} +387 -18
- package/dist/{AuthManager-BU8ZvenF.d.ts → AuthManager-C84xF5ks.d.ts} +1 -1
- package/dist/{BroadcastManager-CGWl9rUO.d.ts → BroadcastManager-D8KoJxiV.d.ts} +21 -0
- package/dist/{CacheManager-BkvHEOZX.d.ts → CacheManager-BmDzUKrF.d.ts} +17 -0
- package/dist/ConsoleKernel-D0dkFt6u.d.ts +101 -0
- package/dist/{McpServiceProvider-RNTDHZAZ.js → McpServiceProvider-TZWQWXCT.js} +2 -2
- package/dist/{Scheduler-BstvSca7.d.ts → Scheduler-pZiT8i57.d.ts} +2 -0
- package/dist/{api-token-CB12xnVg.d.ts → api-token-COQHXyM_.d.ts} +68 -1
- package/dist/auth/index.d.ts +5 -5
- package/dist/auth/index.js +1 -1
- package/dist/authorization/index.js +2 -2
- package/dist/broadcasting/index.d.ts +2 -2
- package/dist/broadcasting/index.js +2 -1
- package/dist/cache/index.d.ts +2 -2
- package/dist/cache/index.js +2 -1
- package/dist/{chunk-EGU5KB7V.js → chunk-4SBGSJNT.js} +31 -1
- package/dist/{chunk-CSDKWLFD.js → chunk-5AD7LYWO.js} +111 -35
- package/dist/{chunk-THSX7OOR.js → chunk-63SKW5PS.js} +3 -0
- package/dist/{chunk-R2TCP7D7.js → chunk-6J6B5KOB.js} +18 -2
- package/dist/{chunk-VY2JPS6V.js → chunk-AUXQISW5.js} +83 -11
- package/dist/chunk-DCYKSYAT.js +63 -0
- package/dist/{chunk-ZRBLZY3M.js → chunk-FZD2AKJI.js} +1 -1
- package/dist/{chunk-HKQSAFSN.js → chunk-MC752CQT.js} +15 -0
- package/dist/{chunk-J753UWAY.js → chunk-NQCZQAJL.js} +93 -28
- package/dist/{chunk-STZUODC3.js → chunk-NYQGAWDN.js} +44 -1
- package/dist/{chunk-EDRGAM6G.js → chunk-RNXTRWKL.js} +2 -1
- package/dist/{chunk-CSP7W3WY.js → chunk-SHYRVOMJ.js} +2 -2
- package/dist/{chunk-44F7JQ7I.js → chunk-XMQZENBP.js} +35 -1
- package/dist/{chunk-WJJ5CTNI.js → chunk-Z3HXKWI6.js} +2 -2
- package/dist/{client-CKXJLsTe.d.ts → client-BQwF2b9Y.d.ts} +7 -0
- package/dist/{email-verification-D9u7krkn.d.ts → email-verification-H_WlpsVH.d.ts} +1 -1
- package/dist/{errors-JOOPDDQ6.js → errors-PUNHAFL2.js} +1 -1
- package/dist/index.d.ts +35 -17
- package/dist/index.js +329 -132
- package/dist/lambda/index.d.ts +7 -7
- package/dist/lambda/index.js +1 -1
- package/dist/mail/index.js +3 -3
- package/dist/mcp/index.d.ts +53 -19
- package/dist/mcp/index.js +2 -2
- package/dist/notifications/index.d.ts +57 -8
- package/dist/notifications/index.js +11 -3
- package/dist/queue/index.d.ts +7 -7
- package/dist/queue/index.js +4 -2
- package/dist/redis/index.d.ts +11 -21
- package/dist/redis/index.js +42 -6
- package/dist/runtime/index.d.ts +7 -7
- package/dist/runtime/index.js +1 -1
- package/dist/scheduling/index.d.ts +2 -2
- package/dist/scheduling/index.js +2 -1
- package/package.json +2 -2
- package/dist/ConsoleKernel-COKndy_V.d.ts +0 -207
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { C as CommandClass, a as Container, O as OutputInterface, b as ConsoleKernelOptions } from './Application-Bi-olFMF.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Console kernel for managing and executing commands.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const kernel = new ConsoleKernel()
|
|
9
|
+
*
|
|
10
|
+
* kernel.register(CreateUserCommand)
|
|
11
|
+
* kernel.register(SendNotificationsCommand)
|
|
12
|
+
*
|
|
13
|
+
* // Execute command
|
|
14
|
+
* const exitCode = await kernel.handle(['users:create', 'john@example.com', '--admin'])
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare class ConsoleKernel {
|
|
18
|
+
/**
|
|
19
|
+
* Registered commands.
|
|
20
|
+
*/
|
|
21
|
+
protected commands: Map<string, CommandClass>;
|
|
22
|
+
/**
|
|
23
|
+
* Service container.
|
|
24
|
+
*/
|
|
25
|
+
protected container?: Container;
|
|
26
|
+
/**
|
|
27
|
+
* Output instance.
|
|
28
|
+
*/
|
|
29
|
+
protected output: OutputInterface;
|
|
30
|
+
constructor(options?: ConsoleKernelOptions);
|
|
31
|
+
/**
|
|
32
|
+
* Register a command.
|
|
33
|
+
*/
|
|
34
|
+
register(command: CommandClass): this;
|
|
35
|
+
/**
|
|
36
|
+
* Register multiple commands.
|
|
37
|
+
*/
|
|
38
|
+
registerMany(commands: CommandClass[]): this;
|
|
39
|
+
/**
|
|
40
|
+
* Get all registered commands.
|
|
41
|
+
*/
|
|
42
|
+
getCommands(): Map<string, CommandClass>;
|
|
43
|
+
/**
|
|
44
|
+
* Get a command by name.
|
|
45
|
+
*/
|
|
46
|
+
getCommand(name: string): CommandClass | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Check if a command is registered.
|
|
49
|
+
*/
|
|
50
|
+
hasCommand(name: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Set the output instance.
|
|
53
|
+
*/
|
|
54
|
+
setOutput(output: OutputInterface): this;
|
|
55
|
+
/**
|
|
56
|
+
* Get the output instance.
|
|
57
|
+
*/
|
|
58
|
+
getOutput(): OutputInterface;
|
|
59
|
+
/**
|
|
60
|
+
* Handle command execution.
|
|
61
|
+
*/
|
|
62
|
+
handle(argv?: string[]): Promise<number>;
|
|
63
|
+
/**
|
|
64
|
+
* Run a command.
|
|
65
|
+
*/
|
|
66
|
+
protected runCommand(CommandClass: CommandClass, args: string[]): Promise<number>;
|
|
67
|
+
/**
|
|
68
|
+
* Show help.
|
|
69
|
+
*/
|
|
70
|
+
protected showHelp(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Show help for a specific command.
|
|
73
|
+
*/
|
|
74
|
+
protected showCommandHelp(commandName: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* List all commands.
|
|
77
|
+
*/
|
|
78
|
+
protected listCommands(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Group commands by namespace.
|
|
81
|
+
*/
|
|
82
|
+
protected groupCommands(): Map<string, Map<string, CommandClass>>;
|
|
83
|
+
/**
|
|
84
|
+
* Suggest similar commands.
|
|
85
|
+
*/
|
|
86
|
+
protected suggestCommands(input: string): void;
|
|
87
|
+
/**
|
|
88
|
+
* Calculate string similarity (simple Dice coefficient).
|
|
89
|
+
*/
|
|
90
|
+
protected similarity(a: string, b: string): number;
|
|
91
|
+
/**
|
|
92
|
+
* Call a command programmatically.
|
|
93
|
+
*/
|
|
94
|
+
call(commandName: string, args?: string[], silent?: boolean): Promise<number>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Create a console kernel.
|
|
98
|
+
*/
|
|
99
|
+
declare function createConsoleKernel(options?: ConsoleKernelOptions): ConsoleKernel;
|
|
100
|
+
|
|
101
|
+
export { ConsoleKernel as C, createConsoleKernel as c };
|
|
@@ -399,6 +399,8 @@ declare class Scheduler {
|
|
|
399
399
|
private interval;
|
|
400
400
|
private isRunning;
|
|
401
401
|
private lastCheck;
|
|
402
|
+
/** This scheduler's claim on its hot-reload slot while it is running. */
|
|
403
|
+
private hotReloadClaim;
|
|
402
404
|
constructor(options?: SchedulerOptions);
|
|
403
405
|
/**
|
|
404
406
|
* Define schedules using a callback.
|
|
@@ -15,6 +15,14 @@ interface SessionStore {
|
|
|
15
15
|
* Destroy a session. Implementations must treat repeated calls as safe.
|
|
16
16
|
*/
|
|
17
17
|
destroy(id: string): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Optional: refresh an existing session's TTL without rewriting its data.
|
|
20
|
+
* The middleware uses this for unchanged sessions (rolling expiry); stores
|
|
21
|
+
* that omit it fall back to a full `write`. Refreshing a session that no
|
|
22
|
+
* longer exists — including one that has expired but not yet been swept
|
|
23
|
+
* from storage — must be a no-op, not a resurrection.
|
|
24
|
+
*/
|
|
25
|
+
touch?(id: string, ttlSeconds: number): Promise<void>;
|
|
18
26
|
}
|
|
19
27
|
declare class MemorySessionStore implements SessionStore {
|
|
20
28
|
private readonly now;
|
|
@@ -23,6 +31,7 @@ declare class MemorySessionStore implements SessionStore {
|
|
|
23
31
|
read(id: string): Promise<SessionData | undefined>;
|
|
24
32
|
write(id: string, data: SessionData, ttlSeconds: number): Promise<void>;
|
|
25
33
|
destroy(id: string): Promise<void>;
|
|
34
|
+
touch(id: string, ttlSeconds: number): Promise<void>;
|
|
26
35
|
}
|
|
27
36
|
interface SessionOptions {
|
|
28
37
|
cookieName?: string;
|
|
@@ -44,6 +53,14 @@ interface Session {
|
|
|
44
53
|
forget(key: string): void;
|
|
45
54
|
flush(): void;
|
|
46
55
|
all(): SessionData;
|
|
56
|
+
/**
|
|
57
|
+
* Rotate the session id (call after login to mitigate session fixation).
|
|
58
|
+
* The new id is persisted and the old one destroyed at request end. Known
|
|
59
|
+
* limitation shared by every multi-process store: a concurrent request
|
|
60
|
+
* still carrying the old cookie can re-persist the old id afterwards; the
|
|
61
|
+
* resurrected row holds only pre-rotation data (no auth state), so
|
|
62
|
+
* fixation does not escalate, but the row can linger until it expires.
|
|
63
|
+
*/
|
|
47
64
|
regenerate(): void;
|
|
48
65
|
invalidate(): void;
|
|
49
66
|
flash(key: string, value: unknown): void;
|
|
@@ -170,6 +187,35 @@ interface OAuthProviderConfig {
|
|
|
170
187
|
tokenAuthMethod?: 'client_secret_post' | 'client_secret_basic';
|
|
171
188
|
userInfoMethod?: 'GET' | 'POST';
|
|
172
189
|
mapProfile?: (raw: Record<string, unknown>, token: OAuthTokenResult) => OAuthUserProfile;
|
|
190
|
+
/**
|
|
191
|
+
* Key in the userinfo response carrying the provider's own verification
|
|
192
|
+
* signal for the email address — Discord returns `verified`, for example.
|
|
193
|
+
* Defaults to OIDC's standard `email_verified` claim. Only boolean values
|
|
194
|
+
* are read; anything else leaves `profile.emailVerified` undefined. Ignored
|
|
195
|
+
* when `mapProfile` is set, since that owns the whole mapping.
|
|
196
|
+
*/
|
|
197
|
+
emailVerifiedKey?: string;
|
|
198
|
+
/**
|
|
199
|
+
* Fallback used when the userinfo response carries no email — e.g. GitHub
|
|
200
|
+
* returns `email: null` for accounts with a private email even when the
|
|
201
|
+
* `user:email` scope was granted. Returns the email to use, or undefined
|
|
202
|
+
* to leave the profile without one.
|
|
203
|
+
*
|
|
204
|
+
* The signal read via `emailVerifiedKey` does not carry over to a fallback
|
|
205
|
+
* address — it was read against a response that had no email. A bare string
|
|
206
|
+
* therefore makes no verification claim and leaves `profile.emailVerified`
|
|
207
|
+
* undefined; return `{ email, emailVerified: true }` to assert one.
|
|
208
|
+
*/
|
|
209
|
+
fetchFallbackEmail?: (token: OAuthTokenResult) => Promise<string | OAuthFallbackEmail | undefined>;
|
|
210
|
+
}
|
|
211
|
+
interface OAuthFallbackEmail {
|
|
212
|
+
email: string;
|
|
213
|
+
/**
|
|
214
|
+
* Whether the provider verified this specific address. Omit it when the
|
|
215
|
+
* lookup cannot tell — the profile then reports `emailVerified: undefined`
|
|
216
|
+
* rather than an unfounded claim.
|
|
217
|
+
*/
|
|
218
|
+
emailVerified?: boolean;
|
|
173
219
|
}
|
|
174
220
|
interface OAuthTokenResult {
|
|
175
221
|
accessToken: string;
|
|
@@ -184,6 +230,15 @@ interface OAuthUserProfile {
|
|
|
184
230
|
email?: string;
|
|
185
231
|
name?: string;
|
|
186
232
|
avatar?: string;
|
|
233
|
+
/**
|
|
234
|
+
* Whether the provider itself verified `email`. Tri-state on purpose:
|
|
235
|
+
* `true` — the provider asserts the address is verified; `false` — it
|
|
236
|
+
* asserts it is not; `undefined` — the provider sends no such signal
|
|
237
|
+
* (GitHub's `/user`, for instance), so the consumer decides its own policy.
|
|
238
|
+
* Returning an email is not by itself a claim that it was checked, so
|
|
239
|
+
* treating `undefined` as verified is a decision, not a default.
|
|
240
|
+
*/
|
|
241
|
+
emailVerified?: boolean;
|
|
187
242
|
token: OAuthTokenResult;
|
|
188
243
|
raw: Record<string, unknown>;
|
|
189
244
|
}
|
|
@@ -196,6 +251,17 @@ interface OAuthStateStore {
|
|
|
196
251
|
store(stateHash: string, payload: OAuthStatePayload): Promise<void>;
|
|
197
252
|
find(stateHash: string): Promise<OAuthStatePayload | null>;
|
|
198
253
|
delete(stateHash: string): Promise<void>;
|
|
254
|
+
/**
|
|
255
|
+
* Atomically fetch and delete a state in one step. Exactly one caller may
|
|
256
|
+
* receive the payload; every other concurrent caller (and any later call)
|
|
257
|
+
* must get null. Expired states must also return null, mirroring `find`.
|
|
258
|
+
*
|
|
259
|
+
* Optional for backward compatibility: `verifyOAuthState` prefers this
|
|
260
|
+
* when present. Stores that only implement find/delete keep working, but
|
|
261
|
+
* leave a window where two concurrent callbacks with the same state can
|
|
262
|
+
* both pass verification.
|
|
263
|
+
*/
|
|
264
|
+
consume?(stateHash: string): Promise<OAuthStatePayload | null>;
|
|
199
265
|
}
|
|
200
266
|
interface OAuthStateConfig {
|
|
201
267
|
expiresIn?: number;
|
|
@@ -232,6 +298,7 @@ declare class MemoryOAuthStateStore implements OAuthStateStore {
|
|
|
232
298
|
private sweepExpired;
|
|
233
299
|
find(stateHash: string): Promise<OAuthStatePayload | null>;
|
|
234
300
|
delete(stateHash: string): Promise<void>;
|
|
301
|
+
consume(stateHash: string): Promise<OAuthStatePayload | null>;
|
|
235
302
|
clear(): void;
|
|
236
303
|
}
|
|
237
304
|
declare class OAuthManager {
|
|
@@ -593,4 +660,4 @@ declare function getApiTokenOrFail(ctx: Context): {
|
|
|
593
660
|
abilities: string[];
|
|
594
661
|
};
|
|
595
662
|
|
|
596
|
-
export {
|
|
663
|
+
export { getUserApiTokens as $, type Authenticatable as A, type BearerTokenMiddlewareOptions as B, type CreateSessionMiddlewareOptions as C, type DefaultSanitizedKeys as D, type Sanitized as E, type Session as F, type GuardFactory as G, buildOAuthAuthorizeUrl as H, buildOAuthRedirectUrl as I, createApiToken as J, createBearerTokenMiddleware as K, createDiscordOAuthProviderConfig as L, MemoryApiTokenStore as M, createGitHubOAuthProviderConfig as N, type OAuthStateStore as O, type ProviderFactory as P, createGoogleOAuthProviderConfig as Q, createOAuthManager as R, type SessionStore as S, createOAuthState as T, type UserProvider as U, createSessionMiddleware as V, exchangeOAuthCode as W, fetchOAuthUserProfile as X, getApiToken as Y, getApiTokenOrFail as Z, getSessionFromContext as _, type AuthCredentials as a, parseApiToken as a0, parseOAuthRedirectUrl as a1, revokeAllApiTokens as a2, revokeApiToken as a3, sanitizeOAuthRedirect as a4, tokenCan as a5, tokenCanAll as a6, tokenCanAny as a7, verifyApiToken as a8, verifyOAuthState as a9, type AuthManagerContract as b, type AuthManagerOptions as c, type GuardContext as d, type Guard as e, type AttachContextOptions as f, type AuthContext as g, type SessionData as h, type ApiTokenStore as i, type ApiToken as j, type OAuthStatePayload as k, OAuthManager as l, API_TOKEN_KEY as m, type CreateApiTokenOptions as n, type CreateApiTokenResult as o, MemoryOAuthStateStore as p, MemorySessionStore as q, type OAuthAuthorizeOptions as r, type OAuthCallbackPayload as s, type OAuthFallbackEmail as t, type OAuthManagerOptions as u, type OAuthProviderConfig as v, type OAuthProviderFactoryInput as w, type OAuthStateConfig as x, type OAuthTokenResult as y, type OAuthUserProfile as z };
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { P as PasswordHasher } from '../AuthManager-
|
|
2
|
-
export { A as AuthManager, B as BaseUserProvider, M as ModelUserProvider } from '../AuthManager-
|
|
3
|
-
import { A as Authenticatable, e as Guard, U as UserProvider,
|
|
4
|
-
export { m as API_TOKEN_KEY, j as ApiToken, i as ApiTokenStore, f as AttachContextOptions, g as AuthContext, b as AuthManagerContract, c as AuthManagerOptions, B as BearerTokenMiddlewareOptions, n as CreateApiTokenOptions, o as CreateApiTokenResult, D as DefaultSanitizedKeys, d as GuardContext, G as GuardFactory, M as MemoryApiTokenStore, p as MemoryOAuthStateStore, r as OAuthAuthorizeOptions, s as OAuthCallbackPayload, l as OAuthManager,
|
|
1
|
+
import { P as PasswordHasher } from '../AuthManager-C84xF5ks.js';
|
|
2
|
+
export { A as AuthManager, B as BaseUserProvider, M as ModelUserProvider } from '../AuthManager-C84xF5ks.js';
|
|
3
|
+
import { A as Authenticatable, e as Guard, U as UserProvider, F as Session, a as AuthCredentials } from '../api-token-COQHXyM_.js';
|
|
4
|
+
export { m as API_TOKEN_KEY, j as ApiToken, i as ApiTokenStore, f as AttachContextOptions, g as AuthContext, b as AuthManagerContract, c as AuthManagerOptions, B as BearerTokenMiddlewareOptions, n as CreateApiTokenOptions, o as CreateApiTokenResult, D as DefaultSanitizedKeys, d as GuardContext, G as GuardFactory, M as MemoryApiTokenStore, p as MemoryOAuthStateStore, r as OAuthAuthorizeOptions, s as OAuthCallbackPayload, t as OAuthFallbackEmail, l as OAuthManager, u as OAuthManagerOptions, v as OAuthProviderConfig, w as OAuthProviderFactoryInput, x as OAuthStateConfig, k as OAuthStatePayload, O as OAuthStateStore, y as OAuthTokenResult, z as OAuthUserProfile, P as ProviderFactory, E as Sanitized, H as buildOAuthAuthorizeUrl, I as buildOAuthRedirectUrl, J as createApiToken, K as createBearerTokenMiddleware, L as createDiscordOAuthProviderConfig, N as createGitHubOAuthProviderConfig, Q as createGoogleOAuthProviderConfig, R as createOAuthManager, T as createOAuthState, W as exchangeOAuthCode, X as fetchOAuthUserProfile, Y as getApiToken, Z as getApiTokenOrFail, $ as getUserApiTokens, a0 as parseApiToken, a1 as parseOAuthRedirectUrl, a2 as revokeAllApiTokens, a3 as revokeApiToken, a4 as sanitizeOAuthRedirect, a5 as tokenCan, a6 as tokenCanAll, a7 as tokenCanAny, a8 as verifyApiToken, a9 as verifyOAuthState } from '../api-token-COQHXyM_.js';
|
|
5
5
|
import { PlainObject, Model } from '@guren/orm';
|
|
6
|
-
export { b as EmailVerificationConfig, a as EmailVerificationToken, c as EmailVerificationTokenResult, E as EmailVerificationTokenStore, M as MemoryEmailVerificationStore, d as MemoryPasswordResetStore, e as PasswordResetConfig, f as PasswordResetTokenResult, P as PasswordResetTokenStore, g as buildPasswordResetUrl, q as buildTokenUrl, h as buildVerificationUrl, i as completeEmailVerification, j as completePasswordReset, k as createEmailVerificationToken, l as createPasswordResetToken, s as generateId, t as generateToken, u as hashToken, m as isEmailVerified, p as parsePasswordResetUrl, w as parseTokenUrl, n as parseVerificationUrl, r as requireVerifiedEmail, x as secureCompare, y as secureStringCompare, v as verifyEmailToken, o as verifyPasswordResetToken } from '../email-verification-
|
|
6
|
+
export { b as EmailVerificationConfig, a as EmailVerificationToken, c as EmailVerificationTokenResult, E as EmailVerificationTokenStore, M as MemoryEmailVerificationStore, d as MemoryPasswordResetStore, e as PasswordResetConfig, f as PasswordResetTokenResult, P as PasswordResetTokenStore, g as buildPasswordResetUrl, q as buildTokenUrl, h as buildVerificationUrl, i as completeEmailVerification, j as completePasswordReset, k as createEmailVerificationToken, l as createPasswordResetToken, s as generateId, t as generateToken, u as hashToken, m as isEmailVerified, p as parsePasswordResetUrl, w as parseTokenUrl, n as parseVerificationUrl, r as requireVerifiedEmail, x as secureCompare, y as secureStringCompare, v as verifyEmailToken, o as verifyPasswordResetToken } from '../email-verification-H_WlpsVH.js';
|
|
7
7
|
import 'hono';
|
|
8
8
|
|
|
9
9
|
interface SessionGuardOptions {
|
package/dist/auth/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as BroadcastManager, P as PresenceBroadcastDriver, c as BroadcastEvent, j as PresenceMember } from '../BroadcastManager-
|
|
2
|
-
export { A as AuthMiddlewareOptions, a as BroadcastDriver, b as BroadcastDriverFactory, d as BroadcastManagerOptions, e as BroadcastableEvent, C as Channel, f as ChannelAuthorizer, g as ChannelRegistration, h as PresenceChannel, i as PresenceChannelAuthorizer, k as PrivateChannel, S as SSEClient, l as SSEMiddlewareOptions, W as WebSocketClient, m as createBroadcastManager, n as getBroadcastManager, s as setBroadcastManager } from '../BroadcastManager-
|
|
1
|
+
import { B as BroadcastManager, P as PresenceBroadcastDriver, c as BroadcastEvent, j as PresenceMember } from '../BroadcastManager-D8KoJxiV.js';
|
|
2
|
+
export { A as AuthMiddlewareOptions, a as BroadcastDriver, b as BroadcastDriverFactory, d as BroadcastManagerOptions, e as BroadcastableEvent, C as Channel, f as ChannelAuthorizer, g as ChannelRegistration, h as PresenceChannel, i as PresenceChannelAuthorizer, k as PrivateChannel, S as SSEClient, l as SSEMiddlewareOptions, W as WebSocketClient, m as createBroadcastManager, n as getBroadcastManager, s as setBroadcastManager } from '../BroadcastManager-D8KoJxiV.js';
|
|
3
3
|
import '../index-9_Jzj5jo.js';
|
|
4
4
|
import 'hono';
|
|
5
5
|
|
package/dist/cache/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as CacheStore, M as MemoryStoreOptions, R as RedisStoreOptions, F as FileStoreOptions, T as TaggedCacheStore } from '../CacheManager-
|
|
2
|
-
export { a as CacheConfig, C as CacheManager, c as CacheStoreFactory, e as CachedItem, S as StoreConfig, f as TaggableCacheStore, d as createCacheManager } from '../CacheManager-
|
|
1
|
+
import { b as CacheStore, M as MemoryStoreOptions, R as RedisStoreOptions, F as FileStoreOptions, T as TaggedCacheStore } from '../CacheManager-BmDzUKrF.js';
|
|
2
|
+
export { a as CacheConfig, C as CacheManager, c as CacheStoreFactory, e as CachedItem, S as StoreConfig, f as TaggableCacheStore, d as createCacheManager } from '../CacheManager-BmDzUKrF.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* In-memory cache store.
|
package/dist/cache/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
claimHotDisposable,
|
|
3
|
+
isHotReloadRuntime
|
|
4
|
+
} from "./chunk-DCYKSYAT.js";
|
|
5
|
+
|
|
1
6
|
// src/cache/stores/MemoryStore.ts
|
|
2
7
|
var MemoryStore = class {
|
|
3
8
|
cache = /* @__PURE__ */ new Map();
|
|
@@ -716,7 +721,17 @@ var CacheManager = class {
|
|
|
716
721
|
defaultStoreName;
|
|
717
722
|
storeFactories = /* @__PURE__ */ new Map();
|
|
718
723
|
resolvedStores = /* @__PURE__ */ new Map();
|
|
724
|
+
/**
|
|
725
|
+
* Where this manager was built, for identifying its stores across hot reloads.
|
|
726
|
+
*
|
|
727
|
+
* Captured here rather than in `store()` because stores resolve lazily, from
|
|
728
|
+
* whichever request first asks for one — a call site that says nothing about
|
|
729
|
+
* which manager owns the result. Skipped outside `--hot`, where it would be a
|
|
730
|
+
* formatted stack string held for the manager's lifetime and never read.
|
|
731
|
+
*/
|
|
732
|
+
builtAt;
|
|
719
733
|
constructor(config = {}) {
|
|
734
|
+
this.builtAt = isHotReloadRuntime() ? new Error().stack : void 0;
|
|
720
735
|
this.defaultStoreName = config.default ?? "memory";
|
|
721
736
|
this.registerBuiltinDrivers();
|
|
722
737
|
if (config.stores) {
|
|
@@ -768,10 +783,25 @@ var CacheManager = class {
|
|
|
768
783
|
if (!factory) {
|
|
769
784
|
throw new Error(`Cache store not found: ${storeName}`);
|
|
770
785
|
}
|
|
771
|
-
const
|
|
786
|
+
const raw = factory();
|
|
787
|
+
this.stopPreviousStore(storeName, raw);
|
|
788
|
+
const store = new TaggableCacheStoreWrapper(raw);
|
|
772
789
|
this.resolvedStores.set(storeName, store);
|
|
773
790
|
return store;
|
|
774
791
|
}
|
|
792
|
+
/**
|
|
793
|
+
* Under `bun --hot`, stops the sweep timer held by the store this one replaces.
|
|
794
|
+
*
|
|
795
|
+
* Registered from here rather than from `MemoryStore` itself because this is
|
|
796
|
+
* where the store's name is known, and the name is what keeps two memory
|
|
797
|
+
* stores in one config from sharing a slot and cancelling each other's sweep.
|
|
798
|
+
*/
|
|
799
|
+
stopPreviousStore(storeName, store) {
|
|
800
|
+
const disposable = store;
|
|
801
|
+
if (typeof disposable.destroy === "function") {
|
|
802
|
+
claimHotDisposable("cache-store", this.builtAt, storeName, () => disposable.destroy?.());
|
|
803
|
+
}
|
|
804
|
+
}
|
|
775
805
|
/**
|
|
776
806
|
* Register a custom store factory.
|
|
777
807
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Job,
|
|
3
3
|
registerJob
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6J6B5KOB.js";
|
|
5
5
|
|
|
6
6
|
// src/notifications/Notification.ts
|
|
7
7
|
var Notification = class {
|
|
@@ -62,6 +62,36 @@ var Notification = class {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
+
// src/notifications/registry.ts
|
|
66
|
+
var notificationRegistry = /* @__PURE__ */ new Map();
|
|
67
|
+
function resolveRegistryKey(notificationClass) {
|
|
68
|
+
try {
|
|
69
|
+
const { type } = Object.create(notificationClass.prototype);
|
|
70
|
+
if (typeof type === "string" && type.length > 0) {
|
|
71
|
+
return type;
|
|
72
|
+
}
|
|
73
|
+
} catch {
|
|
74
|
+
}
|
|
75
|
+
return notificationClass.name;
|
|
76
|
+
}
|
|
77
|
+
function registerNotification(notificationClass, type) {
|
|
78
|
+
notificationRegistry.set(
|
|
79
|
+
type ?? resolveRegistryKey(notificationClass),
|
|
80
|
+
notificationClass
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
function getNotification(type) {
|
|
84
|
+
return notificationRegistry.get(type);
|
|
85
|
+
}
|
|
86
|
+
function clearNotificationRegistry() {
|
|
87
|
+
notificationRegistry.clear();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/notifications/notifiable-type.ts
|
|
91
|
+
function resolveNotifiableType(notifiable) {
|
|
92
|
+
return notifiable.notifiableType ?? notifiable.constructor?.name ?? "Unknown";
|
|
93
|
+
}
|
|
94
|
+
|
|
65
95
|
// src/notifications/NotificationManager.ts
|
|
66
96
|
var NotificationManager = class {
|
|
67
97
|
channels = /* @__PURE__ */ new Map();
|
|
@@ -173,10 +203,16 @@ var NotificationManager = class {
|
|
|
173
203
|
* Queue a notification for later delivery.
|
|
174
204
|
*/
|
|
175
205
|
async queue(notifiable, notification, queueConfig) {
|
|
176
|
-
const job = this.
|
|
177
|
-
|
|
206
|
+
const job = this.registerQueueJob();
|
|
207
|
+
registerNotification(
|
|
208
|
+
notification.constructor,
|
|
209
|
+
notification.type
|
|
210
|
+
);
|
|
178
211
|
const payload = {
|
|
179
|
-
notifiableData: this.serializeNotifiable(
|
|
212
|
+
notifiableData: this.serializeNotifiable(
|
|
213
|
+
notifiable,
|
|
214
|
+
notification.via(notifiable)
|
|
215
|
+
),
|
|
180
216
|
notificationData: this.serializeNotification(notification),
|
|
181
217
|
notificationType: notification.type
|
|
182
218
|
};
|
|
@@ -206,32 +242,47 @@ var NotificationManager = class {
|
|
|
206
242
|
}
|
|
207
243
|
/**
|
|
208
244
|
* Serialize notifiable for queue storage.
|
|
209
|
-
|
|
210
|
-
|
|
245
|
+
*
|
|
246
|
+
* Routing is resolved here rather than in the worker: `routeNotificationFor`
|
|
247
|
+
* is arbitrary user code — often a closure on an object literal — and cannot
|
|
248
|
+
* be reconstructed from a payload.
|
|
249
|
+
*
|
|
250
|
+
* @param channels - Channels to resolve routes for
|
|
251
|
+
*/
|
|
252
|
+
serializeNotifiable(notifiable, channels = []) {
|
|
253
|
+
const routes = {};
|
|
254
|
+
for (const channel of channels) {
|
|
255
|
+
routes[channel] = notifiable.routeNotificationFor(channel);
|
|
256
|
+
}
|
|
211
257
|
return {
|
|
212
|
-
type: notifiable
|
|
258
|
+
type: resolveNotifiableType(notifiable),
|
|
259
|
+
routes,
|
|
213
260
|
data: { ...notifiable }
|
|
214
261
|
};
|
|
215
262
|
}
|
|
216
263
|
/**
|
|
217
264
|
* Serialize notification for queue storage.
|
|
265
|
+
*
|
|
266
|
+
* Only own enumerable properties are captured. Behaviour is restored by
|
|
267
|
+
* rebuilding the registered class in the job handler, not by serializing it.
|
|
218
268
|
*/
|
|
219
269
|
serializeNotification(notification) {
|
|
220
270
|
return {
|
|
221
|
-
type: notification.type,
|
|
222
271
|
id: notification.id,
|
|
272
|
+
createdAt: notification.createdAt.toISOString(),
|
|
223
273
|
data: { ...notification }
|
|
224
274
|
};
|
|
225
275
|
}
|
|
226
276
|
/**
|
|
227
|
-
*
|
|
277
|
+
* Bind this manager to the queued-notification job and register it.
|
|
278
|
+
*
|
|
279
|
+
* Call this during boot in a process that runs a worker but may never send
|
|
280
|
+
* a notification itself: without it, the worker cannot resolve the job.
|
|
228
281
|
*/
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
return BoundSendNotificationJob;
|
|
282
|
+
registerQueueJob() {
|
|
283
|
+
SendNotificationJob.notificationManager = this;
|
|
284
|
+
registerJob(SendNotificationJob);
|
|
285
|
+
return SendNotificationJob;
|
|
235
286
|
}
|
|
236
287
|
};
|
|
237
288
|
var SendNotificationJob = class extends Job {
|
|
@@ -245,33 +296,54 @@ var SendNotificationJob = class extends Job {
|
|
|
245
296
|
if (!manager) {
|
|
246
297
|
throw new Error("NotificationManager not set on SendNotificationJob");
|
|
247
298
|
}
|
|
248
|
-
const notifiable =
|
|
249
|
-
|
|
299
|
+
const notifiable = this.rebuildNotifiable(payload.notifiableData);
|
|
300
|
+
const notification = this.rebuildNotification(
|
|
301
|
+
payload.notificationType,
|
|
302
|
+
payload.notificationData
|
|
303
|
+
);
|
|
304
|
+
await manager.sendNow(notifiable, notification);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Rebuild the notifiable from its serialized data.
|
|
308
|
+
*/
|
|
309
|
+
rebuildNotifiable(serialized) {
|
|
310
|
+
const { data, routes } = serialized;
|
|
311
|
+
return {
|
|
312
|
+
...data,
|
|
313
|
+
notifiableType: serialized.type,
|
|
250
314
|
routeNotificationFor(channel) {
|
|
251
|
-
|
|
252
|
-
|
|
315
|
+
if (routes && channel in routes) {
|
|
316
|
+
return routes[channel] ?? null;
|
|
317
|
+
}
|
|
318
|
+
const value = data[`${channel}Route`];
|
|
253
319
|
if (typeof value === "string") return value;
|
|
254
320
|
if (channel === "mail") {
|
|
255
|
-
const email =
|
|
321
|
+
const email = data["email"];
|
|
256
322
|
return typeof email === "string" ? email : null;
|
|
257
323
|
}
|
|
258
324
|
return null;
|
|
259
325
|
}
|
|
260
326
|
};
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Rebuild a real notification instance from its serialized data.
|
|
330
|
+
*
|
|
331
|
+
* The class is looked up in the notification registry and instantiated via
|
|
332
|
+
* its prototype, so prototype methods (`via`, `toMail`, `toDatabase`,
|
|
333
|
+
* `toSlack`, `shouldSend`) are restored without running the constructor.
|
|
334
|
+
*/
|
|
335
|
+
rebuildNotification(type, serialized) {
|
|
336
|
+
const NotificationClass = getNotification(type);
|
|
337
|
+
if (!NotificationClass) {
|
|
338
|
+
throw new Error(
|
|
339
|
+
`Notification type "${type}" is not registered. Call registerNotification(${type}) before running the queue worker.`
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
return Object.assign(
|
|
343
|
+
Object.create(NotificationClass.prototype),
|
|
344
|
+
serialized.data,
|
|
345
|
+
{ id: serialized.id, createdAt: new Date(serialized.createdAt) }
|
|
346
|
+
);
|
|
275
347
|
}
|
|
276
348
|
};
|
|
277
349
|
var globalNotificationManager = null;
|
|
@@ -399,7 +471,7 @@ var DatabaseChannel = class {
|
|
|
399
471
|
* Get the notifiable type.
|
|
400
472
|
*/
|
|
401
473
|
getNotifiableType(notifiable) {
|
|
402
|
-
return notifiable
|
|
474
|
+
return resolveNotifiableType(notifiable);
|
|
403
475
|
}
|
|
404
476
|
/**
|
|
405
477
|
* Get all stored notifications (for testing).
|
|
@@ -641,6 +713,10 @@ var MemoryChannel = class {
|
|
|
641
713
|
|
|
642
714
|
export {
|
|
643
715
|
Notification,
|
|
716
|
+
registerNotification,
|
|
717
|
+
getNotification,
|
|
718
|
+
clearNotificationRegistry,
|
|
719
|
+
resolveNotifiableType,
|
|
644
720
|
NotificationManager,
|
|
645
721
|
setNotificationManager,
|
|
646
722
|
getNotificationManager,
|
|
@@ -152,6 +152,9 @@ var ExceptionHandler = class {
|
|
|
152
152
|
if (this.shouldNotReport(error)) {
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
|
+
if (this.reporters.length === 0) {
|
|
156
|
+
console.error("Unhandled exception:", error);
|
|
157
|
+
}
|
|
155
158
|
for (const reporter of this.reporters) {
|
|
156
159
|
try {
|
|
157
160
|
await reporter(error);
|
|
@@ -307,6 +307,17 @@ function generateJobId() {
|
|
|
307
307
|
return randomBytes(16).toString("hex");
|
|
308
308
|
}
|
|
309
309
|
var Job = class {
|
|
310
|
+
/**
|
|
311
|
+
* Stable wire name for this job.
|
|
312
|
+
*
|
|
313
|
+
* Queued messages record this name, and the worker resolves the class back
|
|
314
|
+
* from it. When omitted the class name is used, which breaks if a bundler
|
|
315
|
+
* mangles identifiers or if the class is later renamed while messages are
|
|
316
|
+
* still in flight. Set it to pin the name across both.
|
|
317
|
+
*
|
|
318
|
+
* @default the class name
|
|
319
|
+
*/
|
|
320
|
+
static jobName;
|
|
310
321
|
/**
|
|
311
322
|
* The queue this job should be dispatched to.
|
|
312
323
|
* @default 'default'
|
|
@@ -344,7 +355,7 @@ var Job = class {
|
|
|
344
355
|
const delay = options.delay ?? 0;
|
|
345
356
|
const job = {
|
|
346
357
|
id: jobId,
|
|
347
|
-
name: this
|
|
358
|
+
name: resolveJobName(this),
|
|
348
359
|
payload,
|
|
349
360
|
queue: options.queue ?? this.queue,
|
|
350
361
|
attempts: 0,
|
|
@@ -379,9 +390,13 @@ var Job = class {
|
|
|
379
390
|
return Math.pow(2, attempts) * 1e3;
|
|
380
391
|
}
|
|
381
392
|
};
|
|
393
|
+
function resolveJobName(jobClass) {
|
|
394
|
+
const own = Object.prototype.hasOwnProperty.call(jobClass, "jobName") ? jobClass.jobName : void 0;
|
|
395
|
+
return own ?? jobClass.name;
|
|
396
|
+
}
|
|
382
397
|
var jobRegistry = /* @__PURE__ */ new Map();
|
|
383
398
|
function registerJob(jobClass) {
|
|
384
|
-
jobRegistry.set(jobClass
|
|
399
|
+
jobRegistry.set(resolveJobName(jobClass), jobClass);
|
|
385
400
|
}
|
|
386
401
|
function getJob(name) {
|
|
387
402
|
return jobRegistry.get(name);
|
|
@@ -402,6 +417,7 @@ export {
|
|
|
402
417
|
setQueueDriver,
|
|
403
418
|
getQueueDriver,
|
|
404
419
|
Job,
|
|
420
|
+
resolveJobName,
|
|
405
421
|
registerJob,
|
|
406
422
|
getJob,
|
|
407
423
|
getRegisteredJobs,
|