@lunora/platform-node 1.0.0-alpha.83 → 1.0.0-alpha.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -14,13 +14,14 @@ type NodeGlobalContextDatabaseOptions = Omit<SqlCtxDbOptions, "dialect" | "exec"
14
14
  /**
15
15
  * Wrap a `better-sqlite3` connection as the async exec the store core consumes.
16
16
  *
17
- * `batch` is deliberately **not** implemented. The contract lets an exec that
18
- * omits it fall back to a sequential `run()` loop, and that fallback is already
19
- * optimal here: `batch` exists to collapse network round trips (D1 does it
20
- * atomically in one request; the Hyperdrive adapters dispatch concurrently over
21
- * a pool), and an embedded database has no round trip to collapse. Declaring it
22
- * would buy nothing and would opt this exec into the "MAY reorder or
23
- * parallelize" licence for no reason.
17
+ * `batch` runs the statements in order inside one `better-sqlite3`
18
+ * transaction, which is synchronous, so nothing else runs between them. There is
19
+ * no round trip to save; atomicity is the point. The store core's FTS5 search
20
+ * companion writes each document as an ordered list of statements, and without
21
+ * this two async writers interleaved at every `await` between them: one could
22
+ * move a document's mapping while the other's entry was mid-write, leaving an
23
+ * entry no later write or purge could reach. The `sqlite` dialect's contract
24
+ * requires an ordered, atomic `batch` for exactly that reason.
24
25
  */
25
26
  declare const createNodeSqlExec: (database: Database.Database) => SqlCtxExec;
26
27
  /** Options for {@link createNodeGlobalStore}. */
package/dist/index.d.ts CHANGED
@@ -14,13 +14,14 @@ type NodeGlobalContextDatabaseOptions = Omit<SqlCtxDbOptions, "dialect" | "exec"
14
14
  /**
15
15
  * Wrap a `better-sqlite3` connection as the async exec the store core consumes.
16
16
  *
17
- * `batch` is deliberately **not** implemented. The contract lets an exec that
18
- * omits it fall back to a sequential `run()` loop, and that fallback is already
19
- * optimal here: `batch` exists to collapse network round trips (D1 does it
20
- * atomically in one request; the Hyperdrive adapters dispatch concurrently over
21
- * a pool), and an embedded database has no round trip to collapse. Declaring it
22
- * would buy nothing and would opt this exec into the "MAY reorder or
23
- * parallelize" licence for no reason.
17
+ * `batch` runs the statements in order inside one `better-sqlite3`
18
+ * transaction, which is synchronous, so nothing else runs between them. There is
19
+ * no round trip to save; atomicity is the point. The store core's FTS5 search
20
+ * companion writes each document as an ordered list of statements, and without
21
+ * this two async writers interleaved at every `await` between them: one could
22
+ * move a document's mapping while the other's entry was mid-write, leaving an
23
+ * entry no later write or purge could reach. The `sqlite` dialect's contract
24
+ * requires an ordered, atomic `batch` for exactly that reason.
24
25
  */
25
26
  declare const createNodeSqlExec: (database: Database.Database) => SqlCtxExec;
26
27
  /** Options for {@link createNodeGlobalStore}. */
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{createNodeGlobalStore as r,createNodeSqlExec as t}from"./packem_shared/createNodeGlobalStore-nAJ4WO7w.mjs";import{createNodeShardKvStore as d}from"./packem_shared/createNodeShardKvStore-DVi1OsvH.mjs";import{createNodePlatform as f}from"./packem_shared/createNodePlatform-D5wfsfSD.mjs";import{createNodeQueueHost as x}from"./packem_shared/createNodeQueueHost-CttDb5sY.mjs";import{createNodeR2Bucket as p}from"./packem_shared/createNodeR2Bucket-CajTvuOy.mjs";import{createNodeSchedulerHost as l}from"./packem_shared/createNodeSchedulerHost-BEAX6I4m.mjs";import{createNodeShardHost as h}from"./packem_shared/createNodeShardHost-Da19DFX0.mjs";import{createNodeShardRegistry as k}from"./packem_shared/createNodeShardRegistry-D-KxwdUc.mjs";import{createNodeShardState as w}from"./packem_shared/createNodeShardState-D6XMWbFs.mjs";import{createNodeSocketHost as W}from"./packem_shared/createNodeSocketHost-DQs85G7W.mjs";import{createNodeWorkflowHost as g}from"./packem_shared/createNodeWorkflowHost-B5Aiwj3L.mjs";import{createNodeWorkflowStore as q}from"./packem_shared/createNodeWorkflowStore-CL7RYP6H.mjs";export{r as createNodeGlobalStore,f as createNodePlatform,x as createNodeQueueHost,p as createNodeR2Bucket,l as createNodeSchedulerHost,h as createNodeShardHost,d as createNodeShardKvStore,k as createNodeShardRegistry,w as createNodeShardState,W as createNodeSocketHost,t as createNodeSqlExec,g as createNodeWorkflowHost,q as createNodeWorkflowStore};
1
+ import{createNodeGlobalStore as r,createNodeSqlExec as t}from"./packem_shared/createNodeGlobalStore-DiGxjmD7.mjs";import{createNodeShardKvStore as d}from"./packem_shared/createNodeShardKvStore-DVi1OsvH.mjs";import{createNodePlatform as f}from"./packem_shared/createNodePlatform-BJFsyOy5.mjs";import{createNodeQueueHost as x}from"./packem_shared/createNodeQueueHost-CttDb5sY.mjs";import{createNodeR2Bucket as p}from"./packem_shared/createNodeR2Bucket-CajTvuOy.mjs";import{createNodeSchedulerHost as l}from"./packem_shared/createNodeSchedulerHost-BEAX6I4m.mjs";import{createNodeShardHost as h}from"./packem_shared/createNodeShardHost-Da19DFX0.mjs";import{createNodeShardRegistry as k}from"./packem_shared/createNodeShardRegistry-D-KxwdUc.mjs";import{createNodeShardState as w}from"./packem_shared/createNodeShardState-D6XMWbFs.mjs";import{createNodeSocketHost as W}from"./packem_shared/createNodeSocketHost-DQs85G7W.mjs";import{createNodeWorkflowHost as g}from"./packem_shared/createNodeWorkflowHost-B5Aiwj3L.mjs";import{createNodeWorkflowStore as q}from"./packem_shared/createNodeWorkflowStore-CL7RYP6H.mjs";export{r as createNodeGlobalStore,f as createNodePlatform,x as createNodeQueueHost,p as createNodeR2Bucket,l as createNodeSchedulerHost,h as createNodeShardHost,d as createNodeShardKvStore,k as createNodeShardRegistry,w as createNodeShardState,W as createNodeSocketHost,t as createNodeSqlExec,g as createNodeWorkflowHost,q as createNodeWorkflowStore};
@@ -0,0 +1 @@
1
+ import{sqliteDialect as l}from"@lunora/d1";import{createSqlCtxDb as s,runSqlGlobalTableMigrations as p,runSqlAggregateMigrations as u,runSqlRankMigrations as g,runSqlSearchMigrations as f,backfillSqlSearchIndexes as S,runSqlCdcMigration as w}from"@lunora/sql-store";import d from"better-sqlite3";const i=new WeakMap,n=(a,r)=>{let e=i.get(a);e===void 0&&(e=new Map,i.set(a,e));let t=e.get(r);return t===void 0&&(t=a.prepare(r),e.set(r,t)),t},o={...l,searchBackfillHint:"run the global store's migrate(), which backfills every search index to completion"},m=a=>({all:async(r,e)=>n(a,r).all(...e),batch:async r=>{a.transaction(()=>{for(const{params:e,sql:t}of r)n(a,t).run(...e)})()},run:async(r,e)=>({rowsAffected:n(a,r).run(...e).changes})}),x=(a={})=>{const r=new d(a.path??":memory:");r.pragma("journal_mode = WAL");const e=m(r);return{database:r,dispose:()=>{r.open&&r.close()},exec:e,migrate:async(t,c={})=>{await p(e,t,o),await u(e,t,o),await g(e,t,o),await f(e,t,o),await S(e,t,o),c.cdc===!0&&await w(e,o)},writer:t=>s({...t,dialect:o,exec:e,provisionScope:e})}};export{x as createNodeGlobalStore,m as createNodeSqlExec};
@@ -1 +1 @@
1
- import{LunoraError as S}from"@lunora/errors";import{NODE_CAPABILITIES as b}from"@lunora/platform";import{createNodeGlobalStore as N}from"./createNodeGlobalStore-nAJ4WO7w.mjs";import{createNodeShardKvStore as k}from"./createNodeShardKvStore-DVi1OsvH.mjs";import{createNodeQueueHost as g}from"./createNodeQueueHost-CttDb5sY.mjs";import{createNodeR2Bucket as y}from"./createNodeR2Bucket-CajTvuOy.mjs";import{createNodeSchedulerHost as R}from"./createNodeSchedulerHost-BEAX6I4m.mjs";import{createNodeShardHost as q}from"./createNodeShardHost-Da19DFX0.mjs";import{createNodeShardRegistry as B}from"./createNodeShardRegistry-D-KxwdUc.mjs";import{createNodeSocketHost as H}from"./createNodeSocketHost-DQs85G7W.mjs";import{createNodeWorkflowHost as I}from"./createNodeWorkflowHost-B5Aiwj3L.mjs";import{createNodeWorkflowStore as P}from"./createNodeWorkflowStore-CL7RYP6H.mjs";const G=(o={})=>{const e=[],{database:r,dispose:d,drain:u,host:i}=q(o);e.push(d);try{const s=k(r),t=B(o);e.push(()=>{t.close()});const{directory:l}=t,{socket:h}=H(r),{dispose:m,scheduler:f}=R(r,o);e.push(m);const n=o.queues===void 0?void 0:g(r,{onBatch:o.onQueueBatch??(()=>{throw new S("VALIDATION_ERROR","@lunora/platform-node: createNodePlatform was given `queues` without `onQueueBatch`, so a delivered batch has nowhere to go — pass dispatchQueueBatch from @lunora/queue")}),queues:o.queues}),p=o.objectStorageDirectory===void 0?void 0:y({directory:o.objectStorageDirectory}),a=o.globalTablesPath===void 0?void 0:N({path:o.globalTablesPath});a!==void 0&&e.push(()=>{a.dispose()});const w=o.workflows===void 0?void 0:I({store:P(r),workflows:o.workflows}),c=()=>{for(const v of e.toReversed())v()};return{capabilities:b,close:c,directory:l,drain:u,globalTables:a,kv:s,objectStorage:p,queues:n,scheduler:f,shard:i,sockets:h,workflows:w,[Symbol.dispose]:c}}catch(s){for(const t of e.toReversed())try{t()}catch{}throw s}};export{G as createNodePlatform};
1
+ import{LunoraError as S}from"@lunora/errors";import{NODE_CAPABILITIES as b}from"@lunora/platform";import{createNodeGlobalStore as N}from"./createNodeGlobalStore-DiGxjmD7.mjs";import{createNodeShardKvStore as k}from"./createNodeShardKvStore-DVi1OsvH.mjs";import{createNodeQueueHost as g}from"./createNodeQueueHost-CttDb5sY.mjs";import{createNodeR2Bucket as y}from"./createNodeR2Bucket-CajTvuOy.mjs";import{createNodeSchedulerHost as R}from"./createNodeSchedulerHost-BEAX6I4m.mjs";import{createNodeShardHost as q}from"./createNodeShardHost-Da19DFX0.mjs";import{createNodeShardRegistry as B}from"./createNodeShardRegistry-D-KxwdUc.mjs";import{createNodeSocketHost as H}from"./createNodeSocketHost-DQs85G7W.mjs";import{createNodeWorkflowHost as I}from"./createNodeWorkflowHost-B5Aiwj3L.mjs";import{createNodeWorkflowStore as P}from"./createNodeWorkflowStore-CL7RYP6H.mjs";const G=(o={})=>{const e=[],{database:r,dispose:d,drain:u,host:i}=q(o);e.push(d);try{const s=k(r),t=B(o);e.push(()=>{t.close()});const{directory:l}=t,{socket:h}=H(r),{dispose:m,scheduler:f}=R(r,o);e.push(m);const n=o.queues===void 0?void 0:g(r,{onBatch:o.onQueueBatch??(()=>{throw new S("VALIDATION_ERROR","@lunora/platform-node: createNodePlatform was given `queues` without `onQueueBatch`, so a delivered batch has nowhere to go — pass dispatchQueueBatch from @lunora/queue")}),queues:o.queues}),p=o.objectStorageDirectory===void 0?void 0:y({directory:o.objectStorageDirectory}),a=o.globalTablesPath===void 0?void 0:N({path:o.globalTablesPath});a!==void 0&&e.push(()=>{a.dispose()});const w=o.workflows===void 0?void 0:I({store:P(r),workflows:o.workflows}),c=()=>{for(const v of e.toReversed())v()};return{capabilities:b,close:c,directory:l,drain:u,globalTables:a,kv:s,objectStorage:p,queues:n,scheduler:f,shard:i,sockets:h,workflows:w,[Symbol.dispose]:c}}catch(s){for(const t of e.toReversed())try{t()}catch{}throw s}};export{G as createNodePlatform};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/platform-node",
3
- "version": "1.0.0-alpha.83",
3
+ "version": "1.0.0-alpha.84",
4
4
  "description": "Node implementation of the Lunora platform contracts: ShardHost, SocketHost, ShardDirectory, ShardKvStore, SchedulerHost over better-sqlite3 and an in-process socket registry (dev/test target)",
5
5
  "keywords": [
6
6
  "better-sqlite3",
@@ -46,12 +46,12 @@
46
46
  "access": "public"
47
47
  },
48
48
  "dependencies": {
49
- "@lunora/d1": "1.0.0-alpha.130",
49
+ "@lunora/d1": "1.0.0-alpha.131",
50
50
  "@lunora/errors": "1.0.0-alpha.41",
51
- "@lunora/platform": "1.0.0-alpha.34",
52
- "@lunora/queue": "1.0.0-alpha.63",
53
- "@lunora/sql-store": "1.0.0-alpha.132",
54
- "@lunora/workflow": "1.0.0-alpha.60",
51
+ "@lunora/platform": "1.0.0-alpha.35",
52
+ "@lunora/queue": "1.0.0-alpha.64",
53
+ "@lunora/sql-store": "1.0.0-alpha.133",
54
+ "@lunora/workflow": "1.0.0-alpha.61",
55
55
  "@visulima/workflow": "3.0.0",
56
56
  "better-sqlite3": "^13.0.3",
57
57
  "cron-parser": "5.10.0"
@@ -1 +0,0 @@
1
- import{sqliteDialect as o}from"@lunora/d1";import{createSqlCtxDb as c,runSqlGlobalTableMigrations as s,runSqlAggregateMigrations as p,runSqlRankMigrations as u,runSqlSearchMigrations as g,backfillSqlSearchIndexes as S,runSqlCdcMigration as d}from"@lunora/sql-store";import w from"better-sqlite3";const n=new WeakMap,i=(a,r)=>{let e=n.get(a);e===void 0&&(e=new Map,n.set(a,e));let t=e.get(r);return t===void 0&&(t=a.prepare(r),e.set(r,t)),t},f=a=>({all:async(r,e)=>i(a,r).all(...e),run:async(r,e)=>({rowsAffected:i(a,r).run(...e).changes})}),x=(a={})=>{const r=new w(a.path??":memory:");r.pragma("journal_mode = WAL");const e=f(r);return{database:r,dispose:()=>{r.open&&r.close()},exec:e,migrate:async(t,l={})=>{await s(e,t,o),await p(e,t,o),await u(e,t,o),await g(e,t,o),await S(e,t,o),l.cdc===!0&&await d(e,o)},writer:t=>c({...t,dialect:o,exec:e,provisionScope:e})}};export{x as createNodeGlobalStore,f as createNodeSqlExec};