@camstack/system 1.2.458 → 1.2.459
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/{agent-https-DOELEug8.js → agent-https-Dnr_nIVx.js} +3 -723
- package/dist/{agent-https-CQA3W-3e.mjs → agent-https-Iw3RSQup.mjs} +4 -616
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/dist/builtins/alerts/alerts.addon.js +5 -7
- package/dist/builtins/alerts/alerts.addon.mjs +5 -7
- package/dist/builtins/alerts/record-kinds.d.ts +1 -1
- package/dist/builtins/autotrack/index.js +1 -1
- package/dist/builtins/autotrack/index.mjs +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +242 -4
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +240 -2
- package/dist/builtins/calendars/calendars.addon.js +2 -10
- package/dist/builtins/calendars/calendars.addon.mjs +2 -3
- package/dist/builtins/calendars/record-kinds.d.ts +1 -1
- package/dist/builtins/camera-grid/index.js +1 -1
- package/dist/builtins/camera-grid/index.mjs +1 -1
- package/dist/builtins/composer/composer.addon.js +2 -2
- package/dist/builtins/composer/composer.addon.mjs +2 -2
- package/dist/builtins/console-logging/index.js +1 -1
- package/dist/builtins/console-logging/index.mjs +1 -1
- package/dist/builtins/core-blocks/core-blocks.addon.js +4 -6
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +4 -6
- package/dist/builtins/device-history/device-history.addon.js +1 -1
- package/dist/builtins/device-history/device-history.addon.mjs +1 -1
- package/dist/builtins/device-manager/device-manager.addon.js +2 -4
- package/dist/builtins/device-manager/device-manager.addon.mjs +2 -4
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/keychain/index.js +41 -43
- package/dist/builtins/keychain/index.mjs +41 -43
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/dist/builtins/local-auth/local-auth.addon.js +24 -40
- package/dist/builtins/local-auth/local-auth.addon.mjs +24 -40
- package/dist/builtins/local-network/local-network.addon.js +2 -2
- package/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/dist/builtins/loki-logging/index.js +1 -1
- package/dist/builtins/loki-logging/index.mjs +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/dist/builtins/native-metrics/node-metrics-history-recorder.d.ts +1 -2
- package/dist/builtins/platform-probe/index.js +1 -1
- package/dist/builtins/platform-probe/index.mjs +1 -1
- package/dist/builtins/record-entries/index.js +1 -1
- package/dist/builtins/record-entries/index.mjs +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/dist/builtins/snapshot/index.js +1 -1
- package/dist/builtins/snapshot/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/file-host-protocol.d.ts +0 -15
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/dist/builtins/sqlite-storage/index.js +1 -1
- package/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/owned-sqlite-file.d.ts +0 -44
- package/dist/builtins/sqlite-storage/records/records-catalog.d.ts +0 -2
- package/dist/builtins/sqlite-storage/records/records-engine-types.d.ts +0 -21
- package/dist/builtins/sqlite-storage/records/records-engine.d.ts +3 -20
- package/dist/builtins/sqlite-storage/records/records-provider.d.ts +4 -18
- package/dist/builtins/sqlite-storage/records/records-sql.d.ts +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +0 -17
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +21 -196
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +21 -196
- package/dist/builtins/sqlite-storage/storage-admin-provider.d.ts +6 -14
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +2 -2
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +7 -9
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +7 -9
- package/dist/builtins/system-config/system-config.addon.js +667 -40
- package/dist/builtins/system-config/system-config.addon.mjs +625 -15
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{composition-sources-BVguN7VV.mjs → composition-sources-DNRZWR1j.mjs} +1 -1
- package/dist/{composition-sources-DURQNDJ4.js → composition-sources-b0e_2I-D.js} +1 -1
- package/dist/{constants-Njka8Cv6.js → constants-6OeJiZgi.js} +1 -1
- package/dist/{constants-FGjnsE2x.mjs → constants-BnkOdj9Q.mjs} +1 -1
- package/dist/{device-ca-lEaAQ9Xi.mjs → device-ca-Bnkw8GyU.mjs} +1 -1
- package/dist/{device-ca-BrVK_5s3.js → device-ca-CPTDs--d.js} +1 -1
- package/dist/{dist-BZQjLPiz.js → dist-Bn-RNanh.js} +29 -130
- package/dist/{dist-B_GRPhnY.mjs → dist-Wy8cTxg6.mjs} +30 -113
- package/dist/file-host-worker.js +1 -1
- package/dist/file-host-worker.mjs +1 -1
- package/dist/{hub-mdns-ciao-Bg2HfTwP.mjs → hub-mdns-ciao-CJu0nhla.mjs} +2 -2
- package/dist/{hub-mdns-ciao-nce3TXs_.js → hub-mdns-ciao-CTBTlia4.js} +2 -2
- package/dist/index.js +27 -30
- package/dist/index.mjs +11 -14
- package/dist/{restore-archive-C7kLDI_0.mjs → restore-archive-CmP-iiG9.mjs} +84 -331
- package/dist/{restore-archive-FyfZ8YMC.js → restore-archive-DM1OBYq4.js} +89 -342
- package/dist/{wal-maintenance-DfSIOj24.js → wal-maintenance-DUHEp_09.js} +0 -0
- package/dist/{wal-maintenance-Duejh7Lx.mjs → wal-maintenance-NKbwWovZ.mjs} +0 -0
- package/package.json +1 -1
- package/dist/builtins/records/legacy-table-row-count.d.ts +0 -5
- package/dist/builtins/records/phase6-declare-gate.d.ts +0 -28
- package/dist/builtins/sqlite-storage/records/count-settings-array-legacy.d.ts +0 -5
- package/dist/builtins/sqlite-storage/records/count-settings-brokers-legacy.d.ts +0 -6
- package/dist/phase6-declare-gate-Dag1_WR2.js +0 -98
- package/dist/phase6-declare-gate-Lb-mrVvz.mjs +0 -93
|
@@ -43,17 +43,6 @@ export interface OwnedSqliteFile {
|
|
|
43
43
|
readonly bytes: number | null;
|
|
44
44
|
readonly declaredThisBoot: boolean;
|
|
45
45
|
}[]>;
|
|
46
|
-
readLegacyCollection(input: {
|
|
47
|
-
readonly collection: string;
|
|
48
|
-
readonly cursor?: string | undefined;
|
|
49
|
-
readonly limit?: number | undefined;
|
|
50
|
-
}): Promise<{
|
|
51
|
-
readonly rows: readonly {
|
|
52
|
-
readonly id: string;
|
|
53
|
-
readonly data: Record<string, unknown>;
|
|
54
|
-
}[];
|
|
55
|
-
readonly nextCursor: string | null;
|
|
56
|
-
}>;
|
|
57
46
|
dropRetiredTable(name: string): Promise<DroppedRetiredTable | null>;
|
|
58
47
|
/** Which thread serves this file: 0 is the engine's main thread. */
|
|
59
48
|
servingThreadId(): Promise<number>;
|
|
@@ -117,17 +106,6 @@ declare abstract class OwnedFileBase implements OwnedSqliteFile {
|
|
|
117
106
|
readonly bytes: number | null;
|
|
118
107
|
readonly declaredThisBoot: boolean;
|
|
119
108
|
}[]>;
|
|
120
|
-
abstract readLegacyCollection(input: {
|
|
121
|
-
readonly collection: string;
|
|
122
|
-
readonly cursor?: string | undefined;
|
|
123
|
-
readonly limit?: number | undefined;
|
|
124
|
-
}): Promise<{
|
|
125
|
-
readonly rows: readonly {
|
|
126
|
-
readonly id: string;
|
|
127
|
-
readonly data: Record<string, unknown>;
|
|
128
|
-
}[];
|
|
129
|
-
readonly nextCursor: string | null;
|
|
130
|
-
}>;
|
|
131
109
|
abstract dropRetiredTable(name: string): Promise<DroppedRetiredTable | null>;
|
|
132
110
|
abstract servingThreadId(): Promise<number>;
|
|
133
111
|
protected abstract stopConnection(): Promise<void>;
|
|
@@ -163,17 +141,6 @@ export declare class InlineOwnedFile extends OwnedFileBase {
|
|
|
163
141
|
readonly bytes: number | null;
|
|
164
142
|
readonly declaredThisBoot: boolean;
|
|
165
143
|
}[]>;
|
|
166
|
-
readLegacyCollection(input: {
|
|
167
|
-
readonly collection: string;
|
|
168
|
-
readonly cursor?: string | undefined;
|
|
169
|
-
readonly limit?: number | undefined;
|
|
170
|
-
}): Promise<{
|
|
171
|
-
readonly rows: readonly {
|
|
172
|
-
readonly id: string;
|
|
173
|
-
readonly data: Record<string, unknown>;
|
|
174
|
-
}[];
|
|
175
|
-
readonly nextCursor: string | null;
|
|
176
|
-
}>;
|
|
177
144
|
dropRetiredTable(name: string): Promise<DroppedRetiredTable | null>;
|
|
178
145
|
servingThreadId(): Promise<number>;
|
|
179
146
|
protected stopMaintenance(): void;
|
|
@@ -196,17 +163,6 @@ export declare class WorkerOwnedFile extends OwnedFileBase {
|
|
|
196
163
|
readonly bytes: number | null;
|
|
197
164
|
readonly declaredThisBoot: boolean;
|
|
198
165
|
}[]>;
|
|
199
|
-
readLegacyCollection(input: {
|
|
200
|
-
readonly collection: string;
|
|
201
|
-
readonly cursor?: string | undefined;
|
|
202
|
-
readonly limit?: number | undefined;
|
|
203
|
-
}): Promise<{
|
|
204
|
-
readonly rows: readonly {
|
|
205
|
-
readonly id: string;
|
|
206
|
-
readonly data: Record<string, unknown>;
|
|
207
|
-
}[];
|
|
208
|
-
readonly nextCursor: string | null;
|
|
209
|
-
}>;
|
|
210
166
|
dropRetiredTable(name: string): Promise<DroppedRetiredTable | null>;
|
|
211
167
|
servingThreadId(): Promise<number>;
|
|
212
168
|
protected stopMaintenance(): void;
|
|
@@ -9,8 +9,6 @@ export interface KindRow {
|
|
|
9
9
|
readonly hash: string;
|
|
10
10
|
readonly state: "declared" | "orphaned" | "dropped";
|
|
11
11
|
readonly declaration: RecordKindDeclaration;
|
|
12
|
-
/** When `adoptRecords` finished copying the legacy table into this kind; the boot guard reads it. */
|
|
13
|
-
readonly adoptedAt: number | null;
|
|
14
12
|
}
|
|
15
13
|
/** The hash a declaration is known by; two spellings of the same declaration agree. */
|
|
16
14
|
export declare function declarationHash(decl: RecordKindDeclaration): string;
|
|
@@ -22,27 +22,6 @@ export interface RecordsEngineOps extends OwnedOps {
|
|
|
22
22
|
}): Promise<{
|
|
23
23
|
readonly deleted: number;
|
|
24
24
|
}>;
|
|
25
|
-
/** Rows of a legacy table in THIS file; `null` when the table is not there. */
|
|
26
|
-
legacyRowCount(input: {
|
|
27
|
-
readonly table: string;
|
|
28
|
-
}): Promise<number | null>;
|
|
29
|
-
/** Has `adoptRecords` finished copying the legacy table into this kind? (the boot guard) */
|
|
30
|
-
adoptionState(input: {
|
|
31
|
-
readonly owner: string;
|
|
32
|
-
readonly kind: string;
|
|
33
|
-
}): Promise<{
|
|
34
|
-
readonly adoptedAt: number | null;
|
|
35
|
-
}>;
|
|
36
|
-
/** Record that the copy is complete. Idempotent. */
|
|
37
|
-
markAdopted(input: {
|
|
38
|
-
readonly owner: string;
|
|
39
|
-
readonly kind: string;
|
|
40
|
-
}): Promise<void>;
|
|
41
|
-
/** Undo a false `complete` when the legacy table still holds rows. */
|
|
42
|
-
revokeAdopted(input: {
|
|
43
|
-
readonly owner: string;
|
|
44
|
-
readonly kind: string;
|
|
45
|
-
}): Promise<void>;
|
|
46
25
|
}
|
|
47
26
|
export type RecordsOp = keyof RecordsEngineOps;
|
|
48
27
|
export type RecordsInput<K extends RecordsOp> = Parameters<RecordsEngineOps[K]>[0];
|
|
@@ -29,8 +29,8 @@ export declare class RecordsEngine implements RecordsEngineOps {
|
|
|
29
29
|
constructor(db: Database.Database, options: RecordsEngineOptions);
|
|
30
30
|
/**
|
|
31
31
|
* Boot correction: every kind that ever allocated an id has its counter raised
|
|
32
|
-
* above the highest numeric id it holds.
|
|
33
|
-
* chosen numeric id) kept ids far above a counter that started at 1, and the
|
|
32
|
+
* above the highest numeric id it holds. Rows the records migration copied
|
|
33
|
+
* (or any caller chosen numeric id) kept ids far above a counter that started at 1, and the
|
|
34
34
|
* upsert would have overwritten another device's row on the first collision.
|
|
35
35
|
* Runs on the engine's own connection, over the (kind_id, id) unique index.
|
|
36
36
|
*/
|
|
@@ -38,7 +38,7 @@ export declare class RecordsEngine implements RecordsEngineOps {
|
|
|
38
38
|
/** Ids handed out by allocateId and not yet written: their first write is insert-only. */
|
|
39
39
|
private readonly pendingAllocated;
|
|
40
40
|
private static readonly PENDING_ALLOCATED_MAX;
|
|
41
|
-
/** Raise a kind's counter above the numeric ids of a caller-supplied batch
|
|
41
|
+
/** Raise a kind's counter above the numeric ids of a caller-supplied batch. */
|
|
42
42
|
private raiseSequenceFor;
|
|
43
43
|
private schemaReady;
|
|
44
44
|
private kindOf;
|
|
@@ -87,21 +87,4 @@ export declare class RecordsEngine implements RecordsEngineOps {
|
|
|
87
87
|
private countRows;
|
|
88
88
|
/** The declarations this file holds, for the router's placement map and the entries service. */
|
|
89
89
|
declarations(): readonly KindRow[];
|
|
90
|
-
legacyRowCount(input: {
|
|
91
|
-
readonly table: string;
|
|
92
|
-
}): Promise<number | null>;
|
|
93
|
-
adoptionState(input: {
|
|
94
|
-
readonly owner: string;
|
|
95
|
-
readonly kind: string;
|
|
96
|
-
}): Promise<{
|
|
97
|
-
readonly adoptedAt: number | null;
|
|
98
|
-
}>;
|
|
99
|
-
markAdopted(input: {
|
|
100
|
-
readonly owner: string;
|
|
101
|
-
readonly kind: string;
|
|
102
|
-
}): Promise<void>;
|
|
103
|
-
revokeAdopted(input: {
|
|
104
|
-
readonly owner: string;
|
|
105
|
-
readonly kind: string;
|
|
106
|
-
}): Promise<void>;
|
|
107
90
|
}
|
|
@@ -9,17 +9,15 @@
|
|
|
9
9
|
* rebuilt from each open file's own `_record_kinds` at boot and updated on
|
|
10
10
|
* declaration. A kind declared for another file than the one it lives in is
|
|
11
11
|
* refused (the engine never moves data, D853).
|
|
12
|
-
* - **
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* - **No adoption** (D900): the records migration is closed. A declaration
|
|
13
|
+
* reads no legacy table, and a retired `adoptsFrom` an older addon still
|
|
14
|
+
* sends is dropped before the catalog stores the declaration.
|
|
15
15
|
*/
|
|
16
16
|
import { type IRecordsProvider, type IScopedLogger, type IStorageAdminProvider, type StorageKind } from "@camstack/types";
|
|
17
17
|
import type { PlacementRouter } from "../placement-router.js";
|
|
18
18
|
/** The caller the transport stamped, or a refusal. */
|
|
19
19
|
export declare function recordsCallerOf(input: unknown): string;
|
|
20
|
-
type AdminRecords = Pick<IStorageAdminProvider, "listKinds" | "readRecords"
|
|
21
|
-
isAdoptedLegacyTable(collection: string): Promise<boolean>;
|
|
22
|
-
};
|
|
20
|
+
type AdminRecords = Pick<IStorageAdminProvider, "listKinds" | "readRecords">;
|
|
23
21
|
export declare class RecordsProvider implements IRecordsProvider, AdminRecords {
|
|
24
22
|
private readonly router;
|
|
25
23
|
private readonly logger;
|
|
@@ -30,20 +28,11 @@ export declare class RecordsProvider implements IRecordsProvider, AdminRecords {
|
|
|
30
28
|
private fileOf;
|
|
31
29
|
declareKinds(input: Parameters<IRecordsProvider["declareKinds"]>[0]): ReturnType<IRecordsProvider["declareKinds"]>;
|
|
32
30
|
/**
|
|
33
|
-
* Rows of a legacy table in EVERY open records-capable file. A legacy table lives
|
|
34
|
-
* in one file, but which one is the layout's business: the phase-3 NC ledgers moved
|
|
35
|
-
* to `events.db` with the P5 split, and a guard that asked `camstack.db` alone
|
|
36
|
-
* answered "no legacy rows" for 522 outbox rows (2026-10-20 audit).
|
|
37
|
-
*/
|
|
38
|
-
private legacyRowsAnywhere;
|
|
39
|
-
/**
|
|
40
31
|
* `transactFamily` (plan risk 8): kinds that must agree through one `transact` sit
|
|
41
32
|
* in ONE file. A family split across files is refused whole, whether the split is
|
|
42
33
|
* inside this declaration or against a kind of the same owner declared before.
|
|
43
34
|
*/
|
|
44
35
|
private assertFamiliesInOneFile;
|
|
45
|
-
/** The boot guard: empty kind + a legacy table that still has rows = adoption pending. */
|
|
46
|
-
private withAdoption;
|
|
47
36
|
get(input: Parameters<IRecordsProvider["get"]>[0]): ReturnType<IRecordsProvider["get"]>;
|
|
48
37
|
getMany(input: Parameters<IRecordsProvider["getMany"]>[0]): ReturnType<IRecordsProvider["getMany"]>;
|
|
49
38
|
secretRefs(input: Parameters<IRecordsProvider["secretRefs"]>[0]): ReturnType<IRecordsProvider["secretRefs"]>;
|
|
@@ -67,9 +56,6 @@ export declare class RecordsProvider implements IRecordsProvider, AdminRecords {
|
|
|
67
56
|
kinds: StorageKind[];
|
|
68
57
|
}>;
|
|
69
58
|
readRecords(input: Parameters<IStorageAdminProvider["readRecords"]>[0]): ReturnType<IStorageAdminProvider["readRecords"]>;
|
|
70
|
-
/** True when a declared kind lists `collection` as `adoptsFrom` and adoption finished. */
|
|
71
|
-
isAdoptedLegacyTable(collection: string): Promise<boolean>;
|
|
72
|
-
adoptRecords(input: Parameters<IStorageAdminProvider["adoptRecords"]>[0]): ReturnType<IStorageAdminProvider["adoptRecords"]>;
|
|
73
59
|
/** Housekeeping: delete rows past `expires_at` in every file that hosts kinds. */
|
|
74
60
|
sweepExpired(): Promise<number>;
|
|
75
61
|
}
|
|
@@ -17,7 +17,7 @@ export declare const RECORD_KINDS_TABLE = "_record_kinds";
|
|
|
17
17
|
*/
|
|
18
18
|
export declare const RECORD_SEQUENCES_TABLE = "_record_sequences";
|
|
19
19
|
/** The statements that create the shared tables. Idempotent. */
|
|
20
|
-
export declare const RECORDS_SCHEMA_SQL = "\nCREATE TABLE IF NOT EXISTS records (\n rid INTEGER PRIMARY KEY,\n kind_id INTEGER NOT NULL,\n id TEXT NOT NULL,\n device_id INTEGER,\n at INTEGER,\n expires_at INTEGER,\n rev INTEGER NOT NULL DEFAULT 1,\n updated_at INTEGER NOT NULL,\n data BLOB NOT NULL,\n UNIQUE (kind_id, id)\n);\nCREATE INDEX IF NOT EXISTS records_kind_device_at ON records(kind_id, device_id, at);\nCREATE INDEX IF NOT EXISTS records_kind_at ON records(kind_id, at);\nCREATE INDEX IF NOT EXISTS records_expires ON records(expires_at) WHERE expires_at IS NOT NULL;\nCREATE TABLE IF NOT EXISTS _record_kinds (\n kind_id INTEGER PRIMARY KEY AUTOINCREMENT,\n owner TEXT NOT NULL,\n kind TEXT NOT NULL,\n database TEXT NOT NULL,\n manifest_hash TEXT NOT NULL,\n declaration TEXT NOT NULL,\n state TEXT NOT NULL,\n orphaned_at INTEGER,\n adopted_at INTEGER,\n UNIQUE (owner, kind)\n);\nCREATE TABLE IF NOT EXISTS _record_sequences (\n kind_id INTEGER PRIMARY KEY,\n next INTEGER NOT NULL\n);\n";
|
|
20
|
+
export declare const RECORDS_SCHEMA_SQL = "\nCREATE TABLE IF NOT EXISTS records (\n rid INTEGER PRIMARY KEY,\n kind_id INTEGER NOT NULL,\n id TEXT NOT NULL,\n device_id INTEGER,\n at INTEGER,\n expires_at INTEGER,\n rev INTEGER NOT NULL DEFAULT 1,\n updated_at INTEGER NOT NULL,\n data BLOB NOT NULL,\n UNIQUE (kind_id, id)\n);\nCREATE INDEX IF NOT EXISTS records_kind_device_at ON records(kind_id, device_id, at);\nCREATE INDEX IF NOT EXISTS records_kind_at ON records(kind_id, at);\nCREATE INDEX IF NOT EXISTS records_expires ON records(expires_at) WHERE expires_at IS NOT NULL;\nCREATE TABLE IF NOT EXISTS _record_kinds (\n kind_id INTEGER PRIMARY KEY AUTOINCREMENT,\n owner TEXT NOT NULL,\n kind TEXT NOT NULL,\n database TEXT NOT NULL,\n manifest_hash TEXT NOT NULL,\n declaration TEXT NOT NULL,\n state TEXT NOT NULL,\n orphaned_at INTEGER,\n -- RETIRED (D900): the records-migration boot guard's flag. Nothing reads it;\n -- the column stays so an older build can still open a file this one created.\n adopted_at INTEGER,\n UNIQUE (owner, kind)\n);\nCREATE TABLE IF NOT EXISTS _record_sequences (\n kind_id INTEGER PRIMARY KEY,\n next INTEGER NOT NULL\n);\n";
|
|
21
21
|
/** The tables the records engine owns: never droppable through `dropCollection`. */
|
|
22
22
|
export declare const RECORDS_ENGINE_TABLES: readonly string[];
|
|
23
23
|
/** The built-in indexes. */
|
|
@@ -437,23 +437,6 @@ export declare class SqliteSettingsBackend implements ISettingsBackend {
|
|
|
437
437
|
bytes: number | null;
|
|
438
438
|
declaredThisBoot: boolean;
|
|
439
439
|
}[];
|
|
440
|
-
/** Storage-admin only: adopted legacy may still be in `declaredThisBoot` from vestigial declares. */
|
|
441
|
-
forgetDeclaredThisBoot(name: string): void;
|
|
442
|
-
/**
|
|
443
|
-
* Paginated `(id, data)` read of a physical table. Does not consult
|
|
444
|
-
* `declareCollection` — for migration scripts only.
|
|
445
|
-
*/
|
|
446
|
-
readLegacyCollection(input: {
|
|
447
|
-
readonly collection: string;
|
|
448
|
-
readonly cursor?: string | undefined;
|
|
449
|
-
readonly limit?: number | undefined;
|
|
450
|
-
}): {
|
|
451
|
-
rows: {
|
|
452
|
-
id: string;
|
|
453
|
-
data: Record<string, unknown>;
|
|
454
|
-
}[];
|
|
455
|
-
nextCursor: string | null;
|
|
456
|
-
};
|
|
457
440
|
/**
|
|
458
441
|
* Drop one table nobody owns (D870 migration, one-shot). Refuses a canonical
|
|
459
442
|
* or engine table, one a running addon declared since boot, a table that is
|
|
@@ -3,9 +3,9 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-Bn-RNanh.js");
|
|
7
7
|
const require_retired_settings_keys = require("../../retired-settings-keys-D_VwZiDt.js");
|
|
8
|
-
const require_wal_maintenance = require("../../wal-maintenance-
|
|
8
|
+
const require_wal_maintenance = require("../../wal-maintenance-DUHEp_09.js");
|
|
9
9
|
const require_sqlite_snapshot_protocol = require("../../sqlite-snapshot-protocol-B9OndqZv.js");
|
|
10
10
|
const require_wal_checkpoint_policy = require("../../wal-checkpoint-policy-d2z2qPqx.js");
|
|
11
11
|
let node_fs_promises = require("node:fs/promises");
|
|
@@ -937,9 +937,6 @@ var InlineOwnedFile = class extends OwnedFileBase {
|
|
|
937
937
|
listPhysicalTables(ownerPrefix) {
|
|
938
938
|
return Promise.resolve(require_wal_maintenance.callControl(require_wal_maintenance.controlTargetOf(this.backend, 0), "listPhysicalTables", { ownerPrefix }));
|
|
939
939
|
}
|
|
940
|
-
readLegacyCollection(input) {
|
|
941
|
-
return Promise.resolve(require_wal_maintenance.callControl(require_wal_maintenance.controlTargetOf(this.backend, 0), "readLegacyCollection", input));
|
|
942
|
-
}
|
|
943
940
|
async dropRetiredTable(name) {
|
|
944
941
|
return require_wal_maintenance.callControl(require_wal_maintenance.controlTargetOf(this.backend, 0), "dropRetiredTable", { name });
|
|
945
942
|
}
|
|
@@ -997,9 +994,6 @@ var WorkerOwnedFile = class extends OwnedFileBase {
|
|
|
997
994
|
listPhysicalTables(ownerPrefix) {
|
|
998
995
|
return this.client.control("listPhysicalTables", { ownerPrefix });
|
|
999
996
|
}
|
|
1000
|
-
readLegacyCollection(input) {
|
|
1001
|
-
return this.client.control("readLegacyCollection", input);
|
|
1002
|
-
}
|
|
1003
997
|
dropRetiredTable(name) {
|
|
1004
998
|
return this.client.control("dropRetiredTable", { name });
|
|
1005
999
|
}
|
|
@@ -1244,54 +1238,6 @@ var PlacementRouter = class {
|
|
|
1244
1238
|
}
|
|
1245
1239
|
};
|
|
1246
1240
|
//#endregion
|
|
1247
|
-
//#region src/builtins/sqlite-storage/records/count-settings-array-legacy.ts
|
|
1248
|
-
function isRecord$1(value) {
|
|
1249
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1250
|
-
}
|
|
1251
|
-
function unwrapValue$1(raw) {
|
|
1252
|
-
if (isRecord$1(raw) && "value" in raw) return raw["value"];
|
|
1253
|
-
return raw;
|
|
1254
|
-
}
|
|
1255
|
-
function legacyRowId(item) {
|
|
1256
|
-
const id = item["id"];
|
|
1257
|
-
if (typeof id === "string" && id.length > 0) return id;
|
|
1258
|
-
const username = item["username"];
|
|
1259
|
-
if (typeof username === "string" && username.length > 0) return username;
|
|
1260
|
-
return null;
|
|
1261
|
-
}
|
|
1262
|
-
async function countSettingsArrayLegacy(router, addonId, settingsKey) {
|
|
1263
|
-
const list = unwrapValue$1(await router.get({
|
|
1264
|
-
collection: "addon-settings",
|
|
1265
|
-
key: `${addonId}.${settingsKey}`
|
|
1266
|
-
}));
|
|
1267
|
-
if (!Array.isArray(list)) return 0;
|
|
1268
|
-
let n = 0;
|
|
1269
|
-
for (const item of list) {
|
|
1270
|
-
if (!isRecord$1(item)) continue;
|
|
1271
|
-
if (legacyRowId(item) !== null) n += 1;
|
|
1272
|
-
}
|
|
1273
|
-
return n;
|
|
1274
|
-
}
|
|
1275
|
-
//#endregion
|
|
1276
|
-
//#region src/builtins/sqlite-storage/records/count-settings-brokers-legacy.ts
|
|
1277
|
-
function isRecord(value) {
|
|
1278
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1279
|
-
}
|
|
1280
|
-
function unwrapValue(raw) {
|
|
1281
|
-
if (isRecord(raw) && "value" in raw) return raw["value"];
|
|
1282
|
-
return raw;
|
|
1283
|
-
}
|
|
1284
|
-
async function countSettingsBrokersLegacy(router, addonId) {
|
|
1285
|
-
const list = unwrapValue(await router.get({
|
|
1286
|
-
collection: "addon-settings",
|
|
1287
|
-
key: `${addonId}.brokers`
|
|
1288
|
-
}));
|
|
1289
|
-
if (!Array.isArray(list)) return 0;
|
|
1290
|
-
let n = 0;
|
|
1291
|
-
for (const item of list) if (isRecord(item) && typeof item["id"] === "string") n += 1;
|
|
1292
|
-
return n;
|
|
1293
|
-
}
|
|
1294
|
-
//#endregion
|
|
1295
1241
|
//#region src/builtins/sqlite-storage/records/records-provider.ts
|
|
1296
1242
|
/**
|
|
1297
1243
|
* The `records` capability of the engine (D881): resolves WHO is calling and
|
|
@@ -1304,9 +1250,9 @@ async function countSettingsBrokersLegacy(router, addonId) {
|
|
|
1304
1250
|
* rebuilt from each open file's own `_record_kinds` at boot and updated on
|
|
1305
1251
|
* declaration. A kind declared for another file than the one it lives in is
|
|
1306
1252
|
* refused (the engine never moves data, D853).
|
|
1307
|
-
* - **
|
|
1308
|
-
*
|
|
1309
|
-
*
|
|
1253
|
+
* - **No adoption** (D900): the records migration is closed. A declaration
|
|
1254
|
+
* reads no legacy table, and a retired `adoptsFrom` an older addon still
|
|
1255
|
+
* sends is dropped before the catalog stores the declaration.
|
|
1310
1256
|
*/
|
|
1311
1257
|
/** The caller the transport stamped, or a refusal. */
|
|
1312
1258
|
function recordsCallerOf(input) {
|
|
@@ -1317,6 +1263,16 @@ function recordsCallerOf(input) {
|
|
|
1317
1263
|
function keyOf(owner, kind) {
|
|
1318
1264
|
return `${owner}\u0000${kind}`;
|
|
1319
1265
|
}
|
|
1266
|
+
/**
|
|
1267
|
+
* A declaration as the catalog stores it: the retired `adoptsFrom` (D900) left
|
|
1268
|
+
* out, so the row an older addon's redeclaration writes no longer carries it.
|
|
1269
|
+
*/
|
|
1270
|
+
function withoutRetiredKeys(declaration) {
|
|
1271
|
+
return {
|
|
1272
|
+
...declaration,
|
|
1273
|
+
adoptsFrom: void 0
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1320
1276
|
var RecordsProvider = class {
|
|
1321
1277
|
router;
|
|
1322
1278
|
logger;
|
|
@@ -1350,7 +1306,7 @@ var RecordsProvider = class {
|
|
|
1350
1306
|
const owner = recordsCallerOf(input);
|
|
1351
1307
|
const byDatabase = /* @__PURE__ */ new Map();
|
|
1352
1308
|
const parsed = /* @__PURE__ */ new Map();
|
|
1353
|
-
for (const [kind, raw] of Object.entries(input.kinds)) parsed.set(kind, require_dist.RecordKindDeclarationSchema.parse(raw));
|
|
1309
|
+
for (const [kind, raw] of Object.entries(input.kinds)) parsed.set(kind, withoutRetiredKeys(require_dist.RecordKindDeclarationSchema.parse(raw)));
|
|
1354
1310
|
await this.assertFamiliesInOneFile(owner, parsed);
|
|
1355
1311
|
for (const [kind, declaration] of parsed) {
|
|
1356
1312
|
const known = this.placement.get(keyOf(owner, kind));
|
|
@@ -1372,22 +1328,7 @@ var RecordsProvider = class {
|
|
|
1372
1328
|
merged[kind] = result;
|
|
1373
1329
|
}
|
|
1374
1330
|
}
|
|
1375
|
-
return { kinds:
|
|
1376
|
-
}
|
|
1377
|
-
/**
|
|
1378
|
-
* Rows of a legacy table in EVERY open records-capable file. A legacy table lives
|
|
1379
|
-
* in one file, but which one is the layout's business: the phase-3 NC ledgers moved
|
|
1380
|
-
* to `events.db` with the P5 split, and a guard that asked `camstack.db` alone
|
|
1381
|
-
* answered "no legacy rows" for 522 outbox rows (2026-10-20 audit).
|
|
1382
|
-
*/
|
|
1383
|
-
async legacyRowsAnywhere(table) {
|
|
1384
|
-
let total = 0;
|
|
1385
|
-
for (const file of this.router.openFiles()) {
|
|
1386
|
-
if (file.databaseId === "history") continue;
|
|
1387
|
-
const rows = await file.records("legacyRowCount", { table });
|
|
1388
|
-
if (rows !== null) total += rows;
|
|
1389
|
-
}
|
|
1390
|
-
return total;
|
|
1331
|
+
return { kinds: merged };
|
|
1391
1332
|
}
|
|
1392
1333
|
/**
|
|
1393
1334
|
* `transactFamily` (plan risk 8): kinds that must agree through one `transact` sit
|
|
@@ -1418,52 +1359,6 @@ var RecordsProvider = class {
|
|
|
1418
1359
|
throw new require_dist.DeclarationRefusedError(`transactFamily "${family}" of "${owner}" is split across files (${[...members.entries()].map(([k, db]) => `${k}@${db}`).join(", ")}); a family lives in ONE file`);
|
|
1419
1360
|
}
|
|
1420
1361
|
}
|
|
1421
|
-
/** The boot guard: empty kind + a legacy table that still has rows = adoption pending. */
|
|
1422
|
-
async withAdoption(owner, declared, results) {
|
|
1423
|
-
const out = { ...results };
|
|
1424
|
-
for (const [kind, raw] of Object.entries(declared)) {
|
|
1425
|
-
const legacy = raw.adoptsFrom;
|
|
1426
|
-
const result = results[kind];
|
|
1427
|
-
if (legacy === void 0 || result === void 0) continue;
|
|
1428
|
-
if ((await (await this.fileOf(owner, kind)).records("adoptionState", {
|
|
1429
|
-
owner,
|
|
1430
|
-
kind
|
|
1431
|
-
})).adoptedAt !== null) continue;
|
|
1432
|
-
const settingsBrokersAddon = require_dist.parseSettingsBrokersAdoptsFrom(legacy);
|
|
1433
|
-
if (settingsBrokersAddon !== null) {
|
|
1434
|
-
const legacyRows = await countSettingsBrokersLegacy(this.router, settingsBrokersAddon);
|
|
1435
|
-
if (legacyRows > 0) out[kind] = {
|
|
1436
|
-
...result,
|
|
1437
|
-
adoptionPending: {
|
|
1438
|
-
legacyTable: legacy,
|
|
1439
|
-
legacyRows
|
|
1440
|
-
}
|
|
1441
|
-
};
|
|
1442
|
-
continue;
|
|
1443
|
-
}
|
|
1444
|
-
const settingsArray = require_dist.parseSettingsArrayAdoptsFrom(legacy);
|
|
1445
|
-
if (settingsArray !== null) {
|
|
1446
|
-
const legacyRows = await countSettingsArrayLegacy(this.router, settingsArray.addonId, settingsArray.settingsKey);
|
|
1447
|
-
if (legacyRows > 0) out[kind] = {
|
|
1448
|
-
...result,
|
|
1449
|
-
adoptionPending: {
|
|
1450
|
-
legacyTable: legacy,
|
|
1451
|
-
legacyRows
|
|
1452
|
-
}
|
|
1453
|
-
};
|
|
1454
|
-
continue;
|
|
1455
|
-
}
|
|
1456
|
-
const legacyRows = await this.legacyRowsAnywhere(legacy);
|
|
1457
|
-
if (legacyRows > 0) out[kind] = {
|
|
1458
|
-
...result,
|
|
1459
|
-
adoptionPending: {
|
|
1460
|
-
legacyTable: legacy,
|
|
1461
|
-
legacyRows
|
|
1462
|
-
}
|
|
1463
|
-
};
|
|
1464
|
-
}
|
|
1465
|
-
return out;
|
|
1466
|
-
}
|
|
1467
1362
|
async get(input) {
|
|
1468
1363
|
const owner = recordsCallerOf(input);
|
|
1469
1364
|
return (await this.fileOf(owner, input.kind)).records("get", {
|
|
@@ -1597,50 +1492,6 @@ var RecordsProvider = class {
|
|
|
1597
1492
|
} });
|
|
1598
1493
|
return (await this.fileOf(input.owner, input.kind)).records("query", input);
|
|
1599
1494
|
}
|
|
1600
|
-
/** True when a declared kind lists `collection` as `adoptsFrom` and adoption finished. */
|
|
1601
|
-
async isAdoptedLegacyTable(collection) {
|
|
1602
|
-
const { kinds } = await this.listKinds({ counts: false });
|
|
1603
|
-
for (const k of kinds) {
|
|
1604
|
-
if (k.state === "dropped") continue;
|
|
1605
|
-
if (k.declaration.adoptsFrom !== collection) continue;
|
|
1606
|
-
const { adoptedAt } = await (await this.fileOf(k.owner, k.kind)).records("adoptionState", {
|
|
1607
|
-
owner: k.owner,
|
|
1608
|
-
kind: k.kind
|
|
1609
|
-
});
|
|
1610
|
-
if (adoptedAt !== null) return true;
|
|
1611
|
-
}
|
|
1612
|
-
return false;
|
|
1613
|
-
}
|
|
1614
|
-
async adoptRecords(input) {
|
|
1615
|
-
const file = await this.fileOf(input.owner, input.kind);
|
|
1616
|
-
if (input.records.length > 0) {
|
|
1617
|
-
const { adoptedAt } = await file.records("adoptionState", {
|
|
1618
|
-
owner: input.owner,
|
|
1619
|
-
kind: input.kind
|
|
1620
|
-
});
|
|
1621
|
-
if (adoptedAt !== null) {
|
|
1622
|
-
if ((await file.records("count", {
|
|
1623
|
-
owner: input.owner,
|
|
1624
|
-
kind: input.kind
|
|
1625
|
-
})).count === 0) await file.records("revokeAdopted", {
|
|
1626
|
-
owner: input.owner,
|
|
1627
|
-
kind: input.kind
|
|
1628
|
-
});
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
const result = await file.records("putMany", input);
|
|
1632
|
-
if (input.complete === true) await file.records("markAdopted", {
|
|
1633
|
-
owner: input.owner,
|
|
1634
|
-
kind: input.kind
|
|
1635
|
-
});
|
|
1636
|
-
this.logger.warn("records: ADOPTED rows as their declared owner", { meta: {
|
|
1637
|
-
owner: input.owner,
|
|
1638
|
-
kind: input.kind,
|
|
1639
|
-
count: result.count,
|
|
1640
|
-
complete: input.complete === true
|
|
1641
|
-
} });
|
|
1642
|
-
return { adopted: result.count };
|
|
1643
|
-
}
|
|
1644
1495
|
/** Housekeeping: delete rows past `expires_at` in every file that hosts kinds. */
|
|
1645
1496
|
async sweepExpired() {
|
|
1646
1497
|
let deleted = 0;
|
|
@@ -1655,8 +1506,9 @@ var RecordsProvider = class {
|
|
|
1655
1506
|
//#region src/builtins/sqlite-storage/storage-admin-provider.ts
|
|
1656
1507
|
/**
|
|
1657
1508
|
* The `storage-admin` provider of the SQLite engine (D870): the operator's
|
|
1658
|
-
* maintenance reach into the settings database - list its tables
|
|
1659
|
-
*
|
|
1509
|
+
* maintenance reach into the settings database - list its tables and record
|
|
1510
|
+
* kinds, read a kind for diagnosis, drop a table that nothing owns any more.
|
|
1511
|
+
* Every call is logged with its table and counts.
|
|
1660
1512
|
*
|
|
1661
1513
|
* `dropCollection` is a one-shot of the D870 migration: remove it, and the
|
|
1662
1514
|
* capability's method, once the last hub ran `migrate-device-store.ts --drop`.
|
|
@@ -1680,32 +1532,6 @@ var StorageAdminProvider = class {
|
|
|
1680
1532
|
readRecords(input) {
|
|
1681
1533
|
return this.records.readRecords(input);
|
|
1682
1534
|
}
|
|
1683
|
-
adoptRecords(input) {
|
|
1684
|
-
return this.records.adoptRecords(input);
|
|
1685
|
-
}
|
|
1686
|
-
isAdoptedLegacyTable(input) {
|
|
1687
|
-
return this.records.isAdoptedLegacyTable(input.collection).then((adopted) => ({ adopted }));
|
|
1688
|
-
}
|
|
1689
|
-
async readLegacyCollection(input) {
|
|
1690
|
-
if (this.backend.hasTable(input.collection)) {
|
|
1691
|
-
const page = this.backend.readLegacyCollection(input);
|
|
1692
|
-
return {
|
|
1693
|
-
rows: [...page.rows],
|
|
1694
|
-
nextCursor: page.nextCursor
|
|
1695
|
-
};
|
|
1696
|
-
}
|
|
1697
|
-
for (const file of await this.peerFiles()) if (await file.hasTable(input.collection)) {
|
|
1698
|
-
const page = await file.readLegacyCollection(input);
|
|
1699
|
-
return {
|
|
1700
|
-
rows: [...page.rows],
|
|
1701
|
-
nextCursor: page.nextCursor
|
|
1702
|
-
};
|
|
1703
|
-
}
|
|
1704
|
-
return {
|
|
1705
|
-
rows: [],
|
|
1706
|
-
nextCursor: null
|
|
1707
|
-
};
|
|
1708
|
-
}
|
|
1709
1535
|
/** May this table be dropped AT ALL? Throws with the reason when not. */
|
|
1710
1536
|
async assertDroppable(collection) {
|
|
1711
1537
|
const colon = collection.indexOf(":");
|
|
@@ -1717,7 +1543,7 @@ var StorageAdminProvider = class {
|
|
|
1717
1543
|
throw new Error(`drop refused: the installed addons could not be read (${err instanceof Error ? err.message : String(err)})`);
|
|
1718
1544
|
});
|
|
1719
1545
|
const owner = collection.slice(0, colon);
|
|
1720
|
-
if (installed.has(owner)
|
|
1546
|
+
if (installed.has(owner)) throw new Error(`drop refused: "${collection}" belongs to the installed addon "${owner}"`);
|
|
1721
1547
|
}
|
|
1722
1548
|
async listTables(input) {
|
|
1723
1549
|
const tables = [...this.backend.listTables(input.ownerPrefix)];
|
|
@@ -1732,7 +1558,6 @@ var StorageAdminProvider = class {
|
|
|
1732
1558
|
async dropCollection(input) {
|
|
1733
1559
|
try {
|
|
1734
1560
|
await this.assertDroppable(input.collection);
|
|
1735
|
-
if (await this.records.isAdoptedLegacyTable(input.collection)) this.backend.forgetDeclaredThisBoot(input.collection);
|
|
1736
1561
|
const rows = this.backend.dropTable(input.collection, input.expectRows);
|
|
1737
1562
|
this.logger.warn("storage-admin: DROPPED a table", { meta: {
|
|
1738
1563
|
collection: input.collection,
|