@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
package/system/dist/{custom-action-registry-N7flBDwT.mjs → custom-action-registry-B9zFBNVa.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import * as fs from "node:fs";
|
|
2
|
+
import * as fs$1 from "node:fs";
|
|
3
3
|
import { createReadStream, promises } from "node:fs";
|
|
4
4
|
import * as path$1 from "node:path";
|
|
5
5
|
import path from "node:path";
|
|
@@ -159,7 +159,7 @@ var HOSTED_MODEL_REVISIONS = {
|
|
|
159
159
|
//#endregion
|
|
160
160
|
//#region src/download/model-downloader.ts
|
|
161
161
|
function isNonEmptyFile(filePath) {
|
|
162
|
-
return fs.existsSync(filePath) && fs.statSync(filePath).size > 0;
|
|
162
|
+
return fs$1.existsSync(filePath) && fs$1.statSync(filePath).size > 0;
|
|
163
163
|
}
|
|
164
164
|
/**
|
|
165
165
|
* Sibling files of a single-file (non-directory) format — extra files the
|
|
@@ -269,11 +269,11 @@ function resolveRedirectUrl(current, location) {
|
|
|
269
269
|
return new URL(location, current);
|
|
270
270
|
}
|
|
271
271
|
async function downloadFile(url, destPath, onProgressOrOptions) {
|
|
272
|
-
if (fs.existsSync(destPath)) return destPath;
|
|
272
|
+
if (fs$1.existsSync(destPath)) return destPath;
|
|
273
273
|
const opts = normalizeDownloadOptions(onProgressOrOptions);
|
|
274
274
|
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
275
275
|
const maxRedirects = opts.maxRedirects ?? DEFAULT_MAX_REDIRECTS;
|
|
276
|
-
fs.mkdirSync(path$1.dirname(destPath), { recursive: true });
|
|
276
|
+
fs$1.mkdirSync(path$1.dirname(destPath), { recursive: true });
|
|
277
277
|
const tmpPath = destPath + ".downloading";
|
|
278
278
|
try {
|
|
279
279
|
let current = url;
|
|
@@ -315,7 +315,7 @@ async function downloadFile(url, destPath, onProgressOrOptions) {
|
|
|
315
315
|
if (!response.body) throw new Error(`No response body from ${url}`);
|
|
316
316
|
const total = parseInt(response.headers.get("content-length") ?? "0", 10);
|
|
317
317
|
let downloaded = 0;
|
|
318
|
-
const fileStream = fs.createWriteStream(tmpPath);
|
|
318
|
+
const fileStream = fs$1.createWriteStream(tmpPath);
|
|
319
319
|
const reader = response.body.getReader();
|
|
320
320
|
try {
|
|
321
321
|
for (;;) {
|
|
@@ -333,11 +333,11 @@ async function downloadFile(url, destPath, onProgressOrOptions) {
|
|
|
333
333
|
fileStream.on("error", reject);
|
|
334
334
|
});
|
|
335
335
|
}
|
|
336
|
-
fs.renameSync(tmpPath, destPath);
|
|
336
|
+
fs$1.renameSync(tmpPath, destPath);
|
|
337
337
|
return destPath;
|
|
338
338
|
} catch (err) {
|
|
339
339
|
try {
|
|
340
|
-
fs.unlinkSync(tmpPath);
|
|
340
|
+
fs$1.unlinkSync(tmpPath);
|
|
341
341
|
} catch {}
|
|
342
342
|
throw err;
|
|
343
343
|
}
|
|
@@ -368,12 +368,12 @@ async function downloadModel(options) {
|
|
|
368
368
|
const { url, fallbackUrls = [], destDir, filename, expectedSha256, onProgress } = options;
|
|
369
369
|
const fname = filename ?? url.split("/").pop() ?? "model.bin";
|
|
370
370
|
const destPath = path$1.join(destDir, fname);
|
|
371
|
-
if (fs.existsSync(destPath)) return {
|
|
371
|
+
if (fs$1.existsSync(destPath)) return {
|
|
372
372
|
filePath: destPath,
|
|
373
373
|
downloadedBytes: 0,
|
|
374
374
|
fromCache: true
|
|
375
375
|
};
|
|
376
|
-
fs.mkdirSync(destDir, { recursive: true });
|
|
376
|
+
fs$1.mkdirSync(destDir, { recursive: true });
|
|
377
377
|
const urls = [url, ...fallbackUrls];
|
|
378
378
|
let lastError = null;
|
|
379
379
|
for (const tryUrl of urls) try {
|
|
@@ -381,25 +381,25 @@ async function downloadModel(options) {
|
|
|
381
381
|
if (expectedSha256) {
|
|
382
382
|
const hash = await computeSha256(destPath);
|
|
383
383
|
if (hash !== expectedSha256) {
|
|
384
|
-
fs.unlinkSync(destPath);
|
|
384
|
+
fs$1.unlinkSync(destPath);
|
|
385
385
|
throw new Error(`SHA256 mismatch: expected ${expectedSha256}, got ${hash}`);
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
return {
|
|
389
389
|
filePath: destPath,
|
|
390
|
-
downloadedBytes: fs.statSync(destPath).size,
|
|
390
|
+
downloadedBytes: fs$1.statSync(destPath).size,
|
|
391
391
|
fromCache: false
|
|
392
392
|
};
|
|
393
393
|
} catch (e) {
|
|
394
394
|
lastError = e;
|
|
395
|
-
if (fs.existsSync(destPath)) fs.unlinkSync(destPath);
|
|
395
|
+
if (fs$1.existsSync(destPath)) fs$1.unlinkSync(destPath);
|
|
396
396
|
}
|
|
397
397
|
throw lastError ?? /* @__PURE__ */ new Error(`Failed to download model from ${url}`);
|
|
398
398
|
}
|
|
399
399
|
async function computeSha256(filePath) {
|
|
400
400
|
return new Promise((resolve, reject) => {
|
|
401
401
|
const hash = createHash("sha256");
|
|
402
|
-
const stream = fs.createReadStream(filePath);
|
|
402
|
+
const stream = fs$1.createReadStream(filePath);
|
|
403
403
|
stream.on("data", (chunk) => hash.update(chunk));
|
|
404
404
|
stream.on("end", () => resolve(hash.digest("hex")));
|
|
405
405
|
stream.on("error", reject);
|
|
@@ -424,28 +424,28 @@ async function downloadDirectory(url, destDir, knownFiles, onProgress) {
|
|
|
424
424
|
fileUrl: `https://huggingface.co/${repo}/resolve/main/${dirPath}/${f}`
|
|
425
425
|
}));
|
|
426
426
|
const tmpDir = destDir + ".downloading";
|
|
427
|
-
fs.rmSync(tmpDir, {
|
|
427
|
+
fs$1.rmSync(tmpDir, {
|
|
428
428
|
recursive: true,
|
|
429
429
|
force: true
|
|
430
430
|
});
|
|
431
|
-
fs.mkdirSync(tmpDir, { recursive: true });
|
|
431
|
+
fs$1.mkdirSync(tmpDir, { recursive: true });
|
|
432
432
|
let totalDownloaded = 0;
|
|
433
433
|
try {
|
|
434
434
|
for (const file of files) {
|
|
435
435
|
const destPath = path$1.join(tmpDir, file.relativePath);
|
|
436
|
-
fs.mkdirSync(path$1.dirname(destPath), { recursive: true });
|
|
436
|
+
fs$1.mkdirSync(path$1.dirname(destPath), { recursive: true });
|
|
437
437
|
await downloadFile(file.fileUrl, destPath, (downloaded, _total) => {
|
|
438
438
|
onProgress?.(totalDownloaded + downloaded, void 0);
|
|
439
439
|
});
|
|
440
|
-
totalDownloaded += fs.statSync(destPath).size;
|
|
440
|
+
totalDownloaded += fs$1.statSync(destPath).size;
|
|
441
441
|
}
|
|
442
|
-
fs.rmSync(destDir, {
|
|
442
|
+
fs$1.rmSync(destDir, {
|
|
443
443
|
recursive: true,
|
|
444
444
|
force: true
|
|
445
445
|
});
|
|
446
|
-
fs.renameSync(tmpDir, destDir);
|
|
446
|
+
fs$1.renameSync(tmpDir, destDir);
|
|
447
447
|
} catch (err) {
|
|
448
|
-
fs.rmSync(tmpDir, {
|
|
448
|
+
fs$1.rmSync(tmpDir, {
|
|
449
449
|
recursive: true,
|
|
450
450
|
force: true
|
|
451
451
|
});
|
|
@@ -477,7 +477,7 @@ function revisionRecordPath(modelPath) {
|
|
|
477
477
|
}
|
|
478
478
|
function readRevisionRecord(modelPath) {
|
|
479
479
|
try {
|
|
480
|
-
return fs.readFileSync(revisionRecordPath(modelPath), "utf8").trim();
|
|
480
|
+
return fs$1.readFileSync(revisionRecordPath(modelPath), "utf8").trim();
|
|
481
481
|
} catch {
|
|
482
482
|
return null;
|
|
483
483
|
}
|
|
@@ -541,8 +541,8 @@ function writeRevisionRecord(modelPath, revision) {
|
|
|
541
541
|
if (revision === void 0) return;
|
|
542
542
|
const record = revisionRecordPath(modelPath);
|
|
543
543
|
const tmp = `${record}.tmp`;
|
|
544
|
-
fs.writeFileSync(tmp, `${revision}\n`);
|
|
545
|
-
fs.renameSync(tmp, record);
|
|
544
|
+
fs$1.writeFileSync(tmp, `${revision}\n`);
|
|
545
|
+
fs$1.renameSync(tmp, record);
|
|
546
546
|
}
|
|
547
547
|
/**
|
|
548
548
|
* Prove an unrecorded (or differently recorded) copy current by hashing its
|
|
@@ -562,9 +562,9 @@ async function adoptByHash(modelsDir, modelPath, formatEntry) {
|
|
|
562
562
|
}
|
|
563
563
|
/** True when every file of the format is on disk, whatever revision it holds. */
|
|
564
564
|
function isCompleteCopy(modelsDir, modelPath, formatEntry) {
|
|
565
|
-
if (!fs.existsSync(modelPath)) return false;
|
|
566
|
-
if (formatEntry.isDirectory) return fs.existsSync(path$1.join(modelPath, "Manifest.json"));
|
|
567
|
-
if (fs.statSync(modelPath).size <= 0) return false;
|
|
565
|
+
if (!fs$1.existsSync(modelPath)) return false;
|
|
566
|
+
if (formatEntry.isDirectory) return fs$1.existsSync(path$1.join(modelPath, "Manifest.json"));
|
|
567
|
+
if (fs$1.statSync(modelPath).size <= 0) return false;
|
|
568
568
|
return siblingFilesFor(formatEntry).every((f) => isNonEmptyFile(path$1.join(modelsDir, f)));
|
|
569
569
|
}
|
|
570
570
|
/**
|
|
@@ -586,14 +586,14 @@ async function replaceSingleFileFormat(url, modelPath, modelsDir, siblings, onPr
|
|
|
586
586
|
}));
|
|
587
587
|
try {
|
|
588
588
|
for (const [i, part] of parts.entries()) {
|
|
589
|
-
fs.rmSync(part.staged, { force: true });
|
|
589
|
+
fs$1.rmSync(part.staged, { force: true });
|
|
590
590
|
await downloadFile(part.url, part.staged, i === 0 ? (downloaded, total) => onProgress?.(downloaded, total === 0 ? void 0 : total) : void 0);
|
|
591
591
|
}
|
|
592
592
|
} catch (err) {
|
|
593
|
-
for (const part of parts) fs.rmSync(part.staged, { force: true });
|
|
593
|
+
for (const part of parts) fs$1.rmSync(part.staged, { force: true });
|
|
594
594
|
throw err;
|
|
595
595
|
}
|
|
596
|
-
for (const part of parts) fs.renameSync(part.staged, part.dest);
|
|
596
|
+
for (const part of parts) fs$1.renameSync(part.staged, part.dest);
|
|
597
597
|
}
|
|
598
598
|
/**
|
|
599
599
|
* Resolve a `ModelCatalogEntry` against `modelsDir`: download model file
|
|
@@ -608,14 +608,14 @@ async function ensureModel(modelsDir, entry, format, onProgress) {
|
|
|
608
608
|
const modelPath = path$1.join(modelsDir, filename);
|
|
609
609
|
const siblings = siblingFilesFor(formatEntry);
|
|
610
610
|
let outdated = false;
|
|
611
|
-
if (fs.existsSync(modelPath)) if (formatEntry.isDirectory && !fs.existsSync(path$1.join(modelPath, "Manifest.json"))) fs.rmSync(modelPath, {
|
|
611
|
+
if (fs$1.existsSync(modelPath)) if (formatEntry.isDirectory && !fs$1.existsSync(path$1.join(modelPath, "Manifest.json"))) fs$1.rmSync(modelPath, {
|
|
612
612
|
recursive: true,
|
|
613
613
|
force: true
|
|
614
614
|
});
|
|
615
615
|
else if (siblings.some((f) => !isNonEmptyFile(path$1.join(modelsDir, f)))) outdated = !isCurrentRevision(modelPath, formatEntry) && !await adoptByHash(modelsDir, modelPath, formatEntry);
|
|
616
616
|
else if (isCurrentRevision(modelPath, formatEntry) || await adoptByHash(modelsDir, modelPath, formatEntry)) return modelPath;
|
|
617
617
|
else outdated = true;
|
|
618
|
-
fs.mkdirSync(modelsDir, { recursive: true });
|
|
618
|
+
fs$1.mkdirSync(modelsDir, { recursive: true });
|
|
619
619
|
if (formatEntry.isDirectory) await downloadDirectory(formatEntry.url, modelPath, formatEntry.files, onProgress);
|
|
620
620
|
else if (outdated) await replaceSingleFileFormat(formatEntry.url, modelPath, modelsDir, siblings, onProgress);
|
|
621
621
|
else {
|
|
@@ -673,25 +673,25 @@ function isModelDownloaded(modelsDir, entry, format) {
|
|
|
673
673
|
const formatEntry = entry.formats[format];
|
|
674
674
|
if (!formatEntry) return false;
|
|
675
675
|
const modelPath = getModelFilePath(modelsDir, entry, format);
|
|
676
|
-
if (!modelPath || !fs.existsSync(modelPath)) return false;
|
|
676
|
+
if (!modelPath || !fs$1.existsSync(modelPath)) return false;
|
|
677
677
|
if (!isCurrentRevision(modelPath, formatEntry)) return false;
|
|
678
678
|
return isCompleteCopy(modelsDir, modelPath, formatEntry);
|
|
679
679
|
}
|
|
680
680
|
/** Remove the on-disk model file/directory. Returns true if something was deleted. */
|
|
681
681
|
function deleteModelFromDisk(modelsDir, entry, format) {
|
|
682
682
|
const modelPath = getModelFilePath(modelsDir, entry, format);
|
|
683
|
-
if (!modelPath || !fs.existsSync(modelPath)) return false;
|
|
684
|
-
fs.rmSync(revisionRecordPath(modelPath), { force: true });
|
|
683
|
+
if (!modelPath || !fs$1.existsSync(modelPath)) return false;
|
|
684
|
+
fs$1.rmSync(revisionRecordPath(modelPath), { force: true });
|
|
685
685
|
const formatEntry = entry.formats[format];
|
|
686
|
-
if (formatEntry?.isDirectory) fs.rmSync(modelPath, {
|
|
686
|
+
if (formatEntry?.isDirectory) fs$1.rmSync(modelPath, {
|
|
687
687
|
recursive: true,
|
|
688
688
|
force: true
|
|
689
689
|
});
|
|
690
690
|
else {
|
|
691
|
-
fs.unlinkSync(modelPath);
|
|
691
|
+
fs$1.unlinkSync(modelPath);
|
|
692
692
|
if (formatEntry) for (const sibling of siblingFilesFor(formatEntry)) {
|
|
693
693
|
const sibPath = path$1.join(modelsDir, sibling);
|
|
694
|
-
if (fs.existsSync(sibPath)) fs.unlinkSync(sibPath);
|
|
694
|
+
if (fs$1.existsSync(sibPath)) fs$1.unlinkSync(sibPath);
|
|
695
695
|
}
|
|
696
696
|
}
|
|
697
697
|
return true;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region ../types/dist/esm/capabilities/custom-actions.mjs
|
|
2
|
+
/**
|
|
3
|
+
* Identity — preserves literal types for downstream inference.
|
|
4
|
+
*
|
|
5
|
+
* The constraint is `Record<string, unknown>` (not `CustomActionsSpec`) so
|
|
6
|
+
* TypeScript does not widen each entry's literal `kind`/`auth` fields to
|
|
7
|
+
* the broader unions declared on `CustomActionSpec`'s default generics.
|
|
8
|
+
* Shape validity is enforced separately by the `customAction(...)` helper
|
|
9
|
+
* whose return type is already a `CustomActionSpec<...>`.
|
|
10
|
+
*/
|
|
11
|
+
function defineCustomActions(spec) {
|
|
12
|
+
return spec;
|
|
13
|
+
}
|
|
14
|
+
function customAction(input, output, options) {
|
|
15
|
+
return {
|
|
16
|
+
input,
|
|
17
|
+
output,
|
|
18
|
+
kind: options?.kind ?? "query",
|
|
19
|
+
auth: options?.auth ?? "protected",
|
|
20
|
+
scope: options?.scope ?? { kind: "system" },
|
|
21
|
+
...options?.caller ? { caller: "required" } : {}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { defineCustomActions as n, customAction as t };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region ../types/dist/esm/capabilities/custom-actions.mjs
|
|
2
|
+
/**
|
|
3
|
+
* Identity — preserves literal types for downstream inference.
|
|
4
|
+
*
|
|
5
|
+
* The constraint is `Record<string, unknown>` (not `CustomActionsSpec`) so
|
|
6
|
+
* TypeScript does not widen each entry's literal `kind`/`auth` fields to
|
|
7
|
+
* the broader unions declared on `CustomActionSpec`'s default generics.
|
|
8
|
+
* Shape validity is enforced separately by the `customAction(...)` helper
|
|
9
|
+
* whose return type is already a `CustomActionSpec<...>`.
|
|
10
|
+
*/
|
|
11
|
+
function defineCustomActions(spec) {
|
|
12
|
+
return spec;
|
|
13
|
+
}
|
|
14
|
+
function customAction(input, output, options) {
|
|
15
|
+
return {
|
|
16
|
+
input,
|
|
17
|
+
output,
|
|
18
|
+
kind: options?.kind ?? "query",
|
|
19
|
+
auth: options?.auth ?? "protected",
|
|
20
|
+
scope: options?.scope ?? { kind: "system" },
|
|
21
|
+
...options?.caller ? { caller: "required" } : {}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
Object.defineProperty(exports, "customAction", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function() {
|
|
28
|
+
return customAction;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "defineCustomActions", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function() {
|
|
34
|
+
return defineCustomActions;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
const require_capability_definition = require("./capability-definition-HCmTem8c.js");
|
|
2
|
+
const require_system_reasons = require("./system-reasons-Be_k1W8g.js");
|
|
3
|
+
const require_settings_store_cap = require("./settings-store.cap-wlJhCspr.js");
|
|
4
|
+
let zod = require("zod");
|
|
5
|
+
//#region ../types/dist/esm/capabilities/database-snapshot.cap.mjs
|
|
6
|
+
/**
|
|
7
|
+
* The suffix of a verified snapshot, written next to the live database it
|
|
8
|
+
* copies: `<db>.backup-snapshot`. A restore promotes it back over `<db>`
|
|
9
|
+
* (`server/backend/src/sqlite-restore.ts` spells the same string — the
|
|
10
|
+
* launcher stays free of `@camstack/*` runtime imports — and a spec pins the
|
|
11
|
+
* two together).
|
|
12
|
+
*/
|
|
13
|
+
var DATABASE_SNAPSHOT_SUFFIX = ".backup-snapshot";
|
|
14
|
+
/**
|
|
15
|
+
* The suffix of a copy still being written or verified. A file under this name
|
|
16
|
+
* is never archived and never promoted: only a copy that passed every check is
|
|
17
|
+
* renamed to {@link DATABASE_SNAPSHOT_SUFFIX}.
|
|
18
|
+
*/
|
|
19
|
+
var DATABASE_SNAPSHOT_PARTIAL_SUFFIX = ".backup-snapshot-partial";
|
|
20
|
+
/**
|
|
21
|
+
* How long one snapshot may take end to end: the pinned copy of the whole
|
|
22
|
+
* database plus `PRAGMA integrity_check` over the copy, on the hub's slowest
|
|
23
|
+
* disk. ~800 MB at a pessimistic 10 MB/s is under 3 minutes; the bound is
|
|
24
|
+
* generous because a timeout fails the whole backup run.
|
|
25
|
+
*/
|
|
26
|
+
var DATABASE_SNAPSHOT_TIMEOUT_MS = 30 * 6e4;
|
|
27
|
+
/**
|
|
28
|
+
* The databases an owner snapshots — declared by the OWNER, so a caller never
|
|
29
|
+
* guesses which file is live from what sits beside it (a cleanly closed
|
|
30
|
+
* database has no sidecars and is just as owned). Paths are absolute on the
|
|
31
|
+
* owner's host.
|
|
32
|
+
*/
|
|
33
|
+
var DatabaseSnapshotTargetsSchema = /* @__PURE__ */ zod.z.object({ databases: /* @__PURE__ */ zod.z.array(/* @__PURE__ */ zod.z.object({
|
|
34
|
+
/** Which owned file this is — the handle `writeSnapshot` takes. */
|
|
35
|
+
databaseId: require_settings_store_cap.DataStoreDatabaseSchema,
|
|
36
|
+
livePath: /* @__PURE__ */ zod.z.string()
|
|
37
|
+
})) });
|
|
38
|
+
/** One b-tree table of the snapshot and the rows it holds. */
|
|
39
|
+
var DatabaseSnapshotTableSchema = /* @__PURE__ */ zod.z.object({
|
|
40
|
+
name: /* @__PURE__ */ zod.z.string(),
|
|
41
|
+
rows: /* @__PURE__ */ zod.z.number().int().nonnegative()
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* What the owner wrote. Every path is ABSOLUTE on the owner's host — the
|
|
45
|
+
* caller pins the call to its own node, so it can read the file; a caller
|
|
46
|
+
* that finds the path outside its own data root refuses it rather than
|
|
47
|
+
* archiving something it cannot place.
|
|
48
|
+
*/
|
|
49
|
+
var DatabaseSnapshotResultSchema = /* @__PURE__ */ zod.z.object({
|
|
50
|
+
/** The live database the snapshot copies. Never to be copied as a file. */
|
|
51
|
+
livePath: /* @__PURE__ */ zod.z.string(),
|
|
52
|
+
/** The verified copy: `<livePath>` + {@link DATABASE_SNAPSHOT_SUFFIX}. */
|
|
53
|
+
snapshotPath: /* @__PURE__ */ zod.z.string(),
|
|
54
|
+
sizeBytes: /* @__PURE__ */ zod.z.number().int().nonnegative(),
|
|
55
|
+
pageCount: /* @__PURE__ */ zod.z.number().int().nonnegative(),
|
|
56
|
+
pageSize: /* @__PURE__ */ zod.z.number().int().positive(),
|
|
57
|
+
/**
|
|
58
|
+
* Every b-tree table with its row count. Read inside the SAME read
|
|
59
|
+
* transaction the copy was taken from, and found EQUAL on the copy — so
|
|
60
|
+
* this is the content of the snapshot, not an estimate of the source.
|
|
61
|
+
*/
|
|
62
|
+
tables: /* @__PURE__ */ zod.z.array(DatabaseSnapshotTableSchema),
|
|
63
|
+
/** Wall time of the pinned copy (row counts included). */
|
|
64
|
+
copyMs: /* @__PURE__ */ zod.z.number().nonnegative(),
|
|
65
|
+
/** Wall time of the checks on the copy (`integrity_check`, row counts). */
|
|
66
|
+
verifyMs: /* @__PURE__ */ zod.z.number().nonnegative(),
|
|
67
|
+
/** When the pinned read transaction began (ms epoch) — the snapshot's instant. */
|
|
68
|
+
takenAt: /* @__PURE__ */ zod.z.number()
|
|
69
|
+
});
|
|
70
|
+
/** A snapshot the owner wrote, with the file it belongs to. */
|
|
71
|
+
var DatabaseSnapshotWrittenSchema = /* @__PURE__ */ DatabaseSnapshotResultSchema.extend({ databaseId: require_settings_store_cap.DataStoreDatabaseSchema });
|
|
72
|
+
/** Which database `writeSnapshot` copies. Required: an unstated ask is not guessed. */
|
|
73
|
+
var DatabaseSnapshotRequestSchema = /* @__PURE__ */ zod.z.object({ databaseId: require_settings_store_cap.DataStoreDatabaseSchema });
|
|
74
|
+
/**
|
|
75
|
+
* A snapshot as an ARCHIVE records it (`ArchiveManifest.sqliteSnapshots`):
|
|
76
|
+
* the same facts, with both paths relative to the archive root (the node's
|
|
77
|
+
* data dir), because an archive outlives the host that made it.
|
|
78
|
+
*/
|
|
79
|
+
var ArchiveSqliteSnapshotSchema = /* @__PURE__ */ DatabaseSnapshotResultSchema.extend({
|
|
80
|
+
/** Archive-relative path of the live database the archive does NOT carry. */
|
|
81
|
+
livePath: /* @__PURE__ */ zod.z.string(),
|
|
82
|
+
/** Archive-relative path of the verified copy it carries in its place. */
|
|
83
|
+
snapshotPath: /* @__PURE__ */ zod.z.string(),
|
|
84
|
+
/** Absent on an archive made before several files were owned: that was `settings`. */
|
|
85
|
+
databaseId: /* @__PURE__ */ require_settings_store_cap.DataStoreDatabaseSchema.optional()
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* database-snapshot — the OWNER of a live SQLite database writes a consistent,
|
|
89
|
+
* verified copy of it (D693).
|
|
90
|
+
*
|
|
91
|
+
* A live database cannot be copied as files: three files written by a live
|
|
92
|
+
* process cannot be read at one instant from outside it, and a tar of the
|
|
93
|
+
* `.db` / `-wal` / `-shm` trio was measured torn in 6/6 archives (D679). Nor may
|
|
94
|
+
* another process open it (D679 rule 2). So the process that owns the
|
|
95
|
+
* connection writes the copy — through its own connection, on a thread,
|
|
96
|
+
* pinned to one read transaction — and checks it before handing it out.
|
|
97
|
+
*
|
|
98
|
+
* Hub-only and internal: `sqlite-settings` is the registrant, and its consumer
|
|
99
|
+
* is `backup-orchestrator`, which calls it pinned to its own node so the path
|
|
100
|
+
* it gets back is on its own host. `auth: 'admin'` explicitly — `internal`
|
|
101
|
+
* does not gate the mount (see `data-store-provider`).
|
|
102
|
+
*/
|
|
103
|
+
var databaseSnapshotCapability = {
|
|
104
|
+
name: "database-snapshot",
|
|
105
|
+
scope: "system",
|
|
106
|
+
mode: "singleton",
|
|
107
|
+
internal: true,
|
|
108
|
+
methods: {
|
|
109
|
+
/**
|
|
110
|
+
* EVERY database file this owner has open, with its id. Answered from
|
|
111
|
+
* memory — no file is touched — so a backup can ask it before deciding
|
|
112
|
+
* anything. A file created at runtime is listed from the moment it opens,
|
|
113
|
+
* so no backup can leave it out (D693).
|
|
114
|
+
*/
|
|
115
|
+
listDatabases: /* @__PURE__ */ require_capability_definition.method(/* @__PURE__ */ zod.z.object({}), DatabaseSnapshotTargetsSchema, { auth: "admin" }),
|
|
116
|
+
/**
|
|
117
|
+
* Write `<db>.backup-snapshot` for ONE database and return what it holds.
|
|
118
|
+
* Throws — and leaves no file under the final name — when the copy fails
|
|
119
|
+
* `integrity_check` or its row counts differ from the pinned source's, or
|
|
120
|
+
* when the database is not open. A second call for the SAME database while
|
|
121
|
+
* one is running joins it; different databases run one after the other
|
|
122
|
+
* (the disk reserve check is per copy).
|
|
123
|
+
*/
|
|
124
|
+
writeSnapshot: /* @__PURE__ */ require_capability_definition.method(DatabaseSnapshotRequestSchema, DatabaseSnapshotWrittenSchema, {
|
|
125
|
+
kind: "mutation",
|
|
126
|
+
auth: "admin",
|
|
127
|
+
timeoutMs: DATABASE_SNAPSHOT_TIMEOUT_MS
|
|
128
|
+
})
|
|
129
|
+
},
|
|
130
|
+
vocabulary: { notOperatorFacing: require_system_reasons.NOT_A_DEVICE.INTERNAL }
|
|
131
|
+
};
|
|
132
|
+
//#endregion
|
|
133
|
+
Object.defineProperty(exports, "ArchiveSqliteSnapshotSchema", {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
get: function() {
|
|
136
|
+
return ArchiveSqliteSnapshotSchema;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
Object.defineProperty(exports, "DATABASE_SNAPSHOT_PARTIAL_SUFFIX", {
|
|
140
|
+
enumerable: true,
|
|
141
|
+
get: function() {
|
|
142
|
+
return DATABASE_SNAPSHOT_PARTIAL_SUFFIX;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
Object.defineProperty(exports, "DATABASE_SNAPSHOT_SUFFIX", {
|
|
146
|
+
enumerable: true,
|
|
147
|
+
get: function() {
|
|
148
|
+
return DATABASE_SNAPSHOT_SUFFIX;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
Object.defineProperty(exports, "DATABASE_SNAPSHOT_TIMEOUT_MS", {
|
|
152
|
+
enumerable: true,
|
|
153
|
+
get: function() {
|
|
154
|
+
return DATABASE_SNAPSHOT_TIMEOUT_MS;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
Object.defineProperty(exports, "databaseSnapshotCapability", {
|
|
158
|
+
enumerable: true,
|
|
159
|
+
get: function() {
|
|
160
|
+
return databaseSnapshotCapability;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { c as method } from "./capability-definition-C2rJdVeX.mjs";
|
|
2
|
+
import { t as NOT_A_DEVICE } from "./system-reasons-CYj4qwyS.mjs";
|
|
3
|
+
import { a as DataStoreDatabaseSchema } from "./settings-store.cap-Ci4F2zul.mjs";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region ../types/dist/esm/capabilities/database-snapshot.cap.mjs
|
|
6
|
+
/**
|
|
7
|
+
* The suffix of a verified snapshot, written next to the live database it
|
|
8
|
+
* copies: `<db>.backup-snapshot`. A restore promotes it back over `<db>`
|
|
9
|
+
* (`server/backend/src/sqlite-restore.ts` spells the same string — the
|
|
10
|
+
* launcher stays free of `@camstack/*` runtime imports — and a spec pins the
|
|
11
|
+
* two together).
|
|
12
|
+
*/
|
|
13
|
+
var DATABASE_SNAPSHOT_SUFFIX = ".backup-snapshot";
|
|
14
|
+
/**
|
|
15
|
+
* The suffix of a copy still being written or verified. A file under this name
|
|
16
|
+
* is never archived and never promoted: only a copy that passed every check is
|
|
17
|
+
* renamed to {@link DATABASE_SNAPSHOT_SUFFIX}.
|
|
18
|
+
*/
|
|
19
|
+
var DATABASE_SNAPSHOT_PARTIAL_SUFFIX = ".backup-snapshot-partial";
|
|
20
|
+
/**
|
|
21
|
+
* How long one snapshot may take end to end: the pinned copy of the whole
|
|
22
|
+
* database plus `PRAGMA integrity_check` over the copy, on the hub's slowest
|
|
23
|
+
* disk. ~800 MB at a pessimistic 10 MB/s is under 3 minutes; the bound is
|
|
24
|
+
* generous because a timeout fails the whole backup run.
|
|
25
|
+
*/
|
|
26
|
+
var DATABASE_SNAPSHOT_TIMEOUT_MS = 30 * 6e4;
|
|
27
|
+
/**
|
|
28
|
+
* The databases an owner snapshots — declared by the OWNER, so a caller never
|
|
29
|
+
* guesses which file is live from what sits beside it (a cleanly closed
|
|
30
|
+
* database has no sidecars and is just as owned). Paths are absolute on the
|
|
31
|
+
* owner's host.
|
|
32
|
+
*/
|
|
33
|
+
var DatabaseSnapshotTargetsSchema = /* @__PURE__ */ z.object({ databases: /* @__PURE__ */ z.array(/* @__PURE__ */ z.object({
|
|
34
|
+
/** Which owned file this is — the handle `writeSnapshot` takes. */
|
|
35
|
+
databaseId: DataStoreDatabaseSchema,
|
|
36
|
+
livePath: /* @__PURE__ */ z.string()
|
|
37
|
+
})) });
|
|
38
|
+
/** One b-tree table of the snapshot and the rows it holds. */
|
|
39
|
+
var DatabaseSnapshotTableSchema = /* @__PURE__ */ z.object({
|
|
40
|
+
name: /* @__PURE__ */ z.string(),
|
|
41
|
+
rows: /* @__PURE__ */ z.number().int().nonnegative()
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* What the owner wrote. Every path is ABSOLUTE on the owner's host — the
|
|
45
|
+
* caller pins the call to its own node, so it can read the file; a caller
|
|
46
|
+
* that finds the path outside its own data root refuses it rather than
|
|
47
|
+
* archiving something it cannot place.
|
|
48
|
+
*/
|
|
49
|
+
var DatabaseSnapshotResultSchema = /* @__PURE__ */ z.object({
|
|
50
|
+
/** The live database the snapshot copies. Never to be copied as a file. */
|
|
51
|
+
livePath: /* @__PURE__ */ z.string(),
|
|
52
|
+
/** The verified copy: `<livePath>` + {@link DATABASE_SNAPSHOT_SUFFIX}. */
|
|
53
|
+
snapshotPath: /* @__PURE__ */ z.string(),
|
|
54
|
+
sizeBytes: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
55
|
+
pageCount: /* @__PURE__ */ z.number().int().nonnegative(),
|
|
56
|
+
pageSize: /* @__PURE__ */ z.number().int().positive(),
|
|
57
|
+
/**
|
|
58
|
+
* Every b-tree table with its row count. Read inside the SAME read
|
|
59
|
+
* transaction the copy was taken from, and found EQUAL on the copy — so
|
|
60
|
+
* this is the content of the snapshot, not an estimate of the source.
|
|
61
|
+
*/
|
|
62
|
+
tables: /* @__PURE__ */ z.array(DatabaseSnapshotTableSchema),
|
|
63
|
+
/** Wall time of the pinned copy (row counts included). */
|
|
64
|
+
copyMs: /* @__PURE__ */ z.number().nonnegative(),
|
|
65
|
+
/** Wall time of the checks on the copy (`integrity_check`, row counts). */
|
|
66
|
+
verifyMs: /* @__PURE__ */ z.number().nonnegative(),
|
|
67
|
+
/** When the pinned read transaction began (ms epoch) — the snapshot's instant. */
|
|
68
|
+
takenAt: /* @__PURE__ */ z.number()
|
|
69
|
+
});
|
|
70
|
+
/** A snapshot the owner wrote, with the file it belongs to. */
|
|
71
|
+
var DatabaseSnapshotWrittenSchema = /* @__PURE__ */ DatabaseSnapshotResultSchema.extend({ databaseId: DataStoreDatabaseSchema });
|
|
72
|
+
/** Which database `writeSnapshot` copies. Required: an unstated ask is not guessed. */
|
|
73
|
+
var DatabaseSnapshotRequestSchema = /* @__PURE__ */ z.object({ databaseId: DataStoreDatabaseSchema });
|
|
74
|
+
/**
|
|
75
|
+
* A snapshot as an ARCHIVE records it (`ArchiveManifest.sqliteSnapshots`):
|
|
76
|
+
* the same facts, with both paths relative to the archive root (the node's
|
|
77
|
+
* data dir), because an archive outlives the host that made it.
|
|
78
|
+
*/
|
|
79
|
+
var ArchiveSqliteSnapshotSchema = /* @__PURE__ */ DatabaseSnapshotResultSchema.extend({
|
|
80
|
+
/** Archive-relative path of the live database the archive does NOT carry. */
|
|
81
|
+
livePath: /* @__PURE__ */ z.string(),
|
|
82
|
+
/** Archive-relative path of the verified copy it carries in its place. */
|
|
83
|
+
snapshotPath: /* @__PURE__ */ z.string(),
|
|
84
|
+
/** Absent on an archive made before several files were owned: that was `settings`. */
|
|
85
|
+
databaseId: /* @__PURE__ */ DataStoreDatabaseSchema.optional()
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* database-snapshot — the OWNER of a live SQLite database writes a consistent,
|
|
89
|
+
* verified copy of it (D693).
|
|
90
|
+
*
|
|
91
|
+
* A live database cannot be copied as files: three files written by a live
|
|
92
|
+
* process cannot be read at one instant from outside it, and a tar of the
|
|
93
|
+
* `.db` / `-wal` / `-shm` trio was measured torn in 6/6 archives (D679). Nor may
|
|
94
|
+
* another process open it (D679 rule 2). So the process that owns the
|
|
95
|
+
* connection writes the copy — through its own connection, on a thread,
|
|
96
|
+
* pinned to one read transaction — and checks it before handing it out.
|
|
97
|
+
*
|
|
98
|
+
* Hub-only and internal: `sqlite-settings` is the registrant, and its consumer
|
|
99
|
+
* is `backup-orchestrator`, which calls it pinned to its own node so the path
|
|
100
|
+
* it gets back is on its own host. `auth: 'admin'` explicitly — `internal`
|
|
101
|
+
* does not gate the mount (see `data-store-provider`).
|
|
102
|
+
*/
|
|
103
|
+
var databaseSnapshotCapability = {
|
|
104
|
+
name: "database-snapshot",
|
|
105
|
+
scope: "system",
|
|
106
|
+
mode: "singleton",
|
|
107
|
+
internal: true,
|
|
108
|
+
methods: {
|
|
109
|
+
/**
|
|
110
|
+
* EVERY database file this owner has open, with its id. Answered from
|
|
111
|
+
* memory — no file is touched — so a backup can ask it before deciding
|
|
112
|
+
* anything. A file created at runtime is listed from the moment it opens,
|
|
113
|
+
* so no backup can leave it out (D693).
|
|
114
|
+
*/
|
|
115
|
+
listDatabases: /* @__PURE__ */ method(/* @__PURE__ */ z.object({}), DatabaseSnapshotTargetsSchema, { auth: "admin" }),
|
|
116
|
+
/**
|
|
117
|
+
* Write `<db>.backup-snapshot` for ONE database and return what it holds.
|
|
118
|
+
* Throws — and leaves no file under the final name — when the copy fails
|
|
119
|
+
* `integrity_check` or its row counts differ from the pinned source's, or
|
|
120
|
+
* when the database is not open. A second call for the SAME database while
|
|
121
|
+
* one is running joins it; different databases run one after the other
|
|
122
|
+
* (the disk reserve check is per copy).
|
|
123
|
+
*/
|
|
124
|
+
writeSnapshot: /* @__PURE__ */ method(DatabaseSnapshotRequestSchema, DatabaseSnapshotWrittenSchema, {
|
|
125
|
+
kind: "mutation",
|
|
126
|
+
auth: "admin",
|
|
127
|
+
timeoutMs: DATABASE_SNAPSHOT_TIMEOUT_MS
|
|
128
|
+
})
|
|
129
|
+
},
|
|
130
|
+
vocabulary: { notOperatorFacing: NOT_A_DEVICE.INTERNAL }
|
|
131
|
+
};
|
|
132
|
+
//#endregion
|
|
133
|
+
export { databaseSnapshotCapability as a, DATABASE_SNAPSHOT_TIMEOUT_MS as i, DATABASE_SNAPSHOT_PARTIAL_SUFFIX as n, DATABASE_SNAPSHOT_SUFFIX as r, ArchiveSqliteSnapshotSchema as t };
|