@camstack/server 1.2.928 → 1.2.930
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 +12 -0
- package/package.json +10 -10
- 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/actions-service.d.ts +18 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +8670 -386
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +8294 -11
- package/system/dist/builtins/core-blocks/tcp-connect.d.ts +3 -0
- package/system/dist/builtins/core-notifier/core-notifier.addon.js +250 -21
- package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +230 -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-BEUWn2s_.mjs +391 -0
- package/system/dist/composition-sources-acfR4hDq.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-BMeMCBrx.js +18733 -0
- package/system/dist/core-blocks.cap-BRPsLAij.mjs +18008 -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-BDh0LDhV.js +3428 -0
- package/system/dist/notification-rules.cap-DUmiMBQB.mjs +3357 -0
- package/system/dist/notification-targets-CRH-9Dy5.js +509 -0
- package/system/dist/notification-targets-DaNE-pIt.mjs +486 -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-BkMxoXpL.js +843 -0
- package/system/dist/prefix-walk-ifwg_ukx.mjs +790 -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-BJsL58Ih.js +34798 -0
- package/system/dist/rename-composition-block-OAtErZgq.mjs +33631 -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,52 @@
|
|
|
1
|
+
let zod = require("zod");
|
|
2
|
+
//#region ../types/dist/esm/system/server-name.mjs
|
|
3
|
+
/** C0 controls, DEL and the C1 range: none of them belongs in a name. */
|
|
4
|
+
function hasControlCharacter(value) {
|
|
5
|
+
for (const char of value) {
|
|
6
|
+
const code = char.codePointAt(0) ?? 0;
|
|
7
|
+
if (code <= 31 || code >= 127 && code <= 159) return true;
|
|
8
|
+
}
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
/** A name an operator may save: trimmed, 1-48 characters, no control characters. */
|
|
12
|
+
var ServerNameSchema = /* @__PURE__ */ zod.z.string().transform((value) => value.trim()).pipe(/* @__PURE__ */ zod.z.string().min(1, "The server name cannot be empty").max(48, `The server name is at most 48 characters`).refine((value) => !hasControlCharacter(value), { message: "The server name cannot contain control characters" }));
|
|
13
|
+
/** What every reader gets: the name to show, and whether the hub chose it itself. */
|
|
14
|
+
var ServerNameInfoSchema = /* @__PURE__ */ zod.z.object({
|
|
15
|
+
name: /* @__PURE__ */ zod.z.string(),
|
|
16
|
+
/** `true` when nobody named the hub: `name` is the machine hostname. */
|
|
17
|
+
isDefault: /* @__PURE__ */ zod.z.boolean()
|
|
18
|
+
});
|
|
19
|
+
/** What an unset name shows when the hostname says nothing about the hub. */
|
|
20
|
+
var SERVER_NAME_FALLBACK = "CamStack";
|
|
21
|
+
/** A container id: Docker's default hostname (12 hex chars, or the full 64). */
|
|
22
|
+
var CONTAINER_ID_PATTERN = /^(?:[0-9a-f]{12}|[0-9a-f]{64})$/;
|
|
23
|
+
/**
|
|
24
|
+
* The hostname without its domain (`nas.lan.example` becomes `nas`). A hostname
|
|
25
|
+
* that names nothing (empty, `localhost`, a container id) yields
|
|
26
|
+
* {@link SERVER_NAME_FALLBACK}.
|
|
27
|
+
*/
|
|
28
|
+
function shortHostname(hostname) {
|
|
29
|
+
const first = hostname.trim().split(".")[0] ?? "";
|
|
30
|
+
if (first.length === 0 || first.toLowerCase() === "localhost") return SERVER_NAME_FALLBACK;
|
|
31
|
+
if (CONTAINER_ID_PATTERN.test(first)) return SERVER_NAME_FALLBACK;
|
|
32
|
+
return first;
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
Object.defineProperty(exports, "ServerNameInfoSchema", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function() {
|
|
38
|
+
return ServerNameInfoSchema;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(exports, "ServerNameSchema", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function() {
|
|
44
|
+
return ServerNameSchema;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(exports, "shortHostname", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function() {
|
|
50
|
+
return shortHostname;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
import { c as method } from "./capability-definition-C2rJdVeX.mjs";
|
|
2
|
+
import { t as NOT_A_DEVICE } from "./system-reasons-CYj4qwyS.mjs";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region ../types/dist/esm/capabilities/settings-store.cap.mjs
|
|
5
|
+
/**
|
|
6
|
+
* Query filter for settings-store collections.
|
|
7
|
+
*/
|
|
8
|
+
var QueryFilterSchema = /* @__PURE__ */ z.object({
|
|
9
|
+
where: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()).optional(),
|
|
10
|
+
whereIn: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.array(/* @__PURE__ */ z.unknown())).optional(),
|
|
11
|
+
whereBetween: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.tuple([/* @__PURE__ */ z.unknown(), /* @__PURE__ */ z.unknown()])).optional(),
|
|
12
|
+
/** NULL-safe exclusion: matches rows whose field is NULL OR != the value. */
|
|
13
|
+
whereNot: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()).optional(),
|
|
14
|
+
/** NULL-safe exclusion of a SET — `whereNot` for more than one value. An
|
|
15
|
+
* empty list excludes nothing. See `QueryFilter.whereNotIn`. */
|
|
16
|
+
whereNotIn: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.array(/* @__PURE__ */ z.unknown())).optional(),
|
|
17
|
+
orderBy: /* @__PURE__ */ z.object({
|
|
18
|
+
field: /* @__PURE__ */ z.string(),
|
|
19
|
+
direction: /* @__PURE__ */ z.enum(["asc", "desc"])
|
|
20
|
+
}).optional(),
|
|
21
|
+
limit: /* @__PURE__ */ z.number().optional(),
|
|
22
|
+
offset: /* @__PURE__ */ z.number().optional()
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* The predicate half of a filter, for BULK MUTATIONS.
|
|
26
|
+
*
|
|
27
|
+
* Deliberately not `QueryFilterSchema`: `orderBy` / `limit` / `offset` have no
|
|
28
|
+
* meaning for a statement that rewrites a set, and accepting them would invite
|
|
29
|
+
* a caller to believe `limit` bounds the damage. Every field is optional here
|
|
30
|
+
* only so the shape stays composable — the implementation REJECTS a filter
|
|
31
|
+
* that compiles to no predicate, because that is the whole collection.
|
|
32
|
+
*/
|
|
33
|
+
var MutationFilterSchema = /* @__PURE__ */ z.object({
|
|
34
|
+
where: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()).optional(),
|
|
35
|
+
whereIn: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.array(/* @__PURE__ */ z.unknown())).optional(),
|
|
36
|
+
whereBetween: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.tuple([/* @__PURE__ */ z.unknown(), /* @__PURE__ */ z.unknown()])).optional(),
|
|
37
|
+
whereNot: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown()).optional(),
|
|
38
|
+
whereNotIn: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.array(/* @__PURE__ */ z.unknown())).optional()
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
|
|
42
|
+
*
|
|
43
|
+
* `as` names the slot in the result, so the SAME column may be asked twice with
|
|
44
|
+
* two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
|
|
45
|
+
* a `Record<column, op>` shape could not express.
|
|
46
|
+
*/
|
|
47
|
+
var AggregateFieldSchema = /* @__PURE__ */ z.object({
|
|
48
|
+
/** Result key. */
|
|
49
|
+
as: /* @__PURE__ */ z.string().min(1),
|
|
50
|
+
/** Column to aggregate. Must be a real column of a declared collection. */
|
|
51
|
+
field: /* @__PURE__ */ z.string().min(1),
|
|
52
|
+
op: /* @__PURE__ */ z.enum([
|
|
53
|
+
"sum",
|
|
54
|
+
"min",
|
|
55
|
+
"max"
|
|
56
|
+
])
|
|
57
|
+
});
|
|
58
|
+
/**
|
|
59
|
+
* `COUNT(*)` plus one number per requested field.
|
|
60
|
+
*
|
|
61
|
+
* `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
|
|
62
|
+
* that really is 0 are different facts, and an accounting caller that renders
|
|
63
|
+
* "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
|
|
64
|
+
*/
|
|
65
|
+
var AggregateResultSchema = /* @__PURE__ */ z.object({
|
|
66
|
+
count: /* @__PURE__ */ z.number().int(),
|
|
67
|
+
values: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.number().nullable())
|
|
68
|
+
});
|
|
69
|
+
/** A single stored record: `{ id, data }`. */
|
|
70
|
+
var SettingsRecordSchema = /* @__PURE__ */ z.object({
|
|
71
|
+
id: /* @__PURE__ */ z.string(),
|
|
72
|
+
data: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown())
|
|
73
|
+
});
|
|
74
|
+
/**
|
|
75
|
+
* One record of a BULK insert — {@link SettingsRecordSchema} with the id made
|
|
76
|
+
* optional.
|
|
77
|
+
*
|
|
78
|
+
* A separate schema rather than loosening the shared one: every other method
|
|
79
|
+
* on this cap addresses a row BY its id, and making that field optional
|
|
80
|
+
* everywhere would turn a forgotten key into a silently generated one on
|
|
81
|
+
* `update` and `delete` as well.
|
|
82
|
+
*/
|
|
83
|
+
var BulkRecordSchema = /* @__PURE__ */ z.object({
|
|
84
|
+
id: /* @__PURE__ */ z.string().optional(),
|
|
85
|
+
data: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown())
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* The database FILES one `sqlite-settings` engine process owns (D851).
|
|
89
|
+
* Closed on purpose: a file is a thing the engine opens, backs up and gives a
|
|
90
|
+
* serving thread, so a new one is a code change, never a string a caller
|
|
91
|
+
* invents. `settings` is `camstack.db` and the default for every collection
|
|
92
|
+
* that names no file.
|
|
93
|
+
*/
|
|
94
|
+
var DataStoreDatabaseSchema = /* @__PURE__ */ z.enum([
|
|
95
|
+
"settings",
|
|
96
|
+
"events",
|
|
97
|
+
"history"
|
|
98
|
+
]);
|
|
99
|
+
/** Every database file, in a stable order (settings first). */
|
|
100
|
+
var DATA_STORE_DATABASES = DataStoreDatabaseSchema.options;
|
|
101
|
+
/**
|
|
102
|
+
* One write inside a {@link settingsStoreCapability.methods.transact} call.
|
|
103
|
+
* The three that a "replace this set, bump that revision" write needs, plus
|
|
104
|
+
* the batched upsert a rollup writer needs.
|
|
105
|
+
*/
|
|
106
|
+
var TransactOpSchema = /* @__PURE__ */ z.discriminatedUnion("op", [
|
|
107
|
+
/* @__PURE__ */ z.object({
|
|
108
|
+
op: /* @__PURE__ */ z.literal("deleteWhere"),
|
|
109
|
+
collection: /* @__PURE__ */ z.string(),
|
|
110
|
+
filter: MutationFilterSchema
|
|
111
|
+
}),
|
|
112
|
+
/* @__PURE__ */ z.object({
|
|
113
|
+
op: /* @__PURE__ */ z.literal("insertMany"),
|
|
114
|
+
collection: /* @__PURE__ */ z.string(),
|
|
115
|
+
records: /* @__PURE__ */ z.array(BulkRecordSchema).readonly()
|
|
116
|
+
}),
|
|
117
|
+
/* @__PURE__ */ z.object({
|
|
118
|
+
op: /* @__PURE__ */ z.literal("update"),
|
|
119
|
+
collection: /* @__PURE__ */ z.string(),
|
|
120
|
+
id: /* @__PURE__ */ z.string(),
|
|
121
|
+
data: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown())
|
|
122
|
+
}),
|
|
123
|
+
/* @__PURE__ */ z.object({
|
|
124
|
+
op: /* @__PURE__ */ z.literal("upsertMany"),
|
|
125
|
+
collection: /* @__PURE__ */ z.string(),
|
|
126
|
+
conflict: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).readonly(),
|
|
127
|
+
records: /* @__PURE__ */ z.array(BulkRecordSchema).readonly()
|
|
128
|
+
})
|
|
129
|
+
]);
|
|
130
|
+
/**
|
|
131
|
+
* The precondition of a transaction: the row `key` of `collection` must hold
|
|
132
|
+
* `equals` in `column`, read INSIDE the transaction.
|
|
133
|
+
*/
|
|
134
|
+
var TransactGuardSchema = /* @__PURE__ */ z.object({
|
|
135
|
+
collection: /* @__PURE__ */ z.string(),
|
|
136
|
+
key: /* @__PURE__ */ z.string(),
|
|
137
|
+
column: /* @__PURE__ */ z.string(),
|
|
138
|
+
equals: /* @__PURE__ */ z.unknown()
|
|
139
|
+
});
|
|
140
|
+
/**
|
|
141
|
+
* Column declaration for a structured (SQL-backed) collection.
|
|
142
|
+
*
|
|
143
|
+
* Logical types — the backend translates each to the matching SQLite
|
|
144
|
+
* storage class and handles per-type marshaling:
|
|
145
|
+
* - `TEXT` / `INTEGER` / `REAL` — native SQLite types, pass-through
|
|
146
|
+
* - `JSON` — TEXT under the hood; serialised on write, parsed on read
|
|
147
|
+
* - `BOOLEAN` — INTEGER 0/1 under the hood; coerced both directions
|
|
148
|
+
*/
|
|
149
|
+
var CollectionColumnSchema = /* @__PURE__ */ z.object({
|
|
150
|
+
name: /* @__PURE__ */ z.string(),
|
|
151
|
+
type: /* @__PURE__ */ z.enum([
|
|
152
|
+
"TEXT",
|
|
153
|
+
"INTEGER",
|
|
154
|
+
"REAL",
|
|
155
|
+
"JSON",
|
|
156
|
+
"BOOLEAN"
|
|
157
|
+
]),
|
|
158
|
+
primaryKey: /* @__PURE__ */ z.boolean().optional(),
|
|
159
|
+
notNull: /* @__PURE__ */ z.boolean().optional(),
|
|
160
|
+
unique: /* @__PURE__ */ z.boolean().optional(),
|
|
161
|
+
/**
|
|
162
|
+
* Column DEFAULT. Required for B2: the four `ensureTable` consumers declare
|
|
163
|
+
* columns like `enabled INTEGER NOT NULL DEFAULT 1`, and without this the
|
|
164
|
+
* collection surface simply cannot express their existing tables — which is
|
|
165
|
+
* why they were still on the uncapped `table*` API.
|
|
166
|
+
*/
|
|
167
|
+
defaultValue: /* @__PURE__ */ z.union([
|
|
168
|
+
/* @__PURE__ */ z.string(),
|
|
169
|
+
/* @__PURE__ */ z.number(),
|
|
170
|
+
/* @__PURE__ */ z.boolean()
|
|
171
|
+
]).optional()
|
|
172
|
+
});
|
|
173
|
+
var CollectionIndexSchema = /* @__PURE__ */ z.object({
|
|
174
|
+
name: /* @__PURE__ */ z.string(),
|
|
175
|
+
columns: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).readonly(),
|
|
176
|
+
unique: /* @__PURE__ */ z.boolean().optional()
|
|
177
|
+
});
|
|
178
|
+
/**
|
|
179
|
+
* The input of `declareCollection` — ONE schema for the door and for the
|
|
180
|
+
* engine behind it, so the two surfaces cannot drift (the dispatcher forwards
|
|
181
|
+
* the payload untouched).
|
|
182
|
+
*
|
|
183
|
+
* - `database` — the file the collection lives in (D851). Absent means
|
|
184
|
+
* `settings`. A declaration naming a file other than the one the table is
|
|
185
|
+
* already in is REFUSED by the engine, never moved.
|
|
186
|
+
* - `primaryKey` — a COMPOSITE key, as column names. A single name is the same
|
|
187
|
+
* as `primaryKey: true` on that column. A composite-keyed collection has no
|
|
188
|
+
* `id`: it is written with `insertMany` / `upsertMany` / `transact` and read
|
|
189
|
+
* with `query` / `count` / `aggregate` / `deleteWhere`; the calls that
|
|
190
|
+
* address one row by id are refused.
|
|
191
|
+
* - `withoutRowid` — emit `WITHOUT ROWID`. Requires a primary key.
|
|
192
|
+
*/
|
|
193
|
+
var DeclareCollectionInputSchema = /* @__PURE__ */ z.object({
|
|
194
|
+
namespace: /* @__PURE__ */ z.string().optional(),
|
|
195
|
+
collection: /* @__PURE__ */ z.string(),
|
|
196
|
+
columns: /* @__PURE__ */ z.array(CollectionColumnSchema).readonly(),
|
|
197
|
+
indexes: /* @__PURE__ */ z.array(CollectionIndexSchema).readonly().optional(),
|
|
198
|
+
database: /* @__PURE__ */ DataStoreDatabaseSchema.optional(),
|
|
199
|
+
primaryKey: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).readonly().optional(),
|
|
200
|
+
withoutRowid: /* @__PURE__ */ z.boolean().optional()
|
|
201
|
+
});
|
|
202
|
+
/**
|
|
203
|
+
* settings-store — singleton capability for addon-scoped persistence.
|
|
204
|
+
*
|
|
205
|
+
* Every method operates within a `collection`. An optional `namespace`
|
|
206
|
+
* field provides access to additional data spaces beyond the default
|
|
207
|
+
* addon settings — useful for business data (events, tracks, faces, etc.).
|
|
208
|
+
*
|
|
209
|
+
* **Scoping is the CALLER's, and it is opt-in.** The table is
|
|
210
|
+
* `namespace ? `${namespace}:${collection}` : collection` — nothing
|
|
211
|
+
* consults the identity of the caller. An earlier version of this comment
|
|
212
|
+
* claimed the implementation prefixes every collection with the calling
|
|
213
|
+
* addon's ID and that "addons never see each other's data"; that was never
|
|
214
|
+
* true, and this same file contradicted it under `declareCollection`. What
|
|
215
|
+
* exists is `addon-context-factory`, which passes `namespace: addonId` ON
|
|
216
|
+
* THE ADDON'S BEHALF for the `addon-settings` / `addon-devices` paths only.
|
|
217
|
+
* Business collections use bare names, and any caller may name any
|
|
218
|
+
* namespace, or none. Making the door enforce it is tracked separately —
|
|
219
|
+
* it renames tables, so it needs a migration.
|
|
220
|
+
*
|
|
221
|
+
* **So every method is `auth: 'admin'` (D634).** Because nothing scopes a
|
|
222
|
+
* call to its caller, a `protected` method here was a raw, unredacted read
|
|
223
|
+
* (and write) of every addon's collections for any role holding
|
|
224
|
+
* `category:system` — which is every role: a `viewer` could read every
|
|
225
|
+
* notifier token in plaintext from `notifiers:notification-targets`. No
|
|
226
|
+
* browser or app client calls this cap. Addons are not affected: an
|
|
227
|
+
* addon's `ctx.api` cap call is resolved to the provider directly and never
|
|
228
|
+
* enters the tRPC router (so the tier gates sessions and tokens, never
|
|
229
|
+
* addons), and the hub itself calls it through the capability registry.
|
|
230
|
+
*
|
|
231
|
+
* - `{ collection: 'addon-settings' }` → table `addon-settings`
|
|
232
|
+
* - `{ namespace: 'my-addon', collection: 'addon-settings' }` →
|
|
233
|
+
* table `my-addon:addon-settings`
|
|
234
|
+
*
|
|
235
|
+
* Served by the **storage-orchestrator** builtin, which dispatches to the
|
|
236
|
+
* `data-store-provider` engine registered for the collection
|
|
237
|
+
* (`sqlite-settings`, a SQLite WAL backend, today). One addon owns the
|
|
238
|
+
* data door; engines sit behind it
|
|
239
|
+
* ([D44](../../../../docs/decisions/adr-0044.md)).
|
|
240
|
+
* Addons access it via `ctx.api.settingsStore.*`.
|
|
241
|
+
*/
|
|
242
|
+
var settingsStoreCapability = {
|
|
243
|
+
name: "settings-store",
|
|
244
|
+
scope: "system",
|
|
245
|
+
mode: "singleton",
|
|
246
|
+
methods: {
|
|
247
|
+
/** Get a single value by key from a collection. */
|
|
248
|
+
get: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
249
|
+
namespace: /* @__PURE__ */ z.string().optional(),
|
|
250
|
+
collection: /* @__PURE__ */ z.string(),
|
|
251
|
+
key: /* @__PURE__ */ z.string()
|
|
252
|
+
}), /* @__PURE__ */ z.unknown(), { auth: "admin" }),
|
|
253
|
+
/** Set a value by key in a collection (upsert). */
|
|
254
|
+
set: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
255
|
+
namespace: /* @__PURE__ */ z.string().optional(),
|
|
256
|
+
collection: /* @__PURE__ */ z.string(),
|
|
257
|
+
key: /* @__PURE__ */ z.string(),
|
|
258
|
+
value: /* @__PURE__ */ z.unknown()
|
|
259
|
+
}), /* @__PURE__ */ z.void(), {
|
|
260
|
+
kind: "mutation",
|
|
261
|
+
auth: "admin"
|
|
262
|
+
}),
|
|
263
|
+
/**
|
|
264
|
+
* Rows matching a filter.
|
|
265
|
+
*
|
|
266
|
+
* `columns` is a SQL-level projection: the engine SELECTs only those
|
|
267
|
+
* columns (plus the primary key) instead of the whole row. It is the only
|
|
268
|
+
* way to stop paying disk for a column that is discarded — a heavy JSON
|
|
269
|
+
* column dominates the row, and dropping it in JS after the read pays every
|
|
270
|
+
* byte first. Measured on the live `pipeline-analytics:tracks` table: a
|
|
271
|
+
* 501-row page is 4.6 MB whole and 0.11 MB projected, same index, same
|
|
272
|
+
* plan.
|
|
273
|
+
*
|
|
274
|
+
* The engine REFUSES a column it cannot serve rather than omitting it —
|
|
275
|
+
* see `SettingsQueryInput.columns` for why a projection may not be
|
|
276
|
+
* forgiving the way a predicate is.
|
|
277
|
+
*/
|
|
278
|
+
query: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
279
|
+
namespace: /* @__PURE__ */ z.string().optional(),
|
|
280
|
+
collection: /* @__PURE__ */ z.string(),
|
|
281
|
+
filter: /* @__PURE__ */ QueryFilterSchema.optional(),
|
|
282
|
+
columns: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).readonly().optional()
|
|
283
|
+
}), /* @__PURE__ */ z.array(SettingsRecordSchema).readonly(), { auth: "admin" }),
|
|
284
|
+
/**
|
|
285
|
+
* Make a SLOT hold this row — insert it, or update whatever already
|
|
286
|
+
* occupies the slot — and answer with the id the row HAS.
|
|
287
|
+
*
|
|
288
|
+
* ## Why the store needed this
|
|
289
|
+
*
|
|
290
|
+
* {@link set} is already an upsert, but its slot is the PRIMARY KEY: the
|
|
291
|
+
* caller has to know the id to address the row. That is exactly what a
|
|
292
|
+
* collection keyed by an `INTEGER` rowid alias cannot do — SQLite assigns
|
|
293
|
+
* the id, so a writer whose uniqueness rule is "one row per
|
|
294
|
+
* `(ownerKind, ownerId, kind, slot)`" has no id to name and no way to
|
|
295
|
+
* express the rule. {@link insert} can express it (a UNIQUE index
|
|
296
|
+
* arbitrates) but only by THROWING at the loser of a race, and the loser
|
|
297
|
+
* here is a legitimate re-capture, not an error.
|
|
298
|
+
*
|
|
299
|
+
* Getting there without this method means read-then-write: query the slot,
|
|
300
|
+
* then `insert` or `update`. Two statements instead of one, a race between
|
|
301
|
+
* them, and a recovery path that has to recognise a UNIQUE violation by its
|
|
302
|
+
* MESSAGE — across a process boundary, because the store lives behind an
|
|
303
|
+
* RPC door. A string match would be the whole gate, and a store that
|
|
304
|
+
* rephrased its error would lose the row silently. One statement has no
|
|
305
|
+
* such gate (D482).
|
|
306
|
+
*
|
|
307
|
+
* ## The contract
|
|
308
|
+
*
|
|
309
|
+
* `conflict` names the DECLARED columns that identify the slot. They must
|
|
310
|
+
* be covered by a UNIQUE index on the collection — SQLite resolves an
|
|
311
|
+
* `ON CONFLICT` target against its indexes and REFUSES the statement when
|
|
312
|
+
* none matches, so a wrong list is a loud error on the first write, never a
|
|
313
|
+
* silently duplicated row. An empty list is refused rather than passed on:
|
|
314
|
+
* `ON CONFLICT()` is not valid SQL, and the intent it would most likely
|
|
315
|
+
* encode ("no slot, just insert") is {@link insert}.
|
|
316
|
+
*
|
|
317
|
+
* Row shape is {@link insert}'s: `record.id` is used when the collection
|
|
318
|
+
* needs a supplied key and IGNORED when the primary key is an `INTEGER`
|
|
319
|
+
* rowid alias — exactly as `insert` and `insertMany` already treat it.
|
|
320
|
+
*
|
|
321
|
+
* Returns the id either way: the one SQLite assigned on an insert, or the
|
|
322
|
+
* one the row it updated already had. A caller cannot tell which happened,
|
|
323
|
+
* and deliberately — every caller wants the slot's id, and one that needed
|
|
324
|
+
* to distinguish creation from replacement would have to read first anyway.
|
|
325
|
+
*/
|
|
326
|
+
upsert: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
327
|
+
namespace: /* @__PURE__ */ z.string().optional(),
|
|
328
|
+
collection: /* @__PURE__ */ z.string(),
|
|
329
|
+
/** Declared columns identifying the slot; must be covered by a UNIQUE
|
|
330
|
+
* index on the collection. Never empty. */
|
|
331
|
+
conflict: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).readonly(),
|
|
332
|
+
record: BulkRecordSchema
|
|
333
|
+
}), /* @__PURE__ */ z.object({
|
|
334
|
+
/** The id the row HAS: assigned by SQLite on an insert, or the existing
|
|
335
|
+
* row's own id on an update. */
|
|
336
|
+
id: /* @__PURE__ */ z.union([/* @__PURE__ */ z.string(), /* @__PURE__ */ z.number()]) }), {
|
|
337
|
+
kind: "mutation",
|
|
338
|
+
auth: "admin"
|
|
339
|
+
}),
|
|
340
|
+
/**
|
|
341
|
+
* {@link upsert} for a BATCH, in ONE transaction on ONE prepared statement.
|
|
342
|
+
*
|
|
343
|
+
* The write-side twin of {@link insertMany} for rows that may already
|
|
344
|
+
* exist: a rollup writer recomputes a bucket and must overwrite it, and
|
|
345
|
+
* N round trips with N COMMITs is the cost {@link insertMany} was added to
|
|
346
|
+
* avoid. `conflict` has the meaning it has on {@link upsert} (declared
|
|
347
|
+
* columns covered by a UNIQUE index or the primary key, never empty).
|
|
348
|
+
*
|
|
349
|
+
* Every record of a batch must carry the SAME set of declared columns and
|
|
350
|
+
* every `conflict` column: one batch is one statement shape, and a record
|
|
351
|
+
* that silently bound NULL over a column it did not mention would erase
|
|
352
|
+
* it. A heterogeneous batch is refused whole. **All or nothing.**
|
|
353
|
+
*/
|
|
354
|
+
upsertMany: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
355
|
+
namespace: /* @__PURE__ */ z.string().optional(),
|
|
356
|
+
collection: /* @__PURE__ */ z.string(),
|
|
357
|
+
conflict: /* @__PURE__ */ z.array(/* @__PURE__ */ z.string()).readonly(),
|
|
358
|
+
records: /* @__PURE__ */ z.array(BulkRecordSchema).readonly()
|
|
359
|
+
}), /* @__PURE__ */ z.object({ upserted: /* @__PURE__ */ z.number().int() }), {
|
|
360
|
+
kind: "mutation",
|
|
361
|
+
auth: "admin"
|
|
362
|
+
}),
|
|
363
|
+
/** Insert a new record. */
|
|
364
|
+
insert: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
365
|
+
namespace: /* @__PURE__ */ z.string().optional(),
|
|
366
|
+
collection: /* @__PURE__ */ z.string(),
|
|
367
|
+
record: /* @__PURE__ */ z.object({
|
|
368
|
+
id: /* @__PURE__ */ z.string().optional(),
|
|
369
|
+
data: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown())
|
|
370
|
+
})
|
|
371
|
+
}), /* @__PURE__ */ z.object({
|
|
372
|
+
/**
|
|
373
|
+
* The id the row ACTUALLY got (D473): the one supplied, the UUID minted
|
|
374
|
+
* for an absent one, or the ROWID SQLite assigned on an `INTEGER`
|
|
375
|
+
* primary key — which is the only place an auto key is knowable.
|
|
376
|
+
*/
|
|
377
|
+
id: /* @__PURE__ */ z.union([/* @__PURE__ */ z.string(), /* @__PURE__ */ z.number()]) }), {
|
|
378
|
+
kind: "mutation",
|
|
379
|
+
auth: "admin"
|
|
380
|
+
}),
|
|
381
|
+
/**
|
|
382
|
+
* Insert MANY records in ONE transaction, returning how many landed.
|
|
383
|
+
*
|
|
384
|
+
* The write-side twin of {@link deleteWhere}, and it exists for the same
|
|
385
|
+
* reason: without it, appending a batch is N round trips and N COMMITs on
|
|
386
|
+
* the single shared connection that also serves every cluster-wide
|
|
387
|
+
* configuration read. The durable load series writes one process row per
|
|
388
|
+
* process per sample — 76 rows every 10 s on the live fleet — and the
|
|
389
|
+
* operator's rule for it is *one transaction per sample, never one per
|
|
390
|
+
* row*. `insert` cannot express that; nothing else could.
|
|
391
|
+
*
|
|
392
|
+
* **All or nothing.** A batch that fails on its fifth row leaves none of
|
|
393
|
+
* the five behind. A half-written sample is worse than a missing one: the
|
|
394
|
+
* missing one reads as "nobody reported", which is true, while the half
|
|
395
|
+
* one reads as "these were the only processes running", which is not.
|
|
396
|
+
*
|
|
397
|
+
* `id` is OPTIONAL per record, and that is the difference from
|
|
398
|
+
* {@link insert}. A collection whose primary key is an `INTEGER` rowid
|
|
399
|
+
* alias has no id to supply — SQLite assigns it, for free, and inventing a
|
|
400
|
+
* `randomUUID()` for such a column would write a 36-character string into
|
|
401
|
+
* an integer key. Omitted on a TEXT key, a uuid is generated exactly as
|
|
402
|
+
* `insert` does.
|
|
403
|
+
*/
|
|
404
|
+
insertMany: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
405
|
+
namespace: /* @__PURE__ */ z.string().optional(),
|
|
406
|
+
collection: /* @__PURE__ */ z.string(),
|
|
407
|
+
records: /* @__PURE__ */ z.array(BulkRecordSchema).readonly()
|
|
408
|
+
}), /* @__PURE__ */ z.object({ inserted: /* @__PURE__ */ z.number().int() }), {
|
|
409
|
+
kind: "mutation",
|
|
410
|
+
auth: "admin"
|
|
411
|
+
}),
|
|
412
|
+
/**
|
|
413
|
+
* Several writes, ONE transaction, behind an optional precondition.
|
|
414
|
+
*
|
|
415
|
+
* The multi-collection twin of {@link insertMany}: a write that has to move
|
|
416
|
+
* a set of rows in one collection AND a revision in another cannot be
|
|
417
|
+
* expressed as separate calls without a window in which a reader (or a
|
|
418
|
+
* crash) sees half of it. The retrain annotation save replaces a frame's
|
|
419
|
+
* rows, its dismissed set and its revision this way.
|
|
420
|
+
*
|
|
421
|
+
* `guard`, when given, is read inside the transaction: if the row is
|
|
422
|
+
* missing or its column differs from `equals`, NOTHING is written and the
|
|
423
|
+
* answer is `{ applied: false, current }` with what was found — the
|
|
424
|
+
* compare-and-set a revisioned write needs, with no second reader able to
|
|
425
|
+
* slip between the check and the writes.
|
|
426
|
+
*
|
|
427
|
+
* **All or nothing**, like {@link insertMany}: a throw in any op rolls the
|
|
428
|
+
* whole call back. Ops run in the order given (delete before insert to
|
|
429
|
+
* replace a set). `namespace` applies to every collection named.
|
|
430
|
+
*/
|
|
431
|
+
transact: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
432
|
+
namespace: /* @__PURE__ */ z.string().optional(),
|
|
433
|
+
guard: /* @__PURE__ */ TransactGuardSchema.optional(),
|
|
434
|
+
ops: /* @__PURE__ */ z.array(TransactOpSchema).readonly()
|
|
435
|
+
}), /* @__PURE__ */ z.object({
|
|
436
|
+
applied: /* @__PURE__ */ z.boolean(),
|
|
437
|
+
current: /* @__PURE__ */ z.unknown().optional()
|
|
438
|
+
}), {
|
|
439
|
+
kind: "mutation",
|
|
440
|
+
auth: "admin"
|
|
441
|
+
}),
|
|
442
|
+
/** Update an existing record by ID. */
|
|
443
|
+
update: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
444
|
+
namespace: /* @__PURE__ */ z.string().optional(),
|
|
445
|
+
collection: /* @__PURE__ */ z.string(),
|
|
446
|
+
id: /* @__PURE__ */ z.string(),
|
|
447
|
+
data: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown())
|
|
448
|
+
}), /* @__PURE__ */ z.void(), {
|
|
449
|
+
kind: "mutation",
|
|
450
|
+
auth: "admin"
|
|
451
|
+
}),
|
|
452
|
+
/** Delete a record by key/ID. */
|
|
453
|
+
delete: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
454
|
+
namespace: /* @__PURE__ */ z.string().optional(),
|
|
455
|
+
collection: /* @__PURE__ */ z.string(),
|
|
456
|
+
key: /* @__PURE__ */ z.string()
|
|
457
|
+
}), /* @__PURE__ */ z.void(), {
|
|
458
|
+
kind: "mutation",
|
|
459
|
+
auth: "admin"
|
|
460
|
+
}),
|
|
461
|
+
/**
|
|
462
|
+
* Delete every record matching `filter`, in ONE statement, returning how
|
|
463
|
+
* many rows went. This exists because its absence made every retention
|
|
464
|
+
* path in the system an N+1 drain loop: `delete` takes a key, so a sweep
|
|
465
|
+
* had to SELECT a page of full rows — every column, including the fat
|
|
466
|
+
* ones — purely to learn their ids, then issue one call per row.
|
|
467
|
+
*
|
|
468
|
+
* **The filter is required and must resolve.** A predicate naming
|
|
469
|
+
* something the collection cannot express is an ERROR here, not a
|
|
470
|
+
* widening as it is on `query`, and a filter with no predicates is an
|
|
471
|
+
* error rather than "every row". Deleting a whole collection is a
|
|
472
|
+
* legitimate intent, but it must be asked for by name — not reached by
|
|
473
|
+
* an empty object.
|
|
474
|
+
*/
|
|
475
|
+
deleteWhere: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
476
|
+
namespace: /* @__PURE__ */ z.string().optional(),
|
|
477
|
+
collection: /* @__PURE__ */ z.string(),
|
|
478
|
+
filter: MutationFilterSchema
|
|
479
|
+
}), /* @__PURE__ */ z.object({ deleted: /* @__PURE__ */ z.number().int() }), {
|
|
480
|
+
kind: "mutation",
|
|
481
|
+
auth: "admin"
|
|
482
|
+
}),
|
|
483
|
+
/**
|
|
484
|
+
* Apply `data` to every record matching `filter`, in one statement,
|
|
485
|
+
* returning how many rows changed. Same filter contract as
|
|
486
|
+
* {@link deleteWhere} — an unresolvable predicate is an error.
|
|
487
|
+
*/
|
|
488
|
+
updateWhere: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
489
|
+
namespace: /* @__PURE__ */ z.string().optional(),
|
|
490
|
+
collection: /* @__PURE__ */ z.string(),
|
|
491
|
+
filter: MutationFilterSchema,
|
|
492
|
+
data: /* @__PURE__ */ z.record(/* @__PURE__ */ z.string(), /* @__PURE__ */ z.unknown())
|
|
493
|
+
}), /* @__PURE__ */ z.object({ updated: /* @__PURE__ */ z.number().int() }), {
|
|
494
|
+
kind: "mutation",
|
|
495
|
+
auth: "admin"
|
|
496
|
+
}),
|
|
497
|
+
/** Count entries in a collection, optionally filtered. */
|
|
498
|
+
count: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
499
|
+
namespace: /* @__PURE__ */ z.string().optional(),
|
|
500
|
+
collection: /* @__PURE__ */ z.string(),
|
|
501
|
+
filter: /* @__PURE__ */ QueryFilterSchema.optional()
|
|
502
|
+
}), /* @__PURE__ */ z.number(), { auth: "admin" }),
|
|
503
|
+
/**
|
|
504
|
+
* `COUNT(*)` and one `SUM` / `MIN` / `MAX` per requested field, in ONE
|
|
505
|
+
* statement, over the rows `filter` selects.
|
|
506
|
+
*
|
|
507
|
+
* Exists because "how much is there" was being answered by materialising
|
|
508
|
+
* "what is there". The recorder's storage-pressure sweep asked its in-RAM
|
|
509
|
+
* footage index for bytes/count/oldest/newest across a set of storage
|
|
510
|
+
* locations twice a minute, and the only way to answer that from a map is
|
|
511
|
+
* to visit every row — 7.1 M of them on the live hub, ~15 M row visits a
|
|
512
|
+
* minute on the main thread, which is also why the whole archive had to
|
|
513
|
+
* stay resident to be visited. The question is a sum; nothing needs to be
|
|
514
|
+
* materialised to answer it.
|
|
515
|
+
*
|
|
516
|
+
* **The engine REFUSES a field it cannot serve**, exactly as
|
|
517
|
+
* `query.columns` does and unlike a PREDICATE, which is skipped when
|
|
518
|
+
* unresolvable. A dropped predicate over-matches and the caller sees extra
|
|
519
|
+
* rows; a dropped aggregate returns a NUMBER that is wrong and looks
|
|
520
|
+
* exactly like a real one. That asymmetry is what this repo has already
|
|
521
|
+
* paid for once in `count`.
|
|
522
|
+
*/
|
|
523
|
+
aggregate: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
524
|
+
namespace: /* @__PURE__ */ z.string().optional(),
|
|
525
|
+
collection: /* @__PURE__ */ z.string(),
|
|
526
|
+
fields: /* @__PURE__ */ z.array(AggregateFieldSchema).readonly(),
|
|
527
|
+
filter: /* @__PURE__ */ QueryFilterSchema.optional()
|
|
528
|
+
}), AggregateResultSchema, { auth: "admin" }),
|
|
529
|
+
/** Grouped counts per ((field-origin)/bucketSize) bucket, filtered. */
|
|
530
|
+
histogram: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
531
|
+
namespace: /* @__PURE__ */ z.string().optional(),
|
|
532
|
+
collection: /* @__PURE__ */ z.string(),
|
|
533
|
+
field: /* @__PURE__ */ z.string(),
|
|
534
|
+
bucketSize: /* @__PURE__ */ z.number().int().positive(),
|
|
535
|
+
origin: /* @__PURE__ */ z.number().int(),
|
|
536
|
+
filter: /* @__PURE__ */ QueryFilterSchema.optional()
|
|
537
|
+
}), /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
|
|
538
|
+
bucket: /* @__PURE__ */ z.number().int(),
|
|
539
|
+
count: /* @__PURE__ */ z.number().int()
|
|
540
|
+
})).readonly(), { auth: "admin" }),
|
|
541
|
+
/** Check if a collection is empty. */
|
|
542
|
+
isEmpty: /* @__PURE__ */ method(/* @__PURE__ */ z.object({
|
|
543
|
+
namespace: /* @__PURE__ */ z.string().optional(),
|
|
544
|
+
collection: /* @__PURE__ */ z.string()
|
|
545
|
+
}), /* @__PURE__ */ z.boolean(), { auth: "admin" }),
|
|
546
|
+
/**
|
|
547
|
+
* Declare a typed (SQL-backed) collection with explicit columns +
|
|
548
|
+
* indexes. Idempotent: re-declaring an existing collection with the
|
|
549
|
+
* same shape is a no-op; shape changes (new columns, new indexes)
|
|
550
|
+
* are applied additively. Subsequent `insert` / `update` / `delete`
|
|
551
|
+
* / `query` calls on this collection use typed columns instead of
|
|
552
|
+
* JSON-blob storage — `record.data` fields are spread across
|
|
553
|
+
* columns, `query.filter.where` matches real columns (no
|
|
554
|
+
* `json_extract` overhead), `orderBy` uses column indexes.
|
|
555
|
+
*
|
|
556
|
+
* Addons call this in `onInitialize` before their first read/write.
|
|
557
|
+
* Collection names should be namespaced by addon (e.g.
|
|
558
|
+
* `pipeline-analytics:object-events`) to avoid cross-addon
|
|
559
|
+
* clashes — no automatic prefix is added.
|
|
560
|
+
*/
|
|
561
|
+
declareCollection: /* @__PURE__ */ method(DeclareCollectionInputSchema, /* @__PURE__ */ z.void(), {
|
|
562
|
+
kind: "mutation",
|
|
563
|
+
auth: "admin"
|
|
564
|
+
})
|
|
565
|
+
},
|
|
566
|
+
vocabulary: { notOperatorFacing: NOT_A_DEVICE.INTERNAL }
|
|
567
|
+
};
|
|
568
|
+
//#endregion
|
|
569
|
+
export { DataStoreDatabaseSchema as a, QueryFilterSchema as c, TransactOpSchema as d, settingsStoreCapability as f, DATA_STORE_DATABASES as i, SettingsRecordSchema as l, AggregateResultSchema as n, DeclareCollectionInputSchema as o, BulkRecordSchema as r, MutationFilterSchema as s, AggregateFieldSchema as t, TransactGuardSchema as u };
|