@camstack/server 1.2.728 → 1.2.730
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 +19 -0
- package/dist/agent/main.js +2 -14
- package/dist/api/core/cap-providers.js +0 -7
- package/dist/api/trpc/generated-cap-mounts.js +4 -1
- package/dist/api/trpc/generated-cap-routers.js +1923 -1839
- package/dist/boot/boot-config.js +1 -1
- package/dist/core/addon/addon-package.service.js +3 -105
- package/dist/core/addon-bridge/addon-bridge.service.js +1 -5
- package/dist/launcher.js +12 -124
- package/package.json +19 -17
- package/system/dist/addon-runner.js +1 -2
- package/system/dist/addon-runner.mjs +1 -2
- package/system/dist/{agent-https-B1XLr4nm.js → agent-https-C8Gz2jjS.js} +1 -1
- package/system/dist/{agent-https-BsedJhrb.mjs → agent-https-DZq8uf8L.mjs} +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composer.addon.js +3 -3
- package/system/dist/builtins/composer/composer.addon.mjs +3 -3
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +6 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +1361 -440
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +1360 -440
- package/system/dist/builtins/core-blocks/fan-presets-action-source.d.ts +35 -0
- package/system/dist/builtins/core-blocks/fan-presets-service.d.ts +83 -0
- package/system/dist/builtins/core-blocks/fan-presets-wiring.d.ts +31 -0
- package/system/dist/builtins/core-blocks/record-kinds.d.ts +15 -0
- package/system/dist/builtins/core-blocks/timed-run/timed-run-service.d.ts +84 -0
- package/system/dist/builtins/core-blocks/timed-run/timed-run-wiring.d.ts +21 -0
- package/system/dist/builtins/device-history/device-history.addon.d.ts +4 -0
- package/system/dist/builtins/device-history/device-history.addon.js +769 -17
- package/system/dist/builtins/device-history/device-history.addon.mjs +769 -17
- package/system/dist/builtins/device-history/runs/device-runs-provider.d.ts +7 -0
- package/system/dist/builtins/device-history/runs/device-runs-record-kinds.d.ts +15 -0
- package/system/dist/builtins/device-history/runs/device-runs-service.d.ts +42 -0
- package/system/dist/builtins/device-history/runs/energy-from-history.d.ts +22 -0
- package/system/dist/builtins/device-history/runs/run-recorder.d.ts +111 -0
- package/system/dist/builtins/device-history/runs/slice-readers.d.ts +9 -0
- package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +47 -38
- package/system/dist/builtins/keychain/index.mjs +47 -38
- package/system/dist/builtins/keychain/key-sources.d.ts +12 -7
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +3 -3
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +3 -3
- package/system/dist/builtins/local-network/local-network.addon.js +2 -2
- package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- 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 +2 -2
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2 -2
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{composition-sources-BjuQ3xot.mjs → composition-sources-4M_NnTnV.mjs} +1 -1
- package/system/dist/{composition-sources-C5r8i46e.js → composition-sources-hokiaS3J.js} +1 -1
- package/system/dist/{constants-Bh5wQoTg.js → constants-B0L3suFC.js} +1 -1
- package/system/dist/{constants-GnxjCxT3.mjs → constants-DTVU00LZ.mjs} +1 -1
- package/system/dist/{device-ca-OWEYAYaG.mjs → device-ca-C_y2GrU5.mjs} +2 -2
- package/system/dist/{device-ca-oM-nuINR.js → device-ca-DaTT1Y9v.js} +2 -2
- package/system/dist/{dist-Cw8KtuQY.mjs → dist-9lvgpcnm.mjs} +43394 -42706
- package/system/dist/{dist-B9xpybTG.js → dist-B3S0ruBa.js} +43217 -42457
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-BPENkOKX.js → hub-mdns-ciao-Dkw38L-g.js} +2 -2
- package/system/dist/{hub-mdns-ciao-C3qMZFP0.mjs → hub-mdns-ciao-xgLfZIVx.mjs} +2 -2
- package/system/dist/index.js +40 -186
- package/system/dist/index.mjs +41 -185
- package/system/dist/kernel/addon-installer.d.ts +9 -60
- package/system/dist/kernel/bootstrap-config.d.ts +3 -1
- package/system/dist/kernel/config-schema.d.ts +2 -11
- package/system/dist/kernel/fs-utils.d.ts +0 -6
- package/system/dist/kernel/index.d.ts +2 -3
- package/system/dist/{restore-archive-DJv5ATV8.mjs → restore-archive-cxnuWxQM.mjs} +1 -1
- package/system/dist/{restore-archive-BiN1yKZV.js → restore-archive-orP6eHBd.js} +1 -1
- package/system/dist/{retention-BT7TgsUn.js → retention-CB2cyW9k.js} +1 -1
- package/system/dist/{retention-DQje-V4I.mjs → retention-Me4u6zMp.mjs} +1 -1
- package/system/dist/{wal-maintenance-DM08Htuy.mjs → wal-maintenance-De7Ifvph.mjs} +0 -0
- package/system/dist/{wal-maintenance-BLwgOIXb.js → wal-maintenance-_PXj626-.js} +0 -0
- package/system/package.json +11 -2
- package/system/dist/kernel/workspace-detect.d.ts +0 -9
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lists every fan preset as an `action-source` entry so the surfaces that
|
|
3
|
+
* publish actions (a scene, a switch, a button — D968) offer "set the fan to
|
|
4
|
+
* Night" without knowing what a fan preset is. The entry id is
|
|
5
|
+
* `<addonId>:fan-preset:<deviceId>/<presetId>`; running it applies the preset
|
|
6
|
+
* and FAILS the run when any step did not apply, naming the first one.
|
|
7
|
+
*/
|
|
8
|
+
import { type ActionEntry, type IActionSourceProvider, type IFanPresetsProvider, type IScopedLogger } from "@camstack/types";
|
|
9
|
+
import type { FanPresetsDevices, FanPresetsStore } from "./fan-presets-service.js";
|
|
10
|
+
export interface FanPresetActionSourceDeps {
|
|
11
|
+
readonly presets: Pick<IFanPresetsProvider, "applyPreset">;
|
|
12
|
+
readonly devices: Pick<FanPresetsDevices, "describe">;
|
|
13
|
+
readonly store: Pick<FanPresetsStore, "listAll">;
|
|
14
|
+
/** The addon that declares the entries (the id prefix). */
|
|
15
|
+
readonly addonId: string;
|
|
16
|
+
readonly logger: IScopedLogger;
|
|
17
|
+
}
|
|
18
|
+
interface ParsedPresetAction {
|
|
19
|
+
readonly deviceId: number;
|
|
20
|
+
readonly presetId: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function fanPresetActionId(addonId: string, deviceId: number, presetId: string): string;
|
|
23
|
+
export declare function parseFanPresetActionId(addonId: string, actionId: string): ParsedPresetAction | null;
|
|
24
|
+
export declare class FanPresetActionSource implements IActionSourceProvider {
|
|
25
|
+
private readonly deps;
|
|
26
|
+
constructor(deps: FanPresetActionSourceDeps);
|
|
27
|
+
listActions(_input: Record<string, never>): Promise<ActionEntry[]>;
|
|
28
|
+
runAction(input: {
|
|
29
|
+
actionId: string;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
stopAction(input: {
|
|
32
|
+
actionId: string;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `fan-presets` cap: named settings an operator composes for a fan — its
|
|
3
|
+
* own fields (speed, oscillation, direction, native preset) and the devices
|
|
4
|
+
* that sit in the same container (a light, a control). A preset is a short
|
|
5
|
+
* sequence of action steps kept in the fan's settings store (D865, key
|
|
6
|
+
* `fanPresets`).
|
|
7
|
+
*
|
|
8
|
+
* Decisions that shape this file:
|
|
9
|
+
* - **A step may only touch the fan or one of its siblings.** The sibling
|
|
10
|
+
* set is the children of the fan's parent device (the container), or the
|
|
11
|
+
* fan's own children when it has none. Checked at save AND again at apply,
|
|
12
|
+
* because the container changes after a preset was written.
|
|
13
|
+
* - **Apply runs the shared step runner** (`buildActionSteps` + `runSteps`),
|
|
14
|
+
* in order, stopping at the first failure; every step is reported and a
|
|
15
|
+
* failure names its step (D391). Nothing the operator did not write runs.
|
|
16
|
+
* - **Capture never stores a guess.** A reading that is unknown is left out
|
|
17
|
+
* and named, never written as 0 (D393).
|
|
18
|
+
*/
|
|
19
|
+
import { type CapCall, type ControlStatus, type FanControlStatus, type FanPreset, type IFanPresetsProvider, type IScopedLogger, type SwitchStatus, DeviceType } from "@camstack/types";
|
|
20
|
+
/** The per-device store the presets live in. */
|
|
21
|
+
export interface FanPresetsStore {
|
|
22
|
+
read(deviceId: number): Promise<readonly FanPreset[]>;
|
|
23
|
+
write(deviceId: number, presets: readonly FanPreset[]): Promise<void>;
|
|
24
|
+
/** Every fan that has at least one preset. */
|
|
25
|
+
listAll(): Promise<ReadonlyMap<number, readonly FanPreset[]>>;
|
|
26
|
+
}
|
|
27
|
+
export interface FanPresetDeviceFacts {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly type: DeviceType;
|
|
30
|
+
readonly parentDeviceId: number | null;
|
|
31
|
+
}
|
|
32
|
+
export interface FanPresetsDevices {
|
|
33
|
+
describe(deviceId: number): Promise<FanPresetDeviceFacts | null>;
|
|
34
|
+
childrenOf(parentDeviceId: number): Promise<readonly number[]>;
|
|
35
|
+
}
|
|
36
|
+
/** Current values, each null when no source answers (D393). */
|
|
37
|
+
export interface FanPresetsReadings {
|
|
38
|
+
fan(deviceId: number): Promise<FanControlStatus | null>;
|
|
39
|
+
control(deviceId: number): Promise<ControlStatus | null>;
|
|
40
|
+
switchState(deviceId: number): Promise<SwitchStatus | null>;
|
|
41
|
+
}
|
|
42
|
+
export interface FanPresetsServiceDeps {
|
|
43
|
+
readonly store: FanPresetsStore;
|
|
44
|
+
readonly devices: FanPresetsDevices;
|
|
45
|
+
readonly readings: FanPresetsReadings;
|
|
46
|
+
/** Runs one device cap call; throws when it fails. */
|
|
47
|
+
invoke(call: CapCall): Promise<void>;
|
|
48
|
+
readonly logger: IScopedLogger;
|
|
49
|
+
readonly now?: () => number;
|
|
50
|
+
}
|
|
51
|
+
type SetResult = Awaited<ReturnType<IFanPresetsProvider["setPresets"]>>;
|
|
52
|
+
type ApplyResult = Awaited<ReturnType<IFanPresetsProvider["applyPreset"]>>;
|
|
53
|
+
type CaptureResult = Awaited<ReturnType<IFanPresetsProvider["capturePreset"]>>;
|
|
54
|
+
type CaptureInput = Parameters<IFanPresetsProvider["capturePreset"]>[0];
|
|
55
|
+
export declare class FanPresetsService implements IFanPresetsProvider {
|
|
56
|
+
private readonly deps;
|
|
57
|
+
constructor(deps: FanPresetsServiceDeps);
|
|
58
|
+
getPresets(input: {
|
|
59
|
+
deviceId: number;
|
|
60
|
+
}): Promise<FanPreset[]>;
|
|
61
|
+
setPresets(input: {
|
|
62
|
+
deviceId: number;
|
|
63
|
+
presets: FanPreset[];
|
|
64
|
+
}): Promise<SetResult>;
|
|
65
|
+
applyPreset(input: {
|
|
66
|
+
deviceId: number;
|
|
67
|
+
presetId: string;
|
|
68
|
+
}): Promise<ApplyResult>;
|
|
69
|
+
capturePreset(input: CaptureInput): Promise<CaptureResult>;
|
|
70
|
+
private captureFanFields;
|
|
71
|
+
/** The steps the caller composed, each refreshed with its current value. */
|
|
72
|
+
private captureGiven;
|
|
73
|
+
/** Every switch and control in the fan's container, read as they are now. */
|
|
74
|
+
private captureSiblings;
|
|
75
|
+
private fanFieldStep;
|
|
76
|
+
private siblingStep;
|
|
77
|
+
/** The fan and every device in its container. */
|
|
78
|
+
private siblingsOf;
|
|
79
|
+
private judgeStep;
|
|
80
|
+
/** Every step reported, the offending ones `refused`, nothing run; null when all pass. */
|
|
81
|
+
private refusedSteps;
|
|
82
|
+
}
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the `fan-presets` runtime out of what core-blocks owns: the
|
|
3
|
+
* per-device settings store (D865: a fan's presets live under the key
|
|
4
|
+
* `fanPresets`) and the cluster API (a device's type and container, the
|
|
5
|
+
* current readings, the cap call a step makes).
|
|
6
|
+
*
|
|
7
|
+
* Kept out of `core-blocks.addon.ts` so the seams are read and specced
|
|
8
|
+
* without booting the addon.
|
|
9
|
+
*/
|
|
10
|
+
import { type AddonApi, type AddonContext, type IScopedLogger } from "@camstack/types";
|
|
11
|
+
import { FanPresetActionSource } from "./fan-presets-action-source.js";
|
|
12
|
+
import { FanPresetsService, type FanPresetsDevices, type FanPresetsReadings, type FanPresetsStore } from "./fan-presets-service.js";
|
|
13
|
+
/** The key of the device's settings store that holds a fan's presets. */
|
|
14
|
+
export declare const FAN_PRESETS_STORE_KEY = "fanPresets";
|
|
15
|
+
type DeviceSettings = Pick<NonNullable<AddonContext["settings"]>, "readDeviceStore" | "writeDeviceStore" | "readDeviceStoreBatch" | "listDeviceStoreIds">;
|
|
16
|
+
export interface FanPresetsRuntimeDeps {
|
|
17
|
+
readonly settings: DeviceSettings;
|
|
18
|
+
readonly api: () => AddonApi | undefined;
|
|
19
|
+
readonly addonId: string;
|
|
20
|
+
readonly logger: IScopedLogger;
|
|
21
|
+
}
|
|
22
|
+
export interface FanPresetsRuntime {
|
|
23
|
+
readonly presets: FanPresetsService;
|
|
24
|
+
readonly actionSource: FanPresetActionSource;
|
|
25
|
+
}
|
|
26
|
+
export declare function fanPresetsStoreOver(settings: DeviceSettings, logger: IScopedLogger): FanPresetsStore;
|
|
27
|
+
export declare function fanPresetsDevicesOver(api: () => AddonApi | undefined): FanPresetsDevices;
|
|
28
|
+
/** A reading that errors or does not parse is unknown (null), never a default (D393). */
|
|
29
|
+
export declare function fanPresetsReadingsOver(api: () => AddonApi | undefined, logger: IScopedLogger): FanPresetsReadings;
|
|
30
|
+
export declare function buildFanPresetsRuntime(deps: FanPresetsRuntimeDeps): FanPresetsRuntime;
|
|
31
|
+
export {};
|
|
@@ -65,7 +65,21 @@ export type TemplateRowBody = {
|
|
|
65
65
|
readonly updatedAt: number;
|
|
66
66
|
};
|
|
67
67
|
export declare const TemplateRowBodySchema: z.ZodType<TemplateRowBody>;
|
|
68
|
+
/**
|
|
69
|
+
* A pending timed run (D993): the device is on and the hub owes it an off at
|
|
70
|
+
* `activeUntil`. One row per device, written BEFORE the device is switched on,
|
|
71
|
+
* so a crash can only ever cost a harmless extra off at boot. Row id = the
|
|
72
|
+
* deviceId.
|
|
73
|
+
*/
|
|
74
|
+
export type TimedRunRowBody = {
|
|
75
|
+
readonly activeUntil: number;
|
|
76
|
+
readonly requestedBy: string | null;
|
|
77
|
+
readonly requestedAt: number;
|
|
78
|
+
readonly actuator: "switch" | "pet-fountain";
|
|
79
|
+
};
|
|
80
|
+
export declare const TimedRunRowBodySchema: z.ZodType<TimedRunRowBody>;
|
|
68
81
|
export type CoreBlocksRecordKindsMap = {
|
|
82
|
+
readonly "timed-runs": DefinedRecordKind<z.ZodType<TimedRunRowBody>>;
|
|
69
83
|
readonly blocks: DefinedRecordKind<z.ZodType<CoreBlockRowBody>>;
|
|
70
84
|
readonly runs: DefinedRecordKind<z.ZodType<RunsRowBody>>;
|
|
71
85
|
readonly actions: DefinedRecordKind<z.ZodType<ActionRowBody>>;
|
|
@@ -81,3 +95,4 @@ export declare const coreBlocksSettingsRecordKind: DefinedRecordKind<z.ZodType<C
|
|
|
81
95
|
export declare const coreBlocksRunsRecordKind: DefinedRecordKind<z.ZodType<RunsRowBody>>;
|
|
82
96
|
export declare const coreBlocksActionsRecordKind: DefinedRecordKind<z.ZodType<ActionRowBody>>;
|
|
83
97
|
export declare const coreBlocksActionLinksRecordKind: DefinedRecordKind<z.ZodType<ActionLinksRowBody>>;
|
|
98
|
+
export declare const coreBlocksTimedRunsRecordKind: DefinedRecordKind<z.ZodType<TimedRunRowBody>>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `timed-run` provider of core-blocks (D993): switch a device on, and the
|
|
3
|
+
* hub owes it an off after a chosen time.
|
|
4
|
+
*
|
|
5
|
+
* DURABLE. The deadline is a row per device, written BEFORE the device is
|
|
6
|
+
* switched on, so a crash between the two can only cost a harmless extra off at
|
|
7
|
+
* boot, never a device left running with nobody to stop it.
|
|
8
|
+
*
|
|
9
|
+
* ONE time-ordered timer (D983): only the earliest deadline is armed, and when
|
|
10
|
+
* it fires the next one is armed. Not a timer per device.
|
|
11
|
+
*
|
|
12
|
+
* D49: the off is a one-shot. It is issued once, never gated on a read, and a
|
|
13
|
+
* failed off is logged with the device tag and not retried in a loop; the row is
|
|
14
|
+
* dropped either way so a boot does not re-issue it forever.
|
|
15
|
+
*
|
|
16
|
+
* A manual off (the switch observed off, the pump observed stopped) cancels the
|
|
17
|
+
* pending deadline silently: the operator already did what the timer would do.
|
|
18
|
+
*/
|
|
19
|
+
import { DeviceType, type IScopedLogger, type ITimedRunProvider, type TimedRunActuator, type TimedRunStatus } from "@camstack/types";
|
|
20
|
+
import type { PowerSourceScheduler } from "../power-source-service.js";
|
|
21
|
+
import type { TimedRunRowBody } from "../record-kinds.js";
|
|
22
|
+
/** The stored deadlines, one per device. */
|
|
23
|
+
export interface TimedRunRows {
|
|
24
|
+
readonly get: (deviceId: number) => Promise<TimedRunRowBody | null>;
|
|
25
|
+
readonly put: (deviceId: number, body: TimedRunRowBody) => Promise<void>;
|
|
26
|
+
readonly remove: (deviceId: number) => Promise<void>;
|
|
27
|
+
readonly all: () => Promise<readonly {
|
|
28
|
+
readonly deviceId: number;
|
|
29
|
+
readonly body: TimedRunRowBody;
|
|
30
|
+
}[]>;
|
|
31
|
+
}
|
|
32
|
+
export interface TimedRunActuation {
|
|
33
|
+
/** Throws when the device does not take the command. */
|
|
34
|
+
readonly set: (deviceId: number, actuator: TimedRunActuator, on: boolean) => Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
export interface TimedRunServiceDeps {
|
|
37
|
+
readonly rows: TimedRunRows;
|
|
38
|
+
readonly deviceTypeOf: (deviceId: number) => Promise<DeviceType | null>;
|
|
39
|
+
readonly actuation: TimedRunActuation;
|
|
40
|
+
/** Mirror the slice into the device state; failures are logged by the service. */
|
|
41
|
+
readonly publish: (deviceId: number, status: TimedRunStatus) => Promise<void>;
|
|
42
|
+
readonly scheduler: PowerSourceScheduler;
|
|
43
|
+
readonly now: () => number;
|
|
44
|
+
/** Off observations this soon after our own on command are stale echoes, not a manual off. */
|
|
45
|
+
readonly settleMs: number;
|
|
46
|
+
readonly logger: IScopedLogger;
|
|
47
|
+
}
|
|
48
|
+
export interface ObservedDeviceState {
|
|
49
|
+
readonly deviceId: number;
|
|
50
|
+
readonly capName: string;
|
|
51
|
+
readonly slice: Readonly<Record<string, unknown>>;
|
|
52
|
+
}
|
|
53
|
+
export declare const TIMED_RUN_SETTLE_MS: number;
|
|
54
|
+
export declare class TimedRunService implements ITimedRunProvider {
|
|
55
|
+
private readonly deps;
|
|
56
|
+
/** Pending deadlines, mirrored from the rows. */
|
|
57
|
+
private readonly pending;
|
|
58
|
+
/** When our own on command last resolved, per device. */
|
|
59
|
+
private readonly switchedOnAt;
|
|
60
|
+
private timer;
|
|
61
|
+
private armedFor;
|
|
62
|
+
private inflight;
|
|
63
|
+
private stopped;
|
|
64
|
+
constructor(deps: TimedRunServiceDeps);
|
|
65
|
+
getStatus: ITimedRunProvider["getStatus"];
|
|
66
|
+
runFor: ITimedRunProvider["runFor"];
|
|
67
|
+
cancel: ITimedRunProvider["cancel"];
|
|
68
|
+
/** Feed one `DeviceStateChanged`: a manual off cancels the pending deadline. */
|
|
69
|
+
onDeviceState(state: ObservedDeviceState): Promise<void>;
|
|
70
|
+
/** Boot: a passed deadline is switched off once, a future one is re-armed. */
|
|
71
|
+
reconcile(): Promise<void>;
|
|
72
|
+
/** Resolves when every deadline that already fired has been carried out. */
|
|
73
|
+
settled(): Promise<void>;
|
|
74
|
+
stop(): void;
|
|
75
|
+
private forget;
|
|
76
|
+
private statusOf;
|
|
77
|
+
private publishStatus;
|
|
78
|
+
/** Arm the ONE timer for the earliest pending deadline. */
|
|
79
|
+
private rearm;
|
|
80
|
+
private onTimer;
|
|
81
|
+
private queueExpire;
|
|
82
|
+
/** The one-shot off. Logged on failure, never retried (D49). */
|
|
83
|
+
private expire;
|
|
84
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wires `TimedRunService` to the hub: its rows (the `timed-runs` kind), the
|
|
3
|
+
* device registry for a device's type, the device caps for the on/off command
|
|
4
|
+
* and `deviceState.setCapSlice` for the mirrored slice.
|
|
5
|
+
*/
|
|
6
|
+
import { type AddonApi, type IScopedLogger, type RecordsAccess } from "@camstack/types";
|
|
7
|
+
import { TimedRunService } from "./timed-run-service.js";
|
|
8
|
+
export interface TimedRunWiringDeps {
|
|
9
|
+
readonly records: RecordsAccess;
|
|
10
|
+
readonly api: () => AddonApi | undefined;
|
|
11
|
+
readonly logger: IScopedLogger;
|
|
12
|
+
}
|
|
13
|
+
export declare function buildTimedRunService(deps: TimedRunWiringDeps): TimedRunService;
|
|
14
|
+
/**
|
|
15
|
+
* Re-arm the stored deadlines. ARMED, never awaited: the registry is a hub-core
|
|
16
|
+
* cap, answerable only after boot, so a first attempt may find it not ready. A
|
|
17
|
+
* failed read changes nothing (D49) and is tried again a bounded number of times.
|
|
18
|
+
*/
|
|
19
|
+
export declare function armTimedRuns(service: TimedRunService, logger: IScopedLogger, options: {
|
|
20
|
+
readonly isDisposed: () => boolean;
|
|
21
|
+
}): Promise<void>;
|
|
@@ -33,6 +33,8 @@ export declare class DeviceHistoryAddon extends BaseAddon<DeviceHistoryConfig> {
|
|
|
33
33
|
private runtime;
|
|
34
34
|
private unsubscribe;
|
|
35
35
|
private removalHook;
|
|
36
|
+
private runsProvider;
|
|
37
|
+
private runs;
|
|
36
38
|
/** This instance's readiness generation (the base class keeps its own private). */
|
|
37
39
|
private readonly readinessGeneration;
|
|
38
40
|
constructor();
|
|
@@ -44,8 +46,10 @@ export declare class DeviceHistoryAddon extends BaseAddon<DeviceHistoryConfig> {
|
|
|
44
46
|
/** Unraid array counters still stored in GiB. A failed listing throws to the caller. */
|
|
45
47
|
private legacyScales;
|
|
46
48
|
private requireRuntime;
|
|
49
|
+
private requireRuns;
|
|
47
50
|
protected onInitialize(): Promise<ProviderRegistration[]>;
|
|
48
51
|
override onHubReachable(): Promise<void>;
|
|
52
|
+
private openRuns;
|
|
49
53
|
private stopRuntime;
|
|
50
54
|
protected override onShutdown(): Promise<void>;
|
|
51
55
|
protected globalSettingsSchema(): ConfigUISchema;
|