@jini-ai/db 0.6.19 → 0.7.1
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 +26 -0
- package/dist/core/pg-types.d.ts +2 -0
- package/dist/data-modules/data-module.d.ts +90 -0
- package/dist/data-modules/data-module.js +851 -0
- package/dist/data-modules/disk-headroom.d.ts +11 -0
- package/dist/data-modules/disk-headroom.js +44 -0
- package/dist/data-modules/index.d.ts +18 -0
- package/dist/data-modules/index.js +17 -0
- package/dist/data-modules/migration-journal.d.ts +65 -0
- package/dist/data-modules/migration-journal.js +90 -0
- package/dist/data-modules/migration-recovery.d.ts +37 -0
- package/dist/data-modules/migration-recovery.js +62 -0
- package/dist/data-modules/plugin-identity.d.ts +43 -0
- package/dist/data-modules/plugin-identity.js +101 -0
- package/dist/data-modules/plugin-store.d.ts +43 -0
- package/dist/data-modules/plugin-store.js +6 -0
- package/dist/data-modules/restore.d.ts +5 -0
- package/dist/data-modules/restore.js +42 -0
- package/dist/data-modules/snapshot.d.ts +57 -0
- package/dist/data-modules/snapshot.js +94 -0
- package/dist/kernel/index.d.ts +1 -0
- package/dist/kernel/index.js +1 -0
- package/dist/kernel/kernel-core.d.ts +2 -0
- package/dist/kernel/kernel-core.js +2 -0
- package/dist/kernel/postgres/driver.js +13 -0
- package/dist/kernel/schema-scope.js +2 -0
- package/dist/kernel/session-lock.d.ts +40 -0
- package/dist/kernel/session-lock.js +48 -0
- package/package.json +14 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
## 0.7.1
|
|
2
|
+
|
|
3
|
+
### Patch Changes
|
|
4
|
+
|
|
5
|
+
- Updated dependencies [873f10c]
|
|
6
|
+
- @jini-ai/core@0.7.1
|
|
7
|
+
|
|
8
|
+
## 0.7.0
|
|
9
|
+
|
|
10
|
+
### Minor Changes
|
|
11
|
+
|
|
12
|
+
- 2364f89: Expose the driver-neutral plugin data-module engine through the Node entry `@jini-ai/db/data-modules`, preserving persisted names and host-supplied provenance.
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [8fe045b]
|
|
17
|
+
- Updated dependencies [c393010]
|
|
18
|
+
- Updated dependencies [41ff2ff]
|
|
19
|
+
- Updated dependencies [a266ba8]
|
|
20
|
+
- Updated dependencies [27063ef]
|
|
21
|
+
- Updated dependencies [6ab1d81]
|
|
22
|
+
- Updated dependencies [699b478]
|
|
23
|
+
- Updated dependencies [39cf677]
|
|
24
|
+
- @jini-ai/core@0.7.0
|
|
25
|
+
- @jini-ai/platform@0.7.0
|
|
26
|
+
|
|
1
27
|
## 0.6.19
|
|
2
28
|
|
|
3
29
|
- Redact PostgreSQL idle-pool failure diagnostics without changing pool recovery.
|
package/dist/core/pg-types.d.ts
CHANGED
|
@@ -50,6 +50,8 @@ export interface PgCursor<Row> {
|
|
|
50
50
|
}
|
|
51
51
|
/** A checked-out pool connection, described structurally rather than through Kysely. */
|
|
52
52
|
export interface PgPoolClient {
|
|
53
|
+
/** Held session owners also need an error listener while checked out of the pool. */
|
|
54
|
+
on?(event: "error", listener: (err: Error) => void): unknown;
|
|
53
55
|
processID?: number;
|
|
54
56
|
query<Row>(sql: string, parameters: ReadonlyArray<unknown>): Promise<PgQueryResult<Row>>;
|
|
55
57
|
query<Row>(cursor: PgCursor<Row>): PgCursor<Row>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { type HeadroomCheck } from "./disk-headroom.js";
|
|
2
|
+
import type { PluginProvenance } from "./plugin-identity.js";
|
|
3
|
+
import { type PluginStore } from "./plugin-store.js";
|
|
4
|
+
export type ColumnType = "TEXT" | "INTEGER" | "REAL" | "BLOB";
|
|
5
|
+
export type PluginTier = "tier-1" | "tier-2" | "tier-3";
|
|
6
|
+
export interface ColumnDecl {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly type: ColumnType;
|
|
9
|
+
readonly notNull?: boolean;
|
|
10
|
+
readonly primaryKey?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* ADR-023 §2 ("declared FKs") / ADR-031 OQ-1 (SDK stress-test finding) — the dataModule seam's
|
|
14
|
+
* declared-index grammar. Comments' moderation-queue query pattern
|
|
15
|
+
* (`workspace_id, entry_id, status`) is the concrete demand this grows the seam against, per
|
|
16
|
+
* OQ-1's own instruction not to silently work around the gap. Deliberately NOT a foreign-key
|
|
17
|
+
* declaration seam too — ADR-031 §2 itself says referential integrity to `entries`/parent
|
|
18
|
+
* comments is "chokepoint-validated, not FK-enforced (v1)", so only indexes are the real,
|
|
19
|
+
* load-bearing need; adding FK-declaration grammar with no consumer would be speculative.
|
|
20
|
+
*/
|
|
21
|
+
export interface IndexDecl {
|
|
22
|
+
/** SHORT name; core prefixes it the same way tables are (`idx_p_{pluginId}__{name}`). */
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly columns: readonly string[];
|
|
25
|
+
readonly unique?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface TableDecl {
|
|
28
|
+
/** SHORT name; core prefixes it with the reserved `p_{pluginId}__` namespace. */
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly columns: readonly ColumnDecl[];
|
|
31
|
+
readonly indexes?: readonly IndexDecl[];
|
|
32
|
+
/** Share policy belongs to the table owner. Missing declarations still refuse nonempty data.
|
|
33
|
+
* Portable columns are explicit so later personal fields cannot silently enter an archive. */
|
|
34
|
+
readonly portability?: {
|
|
35
|
+
readonly kind: "private";
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: "portable";
|
|
38
|
+
readonly columns: readonly string[];
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export interface DataModuleDecl {
|
|
42
|
+
readonly pluginId: string;
|
|
43
|
+
/** §3/T6: `dataModule` is scoped to Tier-2/Tier-3 only — a Tier-1 declaration is rejected. */
|
|
44
|
+
readonly pluginTier: PluginTier;
|
|
45
|
+
readonly tables: readonly TableDecl[];
|
|
46
|
+
/** §5/§6/T5 — used by the namespace-adoption guard. */
|
|
47
|
+
readonly provenance: PluginProvenance;
|
|
48
|
+
}
|
|
49
|
+
export interface DeclareResult {
|
|
50
|
+
readonly ok: boolean;
|
|
51
|
+
/** Fully-qualified names of tables created this call. */
|
|
52
|
+
readonly created: string[];
|
|
53
|
+
/**
|
|
54
|
+
* Fully-qualified names of already-existing tables that had one or more declared columns added
|
|
55
|
+
* and/or declared indexes added or recreated this call (the column- and index-level
|
|
56
|
+
* reconciliation described in this file's header comment). A table name never appears in both
|
|
57
|
+
* `created` and `altered` — it is either newly made or already existed.
|
|
58
|
+
*/
|
|
59
|
+
readonly altered: string[];
|
|
60
|
+
/** Path to the pre-DDL snapshot, or null when nothing needed doing / the input was invalid. */
|
|
61
|
+
readonly snapshotPath: string | null;
|
|
62
|
+
/** On failure: the snapshot that remains as the named recovery point (§9). */
|
|
63
|
+
readonly recoveryPoint?: string | undefined;
|
|
64
|
+
readonly error?: {
|
|
65
|
+
code: string;
|
|
66
|
+
message: string;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Declare (reconcile) a plugin's tables. Core snapshots first, then runs the DDL transactionally.
|
|
71
|
+
*
|
|
72
|
+
* `db` is the storage kernel (or a SQLite connection, bridged to its kernel). `dbPath` names the
|
|
73
|
+
* SQLite file behind it, for the snapshot; it is ignored for a Postgres/PGlite kernel.
|
|
74
|
+
* `checkHeadroom` replaces only disk measurement; the existing disk-headroom adapter is the default.
|
|
75
|
+
*
|
|
76
|
+
* @agent-note `dbPath` must name the file behind `db`. `":memory:"`, `""` or a memory URI for a
|
|
77
|
+
* file-backed database skips the snapshot, journal and headroom check with no error. Another
|
|
78
|
+
* file's path still snapshots `db`, but beside that file, and sizes headroom from that file.
|
|
79
|
+
* `decl.provenance` is checked against the stored identity row; see {@link PluginProvenance}.
|
|
80
|
+
*/
|
|
81
|
+
export declare function declareDataModule(required: {
|
|
82
|
+
db: PluginStore;
|
|
83
|
+
dbPath: string;
|
|
84
|
+
decl: DataModuleDecl;
|
|
85
|
+
}, { checkHeadroom }?: {
|
|
86
|
+
checkHeadroom?: (required: {
|
|
87
|
+
dbPath: string;
|
|
88
|
+
}, optional?: Record<string, never>) => HeadroomCheck;
|
|
89
|
+
}): Promise<DeclareResult>;
|
|
90
|
+
//# sourceMappingURL=data-module.d.ts.map
|