@camstack/system 1.2.444 → 1.2.446
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/addon-runner.js +40 -31
- package/dist/addon-runner.mjs +41 -32
- package/dist/{agent-https-DlpTMDqA.js → agent-https-5DYAOJMO.js} +810 -12
- package/dist/{agent-https-U0d4uvn2.mjs → agent-https-BWUEf6ev.mjs} +697 -13
- package/dist/auth/admin-token-manager.d.ts +9 -3
- package/dist/auth/api-key-manager.d.ts +9 -3
- package/dist/auth/auth-audit-log.d.ts +9 -3
- package/dist/auth/device-credential-manager.d.ts +5 -1
- package/dist/auth/external-identity-manager.d.ts +8 -21
- package/dist/auth/login-session-manager.d.ts +11 -3
- package/dist/auth/scoped-token-manager.d.ts +8 -52
- package/dist/auth/totp-manager.d.ts +11 -3
- package/dist/auth/user-manager.d.ts +10 -17
- 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/alert-store.d.ts +32 -0
- package/dist/builtins/alerts/alerts.addon.d.ts +9 -2
- package/dist/builtins/alerts/alerts.addon.js +373 -154
- package/dist/builtins/alerts/alerts.addon.mjs +372 -154
- package/dist/builtins/alerts/critical-push.d.ts +4 -0
- package/dist/builtins/alerts/emit-alert-policy.d.ts +28 -0
- package/dist/builtins/alerts/record-kinds.d.ts +15 -0
- package/dist/builtins/autotrack/index.js +1 -1
- package/dist/builtins/autotrack/index.mjs +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.d.ts +1 -0
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +134 -193
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +134 -193
- package/dist/builtins/backup-orchestrator/destination-policy.d.ts +4 -2
- package/dist/builtins/backup-orchestrator/encryption-key-store.d.ts +4 -2
- package/dist/builtins/backup-orchestrator/record-kinds.d.ts +58 -0
- package/dist/builtins/backup-orchestrator/schedule-store.d.ts +4 -2
- package/dist/builtins/backup-orchestrator/seed-marker-store.d.ts +4 -2
- package/dist/builtins/calendars/calendar-prefs-store.d.ts +13 -5
- package/dist/builtins/calendars/calendars.addon.d.ts +2 -2
- package/dist/builtins/calendars/calendars.addon.js +67 -64
- package/dist/builtins/calendars/calendars.addon.mjs +59 -64
- package/dist/builtins/calendars/record-kinds.d.ts +18 -0
- package/dist/builtins/camera-grid/index.js +1 -1
- package/dist/builtins/camera-grid/index.mjs +1 -1
- package/dist/builtins/cluster-agent/record-kinds.d.ts +36 -0
- 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/block-settings-store.d.ts +8 -4
- package/dist/builtins/core-blocks/core-block-store.d.ts +8 -16
- package/dist/builtins/core-blocks/core-blocks.addon.js +85 -112
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +86 -113
- package/dist/builtins/core-blocks/index.mjs +1 -1
- package/dist/builtins/core-blocks/record-kinds.d.ts +26 -0
- package/dist/builtins/device-manager/device-manager.addon.js +111 -187
- package/dist/builtins/device-manager/device-manager.addon.mjs +110 -187
- package/dist/builtins/device-manager/device-tombstone-store.d.ts +9 -48
- package/dist/builtins/device-manager/record-kinds.d.ts +14 -0
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/keychain/index.js +152 -22
- package/dist/builtins/keychain/index.mjs +152 -22
- package/dist/builtins/keychain/keychain-service.d.ts +3 -2
- package/dist/builtins/keychain/keychain-store.d.ts +13 -2
- package/dist/builtins/keychain/record-kinds.d.ts +16 -0
- 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/auth-schema.d.ts +3 -1
- package/dist/builtins/local-auth/local-auth.addon.js +2903 -2123
- package/dist/builtins/local-auth/local-auth.addon.mjs +2904 -2124
- package/dist/builtins/local-auth/oauth-session-manager.d.ts +8 -48
- package/dist/builtins/local-auth/record-kinds.d.ts +141 -0
- 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/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/records/legacy-table-row-count.d.ts +5 -0
- package/dist/builtins/records/phase6-declare-gate.d.ts +28 -0
- package/dist/builtins/records-isolated.d.ts +10 -0
- 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/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/integration-record-kinds.d.ts +30 -0
- package/dist/builtins/sqlite-storage/integration-registry.d.ts +10 -16
- package/dist/builtins/sqlite-storage/records/count-settings-array-legacy.d.ts +5 -0
- package/dist/builtins/sqlite-storage/records/count-settings-brokers-legacy.d.ts +6 -0
- package/dist/builtins/sqlite-storage/records/records-engine-types.d.ts +5 -0
- package/dist/builtins/sqlite-storage/records/records-engine.d.ts +4 -0
- package/dist/builtins/sqlite-storage/records/records-provider.d.ts +5 -1
- package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +17 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +111 -3
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +111 -3
- package/dist/builtins/sqlite-storage/storage-admin-provider.d.ts +9 -1
- package/dist/builtins/storage-orchestrator/drain-state-store.d.ts +5 -2
- package/dist/builtins/storage-orchestrator/location-store.d.ts +7 -2
- package/dist/builtins/storage-orchestrator/record-kinds.d.ts +38 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +2 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +196 -5
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +195 -6
- package/dist/builtins/system-config/record-kinds.d.ts +32 -0
- package/dist/builtins/system-config/system-config.addon.js +53 -618
- package/dist/builtins/system-config/system-config.addon.mjs +29 -577
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{composition-sources-C3rKncIF.mjs → composition-sources-BmC5jAUv.mjs} +1 -1
- package/dist/{composition-sources-NAPZddic.js → composition-sources-BwIIltnZ.js} +1 -1
- package/dist/{constants-BKX2QnIg.mjs → constants-6XHGmEUF.mjs} +1 -1
- package/dist/{constants-BXiNEIeV.js → constants-DA_tjzIk.js} +1 -1
- package/dist/{device-ca-jxjSL8Ov.mjs → device-ca-Bh_ClxMO.mjs} +1 -1
- package/dist/{device-ca-DT9X2S6d.js → device-ca-CnbrgfmW.js} +1 -1
- package/dist/{dist-D1vECb_6.js → dist-BkNfEJKa.js} +521 -64
- package/dist/{dist-DERK-gP5.mjs → dist-CkZIrsAP.mjs} +462 -65
- package/dist/file-host-worker.js +1 -1
- package/dist/file-host-worker.mjs +1 -1
- package/dist/{hub-mdns-ciao-CRaC97V0.mjs → hub-mdns-ciao-CoyIUWHC.mjs} +2 -2
- package/dist/{hub-mdns-ciao-Cah9GCIg.js → hub-mdns-ciao-m5LIr4oA.js} +2 -2
- package/dist/index.d.ts +7 -0
- package/dist/index.js +3095 -2821
- package/dist/index.mjs +3067 -2810
- package/dist/kernel/index.d.ts +2 -0
- package/dist/kernel/moleculer/event-bus.d.ts +3 -1
- package/dist/kernel/moleculer/mesh-mtls/mesh-certificate-registry.d.ts +5 -1
- package/dist/kernel/moleculer/remote-logger.d.ts +2 -2
- package/dist/kernel/transport/cap-route-resolver.d.ts +9 -38
- package/dist/phase6-declare-gate-BDWZuB2n.mjs +93 -0
- package/dist/phase6-declare-gate-Bl7KocEs.js +98 -0
- package/dist/read-all-rows-CVoO1ONM.js +29 -0
- package/dist/read-all-rows-TaPqdWNF.mjs +25 -0
- package/dist/records/read-all-rows.d.ts +6 -0
- package/dist/{restore-archive-Dy-qKTdF.js → restore-archive-B57xI5Ue.js} +353 -5
- package/dist/{restore-archive-daKyE24F.mjs → restore-archive-CMr4V7Fi.mjs} +339 -9
- package/dist/tls/agent-https-names.d.ts +9 -13
- package/dist/{wal-maintenance-zRc24mOC.mjs → wal-maintenance-Bqm4zrNA.mjs} +0 -0
- package/dist/{wal-maintenance-dAv4IdzC.js → wal-maintenance-CuG1DUca.js} +0 -0
- package/package.json +1 -1
|
@@ -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-BkNfEJKa.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-CuG1DUca.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");
|
|
@@ -1232,6 +1232,54 @@ var PlacementRouter = class {
|
|
|
1232
1232
|
}
|
|
1233
1233
|
};
|
|
1234
1234
|
//#endregion
|
|
1235
|
+
//#region src/builtins/sqlite-storage/records/count-settings-array-legacy.ts
|
|
1236
|
+
function isRecord$1(value) {
|
|
1237
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1238
|
+
}
|
|
1239
|
+
function unwrapValue$1(raw) {
|
|
1240
|
+
if (isRecord$1(raw) && "value" in raw) return raw["value"];
|
|
1241
|
+
return raw;
|
|
1242
|
+
}
|
|
1243
|
+
function legacyRowId(item) {
|
|
1244
|
+
const id = item["id"];
|
|
1245
|
+
if (typeof id === "string" && id.length > 0) return id;
|
|
1246
|
+
const username = item["username"];
|
|
1247
|
+
if (typeof username === "string" && username.length > 0) return username;
|
|
1248
|
+
return null;
|
|
1249
|
+
}
|
|
1250
|
+
async function countSettingsArrayLegacy(router, addonId, settingsKey) {
|
|
1251
|
+
const list = unwrapValue$1(await router.get({
|
|
1252
|
+
collection: "addon-settings",
|
|
1253
|
+
key: `${addonId}.${settingsKey}`
|
|
1254
|
+
}));
|
|
1255
|
+
if (!Array.isArray(list)) return 0;
|
|
1256
|
+
let n = 0;
|
|
1257
|
+
for (const item of list) {
|
|
1258
|
+
if (!isRecord$1(item)) continue;
|
|
1259
|
+
if (legacyRowId(item) !== null) n += 1;
|
|
1260
|
+
}
|
|
1261
|
+
return n;
|
|
1262
|
+
}
|
|
1263
|
+
//#endregion
|
|
1264
|
+
//#region src/builtins/sqlite-storage/records/count-settings-brokers-legacy.ts
|
|
1265
|
+
function isRecord(value) {
|
|
1266
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1267
|
+
}
|
|
1268
|
+
function unwrapValue(raw) {
|
|
1269
|
+
if (isRecord(raw) && "value" in raw) return raw["value"];
|
|
1270
|
+
return raw;
|
|
1271
|
+
}
|
|
1272
|
+
async function countSettingsBrokersLegacy(router, addonId) {
|
|
1273
|
+
const list = unwrapValue(await router.get({
|
|
1274
|
+
collection: "addon-settings",
|
|
1275
|
+
key: `${addonId}.brokers`
|
|
1276
|
+
}));
|
|
1277
|
+
if (!Array.isArray(list)) return 0;
|
|
1278
|
+
let n = 0;
|
|
1279
|
+
for (const item of list) if (isRecord(item) && typeof item["id"] === "string") n += 1;
|
|
1280
|
+
return n;
|
|
1281
|
+
}
|
|
1282
|
+
//#endregion
|
|
1235
1283
|
//#region src/builtins/sqlite-storage/records/records-provider.ts
|
|
1236
1284
|
/**
|
|
1237
1285
|
* The `records` capability of the engine (D881): resolves WHO is calling and
|
|
@@ -1323,6 +1371,30 @@ var RecordsProvider = class {
|
|
|
1323
1371
|
owner,
|
|
1324
1372
|
kind
|
|
1325
1373
|
})).adoptedAt !== null) continue;
|
|
1374
|
+
const settingsBrokersAddon = require_dist.parseSettingsBrokersAdoptsFrom(legacy);
|
|
1375
|
+
if (settingsBrokersAddon !== null) {
|
|
1376
|
+
const legacyRows = await countSettingsBrokersLegacy(this.router, settingsBrokersAddon);
|
|
1377
|
+
if (legacyRows > 0) out[kind] = {
|
|
1378
|
+
...result,
|
|
1379
|
+
adoptionPending: {
|
|
1380
|
+
legacyTable: legacy,
|
|
1381
|
+
legacyRows
|
|
1382
|
+
}
|
|
1383
|
+
};
|
|
1384
|
+
continue;
|
|
1385
|
+
}
|
|
1386
|
+
const settingsArray = require_dist.parseSettingsArrayAdoptsFrom(legacy);
|
|
1387
|
+
if (settingsArray !== null) {
|
|
1388
|
+
const legacyRows = await countSettingsArrayLegacy(this.router, settingsArray.addonId, settingsArray.settingsKey);
|
|
1389
|
+
if (legacyRows > 0) out[kind] = {
|
|
1390
|
+
...result,
|
|
1391
|
+
adoptionPending: {
|
|
1392
|
+
legacyTable: legacy,
|
|
1393
|
+
legacyRows
|
|
1394
|
+
}
|
|
1395
|
+
};
|
|
1396
|
+
continue;
|
|
1397
|
+
}
|
|
1326
1398
|
const legacyRows = await (await this.router.recordsFileFor("settings")).records("legacyRowCount", { table: legacy });
|
|
1327
1399
|
if (legacyRows !== null && legacyRows > 0) out[kind] = {
|
|
1328
1400
|
...result,
|
|
@@ -1467,8 +1539,37 @@ var RecordsProvider = class {
|
|
|
1467
1539
|
} });
|
|
1468
1540
|
return (await this.fileOf(input.owner, input.kind)).records("query", input);
|
|
1469
1541
|
}
|
|
1542
|
+
/** True when a declared kind lists `collection` as `adoptsFrom` and adoption finished. */
|
|
1543
|
+
async isAdoptedLegacyTable(collection) {
|
|
1544
|
+
const { kinds } = await this.listKinds({ counts: false });
|
|
1545
|
+
for (const k of kinds) {
|
|
1546
|
+
if (k.state === "dropped") continue;
|
|
1547
|
+
if (k.declaration.adoptsFrom !== collection) continue;
|
|
1548
|
+
const { adoptedAt } = await (await this.fileOf(k.owner, k.kind)).records("adoptionState", {
|
|
1549
|
+
owner: k.owner,
|
|
1550
|
+
kind: k.kind
|
|
1551
|
+
});
|
|
1552
|
+
if (adoptedAt !== null) return true;
|
|
1553
|
+
}
|
|
1554
|
+
return false;
|
|
1555
|
+
}
|
|
1470
1556
|
async adoptRecords(input) {
|
|
1471
1557
|
const file = await this.fileOf(input.owner, input.kind);
|
|
1558
|
+
if (input.records.length > 0) {
|
|
1559
|
+
const { adoptedAt } = await file.records("adoptionState", {
|
|
1560
|
+
owner: input.owner,
|
|
1561
|
+
kind: input.kind
|
|
1562
|
+
});
|
|
1563
|
+
if (adoptedAt !== null) {
|
|
1564
|
+
if ((await file.records("count", {
|
|
1565
|
+
owner: input.owner,
|
|
1566
|
+
kind: input.kind
|
|
1567
|
+
})).count === 0) await file.records("revokeAdopted", {
|
|
1568
|
+
owner: input.owner,
|
|
1569
|
+
kind: input.kind
|
|
1570
|
+
});
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1472
1573
|
const result = await file.records("putMany", input);
|
|
1473
1574
|
if (input.complete === true) await file.records("markAdopted", {
|
|
1474
1575
|
owner: input.owner,
|
|
@@ -1522,6 +1623,12 @@ var StorageAdminProvider = class {
|
|
|
1522
1623
|
adoptRecords(input) {
|
|
1523
1624
|
return this.records.adoptRecords(input);
|
|
1524
1625
|
}
|
|
1626
|
+
isAdoptedLegacyTable(input) {
|
|
1627
|
+
return this.records.isAdoptedLegacyTable(input.collection).then((adopted) => ({ adopted }));
|
|
1628
|
+
}
|
|
1629
|
+
readLegacyCollection(input) {
|
|
1630
|
+
return Promise.resolve(this.backend.readLegacyCollection(input));
|
|
1631
|
+
}
|
|
1525
1632
|
/** May this table be dropped AT ALL? Throws with the reason when not. */
|
|
1526
1633
|
async assertDroppable(collection) {
|
|
1527
1634
|
const colon = collection.indexOf(":");
|
|
@@ -1533,7 +1640,7 @@ var StorageAdminProvider = class {
|
|
|
1533
1640
|
throw new Error(`drop refused: the installed addons could not be read (${err instanceof Error ? err.message : String(err)})`);
|
|
1534
1641
|
});
|
|
1535
1642
|
const owner = collection.slice(0, colon);
|
|
1536
|
-
if (installed.has(owner)) throw new Error(`drop refused: "${collection}" belongs to the installed addon "${owner}"`);
|
|
1643
|
+
if (installed.has(owner) && !await this.records.isAdoptedLegacyTable(collection)) throw new Error(`drop refused: "${collection}" belongs to the installed addon "${owner}"`);
|
|
1537
1644
|
}
|
|
1538
1645
|
async listTables(input) {
|
|
1539
1646
|
const tables = this.backend.listTables(input.ownerPrefix);
|
|
@@ -1546,6 +1653,7 @@ var StorageAdminProvider = class {
|
|
|
1546
1653
|
async dropCollection(input) {
|
|
1547
1654
|
try {
|
|
1548
1655
|
await this.assertDroppable(input.collection);
|
|
1656
|
+
if (await this.records.isAdoptedLegacyTable(input.collection)) this.backend.forgetDeclaredThisBoot(input.collection);
|
|
1549
1657
|
const rows = this.backend.dropTable(input.collection, input.expectRows);
|
|
1550
1658
|
this.logger.warn("storage-admin: DROPPED a table", { meta: {
|
|
1551
1659
|
collection: input.collection,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $r as RECORD_SWEEP_INTERVAL_MS, Ft as databaseSnapshotCapability, Ji as parseSettingsArrayAdoptsFrom, Jr as NoCallerError, Lr as errMsg, Pt as dataStoreProviderCapability, Q as STORAGE_ADMIN_SCOPED_BASES, Rr as BaseAddon, S as DATA_STORE_DATABASES, Vn as recordsCapability, Wi as normalizeSecretOwner, Wr as DeclarationRefusedError, Yi as parseSettingsBrokersAdoptsFrom, Z as STORAGE_ADMIN_MOVED_COLLECTIONS, ai as RecordKindDeclarationSchema, b as DATABASE_SNAPSHOT_SUFFIX, br as vectorStoreCapability, fi as UnknownRecordKindError, ht as bareAddonId, ni as RUNTIME_DEFAULTS, sr as storageAdminCapability, x as DATABASE_SNAPSHOT_TIMEOUT_MS, y as DATABASE_SNAPSHOT_PARTIAL_SUFFIX } from "../../dist-CkZIrsAP.mjs";
|
|
2
2
|
import { i as retiredKeyStoreOf, n as purgeRetiredSettingsKeys } from "../../retired-settings-keys-Bhwe4ymb.mjs";
|
|
3
|
-
import { C as callControl, D as controlTargetOf, E as callVector, S as RecordsEngine, T as callRecords, _ as isFileHostMessage, a as WalMaintenance, c as SqliteSettingsBackend, d as DatabaseBusyError, f as DuplicatePlacementError, g as collectTransferables, l as CollectionPlacementError, o as createVectorIndex, p as rehydrateError, s as vectorProviderOf, u as CrossDatabaseTransactError, w as callData, x as trustResult } from "../../wal-maintenance-
|
|
3
|
+
import { C as callControl, D as controlTargetOf, E as callVector, S as RecordsEngine, T as callRecords, _ as isFileHostMessage, a as WalMaintenance, c as SqliteSettingsBackend, d as DatabaseBusyError, f as DuplicatePlacementError, g as collectTransferables, l as CollectionPlacementError, o as createVectorIndex, p as rehydrateError, s as vectorProviderOf, u as CrossDatabaseTransactError, w as callData, x as trustResult } from "../../wal-maintenance-Bqm4zrNA.mjs";
|
|
4
4
|
import { r as isSnapshotWorkerMessage } from "../../sqlite-snapshot-protocol-2QaTouWV.mjs";
|
|
5
5
|
import { a as isWorkerMessage, t as WAL_CHECKPOINT_LARGE_PASS_FRAMES } from "../../wal-checkpoint-policy-BahrTtyD.mjs";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
@@ -1226,6 +1226,54 @@ var PlacementRouter = class {
|
|
|
1226
1226
|
}
|
|
1227
1227
|
};
|
|
1228
1228
|
//#endregion
|
|
1229
|
+
//#region src/builtins/sqlite-storage/records/count-settings-array-legacy.ts
|
|
1230
|
+
function isRecord$1(value) {
|
|
1231
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1232
|
+
}
|
|
1233
|
+
function unwrapValue$1(raw) {
|
|
1234
|
+
if (isRecord$1(raw) && "value" in raw) return raw["value"];
|
|
1235
|
+
return raw;
|
|
1236
|
+
}
|
|
1237
|
+
function legacyRowId(item) {
|
|
1238
|
+
const id = item["id"];
|
|
1239
|
+
if (typeof id === "string" && id.length > 0) return id;
|
|
1240
|
+
const username = item["username"];
|
|
1241
|
+
if (typeof username === "string" && username.length > 0) return username;
|
|
1242
|
+
return null;
|
|
1243
|
+
}
|
|
1244
|
+
async function countSettingsArrayLegacy(router, addonId, settingsKey) {
|
|
1245
|
+
const list = unwrapValue$1(await router.get({
|
|
1246
|
+
collection: "addon-settings",
|
|
1247
|
+
key: `${addonId}.${settingsKey}`
|
|
1248
|
+
}));
|
|
1249
|
+
if (!Array.isArray(list)) return 0;
|
|
1250
|
+
let n = 0;
|
|
1251
|
+
for (const item of list) {
|
|
1252
|
+
if (!isRecord$1(item)) continue;
|
|
1253
|
+
if (legacyRowId(item) !== null) n += 1;
|
|
1254
|
+
}
|
|
1255
|
+
return n;
|
|
1256
|
+
}
|
|
1257
|
+
//#endregion
|
|
1258
|
+
//#region src/builtins/sqlite-storage/records/count-settings-brokers-legacy.ts
|
|
1259
|
+
function isRecord(value) {
|
|
1260
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1261
|
+
}
|
|
1262
|
+
function unwrapValue(raw) {
|
|
1263
|
+
if (isRecord(raw) && "value" in raw) return raw["value"];
|
|
1264
|
+
return raw;
|
|
1265
|
+
}
|
|
1266
|
+
async function countSettingsBrokersLegacy(router, addonId) {
|
|
1267
|
+
const list = unwrapValue(await router.get({
|
|
1268
|
+
collection: "addon-settings",
|
|
1269
|
+
key: `${addonId}.brokers`
|
|
1270
|
+
}));
|
|
1271
|
+
if (!Array.isArray(list)) return 0;
|
|
1272
|
+
let n = 0;
|
|
1273
|
+
for (const item of list) if (isRecord(item) && typeof item["id"] === "string") n += 1;
|
|
1274
|
+
return n;
|
|
1275
|
+
}
|
|
1276
|
+
//#endregion
|
|
1229
1277
|
//#region src/builtins/sqlite-storage/records/records-provider.ts
|
|
1230
1278
|
/**
|
|
1231
1279
|
* The `records` capability of the engine (D881): resolves WHO is calling and
|
|
@@ -1317,6 +1365,30 @@ var RecordsProvider = class {
|
|
|
1317
1365
|
owner,
|
|
1318
1366
|
kind
|
|
1319
1367
|
})).adoptedAt !== null) continue;
|
|
1368
|
+
const settingsBrokersAddon = parseSettingsBrokersAdoptsFrom(legacy);
|
|
1369
|
+
if (settingsBrokersAddon !== null) {
|
|
1370
|
+
const legacyRows = await countSettingsBrokersLegacy(this.router, settingsBrokersAddon);
|
|
1371
|
+
if (legacyRows > 0) out[kind] = {
|
|
1372
|
+
...result,
|
|
1373
|
+
adoptionPending: {
|
|
1374
|
+
legacyTable: legacy,
|
|
1375
|
+
legacyRows
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1378
|
+
continue;
|
|
1379
|
+
}
|
|
1380
|
+
const settingsArray = parseSettingsArrayAdoptsFrom(legacy);
|
|
1381
|
+
if (settingsArray !== null) {
|
|
1382
|
+
const legacyRows = await countSettingsArrayLegacy(this.router, settingsArray.addonId, settingsArray.settingsKey);
|
|
1383
|
+
if (legacyRows > 0) out[kind] = {
|
|
1384
|
+
...result,
|
|
1385
|
+
adoptionPending: {
|
|
1386
|
+
legacyTable: legacy,
|
|
1387
|
+
legacyRows
|
|
1388
|
+
}
|
|
1389
|
+
};
|
|
1390
|
+
continue;
|
|
1391
|
+
}
|
|
1320
1392
|
const legacyRows = await (await this.router.recordsFileFor("settings")).records("legacyRowCount", { table: legacy });
|
|
1321
1393
|
if (legacyRows !== null && legacyRows > 0) out[kind] = {
|
|
1322
1394
|
...result,
|
|
@@ -1461,8 +1533,37 @@ var RecordsProvider = class {
|
|
|
1461
1533
|
} });
|
|
1462
1534
|
return (await this.fileOf(input.owner, input.kind)).records("query", input);
|
|
1463
1535
|
}
|
|
1536
|
+
/** True when a declared kind lists `collection` as `adoptsFrom` and adoption finished. */
|
|
1537
|
+
async isAdoptedLegacyTable(collection) {
|
|
1538
|
+
const { kinds } = await this.listKinds({ counts: false });
|
|
1539
|
+
for (const k of kinds) {
|
|
1540
|
+
if (k.state === "dropped") continue;
|
|
1541
|
+
if (k.declaration.adoptsFrom !== collection) continue;
|
|
1542
|
+
const { adoptedAt } = await (await this.fileOf(k.owner, k.kind)).records("adoptionState", {
|
|
1543
|
+
owner: k.owner,
|
|
1544
|
+
kind: k.kind
|
|
1545
|
+
});
|
|
1546
|
+
if (adoptedAt !== null) return true;
|
|
1547
|
+
}
|
|
1548
|
+
return false;
|
|
1549
|
+
}
|
|
1464
1550
|
async adoptRecords(input) {
|
|
1465
1551
|
const file = await this.fileOf(input.owner, input.kind);
|
|
1552
|
+
if (input.records.length > 0) {
|
|
1553
|
+
const { adoptedAt } = await file.records("adoptionState", {
|
|
1554
|
+
owner: input.owner,
|
|
1555
|
+
kind: input.kind
|
|
1556
|
+
});
|
|
1557
|
+
if (adoptedAt !== null) {
|
|
1558
|
+
if ((await file.records("count", {
|
|
1559
|
+
owner: input.owner,
|
|
1560
|
+
kind: input.kind
|
|
1561
|
+
})).count === 0) await file.records("revokeAdopted", {
|
|
1562
|
+
owner: input.owner,
|
|
1563
|
+
kind: input.kind
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1466
1567
|
const result = await file.records("putMany", input);
|
|
1467
1568
|
if (input.complete === true) await file.records("markAdopted", {
|
|
1468
1569
|
owner: input.owner,
|
|
@@ -1516,6 +1617,12 @@ var StorageAdminProvider = class {
|
|
|
1516
1617
|
adoptRecords(input) {
|
|
1517
1618
|
return this.records.adoptRecords(input);
|
|
1518
1619
|
}
|
|
1620
|
+
isAdoptedLegacyTable(input) {
|
|
1621
|
+
return this.records.isAdoptedLegacyTable(input.collection).then((adopted) => ({ adopted }));
|
|
1622
|
+
}
|
|
1623
|
+
readLegacyCollection(input) {
|
|
1624
|
+
return Promise.resolve(this.backend.readLegacyCollection(input));
|
|
1625
|
+
}
|
|
1519
1626
|
/** May this table be dropped AT ALL? Throws with the reason when not. */
|
|
1520
1627
|
async assertDroppable(collection) {
|
|
1521
1628
|
const colon = collection.indexOf(":");
|
|
@@ -1527,7 +1634,7 @@ var StorageAdminProvider = class {
|
|
|
1527
1634
|
throw new Error(`drop refused: the installed addons could not be read (${err instanceof Error ? err.message : String(err)})`);
|
|
1528
1635
|
});
|
|
1529
1636
|
const owner = collection.slice(0, colon);
|
|
1530
|
-
if (installed.has(owner)) throw new Error(`drop refused: "${collection}" belongs to the installed addon "${owner}"`);
|
|
1637
|
+
if (installed.has(owner) && !await this.records.isAdoptedLegacyTable(collection)) throw new Error(`drop refused: "${collection}" belongs to the installed addon "${owner}"`);
|
|
1531
1638
|
}
|
|
1532
1639
|
async listTables(input) {
|
|
1533
1640
|
const tables = this.backend.listTables(input.ownerPrefix);
|
|
@@ -1540,6 +1647,7 @@ var StorageAdminProvider = class {
|
|
|
1540
1647
|
async dropCollection(input) {
|
|
1541
1648
|
try {
|
|
1542
1649
|
await this.assertDroppable(input.collection);
|
|
1650
|
+
if (await this.records.isAdoptedLegacyTable(input.collection)) this.backend.forgetDeclaredThisBoot(input.collection);
|
|
1543
1651
|
const rows = this.backend.dropTable(input.collection, input.expectRows);
|
|
1544
1652
|
this.logger.warn("storage-admin: DROPPED a table", { meta: {
|
|
1545
1653
|
collection: input.collection,
|
|
@@ -16,10 +16,18 @@ export declare class StorageAdminProvider implements IStorageAdminProvider {
|
|
|
16
16
|
private readonly installedOwners;
|
|
17
17
|
/** The records provider the System -> Data and migration methods delegate to (D881). */
|
|
18
18
|
private readonly records;
|
|
19
|
-
constructor(backend: SqliteSettingsBackend, logger: IScopedLogger, installedOwners: () => Promise<ReadonlySet<string>>, records: Pick<RecordsProvider, "listKinds" | "readRecords" | "adoptRecords">);
|
|
19
|
+
constructor(backend: SqliteSettingsBackend, logger: IScopedLogger, installedOwners: () => Promise<ReadonlySet<string>>, records: Pick<RecordsProvider, "listKinds" | "readRecords" | "adoptRecords" | "isAdoptedLegacyTable">);
|
|
20
20
|
listKinds(input: Parameters<IStorageAdminProvider["listKinds"]>[0]): ReturnType<IStorageAdminProvider["listKinds"]>;
|
|
21
21
|
readRecords(input: Parameters<IStorageAdminProvider["readRecords"]>[0]): ReturnType<IStorageAdminProvider["readRecords"]>;
|
|
22
22
|
adoptRecords(input: Parameters<IStorageAdminProvider["adoptRecords"]>[0]): ReturnType<IStorageAdminProvider["adoptRecords"]>;
|
|
23
|
+
isAdoptedLegacyTable(input: {
|
|
24
|
+
collection: string;
|
|
25
|
+
}): ReturnType<IStorageAdminProvider["isAdoptedLegacyTable"]>;
|
|
26
|
+
readLegacyCollection(input: {
|
|
27
|
+
collection: string;
|
|
28
|
+
cursor?: string | undefined;
|
|
29
|
+
limit?: number | undefined;
|
|
30
|
+
}): ReturnType<IStorageAdminProvider["readLegacyCollection"]>;
|
|
23
31
|
/** May this table be dropped AT ALL? Throws with the reason when not. */
|
|
24
32
|
private assertDroppable;
|
|
25
33
|
listTables(input: {
|
|
@@ -8,14 +8,17 @@
|
|
|
8
8
|
* on every sweep, through the same `settings-store` door the location table
|
|
9
9
|
* uses.
|
|
10
10
|
*/
|
|
11
|
-
import type { ISettingsStoreProvider } from "@camstack/types";
|
|
11
|
+
import type { ISettingsStoreProvider, RecordKindHandle, RecordsAccess } from "@camstack/types";
|
|
12
12
|
import type { DrainState } from "./drain-ratchet.js";
|
|
13
|
+
import { type StorageDrainStateBody } from "./record-kinds.js";
|
|
13
14
|
import type { DrainStateStore } from "./storage-pressure-manager.js";
|
|
14
15
|
/** {@link DrainStateStore} on the `settings-store` collection surface. */
|
|
15
16
|
export declare class SqliteDrainStateStore implements DrainStateStore {
|
|
16
17
|
private readonly store;
|
|
17
18
|
private declared;
|
|
18
|
-
|
|
19
|
+
private readonly drainKind;
|
|
20
|
+
constructor(store: ISettingsStoreProvider, drainKind?: RecordKindHandle<StorageDrainStateBody> | null);
|
|
21
|
+
static recordStoresOf(records: Pick<RecordsAccess, "kind">): RecordKindHandle<StorageDrainStateBody>;
|
|
19
22
|
private ensureDeclared;
|
|
20
23
|
load(): Promise<readonly DrainState[]>;
|
|
21
24
|
save(state: DrainState): Promise<void>;
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* tests pass a fake (in-memory `Map`-backed) implementation. Same
|
|
8
8
|
* pattern as `IntegrationRegistry` in `sqlite-storage/`.
|
|
9
9
|
*/
|
|
10
|
-
import type { ISettingsStoreProvider, LegacyStorageLocationDefault, StorageLocation } from "@camstack/types";
|
|
10
|
+
import type { ISettingsStoreProvider, LegacyStorageLocationDefault, RecordKindHandle, RecordsAccess, StorageLocation } from "@camstack/types";
|
|
11
|
+
import { type StorageLocationBody } from "./record-kinds.js";
|
|
11
12
|
/**
|
|
12
13
|
* A location as it comes back OFF DISK: the live record plus the retired
|
|
13
14
|
* `isDefault` column, which exists only so the orchestrator's boot migration
|
|
@@ -47,7 +48,9 @@ export declare const STORAGE_LOCATIONS = "storage_locations";
|
|
|
47
48
|
export declare class SqliteLocationStore implements ILocationStore {
|
|
48
49
|
private readonly store;
|
|
49
50
|
private declared;
|
|
50
|
-
|
|
51
|
+
private readonly locationsKind;
|
|
52
|
+
constructor(store: ISettingsStoreProvider, locationsKind?: RecordKindHandle<StorageLocationBody> | null);
|
|
53
|
+
static recordStoresOf(records: Pick<RecordsAccess, "kind">): RecordKindHandle<StorageLocationBody>;
|
|
51
54
|
/**
|
|
52
55
|
* Lazy `declareCollection` — keeps the constructor cheap and async-free.
|
|
53
56
|
* Called from every mutation/read path; `declareCollection` is idempotent
|
|
@@ -64,3 +67,5 @@ export declare class SqliteLocationStore implements ILocationStore {
|
|
|
64
67
|
upsert(loc: StorageLocation): Promise<void>;
|
|
65
68
|
delete(id: string): Promise<void>;
|
|
66
69
|
}
|
|
70
|
+
export declare function locationToBody(loc: StorageLocation): StorageLocationBody;
|
|
71
|
+
export declare function bodyToPersistedLocation(id: string, body: StorageLocationBody): PersistedStorageLocation | null;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Record kinds owned by storage-orchestrator (phase 4 — hub-main).
|
|
3
|
+
*/
|
|
4
|
+
import { StorageLocationModeSchema, StorageLocationTypeSchema, type DefinedRecordKind } from "@camstack/types";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
export declare const STORAGE_DRAIN_STATE_LEGACY = "storage_drain_state";
|
|
7
|
+
export type StorageLocationBody = {
|
|
8
|
+
readonly type: z.infer<typeof StorageLocationTypeSchema>;
|
|
9
|
+
readonly displayName: string;
|
|
10
|
+
readonly providerId: string;
|
|
11
|
+
readonly config: Record<string, unknown>;
|
|
12
|
+
readonly isSystem: boolean;
|
|
13
|
+
readonly createdAt: number;
|
|
14
|
+
readonly updatedAt: number;
|
|
15
|
+
readonly nodeId?: string;
|
|
16
|
+
readonly enabled?: boolean;
|
|
17
|
+
readonly mode?: z.infer<typeof StorageLocationModeSchema>;
|
|
18
|
+
readonly isDefault?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare const StorageLocationBodySchema: z.ZodType<StorageLocationBody>;
|
|
21
|
+
export type StorageDrainStateBody = {
|
|
22
|
+
readonly locationId: string;
|
|
23
|
+
readonly startedAtMs: number;
|
|
24
|
+
readonly startBytes: number;
|
|
25
|
+
readonly capBytes: number;
|
|
26
|
+
readonly lastPeerBytes: number | null;
|
|
27
|
+
readonly lastSweepMs: number;
|
|
28
|
+
readonly observedGrowthBytes: number;
|
|
29
|
+
readonly observedElapsedMs: number;
|
|
30
|
+
};
|
|
31
|
+
export declare const StorageDrainStateBodySchema: z.ZodType<StorageDrainStateBody>;
|
|
32
|
+
export type StorageOrchestratorRecordKindsMap = {
|
|
33
|
+
readonly locations: DefinedRecordKind<z.ZodType<StorageLocationBody>>;
|
|
34
|
+
readonly "drain-state": DefinedRecordKind<z.ZodType<StorageDrainStateBody>>;
|
|
35
|
+
};
|
|
36
|
+
export declare const storageOrchestratorRecordKinds: StorageOrchestratorRecordKindsMap;
|
|
37
|
+
export declare const storageLocationsRecordKind: DefinedRecordKind<z.ZodType<StorageLocationBody>>;
|
|
38
|
+
export declare const storageDrainStateRecordKind: DefinedRecordKind<z.ZodType<StorageDrainStateBody>>;
|
|
@@ -2,6 +2,8 @@ import type { ProviderRegistration } from "@camstack/types";
|
|
|
2
2
|
import { BaseAddon } from "@camstack/types";
|
|
3
3
|
interface StorageOrchestratorConfig extends Record<string, unknown> {}
|
|
4
4
|
export declare class StorageOrchestratorAddon extends BaseAddon<StorageOrchestratorConfig> {
|
|
5
|
+
private locationsKind;
|
|
6
|
+
private drainStateKind;
|
|
5
7
|
private service;
|
|
6
8
|
private pressureManager;
|
|
7
9
|
private readonly locationBandMonitor;
|