@lunora/hyperdrive 1.0.0-alpha.210 → 1.0.0-alpha.212
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 +72 -3
- package/dist/global.d.ts +72 -3
- package/dist/global.mjs +1 -1
- package/package.json +3 -3
package/dist/global.d.mts
CHANGED
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
* `createPool({ flags: ["FOUND_ROWS"] })`) so the affected-rows OCC guard sees
|
|
23
23
|
* matched (not changed) rows — see {@link buildMysqlExec}.
|
|
24
24
|
*/
|
|
25
|
-
import { DatabaseWriterLike } from '@lunora/shard-engine';
|
|
26
|
-
import { SqlExec, SqlDialect, SqlCtxDbOptions } from '@lunora/sql-store';
|
|
25
|
+
import { SchemaLike, ImportConflictMode, CdcChange, DatabaseWriterLike } from '@lunora/shard-engine';
|
|
26
|
+
import { SqlExec, SqlDialect, SqlCtxDbOptions, FacetGlobalColumnOptions, GlobalFacetResult, GlobalTableInfo, ReadGlobalTablePageOptions, GlobalTablePage, ExportRow, ImportResult } from '@lunora/sql-store';
|
|
27
27
|
import { M as Mysql2Like, S as SqlClient } from "./packem_shared/types.d-B2JdXSms.mjs";
|
|
28
28
|
import { VectorMetric, VectorizeIndexLike } from '@lunora/platform';
|
|
29
29
|
/**
|
|
@@ -171,8 +171,77 @@ interface CreateHyperdriveGlobalCtxDbOptions extends Omit<SqlCtxDbOptions, "dial
|
|
|
171
171
|
* D1 store options.
|
|
172
172
|
*/
|
|
173
173
|
declare const createHyperdriveGlobalCtxDb: ({ engine, exec, ...rest }: CreateHyperdriveGlobalCtxDbOptions) => DatabaseWriterLike;
|
|
174
|
+
/** Options for {@link exportHyperdriveGlobalRows}. */
|
|
175
|
+
interface ExportHyperdriveGlobalRowsOptions {
|
|
176
|
+
engine: HyperdriveEngine;
|
|
177
|
+
exec: SqlExec;
|
|
178
|
+
schema: SchemaLike;
|
|
179
|
+
/** Table allowlist; empty or absent exports every `.global()` table. */
|
|
180
|
+
tables?: ReadonlyArray<string>;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The admin export's global plane on Hyperdrive: yield every requested
|
|
184
|
+
* `.global()` table's rows, keyset-paged. Provisions the schema's tables first,
|
|
185
|
+
* so a table that was never written exports as empty instead of failing.
|
|
186
|
+
*/
|
|
187
|
+
declare const exportHyperdriveGlobalRows: ({ engine, exec, schema, tables }: ExportHyperdriveGlobalRowsOptions) => AsyncGenerator<ExportRow, void, undefined>;
|
|
188
|
+
/** Options for {@link importHyperdriveGlobalRows}. */
|
|
189
|
+
interface ImportHyperdriveGlobalRowsOptions {
|
|
190
|
+
/** Append each insert to the global CDC log, like any other write — the app's own `cdc` setting. */
|
|
191
|
+
cdc: boolean;
|
|
192
|
+
/** Validate and report shape errors only; nothing is probed or written. */
|
|
193
|
+
dryRun?: boolean;
|
|
194
|
+
engine: HyperdriveEngine;
|
|
195
|
+
exec: SqlExec;
|
|
196
|
+
/** `"replace"` overwrites a row whose `_id` already exists; `"skip"` (the default) counts it as a conflict. */
|
|
197
|
+
onConflict?: ImportConflictMode;
|
|
198
|
+
rows: ReadonlyArray<ExportRow>;
|
|
199
|
+
schema: SchemaLike;
|
|
200
|
+
startLine?: number;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The admin import's global plane on Hyperdrive: insert snapshot rows through
|
|
204
|
+
* the same store core `.global()` writes use. A row whose `_id` already exists
|
|
205
|
+
* is a conflict left unchanged, unless `onConflict` is `"replace"`.
|
|
206
|
+
*/
|
|
207
|
+
declare const importHyperdriveGlobalRows: ({ cdc, dryRun, engine, exec, onConflict, rows, schema, startLine }: ImportHyperdriveGlobalRowsOptions) => Promise<ImportResult>;
|
|
174
208
|
/** Convenience: a **Postgres** `.global()` writer from a row-client (postgres.js/pg over Hyperdrive). */
|
|
175
209
|
declare const createPostgresGlobalCtxDb: (client: RowClient, options: Omit<CreateHyperdriveGlobalCtxDbOptions, "engine" | "exec">) => DatabaseWriterLike;
|
|
176
210
|
/** Convenience: a **MySQL** `.global()` writer from a `mysql2/promise` connection/pool (created with `flags: ["FOUND_ROWS"]`). */
|
|
177
211
|
declare const createMysqlGlobalCtxDb: (connection: Mysql2Execute, options: Omit<CreateHyperdriveGlobalCtxDbOptions, "engine" | "exec">) => DatabaseWriterLike;
|
|
178
|
-
|
|
212
|
+
/** The studio's global data browser over a Hyperdrive database — every table in the connection's schema, internal ones hidden. */
|
|
213
|
+
interface HyperdriveGlobalIntrospector {
|
|
214
|
+
facetColumn: (options: FacetGlobalColumnOptions) => Promise<GlobalFacetResult>;
|
|
215
|
+
listTables: () => Promise<GlobalTableInfo[]>;
|
|
216
|
+
readTablePage: (options: ReadGlobalTablePageOptions) => Promise<GlobalTablePage>;
|
|
217
|
+
}
|
|
218
|
+
/** Build the studio's global-browser introspector for a Hyperdrive `.global()` store. */
|
|
219
|
+
declare const createHyperdriveGlobalIntrospector: (engine: HyperdriveEngine, exec: SqlExec, schema: SchemaLike) => HyperdriveGlobalIntrospector;
|
|
220
|
+
/**
|
|
221
|
+
* The admin CDC sync's global plane on Hyperdrive: a page of the global
|
|
222
|
+
* `__cdc_log` past `sinceSeq`. The log only exists once a CDC-enabled writer has
|
|
223
|
+
* run, so its absence is "nothing has changed yet" — an empty page that leaves
|
|
224
|
+
* the cursor where it was — not an error.
|
|
225
|
+
*/
|
|
226
|
+
declare const readHyperdriveGlobalCdc: (engine: HyperdriveEngine, exec: SqlExec, request: {
|
|
227
|
+
limit?: number;
|
|
228
|
+
now?: number;
|
|
229
|
+
sinceSeq: number;
|
|
230
|
+
}) => Promise<{
|
|
231
|
+
changes: CdcChange[];
|
|
232
|
+
cursor: number;
|
|
233
|
+
}>;
|
|
234
|
+
/**
|
|
235
|
+
* The admin point-in-time apply's global plane on Hyperdrive: replay CDC changes
|
|
236
|
+
* in order through the store core (insert, falling back to replace). The writer
|
|
237
|
+
* carries the app's `cdc` setting so the replay appends to the global changelog
|
|
238
|
+
* like any other write. Returns the number replayed.
|
|
239
|
+
*/
|
|
240
|
+
declare const applyHyperdriveGlobalCdc: (options: {
|
|
241
|
+
cdc: boolean;
|
|
242
|
+
changes: ReadonlyArray<CdcChange>;
|
|
243
|
+
engine: HyperdriveEngine;
|
|
244
|
+
exec: SqlExec;
|
|
245
|
+
schema: SchemaLike;
|
|
246
|
+
}) => Promise<number>;
|
|
247
|
+
export { CreateHyperdriveGlobalCtxDbOptions, ExportHyperdriveGlobalRowsOptions, HyperdriveEngine, HyperdriveGlobalIntrospector, ImportHyperdriveGlobalRowsOptions, type Mysql2Execute, type PgVectorIndexOptions, type RowClient, applyHyperdriveGlobalCdc, buildMysqlExec, buildPgExec, createHyperdriveGlobalCtxDb, createHyperdriveGlobalIntrospector, createMysqlGlobalCtxDb, createPgVectorIndex, createPostgresGlobalCtxDb, exportHyperdriveGlobalRows, importHyperdriveGlobalRows, mysqlDialect, postgresDialect, readHyperdriveGlobalCdc };
|
package/dist/global.d.ts
CHANGED
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
* `createPool({ flags: ["FOUND_ROWS"] })`) so the affected-rows OCC guard sees
|
|
23
23
|
* matched (not changed) rows — see {@link buildMysqlExec}.
|
|
24
24
|
*/
|
|
25
|
-
import { DatabaseWriterLike } from '@lunora/shard-engine';
|
|
26
|
-
import { SqlExec, SqlDialect, SqlCtxDbOptions } from '@lunora/sql-store';
|
|
25
|
+
import { SchemaLike, ImportConflictMode, CdcChange, DatabaseWriterLike } from '@lunora/shard-engine';
|
|
26
|
+
import { SqlExec, SqlDialect, SqlCtxDbOptions, FacetGlobalColumnOptions, GlobalFacetResult, GlobalTableInfo, ReadGlobalTablePageOptions, GlobalTablePage, ExportRow, ImportResult } from '@lunora/sql-store';
|
|
27
27
|
import { M as Mysql2Like, S as SqlClient } from "./packem_shared/types.d-B2JdXSms.js";
|
|
28
28
|
import { VectorMetric, VectorizeIndexLike } from '@lunora/platform';
|
|
29
29
|
/**
|
|
@@ -171,8 +171,77 @@ interface CreateHyperdriveGlobalCtxDbOptions extends Omit<SqlCtxDbOptions, "dial
|
|
|
171
171
|
* D1 store options.
|
|
172
172
|
*/
|
|
173
173
|
declare const createHyperdriveGlobalCtxDb: ({ engine, exec, ...rest }: CreateHyperdriveGlobalCtxDbOptions) => DatabaseWriterLike;
|
|
174
|
+
/** Options for {@link exportHyperdriveGlobalRows}. */
|
|
175
|
+
interface ExportHyperdriveGlobalRowsOptions {
|
|
176
|
+
engine: HyperdriveEngine;
|
|
177
|
+
exec: SqlExec;
|
|
178
|
+
schema: SchemaLike;
|
|
179
|
+
/** Table allowlist; empty or absent exports every `.global()` table. */
|
|
180
|
+
tables?: ReadonlyArray<string>;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The admin export's global plane on Hyperdrive: yield every requested
|
|
184
|
+
* `.global()` table's rows, keyset-paged. Provisions the schema's tables first,
|
|
185
|
+
* so a table that was never written exports as empty instead of failing.
|
|
186
|
+
*/
|
|
187
|
+
declare const exportHyperdriveGlobalRows: ({ engine, exec, schema, tables }: ExportHyperdriveGlobalRowsOptions) => AsyncGenerator<ExportRow, void, undefined>;
|
|
188
|
+
/** Options for {@link importHyperdriveGlobalRows}. */
|
|
189
|
+
interface ImportHyperdriveGlobalRowsOptions {
|
|
190
|
+
/** Append each insert to the global CDC log, like any other write — the app's own `cdc` setting. */
|
|
191
|
+
cdc: boolean;
|
|
192
|
+
/** Validate and report shape errors only; nothing is probed or written. */
|
|
193
|
+
dryRun?: boolean;
|
|
194
|
+
engine: HyperdriveEngine;
|
|
195
|
+
exec: SqlExec;
|
|
196
|
+
/** `"replace"` overwrites a row whose `_id` already exists; `"skip"` (the default) counts it as a conflict. */
|
|
197
|
+
onConflict?: ImportConflictMode;
|
|
198
|
+
rows: ReadonlyArray<ExportRow>;
|
|
199
|
+
schema: SchemaLike;
|
|
200
|
+
startLine?: number;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The admin import's global plane on Hyperdrive: insert snapshot rows through
|
|
204
|
+
* the same store core `.global()` writes use. A row whose `_id` already exists
|
|
205
|
+
* is a conflict left unchanged, unless `onConflict` is `"replace"`.
|
|
206
|
+
*/
|
|
207
|
+
declare const importHyperdriveGlobalRows: ({ cdc, dryRun, engine, exec, onConflict, rows, schema, startLine }: ImportHyperdriveGlobalRowsOptions) => Promise<ImportResult>;
|
|
174
208
|
/** Convenience: a **Postgres** `.global()` writer from a row-client (postgres.js/pg over Hyperdrive). */
|
|
175
209
|
declare const createPostgresGlobalCtxDb: (client: RowClient, options: Omit<CreateHyperdriveGlobalCtxDbOptions, "engine" | "exec">) => DatabaseWriterLike;
|
|
176
210
|
/** Convenience: a **MySQL** `.global()` writer from a `mysql2/promise` connection/pool (created with `flags: ["FOUND_ROWS"]`). */
|
|
177
211
|
declare const createMysqlGlobalCtxDb: (connection: Mysql2Execute, options: Omit<CreateHyperdriveGlobalCtxDbOptions, "engine" | "exec">) => DatabaseWriterLike;
|
|
178
|
-
|
|
212
|
+
/** The studio's global data browser over a Hyperdrive database — every table in the connection's schema, internal ones hidden. */
|
|
213
|
+
interface HyperdriveGlobalIntrospector {
|
|
214
|
+
facetColumn: (options: FacetGlobalColumnOptions) => Promise<GlobalFacetResult>;
|
|
215
|
+
listTables: () => Promise<GlobalTableInfo[]>;
|
|
216
|
+
readTablePage: (options: ReadGlobalTablePageOptions) => Promise<GlobalTablePage>;
|
|
217
|
+
}
|
|
218
|
+
/** Build the studio's global-browser introspector for a Hyperdrive `.global()` store. */
|
|
219
|
+
declare const createHyperdriveGlobalIntrospector: (engine: HyperdriveEngine, exec: SqlExec, schema: SchemaLike) => HyperdriveGlobalIntrospector;
|
|
220
|
+
/**
|
|
221
|
+
* The admin CDC sync's global plane on Hyperdrive: a page of the global
|
|
222
|
+
* `__cdc_log` past `sinceSeq`. The log only exists once a CDC-enabled writer has
|
|
223
|
+
* run, so its absence is "nothing has changed yet" — an empty page that leaves
|
|
224
|
+
* the cursor where it was — not an error.
|
|
225
|
+
*/
|
|
226
|
+
declare const readHyperdriveGlobalCdc: (engine: HyperdriveEngine, exec: SqlExec, request: {
|
|
227
|
+
limit?: number;
|
|
228
|
+
now?: number;
|
|
229
|
+
sinceSeq: number;
|
|
230
|
+
}) => Promise<{
|
|
231
|
+
changes: CdcChange[];
|
|
232
|
+
cursor: number;
|
|
233
|
+
}>;
|
|
234
|
+
/**
|
|
235
|
+
* The admin point-in-time apply's global plane on Hyperdrive: replay CDC changes
|
|
236
|
+
* in order through the store core (insert, falling back to replace). The writer
|
|
237
|
+
* carries the app's `cdc` setting so the replay appends to the global changelog
|
|
238
|
+
* like any other write. Returns the number replayed.
|
|
239
|
+
*/
|
|
240
|
+
declare const applyHyperdriveGlobalCdc: (options: {
|
|
241
|
+
cdc: boolean;
|
|
242
|
+
changes: ReadonlyArray<CdcChange>;
|
|
243
|
+
engine: HyperdriveEngine;
|
|
244
|
+
exec: SqlExec;
|
|
245
|
+
schema: SchemaLike;
|
|
246
|
+
}) => Promise<number>;
|
|
247
|
+
export { CreateHyperdriveGlobalCtxDbOptions, ExportHyperdriveGlobalRowsOptions, HyperdriveEngine, HyperdriveGlobalIntrospector, ImportHyperdriveGlobalRowsOptions, type Mysql2Execute, type PgVectorIndexOptions, type RowClient, applyHyperdriveGlobalCdc, buildMysqlExec, buildPgExec, createHyperdriveGlobalCtxDb, createHyperdriveGlobalIntrospector, createMysqlGlobalCtxDb, createPgVectorIndex, createPostgresGlobalCtxDb, exportHyperdriveGlobalRows, importHyperdriveGlobalRows, mysqlDialect, postgresDialect, readHyperdriveGlobalCdc };
|
package/dist/global.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createSqlCtxDb as
|
|
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-CjkrA5JG.mjs";import{createPgVectorIndex as A}from"./packem_shared/createPgVectorIndex-CSNnG065.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/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.212",
|
|
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",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
54
54
|
"@lunora/platform": "1.0.0-alpha.75",
|
|
55
|
-
"@lunora/shard-engine": "1.0.0-alpha.
|
|
56
|
-
"@lunora/sql-store": "1.0.0-alpha.
|
|
55
|
+
"@lunora/shard-engine": "1.0.0-alpha.167",
|
|
56
|
+
"@lunora/sql-store": "1.0.0-alpha.215",
|
|
57
57
|
"drizzle-orm": "1.0.0-rc.5"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|