@jini-ai/db 0.3.3 → 0.3.5

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/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.3.5 — 2026-10-16
2
+
3
+ - Store copy lets the host exclude retained restore tables from the catalog, emptiness check and copy (b0b13de4); copy only builds indexes for tables it created (d748cf67).
4
+
5
+ ## 0.3.4 — 2026-10-13
6
+
7
+ - Vault SQL repo imports `@jini-ai/platform/secrets/credential-sets/contracts`; requires @jini-ai/platform >=0.5.6 (credential-sets/contracts); publish platform first.
8
+ - `@jini-ai/platform` is now an optional peer: only `./secrets-vault` loads it. Hosts using the vault list platform themselves.
9
+
1
10
  ## 0.3.3 — 2026-10-12
2
11
 
3
12
  - Vault `findDefault` restates the default group in the normalized expressions and binds `is_default` as a dialect literal, so a host's partial default index is matched (SQLite and Postgres). Raw-column filters stay; results are unchanged.
package/README.md CHANGED
@@ -29,6 +29,12 @@ the tsx CommonJS bootstrap can resolve the subpaths without an active `import` c
29
29
 
30
30
  ## Import and driver isolation
31
31
 
32
+ `@jini-ai/db/secrets-vault` requires the optional `@jini-ai/platform` peer at import
33
+ time for the canonical credential validation and error contracts, plus Kysely for
34
+ SQL. Install platform explicitly when using this subpath; existing vault consumers
35
+ that relied on transitive installation must add it before upgrading. Other database
36
+ entries do not load platform.
37
+
32
38
  `kysely` is an optional peer (`^0.29.6`), imported as a value or type only under `src/kernel/`
33
39
  and `src/migrate/`. `better-sqlite3`, `pg` and `@electric-sql/pglite` are also optional peers.
34
40
  Production code never imports a driver at runtime. PGlite type imports are confined to
@@ -6,8 +6,9 @@ import type { StorageKernel } from "./port.js";
6
6
  *
7
7
  * Same dialect on both sides, so nothing is translated: rows travel as each column's text form and
8
8
  * the target's own input functions read them back (jsonb, tsvector, bytea, arrays alike). Unlike the
9
- * SQLite transfer (`copy-engine.ts`) nothing is excluded: a move is the switch, so logins and sealed
10
- * credentials go too (still sealed with the same site key).
9
+ * SQLite transfer (`copy-engine.ts`) nothing is excluded by default: a move is the switch, so logins
10
+ * and sealed credentials go too (still sealed with the same site key). Hosts may exclude retained
11
+ * restore artifacts through the scope; those tables stay untouched on both sides.
11
12
  *
12
13
  * - Tables the migrations do not create (a plugin's `p_<id>__*` tables, `_plugin_*` bookkeeping) are
13
14
  * created on the target from the source's own catalog: columns, identity, constraints, indexes.
@@ -27,6 +28,11 @@ export interface StoreCopyScope {
27
28
  schema: string;
28
29
  name: string;
29
30
  }[];
31
+ /** True leaves a table out of the catalog, emptiness checks, copy, constraints and indexes. */
32
+ readonly excludeTable?: (required: {
33
+ schema: string;
34
+ name: string;
35
+ }, optional?: {}) => boolean;
30
36
  }
31
37
  /** The migration ledgers: compared, never copied. */
32
38
  /** Rows per source read / target insert (fewer for a wide table, to stay under the bind limit). */
@@ -15,7 +15,7 @@ const tableRef = (table) => sql.table(qualified(table));
15
15
  /** `"schema"."table"` as text, for functions that take a relation name (`pg_get_serial_sequence`). */
16
16
  const quotedName = (table) => [table.schema, table.name].map((part) => `"${part.replace(/"/g, '""')}"`).join(".");
17
17
  const isLedger = (table, scope) => scope.ledgers.some((l) => l.schema === table.schema && l.name === table.name);
18
- /** Every base table in the moved schemas, with columns and primary key, in a stable order. */
18
+ /** Every non-excluded base table in the moved schemas, with columns and primary key, in a stable order. */
19
19
  async function readCatalogInternal(kernel, scope) {
20
20
  const schemas = sql.join(scope.schemas.map((s) => sql.lit(s)));
21
21
  const columns = await kernel.query(sql `
@@ -56,17 +56,18 @@ async function readCatalogInternal(kernel, scope) {
56
56
  }
57
57
  for (const row of keys)
58
58
  tables.get(`${row.schema}.${row.table}`)?.primaryKey.push(row.column);
59
- return [...tables.values()];
59
+ return [...tables.values()].filter((table) => !scope.excludeTable?.(table));
60
60
  }
61
61
  async function readConstraints(kernel, scope) {
62
- return kernel.query(sql `
62
+ return (await kernel.query(sql `
63
63
  SELECT n.nspname AS schema, c.relname AS table, con.conname AS name, con.contype::text AS type,
64
64
  pg_get_constraintdef(con.oid) AS definition
65
65
  FROM pg_constraint con
66
66
  JOIN pg_class c ON c.oid = con.conrelid
67
67
  JOIN pg_namespace n ON n.oid = c.relnamespace
68
68
  WHERE n.nspname IN (${sql.join(scope.schemas.map((s) => sql.lit(s)))}) AND con.contype IN ('p', 'u', 'c', 'f', 'x')
69
- ORDER BY n.nspname, c.relname, con.conname`);
69
+ ORDER BY n.nspname, c.relname, con.conname`))
70
+ .filter((constraint) => !scope.excludeTable?.({ schema: constraint.schema, name: constraint.table }));
70
71
  }
71
72
  /** Indexes that are not a constraint's own (those come back with the constraint). */
72
73
  async function readIndexes(kernel, scope) {
@@ -1,4 +1,4 @@
1
- import { type VaultBatchOp, type VaultBatchResult, type VaultDefaultQuery, type VaultSingletonQuery, type VaultMeta, type VaultOptions, type VaultQuery, type VaultRecord, type VaultRepoPort } from "@jini-ai/platform/secrets/credential-sets";
1
+ import { type VaultBatchOp, type VaultBatchResult, type VaultDefaultQuery, type VaultSingletonQuery, type VaultMeta, type VaultOptions, type VaultQuery, type VaultRecord, type VaultRepoPort } from "@jini-ai/platform/secrets/credential-sets/contracts";
2
2
  import type { StorageKernel } from "../kernel/port.js";
3
3
  /** Fixed columns consumed by the adapter; hosts own DDL, foreign keys and migration provenance.
4
4
  * A partial unique default index and label index use the same scope as VaultRepoPort.
@@ -59,7 +59,7 @@ export declare class SqlSecretsVaultRepo implements VaultRepoPort {
59
59
  }, _options?: VaultOptions): Promise<VaultBatchResult[]>;
60
60
  /** One indexed exact-group lookup; ciphertext is loaded only for the chosen default.
61
61
  * The group is restated in the default index's normalized expressions and `is_default` is a
62
- * literal, else neither SQLite nor a generic Postgres plan can match the partial index (Tovu
62
+ * literal, else neither SQLite nor a generic Postgres plan can match the partial index (host
63
63
  * EXPLAIN 2026-10-12: SQLite fell back to a raw-column index, Postgres to the label index). */
64
64
  findDefault(input: VaultDefaultQuery, _options?: VaultOptions): Promise<VaultRecord | null>;
65
65
  list(input: VaultQuery, _options?: VaultOptions): Promise<VaultRecord[]>;
@@ -1,5 +1,5 @@
1
1
  import { sql } from "kysely";
2
- import { assertVaultReplacement, VaultError } from "@jini-ai/platform/secrets/credential-sets";
2
+ import { assertVaultReplacement, VaultError } from "@jini-ai/platform/secrets/credential-sets/contracts";
3
3
  import { jsonSet, toBool } from "../kernel/dialect.js";
4
4
  function fromRow(row) {
5
5
  const parts = [row.sealed_key_id, row.sealed_ciphertext, row.sealed_nonce, row.sealed_alg];
@@ -88,7 +88,7 @@ export class SqlSecretsVaultRepo {
88
88
  }
89
89
  /** One indexed exact-group lookup; ciphertext is loaded only for the chosen default.
90
90
  * The group is restated in the default index's normalized expressions and `is_default` is a
91
- * literal, else neither SQLite nor a generic Postgres plan can match the partial index (Tovu
91
+ * literal, else neither SQLite nor a generic Postgres plan can match the partial index (host
92
92
  * EXPLAIN 2026-10-12: SQLite fell back to a raw-column index, Postgres to the label index). */
93
93
  async findDefault(input, _options = {}) {
94
94
  const row = await this.kernel.run(db => this.scoped({ db, input }).selectAll()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/db",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Database ports, connection helpers, ownership, isolated Kysely kernels and migrations. All peers are optional; drivers are injected.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -192,14 +192,14 @@
192
192
  "registry": "https://registry.npmjs.org"
193
193
  },
194
194
  "dependencies": {
195
- "@jini-ai/core": "^0.4.3",
196
- "@jini-ai/platform": "^0.5.4"
195
+ "@jini-ai/core": "^0.4.7"
197
196
  },
198
197
  "peerDependencies": {
199
198
  "kysely": "^0.29.6",
200
199
  "better-sqlite3": "^13.0.0",
201
200
  "@electric-sql/pglite": "0.5.8",
202
- "pg": "^8.23.0"
201
+ "pg": "^8.23.0",
202
+ "@jini-ai/platform": "^0.5.6"
203
203
  },
204
204
  "peerDependenciesMeta": {
205
205
  "better-sqlite3": {
@@ -213,6 +213,9 @@
213
213
  },
214
214
  "kysely": {
215
215
  "optional": true
216
+ },
217
+ "@jini-ai/platform": {
218
+ "optional": true
216
219
  }
217
220
  },
218
221
  "devDependencies": {
@@ -223,7 +226,8 @@
223
226
  "better-sqlite3": "13.0.3",
224
227
  "kysely": "0.29.6",
225
228
  "pg": "8.23.0",
226
- "@jini-ai/core": "0.4.3"
229
+ "@jini-ai/core": "0.4.7",
230
+ "@jini-ai/platform": "0.5.9"
227
231
  },
228
232
  "scripts": {
229
233
  "build": "tsc -p tsconfig.build.json",