@guren/server 2.15.0 → 2.16.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/{DocsViewerServiceProvider-qFCaeiUv.js → DocsViewerServiceProvider-D2cuVgtN.js} +7 -12
- package/dist/{Hash-C8aejmi8.js → Hash-D2DFd8xX.js} +7 -57
- package/dist/{HttpException-BkS3euNG.js → HttpException-BlQ2yEmT.js} +2 -79
- package/dist/{Job-BVT813DO.js → Job-DxQK8h3P.js} +24 -179
- package/dist/{McpServiceProvider-BawsYjgN.js → McpServiceProvider-nNcbCIQX.js} +11 -20
- package/dist/{Random-DbIJ22KQ.js → Random-S0OvCuR8.js} +9 -106
- package/dist/agent/AgentApprovalRequested.d.ts +11 -39
- package/dist/agent/approval.d.ts +76 -187
- package/dist/agent/audit-emitter.d.ts +16 -44
- package/dist/agent/audit.d.ts +20 -56
- package/dist/agent/derive.d.ts +32 -66
- package/dist/agent/dispatch.d.ts +38 -90
- package/dist/agent/events.d.ts +11 -19
- package/dist/agent/meta-tools.d.ts +18 -46
- package/dist/agent/public.d.ts +6 -25
- package/dist/agent/public.js +1 -1
- package/dist/agent/redact.d.ts +16 -38
- package/dist/agent/scopes.d.ts +23 -69
- package/dist/auth/AuthManager.d.ts +19 -40
- package/dist/auth/AuthenticatableModel.d.ts +2 -2
- package/dist/auth/SessionGuard.d.ts +0 -1
- package/dist/auth/TokenGuard.d.ts +6 -26
- package/dist/auth/api-token.d.ts +16 -148
- package/dist/auth/context.d.ts +5 -10
- package/dist/auth/email-verification.d.ts +29 -127
- package/dist/auth/index.js +1 -1
- package/dist/auth/oauth/index.d.ts +35 -57
- package/dist/auth/password/DefaultHasher.d.ts +5 -14
- package/dist/auth/password/PasswordHasher.d.ts +5 -13
- package/dist/auth/password/hash-format.d.ts +5 -13
- package/dist/auth/password-reset.d.ts +16 -42
- package/dist/auth/providers/ModelUserProvider.d.ts +3 -4
- package/dist/auth/providers/UserProvider.d.ts +4 -4
- package/dist/auth/signed-token.d.ts +18 -0
- package/dist/auth/types.d.ts +9 -32
- package/dist/auth/utils.d.ts +6 -27
- package/dist/{auth-DkYoAPVn.js → auth-CbdPH4Cd.js} +169 -502
- package/dist/authorization/Gate.d.ts +9 -145
- package/dist/authorization/Policy.d.ts +6 -53
- package/dist/authorization/index.js +1 -1
- package/dist/authorization/middleware.d.ts +16 -62
- package/dist/authorization/types.d.ts +8 -64
- package/dist/{authorization-CdfbCj8J.js → authorization-CdEWZZw3.js} +44 -309
- package/dist/broadcasting/BroadcastManager.d.ts +29 -149
- package/dist/broadcasting/channels/Channel.d.ts +1 -19
- package/dist/broadcasting/channels/PresenceChannel.d.ts +1 -55
- package/dist/broadcasting/channels/PrivateChannel.d.ts +1 -23
- package/dist/broadcasting/drivers/MemoryDriver.d.ts +18 -70
- package/dist/broadcasting/drivers/RedisDriver.d.ts +3 -80
- package/dist/broadcasting/drivers/index.d.ts +1 -1
- package/dist/broadcasting/index.d.ts +1 -1
- package/dist/broadcasting/index.js +1 -1
- package/dist/broadcasting/types.d.ts +7 -88
- package/dist/{broadcasting-BwodCA4q.js → broadcasting-B5RzB0A2.js} +87 -414
- package/dist/cache/CacheManager.d.ts +8 -62
- package/dist/cache/TaggedCache.d.ts +2 -35
- package/dist/cache/index.js +1 -1
- package/dist/cache/stores/FileStore.d.ts +2 -36
- package/dist/cache/stores/MemoryStore.d.ts +2 -26
- package/dist/cache/stores/RedisStore.d.ts +1 -29
- package/dist/cache/types.d.ts +21 -128
- package/dist/{cache-BYnZf2FR.js → cache-BOOIr324.js} +19 -198
- package/dist/client-C4TEr_Dd.js +9 -0
- package/dist/console/Command.d.ts +17 -126
- package/dist/console/ConsoleKernel.d.ts +2 -74
- package/dist/console/Input.d.ts +5 -113
- package/dist/console/Output.d.ts +3 -99
- package/dist/console/types.d.ts +3 -33
- package/dist/container/Container.d.ts +12 -103
- package/dist/container/ServiceProvider.d.ts +17 -61
- package/dist/container/bindings.d.ts +5 -26
- package/dist/container/defineModule.d.ts +16 -54
- package/dist/container/definePlugin.d.ts +12 -45
- package/dist/container/types.d.ts +2 -34
- package/dist/context-CXk_umpT.js +21 -0
- package/dist/database/Factory.d.ts +4 -57
- package/dist/database/Seeder.d.ts +8 -46
- package/dist/database/SeederRunner.d.ts +3 -33
- package/dist/database/types.d.ts +3 -24
- package/dist/discovery/AutoDiscovery.d.ts +10 -82
- package/dist/{dispatch-erOS9epZ.js → dispatch-BAwzftws.js} +32 -79
- package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +2 -5
- package/dist/docs-viewer/endpoint.d.ts +5 -11
- package/dist/encryption/Encrypter.d.ts +5 -71
- package/dist/encryption/Hash.d.ts +7 -57
- package/dist/encryption/Random.d.ts +6 -99
- package/dist/encryption/index.js +3 -3
- package/dist/encryption/types.d.ts +10 -72
- package/dist/{encryption-D99Vmls3.js → encryption-uwP3Di4D.js} +9 -78
- package/dist/{endpoint-D6GIqOpe.js → endpoint-BXipU2Jj.js} +6 -12
- package/dist/endpoint-Dsw3Acvq.js +26 -0
- package/dist/errors/ExceptionHandler.d.ts +3 -90
- package/dist/errors/HttpException.d.ts +2 -79
- package/dist/errors/debug-page.d.ts +3 -17
- package/dist/errors/error-page.d.ts +1 -0
- package/dist/errors/exceptions/AuthenticationException.d.ts +2 -24
- package/dist/errors/exceptions/AuthorizationException.d.ts +1 -24
- package/dist/errors/exceptions/MethodNotAllowedException.d.ts +1 -23
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +1 -27
- package/dist/errors/exceptions/ValidationException.d.ts +2 -43
- package/dist/errors/types.d.ts +1 -25
- package/dist/{errors-BgeOl_DC.js → errors-JpkcCjjn.js} +3 -41
- package/dist/events/Event.d.ts +1 -28
- package/dist/events/EventManager.d.ts +5 -107
- package/dist/events/Listener.d.ts +7 -55
- package/dist/events/builtin.d.ts +0 -24
- package/dist/events/index.js +1 -1
- package/dist/events/types.d.ts +4 -22
- package/dist/{events-aIH_bWRx.js → events-DOmAHDeP.js} +11 -191
- package/dist/facades/index.d.ts +2 -14
- package/dist/health/HealthCheck.d.ts +0 -24
- package/dist/health/HealthManager.d.ts +0 -36
- package/dist/health/checks/CacheCheck.d.ts +2 -17
- package/dist/health/checks/CustomCheck.d.ts +0 -9
- package/dist/health/checks/DatabaseCheck.d.ts +2 -17
- package/dist/health/checks/MemoryCheck.d.ts +3 -12
- package/dist/health/checks/RedisCheck.d.ts +1 -13
- package/dist/health/checks/StorageCheck.d.ts +2 -17
- package/dist/health/index.js +1 -1
- package/dist/health/types.d.ts +4 -24
- package/dist/{health-VWdWXRwh.js → health-DQSvUplL.js} +1 -76
- package/dist/hot-disposables-B5BXqaIH.js +167 -0
- package/dist/hot-reload/hot-disposables.d.ts +22 -74
- package/dist/hot-reload/testing.d.ts +4 -9
- package/dist/http/Application.d.ts +62 -208
- package/dist/http/FormRequest.d.ts +4 -55
- package/dist/http/dev-assets.d.ts +13 -31
- package/dist/http/dev-banner.d.ts +2 -5
- package/dist/http/inertia-assets.d.ts +3 -6
- package/dist/http/middleware/capabilities.d.ts +27 -50
- package/dist/http/middleware/cors.d.ts +4 -29
- package/dist/http/middleware/csp.d.ts +2 -25
- package/dist/http/middleware/csrf.d.ts +20 -95
- package/dist/http/middleware/detect-locale.d.ts +7 -27
- package/dist/http/middleware/force-https.d.ts +6 -24
- package/dist/http/middleware/host-authorization.d.ts +2 -12
- package/dist/http/middleware/loopback-guard.d.ts +15 -33
- package/dist/http/middleware/rate-limit.d.ts +29 -126
- package/dist/http/middleware/redirect-safety.d.ts +2 -20
- package/dist/http/middleware/request-id.d.ts +1 -14
- package/dist/http/middleware/request-logging.d.ts +2 -13
- package/dist/http/middleware/response-headers.d.ts +5 -13
- package/dist/http/middleware/security-headers.d.ts +2 -16
- package/dist/http/middleware/session.d.ts +15 -34
- package/dist/http/middleware/validation-errors-cookie.d.ts +7 -18
- package/dist/http/middleware/validation.d.ts +8 -63
- package/dist/http/public-assets.d.ts +11 -7
- package/dist/http/request.d.ts +32 -118
- package/dist/http/resources/CursorPaginator.d.ts +5 -64
- package/dist/http/resources/Paginator.d.ts +7 -84
- package/dist/http/resources/Resource.d.ts +9 -65
- package/dist/http/resources/ResourceCollection.d.ts +5 -39
- package/dist/http/resources/types.d.ts +10 -30
- package/dist/http/static-documents.d.ts +10 -20
- package/dist/http/validation/Validator.d.ts +25 -85
- package/dist/http/validation/rules.d.ts +48 -147
- package/dist/http/validation/types.d.ts +16 -61
- package/dist/http/vite-assets.d.ts +5 -28
- package/dist/http/vite-dev-server.d.ts +6 -9
- package/dist/http/vite-manifest.d.ts +19 -33
- package/dist/i18n/I18nManager.d.ts +12 -78
- package/dist/i18n/Translator.d.ts +3 -54
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/loaders/JsonLoader.d.ts +4 -31
- package/dist/i18n/loaders/MemoryLoader.d.ts +1 -21
- package/dist/i18n/pluralization.d.ts +4 -13
- package/dist/i18n/types.d.ts +17 -69
- package/dist/{i18n-mcWi7LCd.js → i18n-Cg1aajRP.js} +31 -225
- package/dist/index.d.ts +2 -1
- package/dist/index.js +714 -3011
- package/dist/internal/agent-preflight.d.ts +9 -21
- package/dist/internal/request.d.ts +6 -19
- package/dist/internal/request.js +1 -1
- package/dist/internal/route-path.d.ts +9 -21
- package/dist/internal/route-path.js +9 -21
- package/dist/internal/zod-compat.d.ts +55 -122
- package/dist/internal/zod-compat.js +39 -70
- package/dist/internal/zod-json-schema.d.ts +18 -54
- package/dist/internal/zod-json-schema.js +46 -123
- package/dist/jsx-runtime.d.ts +3 -8
- package/dist/lambda/index.d.ts +17 -79
- package/dist/lambda/index.js +11 -59
- package/dist/logging/LogManager.d.ts +1 -51
- package/dist/logging/Logger.d.ts +8 -47
- package/dist/logging/channels/ConsoleChannel.d.ts +1 -3
- package/dist/logging/channels/DailyFileChannel.d.ts +1 -3
- package/dist/logging/channels/FileChannel.d.ts +1 -3
- package/dist/logging/daily-file-path.d.ts +7 -16
- package/dist/logging/index.js +1 -1
- package/dist/logging/types.d.ts +13 -45
- package/dist/{logging-B-kngi3q.js → logging-zOY1XCtq.js} +52 -141
- package/dist/{loopback-guard-D0Kc7-xc.js → loopback-guard-DT9gHF0F.js} +41 -92
- package/dist/mail/Mail.d.ts +10 -106
- package/dist/mail/MailManager.d.ts +2 -60
- package/dist/mail/index.js +1 -1
- package/dist/mail/transports/LogTransport.d.ts +1 -4
- package/dist/mail/transports/MemoryTransport.d.ts +1 -63
- package/dist/mail/transports/ResendTransport.d.ts +1 -23
- package/dist/mail/transports/SmtpTransport.d.ts +1 -31
- package/dist/mail/types.d.ts +28 -150
- package/dist/{mail-DfEfSQEr.js → mail-76DWy9lj.js} +31 -289
- package/dist/mcp/McpServiceProvider.d.ts +4 -10
- package/dist/mcp/create-mcp-server.d.ts +25 -57
- package/dist/mcp/endpoint.d.ts +12 -36
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +46 -227
- package/dist/mvc/Router.d.ts +50 -129
- package/dist/mvc/inertia/InertiaEngine.d.ts +18 -48
- package/dist/mvc/inertia/shared.d.ts +6 -19
- package/dist/mvc/mount-route.d.ts +2 -6
- package/dist/mvc/view.d.ts +1 -2
- package/dist/notifications/Notification.d.ts +8 -75
- package/dist/notifications/NotificationManager.d.ts +15 -88
- package/dist/notifications/channels/DatabaseChannel.d.ts +1 -41
- package/dist/notifications/channels/MailChannel.d.ts +2 -31
- package/dist/notifications/channels/MemoryChannel.d.ts +2 -62
- package/dist/notifications/channels/SlackChannel.d.ts +3 -48
- package/dist/notifications/index.js +1 -1
- package/dist/notifications/notifiable-type.d.ts +3 -6
- package/dist/notifications/registry.d.ts +8 -27
- package/dist/notifications/types.d.ts +16 -53
- package/dist/{notifications-BGqmUNZ8.js → notifications-okWFs9ly.js} +37 -335
- package/dist/providers/AuthServiceProvider.d.ts +1 -3
- package/dist/providers/AuthorizationServiceProvider.d.ts +2 -3
- package/dist/providers/BroadcastServiceProvider.d.ts +1 -3
- package/dist/providers/CacheServiceProvider.d.ts +1 -3
- package/dist/providers/EncryptionServiceProvider.d.ts +1 -3
- package/dist/providers/ErrorServiceProvider.d.ts +1 -4
- package/dist/providers/EventServiceProvider.d.ts +1 -3
- package/dist/providers/HealthServiceProvider.d.ts +1 -3
- package/dist/providers/I18nServiceProvider.d.ts +6 -10
- package/dist/providers/InertiaServiceProvider.d.ts +1 -4
- package/dist/providers/LogServiceProvider.d.ts +1 -3
- package/dist/providers/MailServiceProvider.d.ts +1 -3
- package/dist/providers/NotificationServiceProvider.d.ts +1 -3
- package/dist/providers/OAuthServiceProvider.d.ts +1 -3
- package/dist/providers/QueueServiceProvider.d.ts +1 -3
- package/dist/providers/SchedulingServiceProvider.d.ts +1 -3
- package/dist/providers/StorageServiceProvider.d.ts +1 -3
- package/dist/queue/FailedJobReporter.d.ts +1 -24
- package/dist/queue/Job.d.ts +12 -99
- package/dist/queue/QueueManager.d.ts +6 -57
- package/dist/queue/Worker.d.ts +4 -65
- package/dist/queue/drivers/MemoryDriver.d.ts +3 -44
- package/dist/queue/drivers/RedisDriver.d.ts +7 -65
- package/dist/queue/drivers/SqsDriver.d.ts +6 -57
- package/dist/queue/drivers/SyncDriver.d.ts +10 -13
- package/dist/queue/index.js +2 -2
- package/dist/queue/types.d.ts +10 -92
- package/dist/{queue-CXrRK85G.js → queue-CcXCjuJI.js} +32 -260
- package/dist/redis/RedisApiTokenStore.d.ts +4 -56
- package/dist/redis/RedisEmailVerificationStore.d.ts +4 -37
- package/dist/redis/RedisOAuthStateStore.d.ts +2 -10
- package/dist/redis/RedisPasswordResetStore.d.ts +4 -37
- package/dist/redis/RedisRateLimitStore.d.ts +16 -49
- package/dist/redis/RedisSessionStore.d.ts +3 -44
- package/dist/redis/client.d.ts +2 -32
- package/dist/redis/index.js +47 -232
- package/dist/redis/redis-values.d.ts +6 -12
- package/dist/redis/scan-keys.d.ts +1 -4
- package/dist/request-CLOYytGP.js +68 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +50 -92
- package/dist/scheduling/CronParser.d.ts +0 -29
- package/dist/scheduling/Schedule.d.ts +1 -153
- package/dist/scheduling/ScheduledTask.d.ts +0 -31
- package/dist/scheduling/Scheduler.d.ts +0 -70
- package/dist/scheduling/index.js +1 -1
- package/dist/scheduling/types.d.ts +4 -65
- package/dist/{scheduling-CPiEdtQd.js → scheduling-C6tcOtUl.js} +2 -287
- package/dist/storage/StorageManager.d.ts +0 -48
- package/dist/storage/drivers/LocalDriver.d.ts +1 -25
- package/dist/storage/drivers/MemoryDriver.d.ts +5 -35
- package/dist/storage/drivers/S3Driver.d.ts +6 -36
- package/dist/storage/drivers/s3-acl.d.ts +5 -10
- package/dist/storage/index.js +1 -1
- package/dist/storage/types.d.ts +27 -265
- package/dist/{storage-TLD9t0Q2.js → storage-BB59f07j.js} +17 -157
- package/dist/support/contained-path.d.ts +10 -20
- package/dist/support/error-polyfill.d.ts +4 -6
- package/dist/support/expiry.d.ts +17 -33
- package/dist/support/expiry.js +17 -33
- package/dist/support/import-map.d.ts +3 -7
- package/dist/support/inertia-defaults.d.ts +5 -10
- package/dist/support/redirect-target.d.ts +4 -6
- package/dist/support/stack-frames.d.ts +11 -50
- package/dist/support/trim-slashes.d.ts +4 -7
- package/dist/support/warn-once.d.ts +2 -6
- package/dist/{trim-slashes-ZJ_VsY5s.js → trim-slashes-BLY9hKAa.js} +4 -7
- package/dist/{vite-manifest-w_RSOvQW.js → vite-manifest-CTQp-SOo.js} +34 -58
- package/package.json +2 -2
- package/dist/client-Dd7vLcqp.js +0 -27
- package/dist/context-DoD0c7J_.js +0 -26
- package/dist/endpoint-D-20PiHY.js +0 -46
- package/dist/hot-disposables-WsTX2ySN.js +0 -281
- package/dist/request-CVQwpu2J.js +0 -129
|
@@ -1,39 +1,16 @@
|
|
|
1
1
|
import type { Redis } from 'ioredis';
|
|
2
2
|
import type { QueueDriver, QueuedJob, FailedJob } from '../types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Options for RedisDriver.
|
|
5
|
-
*/
|
|
6
3
|
export interface RedisDriverOptions {
|
|
7
|
-
/**
|
|
8
|
-
* Key prefix for queue keys.
|
|
9
|
-
* @default 'queue:'
|
|
10
|
-
*/
|
|
4
|
+
/** @default 'queue:' */
|
|
11
5
|
prefix?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Visibility timeout in milliseconds.
|
|
14
|
-
* Jobs reserved longer than this will be released.
|
|
15
|
-
* @default 60000
|
|
16
|
-
*/
|
|
6
|
+
/** Jobs reserved longer than this are released. Milliseconds. @default 60000 */
|
|
17
7
|
visibilityTimeout?: number;
|
|
18
8
|
}
|
|
19
9
|
/**
|
|
20
|
-
* Redis-backed queue driver for production.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* - `{prefix}{queue}:reserved` - Sorted Set (score = timeout timestamp)
|
|
25
|
-
* - `{prefix}{queue}:failed` - List of failed job IDs
|
|
26
|
-
* - `{prefix}job:{id}` - Hash containing job data
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* import { createRedisClient } from '@guren/server/redis'
|
|
31
|
-
* import { RedisDriver, setQueueDriver } from '@guren/server/queue'
|
|
32
|
-
*
|
|
33
|
-
* const redis = createRedisClient({ url: process.env.REDIS_URL })
|
|
34
|
-
* const driver = new RedisDriver(redis)
|
|
35
|
-
* setQueueDriver(driver)
|
|
36
|
-
* ```
|
|
10
|
+
* Redis-backed queue driver for production. Key layout:
|
|
11
|
+
* `{prefix}{queue}:pending` Sorted Set (score = availableAt),
|
|
12
|
+
* `{prefix}{queue}:reserved` Sorted Set (score = timeout),
|
|
13
|
+
* `{prefix}{queue}:failed` List of job IDs, `{prefix}job:{id}` Hash of job data.
|
|
37
14
|
*/
|
|
38
15
|
export declare class RedisDriver implements QueueDriver {
|
|
39
16
|
private readonly redis;
|
|
@@ -44,53 +21,18 @@ export declare class RedisDriver implements QueueDriver {
|
|
|
44
21
|
private reservedKey;
|
|
45
22
|
private failedKey;
|
|
46
23
|
private jobKey;
|
|
47
|
-
/**
|
|
48
|
-
* Push a job onto the queue.
|
|
49
|
-
*/
|
|
50
24
|
push(job: QueuedJob): Promise<void>;
|
|
51
|
-
/**
|
|
52
|
-
* Pop the next available job from the queue.
|
|
53
|
-
*/
|
|
54
25
|
pop(queue: string): Promise<QueuedJob | null>;
|
|
55
|
-
/**
|
|
56
|
-
* Release jobs that have exceeded visibility timeout.
|
|
57
|
-
*/
|
|
58
26
|
private releaseTimedOutJobs;
|
|
59
|
-
/**
|
|
60
|
-
* Release a job back onto the queue.
|
|
61
|
-
*/
|
|
62
27
|
release(job: QueuedJob, delayMs?: number): Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Delete a job from the queue.
|
|
65
|
-
*/
|
|
66
28
|
delete(jobId: string): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Mark a job as failed.
|
|
69
|
-
*/
|
|
70
29
|
fail(job: QueuedJob, error: Error): Promise<void>;
|
|
71
|
-
/**
|
|
72
|
-
* Get the number of jobs in a queue.
|
|
73
|
-
*/
|
|
74
30
|
size(queue: string): Promise<number>;
|
|
75
|
-
/**
|
|
76
|
-
* Get failed jobs.
|
|
77
|
-
*/
|
|
78
31
|
getFailedJobs(queue?: string): Promise<FailedJob[]>;
|
|
79
32
|
private getFailedJobsForQueue;
|
|
80
|
-
/**
|
|
81
|
-
* Retry a failed job.
|
|
82
|
-
*/
|
|
83
33
|
retryFailedJob(jobId: string): Promise<void>;
|
|
84
|
-
/**
|
|
85
|
-
* Delete a failed job.
|
|
86
|
-
*/
|
|
87
34
|
deleteFailedJob(jobId: string): Promise<void>;
|
|
88
|
-
/**
|
|
89
|
-
* Clear all jobs (for testing).
|
|
90
|
-
*/
|
|
35
|
+
/** Testing only. */
|
|
91
36
|
clear(): Promise<void>;
|
|
92
|
-
/**
|
|
93
|
-
* Parse job data from Redis hash.
|
|
94
|
-
*/
|
|
95
37
|
private parseJobData;
|
|
96
38
|
}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import type { QueueDriver, QueuedJob, FailedJob } from '../types.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* This avoids a hard dependency on @aws-sdk/client-sqs in the framework.
|
|
3
|
+
* Implemented by wrapping your own SQS client, which keeps @aws-sdk/client-sqs
|
|
4
|
+
* out of the framework's dependencies.
|
|
6
5
|
*/
|
|
7
6
|
export interface SqsAdapter {
|
|
8
|
-
/**
|
|
9
|
-
* Send a message to an SQS queue.
|
|
10
|
-
*/
|
|
11
7
|
sendMessage(params: {
|
|
12
8
|
queueUrl: string;
|
|
13
9
|
messageBody: string;
|
|
@@ -15,9 +11,6 @@ export interface SqsAdapter {
|
|
|
15
11
|
messageGroupId?: string;
|
|
16
12
|
messageDeduplicationId?: string;
|
|
17
13
|
}): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Receive a single message from an SQS queue.
|
|
20
|
-
*/
|
|
21
14
|
receiveMessage(params: {
|
|
22
15
|
queueUrl: string;
|
|
23
16
|
waitTimeSeconds?: number;
|
|
@@ -25,69 +18,25 @@ export interface SqsAdapter {
|
|
|
25
18
|
body: string;
|
|
26
19
|
receiptHandle: string;
|
|
27
20
|
} | null>;
|
|
28
|
-
/**
|
|
29
|
-
* Change the visibility timeout of a message.
|
|
30
|
-
*/
|
|
31
21
|
changeMessageVisibility(params: {
|
|
32
22
|
queueUrl: string;
|
|
33
23
|
receiptHandle: string;
|
|
34
24
|
visibilityTimeout: number;
|
|
35
25
|
}): Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* Get the approximate number of messages in a queue.
|
|
38
|
-
*/
|
|
39
26
|
getApproximateMessageCount(queueUrl: string): Promise<number>;
|
|
40
27
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Options for SqsDriver.
|
|
43
|
-
*/
|
|
44
28
|
export interface SqsDriverOptions {
|
|
45
|
-
/**
|
|
46
|
-
* SQS queue URL for the primary queue.
|
|
47
|
-
*/
|
|
48
29
|
queueUrl: string;
|
|
49
|
-
/**
|
|
50
|
-
* Optional mapping of logical queue names to SQS queue URLs.
|
|
51
|
-
* If not specified, all queues use the primary `queueUrl`.
|
|
52
|
-
*/
|
|
30
|
+
/** Logical queue name to SQS URL; unlisted queues use `queueUrl`. */
|
|
53
31
|
queueUrls?: Record<string, string>;
|
|
54
|
-
/**
|
|
55
|
-
* Message group ID for FIFO queues. If set, enables FIFO mode.
|
|
56
|
-
*/
|
|
32
|
+
/** Setting this enables FIFO mode. */
|
|
57
33
|
messageGroupId?: string;
|
|
58
34
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Create an SqsAdapter from an @aws-sdk/client-sqs SQSClient.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```ts
|
|
64
|
-
* import { SQSClient } from '@aws-sdk/client-sqs'
|
|
65
|
-
* import { createSqsAdapter, SqsDriver } from '@guren/server/queue'
|
|
66
|
-
*
|
|
67
|
-
* const client = new SQSClient({ region: 'ap-northeast-1' })
|
|
68
|
-
* const adapter = createSqsAdapter(client)
|
|
69
|
-
* const driver = new SqsDriver(adapter, { queueUrl: '...' })
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
35
|
+
/** Builds an SqsAdapter over an @aws-sdk/client-sqs SQSClient. */
|
|
72
36
|
export declare function createSqsAdapter(client: {
|
|
73
37
|
send(command: unknown): Promise<unknown>;
|
|
74
38
|
}): SqsAdapter;
|
|
75
|
-
/**
|
|
76
|
-
* AWS SQS queue driver for serverless deployments.
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* ```ts
|
|
80
|
-
* import { SQSClient } from '@aws-sdk/client-sqs'
|
|
81
|
-
* import { createSqsAdapter, SqsDriver, setQueueDriver } from '@guren/server/queue'
|
|
82
|
-
*
|
|
83
|
-
* const adapter = createSqsAdapter(new SQSClient({ region: 'ap-northeast-1' }))
|
|
84
|
-
* const driver = new SqsDriver(adapter, { queueUrl: process.env.SQS_QUEUE_URL! })
|
|
85
|
-
* setQueueDriver(driver)
|
|
86
|
-
*
|
|
87
|
-
* // Dispatch jobs as usual
|
|
88
|
-
* await SendEmailJob.dispatch({ to: 'user@example.com' })
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
39
|
+
/** AWS SQS queue driver for serverless deployments. */
|
|
91
40
|
export declare class SqsDriver implements QueueDriver {
|
|
92
41
|
private readonly adapter;
|
|
93
42
|
private readonly options;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import type { QueueDriver, QueuedJob, FailedJob } from '../types.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* const queue = createQueueManager({
|
|
11
|
-
* default: 'sync',
|
|
12
|
-
* drivers: { sync: () => new SyncDriver() },
|
|
13
|
-
* })
|
|
14
|
-
* ```
|
|
3
|
+
* Runs jobs inline in the dispatching process, no worker required: the
|
|
4
|
+
* development default. Dispatch semantics match a real queue but failures
|
|
5
|
+
* surface immediately, and retry backoff is not honored because nothing waits
|
|
6
|
+
* in a sync queue (`release()` re-runs the job at once whatever `delayMs`).
|
|
15
7
|
*/
|
|
16
8
|
export declare class SyncDriver implements QueueDriver {
|
|
17
9
|
private failedJobs;
|
|
18
10
|
push(job: QueuedJob): Promise<void>;
|
|
19
11
|
pop(): Promise<QueuedJob | null>;
|
|
20
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Re-run the job now, ignoring `delayMs`: honoring a backoff would block the
|
|
14
|
+
* releasing caller for the full delay, and a detached timer would move the
|
|
15
|
+
* failure off the call that surfaces it. A failure rethrows, as `push()` does.
|
|
16
|
+
*/
|
|
17
|
+
release(job: QueuedJob, _delayMs?: number): Promise<void>;
|
|
21
18
|
delete(): Promise<void>;
|
|
22
19
|
fail(job: QueuedJob, error: Error): Promise<void>;
|
|
23
20
|
size(): Promise<number>;
|
package/dist/queue/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as getRegisteredJobs, c as setQueueDriver, i as getQueueDriver, n as clearJobRegistry, o as registerJob, r as getJob, s as resolveJobName, t as Job } from "../Job-
|
|
2
|
-
import { a as processJob, c as RedisDriver, i as Worker, l as SyncDriver, n as createQueueManager, o as SqsDriver, r as FailedJobReporter, s as createSqsAdapter, t as QueueManager, u as MemoryDriver } from "../queue-
|
|
1
|
+
import { a as getRegisteredJobs, c as setQueueDriver, i as getQueueDriver, n as clearJobRegistry, o as registerJob, r as getJob, s as resolveJobName, t as Job } from "../Job-DxQK8h3P.js";
|
|
2
|
+
import { a as processJob, c as RedisDriver, i as Worker, l as SyncDriver, n as createQueueManager, o as SqsDriver, r as FailedJobReporter, s as createSqsAdapter, t as QueueManager, u as MemoryDriver } from "../queue-CcXCjuJI.js";
|
|
3
3
|
export { FailedJobReporter, Job, MemoryDriver, QueueManager, RedisDriver, SqsDriver, SyncDriver, Worker, clearJobRegistry, createQueueManager, createSqsAdapter, getJob, getQueueDriver, getRegisteredJobs, processJob, registerJob, resolveJobName, setQueueDriver };
|
package/dist/queue/types.d.ts
CHANGED
|
@@ -1,117 +1,41 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Serialized job data stored in the queue.
|
|
3
|
-
*/
|
|
1
|
+
/** Serialized job data stored in the queue. */
|
|
4
2
|
export interface QueuedJob<T = unknown> {
|
|
5
|
-
/**
|
|
6
|
-
* Unique job identifier.
|
|
7
|
-
*/
|
|
8
3
|
id: string;
|
|
9
|
-
/**
|
|
10
|
-
* Job class name.
|
|
11
|
-
*/
|
|
4
|
+
/** The job class name; the registry resolves it back to the class. */
|
|
12
5
|
name: string;
|
|
13
|
-
/**
|
|
14
|
-
* Job payload data.
|
|
15
|
-
*/
|
|
16
6
|
payload: T;
|
|
17
|
-
/**
|
|
18
|
-
* Queue name this job belongs to.
|
|
19
|
-
*/
|
|
20
7
|
queue: string;
|
|
21
|
-
/**
|
|
22
|
-
* Number of times this job has been attempted.
|
|
23
|
-
*/
|
|
24
8
|
attempts: number;
|
|
25
|
-
/**
|
|
26
|
-
* Maximum number of attempts before failing permanently.
|
|
27
|
-
*/
|
|
28
9
|
maxAttempts: number;
|
|
29
|
-
/**
|
|
30
|
-
* When the job becomes available for processing.
|
|
31
|
-
*/
|
|
32
10
|
availableAt: Date;
|
|
33
|
-
/**
|
|
34
|
-
* When the job was created.
|
|
35
|
-
*/
|
|
36
11
|
createdAt: Date;
|
|
37
|
-
/**
|
|
38
|
-
* When the job was reserved by a worker (null if not reserved).
|
|
39
|
-
*/
|
|
40
12
|
reservedAt: Date | null;
|
|
41
|
-
/**
|
|
42
|
-
* Last error message if the job failed.
|
|
43
|
-
*/
|
|
44
13
|
lastError?: string;
|
|
45
14
|
}
|
|
46
|
-
/**
|
|
47
|
-
* Failed job record.
|
|
48
|
-
*/
|
|
15
|
+
/** Failed job record. */
|
|
49
16
|
export interface FailedJob<T = unknown> extends QueuedJob<T> {
|
|
50
|
-
/**
|
|
51
|
-
* When the job failed.
|
|
52
|
-
*/
|
|
53
17
|
failedAt: Date;
|
|
54
|
-
/**
|
|
55
|
-
* Error that caused the failure.
|
|
56
|
-
*/
|
|
57
18
|
error: string;
|
|
58
|
-
/**
|
|
59
|
-
* Stack trace of the error.
|
|
60
|
-
*/
|
|
61
19
|
stack?: string;
|
|
62
20
|
}
|
|
63
|
-
/**
|
|
64
|
-
* Queue driver interface.
|
|
65
|
-
* Implement this to create a custom queue backend.
|
|
66
|
-
*/
|
|
21
|
+
/** Implement to add a queue backend. */
|
|
67
22
|
export interface QueueDriver {
|
|
68
|
-
/**
|
|
69
|
-
* Push a job onto the queue.
|
|
70
|
-
*/
|
|
71
23
|
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
24
|
pop(queue: string): Promise<QueuedJob | null>;
|
|
77
25
|
/**
|
|
78
|
-
* Release a job
|
|
79
|
-
*
|
|
80
|
-
* @param delayMs - Delay before the job becomes available again
|
|
26
|
+
* Release a job for retry. The driver owns the delay: one with nothing to wait
|
|
27
|
+
* in (`SyncDriver`) may run the job again before this resolves.
|
|
81
28
|
*/
|
|
82
29
|
release(job: QueuedJob, delayMs?: number): Promise<void>;
|
|
83
|
-
/**
|
|
84
|
-
* Delete a job from the queue.
|
|
85
|
-
*/
|
|
86
30
|
delete(jobId: string): Promise<void>;
|
|
87
|
-
/**
|
|
88
|
-
* Mark a job as failed and move to failed jobs.
|
|
89
|
-
*/
|
|
90
31
|
fail(job: QueuedJob, error: Error): Promise<void>;
|
|
91
|
-
/**
|
|
92
|
-
* Get the number of jobs in a queue.
|
|
93
|
-
*/
|
|
94
32
|
size(queue: string): Promise<number>;
|
|
95
|
-
/**
|
|
96
|
-
* Get failed jobs.
|
|
97
|
-
*/
|
|
98
33
|
getFailedJobs(queue?: string): Promise<FailedJob[]>;
|
|
99
|
-
/**
|
|
100
|
-
* Retry a failed job.
|
|
101
|
-
*/
|
|
102
34
|
retryFailedJob(jobId: string): Promise<void>;
|
|
103
|
-
/**
|
|
104
|
-
* Delete a failed job.
|
|
105
|
-
*/
|
|
106
35
|
deleteFailedJob(jobId: string): Promise<void>;
|
|
107
|
-
/**
|
|
108
|
-
* Clear all jobs (for testing).
|
|
109
|
-
*/
|
|
110
36
|
clear(): Promise<void>;
|
|
111
37
|
}
|
|
112
|
-
/**
|
|
113
|
-
* Options for creating a job.
|
|
114
|
-
*/
|
|
38
|
+
/** Options for creating a job. */
|
|
115
39
|
export interface JobOptions {
|
|
116
40
|
/**
|
|
117
41
|
* Queue to dispatch the job to.
|
|
@@ -129,9 +53,7 @@ export interface JobOptions {
|
|
|
129
53
|
*/
|
|
130
54
|
maxAttempts?: number;
|
|
131
55
|
}
|
|
132
|
-
/**
|
|
133
|
-
* Worker options.
|
|
134
|
-
*/
|
|
56
|
+
/** Worker options. */
|
|
135
57
|
export interface WorkerOptions {
|
|
136
58
|
/**
|
|
137
59
|
* Queues to process (in priority order).
|
|
@@ -161,11 +83,7 @@ export interface WorkerOptions {
|
|
|
161
83
|
*/
|
|
162
84
|
stopWhenEmpty?: boolean;
|
|
163
85
|
}
|
|
164
|
-
/**
|
|
165
|
-
* Job handler function type.
|
|
166
|
-
*/
|
|
86
|
+
/** Job handler function type. */
|
|
167
87
|
export type JobHandler<T = unknown> = (payload: T) => void | Promise<void>;
|
|
168
|
-
/**
|
|
169
|
-
* Job failure handler function type.
|
|
170
|
-
*/
|
|
88
|
+
/** Job failure handler function type. */
|
|
171
89
|
export type JobFailureHandler<T = unknown> = (payload: T, error: Error) => void | Promise<void>;
|