@guren/server 1.5.0 → 2.0.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 (53) hide show
  1. package/dist/{AuthManager-C84xF5ks.d.ts → AuthManager-DBP4KYsx.d.ts} +1 -1
  2. package/dist/{ConsoleKernel-D0dkFt6u.d.ts → ConsoleKernel-DlK9j2Lu.d.ts} +1 -1
  3. package/dist/DocsViewerServiceProvider-D7RGJPGM.js +75 -0
  4. package/dist/{I18nManager-CmUqj6bU.d.ts → I18nManager-BiSoczfV.d.ts} +1 -1
  5. package/dist/McpServiceProvider-7BB5FPF3.js +8 -0
  6. package/dist/auth/index.d.ts +39 -29
  7. package/dist/auth/index.js +2 -2
  8. package/dist/broadcasting/index.js +2 -2
  9. package/dist/cache/index.js +2 -2
  10. package/dist/chunk-2V3YID4H.js +20 -0
  11. package/dist/{chunk-SHYRVOMJ.js → chunk-4DW4GRWF.js} +3 -3
  12. package/dist/chunk-AZOYI43J.js +18 -0
  13. package/dist/{chunk-DCYKSYAT.js → chunk-B5E5VBDI.js} +54 -2
  14. package/dist/{chunk-NYQGAWDN.js → chunk-BZMZEFRG.js} +7 -11
  15. package/dist/{chunk-4SBGSJNT.js → chunk-CWI4AJ47.js} +2 -1
  16. package/dist/{chunk-NQCZQAJL.js → chunk-DSDX3ASM.js} +21 -2
  17. package/dist/{chunk-MC752CQT.js → chunk-EI5GYMAT.js} +2 -1
  18. package/dist/{chunk-AUXQISW5.js → chunk-HONCNQXZ.js} +38 -5
  19. package/dist/{chunk-CSRQTEQA.js → chunk-HWEWL6TE.js} +6 -1
  20. package/dist/chunk-JBG4AR24.js +18 -0
  21. package/dist/{chunk-RNXTRWKL.js → chunk-K6CUBJX6.js} +9 -15
  22. package/dist/{chunk-Z3HXKWI6.js → chunk-KTNJG7R7.js} +4 -0
  23. package/dist/{chunk-74HTZG3V.js → chunk-LAJQCSSF.js} +24 -0
  24. package/dist/{chunk-H32L2NE3.js → chunk-LVJCZCAV.js} +20 -13
  25. package/dist/{chunk-5AD7LYWO.js → chunk-N7PLD7MB.js} +9 -8
  26. package/dist/{chunk-ONSDE37A.js → chunk-SFQP6O52.js} +1 -0
  27. package/dist/{chunk-XMQZENBP.js → chunk-TVY72CLV.js} +3 -1
  28. package/dist/chunk-WIXGT4TN.js +18 -0
  29. package/dist/{email-verification-H_WlpsVH.d.ts → email-verification-D8N7P6Pu.d.ts} +1 -1
  30. package/dist/encryption/index.js +2 -2
  31. package/dist/events/index.js +1 -1
  32. package/dist/i18n/index.d.ts +2 -2
  33. package/dist/index.d.ts +333 -333
  34. package/dist/index.js +186 -65
  35. package/dist/lambda/index.d.ts +5 -5
  36. package/dist/mail/index.js +3 -2
  37. package/dist/mcp/index.d.ts +14 -4
  38. package/dist/mcp/index.js +3 -2
  39. package/dist/notifications/index.d.ts +5 -5
  40. package/dist/notifications/index.js +3 -2
  41. package/dist/queue/index.d.ts +5 -5
  42. package/dist/queue/index.js +1 -1
  43. package/dist/redis/index.d.ts +4 -4
  44. package/dist/redis/index.js +7 -0
  45. package/dist/runtime/index.d.ts +5 -5
  46. package/dist/runtime/index.js +24 -9
  47. package/dist/scheduling/index.js +2 -2
  48. package/dist/storage/index.js +2 -1
  49. package/dist/{Application-Bi-olFMF.d.ts → validation-CDR7lRE8.d.ts} +749 -719
  50. package/package.json +3 -3
  51. package/dist/McpServiceProvider-TZWQWXCT.js +0 -7
  52. package/dist/{api-token-COQHXyM_.d.ts → api-token-D24VPr_E.d.ts} +101 -101
  53. package/dist/{client-BQwF2b9Y.d.ts → rate-limit-D9J2b4S1.d.ts} +36 -36
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guren/server",
3
- "version": "1.5.0",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -109,8 +109,8 @@
109
109
  "test": "bun test"
110
110
  },
111
111
  "dependencies": {
112
- "@guren/orm": "^1.3.0",
113
- "@modelcontextprotocol/sdk": "^1.27.1",
112
+ "@guren/orm": "^2.0.0",
113
+ "@modelcontextprotocol/sdk": "^1.30.0",
114
114
  "chalk": "^5.3.0",
115
115
  "consola": "^3.4.2",
116
116
  "figlet": "^1.7.0",
@@ -1,7 +0,0 @@
1
- import {
2
- McpServiceProvider
3
- } from "./chunk-NQCZQAJL.js";
4
- import "./chunk-NYQGAWDN.js";
5
- export {
6
- McpServiceProvider
7
- };
@@ -75,107 +75,6 @@ declare function getSessionFromContext<T extends Session = Session>(ctx: {
75
75
  get: (key: string) => unknown;
76
76
  }): T | undefined;
77
77
 
78
- type AuthCredentials = Record<string, unknown>;
79
- interface Authenticatable {
80
- getAuthIdentifier(): unknown;
81
- getAuthPassword(): string | null | undefined;
82
- getRememberToken?(): string | null | undefined;
83
- setRememberToken?(token: string | null): void | Promise<void>;
84
- }
85
- interface Guard<User = Authenticatable> {
86
- check(): Promise<boolean>;
87
- guest(): Promise<boolean>;
88
- user<T = User>(): Promise<T | null>;
89
- id(): Promise<unknown>;
90
- login<T = User>(user: T, remember?: boolean): Promise<void>;
91
- logout(): Promise<void>;
92
- attempt(credentials: AuthCredentials, remember?: boolean): Promise<boolean>;
93
- validate(credentials: AuthCredentials): Promise<User | null>;
94
- session<T extends Session = Session>(): T | undefined;
95
- }
96
- interface UserProvider<User = Authenticatable> {
97
- retrieveById(identifier: unknown): Promise<User | null>;
98
- retrieveByCredentials(credentials: AuthCredentials): Promise<User | null>;
99
- validateCredentials(user: User, credentials: AuthCredentials): Promise<boolean>;
100
- getId(user: User): unknown;
101
- setRememberToken?(user: User, token: string | null): Promise<void> | void;
102
- getRememberToken?(user: User): Promise<string | null> | string | null;
103
- /**
104
- * Strip fields that must never leave the auth layer (password hashes,
105
- * remember tokens, model `hidden` fields) from a user record before it
106
- * is cached or handed to application code via guard.user().
107
- */
108
- sanitize?(user: User): User;
109
- }
110
- /**
111
- * The conventional names for the credential columns that
112
- * `ModelUserProvider.sanitize()` strips: the password column (`password`
113
- * by default, commonly configured as `passwordHash`/`password_hash`) and
114
- * the remember-token column (`remember_token` by default, commonly
115
- * `rememberToken`).
116
- */
117
- type DefaultSanitizedKeys = 'password' | 'passwordHash' | 'password_hash' | 'rememberToken' | 'remember_token';
118
- /**
119
- * The shape of a user record after auth-layer sanitization — what
120
- * `auth.user()` returns at runtime when the provider's column names
121
- * follow the {@link DefaultSanitizedKeys} conventions. Removes those
122
- * conventional credential keys plus any extra keys passed as `Hidden`.
123
- *
124
- * The runtime strips exactly the *configured* password/remember-token
125
- * columns plus the model's `static hidden` — a static type cannot see
126
- * that configuration. If your columns use other names, or the model
127
- * hides additional fields, list them in `Hidden` explicitly. Only
128
- * meaningful for concrete record types (index-signature records like
129
- * `Record<string, string>` cannot have individual keys removed).
130
- *
131
- * @example
132
- * ```ts
133
- * const user = await this.auth.userOrFail<Sanitized<UserRecord>>()
134
- * user.passwordHash // compile error — stripped at runtime
135
- *
136
- * // With additional hidden fields or custom column names:
137
- * type SafeUser = Sanitized<UserRecord, 'twoFactorSecret' | 'credentialDigest'>
138
- * ```
139
- */
140
- type Sanitized<User, Hidden extends string = never> = User extends unknown ? Omit<User, Extract<keyof User, DefaultSanitizedKeys | Hidden>> : never;
141
- interface GuardContext {
142
- ctx: Context;
143
- session: Session | undefined;
144
- manager: AuthManagerContract;
145
- }
146
- type GuardFactory<User = Authenticatable> = (context: GuardContext) => Guard<User>;
147
- interface ProviderFactory<User = Authenticatable> {
148
- (manager: AuthManagerContract): UserProvider<User>;
149
- }
150
- interface AuthManagerOptions {
151
- defaultGuard?: string;
152
- }
153
- interface AttachContextOptions {
154
- guard?: string;
155
- }
156
- interface AuthContext<User = Authenticatable> {
157
- check(): Promise<boolean>;
158
- guest(): Promise<boolean>;
159
- user<T = User>(): Promise<T | null>;
160
- userOrFail<T = User>(): Promise<T>;
161
- id(): Promise<unknown>;
162
- login<T = User>(user: T, remember?: boolean): Promise<void>;
163
- attempt(credentials: AuthCredentials, remember?: boolean): Promise<boolean>;
164
- logout(): Promise<void>;
165
- guard<T = User>(name?: string): Guard<T>;
166
- session<T extends Session = Session>(): T | undefined;
167
- }
168
- interface AuthManagerContract {
169
- registerGuard<User = Authenticatable>(name: string, factory: GuardFactory<User>): void;
170
- registerProvider<User = Authenticatable>(name: string, factory: ProviderFactory<User>): void;
171
- getProvider<User = Authenticatable>(name: string): UserProvider<User>;
172
- createGuard<User = Authenticatable>(name: string, context: GuardContext): Guard<User>;
173
- guardNames(): string[];
174
- setDefaultGuard(name: string): void;
175
- getDefaultGuard(): string;
176
- createAuthContext(ctx: Context, options?: AttachContextOptions): AuthContext;
177
- }
178
-
179
78
  interface OAuthProviderConfig {
180
79
  clientId: string;
181
80
  clientSecret: string;
@@ -361,6 +260,107 @@ declare function parseOAuthRedirectUrl(url: string): {
361
260
  email: string | null;
362
261
  };
363
262
 
263
+ type AuthCredentials = Record<string, unknown>;
264
+ interface Authenticatable {
265
+ getAuthIdentifier(): unknown;
266
+ getAuthPassword(): string | null | undefined;
267
+ getRememberToken?(): string | null | undefined;
268
+ setRememberToken?(token: string | null): void | Promise<void>;
269
+ }
270
+ interface Guard<User = Authenticatable> {
271
+ check(): Promise<boolean>;
272
+ guest(): Promise<boolean>;
273
+ user<T = User>(): Promise<T | null>;
274
+ id(): Promise<unknown>;
275
+ login<T = User>(user: T, remember?: boolean): Promise<void>;
276
+ logout(): Promise<void>;
277
+ attempt(credentials: AuthCredentials, remember?: boolean): Promise<boolean>;
278
+ validate(credentials: AuthCredentials): Promise<User | null>;
279
+ session<T extends Session = Session>(): T | undefined;
280
+ }
281
+ interface UserProvider<User = Authenticatable> {
282
+ retrieveById(identifier: unknown): Promise<User | null>;
283
+ retrieveByCredentials(credentials: AuthCredentials): Promise<User | null>;
284
+ validateCredentials(user: User, credentials: AuthCredentials): Promise<boolean>;
285
+ getId(user: User): unknown;
286
+ setRememberToken?(user: User, token: string | null): Promise<void> | void;
287
+ getRememberToken?(user: User): Promise<string | null> | string | null;
288
+ /**
289
+ * Strip fields that must never leave the auth layer (password hashes,
290
+ * remember tokens, model `hidden` fields) from a user record before it
291
+ * is cached or handed to application code via guard.user().
292
+ */
293
+ sanitize?(user: User): User;
294
+ }
295
+ /**
296
+ * The conventional names for the credential columns that
297
+ * `ModelUserProvider.sanitize()` strips: the password column (`password`
298
+ * by default, commonly configured as `passwordHash`/`password_hash`) and
299
+ * the remember-token column (`remember_token` by default, commonly
300
+ * `rememberToken`).
301
+ */
302
+ type DefaultSanitizedKeys = 'password' | 'passwordHash' | 'password_hash' | 'rememberToken' | 'remember_token';
303
+ /**
304
+ * The shape of a user record after auth-layer sanitization — what
305
+ * `auth.user()` returns at runtime when the provider's column names
306
+ * follow the {@link DefaultSanitizedKeys} conventions. Removes those
307
+ * conventional credential keys plus any extra keys passed as `Hidden`.
308
+ *
309
+ * The runtime strips exactly the *configured* password/remember-token
310
+ * columns plus the model's `static hidden` — a static type cannot see
311
+ * that configuration. If your columns use other names, or the model
312
+ * hides additional fields, list them in `Hidden` explicitly. Only
313
+ * meaningful for concrete record types (index-signature records like
314
+ * `Record<string, string>` cannot have individual keys removed).
315
+ *
316
+ * @example
317
+ * ```ts
318
+ * const user = await this.auth.userOrFail<Sanitized<UserRecord>>()
319
+ * user.passwordHash // compile error — stripped at runtime
320
+ *
321
+ * // With additional hidden fields or custom column names:
322
+ * type SafeUser = Sanitized<UserRecord, 'twoFactorSecret' | 'credentialDigest'>
323
+ * ```
324
+ */
325
+ type Sanitized<User, Hidden extends string = never> = User extends unknown ? Omit<User, Extract<keyof User, DefaultSanitizedKeys | Hidden>> : never;
326
+ interface GuardContext {
327
+ ctx: Context;
328
+ session: Session | undefined;
329
+ manager: AuthManagerContract;
330
+ }
331
+ type GuardFactory<User = Authenticatable> = (context: GuardContext) => Guard<User>;
332
+ interface ProviderFactory<User = Authenticatable> {
333
+ (manager: AuthManagerContract): UserProvider<User>;
334
+ }
335
+ interface AuthManagerOptions {
336
+ defaultGuard?: string;
337
+ }
338
+ interface AttachContextOptions {
339
+ guard?: string;
340
+ }
341
+ interface AuthContext<User = Authenticatable> {
342
+ check(): Promise<boolean>;
343
+ guest(): Promise<boolean>;
344
+ user<T = User>(): Promise<T | null>;
345
+ userOrFail<T = User>(): Promise<T>;
346
+ id(): Promise<unknown>;
347
+ login<T = User>(user: T, remember?: boolean): Promise<void>;
348
+ attempt(credentials: AuthCredentials, remember?: boolean): Promise<boolean>;
349
+ logout(): Promise<void>;
350
+ guard<T = User>(name?: string): Guard<T>;
351
+ session<T extends Session = Session>(): T | undefined;
352
+ }
353
+ interface AuthManagerContract {
354
+ registerGuard<User = Authenticatable>(name: string, factory: GuardFactory<User>): void;
355
+ registerProvider<User = Authenticatable>(name: string, factory: ProviderFactory<User>): void;
356
+ getProvider<User = Authenticatable>(name: string): UserProvider<User>;
357
+ createGuard<User = Authenticatable>(name: string, context: GuardContext): Guard<User>;
358
+ guardNames(): string[];
359
+ setDefaultGuard(name: string): void;
360
+ getDefaultGuard(): string;
361
+ createAuthContext(ctx: Context, options?: AttachContextOptions): AuthContext;
362
+ }
363
+
364
364
  /**
365
365
  * API token data stored in the backing store.
366
366
  */
@@ -1,5 +1,40 @@
1
- import { Context, MiddlewareHandler } from 'hono';
2
1
  import Redis, { RedisOptions } from 'ioredis';
2
+ import { Context, MiddlewareHandler } from 'hono';
3
+
4
+ /**
5
+ * Options for creating a Redis client.
6
+ */
7
+ interface RedisClientOptions extends RedisOptions {
8
+ /**
9
+ * Redis connection URL (e.g., 'redis://localhost:6379').
10
+ * If provided, overrides host/port/password.
11
+ */
12
+ url?: string;
13
+ /**
14
+ * Key prefix for all operations.
15
+ * @default ''
16
+ */
17
+ keyPrefix?: string;
18
+ }
19
+ /**
20
+ * Create a Redis client with the given options.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * // Using URL
25
+ * const redis = createRedisClient({ url: 'redis://localhost:6379' })
26
+ *
27
+ * // Using host/port
28
+ * const redis = createRedisClient({ host: 'localhost', port: 6379 })
29
+ *
30
+ * // With key prefix
31
+ * const redis = createRedisClient({
32
+ * url: process.env.REDIS_URL,
33
+ * keyPrefix: 'myapp:',
34
+ * })
35
+ * ```
36
+ */
37
+ declare function createRedisClient(options?: RedisClientOptions): Redis;
3
38
 
4
39
  /**
5
40
  * Rate limit entry stored in the backing store.
@@ -201,39 +236,4 @@ declare class SlidingWindowRateLimitStore extends BaseMemoryStore {
201
236
  get size(): number;
202
237
  }
203
238
 
204
- /**
205
- * Options for creating a Redis client.
206
- */
207
- interface RedisClientOptions extends RedisOptions {
208
- /**
209
- * Redis connection URL (e.g., 'redis://localhost:6379').
210
- * If provided, overrides host/port/password.
211
- */
212
- url?: string;
213
- /**
214
- * Key prefix for all operations.
215
- * @default ''
216
- */
217
- keyPrefix?: string;
218
- }
219
- /**
220
- * Create a Redis client with the given options.
221
- *
222
- * @example
223
- * ```ts
224
- * // Using URL
225
- * const redis = createRedisClient({ url: 'redis://localhost:6379' })
226
- *
227
- * // Using host/port
228
- * const redis = createRedisClient({ host: 'localhost', port: 6379 })
229
- *
230
- * // With key prefix
231
- * const redis = createRedisClient({
232
- * url: process.env.REDIS_URL,
233
- * keyPrefix: 'myapp:',
234
- * })
235
- * ```
236
- */
237
- declare function createRedisClient(options?: RedisClientOptions): Redis;
238
-
239
239
  export { MemoryRateLimitStore as M, type RateLimitStore as R, SlidingWindowRateLimitStore as S, type RateLimitEntry as a, type RedisClientOptions as b, createRedisClient as c, type RateLimitInfo as d, type RateLimitOptions as e, createRateLimitMiddleware as f, getRateLimitInfo as g, resetRateLimit as r };