@jini-ai/db 0.3.4 → 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 +4 -0
- package/dist/kernel/store-copy.d.ts +8 -2
- package/dist/kernel/store-copy.js +5 -4
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
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
|
+
|
|
1
5
|
## 0.3.4 — 2026-10-13
|
|
2
6
|
|
|
3
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.
|
|
@@ -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
|
|
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) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jini-ai/db",
|
|
3
|
-
"version": "0.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,7 +192,7 @@
|
|
|
192
192
|
"registry": "https://registry.npmjs.org"
|
|
193
193
|
},
|
|
194
194
|
"dependencies": {
|
|
195
|
-
"@jini-ai/core": "^0.4.
|
|
195
|
+
"@jini-ai/core": "^0.4.7"
|
|
196
196
|
},
|
|
197
197
|
"peerDependencies": {
|
|
198
198
|
"kysely": "^0.29.6",
|
|
@@ -226,8 +226,8 @@
|
|
|
226
226
|
"better-sqlite3": "13.0.3",
|
|
227
227
|
"kysely": "0.29.6",
|
|
228
228
|
"pg": "8.23.0",
|
|
229
|
-
"@jini-ai/
|
|
230
|
-
"@jini-ai/
|
|
229
|
+
"@jini-ai/core": "0.4.7",
|
|
230
|
+
"@jini-ai/platform": "0.5.9"
|
|
231
231
|
},
|
|
232
232
|
"scripts": {
|
|
233
233
|
"build": "tsc -p tsconfig.build.json",
|