@velajs/cloudflare 1.10.0 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/CHANGELOG.md +33 -3
  2. package/LICENSE +21 -0
  3. package/README.md +197 -322
  4. package/dist/durable-objects.d.ts +28 -0
  5. package/dist/durable-objects.js +494 -0
  6. package/dist/durable-objects.js.map +1 -0
  7. package/dist/index.d.ts +622 -41
  8. package/dist/index.js +1023 -39
  9. package/dist/index.js.map +1 -0
  10. package/dist/nonce-validation-LE0vFk-7.js +445 -0
  11. package/dist/nonce-validation-LE0vFk-7.js.map +1 -0
  12. package/dist/nonce.durable-object-Df3_42Sy.d.ts +141 -0
  13. package/package.json +66 -44
  14. package/dist/binding-ref.d.ts +0 -8
  15. package/dist/binding-ref.js +0 -19
  16. package/dist/cloudflare-application.d.ts +0 -125
  17. package/dist/cloudflare-application.js +0 -186
  18. package/dist/cloudflare-factory.d.ts +0 -88
  19. package/dist/cloudflare-factory.js +0 -107
  20. package/dist/decorators/env.d.ts +0 -16
  21. package/dist/decorators/env.js +0 -22
  22. package/dist/decorators/queue-consumer.d.ts +0 -23
  23. package/dist/decorators/queue-consumer.js +0 -40
  24. package/dist/decorators/scheduled.d.ts +0 -20
  25. package/dist/decorators/scheduled.js +0 -36
  26. package/dist/env-ref.d.ts +0 -10
  27. package/dist/env-ref.js +0 -13
  28. package/dist/modules/ai.module.d.ts +0 -1
  29. package/dist/modules/ai.module.js +0 -8
  30. package/dist/modules/create-binding-module.d.ts +0 -14
  31. package/dist/modules/create-binding-module.js +0 -42
  32. package/dist/modules/d1.module.d.ts +0 -1
  33. package/dist/modules/d1.module.js +0 -8
  34. package/dist/modules/durable-object.module.d.ts +0 -1
  35. package/dist/modules/durable-object.module.js +0 -8
  36. package/dist/modules/env.module.d.ts +0 -17
  37. package/dist/modules/env.module.js +0 -35
  38. package/dist/modules/hyperdrive.module.d.ts +0 -1
  39. package/dist/modules/hyperdrive.module.js +0 -8
  40. package/dist/modules/kv.module.d.ts +0 -1
  41. package/dist/modules/kv.module.js +0 -8
  42. package/dist/modules/queue.module.d.ts +0 -1
  43. package/dist/modules/queue.module.js +0 -8
  44. package/dist/modules/r2.module.d.ts +0 -1
  45. package/dist/modules/r2.module.js +0 -8
  46. package/dist/modules/vectorize.module.d.ts +0 -1
  47. package/dist/modules/vectorize.module.js +0 -8
  48. package/dist/services/ai.service.d.ts +0 -6
  49. package/dist/services/ai.service.js +0 -33
  50. package/dist/services/d1.service.d.ts +0 -6
  51. package/dist/services/d1.service.js +0 -33
  52. package/dist/services/durable-object.service.d.ts +0 -6
  53. package/dist/services/durable-object.service.js +0 -33
  54. package/dist/services/env.service.d.ts +0 -31
  55. package/dist/services/env.service.js +0 -36
  56. package/dist/services/flagship-flag.driver.d.ts +0 -57
  57. package/dist/services/flagship-flag.driver.js +0 -49
  58. package/dist/services/hyperdrive.service.d.ts +0 -12
  59. package/dist/services/hyperdrive.service.js +0 -51
  60. package/dist/services/kv-cache.store.d.ts +0 -19
  61. package/dist/services/kv-cache.store.js +0 -58
  62. package/dist/services/kv-flag.driver.d.ts +0 -48
  63. package/dist/services/kv-flag.driver.js +0 -62
  64. package/dist/services/kv.service.d.ts +0 -11
  65. package/dist/services/kv.service.js +0 -33
  66. package/dist/services/queue.service.d.ts +0 -6
  67. package/dist/services/queue.service.js +0 -33
  68. package/dist/services/r2.service.d.ts +0 -6
  69. package/dist/services/r2.service.js +0 -33
  70. package/dist/services/vectorize.service.d.ts +0 -6
  71. package/dist/services/vectorize.service.js +0 -33
  72. package/dist/storage/index.d.ts +0 -7
  73. package/dist/storage/index.js +0 -6
  74. package/dist/storage/r2-storage.driver.d.ts +0 -19
  75. package/dist/storage/r2-storage.driver.js +0 -61
  76. package/dist/storage/storage-manager.service.d.ts +0 -16
  77. package/dist/storage/storage-manager.service.js +0 -56
  78. package/dist/storage/storage.controller.d.ts +0 -16
  79. package/dist/storage/storage.controller.js +0 -88
  80. package/dist/storage/storage.module.d.ts +0 -7
  81. package/dist/storage/storage.module.js +0 -37
  82. package/dist/storage/storage.service.d.ts +0 -20
  83. package/dist/storage/storage.service.js +0 -78
  84. package/dist/storage/storage.tokens.d.ts +0 -3
  85. package/dist/storage/storage.tokens.js +0 -2
  86. package/dist/storage/storage.types.d.ts +0 -17
  87. package/dist/storage/storage.types.js +0 -1
  88. package/dist/tokens.d.ts +0 -12
  89. package/dist/tokens.js +0 -12
  90. package/dist/types.d.ts +0 -13
  91. package/dist/types.js +0 -1
  92. package/dist/websocket/broadcast.d.ts +0 -15
  93. package/dist/websocket/broadcast.js +0 -26
  94. package/dist/websocket/cf-room-registry.d.ts +0 -23
  95. package/dist/websocket/cf-room-registry.js +0 -65
  96. package/dist/websocket/cf-ws-client.d.ts +0 -28
  97. package/dist/websocket/cf-ws-client.js +0 -83
  98. package/dist/websocket/cloudflare-websocket.module.d.ts +0 -11
  99. package/dist/websocket/cloudflare-websocket.module.js +0 -27
  100. package/dist/websocket/do-bootstrap.d.ts +0 -24
  101. package/dist/websocket/do-bootstrap.js +0 -55
  102. package/dist/websocket/do-live.d.ts +0 -81
  103. package/dist/websocket/do-live.js +0 -197
  104. package/dist/websocket/do-state.d.ts +0 -35
  105. package/dist/websocket/do-state.js +0 -4
  106. package/dist/websocket/do-websocket-host.d.ts +0 -28
  107. package/dist/websocket/do-websocket-host.js +0 -69
  108. package/dist/websocket/index.d.ts +0 -15
  109. package/dist/websocket/index.js +0 -15
  110. package/dist/websocket/room-id.d.ts +0 -6
  111. package/dist/websocket/room-id.js +0 -12
  112. package/dist/websocket/websocket-routing.d.ts +0 -14
  113. package/dist/websocket/websocket-routing.js +0 -45
  114. package/dist/websocket/websocket.durable-object.d.ts +0 -15
  115. package/dist/websocket/websocket.durable-object.js +0 -83
  116. package/dist/websocket/ws-server-holder.d.ts +0 -16
  117. package/dist/websocket/ws-server-holder.js +0 -34
package/dist/index.d.ts CHANGED
@@ -1,41 +1,622 @@
1
- export { cloudflareAdapter, createCloudflareApp } from './cloudflare-factory';
2
- export type { CreateCloudflareAppOptions } from './cloudflare-factory';
3
- export { CloudflareApplication } from './cloudflare-application';
4
- export type { MountOpenApiOptions } from './cloudflare-application';
5
- export { KVModule } from './modules/kv.module';
6
- export { D1Module } from './modules/d1.module';
7
- export { R2Module } from './modules/r2.module';
8
- export { QueueModule } from './modules/queue.module';
9
- export { DurableObjectModule } from './modules/durable-object.module';
10
- export { AIModule } from './modules/ai.module';
11
- export { VectorizeModule } from './modules/vectorize.module';
12
- export { HyperdriveModule } from './modules/hyperdrive.module';
13
- export { EnvModule } from './modules/env.module';
14
- export { StorageModule, StorageService, StorageManagerService, StorageController, R2StorageDriver, STORAGE_OPTIONS, } from './storage/index';
15
- export type { StorageModuleOptions, DiskConfig, PresignedUrlConfig } from './storage/index';
16
- export { KVService } from './services/kv.service';
17
- export { KVCacheStore } from './services/kv-cache.store';
18
- export { D1Service } from './services/d1.service';
19
- export { R2Service } from './services/r2.service';
20
- export { QueueService } from './services/queue.service';
21
- export { DurableObjectService } from './services/durable-object.service';
22
- export { AIService } from './services/ai.service';
23
- export { VectorizeService } from './services/vectorize.service';
24
- export { HyperdriveService } from './services/hyperdrive.service';
25
- export { EnvService } from './services/env.service';
26
- export { FlagshipFlagDriver, flagshipFlagDriver } from './services/flagship-flag.driver';
27
- export type { FlagshipBinding, FlagshipFlagDriverOptions } from './services/flagship-flag.driver';
28
- export { KvFlagDriver, kvFlagDriver } from './services/kv-flag.driver';
29
- export type { KvFlagDriverOptions } from './services/kv-flag.driver';
30
- export { Env } from './decorators/env';
31
- export { Scheduled } from './decorators/scheduled';
32
- export { QueueConsumer } from './decorators/queue-consumer';
33
- export { VelaWebSocketDurableObject, CloudflareWebSocketModule, broadcastToRoom, } from './websocket/index';
34
- export type { WsGatewayRoute } from './websocket/index';
35
- export { DoCursorLog, durableObjectCursorLog, durableObjectLive, liveInvalidateToRoom, } from './websocket/index';
36
- export type { CfLiveDriver, DurableObjectLiveOptions } from './websocket/index';
37
- export { WebSocketGateway, SubscribeMessage, MessageBody, ConnectedSocket, WebSocketServer, WsException, } from '@velajs/vela/websocket';
38
- export type { WsClient, WsServer, WsResponse, WsMessage, OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect, } from '@velajs/vela/websocket';
39
- export type { CloudflareEnv, ScheduledRegistration, QueueRegistration } from './types';
40
- export type { ScheduledMetadata } from './decorators/scheduled';
41
- export type { QueueConsumerMetadata } from './decorators/queue-consumer';
1
+ import { a as DoPitrId, c as DoPitrUnavailableError, d as isDoPitrUnavailable, f as readDoPitrBookmark, i as DoPitrBookmarkRead, l as VelaDoPitrRpc, n as DoPitrArmOptions, o as DoPitrNamespace, p as CloudflareRoot, r as DoPitrArmResult, s as DoPitrStorage, t as VelaNonceDurableObject, u as armDoPitr } from "./nonce.durable-object-Df3_42Sy.js";
2
+ import { AsyncCacheStore, DynamicModule, InjectionToken, NonceStore, RuntimeAdapter, ThrottlerStore, Type, VelaApplication, VelaMiddlewareHandler, VelaSecurityOptions } from "@velajs/vela";
3
+ import { BroadcastCommand, ConnectedSocket, MessageBody, OnGatewayConnection, OnGatewayDisconnect, OnGatewayInit, SubscribeMessage, WebSocketGateway, WebSocketGatewayOptions, WebSocketServer, WsClient, WsDispatcher, WsException, WsMessage, WsResponse, WsServer } from "@velajs/vela/websocket";
4
+ import { DownloadResult, PresignMethod, PresignedUrlResult, StorageBody, StorageDriver, UploadOptions, UploadResult } from "@velajs/vela/storage";
5
+ import { CommitStamp, CursorLog, InvalidationCommand, LiveDriver, LiveEngine, LiveInvalidationSink, ResumeVerdict } from "@velajs/vela/live";
6
+ import { Context, ExecutionContext } from "hono";
7
+ import { FeatureFlagDriver, FlagContext } from "@velajs/feature-flags";
8
+ //#region src/websocket/room-id.d.ts
9
+ /** Stable, collision-free Durable Object name for one gateway's room. */
10
+ export declare function durableObjectRoomName(gatewayPath: string, roomId: string): string;
11
+ //#endregion
12
+ //#region src/websocket/websocket-routing.d.ts
13
+ interface WsGatewayRoute {
14
+ path: string;
15
+ binding: string;
16
+ options: WebSocketGatewayOptions;
17
+ }
18
+ //#endregion
19
+ //#region src/cloudflare-application.d.ts
20
+ /**
21
+ * Options accepted by {@link CloudflareApplication.mountOpenApi}.
22
+ *
23
+ * Re-exposes vela's `MountOpenApiOptions` type — derived structurally from
24
+ * the underlying `VelaApplication.mountOpenApi` signature so consumers don't
25
+ * have to reach into vela's internal subpaths to type the argument.
26
+ */
27
+ type MountOpenApiOptions = Parameters<VelaApplication['mountOpenApi']>[0];
28
+ /**
29
+ * Wraps VelaApplication with Cloudflare-specific handlers:
30
+ * - `fetch` — HTTP request handler (from Hono)
31
+ * - `scheduled` Cron trigger handler (matches `@Scheduled()` decorators
32
+ * AND vela's own `@Cron()` jobs)
33
+ * - `queue` Queue consumer handler (matches `@QueueConsumer()` decorators)
34
+ * - `mountOpenApi` Serve an OpenAPI document (and optional Scalar UI) on
35
+ * the underlying Hono app
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const app = await createCloudflareApp(AppModule, { env, envToken: ENV });
40
+ * export default {
41
+ * fetch: app.fetch,
42
+ * scheduled: app.scheduled.bind(app),
43
+ * queue: app.queue.bind(app),
44
+ * };
45
+ * ```
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * // Serve OpenAPI docs alongside your routes
50
+ * const app = await createCloudflareApp(AppModule, { env, envToken: ENV });
51
+ * const document = createOpenApiDocument(AppModule);
52
+ * app.mountOpenApi({ document, ui: 'scalar' });
53
+ * // GET /openapi.json -> JSON document
54
+ * // GET /scalar -> Scalar UI (loads from CDN)
55
+ * ```
56
+ */
57
+ export declare class CloudflareApplication<T extends object = object> {
58
+ private app;
59
+ readonly env: T;
60
+ private wsGatewayRoutes;
61
+ constructor(app: VelaApplication, env: T);
62
+ readonly fetch: (request: Request, env: T, ctx?: ExecutionContext) => Promise<Response>;
63
+ getHonoApp(): ReturnType<VelaApplication['getHonoApp']>;
64
+ /**
65
+ * Resolve a provider from the application's DI container (delegates to
66
+ * `VelaApplication.get`). Handy for grabbing a service — e.g. an auth service —
67
+ * to use inside `createCloudflareApp({ middleware: env => [...] })` request middleware,
68
+ * which runs outside the DI request pipeline.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * const app = await createCloudflareApp(AppModule, { env, envToken: ENV });
73
+ * const auth = app.get(BetterAuthService);
74
+ * ```
75
+ */
76
+ readonly get: VelaApplication['get'];
77
+ get entrypoints(): VelaApplication['entrypoints'];
78
+ /**
79
+ * Serve a pre-built OpenAPI document (and optionally a Scalar UI) on the
80
+ * underlying Hono app. Delegates verbatim to `VelaApplication.mountOpenApi`,
81
+ * so the JSON endpoint defaults to `/openapi.json` and the Scalar UI (when
82
+ * opted in) defaults to `/scalar`. Edge-safe — the UI HTML loads Scalar from
83
+ * a CDN at runtime, nothing is bundled server-side.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * import { createOpenApiDocument } from '@velajs/vela';
88
+ *
89
+ * const app = await createCloudflareApp(AppModule, { env, envToken: ENV });
90
+ * const document = createOpenApiDocument(AppModule, {
91
+ * info: { title: 'My API', version: '1.0.0' },
92
+ * });
93
+ * app.mountOpenApi({ document, ui: 'scalar' });
94
+ * // GET /openapi.json -> { openapi: '3.1.0', ... }
95
+ * // GET /scalar -> Scalar UI HTML
96
+ * ```
97
+ */
98
+ mountOpenApi(options: MountOpenApiOptions): this;
99
+ /**
100
+ * @internal — scans instances for `@WebSocketGateway({ path, binding })`
101
+ * upgrade routes. Queue/scheduled handlers are NOT scanned anymore: they
102
+ * come from `app.entrypoints` (`cf:queue` / `cf:scheduled` / `cf:vela-cron`
103
+ * kinds) at dispatch time.
104
+ */
105
+ scanInstances(instances: unknown[]): void;
106
+ /** @internal — upgrade routes discovered from `@WebSocketGateway({ path, binding })`. */
107
+ getWsGatewayRoutes(): WsGatewayRoute[];
108
+ /**
109
+ * Handle Cloudflare scheduled (cron) events.
110
+ * Matches the event's cron expression to `@Scheduled()` and vela `@Cron()`
111
+ * handlers read from `app.entrypoints`; each handler runs inside a fresh
112
+ * request-scoped child (request-scoped providers rebuild per tick).
113
+ */
114
+ scheduled(event: {
115
+ cron: string;
116
+ scheduledTime?: number;
117
+ }, env: T, ctx: {
118
+ waitUntil: (promise: Promise<unknown>) => void;
119
+ }): Promise<void>;
120
+ /**
121
+ * Run one entrypoint handler inside a fresh request scope, through the
122
+ * shared guard → interceptor pipeline (components declared with
123
+ * `@UseGuards`/`@UseInterceptors`/`@UseFilters` on the consumer class or
124
+ * method). HTTP-global components deliberately do NOT apply — an HTTP auth
125
+ * guard has no business rejecting a queue batch. Unclaimed errors rethrow
126
+ * so the platform's retry semantics stay intact.
127
+ */
128
+ private dispatchEntrypoint;
129
+ /**
130
+ * Handle Cloudflare Queue consumer events.
131
+ * Matches the batch queue name to `@QueueConsumer()` handlers read from
132
+ * `app.entrypoints`; each batch is processed inside a fresh request-scoped
133
+ * child (request-scoped providers rebuild per batch — no boot-time captives).
134
+ */
135
+ queue(batch: {
136
+ queue: string;
137
+ messages: readonly unknown[];
138
+ }, env: T, ctx: {
139
+ waitUntil: (promise: Promise<unknown>) => void;
140
+ }): Promise<void>;
141
+ close(signal?: string): Promise<void>;
142
+ }
143
+ //#endregion
144
+ //#region src/cloudflare-factory.d.ts
145
+ interface CloudflareWorkerOptions<T extends object> {
146
+ /** Global typed DI token for the platform's native environment. */
147
+ envToken: InjectionToken<T>;
148
+ globalPrefix?: string;
149
+ security?: VelaSecurityOptions;
150
+ /** Build request middleware from the same typed native environment as DI. */
151
+ middleware?: (env: NoInfer<T>) => VelaMiddlewareHandler[];
152
+ }
153
+ interface CreateCloudflareAppOptions<T extends object> extends CloudflareWorkerOptions<T> {
154
+ /** Supply the platform environment inside fetch/queue/scheduled or a DO constructor. */
155
+ env: NoInfer<T>;
156
+ }
157
+ /** Bind an application to one environment before provider factories and lifecycle hooks. */
158
+ export declare function cloudflareAdapter<T extends object>(options: CreateCloudflareAppOptions<T>): RuntimeAdapter;
159
+ /** Build an application for one native Workers environment. Call inside a platform event. */
160
+ export declare function createCloudflareApp<T extends object>(rootModule: CloudflareRoot<NoInfer<T>>, options: CreateCloudflareAppOptions<T>): Promise<CloudflareApplication<T>>;
161
+ /**
162
+ * Worker entrypoint with one bootstrap per environment identity. Weak keys let
163
+ * obsolete environments and secrets be collected. Concurrent cold events share
164
+ * construction; failed construction is evicted so the next event can retry.
165
+ */
166
+ export declare function createCloudflareWorker<T extends object>(rootModule: CloudflareRoot<NoInfer<T>>, options: CloudflareWorkerOptions<T>): {
167
+ fetch(request: Request, env: T, ctx: ExecutionContext): Promise<Response>;
168
+ scheduled(event: {
169
+ cron: string;
170
+ scheduledTime?: number;
171
+ }, env: T, ctx: {
172
+ waitUntil: (promise: Promise<unknown>) => void;
173
+ }): Promise<void>;
174
+ queue(batch: {
175
+ queue: string;
176
+ messages: readonly unknown[];
177
+ }, env: T, ctx: {
178
+ waitUntil: (promise: Promise<unknown>) => void;
179
+ }): Promise<void>;
180
+ };
181
+ //#endregion
182
+ //#region src/storage/storage.types.d.ts
183
+ /** A named storage disk backed by an R2 bucket binding. */
184
+ interface DiskConfig {
185
+ disk: string;
186
+ /** Native bucket supplied by a typed environment provider factory. */
187
+ bucket: R2Bucket;
188
+ /** Optional root prefix; supports path-template tokens ({date}/{year}/…). */
189
+ root?: string;
190
+ }
191
+ interface PresignedUrlConfig {
192
+ defaultExpiry: number;
193
+ maxExpiry: number;
194
+ }
195
+ interface StorageModuleOptions {
196
+ /** HMAC secret used for signed downloads. */
197
+ secret?: string;
198
+ disks: DiskConfig[];
199
+ defaultDisk: string;
200
+ presignedUrl?: PresignedUrlConfig;
201
+ }
202
+ //#endregion
203
+ //#region src/storage/storage.module.d.ts
204
+ declare const ConfigurableModuleClass: import("@velajs/vela").ConfigurableModuleClassType<StorageModuleOptions, "forRoot", "create", {
205
+ isGlobal?: boolean;
206
+ }>;
207
+ export declare class StorageModule extends ConfigurableModuleClass {}
208
+ //#endregion
209
+ //#region src/storage/r2-storage.driver.d.ts
210
+ interface R2StorageDriverConfig {
211
+ disk: string;
212
+ bucket: R2Bucket;
213
+ /** HMAC secret for presigned URLs (typically env.APP_SECRET). */
214
+ secret?: string;
215
+ }
216
+ /** {@link StorageDriver} over a Cloudflare R2 bucket. */
217
+ export declare class R2StorageDriver implements StorageDriver {
218
+ private readonly config;
219
+ constructor(config: R2StorageDriverConfig);
220
+ upload(body: StorageBody, path: string, options: UploadOptions): Promise<UploadResult>;
221
+ download(path: string): Promise<DownloadResult>;
222
+ delete(path: string): Promise<void>;
223
+ exists(path: string): Promise<boolean>;
224
+ getPresignedUrl(path: string, method: PresignMethod, expiresIn: number): Promise<PresignedUrlResult>;
225
+ }
226
+ //#endregion
227
+ //#region src/storage/storage-manager.service.d.ts
228
+ export declare class StorageManagerService {
229
+ private readonly options;
230
+ constructor(options: StorageModuleOptions);
231
+ hasDisk(disk: string): boolean;
232
+ getDiskConfig(disk: string): DiskConfig;
233
+ getDriver(disk: string): R2StorageDriver;
234
+ }
235
+ //#endregion
236
+ //#region src/storage/storage.service.d.ts
237
+ /**
238
+ * Multi-disk storage facade. Applies each disk's (templated) root, resolves the
239
+ * driver, and validates presign expiry. Injectable anywhere via `StorageService`.
240
+ */
241
+ export declare class StorageService {
242
+ private readonly options;
243
+ private readonly manager;
244
+ constructor(options: StorageModuleOptions, manager: StorageManagerService);
245
+ put(relativePath: string, body: StorageBody, options?: UploadOptions, disk?: string): Promise<UploadResult>;
246
+ get(relativePath: string, disk?: string): Promise<DownloadResult>;
247
+ delete(relativePath: string, disk?: string): Promise<void>;
248
+ exists(relativePath: string, disk?: string): Promise<boolean>;
249
+ url(relativePath: string, method?: PresignMethod, expiresIn?: number, disk?: string): Promise<PresignedUrlResult>;
250
+ private resolveDisk;
251
+ private fullPath;
252
+ private validateExpiry;
253
+ }
254
+ //#endregion
255
+ //#region src/storage/storage.controller.d.ts
256
+ /**
257
+ * Presign-proxy: serves objects for HMAC-signed URLs produced by
258
+ * `StorageService.url()`. R2 has no native presign, so a signed URL points here;
259
+ * this route verifies the signature (+expiry) before streaming the object.
260
+ * The FULL object key (root already applied at sign time) is carried as an
261
+ * opaque base64url query claim. The signature is verified before the claim is
262
+ * decoded exactly once and checked against the configured disk root.
263
+ */
264
+ export declare class StorageController {
265
+ private readonly manager;
266
+ private readonly options;
267
+ constructor(manager: StorageManagerService, options: StorageModuleOptions);
268
+ download(c: Context): Promise<Response>;
269
+ }
270
+ //#endregion
271
+ //#region src/storage/storage.tokens.d.ts
272
+ export declare const STORAGE_OPTIONS: InjectionToken<StorageModuleOptions>;
273
+ //#endregion
274
+ //#region src/services/kv-cache.store.d.ts
275
+ /**
276
+ * Cloudflare KV-backed {@link CacheStore}. Values are JSON-encoded. Intended as
277
+ * the slow tier under a `TieredCacheStore` (memory L1 → KV L2), but usable
278
+ * standalone from a typed environment factory: `new KVCacheStore(env.CACHE)`.
279
+ * Reads return unknown JSON; validate values at the consuming boundary.
280
+ *
281
+ * Note: Cloudflare KV requires `expirationTtl >= 60s`, so sub-minute TTLs are
282
+ * clamped up. Keep short TTLs on the memory tier; use KV for longer-lived entries.
283
+ */
284
+ export declare class KVCacheStore implements AsyncCacheStore {
285
+ private readonly ns;
286
+ constructor(ns: KVNamespace);
287
+ get(key: string): Promise<unknown>;
288
+ set(key: string, value: unknown, ttl?: number): Promise<void>;
289
+ del(key: string): Promise<void>;
290
+ clear(): Promise<void>;
291
+ }
292
+ //#endregion
293
+ //#region src/services/flagship-flag.driver.d.ts
294
+ /**
295
+ * The subset of a Cloudflare **Flagship** binding this driver evaluates against
296
+ * — the four typed value methods. The binding itself returns the supplied
297
+ * `defaultValue` on evaluation errors; transport-level failures reject and are
298
+ * left to propagate (never-throw is the service layer's job, not the driver's).
299
+ *
300
+ * @see https://developers.cloudflare.com/flagship/binding/
301
+ */
302
+ interface FlagshipBinding {
303
+ getBooleanValue(key: string, defaultValue: boolean, context?: FlagContext): Promise<boolean>;
304
+ getStringValue(key: string, defaultValue: string, context?: FlagContext): Promise<string>;
305
+ getNumberValue(key: string, defaultValue: number, context?: FlagContext): Promise<number>;
306
+ getObjectValue(key: string, defaultValue: object, context?: FlagContext): Promise<unknown>;
307
+ }
308
+ interface FlagshipFlagDriverOptions {
309
+ /** Driver name used for `use(name)` / default-driver selection. Default `"flagship"`. */
310
+ name?: string;
311
+ }
312
+ /**
313
+ * {@link FeatureFlagDriver} backed by a Cloudflare Flagship binding.
314
+ *
315
+ * A thin, honest wrapper: each contract method maps 1:1 onto the binding's
316
+ * corresponding value method, forwarding the caller's `fallback` (the binding's
317
+ * `defaultValue`) and evaluation context. The binding resolves the fallback on
318
+ * evaluation errors; anything the binding *rejects* with (e.g. a `remote: true`
319
+ * dev-proxy tunnel dropping) propagates — `@velajs/feature-flags`'s service owns
320
+ * the never-throw guarantee.
321
+ *
322
+ * Build the driver inside a provider factory with the native environment:
323
+ *
324
+ * ```ts
325
+ * FeatureFlagsModule.forRootAsync({
326
+ * inject: [ENV],
327
+ * useFactory: (env: WorkerEnv) => ({ drivers: [flagshipFlagDriver(env.FLAGS)] }),
328
+ * });
329
+ * ```
330
+ *
331
+ * Evaluation ergonomics (the 1:1 binding-method mapping) are ported from the
332
+ * Stratal feature-flags service (MIT, © Temitayo Fadojutimi), reshaped as a
333
+ * bare driver.
334
+ */
335
+ export declare class FlagshipFlagDriver implements FeatureFlagDriver {
336
+ readonly name: string;
337
+ private readonly resolve;
338
+ constructor(binding: FlagshipBinding | (() => FlagshipBinding), options?: FlagshipFlagDriverOptions);
339
+ getBoolean(key: string, fallback: boolean, ctx?: FlagContext): Promise<boolean>;
340
+ getString(key: string, fallback: string, ctx?: FlagContext): Promise<string>;
341
+ getNumber(key: string, fallback: number, ctx?: FlagContext): Promise<number>;
342
+ getObject(key: string, fallback: object, ctx?: FlagContext): Promise<unknown>;
343
+ }
344
+ /** Convenience factory for {@link FlagshipFlagDriver}. */
345
+ export declare function flagshipFlagDriver(binding: FlagshipBinding | (() => FlagshipBinding), options?: FlagshipFlagDriverOptions): FlagshipFlagDriver;
346
+ //#endregion
347
+ //#region src/services/kv-flag.driver.d.ts
348
+ interface KvFlagDriverOptions {
349
+ /** Driver name used for `use(name)` / default-driver selection. Default `"kv"`. */
350
+ name?: string;
351
+ /** Prefix prepended to every flag key before the KV read. Default `""` (none). */
352
+ prefix?: string;
353
+ }
354
+ /**
355
+ * Cloudflare KV-backed {@link FeatureFlagDriver}. Flags are stored as JSON
356
+ * values under an optional key prefix and read with `get(key, 'json')`. Reads
357
+ * are type-checked against the requested type: a missing key or a value of the
358
+ * wrong JSON type returns the caller's `fallback`. KV has no targeting, so the
359
+ * evaluation context is ignored.
360
+ *
361
+ * The driver stays honest — it does **not** swallow errors. A KV failure (or a
362
+ * `SyntaxError` from a malformed stored value) propagates; the never-throw
363
+ * guarantee lives in `@velajs/feature-flags`'s service layer.
364
+ *
365
+ * Placed like {@link KVCacheStore}: construct it in a wiring factory over a
366
+ * resolved {@link KVNamespace}.
367
+ *
368
+ * ```ts
369
+ * FeatureFlagsModule.forRootAsync({
370
+ * inject: [ENV],
371
+ * useFactory: (env: WorkerEnv) => ({ drivers: [new KvFlagDriver(env.CACHE, { prefix: 'flag:' })] }),
372
+ * });
373
+ * ```
374
+ */
375
+ export declare class KvFlagDriver implements FeatureFlagDriver {
376
+ private readonly ns;
377
+ readonly name: string;
378
+ private readonly prefix;
379
+ constructor(ns: KVNamespace, options?: KvFlagDriverOptions);
380
+ getBoolean(key: string, fallback: boolean, _ctx?: FlagContext): Promise<boolean>;
381
+ getString(key: string, fallback: string, _ctx?: FlagContext): Promise<string>;
382
+ getNumber(key: string, fallback: number, _ctx?: FlagContext): Promise<number>;
383
+ getObject(key: string, fallback: object, _ctx?: FlagContext): Promise<unknown>;
384
+ /**
385
+ * Reads and JSON-parses the (prefixed) key, returning the parsed value only
386
+ * when `matches` accepts its type; otherwise the caller's fallback. A missing
387
+ * key reads as `null` → fallback. Read/parse errors are left to propagate.
388
+ */
389
+ private read;
390
+ }
391
+ /** Convenience factory for {@link KvFlagDriver}. */
392
+ export declare function kvFlagDriver(kv: KVNamespace, options?: KvFlagDriverOptions): KvFlagDriver;
393
+ //#endregion
394
+ //#region src/decorators/env.d.ts
395
+ /**
396
+ * Parameter decorator to inject Cloudflare environment bindings.
397
+ *
398
+ * Without arguments, returns the entire `env` object.
399
+ * With a binding name, returns that specific binding.
400
+ *
401
+ * @example
402
+ * ```ts
403
+ * @Get()
404
+ * handle(@Env() env: WorkerEnv) { ... }
405
+ *
406
+ * @Get()
407
+ * handle(@Env('MY_KV') kv: KVNamespace) { ... }
408
+ * ```
409
+ */
410
+ export declare const Env: (data?: string | undefined, ...pipes: import("@velajs/vela").PipeType[]) => ParameterDecorator;
411
+ //#endregion
412
+ //#region src/decorators/scheduled.d.ts
413
+ interface ScheduledMetadata {
414
+ cron: string;
415
+ methodName: string;
416
+ }
417
+ /**
418
+ * Marks a method as a scheduled (cron) handler.
419
+ *
420
+ * @example
421
+ * ```ts
422
+ * @Injectable()
423
+ * class WorkerService {
424
+ * @Scheduled('0 * * * *')
425
+ * async hourlyCron() {
426
+ * console.log('Running hourly');
427
+ * }
428
+ * }
429
+ * ```
430
+ */
431
+ export declare function Scheduled(cron: string): MethodDecorator;
432
+ //#endregion
433
+ //#region src/decorators/queue-consumer.d.ts
434
+ interface QueueConsumerMetadata {
435
+ queueName: string;
436
+ methodName: string;
437
+ }
438
+ /**
439
+ * Marks a method as a queue consumer handler.
440
+ *
441
+ * @example
442
+ * ```ts
443
+ * @Injectable()
444
+ * class WorkerService {
445
+ * @QueueConsumer('email-queue')
446
+ * async processEmails(batch: MessageBatch) {
447
+ * for (const msg of batch.messages) {
448
+ * console.log('Processing:', msg.body);
449
+ * msg.ack();
450
+ * }
451
+ * }
452
+ * }
453
+ * ```
454
+ */
455
+ export declare function QueueConsumer(queueName: string): MethodDecorator;
456
+ //#endregion
457
+ //#region src/websocket/cloudflare-websocket.module.d.ts
458
+ /**
459
+ * Cloudflare counterpart to the core `WebSocketModule.forRoot()`. Import this in
460
+ * your `AppModule` instead: it provides the gateway dispatcher plus a late-bound
461
+ * `WS_SERVER` (`WsServerHolder`) that the WebSocket Durable Object wires to a
462
+ * ctx-backed server per instance. `useClass` ensures a fresh holder per DI
463
+ * container so colocated DO instances never share a server.
464
+ */
465
+ export declare class CloudflareWebSocketModule {
466
+ static forRoot(): DynamicModule;
467
+ }
468
+ //#endregion
469
+ //#region src/websocket/broadcast.d.ts
470
+ interface WsBroadcastStub {
471
+ broadcast(cmd: BroadcastCommand): Promise<void>;
472
+ }
473
+ interface BroadcastNamespace {
474
+ idFromName(name: string): DurableObjectId;
475
+ get(id: DurableObjectId): WsBroadcastStub;
476
+ }
477
+ /**
478
+ * Push to a room from a Worker HTTP handler / cron / queue consumer (server-
479
+ * initiated emit). Resolves the room's Durable Object and calls its `broadcast`
480
+ * RPC method — the same canonical room→DO mapping the upgrade route uses, so it
481
+ * always reaches the DO holding those sockets.
482
+ *
483
+ * @example
484
+ * ```ts
485
+ * // In a controller — ns from the typed Worker environment
486
+ * await broadcastToRoom(ns, '/orgs/:orgId/ws', `org:${id}`, 'order.created', order);
487
+ * ```
488
+ */
489
+ export declare function broadcastToRoom(ns: BroadcastNamespace, gatewayPath: string, room: string, event: string, data?: unknown, options?: {
490
+ exceptIds?: string[];
491
+ maxFrameBytes?: number;
492
+ }): Promise<void>;
493
+ //#endregion
494
+ //#region src/websocket/do-state.d.ts
495
+ /** Structural view of the DO's SQLite handle (`ctx.storage.sql`, requires `new_sqlite_classes`). */
496
+ interface SqlStorageLike {
497
+ exec(query: string, ...bindings: unknown[]): {
498
+ toArray(): Record<string, unknown>[];
499
+ };
500
+ }
501
+ //#endregion
502
+ //#region src/websocket/do-live.d.ts
503
+ /**
504
+ * The durable `CursorLog`: an append-only tag-invalidation log in the DO's
505
+ * SQLite (`__vela_live_log`, AUTOINCREMENT seq = cursor) plus an epoch UUID in
506
+ * `__vela_live_meta`. Because the cursor survives hibernation AND trims (it is
507
+ * read from `sqlite_sequence`, lunora's `ctx-db-cdc.ts` trick), a reconnecting
508
+ * client whose gap the log still covers gets a tiny `resume` instead of a
509
+ * re-run — the real-resume half of the live protocol.
510
+ *
511
+ * Constructed un-initialized at module-composition time (the same app module
512
+ * bootstraps in the Worker AND in each DO); `initDoLive` wires the SQLite
513
+ * handle inside the DO. In the Worker isolate it stays un-initialized — and is
514
+ * never consulted there, because `durableObjectLive()` routes every
515
+ * invalidation to the room DO's log (one log scope per room, exactly the
516
+ * protocol's model).
517
+ */
518
+ export declare class DoCursorLog implements CursorLog {
519
+ private readonly maxRows;
520
+ private sql?;
521
+ private epoch?;
522
+ constructor(maxRows?: number);
523
+ /** @internal — called by `initDoLive` with the DO's `ctx.storage.sql`. */
524
+ _initialize(sql: SqlStorageLike): void;
525
+ append(tags: string[]): CommitStamp;
526
+ current(): CommitStamp;
527
+ evaluateResume(sinceCursor: number, sinceEpoch: string, subscriptionTags: string[]): ResumeVerdict;
528
+ private assertReady;
529
+ }
530
+ interface DurableObjectLiveOptions {
531
+ /** Native, RPC-typed namespace supplied by the application's environment. */
532
+ namespace: LiveNamespace;
533
+ /** Exact `@WebSocketGateway()` path sharing this room/log namespace. */
534
+ gatewayPath: string;
535
+ /** Room used when an invalidation names none. Matches the client default. */
536
+ defaultRoom?: string;
537
+ }
538
+ interface LiveInvalidateStub {
539
+ invalidate(cmd: InvalidationCommand): Promise<CommitStamp | undefined>;
540
+ }
541
+ /** Only the native namespace operations required for live invalidation. */
542
+ interface LiveNamespace {
543
+ idFromName(name: string): DurableObjectId;
544
+ get(id: DurableObjectId): LiveInvalidateStub;
545
+ }
546
+ /** One driver per application; construct from a LiveModule driver factory. */
547
+ declare class CfLiveDriver implements LiveDriver {
548
+ private readonly options;
549
+ readonly kind = "durable-object";
550
+ private sink;
551
+ private localMode;
552
+ constructor(options: DurableObjectLiveOptions);
553
+ bind(sink: LiveInvalidationSink): void;
554
+ /** @internal — a DO dispatches to its own engine and SQLite log. */
555
+ _setLocalMode(): void;
556
+ dispatch(cmd: InvalidationCommand): Promise<CommitStamp | undefined> | CommitStamp | undefined;
557
+ }
558
+ /** Use in LiveModule.forRootAsync: driver: () => durableObjectLive({ namespace: env.ROOMS, ... }). */
559
+ export declare function durableObjectLive(options: DurableObjectLiveOptions): CfLiveDriver;
560
+ /** Ergonomic alias: the log option for `LiveModule.forRoot` on Cloudflare. */
561
+ export declare function durableObjectCursorLog(maxRows?: number): DoCursorLog;
562
+ /**
563
+ * Invalidate live tags in a room from a Worker (controller / cron / queue
564
+ * consumer) — the live sibling of `broadcastToRoom`. Returns the room log
565
+ * scope's commit stamp for `Vela-Commit-Cursor` stamping.
566
+ */
567
+ export declare function liveInvalidateToRoom(ns: LiveNamespace, gatewayPath: string, room: string, tags: string[]): Promise<CommitStamp | undefined>;
568
+ //#endregion
569
+ //#region src/rate-limit/cloudflare-rate-limit.store.d.ts
570
+ /** The deliberately small surface exposed by a Workers Rate Limiting binding. */
571
+ interface CloudflareRateLimitBinding {
572
+ limit(input: {
573
+ key: string;
574
+ }): Promise<{
575
+ success: boolean;
576
+ }>;
577
+ }
578
+ interface CloudflareRateLimitStoreOptions {
579
+ /** Must match the binding's configured `simple.limit`. */
580
+ limit: number;
581
+ /** Must match the binding's configured `simple.period`. */
582
+ periodSeconds: 10 | 60;
583
+ /** Bound attacker-influenced tracking keys before calling the platform. */
584
+ maxKeyBytes?: number;
585
+ }
586
+ /**
587
+ * Adapt a Cloudflare Workers Rate Limiting binding to Vela's throttler store.
588
+ *
589
+ * The platform binding makes the allow/deny decision. It does not expose exact
590
+ * counters or reset timestamps, so this adapter intentionally omits `remaining`.
591
+ */
592
+ export declare function cloudflareRateLimitStore(binding: CloudflareRateLimitBinding | (() => CloudflareRateLimitBinding), options: CloudflareRateLimitStoreOptions): ThrottlerStore;
593
+ //#endregion
594
+ //#region src/nonce/durable-object-nonce.store.d.ts
595
+ /** The generated Workers binding type for {@link VelaNonceDurableObject}. */
596
+ type DurableObjectNonceNamespace = DurableObjectNamespace<VelaNonceDurableObject>;
597
+ interface DurableObjectNonceStoreOptions {
598
+ /**
599
+ * Stable application/environment boundary (for example `billing-api:prod`).
600
+ * Claims are globally single-use inside this namespace and isolated from all
601
+ * other application namespaces. It must be non-empty, canonical, and at most
602
+ * 128 UTF-8 bytes.
603
+ */
604
+ appNamespace: string;
605
+ /**
606
+ * Resolve the Workers Durable Object namespace at claim time. The resolver is
607
+ * intentionally not cached so request-scoped env/binding references stay safe.
608
+ */
609
+ binding: () => DurableObjectNonceNamespace | Promise<DurableObjectNonceNamespace>;
610
+ }
611
+ /**
612
+ * Strict, cross-isolate {@link NonceStore} backed by one SQLite Durable Object
613
+ * per explicit application namespace.
614
+ *
615
+ * Invalid input, an unavailable/malformed binding, RPC failure, or a malformed
616
+ * RPC result all deny the claim (`false`). Only the literal boolean `true` from
617
+ * the Durable Object is accepted.
618
+ */
619
+ export declare function durableObjectNonceStore(options: DurableObjectNonceStoreOptions): NonceStore;
620
+ //#endregion
621
+ export { type BroadcastNamespace, type CfLiveDriver, type CloudflareRateLimitBinding, type CloudflareRateLimitStoreOptions, type CloudflareRoot, type CloudflareWorkerOptions, ConnectedSocket, type CreateCloudflareAppOptions, type DiskConfig, type DoPitrArmOptions, type DoPitrArmResult, type DoPitrBookmarkRead, type DoPitrId, type DoPitrNamespace, type DoPitrStorage, DoPitrUnavailableError, type DurableObjectLiveOptions, type DurableObjectNonceNamespace, type DurableObjectNonceStoreOptions, type FlagshipBinding, type FlagshipFlagDriverOptions, type KvFlagDriverOptions, type LiveNamespace, MessageBody, type MountOpenApiOptions, type OnGatewayConnection, type OnGatewayDisconnect, type OnGatewayInit, type PresignedUrlConfig, type QueueConsumerMetadata, type ScheduledMetadata, type StorageModuleOptions, SubscribeMessage, type VelaDoPitrRpc, WebSocketGateway, WebSocketServer, type WsClient, WsException, type WsGatewayRoute, type WsMessage, type WsResponse, type WsServer, armDoPitr, isDoPitrUnavailable, readDoPitrBookmark };
622
+ //# sourceMappingURL=index.d.ts.map