@guren/server 2.1.0 → 2.2.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/{McpServiceProvider-7BB5FPF3.js → McpServiceProvider-GRDYNEQG.js} +1 -1
- package/dist/auth/AuthManager.d.ts +30 -0
- package/dist/auth/AuthenticatableModel.d.ts +25 -0
- package/dist/auth/RequestAuthContext.d.ts +24 -0
- package/dist/auth/SessionGuard.d.ts +31 -0
- package/dist/auth/api-token.d.ts +299 -0
- package/dist/auth/email-verification.d.ts +203 -0
- package/dist/auth/index.d.ts +18 -110
- package/dist/auth/index.js +3 -1
- package/dist/auth/oauth/index.d.ts +239 -0
- package/dist/auth/password/DefaultHasher.d.ts +13 -0
- package/dist/auth/password/NodeHasher.d.ts +22 -0
- package/dist/auth/password/PasswordHasher.d.ts +5 -0
- package/dist/auth/password/ScryptHasher.d.ts +26 -0
- package/dist/auth/password-reset.d.ts +91 -0
- package/dist/auth/providers/ModelUserProvider.d.ts +36 -0
- package/dist/auth/providers/UserProvider.d.ts +9 -0
- package/dist/auth/types.d.ts +102 -0
- package/dist/auth/utils.d.ts +39 -0
- package/dist/{Gate-CynjZCtS.d.ts → authorization/Gate.d.ts} +30 -111
- package/dist/authorization/Policy.d.ts +77 -0
- package/dist/authorization/index.d.ts +5 -129
- package/dist/authorization/index.js +3 -1
- package/dist/authorization/middleware.d.ts +49 -0
- package/dist/authorization/types.d.ts +108 -0
- package/dist/broadcasting/BroadcastManager.d.ts +205 -0
- package/dist/broadcasting/channels/Channel.d.ts +28 -0
- package/dist/broadcasting/channels/PresenceChannel.d.ts +72 -0
- package/dist/broadcasting/channels/PrivateChannel.d.ts +32 -0
- package/dist/broadcasting/channels/index.d.ts +3 -0
- package/dist/broadcasting/drivers/MemoryDriver.d.ts +93 -0
- package/dist/broadcasting/drivers/RedisDriver.d.ts +112 -0
- package/dist/broadcasting/drivers/index.d.ts +2 -0
- package/dist/broadcasting/index.d.ts +6 -233
- package/dist/broadcasting/index.js +1 -1
- package/dist/broadcasting/typed.d.ts +23 -0
- package/dist/broadcasting/types.d.ts +155 -0
- package/dist/cache/CacheManager.d.ts +87 -0
- package/dist/cache/TaggedCache.d.ts +62 -0
- package/dist/cache/index.d.ts +6 -233
- package/dist/cache/index.js +1 -1
- package/dist/cache/stores/FileStore.d.ts +64 -0
- package/dist/cache/stores/MemoryStore.d.ts +52 -0
- package/dist/cache/stores/RedisStore.d.ts +53 -0
- package/dist/{CacheManager-BmDzUKrF.d.ts → cache/types.d.ts} +26 -99
- package/dist/{chunk-TVY72CLV.js → chunk-4VE3LYOM.js} +3 -2
- package/dist/{chunk-FZD2AKJI.js → chunk-7OB2YXRE.js} +56 -28
- package/dist/{chunk-HONCNQXZ.js → chunk-BUQXOZCT.js} +97 -10
- package/dist/{chunk-DSDX3ASM.js → chunk-CDZUNKI6.js} +65 -83
- package/dist/{chunk-CWI4AJ47.js → chunk-HPET6XY5.js} +13 -9
- package/dist/{chunk-A3ISJVEV.js → chunk-HR2KZ3WL.js} +23 -5
- package/dist/{chunk-EARA7JM4.js → chunk-PZKUDFMW.js} +11 -8
- package/dist/console/Command.d.ts +179 -0
- package/dist/{ConsoleKernel-CJg975mp.d.ts → console/ConsoleKernel.d.ts} +4 -6
- package/dist/console/Input.d.ts +140 -0
- package/dist/console/Output.d.ts +161 -0
- package/dist/console/index.d.ts +5 -0
- package/dist/console/types.d.ts +106 -0
- package/dist/container/Container.d.ts +148 -0
- package/dist/container/ServiceProvider.d.ts +103 -0
- package/dist/container/bindings.d.ts +55 -0
- package/dist/container/defineModule.d.ts +88 -0
- package/dist/container/definePlugin.d.ts +62 -0
- package/dist/container/index.d.ts +8 -0
- package/dist/container/types.d.ts +73 -0
- package/dist/database/Factory.d.ts +82 -0
- package/dist/database/Seeder.d.ts +35 -0
- package/dist/database/SeederRunner.d.ts +41 -0
- package/dist/database/index.d.ts +4 -0
- package/dist/database/types.d.ts +49 -0
- package/dist/discovery/AutoDiscovery.d.ts +113 -0
- package/dist/discovery/index.d.ts +2 -0
- package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +12 -0
- package/dist/docs-viewer/endpoint.d.ts +19 -0
- package/dist/encryption/Encrypter.d.ts +96 -0
- package/dist/encryption/Hash.d.ts +69 -0
- package/dist/encryption/MessageSigner.d.ts +21 -0
- package/dist/encryption/Random.d.ts +119 -0
- package/dist/encryption/app-key.d.ts +12 -0
- package/dist/encryption/index.d.ts +10 -222
- package/dist/encryption/signed-url.d.ts +9 -0
- package/dist/encryption/types.d.ts +103 -0
- package/dist/errors/ExceptionHandler.d.ts +118 -0
- package/dist/errors/HttpException.d.ts +106 -0
- package/dist/errors/debug-page.d.ts +22 -0
- package/dist/errors/error-page.d.ts +1 -0
- package/dist/errors/exceptions/AuthenticationException.d.ts +32 -0
- package/dist/errors/exceptions/AuthorizationException.d.ts +32 -0
- package/dist/errors/exceptions/MethodNotAllowedException.d.ts +31 -0
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +36 -0
- package/dist/errors/exceptions/ValidationException.d.ts +60 -0
- package/dist/errors/exceptions/index.d.ts +5 -0
- package/dist/errors/index.d.ts +5 -0
- package/dist/errors/types.d.ts +43 -0
- package/dist/events/Event.d.ts +33 -0
- package/dist/{EventManager-CmIoLt7r.d.ts → events/EventManager.d.ts} +4 -86
- package/dist/events/Listener.d.ts +79 -0
- package/dist/events/builtin.d.ts +73 -0
- package/dist/events/index.d.ts +6 -155
- package/dist/events/types.d.ts +48 -0
- package/dist/facades/index.d.ts +31 -0
- package/dist/health/HealthCheck.d.ts +34 -0
- package/dist/health/HealthManager.d.ts +53 -0
- package/dist/health/checks/CacheCheck.d.ts +35 -0
- package/dist/health/checks/CustomCheck.d.ts +23 -0
- package/dist/health/checks/DatabaseCheck.d.ts +33 -0
- package/dist/health/checks/MemoryCheck.d.ts +32 -0
- package/dist/health/checks/RedisCheck.d.ts +27 -0
- package/dist/health/checks/StorageCheck.d.ts +35 -0
- package/dist/health/checks/index.d.ts +12 -0
- package/dist/health/index.d.ts +5 -185
- package/dist/health/types.d.ts +52 -0
- package/dist/hot-reload/hot-disposables.d.ts +96 -0
- package/dist/hot-reload/testing.d.ts +14 -0
- package/dist/http/Application.d.ts +187 -0
- package/dist/http/FormRequest.d.ts +73 -0
- package/dist/http/dev-assets.d.ts +51 -0
- package/dist/http/dev-banner.d.ts +7 -0
- package/dist/http/inertia-assets.d.ts +22 -0
- package/dist/http/middleware/auth.d.ts +13 -0
- package/dist/http/middleware/capabilities.d.ts +22 -0
- package/dist/http/middleware/cors.d.ts +40 -0
- package/dist/http/middleware/csp.d.ts +59 -0
- package/dist/http/middleware/csrf.d.ts +121 -0
- package/dist/http/middleware/detect-locale.d.ts +65 -0
- package/dist/http/middleware/force-https.d.ts +34 -0
- package/dist/http/middleware/host-authorization.d.ts +24 -0
- package/dist/http/middleware/index.d.ts +19 -0
- package/dist/http/middleware/loopback-guard.d.ts +38 -0
- package/dist/{rate-limit-D9J2b4S1.d.ts → http/middleware/rate-limit.d.ts} +22 -50
- package/dist/http/middleware/redirect-safety.d.ts +29 -0
- package/dist/http/middleware/request-id.d.ts +19 -0
- package/dist/http/middleware/request-logging.d.ts +16 -0
- package/dist/http/middleware/security-headers.d.ts +49 -0
- package/dist/http/middleware/session.d.ts +93 -0
- package/dist/http/middleware/validation.d.ts +94 -0
- package/dist/http/public-assets.d.ts +15 -0
- package/dist/http/request.d.ts +24 -0
- package/dist/http/resources/CursorPaginator.d.ts +106 -0
- package/dist/http/resources/Paginator.d.ts +130 -0
- package/dist/http/resources/Resource.d.ts +67 -0
- package/dist/http/resources/ResourceCollection.d.ts +60 -0
- package/dist/http/resources/index.d.ts +6 -0
- package/dist/http/resources/types.d.ts +91 -0
- package/dist/http/validation/Validator.d.ts +128 -0
- package/dist/http/validation/index.d.ts +3 -0
- package/dist/http/validation/rules.d.ts +196 -0
- package/dist/http/validation/types.d.ts +96 -0
- package/dist/http/vite-dev-server.d.ts +27 -0
- package/dist/i18n/I18nManager.d.ts +114 -0
- package/dist/i18n/Translator.d.ts +80 -0
- package/dist/i18n/index.d.ts +6 -101
- package/dist/i18n/index.js +5 -3
- package/dist/i18n/loaders/JsonLoader.d.ts +47 -0
- package/dist/i18n/loaders/MemoryLoader.d.ts +37 -0
- package/dist/i18n/pluralization.d.ts +19 -0
- package/dist/i18n/types.d.ts +106 -0
- package/dist/index.d.ts +69 -2605
- package/dist/index.js +332 -152
- package/dist/lambda/index.d.ts +17 -37
- package/dist/logging/LogManager.d.ts +83 -0
- package/dist/logging/Logger.d.ts +76 -0
- package/dist/logging/channels/ConsoleChannel.d.ts +11 -0
- package/dist/logging/channels/DailyFileChannel.d.ts +20 -0
- package/dist/logging/channels/FileChannel.d.ts +15 -0
- package/dist/logging/index.d.ts +8 -50
- package/dist/logging/types.d.ts +96 -0
- package/dist/mail/Mail.d.ts +138 -0
- package/dist/mail/MailManager.d.ts +79 -0
- package/dist/mail/address.d.ts +8 -0
- package/dist/mail/index.d.ts +7 -316
- package/dist/mail/transports/LogTransport.d.ts +19 -0
- package/dist/mail/transports/MemoryTransport.d.ts +84 -0
- package/dist/mail/transports/ResendTransport.d.ts +32 -0
- package/dist/mail/transports/SmtpTransport.d.ts +40 -0
- package/dist/{MailManager-DpMvYiP9.d.ts → mail/types.d.ts} +11 -92
- package/dist/mcp/McpServiceProvider.d.ts +17 -0
- package/dist/mcp/create-mcp-server.d.ts +144 -0
- package/dist/mcp/endpoint.d.ts +29 -0
- package/dist/mcp/index.d.ts +3 -185
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +326 -0
- package/dist/mvc/Router.d.ts +239 -0
- package/dist/mvc/ViewEngine.d.ts +11 -0
- package/dist/mvc/inertia/InertiaEngine.d.ts +114 -0
- package/dist/mvc/inertia/shared.d.ts +90 -0
- package/dist/mvc/mount-route.d.ts +10 -0
- package/dist/notifications/Notification.d.ts +99 -0
- package/dist/notifications/NotificationManager.d.ts +150 -0
- package/dist/notifications/channels/DatabaseChannel.d.ts +55 -0
- package/dist/notifications/channels/MailChannel.d.ts +45 -0
- package/dist/notifications/channels/MemoryChannel.d.ts +85 -0
- package/dist/notifications/channels/SlackChannel.d.ts +73 -0
- package/dist/notifications/channels/index.d.ts +4 -0
- package/dist/notifications/index.d.ts +6 -322
- package/dist/notifications/notifiable-type.d.ts +10 -0
- package/dist/notifications/registry.d.ts +39 -0
- package/dist/notifications/types.d.ts +162 -0
- package/dist/providers/AuthServiceProvider.d.ts +7 -0
- package/dist/providers/AuthorizationServiceProvider.d.ts +9 -0
- package/dist/providers/BroadcastServiceProvider.d.ts +7 -0
- package/dist/providers/CacheServiceProvider.d.ts +7 -0
- package/dist/providers/EncryptionServiceProvider.d.ts +7 -0
- package/dist/providers/ErrorServiceProvider.d.ts +9 -0
- package/dist/providers/EventServiceProvider.d.ts +7 -0
- package/dist/providers/HealthServiceProvider.d.ts +7 -0
- package/dist/providers/I18nServiceProvider.d.ts +27 -0
- package/dist/providers/InertiaServiceProvider.d.ts +20 -0
- package/dist/providers/LogServiceProvider.d.ts +7 -0
- package/dist/providers/MailServiceProvider.d.ts +7 -0
- package/dist/providers/NotificationServiceProvider.d.ts +8 -0
- package/dist/providers/OAuthServiceProvider.d.ts +7 -0
- package/dist/providers/QueueServiceProvider.d.ts +7 -0
- package/dist/providers/SchedulingServiceProvider.d.ts +7 -0
- package/dist/providers/StorageServiceProvider.d.ts +7 -0
- package/dist/providers/index.d.ts +17 -0
- package/dist/queue/FailedJobReporter.d.ts +40 -0
- package/dist/queue/Job.d.ts +140 -0
- package/dist/queue/QueueManager.d.ts +79 -0
- package/dist/queue/Worker.d.ts +99 -0
- package/dist/queue/drivers/MemoryDriver.d.ts +60 -0
- package/dist/queue/drivers/RedisDriver.d.ts +96 -0
- package/dist/queue/drivers/SqsDriver.d.ts +108 -0
- package/dist/queue/drivers/SyncDriver.d.ts +28 -0
- package/dist/queue/index.d.ts +9 -453
- package/dist/queue/types.d.ts +171 -0
- package/dist/redis/RedisApiTokenStore.d.ts +78 -0
- package/dist/redis/RedisEmailVerificationStore.d.ts +54 -0
- package/dist/redis/RedisOAuthStateStore.d.ts +26 -0
- package/dist/redis/RedisPasswordResetStore.d.ts +57 -0
- package/dist/redis/RedisRateLimitStore.d.ts +77 -0
- package/dist/redis/RedisSessionStore.d.ts +61 -0
- package/dist/redis/client.d.ts +41 -0
- package/dist/redis/index.d.ts +14 -356
- package/dist/redis/index.js +5 -2
- package/dist/redis/scan-keys.d.ts +6 -0
- package/dist/runtime/index.d.ts +8 -95
- package/dist/runtime/index.js +1 -1
- package/dist/scheduling/CronParser.d.ts +37 -0
- package/dist/scheduling/Schedule.d.ts +229 -0
- package/dist/scheduling/ScheduledTask.d.ts +47 -0
- package/dist/scheduling/Scheduler.d.ts +99 -0
- package/dist/scheduling/index.d.ts +5 -41
- package/dist/scheduling/types.d.ts +97 -0
- package/dist/storage/StorageManager.d.ts +65 -0
- package/dist/storage/drivers/LocalDriver.d.ts +55 -0
- package/dist/storage/drivers/MemoryDriver.d.ts +66 -0
- package/dist/storage/drivers/S3Driver.d.ts +72 -0
- package/dist/storage/index.d.ts +5 -197
- package/dist/{StorageManager-oZTHqaza.d.ts → storage/types.d.ts} +10 -77
- package/dist/support/error-polyfill.d.ts +9 -0
- package/dist/support/import-map.d.ts +13 -0
- package/dist/support/redirect-target.d.ts +11 -0
- package/dist/support/stack-frames.d.ts +56 -0
- package/dist/support/trim-slashes.d.ts +11 -0
- package/dist/vite/index.d.ts +2 -35
- package/dist/vite/index.js +0 -3
- package/dist/vite/plugin.d.ts +34 -0
- package/package.json +3 -3
- package/dist/AuthManager-DBP4KYsx.d.ts +0 -79
- package/dist/BroadcastManager-D8KoJxiV.d.ts +0 -492
- package/dist/HealthManager-DUyMIzsZ.d.ts +0 -141
- package/dist/I18nManager-BiSoczfV.d.ts +0 -275
- package/dist/LogManager-7mxnkaPM.d.ts +0 -256
- package/dist/Scheduler-pZiT8i57.d.ts +0 -471
- package/dist/api-token-D24VPr_E.d.ts +0 -663
- package/dist/app-key-CsBfRC_Q.d.ts +0 -214
- package/dist/email-verification-D60YF2ZO.d.ts +0 -329
- package/dist/index-9_Jzj5jo.d.ts +0 -7
- package/dist/validation-yAL53e1S.d.ts +0 -2610
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialized job data stored in the queue.
|
|
3
|
+
*/
|
|
4
|
+
export interface QueuedJob<T = unknown> {
|
|
5
|
+
/**
|
|
6
|
+
* Unique job identifier.
|
|
7
|
+
*/
|
|
8
|
+
id: string;
|
|
9
|
+
/**
|
|
10
|
+
* Job class name.
|
|
11
|
+
*/
|
|
12
|
+
name: string;
|
|
13
|
+
/**
|
|
14
|
+
* Job payload data.
|
|
15
|
+
*/
|
|
16
|
+
payload: T;
|
|
17
|
+
/**
|
|
18
|
+
* Queue name this job belongs to.
|
|
19
|
+
*/
|
|
20
|
+
queue: string;
|
|
21
|
+
/**
|
|
22
|
+
* Number of times this job has been attempted.
|
|
23
|
+
*/
|
|
24
|
+
attempts: number;
|
|
25
|
+
/**
|
|
26
|
+
* Maximum number of attempts before failing permanently.
|
|
27
|
+
*/
|
|
28
|
+
maxAttempts: number;
|
|
29
|
+
/**
|
|
30
|
+
* When the job becomes available for processing.
|
|
31
|
+
*/
|
|
32
|
+
availableAt: Date;
|
|
33
|
+
/**
|
|
34
|
+
* When the job was created.
|
|
35
|
+
*/
|
|
36
|
+
createdAt: Date;
|
|
37
|
+
/**
|
|
38
|
+
* When the job was reserved by a worker (null if not reserved).
|
|
39
|
+
*/
|
|
40
|
+
reservedAt: Date | null;
|
|
41
|
+
/**
|
|
42
|
+
* Last error message if the job failed.
|
|
43
|
+
*/
|
|
44
|
+
lastError?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Failed job record.
|
|
48
|
+
*/
|
|
49
|
+
export interface FailedJob<T = unknown> extends QueuedJob<T> {
|
|
50
|
+
/**
|
|
51
|
+
* When the job failed.
|
|
52
|
+
*/
|
|
53
|
+
failedAt: Date;
|
|
54
|
+
/**
|
|
55
|
+
* Error that caused the failure.
|
|
56
|
+
*/
|
|
57
|
+
error: string;
|
|
58
|
+
/**
|
|
59
|
+
* Stack trace of the error.
|
|
60
|
+
*/
|
|
61
|
+
stack?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Queue driver interface.
|
|
65
|
+
* Implement this to create a custom queue backend.
|
|
66
|
+
*/
|
|
67
|
+
export interface QueueDriver {
|
|
68
|
+
/**
|
|
69
|
+
* Push a job onto the queue.
|
|
70
|
+
*/
|
|
71
|
+
push(job: QueuedJob): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Pop the next available job from the queue.
|
|
74
|
+
* Returns null if no jobs are available.
|
|
75
|
+
*/
|
|
76
|
+
pop(queue: string): Promise<QueuedJob | null>;
|
|
77
|
+
/**
|
|
78
|
+
* Release a job back onto the queue (for retry).
|
|
79
|
+
* @param job - The job to release
|
|
80
|
+
* @param delayMs - Delay before the job becomes available again
|
|
81
|
+
*/
|
|
82
|
+
release(job: QueuedJob, delayMs?: number): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Delete a job from the queue.
|
|
85
|
+
*/
|
|
86
|
+
delete(jobId: string): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Mark a job as failed and move to failed jobs.
|
|
89
|
+
*/
|
|
90
|
+
fail(job: QueuedJob, error: Error): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Get the number of jobs in a queue.
|
|
93
|
+
*/
|
|
94
|
+
size(queue: string): Promise<number>;
|
|
95
|
+
/**
|
|
96
|
+
* Get failed jobs.
|
|
97
|
+
*/
|
|
98
|
+
getFailedJobs(queue?: string): Promise<FailedJob[]>;
|
|
99
|
+
/**
|
|
100
|
+
* Retry a failed job.
|
|
101
|
+
*/
|
|
102
|
+
retryFailedJob(jobId: string): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Delete a failed job.
|
|
105
|
+
*/
|
|
106
|
+
deleteFailedJob(jobId: string): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Clear all jobs (for testing).
|
|
109
|
+
*/
|
|
110
|
+
clear(): Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Options for creating a job.
|
|
114
|
+
*/
|
|
115
|
+
export interface JobOptions {
|
|
116
|
+
/**
|
|
117
|
+
* Queue to dispatch the job to.
|
|
118
|
+
* @default 'default'
|
|
119
|
+
*/
|
|
120
|
+
queue?: string;
|
|
121
|
+
/**
|
|
122
|
+
* Delay in milliseconds before the job is available.
|
|
123
|
+
* @default 0
|
|
124
|
+
*/
|
|
125
|
+
delay?: number;
|
|
126
|
+
/**
|
|
127
|
+
* Maximum number of attempts.
|
|
128
|
+
* @default 3
|
|
129
|
+
*/
|
|
130
|
+
maxAttempts?: number;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Worker options.
|
|
134
|
+
*/
|
|
135
|
+
export interface WorkerOptions {
|
|
136
|
+
/**
|
|
137
|
+
* Queues to process (in priority order).
|
|
138
|
+
* @default ['default']
|
|
139
|
+
*/
|
|
140
|
+
queues?: string[];
|
|
141
|
+
/**
|
|
142
|
+
* Sleep time in milliseconds when no jobs are available.
|
|
143
|
+
* @default 1000
|
|
144
|
+
*/
|
|
145
|
+
sleep?: number;
|
|
146
|
+
/**
|
|
147
|
+
* Maximum number of jobs to process before stopping.
|
|
148
|
+
* Set to 0 for unlimited.
|
|
149
|
+
* @default 0
|
|
150
|
+
*/
|
|
151
|
+
maxJobs?: number;
|
|
152
|
+
/**
|
|
153
|
+
* Timeout for each job in milliseconds.
|
|
154
|
+
* @default 60000
|
|
155
|
+
*/
|
|
156
|
+
timeout?: number;
|
|
157
|
+
/**
|
|
158
|
+
* Stop the worker when no jobs are available.
|
|
159
|
+
* Useful for one-shot processing or testing.
|
|
160
|
+
* @default false
|
|
161
|
+
*/
|
|
162
|
+
stopWhenEmpty?: boolean;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Job handler function type.
|
|
166
|
+
*/
|
|
167
|
+
export type JobHandler<T = unknown> = (payload: T) => void | Promise<void>;
|
|
168
|
+
/**
|
|
169
|
+
* Job failure handler function type.
|
|
170
|
+
*/
|
|
171
|
+
export type JobFailureHandler<T = unknown> = (payload: T, error: Error) => void | Promise<void>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Redis } from 'ioredis';
|
|
2
|
+
import type { ApiToken, ApiTokenStore } from '../auth/api-token.js';
|
|
3
|
+
/**
|
|
4
|
+
* Options for RedisApiTokenStore.
|
|
5
|
+
*/
|
|
6
|
+
export interface RedisApiTokenStoreOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Key prefix for token keys.
|
|
9
|
+
* @default 'apitoken:'
|
|
10
|
+
*/
|
|
11
|
+
prefix?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Redis-backed API token store.
|
|
15
|
+
*
|
|
16
|
+
* Uses the following key structure:
|
|
17
|
+
* - `apitoken:{id}` - Token data (hash)
|
|
18
|
+
* - `apitoken:hash:{hashedToken}` - Maps hash to token ID
|
|
19
|
+
* - `apitoken:user:{userId}` - Set of token IDs for a user
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { createRedisClient } from '@guren/server/redis'
|
|
24
|
+
*
|
|
25
|
+
* const redis = createRedisClient({ url: process.env.REDIS_URL })
|
|
26
|
+
* const store = new RedisApiTokenStore(redis)
|
|
27
|
+
*
|
|
28
|
+
* const { plainTextToken } = await createApiToken(store, {
|
|
29
|
+
* name: 'API Token',
|
|
30
|
+
* userId: user.id,
|
|
31
|
+
* })
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare class RedisApiTokenStore implements ApiTokenStore {
|
|
35
|
+
private readonly redis;
|
|
36
|
+
private readonly prefix;
|
|
37
|
+
constructor(redis: Redis, options?: RedisApiTokenStoreOptions);
|
|
38
|
+
/**
|
|
39
|
+
* Store a new API token.
|
|
40
|
+
*/
|
|
41
|
+
store(token: ApiToken): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Find a token by its hashed value.
|
|
44
|
+
*/
|
|
45
|
+
findByHashedToken(hashedToken: string): Promise<ApiToken | null>;
|
|
46
|
+
/**
|
|
47
|
+
* Find all tokens for a user.
|
|
48
|
+
*/
|
|
49
|
+
findByUserId(userId: string | number): Promise<ApiToken[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Delete a token by its ID.
|
|
52
|
+
*/
|
|
53
|
+
delete(id: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Delete all tokens for a user.
|
|
56
|
+
*/
|
|
57
|
+
deleteForUser(userId: string | number): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Update the last used timestamp.
|
|
60
|
+
*/
|
|
61
|
+
updateLastUsed(id: string, timestamp: Date): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Find a token by its ID.
|
|
64
|
+
*/
|
|
65
|
+
private findById;
|
|
66
|
+
/**
|
|
67
|
+
* Serialize a token for Redis storage.
|
|
68
|
+
*/
|
|
69
|
+
private serializeToken;
|
|
70
|
+
/**
|
|
71
|
+
* Deserialize a token from Redis storage.
|
|
72
|
+
*/
|
|
73
|
+
private deserializeToken;
|
|
74
|
+
/**
|
|
75
|
+
* Clear all tokens (for testing).
|
|
76
|
+
*/
|
|
77
|
+
clear(): Promise<void>;
|
|
78
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Redis } from 'ioredis';
|
|
2
|
+
import type { EmailVerificationTokenStore, EmailVerificationToken } from '../auth/email-verification.js';
|
|
3
|
+
/**
|
|
4
|
+
* Options for RedisEmailVerificationStore.
|
|
5
|
+
*/
|
|
6
|
+
export interface RedisEmailVerificationStoreOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Key prefix for email verification keys.
|
|
9
|
+
* @default 'emailverify:'
|
|
10
|
+
*/
|
|
11
|
+
prefix?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Redis-backed email verification token store.
|
|
15
|
+
*
|
|
16
|
+
* Uses the following key structure:
|
|
17
|
+
* - `emailverify:{tokenId}` - Token data (JSON)
|
|
18
|
+
* - `emailverify:email:{email}` - Set of token IDs for an email
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { createRedisClient } from '@guren/server/redis'
|
|
23
|
+
*
|
|
24
|
+
* const redis = createRedisClient({ url: process.env.REDIS_URL })
|
|
25
|
+
* const store = new RedisEmailVerificationStore(redis)
|
|
26
|
+
*
|
|
27
|
+
* const { token } = await createEmailVerificationToken(email, store, { expiresIn: 86400000 })
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class RedisEmailVerificationStore implements EmailVerificationTokenStore {
|
|
31
|
+
private readonly redis;
|
|
32
|
+
private readonly prefix;
|
|
33
|
+
constructor(redis: Redis, options?: RedisEmailVerificationStoreOptions);
|
|
34
|
+
/**
|
|
35
|
+
* Store an email verification token.
|
|
36
|
+
*/
|
|
37
|
+
store(token: EmailVerificationToken): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Find a token by its hash.
|
|
40
|
+
*/
|
|
41
|
+
findByTokenId(tokenId: string): Promise<EmailVerificationToken | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Delete a token by its hash.
|
|
44
|
+
*/
|
|
45
|
+
delete(tokenId: string): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Delete all tokens for an email.
|
|
48
|
+
*/
|
|
49
|
+
deleteForEmail(email: string): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Clear all tokens (for testing).
|
|
52
|
+
*/
|
|
53
|
+
clear(): Promise<void>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Redis } from 'ioredis';
|
|
2
|
+
import type { OAuthStatePayload, OAuthStateStore } from '../auth/oauth/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Options for RedisOAuthStateStore.
|
|
5
|
+
*/
|
|
6
|
+
export interface RedisOAuthStateStoreOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Key prefix for OAuth state keys.
|
|
9
|
+
* @default 'oauthstate:'
|
|
10
|
+
*/
|
|
11
|
+
prefix?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class RedisOAuthStateStore implements OAuthStateStore {
|
|
14
|
+
private readonly redis;
|
|
15
|
+
private readonly prefix;
|
|
16
|
+
constructor(redis: Redis, options?: RedisOAuthStateStoreOptions);
|
|
17
|
+
store(stateHash: string, payload: OAuthStatePayload): Promise<void>;
|
|
18
|
+
find(stateHash: string): Promise<OAuthStatePayload | null>;
|
|
19
|
+
consume(stateHash: string): Promise<OAuthStatePayload | null>;
|
|
20
|
+
private parsePayload;
|
|
21
|
+
delete(stateHash: string): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Clear all states (for testing).
|
|
24
|
+
*/
|
|
25
|
+
clear(): Promise<void>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Redis } from 'ioredis';
|
|
2
|
+
import type { PasswordResetTokenStore } from '../auth/password-reset.js';
|
|
3
|
+
/**
|
|
4
|
+
* Options for RedisPasswordResetStore.
|
|
5
|
+
*/
|
|
6
|
+
export interface RedisPasswordResetStoreOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Key prefix for password reset keys.
|
|
9
|
+
* @default 'pwreset:'
|
|
10
|
+
*/
|
|
11
|
+
prefix?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Redis-backed password reset token store.
|
|
15
|
+
*
|
|
16
|
+
* Uses the following key structure:
|
|
17
|
+
* - `pwreset:{tokenId}` - Token data (JSON with email and expiresAt)
|
|
18
|
+
* - `pwreset:email:{email}` - Set of token IDs for an email
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { createRedisClient } from '@guren/server/redis'
|
|
23
|
+
*
|
|
24
|
+
* const redis = createRedisClient({ url: process.env.REDIS_URL })
|
|
25
|
+
* const store = new RedisPasswordResetStore(redis)
|
|
26
|
+
*
|
|
27
|
+
* const { token } = await createPasswordResetToken(email, store, { expiresIn: 3600000 })
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class RedisPasswordResetStore implements PasswordResetTokenStore {
|
|
31
|
+
private readonly redis;
|
|
32
|
+
private readonly prefix;
|
|
33
|
+
constructor(redis: Redis, options?: RedisPasswordResetStoreOptions);
|
|
34
|
+
/**
|
|
35
|
+
* Store a password reset token.
|
|
36
|
+
*/
|
|
37
|
+
store(tokenId: string, email: string, expiresAt: Date): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Find a token by its hash.
|
|
40
|
+
*/
|
|
41
|
+
find(tokenId: string): Promise<{
|
|
42
|
+
email: string;
|
|
43
|
+
expiresAt: Date;
|
|
44
|
+
} | null>;
|
|
45
|
+
/**
|
|
46
|
+
* Delete a token by its hash.
|
|
47
|
+
*/
|
|
48
|
+
delete(tokenId: string): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Delete all tokens for an email.
|
|
51
|
+
*/
|
|
52
|
+
deleteForEmail(email: string): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Clear all tokens (for testing).
|
|
55
|
+
*/
|
|
56
|
+
clear(): Promise<void>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Redis } from 'ioredis';
|
|
2
|
+
import type { RateLimitStore, RateLimitEntry } from '../http/middleware/rate-limit.js';
|
|
3
|
+
/**
|
|
4
|
+
* Options for RedisRateLimitStore.
|
|
5
|
+
*/
|
|
6
|
+
export interface RedisRateLimitStoreOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Key prefix for rate limit keys.
|
|
9
|
+
* @default 'ratelimit:'
|
|
10
|
+
*/
|
|
11
|
+
prefix?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Redis-backed rate limit store using fixed window algorithm.
|
|
15
|
+
* Uses Lua script for atomic increment operations.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { createRedisClient } from '@guren/server/redis'
|
|
20
|
+
*
|
|
21
|
+
* const redis = createRedisClient({ url: process.env.REDIS_URL })
|
|
22
|
+
* const store = new RedisRateLimitStore(redis)
|
|
23
|
+
*
|
|
24
|
+
* app.use(createRateLimitMiddleware({ store, limit: 100 }))
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare class RedisRateLimitStore implements RateLimitStore {
|
|
28
|
+
private readonly redis;
|
|
29
|
+
private readonly prefix;
|
|
30
|
+
constructor(redis: Redis, options?: RedisRateLimitStoreOptions);
|
|
31
|
+
/**
|
|
32
|
+
* Get current rate limit entry for a key.
|
|
33
|
+
*/
|
|
34
|
+
get(key: string): Promise<RateLimitEntry | null>;
|
|
35
|
+
/**
|
|
36
|
+
* Increment the rate limit counter atomically.
|
|
37
|
+
*/
|
|
38
|
+
increment(key: string, windowMs: number): Promise<RateLimitEntry>;
|
|
39
|
+
/**
|
|
40
|
+
* Reset the rate limit for a key.
|
|
41
|
+
*/
|
|
42
|
+
reset(key: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Get all rate limit keys (for debugging/admin purposes).
|
|
45
|
+
*/
|
|
46
|
+
keys(): Promise<string[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Clear all rate limits.
|
|
49
|
+
*/
|
|
50
|
+
clear(): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Redis-backed rate limit store using sliding window algorithm.
|
|
54
|
+
* More accurate than fixed window but slightly more expensive.
|
|
55
|
+
*/
|
|
56
|
+
export declare class RedisSlidingWindowRateLimitStore implements RateLimitStore {
|
|
57
|
+
private readonly redis;
|
|
58
|
+
private readonly prefix;
|
|
59
|
+
constructor(redis: Redis, options?: RedisRateLimitStoreOptions);
|
|
60
|
+
/**
|
|
61
|
+
* Get current rate limit entry for a key.
|
|
62
|
+
*/
|
|
63
|
+
get(key: string): Promise<RateLimitEntry | null>;
|
|
64
|
+
/**
|
|
65
|
+
* Increment the rate limit counter using sorted set.
|
|
66
|
+
* Each request is stored with its timestamp as score.
|
|
67
|
+
*/
|
|
68
|
+
increment(key: string, windowMs: number): Promise<RateLimitEntry>;
|
|
69
|
+
/**
|
|
70
|
+
* Reset the rate limit for a key.
|
|
71
|
+
*/
|
|
72
|
+
reset(key: string): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Clear all rate limits.
|
|
75
|
+
*/
|
|
76
|
+
clear(): Promise<void>;
|
|
77
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Redis } from 'ioredis';
|
|
2
|
+
import type { SessionStore, SessionData } from '../http/middleware/session.js';
|
|
3
|
+
/**
|
|
4
|
+
* Options for RedisSessionStore.
|
|
5
|
+
*/
|
|
6
|
+
export interface RedisSessionStoreOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Key prefix for session keys.
|
|
9
|
+
* @default 'session:'
|
|
10
|
+
*/
|
|
11
|
+
prefix?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Redis-backed session store.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { createRedisClient } from '@guren/server/redis'
|
|
19
|
+
*
|
|
20
|
+
* const redis = createRedisClient({ url: process.env.REDIS_URL })
|
|
21
|
+
* const store = new RedisSessionStore(redis)
|
|
22
|
+
*
|
|
23
|
+
* app.use(createSessionMiddleware({ store }))
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare class RedisSessionStore implements SessionStore {
|
|
27
|
+
private readonly redis;
|
|
28
|
+
private readonly prefix;
|
|
29
|
+
constructor(redis: Redis, options?: RedisSessionStoreOptions);
|
|
30
|
+
/**
|
|
31
|
+
* Read session data from Redis.
|
|
32
|
+
*/
|
|
33
|
+
read(id: string): Promise<SessionData | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Write session data to Redis with TTL.
|
|
36
|
+
*/
|
|
37
|
+
write(id: string, data: SessionData, ttlSeconds: number): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Delete a session from Redis.
|
|
40
|
+
*/
|
|
41
|
+
destroy(id: string): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Refresh an existing session's TTL without rewriting its data.
|
|
44
|
+
* EXPIRE on a missing key is a no-op, never a resurrection.
|
|
45
|
+
*/
|
|
46
|
+
touch(id: string, ttlSeconds: number): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Get all session keys (for debugging/admin purposes).
|
|
49
|
+
* Note: This uses SCAN to avoid blocking Redis.
|
|
50
|
+
*/
|
|
51
|
+
keys(): Promise<string[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Get the count of sessions (for monitoring).
|
|
54
|
+
*/
|
|
55
|
+
size(): Promise<number>;
|
|
56
|
+
/**
|
|
57
|
+
* Clear all sessions.
|
|
58
|
+
* Use with caution in production!
|
|
59
|
+
*/
|
|
60
|
+
clear(): Promise<void>;
|
|
61
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Redis from 'ioredis';
|
|
2
|
+
import type { RedisOptions } from 'ioredis';
|
|
3
|
+
/**
|
|
4
|
+
* Options for creating a Redis client.
|
|
5
|
+
*/
|
|
6
|
+
export interface RedisClientOptions extends RedisOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Redis connection URL (e.g., 'redis://localhost:6379').
|
|
9
|
+
* If provided, overrides host/port/password.
|
|
10
|
+
*/
|
|
11
|
+
url?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Key prefix for all operations.
|
|
14
|
+
* @default ''
|
|
15
|
+
*/
|
|
16
|
+
keyPrefix?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create a Redis client with the given options.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* // Using URL
|
|
24
|
+
* const redis = createRedisClient({ url: 'redis://localhost:6379' })
|
|
25
|
+
*
|
|
26
|
+
* // Using host/port
|
|
27
|
+
* const redis = createRedisClient({ host: 'localhost', port: 6379 })
|
|
28
|
+
*
|
|
29
|
+
* // With key prefix
|
|
30
|
+
* const redis = createRedisClient({
|
|
31
|
+
* url: process.env.REDIS_URL,
|
|
32
|
+
* keyPrefix: 'myapp:',
|
|
33
|
+
* })
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function createRedisClient(options?: RedisClientOptions): Redis;
|
|
37
|
+
/**
|
|
38
|
+
* Re-export Redis class for type usage.
|
|
39
|
+
*/
|
|
40
|
+
export { Redis };
|
|
41
|
+
export type { RedisOptions };
|