@camstack/server 1.2.786 → 1.2.787
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 +6 -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 +17 -13
- package/dist/core/addon/instances-of-cap.js +35 -0
- package/package.json +31 -40
- package/system/dist/addon-utils.mjs +1 -1
- package/system/dist/{agent-https-snFEmSqQ.js → agent-https--lvZp4PX.js} +1 -1
- package/system/dist/{agent-https-D779EYj3.mjs → agent-https-pSCzmbQd.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-NZ11ORZS.js → capture-engine-CTFHb-UX.js} +1 -1
- package/system/dist/{capture-engine-DkTEWrRe.mjs → capture-engine-N1-UaQr0.mjs} +1 -1
- package/system/dist/{composition-sources-B9-lkIvO.mjs → composition-sources-Qe3MRI1x.mjs} +1 -1
- package/system/dist/{composition-sources-B6GYTy_7.js → composition-sources-Yjz-b6-8.js} +1 -1
- package/system/dist/{constants-DR8hdi45.js → constants-7gannWcO.js} +1 -1
- package/system/dist/{constants--9ui1LK0.mjs → constants-lWMAnwmj.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-8lpRo9Ss.mjs} +1 -1
- package/system/dist/{device-ca-sIFmKkGM.js → device-ca-HGx3Pwb6.js} +1 -1
- package/system/dist/{dist-D-iGSnX_.mjs → dist-DgZrPBbX.mjs} +668 -839
- package/system/dist/{dist-h3Yla8gE.js → dist-j7uy5oG9.js} +668 -839
- 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-BM3peDu1.mjs} +2 -2
- package/system/dist/{hub-mdns-ciao-C5DkUEZF.js → hub-mdns-ciao-BUKHJL6N.js} +2 -2
- package/system/dist/index.d.ts +2 -2
- package/system/dist/index.js +40 -220
- package/system/dist/index.mjs +253 -431
- package/system/dist/{legacy-integration-rows-door-DTDD5wwC.js → legacy-integration-rows-door-D51X6Fdr.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-BTdhD-Yp.mjs → legacy-integration-rows-door-DIm4Q3Jj.mjs} +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-CkAD_-E9.js → restore-archive-8jRnSzmw.js} +1 -1
- package/system/dist/{restore-archive-DQWz5Wp-.mjs → restore-archive-D-Wmp8OK.mjs} +94 -94
- package/system/dist/{wal-maintenance-DouX1XsY.mjs → wal-maintenance-CBnqPn4u.mjs} +0 -0
- package/system/dist/{wal-maintenance-CB-O-GPP.js → wal-maintenance-D0FMnpba.js} +0 -0
- package/system/package.json +1 -1
|
@@ -5,21 +5,17 @@
|
|
|
5
5
|
* restart the ratchet at the top of the disk and silently undo every byte of
|
|
6
6
|
* progress — the operator would see a drain that never finishes and no line
|
|
7
7
|
* saying why. So the cap, the drain start and the observed growth are persisted
|
|
8
|
-
* on every sweep,
|
|
9
|
-
* uses.
|
|
8
|
+
* on every sweep, as `drain-state` records.
|
|
10
9
|
*/
|
|
11
|
-
import type {
|
|
10
|
+
import type { RecordKindHandle, RecordsAccess } from "@camstack/types";
|
|
12
11
|
import type { DrainState } from "./drain-ratchet.js";
|
|
13
12
|
import { type StorageDrainStateBody } from "./record-kinds.js";
|
|
14
13
|
import type { DrainStateStore } from "./storage-pressure-manager.js";
|
|
15
|
-
/** {@link DrainStateStore}
|
|
14
|
+
/** {@link DrainStateStore} over the `drain-state` record kind. */
|
|
16
15
|
export declare class SqliteDrainStateStore implements DrainStateStore {
|
|
17
|
-
private readonly store;
|
|
18
|
-
private declared;
|
|
19
16
|
private readonly drainKind;
|
|
20
|
-
constructor(
|
|
17
|
+
constructor(drainKind: RecordKindHandle<StorageDrainStateBody>);
|
|
21
18
|
static recordStoresOf(records: Pick<RecordsAccess, "kind">): RecordKindHandle<StorageDrainStateBody>;
|
|
22
|
-
private ensureDeclared;
|
|
23
19
|
load(): Promise<readonly DrainState[]>;
|
|
24
20
|
save(state: DrainState): Promise<void>;
|
|
25
21
|
clear(locationId: string): Promise<void>;
|
|
@@ -7,7 +7,7 @@
|
|
|
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 {
|
|
10
|
+
import type { LegacyStorageLocationDefault, RecordKindHandle, RecordsAccess, StorageLocation } from "@camstack/types";
|
|
11
11
|
import { type StorageLocationBody, type StorageSeedMarkerBody } from "./record-kinds.js";
|
|
12
12
|
/**
|
|
13
13
|
* A location as it comes back OFF DISK: the live record plus the retired
|
|
@@ -47,42 +47,25 @@ export interface ILocationStore {
|
|
|
47
47
|
unmarkTypeSeeded?(type: string): Promise<void>;
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
50
|
+
* The keychain scope collection a storage location's secret fields are filed
|
|
51
|
+
* under (`row/storage_locations/<id>`). The table it was named for is gone; the
|
|
52
|
+
* string stays because existing secret markers point at it.
|
|
53
53
|
*/
|
|
54
|
-
export declare const
|
|
54
|
+
export declare const STORAGE_LOCATIONS_SECRET_SCOPE = "storage_locations";
|
|
55
55
|
/**
|
|
56
|
-
* `ILocationStore` on the
|
|
57
|
-
*
|
|
58
|
-
* directly (not the `settings-store` singleton) because since D44 the
|
|
59
|
-
* storage-orchestrator IS that singleton, and asking the registry for it would
|
|
60
|
-
* route this table back through the orchestrator itself.
|
|
56
|
+
* `ILocationStore` on the storage-orchestrator's own record kinds (`locations`
|
|
57
|
+
* and `seed-markers`).
|
|
61
58
|
*/
|
|
62
59
|
export declare class SqliteLocationStore implements ILocationStore {
|
|
63
|
-
private readonly store;
|
|
64
|
-
private declared;
|
|
65
60
|
private readonly locationsKind;
|
|
66
|
-
constructor(store: ISettingsStoreProvider, locationsKind?: RecordKindHandle<StorageLocationBody> | null, seedMarkersKind?: RecordKindHandle<StorageSeedMarkerBody> | null);
|
|
67
61
|
private readonly seedMarkersKind;
|
|
62
|
+
constructor(locationsKind: RecordKindHandle<StorageLocationBody>, seedMarkersKind: RecordKindHandle<StorageSeedMarkerBody>);
|
|
68
63
|
static seedMarkersOf(records: Pick<RecordsAccess, "kind">): RecordKindHandle<StorageSeedMarkerBody>;
|
|
69
64
|
loadSeededTypes(): Promise<readonly string[]>;
|
|
70
65
|
markTypeSeeded(type: string): Promise<void>;
|
|
71
66
|
unmarkTypeSeeded(type: string): Promise<void>;
|
|
72
67
|
static recordStoresOf(records: Pick<RecordsAccess, "kind">): RecordKindHandle<StorageLocationBody>;
|
|
73
|
-
|
|
74
|
-
* Lazy `declareCollection` — keeps the constructor cheap and async-free.
|
|
75
|
-
* Called from every mutation/read path; `declareCollection` is idempotent
|
|
76
|
-
* (and additive on shape changes), so repeated calls collapse to a no-op.
|
|
77
|
-
*/
|
|
78
|
-
private ensureDeclared;
|
|
79
|
-
loadAll(): Promise<readonly StorageLocation[]>;
|
|
80
|
-
/**
|
|
81
|
-
* Replace-or-insert. Implemented as delete + insert rather than a
|
|
82
|
-
* conditional update because the orchestrator serializes every mutation
|
|
83
|
-
* through the in-memory map before dispatching to the store — there's no
|
|
84
|
-
* contention to lose, and delete-then-insert is unconditionally simpler.
|
|
85
|
-
*/
|
|
68
|
+
loadAll(): Promise<readonly PersistedStorageLocation[]>;
|
|
86
69
|
upsert(loc: StorageLocation): Promise<void>;
|
|
87
70
|
delete(id: string): Promise<void>;
|
|
88
71
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { StorageLocationModeSchema, StorageLocationTypeSchema, type DefinedRecordKind } from "@camstack/types";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
export declare const STORAGE_DRAIN_STATE_LEGACY = "storage_drain_state";
|
|
7
6
|
export type StorageLocationBody = {
|
|
8
7
|
readonly type: z.infer<typeof StorageLocationTypeSchema>;
|
|
9
8
|
readonly displayName: string;
|
|
@@ -3,7 +3,7 @@ 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-j7uy5oG9.js");
|
|
7
7
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
8
8
|
let zod = require("zod");
|
|
9
9
|
let node_crypto = require("node:crypto");
|
|
@@ -14,10 +14,6 @@ let node_fs_promises = require("node:fs/promises");
|
|
|
14
14
|
node_fs_promises = require_chunk.__toESM(node_fs_promises);
|
|
15
15
|
//#region src/builtins/storage-orchestrator/record-kinds.ts
|
|
16
16
|
var import_read_all_rows = require_read_all_rows$1.require_read_all_rows();
|
|
17
|
-
/**
|
|
18
|
-
* Record kinds owned by storage-orchestrator (phase 4 — hub-main).
|
|
19
|
-
*/
|
|
20
|
-
var STORAGE_DRAIN_STATE_LEGACY = "storage_drain_state";
|
|
21
17
|
var StorageLocationBodySchema = zod.z.object({
|
|
22
18
|
type: require_dist.StorageLocationTypeSchema,
|
|
23
19
|
displayName: zod.z.string(),
|
|
@@ -82,232 +78,59 @@ _storageOrchestratorRecordKinds["drain-state"];
|
|
|
82
78
|
//#endregion
|
|
83
79
|
//#region src/builtins/storage-orchestrator/location-store.ts
|
|
84
80
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*/
|
|
89
|
-
var STORAGE_LOCATIONS = "storage_locations";
|
|
90
|
-
/**
|
|
91
|
-
* Reserved key under which the cluster `nodeId` (SP1) is persisted INSIDE
|
|
92
|
-
* the `config` JSON blob. Storing it in the blob rather than a dedicated
|
|
93
|
-
* column avoids a destructive `ensureTable` DROP+recreate on deploy (a
|
|
94
|
-
* newly-declared column counts as a missing column → the structured
|
|
95
|
-
* backend drops the table, wiping operator location customizations such
|
|
96
|
-
* as `recordings:default`'s `minFreePercent`). The double-underscore
|
|
97
|
-
* prefix keeps it out of the provider-facing config namespace
|
|
98
|
-
* (`basePath`, `minFreePercent`, …) — the mapper strips it on read so
|
|
99
|
-
* API consumers and providers never see it.
|
|
100
|
-
*/
|
|
101
|
-
var NODE_ID_CONFIG_KEY = "__nodeId";
|
|
102
|
-
/**
|
|
103
|
-
* Reserved key under which the operator opt-in flag (`StorageLocation.enabled`)
|
|
104
|
-
* is persisted INSIDE the `config` JSON blob — same channel, same reason, as
|
|
105
|
-
* {@link NODE_ID_CONFIG_KEY}: a newly-declared COLUMN counts as a missing
|
|
106
|
-
* column, and the structured backend answers that by dropping and recreating
|
|
107
|
-
* the table, wiping every operator customization on it.
|
|
108
|
-
*
|
|
109
|
-
* ABSENT means ACTIVE. A row written before the flag existed carries no key and
|
|
110
|
-
* reads back with `enabled: undefined`, which every consumer treats as enabled —
|
|
111
|
-
* that is why this ships with no migration and no backfill pass.
|
|
112
|
-
*/
|
|
113
|
-
var ENABLED_CONFIG_KEY = "__enabled";
|
|
114
|
-
/**
|
|
115
|
-
* Reserved key under which the location's typed STATE ({@link
|
|
116
|
-
* StorageLocationMode}, D385) is persisted — same channel, same reason, as
|
|
117
|
-
* {@link NODE_ID_CONFIG_KEY} and {@link ENABLED_CONFIG_KEY}.
|
|
118
|
-
*
|
|
119
|
-
* ABSENT means UNSTAMPED, not `active`: the orchestrator's boot migration folds
|
|
120
|
-
* the legacy `enabled` / `config.readOnly` pair into a mode and writes it once.
|
|
121
|
-
* Reading absence as a state here would do that fold on every read forever,
|
|
122
|
-
* which is the thing D385 removes.
|
|
81
|
+
* The keychain scope collection a storage location's secret fields are filed
|
|
82
|
+
* under (`row/storage_locations/<id>`). The table it was named for is gone; the
|
|
83
|
+
* string stays because existing secret markers point at it.
|
|
123
84
|
*/
|
|
124
|
-
var
|
|
85
|
+
var STORAGE_LOCATIONS_SECRET_SCOPE = "storage_locations";
|
|
125
86
|
/**
|
|
126
|
-
* `
|
|
127
|
-
*
|
|
128
|
-
* rides inside the blob under a reserved key (see {@link NODE_ID_CONFIG_KEY}),
|
|
129
|
-
* because a newly-declared column would put this table through
|
|
130
|
-
* `declareCollection`'s destructive rebuild and wipe operator customizations
|
|
131
|
-
* such as `recordings:default`'s `minFreePercent`.
|
|
132
|
-
*/
|
|
133
|
-
var STORAGE_LOCATIONS_COLUMNS = [
|
|
134
|
-
{
|
|
135
|
-
name: "id",
|
|
136
|
-
type: "TEXT",
|
|
137
|
-
primaryKey: true
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
name: "type",
|
|
141
|
-
type: "TEXT",
|
|
142
|
-
notNull: true
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
name: "display_name",
|
|
146
|
-
type: "TEXT",
|
|
147
|
-
notNull: true
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
name: "provider_id",
|
|
151
|
-
type: "TEXT",
|
|
152
|
-
notNull: true
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
name: "config",
|
|
156
|
-
type: "JSON",
|
|
157
|
-
notNull: true,
|
|
158
|
-
defaultValue: "{}"
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
name: "is_default",
|
|
162
|
-
type: "INTEGER",
|
|
163
|
-
notNull: true,
|
|
164
|
-
defaultValue: 0
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
name: "is_system",
|
|
168
|
-
type: "INTEGER",
|
|
169
|
-
notNull: true,
|
|
170
|
-
defaultValue: 0
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
name: "created_at",
|
|
174
|
-
type: "INTEGER",
|
|
175
|
-
notNull: true
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
name: "updated_at",
|
|
179
|
-
type: "INTEGER",
|
|
180
|
-
notNull: true
|
|
181
|
-
}
|
|
182
|
-
];
|
|
183
|
-
var STORAGE_LOCATIONS_INDEXES = [{
|
|
184
|
-
name: "idx_storage_locations_type",
|
|
185
|
-
columns: ["type"]
|
|
186
|
-
}];
|
|
187
|
-
/**
|
|
188
|
-
* `ILocationStore` on the `settings-store` collection surface — the same door
|
|
189
|
-
* every other consumer uses. It holds the `data-store-provider` engine object
|
|
190
|
-
* directly (not the `settings-store` singleton) because since D44 the
|
|
191
|
-
* storage-orchestrator IS that singleton, and asking the registry for it would
|
|
192
|
-
* route this table back through the orchestrator itself.
|
|
87
|
+
* `ILocationStore` on the storage-orchestrator's own record kinds (`locations`
|
|
88
|
+
* and `seed-markers`).
|
|
193
89
|
*/
|
|
194
90
|
var SqliteLocationStore = class {
|
|
195
|
-
store;
|
|
196
|
-
declared = false;
|
|
197
91
|
locationsKind;
|
|
198
|
-
|
|
199
|
-
|
|
92
|
+
seedMarkersKind;
|
|
93
|
+
constructor(locationsKind, seedMarkersKind) {
|
|
200
94
|
this.locationsKind = locationsKind;
|
|
201
95
|
this.seedMarkersKind = seedMarkersKind;
|
|
202
96
|
}
|
|
203
|
-
seedMarkersKind;
|
|
204
97
|
static seedMarkersOf(records) {
|
|
205
98
|
return records.kind(storageOrchestratorRecordKinds["seed-markers"]);
|
|
206
99
|
}
|
|
207
100
|
async loadSeededTypes() {
|
|
208
|
-
|
|
209
|
-
if (kind === null) return [];
|
|
210
|
-
return (await (0, import_read_all_rows.readAllRows)(kind)).map((r) => r.id);
|
|
101
|
+
return (await (0, import_read_all_rows.readAllRows)(this.seedMarkersKind)).map((r) => r.id);
|
|
211
102
|
}
|
|
212
103
|
async markTypeSeeded(type) {
|
|
213
|
-
|
|
214
|
-
if (kind === null) return;
|
|
215
|
-
await kind.put({
|
|
104
|
+
await this.seedMarkersKind.put({
|
|
216
105
|
id: type,
|
|
217
106
|
data: { seededAt: Date.now() }
|
|
218
107
|
});
|
|
219
108
|
}
|
|
220
109
|
async unmarkTypeSeeded(type) {
|
|
221
|
-
|
|
222
|
-
if (kind === null) return;
|
|
223
|
-
await kind.delete(type);
|
|
110
|
+
await this.seedMarkersKind.delete(type);
|
|
224
111
|
}
|
|
225
112
|
static recordStoresOf(records) {
|
|
226
113
|
return records.kind(storageOrchestratorRecordKinds.locations);
|
|
227
114
|
}
|
|
228
|
-
/**
|
|
229
|
-
* Lazy `declareCollection` — keeps the constructor cheap and async-free.
|
|
230
|
-
* Called from every mutation/read path; `declareCollection` is idempotent
|
|
231
|
-
* (and additive on shape changes), so repeated calls collapse to a no-op.
|
|
232
|
-
*/
|
|
233
|
-
async ensureDeclared() {
|
|
234
|
-
if (this.locationsKind !== null) return;
|
|
235
|
-
if (this.declared) return;
|
|
236
|
-
await this.store.declareCollection({
|
|
237
|
-
collection: STORAGE_LOCATIONS,
|
|
238
|
-
columns: STORAGE_LOCATIONS_COLUMNS,
|
|
239
|
-
indexes: STORAGE_LOCATIONS_INDEXES
|
|
240
|
-
});
|
|
241
|
-
this.declared = true;
|
|
242
|
-
}
|
|
243
115
|
async loadAll() {
|
|
244
|
-
await this.
|
|
245
|
-
|
|
246
|
-
if (kind !== null) {
|
|
247
|
-
const rows = await (0, import_read_all_rows.readAllRows)(kind);
|
|
248
|
-
rows.sort((a, b) => a.data.createdAt - b.data.createdAt);
|
|
249
|
-
const out = [];
|
|
250
|
-
for (const row of rows) {
|
|
251
|
-
const mapped = bodyToPersistedLocation(row.id, row.data);
|
|
252
|
-
if (mapped) out.push(mapped);
|
|
253
|
-
}
|
|
254
|
-
return out;
|
|
255
|
-
}
|
|
256
|
-
const rows = await this.store.query({
|
|
257
|
-
collection: STORAGE_LOCATIONS,
|
|
258
|
-
filter: { orderBy: {
|
|
259
|
-
field: "created_at",
|
|
260
|
-
direction: "asc"
|
|
261
|
-
} }
|
|
262
|
-
});
|
|
116
|
+
const rows = await (0, import_read_all_rows.readAllRows)(this.locationsKind);
|
|
117
|
+
rows.sort((a, b) => a.data.createdAt - b.data.createdAt);
|
|
263
118
|
const out = [];
|
|
264
119
|
for (const row of rows) {
|
|
265
|
-
const mapped =
|
|
120
|
+
const mapped = bodyToPersistedLocation(row.id, row.data);
|
|
266
121
|
if (mapped) out.push(mapped);
|
|
267
122
|
}
|
|
268
123
|
return out;
|
|
269
124
|
}
|
|
270
|
-
/**
|
|
271
|
-
* Replace-or-insert. Implemented as delete + insert rather than a
|
|
272
|
-
* conditional update because the orchestrator serializes every mutation
|
|
273
|
-
* through the in-memory map before dispatching to the store — there's no
|
|
274
|
-
* contention to lose, and delete-then-insert is unconditionally simpler.
|
|
275
|
-
*/
|
|
276
125
|
async upsert(loc) {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const data = storageOrchestratorRecordKinds.locations.schema.parse(body);
|
|
282
|
-
await kind.put({
|
|
283
|
-
id: loc.id,
|
|
284
|
-
data
|
|
285
|
-
});
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
await this.store.deleteWhere({
|
|
289
|
-
collection: STORAGE_LOCATIONS,
|
|
290
|
-
filter: { where: { id: loc.id } }
|
|
291
|
-
});
|
|
292
|
-
await this.store.insert({
|
|
293
|
-
collection: STORAGE_LOCATIONS,
|
|
294
|
-
record: {
|
|
295
|
-
id: loc.id,
|
|
296
|
-
data: mapLocationToRow(loc)
|
|
297
|
-
}
|
|
126
|
+
const data = storageOrchestratorRecordKinds.locations.schema.parse(locationToBody(loc));
|
|
127
|
+
await this.locationsKind.put({
|
|
128
|
+
id: loc.id,
|
|
129
|
+
data
|
|
298
130
|
});
|
|
299
131
|
}
|
|
300
132
|
async delete(id) {
|
|
301
|
-
await this.
|
|
302
|
-
const kind = this.locationsKind;
|
|
303
|
-
if (kind !== null) {
|
|
304
|
-
await kind.delete(id);
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
await this.store.deleteWhere({
|
|
308
|
-
collection: STORAGE_LOCATIONS,
|
|
309
|
-
filter: { where: { id } }
|
|
310
|
-
});
|
|
133
|
+
await this.locationsKind.delete(id);
|
|
311
134
|
}
|
|
312
135
|
};
|
|
313
136
|
function locationToBody(loc) {
|
|
@@ -342,69 +165,6 @@ function bodyToPersistedLocation(id, body) {
|
|
|
342
165
|
updatedAt: body.updatedAt
|
|
343
166
|
};
|
|
344
167
|
}
|
|
345
|
-
function isPlainObject(value) {
|
|
346
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
347
|
-
}
|
|
348
|
-
function readConfig(raw) {
|
|
349
|
-
if (isPlainObject(raw)) return { ...raw };
|
|
350
|
-
if (typeof raw === "string" && raw.length > 0) return require_dist.parseJsonObject(raw) ?? {};
|
|
351
|
-
return {};
|
|
352
|
-
}
|
|
353
|
-
function mapLocationToRow(loc) {
|
|
354
|
-
const storedConfig = { ...loc.config };
|
|
355
|
-
if (loc.nodeId !== void 0) storedConfig[NODE_ID_CONFIG_KEY] = loc.nodeId;
|
|
356
|
-
if (loc.enabled !== void 0) storedConfig[ENABLED_CONFIG_KEY] = loc.enabled;
|
|
357
|
-
if (loc.mode !== void 0) storedConfig[MODE_CONFIG_KEY] = loc.mode;
|
|
358
|
-
return {
|
|
359
|
-
id: loc.id,
|
|
360
|
-
type: loc.type,
|
|
361
|
-
display_name: loc.displayName,
|
|
362
|
-
provider_id: loc.providerId,
|
|
363
|
-
config: storedConfig,
|
|
364
|
-
is_default: 0,
|
|
365
|
-
is_system: loc.isSystem ? 1 : 0,
|
|
366
|
-
created_at: loc.createdAt,
|
|
367
|
-
updated_at: loc.updatedAt
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* Decode a row read from the collection. Returns `null` when the row's `type`
|
|
372
|
-
* fails the id-format schema or the row has no id — a corrupt row (hand-edited,
|
|
373
|
-
* partial migration) is skipped rather than taking the boot read down with it.
|
|
374
|
-
*/
|
|
375
|
-
function mapRowToLocation(row) {
|
|
376
|
-
const typeRaw = row["type"];
|
|
377
|
-
const parsedType = require_dist.StorageLocationTypeSchema.safeParse(typeRaw);
|
|
378
|
-
if (!parsedType.success) return null;
|
|
379
|
-
const type = parsedType.data;
|
|
380
|
-
const id = String(row["id"] ?? "");
|
|
381
|
-
if (!id) return null;
|
|
382
|
-
const storedConfig = readConfig(row["config"]);
|
|
383
|
-
const nodeIdRaw = storedConfig[NODE_ID_CONFIG_KEY];
|
|
384
|
-
const nodeId = typeof nodeIdRaw === "string" && nodeIdRaw.length > 0 ? nodeIdRaw : void 0;
|
|
385
|
-
const enabledRaw = storedConfig[ENABLED_CONFIG_KEY];
|
|
386
|
-
const enabled = typeof enabledRaw === "boolean" ? enabledRaw : void 0;
|
|
387
|
-
const parsedMode = require_dist.StorageLocationModeSchema.safeParse(storedConfig[MODE_CONFIG_KEY]);
|
|
388
|
-
const mode = parsedMode.success ? parsedMode.data : void 0;
|
|
389
|
-
const config = { ...storedConfig };
|
|
390
|
-
delete config[NODE_ID_CONFIG_KEY];
|
|
391
|
-
delete config[ENABLED_CONFIG_KEY];
|
|
392
|
-
delete config[MODE_CONFIG_KEY];
|
|
393
|
-
return {
|
|
394
|
-
id,
|
|
395
|
-
type,
|
|
396
|
-
displayName: String(row["display_name"] ?? ""),
|
|
397
|
-
providerId: String(row["provider_id"] ?? ""),
|
|
398
|
-
config,
|
|
399
|
-
...nodeId !== void 0 ? { nodeId } : {},
|
|
400
|
-
...enabled !== void 0 ? { enabled } : {},
|
|
401
|
-
...mode !== void 0 ? { mode } : {},
|
|
402
|
-
...require_dist.LegacyStorageLocationDefaultSchema.parse({ isDefault: row["is_default"] === 1 || row["is_default"] === true }),
|
|
403
|
-
isSystem: row["is_system"] === 1 || row["is_system"] === true,
|
|
404
|
-
createdAt: Number(row["created_at"] ?? 0),
|
|
405
|
-
updatedAt: Number(row["updated_at"] ?? 0)
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
168
|
//#endregion
|
|
409
169
|
//#region src/builtins/storage-orchestrator/storage-migration-coordinator.ts
|
|
410
170
|
var STORAGE_CLASSES = [
|
|
@@ -1655,87 +1415,6 @@ function createDataStoreDispatch(getEngines, getRemote) {
|
|
|
1655
1415
|
}
|
|
1656
1416
|
//#endregion
|
|
1657
1417
|
//#region src/builtins/storage-orchestrator/drain-state-store.ts
|
|
1658
|
-
/**
|
|
1659
|
-
* @durable class=config owner=storage-orchestrator
|
|
1660
|
-
* write="one row per location the operator has switched to `drain`, rewritten on every pressure sweep (60 s) while it drains"
|
|
1661
|
-
* retention="the row is deleted the moment the location leaves `drain` mode. Bounded by the number of disks a human is retiring at once."
|
|
1662
|
-
*/
|
|
1663
|
-
var STORAGE_DRAIN_STATE = "storage_drain_state";
|
|
1664
|
-
var STORAGE_DRAIN_STATE_COLUMNS = [
|
|
1665
|
-
{
|
|
1666
|
-
name: "location_id",
|
|
1667
|
-
type: "TEXT",
|
|
1668
|
-
primaryKey: true
|
|
1669
|
-
},
|
|
1670
|
-
{
|
|
1671
|
-
name: "started_at_ms",
|
|
1672
|
-
type: "INTEGER",
|
|
1673
|
-
notNull: true
|
|
1674
|
-
},
|
|
1675
|
-
{
|
|
1676
|
-
name: "start_bytes",
|
|
1677
|
-
type: "INTEGER",
|
|
1678
|
-
notNull: true
|
|
1679
|
-
},
|
|
1680
|
-
{
|
|
1681
|
-
name: "cap_bytes",
|
|
1682
|
-
type: "INTEGER",
|
|
1683
|
-
notNull: true
|
|
1684
|
-
},
|
|
1685
|
-
{
|
|
1686
|
-
name: "last_peer_bytes",
|
|
1687
|
-
type: "INTEGER"
|
|
1688
|
-
},
|
|
1689
|
-
{
|
|
1690
|
-
name: "last_sweep_ms",
|
|
1691
|
-
type: "INTEGER",
|
|
1692
|
-
notNull: true
|
|
1693
|
-
},
|
|
1694
|
-
{
|
|
1695
|
-
name: "observed_growth_bytes",
|
|
1696
|
-
type: "INTEGER",
|
|
1697
|
-
notNull: true,
|
|
1698
|
-
defaultValue: 0
|
|
1699
|
-
},
|
|
1700
|
-
{
|
|
1701
|
-
name: "observed_elapsed_ms",
|
|
1702
|
-
type: "INTEGER",
|
|
1703
|
-
notNull: true,
|
|
1704
|
-
defaultValue: 0
|
|
1705
|
-
}
|
|
1706
|
-
];
|
|
1707
|
-
/** A finite number off a persisted row, or the documented fallback. A row
|
|
1708
|
-
* written by a hand-edit must never become a cap. */
|
|
1709
|
-
function num(raw, fallback) {
|
|
1710
|
-
return typeof raw === "number" && Number.isFinite(raw) ? raw : fallback;
|
|
1711
|
-
}
|
|
1712
|
-
function mapRow(row) {
|
|
1713
|
-
const locationId = String(row["location_id"] ?? "");
|
|
1714
|
-
if (!locationId) return null;
|
|
1715
|
-
const lastPeerRaw = row["last_peer_bytes"];
|
|
1716
|
-
return {
|
|
1717
|
-
locationId,
|
|
1718
|
-
startedAtMs: num(row["started_at_ms"], 0),
|
|
1719
|
-
startBytes: num(row["start_bytes"], 0),
|
|
1720
|
-
capBytes: num(row["cap_bytes"], 0),
|
|
1721
|
-
lastPeerBytes: typeof lastPeerRaw === "number" && Number.isFinite(lastPeerRaw) ? lastPeerRaw : null,
|
|
1722
|
-
lastSweepMs: num(row["last_sweep_ms"], 0),
|
|
1723
|
-
observedGrowthBytes: num(row["observed_growth_bytes"], 0),
|
|
1724
|
-
observedElapsedMs: num(row["observed_elapsed_ms"], 0)
|
|
1725
|
-
};
|
|
1726
|
-
}
|
|
1727
|
-
function mapState(state) {
|
|
1728
|
-
return {
|
|
1729
|
-
location_id: state.locationId,
|
|
1730
|
-
started_at_ms: state.startedAtMs,
|
|
1731
|
-
start_bytes: state.startBytes,
|
|
1732
|
-
cap_bytes: state.capBytes,
|
|
1733
|
-
last_peer_bytes: state.lastPeerBytes,
|
|
1734
|
-
last_sweep_ms: state.lastSweepMs,
|
|
1735
|
-
observed_growth_bytes: state.observedGrowthBytes,
|
|
1736
|
-
observed_elapsed_ms: state.observedElapsedMs
|
|
1737
|
-
};
|
|
1738
|
-
}
|
|
1739
1418
|
function drainStateToBody(state) {
|
|
1740
1419
|
return {
|
|
1741
1420
|
locationId: state.locationId,
|
|
@@ -1761,81 +1440,32 @@ function bodyToDrainState(body) {
|
|
|
1761
1440
|
observedElapsedMs: body.observedElapsedMs
|
|
1762
1441
|
};
|
|
1763
1442
|
}
|
|
1764
|
-
/** {@link DrainStateStore}
|
|
1443
|
+
/** {@link DrainStateStore} over the `drain-state` record kind. */
|
|
1765
1444
|
var SqliteDrainStateStore = class {
|
|
1766
|
-
store;
|
|
1767
|
-
declared = false;
|
|
1768
1445
|
drainKind;
|
|
1769
|
-
constructor(
|
|
1770
|
-
this.store = store;
|
|
1446
|
+
constructor(drainKind) {
|
|
1771
1447
|
this.drainKind = drainKind;
|
|
1772
1448
|
}
|
|
1773
1449
|
static recordStoresOf(records) {
|
|
1774
1450
|
return records.kind(storageOrchestratorRecordKinds["drain-state"]);
|
|
1775
1451
|
}
|
|
1776
|
-
async ensureDeclared() {
|
|
1777
|
-
if (this.drainKind !== null) return;
|
|
1778
|
-
if (this.declared) return;
|
|
1779
|
-
await this.store.declareCollection({
|
|
1780
|
-
collection: STORAGE_DRAIN_STATE,
|
|
1781
|
-
columns: STORAGE_DRAIN_STATE_COLUMNS
|
|
1782
|
-
});
|
|
1783
|
-
this.declared = true;
|
|
1784
|
-
}
|
|
1785
1452
|
async load() {
|
|
1786
|
-
await this.ensureDeclared();
|
|
1787
|
-
const kind = this.drainKind;
|
|
1788
|
-
if (kind !== null) {
|
|
1789
|
-
const out = [];
|
|
1790
|
-
for (const row of await (0, import_read_all_rows.readAllRows)(kind)) {
|
|
1791
|
-
const mapped = bodyToDrainState(row.data);
|
|
1792
|
-
if (mapped) out.push(mapped);
|
|
1793
|
-
}
|
|
1794
|
-
return out;
|
|
1795
|
-
}
|
|
1796
|
-
const rows = await this.store.query({ collection: STORAGE_DRAIN_STATE });
|
|
1797
1453
|
const out = [];
|
|
1798
|
-
for (const row of
|
|
1799
|
-
const mapped =
|
|
1454
|
+
for (const row of await (0, import_read_all_rows.readAllRows)(this.drainKind)) {
|
|
1455
|
+
const mapped = bodyToDrainState(row.data);
|
|
1800
1456
|
if (mapped) out.push(mapped);
|
|
1801
1457
|
}
|
|
1802
1458
|
return out;
|
|
1803
1459
|
}
|
|
1804
1460
|
async save(state) {
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
const data = storageOrchestratorRecordKinds["drain-state"].schema.parse(body);
|
|
1810
|
-
await kind.put({
|
|
1811
|
-
id: state.locationId,
|
|
1812
|
-
data
|
|
1813
|
-
});
|
|
1814
|
-
return;
|
|
1815
|
-
}
|
|
1816
|
-
await this.store.deleteWhere({
|
|
1817
|
-
collection: STORAGE_DRAIN_STATE,
|
|
1818
|
-
filter: { where: { location_id: state.locationId } }
|
|
1819
|
-
});
|
|
1820
|
-
await this.store.insert({
|
|
1821
|
-
collection: STORAGE_DRAIN_STATE,
|
|
1822
|
-
record: {
|
|
1823
|
-
id: state.locationId,
|
|
1824
|
-
data: mapState(state)
|
|
1825
|
-
}
|
|
1461
|
+
const data = storageOrchestratorRecordKinds["drain-state"].schema.parse(drainStateToBody(state));
|
|
1462
|
+
await this.drainKind.put({
|
|
1463
|
+
id: state.locationId,
|
|
1464
|
+
data
|
|
1826
1465
|
});
|
|
1827
1466
|
}
|
|
1828
1467
|
async clear(locationId) {
|
|
1829
|
-
await this.
|
|
1830
|
-
const kind = this.drainKind;
|
|
1831
|
-
if (kind !== null) {
|
|
1832
|
-
await kind.delete(locationId);
|
|
1833
|
-
return;
|
|
1834
|
-
}
|
|
1835
|
-
await this.store.deleteWhere({
|
|
1836
|
-
collection: STORAGE_DRAIN_STATE,
|
|
1837
|
-
filter: { where: { location_id: locationId } }
|
|
1838
|
-
});
|
|
1468
|
+
await this.drainKind.delete(locationId);
|
|
1839
1469
|
}
|
|
1840
1470
|
};
|
|
1841
1471
|
//#endregion
|
|
@@ -4799,13 +4429,13 @@ var StorageOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
4799
4429
|
resolveLocationStore(quiet = false) {
|
|
4800
4430
|
const reg = this.ctx.kernel.capabilityRegistry;
|
|
4801
4431
|
if (!reg) return null;
|
|
4802
|
-
|
|
4803
|
-
if (!engine) {
|
|
4432
|
+
if (!reg.getCollection(DATA_STORE_PROVIDER_CAP_NAME)[0]) {
|
|
4804
4433
|
if (!quiet) if (nodeOwnsItsDataStore(process.env)) this.ctx.logger.warn("storage-orchestrator: no data-store-provider engine yet — running in-memory until one registers");
|
|
4805
4434
|
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");
|
|
4806
4435
|
return null;
|
|
4807
4436
|
}
|
|
4808
|
-
|
|
4437
|
+
if (this.locationsKind === null || this.seedMarkersKind === null) return null;
|
|
4438
|
+
return new SqliteLocationStore(this.locationsKind, this.seedMarkersKind);
|
|
4809
4439
|
}
|
|
4810
4440
|
/**
|
|
4811
4441
|
* Late-wire the persistence store once a `data-store-provider` engine
|
|
@@ -5000,9 +4630,8 @@ var StorageOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
5000
4630
|
* late-wiring window as the location table — on an agent it is never. */
|
|
5001
4631
|
resolveDrainStore() {
|
|
5002
4632
|
if (this.drainStore) return this.drainStore;
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
this.drainStore = new SqliteDrainStateStore(engine, this.drainStateKind);
|
|
4633
|
+
if (this.drainStateKind === null) return null;
|
|
4634
|
+
this.drainStore = new SqliteDrainStateStore(this.drainStateKind);
|
|
5006
4635
|
return this.drainStore;
|
|
5007
4636
|
}
|
|
5008
4637
|
drainPlanRefusalLogged = false;
|
|
@@ -5152,7 +4781,7 @@ var StorageOrchestratorAddon = class extends require_dist.BaseAddon {
|
|
|
5152
4781
|
stored: { ...stored },
|
|
5153
4782
|
scope: {
|
|
5154
4783
|
kind: "row",
|
|
5155
|
-
collection:
|
|
4784
|
+
collection: STORAGE_LOCATIONS_SECRET_SCOPE,
|
|
5156
4785
|
rowId: locationId
|
|
5157
4786
|
}
|
|
5158
4787
|
});
|
|
@@ -5509,7 +5138,6 @@ function parseOrphanStatus(raw) {
|
|
|
5509
5138
|
//#endregion
|
|
5510
5139
|
exports.HUB_CAP_FWD_ACTION = HUB_CAP_FWD_ACTION;
|
|
5511
5140
|
exports.HUB_CAP_FWD_SERVICE = HUB_CAP_FWD_SERVICE;
|
|
5512
|
-
exports.STORAGE_DRAIN_STATE_LEGACY = STORAGE_DRAIN_STATE_LEGACY;
|
|
5513
5141
|
exports.SqliteLocationStore = SqliteLocationStore;
|
|
5514
5142
|
exports.StorageMigrationCoordinator = StorageMigrationCoordinator;
|
|
5515
5143
|
exports.StorageOrchestratorAddon = StorageOrchestratorAddon;
|