@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,87 +1,33 @@
|
|
|
1
1
|
import type { CacheStore, TaggableCacheStore, CacheStoreFactory, CacheConfig } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Cache manager for handling multiple cache stores.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* const cache = new CacheManager({
|
|
8
|
-
* default: 'redis',
|
|
9
|
-
* stores: {
|
|
10
|
-
* memory: { driver: 'memory' },
|
|
11
|
-
* redis: { driver: 'redis', client: redisClient },
|
|
12
|
-
* file: { driver: 'file', path: './storage/cache' },
|
|
13
|
-
* }
|
|
14
|
-
* })
|
|
15
|
-
*
|
|
16
|
-
* // Use the default store
|
|
17
|
-
* await cache.store().set('key', 'value', 3600)
|
|
18
|
-
*
|
|
19
|
-
* // Use a specific store
|
|
20
|
-
* await cache.store('memory').set('key', 'value')
|
|
21
|
-
*
|
|
22
|
-
* // Use tagged cache
|
|
23
|
-
* await cache.store().tags(['posts', 'user:1']).set('user:1:posts', posts)
|
|
24
|
-
* await cache.store().tags(['user:1']).flush()
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
2
|
+
/** Cache manager for handling multiple cache stores. */
|
|
27
3
|
export declare class CacheManager {
|
|
28
4
|
private readonly defaultStoreName;
|
|
29
5
|
private readonly storeFactories;
|
|
30
6
|
private readonly resolvedStores;
|
|
31
7
|
/**
|
|
32
8
|
* Where this manager was built, for identifying its stores across hot reloads.
|
|
33
|
-
*
|
|
34
9
|
* Captured here rather than in `store()` because stores resolve lazily, from
|
|
35
|
-
* whichever request first asks for one
|
|
36
|
-
*
|
|
37
|
-
* formatted stack string held for the manager's lifetime and never read.
|
|
10
|
+
* whichever request first asks for one. Skipped outside `--hot`, where the
|
|
11
|
+
* stack string would be held for the manager's lifetime and never read.
|
|
38
12
|
*/
|
|
39
13
|
private readonly builtAt;
|
|
40
14
|
constructor(config?: CacheConfig);
|
|
41
15
|
private driverFactories;
|
|
42
|
-
/**
|
|
43
|
-
* Register built-in store drivers.
|
|
44
|
-
*/
|
|
45
16
|
private registerBuiltinDrivers;
|
|
46
|
-
/**
|
|
47
|
-
* Register a store from configuration.
|
|
48
|
-
*/
|
|
49
17
|
private registerStoreFromConfig;
|
|
50
|
-
/**
|
|
51
|
-
* Get a cache store by name.
|
|
52
|
-
* Returns the default store if no name is specified.
|
|
53
|
-
*/
|
|
18
|
+
/** Returns the default store if no name is given. */
|
|
54
19
|
store(name?: string): TaggableCacheStore;
|
|
55
20
|
/**
|
|
56
|
-
* Under `bun --hot`, stops the sweep timer held by the store this one
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* stores in one config from sharing a slot and cancelling each other's sweep.
|
|
21
|
+
* Under `bun --hot`, stops the sweep timer held by the store this one
|
|
22
|
+
* replaces. Registered from here because the store's name is known here, and
|
|
23
|
+
* that name keeps two memory stores in one config from cancelling each
|
|
24
|
+
* other's sweep.
|
|
61
25
|
*/
|
|
62
26
|
private stopPreviousStore;
|
|
63
|
-
/**
|
|
64
|
-
* Register a custom store factory.
|
|
65
|
-
*/
|
|
66
27
|
registerStore(name: string, factory: CacheStoreFactory): void;
|
|
67
|
-
/**
|
|
68
|
-
* Register a custom driver.
|
|
69
|
-
*/
|
|
70
28
|
registerDriver(name: string, factory: (options: unknown) => CacheStore): void;
|
|
71
|
-
/**
|
|
72
|
-
* Check if a store is registered.
|
|
73
|
-
*/
|
|
74
29
|
hasStore(name: string): boolean;
|
|
75
|
-
/**
|
|
76
|
-
* Get the default store name.
|
|
77
|
-
*/
|
|
78
30
|
getDefaultStoreName(): string;
|
|
79
|
-
/**
|
|
80
|
-
* Get all registered store names.
|
|
81
|
-
*/
|
|
82
31
|
getStoreNames(): string[];
|
|
83
32
|
}
|
|
84
|
-
/**
|
|
85
|
-
* Create a cache manager with configuration.
|
|
86
|
-
*/
|
|
87
33
|
export declare function createCacheManager(config?: CacheConfig): CacheManager;
|
|
@@ -1,36 +1,13 @@
|
|
|
1
1
|
import type { CacheStore, TaggedCacheStore } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Tagged cache implementation.
|
|
4
|
-
* Allows grouping cache items by tags for bulk invalidation.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* const tagged = new TaggedCache(store, ['posts', 'user:1'])
|
|
9
|
-
*
|
|
10
|
-
* await tagged.set('user:1:posts', posts, 3600)
|
|
11
|
-
* await tagged.flush() // Removes all items with these tags
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
2
|
+
/** Groups cache items by tags for bulk invalidation. */
|
|
14
3
|
export declare class TaggedCache implements TaggedCacheStore {
|
|
15
4
|
private readonly store;
|
|
16
5
|
private readonly tags;
|
|
17
6
|
private readonly tagSetPrefix;
|
|
18
7
|
constructor(store: CacheStore, tags: string[], tagSetPrefix?: string);
|
|
19
|
-
/**
|
|
20
|
-
* Get a unique namespace for the current tags.
|
|
21
|
-
*/
|
|
22
8
|
private getTagNamespace;
|
|
23
|
-
/**
|
|
24
|
-
* Generate a unique namespace identifier.
|
|
25
|
-
*/
|
|
26
9
|
private generateNamespace;
|
|
27
|
-
/**
|
|
28
|
-
* Get the tagged key.
|
|
29
|
-
*/
|
|
30
10
|
private taggedKey;
|
|
31
|
-
/**
|
|
32
|
-
* Track a key in the tag sets.
|
|
33
|
-
*/
|
|
34
11
|
private trackKey;
|
|
35
12
|
get<T>(key: string): Promise<T | null>;
|
|
36
13
|
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|
|
@@ -45,18 +22,8 @@ export declare class TaggedCache implements TaggedCacheStore {
|
|
|
45
22
|
setMany<T>(items: Map<string, T>, ttl?: number): Promise<void>;
|
|
46
23
|
deleteMany(keys: string[]): Promise<number>;
|
|
47
24
|
ttl(key: string): Promise<number>;
|
|
48
|
-
/**
|
|
49
|
-
* Flush all items with the current tags.
|
|
50
|
-
* This works by resetting the tag namespaces, effectively
|
|
51
|
-
* making all previously tagged items inaccessible.
|
|
52
|
-
*/
|
|
25
|
+
/** Flush every item carrying the current tags, and the tag namespaces themselves. */
|
|
53
26
|
flush(): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
* Get the current tags.
|
|
56
|
-
*/
|
|
57
27
|
getTags(): string[];
|
|
58
|
-
/**
|
|
59
|
-
* Get the underlying store.
|
|
60
|
-
*/
|
|
61
28
|
getStore(): CacheStore;
|
|
62
29
|
}
|
package/dist/cache/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as RedisStore, i as FileStore, n as createCacheManager, o as MemoryStore, r as TaggedCache, t as CacheManager } from "../cache-
|
|
1
|
+
import { a as RedisStore, i as FileStore, n as createCacheManager, o as MemoryStore, r as TaggedCache, t as CacheManager } from "../cache-BOOIr324.js";
|
|
2
2
|
export { CacheManager, FileStore, MemoryStore, RedisStore, TaggedCache, createCacheManager };
|
|
@@ -1,43 +1,15 @@
|
|
|
1
1
|
import type { CacheStore, FileStoreOptions } from '../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* File-based cache store.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* const store = new FileStore({ path: './storage/cache' })
|
|
8
|
-
*
|
|
9
|
-
* await store.set('user:1', { name: 'John' }, 3600)
|
|
10
|
-
* const user = await store.get<User>('user:1')
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
2
|
+
/** File-based cache store. */
|
|
13
3
|
export declare class FileStore implements CacheStore {
|
|
14
4
|
private readonly basePath;
|
|
15
5
|
private readonly extension;
|
|
16
6
|
private readonly now;
|
|
17
7
|
constructor(options: FileStoreOptions);
|
|
18
|
-
/**
|
|
19
|
-
* Generate a hashed filename for a cache key.
|
|
20
|
-
*/
|
|
21
8
|
private getFilePath;
|
|
22
|
-
/**
|
|
23
|
-
* Ensure the cache directory exists.
|
|
24
|
-
*/
|
|
25
9
|
private ensureDirectory;
|
|
26
|
-
/**
|
|
27
|
-
* Read a cache file.
|
|
28
|
-
*/
|
|
29
10
|
private readCacheFile;
|
|
30
|
-
/**
|
|
31
|
-
* Write a cache file.
|
|
32
|
-
*/
|
|
33
11
|
private writeCacheFile;
|
|
34
|
-
/**
|
|
35
|
-
* Delete a cache file.
|
|
36
|
-
*/
|
|
37
12
|
private deleteCacheFile;
|
|
38
|
-
/**
|
|
39
|
-
* Check if a cached item is expired.
|
|
40
|
-
*/
|
|
41
13
|
private isExpired;
|
|
42
14
|
get<T>(key: string): Promise<T | null>;
|
|
43
15
|
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|
|
@@ -52,13 +24,7 @@ export declare class FileStore implements CacheStore {
|
|
|
52
24
|
setMany<T>(items: Map<string, T>, ttl?: number): Promise<void>;
|
|
53
25
|
deleteMany(keys: string[]): Promise<number>;
|
|
54
26
|
ttl(key: string): Promise<number>;
|
|
55
|
-
/**
|
|
56
|
-
* Clean up expired cache files.
|
|
57
|
-
* This can be called periodically to free disk space.
|
|
58
|
-
*/
|
|
27
|
+
/** Delete expired cache files; call periodically to free disk space. */
|
|
59
28
|
cleanup(): Promise<number>;
|
|
60
|
-
/**
|
|
61
|
-
* Get the base path.
|
|
62
|
-
*/
|
|
63
29
|
getBasePath(): string;
|
|
64
30
|
}
|
|
@@ -1,32 +1,13 @@
|
|
|
1
1
|
import type { CacheStore, MemoryStoreOptions } from '../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* In-memory cache store.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* const store = new MemoryStore()
|
|
8
|
-
*
|
|
9
|
-
* await store.set('user:1', { name: 'John' }, 3600)
|
|
10
|
-
* const user = await store.get<User>('user:1')
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
2
|
+
/** In-memory cache store. */
|
|
13
3
|
export declare class MemoryStore implements CacheStore {
|
|
14
4
|
private readonly cache;
|
|
15
5
|
private readonly maxSize;
|
|
16
6
|
private readonly now;
|
|
17
7
|
private checkInterval;
|
|
18
8
|
constructor(options?: MemoryStoreOptions);
|
|
19
|
-
/**
|
|
20
|
-
* Remove expired items from the cache.
|
|
21
|
-
*/
|
|
22
9
|
private removeExpired;
|
|
23
|
-
/**
|
|
24
|
-
* Check if an item is expired.
|
|
25
|
-
*/
|
|
26
10
|
private isExpired;
|
|
27
|
-
/**
|
|
28
|
-
* Evict items if cache is full.
|
|
29
|
-
*/
|
|
30
11
|
private evictIfNeeded;
|
|
31
12
|
get<T>(key: string): Promise<T | null>;
|
|
32
13
|
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|
|
@@ -41,12 +22,7 @@ export declare class MemoryStore implements CacheStore {
|
|
|
41
22
|
setMany<T>(items: Map<string, T>, ttl?: number): Promise<void>;
|
|
42
23
|
deleteMany(keys: string[]): Promise<number>;
|
|
43
24
|
ttl(key: string): Promise<number>;
|
|
44
|
-
/**
|
|
45
|
-
* Get the number of items in the cache.
|
|
46
|
-
*/
|
|
47
25
|
size(): number;
|
|
48
|
-
/**
|
|
49
|
-
* Stop the expiration check interval.
|
|
50
|
-
*/
|
|
26
|
+
/** Stop the expiration check interval. */
|
|
51
27
|
destroy(): void;
|
|
52
28
|
}
|
|
@@ -1,33 +1,11 @@
|
|
|
1
1
|
import type { CacheStore, RedisStoreOptions } from '../types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Redis-backed cache store.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* import Redis from 'ioredis'
|
|
8
|
-
*
|
|
9
|
-
* const redis = new Redis(process.env.REDIS_URL)
|
|
10
|
-
* const store = new RedisStore({ client: redis })
|
|
11
|
-
*
|
|
12
|
-
* await store.set('user:1', { name: 'John' }, 3600)
|
|
13
|
-
* const user = await store.get<User>('user:1')
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
2
|
+
/** Redis-backed cache store. */
|
|
16
3
|
export declare class RedisStore implements CacheStore {
|
|
17
4
|
private readonly client;
|
|
18
5
|
private readonly prefix;
|
|
19
6
|
constructor(options: RedisStoreOptions);
|
|
20
|
-
/**
|
|
21
|
-
* Get the prefixed key.
|
|
22
|
-
*/
|
|
23
7
|
private prefixKey;
|
|
24
|
-
/**
|
|
25
|
-
* Serialize a value for storage.
|
|
26
|
-
*/
|
|
27
8
|
private serialize;
|
|
28
|
-
/**
|
|
29
|
-
* Deserialize a stored value.
|
|
30
|
-
*/
|
|
31
9
|
private deserialize;
|
|
32
10
|
get<T>(key: string): Promise<T | null>;
|
|
33
11
|
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|
|
@@ -42,12 +20,6 @@ export declare class RedisStore implements CacheStore {
|
|
|
42
20
|
setMany<T>(items: Map<string, T>, ttl?: number): Promise<void>;
|
|
43
21
|
deleteMany(keys: string[]): Promise<number>;
|
|
44
22
|
ttl(key: string): Promise<number>;
|
|
45
|
-
/**
|
|
46
|
-
* Get the Redis client instance.
|
|
47
|
-
*/
|
|
48
23
|
getClient(): unknown;
|
|
49
|
-
/**
|
|
50
|
-
* Get the key prefix.
|
|
51
|
-
*/
|
|
52
24
|
getPrefix(): string;
|
|
53
25
|
}
|
package/dist/cache/types.d.ts
CHANGED
|
@@ -1,163 +1,68 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cache store interface.
|
|
3
|
-
*/
|
|
4
1
|
export interface CacheStore {
|
|
5
|
-
/**
|
|
6
|
-
* Get a value from the cache.
|
|
7
|
-
*/
|
|
8
2
|
get<T>(key: string): Promise<T | null>;
|
|
9
|
-
/**
|
|
10
|
-
* Set a value in the cache.
|
|
11
|
-
* @param key Cache key
|
|
12
|
-
* @param value Value to cache
|
|
13
|
-
* @param ttl Time-to-live in seconds (optional)
|
|
14
|
-
*/
|
|
3
|
+
/** @param ttl Time-to-live in seconds. */
|
|
15
4
|
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Check if a key exists in the cache.
|
|
18
|
-
*/
|
|
19
5
|
has(key: string): Promise<boolean>;
|
|
20
|
-
/**
|
|
21
|
-
* Delete a key from the cache.
|
|
22
|
-
*/
|
|
23
6
|
delete(key: string): Promise<boolean>;
|
|
24
|
-
/**
|
|
25
|
-
* Clear all items from the cache.
|
|
26
|
-
*/
|
|
27
7
|
clear(): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* Increment a numeric value.
|
|
30
|
-
* @param key Cache key
|
|
31
|
-
* @param value Amount to increment (default: 1)
|
|
32
|
-
* @returns The new value
|
|
33
|
-
*/
|
|
8
|
+
/** Returns the new value; `value` defaults to 1. */
|
|
34
9
|
increment(key: string, value?: number): Promise<number>;
|
|
35
|
-
/**
|
|
36
|
-
* Decrement a numeric value.
|
|
37
|
-
* @param key Cache key
|
|
38
|
-
* @param value Amount to decrement (default: 1)
|
|
39
|
-
* @returns The new value
|
|
40
|
-
*/
|
|
10
|
+
/** Returns the new value; `value` defaults to 1. */
|
|
41
11
|
decrement(key: string, value?: number): Promise<number>;
|
|
42
|
-
/**
|
|
43
|
-
* Get a value from the cache, or store and return the result of the callback.
|
|
44
|
-
* @param key Cache key
|
|
45
|
-
* @param ttl Time-to-live in seconds
|
|
46
|
-
* @param callback Function to compute the value if not cached
|
|
47
|
-
*/
|
|
12
|
+
/** Cached value, or the callback's result stored for `ttl` seconds. */
|
|
48
13
|
remember<T>(key: string, ttl: number, callback: () => Promise<T>): Promise<T>;
|
|
49
|
-
/**
|
|
50
|
-
* Get a value from the cache, or store and return the result of the callback forever.
|
|
51
|
-
* @param key Cache key
|
|
52
|
-
* @param callback Function to compute the value if not cached
|
|
53
|
-
*/
|
|
14
|
+
/** Cached value, or the callback's result stored without expiry. */
|
|
54
15
|
rememberForever<T>(key: string, callback: () => Promise<T>): Promise<T>;
|
|
55
|
-
/**
|
|
56
|
-
* Get multiple values from the cache.
|
|
57
|
-
*/
|
|
58
16
|
getMany<T>(keys: string[]): Promise<Map<string, T | null>>;
|
|
59
|
-
/**
|
|
60
|
-
* Set multiple values in the cache.
|
|
61
|
-
*/
|
|
62
17
|
setMany<T>(items: Map<string, T>, ttl?: number): Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Delete multiple keys from the cache.
|
|
65
|
-
*/
|
|
66
18
|
deleteMany(keys: string[]): Promise<number>;
|
|
67
19
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
20
|
+
* Remaining TTL in seconds; -1 when the key has no expiration, -2 when it
|
|
21
|
+
* does not exist.
|
|
70
22
|
*/
|
|
71
23
|
ttl(key: string): Promise<number>;
|
|
72
24
|
}
|
|
73
|
-
/**
|
|
74
|
-
* Cache store that supports tagging.
|
|
75
|
-
*/
|
|
76
25
|
export interface TaggableCacheStore extends CacheStore {
|
|
77
|
-
/**
|
|
78
|
-
* Get a tagged cache instance.
|
|
79
|
-
*/
|
|
80
26
|
tags(tags: string[]): TaggedCacheStore;
|
|
81
27
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Tagged cache store interface.
|
|
84
|
-
*/
|
|
85
28
|
export interface TaggedCacheStore extends CacheStore {
|
|
86
|
-
/**
|
|
87
|
-
* Flush all items with the current tags.
|
|
88
|
-
*/
|
|
29
|
+
/** Flush all items with the current tags. */
|
|
89
30
|
flush(): Promise<void>;
|
|
90
|
-
/**
|
|
91
|
-
* Get the current tags.
|
|
92
|
-
*/
|
|
93
31
|
getTags(): string[];
|
|
94
32
|
}
|
|
95
|
-
/**
|
|
96
|
-
* Cache store factory function.
|
|
97
|
-
*/
|
|
98
33
|
export type CacheStoreFactory = () => CacheStore;
|
|
99
|
-
/**
|
|
100
|
-
* Memory store options.
|
|
101
|
-
*/
|
|
102
34
|
export interface MemoryStoreOptions {
|
|
103
|
-
/**
|
|
104
|
-
* Maximum number of items to store.
|
|
105
|
-
* @default Infinity
|
|
106
|
-
*/
|
|
35
|
+
/** @default Infinity */
|
|
107
36
|
maxSize?: number;
|
|
108
|
-
/**
|
|
109
|
-
* Check interval for expired items in milliseconds.
|
|
110
|
-
* @default 60000 (1 minute)
|
|
111
|
-
*/
|
|
37
|
+
/** Check interval for expired items, in milliseconds. @default 60000 */
|
|
112
38
|
checkPeriod?: number;
|
|
113
39
|
/**
|
|
114
|
-
* Clock
|
|
115
|
-
* milliseconds
|
|
116
|
-
*
|
|
117
|
-
* Injectable for tests.
|
|
40
|
+
* Clock for TTL calculations, injectable for tests. Must return a Unix
|
|
41
|
+
* timestamp in milliseconds: persisted `expiresAt` values are read by other
|
|
42
|
+
* instances using the default clock.
|
|
118
43
|
* @default Date.now
|
|
119
44
|
*/
|
|
120
45
|
now?: () => number;
|
|
121
46
|
}
|
|
122
|
-
/**
|
|
123
|
-
* Redis store options.
|
|
124
|
-
*/
|
|
125
47
|
export interface RedisStoreOptions {
|
|
126
|
-
/**
|
|
127
|
-
* Redis client instance (ioredis).
|
|
128
|
-
*/
|
|
48
|
+
/** Redis client instance (ioredis). */
|
|
129
49
|
client: unknown;
|
|
130
|
-
/**
|
|
131
|
-
* Key prefix.
|
|
132
|
-
* @default 'cache:'
|
|
133
|
-
*/
|
|
50
|
+
/** @default 'cache:' */
|
|
134
51
|
prefix?: string;
|
|
135
52
|
}
|
|
136
|
-
/**
|
|
137
|
-
* File store options.
|
|
138
|
-
*/
|
|
139
53
|
export interface FileStoreOptions {
|
|
140
|
-
/**
|
|
141
|
-
* Directory path for cache files.
|
|
142
|
-
*/
|
|
54
|
+
/** Directory path for cache files. */
|
|
143
55
|
path: string;
|
|
144
|
-
/**
|
|
145
|
-
* File extension.
|
|
146
|
-
* @default '.cache'
|
|
147
|
-
*/
|
|
56
|
+
/** @default '.cache' */
|
|
148
57
|
extension?: string;
|
|
149
58
|
/**
|
|
150
|
-
* Clock
|
|
151
|
-
* milliseconds
|
|
152
|
-
*
|
|
153
|
-
* Injectable for tests.
|
|
59
|
+
* Clock for TTL calculations, injectable for tests. Must return a Unix
|
|
60
|
+
* timestamp in milliseconds: persisted `expiresAt` values are read by other
|
|
61
|
+
* instances using the default clock.
|
|
154
62
|
* @default Date.now
|
|
155
63
|
*/
|
|
156
64
|
now?: () => number;
|
|
157
65
|
}
|
|
158
|
-
/**
|
|
159
|
-
* Store configuration union type.
|
|
160
|
-
*/
|
|
161
66
|
export type StoreConfig = ({
|
|
162
67
|
driver: 'memory';
|
|
163
68
|
} & MemoryStoreOptions) | ({
|
|
@@ -165,23 +70,11 @@ export type StoreConfig = ({
|
|
|
165
70
|
} & RedisStoreOptions) | ({
|
|
166
71
|
driver: 'file';
|
|
167
72
|
} & FileStoreOptions);
|
|
168
|
-
/**
|
|
169
|
-
* Cache manager configuration.
|
|
170
|
-
*/
|
|
171
73
|
export interface CacheConfig {
|
|
172
|
-
/**
|
|
173
|
-
* Default store name.
|
|
174
|
-
* @default 'memory'
|
|
175
|
-
*/
|
|
74
|
+
/** @default 'memory' */
|
|
176
75
|
default?: string;
|
|
177
|
-
/**
|
|
178
|
-
* Store configurations.
|
|
179
|
-
*/
|
|
180
76
|
stores?: Record<string, StoreConfig>;
|
|
181
77
|
}
|
|
182
|
-
/**
|
|
183
|
-
* Cached item with metadata.
|
|
184
|
-
*/
|
|
185
78
|
export interface CachedItem<T = unknown> {
|
|
186
79
|
value: T;
|
|
187
80
|
expiresAt: number | null;
|