@lunora/hyperdrive 1.0.0-alpha.220 → 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/dist/global.d.mts +10 -1
- package/dist/global.d.ts +10 -1
- package/dist/global.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/buildMysqlExec-DrnJfCYF.mjs +1 -0
- package/dist/packem_shared/createHyperdrive-HbpYCCgt.mjs +1 -0
- package/dist/packem_shared/{types.d-Zm06MRhL.d.mts → types.d-DKB5Qb1Z.d.mts} +11 -0
- package/dist/packem_shared/{types.d-Zm06MRhL.d.ts → types.d-DKB5Qb1Z.d.ts} +11 -0
- package/package.json +4 -4
- package/dist/packem_shared/buildMysqlExec-PqvV5h4p.mjs +0 -1
- package/dist/packem_shared/createHyperdrive-DWZZ_3e2.mjs +0 -1
package/dist/global.d.mts
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
*/
|
|
31
31
|
import { SchemaLike, ImportConflictMode, CdcChange, DatabaseWriterLike } from '@lunora/shard-engine';
|
|
32
32
|
import { SqlExec, SqlDialect, SqlCtxDbOptions, FacetGlobalColumnOptions, GlobalFacetResult, GlobalTableInfo, ReadGlobalTablePageOptions, GlobalTablePage, ExportRow, ImportResult } from '@lunora/sql-store';
|
|
33
|
-
import { M as Mysql2Like, S as SqlClient } from "./packem_shared/types.d-
|
|
33
|
+
import { M as Mysql2Like, S as SqlClient } from "./packem_shared/types.d-DKB5Qb1Z.mjs";
|
|
34
34
|
import { VectorMetric, VectorizeIndexLike } from '@lunora/platform';
|
|
35
35
|
/**
|
|
36
36
|
* Minimal row-returning client (e.g. `@lunora/hyperdrive`'s `fromPostgresJs`/`fromNodePg`
|
|
@@ -90,6 +90,10 @@ type Mysql2Client = Mysql2Like & {
|
|
|
90
90
|
* sequential fallback minus the ordering — safe only for statements whose
|
|
91
91
|
* effects don't depend on each other, which is what every current caller
|
|
92
92
|
* batches (distinct-keyed companion rows).
|
|
93
|
+
*
|
|
94
|
+
* `transaction` is present when `client` has one (`fromPostgresJs`): the
|
|
95
|
+
* store's row + companion writes then run on one reserved connection and
|
|
96
|
+
* commit together.
|
|
93
97
|
*/
|
|
94
98
|
declare const buildPgExec: (client: RowClient) => SqlExec;
|
|
95
99
|
/**
|
|
@@ -107,6 +111,11 @@ declare const buildPgExec: (client: RowClient) => SqlExec;
|
|
|
107
111
|
* same values reports 0 and the OCC guard raises a spurious conflict. Verified
|
|
108
112
|
* once here at construction — see {@link assertFoundRows} — never per statement.
|
|
109
113
|
*
|
|
114
|
+
* Given a **pool** (anything with `getConnection`), `transaction` takes one
|
|
115
|
+
* connection for the store's row + companion writes, so they commit together.
|
|
116
|
+
* A single connection gets no `transaction`: other writers' statements would
|
|
117
|
+
* land inside an open one, so its companions commit one statement at a time.
|
|
118
|
+
*
|
|
110
119
|
* `batch` dispatches every statement concurrently (`Promise.all`), same
|
|
111
120
|
* rationale as {@link buildPgExec}'s `batch` — `Mysql2Like` only exposes a
|
|
112
121
|
* single-statement `query`, so this is "spread across a pool's connections"
|
package/dist/global.d.ts
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
*/
|
|
31
31
|
import { SchemaLike, ImportConflictMode, CdcChange, DatabaseWriterLike } from '@lunora/shard-engine';
|
|
32
32
|
import { SqlExec, SqlDialect, SqlCtxDbOptions, FacetGlobalColumnOptions, GlobalFacetResult, GlobalTableInfo, ReadGlobalTablePageOptions, GlobalTablePage, ExportRow, ImportResult } from '@lunora/sql-store';
|
|
33
|
-
import { M as Mysql2Like, S as SqlClient } from "./packem_shared/types.d-
|
|
33
|
+
import { M as Mysql2Like, S as SqlClient } from "./packem_shared/types.d-DKB5Qb1Z.js";
|
|
34
34
|
import { VectorMetric, VectorizeIndexLike } from '@lunora/platform';
|
|
35
35
|
/**
|
|
36
36
|
* Minimal row-returning client (e.g. `@lunora/hyperdrive`'s `fromPostgresJs`/`fromNodePg`
|
|
@@ -90,6 +90,10 @@ type Mysql2Client = Mysql2Like & {
|
|
|
90
90
|
* sequential fallback minus the ordering — safe only for statements whose
|
|
91
91
|
* effects don't depend on each other, which is what every current caller
|
|
92
92
|
* batches (distinct-keyed companion rows).
|
|
93
|
+
*
|
|
94
|
+
* `transaction` is present when `client` has one (`fromPostgresJs`): the
|
|
95
|
+
* store's row + companion writes then run on one reserved connection and
|
|
96
|
+
* commit together.
|
|
93
97
|
*/
|
|
94
98
|
declare const buildPgExec: (client: RowClient) => SqlExec;
|
|
95
99
|
/**
|
|
@@ -107,6 +111,11 @@ declare const buildPgExec: (client: RowClient) => SqlExec;
|
|
|
107
111
|
* same values reports 0 and the OCC guard raises a spurious conflict. Verified
|
|
108
112
|
* once here at construction — see {@link assertFoundRows} — never per statement.
|
|
109
113
|
*
|
|
114
|
+
* Given a **pool** (anything with `getConnection`), `transaction` takes one
|
|
115
|
+
* connection for the store's row + companion writes, so they commit together.
|
|
116
|
+
* A single connection gets no `transaction`: other writers' statements would
|
|
117
|
+
* land inside an open one, so its companions commit one statement at a time.
|
|
118
|
+
*
|
|
110
119
|
* `batch` dispatches every statement concurrently (`Promise.all`), same
|
|
111
120
|
* rationale as {@link buildPgExec}'s `batch` — `Mysql2Like` only exposes a
|
|
112
121
|
* single-statement `query`, so this is "spread across a pool's connections"
|
package/dist/global.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{applyCdcChanges as d,CDC_LOG_TABLE as b}from"@lunora/shard-engine";import{createSqlCtxDb as p,readSqlGlobalTablePage as g,listSqlGlobalTables as m,facetSqlGlobalColumn as y,exportSqlGlobalRows as C,importSqlGlobalRows as G,readSqlCdcChanges as x}from"@lunora/sql-store";import{postgresDialect as q,mysqlDialect as u}from"./packem_shared/mysqlDialect-BS1Sz60B.mjs";import{buildMysqlExec as f,buildPgExec as v}from"./packem_shared/buildMysqlExec-
|
|
1
|
+
import{applyCdcChanges as d,CDC_LOG_TABLE as b}from"@lunora/shard-engine";import{createSqlCtxDb as p,readSqlGlobalTablePage as g,listSqlGlobalTables as m,facetSqlGlobalColumn as y,exportSqlGlobalRows as C,importSqlGlobalRows as G,readSqlCdcChanges as x}from"@lunora/sql-store";import{postgresDialect as q,mysqlDialect as u}from"./packem_shared/mysqlDialect-BS1Sz60B.mjs";import{buildMysqlExec as f,buildPgExec as v}from"./packem_shared/buildMysqlExec-DrnJfCYF.mjs";import{createPgVectorIndex as A}from"./packem_shared/createPgVectorIndex-B2Wbzqns.mjs";const o=e=>e==="postgres"?q:u,c=({engine:e,exec:l,...r})=>p({...r,dialect:o(e),exec:l}),H=({engine:e,exec:l,schema:r,tables:t})=>C(l,r,o(e),t===void 0?{}:{tables:t}),P=({cdc:e,dryRun:l,engine:r,exec:t,onConflict:a,rows:s,schema:n,startLine:i})=>G(c({cdc:e,engine:r,exec:t,schema:n}),n,o(r),{dryRun:l===!0,exec:t,onConflict:a??"skip",rows:s,...i===void 0?{}:{startLine:i}}),R=(e,l)=>c({...l,engine:"postgres",exec:v(e)}),T=(e,l)=>c({...l,engine:"mysql",exec:f(e)}),E=(e,l,r)=>{const t=o(e);return{facetColumn:a=>y(l,r,t,a),listTables:()=>m(l,r,t),readTablePage:a=>g(l,r,t,a)}},I=async(e,l,r)=>{const t=o(e),{params:a,sql:s}=t.render(t.tableExists(b));return(await l.all(s,a)).length===0?{changes:[],cursor:r.sinceSeq}:x(l,r,t)},M=async e=>(await d(c({cdc:e.cdc,engine:e.engine,exec:e.exec,schema:e.schema}),e.changes),e.changes.length);export{M as applyHyperdriveGlobalCdc,f as buildMysqlExec,v as buildPgExec,c as createHyperdriveGlobalCtxDb,E as createHyperdriveGlobalIntrospector,T as createMysqlGlobalCtxDb,A as createPgVectorIndex,R as createPostgresGlobalCtxDb,H as exportHyperdriveGlobalRows,P as importHyperdriveGlobalRows,u as mysqlDialect,q as postgresDialect,I as readHyperdriveGlobalCdc};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HyperdriveLike, a as HyperdriveConnection, M as Mysql2Like, S as SqlClient, N as NodePgLike, P as PostgresJsLike } from "./packem_shared/types.d-
|
|
1
|
+
import { H as HyperdriveLike, a as HyperdriveConnection, M as Mysql2Like, S as SqlClient, N as NodePgLike, P as PostgresJsLike } from "./packem_shared/types.d-DKB5Qb1Z.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* Surface a Cloudflare Hyperdrive binding as a connection ready to feed a
|
|
4
4
|
* user-supplied SQL driver.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HyperdriveLike, a as HyperdriveConnection, M as Mysql2Like, S as SqlClient, N as NodePgLike, P as PostgresJsLike } from "./packem_shared/types.d-
|
|
1
|
+
import { H as HyperdriveLike, a as HyperdriveConnection, M as Mysql2Like, S as SqlClient, N as NodePgLike, P as PostgresJsLike } from "./packem_shared/types.d-DKB5Qb1Z.js";
|
|
2
2
|
/**
|
|
3
3
|
* Surface a Cloudflare Hyperdrive binding as a connection ready to feed a
|
|
4
4
|
* user-supplied SQL driver.
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHyperdrive as e,fromMysql2 as f,fromNodePg as m,fromPostgresJs as p}from"./packem_shared/createHyperdrive-
|
|
1
|
+
import{createHyperdrive as e,fromMysql2 as f,fromNodePg as m,fromPostgresJs as p}from"./packem_shared/createHyperdrive-HbpYCCgt.mjs";import{projectSourceRow as t,pullSourceRows as c}from"./packem_shared/projectSourceRow-DN8ywPRl.mjs";export{e as createHyperdrive,f as fromMysql2,m as fromNodePg,p as fromPostgresJs,t as projectSourceRow,c as pullSourceRows};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{LunoraError as c}from"@lunora/errors";import{t as n}from"./mysql-params-D4Ijlvo5.mjs";const l=2,i=new WeakSet,u=t=>{const a=t,e=a.config?.clientFlags;if(typeof e=="number")return e;const r=a.pool?.config?.connectionConfig?.clientFlags;return typeof r=="number"?r:void 0},d=t=>{const a=u(t);if(a===void 0){if(i.has(t))return;i.add(t),console.warn('@lunora/hyperdrive: could not determine whether this MySQL connection negotiated CLIENT_FOUND_ROWS (the driver exposes no flag introspection). If it was NOT created with the `CLIENT_FOUND_ROWS` flag (mysql2: `createPool({ flags: ["FOUND_ROWS"] })`), an idempotent patch/replace that rewrites identical values may report 0 affectedRows and raise a spurious OCC ConflictError.');return}if((a&l)===0)throw new c("INTERNAL",'@lunora/hyperdrive: this MySQL connection was not created with the `CLIENT_FOUND_ROWS` flag (mysql2: `createPool({ flags: ["FOUND_ROWS"] })`). Without it, `affectedRows` counts changed (not matched) rows, so an idempotent patch/replace that rewrites identical values reports 0 and the OCC guard raises a spurious conflict.')},w=async(t,a,e)=>{const r=await t.getConnection();let o;try{await r.beginTransaction(),o=await e(a(r)),await r.commit()}catch(s){try{await r.rollback(),r.release()}catch{r.destroy()}throw s}return r.release(),o},y=t=>({all:(a,e)=>t.query(a,e),batch:async a=>{await Promise.all(a.map(e=>t.query(e.sql,e.params)))},run:async(a,e)=>(await t.query(a,e),{rowsAffected:0}),...t.transaction===void 0?{}:{transaction:async a=>await t.transaction(async e=>await a(y(e)))}}),f=t=>{d(t);const a=t,{getConnection:e}=a;return{...typeof e=="function"?{transaction:async r=>await w(a,f,r)}:{},all:async(r,o)=>{const[s]=await t.query(r,n(o));return Array.isArray(s)?s:[]},batch:async r=>{await Promise.all(r.map(o=>t.query(o.sql,n(o.params))))},run:async(r,o)=>{const[s]=await t.query(r,n(o));return{rowsAffected:s.affectedRows??0}}}};export{f as buildMysqlExec,y as buildPgExec};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./mysql-params-D4Ijlvo5.mjs";const y=r=>({config:{database:r.database,host:r.host,password:r.password,port:r.port,user:r.user},connectionString:r.connectionString}),a=r=>{const{begin:s}=r;return{dbSystem:"postgresql",query:async(t,o=[])=>await r.unsafe(t,o,{prepare:!0}),...s===void 0?{}:{transaction:async t=>await s(async o=>await t(a(o)))}}},u=r=>({dbSystem:"postgresql",query:async(s,t=[])=>(await r.query(s,t)).rows}),p=r=>({dbSystem:"mysql",query:async(s,t=[])=>{const[o]=await r.query(s,e(t));return Array.isArray(o)?o:[]}});export{y as createHyperdrive,p as fromMysql2,u as fromNodePg,a as fromPostgresJs};
|
|
@@ -93,6 +93,15 @@ interface SqlClient {
|
|
|
93
93
|
* return no rows).
|
|
94
94
|
*/
|
|
95
95
|
query: <Row = Record<string, unknown>>(text: string, params?: ReadonlyArray<unknown>) => Promise<Row[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Run `work` against a client pinned to one connection inside one
|
|
98
|
+
* transaction: committed when `work` resolves, rolled back when it throws.
|
|
99
|
+
* {@link import("./create-hyperdrive").fromPostgresJs | fromPostgresJs} provides it over postgres.js's `begin`;
|
|
100
|
+
* `@lunora/hyperdrive/global`'s `buildPgExec` uses it so a `.global()` row
|
|
101
|
+
* write and its aggregate/rank/CDC companions commit together. Absent, they
|
|
102
|
+
* commit one statement at a time.
|
|
103
|
+
*/
|
|
104
|
+
transaction?: <T>(work: (tx: SqlClient) => Promise<T>) => Promise<T>;
|
|
96
105
|
}
|
|
97
106
|
/**
|
|
98
107
|
* Structural projection of a `pg` (node-postgres) `Client`/`Pool`. Only the
|
|
@@ -125,6 +134,8 @@ interface NodePgLike {
|
|
|
125
134
|
* direction, which is all bivariance asks for.
|
|
126
135
|
*/
|
|
127
136
|
interface PostgresJsLike {
|
|
137
|
+
/** postgres.js's `sql.begin(fn)`: reserves one connection and runs `fn` inside `BEGIN` … `COMMIT`. */
|
|
138
|
+
begin?(this: void, work: (tx: PostgresJsLike) => Promise<unknown>): Promise<unknown>;
|
|
128
139
|
unsafe(this: void, text: string, params?: ReadonlyArray<unknown>, options?: {
|
|
129
140
|
prepare?: boolean;
|
|
130
141
|
}): Promise<unknown>;
|
|
@@ -93,6 +93,15 @@ interface SqlClient {
|
|
|
93
93
|
* return no rows).
|
|
94
94
|
*/
|
|
95
95
|
query: <Row = Record<string, unknown>>(text: string, params?: ReadonlyArray<unknown>) => Promise<Row[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Run `work` against a client pinned to one connection inside one
|
|
98
|
+
* transaction: committed when `work` resolves, rolled back when it throws.
|
|
99
|
+
* {@link import("./create-hyperdrive").fromPostgresJs | fromPostgresJs} provides it over postgres.js's `begin`;
|
|
100
|
+
* `@lunora/hyperdrive/global`'s `buildPgExec` uses it so a `.global()` row
|
|
101
|
+
* write and its aggregate/rank/CDC companions commit together. Absent, they
|
|
102
|
+
* commit one statement at a time.
|
|
103
|
+
*/
|
|
104
|
+
transaction?: <T>(work: (tx: SqlClient) => Promise<T>) => Promise<T>;
|
|
96
105
|
}
|
|
97
106
|
/**
|
|
98
107
|
* Structural projection of a `pg` (node-postgres) `Client`/`Pool`. Only the
|
|
@@ -125,6 +134,8 @@ interface NodePgLike {
|
|
|
125
134
|
* direction, which is all bivariance asks for.
|
|
126
135
|
*/
|
|
127
136
|
interface PostgresJsLike {
|
|
137
|
+
/** postgres.js's `sql.begin(fn)`: reserves one connection and runs `fn` inside `BEGIN` … `COMMIT`. */
|
|
138
|
+
begin?(this: void, work: (tx: PostgresJsLike) => Promise<unknown>): Promise<unknown>;
|
|
128
139
|
unsafe(this: void, text: string, params?: ReadonlyArray<unknown>, options?: {
|
|
129
140
|
prepare?: boolean;
|
|
130
141
|
}): Promise<unknown>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/hyperdrive",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.222",
|
|
4
4
|
"description": "Bring-your-own Postgres/MySQL for Lunora via Cloudflare Hyperdrive: a driver-agnostic, action-only ctx.sql",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
54
|
-
"@lunora/platform": "1.0.0-alpha.
|
|
55
|
-
"@lunora/shard-engine": "1.0.0-alpha.
|
|
56
|
-
"@lunora/sql-store": "1.0.0-alpha.
|
|
54
|
+
"@lunora/platform": "1.0.0-alpha.77",
|
|
55
|
+
"@lunora/shard-engine": "1.0.0-alpha.179",
|
|
56
|
+
"@lunora/sql-store": "1.0.0-alpha.227",
|
|
57
57
|
"drizzle-orm": "1.0.0-rc.5"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{LunoraError as n}from"@lunora/errors";import{t as o}from"./mysql-params-D4Ijlvo5.mjs";const i=2,s=new WeakSet,c=t=>{const e=t,r=e.config?.clientFlags;if(typeof r=="number")return r;const a=e.pool?.config?.connectionConfig?.clientFlags;return typeof a=="number"?a:void 0},l=t=>{const e=c(t);if(e===void 0){if(s.has(t))return;s.add(t),console.warn('@lunora/hyperdrive: could not determine whether this MySQL connection negotiated CLIENT_FOUND_ROWS (the driver exposes no flag introspection). If it was NOT created with the `CLIENT_FOUND_ROWS` flag (mysql2: `createPool({ flags: ["FOUND_ROWS"] })`), an idempotent patch/replace that rewrites identical values may report 0 affectedRows and raise a spurious OCC ConflictError.');return}if((e&i)===0)throw new n("INTERNAL",'@lunora/hyperdrive: this MySQL connection was not created with the `CLIENT_FOUND_ROWS` flag (mysql2: `createPool({ flags: ["FOUND_ROWS"] })`). Without it, `affectedRows` counts changed (not matched) rows, so an idempotent patch/replace that rewrites identical values reports 0 and the OCC guard raises a spurious conflict.')},f=t=>({all:(e,r)=>t.query(e,r),batch:async e=>{await Promise.all(e.map(r=>t.query(r.sql,r.params)))},run:async(e,r)=>(await t.query(e,r),{rowsAffected:0})}),p=t=>(l(t),{all:async(e,r)=>{const[a]=await t.query(e,o(r));return Array.isArray(a)?a:[]},batch:async e=>{await Promise.all(e.map(r=>t.query(r.sql,o(r.params))))},run:async(e,r)=>{const[a]=await t.query(e,o(r));return{rowsAffected:a.affectedRows??0}}});export{p as buildMysqlExec,f as buildPgExec};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as o}from"./mysql-params-D4Ijlvo5.mjs";const n=r=>({config:{database:r.database,host:r.host,password:r.password,port:r.port,user:r.user},connectionString:r.connectionString}),c=r=>({dbSystem:"postgresql",query:async(s,t=[])=>await r.unsafe(s,t,{prepare:!0})}),u=r=>({dbSystem:"postgresql",query:async(s,t=[])=>(await r.query(s,t)).rows}),y=r=>({dbSystem:"mysql",query:async(s,t=[])=>{const[e]=await r.query(s,o(t));return Array.isArray(e)?e:[]}});export{n as createHyperdrive,y as fromMysql2,u as fromNodePg,c as fromPostgresJs};
|