@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,143 @@
|
|
|
1
|
+
let zod = require("zod");
|
|
2
|
+
//#region ../types/dist/esm/units/quantity.mjs
|
|
3
|
+
var READING_QUANTITIES = [
|
|
4
|
+
"temperature",
|
|
5
|
+
"pressure",
|
|
6
|
+
"speed",
|
|
7
|
+
"precipitation",
|
|
8
|
+
"precipitation-rate",
|
|
9
|
+
"length",
|
|
10
|
+
"area",
|
|
11
|
+
"illuminance",
|
|
12
|
+
"irradiance",
|
|
13
|
+
"power",
|
|
14
|
+
"energy",
|
|
15
|
+
"voltage",
|
|
16
|
+
"current",
|
|
17
|
+
"apparent-power",
|
|
18
|
+
"humidity",
|
|
19
|
+
"percentage",
|
|
20
|
+
"concentration-volume",
|
|
21
|
+
"concentration-mass",
|
|
22
|
+
"concentration-ppb",
|
|
23
|
+
"volume",
|
|
24
|
+
"duration",
|
|
25
|
+
"duration-ms",
|
|
26
|
+
"information",
|
|
27
|
+
"sound-level",
|
|
28
|
+
"signal-level",
|
|
29
|
+
"signal-ratio",
|
|
30
|
+
"frequency",
|
|
31
|
+
"colour-temperature",
|
|
32
|
+
"angle",
|
|
33
|
+
"bitrate",
|
|
34
|
+
"rate",
|
|
35
|
+
"mass",
|
|
36
|
+
"index",
|
|
37
|
+
"ratio",
|
|
38
|
+
"count",
|
|
39
|
+
"none",
|
|
40
|
+
"device"
|
|
41
|
+
];
|
|
42
|
+
var ReadingQuantitySchema = /* @__PURE__ */ zod.z.enum(READING_QUANTITIES);
|
|
43
|
+
var QUANTITY_SET = /* @__PURE__ */ new Set(READING_QUANTITIES);
|
|
44
|
+
function isReadingQuantity(value) {
|
|
45
|
+
return typeof value === "string" && QUANTITY_SET.has(value);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Stored unit symbol for a quantity. `none` means the number is dimensionless
|
|
49
|
+
* (or an index / ratio / count). `device` means the cap has no single unit.
|
|
50
|
+
*/
|
|
51
|
+
var QUANTITY_BASE = {
|
|
52
|
+
temperature: "°C",
|
|
53
|
+
pressure: "hPa",
|
|
54
|
+
speed: "m/s",
|
|
55
|
+
precipitation: "mm",
|
|
56
|
+
"precipitation-rate": "mm/h",
|
|
57
|
+
length: "m",
|
|
58
|
+
area: "m²",
|
|
59
|
+
illuminance: "lx",
|
|
60
|
+
irradiance: "W/m²",
|
|
61
|
+
power: "W",
|
|
62
|
+
energy: "kWh",
|
|
63
|
+
voltage: "V",
|
|
64
|
+
current: "A",
|
|
65
|
+
"apparent-power": "VA",
|
|
66
|
+
humidity: "%",
|
|
67
|
+
percentage: "%",
|
|
68
|
+
"concentration-volume": "ppm",
|
|
69
|
+
"concentration-mass": "µg/m³",
|
|
70
|
+
"concentration-ppb": "ppb",
|
|
71
|
+
volume: "L",
|
|
72
|
+
duration: "s",
|
|
73
|
+
"duration-ms": "ms",
|
|
74
|
+
information: "B",
|
|
75
|
+
"sound-level": "dBFS",
|
|
76
|
+
"signal-level": "dBm",
|
|
77
|
+
"signal-ratio": "dB",
|
|
78
|
+
frequency: "Hz",
|
|
79
|
+
"colour-temperature": "mired",
|
|
80
|
+
angle: "°",
|
|
81
|
+
bitrate: "kbps",
|
|
82
|
+
rate: "fps",
|
|
83
|
+
mass: "kg",
|
|
84
|
+
index: "none",
|
|
85
|
+
ratio: "none",
|
|
86
|
+
count: "none",
|
|
87
|
+
none: "none",
|
|
88
|
+
device: "device"
|
|
89
|
+
};
|
|
90
|
+
/** The stored unit, or `undefined` when the quantity has no unit symbol. */
|
|
91
|
+
function baseUnitOf(quantity) {
|
|
92
|
+
const symbol = QUANTITY_BASE[quantity];
|
|
93
|
+
if (symbol === "none" || symbol === "device") return void 0;
|
|
94
|
+
return symbol;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* History catalog label for a quantity. Index and ratio keep the labels the
|
|
98
|
+
* series already used (`count`, `ratio`). A polymorphic reading has no
|
|
99
|
+
* single label.
|
|
100
|
+
*/
|
|
101
|
+
function historyUnitFor(quantity) {
|
|
102
|
+
if (quantity === "index" || quantity === "count") return "count";
|
|
103
|
+
if (quantity === "ratio") return "ratio";
|
|
104
|
+
return baseUnitOf(quantity);
|
|
105
|
+
}
|
|
106
|
+
function readingMeta(quantity, extras) {
|
|
107
|
+
return {
|
|
108
|
+
quantity,
|
|
109
|
+
...extras?.precision !== void 0 ? { precision: extras.precision } : {},
|
|
110
|
+
...extras?.label !== void 0 ? { label: extras.label } : {}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
114
|
+
Object.defineProperty(exports, "ReadingQuantitySchema", {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function() {
|
|
117
|
+
return ReadingQuantitySchema;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
Object.defineProperty(exports, "baseUnitOf", {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function() {
|
|
123
|
+
return baseUnitOf;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
Object.defineProperty(exports, "historyUnitFor", {
|
|
127
|
+
enumerable: true,
|
|
128
|
+
get: function() {
|
|
129
|
+
return historyUnitFor;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
Object.defineProperty(exports, "isReadingQuantity", {
|
|
133
|
+
enumerable: true,
|
|
134
|
+
get: function() {
|
|
135
|
+
return isReadingQuantity;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
Object.defineProperty(exports, "readingMeta", {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function() {
|
|
141
|
+
return readingMeta;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
let zod = require("zod");
|
|
2
|
+
//#region ../types/dist/esm/capabilities/raw-secret-migration.mjs
|
|
3
|
+
/**
|
|
4
|
+
* The report of a one-shot "move this owner's plaintext secrets into the
|
|
5
|
+
* keychain" run (D878). COUNTS only - never a value, never a ref.
|
|
6
|
+
*
|
|
7
|
+
* The owner runs it on its own rows, through its own write path; an operator
|
|
8
|
+
* script (`scripts/hub/migrate-raw-secrets.ts`) calls the owner's cap method.
|
|
9
|
+
* Dry run (`apply: false`) reports what WOULD move and changes nothing.
|
|
10
|
+
*/
|
|
11
|
+
var RawSecretMigrationInputSchema = /* @__PURE__ */ zod.z.object({
|
|
12
|
+
/** `false` (the default of the script) = report only. */
|
|
13
|
+
apply: /* @__PURE__ */ zod.z.boolean() });
|
|
14
|
+
var RawSecretMigrationReportSchema = /* @__PURE__ */ zod.z.object({
|
|
15
|
+
apply: /* @__PURE__ */ zod.z.boolean(),
|
|
16
|
+
/** Rows that can carry a secret (a profile, an enrolment). */
|
|
17
|
+
rows: /* @__PURE__ */ zod.z.number().int(),
|
|
18
|
+
/** Rows whose secret was plaintext when the run started. */
|
|
19
|
+
raw: /* @__PURE__ */ zod.z.number().int(),
|
|
20
|
+
/** Rows that already held a keychain marker when the run started. */
|
|
21
|
+
markers: /* @__PURE__ */ zod.z.number().int(),
|
|
22
|
+
/** Plaintext rows moved by THIS run (always 0 on a dry run). */
|
|
23
|
+
migrated: /* @__PURE__ */ zod.z.number().int(),
|
|
24
|
+
/** Plaintext rows left in place because the move or its read-back failed. */
|
|
25
|
+
failed: /* @__PURE__ */ zod.z.number().int(),
|
|
26
|
+
/** After the run: rows still holding plaintext. */
|
|
27
|
+
remainingRaw: /* @__PURE__ */ zod.z.number().int(),
|
|
28
|
+
/** After the run: markers the keychain could not resolve right now. */
|
|
29
|
+
unresolvedMarkers: /* @__PURE__ */ zod.z.number().int(),
|
|
30
|
+
/**
|
|
31
|
+
* A second, redundant copy of the secrets' rows that the run found (and, on
|
|
32
|
+
* `apply`, deleted after verifying the first). Owners with a single copy omit it.
|
|
33
|
+
*/
|
|
34
|
+
redundantCopies: /* @__PURE__ */ zod.z.number().int().optional(),
|
|
35
|
+
/** True when nothing is raw and every marker resolves. */
|
|
36
|
+
verified: /* @__PURE__ */ zod.z.boolean()
|
|
37
|
+
});
|
|
38
|
+
//#endregion
|
|
39
|
+
Object.defineProperty(exports, "RawSecretMigrationInputSchema", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function() {
|
|
42
|
+
return RawSecretMigrationInputSchema;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(exports, "RawSecretMigrationReportSchema", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function() {
|
|
48
|
+
return RawSecretMigrationReportSchema;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region ../types/dist/esm/capabilities/raw-secret-migration.mjs
|
|
3
|
+
/**
|
|
4
|
+
* The report of a one-shot "move this owner's plaintext secrets into the
|
|
5
|
+
* keychain" run (D878). COUNTS only - never a value, never a ref.
|
|
6
|
+
*
|
|
7
|
+
* The owner runs it on its own rows, through its own write path; an operator
|
|
8
|
+
* script (`scripts/hub/migrate-raw-secrets.ts`) calls the owner's cap method.
|
|
9
|
+
* Dry run (`apply: false`) reports what WOULD move and changes nothing.
|
|
10
|
+
*/
|
|
11
|
+
var RawSecretMigrationInputSchema = /* @__PURE__ */ z.object({
|
|
12
|
+
/** `false` (the default of the script) = report only. */
|
|
13
|
+
apply: /* @__PURE__ */ z.boolean() });
|
|
14
|
+
var RawSecretMigrationReportSchema = /* @__PURE__ */ z.object({
|
|
15
|
+
apply: /* @__PURE__ */ z.boolean(),
|
|
16
|
+
/** Rows that can carry a secret (a profile, an enrolment). */
|
|
17
|
+
rows: /* @__PURE__ */ z.number().int(),
|
|
18
|
+
/** Rows whose secret was plaintext when the run started. */
|
|
19
|
+
raw: /* @__PURE__ */ z.number().int(),
|
|
20
|
+
/** Rows that already held a keychain marker when the run started. */
|
|
21
|
+
markers: /* @__PURE__ */ z.number().int(),
|
|
22
|
+
/** Plaintext rows moved by THIS run (always 0 on a dry run). */
|
|
23
|
+
migrated: /* @__PURE__ */ z.number().int(),
|
|
24
|
+
/** Plaintext rows left in place because the move or its read-back failed. */
|
|
25
|
+
failed: /* @__PURE__ */ z.number().int(),
|
|
26
|
+
/** After the run: rows still holding plaintext. */
|
|
27
|
+
remainingRaw: /* @__PURE__ */ z.number().int(),
|
|
28
|
+
/** After the run: markers the keychain could not resolve right now. */
|
|
29
|
+
unresolvedMarkers: /* @__PURE__ */ z.number().int(),
|
|
30
|
+
/**
|
|
31
|
+
* A second, redundant copy of the secrets' rows that the run found (and, on
|
|
32
|
+
* `apply`, deleted after verifying the first). Owners with a single copy omit it.
|
|
33
|
+
*/
|
|
34
|
+
redundantCopies: /* @__PURE__ */ z.number().int().optional(),
|
|
35
|
+
/** True when nothing is raw and every marker resolves. */
|
|
36
|
+
verified: /* @__PURE__ */ z.boolean()
|
|
37
|
+
});
|
|
38
|
+
//#endregion
|
|
39
|
+
export { RawSecretMigrationReportSchema as n, RawSecretMigrationInputSchema as t };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { c as method } from "./capability-definition-C2rJdVeX.mjs";
|
|
2
|
+
import { r as RecordKindNameSchema } from "./record-kind-ub6NXqfh.mjs";
|
|
3
|
+
import { t as NOT_A_DEVICE } from "./system-reasons-CYj4qwyS.mjs";
|
|
4
|
+
import { n as RecordIdSchema, t as RecordBodySchema } from "./records.cap-CwLT2ByG.mjs";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
//#region ../types/dist/esm/capabilities/record-entries.cap.mjs
|
|
7
|
+
/**
|
|
8
|
+
* record-entries - the ONE admin surface for every list of user-created entries
|
|
9
|
+
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
10
|
+
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
11
|
+
*
|
|
12
|
+
* The UI is generic. `listEntryKinds` hands it, per kind, the JSON Schema of
|
|
13
|
+
* the entry body with `secret: true` on every credential field, so a password
|
|
14
|
+
* field is derived from the schema and never from a name. `putEntry` takes the
|
|
15
|
+
* redaction token for an untouched secret (the stored value is kept), a string
|
|
16
|
+
* for a new one, and the clear instruction to remove one. A read never carries
|
|
17
|
+
* a secret value, and a locked keychain refuses the write with
|
|
18
|
+
* `records/secret-unavailable` instead of storing plaintext.
|
|
19
|
+
*
|
|
20
|
+
* Hub-only, served in-process (it acts for each entry's owner on the keychain).
|
|
21
|
+
*/
|
|
22
|
+
var EntryKindInfoSchema = /* @__PURE__ */ z.object({
|
|
23
|
+
owner: /* @__PURE__ */ z.string(),
|
|
24
|
+
kind: RecordKindNameSchema,
|
|
25
|
+
title: /* @__PURE__ */ z.string(),
|
|
26
|
+
nameField: /* @__PURE__ */ z.string(),
|
|
27
|
+
/** JSON Schema of the body; `secret: true` marks a password field. */
|
|
28
|
+
fields: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()),
|
|
29
|
+
secretPaths: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()),
|
|
30
|
+
rows: /* @__PURE__ */ z.number().int().nonnegative()
|
|
31
|
+
});
|
|
32
|
+
var EntryViewSchema = /* @__PURE__ */ z.object({
|
|
33
|
+
id: RecordIdSchema,
|
|
34
|
+
name: /* @__PURE__ */ z.string(),
|
|
35
|
+
rev: /* @__PURE__ */ z.number().int(),
|
|
36
|
+
updatedAt: /* @__PURE__ */ z.number(),
|
|
37
|
+
/** Secret fields hold the redaction token. */
|
|
38
|
+
data: RecordBodySchema
|
|
39
|
+
});
|
|
40
|
+
var EntryAddress = {
|
|
41
|
+
owner: /* @__PURE__ */ z.string().min(1),
|
|
42
|
+
kind: RecordKindNameSchema
|
|
43
|
+
};
|
|
44
|
+
var recordEntriesCapability = {
|
|
45
|
+
name: "record-entries",
|
|
46
|
+
scope: "system",
|
|
47
|
+
mode: "singleton",
|
|
48
|
+
methods: {
|
|
49
|
+
listEntryKinds: /* @__PURE__ */ method(/* @__PURE__ */ z.object({}), /* @__PURE__ */ z.object({ kinds: /* @__PURE__ */ z.array(EntryKindInfoSchema) }), { auth: "admin" }),
|
|
50
|
+
listEntries: /* @__PURE__ */ method(/* @__PURE__ */ z.object({ ...EntryAddress }), /* @__PURE__ */ z.object({ entries: /* @__PURE__ */ z.array(EntryViewSchema) }), { auth: "admin" }),
|
|
51
|
+
/** Create (no `id`: one is generated) or edit. `ifRev` guards an edit against a concurrent one. */
|
|
52
|
+
putEntry: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
53
|
+
...EntryAddress,
|
|
54
|
+
id: /* @__PURE__ */ RecordIdSchema.optional(),
|
|
55
|
+
data: RecordBodySchema,
|
|
56
|
+
ifRev: /* @__PURE__ */ z.number().int().min(1).optional()
|
|
57
|
+
}), /* @__PURE__ */ z.object({
|
|
58
|
+
id: /* @__PURE__ */ z.string(),
|
|
59
|
+
rev: /* @__PURE__ */ z.number().int()
|
|
60
|
+
}), {
|
|
61
|
+
kind: "mutation",
|
|
62
|
+
auth: "admin"
|
|
63
|
+
}),
|
|
64
|
+
deleteEntry: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
65
|
+
...EntryAddress,
|
|
66
|
+
id: RecordIdSchema
|
|
67
|
+
}), /* @__PURE__ */ z.object({ deleted: /* @__PURE__ */ z.boolean() }), {
|
|
68
|
+
kind: "mutation",
|
|
69
|
+
auth: "admin"
|
|
70
|
+
})
|
|
71
|
+
},
|
|
72
|
+
vocabulary: { notOperatorFacing: NOT_A_DEVICE.INTERNAL }
|
|
73
|
+
};
|
|
74
|
+
//#endregion
|
|
75
|
+
export { recordEntriesCapability as t };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const require_capability_definition = require("./capability-definition-HCmTem8c.js");
|
|
2
|
+
const require_record_kind = require("./record-kind-DoBfYHCs.js");
|
|
3
|
+
const require_system_reasons = require("./system-reasons-Be_k1W8g.js");
|
|
4
|
+
const require_records_cap = require("./records.cap-ClcWV64i.js");
|
|
5
|
+
let zod = require("zod");
|
|
6
|
+
//#region ../types/dist/esm/capabilities/record-entries.cap.mjs
|
|
7
|
+
/**
|
|
8
|
+
* record-entries - the ONE admin surface for every list of user-created entries
|
|
9
|
+
* (D881): notification targets, brokers, LLM profiles, anything an addon
|
|
10
|
+
* declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
|
|
11
|
+
*
|
|
12
|
+
* The UI is generic. `listEntryKinds` hands it, per kind, the JSON Schema of
|
|
13
|
+
* the entry body with `secret: true` on every credential field, so a password
|
|
14
|
+
* field is derived from the schema and never from a name. `putEntry` takes the
|
|
15
|
+
* redaction token for an untouched secret (the stored value is kept), a string
|
|
16
|
+
* for a new one, and the clear instruction to remove one. A read never carries
|
|
17
|
+
* a secret value, and a locked keychain refuses the write with
|
|
18
|
+
* `records/secret-unavailable` instead of storing plaintext.
|
|
19
|
+
*
|
|
20
|
+
* Hub-only, served in-process (it acts for each entry's owner on the keychain).
|
|
21
|
+
*/
|
|
22
|
+
var EntryKindInfoSchema = /* @__PURE__ */ zod.z.object({
|
|
23
|
+
owner: /* @__PURE__ */ zod.z.string(),
|
|
24
|
+
kind: require_record_kind.RecordKindNameSchema,
|
|
25
|
+
title: /* @__PURE__ */ zod.z.string(),
|
|
26
|
+
nameField: /* @__PURE__ */ zod.z.string(),
|
|
27
|
+
/** JSON Schema of the body; `secret: true` marks a password field. */
|
|
28
|
+
fields: /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.unknown()),
|
|
29
|
+
secretPaths: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.string()),
|
|
30
|
+
rows: /* @__PURE__ */ zod.z.number().int().nonnegative()
|
|
31
|
+
});
|
|
32
|
+
var EntryViewSchema = /* @__PURE__ */ zod.z.object({
|
|
33
|
+
id: require_records_cap.RecordIdSchema,
|
|
34
|
+
name: /* @__PURE__ */ zod.z.string(),
|
|
35
|
+
rev: /* @__PURE__ */ zod.z.number().int(),
|
|
36
|
+
updatedAt: /* @__PURE__ */ zod.z.number(),
|
|
37
|
+
/** Secret fields hold the redaction token. */
|
|
38
|
+
data: require_records_cap.RecordBodySchema
|
|
39
|
+
});
|
|
40
|
+
var EntryAddress = {
|
|
41
|
+
owner: /* @__PURE__ */ zod.z.string().min(1),
|
|
42
|
+
kind: require_record_kind.RecordKindNameSchema
|
|
43
|
+
};
|
|
44
|
+
var recordEntriesCapability = {
|
|
45
|
+
name: "record-entries",
|
|
46
|
+
scope: "system",
|
|
47
|
+
mode: "singleton",
|
|
48
|
+
methods: {
|
|
49
|
+
listEntryKinds: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({}), /* @__PURE__ */ zod.z.object({ kinds: /* @__PURE__ */ zod.z.array(EntryKindInfoSchema) }), { auth: "admin" }),
|
|
50
|
+
listEntries: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({ ...EntryAddress }), /* @__PURE__ */ zod.z.object({ entries: /* @__PURE__ */ zod.z.array(EntryViewSchema) }), { auth: "admin" }),
|
|
51
|
+
/** Create (no `id`: one is generated) or edit. `ifRev` guards an edit against a concurrent one. */
|
|
52
|
+
putEntry: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
|
|
53
|
+
...EntryAddress,
|
|
54
|
+
id: /* @__PURE__ */ require_records_cap.RecordIdSchema.optional(),
|
|
55
|
+
data: require_records_cap.RecordBodySchema,
|
|
56
|
+
ifRev: /* @__PURE__ */ zod.z.number().int().min(1).optional()
|
|
57
|
+
}), /* @__PURE__ */ zod.z.object({
|
|
58
|
+
id: /* @__PURE__ */ zod.z.string(),
|
|
59
|
+
rev: /* @__PURE__ */ zod.z.number().int()
|
|
60
|
+
}), {
|
|
61
|
+
kind: "mutation",
|
|
62
|
+
auth: "admin"
|
|
63
|
+
}),
|
|
64
|
+
deleteEntry: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({
|
|
65
|
+
...EntryAddress,
|
|
66
|
+
id: require_records_cap.RecordIdSchema
|
|
67
|
+
}), /* @__PURE__ */ zod.z.object({ deleted: /* @__PURE__ */ zod.z.boolean() }), {
|
|
68
|
+
kind: "mutation",
|
|
69
|
+
auth: "admin"
|
|
70
|
+
})
|
|
71
|
+
},
|
|
72
|
+
vocabulary: { notOperatorFacing: require_system_reasons.NOT_A_DEVICE.INTERNAL }
|
|
73
|
+
};
|
|
74
|
+
//#endregion
|
|
75
|
+
Object.defineProperty(exports, "recordEntriesCapability", {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function() {
|
|
78
|
+
return recordEntriesCapability;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
const require_scoped_settings = require("./scoped-settings-CylSSq_8.js");
|
|
2
|
+
const require_zod_secret = require("./zod-secret-DS7mj1bk.js");
|
|
3
|
+
let zod = require("zod");
|
|
4
|
+
//#region ../types/dist/esm/records/record-kind.mjs
|
|
5
|
+
/**
|
|
6
|
+
* Record kinds (D881): the declaration an addon makes of one kind of fact, the
|
|
7
|
+
* Zod row schema that describes it, and the helper that turns the two into the
|
|
8
|
+
* JSON the engine stores.
|
|
9
|
+
*
|
|
10
|
+
* A kind is declared ONCE, next to the code that owns it, and the engine's
|
|
11
|
+
* reconciler creates its indexes - nothing creates DDL at runtime from a write.
|
|
12
|
+
* Everything the generic machinery needs (secret fields, the entry descriptor)
|
|
13
|
+
* is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
|
|
14
|
+
* never a field name (D879).
|
|
15
|
+
*/
|
|
16
|
+
/** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
|
|
17
|
+
var RecordFieldPathSchema = /* @__PURE__ */ zod.z.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
|
|
18
|
+
var RecordIndexSchema = /* @__PURE__ */ zod.z.object({
|
|
19
|
+
name: /* @__PURE__ */ zod.z.string().regex(/^[a-z][a-z0-9_]{0,31}$/),
|
|
20
|
+
fields: /* @__PURE__ */ zod.z.array(RecordFieldPathSchema).min(1).max(4),
|
|
21
|
+
unique: /* @__PURE__ */ zod.z.boolean().optional()
|
|
22
|
+
}).strict();
|
|
23
|
+
var RecordRetentionSchema = /* @__PURE__ */ zod.z.union([
|
|
24
|
+
/* @__PURE__ */ zod.z.object({
|
|
25
|
+
ttlMs: /* @__PURE__ */ zod.z.number().int().positive(),
|
|
26
|
+
from: /* @__PURE__ */ zod.z.enum(["at", "write"])
|
|
27
|
+
}).strict(),
|
|
28
|
+
/* @__PURE__ */ zod.z.object({
|
|
29
|
+
maxRows: /* @__PURE__ */ zod.z.number().int().positive().optional(),
|
|
30
|
+
maxRowsPerDevice: /* @__PURE__ */ zod.z.number().int().positive().optional()
|
|
31
|
+
}).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
|
|
32
|
+
/* @__PURE__ */ zod.z.object({
|
|
33
|
+
owner: /* @__PURE__ */ zod.z.string().min(1),
|
|
34
|
+
reason: /* @__PURE__ */ zod.z.string().min(1)
|
|
35
|
+
}).strict(),
|
|
36
|
+
/* @__PURE__ */ zod.z.object({ none: /* @__PURE__ */ zod.z.string().min(1) }).strict()
|
|
37
|
+
]);
|
|
38
|
+
/** The descriptor a generic entries UI reads (D881 "generic entries"). */
|
|
39
|
+
var EntryDescriptorSchema = /* @__PURE__ */ zod.z.object({
|
|
40
|
+
title: /* @__PURE__ */ zod.z.string().min(1),
|
|
41
|
+
/** The record body field shown as the entry's name. */
|
|
42
|
+
nameField: /* @__PURE__ */ zod.z.string().min(1),
|
|
43
|
+
/** JSON Schema of the entry body; `secret: true` marks a password field. */
|
|
44
|
+
fields: /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.unknown())
|
|
45
|
+
}).strict();
|
|
46
|
+
var RecordKindDeclarationShape = /* @__PURE__ */ zod.z.object({
|
|
47
|
+
database: /* @__PURE__ */ zod.z.enum(require_scoped_settings.RECORD_DATABASES).default("settings"),
|
|
48
|
+
class: /* @__PURE__ */ zod.z.enum(require_scoped_settings.RECORD_CLASSES),
|
|
49
|
+
writeTrigger: /* @__PURE__ */ zod.z.string().min(1),
|
|
50
|
+
device: /* @__PURE__ */ zod.z.enum([
|
|
51
|
+
"required",
|
|
52
|
+
"optional",
|
|
53
|
+
"none"
|
|
54
|
+
]).default("none"),
|
|
55
|
+
at: /* @__PURE__ */ zod.z.enum(["required", "none"]).default("none"),
|
|
56
|
+
indexes: /* @__PURE__ */ zod.z.array(RecordIndexSchema).max(8).default([]),
|
|
57
|
+
retention: RecordRetentionSchema,
|
|
58
|
+
deviceRemoval: /* @__PURE__ */ zod.z.enum(["delete", "none"]).default("none"),
|
|
59
|
+
maxDataBytes: /* @__PURE__ */ zod.z.number().int().positive().max(require_scoped_settings.RECORD_MAX_DATA_BYTES).default(require_scoped_settings.RECORD_DEFAULT_MAX_DATA_BYTES),
|
|
60
|
+
/** Derived from the Zod schema; never written by hand. */
|
|
61
|
+
secretPaths: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.string().min(1)).default([]),
|
|
62
|
+
/** The id key of each array that carries a secret (`{ headers: 'name' }`). */
|
|
63
|
+
secretArrayKeys: /* @__PURE__ */ zod.z.record(/* @__PURE__ */ zod.z.string(), /* @__PURE__ */ zod.z.string()).default({}),
|
|
64
|
+
/** Kinds that must agree through `transact` sit in one file under one family name. */
|
|
65
|
+
transactFamily: /* @__PURE__ */ zod.z.string().min(1).optional(),
|
|
66
|
+
entry: /* @__PURE__ */ EntryDescriptorSchema.optional()
|
|
67
|
+
});
|
|
68
|
+
/** What crosses the wire from an addon: JSON only, no Zod. An unknown key is refused. */
|
|
69
|
+
var RecordKindDeclarationSchema = /* @__PURE__ */ RecordKindDeclarationShape.strict();
|
|
70
|
+
/**
|
|
71
|
+
* A declaration as the engine's catalog stored it: an unknown key is DROPPED,
|
|
72
|
+
* because a row written by an older engine must never stop records from
|
|
73
|
+
* starting. Only for rows read back from the catalog, never for input.
|
|
74
|
+
*/
|
|
75
|
+
var StoredRecordKindDeclarationSchema = RecordKindDeclarationShape;
|
|
76
|
+
/** The kind names: lower-case, dash separated, short enough for an index name. */
|
|
77
|
+
var RecordKindNameSchema = /* @__PURE__ */ zod.z.string().regex(/^[a-z][a-z0-9-]{0,47}$/);
|
|
78
|
+
/** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
|
|
79
|
+
function assertValidDeclaration(name, decl) {
|
|
80
|
+
const refuse = (why) => {
|
|
81
|
+
throw new require_scoped_settings.DeclarationRefusedError(`kind "${name}": ${why}`);
|
|
82
|
+
};
|
|
83
|
+
if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
|
|
84
|
+
const seen = /* @__PURE__ */ new Set();
|
|
85
|
+
for (const index of decl.indexes) {
|
|
86
|
+
if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
|
|
87
|
+
seen.add(index.name);
|
|
88
|
+
}
|
|
89
|
+
const { retention } = decl;
|
|
90
|
+
const hasSecrets = decl.secretPaths.length > 0;
|
|
91
|
+
if ("ttlMs" in retention) {
|
|
92
|
+
if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
|
|
93
|
+
if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
|
|
94
|
+
}
|
|
95
|
+
if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
|
|
96
|
+
if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
|
|
97
|
+
if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
|
|
98
|
+
if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
|
|
99
|
+
const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
|
|
100
|
+
if (decl.database === "settings" && bound > 5e4) refuse(`a row bound above ${require_scoped_settings.RECORD_SETTINGS_MAX_ROWS} belongs in database: "events" (a big delete on the settings thread stalls every configuration read)`);
|
|
101
|
+
}
|
|
102
|
+
if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
|
|
103
|
+
for (const path of decl.secretPaths) for (const prefix of require_scoped_settings.secretArrayPrefixes(path)) if (decl.secretArrayKeys[prefix] === void 0) refuse(`secret path "${path}" crosses the array "${prefix}": declare its id key in secretArrayKeys`);
|
|
104
|
+
}
|
|
105
|
+
function bodyFieldsOf(schema) {
|
|
106
|
+
return { ...zod.z.toJSONSchema(schema, {
|
|
107
|
+
unrepresentable: "any",
|
|
108
|
+
io: "input"
|
|
109
|
+
}) };
|
|
110
|
+
}
|
|
111
|
+
function isRecordLike(value) {
|
|
112
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
113
|
+
}
|
|
114
|
+
/** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
|
|
115
|
+
function hasNameField(json, field) {
|
|
116
|
+
const branches = json["oneOf"] ?? json["anyOf"];
|
|
117
|
+
if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
|
|
118
|
+
const properties = json["properties"];
|
|
119
|
+
return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Declare the kinds of a package. The keys are the kind names. The result is
|
|
123
|
+
* what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
|
|
124
|
+
* types its handle from.
|
|
125
|
+
*/
|
|
126
|
+
function defineRecordKinds(specs) {
|
|
127
|
+
const out = {};
|
|
128
|
+
for (const [name, spec] of Object.entries(specs)) {
|
|
129
|
+
const secretPaths = require_zod_secret.collectZodSecretPaths(spec.schema);
|
|
130
|
+
const nameField = spec.entry?.nameField ?? "name";
|
|
131
|
+
const fields = bodyFieldsOf(spec.schema);
|
|
132
|
+
if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new require_scoped_settings.DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
|
|
133
|
+
const parsed = RecordKindDeclarationSchema.parse({
|
|
134
|
+
database: spec.database,
|
|
135
|
+
class: spec.class,
|
|
136
|
+
writeTrigger: spec.writeTrigger,
|
|
137
|
+
device: spec.device,
|
|
138
|
+
at: spec.at,
|
|
139
|
+
indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
|
|
140
|
+
retention: spec.retention,
|
|
141
|
+
deviceRemoval: spec.deviceRemoval,
|
|
142
|
+
maxDataBytes: spec.maxDataBytes,
|
|
143
|
+
secretPaths: [...new Set([...secretPaths, ...spec.retiredSecretPaths ?? []])],
|
|
144
|
+
secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
|
|
145
|
+
transactFamily: spec.transactFamily,
|
|
146
|
+
entry: spec.entry === void 0 ? void 0 : {
|
|
147
|
+
title: spec.entry.title,
|
|
148
|
+
nameField,
|
|
149
|
+
fields
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
assertValidDeclaration(name, parsed);
|
|
153
|
+
out[name] = {
|
|
154
|
+
name,
|
|
155
|
+
schema: spec.schema,
|
|
156
|
+
declaration: parsed
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return out;
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
162
|
+
Object.defineProperty(exports, "RecordFieldPathSchema", {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function() {
|
|
165
|
+
return RecordFieldPathSchema;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(exports, "RecordKindDeclarationSchema", {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: function() {
|
|
171
|
+
return RecordKindDeclarationSchema;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
Object.defineProperty(exports, "RecordKindNameSchema", {
|
|
175
|
+
enumerable: true,
|
|
176
|
+
get: function() {
|
|
177
|
+
return RecordKindNameSchema;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
Object.defineProperty(exports, "RecordRetentionSchema", {
|
|
181
|
+
enumerable: true,
|
|
182
|
+
get: function() {
|
|
183
|
+
return RecordRetentionSchema;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
Object.defineProperty(exports, "StoredRecordKindDeclarationSchema", {
|
|
187
|
+
enumerable: true,
|
|
188
|
+
get: function() {
|
|
189
|
+
return StoredRecordKindDeclarationSchema;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
Object.defineProperty(exports, "assertValidDeclaration", {
|
|
193
|
+
enumerable: true,
|
|
194
|
+
get: function() {
|
|
195
|
+
return assertValidDeclaration;
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
Object.defineProperty(exports, "defineRecordKinds", {
|
|
199
|
+
enumerable: true,
|
|
200
|
+
get: function() {
|
|
201
|
+
return defineRecordKinds;
|
|
202
|
+
}
|
|
203
|
+
});
|