@camstack/server 1.2.786 → 1.2.788
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 +13 -0
- package/dist/api/core/cap-providers.js +62 -96
- package/dist/api/trpc/generated-cap-mounts.js +1 -10
- package/dist/api/trpc/generated-cap-routers.js +2289 -2366
- package/dist/core/addon/addon-registry.service.js +29 -28
- package/dist/core/addon/boot-health-snapshot.js +42 -0
- package/dist/core/addon/hub-spawn-gate.js +1 -0
- package/dist/core/addon/instances-of-cap.js +35 -0
- package/package.json +64 -46
- package/system/dist/addon-utils.mjs +1 -1
- package/system/dist/{agent-https-snFEmSqQ.js → agent-https-jJDe-XNl.js} +1 -1
- package/system/dist/{agent-https-D779EYj3.mjs → agent-https-szf2FU49.mjs} +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +3 -3
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composer.addon.js +3 -3
- package/system/dist/builtins/composer/composer.addon.mjs +3 -3
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +5 -5
- package/system/dist/builtins/local-network/local-network.addon.js +2 -2
- package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +10 -10
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/integration-record-kinds.d.ts +0 -1
- package/system/dist/builtins/sqlite-storage/integration-registry.d.ts +2 -4
- package/system/dist/builtins/sqlite-storage/migrations/migration-types.d.ts +6 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +7 -4
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +7 -4
- package/system/dist/builtins/storage-orchestrator/drain-state-store.d.ts +4 -8
- package/system/dist/builtins/storage-orchestrator/location-store.d.ts +9 -26
- package/system/dist/builtins/storage-orchestrator/record-kinds.d.ts +0 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +35 -407
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +36 -407
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +115 -115
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-DkTEWrRe.mjs → capture-engine-BsKY_3xa.mjs} +1 -1
- package/system/dist/{capture-engine-NZ11ORZS.js → capture-engine-DNHgjQot.js} +1 -1
- package/system/dist/{composition-sources-B9-lkIvO.mjs → composition-sources-BRdGsbVT.mjs} +1 -1
- package/system/dist/{composition-sources-B6GYTy_7.js → composition-sources-BgO0GQYW.js} +1 -1
- package/system/dist/{constants-DR8hdi45.js → constants-C3jGKQSQ.js} +1 -1
- package/system/dist/{constants--9ui1LK0.mjs → constants-CQeMrR4f.mjs} +1 -1
- package/system/dist/{coral-accelerators-DBlgWB8k.mjs → coral-accelerators-BW3OcrLD.mjs} +6 -6
- package/system/dist/{custom-action-registry-B9zFBNVa.mjs → custom-action-registry-N7flBDwT.mjs} +37 -37
- package/system/dist/{device-ca-D-7tAHJ_.mjs → device-ca-ByVi5eUC.mjs} +1 -1
- package/system/dist/{device-ca-sIFmKkGM.js → device-ca-D3y6wGmn.js} +1 -1
- package/system/dist/{dist-h3Yla8gE.js → dist-BRI-Mwx0.js} +824 -957
- package/system/dist/{dist-D-iGSnX_.mjs → dist-BsQA6-0i.mjs} +824 -957
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-DuEfM0fI.mjs → hub-mdns-ciao-8dJTW2LI.mjs} +2 -2
- package/system/dist/{hub-mdns-ciao-C5DkUEZF.js → hub-mdns-ciao-Ry_Jpljx.js} +2 -2
- package/system/dist/index.d.ts +2 -2
- package/system/dist/index.js +85 -223
- package/system/dist/index.mjs +298 -434
- package/system/dist/kernel/addon-health-monitor.d.ts +21 -0
- package/system/dist/{legacy-integration-rows-door-BTdhD-Yp.mjs → legacy-integration-rows-door-CjXTbmvH.mjs} +1 -1
- package/system/dist/{legacy-integration-rows-door-DTDD5wwC.js → legacy-integration-rows-door-D5BdSNla.js} +1 -1
- package/system/dist/migrations/hub/2026-11-06-drop-legacy-integrations-and-storage-locations.d.ts +12 -0
- package/system/dist/{restore-archive-DQWz5Wp-.mjs → restore-archive-Co2lk3OU.mjs} +94 -94
- package/system/dist/{restore-archive-CkAD_-E9.js → restore-archive-GoWJMdHy.js} +1 -1
- package/system/dist/{wal-maintenance-CB-O-GPP.js → wal-maintenance-C1Haue74.js} +0 -0
- package/system/dist/{wal-maintenance-DouX1XsY.mjs → wal-maintenance-DRnV6QYu.mjs} +0 -0
- package/system/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { As as defineAddonMigrations, Ci as modeMayWrite, Ec as EventCategory, Lo as BaseAddon, Lr as gbToBytes, Ma as storageCapability, Na as storageMigrationCapability, Ns as defineRecordKinds, Sa as settingsStoreCapability, Tr as evictionPolicyOfLocation, Xs as isSecretMarker, Zr as isLocationEnabled,
|
|
1
|
+
import { As as defineAddonMigrations, Ci as modeMayWrite, Ec as EventCategory, Lo as BaseAddon, Lr as gbToBytes, Ma as storageCapability, Na as storageMigrationCapability, Ns as defineRecordKinds, Sa as settingsStoreCapability, Tr as evictionPolicyOfLocation, Xs as isSecretMarker, Zr as isLocationEnabled, ai as legacyModeOf, dc as resolveSecretMarkers, en as StorageCleanupJobSchema, gi as mayWriteToLocation, hi as mayReadLocation, la as resolveLocationMode, nn as StorageLocationTypeSchema, pc as secretTreeFromPaths, rc as normalizeNodeId, rn as StorageMigrationJobSchema, tn as StorageLocationModeSchema, to as withLocationMode, ts as REDACTED_SECRET, ws as collectSecretConfigKeys, xt as LegacyStorageLocationDefaultSchema, yc as transformSecretWrite } from "../../dist-BsQA6-0i.mjs";
|
|
2
2
|
import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
@@ -9,10 +9,6 @@ import * as fs from "node:fs/promises";
|
|
|
9
9
|
import { opendir, readdir } from "node:fs/promises";
|
|
10
10
|
//#region src/builtins/storage-orchestrator/record-kinds.ts
|
|
11
11
|
var import_read_all_rows = require_read_all_rows();
|
|
12
|
-
/**
|
|
13
|
-
* Record kinds owned by storage-orchestrator (phase 4 — hub-main).
|
|
14
|
-
*/
|
|
15
|
-
var STORAGE_DRAIN_STATE_LEGACY = "storage_drain_state";
|
|
16
12
|
var StorageLocationBodySchema = z.object({
|
|
17
13
|
type: StorageLocationTypeSchema,
|
|
18
14
|
displayName: z.string(),
|
|
@@ -77,232 +73,59 @@ _storageOrchestratorRecordKinds["drain-state"];
|
|
|
77
73
|
//#endregion
|
|
78
74
|
//#region src/builtins/storage-orchestrator/location-store.ts
|
|
79
75
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*/
|
|
84
|
-
var STORAGE_LOCATIONS = "storage_locations";
|
|
85
|
-
/**
|
|
86
|
-
* Reserved key under which the cluster `nodeId` (SP1) is persisted INSIDE
|
|
87
|
-
* the `config` JSON blob. Storing it in the blob rather than a dedicated
|
|
88
|
-
* column avoids a destructive `ensureTable` DROP+recreate on deploy (a
|
|
89
|
-
* newly-declared column counts as a missing column → the structured
|
|
90
|
-
* backend drops the table, wiping operator location customizations such
|
|
91
|
-
* as `recordings:default`'s `minFreePercent`). The double-underscore
|
|
92
|
-
* prefix keeps it out of the provider-facing config namespace
|
|
93
|
-
* (`basePath`, `minFreePercent`, …) — the mapper strips it on read so
|
|
94
|
-
* API consumers and providers never see it.
|
|
95
|
-
*/
|
|
96
|
-
var NODE_ID_CONFIG_KEY = "__nodeId";
|
|
97
|
-
/**
|
|
98
|
-
* Reserved key under which the operator opt-in flag (`StorageLocation.enabled`)
|
|
99
|
-
* is persisted INSIDE the `config` JSON blob — same channel, same reason, as
|
|
100
|
-
* {@link NODE_ID_CONFIG_KEY}: a newly-declared COLUMN counts as a missing
|
|
101
|
-
* column, and the structured backend answers that by dropping and recreating
|
|
102
|
-
* the table, wiping every operator customization on it.
|
|
103
|
-
*
|
|
104
|
-
* ABSENT means ACTIVE. A row written before the flag existed carries no key and
|
|
105
|
-
* reads back with `enabled: undefined`, which every consumer treats as enabled —
|
|
106
|
-
* that is why this ships with no migration and no backfill pass.
|
|
107
|
-
*/
|
|
108
|
-
var ENABLED_CONFIG_KEY = "__enabled";
|
|
109
|
-
/**
|
|
110
|
-
* Reserved key under which the location's typed STATE ({@link
|
|
111
|
-
* StorageLocationMode}, D385) is persisted — same channel, same reason, as
|
|
112
|
-
* {@link NODE_ID_CONFIG_KEY} and {@link ENABLED_CONFIG_KEY}.
|
|
113
|
-
*
|
|
114
|
-
* ABSENT means UNSTAMPED, not `active`: the orchestrator's boot migration folds
|
|
115
|
-
* the legacy `enabled` / `config.readOnly` pair into a mode and writes it once.
|
|
116
|
-
* Reading absence as a state here would do that fold on every read forever,
|
|
117
|
-
* which is the thing D385 removes.
|
|
76
|
+
* The keychain scope collection a storage location's secret fields are filed
|
|
77
|
+
* under (`row/storage_locations/<id>`). The table it was named for is gone; the
|
|
78
|
+
* string stays because existing secret markers point at it.
|
|
118
79
|
*/
|
|
119
|
-
var
|
|
80
|
+
var STORAGE_LOCATIONS_SECRET_SCOPE = "storage_locations";
|
|
120
81
|
/**
|
|
121
|
-
* `
|
|
122
|
-
*
|
|
123
|
-
* rides inside the blob under a reserved key (see {@link NODE_ID_CONFIG_KEY}),
|
|
124
|
-
* because a newly-declared column would put this table through
|
|
125
|
-
* `declareCollection`'s destructive rebuild and wipe operator customizations
|
|
126
|
-
* such as `recordings:default`'s `minFreePercent`.
|
|
127
|
-
*/
|
|
128
|
-
var STORAGE_LOCATIONS_COLUMNS = [
|
|
129
|
-
{
|
|
130
|
-
name: "id",
|
|
131
|
-
type: "TEXT",
|
|
132
|
-
primaryKey: true
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
name: "type",
|
|
136
|
-
type: "TEXT",
|
|
137
|
-
notNull: true
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
name: "display_name",
|
|
141
|
-
type: "TEXT",
|
|
142
|
-
notNull: true
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
name: "provider_id",
|
|
146
|
-
type: "TEXT",
|
|
147
|
-
notNull: true
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
name: "config",
|
|
151
|
-
type: "JSON",
|
|
152
|
-
notNull: true,
|
|
153
|
-
defaultValue: "{}"
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
name: "is_default",
|
|
157
|
-
type: "INTEGER",
|
|
158
|
-
notNull: true,
|
|
159
|
-
defaultValue: 0
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
name: "is_system",
|
|
163
|
-
type: "INTEGER",
|
|
164
|
-
notNull: true,
|
|
165
|
-
defaultValue: 0
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
name: "created_at",
|
|
169
|
-
type: "INTEGER",
|
|
170
|
-
notNull: true
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
name: "updated_at",
|
|
174
|
-
type: "INTEGER",
|
|
175
|
-
notNull: true
|
|
176
|
-
}
|
|
177
|
-
];
|
|
178
|
-
var STORAGE_LOCATIONS_INDEXES = [{
|
|
179
|
-
name: "idx_storage_locations_type",
|
|
180
|
-
columns: ["type"]
|
|
181
|
-
}];
|
|
182
|
-
/**
|
|
183
|
-
* `ILocationStore` on the `settings-store` collection surface — the same door
|
|
184
|
-
* every other consumer uses. It holds the `data-store-provider` engine object
|
|
185
|
-
* directly (not the `settings-store` singleton) because since D44 the
|
|
186
|
-
* storage-orchestrator IS that singleton, and asking the registry for it would
|
|
187
|
-
* route this table back through the orchestrator itself.
|
|
82
|
+
* `ILocationStore` on the storage-orchestrator's own record kinds (`locations`
|
|
83
|
+
* and `seed-markers`).
|
|
188
84
|
*/
|
|
189
85
|
var SqliteLocationStore = class {
|
|
190
|
-
store;
|
|
191
|
-
declared = false;
|
|
192
86
|
locationsKind;
|
|
193
|
-
|
|
194
|
-
|
|
87
|
+
seedMarkersKind;
|
|
88
|
+
constructor(locationsKind, seedMarkersKind) {
|
|
195
89
|
this.locationsKind = locationsKind;
|
|
196
90
|
this.seedMarkersKind = seedMarkersKind;
|
|
197
91
|
}
|
|
198
|
-
seedMarkersKind;
|
|
199
92
|
static seedMarkersOf(records) {
|
|
200
93
|
return records.kind(storageOrchestratorRecordKinds["seed-markers"]);
|
|
201
94
|
}
|
|
202
95
|
async loadSeededTypes() {
|
|
203
|
-
|
|
204
|
-
if (kind === null) return [];
|
|
205
|
-
return (await (0, import_read_all_rows.readAllRows)(kind)).map((r) => r.id);
|
|
96
|
+
return (await (0, import_read_all_rows.readAllRows)(this.seedMarkersKind)).map((r) => r.id);
|
|
206
97
|
}
|
|
207
98
|
async markTypeSeeded(type) {
|
|
208
|
-
|
|
209
|
-
if (kind === null) return;
|
|
210
|
-
await kind.put({
|
|
99
|
+
await this.seedMarkersKind.put({
|
|
211
100
|
id: type,
|
|
212
101
|
data: { seededAt: Date.now() }
|
|
213
102
|
});
|
|
214
103
|
}
|
|
215
104
|
async unmarkTypeSeeded(type) {
|
|
216
|
-
|
|
217
|
-
if (kind === null) return;
|
|
218
|
-
await kind.delete(type);
|
|
105
|
+
await this.seedMarkersKind.delete(type);
|
|
219
106
|
}
|
|
220
107
|
static recordStoresOf(records) {
|
|
221
108
|
return records.kind(storageOrchestratorRecordKinds.locations);
|
|
222
109
|
}
|
|
223
|
-
/**
|
|
224
|
-
* Lazy `declareCollection` — keeps the constructor cheap and async-free.
|
|
225
|
-
* Called from every mutation/read path; `declareCollection` is idempotent
|
|
226
|
-
* (and additive on shape changes), so repeated calls collapse to a no-op.
|
|
227
|
-
*/
|
|
228
|
-
async ensureDeclared() {
|
|
229
|
-
if (this.locationsKind !== null) return;
|
|
230
|
-
if (this.declared) return;
|
|
231
|
-
await this.store.declareCollection({
|
|
232
|
-
collection: STORAGE_LOCATIONS,
|
|
233
|
-
columns: STORAGE_LOCATIONS_COLUMNS,
|
|
234
|
-
indexes: STORAGE_LOCATIONS_INDEXES
|
|
235
|
-
});
|
|
236
|
-
this.declared = true;
|
|
237
|
-
}
|
|
238
110
|
async loadAll() {
|
|
239
|
-
await this.
|
|
240
|
-
|
|
241
|
-
if (kind !== null) {
|
|
242
|
-
const rows = await (0, import_read_all_rows.readAllRows)(kind);
|
|
243
|
-
rows.sort((a, b) => a.data.createdAt - b.data.createdAt);
|
|
244
|
-
const out = [];
|
|
245
|
-
for (const row of rows) {
|
|
246
|
-
const mapped = bodyToPersistedLocation(row.id, row.data);
|
|
247
|
-
if (mapped) out.push(mapped);
|
|
248
|
-
}
|
|
249
|
-
return out;
|
|
250
|
-
}
|
|
251
|
-
const rows = await this.store.query({
|
|
252
|
-
collection: STORAGE_LOCATIONS,
|
|
253
|
-
filter: { orderBy: {
|
|
254
|
-
field: "created_at",
|
|
255
|
-
direction: "asc"
|
|
256
|
-
} }
|
|
257
|
-
});
|
|
111
|
+
const rows = await (0, import_read_all_rows.readAllRows)(this.locationsKind);
|
|
112
|
+
rows.sort((a, b) => a.data.createdAt - b.data.createdAt);
|
|
258
113
|
const out = [];
|
|
259
114
|
for (const row of rows) {
|
|
260
|
-
const mapped =
|
|
115
|
+
const mapped = bodyToPersistedLocation(row.id, row.data);
|
|
261
116
|
if (mapped) out.push(mapped);
|
|
262
117
|
}
|
|
263
118
|
return out;
|
|
264
119
|
}
|
|
265
|
-
/**
|
|
266
|
-
* Replace-or-insert. Implemented as delete + insert rather than a
|
|
267
|
-
* conditional update because the orchestrator serializes every mutation
|
|
268
|
-
* through the in-memory map before dispatching to the store — there's no
|
|
269
|
-
* contention to lose, and delete-then-insert is unconditionally simpler.
|
|
270
|
-
*/
|
|
271
120
|
async upsert(loc) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const data = storageOrchestratorRecordKinds.locations.schema.parse(body);
|
|
277
|
-
await kind.put({
|
|
278
|
-
id: loc.id,
|
|
279
|
-
data
|
|
280
|
-
});
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
await this.store.deleteWhere({
|
|
284
|
-
collection: STORAGE_LOCATIONS,
|
|
285
|
-
filter: { where: { id: loc.id } }
|
|
286
|
-
});
|
|
287
|
-
await this.store.insert({
|
|
288
|
-
collection: STORAGE_LOCATIONS,
|
|
289
|
-
record: {
|
|
290
|
-
id: loc.id,
|
|
291
|
-
data: mapLocationToRow(loc)
|
|
292
|
-
}
|
|
121
|
+
const data = storageOrchestratorRecordKinds.locations.schema.parse(locationToBody(loc));
|
|
122
|
+
await this.locationsKind.put({
|
|
123
|
+
id: loc.id,
|
|
124
|
+
data
|
|
293
125
|
});
|
|
294
126
|
}
|
|
295
127
|
async delete(id) {
|
|
296
|
-
await this.
|
|
297
|
-
const kind = this.locationsKind;
|
|
298
|
-
if (kind !== null) {
|
|
299
|
-
await kind.delete(id);
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
await this.store.deleteWhere({
|
|
303
|
-
collection: STORAGE_LOCATIONS,
|
|
304
|
-
filter: { where: { id } }
|
|
305
|
-
});
|
|
128
|
+
await this.locationsKind.delete(id);
|
|
306
129
|
}
|
|
307
130
|
};
|
|
308
131
|
function locationToBody(loc) {
|
|
@@ -337,69 +160,6 @@ function bodyToPersistedLocation(id, body) {
|
|
|
337
160
|
updatedAt: body.updatedAt
|
|
338
161
|
};
|
|
339
162
|
}
|
|
340
|
-
function isPlainObject(value) {
|
|
341
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
342
|
-
}
|
|
343
|
-
function readConfig(raw) {
|
|
344
|
-
if (isPlainObject(raw)) return { ...raw };
|
|
345
|
-
if (typeof raw === "string" && raw.length > 0) return parseJsonObject(raw) ?? {};
|
|
346
|
-
return {};
|
|
347
|
-
}
|
|
348
|
-
function mapLocationToRow(loc) {
|
|
349
|
-
const storedConfig = { ...loc.config };
|
|
350
|
-
if (loc.nodeId !== void 0) storedConfig[NODE_ID_CONFIG_KEY] = loc.nodeId;
|
|
351
|
-
if (loc.enabled !== void 0) storedConfig[ENABLED_CONFIG_KEY] = loc.enabled;
|
|
352
|
-
if (loc.mode !== void 0) storedConfig[MODE_CONFIG_KEY] = loc.mode;
|
|
353
|
-
return {
|
|
354
|
-
id: loc.id,
|
|
355
|
-
type: loc.type,
|
|
356
|
-
display_name: loc.displayName,
|
|
357
|
-
provider_id: loc.providerId,
|
|
358
|
-
config: storedConfig,
|
|
359
|
-
is_default: 0,
|
|
360
|
-
is_system: loc.isSystem ? 1 : 0,
|
|
361
|
-
created_at: loc.createdAt,
|
|
362
|
-
updated_at: loc.updatedAt
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Decode a row read from the collection. Returns `null` when the row's `type`
|
|
367
|
-
* fails the id-format schema or the row has no id — a corrupt row (hand-edited,
|
|
368
|
-
* partial migration) is skipped rather than taking the boot read down with it.
|
|
369
|
-
*/
|
|
370
|
-
function mapRowToLocation(row) {
|
|
371
|
-
const typeRaw = row["type"];
|
|
372
|
-
const parsedType = StorageLocationTypeSchema.safeParse(typeRaw);
|
|
373
|
-
if (!parsedType.success) return null;
|
|
374
|
-
const type = parsedType.data;
|
|
375
|
-
const id = String(row["id"] ?? "");
|
|
376
|
-
if (!id) return null;
|
|
377
|
-
const storedConfig = readConfig(row["config"]);
|
|
378
|
-
const nodeIdRaw = storedConfig[NODE_ID_CONFIG_KEY];
|
|
379
|
-
const nodeId = typeof nodeIdRaw === "string" && nodeIdRaw.length > 0 ? nodeIdRaw : void 0;
|
|
380
|
-
const enabledRaw = storedConfig[ENABLED_CONFIG_KEY];
|
|
381
|
-
const enabled = typeof enabledRaw === "boolean" ? enabledRaw : void 0;
|
|
382
|
-
const parsedMode = StorageLocationModeSchema.safeParse(storedConfig[MODE_CONFIG_KEY]);
|
|
383
|
-
const mode = parsedMode.success ? parsedMode.data : void 0;
|
|
384
|
-
const config = { ...storedConfig };
|
|
385
|
-
delete config[NODE_ID_CONFIG_KEY];
|
|
386
|
-
delete config[ENABLED_CONFIG_KEY];
|
|
387
|
-
delete config[MODE_CONFIG_KEY];
|
|
388
|
-
return {
|
|
389
|
-
id,
|
|
390
|
-
type,
|
|
391
|
-
displayName: String(row["display_name"] ?? ""),
|
|
392
|
-
providerId: String(row["provider_id"] ?? ""),
|
|
393
|
-
config,
|
|
394
|
-
...nodeId !== void 0 ? { nodeId } : {},
|
|
395
|
-
...enabled !== void 0 ? { enabled } : {},
|
|
396
|
-
...mode !== void 0 ? { mode } : {},
|
|
397
|
-
...LegacyStorageLocationDefaultSchema.parse({ isDefault: row["is_default"] === 1 || row["is_default"] === true }),
|
|
398
|
-
isSystem: row["is_system"] === 1 || row["is_system"] === true,
|
|
399
|
-
createdAt: Number(row["created_at"] ?? 0),
|
|
400
|
-
updatedAt: Number(row["updated_at"] ?? 0)
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
163
|
//#endregion
|
|
404
164
|
//#region src/builtins/storage-orchestrator/storage-migration-coordinator.ts
|
|
405
165
|
var STORAGE_CLASSES = [
|
|
@@ -1650,87 +1410,6 @@ function createDataStoreDispatch(getEngines, getRemote) {
|
|
|
1650
1410
|
}
|
|
1651
1411
|
//#endregion
|
|
1652
1412
|
//#region src/builtins/storage-orchestrator/drain-state-store.ts
|
|
1653
|
-
/**
|
|
1654
|
-
* @durable class=config owner=storage-orchestrator
|
|
1655
|
-
* write="one row per location the operator has switched to `drain`, rewritten on every pressure sweep (60 s) while it drains"
|
|
1656
|
-
* retention="the row is deleted the moment the location leaves `drain` mode. Bounded by the number of disks a human is retiring at once."
|
|
1657
|
-
*/
|
|
1658
|
-
var STORAGE_DRAIN_STATE = "storage_drain_state";
|
|
1659
|
-
var STORAGE_DRAIN_STATE_COLUMNS = [
|
|
1660
|
-
{
|
|
1661
|
-
name: "location_id",
|
|
1662
|
-
type: "TEXT",
|
|
1663
|
-
primaryKey: true
|
|
1664
|
-
},
|
|
1665
|
-
{
|
|
1666
|
-
name: "started_at_ms",
|
|
1667
|
-
type: "INTEGER",
|
|
1668
|
-
notNull: true
|
|
1669
|
-
},
|
|
1670
|
-
{
|
|
1671
|
-
name: "start_bytes",
|
|
1672
|
-
type: "INTEGER",
|
|
1673
|
-
notNull: true
|
|
1674
|
-
},
|
|
1675
|
-
{
|
|
1676
|
-
name: "cap_bytes",
|
|
1677
|
-
type: "INTEGER",
|
|
1678
|
-
notNull: true
|
|
1679
|
-
},
|
|
1680
|
-
{
|
|
1681
|
-
name: "last_peer_bytes",
|
|
1682
|
-
type: "INTEGER"
|
|
1683
|
-
},
|
|
1684
|
-
{
|
|
1685
|
-
name: "last_sweep_ms",
|
|
1686
|
-
type: "INTEGER",
|
|
1687
|
-
notNull: true
|
|
1688
|
-
},
|
|
1689
|
-
{
|
|
1690
|
-
name: "observed_growth_bytes",
|
|
1691
|
-
type: "INTEGER",
|
|
1692
|
-
notNull: true,
|
|
1693
|
-
defaultValue: 0
|
|
1694
|
-
},
|
|
1695
|
-
{
|
|
1696
|
-
name: "observed_elapsed_ms",
|
|
1697
|
-
type: "INTEGER",
|
|
1698
|
-
notNull: true,
|
|
1699
|
-
defaultValue: 0
|
|
1700
|
-
}
|
|
1701
|
-
];
|
|
1702
|
-
/** A finite number off a persisted row, or the documented fallback. A row
|
|
1703
|
-
* written by a hand-edit must never become a cap. */
|
|
1704
|
-
function num(raw, fallback) {
|
|
1705
|
-
return typeof raw === "number" && Number.isFinite(raw) ? raw : fallback;
|
|
1706
|
-
}
|
|
1707
|
-
function mapRow(row) {
|
|
1708
|
-
const locationId = String(row["location_id"] ?? "");
|
|
1709
|
-
if (!locationId) return null;
|
|
1710
|
-
const lastPeerRaw = row["last_peer_bytes"];
|
|
1711
|
-
return {
|
|
1712
|
-
locationId,
|
|
1713
|
-
startedAtMs: num(row["started_at_ms"], 0),
|
|
1714
|
-
startBytes: num(row["start_bytes"], 0),
|
|
1715
|
-
capBytes: num(row["cap_bytes"], 0),
|
|
1716
|
-
lastPeerBytes: typeof lastPeerRaw === "number" && Number.isFinite(lastPeerRaw) ? lastPeerRaw : null,
|
|
1717
|
-
lastSweepMs: num(row["last_sweep_ms"], 0),
|
|
1718
|
-
observedGrowthBytes: num(row["observed_growth_bytes"], 0),
|
|
1719
|
-
observedElapsedMs: num(row["observed_elapsed_ms"], 0)
|
|
1720
|
-
};
|
|
1721
|
-
}
|
|
1722
|
-
function mapState(state) {
|
|
1723
|
-
return {
|
|
1724
|
-
location_id: state.locationId,
|
|
1725
|
-
started_at_ms: state.startedAtMs,
|
|
1726
|
-
start_bytes: state.startBytes,
|
|
1727
|
-
cap_bytes: state.capBytes,
|
|
1728
|
-
last_peer_bytes: state.lastPeerBytes,
|
|
1729
|
-
last_sweep_ms: state.lastSweepMs,
|
|
1730
|
-
observed_growth_bytes: state.observedGrowthBytes,
|
|
1731
|
-
observed_elapsed_ms: state.observedElapsedMs
|
|
1732
|
-
};
|
|
1733
|
-
}
|
|
1734
1413
|
function drainStateToBody(state) {
|
|
1735
1414
|
return {
|
|
1736
1415
|
locationId: state.locationId,
|
|
@@ -1756,81 +1435,32 @@ function bodyToDrainState(body) {
|
|
|
1756
1435
|
observedElapsedMs: body.observedElapsedMs
|
|
1757
1436
|
};
|
|
1758
1437
|
}
|
|
1759
|
-
/** {@link DrainStateStore}
|
|
1438
|
+
/** {@link DrainStateStore} over the `drain-state` record kind. */
|
|
1760
1439
|
var SqliteDrainStateStore = class {
|
|
1761
|
-
store;
|
|
1762
|
-
declared = false;
|
|
1763
1440
|
drainKind;
|
|
1764
|
-
constructor(
|
|
1765
|
-
this.store = store;
|
|
1441
|
+
constructor(drainKind) {
|
|
1766
1442
|
this.drainKind = drainKind;
|
|
1767
1443
|
}
|
|
1768
1444
|
static recordStoresOf(records) {
|
|
1769
1445
|
return records.kind(storageOrchestratorRecordKinds["drain-state"]);
|
|
1770
1446
|
}
|
|
1771
|
-
async ensureDeclared() {
|
|
1772
|
-
if (this.drainKind !== null) return;
|
|
1773
|
-
if (this.declared) return;
|
|
1774
|
-
await this.store.declareCollection({
|
|
1775
|
-
collection: STORAGE_DRAIN_STATE,
|
|
1776
|
-
columns: STORAGE_DRAIN_STATE_COLUMNS
|
|
1777
|
-
});
|
|
1778
|
-
this.declared = true;
|
|
1779
|
-
}
|
|
1780
1447
|
async load() {
|
|
1781
|
-
await this.ensureDeclared();
|
|
1782
|
-
const kind = this.drainKind;
|
|
1783
|
-
if (kind !== null) {
|
|
1784
|
-
const out = [];
|
|
1785
|
-
for (const row of await (0, import_read_all_rows.readAllRows)(kind)) {
|
|
1786
|
-
const mapped = bodyToDrainState(row.data);
|
|
1787
|
-
if (mapped) out.push(mapped);
|
|
1788
|
-
}
|
|
1789
|
-
return out;
|
|
1790
|
-
}
|
|
1791
|
-
const rows = await this.store.query({ collection: STORAGE_DRAIN_STATE });
|
|
1792
1448
|
const out = [];
|
|
1793
|
-
for (const row of
|
|
1794
|
-
const mapped =
|
|
1449
|
+
for (const row of await (0, import_read_all_rows.readAllRows)(this.drainKind)) {
|
|
1450
|
+
const mapped = bodyToDrainState(row.data);
|
|
1795
1451
|
if (mapped) out.push(mapped);
|
|
1796
1452
|
}
|
|
1797
1453
|
return out;
|
|
1798
1454
|
}
|
|
1799
1455
|
async save(state) {
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
const data = storageOrchestratorRecordKinds["drain-state"].schema.parse(body);
|
|
1805
|
-
await kind.put({
|
|
1806
|
-
id: state.locationId,
|
|
1807
|
-
data
|
|
1808
|
-
});
|
|
1809
|
-
return;
|
|
1810
|
-
}
|
|
1811
|
-
await this.store.deleteWhere({
|
|
1812
|
-
collection: STORAGE_DRAIN_STATE,
|
|
1813
|
-
filter: { where: { location_id: state.locationId } }
|
|
1814
|
-
});
|
|
1815
|
-
await this.store.insert({
|
|
1816
|
-
collection: STORAGE_DRAIN_STATE,
|
|
1817
|
-
record: {
|
|
1818
|
-
id: state.locationId,
|
|
1819
|
-
data: mapState(state)
|
|
1820
|
-
}
|
|
1456
|
+
const data = storageOrchestratorRecordKinds["drain-state"].schema.parse(drainStateToBody(state));
|
|
1457
|
+
await this.drainKind.put({
|
|
1458
|
+
id: state.locationId,
|
|
1459
|
+
data
|
|
1821
1460
|
});
|
|
1822
1461
|
}
|
|
1823
1462
|
async clear(locationId) {
|
|
1824
|
-
await this.
|
|
1825
|
-
const kind = this.drainKind;
|
|
1826
|
-
if (kind !== null) {
|
|
1827
|
-
await kind.delete(locationId);
|
|
1828
|
-
return;
|
|
1829
|
-
}
|
|
1830
|
-
await this.store.deleteWhere({
|
|
1831
|
-
collection: STORAGE_DRAIN_STATE,
|
|
1832
|
-
filter: { where: { location_id: locationId } }
|
|
1833
|
-
});
|
|
1463
|
+
await this.drainKind.delete(locationId);
|
|
1834
1464
|
}
|
|
1835
1465
|
};
|
|
1836
1466
|
//#endregion
|
|
@@ -4794,13 +4424,13 @@ var StorageOrchestratorAddon = class extends BaseAddon {
|
|
|
4794
4424
|
resolveLocationStore(quiet = false) {
|
|
4795
4425
|
const reg = this.ctx.kernel.capabilityRegistry;
|
|
4796
4426
|
if (!reg) return null;
|
|
4797
|
-
|
|
4798
|
-
if (!engine) {
|
|
4427
|
+
if (!reg.getCollection(DATA_STORE_PROVIDER_CAP_NAME)[0]) {
|
|
4799
4428
|
if (!quiet) if (nodeOwnsItsDataStore(process.env)) this.ctx.logger.warn("storage-orchestrator: no data-store-provider engine yet — running in-memory until one registers");
|
|
4800
4429
|
else this.ctx.logger.info("storage-orchestrator: this node boots no data-store engine — storage locations are seeded from addon declarations at every boot, and node-pinned locations live on the hub");
|
|
4801
4430
|
return null;
|
|
4802
4431
|
}
|
|
4803
|
-
|
|
4432
|
+
if (this.locationsKind === null || this.seedMarkersKind === null) return null;
|
|
4433
|
+
return new SqliteLocationStore(this.locationsKind, this.seedMarkersKind);
|
|
4804
4434
|
}
|
|
4805
4435
|
/**
|
|
4806
4436
|
* Late-wire the persistence store once a `data-store-provider` engine
|
|
@@ -4995,9 +4625,8 @@ var StorageOrchestratorAddon = class extends BaseAddon {
|
|
|
4995
4625
|
* late-wiring window as the location table — on an agent it is never. */
|
|
4996
4626
|
resolveDrainStore() {
|
|
4997
4627
|
if (this.drainStore) return this.drainStore;
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
this.drainStore = new SqliteDrainStateStore(engine, this.drainStateKind);
|
|
4628
|
+
if (this.drainStateKind === null) return null;
|
|
4629
|
+
this.drainStore = new SqliteDrainStateStore(this.drainStateKind);
|
|
5001
4630
|
return this.drainStore;
|
|
5002
4631
|
}
|
|
5003
4632
|
drainPlanRefusalLogged = false;
|
|
@@ -5147,7 +4776,7 @@ var StorageOrchestratorAddon = class extends BaseAddon {
|
|
|
5147
4776
|
stored: { ...stored },
|
|
5148
4777
|
scope: {
|
|
5149
4778
|
kind: "row",
|
|
5150
|
-
collection:
|
|
4779
|
+
collection: STORAGE_LOCATIONS_SECRET_SCOPE,
|
|
5151
4780
|
rowId: locationId
|
|
5152
4781
|
}
|
|
5153
4782
|
});
|
|
@@ -5502,4 +5131,4 @@ function parseOrphanStatus(raw) {
|
|
|
5502
5131
|
};
|
|
5503
5132
|
}
|
|
5504
5133
|
//#endregion
|
|
5505
|
-
export { StorageOrchestratorAddon, StorageOrchestratorAddon as default, stripForwardedCaller as a, SqliteLocationStore as c, createHubCapForwardService as i,
|
|
5134
|
+
export { StorageOrchestratorAddon, StorageOrchestratorAddon as default, stripForwardedCaller as a, SqliteLocationStore as c, createHubCapForwardService as i, storageOrchestratorRecordKinds as l, HUB_CAP_FWD_ACTION as n, buildStorageLocationRegistry as o, HUB_CAP_FWD_SERVICE as r, StorageMigrationCoordinator as s, StorageOrchestratorService as t };
|
|
@@ -3,11 +3,11 @@ 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-BRI-Mwx0.js");
|
|
7
7
|
const require_safe_buffer$1 = require("../../safe-buffer-D3aoa-7X.js");
|
|
8
8
|
const require_x509_es = require("../../x509.es-WtnRNyYS.js");
|
|
9
|
-
const require_agent_https = require("../../agent-https-
|
|
10
|
-
const require_constants$8 = require("../../constants-
|
|
9
|
+
const require_agent_https = require("../../agent-https-jJDe-XNl.js");
|
|
10
|
+
const require_constants$8 = require("../../constants-C3jGKQSQ.js");
|
|
11
11
|
const require_src$1 = require("../../src-CnAqG6EF.js");
|
|
12
12
|
let zod = require("zod");
|
|
13
13
|
let node_crypto = require("node:crypto");
|