@camstack/server 1.2.928 → 1.2.929
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/package.json +10 -8
- package/system/dist/addon-id-CVg1_r5E.mjs +39 -0
- package/system/dist/addon-id-Di0lNJ89.js +50 -0
- package/system/dist/addon-pages.cap-Df9FQwN1.js +49 -0
- package/system/dist/addon-pages.cap-DksUlE8j.mjs +44 -0
- package/system/dist/addon-settings.cap-3-TIIMq_.mjs +592 -0
- package/system/dist/addon-settings.cap-DAiE0Nb0.js +651 -0
- package/system/dist/addon-utils.mjs +1 -1
- package/system/dist/addon-widgets.cap-C4jxflbF.js +200 -0
- package/system/dist/addon-widgets.cap-D9m48X78.mjs +183 -0
- package/system/dist/base-addon-DD5dIfcZ.js +4624 -0
- package/system/dist/base-addon-Md14i7pe.mjs +4505 -0
- package/system/dist/base-device-2sL1DMm1.js +1103 -0
- package/system/dist/base-device-IuM1AwXZ.mjs +1098 -0
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +8 -6
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +6 -4
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +8 -6
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +7 -5
- package/system/dist/builtins/alerts/alerts.addon.js +113 -56
- package/system/dist/builtins/alerts/alerts.addon.mjs +60 -3
- package/system/dist/builtins/autotrack/index.js +21 -17
- package/system/dist/builtins/autotrack/index.mjs +5 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +14 -11
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +8 -5
- package/system/dist/builtins/calendars/calendars.addon.js +8 -6
- package/system/dist/builtins/calendars/calendars.addon.mjs +3 -1
- package/system/dist/builtins/camera-grid/index.js +615 -58
- package/system/dist/builtins/camera-grid/index.mjs +558 -1
- package/system/dist/builtins/composer/composer.addon.js +788 -209
- package/system/dist/builtins/composer/composer.addon.mjs +583 -4
- package/system/dist/builtins/console-logging/index.js +4 -3
- package/system/dist/builtins/console-logging/index.mjs +2 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +7887 -381
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +7511 -5
- package/system/dist/builtins/core-notifier/core-notifier.addon.js +731 -21
- package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +711 -1
- package/system/dist/builtins/device-history/device-history.addon.js +110 -31
- package/system/dist/builtins/device-history/device-history.addon.mjs +81 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +12806 -227
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +12583 -5
- package/system/dist/builtins/hub-forwarder/index.js +4 -3
- package/system/dist/builtins/hub-forwarder/index.mjs +2 -1
- package/system/dist/builtins/keychain/index.js +31 -28
- package/system/dist/builtins/keychain/index.mjs +7 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +15 -12
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +4 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +140 -39
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +106 -6
- package/system/dist/builtins/local-network/local-network.addon.js +43 -39
- package/system/dist/builtins/local-network/local-network.addon.mjs +7 -3
- package/system/dist/builtins/loki-logging/index.js +23 -17
- package/system/dist/builtins/loki-logging/index.mjs +7 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +156 -15
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +151 -10
- package/system/dist/builtins/platform-probe/index.js +25 -23
- package/system/dist/builtins/platform-probe/index.mjs +12 -10
- package/system/dist/builtins/record-entries/index.js +9 -7
- package/system/dist/builtins/record-entries/index.mjs +3 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +4 -4
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +97 -44
- package/system/dist/builtins/snapshot/index.mjs +54 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +5 -4
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +21 -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/sqlite-settings.addon.js +87 -61
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +29 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +81 -72
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +10 -1
- package/system/dist/builtins/system-config/system-config.addon.js +17 -14
- package/system/dist/builtins/system-config/system-config.addon.mjs +118 -115
- package/system/dist/builtins/winston-logging/index.js +7 -5
- package/system/dist/builtins/winston-logging/index.mjs +3 -1
- package/system/dist/calendars.cap-CaFlShS9.js +155 -0
- package/system/dist/calendars.cap-_C4eD4fi.mjs +138 -0
- package/system/dist/camstack-error-DJ-TUAi1.js +23 -0
- package/system/dist/camstack-error-viZYfcj9.mjs +18 -0
- package/system/dist/cap-call-context-Bd76CbOW.js +95 -0
- package/system/dist/cap-call-context-DNwdgGSQ.mjs +78 -0
- package/system/dist/capability-definition-C2rJdVeX.mjs +177 -0
- package/system/dist/capability-definition-HCmTem8c.js +242 -0
- package/system/dist/{capture-engine-BcuwOSXv.js → capture-engine-DZ0LIUqA.js} +5 -4
- package/system/dist/{capture-engine-Bz7eXFjT.mjs → capture-engine-DiwbjoWp.mjs} +2 -1
- package/system/dist/command-origin-claim-Cief660O.js +35 -0
- package/system/dist/command-origin-claim-D1Wy7Qld.mjs +24 -0
- package/system/dist/composition-sources-Caqv7O7z.mjs +391 -0
- package/system/dist/composition-sources-CgnHjm8Q.js +408 -0
- package/system/dist/{constants-D2etJ02O.js → constants-Ba3FTIHl.js} +1 -1
- package/system/dist/constants-C860Y6U4.js +26 -0
- package/system/dist/{constants-BcUTQd1M.mjs → constants-DB4piTD5.mjs} +1 -1
- package/system/dist/constants-DCLpoF4L.mjs +21 -0
- package/system/dist/coral-accelerators-7o8hqvcN.js +564 -0
- package/system/dist/coral-accelerators-BKcXP59c.mjs +521 -0
- package/system/dist/core-blocks.cap-C6iKAZ-x.mjs +17986 -0
- package/system/dist/core-blocks.cap-LEMqVwxO.js +18705 -0
- package/system/dist/{custom-action-registry-N7flBDwT.mjs → custom-action-registry-B9zFBNVa.mjs} +37 -37
- package/system/dist/custom-actions-BFUSalC9.mjs +25 -0
- package/system/dist/custom-actions-D92NRi2c.js +36 -0
- package/system/dist/database-snapshot.cap-DF38e-0P.js +162 -0
- package/system/dist/database-snapshot.cap-dhrc9xnY.mjs +133 -0
- package/system/dist/declared-device-BWphj9WE.js +303 -0
- package/system/dist/declared-device-CKERA1Hi.mjs +286 -0
- package/system/dist/{device-ca-ExMN3xW3.mjs → device-ca-BLM6fccc.mjs} +2 -1
- package/system/dist/{device-ca-CU8zh9Pi.js → device-ca-C5kJE6mL.js} +7 -6
- package/system/dist/device-certificate-Cddm4Idn.mjs +91 -0
- package/system/dist/device-certificate-CguVACQO.js +162 -0
- package/system/dist/device-identifiers-BQg9EQi1.js +600 -0
- package/system/dist/device-identifiers-iSuQCKmK.mjs +529 -0
- package/system/dist/device-kind-BJ2pfsjw.mjs +78 -0
- package/system/dist/device-kind-CsSiv_YF.js +101 -0
- package/system/dist/device-manager.cap-2abwVLCM.js +2874 -0
- package/system/dist/device-manager.cap-CFZSPfUh.mjs +2749 -0
- package/system/dist/device-provider.cap-3Uvk6f5-.mjs +331 -0
- package/system/dist/device-provider.cap-D7TV2kVH.js +366 -0
- package/system/dist/{device-row-store-CeW_GWh9.mjs → device-row-store-YF3jtmkk.mjs} +4 -1
- package/system/dist/{device-row-store-BMIR-n3m.js → device-row-store-doTfMOqn.js} +12 -9
- package/system/dist/device-transitions.cap-B5w5PYU_.js +860 -0
- package/system/dist/device-transitions.cap-DojcwEuX.mjs +819 -0
- package/system/dist/device-type-CbQsnFdC.js +477 -0
- package/system/dist/device-type-DgEvK3ch.mjs +454 -0
- package/system/dist/entry-kind-D9MuVJCK.mjs +44 -0
- package/system/dist/entry-kind-cq90c--V.js +55 -0
- package/system/dist/error.cap-CSM_SRfR.mjs +3423 -0
- package/system/dist/error.cap-DBhgPeWK.js +3848 -0
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/history-catalog-BKRarIL_.js +831 -0
- package/system/dist/history-catalog-BwTeQ4Mr.mjs +802 -0
- package/system/dist/{hub-identity-Csxx2Q8k.js → hub-identity-BMdR3Mw9.js} +2 -2
- package/system/dist/{hub-identity-CYC1820R.mjs → hub-identity-DjMN9Ac2.mjs} +10 -10
- package/system/dist/{hub-mdns-ciao-By5577HM.js → hub-mdns-ciao--0v1TKME.js} +5 -5
- package/system/dist/{hub-mdns-ciao-CCDxM5qz.mjs → hub-mdns-ciao-DBrtHOcc.mjs} +2 -2
- package/system/dist/index.js +763 -151
- package/system/dist/index.mjs +832 -220
- package/system/dist/integration-instances.cap-Cl9O-k4h.mjs +538 -0
- package/system/dist/integration-instances.cap-dJIxg2_s.js +549 -0
- package/system/dist/keychain-admin.cap-Db_oFX4H.js +425 -0
- package/system/dist/keychain-admin.cap-GtM7gVGG.mjs +396 -0
- package/system/dist/l10n-Bu6aUvSY.mjs +10 -0
- package/system/dist/l10n-CGMvp7NF.js +15 -0
- package/system/dist/labels-DX5S8deC.js +81 -0
- package/system/dist/labels-DsBcU7md.mjs +64 -0
- package/system/dist/{legacy-integration-rows-door-CVwOo5aq.js → legacy-integration-rows-door-B1nzxxr5.js} +2 -2
- package/system/dist/{legacy-integration-rows-door-D9tQOUzh.mjs → legacy-integration-rows-door-nTvo_6jQ.mjs} +1 -1
- package/system/dist/log-destination.cap-CxZzAVaR.mjs +143 -0
- package/system/dist/log-destination.cap-DELPJkZ0.js +148 -0
- package/system/dist/low-power-sleep.cap-7lfVU41N.js +103 -0
- package/system/dist/low-power-sleep.cap-tGPmaZ_V.mjs +92 -0
- package/system/dist/mask-shape-Ci8Co9w0.mjs +57 -0
- package/system/dist/mask-shape-CmPA2fst.js +92 -0
- package/system/dist/metrics-provider.cap-BNmcHDkQ.mjs +405 -0
- package/system/dist/metrics-provider.cap-BcmQUt6l.js +410 -0
- package/system/dist/migration-BMjgkyG2.js +380 -0
- package/system/dist/migration-DRJAtdy7.mjs +321 -0
- package/system/dist/network-access.cap-B5TWLDCC.js +1099 -0
- package/system/dist/network-access.cap-BJnGbE6n.mjs +1004 -0
- package/system/dist/notification-rules.cap-B__YBgnG.js +3422 -0
- package/system/dist/notification-rules.cap-D9ArZlwx.mjs +3357 -0
- package/system/dist/ops-log-CB4pIdqi.mjs +64 -0
- package/system/dist/ops-log-pxt9176Z.js +81 -0
- package/system/dist/pinned-binary-BOhOSNff.js +28 -0
- package/system/dist/pinned-binary-CrIRAi4G.mjs +23 -0
- package/system/dist/platform-probe.cap-1WrMhWHx.js +250 -0
- package/system/dist/platform-probe.cap-BFeqFLtQ.mjs +233 -0
- package/system/dist/prefix-walk-B4b2-9aK.mjs +790 -0
- package/system/dist/prefix-walk-DC0ljmbB.js +843 -0
- package/system/dist/ptz-autotrack.cap-BW7w0zHD.js +229 -0
- package/system/dist/ptz-autotrack.cap-DT2GypXw.mjs +224 -0
- package/system/dist/quantity-D3g5SxsZ.mjs +114 -0
- package/system/dist/quantity-lY1KiTSZ.js +143 -0
- package/system/dist/raw-secret-migration-DxuBFtvi.js +50 -0
- package/system/dist/raw-secret-migration-iv88mLoc.mjs +39 -0
- package/system/dist/record-entries.cap-sMUhTvTU.mjs +75 -0
- package/system/dist/record-entries.cap-ti1C046R.js +80 -0
- package/system/dist/record-kind-DoBfYHCs.js +203 -0
- package/system/dist/record-kind-ub6NXqfh.mjs +162 -0
- package/system/dist/recording-archive.cap-7OrIn9e5.mjs +1299 -0
- package/system/dist/recording-archive.cap-D7bo-QSM.js +1328 -0
- package/system/dist/records.cap-ClcWV64i.js +329 -0
- package/system/dist/records.cap-CwLT2ByG.mjs +294 -0
- package/system/dist/relocate-CdVQAk-w.js +804 -0
- package/system/dist/relocate-CoZZTui1.mjs +661 -0
- package/system/dist/rename-composition-block-7WIICIDq.mjs +33525 -0
- package/system/dist/rename-composition-block-CcWLwVhG.js +34692 -0
- package/system/dist/{restore-archive-BJfyu0sG.mjs → restore-archive-CjAyKpgX.mjs} +96 -94
- package/system/dist/{restore-archive-CIFvqOze.js → restore-archive-CkTkv3Ss.js} +6 -4
- package/system/dist/scoped-settings-CylSSq_8.js +955 -0
- package/system/dist/scoped-settings-DVWUIP7Z.mjs +650 -0
- package/system/dist/server-name-BIhLuHvX.mjs +35 -0
- package/system/dist/server-name-OALNvpqC.js +52 -0
- package/system/dist/settings-store.cap-Ci4F2zul.mjs +569 -0
- package/system/dist/settings-store.cap-wlJhCspr.js +640 -0
- package/system/dist/snapshot.cap-3suPdBHV.js +250 -0
- package/system/dist/snapshot.cap-Bs8Oyaqh.mjs +245 -0
- package/system/dist/source-info-DGB7SdB_.mjs +190 -0
- package/system/dist/source-info-DtWf4k2j.js +225 -0
- package/system/dist/storage-admin.cap-BSv1NjKJ.mjs +883 -0
- package/system/dist/storage-admin.cap-he0OqvVM.js +906 -0
- package/system/dist/storage-location-CBT8GCD6.mjs +163 -0
- package/system/dist/storage-location-CTweDMZf.js +198 -0
- package/system/dist/storage-location-mode-B21UVRRX.mjs +167 -0
- package/system/dist/storage-location-mode-CS4sMzo-.js +232 -0
- package/system/dist/storage-migration.cap-CyyATY_p.js +330 -0
- package/system/dist/storage-migration.cap-D7QqGobp.mjs +313 -0
- package/system/dist/storage-occupancy.cap-2rmnS58Z.js +622 -0
- package/system/dist/storage-occupancy.cap-CqBztTl9.mjs +611 -0
- package/system/dist/storage-provider.cap-Bw0CfxVc.js +213 -0
- package/system/dist/storage-provider.cap-CMeck2w4.mjs +202 -0
- package/system/dist/stream-catalog.cap-Bp7SkgIf.mjs +6560 -0
- package/system/dist/stream-catalog.cap-D3uwePiA.js +6763 -0
- package/system/dist/streaming-shared-B8cXatuU.mjs +431 -0
- package/system/dist/streaming-shared-DQwFZOSi.js +526 -0
- package/system/dist/system-reasons-Be_k1W8g.js +25 -0
- package/system/dist/system-reasons-CYj4qwyS.mjs +20 -0
- package/system/dist/tag-BxLazvVb.js +2138 -0
- package/system/dist/tag-uZBAq6ox.mjs +2073 -0
- package/system/dist/user-management.cap-B9QDu8NE.js +825 -0
- package/system/dist/user-management.cap-DBIi77sB.mjs +766 -0
- package/system/dist/vector-store.cap-DnyfrYDn.js +330 -0
- package/system/dist/vector-store.cap-h2GHWQ1t.mjs +319 -0
- package/system/dist/{wal-maintenance-CTrCPzds.mjs → wal-maintenance-BG01rOn9.mjs} +0 -0
- package/system/dist/{wal-maintenance-dq7T3quB.js → wal-maintenance-DyrebYKF.js} +0 -0
- package/system/dist/zod-secret-DS7mj1bk.js +78 -0
- package/system/dist/zod-secret-zY4nM61M.mjs +73 -0
- package/system/package.json +1 -1
- package/system/dist/composition-sources-BI614LJx.mjs +0 -141
- package/system/dist/composition-sources-v_kkb8A9.js +0 -152
- package/system/dist/coral-accelerators-BSVsBVzt.js +0 -250
- package/system/dist/coral-accelerators-BW3OcrLD.mjs +0 -231
- package/system/dist/dist-BCHMSqzc.mjs +0 -143467
- package/system/dist/dist-BZfvhfS1.js +0 -146970
- package/system/dist/prefix-walk-DAOBSyH1.mjs +0 -88
- package/system/dist/prefix-walk-Dv6MLZlM.js +0 -99
- package/system/dist/rename-composition-block-C9HuBrKS.js +0 -112
- package/system/dist/rename-composition-block-DtaYmYAR.mjs +0 -101
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { n as StorageLocationModeSchema, o as mayWriteToLocation } from "./storage-location-mode-B21UVRRX.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region ../types/dist/esm/interfaces/storage-location.mjs
|
|
4
|
+
/**
|
|
5
|
+
* `StorageLocationType` — an addon-declared id that identifies the *kind* of
|
|
6
|
+
* storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
|
|
7
|
+
* so the persisted record schema and the consumer-facing cap can both consume it
|
|
8
|
+
* without forming a circular import. The `storage` cap re-exports it
|
|
9
|
+
* verbatim for back-compat.
|
|
10
|
+
*
|
|
11
|
+
* This Zod schema is the **authoritative source** for `StorageLocationType`.
|
|
12
|
+
* The TS alias in `./storage.ts` re-exports `z.infer<typeof
|
|
13
|
+
* StorageLocationTypeSchema>` so the wire surface (cap) and the legacy
|
|
14
|
+
* `IStorageProvider` interface stay in lockstep.
|
|
15
|
+
*
|
|
16
|
+
* The type is now an **open string** (not a closed enum) — addons declare
|
|
17
|
+
* their own location kinds via `StorageLocationDeclaration.id`. The regex
|
|
18
|
+
* enforces a safe id format: lowercase-start, alphanumeric + hyphens.
|
|
19
|
+
*/
|
|
20
|
+
var StorageLocationTypeSchema = /* @__PURE__ */ z.string().regex(/^[a-z][a-zA-Z0-9-]*$/);
|
|
21
|
+
/**
|
|
22
|
+
* Persisted record for a storage location instance. Operators can register
|
|
23
|
+
* multiple instances for multi-cardinality types (e.g. two `backups`
|
|
24
|
+
* locations with different `providerId`s). Cardinality is now declared per
|
|
25
|
+
* location via `StorageLocationDeclaration.cardinality` — the static
|
|
26
|
+
* `STORAGE_LOCATION_CARDINALITY` map has been removed.
|
|
27
|
+
*
|
|
28
|
+
* `id` is a stable namespaced string of the form `<type>:<slug>`.
|
|
29
|
+
* The seed names its first instance `<type>:default` — a NAME, not a flag.
|
|
30
|
+
* There is no default location any more (D383): `enabled` is the whole write
|
|
31
|
+
* model, and a bare type ref resolves to the sole location of the type, or —
|
|
32
|
+
* transitionally, only while legacy NULL-stamped rows exist — to the row whose
|
|
33
|
+
* slug is `default`.
|
|
34
|
+
*
|
|
35
|
+
* `isSystem` is a legacy persisted flag. Seed still creates the initial
|
|
36
|
+
* `<type>:default` locations; the flag is no longer a lock, a badge, or a
|
|
37
|
+
* prune selector. New writes leave it false. Deletion is gated on uniqueness
|
|
38
|
+
* / last-enabled, not on this bit.
|
|
39
|
+
*/
|
|
40
|
+
var StorageLocationSchema = /* @__PURE__ */ z.object({
|
|
41
|
+
id: /* @__PURE__ */ z.string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/),
|
|
42
|
+
type: /* @__PURE__ */ z.string(),
|
|
43
|
+
displayName: /* @__PURE__ */ z.string().min(1),
|
|
44
|
+
providerId: /* @__PURE__ */ z.string().min(1),
|
|
45
|
+
config: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()),
|
|
46
|
+
/**
|
|
47
|
+
* Cluster node this location physically lives on. REQUIRED for node-local
|
|
48
|
+
* providers (filesystem — the path exists on one node's disk), null/absent
|
|
49
|
+
* for node-agnostic providers (S3/SFTP/WebDAV, reachable from any node).
|
|
50
|
+
* `'hub'` is the hub node. Validated against the provider's `nodeLocal`
|
|
51
|
+
* flag at upsert time, not here (the schema is provider-agnostic).
|
|
52
|
+
*/
|
|
53
|
+
nodeId: /* @__PURE__ */ z.string().optional(),
|
|
54
|
+
isSystem: /* @__PURE__ */ z.boolean().default(false),
|
|
55
|
+
/**
|
|
56
|
+
* THE write switch, and the only one (D383). `enabled: true` means every
|
|
57
|
+
* consumer that chooses a write target for this type may write here, and all
|
|
58
|
+
* enabled locations of a type are used TOGETHER; `false` means read-only —
|
|
59
|
+
* still read, still played back, still age-swept, still drained, never
|
|
60
|
+
* written.
|
|
61
|
+
*
|
|
62
|
+
* OPTIONAL only for the wire: an upsert that omits it means "leave what is
|
|
63
|
+
* stored" on an update and "born inert unless it is the first location of its
|
|
64
|
+
* type" on a create. On a PERSISTED row absence is legacy and it means
|
|
65
|
+
* enabled — {@link isLocationEnabled} is the one place that says so, and the
|
|
66
|
+
* orchestrator stamps every flagless row `true` once at hydrate so absence
|
|
67
|
+
* stops existing rather than being re-derived on every read.
|
|
68
|
+
*/
|
|
69
|
+
enabled: /* @__PURE__ */ z.boolean().optional(),
|
|
70
|
+
/**
|
|
71
|
+
* THE state of this location (D385), and the only authority on what may be
|
|
72
|
+
* written, read or evicted here. Interpreted in exactly one place —
|
|
73
|
+
* `storage-location-mode.ts` — which also folds the legacy
|
|
74
|
+
* `enabled` / `config.readOnly` pair into a mode so an old row is never
|
|
75
|
+
* ambiguous.
|
|
76
|
+
*
|
|
77
|
+
* OPTIONAL only for the wire and for rows written before D385: absence is
|
|
78
|
+
* resolved by `resolveLocationMode`, and the orchestrator stamps every
|
|
79
|
+
* unstamped row ONCE at hydrate so absence stops existing rather than being
|
|
80
|
+
* re-derived on every read. `enabled` survives one release as a DERIVED
|
|
81
|
+
* mirror (`mode === 'active'`); `withLocationMode` is the only writer of
|
|
82
|
+
* either, so the two cannot disagree.
|
|
83
|
+
*/
|
|
84
|
+
mode: /* @__PURE__ */ StorageLocationModeSchema.optional(),
|
|
85
|
+
/** COMPUTED at read time by the orchestrator (statfs of the backing volume
|
|
86
|
+
* for node-local locations it can reach) — never persisted, absent when the
|
|
87
|
+
* volume is remote/unreachable. The single capacity truth every UI reads. */
|
|
88
|
+
capacity: /* @__PURE__ */ z.object({
|
|
89
|
+
totalBytes: /* @__PURE__ */ z.number(),
|
|
90
|
+
availableBytes: /* @__PURE__ */ z.number()
|
|
91
|
+
}).nullable().optional(),
|
|
92
|
+
/**
|
|
93
|
+
* How much of that volume CamStack ITSELF holds on this location (D388) —
|
|
94
|
+
* COMPUTED at read time from the `storage-occupancy` providers' own figures,
|
|
95
|
+
* never persisted, never a filesystem walk.
|
|
96
|
+
*
|
|
97
|
+
* **ABSENT MEANS UNKNOWN, never zero.** No provider has reported for this
|
|
98
|
+
* location yet — nobody stores here, the owning addon is down, or the first
|
|
99
|
+
* refresh has not completed. A UI must omit the segment rather than draw it
|
|
100
|
+
* at zero, which would claim we occupy nothing (D315). It is an OBJECT and
|
|
101
|
+
* not a bare number precisely so that a `?? 0` on the consuming side has to
|
|
102
|
+
* be spelled out loud instead of appearing by accident.
|
|
103
|
+
*
|
|
104
|
+
* `measuredAtMs` is the OLDEST contributing measurement, so it is honest
|
|
105
|
+
* about the whole figure rather than about its freshest part.
|
|
106
|
+
*/
|
|
107
|
+
owned: /* @__PURE__ */ z.object({
|
|
108
|
+
bytes: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
109
|
+
measuredAtMs: /* @__PURE__ */ z.number().int().nonnegative()
|
|
110
|
+
}).optional(),
|
|
111
|
+
createdAt: /* @__PURE__ */ z.number(),
|
|
112
|
+
updatedAt: /* @__PURE__ */ z.number()
|
|
113
|
+
});
|
|
114
|
+
function isLocationEnabled(location) {
|
|
115
|
+
return mayWriteToLocation({
|
|
116
|
+
...location,
|
|
117
|
+
config: location.config ?? {}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Bytes in one GB, for every storage figure an operator types.
|
|
122
|
+
*
|
|
123
|
+
* BINARY (1024³), everywhere. The repo had both: the orchestrator's
|
|
124
|
+
* `maxUsedGb` → bytes conversion used 1024³ while the recorder's placement
|
|
125
|
+
* headroom used 10⁹ for the SAME stored key, so a location with a cap set was
|
|
126
|
+
* silently 7.4% off depending on which side of the pipe asked. The persisted
|
|
127
|
+
* values were entered against the binary unit and the admin UI reads it, so
|
|
128
|
+
* that is the one that stays. Every GB knob — `maxUsedGb`, `minFreeGb` —
|
|
129
|
+
* converts through {@link gbToBytes} and nowhere else.
|
|
130
|
+
*/
|
|
131
|
+
var STORAGE_BYTES_PER_GB = 1024 ** 3;
|
|
132
|
+
/** GB → bytes, binary. Fractional GB is admitted and floored. */
|
|
133
|
+
function gbToBytes(gb) {
|
|
134
|
+
return Math.floor(gb * STORAGE_BYTES_PER_GB);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* How far a `drain` has got (D386) — the read a UI renders, and nothing more.
|
|
138
|
+
*
|
|
139
|
+
* `estimatedEmptyAtMs` is derived from the growth the ratchet has actually
|
|
140
|
+
* OBSERVED and is `null` when it has observed none. Never a fabricated date: a
|
|
141
|
+
* drain with no observed growth has no honest ETA, and inventing one is how an
|
|
142
|
+
* operator learns not to believe the screen.
|
|
143
|
+
*/
|
|
144
|
+
var StorageDrainProgressSchema = /* @__PURE__ */ z.object({
|
|
145
|
+
locationId: /* @__PURE__ */ z.string(),
|
|
146
|
+
startedAtMs: /* @__PURE__ */ z.number(),
|
|
147
|
+
startBytes: /* @__PURE__ */ z.number(),
|
|
148
|
+
bytesRemaining: /* @__PURE__ */ z.number(),
|
|
149
|
+
drained: /* @__PURE__ */ z.boolean(),
|
|
150
|
+
estimatedEmptyAtMs: /* @__PURE__ */ z.number().nullable()
|
|
151
|
+
});
|
|
152
|
+
/**
|
|
153
|
+
* Reference accepted by consumer-facing `api.storage.*` calls.
|
|
154
|
+
* Either:
|
|
155
|
+
* - a `StorageLocationType` (e.g. `'backups'`) → the sole location of that type
|
|
156
|
+
* (transitionally, the `<type>:default`-slugged row when several exist)
|
|
157
|
+
* - a fully-qualified id (e.g. `'backups:nas-01'`) → addresses a specific instance
|
|
158
|
+
*
|
|
159
|
+
* The orchestrator's `resolveRef(ref)` handles both cases.
|
|
160
|
+
*/
|
|
161
|
+
var StorageLocationRefSchema = /* @__PURE__ */ z.union([StorageLocationTypeSchema, /* @__PURE__ */ z.string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/)]);
|
|
162
|
+
//#endregion
|
|
163
|
+
export { gbToBytes as a, StorageLocationTypeSchema as i, StorageLocationRefSchema as n, isLocationEnabled as o, StorageLocationSchema as r, StorageDrainProgressSchema as t };
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
const require_storage_location_mode = require("./storage-location-mode-CS4sMzo-.js");
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
//#region ../types/dist/esm/interfaces/storage-location.mjs
|
|
4
|
+
/**
|
|
5
|
+
* `StorageLocationType` — an addon-declared id that identifies the *kind* of
|
|
6
|
+
* storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
|
|
7
|
+
* so the persisted record schema and the consumer-facing cap can both consume it
|
|
8
|
+
* without forming a circular import. The `storage` cap re-exports it
|
|
9
|
+
* verbatim for back-compat.
|
|
10
|
+
*
|
|
11
|
+
* This Zod schema is the **authoritative source** for `StorageLocationType`.
|
|
12
|
+
* The TS alias in `./storage.ts` re-exports `z.infer<typeof
|
|
13
|
+
* StorageLocationTypeSchema>` so the wire surface (cap) and the legacy
|
|
14
|
+
* `IStorageProvider` interface stay in lockstep.
|
|
15
|
+
*
|
|
16
|
+
* The type is now an **open string** (not a closed enum) — addons declare
|
|
17
|
+
* their own location kinds via `StorageLocationDeclaration.id`. The regex
|
|
18
|
+
* enforces a safe id format: lowercase-start, alphanumeric + hyphens.
|
|
19
|
+
*/
|
|
20
|
+
var StorageLocationTypeSchema = /* @__PURE__ */ zod.z.string().regex(/^[a-z][a-zA-Z0-9-]*$/);
|
|
21
|
+
/**
|
|
22
|
+
* Persisted record for a storage location instance. Operators can register
|
|
23
|
+
* multiple instances for multi-cardinality types (e.g. two `backups`
|
|
24
|
+
* locations with different `providerId`s). Cardinality is now declared per
|
|
25
|
+
* location via `StorageLocationDeclaration.cardinality` — the static
|
|
26
|
+
* `STORAGE_LOCATION_CARDINALITY` map has been removed.
|
|
27
|
+
*
|
|
28
|
+
* `id` is a stable namespaced string of the form `<type>:<slug>`.
|
|
29
|
+
* The seed names its first instance `<type>:default` — a NAME, not a flag.
|
|
30
|
+
* There is no default location any more (D383): `enabled` is the whole write
|
|
31
|
+
* model, and a bare type ref resolves to the sole location of the type, or —
|
|
32
|
+
* transitionally, only while legacy NULL-stamped rows exist — to the row whose
|
|
33
|
+
* slug is `default`.
|
|
34
|
+
*
|
|
35
|
+
* `isSystem` is a legacy persisted flag. Seed still creates the initial
|
|
36
|
+
* `<type>:default` locations; the flag is no longer a lock, a badge, or a
|
|
37
|
+
* prune selector. New writes leave it false. Deletion is gated on uniqueness
|
|
38
|
+
* / last-enabled, not on this bit.
|
|
39
|
+
*/
|
|
40
|
+
var StorageLocationSchema = /* @__PURE__ */ zod.z.object({
|
|
41
|
+
id: /* @__PURE__ */ zod.z.string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/),
|
|
42
|
+
type: /* @__PURE__ */ zod.z.string(),
|
|
43
|
+
displayName: /* @__PURE__ */ zod.z.string().min(1),
|
|
44
|
+
providerId: /* @__PURE__ */ zod.z.string().min(1),
|
|
45
|
+
config: /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.unknown()),
|
|
46
|
+
/**
|
|
47
|
+
* Cluster node this location physically lives on. REQUIRED for node-local
|
|
48
|
+
* providers (filesystem — the path exists on one node's disk), null/absent
|
|
49
|
+
* for node-agnostic providers (S3/SFTP/WebDAV, reachable from any node).
|
|
50
|
+
* `'hub'` is the hub node. Validated against the provider's `nodeLocal`
|
|
51
|
+
* flag at upsert time, not here (the schema is provider-agnostic).
|
|
52
|
+
*/
|
|
53
|
+
nodeId: /* @__PURE__ */ zod.z.string().optional(),
|
|
54
|
+
isSystem: /* @__PURE__ */ zod.z.boolean().default(false),
|
|
55
|
+
/**
|
|
56
|
+
* THE write switch, and the only one (D383). `enabled: true` means every
|
|
57
|
+
* consumer that chooses a write target for this type may write here, and all
|
|
58
|
+
* enabled locations of a type are used TOGETHER; `false` means read-only —
|
|
59
|
+
* still read, still played back, still age-swept, still drained, never
|
|
60
|
+
* written.
|
|
61
|
+
*
|
|
62
|
+
* OPTIONAL only for the wire: an upsert that omits it means "leave what is
|
|
63
|
+
* stored" on an update and "born inert unless it is the first location of its
|
|
64
|
+
* type" on a create. On a PERSISTED row absence is legacy and it means
|
|
65
|
+
* enabled — {@link isLocationEnabled} is the one place that says so, and the
|
|
66
|
+
* orchestrator stamps every flagless row `true` once at hydrate so absence
|
|
67
|
+
* stops existing rather than being re-derived on every read.
|
|
68
|
+
*/
|
|
69
|
+
enabled: /* @__PURE__ */ zod.z.boolean().optional(),
|
|
70
|
+
/**
|
|
71
|
+
* THE state of this location (D385), and the only authority on what may be
|
|
72
|
+
* written, read or evicted here. Interpreted in exactly one place —
|
|
73
|
+
* `storage-location-mode.ts` — which also folds the legacy
|
|
74
|
+
* `enabled` / `config.readOnly` pair into a mode so an old row is never
|
|
75
|
+
* ambiguous.
|
|
76
|
+
*
|
|
77
|
+
* OPTIONAL only for the wire and for rows written before D385: absence is
|
|
78
|
+
* resolved by `resolveLocationMode`, and the orchestrator stamps every
|
|
79
|
+
* unstamped row ONCE at hydrate so absence stops existing rather than being
|
|
80
|
+
* re-derived on every read. `enabled` survives one release as a DERIVED
|
|
81
|
+
* mirror (`mode === 'active'`); `withLocationMode` is the only writer of
|
|
82
|
+
* either, so the two cannot disagree.
|
|
83
|
+
*/
|
|
84
|
+
mode: /* @__PURE__ */ require_storage_location_mode.StorageLocationModeSchema.optional(),
|
|
85
|
+
/** COMPUTED at read time by the orchestrator (statfs of the backing volume
|
|
86
|
+
* for node-local locations it can reach) — never persisted, absent when the
|
|
87
|
+
* volume is remote/unreachable. The single capacity truth every UI reads. */
|
|
88
|
+
capacity: /* @__PURE__ */ zod.z.object({
|
|
89
|
+
totalBytes: /* @__PURE__ */ zod.z.number(),
|
|
90
|
+
availableBytes: /* @__PURE__ */ zod.z.number()
|
|
91
|
+
}).nullable().optional(),
|
|
92
|
+
/**
|
|
93
|
+
* How much of that volume CamStack ITSELF holds on this location (D388) —
|
|
94
|
+
* COMPUTED at read time from the `storage-occupancy` providers' own figures,
|
|
95
|
+
* never persisted, never a filesystem walk.
|
|
96
|
+
*
|
|
97
|
+
* **ABSENT MEANS UNKNOWN, never zero.** No provider has reported for this
|
|
98
|
+
* location yet — nobody stores here, the owning addon is down, or the first
|
|
99
|
+
* refresh has not completed. A UI must omit the segment rather than draw it
|
|
100
|
+
* at zero, which would claim we occupy nothing (D315). It is an OBJECT and
|
|
101
|
+
* not a bare number precisely so that a `?? 0` on the consuming side has to
|
|
102
|
+
* be spelled out loud instead of appearing by accident.
|
|
103
|
+
*
|
|
104
|
+
* `measuredAtMs` is the OLDEST contributing measurement, so it is honest
|
|
105
|
+
* about the whole figure rather than about its freshest part.
|
|
106
|
+
*/
|
|
107
|
+
owned: /* @__PURE__ */ zod.z.object({
|
|
108
|
+
bytes: /* @__PURE__ */ zod.z.number().int().nonnegative(),
|
|
109
|
+
measuredAtMs: /* @__PURE__ */ zod.z.number().int().nonnegative()
|
|
110
|
+
}).optional(),
|
|
111
|
+
createdAt: /* @__PURE__ */ zod.z.number(),
|
|
112
|
+
updatedAt: /* @__PURE__ */ zod.z.number()
|
|
113
|
+
});
|
|
114
|
+
function isLocationEnabled(location) {
|
|
115
|
+
return require_storage_location_mode.mayWriteToLocation({
|
|
116
|
+
...location,
|
|
117
|
+
config: location.config ?? {}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Bytes in one GB, for every storage figure an operator types.
|
|
122
|
+
*
|
|
123
|
+
* BINARY (1024³), everywhere. The repo had both: the orchestrator's
|
|
124
|
+
* `maxUsedGb` → bytes conversion used 1024³ while the recorder's placement
|
|
125
|
+
* headroom used 10⁹ for the SAME stored key, so a location with a cap set was
|
|
126
|
+
* silently 7.4% off depending on which side of the pipe asked. The persisted
|
|
127
|
+
* values were entered against the binary unit and the admin UI reads it, so
|
|
128
|
+
* that is the one that stays. Every GB knob — `maxUsedGb`, `minFreeGb` —
|
|
129
|
+
* converts through {@link gbToBytes} and nowhere else.
|
|
130
|
+
*/
|
|
131
|
+
var STORAGE_BYTES_PER_GB = 1024 ** 3;
|
|
132
|
+
/** GB → bytes, binary. Fractional GB is admitted and floored. */
|
|
133
|
+
function gbToBytes(gb) {
|
|
134
|
+
return Math.floor(gb * STORAGE_BYTES_PER_GB);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* How far a `drain` has got (D386) — the read a UI renders, and nothing more.
|
|
138
|
+
*
|
|
139
|
+
* `estimatedEmptyAtMs` is derived from the growth the ratchet has actually
|
|
140
|
+
* OBSERVED and is `null` when it has observed none. Never a fabricated date: a
|
|
141
|
+
* drain with no observed growth has no honest ETA, and inventing one is how an
|
|
142
|
+
* operator learns not to believe the screen.
|
|
143
|
+
*/
|
|
144
|
+
var StorageDrainProgressSchema = /* @__PURE__ */ zod.z.object({
|
|
145
|
+
locationId: /* @__PURE__ */ zod.z.string(),
|
|
146
|
+
startedAtMs: /* @__PURE__ */ zod.z.number(),
|
|
147
|
+
startBytes: /* @__PURE__ */ zod.z.number(),
|
|
148
|
+
bytesRemaining: /* @__PURE__ */ zod.z.number(),
|
|
149
|
+
drained: /* @__PURE__ */ zod.z.boolean(),
|
|
150
|
+
estimatedEmptyAtMs: /* @__PURE__ */ zod.z.number().nullable()
|
|
151
|
+
});
|
|
152
|
+
/**
|
|
153
|
+
* Reference accepted by consumer-facing `api.storage.*` calls.
|
|
154
|
+
* Either:
|
|
155
|
+
* - a `StorageLocationType` (e.g. `'backups'`) → the sole location of that type
|
|
156
|
+
* (transitionally, the `<type>:default`-slugged row when several exist)
|
|
157
|
+
* - a fully-qualified id (e.g. `'backups:nas-01'`) → addresses a specific instance
|
|
158
|
+
*
|
|
159
|
+
* The orchestrator's `resolveRef(ref)` handles both cases.
|
|
160
|
+
*/
|
|
161
|
+
var StorageLocationRefSchema = /* @__PURE__ */ zod.z.union([StorageLocationTypeSchema, /* @__PURE__ */ zod.z.string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/)]);
|
|
162
|
+
//#endregion
|
|
163
|
+
Object.defineProperty(exports, "StorageDrainProgressSchema", {
|
|
164
|
+
enumerable: true,
|
|
165
|
+
get: function() {
|
|
166
|
+
return StorageDrainProgressSchema;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
Object.defineProperty(exports, "StorageLocationRefSchema", {
|
|
170
|
+
enumerable: true,
|
|
171
|
+
get: function() {
|
|
172
|
+
return StorageLocationRefSchema;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
Object.defineProperty(exports, "StorageLocationSchema", {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
get: function() {
|
|
178
|
+
return StorageLocationSchema;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
Object.defineProperty(exports, "StorageLocationTypeSchema", {
|
|
182
|
+
enumerable: true,
|
|
183
|
+
get: function() {
|
|
184
|
+
return StorageLocationTypeSchema;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
Object.defineProperty(exports, "gbToBytes", {
|
|
188
|
+
enumerable: true,
|
|
189
|
+
get: function() {
|
|
190
|
+
return gbToBytes;
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
Object.defineProperty(exports, "isLocationEnabled", {
|
|
194
|
+
enumerable: true,
|
|
195
|
+
get: function() {
|
|
196
|
+
return isLocationEnabled;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region ../types/dist/esm/interfaces/storage-location-mode.mjs
|
|
3
|
+
/**
|
|
4
|
+
* The storage-location STATE MODEL (D385) — one typed state, one policy module.
|
|
5
|
+
*
|
|
6
|
+
* A location's state used to be split across two authorities: the typed
|
|
7
|
+
* `enabled` field (THE write switch since D383) and an untyped `config.readOnly`
|
|
8
|
+
* key. They did not mean the same thing — `enabled: false` was still evicted
|
|
9
|
+
* under disk pressure while `config.readOnly` was deliberately excluded — and
|
|
10
|
+
* neither name said which. Every consumer re-derived the difference, and the
|
|
11
|
+
* three questions that actually matter were answered in six places.
|
|
12
|
+
*
|
|
13
|
+
* This module is the ONLY place in the repo allowed to interpret the state. It
|
|
14
|
+
* answers three questions and nothing else:
|
|
15
|
+
*
|
|
16
|
+
* - may this location be WRITTEN to? {@link modeMayWrite}
|
|
17
|
+
* - may this location be READ? {@link modeMayRead}
|
|
18
|
+
* - what is its eviction policy? {@link evictionPolicyForMode}
|
|
19
|
+
*
|
|
20
|
+
* | mode | write | read | eviction |
|
|
21
|
+
* | ---------- | ----- | ---- | ------------------------------ |
|
|
22
|
+
* | `active` | yes | yes | `normal` (pressure + usage cap) |
|
|
23
|
+
* | `readonly` | no | yes | `never` |
|
|
24
|
+
* | `drain` | no | yes | `drain` (paced, until empty) |
|
|
25
|
+
* | `disabled` | no | no | `never` |
|
|
26
|
+
*
|
|
27
|
+
* `scripts/check-storage-location-mode-single-owner.ts` fails the build when
|
|
28
|
+
* anything outside this module reads `config['readOnly']` or compares `enabled`
|
|
29
|
+
* directly. A rule nothing checks has already been broken somewhere.
|
|
30
|
+
*/
|
|
31
|
+
var STORAGE_LOCATION_MODES = [
|
|
32
|
+
"active",
|
|
33
|
+
"readonly",
|
|
34
|
+
"drain",
|
|
35
|
+
"disabled"
|
|
36
|
+
];
|
|
37
|
+
/**
|
|
38
|
+
* The one typed state of a storage location. Authoritative Zod schema — the TS
|
|
39
|
+
* alias below is `z.infer<>` of it, never a second spelling.
|
|
40
|
+
*/
|
|
41
|
+
var StorageLocationModeSchema = /* @__PURE__ */ z.enum(STORAGE_LOCATION_MODES);
|
|
42
|
+
/**
|
|
43
|
+
* The legacy untyped drain key. Named ONCE, here, so the guard has exactly one
|
|
44
|
+
* sanctioned reader and the string never appears anywhere else.
|
|
45
|
+
*/
|
|
46
|
+
var LEGACY_READ_ONLY_CONFIG_KEY = "readOnly";
|
|
47
|
+
/** Is this mode a write target? Only `active` is. */
|
|
48
|
+
function modeMayWrite(mode) {
|
|
49
|
+
return mode === "active";
|
|
50
|
+
}
|
|
51
|
+
/** May this mode be read (playback, timeline, scrub, relocate source)? */
|
|
52
|
+
function modeMayRead(mode) {
|
|
53
|
+
return mode !== "disabled";
|
|
54
|
+
}
|
|
55
|
+
/** What eviction may do here. See {@link StorageEvictionPolicy}. */
|
|
56
|
+
function evictionPolicyForMode(mode) {
|
|
57
|
+
switch (mode) {
|
|
58
|
+
case "active": return "normal";
|
|
59
|
+
case "drain": return "drain";
|
|
60
|
+
case "readonly":
|
|
61
|
+
case "disabled": return "never";
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The mode a LEGACY row implies, or `null` when it implies nothing — the row is
|
|
66
|
+
* already stamped, or it carried neither flag.
|
|
67
|
+
*
|
|
68
|
+
* Both legacy flags fold to `readonly`, which is the CONSERVATIVE direction: a
|
|
69
|
+
* state change must never start deleting footage on its own, and it must never
|
|
70
|
+
* make footage that was still being served disappear. `enabled: false` used to
|
|
71
|
+
* leave the location evictable under pressure; folding it to `readonly` stops
|
|
72
|
+
* that, which is a strictly safer answer than the one it replaces.
|
|
73
|
+
*/
|
|
74
|
+
function legacyModeOf(location) {
|
|
75
|
+
if (location.mode !== void 0) return null;
|
|
76
|
+
if (location.config["readOnly"] === true) return "readonly";
|
|
77
|
+
if (location.enabled === false) return "readonly";
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The state of a location, stamped or folded. THE one interpretation: a row
|
|
82
|
+
* that predates D385 is never ambiguous, and a stamped `mode` always wins over
|
|
83
|
+
* whatever the legacy pair still says.
|
|
84
|
+
*/
|
|
85
|
+
function resolveLocationMode(location) {
|
|
86
|
+
return (isStorageLocationMode(location.mode) ? location.mode : void 0) ?? legacyModeOf(location) ?? "active";
|
|
87
|
+
}
|
|
88
|
+
/** Is this one of the four states? The stamped value crosses a wire, and a
|
|
89
|
+
* value nobody defined must not be rendered as if it were a state. */
|
|
90
|
+
function isStorageLocationMode(value) {
|
|
91
|
+
return STORAGE_LOCATION_MODES.some((mode) => mode === value);
|
|
92
|
+
}
|
|
93
|
+
/** May this location be written to? */
|
|
94
|
+
function mayWriteToLocation(location) {
|
|
95
|
+
return modeMayWrite(resolveLocationMode(location));
|
|
96
|
+
}
|
|
97
|
+
/** May this location be read? A `disabled` one may not — and that is an
|
|
98
|
+
* operator CHOICE, which callers must report as unavailable rather than as an
|
|
99
|
+
* unknown-location fault. */
|
|
100
|
+
function mayReadLocation(location) {
|
|
101
|
+
return modeMayRead(resolveLocationMode(location));
|
|
102
|
+
}
|
|
103
|
+
/** What eviction may do to this location. */
|
|
104
|
+
function evictionPolicyOfLocation(location) {
|
|
105
|
+
return evictionPolicyForMode(resolveLocationMode(location));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The config blob with the retired drain key removed. Returns the SAME object
|
|
109
|
+
* when there was nothing to strip, so a caller can tell "changed" from
|
|
110
|
+
* "unchanged" by identity and skip a pointless persist.
|
|
111
|
+
*/
|
|
112
|
+
function strippedOfLegacyReadOnly(config) {
|
|
113
|
+
if (!("readOnly" in config)) return config;
|
|
114
|
+
const next = { ...config };
|
|
115
|
+
delete next[LEGACY_READ_ONLY_CONFIG_KEY];
|
|
116
|
+
return next;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Set a location's mode, and with it everything that must agree with it.
|
|
120
|
+
*
|
|
121
|
+
* `enabled` stays readable for one release as a DERIVED value (`mode ===
|
|
122
|
+
* 'active'`) so consumers that have not moved yet keep working, and the legacy
|
|
123
|
+
* `config.readOnly` key is DELETED. This function is the only way to write
|
|
124
|
+
* either, which is what makes it impossible for the two to disagree.
|
|
125
|
+
*
|
|
126
|
+
* Returns a new object — the input is never mutated.
|
|
127
|
+
*/
|
|
128
|
+
function withLocationMode(location, mode) {
|
|
129
|
+
return {
|
|
130
|
+
...location,
|
|
131
|
+
mode,
|
|
132
|
+
enabled: modeMayWrite(mode),
|
|
133
|
+
config: strippedOfLegacyReadOnly(location.config)
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/** Is the row switch of a location ON? Only a location that is written to reads as on. */
|
|
137
|
+
function switchStateOfMode(mode) {
|
|
138
|
+
return modeMayWrite(mode);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The move a row switch makes. The switch is a two-state view of a four-state mode, so it only
|
|
142
|
+
* crosses the active/not-active line and never cancels a retirement:
|
|
143
|
+
*
|
|
144
|
+
* - on: `readonly` and `disabled` become `active`; `active` stays; a `drain` is REFUSED
|
|
145
|
+
* (turning it on would silently cancel the drain; the mode select ends it on purpose).
|
|
146
|
+
* - off: `active` becomes `readonly`; `readonly`, `disabled` and `drain` already are not
|
|
147
|
+
* written to and stay as they are.
|
|
148
|
+
*/
|
|
149
|
+
function modeForSwitch(on, current) {
|
|
150
|
+
if (on) {
|
|
151
|
+
if (current === "active") return { kind: "keep" };
|
|
152
|
+
if (current === "drain") return {
|
|
153
|
+
kind: "refuse",
|
|
154
|
+
reason: "the location is draining; end the drain by changing its mode, not with the switch"
|
|
155
|
+
};
|
|
156
|
+
return {
|
|
157
|
+
kind: "set",
|
|
158
|
+
mode: "active"
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
return current === "active" ? {
|
|
162
|
+
kind: "set",
|
|
163
|
+
mode: "readonly"
|
|
164
|
+
} : { kind: "keep" };
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
export { mayReadLocation as a, modeMayWrite as c, withLocationMode as d, legacyModeOf as i, resolveLocationMode as l, StorageLocationModeSchema as n, mayWriteToLocation as o, evictionPolicyOfLocation as r, modeForSwitch as s, STORAGE_LOCATION_MODES as t, switchStateOfMode as u };
|