@lunora/d1 1.0.0-alpha.56 → 1.0.0-alpha.57
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
|
@@ -31,6 +31,17 @@ declare const trimD1CdcChanges: (exec: SqlCtxExec, throughSeq: number) => Promis
|
|
|
31
31
|
/** One exported row: `doc` is reconstructed from the column tuple. */
|
|
32
32
|
interface ExportRow {
|
|
33
33
|
doc: Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* True physical source line, when the caller has it (e.g. a global row
|
|
36
|
+
* pulled out of an interspersed NDJSON import stream by
|
|
37
|
+
* `@lunora/runtime`'s `import-stream.ts`). When present this overrides the
|
|
38
|
+
* position-derived line below — the caller-side positions of a
|
|
39
|
+
* global-only subset don't line up with the original file once
|
|
40
|
+
* non-global rows have been filtered out. Absent for callers with no
|
|
41
|
+
* physical source to attribute (e.g. a fresh `exportGlobalRows` roundtrip
|
|
42
|
+
* in tests), which keeps the positional fallback.
|
|
43
|
+
*/
|
|
44
|
+
line?: number;
|
|
34
45
|
table: string;
|
|
35
46
|
}
|
|
36
47
|
interface ImportError {
|
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,17 @@ declare const trimD1CdcChanges: (exec: SqlCtxExec, throughSeq: number) => Promis
|
|
|
31
31
|
/** One exported row: `doc` is reconstructed from the column tuple. */
|
|
32
32
|
interface ExportRow {
|
|
33
33
|
doc: Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* True physical source line, when the caller has it (e.g. a global row
|
|
36
|
+
* pulled out of an interspersed NDJSON import stream by
|
|
37
|
+
* `@lunora/runtime`'s `import-stream.ts`). When present this overrides the
|
|
38
|
+
* position-derived line below — the caller-side positions of a
|
|
39
|
+
* global-only subset don't line up with the original file once
|
|
40
|
+
* non-global rows have been filtered out. Absent for callers with no
|
|
41
|
+
* physical source to attribute (e.g. a fresh `exportGlobalRows` roundtrip
|
|
42
|
+
* in tests), which keeps the positional fallback.
|
|
43
|
+
*/
|
|
44
|
+
line?: number;
|
|
34
45
|
table: string;
|
|
35
46
|
}
|
|
36
47
|
interface ImportError {
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{exportGlobalRows as a,importGlobalRows as o,selectGlobalTables as l}from"./packem_shared/exportGlobalRows-
|
|
1
|
+
import{exportGlobalRows as a,importGlobalRows as o,selectGlobalTables as l}from"./packem_shared/exportGlobalRows-1Zw30YqW.mjs";import{D1Client as i,D1Session as n}from"./packem_shared/D1Client-DeccGO7F.mjs";import{backfillD1SearchIndexes as b,createD1CtxDb as D,readD1CdcChanges as g,runD1AggregateMigrations as c,runD1CdcMigration as x,runD1GlobalTableMigrations as f,runD1RankMigrations as m,runD1SearchMigrations as p,trimD1CdcChanges as C}from"./packem_shared/backfillD1SearchIndexes-ERQf6szv.mjs";import{facetGlobalColumn as d,listGlobalTables as G,readGlobalTablePage as M}from"./packem_shared/facetGlobalColumn-R-BETSuA.mjs";import{MigrationRunner as R}from"./packem_shared/MigrationRunner-CNH8wlIl.mjs";import{default as T}from"./packem_shared/sqliteDialect-B43yA0ek.mjs";import{createSqlCtxDb as q}from"@lunora/sql-store";export{i as D1Client,n as D1Session,R as MigrationRunner,b as backfillD1SearchIndexes,D as createD1CtxDb,q as createSqlCtxDb,a as exportGlobalRows,d as facetGlobalColumn,o as importGlobalRows,G as listGlobalTables,g as readD1CdcChanges,M as readGlobalTablePage,c as runD1AggregateMigrations,x as runD1CdcMigration,f as runD1GlobalTableMigrations,m as runD1RankMigrations,p as runD1SearchMigrations,l as selectGlobalTables,T as sqliteDialect,C as trimD1CdcChanges};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toErrorBody as u}from"@lunora/errors";import{runD1GlobalTableMigrations as m}from"./backfillD1SearchIndexes-ERQf6szv.mjs";import{quoteIdentifier as f}from"./quoteIdentifier-CObIFRhb.mjs";import{decodeGlobalRow as E}from"@lunora/sql-store";const k=200,R=(o,t)=>{const r=e=>o.tables[e]?.shardMode?.kind==="global";return t&&t.length>0?t.filter(e=>r(e)):Object.keys(o.tables).filter(e=>r(e))},w=(o,t,r)=>{const e=o.tables[t];return e?E(e,r):{_creationTime:r._creationTime,_id:r.id}},O=async function*(o,t,r){const e=R(t,r.tables),a=r.batchSize??k;await m(o,t);for(const i of e){const n=f(i);let c,
|
|
1
|
+
import{toErrorBody as u}from"@lunora/errors";import{runD1GlobalTableMigrations as m}from"./backfillD1SearchIndexes-ERQf6szv.mjs";import{quoteIdentifier as f}from"./quoteIdentifier-CObIFRhb.mjs";import{decodeGlobalRow as E}from"@lunora/sql-store";const k=200,R=(o,t)=>{const r=e=>o.tables[e]?.shardMode?.kind==="global";return t&&t.length>0?t.filter(e=>r(e)):Object.keys(o.tables).filter(e=>r(e))},w=(o,t,r)=>{const e=o.tables[t];return e?E(e,r):{_creationTime:r._creationTime,_id:r.id}},O=async function*(o,t,r){const e=R(t,r.tables),a=r.batchSize??k;await m(o,t);for(const i of e){const n=f(i);let c,l=!0;for(;l;){const s=c===void 0?await o.all(`SELECT * FROM ${n} ORDER BY "id" LIMIT ?`,[a]):await o.all(`SELECT * FROM ${n} WHERE "id" > ? ORDER BY "id" LIMIT ?`,[c,a]);for(const b of s)yield{doc:w(t,i,b),table:i};const d=s.at(-1);d!==void 0&&(c=String(d.id)),l=s.length===a}}},y=(o,t,r)=>{const e=o.tables[t];if(!e)return`unknown table: ${t}`;for(const[a,i]of Object.entries(e.shape)){const n=r[a],c=i.kind==="optional";if(n===void 0&&c)continue;const l=i.parse;if(typeof l=="function")try{l(n)}catch(s){const d=s instanceof Error?s.message:String(s);return`field "${a}": ${d}`}}},g=async(o,t,r,e)=>{try{return t?(await t.all(`SELECT 1 AS hit FROM ${f(r)} WHERE "id" = ? LIMIT 1`,[e])).length>0:await o.get(e)!==null}catch{return!1}},p=async(o,t,r,e,a)=>{const{doc:i,table:n}=e;if(t.tables[n]?.shardMode?.kind!=="global")return{kind:"skip"};if(!i||typeof i!="object"||Array.isArray(i))return{error:{code:"BAD_ROW",line:a,message:"row is missing or malformed `doc`",table:n},kind:"error"};const c=y(t,n,i);if(c!==void 0)return{error:{code:"VALIDATION_ERROR",line:a,message:c,table:n},kind:"error"};const l=typeof i._id=="string"?i._id:void 0;if(l!==void 0&&await g(o,r.exec,n,l))return{kind:"conflict"};try{return await o.insert(n,i,{allowExplicitId:!0}),{inserted:n,kind:"inserted"}}catch(s){const{body:d}=u(s,{fallbackCode:"INSERT_FAILED"});return{error:{code:d.code,line:a,message:d.message,table:n},kind:"error"}}},M=async(o,t,r)=>{const e=[],a={};let i=0,n=(r.startLine??1)-1;for(const c of r.rows){n+=1;const l=c.line??n,s=await p(o,t,r,c,l);switch(s.kind){case"conflict":{i+=1;break}case"error":{e.push(s.error);break}case"inserted":{a[s.inserted]=(a[s.inserted]??0)+1;break}}}return{conflicts:i,errors:e,inserted:a}};export{O as exportGlobalRows,M as importGlobalRows,R as selectGlobalTables};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/d1",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.57",
|
|
4
4
|
"description": "D1 adapter for Lunora .global() tables, wrapping the Sessions API for read-your-writes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
54
|
-
"@lunora/platform": "1.0.0-alpha.
|
|
55
|
-
"@lunora/shard-engine": "1.0.0-alpha.
|
|
56
|
-
"@lunora/sql-store": "1.0.0-alpha.
|
|
53
|
+
"@lunora/errors": "1.0.0-alpha.12",
|
|
54
|
+
"@lunora/platform": "1.0.0-alpha.3",
|
|
55
|
+
"@lunora/shard-engine": "1.0.0-alpha.6",
|
|
56
|
+
"@lunora/sql-store": "1.0.0-alpha.59",
|
|
57
57
|
"drizzle-orm": "^0.45.2"
|
|
58
58
|
},
|
|
59
59
|
"engines": {
|