@camstack/system 1.2.56 → 1.2.58
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/dist/addon-runner.js +1 -1
- package/dist/addon-runner.mjs +1 -1
- package/dist/addon-utils.js +1 -1
- package/dist/addon-utils.mjs +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +2 -2
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +2 -2
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +2 -2
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +2 -2
- package/dist/builtins/alerts/alerts.addon.js +1 -1
- package/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/dist/builtins/console-logging/index.js +1 -1
- package/dist/builtins/console-logging/index.mjs +1 -1
- package/dist/builtins/core-blocks/core-blocks.addon.js +2 -2
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
- package/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
- package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/dist/builtins/local-auth/local-auth.addon.js +1 -1
- package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
- package/dist/builtins/local-network/local-network.addon.js +1 -1
- package/dist/builtins/local-network/local-network.addon.mjs +1 -1
- package/dist/builtins/loki-logging/index.js +1 -1
- package/dist/builtins/loki-logging/index.mjs +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/dist/builtins/platform-probe/index.js +1 -1
- package/dist/builtins/platform-probe/index.mjs +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/dist/builtins/snapshot/index.js +1 -1
- package/dist/builtins/snapshot/index.mjs +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +2 -2
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +2 -2
- package/dist/builtins/sqlite-storage/index.d.ts +3 -0
- package/dist/builtins/sqlite-storage/index.js +8 -0
- package/dist/builtins/sqlite-storage/index.mjs +2 -2
- package/dist/builtins/sqlite-storage/sqlite-pragmas.d.ts +85 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts +1 -0
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +304 -1
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +297 -2
- package/dist/builtins/sqlite-storage/wal-maintenance.d.ts +113 -0
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/dist/builtins/system-config/system-config.addon.js +1 -1
- package/dist/builtins/system-config/system-config.addon.mjs +1 -1
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{dist-CblJsHb-.js → dist-Chl2MvMd.js} +692 -25
- package/dist/{dist-BOpRqInW.mjs → dist-UrXyJ9Zm.mjs} +692 -25
- package/dist/index.js +4 -4
- package/dist/index.mjs +5 -5
- package/dist/kernel/transport/frame-codec.d.ts +43 -2
- package/dist/{manifest-python-deps-Ck4-9K9m.mjs → manifest-python-deps-CX5tGRqf.mjs} +95 -10
- package/dist/{manifest-python-deps-BqE5j0-O.js → manifest-python-deps-d4acYXVV.js} +95 -10
- package/package.json +1 -1
- package/dist/{model-download-service-hf0ookyy.js → model-download-service-Cpc6SWzV.js} +1 -1
- package/dist/{model-download-service-Cp9f4dk6.mjs → model-download-service-D8B-4ktF.mjs} +1 -1
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { IScopedLogger } from '@camstack/types';
|
|
2
|
+
import { default as Database } from 'better-sqlite3';
|
|
3
|
+
/**
|
|
4
|
+
* Size at or above which the WAL is a candidate for a truncating checkpoint,
|
|
5
|
+
* in bytes. 67108864 = **64 MiB**.
|
|
6
|
+
*
|
|
7
|
+
* Matched to `SQLITE_JOURNAL_SIZE_LIMIT_BYTES`: below this, the passive
|
|
8
|
+
* mechanism (autocheckpoint + `journal_size_limit`) is doing its job and there
|
|
9
|
+
* is nothing to reclaim. The live hub's WAL had reached 248,955,152 bytes —
|
|
10
|
+
* roughly 2x the 130 MB database — which is what says the passive path alone
|
|
11
|
+
* had stopped keeping up.
|
|
12
|
+
*/
|
|
13
|
+
export declare const WAL_HIGH_WATER_BYTES = 67108864;
|
|
14
|
+
/**
|
|
15
|
+
* How long the WAL must have gone UNWRITTEN before a truncating checkpoint is
|
|
16
|
+
* allowed, in ms.
|
|
17
|
+
*
|
|
18
|
+
* This is the stall guard and the reason this file exists. `wal_checkpoint
|
|
19
|
+
* (TRUNCATE)` takes the writer lock, waits for readers, and copies the whole
|
|
20
|
+
* WAL back into the database — synchronously, on the thread that serves every
|
|
21
|
+
* request. An unconditional periodic one on a busy NVR would be the disease
|
|
22
|
+
* (hub-main already spends 42 s per 2 minutes inside uninterrupted blocks),
|
|
23
|
+
* not the cure.
|
|
24
|
+
*
|
|
25
|
+
* The idle signal is the WAL file's own mtime. It is one `stat`, and unlike a
|
|
26
|
+
* write counter maintained in this class it covers EVERY writer on the file —
|
|
27
|
+
* the settings backend, the sqlite-vec index sharing the handle, and the
|
|
28
|
+
* short-lived second connection system-backup opens. On a genuinely busy NVR
|
|
29
|
+
* this gate simply never opens, and `journal_size_limit` remains the only
|
|
30
|
+
* thing bounding the file. That is the intended failure mode: doing nothing is
|
|
31
|
+
* strictly better than a 249 MB copy in the middle of a live request.
|
|
32
|
+
*/
|
|
33
|
+
export declare const WAL_IDLE_QUIET_MS = 30000;
|
|
34
|
+
/**
|
|
35
|
+
* Ceiling on how long the checkpoint may wait for a lock, in ms.
|
|
36
|
+
*
|
|
37
|
+
* better-sqlite3 defaults `busy_timeout` to 5000. A checkpoint invokes the
|
|
38
|
+
* busy handler while waiting for readers, so without this a "quiet" moment
|
|
39
|
+
* that turns out not to be quiet could park the main thread for 5 s. 250 ms
|
|
40
|
+
* means the checkpoint gives up and we try again on the next tick — the WAL
|
|
41
|
+
* staying big for another minute costs nothing.
|
|
42
|
+
*/
|
|
43
|
+
export declare const WAL_CHECKPOINT_BUSY_TIMEOUT_MS = 250;
|
|
44
|
+
/** How often the gate is evaluated, in ms. Cheap: a `stat` unless it fires. */
|
|
45
|
+
export declare const WAL_MAINTENANCE_INTERVAL_MS = 60000;
|
|
46
|
+
/** What a single maintenance tick did. Every branch is named. */
|
|
47
|
+
export type WalMaintenanceOutcome = {
|
|
48
|
+
readonly kind: 'no-wal';
|
|
49
|
+
} | {
|
|
50
|
+
readonly kind: 'below-high-water';
|
|
51
|
+
readonly walBytes: number;
|
|
52
|
+
} | {
|
|
53
|
+
readonly kind: 'deferred-not-idle';
|
|
54
|
+
readonly walBytes: number;
|
|
55
|
+
readonly quietForMs: number;
|
|
56
|
+
} | {
|
|
57
|
+
readonly kind: 'checkpointed';
|
|
58
|
+
readonly beforeBytes: number;
|
|
59
|
+
readonly afterBytes: number;
|
|
60
|
+
readonly busy: boolean;
|
|
61
|
+
readonly walFrames: number;
|
|
62
|
+
readonly checkpointedFrames: number;
|
|
63
|
+
} | {
|
|
64
|
+
readonly kind: 'failed';
|
|
65
|
+
readonly error: string;
|
|
66
|
+
};
|
|
67
|
+
/** Construction inputs for {@link WalMaintenance}. */
|
|
68
|
+
export interface WalMaintenanceOptions {
|
|
69
|
+
readonly db: Database.Database;
|
|
70
|
+
/** Path to the main database file; the WAL is `${dbPath}-wal`. */
|
|
71
|
+
readonly dbPath: string;
|
|
72
|
+
readonly logger: IScopedLogger;
|
|
73
|
+
readonly highWaterBytes?: number;
|
|
74
|
+
readonly idleQuietMs?: number;
|
|
75
|
+
readonly intervalMs?: number;
|
|
76
|
+
readonly busyTimeoutMs?: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Periodic, heavily gated `wal_checkpoint(TRUNCATE)`.
|
|
80
|
+
*
|
|
81
|
+
* The interesting behaviour is all refusal. A tick costs one `stat` in the
|
|
82
|
+
* common case; it escalates to a lock-taking checkpoint only when the WAL is
|
|
83
|
+
* over the high-water mark AND nothing has written to it for
|
|
84
|
+
* {@link WAL_IDLE_QUIET_MS}, and even then the wait is bounded to
|
|
85
|
+
* {@link WAL_CHECKPOINT_BUSY_TIMEOUT_MS}.
|
|
86
|
+
*/
|
|
87
|
+
export declare class WalMaintenance {
|
|
88
|
+
private readonly db;
|
|
89
|
+
private readonly walPath;
|
|
90
|
+
private readonly logger;
|
|
91
|
+
private readonly highWaterBytes;
|
|
92
|
+
private readonly idleQuietMs;
|
|
93
|
+
private readonly intervalMs;
|
|
94
|
+
private readonly busyTimeoutMs;
|
|
95
|
+
private timer;
|
|
96
|
+
constructor(options: WalMaintenanceOptions);
|
|
97
|
+
start(): void;
|
|
98
|
+
stop(): void;
|
|
99
|
+
isRunning(): boolean;
|
|
100
|
+
/** Evaluate the gate once and act. Never throws. */
|
|
101
|
+
runOnce(): WalMaintenanceOutcome;
|
|
102
|
+
private evaluate;
|
|
103
|
+
/**
|
|
104
|
+
* Take the writer lock and fold the WAL back, with the wait bounded.
|
|
105
|
+
*
|
|
106
|
+
* The original `busy_timeout` is restored in a `finally`: this connection is
|
|
107
|
+
* shared with the settings backend and the vector index, and leaving them on
|
|
108
|
+
* a 250 ms timeout would turn an ordinary contended write into a spurious
|
|
109
|
+
* SQLITE_BUSY.
|
|
110
|
+
*/
|
|
111
|
+
private checkpoint;
|
|
112
|
+
private statWal;
|
|
113
|
+
}
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-Chl2MvMd.js");
|
|
7
7
|
let node_path = require("node:path");
|
|
8
8
|
node_path = require_chunk.__toESM(node_path);
|
|
9
9
|
let node_fs_promises = require("node:fs/promises");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dt as BaseAddon, et as settingsStoreCapability, f as StorageLocationTypeSchema, jt as parseJsonObject, nt as storageCapability } from "../../dist-
|
|
1
|
+
import { dt as BaseAddon, et as settingsStoreCapability, f as StorageLocationTypeSchema, jt as parseJsonObject, nt as storageCapability } from "../../dist-UrXyJ9Zm.mjs";
|
|
2
2
|
import * as path$1 from "node:path";
|
|
3
3
|
import * as fs from "node:fs/promises";
|
|
4
4
|
import { buildStorageLocationRegistry } from "@camstack/system";
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-Chl2MvMd.js");
|
|
7
7
|
//#region src/builtins/system-config/system-config.addon.ts
|
|
8
8
|
/**
|
|
9
9
|
* Built-in `system-config` addon — Phase 4 of the settings redesign.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ot as hydrateSchema, dt as BaseAddon, ut as errMsg } from "../../dist-
|
|
1
|
+
import { Ot as hydrateSchema, dt as BaseAddon, ut as errMsg } from "../../dist-UrXyJ9Zm.mjs";
|
|
2
2
|
//#region src/builtins/system-config/system-config.addon.ts
|
|
3
3
|
/**
|
|
4
4
|
* Built-in `system-config` addon — Phase 4 of the settings redesign.
|
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-Chl2MvMd.js");
|
|
7
7
|
const require_formatter = require("../../formatter-DqAKDlvN.js");
|
|
8
8
|
let node_path = require("node:path");
|
|
9
9
|
node_path = require_chunk.__toESM(node_path);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { U as logDestinationCapability, dt as BaseAddon } from "../../dist-
|
|
1
|
+
import { U as logDestinationCapability, dt as BaseAddon } from "../../dist-UrXyJ9Zm.mjs";
|
|
2
2
|
import { t as formatLogLine } from "../../formatter-B7qW8bPJ.mjs";
|
|
3
3
|
import * as path$1 from "node:path";
|
|
4
4
|
import path from "node:path";
|