@lunora/platform-node 1.0.0-alpha.221 → 1.0.0-alpha.222
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 +1 -1
- package/dist/conformance/index.mjs +1 -1
- package/dist/index.d.mts +220 -150
- package/dist/index.d.ts +220 -150
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{NODE_SCHEDULER_DISPATCH_PATH-uDl0zU2t.mjs → NODE_SCHEDULER_DISPATCH_PATH-DmMrAPjT.mjs} +1 -1
- package/dist/packem_shared/bindShardSockets-DjLmRlIA.mjs +1 -0
- package/dist/packem_shared/checkNodeAppHost-Cv5p7igg.mjs +1 -0
- package/dist/packem_shared/createNodeDurableObjectFactory-hAwJt_pN.mjs +1 -0
- package/dist/packem_shared/{createNodePlatform-BqtVmQqS.mjs → createNodePlatform-De8dIBya.mjs} +1 -1
- package/dist/packem_shared/createNodeShardHost-DZ2cwIKF.mjs +1 -0
- package/dist/packem_shared/createNodeShardRegistry-D1r6M8Rg.mjs +1 -0
- package/dist/packem_shared/node-dispatch-route-B3GAZkHT.mjs +2 -0
- package/package.json +3 -3
- package/dist/packem_shared/bindShardSockets-9GvSocBW.mjs +0 -1
- package/dist/packem_shared/createNodeShardHost-VU8MPeba.mjs +0 -1
- package/dist/packem_shared/createNodeShardRegistry-C1SRJQhd.mjs +0 -1
- package/dist/packem_shared/node-dispatch-route-ByuCR26s.mjs +0 -2
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ Portability was a claim, not a construction check — `PLATFORM_MATRICES` held e
|
|
|
16
16
|
|
|
17
17
|
## Scope
|
|
18
18
|
|
|
19
|
-
This is a **spike**, not a production target:
|
|
19
|
+
This is a **spike**, not a production target: `lunora dev --target node` serves an app on it, it deploys only as the container build context `lunora deploy --target node` writes, and several capabilities are honestly rated `emulated`/`unsupported` in its capability matrix entry (see `@lunora/platform`'s `NODE_CAPABILITIES`).
|
|
20
20
|
|
|
21
21
|
## On-demand profiling
|
|
22
22
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NODE_CAPABILITIES as g}from"@lunora/platform";import{createNodeShardKvStore as D}from"../packem_shared/createNodeShardKvStore-DVi1OsvH.mjs";import{createNodeSchedulerHost as k}from"../packem_shared/createNodeSchedulerHost-BQPmMWJ7.mjs";import{createNodeShardHost as T}from"../packem_shared/createNodeShardHost-
|
|
1
|
+
import{NODE_CAPABILITIES as g}from"@lunora/platform";import{createNodeShardKvStore as D}from"../packem_shared/createNodeShardKvStore-DVi1OsvH.mjs";import{createNodeSchedulerHost as k}from"../packem_shared/createNodeSchedulerHost-BQPmMWJ7.mjs";import{createNodeShardHost as T}from"../packem_shared/createNodeShardHost-DZ2cwIKF.mjs";import{createNodeShardRegistry as H}from"../packem_shared/createNodeShardRegistry-D1r6M8Rg.mjs";import{createNodeSocketHost as b}from"../packem_shared/createNodeSocketHost-ByOmEGFe.mjs";const P=()=>{const{database:o,dispose:m,host:p}=T(),h=D(o),i=H(),{directory:l}=i,{readFrames:w,restoreSocket:S,simulateRecycle:u,socket:f}=b(o),c=new Set,s=new Map,{dispose:y,scheduler:d,simulateDeadLetter:N}=k(o,{onDispatch:(e,a,t)=>{c.add(t.id),s.set(e,(s.get(e)??0)+1)}}),n=()=>{y(),m(),i.close()};return{capabilities:g,awaitAlarmFired:async e=>{await new Promise(a=>{setTimeout(a,Math.max(0,e-Date.now())+30)})},awaitJobDispatched:async e=>{const t=(await d.list?.())?.find(r=>r.id===e);return t!==void 0&&await new Promise(r=>{setTimeout(r,Math.max(0,t.scheduledFor-Date.now())+30)}),c.has(e)},cleanup:n,cronTicks:e=>s.get(e)??0,directory:l,disposeTerminally:n,kv:h,readFrames:w,restoreSocket:S,scheduler:d,shard:p,simulateDeadLetter:N,simulateRecycle:u,socket:f}};export{P as createNodeConformanceHost};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { QueueBindingLike, MessageBatchLike, SchedulerHost, ShardHost, SocketHandle, SocketHost, ShardKvStore, DirectShardDirectory, PlatformCapabilities, R2BucketLike } from '@lunora/platform';
|
|
1
2
|
import { SchemaLike } from '@lunora/shard-engine';
|
|
2
3
|
import { SqlCtxDbOptions, SqlCtxExec, createSqlCtxDb } from '@lunora/sql-store';
|
|
3
4
|
import Database from 'better-sqlite3';
|
|
4
|
-
import { ShardKvStore, QueueBindingLike, MessageBatchLike, SchedulerHost, ShardHost, SocketHandle, SocketHost, DirectShardDirectory, PlatformCapabilities, ShardDirectory, R2BucketLike } from '@lunora/platform';
|
|
5
5
|
import { Mailer, QueueLike, MailEnv, MailTransport } from '@lunora/mail';
|
|
6
6
|
import { WorkflowBindingLike } from '@lunora/workflow';
|
|
7
7
|
import { WorkflowRuntime, WorkflowStore } from '@visulima/workflow';
|
|
@@ -155,78 +155,6 @@ interface NodeGlobalStore {
|
|
|
155
155
|
* which is the whole point of the dialect seam.
|
|
156
156
|
*/
|
|
157
157
|
declare const createNodeGlobalStore: (options?: NodeGlobalStoreOptions) => NodeGlobalStore;
|
|
158
|
-
/** Serve `options.fetch` over `node:http`. Resolves once the server is listening. */
|
|
159
|
-
declare const createNodeHttpServer: (options: NodeHttpServerOptions) => Promise<NodeHttpServer>;
|
|
160
|
-
/** Options for {@link createNodeHttpServer}. */
|
|
161
|
-
interface NodeHttpServerOptions {
|
|
162
|
-
/** The app worker's `fetch`, already bound to its env and context. */
|
|
163
|
-
fetch: (request: Request) => Promise<Response> | Response;
|
|
164
|
-
/** Host to bind. Defaults to the loopback interface. */
|
|
165
|
-
host?: string;
|
|
166
|
-
/**
|
|
167
|
-
* The public base URL the app is served at, e.g. `https://app.example`. Every request URL uses its origin, so origin-sensitive
|
|
168
|
-
* behaviour (CSRF, WebSocket origin checks, cookie rules) sees the public scheme behind a TLS proxy. The client's `Host` header is
|
|
169
|
-
* never used. Defaults to the bound `http://host:port`, which is only allowed for a loopback `host`: binding a non-loopback address
|
|
170
|
-
* (e.g. `0.0.0.0` or a LAN IP) without `origin` makes {@link createNodeHttpServer} reject, because browsers would send that address
|
|
171
|
-
* as `Origin` and fail the CSRF check. Set `origin` to the URL users open.
|
|
172
|
-
*/
|
|
173
|
-
origin?: string;
|
|
174
|
-
/** Port to bind. `0` (the default) picks a free ephemeral port. */
|
|
175
|
-
port?: number;
|
|
176
|
-
}
|
|
177
|
-
/** A listening server. */
|
|
178
|
-
interface NodeHttpServer {
|
|
179
|
-
/** Stop accepting connections and end every open one, streams included. */
|
|
180
|
-
close: () => Promise<void>;
|
|
181
|
-
/**
|
|
182
|
-
* Stop accepting connections, then wait until every HTTP response that was in progress when the drain began has been written
|
|
183
|
-
* to the end or its client has gone, or until the deadline passes (`timeoutMs`, 30 s by default). A request that still
|
|
184
|
-
* arrives on an open connection is answered with keep-alive off and is not waited for. Event streams (`text/event-stream`)
|
|
185
|
-
* and WebSockets are endless by design and are not waited for; {@link NodeHttpServer.close} ends them. Resolves with what was
|
|
186
|
-
* still unfinished when the deadline passed, which it also logs.
|
|
187
|
-
*/
|
|
188
|
-
drain: (options?: DrainOptions) => Promise<DrainResult>;
|
|
189
|
-
/** The `http://host:port` origin the server answers on. */
|
|
190
|
-
origin: string;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* The connection fields a Cloudflare `Hyperdrive` binding exposes, and the
|
|
194
|
-
* `HyperdriveLike` shape `@lunora/hyperdrive`'s `createHyperdrive` reads.
|
|
195
|
-
* Declared here structurally so this package does not depend on
|
|
196
|
-
* `@lunora/hyperdrive` for a type.
|
|
197
|
-
*/
|
|
198
|
-
interface NodeHyperdriveBinding {
|
|
199
|
-
connectionString: string;
|
|
200
|
-
database: string;
|
|
201
|
-
host: string;
|
|
202
|
-
password: string;
|
|
203
|
-
port: number;
|
|
204
|
-
user: string;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Build the `HYPERDRIVE` binding for a Node host from a database URL, by
|
|
208
|
-
* default `process.env.DATABASE_URL`. Put it on the `env` the worker and shard
|
|
209
|
-
* are built over, under the binding name the app reads (`env.HYPERDRIVE`), and
|
|
210
|
-
* the app's own `.hyperdrive((env) => …)` wiring builds `ctx.sql` from it
|
|
211
|
-
* unchanged.
|
|
212
|
-
*
|
|
213
|
-
* There is no pool or query cache in front of the database here: the driver
|
|
214
|
-
* the app constructs from `connectionString` connects to it directly, so its own
|
|
215
|
-
* pool settings are the only ones that apply.
|
|
216
|
-
* A Postgres URL may name a Unix socket the libpq way: an empty host with the
|
|
217
|
-
* socket directory in a `host` query parameter (`postgres:///db?host=/var/run/postgresql`),
|
|
218
|
-
* which becomes the binding's `host`.
|
|
219
|
-
*
|
|
220
|
-
* A URL with any TLS option other than an explicit off (`sslmode=prefer` or
|
|
221
|
-
* `require`, `ssl=true`, `sslrootcert=…`) gets a binding whose discrete fields
|
|
222
|
-
* throw: they cannot carry it, so a pool built from them would silently connect
|
|
223
|
-
* without TLS. `sslmode=disable` and `ssl=false` keep them. Build the driver
|
|
224
|
-
* from `connectionString`, which keeps every query option.
|
|
225
|
-
* @param url A `postgres://`, `postgresql://`, `mysql://` or `mariadb://` URL; `DATABASE_URL` unless given.
|
|
226
|
-
*/
|
|
227
|
-
declare const createNodeHyperdrive: (url?: string | undefined) => NodeHyperdriveBinding;
|
|
228
|
-
/** Build a `ShardKvStore` over a `better-sqlite3` table in the shard's database. */
|
|
229
|
-
declare const createNodeShardKvStore: (database: Database.Database) => ShardKvStore;
|
|
230
158
|
/** Options for {@link createNodeMailHost}. */
|
|
231
159
|
interface NodeMailHostOptions {
|
|
232
160
|
/**
|
|
@@ -553,7 +481,8 @@ interface NodeShardHostOptions {
|
|
|
553
481
|
* rather than closing `database` directly, so the alarm timer and the
|
|
554
482
|
* connection are always retired together.
|
|
555
483
|
*/
|
|
556
|
-
|
|
484
|
+
/** What {@link createNodeShardHost} returns. */
|
|
485
|
+
interface NodeShardHostParts {
|
|
557
486
|
/** Settles once every alarm delivery running now (its handler and any retry write) has; `undefined` when none is. */
|
|
558
487
|
alarmsSettled: () => Promise<unknown> | undefined;
|
|
559
488
|
database: Database.Database;
|
|
@@ -566,7 +495,8 @@ declare const createNodeShardHost: (options?: NodeShardHostOptions) => {
|
|
|
566
495
|
suspendAlarms: () => void;
|
|
567
496
|
/** The failures recorded since the last call, which a drain reports in its result; each is also logged when it happens. */
|
|
568
497
|
takeFailures: () => string[];
|
|
569
|
-
}
|
|
498
|
+
}
|
|
499
|
+
declare const createNodeShardHost: (options?: NodeShardHostOptions) => NodeShardHostParts;
|
|
570
500
|
/** The end a shard accepts. Its `send` and `close` are what the socket host calls through its handle. */
|
|
571
501
|
interface NodeServerEnd {
|
|
572
502
|
close: (code?: number, reason?: string) => void;
|
|
@@ -797,7 +727,7 @@ interface NodePlatform<Queues extends Record<string, {
|
|
|
797
727
|
force?: boolean;
|
|
798
728
|
}) => void;
|
|
799
729
|
/** In-process shard directory (see `createNodeShardRegistry` for what it can and cannot do). */
|
|
800
|
-
directory:
|
|
730
|
+
directory: DirectShardDirectory;
|
|
801
731
|
/**
|
|
802
732
|
* The scheduler dispatch route, served in-process: `Request` in, shard
|
|
803
733
|
* response out, no listener. It answers the path `@lunora/dispatch` and
|
|
@@ -991,6 +921,142 @@ declare const createNodePlatform: <Queues extends Record<string, {
|
|
|
991
921
|
}> = Record<string, never>, Workflows extends Record<string, {
|
|
992
922
|
isLunoraWorkflow: true;
|
|
993
923
|
}> = Record<string, never>>(options?: NodePlatformOptions<Queues, Workflows>) => NodePlatform<Queues, Workflows>;
|
|
924
|
+
/** One `durable_objects.bindings[]` entry: the `env` key and the exported class behind it. */
|
|
925
|
+
interface NodeAppDurableObjectBinding {
|
|
926
|
+
className: string;
|
|
927
|
+
name: string;
|
|
928
|
+
}
|
|
929
|
+
/** Options for {@link createNodeAppHost}. */
|
|
930
|
+
interface NodeAppHostOptions {
|
|
931
|
+
/**
|
|
932
|
+
* The app's declared crons — the generated `LUNORA_CRONS` map. Armed on the {@link NodeAppHostOptions.shardBinding} platform and
|
|
933
|
+
* delivered to its default shard, as `createNodePlatform`'s `crons` are. The map is the whole declared set, so a host built
|
|
934
|
+
* without a job an earlier one declared deletes it.
|
|
935
|
+
*/
|
|
936
|
+
crons?: Readonly<Record<string, ReadonlyArray<NodeCronJob>>>;
|
|
937
|
+
/**
|
|
938
|
+
* Directory the shard databases live in, one subdirectory per binding. Omit for in-memory shards, which lose every row when the
|
|
939
|
+
* host closes.
|
|
940
|
+
*/
|
|
941
|
+
dataDirectory?: string;
|
|
942
|
+
/** The wrangler config's `durable_objects.bindings`. Each `className` must be a named export of `worker`. */
|
|
943
|
+
durableObjects: ReadonlyArray<NodeAppDurableObjectBinding>;
|
|
944
|
+
/** Plain values for `env`: vars, dev vars, and any binding the caller composes itself. A Durable Object binding of the same name wins. */
|
|
945
|
+
env?: Record<string, unknown>;
|
|
946
|
+
/** The Durable Object binding whose shards run functions, which is where crons fire. Defaults to `SHARD`. */
|
|
947
|
+
shardBinding?: string;
|
|
948
|
+
/** The imported worker module. */
|
|
949
|
+
worker: Record<string, unknown>;
|
|
950
|
+
}
|
|
951
|
+
/** A worker module composed over this host. */
|
|
952
|
+
interface NodeAppHost {
|
|
953
|
+
/**
|
|
954
|
+
* Drain, then close: wait under one deadline (`timeoutMs`, 30 s by default) for the requests `fetch` is still answering, the
|
|
955
|
+
* worker's `waitUntil` work, and every
|
|
956
|
+
* platform to go idle (in-flight shard requests, alarms, cron deliveries and each shard's own `waitUntil` work), then close
|
|
957
|
+
* every platform, cron timers included. The close runs whether or not the drain finished in time, so a reload never opens the
|
|
958
|
+
* databases while this host still holds them. Resolves with what the drain cut off or saw fail. Safe to call more than once.
|
|
959
|
+
*/
|
|
960
|
+
close: (options?: DrainOptions) => Promise<DrainResult>;
|
|
961
|
+
/** The worker's `fetch`, bound to the composed `env`. Hand it to `createNodeHttpServer`. */
|
|
962
|
+
fetch: (request: Request) => Promise<Response>;
|
|
963
|
+
/**
|
|
964
|
+
* Open every stored shard with a persisted alarm, so its alarm fires without waiting for a request to reach it. Call once
|
|
965
|
+
* the host serves; a shard opens its database here, so a caller replacing an older host calls it after closing that one.
|
|
966
|
+
*/
|
|
967
|
+
rearmPersistedAlarms: () => string[];
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Throw what `createNodeAppHost` would refuse for `options`, without opening a database or arming a timer: the default export,
|
|
971
|
+
* every binding's name and class, and the declared crons. `createNodeAppHost` runs it before building anything, so a refused composition
|
|
972
|
+
* changes no stored state (cron rows included); a caller replacing a running host runs it first, so a refused candidate leaves
|
|
973
|
+
* that host serving.
|
|
974
|
+
*/
|
|
975
|
+
declare const checkNodeAppHost: (options: NodeAppHostOptions) => void;
|
|
976
|
+
/** Compose `worker` over one in-process platform per Durable Object binding. */
|
|
977
|
+
declare const createNodeAppHost: (options: NodeAppHostOptions) => NodeAppHost;
|
|
978
|
+
/** What a Durable Object instance must answer on this host. The socket and alarm hooks are optional, as on Cloudflare. */
|
|
979
|
+
interface NodeDurableObjectInstance {
|
|
980
|
+
alarm?: () => Promise<void> | void;
|
|
981
|
+
fetch: (request: Request) => Promise<Response> | Response;
|
|
982
|
+
webSocketClose?: (socket: unknown, code: number, reason: string, wasClean: boolean) => Promise<void> | void;
|
|
983
|
+
webSocketMessage?: (socket: unknown, data: ArrayBuffer | string) => Promise<void> | void;
|
|
984
|
+
}
|
|
985
|
+
type NodeDurableObjectClass = new (state: never, env: Record<string, unknown>) => NodeDurableObjectInstance;
|
|
986
|
+
/** The instance of `DurableObject` for a shard, constructed on first use and once it is ready. */
|
|
987
|
+
declare const createNodeDurableObjectFactory: (DurableObject: NodeDurableObjectClass, env: Record<string, unknown>) => ((shard: NodeShard) => Promise<NodeDurableObjectInstance>);
|
|
988
|
+
/** Serve `options.fetch` over `node:http`. Resolves once the server is listening. */
|
|
989
|
+
declare const createNodeHttpServer: (options: NodeHttpServerOptions) => Promise<NodeHttpServer>;
|
|
990
|
+
/** Options for {@link createNodeHttpServer}. */
|
|
991
|
+
interface NodeHttpServerOptions {
|
|
992
|
+
/** The app worker's `fetch`, already bound to its env and context. */
|
|
993
|
+
fetch: (request: Request) => Promise<Response> | Response;
|
|
994
|
+
/** Host to bind. Defaults to the loopback interface. */
|
|
995
|
+
host?: string;
|
|
996
|
+
/**
|
|
997
|
+
* The public base URL the app is served at, e.g. `https://app.example`. Every request URL uses its origin, so origin-sensitive
|
|
998
|
+
* behaviour (CSRF, WebSocket origin checks, cookie rules) sees the public scheme behind a TLS proxy. The client's `Host` header is
|
|
999
|
+
* never used. Defaults to the bound `http://host:port`, which is only allowed for a loopback `host`: binding a non-loopback address
|
|
1000
|
+
* (e.g. `0.0.0.0` or a LAN IP) without `origin` makes {@link createNodeHttpServer} reject, because browsers would send that address
|
|
1001
|
+
* as `Origin` and fail the CSRF check. Set `origin` to the URL users open.
|
|
1002
|
+
*/
|
|
1003
|
+
origin?: string;
|
|
1004
|
+
/** Port to bind. `0` (the default) picks a free ephemeral port. */
|
|
1005
|
+
port?: number;
|
|
1006
|
+
}
|
|
1007
|
+
/** A listening server. */
|
|
1008
|
+
interface NodeHttpServer {
|
|
1009
|
+
/** Stop accepting connections and end every open one, streams included. */
|
|
1010
|
+
close: () => Promise<void>;
|
|
1011
|
+
/**
|
|
1012
|
+
* Stop accepting connections, then wait until every HTTP response that was in progress when the drain began has been written
|
|
1013
|
+
* to the end or its client has gone, or until the deadline passes (`timeoutMs`, 30 s by default). A request that still
|
|
1014
|
+
* arrives on an open connection is answered with keep-alive off and is not waited for. Event streams (`text/event-stream`)
|
|
1015
|
+
* and WebSockets are endless by design and are not waited for; {@link NodeHttpServer.close} ends them. Resolves with what was
|
|
1016
|
+
* still unfinished when the deadline passed, which it also logs.
|
|
1017
|
+
*/
|
|
1018
|
+
drain: (options?: DrainOptions) => Promise<DrainResult>;
|
|
1019
|
+
/** The `http://host:port` origin the server answers on. */
|
|
1020
|
+
origin: string;
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* The connection fields a Cloudflare `Hyperdrive` binding exposes, and the
|
|
1024
|
+
* `HyperdriveLike` shape `@lunora/hyperdrive`'s `createHyperdrive` reads.
|
|
1025
|
+
* Declared here structurally so this package does not depend on
|
|
1026
|
+
* `@lunora/hyperdrive` for a type.
|
|
1027
|
+
*/
|
|
1028
|
+
interface NodeHyperdriveBinding {
|
|
1029
|
+
connectionString: string;
|
|
1030
|
+
database: string;
|
|
1031
|
+
host: string;
|
|
1032
|
+
password: string;
|
|
1033
|
+
port: number;
|
|
1034
|
+
user: string;
|
|
1035
|
+
}
|
|
1036
|
+
/**
|
|
1037
|
+
* Build the `HYPERDRIVE` binding for a Node host from a database URL, by
|
|
1038
|
+
* default `process.env.DATABASE_URL`. Put it on the `env` the worker and shard
|
|
1039
|
+
* are built over, under the binding name the app reads (`env.HYPERDRIVE`), and
|
|
1040
|
+
* the app's own `.hyperdrive((env) => …)` wiring builds `ctx.sql` from it
|
|
1041
|
+
* unchanged.
|
|
1042
|
+
*
|
|
1043
|
+
* There is no pool or query cache in front of the database here: the driver
|
|
1044
|
+
* the app constructs from `connectionString` connects to it directly, so its own
|
|
1045
|
+
* pool settings are the only ones that apply.
|
|
1046
|
+
* A Postgres URL may name a Unix socket the libpq way: an empty host with the
|
|
1047
|
+
* socket directory in a `host` query parameter (`postgres:///db?host=/var/run/postgresql`),
|
|
1048
|
+
* which becomes the binding's `host`.
|
|
1049
|
+
*
|
|
1050
|
+
* A URL with any TLS option other than an explicit off (`sslmode=prefer` or
|
|
1051
|
+
* `require`, `ssl=true`, `sslrootcert=…`) gets a binding whose discrete fields
|
|
1052
|
+
* throw: they cannot carry it, so a pool built from them would silently connect
|
|
1053
|
+
* without TLS. `sslmode=disable` and `ssl=false` keep them. Build the driver
|
|
1054
|
+
* from `connectionString`, which keeps every query option.
|
|
1055
|
+
* @param url A `postgres://`, `postgresql://`, `mysql://` or `mariadb://` URL; `DATABASE_URL` unless given.
|
|
1056
|
+
*/
|
|
1057
|
+
declare const createNodeHyperdrive: (url?: string | undefined) => NodeHyperdriveBinding;
|
|
1058
|
+
/** Build a `ShardKvStore` over a `better-sqlite3` table in the shard's database. */
|
|
1059
|
+
declare const createNodeShardKvStore: (database: Database.Database) => ShardKvStore;
|
|
994
1060
|
interface NodeProfileHandlerOptions {
|
|
995
1061
|
/** The bearer a caller must present. Required and non-empty: an empty token would make the endpoint open to anyone. */
|
|
996
1062
|
token: string;
|
|
@@ -1092,7 +1158,11 @@ interface NodeShardState {
|
|
|
1092
1158
|
* one local `wrangler dev` takes — whereas supplying a stub that resolves would
|
|
1093
1159
|
* report a point-in-time restore that never happened.
|
|
1094
1160
|
*/
|
|
1095
|
-
|
|
1161
|
+
/**
|
|
1162
|
+
* `onBlockConcurrency` sees each `blockConcurrencyWhile` promise as it starts, so a caller can tell when the work an object's
|
|
1163
|
+
* constructor gated behind it has finished (see `createNodeDurableObjectFactory`).
|
|
1164
|
+
*/
|
|
1165
|
+
declare const createNodeShardState: (shard: NodeShard, onBlockConcurrency?: (work: Promise<unknown>) => void) => NodeShardState;
|
|
1096
1166
|
/** The two socket hooks a `ShardDO` runs on the Cloudflare runtime's behalf. */
|
|
1097
1167
|
interface ShardSocketHooks {
|
|
1098
1168
|
webSocketClose(ws: unknown, code: number, reason: string, wasClean: boolean): unknown;
|
|
@@ -1139,30 +1209,30 @@ export { DEFAULT_DRAIN_TIMEOUT_MS,
|
|
|
1139
1209
|
* `objectStorageDirectory`) — a capability rated `emulated` with nothing bound
|
|
1140
1210
|
* is the one combination that fails at runtime with no diagnostic before it.
|
|
1141
1211
|
*
|
|
1142
|
-
* **
|
|
1143
|
-
*
|
|
1144
|
-
* `
|
|
1145
|
-
* `
|
|
1146
|
-
*
|
|
1147
|
-
*
|
|
1148
|
-
*
|
|
1149
|
-
*
|
|
1150
|
-
*
|
|
1151
|
-
*
|
|
1152
|
-
*
|
|
1153
|
-
*
|
|
1154
|
-
*
|
|
1212
|
+
* **Serving an app.** `createNodeAppHost` composes a worker entry module over
|
|
1213
|
+
* one shard registry per Durable Object binding, and `createNodeHttpServer`
|
|
1214
|
+
* serves its `fetch` over `node:http`, streaming the response body. `lunora dev
|
|
1215
|
+
* --target node` runs exactly that pair. Nothing here owns a timer, so queue
|
|
1216
|
+
* delivery is driven by an explicit `poll()`. Absent are the Cloudflare product
|
|
1217
|
+
* bindings with no local equivalent — Vectorize, Workers AI, Browser Rendering,
|
|
1218
|
+
* Containers, Analytics Engine, Pipelines. `ctx.secrets` reads environment
|
|
1219
|
+
* variables through `createNodeSecretBindings` (`./node-secrets`), and the
|
|
1220
|
+
* Hyperdrive binding is built from `DATABASE_URL` by `createNodeHyperdrive`
|
|
1221
|
+
* (`./node-hyperdrive`). Queued `@lunora/mail` sends are delivered by
|
|
1222
|
+
* `createNodeMailHost` (`./node-mail-host`) through Resend or a caller-supplied
|
|
1223
|
+
* transport, for a process that composes it and polls it, as the server
|
|
1224
|
+
* `lunora deploy --target node` writes does. `lunora dev --target node` composes
|
|
1225
|
+
* none: there mail is captured to the Studio inbox, and with capture turned off
|
|
1226
|
+
* a queued send is not delivered.
|
|
1155
1227
|
*
|
|
1156
1228
|
* `lunora deploy --target node` bundles an app into a container build context
|
|
1157
1229
|
* whose generated entry composes this package (crons, `ctx.secrets`,
|
|
1158
1230
|
* Hyperdrive from `DATABASE_URL`) and serves it with `createNodeHttpServer`.
|
|
1159
1231
|
*
|
|
1160
1232
|
* `@lunora/config` ships a `node` **deploy** driver, so `--target node` resolves
|
|
1161
|
-
*
|
|
1162
|
-
*
|
|
1163
|
-
*
|
|
1164
|
-
* server, which is why both statements above hold at once. See
|
|
1165
|
-
* `plans/234-node-host-findings.md`.
|
|
1233
|
+
* and codegen gates against `NODE_CAPABILITIES`. There is no hosted control
|
|
1234
|
+
* plane to deploy to and no `wrangler`-equivalent to shell out to, which is why
|
|
1235
|
+
* the deploy stops at a build context. See `plans/234-node-host-findings.md`.
|
|
1166
1236
|
*/
|
|
1167
1237
|
type DrainOptions,
|
|
1168
1238
|
/**
|
|
@@ -1193,30 +1263,30 @@ type DrainOptions,
|
|
|
1193
1263
|
* `objectStorageDirectory`) — a capability rated `emulated` with nothing bound
|
|
1194
1264
|
* is the one combination that fails at runtime with no diagnostic before it.
|
|
1195
1265
|
*
|
|
1196
|
-
* **
|
|
1197
|
-
*
|
|
1198
|
-
* `
|
|
1199
|
-
* `
|
|
1200
|
-
*
|
|
1201
|
-
*
|
|
1202
|
-
*
|
|
1203
|
-
*
|
|
1204
|
-
*
|
|
1205
|
-
*
|
|
1206
|
-
*
|
|
1207
|
-
*
|
|
1208
|
-
*
|
|
1266
|
+
* **Serving an app.** `createNodeAppHost` composes a worker entry module over
|
|
1267
|
+
* one shard registry per Durable Object binding, and `createNodeHttpServer`
|
|
1268
|
+
* serves its `fetch` over `node:http`, streaming the response body. `lunora dev
|
|
1269
|
+
* --target node` runs exactly that pair. Nothing here owns a timer, so queue
|
|
1270
|
+
* delivery is driven by an explicit `poll()`. Absent are the Cloudflare product
|
|
1271
|
+
* bindings with no local equivalent — Vectorize, Workers AI, Browser Rendering,
|
|
1272
|
+
* Containers, Analytics Engine, Pipelines. `ctx.secrets` reads environment
|
|
1273
|
+
* variables through `createNodeSecretBindings` (`./node-secrets`), and the
|
|
1274
|
+
* Hyperdrive binding is built from `DATABASE_URL` by `createNodeHyperdrive`
|
|
1275
|
+
* (`./node-hyperdrive`). Queued `@lunora/mail` sends are delivered by
|
|
1276
|
+
* `createNodeMailHost` (`./node-mail-host`) through Resend or a caller-supplied
|
|
1277
|
+
* transport, for a process that composes it and polls it, as the server
|
|
1278
|
+
* `lunora deploy --target node` writes does. `lunora dev --target node` composes
|
|
1279
|
+
* none: there mail is captured to the Studio inbox, and with capture turned off
|
|
1280
|
+
* a queued send is not delivered.
|
|
1209
1281
|
*
|
|
1210
1282
|
* `lunora deploy --target node` bundles an app into a container build context
|
|
1211
1283
|
* whose generated entry composes this package (crons, `ctx.secrets`,
|
|
1212
1284
|
* Hyperdrive from `DATABASE_URL`) and serves it with `createNodeHttpServer`.
|
|
1213
1285
|
*
|
|
1214
1286
|
* `@lunora/config` ships a `node` **deploy** driver, so `--target node` resolves
|
|
1215
|
-
*
|
|
1216
|
-
*
|
|
1217
|
-
*
|
|
1218
|
-
* server, which is why both statements above hold at once. See
|
|
1219
|
-
* `plans/234-node-host-findings.md`.
|
|
1287
|
+
* and codegen gates against `NODE_CAPABILITIES`. There is no hosted control
|
|
1288
|
+
* plane to deploy to and no `wrangler`-equivalent to shell out to, which is why
|
|
1289
|
+
* the deploy stops at a build context. See `plans/234-node-host-findings.md`.
|
|
1220
1290
|
*/
|
|
1221
1291
|
type DrainResult,
|
|
1222
1292
|
/**
|
|
@@ -1247,30 +1317,30 @@ type DrainResult,
|
|
|
1247
1317
|
* `objectStorageDirectory`) — a capability rated `emulated` with nothing bound
|
|
1248
1318
|
* is the one combination that fails at runtime with no diagnostic before it.
|
|
1249
1319
|
*
|
|
1250
|
-
* **
|
|
1251
|
-
*
|
|
1252
|
-
* `
|
|
1253
|
-
* `
|
|
1254
|
-
*
|
|
1255
|
-
*
|
|
1256
|
-
*
|
|
1257
|
-
*
|
|
1258
|
-
*
|
|
1259
|
-
*
|
|
1260
|
-
*
|
|
1261
|
-
*
|
|
1262
|
-
*
|
|
1320
|
+
* **Serving an app.** `createNodeAppHost` composes a worker entry module over
|
|
1321
|
+
* one shard registry per Durable Object binding, and `createNodeHttpServer`
|
|
1322
|
+
* serves its `fetch` over `node:http`, streaming the response body. `lunora dev
|
|
1323
|
+
* --target node` runs exactly that pair. Nothing here owns a timer, so queue
|
|
1324
|
+
* delivery is driven by an explicit `poll()`. Absent are the Cloudflare product
|
|
1325
|
+
* bindings with no local equivalent — Vectorize, Workers AI, Browser Rendering,
|
|
1326
|
+
* Containers, Analytics Engine, Pipelines. `ctx.secrets` reads environment
|
|
1327
|
+
* variables through `createNodeSecretBindings` (`./node-secrets`), and the
|
|
1328
|
+
* Hyperdrive binding is built from `DATABASE_URL` by `createNodeHyperdrive`
|
|
1329
|
+
* (`./node-hyperdrive`). Queued `@lunora/mail` sends are delivered by
|
|
1330
|
+
* `createNodeMailHost` (`./node-mail-host`) through Resend or a caller-supplied
|
|
1331
|
+
* transport, for a process that composes it and polls it, as the server
|
|
1332
|
+
* `lunora deploy --target node` writes does. `lunora dev --target node` composes
|
|
1333
|
+
* none: there mail is captured to the Studio inbox, and with capture turned off
|
|
1334
|
+
* a queued send is not delivered.
|
|
1263
1335
|
*
|
|
1264
1336
|
* `lunora deploy --target node` bundles an app into a container build context
|
|
1265
1337
|
* whose generated entry composes this package (crons, `ctx.secrets`,
|
|
1266
1338
|
* Hyperdrive from `DATABASE_URL`) and serves it with `createNodeHttpServer`.
|
|
1267
1339
|
*
|
|
1268
1340
|
* `@lunora/config` ships a `node` **deploy** driver, so `--target node` resolves
|
|
1269
|
-
*
|
|
1270
|
-
*
|
|
1271
|
-
*
|
|
1272
|
-
* server, which is why both statements above hold at once. See
|
|
1273
|
-
* `plans/234-node-host-findings.md`.
|
|
1341
|
+
* and codegen gates against `NODE_CAPABILITIES`. There is no hosted control
|
|
1342
|
+
* plane to deploy to and no `wrangler`-equivalent to shell out to, which is why
|
|
1343
|
+
* the deploy stops at a build context. See `plans/234-node-host-findings.md`.
|
|
1274
1344
|
*/
|
|
1275
1345
|
type DrainTimer,
|
|
1276
1346
|
/**
|
|
@@ -1301,29 +1371,29 @@ type DrainTimer,
|
|
|
1301
1371
|
* `objectStorageDirectory`) — a capability rated `emulated` with nothing bound
|
|
1302
1372
|
* is the one combination that fails at runtime with no diagnostic before it.
|
|
1303
1373
|
*
|
|
1304
|
-
* **
|
|
1305
|
-
*
|
|
1306
|
-
* `
|
|
1307
|
-
* `
|
|
1308
|
-
*
|
|
1309
|
-
*
|
|
1310
|
-
*
|
|
1311
|
-
*
|
|
1312
|
-
*
|
|
1313
|
-
*
|
|
1314
|
-
*
|
|
1315
|
-
*
|
|
1316
|
-
*
|
|
1374
|
+
* **Serving an app.** `createNodeAppHost` composes a worker entry module over
|
|
1375
|
+
* one shard registry per Durable Object binding, and `createNodeHttpServer`
|
|
1376
|
+
* serves its `fetch` over `node:http`, streaming the response body. `lunora dev
|
|
1377
|
+
* --target node` runs exactly that pair. Nothing here owns a timer, so queue
|
|
1378
|
+
* delivery is driven by an explicit `poll()`. Absent are the Cloudflare product
|
|
1379
|
+
* bindings with no local equivalent — Vectorize, Workers AI, Browser Rendering,
|
|
1380
|
+
* Containers, Analytics Engine, Pipelines. `ctx.secrets` reads environment
|
|
1381
|
+
* variables through `createNodeSecretBindings` (`./node-secrets`), and the
|
|
1382
|
+
* Hyperdrive binding is built from `DATABASE_URL` by `createNodeHyperdrive`
|
|
1383
|
+
* (`./node-hyperdrive`). Queued `@lunora/mail` sends are delivered by
|
|
1384
|
+
* `createNodeMailHost` (`./node-mail-host`) through Resend or a caller-supplied
|
|
1385
|
+
* transport, for a process that composes it and polls it, as the server
|
|
1386
|
+
* `lunora deploy --target node` writes does. `lunora dev --target node` composes
|
|
1387
|
+
* none: there mail is captured to the Studio inbox, and with capture turned off
|
|
1388
|
+
* a queued send is not delivered.
|
|
1317
1389
|
*
|
|
1318
1390
|
* `lunora deploy --target node` bundles an app into a container build context
|
|
1319
1391
|
* whose generated entry composes this package (crons, `ctx.secrets`,
|
|
1320
1392
|
* Hyperdrive from `DATABASE_URL`) and serves it with `createNodeHttpServer`.
|
|
1321
1393
|
*
|
|
1322
1394
|
* `@lunora/config` ships a `node` **deploy** driver, so `--target node` resolves
|
|
1323
|
-
*
|
|
1324
|
-
*
|
|
1325
|
-
*
|
|
1326
|
-
* server, which is why both statements above hold at once. See
|
|
1327
|
-
* `plans/234-node-host-findings.md`.
|
|
1395
|
+
* and codegen gates against `NODE_CAPABILITIES`. There is no hosted control
|
|
1396
|
+
* plane to deploy to and no `wrangler`-equivalent to shell out to, which is why
|
|
1397
|
+
* the deploy stops at a build context. See `plans/234-node-host-findings.md`.
|
|
1328
1398
|
*/
|
|
1329
|
-
type Drainable, type MailParkReason, NODE_SCHEDULER_DISPATCH_PATH, type NodeCronJob, type NodeDeclaredCron, type NodeDispatchInvocation, type NodeDispatchRouteOptions, type NodeGlobalContextDatabaseOptions, type NodeGlobalStore, type NodeGlobalStoreOptions, type NodeHttpServer, type NodeHttpServerOptions, type NodeHyperdriveBinding, type NodeMailHost, type NodeMailHostOptions, type NodePlatform, type NodePlatformDispatchOptions, type NodePlatformMailOptions, type NodePlatformOptions, type NodeProfileHandler, type NodeProfileHandlerOptions, type NodeQueueHost, type NodeQueueHostOptions, type NodeR2BucketOptions, type NodeSchedulerHost, type NodeSchedulerHostOptions, type NodeSecretBinding, type NodeShard, type NodeShardHostOptions, type NodeShardRegistry, type NodeShardRegistryOptions, type NodeShardState, type NodeSocketHost, type NodeWorkflowHost, type NodeWorkflowHostOptions, type ShardSocketHooks, bindShardSockets, createNodeDispatchRoute, createNodeGlobalStore, createNodeHttpServer, createNodeHyperdrive, createNodeMailHost, createNodePlatform, createNodeProfileHandler, createNodeQueueHost, createNodeR2Bucket, createNodeSchedulerHost, createNodeSecretBindings, createNodeShardHost, createNodeShardKvStore, createNodeShardNamespace, createNodeShardRegistry, createNodeShardState, createNodeSocketHost, createNodeSqlExec, createNodeWorkflowHost, createNodeWorkflowStore, drainTogether };
|
|
1399
|
+
type Drainable, type MailParkReason, NODE_SCHEDULER_DISPATCH_PATH, type NodeAppDurableObjectBinding, type NodeAppHost, type NodeAppHostOptions, type NodeCronJob, type NodeDeclaredCron, type NodeDispatchInvocation, type NodeDispatchRouteOptions, type NodeDurableObjectClass, type NodeDurableObjectInstance, type NodeGlobalContextDatabaseOptions, type NodeGlobalStore, type NodeGlobalStoreOptions, type NodeHttpServer, type NodeHttpServerOptions, type NodeHyperdriveBinding, type NodeMailHost, type NodeMailHostOptions, type NodePlatform, type NodePlatformDispatchOptions, type NodePlatformMailOptions, type NodePlatformOptions, type NodeProfileHandler, type NodeProfileHandlerOptions, type NodeQueueHost, type NodeQueueHostOptions, type NodeR2BucketOptions, type NodeSchedulerHost, type NodeSchedulerHostOptions, type NodeSecretBinding, type NodeShard, type NodeShardHostOptions, type NodeShardRegistry, type NodeShardRegistryOptions, type NodeShardState, type NodeSocketHost, type NodeWorkflowHost, type NodeWorkflowHostOptions, type ShardSocketHooks, bindShardSockets, checkNodeAppHost, createNodeAppHost, createNodeDispatchRoute, createNodeDurableObjectFactory, createNodeGlobalStore, createNodeHttpServer, createNodeHyperdrive, createNodeMailHost, createNodePlatform, createNodeProfileHandler, createNodeQueueHost, createNodeR2Bucket, createNodeSchedulerHost, createNodeSecretBindings, createNodeShardHost, createNodeShardKvStore, createNodeShardNamespace, createNodeShardRegistry, createNodeShardState, createNodeSocketHost, createNodeSqlExec, createNodeWorkflowHost, createNodeWorkflowStore, drainTogether };
|