@lunora/hyperdrive 1.0.0-alpha.2 → 1.0.0-alpha.200

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 CHANGED
@@ -1,47 +1,136 @@
1
- import { DatabaseWriterLike } from '@lunora/do';
1
+ import { DatabaseWriterLike } from '@lunora/shard-engine';
2
2
  import { SqlExec, SqlDialect, SqlCtxDbOptions } from '@lunora/sql-store';
3
- /** Minimal row-returning client (e.g. `@lunora/hyperdrive`'s `fromPostgresJs`/`fromNodePg` result). */
4
- interface RowClient {
5
- query: <Row = Record<string, unknown>>(text: string, params?: ReadonlyArray<unknown>) => Promise<Row[]>;
6
- }
7
- /** Minimal `mysql2/promise` connection/pool surface — `execute` resolves to `[rows | ResultSetHeader, fields]`. */
8
- interface Mysql2Execute {
9
- execute: (text: string, params?: ReadonlyArray<unknown>) => Promise<[unknown, unknown]>;
10
- }
3
+ import { M as Mysql2Like, S as SqlClient } from "./packem_shared/types.d-B2JdXSms.mjs";
4
+ import { VectorMetric, VectorizeIndexLike } from '@lunora/platform';
5
+ /**
6
+ * Minimal row-returning client (e.g. `@lunora/hyperdrive`'s `fromPostgresJs`/`fromNodePg`
7
+ * result). Aliases {@link SqlClient} — the exec-facing name is kept so call sites read
8
+ * intent, but the shape is the single source of truth in `./types` (no drift).
9
+ */
10
+ type RowClient = SqlClient;
11
11
  /**
12
- * Wrap a Postgres row-client (from `@lunora/hyperdrive`'s `fromPostgresJs` /
13
- * `fromNodePg`) as a {@link SqlExec}. The core already renders `$N` placeholders
14
- * for Postgres, so `all`/`run` forward verbatim. Postgres uses `RETURNING` for
15
- * OCC (read via `all`), so `run` reports no affected-row count.
16
- */
12
+ * Minimal `mysql2/promise` connection/pool surface — `execute` resolves to
13
+ * `[rows | ResultSetHeader, fields]`. Aliases {@link Mysql2Like} so the /global
14
+ * entry's driver surface can never drift from the main entry's, widened with the
15
+ * (optional, structural) shape {@link assertFoundRows}'s `CLIENT_FOUND_ROWS`
16
+ * probe reads.
17
+ *
18
+ * A real `mysql2/promise` connection/pool exposes the merged client-flags
19
+ * bitmask synchronously, but at two different depths depending on which one it
20
+ * is, and NEITHER is in `mysql2`'s own `.d.ts` — its `Pool extends Connection`
21
+ * signature claims a top-level `config`, but at runtime a `mysql2/promise`
22
+ * `Pool` has none; the real value lives one level down, on the core pool it
23
+ * wraps:
24
+ *
25
+ * - a single `Connection`/`PoolConnection` → `connection.config.clientFlags`
26
+ * - a `Pool` (the `createPool({ flags: ["FOUND_ROWS"] })` example above) →
27
+ * `pool.pool.config.connectionConfig.clientFlags`
28
+ *
29
+ * Because those paths are undocumented driver internals, `global-dialect.test.ts`
30
+ * pins them against a REAL `mysql2` pool (built without connecting) rather than
31
+ * only against hand-written doubles — if a `mysql2` release relocates them, the
32
+ * probe would otherwise degrade silently to the warn branch and the OCC guard
33
+ * would go unchecked.
34
+ *
35
+ * The probe fields are typed `unknown` publicly: the paths are not in `mysql2`'s
36
+ * typings, so spelling them out made a real `createPool(...)` fail to type-check
37
+ * (TS2345, weak-type mismatch on `config`). {@link readMysqlClientFlags} reads
38
+ * them through the internal `FlagProbeShape` instead, and a minimal test double
39
+ * (only `execute`) resolves to "undeterminable" rather than a `TypeError`.
40
+ */
41
+ type Mysql2Execute = Mysql2Like & {
42
+ config?: unknown;
43
+ pool?: unknown;
44
+ };
45
+ /**
46
+ * Wrap a Postgres row-client (from `@lunora/hyperdrive`'s `fromPostgresJs` /
47
+ * `fromNodePg`) as a {@link SqlExec}. The core already renders `$N` placeholders
48
+ * for Postgres, so `all`/`run` forward verbatim. Postgres uses `RETURNING` for
49
+ * OCC (read via `all`), so `run` reports no affected-row count.
50
+ *
51
+ * `batch` dispatches every statement concurrently (`Promise.all`) over `client`
52
+ * rather than awaiting each `query` call in turn — `RowClient` only exposes a
53
+ * single-statement `query`, so there is no wire-level multi-statement command
54
+ * to reach for. When `client` is backed by a pool (the common production
55
+ * shape), this genuinely spreads the statements across multiple physical
56
+ * connections instead of serializing one full round trip at a time; against a
57
+ * single connection it still removes the sequential *await*, though the
58
+ * underlying driver may itself queue the sends. Either way it stays
59
+ * non-atomic, at-least-once, and unordered between elements, same as the
60
+ * sequential fallback minus the ordering — safe only for statements whose
61
+ * effects don't depend on each other, which is what every current caller
62
+ * batches (distinct-keyed companion rows).
63
+ */
17
64
  declare const buildPgExec: (client: RowClient) => SqlExec;
18
65
  /**
19
- * Wrap a `mysql2/promise` connection/pool as a {@link SqlExec}. The core already
20
- * renders backtick identifiers and `?` placeholders for MySQL, so `all`/`run`
21
- * forward verbatim. MySQL has no `RETURNING`, so `run` surfaces `affectedRows`
22
- * for the store's affected-rows OCC guard.
23
- *
24
- * **The connection MUST be created with the `CLIENT_FOUND_ROWS` flag**
25
- * (mysql2: `createPool({ flags: ["FOUND_ROWS"] })`). Without it, `affectedRows`
26
- * counts *changed* rows, so an idempotent `patch`/`replace` that re-writes the
27
- * same values reports 0 and the OCC guard raises a spurious conflict.
28
- */
66
+ * Wrap a `mysql2/promise` connection/pool as a {@link SqlExec}. The core already
67
+ * renders backtick identifiers and `?` placeholders for MySQL, so `all`/`run`
68
+ * forward verbatim. MySQL has no `RETURNING`, so `run` surfaces `affectedRows`
69
+ * for the store's affected-rows OCC guard.
70
+ *
71
+ * **The connection MUST be created with the `CLIENT_FOUND_ROWS` flag**
72
+ * (mysql2: `createPool({ flags: ["FOUND_ROWS"] })`). Without it, `affectedRows`
73
+ * counts *changed* rows, so an idempotent `patch`/`replace` that re-writes the
74
+ * same values reports 0 and the OCC guard raises a spurious conflict. Verified
75
+ * once here at construction — see {@link assertFoundRows} — never per statement.
76
+ *
77
+ * `batch` dispatches every statement concurrently (`Promise.all`), same
78
+ * rationale as {@link buildPgExec}'s `batch` — `Mysql2Like` only exposes a
79
+ * single-statement `execute`, so this is "spread across a pool's connections"
80
+ * rather than one wire-level multi-statement command; still non-atomic,
81
+ * at-least-once, and unordered between elements, safe only for statements
82
+ * with no cross-effect (what every current caller batches).
83
+ */
29
84
  declare const buildMysqlExec: (connection: Mysql2Execute) => SqlExec;
30
85
  /**
31
- * **Postgres** dialect. Differs from SQLite only in column types
32
- * (`DOUBLE PRECISION`/`BYTEA`/`BIGSERIAL`), the `information_schema` catalog
33
- * probe, and unique-violation detection (SQLSTATE `23505`).
34
- */
86
+ * **Postgres** dialect. Differs from SQLite only in column types
87
+ * (`DOUBLE PRECISION`/`BYTEA`/`BIGSERIAL`), the `information_schema` catalog
88
+ * probe, and unique-violation detection (SQLSTATE `23505`).
89
+ */
35
90
  declare const postgresDialect: SqlDialect;
36
91
  /**
37
- * **MySQL** dialect. Diverges in: **no `RETURNING`** (the store's OCC falls back
38
- * to affected-rows — which requires the connection's `CLIENT_FOUND_ROWS` flag so
39
- * a no-op update still reports a matched row, see `buildMysqlExec`); bounded
40
- * `VARCHAR` keys (TEXT can't be a primary key / unindexed); a TEXT/BLOB index key
41
- * prefix; and `ER_DUP_ENTRY` (errno 1062) unique violations. (Drizzle's MySQL
42
- * dialect supplies the backtick identifiers + `ON DUPLICATE KEY` upserts.)
43
- */
92
+ * **MySQL** dialect. Diverges in: **no `RETURNING`** (the store's OCC falls back
93
+ * to affected-rows — which requires the connection's `CLIENT_FOUND_ROWS` flag so
94
+ * a no-op update still reports a matched row, see `buildMysqlExec`); bounded
95
+ * `VARCHAR` keys (TEXT can't be a primary key / unindexed); a TEXT/BLOB index key
96
+ * prefix; and `ER_DUP_ENTRY` (errno 1062) unique violations. (Drizzle's MySQL
97
+ * dialect supplies the backtick identifiers + `ON DUPLICATE KEY` upserts.)
98
+ */
44
99
  declare const mysqlDialect: SqlDialect;
100
+ /** Options for {@link createPgVectorIndex}. */
101
+ interface PgVectorIndexOptions {
102
+ /** Postgres client — the same `SqlClient` the Hyperdrive global store takes. */
103
+ client: SqlClient;
104
+ /**
105
+ * Vector width. Must match the embedder's output and the `dimensions` on the
106
+ * schema's `.vectorize(...)`; Postgres enforces it per row, so a mismatch
107
+ * surfaces as a write error rather than silently bad neighbours.
108
+ */
109
+ dimensions: number;
110
+ /** Distance metric. Defaults to `"cosine"`, matching the common embedding case. */
111
+ metric?: VectorMetric;
112
+ /**
113
+ * Names the backing table (`__vec_<name>`), derived rather than configurable —
114
+ * a second name for one index is a way to lose data, not a feature.
115
+ *
116
+ * This is NOT required to equal the key in the shard's `vectors` map, and often
117
+ * cannot: that key mirrors the schema's `.vectorize({ index })`, which may carry
118
+ * hyphens (`"docs-body"`), while this must be a bare SQL identifier. Keep it
119
+ * stable — changing it points the index at a different, empty table.
120
+ */
121
+ name: string;
122
+ }
123
+ /**
124
+ * Build a `pgvector`-backed vector index that satisfies {@link VectorizeIndexLike}.
125
+ *
126
+ * Requires the `vector` extension to be installable by the connecting role
127
+ * (`CREATE EXTENSION IF NOT EXISTS vector`). On a managed Postgres where the
128
+ * role cannot create extensions, install it once out-of-band; the statement is
129
+ * then a no-op.
130
+ * @param options See {@link PgVectorIndexOptions}.
131
+ * @returns An index object the shard's `vectors` map accepts as-is.
132
+ */
133
+ declare const createPgVectorIndex: (options: PgVectorIndexOptions) => VectorizeIndexLike;
45
134
  /** Which engine a Hyperdrive-backed `.global()` store targets. */
46
135
  type HyperdriveEngine = "mysql" | "postgres";
47
136
  /** Options for {@link createHyperdriveGlobalCtxDb}: the store options minus `exec`/`dialect`, plus the engine and a built `SqlExec`. */
@@ -52,18 +141,14 @@ interface CreateHyperdriveGlobalCtxDbOptions extends Omit<SqlCtxDbOptions, "dial
52
141
  exec: SqlExec;
53
142
  }
54
143
  /**
55
- * Build a reactive `.global()` writer backed by a Hyperdrive-reachable
56
- * Postgres/MySQL database. Pass a built {@link SqlExec} (via {@link buildPgExec}/
57
- * {@link buildMysqlExec}) and the matching `engine`; everything else mirrors the
58
- * D1 store options.
59
- */
60
- declare const createHyperdriveGlobalCtxDb: ({
61
- engine,
62
- exec,
63
- ...rest
64
- }: CreateHyperdriveGlobalCtxDbOptions) => DatabaseWriterLike;
144
+ * Build a reactive `.global()` writer backed by a Hyperdrive-reachable
145
+ * Postgres/MySQL database. Pass a built {@link SqlExec} (via {@link buildPgExec}/
146
+ * {@link buildMysqlExec}) and the matching `engine`; everything else mirrors the
147
+ * D1 store options.
148
+ */
149
+ declare const createHyperdriveGlobalCtxDb: ({ engine, exec, ...rest }: CreateHyperdriveGlobalCtxDbOptions) => DatabaseWriterLike;
65
150
  /** Convenience: a **Postgres** `.global()` writer from a row-client (postgres.js/pg over Hyperdrive). */
66
151
  declare const createPostgresGlobalCtxDb: (client: RowClient, options: Omit<CreateHyperdriveGlobalCtxDbOptions, "engine" | "exec">) => DatabaseWriterLike;
67
152
  /** Convenience: a **MySQL** `.global()` writer from a `mysql2/promise` connection/pool (created with `flags: ["FOUND_ROWS"]`). */
68
153
  declare const createMysqlGlobalCtxDb: (connection: Mysql2Execute, options: Omit<CreateHyperdriveGlobalCtxDbOptions, "engine" | "exec">) => DatabaseWriterLike;
69
- export { CreateHyperdriveGlobalCtxDbOptions, HyperdriveEngine, type Mysql2Execute, type RowClient, buildMysqlExec, buildPgExec, createHyperdriveGlobalCtxDb, createMysqlGlobalCtxDb, createPostgresGlobalCtxDb, mysqlDialect, postgresDialect };
154
+ export { CreateHyperdriveGlobalCtxDbOptions, HyperdriveEngine, type Mysql2Execute, type PgVectorIndexOptions, type RowClient, buildMysqlExec, buildPgExec, createHyperdriveGlobalCtxDb, createMysqlGlobalCtxDb, createPgVectorIndex, createPostgresGlobalCtxDb, mysqlDialect, postgresDialect };
package/dist/global.d.ts CHANGED
@@ -1,47 +1,136 @@
1
- import { DatabaseWriterLike } from '@lunora/do';
1
+ import { DatabaseWriterLike } from '@lunora/shard-engine';
2
2
  import { SqlExec, SqlDialect, SqlCtxDbOptions } from '@lunora/sql-store';
3
- /** Minimal row-returning client (e.g. `@lunora/hyperdrive`'s `fromPostgresJs`/`fromNodePg` result). */
4
- interface RowClient {
5
- query: <Row = Record<string, unknown>>(text: string, params?: ReadonlyArray<unknown>) => Promise<Row[]>;
6
- }
7
- /** Minimal `mysql2/promise` connection/pool surface — `execute` resolves to `[rows | ResultSetHeader, fields]`. */
8
- interface Mysql2Execute {
9
- execute: (text: string, params?: ReadonlyArray<unknown>) => Promise<[unknown, unknown]>;
10
- }
3
+ import { M as Mysql2Like, S as SqlClient } from "./packem_shared/types.d-B2JdXSms.js";
4
+ import { VectorMetric, VectorizeIndexLike } from '@lunora/platform';
5
+ /**
6
+ * Minimal row-returning client (e.g. `@lunora/hyperdrive`'s `fromPostgresJs`/`fromNodePg`
7
+ * result). Aliases {@link SqlClient} — the exec-facing name is kept so call sites read
8
+ * intent, but the shape is the single source of truth in `./types` (no drift).
9
+ */
10
+ type RowClient = SqlClient;
11
11
  /**
12
- * Wrap a Postgres row-client (from `@lunora/hyperdrive`'s `fromPostgresJs` /
13
- * `fromNodePg`) as a {@link SqlExec}. The core already renders `$N` placeholders
14
- * for Postgres, so `all`/`run` forward verbatim. Postgres uses `RETURNING` for
15
- * OCC (read via `all`), so `run` reports no affected-row count.
16
- */
12
+ * Minimal `mysql2/promise` connection/pool surface — `execute` resolves to
13
+ * `[rows | ResultSetHeader, fields]`. Aliases {@link Mysql2Like} so the /global
14
+ * entry's driver surface can never drift from the main entry's, widened with the
15
+ * (optional, structural) shape {@link assertFoundRows}'s `CLIENT_FOUND_ROWS`
16
+ * probe reads.
17
+ *
18
+ * A real `mysql2/promise` connection/pool exposes the merged client-flags
19
+ * bitmask synchronously, but at two different depths depending on which one it
20
+ * is, and NEITHER is in `mysql2`'s own `.d.ts` — its `Pool extends Connection`
21
+ * signature claims a top-level `config`, but at runtime a `mysql2/promise`
22
+ * `Pool` has none; the real value lives one level down, on the core pool it
23
+ * wraps:
24
+ *
25
+ * - a single `Connection`/`PoolConnection` → `connection.config.clientFlags`
26
+ * - a `Pool` (the `createPool({ flags: ["FOUND_ROWS"] })` example above) →
27
+ * `pool.pool.config.connectionConfig.clientFlags`
28
+ *
29
+ * Because those paths are undocumented driver internals, `global-dialect.test.ts`
30
+ * pins them against a REAL `mysql2` pool (built without connecting) rather than
31
+ * only against hand-written doubles — if a `mysql2` release relocates them, the
32
+ * probe would otherwise degrade silently to the warn branch and the OCC guard
33
+ * would go unchecked.
34
+ *
35
+ * The probe fields are typed `unknown` publicly: the paths are not in `mysql2`'s
36
+ * typings, so spelling them out made a real `createPool(...)` fail to type-check
37
+ * (TS2345, weak-type mismatch on `config`). {@link readMysqlClientFlags} reads
38
+ * them through the internal `FlagProbeShape` instead, and a minimal test double
39
+ * (only `execute`) resolves to "undeterminable" rather than a `TypeError`.
40
+ */
41
+ type Mysql2Execute = Mysql2Like & {
42
+ config?: unknown;
43
+ pool?: unknown;
44
+ };
45
+ /**
46
+ * Wrap a Postgres row-client (from `@lunora/hyperdrive`'s `fromPostgresJs` /
47
+ * `fromNodePg`) as a {@link SqlExec}. The core already renders `$N` placeholders
48
+ * for Postgres, so `all`/`run` forward verbatim. Postgres uses `RETURNING` for
49
+ * OCC (read via `all`), so `run` reports no affected-row count.
50
+ *
51
+ * `batch` dispatches every statement concurrently (`Promise.all`) over `client`
52
+ * rather than awaiting each `query` call in turn — `RowClient` only exposes a
53
+ * single-statement `query`, so there is no wire-level multi-statement command
54
+ * to reach for. When `client` is backed by a pool (the common production
55
+ * shape), this genuinely spreads the statements across multiple physical
56
+ * connections instead of serializing one full round trip at a time; against a
57
+ * single connection it still removes the sequential *await*, though the
58
+ * underlying driver may itself queue the sends. Either way it stays
59
+ * non-atomic, at-least-once, and unordered between elements, same as the
60
+ * sequential fallback minus the ordering — safe only for statements whose
61
+ * effects don't depend on each other, which is what every current caller
62
+ * batches (distinct-keyed companion rows).
63
+ */
17
64
  declare const buildPgExec: (client: RowClient) => SqlExec;
18
65
  /**
19
- * Wrap a `mysql2/promise` connection/pool as a {@link SqlExec}. The core already
20
- * renders backtick identifiers and `?` placeholders for MySQL, so `all`/`run`
21
- * forward verbatim. MySQL has no `RETURNING`, so `run` surfaces `affectedRows`
22
- * for the store's affected-rows OCC guard.
23
- *
24
- * **The connection MUST be created with the `CLIENT_FOUND_ROWS` flag**
25
- * (mysql2: `createPool({ flags: ["FOUND_ROWS"] })`). Without it, `affectedRows`
26
- * counts *changed* rows, so an idempotent `patch`/`replace` that re-writes the
27
- * same values reports 0 and the OCC guard raises a spurious conflict.
28
- */
66
+ * Wrap a `mysql2/promise` connection/pool as a {@link SqlExec}. The core already
67
+ * renders backtick identifiers and `?` placeholders for MySQL, so `all`/`run`
68
+ * forward verbatim. MySQL has no `RETURNING`, so `run` surfaces `affectedRows`
69
+ * for the store's affected-rows OCC guard.
70
+ *
71
+ * **The connection MUST be created with the `CLIENT_FOUND_ROWS` flag**
72
+ * (mysql2: `createPool({ flags: ["FOUND_ROWS"] })`). Without it, `affectedRows`
73
+ * counts *changed* rows, so an idempotent `patch`/`replace` that re-writes the
74
+ * same values reports 0 and the OCC guard raises a spurious conflict. Verified
75
+ * once here at construction — see {@link assertFoundRows} — never per statement.
76
+ *
77
+ * `batch` dispatches every statement concurrently (`Promise.all`), same
78
+ * rationale as {@link buildPgExec}'s `batch` — `Mysql2Like` only exposes a
79
+ * single-statement `execute`, so this is "spread across a pool's connections"
80
+ * rather than one wire-level multi-statement command; still non-atomic,
81
+ * at-least-once, and unordered between elements, safe only for statements
82
+ * with no cross-effect (what every current caller batches).
83
+ */
29
84
  declare const buildMysqlExec: (connection: Mysql2Execute) => SqlExec;
30
85
  /**
31
- * **Postgres** dialect. Differs from SQLite only in column types
32
- * (`DOUBLE PRECISION`/`BYTEA`/`BIGSERIAL`), the `information_schema` catalog
33
- * probe, and unique-violation detection (SQLSTATE `23505`).
34
- */
86
+ * **Postgres** dialect. Differs from SQLite only in column types
87
+ * (`DOUBLE PRECISION`/`BYTEA`/`BIGSERIAL`), the `information_schema` catalog
88
+ * probe, and unique-violation detection (SQLSTATE `23505`).
89
+ */
35
90
  declare const postgresDialect: SqlDialect;
36
91
  /**
37
- * **MySQL** dialect. Diverges in: **no `RETURNING`** (the store's OCC falls back
38
- * to affected-rows — which requires the connection's `CLIENT_FOUND_ROWS` flag so
39
- * a no-op update still reports a matched row, see `buildMysqlExec`); bounded
40
- * `VARCHAR` keys (TEXT can't be a primary key / unindexed); a TEXT/BLOB index key
41
- * prefix; and `ER_DUP_ENTRY` (errno 1062) unique violations. (Drizzle's MySQL
42
- * dialect supplies the backtick identifiers + `ON DUPLICATE KEY` upserts.)
43
- */
92
+ * **MySQL** dialect. Diverges in: **no `RETURNING`** (the store's OCC falls back
93
+ * to affected-rows — which requires the connection's `CLIENT_FOUND_ROWS` flag so
94
+ * a no-op update still reports a matched row, see `buildMysqlExec`); bounded
95
+ * `VARCHAR` keys (TEXT can't be a primary key / unindexed); a TEXT/BLOB index key
96
+ * prefix; and `ER_DUP_ENTRY` (errno 1062) unique violations. (Drizzle's MySQL
97
+ * dialect supplies the backtick identifiers + `ON DUPLICATE KEY` upserts.)
98
+ */
44
99
  declare const mysqlDialect: SqlDialect;
100
+ /** Options for {@link createPgVectorIndex}. */
101
+ interface PgVectorIndexOptions {
102
+ /** Postgres client — the same `SqlClient` the Hyperdrive global store takes. */
103
+ client: SqlClient;
104
+ /**
105
+ * Vector width. Must match the embedder's output and the `dimensions` on the
106
+ * schema's `.vectorize(...)`; Postgres enforces it per row, so a mismatch
107
+ * surfaces as a write error rather than silently bad neighbours.
108
+ */
109
+ dimensions: number;
110
+ /** Distance metric. Defaults to `"cosine"`, matching the common embedding case. */
111
+ metric?: VectorMetric;
112
+ /**
113
+ * Names the backing table (`__vec_<name>`), derived rather than configurable —
114
+ * a second name for one index is a way to lose data, not a feature.
115
+ *
116
+ * This is NOT required to equal the key in the shard's `vectors` map, and often
117
+ * cannot: that key mirrors the schema's `.vectorize({ index })`, which may carry
118
+ * hyphens (`"docs-body"`), while this must be a bare SQL identifier. Keep it
119
+ * stable — changing it points the index at a different, empty table.
120
+ */
121
+ name: string;
122
+ }
123
+ /**
124
+ * Build a `pgvector`-backed vector index that satisfies {@link VectorizeIndexLike}.
125
+ *
126
+ * Requires the `vector` extension to be installable by the connecting role
127
+ * (`CREATE EXTENSION IF NOT EXISTS vector`). On a managed Postgres where the
128
+ * role cannot create extensions, install it once out-of-band; the statement is
129
+ * then a no-op.
130
+ * @param options See {@link PgVectorIndexOptions}.
131
+ * @returns An index object the shard's `vectors` map accepts as-is.
132
+ */
133
+ declare const createPgVectorIndex: (options: PgVectorIndexOptions) => VectorizeIndexLike;
45
134
  /** Which engine a Hyperdrive-backed `.global()` store targets. */
46
135
  type HyperdriveEngine = "mysql" | "postgres";
47
136
  /** Options for {@link createHyperdriveGlobalCtxDb}: the store options minus `exec`/`dialect`, plus the engine and a built `SqlExec`. */
@@ -52,18 +141,14 @@ interface CreateHyperdriveGlobalCtxDbOptions extends Omit<SqlCtxDbOptions, "dial
52
141
  exec: SqlExec;
53
142
  }
54
143
  /**
55
- * Build a reactive `.global()` writer backed by a Hyperdrive-reachable
56
- * Postgres/MySQL database. Pass a built {@link SqlExec} (via {@link buildPgExec}/
57
- * {@link buildMysqlExec}) and the matching `engine`; everything else mirrors the
58
- * D1 store options.
59
- */
60
- declare const createHyperdriveGlobalCtxDb: ({
61
- engine,
62
- exec,
63
- ...rest
64
- }: CreateHyperdriveGlobalCtxDbOptions) => DatabaseWriterLike;
144
+ * Build a reactive `.global()` writer backed by a Hyperdrive-reachable
145
+ * Postgres/MySQL database. Pass a built {@link SqlExec} (via {@link buildPgExec}/
146
+ * {@link buildMysqlExec}) and the matching `engine`; everything else mirrors the
147
+ * D1 store options.
148
+ */
149
+ declare const createHyperdriveGlobalCtxDb: ({ engine, exec, ...rest }: CreateHyperdriveGlobalCtxDbOptions) => DatabaseWriterLike;
65
150
  /** Convenience: a **Postgres** `.global()` writer from a row-client (postgres.js/pg over Hyperdrive). */
66
151
  declare const createPostgresGlobalCtxDb: (client: RowClient, options: Omit<CreateHyperdriveGlobalCtxDbOptions, "engine" | "exec">) => DatabaseWriterLike;
67
152
  /** Convenience: a **MySQL** `.global()` writer from a `mysql2/promise` connection/pool (created with `flags: ["FOUND_ROWS"]`). */
68
153
  declare const createMysqlGlobalCtxDb: (connection: Mysql2Execute, options: Omit<CreateHyperdriveGlobalCtxDbOptions, "engine" | "exec">) => DatabaseWriterLike;
69
- export { CreateHyperdriveGlobalCtxDbOptions, HyperdriveEngine, type Mysql2Execute, type RowClient, buildMysqlExec, buildPgExec, createHyperdriveGlobalCtxDb, createMysqlGlobalCtxDb, createPostgresGlobalCtxDb, mysqlDialect, postgresDialect };
154
+ export { CreateHyperdriveGlobalCtxDbOptions, HyperdriveEngine, type Mysql2Execute, type PgVectorIndexOptions, type RowClient, buildMysqlExec, buildPgExec, createHyperdriveGlobalCtxDb, createMysqlGlobalCtxDb, createPgVectorIndex, createPostgresGlobalCtxDb, mysqlDialect, postgresDialect };
package/dist/global.mjs CHANGED
@@ -1,9 +1 @@
1
- import { createSqlCtxDb } from '@lunora/sql-store';
2
- import { postgresDialect, mysqlDialect } from './packem_shared/postgresDialect-oNhZ58s8.mjs';
3
- import { buildMysqlExec, buildPgExec } from './packem_shared/buildPgExec-DBbCjyq3.mjs';
4
-
5
- const createHyperdriveGlobalCtxDb = ({ engine, exec, ...rest }) => createSqlCtxDb({ ...rest, dialect: engine === "postgres" ? postgresDialect : mysqlDialect, exec });
6
- const createPostgresGlobalCtxDb = (client, options) => createHyperdriveGlobalCtxDb({ ...options, engine: "postgres", exec: buildPgExec(client) });
7
- const createMysqlGlobalCtxDb = (connection, options) => createHyperdriveGlobalCtxDb({ ...options, engine: "mysql", exec: buildMysqlExec(connection) });
8
-
9
- export { buildMysqlExec, buildPgExec, createHyperdriveGlobalCtxDb, createMysqlGlobalCtxDb, createPostgresGlobalCtxDb, mysqlDialect, postgresDialect };
1
+ import{createSqlCtxDb as c}from"@lunora/sql-store";import{postgresDialect as l,mysqlDialect as s}from"./packem_shared/mysqlDialect-BS1Sz60B.mjs";import{buildMysqlExec as a,buildPgExec as i}from"./packem_shared/buildMysqlExec-CjkrA5JG.mjs";import{createPgVectorIndex as d}from"./packem_shared/createPgVectorIndex-CSNnG065.mjs";const r=({engine:e,exec:t,...o})=>c({...o,dialect:e==="postgres"?l:s,exec:t}),p=(e,t)=>r({...t,engine:"postgres",exec:i(e)}),g=(e,t)=>r({...t,engine:"mysql",exec:a(e)});export{a as buildMysqlExec,i as buildPgExec,r as createHyperdriveGlobalCtxDb,g as createMysqlGlobalCtxDb,d as createPgVectorIndex,p as createPostgresGlobalCtxDb,s as mysqlDialect,l as postgresDialect};