@velajs/cloudflare 1.30.0 → 1.32.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/CHANGELOG.md +174 -0
- package/README.md +407 -77
- package/dist/bindings.js +93 -0
- package/dist/bindings.js.map +1 -0
- package/dist/cloudflare-application-CXDy9C1R.d.ts +199 -0
- package/dist/cloudflare-application.js +15 -34
- package/dist/cloudflare-application.js.map +1 -1
- package/dist/cloudflare-factory-CuFNUJJD.d.ts +241 -0
- package/dist/cloudflare-factory.js +227 -38
- package/dist/cloudflare-factory.js.map +1 -1
- package/dist/diagnostics.js +18 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/durable-object/boot.js +76 -0
- package/dist/durable-object/boot.js.map +1 -0
- package/dist/durable-object/host-dispatch.js +134 -0
- package/dist/durable-object/host-dispatch.js.map +1 -0
- package/dist/durable-object/host-methods.js +47 -0
- package/dist/durable-object/host-methods.js.map +1 -0
- package/dist/durable-object/tokens.js +17 -0
- package/dist/durable-object/tokens.js.map +1 -0
- package/dist/durable-object/vela-durable-object.js +121 -0
- package/dist/durable-object/vela-durable-object.js.map +1 -0
- package/dist/durable-objects.d.ts +136 -10
- package/dist/durable-objects.js +3 -1
- package/dist/email/email-dispatch.js +65 -0
- package/dist/email/email-dispatch.js.map +1 -0
- package/dist/email/on-email.js +57 -0
- package/dist/email/on-email.js.map +1 -0
- package/dist/email.d.ts +51 -0
- package/dist/email.js +3 -0
- package/dist/entrypoint/vela-entrypoint.js +160 -0
- package/dist/entrypoint/vela-entrypoint.js.map +1 -0
- package/dist/entrypoints.d.ts +93 -0
- package/dist/entrypoints.js +2 -0
- package/dist/host/host-invoker.js +276 -0
- package/dist/host/host-invoker.js.map +1 -0
- package/dist/host/host-members.js +73 -0
- package/dist/host/host-members.js.map +1 -0
- package/dist/host-members-DECj_4yz.d.ts +13 -0
- package/dist/index.d.ts +211 -445
- package/dist/index.js +8 -13
- package/dist/{nonce.durable-object-Ci9AGssY.d.ts → nonce.durable-object-Bg1e0BMD.d.ts} +1 -11
- package/dist/platform.js +22 -0
- package/dist/platform.js.map +1 -0
- package/dist/queue/cloudflare-queues.js +7 -7
- package/dist/queue/cloudflare-queues.js.map +1 -1
- package/dist/rate-limit/cloudflare-rate-limit.store.js +66 -27
- package/dist/rate-limit/cloudflare-rate-limit.store.js.map +1 -1
- package/dist/root-module.js +19 -0
- package/dist/root-module.js.map +1 -0
- package/dist/rpc/entrypoint-error.js +145 -0
- package/dist/rpc/entrypoint-error.js.map +1 -0
- package/dist/schedule-diagnostics.js +8 -15
- package/dist/schedule-diagnostics.js.map +1 -1
- package/dist/services/kv-cache.store.js +33 -7
- package/dist/services/kv-cache.store.js.map +1 -1
- package/dist/storage/r2-storage.js +30 -0
- package/dist/storage/r2-storage.js.map +1 -0
- package/dist/storage.d.ts +28 -0
- package/dist/storage.js +2 -0
- package/dist/tail/on-tail.js +46 -0
- package/dist/tail/on-tail.js.map +1 -0
- package/dist/tail/tail-dispatch.js +67 -0
- package/dist/tail/tail-dispatch.js.map +1 -0
- package/dist/tail.d.ts +39 -0
- package/dist/tail.js +2 -0
- package/dist/testing.d.ts +148 -0
- package/dist/testing.js +188 -0
- package/dist/testing.js.map +1 -0
- package/dist/websocket/binding-gateways.js +33 -0
- package/dist/websocket/binding-gateways.js.map +1 -0
- package/dist/websocket/cf-room-registry.js +3 -1
- package/dist/websocket/cf-room-registry.js.map +1 -1
- package/dist/websocket/do-bootstrap.js +64 -40
- package/dist/websocket/do-bootstrap.js.map +1 -1
- package/dist/websocket/do-live.js +49 -90
- package/dist/websocket/do-live.js.map +1 -1
- package/dist/websocket/do-state.js.map +1 -1
- package/dist/websocket/live-driver.js +149 -0
- package/dist/websocket/live-driver.js.map +1 -0
- package/dist/websocket/room-id.js +11 -1
- package/dist/websocket/room-id.js.map +1 -1
- package/dist/websocket/websocket.durable-object.js +51 -18
- package/dist/websocket/websocket.durable-object.js.map +1 -1
- package/dist/websocket/worker-transport.js +80 -0
- package/dist/websocket/worker-transport.js.map +1 -0
- package/dist/worker-events.js +49 -0
- package/dist/worker-events.js.map +1 -0
- package/dist/workflow/vela-workflow.js +104 -0
- package/dist/workflow/vela-workflow.js.map +1 -0
- package/dist/workflows.d.ts +82 -0
- package/dist/workflows.js +2 -0
- package/package.json +39 -6
- package/dist/_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/decorate.js +0 -9
- package/dist/_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/decorateMetadata.js +0 -6
- package/dist/_virtual/_@oxc-project_runtime@0.150.0/helpers/esm/decorateParam.js +0 -8
- package/dist/storage/r2-storage.driver.js +0 -67
- package/dist/storage/r2-storage.driver.js.map +0 -1
- package/dist/storage/storage-key-claim.js +0 -74
- package/dist/storage/storage-key-claim.js.map +0 -1
- package/dist/storage/storage-manager.service.js +0 -38
- package/dist/storage/storage-manager.service.js.map +0 -1
- package/dist/storage/storage.controller.js +0 -64
- package/dist/storage/storage.controller.js.map +0 -1
- package/dist/storage/storage.module.js +0 -25
- package/dist/storage/storage.module.js.map +0 -1
- package/dist/storage/storage.service.js +0 -64
- package/dist/storage/storage.service.js.map +0 -1
- package/dist/storage/storage.tokens.js +0 -7
- package/dist/storage/storage.tokens.js.map +0 -1
- package/dist/websocket/broadcast.js +0 -32
- package/dist/websocket/broadcast.js.map +0 -1
- package/dist/websocket/cloudflare-websocket.module.js +0 -25
- package/dist/websocket/cloudflare-websocket.module.js.map +0 -1
- package/dist/websocket/websocket-routing.js +0 -133
- package/dist/websocket/websocket-routing.js.map +0 -1
- package/dist/websocket/ws-server-holder.js +0 -38
- package/dist/websocket/ws-server-holder.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "./vela-env-DFvyoNT3.js";
|
|
2
|
-
import { a as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { a as ScheduledEvent, i as CloudflareScheduledEvent, n as MountOpenApiOptions, r as CLOUDFLARE_SCHEDULED_EVENT, t as CloudflareApplication } from "./cloudflare-application-CXDy9C1R.js";
|
|
3
|
+
import { _ as defineCloudflareApp, a as CloudflareApp, c as CloudflareEntrypointDescriptor, d as CloudflareWorkerOptions, f as CloudflareWorkflowDescriptor, g as createCloudflareWorker, h as createCloudflareApp, i as CLOUDFLARE_WORKFLOW, l as CloudflareWorker, m as cloudflareAdapter, n as CLOUDFLARE_ENTRYPOINT, o as CloudflareAppOptions, p as CreateCloudflareAppOptions, r as CLOUDFLARE_WORKER, s as CloudflareDurableObjectDescriptor, t as CLOUDFLARE_DURABLE_OBJECT, u as CloudflareWorkerDescriptor, v as isCloudflareApp, y as CloudflareRoot } from "./cloudflare-factory-CuFNUJJD.js";
|
|
4
|
+
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, r as DoPitrArmResult, s as DoPitrStorage, t as VelaNonceDurableObject, u as armDoPitr } from "./nonce.durable-object-Bg1e0BMD.js";
|
|
5
|
+
import { DynamicModule, Type, VelaEnv } from "@velajs/vela";
|
|
6
|
+
import { Binding, BindingRef, EnvFactory, RuntimeAdapter } from "@velajs/vela/module-kit";
|
|
5
7
|
import { CommitStamp, CursorLog, InvalidationCommand, LiveDriver, LiveInvalidationSink, ResumeVerdict } from "@velajs/vela/live";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { DownloadResult, PresignMethod, PresignedUrlResult, StorageBody, StorageDriver, UploadOptions, UploadResult } from "@velajs/vela/storage";
|
|
9
|
-
import { AsyncCacheStore, CacheEntry, CacheEntryReader, CacheEntryWriter, CacheInvalidationStore } from "@velajs/vela/cache";
|
|
8
|
+
import { BroadcastCommand } from "@velajs/vela/websocket";
|
|
9
|
+
import { CacheEntry, CacheEntryReader, CacheEntryWriter, CacheInvalidationStore, CacheStore } from "@velajs/vela/cache";
|
|
10
10
|
import { FeatureFlagDriver, FlagContext } from "@velajs/feature-flags";
|
|
11
11
|
import { ThrottlerStore } from "@velajs/vela/throttler";
|
|
12
12
|
import { NonceStore } from "@velajs/vela/security";
|
|
@@ -14,360 +14,87 @@ import { NonceStore } from "@velajs/vela/security";
|
|
|
14
14
|
/** Stable, collision-free Durable Object name for one gateway's room. */
|
|
15
15
|
export declare function durableObjectRoomName(gatewayPath: string, roomId: string): string;
|
|
16
16
|
//#endregion
|
|
17
|
-
//#region src/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The event a Worker's `scheduled()` export receives. The native
|
|
29
|
-
* `ScheduledController` satisfies it; direct calls (tests, scripts) may omit
|
|
30
|
-
* `scheduledTime`, which then defaults to the current time, and `noRetry`.
|
|
31
|
-
*/
|
|
32
|
-
interface ScheduledEvent {
|
|
33
|
-
readonly cron: string;
|
|
34
|
-
readonly scheduledTime?: number;
|
|
35
|
-
noRetry?(): void;
|
|
17
|
+
//#region src/rpc/entrypoint-error.d.ts
|
|
18
|
+
/** What a failed JS-RPC call of a Vela entrypoint carries across the RPC boundary. */
|
|
19
|
+
interface EntrypointErrorInit {
|
|
20
|
+
/** An HTTP error status, 400–599. */
|
|
21
|
+
readonly status: number;
|
|
22
|
+
/** A stable error code, such as `not_found` or `internal`. */
|
|
23
|
+
readonly code: string;
|
|
24
|
+
readonly message: string;
|
|
25
|
+
/** Client-safe details of a client fault (4xx), such as validation issues. */
|
|
26
|
+
readonly details?: unknown;
|
|
36
27
|
}
|
|
37
|
-
/** The Cloudflare trigger behind the current scheduled invocation. */
|
|
38
|
-
interface CloudflareScheduledEvent {
|
|
39
|
-
/** The trigger's exact cron string; it equals the invocation's `expression`. */
|
|
40
|
-
readonly cron: string;
|
|
41
|
-
/** The platform's scheduled time in Unix milliseconds. */
|
|
42
|
-
readonly scheduledTime: number;
|
|
43
|
-
/**
|
|
44
|
-
* Ask Cloudflare not to retry this trigger if the invocation fails. Already
|
|
45
|
-
* bound to the native controller, so it can be passed around or destructured.
|
|
46
|
-
* A no-op for direct calls that supplied no controller.
|
|
47
|
-
*/
|
|
48
|
-
readonly noRetry: () => void;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Request-scoped Cloudflare view of the scheduled trigger, seeded into each
|
|
52
|
-
* `@Cron` job's invocation scope by the Cloudflare adapter. Inject it where a
|
|
53
|
-
* job needs platform controls such as `noRetry()`; the job's argument stays
|
|
54
|
-
* the portable `ScheduleInvocation`. It resolves only inside a scheduled
|
|
55
|
-
* invocation; resolving it anywhere else throws. A cron job fired on demand
|
|
56
|
-
* (Studio's run-now) receives a synthetic event: `cron` is the job's
|
|
57
|
-
* expression and `noRetry()` does nothing.
|
|
58
|
-
*
|
|
59
|
-
* The token provides itself as request-scoped in every container, so a class
|
|
60
|
-
* that injects it is request-scoped wherever the graph boots (a Worker, a
|
|
61
|
-
* Durable Object, the CLI or a testing module) and is built only for an
|
|
62
|
-
* invocation, never at bootstrap.
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```ts
|
|
66
|
-
* @Injectable({ scope: Scope.REQUEST })
|
|
67
|
-
* class Reports {
|
|
68
|
-
* constructor(@Inject(CLOUDFLARE_SCHEDULED_EVENT) private readonly trigger: CloudflareScheduledEvent) {}
|
|
69
|
-
*
|
|
70
|
-
* @Cron('0 3 * * *', { dialect: 'cloudflare' })
|
|
71
|
-
* async nightly(tick: CronInvocation) {
|
|
72
|
-
* if (!(await this.upstreamAvailable(tick.signal))) this.trigger.noRetry();
|
|
73
|
-
* }
|
|
74
|
-
* }
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
export declare const CLOUDFLARE_SCHEDULED_EVENT: InjectionToken<CloudflareScheduledEvent>;
|
|
78
|
-
//#endregion
|
|
79
|
-
//#region src/cloudflare-application.d.ts
|
|
80
28
|
/**
|
|
81
|
-
*
|
|
29
|
+
* The one error the JS-RPC methods of a Vela entrypoint reject with: a
|
|
30
|
+
* Durable Object from `VelaDurableObject()` and a service entrypoint from
|
|
31
|
+
* `VelaEntrypoint()`. The entrypoint reports the original error first, then
|
|
32
|
+
* renders it as HTTP renders a response with server bodies redacted
|
|
33
|
+
* (`renderHttpError`): a 4xx `HttpException` keeps its code, message and
|
|
34
|
+
* details; a branded `VelaError` keeps its code and message at any status, and
|
|
35
|
+
* its details below 500; a 5xx `HttpException` becomes its status's code and
|
|
36
|
+
* title; an unknown error becomes `500 internal "Internal Server Error"`. A 4xx
|
|
37
|
+
* `HttpException` constructed with an object response keeps only its status
|
|
38
|
+
* (code `error`) unless that object is a canonical `{ error: { code, message,
|
|
39
|
+
* details } }` body. Only these own properties cross the RPC boundary: no stack
|
|
40
|
+
* frames, causes or other fields of the original.
|
|
82
41
|
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* expression is the trigger's exact string)
|
|
93
|
-
* - `queue` — Queue consumer handler (`@QueueConsumer()` by physical queue,
|
|
94
|
-
* then `QueueModule`'s native consumer)
|
|
95
|
-
* - `mountOpenApi` — Serve an OpenAPI document (and optional Scalar UI) on
|
|
96
|
-
* the underlying Hono app
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```ts
|
|
100
|
-
* const app = await createCloudflareApp(AppModule, { env });
|
|
101
|
-
* export default {
|
|
102
|
-
* fetch: app.fetch,
|
|
103
|
-
* scheduled: app.scheduled.bind(app),
|
|
104
|
-
* queue: app.queue.bind(app),
|
|
105
|
-
* };
|
|
106
|
-
* ```
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* ```ts
|
|
110
|
-
* // Serve OpenAPI docs alongside your routes
|
|
111
|
-
* const app = await createCloudflareApp(AppModule, { env });
|
|
112
|
-
* const document = createOpenApiDocument(AppModule);
|
|
113
|
-
* app.mountOpenApi({ document, ui: 'scalar' });
|
|
114
|
-
* // GET /openapi.json -> JSON document
|
|
115
|
-
* // GET /scalar -> Scalar UI (loads from CDN)
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
export declare class CloudflareApplication {
|
|
119
|
-
#private;
|
|
120
|
-
readonly env: VelaEnv;
|
|
121
|
-
constructor(app: VelaApplication, env: VelaEnv);
|
|
122
|
-
readonly fetch: (request: Request, env: VelaEnv, ctx?: ExecutionContext) => Promise<Response>;
|
|
123
|
-
getHonoApp(): ReturnType<VelaApplication['getHonoApp']>;
|
|
124
|
-
/**
|
|
125
|
-
* Resolve a provider from the application's DI container (delegates to
|
|
126
|
-
* `VelaApplication.get`). Handy for grabbing a service — e.g. an auth service —
|
|
127
|
-
* to use inside `createCloudflareApp({ middleware: env => [...] })` request middleware,
|
|
128
|
-
* which runs outside the DI request pipeline.
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
* ```ts
|
|
132
|
-
* const app = await createCloudflareApp(AppModule, { env });
|
|
133
|
-
* const auth = app.get(BetterAuthService);
|
|
134
|
-
* ```
|
|
135
|
-
*/
|
|
136
|
-
readonly get: VelaApplication['get'];
|
|
137
|
-
get entrypoints(): VelaApplication['entrypoints'];
|
|
138
|
-
/**
|
|
139
|
-
* Serve a pre-built OpenAPI document (and optionally a Scalar UI) on the
|
|
140
|
-
* underlying Hono app. Delegates verbatim to `VelaApplication.mountOpenApi`,
|
|
141
|
-
* so the JSON endpoint defaults to `/openapi.json` and the Scalar UI (when
|
|
142
|
-
* opted in) defaults to `/scalar`. Edge-safe — the UI HTML loads Scalar from
|
|
143
|
-
* a CDN at runtime, nothing is bundled server-side.
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* ```ts
|
|
147
|
-
* import { createOpenApiDocument } from '@velajs/vela/openapi';
|
|
148
|
-
*
|
|
149
|
-
* const app = await createCloudflareApp(AppModule, { env });
|
|
150
|
-
* const document = createOpenApiDocument(AppModule, {
|
|
151
|
-
* info: { title: 'My API', version: '1.0.0' },
|
|
152
|
-
* });
|
|
153
|
-
* app.mountOpenApi({ document, ui: 'scalar' });
|
|
154
|
-
* // GET /openapi.json -> { openapi: '3.1.0', ... }
|
|
155
|
-
* // GET /scalar -> Scalar UI HTML
|
|
156
|
-
* ```
|
|
157
|
-
*/
|
|
158
|
-
mountOpenApi(options: MountOpenApiOptions): this;
|
|
159
|
-
/**
|
|
160
|
-
* @internal Upgrade routes come from validated gateway entrypoints, including
|
|
161
|
-
* request-scoped gateways without a bootstrap instance. Retain the instance
|
|
162
|
-
* scan for legacy applications that only declare forwarding metadata.
|
|
163
|
-
*/
|
|
164
|
-
scanInstances(instances: unknown[]): void;
|
|
165
|
-
/** @internal — upgrade routes discovered from the application's gateways. */
|
|
166
|
-
getWsGatewayRoutes(): WsGatewayRoute[];
|
|
167
|
-
/**
|
|
168
|
-
* Handle a Cloudflare cron trigger. Runs every core `@Cron()` job whose
|
|
169
|
-
* expression is exactly `event.cron` (the trigger string is compared as
|
|
170
|
-
* delivered, never re-evaluated) through `invokeScheduledJob`, the dispatch
|
|
171
|
-
* primitive every runtime shares. Each job receives only its
|
|
172
|
-
* `ScheduleInvocation`, runs in a fresh invocation scope seeded with
|
|
173
|
-
* {@link CLOUDFLARE_SCHEDULED_EVENT}, and honors signed `ScheduleModule`
|
|
174
|
-
* dispatch. The trigger settles after every matching job and its managed
|
|
175
|
-
* work (`EXECUTION_LIFETIME.waitUntil`/`defer`) settle; failures reject it.
|
|
176
|
-
*/
|
|
177
|
-
scheduled(event: ScheduledEvent, env: VelaEnv, _ctx?: {
|
|
178
|
-
waitUntil: (promise: Promise<unknown>) => void;
|
|
179
|
-
}): Promise<void>;
|
|
180
|
-
/**
|
|
181
|
-
* Run one queue consumer inside a fresh request scope, through the shared
|
|
182
|
-
* guard → interceptor pipeline (components declared with
|
|
183
|
-
* `@UseGuards`/`@UseInterceptors`/`@UseFilters` on the consumer class or
|
|
184
|
-
* method). HTTP-global components deliberately do NOT apply — an HTTP auth
|
|
185
|
-
* guard has no business rejecting a queue batch. Unclaimed errors are
|
|
186
|
-
* reported once (`QueueModule`'s consumer reports its own) and rethrow so
|
|
187
|
-
* the platform's retry semantics stay intact.
|
|
188
|
-
*/
|
|
189
|
-
private dispatchEntrypoint;
|
|
190
|
-
/**
|
|
191
|
-
* Handle Cloudflare Queue consumer events. `@QueueConsumer()` handlers read
|
|
192
|
-
* from `app.entrypoints` claim a batch by its physical queue name and
|
|
193
|
-
* receive it whole. A batch no handler claims goes to `QueueModule`'s native
|
|
194
|
-
* consumer (`cloudflareQueues()` from `@velajs/cloudflare/queues`), which
|
|
195
|
-
* routes each job by its logical queue. Each dispatch runs inside a fresh
|
|
196
|
-
* request-scoped child (request-scoped providers rebuild per batch — no
|
|
197
|
-
* boot-time captives). A batch nothing claims rejects: resolving would let
|
|
198
|
-
* Cloudflare acknowledge every message implicitly.
|
|
199
|
-
*/
|
|
200
|
-
queue(batch: {
|
|
201
|
-
queue: string;
|
|
202
|
-
messages: readonly unknown[];
|
|
203
|
-
}, env: VelaEnv, ctx: {
|
|
204
|
-
waitUntil: (promise: Promise<unknown>) => void;
|
|
205
|
-
}): Promise<void>;
|
|
206
|
-
/**
|
|
207
|
-
* A raw `@QueueConsumer` owns its physical queue's batches and must not carry
|
|
208
|
-
* jobs of a queue registered with `QueueModule`: those reach their
|
|
209
|
-
* `@Processor` only if the raw handler dispatches them itself, while
|
|
210
|
-
* `cloudflareQueues()` delivers registered queues. Warn once per physical and
|
|
211
|
-
* logical queue (unless diagnostics are silent); the raw consumer still
|
|
212
|
-
* receives and settles the batch.
|
|
213
|
-
*/
|
|
214
|
-
private warnRawJobs;
|
|
215
|
-
/**
|
|
216
|
-
* Abort the signals of scheduled jobs still running, wait for them and their
|
|
217
|
-
* managed work to settle, then close the application.
|
|
218
|
-
*/
|
|
219
|
-
close(signal?: string): Promise<void>;
|
|
220
|
-
}
|
|
221
|
-
//#endregion
|
|
222
|
-
//#region src/cloudflare-factory.d.ts
|
|
223
|
-
interface CloudflareWorkerOptions {
|
|
224
|
-
globalPrefix?: string;
|
|
225
|
-
security?: VelaSecurityOptions;
|
|
226
|
-
/** Build request middleware from the same native environment DI receives as ENV. */
|
|
227
|
-
middleware?: (env: VelaEnv) => VelaMiddlewareHandler[];
|
|
228
|
-
/** Further runtime adapters, composed after the Cloudflare adapter for each application. */
|
|
229
|
-
adapters?: RuntimeAdapter[];
|
|
230
|
-
}
|
|
231
|
-
interface CreateCloudflareAppOptions extends CloudflareWorkerOptions {
|
|
232
|
-
/** Supply the platform environment inside fetch/queue/scheduled or a DO constructor. */
|
|
233
|
-
env: VelaEnv;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Bind an application to one environment: seeded as the global ENV before
|
|
237
|
-
* provider factories and lifecycle hooks, and asserted on every request. The
|
|
238
|
-
* adapter also supplies the `InternalDispatcher` transport, so signed queue and
|
|
239
|
-
* schedule dispatch re-enter this application's routes, and reports schedule
|
|
240
|
-
* declarations a cron trigger cannot honor through the diagnostics policy.
|
|
241
|
-
*/
|
|
242
|
-
export declare function cloudflareAdapter(options: {
|
|
243
|
-
env: VelaEnv;
|
|
244
|
-
}): RuntimeAdapter;
|
|
245
|
-
/**
|
|
246
|
-
* Build an application for one native Workers environment. Call inside a platform event.
|
|
247
|
-
* The root is static: a module class or a `DynamicModule` declared at module scope.
|
|
248
|
-
* Read bindings in providers (`@InjectEnv()`) and module factories
|
|
249
|
-
* (`forRootAsync({ inject: [ENV], useFactory })`), which run for each application.
|
|
42
|
+
* workerd rebuilds it on the caller's side as a plain `Error` with the same
|
|
43
|
+
* `name`, `status`, `code`, `message` and `details`; read it with
|
|
44
|
+
* {@link isEntrypointError}. That needs a Worker `compatibility_date` of
|
|
45
|
+
* 2026-04-21 or later, or the `enhanced_error_serialization` compatibility
|
|
46
|
+
* flag: before it, workerd delivers only an `Error` whose message is
|
|
47
|
+
* `EntrypointError: <message>`, without the status, code or details
|
|
48
|
+
* (`vela deploy check` warns about it). A host may throw one itself, for
|
|
49
|
+
* example to pass on another entrypoint's failure: a 4xx one keeps its code,
|
|
50
|
+
* message and details, a 5xx one only its status.
|
|
250
51
|
*/
|
|
251
|
-
export declare
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
export declare function createCloudflareWorker(rootModule: CloudflareRoot, options?: CloudflareWorkerOptions): {
|
|
258
|
-
fetch(request: Request, env: VelaEnv, ctx: ExecutionContext): Promise<Response>;
|
|
259
|
-
scheduled(event: ScheduledEvent, env: VelaEnv, ctx?: {
|
|
260
|
-
waitUntil: (promise: Promise<unknown>) => void;
|
|
261
|
-
}): Promise<void>;
|
|
262
|
-
queue(batch: {
|
|
263
|
-
queue: string;
|
|
264
|
-
messages: readonly unknown[];
|
|
265
|
-
}, env: VelaEnv, ctx: {
|
|
266
|
-
waitUntil: (promise: Promise<unknown>) => void;
|
|
267
|
-
}): Promise<void>;
|
|
268
|
-
};
|
|
269
|
-
//#endregion
|
|
270
|
-
//#region src/storage/storage.types.d.ts
|
|
271
|
-
/** A named storage disk backed by an R2 bucket binding. */
|
|
272
|
-
interface DiskConfig {
|
|
273
|
-
disk: string;
|
|
274
|
-
/** Native bucket supplied by a typed environment provider factory. */
|
|
275
|
-
bucket: R2Bucket;
|
|
276
|
-
/** Optional root prefix; supports path-template tokens ({date}/{year}/…). */
|
|
277
|
-
root?: string;
|
|
52
|
+
export declare class EntrypointError extends Error implements EntrypointErrorInit {
|
|
53
|
+
readonly name = "EntrypointError";
|
|
54
|
+
readonly status: number;
|
|
55
|
+
readonly code: string;
|
|
56
|
+
readonly details?: unknown;
|
|
57
|
+
constructor(init: EntrypointErrorInit);
|
|
278
58
|
}
|
|
279
|
-
interface PresignedUrlConfig {
|
|
280
|
-
defaultExpiry: number;
|
|
281
|
-
maxExpiry: number;
|
|
282
|
-
}
|
|
283
|
-
interface StorageModuleOptions {
|
|
284
|
-
/** HMAC secret used for signed downloads. */
|
|
285
|
-
secret?: string;
|
|
286
|
-
disks: DiskConfig[];
|
|
287
|
-
defaultDisk: string;
|
|
288
|
-
presignedUrl?: PresignedUrlConfig;
|
|
289
|
-
}
|
|
290
|
-
//#endregion
|
|
291
|
-
//#region src/storage/storage.module.d.ts
|
|
292
|
-
declare const ConfigurableModuleClass: import("@velajs/vela").ConfigurableModuleClassType<StorageModuleOptions, "forRoot", "create", {
|
|
293
|
-
isGlobal?: boolean;
|
|
294
|
-
}>;
|
|
295
|
-
export declare class StorageModule extends ConfigurableModuleClass {}
|
|
296
|
-
//#endregion
|
|
297
|
-
//#region src/storage/r2-storage.driver.d.ts
|
|
298
|
-
interface R2StorageDriverConfig {
|
|
299
|
-
disk: string;
|
|
300
|
-
bucket: R2Bucket;
|
|
301
|
-
/** HMAC secret for presigned URLs (typically env.APP_SECRET). */
|
|
302
|
-
secret?: string;
|
|
303
|
-
}
|
|
304
|
-
/** {@link StorageDriver} over a Cloudflare R2 bucket. */
|
|
305
|
-
export declare class R2StorageDriver implements StorageDriver {
|
|
306
|
-
private readonly config;
|
|
307
|
-
constructor(config: R2StorageDriverConfig);
|
|
308
|
-
upload(body: StorageBody, path: string, options: UploadOptions): Promise<UploadResult>;
|
|
309
|
-
download(path: string): Promise<DownloadResult>;
|
|
310
|
-
delete(path: string): Promise<void>;
|
|
311
|
-
exists(path: string): Promise<boolean>;
|
|
312
|
-
getPresignedUrl(path: string, method: PresignMethod, expiresIn: number): Promise<PresignedUrlResult>;
|
|
313
|
-
}
|
|
314
|
-
//#endregion
|
|
315
|
-
//#region src/storage/storage-manager.service.d.ts
|
|
316
|
-
export declare class StorageManagerService {
|
|
317
|
-
private readonly options;
|
|
318
|
-
constructor(options: StorageModuleOptions);
|
|
319
|
-
hasDisk(disk: string): boolean;
|
|
320
|
-
getDiskConfig(disk: string): DiskConfig;
|
|
321
|
-
getDriver(disk: string): R2StorageDriver;
|
|
322
|
-
}
|
|
323
|
-
//#endregion
|
|
324
|
-
//#region src/storage/storage.service.d.ts
|
|
325
59
|
/**
|
|
326
|
-
*
|
|
327
|
-
*
|
|
60
|
+
* Whether `error` is a failed JS-RPC call of a Vela entrypoint: an
|
|
61
|
+
* {@link EntrypointError}, or the plain `Error` workerd delivers for one to
|
|
62
|
+
* the caller. On a compatibility date before 2026-04-21 without
|
|
63
|
+
* `enhanced_error_serialization`, workerd drops the error's properties, so
|
|
64
|
+
* this is false.
|
|
328
65
|
*/
|
|
329
|
-
export declare
|
|
330
|
-
private readonly options;
|
|
331
|
-
private readonly manager;
|
|
332
|
-
constructor(options: StorageModuleOptions, manager: StorageManagerService);
|
|
333
|
-
put(relativePath: string, body: StorageBody, options?: UploadOptions, disk?: string): Promise<UploadResult>;
|
|
334
|
-
get(relativePath: string, disk?: string): Promise<DownloadResult>;
|
|
335
|
-
delete(relativePath: string, disk?: string): Promise<void>;
|
|
336
|
-
exists(relativePath: string, disk?: string): Promise<boolean>;
|
|
337
|
-
url(relativePath: string, method?: PresignMethod, expiresIn?: number, disk?: string): Promise<PresignedUrlResult>;
|
|
338
|
-
private resolveDisk;
|
|
339
|
-
private fullPath;
|
|
340
|
-
private validateExpiry;
|
|
341
|
-
}
|
|
66
|
+
export declare function isEntrypointError(error: unknown): error is EntrypointError;
|
|
342
67
|
//#endregion
|
|
343
|
-
//#region src/
|
|
68
|
+
//#region src/bindings.d.ts
|
|
69
|
+
export declare const kv: (ref: BindingRef) => Binding<KVNamespace<string>>;
|
|
70
|
+
export declare const r2: (ref: BindingRef) => Binding<R2Bucket>;
|
|
71
|
+
export declare const d1: (ref: BindingRef) => Binding<D1Database>;
|
|
72
|
+
export declare const queue: (ref: BindingRef) => Binding<Queue<unknown>>;
|
|
73
|
+
export declare const durableObject: (ref: BindingRef) => Binding<DurableObjectNamespace<undefined>>;
|
|
74
|
+
export declare const rateLimit: (ref: BindingRef) => Binding<RateLimit>;
|
|
344
75
|
/**
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
76
|
+
* A reference to a Workflow binding declared under `workflows`, whose
|
|
77
|
+
* instances take `Params`: for a class from `VelaWorkflow()`,
|
|
78
|
+
* `workflow<WorkflowParams<SignupWorkflow>>({ binding: 'SIGNUP_WORKFLOW' })`.
|
|
79
|
+
* Called with an application's ENV, it returns the native binding typed with
|
|
80
|
+
* those params: `await signups(env).create({ params: { email } })`. The
|
|
81
|
+
* runtime checks that the binding is a Workflow; its params are what the
|
|
82
|
+
* Workflow class declares.
|
|
351
83
|
*/
|
|
352
|
-
export declare
|
|
353
|
-
private readonly manager;
|
|
354
|
-
private readonly options;
|
|
355
|
-
constructor(manager: StorageManagerService, options: StorageModuleOptions);
|
|
356
|
-
download(c: Context): Promise<Response>;
|
|
357
|
-
}
|
|
358
|
-
//#endregion
|
|
359
|
-
//#region src/storage/storage.tokens.d.ts
|
|
360
|
-
export declare const STORAGE_OPTIONS: InjectionToken<StorageModuleOptions>;
|
|
84
|
+
export declare function workflow<Params = unknown>(ref: BindingRef): Binding<Workflow<Params>>;
|
|
361
85
|
//#endregion
|
|
362
86
|
//#region src/services/kv-cache.store.d.ts
|
|
87
|
+
/** A KV namespace, or a function that reads it when an operation needs it. */
|
|
88
|
+
type KVNamespaceSource = KVNamespace | (() => KVNamespace);
|
|
363
89
|
/**
|
|
364
90
|
* Native KV JSON value store. Metadata retains logical expiry even when KV's
|
|
365
91
|
* physical retention rounds up to its 60-second minimum. Legacy values without
|
|
366
92
|
* metadata remain readable, but cannot safely backfill another tier.
|
|
367
93
|
*/
|
|
368
|
-
export declare class KVCacheStore implements
|
|
369
|
-
private
|
|
370
|
-
constructor(
|
|
94
|
+
export declare class KVCacheStore implements CacheStore, CacheEntryReader, CacheEntryWriter {
|
|
95
|
+
#private;
|
|
96
|
+
constructor(namespace: KVNamespaceSource);
|
|
97
|
+
private get ns();
|
|
371
98
|
get(key: string): Promise<unknown>;
|
|
372
99
|
getEntry(key: string): Promise<{
|
|
373
100
|
value: unknown;
|
|
@@ -386,11 +113,28 @@ export declare class KVCacheStore implements AsyncCacheStore, CacheEntryReader,
|
|
|
386
113
|
* this is unsuitable for strict read-after-write or authorization revocation.
|
|
387
114
|
*/
|
|
388
115
|
export declare class KVCacheInvalidationStore implements CacheInvalidationStore {
|
|
389
|
-
private
|
|
390
|
-
constructor(
|
|
116
|
+
#private;
|
|
117
|
+
constructor(namespace: KVNamespaceSource);
|
|
118
|
+
private get ns();
|
|
391
119
|
getVersion(key: string): Promise<string>;
|
|
392
120
|
invalidate(key: string): Promise<void>;
|
|
393
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* `CacheModule`'s value store over the KV namespace named `binding`, read from
|
|
124
|
+
* each application's `ENV` when an operation needs it:
|
|
125
|
+
* `CacheModule.forRoot({ namespace, scope, store: kvCache({ binding: 'CACHE' }) })`.
|
|
126
|
+
*/
|
|
127
|
+
export declare function kvCache(ref: {
|
|
128
|
+
binding: string;
|
|
129
|
+
}): EnvFactory<CacheStore>;
|
|
130
|
+
/**
|
|
131
|
+
* `CacheModule`'s generation store over a dedicated KV namespace named
|
|
132
|
+
* `binding`, without TTLs or lifecycle cleanup. Eventually consistent; see
|
|
133
|
+
* {@link KVCacheInvalidationStore}.
|
|
134
|
+
*/
|
|
135
|
+
export declare function kvCacheInvalidation(ref: {
|
|
136
|
+
binding: string;
|
|
137
|
+
}): EnvFactory<CacheInvalidationStore>;
|
|
394
138
|
//#endregion
|
|
395
139
|
//#region src/services/flagship-flag.driver.d.ts
|
|
396
140
|
/**
|
|
@@ -517,43 +261,6 @@ interface QueueConsumerMetadata {
|
|
|
517
261
|
*/
|
|
518
262
|
export declare function QueueConsumer(queueName: string): MethodDecorator;
|
|
519
263
|
//#endregion
|
|
520
|
-
//#region src/websocket/cloudflare-websocket.module.d.ts
|
|
521
|
-
/**
|
|
522
|
-
* Cloudflare counterpart to the core `WebSocketModule.forRoot()`. Import this in
|
|
523
|
-
* your `AppModule` instead: it provides the gateway dispatcher plus a late-bound
|
|
524
|
-
* `WS_SERVER` (`WsServerHolder`) that the WebSocket Durable Object wires to a
|
|
525
|
-
* ctx-backed server per instance. `useClass` ensures a fresh holder per DI
|
|
526
|
-
* container so colocated DO instances never share a server.
|
|
527
|
-
*/
|
|
528
|
-
export declare class CloudflareWebSocketModule {
|
|
529
|
-
static forRoot(): DynamicModule;
|
|
530
|
-
}
|
|
531
|
-
//#endregion
|
|
532
|
-
//#region src/websocket/broadcast.d.ts
|
|
533
|
-
interface WsBroadcastStub {
|
|
534
|
-
broadcast(cmd: BroadcastCommand): Promise<void>;
|
|
535
|
-
}
|
|
536
|
-
interface BroadcastNamespace {
|
|
537
|
-
idFromName(name: string): DurableObjectId;
|
|
538
|
-
get(id: DurableObjectId): WsBroadcastStub;
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* Push to a room from a Worker HTTP handler / cron / queue consumer (server-
|
|
542
|
-
* initiated emit). Resolves the room's Durable Object and calls its `broadcast`
|
|
543
|
-
* RPC method — the same canonical room→DO mapping the upgrade route uses, so it
|
|
544
|
-
* always reaches the DO holding those sockets.
|
|
545
|
-
*
|
|
546
|
-
* @example
|
|
547
|
-
* ```ts
|
|
548
|
-
* // In a controller — ns from the typed Worker environment
|
|
549
|
-
* await broadcastToRoom(ns, '/orgs/:orgId/ws', `org:${id}`, 'order.created', order);
|
|
550
|
-
* ```
|
|
551
|
-
*/
|
|
552
|
-
export declare function broadcastToRoom(ns: BroadcastNamespace, gatewayPath: string, room: string, event: string, data?: unknown, options?: {
|
|
553
|
-
exceptIds?: string[];
|
|
554
|
-
maxFrameBytes?: number;
|
|
555
|
-
}): Promise<void>;
|
|
556
|
-
//#endregion
|
|
557
264
|
//#region src/websocket/do-state.d.ts
|
|
558
265
|
/** Structural view of the DO's SQLite handle (`ctx.storage.sql`, requires `new_sqlite_classes`). */
|
|
559
266
|
interface SqlStorageLike {
|
|
@@ -562,40 +269,40 @@ interface SqlStorageLike {
|
|
|
562
269
|
};
|
|
563
270
|
}
|
|
564
271
|
//#endregion
|
|
565
|
-
//#region src/websocket/
|
|
566
|
-
/**
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
* protocol's model).
|
|
580
|
-
*/
|
|
581
|
-
export declare class DoCursorLog implements CursorLog {
|
|
582
|
-
private readonly maxRows;
|
|
583
|
-
private sql?;
|
|
584
|
-
private epoch?;
|
|
585
|
-
constructor(maxRows?: number);
|
|
586
|
-
/** @internal — called by `initDoLive` with the DO's `ctx.storage.sql`. */
|
|
587
|
-
_initialize(sql: SqlStorageLike): void;
|
|
588
|
-
append(tags: string[]): CommitStamp;
|
|
589
|
-
current(): CommitStamp;
|
|
590
|
-
evaluateResume(sinceCursor: number, sinceEpoch: string, subscriptionTags: string[]): ResumeVerdict;
|
|
591
|
-
private assertReady;
|
|
272
|
+
//#region src/websocket/binding-gateways.d.ts
|
|
273
|
+
/** A gateway whose rooms live in Durable Objects: its path and namespace binding. */
|
|
274
|
+
interface BindingGateway {
|
|
275
|
+
path: string;
|
|
276
|
+
binding: string;
|
|
277
|
+
/** The gateway class name, for diagnostics. */
|
|
278
|
+
name: string;
|
|
279
|
+
}
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/websocket/worker-transport.d.ts
|
|
282
|
+
/** One gateway room's Durable Object: its id, and calls to its operations. */
|
|
283
|
+
interface GatewayRoomObject {
|
|
284
|
+
readonly id: unknown;
|
|
285
|
+
call(method: string, ...args: unknown[]): Promise<unknown>;
|
|
592
286
|
}
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region src/websocket/live-driver.d.ts
|
|
593
289
|
interface DurableObjectLiveOptions {
|
|
594
|
-
/**
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
290
|
+
/**
|
|
291
|
+
* Durable Object namespace binding that holds the gateway's rooms, read from
|
|
292
|
+
* the application's `ENV` when an invalidation first needs it. Defaults to
|
|
293
|
+
* the `binding` of the chosen gateway.
|
|
294
|
+
*/
|
|
295
|
+
binding?: string;
|
|
296
|
+
/**
|
|
297
|
+
* Exact `@WebSocketGateway()` path whose rooms hold the subscriptions.
|
|
298
|
+
* Defaults to the single gateway backed by `binding` (or by any binding).
|
|
299
|
+
*/
|
|
300
|
+
gatewayPath?: string;
|
|
301
|
+
/**
|
|
302
|
+
* Room used when an invalidation names none. Matches the client default. A
|
|
303
|
+
* gateway without `roomParam` has one room, its path, which every
|
|
304
|
+
* invalidation reaches.
|
|
305
|
+
*/
|
|
599
306
|
defaultRoom?: string;
|
|
600
307
|
}
|
|
601
308
|
interface LiveInvalidateStub {
|
|
@@ -606,53 +313,112 @@ interface LiveNamespace {
|
|
|
606
313
|
idFromName(name: string): DurableObjectId;
|
|
607
314
|
get(id: DurableObjectId): LiveInvalidateStub;
|
|
608
315
|
}
|
|
609
|
-
/**
|
|
316
|
+
/** @internal What the Worker's live platform hands a driver. */
|
|
317
|
+
interface WorkerLiveContext {
|
|
318
|
+
env: VelaEnv;
|
|
319
|
+
gateways(): readonly Pick<BindingGateway, 'path' | 'binding'>[];
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Delivers live invalidations to the room Durable Object of a
|
|
323
|
+
* `@WebSocketGateway({ binding })`, whose SQLite log stamps the commit. Inside
|
|
324
|
+
* that Durable Object the same driver applies invalidations locally.
|
|
325
|
+
*/
|
|
610
326
|
declare class CfLiveDriver implements LiveDriver {
|
|
327
|
+
#private;
|
|
611
328
|
private readonly options;
|
|
612
329
|
readonly kind = "durable-object";
|
|
613
|
-
|
|
614
|
-
private localMode;
|
|
615
|
-
constructor(options: DurableObjectLiveOptions);
|
|
330
|
+
constructor(options?: DurableObjectLiveOptions);
|
|
616
331
|
bind(sink: LiveInvalidationSink): void;
|
|
617
|
-
/** @internal
|
|
332
|
+
/** @internal The Worker's live platform supplies its environment and gateways. */
|
|
333
|
+
_attach(context: WorkerLiveContext): void;
|
|
334
|
+
/** @internal A Durable Object dispatches to its own engine and SQLite log. */
|
|
618
335
|
_setLocalMode(): void;
|
|
336
|
+
/**
|
|
337
|
+
* @internal The Durable Object that holds one room's subscriptions. As for
|
|
338
|
+
* upgrades and `Gateways` pushes, a gateway without `roomParam` keeps every
|
|
339
|
+
* socket in one room, its path, so each of its rooms is in that object.
|
|
340
|
+
*/
|
|
341
|
+
_room(room: string): GatewayRoomObject;
|
|
619
342
|
dispatch(cmd: InvalidationCommand): Promise<CommitStamp | undefined> | CommitStamp | undefined;
|
|
620
343
|
}
|
|
621
|
-
/**
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
344
|
+
/**
|
|
345
|
+
* The Cloudflare live driver, for `LiveModule.forRoot({ driver })`. It is the
|
|
346
|
+
* default on Cloudflare, so name it only to choose a gateway, binding or
|
|
347
|
+
* default room:
|
|
348
|
+
*
|
|
349
|
+
* ```ts
|
|
350
|
+
* LiveModule.forRoot({ driver: () => durableObjectLive({ gatewayPath: '/rooms/:id/ws' }) })
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
export declare function durableObjectLive(options?: DurableObjectLiveOptions): CfLiveDriver;
|
|
354
|
+
//#endregion
|
|
355
|
+
//#region src/websocket/do-live.d.ts
|
|
356
|
+
/**
|
|
357
|
+
* The durable `CursorLog`: an append-only tag-invalidation log in the DO's
|
|
358
|
+
* SQLite (`__vela_live_log`, AUTOINCREMENT seq = cursor) plus an epoch UUID in
|
|
359
|
+
* `__vela_live_meta`. Because the cursor survives hibernation AND trims (it is
|
|
360
|
+
* read from `sqlite_sequence`, lunora's `ctx-db-cdc.ts` trick), a reconnecting
|
|
361
|
+
* client whose gap the log still covers gets a tiny `resume` instead of a
|
|
362
|
+
* re-run — the real-resume half of the live protocol.
|
|
363
|
+
*
|
|
364
|
+
* The Cloudflare adapter gives `LiveModule` one inside every SQLite-backed
|
|
365
|
+
* WebSocket Durable Object (wrangler: `new_sqlite_classes`); a class without
|
|
366
|
+
* SQLite keeps an in-memory log. The Worker never consults a log: its
|
|
367
|
+
* invalidations go to the room Durable Object, one log scope per room, exactly
|
|
368
|
+
* the protocol's model.
|
|
369
|
+
*/
|
|
370
|
+
export declare class DoCursorLog implements CursorLog {
|
|
371
|
+
private readonly sql;
|
|
372
|
+
private readonly maxRows;
|
|
373
|
+
private readonly epoch;
|
|
374
|
+
constructor(sql: SqlStorageLike, maxRows?: number);
|
|
375
|
+
append(tags: string[]): CommitStamp;
|
|
376
|
+
current(): CommitStamp;
|
|
377
|
+
evaluateResume(sinceCursor: number, sinceEpoch: string, subscriptionTags: string[]): ResumeVerdict;
|
|
378
|
+
}
|
|
625
379
|
/**
|
|
626
380
|
* Invalidate live tags in a room from a Worker (controller / cron / queue
|
|
627
|
-
* consumer)
|
|
628
|
-
*
|
|
381
|
+
* consumer) through an explicit namespace. Returns the room log scope's
|
|
382
|
+
* commit stamp for `Vela-Commit-Cursor` stamping. As with the live driver, a
|
|
383
|
+
* gateway without roomParam keeps every room in one object, named by its path.
|
|
629
384
|
*/
|
|
630
385
|
export declare function liveInvalidateToRoom(ns: LiveNamespace, gatewayPath: string, room: string, tags: string[]): Promise<CommitStamp | undefined>;
|
|
631
386
|
//#endregion
|
|
632
387
|
//#region src/rate-limit/cloudflare-rate-limit.store.d.ts
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
/** Bound attacker-influenced tracking keys before calling the platform. */
|
|
388
|
+
interface RateLimitStoreOptions {
|
|
389
|
+
/**
|
|
390
|
+
* The Workers Rate Limiting binding (declared under `ratelimits`) that
|
|
391
|
+
* serves every throttler, or one binding per named throttler:
|
|
392
|
+
* `{ burst: 'BURST_LIMITER', sustained: 'API_LIMITER' }`. Each binding's
|
|
393
|
+
* `simple.limit` and `simple.period` must equal its throttler's `limit` and
|
|
394
|
+
* `ttl`; the platform enforces them. One binding therefore serves only
|
|
395
|
+
* throttlers that share a limit and window: a throttler with other values,
|
|
396
|
+
* or one the map leaves out, fails the application's bootstrap instead of
|
|
397
|
+
* being enforced at the binding's.
|
|
398
|
+
*/
|
|
399
|
+
binding: string | Readonly<Record<string, string>>;
|
|
400
|
+
/** Bound attacker-influenced tracking keys before calling the platform. Default 1024. */
|
|
647
401
|
maxKeyBytes?: number;
|
|
648
402
|
}
|
|
649
403
|
/**
|
|
650
|
-
*
|
|
404
|
+
* `ThrottlerModule`'s storage over Workers Rate Limiting bindings, read from
|
|
405
|
+
* each application's `ENV` by name:
|
|
406
|
+
*
|
|
407
|
+
* ```ts
|
|
408
|
+
* ThrottlerModule.forRoot({
|
|
409
|
+
* throttlers: [{ ttl: 60_000, limit: 100 }],
|
|
410
|
+
* storage: rateLimitStore({ binding: 'API_LIMITER' }),
|
|
411
|
+
* })
|
|
412
|
+
* ```
|
|
651
413
|
*
|
|
652
|
-
* The platform
|
|
653
|
-
*
|
|
414
|
+
* The platform makes the allow/deny decision and exposes no counters or reset
|
|
415
|
+
* times, so the store reports no `remaining` quota. It enforces the limit and
|
|
416
|
+
* period configured on the binding, so it declares `fixedLimits`: a
|
|
417
|
+
* `@Throttle()` override that changes them fails instead of being ignored.
|
|
418
|
+
* Periods are 10 or 60 seconds. `ThrottlerModule` checks the declared
|
|
419
|
+
* throttlers against the bindings when the application starts.
|
|
654
420
|
*/
|
|
655
|
-
export declare function
|
|
421
|
+
export declare function rateLimitStore(options: RateLimitStoreOptions): EnvFactory<ThrottlerStore>;
|
|
656
422
|
//#endregion
|
|
657
423
|
//#region src/nonce/durable-object-nonce.store.d.ts
|
|
658
424
|
/** The generated Workers binding type for {@link VelaNonceDurableObject}. */
|
|
@@ -681,4 +447,4 @@ interface DurableObjectNonceStoreOptions {
|
|
|
681
447
|
*/
|
|
682
448
|
export declare function durableObjectNonceStore(options: DurableObjectNonceStoreOptions): NonceStore;
|
|
683
449
|
//#endregion
|
|
684
|
-
export {
|
|
450
|
+
export { CLOUDFLARE_DURABLE_OBJECT, CLOUDFLARE_ENTRYPOINT, CLOUDFLARE_SCHEDULED_EVENT, CLOUDFLARE_WORKER, CLOUDFLARE_WORKFLOW, type CfLiveDriver, type CloudflareApp, type CloudflareAppOptions, CloudflareApplication, type CloudflareDurableObjectDescriptor, type CloudflareEntrypointDescriptor, type CloudflareRoot, type CloudflareScheduledEvent, type CloudflareWorker, type CloudflareWorkerDescriptor, type CloudflareWorkerOptions, type CloudflareWorkflowDescriptor, type CreateCloudflareAppOptions, type DoPitrArmOptions, type DoPitrArmResult, type DoPitrBookmarkRead, type DoPitrId, type DoPitrNamespace, type DoPitrStorage, DoPitrUnavailableError, type DurableObjectLiveOptions, type DurableObjectNonceNamespace, type DurableObjectNonceStoreOptions, type EntrypointErrorInit, type FlagshipBinding, type FlagshipFlagDriverOptions, type KVNamespaceSource, type KvFlagDriverOptions, type LiveNamespace, type MountOpenApiOptions, type QueueConsumerMetadata, type RateLimitStoreOptions, type ScheduledEvent, type VelaDoPitrRpc, armDoPitr, cloudflareAdapter, createCloudflareApp, createCloudflareWorker, defineCloudflareApp, isCloudflareApp, isDoPitrUnavailable, readDoPitrBookmark };
|