@lunora/hyperdrive 1.0.0-alpha.13 → 1.0.0-alpha.14
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 +40 -1
- package/dist/index.d.ts +40 -1
- package/dist/index.mjs +1 -0
- package/dist/packem_shared/projectSourceRow-DtKuMRIm.mjs +10 -0
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -162,4 +162,43 @@ declare const fromNodePg: (client: NodePgLike) => SqlClient;
|
|
|
162
162
|
* contract the postgres.js / node-postgres adapters already honour.
|
|
163
163
|
*/
|
|
164
164
|
declare const fromMysql2: (connection: Mysql2Like) => SqlClient;
|
|
165
|
-
|
|
165
|
+
/** How an external row maps to a Lunora document. */
|
|
166
|
+
interface ProjectOptions {
|
|
167
|
+
/**
|
|
168
|
+
* Column whose value becomes the Lunora `_id` (stringified). Defaults to `"id"`.
|
|
169
|
+
* With no `map`, this column is dropped from the document body (it lives on as
|
|
170
|
+
* `_id`); with a `map`, the mapper owns the body and `_id` is added from here.
|
|
171
|
+
*/
|
|
172
|
+
idColumn?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Transform an external row into the stored document body. Omit for the default:
|
|
175
|
+
* every selected column except `idColumn` is copied verbatim. The returned object
|
|
176
|
+
* must not include `_id` — it is set from `idColumn`.
|
|
177
|
+
*/
|
|
178
|
+
map?: (row: Record<string, unknown>) => Record<string, unknown>;
|
|
179
|
+
}
|
|
180
|
+
/** Options for {@link pullSourceRows}: the parameterised tenant query plus the row projection. */
|
|
181
|
+
interface PullSourceOptions extends ProjectOptions {
|
|
182
|
+
/** Bound parameter values, positionally matched to `query` (the tenant scope binds here). */
|
|
183
|
+
params?: ReadonlyArray<unknown>;
|
|
184
|
+
/** The full tenant-membership query with driver-native placeholders (`$1` / `?`). */
|
|
185
|
+
query: string;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Project one external row to a Lunora document: lift `idColumn` to a stringified
|
|
189
|
+
* `_id`, then either apply `map` or copy every other column verbatim. Throws when
|
|
190
|
+
* the id column is missing/nullish so a misconfigured query fails loudly rather than
|
|
191
|
+
* materializing rows under an `"undefined"` id.
|
|
192
|
+
*
|
|
193
|
+
* Delegates to `@lunora/do`'s `liftSourceId` — the single id-lift the declarative
|
|
194
|
+
* `.source()` poll loop also uses — so the manual bridge and the codegen path can
|
|
195
|
+
* never diverge in their missing-id handling.
|
|
196
|
+
*/
|
|
197
|
+
declare const projectSourceRow: (row: Record<string, unknown>, options?: ProjectOptions) => Record<string, unknown>;
|
|
198
|
+
/**
|
|
199
|
+
* Run a parameterised tenant query against Hyperdrive and project every row to a
|
|
200
|
+
* Lunora document ready to hand to `materializeExternalRows`. Call this inside an
|
|
201
|
+
* **action** (where `ctx.sql` lives); pass the result to a mutation for the write.
|
|
202
|
+
*/
|
|
203
|
+
declare const pullSourceRows: (sql: SqlClient, options: PullSourceOptions) => Promise<Record<string, unknown>[]>;
|
|
204
|
+
export { type HyperdriveConnection, type HyperdriveLike, type Mysql2Like, type NodePgLike, type PostgresJsLike, type ProjectOptions, type PullSourceOptions, type SqlClient, createHyperdrive, fromMysql2, fromNodePg, fromPostgresJs, projectSourceRow, pullSourceRows };
|
package/dist/index.d.ts
CHANGED
|
@@ -162,4 +162,43 @@ declare const fromNodePg: (client: NodePgLike) => SqlClient;
|
|
|
162
162
|
* contract the postgres.js / node-postgres adapters already honour.
|
|
163
163
|
*/
|
|
164
164
|
declare const fromMysql2: (connection: Mysql2Like) => SqlClient;
|
|
165
|
-
|
|
165
|
+
/** How an external row maps to a Lunora document. */
|
|
166
|
+
interface ProjectOptions {
|
|
167
|
+
/**
|
|
168
|
+
* Column whose value becomes the Lunora `_id` (stringified). Defaults to `"id"`.
|
|
169
|
+
* With no `map`, this column is dropped from the document body (it lives on as
|
|
170
|
+
* `_id`); with a `map`, the mapper owns the body and `_id` is added from here.
|
|
171
|
+
*/
|
|
172
|
+
idColumn?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Transform an external row into the stored document body. Omit for the default:
|
|
175
|
+
* every selected column except `idColumn` is copied verbatim. The returned object
|
|
176
|
+
* must not include `_id` — it is set from `idColumn`.
|
|
177
|
+
*/
|
|
178
|
+
map?: (row: Record<string, unknown>) => Record<string, unknown>;
|
|
179
|
+
}
|
|
180
|
+
/** Options for {@link pullSourceRows}: the parameterised tenant query plus the row projection. */
|
|
181
|
+
interface PullSourceOptions extends ProjectOptions {
|
|
182
|
+
/** Bound parameter values, positionally matched to `query` (the tenant scope binds here). */
|
|
183
|
+
params?: ReadonlyArray<unknown>;
|
|
184
|
+
/** The full tenant-membership query with driver-native placeholders (`$1` / `?`). */
|
|
185
|
+
query: string;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Project one external row to a Lunora document: lift `idColumn` to a stringified
|
|
189
|
+
* `_id`, then either apply `map` or copy every other column verbatim. Throws when
|
|
190
|
+
* the id column is missing/nullish so a misconfigured query fails loudly rather than
|
|
191
|
+
* materializing rows under an `"undefined"` id.
|
|
192
|
+
*
|
|
193
|
+
* Delegates to `@lunora/do`'s `liftSourceId` — the single id-lift the declarative
|
|
194
|
+
* `.source()` poll loop also uses — so the manual bridge and the codegen path can
|
|
195
|
+
* never diverge in their missing-id handling.
|
|
196
|
+
*/
|
|
197
|
+
declare const projectSourceRow: (row: Record<string, unknown>, options?: ProjectOptions) => Record<string, unknown>;
|
|
198
|
+
/**
|
|
199
|
+
* Run a parameterised tenant query against Hyperdrive and project every row to a
|
|
200
|
+
* Lunora document ready to hand to `materializeExternalRows`. Call this inside an
|
|
201
|
+
* **action** (where `ctx.sql` lives); pass the result to a mutation for the write.
|
|
202
|
+
*/
|
|
203
|
+
declare const pullSourceRows: (sql: SqlClient, options: PullSourceOptions) => Promise<Record<string, unknown>[]>;
|
|
204
|
+
export { type HyperdriveConnection, type HyperdriveLike, type Mysql2Like, type NodePgLike, type PostgresJsLike, type ProjectOptions, type PullSourceOptions, type SqlClient, createHyperdrive, fromMysql2, fromNodePg, fromPostgresJs, projectSourceRow, pullSourceRows };
|
package/dist/index.mjs
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { liftSourceId } from '@lunora/do';
|
|
2
|
+
|
|
3
|
+
const projectSourceRow = (row, options = {}) => liftSourceId(row, options);
|
|
4
|
+
const pullSourceRows = async (sql, options) => {
|
|
5
|
+
const { idColumn, map, params, query } = options;
|
|
6
|
+
const rows = await sql.query(query, params);
|
|
7
|
+
return rows.map((row) => projectSourceRow(row, { idColumn, map }));
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { projectSourceRow, pullSourceRows };
|
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.14",
|
|
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",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@lunora/do": "1.0.0-alpha.
|
|
54
|
-
"@lunora/sql-store": "1.0.0-alpha.
|
|
53
|
+
"@lunora/do": "1.0.0-alpha.14",
|
|
54
|
+
"@lunora/sql-store": "1.0.0-alpha.14",
|
|
55
55
|
"drizzle-orm": "^0.45.2"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|