@jini-ai/db 0.7.3-next.1 → 0.7.3-next.3

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.
Files changed (89) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +46 -1
  3. package/dist/core/ports.d.ts +2 -2
  4. package/dist/core/ports.js +2 -2
  5. package/dist/data-modules/data-module.d.ts +2 -46
  6. package/dist/data-modules/plugin-identity.d.ts +2 -11
  7. package/dist/data-modules/snapshot.d.ts +5 -3
  8. package/dist/data-modules/snapshot.js +5 -3
  9. package/dist/events/change-set-repo.sql.d.ts +18 -5
  10. package/dist/events/change-set-repo.sql.js +25 -8
  11. package/dist/events/index.d.ts +1 -1
  12. package/dist/events/outbox-repo.sql.d.ts +26 -1
  13. package/dist/events/outbox-repo.sql.js +36 -2
  14. package/dist/events/repo.rows.d.ts +22 -4
  15. package/dist/events/repo.rows.js +32 -4
  16. package/dist/kernel/idle-turn.d.ts +62 -0
  17. package/dist/kernel/idle-turn.js +32 -0
  18. package/dist/kernel/index.d.ts +1 -0
  19. package/dist/kernel/index.js +1 -0
  20. package/dist/kernel/kernel-core.js +28 -0
  21. package/dist/kernel/schema-scope.js +2 -0
  22. package/dist/kernel/sqlite/driver.js +2 -0
  23. package/dist/kernel/turn-lock.d.ts +2 -0
  24. package/dist/kernel/turn-lock.js +7 -0
  25. package/dist/pglite/copy-source.d.ts +45 -0
  26. package/dist/pglite/copy-source.js +36 -0
  27. package/dist/pglite/index.d.ts +1 -0
  28. package/dist/pglite/index.js +1 -0
  29. package/dist/react/recovery/Recovery.d.ts +205 -0
  30. package/dist/react/recovery/Recovery.js +141 -0
  31. package/dist/react/recovery/Recovery.restore-steps.d.ts +10 -0
  32. package/dist/react/recovery/Recovery.restore-steps.js +71 -0
  33. package/dist/recovery/agent-tools.d.ts +33 -0
  34. package/dist/recovery/agent-tools.js +166 -0
  35. package/dist/recovery/drift.d.ts +47 -0
  36. package/dist/recovery/drift.js +51 -0
  37. package/dist/recovery/journal-kernel.d.ts +80 -0
  38. package/dist/recovery/journal-kernel.js +40 -0
  39. package/dist/recovery/journal-repo.sql.d.ts +154 -0
  40. package/dist/recovery/journal-repo.sql.js +303 -0
  41. package/dist/recovery/journal-schema.d.ts +37 -0
  42. package/dist/recovery/journal-schema.js +110 -0
  43. package/dist/recovery/migrate-forward-hooks.d.ts +2 -1
  44. package/dist/recovery/migrate-forward-hooks.js +3 -3
  45. package/dist/recovery/operation-lock.d.ts +2 -17
  46. package/dist/recovery/reconcile-interrupted-migration.d.ts +2 -5
  47. package/dist/recovery/reconcile-interrupted-migration.js +0 -30
  48. package/dist/recovery/restore-hooks.d.ts +4 -0
  49. package/dist/recovery/restore-hooks.js +1 -1
  50. package/dist/recovery/tool-registrations.d.ts +175 -0
  51. package/dist/recovery/tool-registrations.js +295 -0
  52. package/dist/site/repo.memory.d.ts +149 -0
  53. package/dist/site/repo.memory.js +162 -0
  54. package/dist/site/tool-registrations.d.ts +130 -0
  55. package/dist/site/tool-registrations.js +185 -0
  56. package/dist/sqlite/backup-policy.d.ts +14 -0
  57. package/dist/sqlite/backup-policy.js +47 -3
  58. package/dist/sqlite/compaction-steps.d.ts +43 -0
  59. package/dist/sqlite/compaction-steps.js +73 -0
  60. package/dist/sqlite/compaction.d.ts +63 -0
  61. package/dist/sqlite/compaction.js +263 -0
  62. package/dist/sqlite/index.d.ts +2 -1
  63. package/dist/sqlite/index.js +2 -1
  64. package/dist/tools/index.d.ts +2 -0
  65. package/dist/tools/index.js +2 -0
  66. package/dist/tools/plan-store.d.ts +1 -1
  67. package/dist/tools/plan-store.js +10 -6
  68. package/dist/tools/site-db-messages.d.ts +10 -0
  69. package/dist/tools/site-db-messages.js +23 -0
  70. package/dist/tools/site-transfer-messages.d.ts +9 -0
  71. package/dist/tools/site-transfer-messages.js +20 -0
  72. package/dist/transfer/confirmation-ui.d.ts +19 -0
  73. package/dist/transfer/confirmation-ui.js +39 -0
  74. package/dist/transfer/copy-engine.js +11 -11
  75. package/dist/transfer/destination-store.d.ts +69 -0
  76. package/dist/transfer/destination-store.js +75 -0
  77. package/dist/transfer/index.d.ts +2 -0
  78. package/dist/transfer/index.js +2 -0
  79. package/dist/transfer/internal-ddl.d.ts +6 -2
  80. package/dist/transfer/internal-ddl.js +15 -15
  81. package/dist/transfer/postgres-ddl.js +2 -2
  82. package/dist/transfer/schema-catalog.d.ts +148 -0
  83. package/dist/transfer/schema-catalog.js +141 -0
  84. package/dist/transfer/sqlite-backup.d.ts +27 -0
  85. package/dist/transfer/sqlite-backup.js +31 -0
  86. package/dist/transfer/table-catalog.js +1 -0
  87. package/dist/watermark/kernel.d.ts +64 -0
  88. package/dist/watermark/kernel.js +45 -0
  89. package/package.json +105 -10
@@ -0,0 +1,141 @@
1
+ import { quoteIdent } from "./postgres-ddl.js";
2
+ import { planSnapshotTables } from "./table-catalog.js";
3
+ function quoteLiteral({ value }, _options = {}) {
4
+ return `'${value.replace(/'/g, "''")}'`;
5
+ }
6
+ function coreDefault({ column, introspection, schemaLabel }, _optional = {}) {
7
+ if (!column.hasDefault || column.default === undefined)
8
+ return undefined;
9
+ const value = column.default;
10
+ if (introspection.isSql(value))
11
+ return introspection.renderSql({ value });
12
+ if (typeof value === "string")
13
+ return quoteLiteral({ value });
14
+ if (typeof value === "number" || typeof value === "boolean")
15
+ return String(value);
16
+ throw new Error(`${schemaLabel}: '${column.name}' has a default this copier cannot write`);
17
+ }
18
+ function coreColumn({ column, introspection, schemaLabel }, _optional = {}) {
19
+ const base = { name: column.name, sqlType: column.sqlType, notNull: column.notNull };
20
+ const fallback = coreDefault({ column, introspection, schemaLabel });
21
+ const identity = column.identity;
22
+ return {
23
+ ...base,
24
+ ...(fallback === undefined ? {} : { default: fallback }),
25
+ ...(identity === undefined ? {} : { identity: identity === "always" ? "ALWAYS" : "BY DEFAULT" }),
26
+ };
27
+ }
28
+ /** Project the trusted host schema into the DDL contract; plugin SQL never enters here.
29
+ * @complexity O(index terms + columns + unique constraints); no I/O or source mutation.
30
+ */
31
+ function coreIndexes({ cfg, introspection }, _optional = {}) {
32
+ const declared = cfg.indexes.map((index) => {
33
+ const label = index.name ?? cfg.name;
34
+ const named = (term) => {
35
+ if (term.name === undefined)
36
+ throw new Error(`Index ${label} has a column with no name`);
37
+ return term.name;
38
+ };
39
+ return {
40
+ name: index.name ?? `${cfg.name}_idx`,
41
+ columns: index.terms.flatMap((term) => term.kind === "sql" ? [] : [named(term)]),
42
+ // The ORM's index rendering omits table qualifiers. Only the developer-owned schema supplies
43
+ // expressions; introspected plugin expressions remain excluded by the snapshot planner.
44
+ ...(index.terms.some((term) => term.kind === "sql") ? { expressions: index.terms.map((term) => term.kind === "sql" ? `(${introspection.renderSql({ value: term.sql, indexTerm: true })})` : quoteIdent({ name: named(term) })) } : {}),
45
+ unique: index.unique,
46
+ // Only the developer-owned Postgres schema supplies SQL; plugin predicates stay excluded.
47
+ ...(index.where === undefined ? {} : { where: introspection.renderSql({ value: index.where }) }),
48
+ };
49
+ });
50
+ const uniqueColumns = cfg.columns.filter((column) => column.isUnique).map((column) => ({ name: column.uniqueName ?? `${cfg.name}_${column.name}_unique`, columns: [column.name], unique: true }));
51
+ const uniqueConstraints = cfg.uniqueConstraints.map((constraint) => ({ name: constraint.name ?? `${cfg.name}_unique`, columns: [...constraint.columns], unique: true }));
52
+ return [...declared, ...uniqueColumns, ...uniqueConstraints];
53
+ }
54
+ function coreTable({ table, catalog }, _optional = {}) {
55
+ const { introspection, schemaLabel } = catalog;
56
+ const cfg = introspection.tableConfig(table);
57
+ const inline = cfg.columns.filter((column) => column.primary).map((column) => column.name);
58
+ const composite = cfg.primaryKeys.flatMap((pk) => pk.columns);
59
+ const keep = catalog.partiallyExcluded[cfg.name]?.keep;
60
+ return {
61
+ name: cfg.name,
62
+ columns: cfg.columns.map((column) => coreColumn({ column, introspection, schemaLabel })),
63
+ primaryKey: inline.length > 0 ? inline : [...composite],
64
+ ...(keep === undefined ? {} : { keep }),
65
+ indexes: coreIndexes({ cfg, introspection }),
66
+ foreignKeys: cfg.foreignKeys().map((fk) => ({
67
+ name: fk.name,
68
+ columns: [...fk.columns],
69
+ foreignTable: fk.foreignTable,
70
+ foreignColumns: [...fk.foreignColumns],
71
+ onDelete: fk.onDelete ?? "no action",
72
+ onUpdate: fk.onUpdate ?? "no action",
73
+ })),
74
+ checks: cfg.checks.map((check) => ({ name: check.name, sql: introspection.renderSql({ value: check.value }) })),
75
+ };
76
+ }
77
+ function exportedTable({ catalog, exportName }, _optional = {}) {
78
+ const table = catalog.schema[exportName];
79
+ if (table === undefined)
80
+ throw new Error(`${catalog.schemaLabel} has no table exported as '${exportName}'; regenerate it`);
81
+ return table;
82
+ }
83
+ /**
84
+ * The core tables a copy carries, in foreign-key-safe order, logins and saved keys removed.
85
+ *
86
+ * @complexity O(tables + foreign keys).
87
+ */
88
+ export function collectCatalogTransferTables({ catalog }, _optional = {}) {
89
+ return catalog.copyOrder().flatMap((exportName) => {
90
+ const table = exportedTable({ catalog, exportName });
91
+ if (catalog.introspection.tableName(table) in catalog.excludedTables)
92
+ return [];
93
+ return [coreTable({ table, catalog })];
94
+ });
95
+ }
96
+ /**
97
+ * EVERY table the host schema declares, in the same foreign-key-safe order, nothing left out:
98
+ * the full schema a fresh Postgres database is created with.
99
+ *
100
+ * @complexity O(tables + foreign keys).
101
+ */
102
+ export function collectCatalogSchemaTables({ catalog }, _optional = {}) {
103
+ return catalog.copyOrder().map((exportName) => coreTable({ table: exportedTable({ catalog, exportName }), catalog }));
104
+ }
105
+ /** Every SQL table name the host schema declares, copied or not. */
106
+ function coreTableNames({ catalog }, _optional = {}) {
107
+ const names = new Set();
108
+ for (const value of Object.values(catalog.schema)) {
109
+ if (value !== null && typeof value === "object" && catalog.introspection.isTable(value))
110
+ names.add(catalog.introspection.tableName(value));
111
+ }
112
+ return names;
113
+ }
114
+ export function planCatalogSnapshotTables({ source, catalog, policy }, _optional = {}) {
115
+ return planSnapshotTables({ source, policy: {
116
+ coreTables: collectCatalogTransferTables({ catalog }), coreNames: coreTableNames({ catalog }),
117
+ excludedTables: {
118
+ ...catalog.excludedTables,
119
+ ...Object.fromEntries(policy.foreignOwnedTables.map(name => [name, policy.foreignOwnedReason])),
120
+ },
121
+ derivedNames: catalog.derivedNames, migrationLedgers: policy.migrationLedgers,
122
+ bookkeepingPrefixes: policy.bookkeepingPrefixes, secretColumnPattern: policy.secretColumnPattern,
123
+ } });
124
+ }
125
+ /**
126
+ * A database whose raw-SQL schema is introspected separately, never through a host ORM catalog.
127
+ * `ownedTables` are copied first, in that order, then everything else by name.
128
+ */
129
+ export function planIntrospectedSnapshotTables({ source, ownedTables, migrationLedgers, bookkeepingPrefixes }, _optional = {}) {
130
+ const plan = planSnapshotTables({ source, policy: {
131
+ coreTables: [], coreNames: new Set(), excludedTables: {}, derivedNames: new Set(),
132
+ migrationLedgers, bookkeepingPrefixes,
133
+ // Owned transcript/session columns are data, not credential records; copy every owned table raw.
134
+ secretColumnPattern: /(?!)/,
135
+ } });
136
+ return { ...plan, tables: [...plan.tables].sort((a, b) => {
137
+ const rank = ({ name }, _options = {}) => ownedTables.includes(name) ? ownedTables.indexOf(name) : ownedTables.length;
138
+ return rank({ name: a.name }) - rank({ name: b.name }) || a.name.localeCompare(b.name);
139
+ }) };
140
+ }
141
+ //# sourceMappingURL=schema-catalog.js.map
@@ -0,0 +1,27 @@
1
+ /** A host-supplied scope that hands `work` a private, already-created folder and removes it afterwards. */
2
+ export type SqliteBackupTempRoot = <T>(required: {
3
+ work: (scope: {
4
+ root: string;
5
+ }) => Promise<T>;
6
+ }) => Promise<T>;
7
+ type BackupSource = {
8
+ backupTo(destPath: string): Promise<void>;
9
+ };
10
+ /**
11
+ * Online backup (includes WAL writes) of an open SQLite handle, read back as bytes; the temp copy is always removed.
12
+ * Driver-free: the handle is structural (`backupTo`), so the consumer owns its driver installation.
13
+ *
14
+ * @param required.source an open SQLite handle that can write an online backup to a path.
15
+ * @param required.tempDirPrefix the host's `mkdtemp` prefix for the short-lived backup directory.
16
+ * @param optional.withTempRoot a host scope (e.g. an owned temporary root) to run the backup and read in;
17
+ * when given, no nested temp directory is allocated and the scope owns removal.
18
+ * @complexity O(database size) — one backup write and one read.
19
+ */
20
+ export declare function captureSqliteBackupBytes(required: {
21
+ source: BackupSource;
22
+ tempDirPrefix: string;
23
+ }, optional?: {
24
+ withTempRoot?: SqliteBackupTempRoot;
25
+ }): Promise<Buffer>;
26
+ export {};
27
+ //# sourceMappingURL=sqlite-backup.d.ts.map
@@ -0,0 +1,31 @@
1
+ import { readFile, mkdtemp, rm } from "node:fs/promises";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ async function backupAndRead(source, root) {
5
+ const snapshotPath = join(root, "chat.db");
6
+ await source.backupTo(snapshotPath);
7
+ return await readFile(snapshotPath);
8
+ }
9
+ /**
10
+ * Online backup (includes WAL writes) of an open SQLite handle, read back as bytes; the temp copy is always removed.
11
+ * Driver-free: the handle is structural (`backupTo`), so the consumer owns its driver installation.
12
+ *
13
+ * @param required.source an open SQLite handle that can write an online backup to a path.
14
+ * @param required.tempDirPrefix the host's `mkdtemp` prefix for the short-lived backup directory.
15
+ * @param optional.withTempRoot a host scope (e.g. an owned temporary root) to run the backup and read in;
16
+ * when given, no nested temp directory is allocated and the scope owns removal.
17
+ * @complexity O(database size) — one backup write and one read.
18
+ */
19
+ export async function captureSqliteBackupBytes(required, optional = {}) {
20
+ // The host's scope is an injected effect, so this package never imports a platform implementation.
21
+ if (optional.withTempRoot)
22
+ return optional.withTempRoot({ work: ({ root }) => backupAndRead(required.source, root) });
23
+ const dir = await mkdtemp(join(tmpdir(), required.tempDirPrefix));
24
+ try {
25
+ return await backupAndRead(required.source, dir);
26
+ }
27
+ finally {
28
+ await rm(dir, { recursive: true, force: true });
29
+ }
30
+ }
31
+ //# sourceMappingURL=sqlite-backup.js.map
@@ -34,6 +34,7 @@ function introspectedColumn(column, rowId) {
34
34
  /** A table no host schema file describes, in the layout the snapshot declares. */
35
35
  export function introspectedTable({ name, layout }, _optional = {}) {
36
36
  const primaryKey = layout.columns.filter((column) => column.primaryKeyPosition > 0).sort((a, b) => a.primaryKeyPosition - b.primaryKeyPosition).map((column) => column.name);
37
+ // A lone INTEGER primary key is SQLite's auto-numbered row id, so it becomes an identity column.
37
38
  const rowIdColumn = primaryKey.length === 1 ? layout.columns.find((column) => column.name === primaryKey[0] && column.declaredType.toUpperCase() === "INTEGER") : undefined;
38
39
  const indexes = layout.indexes
39
40
  .filter((index) => index.origin !== "pk" && !index.partial && index.columns.every((column) => column !== null))
@@ -0,0 +1,64 @@
1
+ import type { Kysely } from "kysely";
2
+ import type { StorageKernel } from "@jini-ai/core/contracts/storage";
3
+ /**
4
+ * @file The site write watermark (the host's watermark table, `database_write_watermark` in the
5
+ * first host; SPEC-016 C-004/U-002/U-004) on the storage kernel, every dialect: the stamp, the read,
6
+ * and the read-side mirror reconciliation.
7
+ *
8
+ * The watermark table is a singleton row (id 1, created by the host's content-store preparation)
9
+ * advanced by exactly 1 per gated write. The stamp is async, so it is correct only where the caller
10
+ * awaits it: Jini cms's taxonomy write-service does (owner decision O2, `WriteServiceDeps.stampWatermark:
11
+ * () => Promise<void> | void`). Inside a kernel transaction the UPDATE joins it (the kernel hands
12
+ * `run()` the open transaction); outside one it is its own statement, the same envelope as the write
13
+ * it follows.
14
+ */
15
+ /** Host-owned table name. No schema or product table default lives here. */
16
+ export interface WriteWatermarkTables {
17
+ watermark: string;
18
+ }
19
+ /** The structural singleton row this module reads and writes; the host's generated table type must match it. */
20
+ export interface WriteWatermarkTable {
21
+ id: number;
22
+ value: number;
23
+ last_stamped_at: string | null;
24
+ }
25
+ /** The schema-erased kernel and the host's table name. */
26
+ export interface WriteWatermarkRequired {
27
+ kernel: StorageKernel<Kysely<unknown>, unknown>;
28
+ tables: WriteWatermarkTables;
29
+ }
30
+ /**
31
+ * The read-side mirror slice reconciliation writes to (the host's `MirrorStorePort` matches it):
32
+ * a cheap, possibly-stale copy of the authoritative value that can be marked unrefreshable.
33
+ */
34
+ export interface WriteWatermarkMirror {
35
+ set(value: number): Promise<void>;
36
+ markUnrefreshable(): Promise<void>;
37
+ }
38
+ /**
39
+ * A `stampWatermark` binding over `kernel`: `value = value + 1` on the singleton row (id 1, created
40
+ * by the host's content-store preparation).
41
+ *
42
+ * @complexity O(1) — one single-row UPDATE by primary key.
43
+ */
44
+ export declare function kernelStampWatermark({ kernel, tables }: WriteWatermarkRequired, _optional?: Record<string, never>): () => Promise<void>;
45
+ /**
46
+ * The current authoritative watermark (0 when the singleton row is missing).
47
+ *
48
+ * @complexity O(1) — single-row lookup by primary key.
49
+ */
50
+ export declare function readKernelWatermark({ kernel, tables }: WriteWatermarkRequired, _optional?: Record<string, never>): Promise<number>;
51
+ /**
52
+ * Boot-time (and on-demand) mirror reconciliation (U-004). `kernel: null` models "the content
53
+ * database failed to open": the mirror keeps its value and is marked `'unrefreshable'`
54
+ * (U-004-B2/REQ-05), never given a precise-looking but wrong value. Otherwise the mirror is
55
+ * overwritten from the authoritative value, its own prior value discarded (U-004-B1: never a merge).
56
+ *
57
+ * @complexity O(1) plus one read when `kernel` is non-null.
58
+ */
59
+ export declare function reconcileMirror(required: {
60
+ kernel: WriteWatermarkRequired["kernel"] | null;
61
+ tables: WriteWatermarkTables;
62
+ mirror: WriteWatermarkMirror;
63
+ }, _optional?: Record<string, never>): Promise<void>;
64
+ //# sourceMappingURL=kernel.d.ts.map
@@ -0,0 +1,45 @@
1
+ /** The narrow typed view of the schema-erased kernel's connection. */
2
+ function view(db) {
3
+ return db.withTables();
4
+ }
5
+ /**
6
+ * A `stampWatermark` binding over `kernel`: `value = value + 1` on the singleton row (id 1, created
7
+ * by the host's content-store preparation).
8
+ *
9
+ * @complexity O(1) — one single-row UPDATE by primary key.
10
+ */
11
+ export function kernelStampWatermark({ kernel, tables }, _optional = {}) {
12
+ return async () => {
13
+ await kernel.run((db) => view(db)
14
+ .updateTable(tables.watermark)
15
+ .set((eb) => ({ value: eb("value", "+", 1), last_stamped_at: new Date().toISOString() }))
16
+ .where("id", "=", 1)
17
+ .execute());
18
+ };
19
+ }
20
+ /**
21
+ * The current authoritative watermark (0 when the singleton row is missing).
22
+ *
23
+ * @complexity O(1) — single-row lookup by primary key.
24
+ */
25
+ export async function readKernelWatermark({ kernel, tables }, _optional = {}) {
26
+ const row = await kernel.run((db) => view(db).selectFrom(tables.watermark).select("value").where("id", "=", 1).executeTakeFirst());
27
+ return Number(row?.value ?? 0);
28
+ }
29
+ /**
30
+ * Boot-time (and on-demand) mirror reconciliation (U-004). `kernel: null` models "the content
31
+ * database failed to open": the mirror keeps its value and is marked `'unrefreshable'`
32
+ * (U-004-B2/REQ-05), never given a precise-looking but wrong value. Otherwise the mirror is
33
+ * overwritten from the authoritative value, its own prior value discarded (U-004-B1: never a merge).
34
+ *
35
+ * @complexity O(1) plus one read when `kernel` is non-null.
36
+ */
37
+ export async function reconcileMirror(required, _optional = {}) {
38
+ const { kernel, tables, mirror } = required;
39
+ if (kernel === null) {
40
+ await mirror.markUnrefreshable();
41
+ return;
42
+ }
43
+ await mirror.set(await readKernelWatermark({ kernel, tables }));
44
+ }
45
+ //# sourceMappingURL=kernel.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/db",
3
- "version": "0.7.3-next.1",
3
+ "version": "0.7.3-next.3",
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": {
@@ -17,11 +17,14 @@
17
17
  ],
18
18
  "isolation": {
19
19
  "entries": {
20
- "./tools": "transfer"
20
+ "./tools": "transfer",
21
+ "./react/recovery/Recovery": "react"
21
22
  },
22
23
  "shared": [
23
24
  "src/shared/ddl.adapter.ts",
25
+ "src/tools/restore-points.ts",
24
26
  "src/kernel/dialect.ts",
27
+ "src/kernel/idle-turn.ts",
25
28
  "src/kernel/index.ts",
26
29
  "src/kernel/kernel-core.ts",
27
30
  "src/kernel/ops.ts",
@@ -41,12 +44,50 @@
41
44
  "optionalPeers": {
42
45
  "better-sqlite3": "opt-in: sqlite storage — SQLite storage could not load better-sqlite3. Install better-sqlite3 to enable this feature, or check its installed version and native binaries.",
43
46
  "@electric-sql/pglite": "opt-in: embedded postgresql storage — Embedded PostgreSQL storage could not load @electric-sql/pglite. Install @electric-sql/pglite to enable this feature, or check its installed version and native binaries.",
44
- "pg": "opt-in: postgresql storage — PostgreSQL storage could not load pg. Install pg to enable this feature, or check its installed version and native binaries."
47
+ "pg": "opt-in: postgresql storage — PostgreSQL storage could not load pg. Install pg to enable this feature, or check its installed version and native binaries.",
48
+ "react": "opt-in: react browser bindings; import @jini-ai/db/react/recovery/Recovery — React browser bindings could not load react. Install react to enable this feature, or check its installed version.",
49
+ "react-dom": "opt-in: react browser bindings; import @jini-ai/db/react/recovery/Recovery — React browser bindings could not load react-dom. Install react-dom to enable this feature, or check its installed version."
50
+ },
51
+ "entries": {
52
+ "./core": "node",
53
+ "./sqlite": "node",
54
+ "./pglite": "node",
55
+ "./postgres": "node",
56
+ "./kernel": "node",
57
+ "./kernel/sqlite": "node",
58
+ "./kernel/pglite": "node",
59
+ "./kernel/postgres": "node",
60
+ "./migrate": "node",
61
+ "./testing/pg-fixture": "node",
62
+ "./package.json": "node",
63
+ "./transfer": "node",
64
+ "./tools": "node",
65
+ "./kernel/store-copy": "node",
66
+ "./recovery/*": "node",
67
+ "./recovery": "node",
68
+ "./owner-store": "node",
69
+ "./secrets-vault": "node",
70
+ "./settings": "node",
71
+ "./events": "node",
72
+ "./gated-mutations": "node",
73
+ "./verified-origin": "node",
74
+ "./data-modules": "node",
75
+ "./watermark/kernel": "node",
76
+ "./react/recovery/Recovery": "browser",
77
+ "./site/repo.memory": "node",
78
+ "./transfer/confirmation-ui": "node",
79
+ "./transfer/destination-store": "node",
80
+ "./site/tool-registrations": "node"
45
81
  }
46
82
  },
47
83
  "type": "module",
48
84
  "sideEffects": false,
49
85
  "exports": {
86
+ "./site/tool-registrations": {
87
+ "types": "./dist/site/tool-registrations.d.ts",
88
+ "import": "./dist/site/tool-registrations.js",
89
+ "default": "./dist/site/tool-registrations.js"
90
+ },
50
91
  "./core": {
51
92
  "types": "./dist/core/index.d.ts",
52
93
  "import": "./dist/core/index.js",
@@ -157,6 +198,31 @@
157
198
  "types": "./dist/data-modules/index.d.ts",
158
199
  "import": "./dist/data-modules/index.js",
159
200
  "default": "./dist/data-modules/index.js"
201
+ },
202
+ "./watermark/kernel": {
203
+ "types": "./dist/watermark/kernel.d.ts",
204
+ "import": "./dist/watermark/kernel.js",
205
+ "default": "./dist/watermark/kernel.js"
206
+ },
207
+ "./site/repo.memory": {
208
+ "types": "./dist/site/repo.memory.d.ts",
209
+ "import": "./dist/site/repo.memory.js",
210
+ "default": "./dist/site/repo.memory.js"
211
+ },
212
+ "./transfer/confirmation-ui": {
213
+ "types": "./dist/transfer/confirmation-ui.d.ts",
214
+ "import": "./dist/transfer/confirmation-ui.js",
215
+ "default": "./dist/transfer/confirmation-ui.js"
216
+ },
217
+ "./transfer/destination-store": {
218
+ "types": "./dist/transfer/destination-store.d.ts",
219
+ "import": "./dist/transfer/destination-store.js",
220
+ "default": "./dist/transfer/destination-store.js"
221
+ },
222
+ "./react/recovery/Recovery": {
223
+ "types": "./dist/react/recovery/Recovery.d.ts",
224
+ "import": "./dist/react/recovery/Recovery.js",
225
+ "default": "./dist/react/recovery/Recovery.js"
160
226
  }
161
227
  },
162
228
  "typesVersions": {
@@ -229,6 +295,21 @@
229
295
  ],
230
296
  "data-modules": [
231
297
  "./dist/data-modules/index.d.ts"
298
+ ],
299
+ "watermark/kernel": [
300
+ "./dist/watermark/kernel.d.ts"
301
+ ],
302
+ "react/recovery/Recovery": [
303
+ "./dist/react/recovery/Recovery.d.ts"
304
+ ],
305
+ "site/repo.memory": [
306
+ "./dist/site/repo.memory.d.ts"
307
+ ],
308
+ "transfer/confirmation-ui": [
309
+ "./dist/transfer/confirmation-ui.d.ts"
310
+ ],
311
+ "transfer/destination-store": [
312
+ "./dist/transfer/destination-store.d.ts"
232
313
  ]
233
314
  }
234
315
  },
@@ -251,23 +332,31 @@
251
332
  },
252
333
  "dependencies": {
253
334
  "kysely": "^0.29.6",
254
- "@jini-ai/core": "^0.7.3-next.1"
335
+ "@jini-ai/core": "^0.7.3-next.3"
255
336
  },
256
337
  "peerDependencies": {
257
338
  "better-sqlite3": "^13.0.0",
258
339
  "@electric-sql/pglite": "0.5.8",
259
- "pg": "^8.23.0"
340
+ "pg": "^8.23.0",
341
+ "react": "^18.3.0 || ^19.0.0",
342
+ "react-dom": "^18.3.0 || ^19.0.0"
260
343
  },
261
344
  "devDependencies": {
262
345
  "@electric-sql/pglite": "0.5.8",
263
346
  "@types/better-sqlite3": "7.6.13",
264
347
  "@types/pg": "8.23.1",
265
- "@vitest/coverage-v8": "^2.1.9",
348
+ "@vitest/coverage-v8": "^3.2.6",
266
349
  "better-sqlite3": "13.0.3",
267
350
  "kysely": "0.29.6",
268
351
  "pg": "8.23.0",
269
- "@jini-ai/core": "0.7.3-next.1",
270
- "@jini-ai/platform": "0.7.3-next.1"
352
+ "react": "^19.2.0",
353
+ "react-dom": "^19.2.0",
354
+ "@types/react": "^19.2.0",
355
+ "@types/react-dom": "^19.2.0",
356
+ "@testing-library/react": "^16.3.0",
357
+ "jsdom": "^26.1.0",
358
+ "@jini-ai/platform": "0.7.3-next.3",
359
+ "@jini-ai/core": "0.7.3-next.3"
271
360
  },
272
361
  "peerDependenciesMeta": {
273
362
  "better-sqlite3": {
@@ -278,11 +367,17 @@
278
367
  },
279
368
  "pg": {
280
369
  "optional": true
370
+ },
371
+ "react": {
372
+ "optional": true
373
+ },
374
+ "react-dom": {
375
+ "optional": true
281
376
  }
282
377
  },
283
378
  "scripts": {
284
- "build": "tsc -p tsconfig.build.json",
285
- "typecheck": "tsc -p tsconfig.json --noEmit",
379
+ "build": "tsc -p tsconfig.build.json && tsc -p tsconfig.react.build.json",
380
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.react.json --noEmit",
286
381
  "test": "vitest run",
287
382
  "test:coverage": "vitest run --coverage",
288
383
  "test:postgres": "vitest run --config vitest.postgres.config.ts"