@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.
Files changed (51) hide show
  1. package/dist/{Application-DImeY-VW.d.ts → Application-Bi-olFMF.d.ts} +387 -18
  2. package/dist/{AuthManager-BU8ZvenF.d.ts → AuthManager-C84xF5ks.d.ts} +1 -1
  3. package/dist/{BroadcastManager-CGWl9rUO.d.ts → BroadcastManager-D8KoJxiV.d.ts} +21 -0
  4. package/dist/{CacheManager-BkvHEOZX.d.ts → CacheManager-BmDzUKrF.d.ts} +17 -0
  5. package/dist/ConsoleKernel-D0dkFt6u.d.ts +101 -0
  6. package/dist/{McpServiceProvider-RNTDHZAZ.js → McpServiceProvider-TZWQWXCT.js} +2 -2
  7. package/dist/{Scheduler-BstvSca7.d.ts → Scheduler-pZiT8i57.d.ts} +2 -0
  8. package/dist/{api-token-CB12xnVg.d.ts → api-token-COQHXyM_.d.ts} +68 -1
  9. package/dist/auth/index.d.ts +5 -5
  10. package/dist/auth/index.js +1 -1
  11. package/dist/authorization/index.js +2 -2
  12. package/dist/broadcasting/index.d.ts +2 -2
  13. package/dist/broadcasting/index.js +2 -1
  14. package/dist/cache/index.d.ts +2 -2
  15. package/dist/cache/index.js +2 -1
  16. package/dist/{chunk-EGU5KB7V.js → chunk-4SBGSJNT.js} +31 -1
  17. package/dist/{chunk-CSDKWLFD.js → chunk-5AD7LYWO.js} +111 -35
  18. package/dist/{chunk-THSX7OOR.js → chunk-63SKW5PS.js} +3 -0
  19. package/dist/{chunk-R2TCP7D7.js → chunk-6J6B5KOB.js} +18 -2
  20. package/dist/{chunk-VY2JPS6V.js → chunk-AUXQISW5.js} +83 -11
  21. package/dist/chunk-DCYKSYAT.js +63 -0
  22. package/dist/{chunk-ZRBLZY3M.js → chunk-FZD2AKJI.js} +1 -1
  23. package/dist/{chunk-HKQSAFSN.js → chunk-MC752CQT.js} +15 -0
  24. package/dist/{chunk-J753UWAY.js → chunk-NQCZQAJL.js} +93 -28
  25. package/dist/{chunk-STZUODC3.js → chunk-NYQGAWDN.js} +44 -1
  26. package/dist/{chunk-EDRGAM6G.js → chunk-RNXTRWKL.js} +2 -1
  27. package/dist/{chunk-CSP7W3WY.js → chunk-SHYRVOMJ.js} +2 -2
  28. package/dist/{chunk-44F7JQ7I.js → chunk-XMQZENBP.js} +35 -1
  29. package/dist/{chunk-WJJ5CTNI.js → chunk-Z3HXKWI6.js} +2 -2
  30. package/dist/{client-CKXJLsTe.d.ts → client-BQwF2b9Y.d.ts} +7 -0
  31. package/dist/{email-verification-D9u7krkn.d.ts → email-verification-H_WlpsVH.d.ts} +1 -1
  32. package/dist/{errors-JOOPDDQ6.js → errors-PUNHAFL2.js} +1 -1
  33. package/dist/index.d.ts +35 -17
  34. package/dist/index.js +329 -132
  35. package/dist/lambda/index.d.ts +7 -7
  36. package/dist/lambda/index.js +1 -1
  37. package/dist/mail/index.js +3 -3
  38. package/dist/mcp/index.d.ts +53 -19
  39. package/dist/mcp/index.js +2 -2
  40. package/dist/notifications/index.d.ts +57 -8
  41. package/dist/notifications/index.js +11 -3
  42. package/dist/queue/index.d.ts +7 -7
  43. package/dist/queue/index.js +4 -2
  44. package/dist/redis/index.d.ts +11 -21
  45. package/dist/redis/index.js +42 -6
  46. package/dist/runtime/index.d.ts +7 -7
  47. package/dist/runtime/index.js +1 -1
  48. package/dist/scheduling/index.d.ts +2 -2
  49. package/dist/scheduling/index.js +2 -1
  50. package/package.json +2 -2
  51. package/dist/ConsoleKernel-COKndy_V.d.ts +0 -207
@@ -1,19 +1,19 @@
1
1
  import * as hono_aws_lambda from 'hono/aws-lambda';
2
2
  export { APIGatewayProxyResult, LambdaEvent } from 'hono/aws-lambda';
3
- import { A as Application } from '../Application-DImeY-VW.js';
4
- import { S as Scheduler } from '../Scheduler-BstvSca7.js';
5
- import { C as ConsoleKernel } from '../ConsoleKernel-COKndy_V.js';
3
+ import { A as Application } from '../Application-Bi-olFMF.js';
4
+ import { S as Scheduler } from '../Scheduler-pZiT8i57.js';
5
+ import { C as ConsoleKernel } from '../ConsoleKernel-D0dkFt6u.js';
6
6
  import 'hono';
7
- import '../api-token-CB12xnVg.js';
8
- import '../AuthManager-BU8ZvenF.js';
7
+ import '../api-token-COQHXyM_.js';
8
+ import '../AuthManager-C84xF5ks.js';
9
9
  import '@guren/orm';
10
10
  import 'vite';
11
11
  import '../EventManager-CmIoLt7r.js';
12
- import '../CacheManager-BkvHEOZX.js';
12
+ import '../CacheManager-BmDzUKrF.js';
13
13
  import '../MailManager-DpMvYiP9.js';
14
14
  import '../LogManager-7mxnkaPM.js';
15
15
  import '../I18nManager-CmUqj6bU.js';
16
- import '../BroadcastManager-CGWl9rUO.js';
16
+ import '../BroadcastManager-D8KoJxiV.js';
17
17
  import '../index-9_Jzj5jo.js';
18
18
  import '../app-key-CsBfRC_Q.js';
19
19
  import '../StorageManager-oZTHqaza.js';
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getJob
3
- } from "../chunk-R2TCP7D7.js";
3
+ } from "../chunk-6J6B5KOB.js";
4
4
 
5
5
  // src/lambda/index.ts
6
6
  import { handle } from "hono/aws-lambda";
@@ -9,9 +9,9 @@ import {
9
9
  getMailManager,
10
10
  mail,
11
11
  setMailManager
12
- } from "../chunk-EDRGAM6G.js";
13
- import "../chunk-WJJ5CTNI.js";
14
- import "../chunk-R2TCP7D7.js";
12
+ } from "../chunk-RNXTRWKL.js";
13
+ import "../chunk-Z3HXKWI6.js";
14
+ import "../chunk-6J6B5KOB.js";
15
15
  export {
16
16
  LogTransport,
17
17
  Mail,
@@ -1,23 +1,47 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { S as ServiceProvider } from '../Application-DImeY-VW.js';
2
+ import { S as ServiceProvider } from '../Application-Bi-olFMF.js';
3
3
  import 'hono';
4
- import '../api-token-CB12xnVg.js';
5
- import '../AuthManager-BU8ZvenF.js';
4
+ import '../api-token-COQHXyM_.js';
5
+ import '../AuthManager-C84xF5ks.js';
6
6
  import '@guren/orm';
7
7
  import 'vite';
8
8
  import '../EventManager-CmIoLt7r.js';
9
- import '../CacheManager-BkvHEOZX.js';
9
+ import '../CacheManager-BmDzUKrF.js';
10
10
  import '../MailManager-DpMvYiP9.js';
11
11
  import '../LogManager-7mxnkaPM.js';
12
12
  import '../I18nManager-CmUqj6bU.js';
13
- import '../BroadcastManager-CGWl9rUO.js';
13
+ import '../BroadcastManager-D8KoJxiV.js';
14
14
  import '../index-9_Jzj5jo.js';
15
15
  import '../app-key-CsBfRC_Q.js';
16
16
  import '../StorageManager-oZTHqaza.js';
17
17
  import '../HealthManager-DUyMIzsZ.js';
18
- import '../Scheduler-BstvSca7.js';
18
+ import '../Scheduler-pZiT8i57.js';
19
19
  import '../Gate-CynjZCtS.js';
20
20
 
21
+ /**
22
+ * Options the `.guren/*.gen.ts` generators are called with. Only `force`
23
+ * reaches them — they resolve every path against the process cwd, which the
24
+ * codegen tool sets before calling. `cwd` rides along to name the project the
25
+ * call is for.
26
+ */
27
+ interface CodegenOptions {
28
+ cwd: string;
29
+ force?: boolean;
30
+ }
31
+ /**
32
+ * What a generator reports back. An empty `outputPath` means the generator
33
+ * found nothing to describe and wrote no file (a project with no page
34
+ * components, for instance).
35
+ *
36
+ * `definitions` is the route manifest `generateRouteTypes` builds. It stays
37
+ * opaque here — this package only carries it from one CLI call to the next
38
+ * (`generateApiClientTypes` consumes it) and never reads inside it, so
39
+ * mirroring the CLI's route shape would only create something to keep in sync.
40
+ */
41
+ interface CodegenResult {
42
+ outputPath?: string;
43
+ definitions?: unknown[];
44
+ }
21
45
  /**
22
46
  * CLI functions that the MCP server wraps.
23
47
  * These are injected at runtime to avoid circular dependencies
@@ -45,6 +69,11 @@ interface GurenCliApi {
45
69
  validators: string[];
46
70
  }>;
47
71
  renderContextMarkdown(ctx: unknown): string;
72
+ generateEntityContext(entity: string, opts: {
73
+ cwd: string;
74
+ module?: string;
75
+ }): Promise<unknown>;
76
+ renderEntityContextMarkdown(ctx: unknown): string;
48
77
  runCheck(opts: {
49
78
  cwd: string;
50
79
  }): Promise<{
@@ -103,18 +132,21 @@ interface GurenCliApi {
103
132
  makeRoute(name: string, opts: {
104
133
  force?: boolean;
105
134
  }): Promise<string | string[]>;
106
- generateRouteTypes(opts: {
107
- cwd: string;
108
- }): Promise<unknown>;
109
- generatePageTypes(opts: {
110
- cwd: string;
111
- }): Promise<unknown>;
112
- generateDataTypes(opts: {
113
- cwd: string;
114
- }): Promise<unknown>;
115
- generateChannelTypes(opts: {
116
- cwd: string;
117
- }): Promise<unknown>;
135
+ generateRouteTypes(opts: CodegenOptions): Promise<CodegenResult | void>;
136
+ generatePageTypes(opts: CodegenOptions): Promise<CodegenResult | void>;
137
+ generateDataTypes(opts: CodegenOptions): Promise<CodegenResult | void>;
138
+ generateChannelTypes(opts: CodegenOptions): Promise<CodegenResult | void>;
139
+ /**
140
+ * Takes the route manifest `generateRouteTypes` returns, so it can only run
141
+ * after that succeeded.
142
+ */
143
+ generateApiClientTypes(definitions: unknown[], opts: CodegenOptions): Promise<CodegenResult | void>;
144
+ /**
145
+ * Route-dependent context generation that re-runs the CLI in a fresh
146
+ * process. Optional because `@guren/cli` is resolved from the app at
147
+ * runtime and may predate it — see `McpServiceProvider`.
148
+ */
149
+ createFreshContextApi?: () => Pick<GurenCliApi, 'generateContext' | 'generateEntityContext'>;
118
150
  }
119
151
  interface CreateMcpServerOptions {
120
152
  cwd: string;
@@ -126,7 +158,9 @@ declare function createMcpServer(options: CreateMcpServerOptions): McpServer;
126
158
  /**
127
159
  * Registers the MCP (Model Context Protocol) endpoint at /_guren/mcp.
128
160
  *
129
- * This provider is only active in development mode (NODE_ENV !== 'production').
161
+ * Only active while `isMcpEndpointEnabled()` holds, so registering this
162
+ * provider directly honours the same `GUREN_MCP=1` opt-in that `Application`
163
+ * gates on — and the same condition that exempts the endpoint from CSRF.
130
164
  * It allows AI coding agents (Claude Code, Cursor, etc.) to introspect
131
165
  * the project structure, run integrity checks, and scaffold code.
132
166
  *
package/dist/mcp/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  McpServiceProvider,
3
3
  createMcpServer
4
- } from "../chunk-J753UWAY.js";
5
- import "../chunk-STZUODC3.js";
4
+ } from "../chunk-NQCZQAJL.js";
5
+ import "../chunk-NYQGAWDN.js";
6
6
  export {
7
7
  McpServiceProvider,
8
8
  createMcpServer
@@ -1,23 +1,72 @@
1
- import { a1 as NotificationChannel, _ as Notifiable, $ as Notification, u as DatabaseNotification, t as DatabaseChannelOptions, au as SlackMessage, al as SentNotification } from '../Application-DImeY-VW.js';
2
- export { a0 as NotificationAttachment, a2 as NotificationChannelFactory, a3 as NotificationClass, a4 as NotificationMailMessage, N as NotificationManager, a5 as NotificationManagerOptions, as as SlackAttachment, at as SlackBlock, aI as createNotificationManager, aS as getNotificationManager, b1 as setNotificationManager } from '../Application-DImeY-VW.js';
1
+ import { ab as Notification, aa as Notifiable, ad as NotificationChannel, B as DatabaseNotification, z as DatabaseChannelOptions, aJ as SlackMessage, aA as SentNotification } from '../Application-Bi-olFMF.js';
2
+ export { ac as NotificationAttachment, ae as NotificationChannelFactory, af as NotificationClass, ag as NotificationMailMessage, N as NotificationManager, ah as NotificationManagerOptions, aH as SlackAttachment, aI as SlackBlock, aX as createNotificationManager, b6 as getNotificationManager, bl as setNotificationManager } from '../Application-Bi-olFMF.js';
3
3
  import { M as MailManager } from '../MailManager-DpMvYiP9.js';
4
4
  import 'hono';
5
- import '../api-token-CB12xnVg.js';
6
- import '../AuthManager-BU8ZvenF.js';
5
+ import '../api-token-COQHXyM_.js';
6
+ import '../AuthManager-C84xF5ks.js';
7
7
  import '@guren/orm';
8
8
  import 'vite';
9
9
  import '../EventManager-CmIoLt7r.js';
10
- import '../CacheManager-BkvHEOZX.js';
10
+ import '../CacheManager-BmDzUKrF.js';
11
11
  import '../LogManager-7mxnkaPM.js';
12
12
  import '../I18nManager-CmUqj6bU.js';
13
- import '../BroadcastManager-CGWl9rUO.js';
13
+ import '../BroadcastManager-D8KoJxiV.js';
14
14
  import '../index-9_Jzj5jo.js';
15
15
  import '../app-key-CsBfRC_Q.js';
16
16
  import '../StorageManager-oZTHqaza.js';
17
17
  import '../HealthManager-DUyMIzsZ.js';
18
- import '../Scheduler-BstvSca7.js';
18
+ import '../Scheduler-pZiT8i57.js';
19
19
  import '../Gate-CynjZCtS.js';
20
20
 
21
+ /**
22
+ * A notification class usable for queue reconstruction.
23
+ *
24
+ * Only the prototype and name are required: queued notifications are rebuilt
25
+ * with `Object.create(prototype)` and never constructed, so classes with
26
+ * required constructor arguments are supported.
27
+ */
28
+ interface NotificationConstructor {
29
+ readonly name: string;
30
+ readonly prototype: Notification;
31
+ }
32
+ /**
33
+ * Register a notification class so queued instances can be rebuilt.
34
+ *
35
+ * Notifications are registered automatically when they are queued, which
36
+ * covers delivery by a worker running in the same process. A worker running
37
+ * in a separate process must register them explicitly at boot.
38
+ *
39
+ * Type names must be unique within an application: as with the job registry,
40
+ * registering a second class under an existing type replaces the first.
41
+ *
42
+ * @param notificationClass - The notification class to register
43
+ * @param type - Registry key, defaulting to the class's own `type` value
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * registerNotification(OrderShipped)
48
+ * ```
49
+ */
50
+ declare function registerNotification(notificationClass: NotificationConstructor, type?: string): void;
51
+ /**
52
+ * Get a registered notification class by type.
53
+ */
54
+ declare function getNotification(type: string): NotificationConstructor | undefined;
55
+ /**
56
+ * Clear all registered notifications (for testing).
57
+ */
58
+ declare function clearNotificationRegistry(): void;
59
+
60
+ /**
61
+ * Resolve the stable type name of a notifiable.
62
+ *
63
+ * Channels that record which entity a notification belongs to should use this
64
+ * rather than reading `constructor.name` directly: a notifiable rebuilt from a
65
+ * queue payload carries its original name in `notifiableType`, and its
66
+ * constructor is a plain object.
67
+ */
68
+ declare function resolveNotifiableType(notifiable: Notifiable): string;
69
+
21
70
  /**
22
71
  * Mail notification channel.
23
72
  *
@@ -270,4 +319,4 @@ declare class MemoryChannel implements NotificationChannel {
270
319
  clear(): void;
271
320
  }
272
321
 
273
- export { DatabaseChannel, DatabaseChannelOptions, DatabaseNotification, MailChannel, type MailChannelOptions, MemoryChannel, Notifiable, Notification, NotificationChannel, SentNotification, SlackChannel, type SlackChannelOptions, SlackMessage };
322
+ export { DatabaseChannel, DatabaseChannelOptions, DatabaseNotification, MailChannel, type MailChannelOptions, MemoryChannel, Notifiable, Notification, NotificationChannel, type NotificationConstructor, SentNotification, SlackChannel, type SlackChannelOptions, SlackMessage, clearNotificationRegistry, getNotification, registerNotification, resolveNotifiableType };
@@ -5,12 +5,16 @@ import {
5
5
  Notification,
6
6
  NotificationManager,
7
7
  SlackChannel,
8
+ clearNotificationRegistry,
8
9
  createNotificationManager,
10
+ getNotification,
9
11
  getNotificationManager,
12
+ registerNotification,
13
+ resolveNotifiableType,
10
14
  setNotificationManager
11
- } from "../chunk-CSDKWLFD.js";
12
- import "../chunk-WJJ5CTNI.js";
13
- import "../chunk-R2TCP7D7.js";
15
+ } from "../chunk-5AD7LYWO.js";
16
+ import "../chunk-Z3HXKWI6.js";
17
+ import "../chunk-6J6B5KOB.js";
14
18
  export {
15
19
  DatabaseChannel,
16
20
  MailChannel,
@@ -18,7 +22,11 @@ export {
18
22
  Notification,
19
23
  NotificationManager,
20
24
  SlackChannel,
25
+ clearNotificationRegistry,
21
26
  createNotificationManager,
27
+ getNotification,
22
28
  getNotificationManager,
29
+ registerNotification,
30
+ resolveNotifiableType,
23
31
  setNotificationManager
24
32
  };
@@ -1,22 +1,22 @@
1
- import { a8 as QueueDriver, aa as QueuedJob, F as FailedJob, ay as WorkerOptions } from '../Application-DImeY-VW.js';
2
- export { V as Job, W as JobClass, X as JobFailureHandler, Y as JobHandler, Z as JobOptions, a7 as QueueConfig, a9 as QueueDriverFactory, Q as QueueManager, aC as clearJobRegistry, aJ as createQueueManager, aR as getJob, aT as getQueueDriver, aU as getRegisteredJobs, aY as registerJob, b2 as setQueueDriver } from '../Application-DImeY-VW.js';
1
+ import { am as QueueDriver, ao as QueuedJob, M as FailedJob, aN as WorkerOptions } from '../Application-Bi-olFMF.js';
2
+ export { a4 as Job, a5 as JobClass, a6 as JobFailureHandler, a7 as JobHandler, a8 as JobOptions, al as QueueConfig, an as QueueDriverFactory, Q as QueueManager, aR as clearJobRegistry, aY as createQueueManager, b5 as getJob, b7 as getQueueDriver, b8 as getRegisteredJobs, bd as registerJob, bf as resolveJobName, bm as setQueueDriver } from '../Application-Bi-olFMF.js';
3
3
  import { Redis } from 'ioredis';
4
4
  import 'hono';
5
- import '../api-token-CB12xnVg.js';
6
- import '../AuthManager-BU8ZvenF.js';
5
+ import '../api-token-COQHXyM_.js';
6
+ import '../AuthManager-C84xF5ks.js';
7
7
  import '@guren/orm';
8
8
  import 'vite';
9
9
  import '../EventManager-CmIoLt7r.js';
10
- import '../CacheManager-BkvHEOZX.js';
10
+ import '../CacheManager-BmDzUKrF.js';
11
11
  import '../MailManager-DpMvYiP9.js';
12
12
  import '../LogManager-7mxnkaPM.js';
13
13
  import '../I18nManager-CmUqj6bU.js';
14
- import '../BroadcastManager-CGWl9rUO.js';
14
+ import '../BroadcastManager-D8KoJxiV.js';
15
15
  import '../index-9_Jzj5jo.js';
16
16
  import '../app-key-CsBfRC_Q.js';
17
17
  import '../StorageManager-oZTHqaza.js';
18
18
  import '../HealthManager-DUyMIzsZ.js';
19
- import '../Scheduler-BstvSca7.js';
19
+ import '../Scheduler-pZiT8i57.js';
20
20
  import '../Gate-CynjZCtS.js';
21
21
 
22
22
  /**
@@ -9,7 +9,7 @@ import {
9
9
  createQueueManager,
10
10
  createSqsAdapter,
11
11
  processJob
12
- } from "../chunk-WJJ5CTNI.js";
12
+ } from "../chunk-Z3HXKWI6.js";
13
13
  import {
14
14
  Job,
15
15
  clearJobRegistry,
@@ -17,8 +17,9 @@ import {
17
17
  getQueueDriver,
18
18
  getRegisteredJobs,
19
19
  registerJob,
20
+ resolveJobName,
20
21
  setQueueDriver
21
- } from "../chunk-R2TCP7D7.js";
22
+ } from "../chunk-6J6B5KOB.js";
22
23
  export {
23
24
  FailedJobReporter,
24
25
  Job,
@@ -36,5 +37,6 @@ export {
36
37
  getRegisteredJobs,
37
38
  processJob,
38
39
  registerJob,
40
+ resolveJobName,
39
41
  setQueueDriver
40
42
  };
@@ -1,9 +1,9 @@
1
- import { R as RateLimitStore, a as RateLimitEntry } from '../client-CKXJLsTe.js';
2
- export { b as RedisClientOptions, c as createRedisClient } from '../client-CKXJLsTe.js';
1
+ import { R as RateLimitStore, a as RateLimitEntry } from '../client-BQwF2b9Y.js';
2
+ export { b as RedisClientOptions, c as createRedisClient } from '../client-BQwF2b9Y.js';
3
3
  import { Redis } from 'ioredis';
4
4
  export { default as Redis, RedisOptions } from 'ioredis';
5
- import { S as SessionStore, h as SessionData, i as ApiTokenStore, j as ApiToken, O as OAuthStateStore, k as OAuthStatePayload } from '../api-token-CB12xnVg.js';
6
- import { P as PasswordResetTokenStore, E as EmailVerificationTokenStore, a as EmailVerificationToken } from '../email-verification-D9u7krkn.js';
5
+ import { S as SessionStore, h as SessionData, i as ApiTokenStore, j as ApiToken, O as OAuthStateStore, k as OAuthStatePayload } from '../api-token-COQHXyM_.js';
6
+ import { P as PasswordResetTokenStore, E as EmailVerificationTokenStore, a as EmailVerificationToken } from '../email-verification-H_WlpsVH.js';
7
7
  import 'hono';
8
8
 
9
9
  /**
@@ -45,6 +45,11 @@ declare class RedisSessionStore implements SessionStore {
45
45
  * Delete a session from Redis.
46
46
  */
47
47
  destroy(id: string): Promise<void>;
48
+ /**
49
+ * Refresh an existing session's TTL without rewriting its data.
50
+ * EXPIRE on a missing key is a no-op, never a resurrection.
51
+ */
52
+ touch(id: string, ttlSeconds: number): Promise<void>;
48
53
  /**
49
54
  * Get all session keys (for debugging/admin purposes).
50
55
  * Note: This uses SCAN to avoid blocking Redis.
@@ -333,29 +338,14 @@ interface RedisOAuthStateStoreOptions {
333
338
  */
334
339
  prefix?: string;
335
340
  }
336
- /**
337
- * Redis-backed OAuth state store.
338
- *
339
- * Required in production whenever more than one server process handles
340
- * traffic (load balancers, serverless): the default MemoryOAuthStateStore
341
- * is per-process, so the callback request may land on a process that never
342
- * saw the state. Entries expire automatically via Redis TTL.
343
- *
344
- * @example
345
- * ```ts
346
- * import { createOAuthManager } from '@guren/core'
347
- * import { createRedisClient, RedisOAuthStateStore } from '@guren/core/redis'
348
- *
349
- * const redis = createRedisClient({ url: process.env.REDIS_URL })
350
- * const oauth = createOAuthManager({ stateStore: new RedisOAuthStateStore(redis) })
351
- * ```
352
- */
353
341
  declare class RedisOAuthStateStore implements OAuthStateStore {
354
342
  private readonly redis;
355
343
  private readonly prefix;
356
344
  constructor(redis: Redis, options?: RedisOAuthStateStoreOptions);
357
345
  store(stateHash: string, payload: OAuthStatePayload): Promise<void>;
358
346
  find(stateHash: string): Promise<OAuthStatePayload | null>;
347
+ consume(stateHash: string): Promise<OAuthStatePayload | null>;
348
+ private parsePayload;
359
349
  delete(stateHash: string): Promise<void>;
360
350
  /**
361
351
  * Clear all states (for testing).
@@ -52,6 +52,14 @@ var RedisSessionStore = class {
52
52
  const key = this.prefix + id;
53
53
  await this.redis.del(key);
54
54
  }
55
+ /**
56
+ * Refresh an existing session's TTL without rewriting its data.
57
+ * EXPIRE on a missing key is a no-op, never a resurrection.
58
+ */
59
+ async touch(id, ttlSeconds) {
60
+ const key = this.prefix + id;
61
+ await this.redis.expire(key, ttlSeconds);
62
+ }
55
63
  /**
56
64
  * Get all session keys (for debugging/admin purposes).
57
65
  * Note: This uses SCAN to avoid blocking Redis.
@@ -532,6 +540,13 @@ var RedisEmailVerificationStore = class {
532
540
  };
533
541
 
534
542
  // src/redis/RedisOAuthStateStore.ts
543
+ var CONSUME_SCRIPT = `
544
+ local value = redis.call('GET', KEYS[1])
545
+ if value then
546
+ redis.call('DEL', KEYS[1])
547
+ end
548
+ return value
549
+ `;
535
550
  var RedisOAuthStateStore = class {
536
551
  constructor(redis, options = {}) {
537
552
  this.redis = redis;
@@ -555,18 +570,39 @@ var RedisOAuthStateStore = class {
555
570
  if (!data) {
556
571
  return null;
557
572
  }
573
+ const payload = this.parsePayload(data);
574
+ if (!payload) {
575
+ return null;
576
+ }
577
+ if (payload.expiresAt.getTime() <= Date.now()) {
578
+ await this.delete(stateHash);
579
+ return null;
580
+ }
581
+ return payload;
582
+ }
583
+ async consume(stateHash) {
584
+ const data = await this.redis.eval(
585
+ CONSUME_SCRIPT,
586
+ 1,
587
+ `${this.prefix}${stateHash}`
588
+ );
589
+ if (!data) {
590
+ return null;
591
+ }
592
+ const payload = this.parsePayload(data);
593
+ if (!payload || payload.expiresAt.getTime() <= Date.now()) {
594
+ return null;
595
+ }
596
+ return payload;
597
+ }
598
+ parsePayload(data) {
558
599
  try {
559
600
  const parsed = JSON.parse(data);
560
- const payload = {
601
+ return {
561
602
  provider: parsed.provider,
562
603
  redirectTo: parsed.redirectTo,
563
604
  expiresAt: new Date(parsed.expiresAt)
564
605
  };
565
- if (payload.expiresAt.getTime() <= Date.now()) {
566
- await this.delete(stateHash);
567
- return null;
568
- }
569
- return payload;
570
606
  } catch {
571
607
  return null;
572
608
  }
@@ -1,21 +1,21 @@
1
- import { A as Application } from '../Application-DImeY-VW.js';
2
- export { D as DevBannerOptions, G as GUREN_ASCII_ART, a as StartViteDevServerOptions, b as StartedViteDevServer, l as logDevServerBanner, s as startViteDevServer } from '../Application-DImeY-VW.js';
1
+ import { A as Application } from '../Application-Bi-olFMF.js';
2
+ export { D as DevBannerOptions, G as GUREN_ASCII_ART, c as StartViteDevServerOptions, d as StartedViteDevServer, l as logDevServerBanner, s as startViteDevServer } from '../Application-Bi-olFMF.js';
3
3
  import 'hono';
4
- import '../api-token-CB12xnVg.js';
5
- import '../AuthManager-BU8ZvenF.js';
4
+ import '../api-token-COQHXyM_.js';
5
+ import '../AuthManager-C84xF5ks.js';
6
6
  import '@guren/orm';
7
7
  import 'vite';
8
8
  import '../EventManager-CmIoLt7r.js';
9
- import '../CacheManager-BkvHEOZX.js';
9
+ import '../CacheManager-BmDzUKrF.js';
10
10
  import '../MailManager-DpMvYiP9.js';
11
11
  import '../LogManager-7mxnkaPM.js';
12
12
  import '../I18nManager-CmUqj6bU.js';
13
- import '../BroadcastManager-CGWl9rUO.js';
13
+ import '../BroadcastManager-D8KoJxiV.js';
14
14
  import '../index-9_Jzj5jo.js';
15
15
  import '../app-key-CsBfRC_Q.js';
16
16
  import '../StorageManager-oZTHqaza.js';
17
17
  import '../HealthManager-DUyMIzsZ.js';
18
- import '../Scheduler-BstvSca7.js';
18
+ import '../Scheduler-pZiT8i57.js';
19
19
  import '../Gate-CynjZCtS.js';
20
20
 
21
21
  type RootPublicAssetsConfig = boolean | RootPublicAssetsOptions;
@@ -3,7 +3,7 @@ import {
3
3
  logDevServerBanner,
4
4
  parseImportMap,
5
5
  startViteDevServer
6
- } from "../chunk-CSP7W3WY.js";
6
+ } from "../chunk-SHYRVOMJ.js";
7
7
  import {
8
8
  hash
9
9
  } from "../chunk-QQKTH5KX.js";
@@ -1,5 +1,5 @@
1
- import { P as ParsedCron } from '../Scheduler-BstvSca7.js';
2
- export { J as JobClass, a as PendingSchedule, b as Schedule, c as ScheduledTask, S as Scheduler, d as SchedulerOptions, T as TaskCallback, e as TaskDefinition, f as createScheduler } from '../Scheduler-BstvSca7.js';
1
+ import { P as ParsedCron } from '../Scheduler-pZiT8i57.js';
2
+ export { J as JobClass, a as PendingSchedule, b as Schedule, c as ScheduledTask, S as Scheduler, d as SchedulerOptions, T as TaskCallback, e as TaskDefinition, f as createScheduler } from '../Scheduler-pZiT8i57.js';
3
3
 
4
4
  /**
5
5
  * Parse a cron expression.
@@ -11,7 +11,8 @@ import {
11
11
  matchesCron,
12
12
  parseCron,
13
13
  toTimezone
14
- } from "../chunk-HKQSAFSN.js";
14
+ } from "../chunk-MC752CQT.js";
15
+ import "../chunk-DCYKSYAT.js";
15
16
  export {
16
17
  PendingSchedule,
17
18
  Schedule,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guren/server",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -109,7 +109,7 @@
109
109
  "test": "bun test"
110
110
  },
111
111
  "dependencies": {
112
- "@guren/orm": "^1.0.1",
112
+ "@guren/orm": "^1.3.0",
113
113
  "@modelcontextprotocol/sdk": "^1.27.1",
114
114
  "chalk": "^5.3.0",
115
115
  "consola": "^3.4.2",