@lunora/platform-node 1.0.0-alpha.21 → 1.0.0-alpha.211
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/README.md +7 -0
- package/dist/conformance/index.mjs +1 -1
- package/dist/index.d.mts +404 -147
- package/dist/index.d.ts +404 -147
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/NODE_SCHEDULER_DISPATCH_PATH-RI9fOO8d.mjs +1 -0
- package/dist/packem_shared/bindShardSockets-9GvSocBW.mjs +1 -0
- package/dist/packem_shared/createNodeGlobalStore-CD4DiqeS.mjs +1 -0
- package/dist/packem_shared/createNodeHttpServer-D4YVdhJn.mjs +4 -0
- package/dist/packem_shared/createNodePlatform-DJZCR46S.mjs +1 -0
- package/dist/packem_shared/createNodeProfileHandler-MX5xKPg0.mjs +1 -0
- package/dist/packem_shared/createNodeQueueHost-CttDb5sY.mjs +17 -0
- package/dist/packem_shared/createNodeR2Bucket-D_jsnenX.mjs +1 -0
- package/dist/packem_shared/createNodeSchedulerHost-CjgGhVoQ.mjs +15 -0
- package/dist/packem_shared/createNodeShardHost-Bhbm4txQ.mjs +1 -0
- package/dist/packem_shared/createNodeShardNamespace-BgQjDv7V.mjs +1 -0
- package/dist/packem_shared/createNodeShardRegistry-BKl1QXiv.mjs +1 -0
- package/dist/packem_shared/createNodeSocketHost-ByOmEGFe.mjs +2 -0
- package/dist/packem_shared/createNodeWorkflowHost-B76TKiw_.mjs +1 -0
- package/dist/packem_shared/hmac-url-Bogwm7I6.mjs +1 -0
- package/dist/packem_shared/node-socket-pair-0baNnoFw.mjs +1 -0
- package/dist/packem_shared/prepared-statement-3XBQZXtC.mjs +1 -0
- package/package.json +15 -9
- package/dist/packem_shared/createNodeGlobalStore-Cwi33XOk.mjs +0 -1
- package/dist/packem_shared/createNodePlatform-1fAQ_biu.mjs +0 -1
- package/dist/packem_shared/createNodeQueueHost--mBLGSxF.mjs +0 -17
- package/dist/packem_shared/createNodeR2Bucket-CmHYlIni.mjs +0 -1
- package/dist/packem_shared/createNodeSchedulerHost-vZgv1CEo.mjs +0 -15
- package/dist/packem_shared/createNodeShardHost-C0j8nvSU.mjs +0 -1
- package/dist/packem_shared/createNodeShardRegistry-DKdc0pV8.mjs +0 -1
- package/dist/packem_shared/createNodeShardState-CpUzvWwd.mjs +0 -1
- package/dist/packem_shared/createNodeSocketHost-DK3X5PlQ.mjs +0 -2
- package/dist/packem_shared/createNodeWorkflowHost-CTVBYiuj.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,45 @@
|
|
|
1
1
|
import { SchemaLike } from '@lunora/shard-engine';
|
|
2
2
|
import { SqlCtxDbOptions, SqlCtxExec, createSqlCtxDb } from '@lunora/sql-store';
|
|
3
3
|
import Database from 'better-sqlite3';
|
|
4
|
-
import { ShardKvStore, QueueBindingLike, MessageBatchLike, SchedulerHost, ShardHost, SocketHost, DirectShardDirectory, PlatformCapabilities, ShardDirectory, R2BucketLike
|
|
4
|
+
import { ShardKvStore, QueueBindingLike, MessageBatchLike, SchedulerHost, ShardHost, SocketHandle, SocketHost, DirectShardDirectory, PlatformCapabilities, ShardDirectory, R2BucketLike } from '@lunora/platform';
|
|
5
5
|
import { WorkflowBindingLike } from '@lunora/workflow';
|
|
6
6
|
import { WorkflowRuntime, WorkflowStore } from '@visulima/workflow';
|
|
7
|
+
import { ShardNamespaceLike } from '@lunora/runtime';
|
|
8
|
+
/** One function call the route has authenticated and parsed. */
|
|
9
|
+
interface NodeDispatchInvocation {
|
|
10
|
+
args: Record<string, unknown>;
|
|
11
|
+
functionPath: string;
|
|
12
|
+
/** The scheduler record or delivery id, used as the shard's idempotency key. */
|
|
13
|
+
id: string | undefined;
|
|
14
|
+
/** Identity the trusted caller forwarded, if any. */
|
|
15
|
+
identity: {
|
|
16
|
+
identity?: string;
|
|
17
|
+
userId?: string;
|
|
18
|
+
} | undefined;
|
|
19
|
+
/** The job's due time in epoch-ms, when the sender stamped one. */
|
|
20
|
+
scheduledFor?: number;
|
|
21
|
+
shardKey: string;
|
|
22
|
+
traceparent: string | undefined;
|
|
23
|
+
}
|
|
24
|
+
interface NodeDispatchRouteOptions {
|
|
25
|
+
/** `LUNORA_ADMIN_TOKEN`. Used as the bearer when no HMAC signature is presented. */
|
|
26
|
+
adminToken?: string;
|
|
27
|
+
/** The shard a body without `shardKey` is sent to. */
|
|
28
|
+
defaultShardKey: string;
|
|
29
|
+
/** Runs the call in-process and returns the shard's response, unchanged. */
|
|
30
|
+
invoke: (call: NodeDispatchInvocation) => Promise<Response>;
|
|
31
|
+
/** `LUNORA_SCHEDULER_SECRET`. When set, a signed request is verified against it. */
|
|
32
|
+
schedulerSecret?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Build the dispatch route. The returned function answers any request it is
|
|
36
|
+
* handed; mounting it at {@link NODE_SCHEDULER_DISPATCH_PATH} is the caller's job.
|
|
37
|
+
* With neither secret configured every request is refused, so an unconfigured
|
|
38
|
+
* route fails closed.
|
|
39
|
+
*/
|
|
40
|
+
declare const createNodeDispatchRoute: (options: NodeDispatchRouteOptions) => ((request: Request) => Promise<Response>);
|
|
41
|
+
/** The path `@lunora/dispatch` and `@lunora/scheduler` POST to. */
|
|
42
|
+
declare const NODE_SCHEDULER_DISPATCH_PATH: "/_lunora/scheduler/dispatch";
|
|
7
43
|
/**
|
|
8
44
|
* The Node store options — the shared store options minus the two this binding
|
|
9
45
|
* owns. `dialect` is fixed (SQLite) and `exec` is the store's own connection;
|
|
@@ -14,13 +50,21 @@ type NodeGlobalContextDatabaseOptions = Omit<SqlCtxDbOptions, "dialect" | "exec"
|
|
|
14
50
|
/**
|
|
15
51
|
* Wrap a `better-sqlite3` connection as the async exec the store core consumes.
|
|
16
52
|
*
|
|
17
|
-
* `batch`
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
53
|
+
* `batch` runs the statements in order inside one `better-sqlite3`
|
|
54
|
+
* transaction, which is synchronous, so nothing else runs between them. There is
|
|
55
|
+
* no round trip to save; atomicity is the point. The store core's FTS5 search
|
|
56
|
+
* companion writes each document as an ordered list of statements, and without
|
|
57
|
+
* this two async writers interleaved at every `await` between them: one could
|
|
58
|
+
* move a document's mapping while the other's entry was mid-write, leaving an
|
|
59
|
+
* entry no later write or purge could reach. The `sqlite` dialect's contract
|
|
60
|
+
* requires an ordered, atomic `batch` for exactly that reason.
|
|
61
|
+
*
|
|
62
|
+
* `transaction` holds `BEGIN IMMEDIATE` … `COMMIT` open across the awaits of
|
|
63
|
+
* an async `work`, which `better-sqlite3`'s own synchronous `transaction()`
|
|
64
|
+
* cannot. The connection is shared, so while one is open every other statement
|
|
65
|
+
* waits for it to settle: run in between, another writer's statement would land
|
|
66
|
+
* inside it and be rolled back with it. The wait and the statement (or the
|
|
67
|
+
* `BEGIN`) run with no `await` between them, so nothing slips in after the check.
|
|
24
68
|
*/
|
|
25
69
|
declare const createNodeSqlExec: (database: Database.Database) => SqlCtxExec;
|
|
26
70
|
/** Options for {@link createNodeGlobalStore}. */
|
|
@@ -63,6 +107,32 @@ interface NodeGlobalStore {
|
|
|
63
107
|
* which is the whole point of the dialect seam.
|
|
64
108
|
*/
|
|
65
109
|
declare const createNodeGlobalStore: (options?: NodeGlobalStoreOptions) => NodeGlobalStore;
|
|
110
|
+
/** Serve `options.fetch` over `node:http`. Resolves once the server is listening. */
|
|
111
|
+
declare const createNodeHttpServer: (options: NodeHttpServerOptions) => Promise<NodeHttpServer>;
|
|
112
|
+
/** Options for {@link createNodeHttpServer}. */
|
|
113
|
+
interface NodeHttpServerOptions {
|
|
114
|
+
/** The app worker's `fetch`, already bound to its env and context. */
|
|
115
|
+
fetch: (request: Request) => Promise<Response> | Response;
|
|
116
|
+
/** Host to bind. Defaults to the loopback interface. */
|
|
117
|
+
host?: string;
|
|
118
|
+
/**
|
|
119
|
+
* The public base URL the app is served at, e.g. `https://app.example`. Every request URL uses its origin, so origin-sensitive
|
|
120
|
+
* behaviour (CSRF, WebSocket origin checks, cookie rules) sees the public scheme behind a TLS proxy. The client's `Host` header is
|
|
121
|
+
* never used. Defaults to the bound `http://host:port`, which is only allowed for a loopback `host`: binding a non-loopback address
|
|
122
|
+
* (e.g. `0.0.0.0` or a LAN IP) without `origin` makes {@link createNodeHttpServer} reject, because browsers would send that address
|
|
123
|
+
* as `Origin` and fail the CSRF check. Set `origin` to the URL users open.
|
|
124
|
+
*/
|
|
125
|
+
origin?: string;
|
|
126
|
+
/** Port to bind. `0` (the default) picks a free ephemeral port. */
|
|
127
|
+
port?: number;
|
|
128
|
+
}
|
|
129
|
+
/** A listening server. */
|
|
130
|
+
interface NodeHttpServer {
|
|
131
|
+
/** Stop accepting connections and end every open one, streams included. */
|
|
132
|
+
close: () => Promise<void>;
|
|
133
|
+
/** The `http://host:port` origin the server answers on. */
|
|
134
|
+
origin: string;
|
|
135
|
+
}
|
|
66
136
|
/** Build a `ShardKvStore` over a `better-sqlite3` table in the shard's database. */
|
|
67
137
|
declare const createNodeShardKvStore: (database: Database.Database) => ShardKvStore;
|
|
68
138
|
/** Options for {@link createNodeQueueHost}. */
|
|
@@ -146,17 +216,22 @@ interface NodeSchedulerHostOptions {
|
|
|
146
216
|
* A handler that **throws** marks the delivery failed, which is what drives
|
|
147
217
|
* the retry/dead-letter machinery: the job's `attempts` increments and it is
|
|
148
218
|
* either re-armed with backoff or parked. A handler that resolves marks the
|
|
149
|
-
* job
|
|
219
|
+
* job `succeeded`.
|
|
150
220
|
*
|
|
151
221
|
* Omitting it makes every delivery trivially succeed, which means a caller
|
|
152
222
|
* who forgets to pass one gets a scheduler that quietly drops work — the
|
|
153
223
|
* precise failure plan 267 caught. Supply one in anything real; the
|
|
154
224
|
* conformance host supplies one purely so the TCK can tell a delivery apart
|
|
155
225
|
* from an expired timer.
|
|
226
|
+
*
|
|
227
|
+
* `job.scheduledFor` is the due time (a cron tick's planned fire time).
|
|
228
|
+
* Forwarding it as the dispatch body's `scheduledFor` is what lets the shard
|
|
229
|
+
* record the `scheduler.lag_ms` metric, as the Worker dispatch path does.
|
|
156
230
|
*/
|
|
157
231
|
onDispatch?: (functionPath: string, args: Record<string, unknown>, job: {
|
|
158
232
|
attempts: number;
|
|
159
233
|
id: string;
|
|
234
|
+
scheduledFor: number;
|
|
160
235
|
}) => Promise<void> | void;
|
|
161
236
|
}
|
|
162
237
|
/**
|
|
@@ -197,9 +272,12 @@ interface NodeShardHostOptions {
|
|
|
197
272
|
* `_lunora_alarm` when the host is constructed over an existing database,
|
|
198
273
|
* including an alarm whose time elapsed while nothing was running.
|
|
199
274
|
*
|
|
200
|
-
* A handler that throws is isolated to its own delivery
|
|
275
|
+
* A handler that throws is isolated to its own delivery — it never reaches
|
|
201
276
|
* the caller that set the alarm, because by then that call has long
|
|
202
|
-
* returned
|
|
277
|
+
* returned — and the wakeup is then re-delivered with backoff up to
|
|
278
|
+
* {@link ALARM_RETRY_LIMIT} times, the way workerd retries a throwing
|
|
279
|
+
* `alarm()`. Delivery is at-least-once, so the handler must tolerate
|
|
280
|
+
* running twice for one scheduled timestamp.
|
|
203
281
|
*/
|
|
204
282
|
onAlarm?: () => Promise<void> | void;
|
|
205
283
|
/**
|
|
@@ -218,25 +296,59 @@ interface NodeShardHostOptions {
|
|
|
218
296
|
/**
|
|
219
297
|
* Build a `ShardHost` over a real `better-sqlite3` database.
|
|
220
298
|
*
|
|
221
|
-
* `runSerialized`
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
299
|
+
* `runSerialized` and `transaction` share **one** boundary lock, because they
|
|
300
|
+
* write **one** `better-sqlite3` connection. `transaction` issues raw
|
|
301
|
+
* `BEGIN`/`COMMIT`/`ROLLBACK` — legal here (unlike inside a Cloudflare Durable
|
|
302
|
+
* Object, where the runtime forbids it and callers must use
|
|
303
|
+
* `storage.transaction`) because better-sqlite3 is a plain embedded database
|
|
304
|
+
* with no platform-level transaction primitive layered over it.
|
|
305
|
+
*
|
|
306
|
+
* ## Why one lane and not two
|
|
227
307
|
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
* a
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
308
|
+
* This host shipped with two private tail chains, one per entry point, so each
|
|
309
|
+
* serialized against itself and neither against the other. `runSerialized`
|
|
310
|
+
* issues no `BEGIN` of its own, so one of its closures overlapping a bare
|
|
311
|
+
* `transaction()` wrote straight into that transaction's span. `assertOwnTurn`
|
|
312
|
+
* below catches the write — it is the only reason this host never silently lost
|
|
313
|
+
* one the way an unguarded connection would — but catching it is not the same
|
|
314
|
+
* as preventing it, and the refusal lands in the wrong place:
|
|
315
|
+
*
|
|
316
|
+
* 1. A `runSerialized` closure writes a row. Nothing is open, so it commits.
|
|
317
|
+
* 2. It awaits (a scheduler hop, an `onShardInit` read, any real I/O).
|
|
318
|
+
* 3. A bare `transaction()` runs `BEGIN` while it is parked. `transaction` is
|
|
319
|
+
* a public contract surface, and `./node-shard-state` re-exports it as the
|
|
320
|
+
* `storage.transaction` member `ShardDO` documents as "the platform
|
|
321
|
+
* primitive", so a subclass reaches one without going through the engine.
|
|
322
|
+
* 4. The closure resumes and its next write is refused with
|
|
323
|
+
* `SHARD_UNAVAILABLE`, so `runSerialized` **rejects** — with step 1 already
|
|
324
|
+
* durable.
|
|
325
|
+
*
|
|
326
|
+
* The boundary the contract promises is atomic-or-nothing to its caller tore in
|
|
327
|
+
* half: a rejection the caller will retry, on top of a write the retry now
|
|
328
|
+
* re-applies. That is `runSerialized`'s "no two closures interleave" guarantee
|
|
329
|
+
* broken by a `transaction` it was never serialized against.
|
|
330
|
+
*
|
|
331
|
+
* ## Why the lock is re-entrant, and why `AsyncLocalStorage` is what makes it so
|
|
332
|
+
*
|
|
333
|
+
* The engine composes the two, and stacks them: `ShardRunner.runInTransaction`
|
|
334
|
+
* is `runSerialized(() => transaction(work))` (`@lunora/shard-engine`), and
|
|
335
|
+
* `ShardDO.fetch` widens a mutation dispatch carrying `x-lunora-mutation-id`
|
|
336
|
+
* into a *further* `runSerialized` span around it (`@lunora/do`). Under two
|
|
337
|
+
* plain FIFO chains that outer span is already fatal on this host — the inner
|
|
338
|
+
* `runSerialized` waits on a `tail` that only settles when the outer closure it
|
|
339
|
+
* is running inside resolves, and because nothing ever resets that `tail`, the
|
|
340
|
+
* shard's write lane is wedged for the life of the process rather than for the
|
|
341
|
+
* life of the request.
|
|
342
|
+
*
|
|
343
|
+
* So the lock is skipped for a boundary opened from inside a boundary, and
|
|
344
|
+
* `AsyncLocalStorage` is the only thing that can tell that case from the one
|
|
345
|
+
* that must queue: its store follows a single call's own await chain without
|
|
346
|
+
* leaking into a sibling chain. A held boolean cannot — it reads `true` for an
|
|
347
|
+
* unrelated *second top-level* `transaction()` too, which would then nest a raw
|
|
348
|
+
* `BEGIN` on a connection already inside one. This is the same distinction
|
|
349
|
+
* workerd's `blockConcurrencyWhile` draws natively with "does not queue events
|
|
350
|
+
* initiated as part of the callback itself", which is what
|
|
351
|
+
* `@lunora/platform-cloudflare` leans on for the identical composition.
|
|
240
352
|
*
|
|
241
353
|
* The returned `dispose()` is this host's lifecycle owner: it clears the
|
|
242
354
|
* pending alarm `setTimeout` (so it can never fire against a connection this
|
|
@@ -252,8 +364,55 @@ declare const createNodeShardHost: (options?: NodeShardHostOptions) => {
|
|
|
252
364
|
drain: () => Promise<void>;
|
|
253
365
|
host: ShardHost;
|
|
254
366
|
};
|
|
367
|
+
/** The end a shard accepts. Its `send` and `close` are what the socket host calls through its handle. */
|
|
368
|
+
interface NodeServerEnd {
|
|
369
|
+
close: (code?: number, reason?: string) => void;
|
|
370
|
+
send: (data: string | ArrayBuffer) => void;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* The socket-host half of a Node platform instance, plus the test-only hooks
|
|
374
|
+
* `@lunora/platform/conformance`'s `ConformanceHost` needs to drive a recycle
|
|
375
|
+
* from inside a test.
|
|
376
|
+
*/
|
|
377
|
+
interface NodeSocketHost {
|
|
378
|
+
/**
|
|
379
|
+
* Wait for every close handler still running, including ones they start. `undefined` when none are,
|
|
380
|
+
* so a caller can dispose synchronously.
|
|
381
|
+
*/
|
|
382
|
+
drain: () => Promise<void> | undefined;
|
|
383
|
+
/** Deliver a connection's close to `handler`, which calls `webSocketClose`. One handler per host. */
|
|
384
|
+
onClose: (handler: (socket: NodeServerEnd, code: number, reason: string, wasClean: boolean) => void | Promise<void>) => void;
|
|
385
|
+
/**
|
|
386
|
+
* Deliver a connection's inbound frames to `handler`. The handler is the
|
|
387
|
+
* shard that accepted the connection, so it calls `webSocketMessage`. One
|
|
388
|
+
* handler per host: a later call replaces the earlier one.
|
|
389
|
+
*/
|
|
390
|
+
onMessage: (handler: (socket: NodeServerEnd, data: string | ArrayBuffer) => void) => void;
|
|
391
|
+
/** Read back the frames sent to a socket, oldest first, text frames only. */
|
|
392
|
+
readFrames: (handle: SocketHandle) => string[];
|
|
393
|
+
/**
|
|
394
|
+
* Re-create a runtime socket from durable state.
|
|
395
|
+
*
|
|
396
|
+
* `attachment` is a fallback only: this host restores what it persisted,
|
|
397
|
+
* because that is what a real wake looks like. The argument covers an id
|
|
398
|
+
* this host never durably tracked (a synthetic id a test constructs).
|
|
399
|
+
*/
|
|
400
|
+
restoreSocket: (id: string, attachment: unknown) => SocketHandle;
|
|
401
|
+
/** Drop the runtime socket map while keeping durable attachments/tags. */
|
|
402
|
+
simulateRecycle: () => void;
|
|
403
|
+
/** The `SocketHost` contract implementation. */
|
|
404
|
+
socket: SocketHost;
|
|
405
|
+
}
|
|
406
|
+
/** Build the socket registry, persisting attachments and tags to `database`. */
|
|
407
|
+
declare const createNodeSocketHost: (database: Database.Database) => NodeSocketHost;
|
|
255
408
|
/** The contracts scoped to one shard key. */
|
|
256
409
|
interface NodeShard {
|
|
410
|
+
/**
|
|
411
|
+
* Inbound socket events for this shard's registry. Bind the shard that owns
|
|
412
|
+
* the sockets here, so a frame or close reaches its `webSocketMessage` and
|
|
413
|
+
* `webSocketClose`. See `bindShardSockets`.
|
|
414
|
+
*/
|
|
415
|
+
inbound: Pick<NodeSocketHost, "onClose" | "onMessage">;
|
|
257
416
|
/** Durable key-value storage on this shard's database. */
|
|
258
417
|
kv: ShardKvStore;
|
|
259
418
|
/** Single-writer execution, local SQL, transactions, durable alarms. */
|
|
@@ -310,22 +469,65 @@ interface NodeShardRegistry {
|
|
|
310
469
|
}
|
|
311
470
|
/** Build the in-process shard registry. */
|
|
312
471
|
declare const createNodeShardRegistry: (options?: NodeShardRegistryOptions) => NodeShardRegistry;
|
|
472
|
+
/** Options for {@link createNodeWorkflowHost}. */
|
|
473
|
+
interface NodeWorkflowHostOptions<Workflows extends Record<string, {
|
|
474
|
+
isLunoraWorkflow: true;
|
|
475
|
+
}>> {
|
|
476
|
+
/** Base env merged under the derived workflow bindings — surfaced to workflow bodies as `ctx.env` and used to resolve spawned children. */
|
|
477
|
+
env?: Record<string, unknown>;
|
|
478
|
+
/** How long (ms) the engine holds a cross-process lease while an activation runs, for stores that implement `acquire`. Defaults to 30000. */
|
|
479
|
+
leaseTtlMs?: number;
|
|
480
|
+
/** Where runs are persisted. Required — see the header for why there is no default. `createNodeWorkflowStore(database)` is the durable one. */
|
|
481
|
+
store: WorkflowStore;
|
|
482
|
+
/** The declared workflows keyed by their `lunora/workflows.ts` export name (e.g. `{ orderPipeline: orderPipeline }`). Values must be `defineWorkflow` results. */
|
|
483
|
+
workflows: Workflows;
|
|
484
|
+
}
|
|
485
|
+
/** A fully-wired Node workflow host. */
|
|
486
|
+
interface NodeWorkflowHost<Workflows extends Record<string, {
|
|
487
|
+
isLunoraWorkflow: true;
|
|
488
|
+
}>> {
|
|
489
|
+
/** Per-export-name `WorkflowBindingLike` — the map `ctx.workflows` consumes. */
|
|
490
|
+
readonly bindings: { [K in keyof Workflows]: WorkflowBindingLike; };
|
|
491
|
+
/**
|
|
492
|
+
* The caller's `env` plus one binding per workflow under its class name
|
|
493
|
+
* (`OrderPipelineWorkflow`), the key `ctx.exports` would carry on Cloudflare —
|
|
494
|
+
* merge this into a worker env so `ctx.spawn`/`ctx.parallel` resolve
|
|
495
|
+
* children through the same runtime.
|
|
496
|
+
*/
|
|
497
|
+
readonly env: Record<string, unknown>;
|
|
498
|
+
/** The underlying visulima runtime — `sweep`/`signal` for a dev loop or tests. */
|
|
499
|
+
readonly runtime: WorkflowRuntime;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Create a Node workflow host: compile every declared Lunora workflow onto the
|
|
503
|
+
* visulima engine, derive the workflow env, and expose the per-workflow
|
|
504
|
+
* `WorkflowBindingLike` handles.
|
|
505
|
+
*/
|
|
506
|
+
declare const createNodeWorkflowHost: <Workflows extends Record<string, {
|
|
507
|
+
isLunoraWorkflow: true;
|
|
508
|
+
}>>(options: NodeWorkflowHostOptions<Workflows>) => NodeWorkflowHost<Workflows>;
|
|
313
509
|
/** Every contract this package provides, composed for one Node process. */
|
|
314
510
|
interface NodePlatform<Queues extends Record<string, {
|
|
315
511
|
isLunoraQueue: true;
|
|
512
|
+
}> = Record<string, never>, Workflows extends Record<string, {
|
|
513
|
+
isLunoraWorkflow: true;
|
|
316
514
|
}> = Record<string, never>> {
|
|
317
515
|
/** `using platform = createNodePlatform(...)` support — delegates to `close()`. */
|
|
318
516
|
[Symbol.dispose]: () => void;
|
|
319
517
|
/** What this target supports — see `NODE_CAPABILITIES` in `@lunora/platform`. */
|
|
320
518
|
capabilities: PlatformCapabilities;
|
|
321
519
|
/**
|
|
322
|
-
* Tear this platform instance down:
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
520
|
+
* Tear this platform instance down: every resource this root built, in
|
|
521
|
+
* reverse construction order — the global store's own connection, every
|
|
522
|
+
* armed scheduler job timer, the registry's live shards, and last the shard
|
|
523
|
+
* host's pending alarm timer and its `better-sqlite3` database (and, with
|
|
524
|
+
* it, `kv`'s table — both live on the same connection). Nothing in this
|
|
525
|
+
* package closes these resources on its own — a `NodePlatform` a caller
|
|
526
|
+
* stops using without calling `close()` leaks the open file handles (plus
|
|
527
|
+
* their WAL/SHM sidecar files) and keeps the process alive on outstanding
|
|
528
|
+
* timers. Safe to call more than once. A `createNodePlatform` that throws
|
|
529
|
+
* unwinds the same list itself, so a failed construction leaks nothing and
|
|
530
|
+
* leaves nothing to call this on.
|
|
329
531
|
*
|
|
330
532
|
* **`close()` is a terminal state, not merely a cleanup step.** After it
|
|
331
533
|
* runs: `scheduler.schedule()` throws instead of arming a fresh timer
|
|
@@ -344,6 +546,16 @@ interface NodePlatform<Queues extends Record<string, {
|
|
|
344
546
|
close: () => void;
|
|
345
547
|
/** In-process shard directory (see `createNodeShardRegistry` for what it can and cannot do). */
|
|
346
548
|
directory: ShardDirectory;
|
|
549
|
+
/**
|
|
550
|
+
* The scheduler dispatch route, served in-process: `Request` in, shard
|
|
551
|
+
* response out, no listener. It answers the path `@lunora/dispatch` and
|
|
552
|
+
* `@lunora/scheduler` POST to. Pass it to `dispatchQueueBatch` as
|
|
553
|
+
* `queueFetchImpl` on `createWorker` so a queue handler's `message.run` /
|
|
554
|
+
* `ctx.run` reaches the shard; the env you pass there must carry `LUNORA_ORIGIN_URL` and the same
|
|
555
|
+
* `LUNORA_ADMIN_TOKEN` as `dispatch.adminToken`. Every request is refused
|
|
556
|
+
* unless `dispatch` supplies a secret.
|
|
557
|
+
*/
|
|
558
|
+
dispatch: (request: Request) => Promise<Response>;
|
|
347
559
|
/**
|
|
348
560
|
* Wait for every promise handed to `shard.waitUntil` to settle.
|
|
349
561
|
*
|
|
@@ -353,8 +565,28 @@ interface NodePlatform<Queues extends Record<string, {
|
|
|
353
565
|
* shutdown is `await platform.drain()` then `platform.close()`.
|
|
354
566
|
*/
|
|
355
567
|
drain: () => Promise<void>;
|
|
568
|
+
/**
|
|
569
|
+
* The `.global()` backend, or `undefined` when the caller named no database
|
|
570
|
+
* file for it. There is no default path, because a global store silently
|
|
571
|
+
* rooted at `:memory:` loses every row when the process exits.
|
|
572
|
+
*
|
|
573
|
+
* **A building block, not a wiring.** Unlike its three siblings, nothing
|
|
574
|
+
* downstream of this composition root reads it: a `.global()` read or write
|
|
575
|
+
* reaches its backend through exactly one seam, `createShardCtxDb({ globalDb
|
|
576
|
+
* })`, and the only thing that passes `globalDb` is the generated `shard.ts`,
|
|
577
|
+
* from its `d1` / `hyperdriveGlobal` config thunks. `createNodePlatform`
|
|
578
|
+
* constructs no shard DO, so it cannot make that hop itself. A caller that
|
|
579
|
+
* wants `.global()` on this host makes it: after `migrate(schema)` has
|
|
580
|
+
* provisioned the tables, give the generated `createShardDO` a `d1` thunk
|
|
581
|
+
* returning `platform.globalTables.writer({ schema, … })` — `writer` builds
|
|
582
|
+
* the `createSqlCtxDb` facade that seam expects, and `node-platform.test.ts`
|
|
583
|
+
* round-trips a row through exactly that object.
|
|
584
|
+
*/
|
|
585
|
+
globalTables?: NodeGlobalStore;
|
|
356
586
|
/** Durable key-value storage backed by the same `better-sqlite3` database as `shard`. */
|
|
357
587
|
kv: ShardKvStore;
|
|
588
|
+
/** The local-filesystem bucket, or `undefined` when the caller named no bucket directory. */
|
|
589
|
+
objectStorage?: R2BucketLike;
|
|
358
590
|
/**
|
|
359
591
|
* The declared queues, or `undefined` when the caller declared none.
|
|
360
592
|
*
|
|
@@ -369,6 +601,28 @@ interface NodePlatform<Queues extends Record<string, {
|
|
|
369
601
|
shard: ShardHost;
|
|
370
602
|
/** Socket registry with mutable tags and SQLite-persisted attachments. */
|
|
371
603
|
sockets: SocketHost;
|
|
604
|
+
/**
|
|
605
|
+
* The declared workflows, or `undefined` when the caller declared none.
|
|
606
|
+
* Runs are persisted to the same `better-sqlite3` database as the shard, so
|
|
607
|
+
* they survive a restart without a second store to configure.
|
|
608
|
+
*/
|
|
609
|
+
workflows?: NodeWorkflowHost<Workflows>;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* The secrets the dispatch route authenticates with. With neither, the route
|
|
613
|
+
* refuses everything.
|
|
614
|
+
*
|
|
615
|
+
* Queue and topic delivery authenticates with `adminToken` alone:
|
|
616
|
+
* `@lunora/dispatch` always sends `Bearer <LUNORA_ADMIN_TOKEN>` and never signs,
|
|
617
|
+
* so the value here must match the token the caller puts on the env it passes
|
|
618
|
+
* `dispatchQueueBatch`. `schedulerSecret` only verifies a signed body, which the
|
|
619
|
+
* scheduler's own delivery sends; queue delivery never does.
|
|
620
|
+
*/
|
|
621
|
+
interface NodePlatformDispatchOptions {
|
|
622
|
+
/** `LUNORA_ADMIN_TOKEN`. The bearer queue and topic delivery sends, so it must match the caller's env. */
|
|
623
|
+
adminToken?: string;
|
|
624
|
+
/** `LUNORA_SCHEDULER_SECRET`. When set, a signed body is verified against it. Queue delivery does not sign. */
|
|
625
|
+
schedulerSecret?: string;
|
|
372
626
|
}
|
|
373
627
|
/**
|
|
374
628
|
* Options for {@link createNodePlatform} — the shard host's (`path`,
|
|
@@ -378,23 +632,58 @@ interface NodePlatform<Queues extends Record<string, {
|
|
|
378
632
|
* or job with nowhere to land is bookkeeping. `directory` makes the shards the
|
|
379
633
|
* directory resolves for fan-out file-backed too, and `onAlarm` gives their
|
|
380
634
|
* durable alarms somewhere to land.
|
|
635
|
+
*
|
|
636
|
+
* `queues`, `workflows`, `objectStorageDirectory` and `globalTablesPath` are the
|
|
637
|
+
* four declarations — each is absent from the returned platform when omitted.
|
|
381
638
|
*/
|
|
382
639
|
type NodePlatformOptions<Queues extends Record<string, {
|
|
383
640
|
isLunoraQueue: true;
|
|
641
|
+
}> = Record<string, never>, Workflows extends Record<string, {
|
|
642
|
+
isLunoraWorkflow: true;
|
|
384
643
|
}> = Record<string, never>> = {
|
|
644
|
+
/** Secrets for the dispatch route. Omit to leave the route refusing every request. */
|
|
645
|
+
dispatch?: NodePlatformDispatchOptions;
|
|
646
|
+
/**
|
|
647
|
+
* Database file the `.global()` tables live in — its own file, never a
|
|
648
|
+
* shard's, because a table every shard reads must not be inside any one of
|
|
649
|
+
* them. Omit when the app declares no `.global()` table; there is no
|
|
650
|
+
* default, for the same reason the bucket has none.
|
|
651
|
+
*/
|
|
652
|
+
globalTablesPath?: string;
|
|
653
|
+
/**
|
|
654
|
+
* Directory the object-storage bucket keeps its objects in, one file per
|
|
655
|
+
* key. Omit when the app declares no buckets — there is no default,
|
|
656
|
+
* because a bucket silently rooted at the process's working directory is
|
|
657
|
+
* worse than an absent one.
|
|
658
|
+
*/
|
|
659
|
+
objectStorageDirectory?: string;
|
|
385
660
|
/**
|
|
386
|
-
* Deliver one assembled queue batch — wire this to `
|
|
387
|
-
*
|
|
388
|
-
* and
|
|
661
|
+
* Deliver one assembled queue batch — wire this to the app worker's `queue`
|
|
662
|
+
* export from `createWorker`, not to bare `dispatchQueueBatch`. That export
|
|
663
|
+
* is the only path that hands the consumer `ctx.live`, and it takes
|
|
664
|
+
* `queueFetchImpl` (this platform's `dispatch`, wrapped as a `fetch`) so
|
|
665
|
+
* `ctx.run` reaches the shard here rather than `LUNORA_ORIGIN_URL`. Required
|
|
666
|
+
* alongside `queues`; without it the messages would be stored and never consumed.
|
|
389
667
|
*/
|
|
390
668
|
onQueueBatch?: NodeQueueHostOptions<Queues>["onBatch"];
|
|
391
669
|
/** The app's `defineQueue` results, keyed by export name. Omit when the app declares no queues. */
|
|
392
670
|
queues?: Queues;
|
|
671
|
+
/** The app's `defineWorkflow` results, keyed by export name. Omit when the app declares no workflows. */
|
|
672
|
+
workflows?: Workflows;
|
|
393
673
|
} & NodeSchedulerHostOptions & NodeShardHostOptions & NodeShardRegistryOptions;
|
|
394
674
|
/** Compose every contract this package provides over one `better-sqlite3` database. */
|
|
395
675
|
declare const createNodePlatform: <Queues extends Record<string, {
|
|
396
676
|
isLunoraQueue: true;
|
|
397
|
-
}> = Record<string, never
|
|
677
|
+
}> = Record<string, never>, Workflows extends Record<string, {
|
|
678
|
+
isLunoraWorkflow: true;
|
|
679
|
+
}> = Record<string, never>>(options?: NodePlatformOptions<Queues, Workflows>) => NodePlatform<Queues, Workflows>;
|
|
680
|
+
interface NodeProfileHandlerOptions {
|
|
681
|
+
/** The bearer a caller must present. Required and non-empty: an empty token would make the endpoint open to anyone. */
|
|
682
|
+
token: string;
|
|
683
|
+
}
|
|
684
|
+
type NodeProfileHandler = (request: Request) => Promise<Response>;
|
|
685
|
+
/** The public handler: the real profiler, guarded by `token`. */
|
|
686
|
+
declare const createNodeProfileHandler: ({ token }: NodeProfileHandlerOptions) => NodeProfileHandler;
|
|
398
687
|
/** Options for {@link createNodeR2Bucket}. */
|
|
399
688
|
interface NodeR2BucketOptions {
|
|
400
689
|
/** The bucket directory — created on first write. Objects live here, one file per key. */
|
|
@@ -402,10 +691,19 @@ interface NodeR2BucketOptions {
|
|
|
402
691
|
}
|
|
403
692
|
/**
|
|
404
693
|
* Create an `R2BucketLike` over the local filesystem. Any object shape
|
|
405
|
-
* `createStorage({ bucket })` accepts — `put`/`get`/`head`/`delete`/`list` —
|
|
694
|
+
* `createStorage({ bucket, bucketName })` accepts — `put`/`get`/`head`/`delete`/`list` —
|
|
406
695
|
* maps directly onto a file operation.
|
|
407
696
|
*/
|
|
408
697
|
declare const createNodeR2Bucket: (options: NodeR2BucketOptions) => R2BucketLike;
|
|
698
|
+
/**
|
|
699
|
+
* Present the node shard registry as the `ShardNamespaceLike` a worker is built
|
|
700
|
+
* over (`createWorker({ shardDO })`).
|
|
701
|
+
*
|
|
702
|
+
* The registry names its id derivation `idForName`, which is the
|
|
703
|
+
* `ShardDirectory` spelling; the worker reads Cloudflare's `idFromName`. Both
|
|
704
|
+
* return the key itself here, so a stub from either route reaches the same shard.
|
|
705
|
+
*/
|
|
706
|
+
declare const createNodeShardNamespace: (directory: DirectShardDirectory) => ShardNamespaceLike;
|
|
409
707
|
/**
|
|
410
708
|
* The `DurableObjectState` subset `ShardDO` consumes.
|
|
411
709
|
*
|
|
@@ -422,6 +720,11 @@ interface NodeShardState {
|
|
|
422
720
|
id: {
|
|
423
721
|
name?: string;
|
|
424
722
|
};
|
|
723
|
+
/** Open a connection pair. Read by `@lunora/platform-cloudflare`'s socket host, which has no `WebSocketPair` here. */
|
|
724
|
+
openSocketPair: () => {
|
|
725
|
+
client: unknown;
|
|
726
|
+
server: unknown;
|
|
727
|
+
};
|
|
425
728
|
storage: {
|
|
426
729
|
delete: (key: string) => Promise<boolean>;
|
|
427
730
|
deleteAlarm: () => Promise<void>;
|
|
@@ -438,6 +741,8 @@ interface NodeShardState {
|
|
|
438
741
|
};
|
|
439
742
|
transaction: <T>(closure: () => Promise<T>) => Promise<T>;
|
|
440
743
|
};
|
|
744
|
+
/** Build the upgrade response for a pair's client end. A Node `Response` cannot carry status 101, so this is a marker. */
|
|
745
|
+
upgradeResponse: (client: unknown) => Response;
|
|
441
746
|
waitUntil: (promise: Promise<unknown>) => void;
|
|
442
747
|
}
|
|
443
748
|
/**
|
|
@@ -452,71 +757,24 @@ interface NodeShardState {
|
|
|
452
757
|
* report a point-in-time restore that never happened.
|
|
453
758
|
*/
|
|
454
759
|
declare const createNodeShardState: (shard: NodeShard) => NodeShardState;
|
|
455
|
-
/**
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
*/
|
|
460
|
-
interface NodeSocketHost {
|
|
461
|
-
/** Read back the frames sent to a socket, oldest first, text frames only. */
|
|
462
|
-
readFrames: (handle: SocketHandle) => string[];
|
|
463
|
-
/**
|
|
464
|
-
* Re-create a runtime socket from durable state.
|
|
465
|
-
*
|
|
466
|
-
* `attachment` is a fallback only: this host restores what it persisted,
|
|
467
|
-
* because that is what a real wake looks like. The argument covers an id
|
|
468
|
-
* this host never durably tracked (a synthetic id a test constructs).
|
|
469
|
-
*/
|
|
470
|
-
restoreSocket: (id: string, attachment: unknown) => SocketHandle;
|
|
471
|
-
/** Drop the runtime socket map while keeping durable attachments/tags. */
|
|
472
|
-
simulateRecycle: () => void;
|
|
473
|
-
/** The `SocketHost` contract implementation. */
|
|
474
|
-
socket: SocketHost;
|
|
475
|
-
}
|
|
476
|
-
/** Build the socket registry, persisting attachments and tags to `database`. */
|
|
477
|
-
declare const createNodeSocketHost: (database: Database.Database) => NodeSocketHost;
|
|
478
|
-
/** Options for {@link createNodeWorkflowHost}. */
|
|
479
|
-
interface NodeWorkflowHostOptions<Workflows extends Record<string, {
|
|
480
|
-
isLunoraWorkflow: true;
|
|
481
|
-
}>> {
|
|
482
|
-
/** Base env merged under the derived `WORKFLOW_*` bindings — surfaced to workflow bodies as `ctx.env` and used to resolve spawned children. */
|
|
483
|
-
env?: Record<string, unknown>;
|
|
484
|
-
/** How long (ms) the engine holds a cross-process lease while an activation runs, for stores that implement `acquire`. Defaults to 30000. */
|
|
485
|
-
leaseTtlMs?: number;
|
|
486
|
-
/** Where runs are persisted. Required — see the header for why there is no default. `createNodeWorkflowStore(database)` is the durable one. */
|
|
487
|
-
store: WorkflowStore;
|
|
488
|
-
/** The declared workflows keyed by their `lunora/workflows.ts` export name (e.g. `{ orderPipeline: orderPipeline }`). Values must be `defineWorkflow` results. */
|
|
489
|
-
workflows: Workflows;
|
|
490
|
-
}
|
|
491
|
-
/** A fully-wired Node workflow host. */
|
|
492
|
-
interface NodeWorkflowHost<Workflows extends Record<string, {
|
|
493
|
-
isLunoraWorkflow: true;
|
|
494
|
-
}>> {
|
|
495
|
-
/** Per-export-name `WorkflowBindingLike` — the map `ctx.workflows` consumes. */
|
|
496
|
-
readonly bindings: { [K in keyof Workflows]: WorkflowBindingLike; };
|
|
497
|
-
/**
|
|
498
|
-
* The caller's `env` plus one `WORKFLOW_<EXPORT>` binding per workflow —
|
|
499
|
-
* merge this into a worker env so `ctx.spawn`/`ctx.parallel` resolve
|
|
500
|
-
* children through the same runtime.
|
|
501
|
-
*/
|
|
502
|
-
readonly env: Record<string, unknown>;
|
|
503
|
-
/** The underlying visulima runtime — `sweep`/`signal` for a dev loop or tests. */
|
|
504
|
-
readonly runtime: WorkflowRuntime;
|
|
760
|
+
/** The two socket hooks a `ShardDO` runs on the Cloudflare runtime's behalf. */
|
|
761
|
+
interface ShardSocketHooks {
|
|
762
|
+
webSocketClose(ws: unknown, code: number, reason: string, wasClean: boolean): unknown;
|
|
763
|
+
webSocketMessage(ws: unknown, message: string | ArrayBuffer): unknown;
|
|
505
764
|
}
|
|
506
765
|
/**
|
|
507
|
-
*
|
|
508
|
-
*
|
|
509
|
-
*
|
|
766
|
+
* Deliver a shard's inbound socket events. The Cloudflare runtime calls
|
|
767
|
+
* `webSocketMessage` and `webSocketClose` on the Durable Object for a hibernated
|
|
768
|
+
* socket. On Node nothing does, so the embedder calls this once per shard
|
|
769
|
+
* instance, at the same point it builds the shard.
|
|
510
770
|
*/
|
|
511
|
-
declare const
|
|
512
|
-
isLunoraWorkflow: true;
|
|
513
|
-
}>>(options: NodeWorkflowHostOptions<Workflows>) => NodeWorkflowHost<Workflows>;
|
|
771
|
+
declare const bindShardSockets: (shard: ShardSocketHooks, inbound: Pick<NodeShard["inbound"], "onClose" | "onMessage">) => void;
|
|
514
772
|
/**
|
|
515
773
|
* Build a durable {@link WorkflowStore} over a `better-sqlite3` connection.
|
|
516
774
|
* Pass the result as `createNodeWorkflowHost({ store })`.
|
|
517
775
|
*/
|
|
518
776
|
declare const createNodeWorkflowStore: (database: Database.Database) => WorkflowStore;
|
|
519
|
-
export {
|
|
777
|
+
export { NODE_SCHEDULER_DISPATCH_PATH,
|
|
520
778
|
/**
|
|
521
779
|
* `@lunora/platform-node` — a Node implementation of the `@lunora/platform`
|
|
522
780
|
* host contracts (`ShardHost`, `SocketHost`, `ShardDirectory`, `ShardKvStore`,
|
|
@@ -536,49 +794,33 @@ export {
|
|
|
536
794
|
* TCK, `@lunora/shard-engine/conformance`'s engine suite, and its own
|
|
537
795
|
* lifecycle/global-store tests.
|
|
538
796
|
*
|
|
539
|
-
* **
|
|
540
|
-
* (`@lunora/platform`):
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
* a `@lunora/config` deploy driver makes `--target node` resolve. See
|
|
548
|
-
* `plans/234-node-host-findings.md`.
|
|
549
|
-
*/
|
|
550
|
-
type NodeGlobalContextDatabaseOptions,
|
|
551
|
-
/**
|
|
552
|
-
* `@lunora/platform-node` — a Node implementation of the `@lunora/platform`
|
|
553
|
-
* host contracts (`ShardHost`, `SocketHost`, `ShardDirectory`, `ShardKvStore`,
|
|
554
|
-
* `SchedulerHost`) over `better-sqlite3` and an in-process socket/directory/
|
|
555
|
-
* scheduler registry.
|
|
556
|
-
*
|
|
557
|
-
* Promoted from `@lunora/platform`'s `node:sqlite` reference host
|
|
558
|
-
* (`src/conformance/reference-host.ts`) under plan 234, then hardened until the
|
|
559
|
-
* durability half of each contract actually holds: alarms and scheduler jobs
|
|
560
|
-
* are persisted **and re-armed on construction**, socket attachments and tags
|
|
561
|
-
* live in SQLite rather than a `Map`, and `.global()` tables run the real
|
|
562
|
-
* `@lunora/sql-store` core (`./node-global-store`). Each of those is pinned by
|
|
563
|
-
* a restart test — a second host over the same database file — not only by the
|
|
564
|
-
* TCK's simulated recycle.
|
|
797
|
+
* **Emulated here**, and rated accordingly in `NODE_CAPABILITIES`
|
|
798
|
+
* (`@lunora/platform`): queues over a durable table (`./node-queue-host`), R2
|
|
799
|
+
* buckets over the local filesystem (`./node-r2-bucket`), workflows over the
|
|
800
|
+
* `@visulima/workflow` engine (`./node-workflow-host`), and cross-shard fan-out
|
|
801
|
+
* via `@lunora/runtime`'s query coordinator over the in-process shard registry.
|
|
802
|
+
* `createNodePlatform` binds all three declarations (`queues`, `workflows`,
|
|
803
|
+
* `objectStorageDirectory`) — a capability rated `emulated` with nothing bound
|
|
804
|
+
* is the one combination that fails at runtime with no diagnostic before it.
|
|
565
805
|
*
|
|
566
|
-
*
|
|
567
|
-
*
|
|
568
|
-
*
|
|
806
|
+
* **Still missing:** a dev server. There is no `lunora dev --target node`, and
|
|
807
|
+
* nothing here owns a timer, so queue delivery is driven by an explicit
|
|
808
|
+
* `poll()`. What exists is the listener a dev server would sit on:
|
|
809
|
+
* `createNodeHttpServer` serves an app worker's `fetch` over `node:http`,
|
|
810
|
+
* streaming the response body, and `createNodeShardNamespace` presents the
|
|
811
|
+
* registry as the `shardDO` namespace that worker routes to. Also absent are
|
|
812
|
+
* the Cloudflare product bindings with no local
|
|
813
|
+
* equivalent — Vectorize, Workers AI, Browser Rendering, Containers, Analytics
|
|
814
|
+
* Engine, Pipelines, Secrets Store, Hyperdrive.
|
|
569
815
|
*
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
* (`./node-r2-bucket`) and Workflows over the `@visulima/workflow` engine
|
|
576
|
-
* (`./node-workflow-host`). Cross-shard fan-out is emulated via
|
|
577
|
-
* `@lunora/runtime`'s query coordinator over the in-process shard registry, and
|
|
578
|
-
* a `@lunora/config` deploy driver makes `--target node` resolve. See
|
|
816
|
+
* `@lunora/config` ships a `node` **deploy** driver, so `--target node` resolves
|
|
817
|
+
* for `provision` — which reports, once, which declared features this target
|
|
818
|
+
* cannot serve, and writes nothing: there is no hosted control plane to deploy
|
|
819
|
+
* to and no `wrangler`-equivalent to shell out to. A deploy driver is not a dev
|
|
820
|
+
* server, which is why both statements above hold at once. See
|
|
579
821
|
* `plans/234-node-host-findings.md`.
|
|
580
822
|
*/
|
|
581
|
-
type
|
|
823
|
+
type NodeDispatchInvocation,
|
|
582
824
|
/**
|
|
583
825
|
* `@lunora/platform-node` — a Node implementation of the `@lunora/platform`
|
|
584
826
|
* host contracts (`ShardHost`, `SocketHost`, `ShardDirectory`, `ShardKvStore`,
|
|
@@ -598,15 +840,30 @@ type NodeGlobalStore,
|
|
|
598
840
|
* TCK, `@lunora/shard-engine/conformance`'s engine suite, and its own
|
|
599
841
|
* lifecycle/global-store tests.
|
|
600
842
|
*
|
|
601
|
-
* **
|
|
602
|
-
* (`@lunora/platform`):
|
|
603
|
-
*
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
843
|
+
* **Emulated here**, and rated accordingly in `NODE_CAPABILITIES`
|
|
844
|
+
* (`@lunora/platform`): queues over a durable table (`./node-queue-host`), R2
|
|
845
|
+
* buckets over the local filesystem (`./node-r2-bucket`), workflows over the
|
|
846
|
+
* `@visulima/workflow` engine (`./node-workflow-host`), and cross-shard fan-out
|
|
847
|
+
* via `@lunora/runtime`'s query coordinator over the in-process shard registry.
|
|
848
|
+
* `createNodePlatform` binds all three declarations (`queues`, `workflows`,
|
|
849
|
+
* `objectStorageDirectory`) — a capability rated `emulated` with nothing bound
|
|
850
|
+
* is the one combination that fails at runtime with no diagnostic before it.
|
|
851
|
+
*
|
|
852
|
+
* **Still missing:** a dev server. There is no `lunora dev --target node`, and
|
|
853
|
+
* nothing here owns a timer, so queue delivery is driven by an explicit
|
|
854
|
+
* `poll()`. What exists is the listener a dev server would sit on:
|
|
855
|
+
* `createNodeHttpServer` serves an app worker's `fetch` over `node:http`,
|
|
856
|
+
* streaming the response body, and `createNodeShardNamespace` presents the
|
|
857
|
+
* registry as the `shardDO` namespace that worker routes to. Also absent are
|
|
858
|
+
* the Cloudflare product bindings with no local
|
|
859
|
+
* equivalent — Vectorize, Workers AI, Browser Rendering, Containers, Analytics
|
|
860
|
+
* Engine, Pipelines, Secrets Store, Hyperdrive.
|
|
861
|
+
*
|
|
862
|
+
* `@lunora/config` ships a `node` **deploy** driver, so `--target node` resolves
|
|
863
|
+
* for `provision` — which reports, once, which declared features this target
|
|
864
|
+
* cannot serve, and writes nothing: there is no hosted control plane to deploy
|
|
865
|
+
* to and no `wrangler`-equivalent to shell out to. A deploy driver is not a dev
|
|
866
|
+
* server, which is why both statements above hold at once. See
|
|
610
867
|
* `plans/234-node-host-findings.md`.
|
|
611
868
|
*/
|
|
612
|
-
type NodeGlobalStoreOptions, type NodePlatform, type NodePlatformOptions, type NodeQueueHost, type NodeQueueHostOptions, type NodeR2BucketOptions, type NodeSchedulerHost, type NodeSchedulerHostOptions, type NodeShard, type NodeShardHostOptions, type NodeShardRegistry, type NodeShardRegistryOptions, type NodeShardState, type NodeSocketHost, type NodeWorkflowHost, type NodeWorkflowHostOptions, createNodeGlobalStore, createNodePlatform, createNodeQueueHost, createNodeR2Bucket, createNodeSchedulerHost, createNodeShardHost, createNodeShardKvStore, createNodeShardRegistry, createNodeShardState, createNodeSocketHost, createNodeSqlExec, createNodeWorkflowHost, createNodeWorkflowStore };
|
|
869
|
+
type NodeDispatchRouteOptions, type NodeGlobalContextDatabaseOptions, type NodeGlobalStore, type NodeGlobalStoreOptions, type NodeHttpServer, type NodeHttpServerOptions, type NodePlatform, type NodePlatformDispatchOptions, type NodePlatformOptions, type NodeProfileHandler, type NodeProfileHandlerOptions, type NodeQueueHost, type NodeQueueHostOptions, type NodeR2BucketOptions, type NodeSchedulerHost, type NodeSchedulerHostOptions, type NodeShard, type NodeShardHostOptions, type NodeShardRegistry, type NodeShardRegistryOptions, type NodeShardState, type NodeSocketHost, type NodeWorkflowHost, type NodeWorkflowHostOptions, type ShardSocketHooks, bindShardSockets, createNodeDispatchRoute, createNodeGlobalStore, createNodeHttpServer, createNodePlatform, createNodeProfileHandler, createNodeQueueHost, createNodeR2Bucket, createNodeSchedulerHost, createNodeShardHost, createNodeShardKvStore, createNodeShardNamespace, createNodeShardRegistry, createNodeShardState, createNodeSocketHost, createNodeSqlExec, createNodeWorkflowHost, createNodeWorkflowStore };
|