@camstack/server 1.2.849 → 1.2.851
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 +16 -1
- package/dist/api/trpc/generated-cap-routers.js +9 -0
- package/package.json +9 -14
- 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 +4 -4
- package/system/dist/builtins/composer/composer.addon.mjs +4 -4
- 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/actions-service.d.ts +13 -3
- package/system/dist/builtins/core-blocks/actions-store.d.ts +13 -7
- package/system/dist/builtins/core-blocks/actions-wiring.d.ts +10 -3
- package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +0 -1
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +132 -71
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +132 -71
- package/system/dist/builtins/core-blocks/scheduler/scheduler-service.d.ts +5 -1
- package/system/dist/builtins/core-blocks/scheduler/scheduler-wiring.d.ts +2 -1
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-aggregation.d.ts +0 -25
- package/system/dist/builtins/device-manager/device-manager.addon.js +131 -5
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +131 -5
- package/system/dist/builtins/device-manager/export-name-fields.d.ts +39 -0
- 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 +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- 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 +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/local-network.addon.js +3 -3
- package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
- 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 +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- 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/{capture-engine-QQtJ9iXs.js → capture-engine-BM9nGdvv.js} +1 -1
- package/system/dist/{capture-engine-CgCljSbM.mjs → capture-engine-Bshtl7Kd.mjs} +1 -1
- package/system/dist/{composition-sources-DxDmYFCD.js → composition-sources-63HlIklt.js} +1 -1
- package/system/dist/{composition-sources-pEPr0Ucn.mjs → composition-sources-CYpKKHtf.mjs} +1 -1
- package/system/dist/{constants-CNZ_oxrp.mjs → constants-15k32igK.mjs} +1 -1
- package/system/dist/{constants-Df49f3b4.js → constants-lHbp6u7t.js} +1 -1
- package/system/dist/{device-ca-Bl-6F9mv.mjs → device-ca-BmKBCV_4.mjs} +1 -1
- package/system/dist/{device-ca-BzUtH2U5.js → device-ca-aB_rFHhZ.js} +1 -1
- package/system/dist/{dist-DKsFOzpr.js → dist-DNDhIlAe.js} +2788 -2476
- package/system/dist/{dist-zkNb0bBi.mjs → dist-DY7OGObz.mjs} +2765 -2465
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-identity-BrGlipuh.mjs → hub-identity-BMz4OOYu.mjs} +1 -1
- package/system/dist/{hub-identity-Dv4V44gP.js → hub-identity-dcbGnvVX.js} +1 -1
- package/system/dist/{hub-mdns-ciao-Dzht7PBY.mjs → hub-mdns-ciao-BOecE4tm.mjs} +2 -2
- package/system/dist/{hub-mdns-ciao-DcWSdIki.js → hub-mdns-ciao-Y7YjcHQ4.js} +2 -2
- package/system/dist/index.js +8 -8
- package/system/dist/index.mjs +8 -8
- package/system/dist/{legacy-integration-rows-door-CL6R8xaY.mjs → legacy-integration-rows-door-87W9dzLF.mjs} +1 -1
- package/system/dist/{legacy-integration-rows-door-CISh8s7H.js → legacy-integration-rows-door-BQKarbeM.js} +1 -1
- package/system/dist/{rename-composition-block-DM_koTq7.mjs → rename-composition-block-DOzzdV9v.mjs} +1 -1
- package/system/dist/{rename-composition-block-DFi7GTKn.js → rename-composition-block-p_8C4nY4.js} +1 -1
- package/system/dist/{restore-archive-Daw2fB9X.js → restore-archive-Bc-Xm8TB.js} +1 -1
- package/system/dist/{restore-archive-D_3y4vj-.mjs → restore-archive-TpUr6_kg.mjs} +1 -1
- package/system/dist/{wal-maintenance-BPohUtyD.mjs → wal-maintenance-CE7-afh9.mjs} +0 -0
- package/system/dist/{wal-maintenance-GyMlkYI_.js → wal-maintenance-auHpWNP7.js} +0 -0
- package/system/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $ as DeclaredDevices, $a as seedInstanceOnce, $o as composedDeviceStableId, Aa as resolveActionVariables, Ao as validateComposition, Bo as zoneOnlySite, C as COMPOSER_RUNNER_ID, Cc as
|
|
1
|
+
import { $ as DeclaredDevices, $a as seedInstanceOnce, $n as collectWhenMirrorSources, $o as composedDeviceStableId, $t as RunningStateStatusSchema, Aa as resolveActionVariables, Ao as validateComposition, Bo as zoneOnlySite, C as COMPOSER_RUNNER_ID, Cc as defineEntryKind, Ci as kebabToCamel, Co as timedRunLimitOf, Cr as describeComposableCaps, Ct as IDLE_ACTION_STATUS, Da as remoteLayoutComponentsCapability, Dc as entryBody, Dn as appendTrace, Do as toTimings, Ea as remoteCapability, Eo as timedRunSeconds, Fa as resolveHeroLayout, Fn as buildActionSteps, Gc as isSecretRefOwnedBy, Ho as CompositionSchema, Ht as PowerSourceInfoSchema, In as buildCapabilityLookup, Ji as nextOccurrence, Jo as HelperMemberSchema, Jt as REMOTE_MEDIA_COMMANDS, Ka as runSteps, Kn as capUnitResolver, Ks as RecordIntegrationInstances, Kt as QuantityUnitError, Lo as weekdayOfLocalDate, Mo as validateSchedulerInput, Na as resolveCoreBlockEntry, Nc as hydrateSchema, Ni as lockDoorLinkOfComposition, Nt as MediaPlayerStatusSchema, Oa as remoteSourceSteps, Pa as resolveCoreBlockFiles, Qn as collectDeviceTemplates, Qo as composedDeviceRef, Qt as RemoteLayoutPayloadSchema, R as DEFAULT_HOLD_OVERRIDE, Rr as evaluateStepCondition, Sl as errMsg$1, So as timedRunCapability, Ss as BaseAddon, T as CORE_BLOCK_ADDON_PREFIX, To as timedRunQuickRun, Ua as resolveStepArgs, Uc as isSecretMarker, Uo as DAY_MS, Va as resolveRemoteSource, Vo as COMPOSER_ADDON_ID, Wr as fanAxisPath, Xi as normalizeActionUnits, Xn as checkTemplatePayload, Xr as findChannelSource, Ya as schedulersCapability, Yi as nextTimeBoundaryInMs, Zi as normalizeCoreBlockWrite, Zt as RemoteAssumedStateSchema, _i as isInternalActionId, _n as actionSourceCapability, ac as actionEffect, ai as heroLayoutCapability, al as ruleFireOfClaim, ar as compositionSourceRefs, at as EMPTY_REMOTE_ASSUMED_STATE, bl as DeviceRole, bn as addonIdOfActionId, c as ActionError, cl as secretTreeFromSchema, cr as coreBlockAddonId, cs as helperMembers, ct as FAN_CAPTURE_FIELDS, d as ActionTargetResolver, da as powerSourceActuatorConflicts, dr as coreBlockSourceKind, es as compositionFeatureEnabled, f as ActionVariableSchema, fa as powerSourceCapability, fr as coreBlocksCapability, ft as FanControlStatusSchema, gl as vocabCall, h as BUILTIN_REMOTE_COMPONENTS, ha as problemsBlockSave, hc as collectSecretMarkerRefs, hl as vocabActionIdFor, hr as customKeyOfRole, ii as hasTimeLeaves, il as resolveSecretMarkers, in as SchedulerSchema, it as EMPTY_AUTOMATION_STATE, j as CoreBlockSchema, k as ConditionMirror, ka as replacedFieldKeys, ki as localDateOf, kn as assertStepsOffered, l as ActionMinDelaySecSchema, la as planComposition, lr as coreBlockComposition, ls as historyRetentionFromSettings, lt as FAN_OSCILLATION_AXES, m as AutomationStateDocSchema, mt as FanPresetSchema, n as ACTION_TARGET_INVALIDATION_EVENTS, nr as compileScalarOverride, oi as integrationInstancesCapability, oo as siteFor, or as compositionUnionReads, ot as EMPTY_REMOTE_CONFIG, pa as powerSourceLinkOfComposition, pl as transformSecretWrite, pn as TemplateKindSchema, qr as fanPresetsCapability, rc as VocabActionError, rn as SchedulerError, rs as compositionSourceKey, s as ALL_CAPABILITY_DEFINITIONS, si as internalActionId, sn as SetOscillationAxisInputSchema, ta as occurrenceOn, u as ActionStepSchema, uo as stableIdMapOf, ur as coreBlockIdFromAddonId, ut as FAN_OSCILLATION_AXIS_SETTABLE, va as projectDeviceRow, vc as commandOrigin$1, vn as actionWaitTotalMs, w as CORE_BLOCKS_ADDON_ID, wc as defineRecordKinds, wl as EventCategory$1, wo as timedRunMaxIn, wt as INTERNAL_ACTION_PREFIX, xa as readStoredRemoteConfig, xc as defineAddonMigrations, xl as DeviceType$1, xo as templateCapability, ya as proposeRunningThreshold, yn as actionsCapability, zn as buildHeroModel, zr as evaluateWhenTree } from "../../dist-DY7OGObz.mjs";
|
|
2
2
|
import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
|
|
3
|
-
import { i as parseDeviceStateChanged, r as isRecord$1, t as describeCompositionSources } from "../../composition-sources-
|
|
4
|
-
import { i as capSeriesKey } from "../../capture-engine-
|
|
3
|
+
import { i as parseDeviceStateChanged, r as isRecord$1, t as describeCompositionSources } from "../../composition-sources-CYpKKHtf.mjs";
|
|
4
|
+
import { i as capSeriesKey } from "../../capture-engine-Bshtl7Kd.mjs";
|
|
5
5
|
import { t as prefixRange } from "../../prefix-range-Dl0znowN.mjs";
|
|
6
6
|
import { n as unwrapStoredValue, t as loadPrefixed } from "../../prefix-walk-DAOBSyH1.mjs";
|
|
7
7
|
import { n as readCurrentCommandOrigin } from "../../cap-call-scope-Bic6Ekfw.mjs";
|
|
@@ -3094,6 +3094,7 @@ var ActionsService = class {
|
|
|
3094
3094
|
/** Last run START per action — the throttle's memory. */
|
|
3095
3095
|
lastStartedAt = /* @__PURE__ */ new Map();
|
|
3096
3096
|
maxRunMs;
|
|
3097
|
+
boundCaps;
|
|
3097
3098
|
stopGraceMs;
|
|
3098
3099
|
constructor(deps) {
|
|
3099
3100
|
this.store = deps.store;
|
|
@@ -3107,16 +3108,11 @@ var ActionsService = class {
|
|
|
3107
3108
|
this.maxRunMs = deps.maxRunMs ?? 36e5;
|
|
3108
3109
|
this.stopGraceMs = deps.stopGraceMs ?? STOP_GRACE_MS;
|
|
3109
3110
|
this.units = deps.units ?? capUnitResolver(ALL_CAPABILITY_DEFINITIONS);
|
|
3111
|
+
this.boundCaps = deps.boundCaps;
|
|
3110
3112
|
this.targets = new ActionTargetResolver(deps.directory, deps.logger);
|
|
3111
3113
|
this.templates = deps.templates;
|
|
3112
3114
|
this.conditions = deps.conditions;
|
|
3113
3115
|
}
|
|
3114
|
-
/** One-shot at boot: stored steps written before D983 are rewritten to the target shape. */
|
|
3115
|
-
async migrateTargets() {
|
|
3116
|
-
const moved = await this.store.migrateLegacyTargets();
|
|
3117
|
-
if (moved > 0) this.logger.info("internal actions rewritten to the target shape", { meta: { moved } });
|
|
3118
|
-
return moved;
|
|
3119
|
-
}
|
|
3120
3116
|
/** A device was added, removed, moved or re-bound: forget the cached domains. */
|
|
3121
3117
|
invalidateTargets() {
|
|
3122
3118
|
this.targets.invalidate();
|
|
@@ -3515,6 +3511,7 @@ var ActionsService = class {
|
|
|
3515
3511
|
}
|
|
3516
3512
|
async create(input) {
|
|
3517
3513
|
this.requireWithinCeiling(input.action.steps, input.action.name);
|
|
3514
|
+
await this.requireOffered(input.action.steps, input.action.name);
|
|
3518
3515
|
const { steps, warnings } = this.normalizeSteps(input.action.steps, input.action.name);
|
|
3519
3516
|
const action = await this.store.create({
|
|
3520
3517
|
...input.action,
|
|
@@ -3531,10 +3528,10 @@ var ActionsService = class {
|
|
|
3531
3528
|
}
|
|
3532
3529
|
async update(input) {
|
|
3533
3530
|
await this.requireInternal(input.actionId);
|
|
3534
|
-
const existing = await this.store.get(input.actionId);
|
|
3535
|
-
if (existing === null) throw new ActionError("not-found", `no action "${input.actionId}"`);
|
|
3536
3531
|
const patch = input.action;
|
|
3532
|
+
const existing = await this.existingForUpdate(input.actionId, patch);
|
|
3537
3533
|
if (patch.steps !== void 0) this.requireWithinCeiling(patch.steps, patch.name ?? existing.name);
|
|
3534
|
+
if (patch.steps !== void 0) await this.requireOffered(patch.steps, patch.name ?? existing.name);
|
|
3538
3535
|
const { steps, warnings } = this.normalizeSteps(patch.steps ?? existing.steps ?? [], patch.name ?? existing.name);
|
|
3539
3536
|
const action = await this.store.update(input.actionId, {
|
|
3540
3537
|
name: patch.name ?? existing.name,
|
|
@@ -3548,6 +3545,47 @@ var ActionsService = class {
|
|
|
3548
3545
|
...warnings.length > 0 ? { warnings } : {}
|
|
3549
3546
|
};
|
|
3550
3547
|
}
|
|
3548
|
+
/**
|
|
3549
|
+
* The action an update patches. A stored row that no longer parses (steps
|
|
3550
|
+
* from an older shape) is not read: a save carrying a whole new body — name
|
|
3551
|
+
* and steps — overwrites it under the same id, which is how the operator
|
|
3552
|
+
* converts it from the editor. A partial patch of such a row is refused.
|
|
3553
|
+
*/
|
|
3554
|
+
async existingForUpdate(actionId, patch) {
|
|
3555
|
+
const existing = await this.store.get(actionId);
|
|
3556
|
+
if (existing !== null) return existing;
|
|
3557
|
+
if (!await this.store.exists(actionId)) throw new ActionError("not-found", `no action "${actionId}"`);
|
|
3558
|
+
if (patch.name === void 0 || patch.steps === void 0) throw new ActionError("invalid-steps", `"${actionId}" is stored in a shape this version no longer reads — save it with a name and its steps`);
|
|
3559
|
+
this.logger.info("internal action rewritten over a stored body that no longer parses", { meta: { actionId } });
|
|
3560
|
+
return {
|
|
3561
|
+
id: actionId,
|
|
3562
|
+
name: patch.name,
|
|
3563
|
+
addonId: CORE_BLOCKS_ADDON_ID,
|
|
3564
|
+
source: "internal",
|
|
3565
|
+
readOnly: false,
|
|
3566
|
+
steps: patch.steps,
|
|
3567
|
+
status: IDLE_ACTION_STATUS
|
|
3568
|
+
};
|
|
3569
|
+
}
|
|
3570
|
+
/** A step naming a device whose own bindings lack its action's cap is refused at save (D12). */
|
|
3571
|
+
async requireOffered(steps, actionName) {
|
|
3572
|
+
try {
|
|
3573
|
+
await assertStepsOffered(steps, this.boundCaps);
|
|
3574
|
+
} catch (err) {
|
|
3575
|
+
if (err instanceof VocabActionError) {
|
|
3576
|
+
this.logger.warn("action save refused — a device does not offer the action", {
|
|
3577
|
+
...err.deviceId === void 0 ? {} : { tags: { deviceId: err.deviceId } },
|
|
3578
|
+
meta: {
|
|
3579
|
+
action: actionName,
|
|
3580
|
+
actionId: err.actionId,
|
|
3581
|
+
reason: err.reason
|
|
3582
|
+
}
|
|
3583
|
+
});
|
|
3584
|
+
throw new ActionError("invalid-steps", err.message);
|
|
3585
|
+
}
|
|
3586
|
+
throw err;
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3551
3589
|
/** An action whose waits alone exceed the run ceiling could never finish: refuse the save. */
|
|
3552
3590
|
requireWithinCeiling(steps, actionName) {
|
|
3553
3591
|
const total = actionWaitTotalMs(steps);
|
|
@@ -3658,11 +3696,13 @@ function uuidOf(actionId) {
|
|
|
3658
3696
|
var ActionsStore = class ActionsStore {
|
|
3659
3697
|
actions;
|
|
3660
3698
|
links;
|
|
3699
|
+
logger;
|
|
3661
3700
|
now;
|
|
3662
3701
|
newId;
|
|
3663
3702
|
constructor(options) {
|
|
3664
3703
|
this.actions = options.actions;
|
|
3665
3704
|
this.links = options.links;
|
|
3705
|
+
this.logger = options.logger;
|
|
3666
3706
|
this.now = options.now ?? Date.now;
|
|
3667
3707
|
this.newId = options.newId ?? randomUUID;
|
|
3668
3708
|
}
|
|
@@ -3673,52 +3713,50 @@ var ActionsStore = class ActionsStore {
|
|
|
3673
3713
|
addonId: CORE_BLOCKS_ADDON_ID,
|
|
3674
3714
|
source: "internal",
|
|
3675
3715
|
readOnly: false,
|
|
3676
|
-
steps:
|
|
3716
|
+
steps: body.steps,
|
|
3677
3717
|
...body.variables === void 0 ? {} : { variables: body.variables },
|
|
3678
3718
|
...body.minDelaySec === void 0 || body.minDelaySec === 0 ? {} : { minDelaySec: body.minDelaySec },
|
|
3679
3719
|
status: IDLE_ACTION_STATUS
|
|
3680
3720
|
};
|
|
3681
3721
|
}
|
|
3682
|
-
async list() {
|
|
3683
|
-
const out = [];
|
|
3684
|
-
let cursor;
|
|
3685
|
-
do {
|
|
3686
|
-
const page = await this.actions.query({ ...cursor === void 0 ? {} : { cursor } });
|
|
3687
|
-
for (const row of page.records) out.push(ActionsStore.entryOf(row.id, row.data));
|
|
3688
|
-
cursor = page.nextCursor ?? void 0;
|
|
3689
|
-
} while (cursor !== void 0);
|
|
3690
|
-
return out;
|
|
3691
|
-
}
|
|
3692
3722
|
/**
|
|
3693
|
-
*
|
|
3694
|
-
*
|
|
3695
|
-
*
|
|
3723
|
+
* A stored row is served only while it still parses. A row written under an
|
|
3724
|
+
* older step shape (a `cap` step, from before steps were stored by action id)
|
|
3725
|
+
* is skipped and logged, so it cannot break the list or reach a run; it stays
|
|
3726
|
+
* on disk until the operator saves the action again from the editor, which
|
|
3727
|
+
* overwrites it without reading its steps (`update`).
|
|
3696
3728
|
*/
|
|
3697
|
-
|
|
3698
|
-
|
|
3729
|
+
readable(id, data) {
|
|
3730
|
+
const parsed = ActionRowBodySchema.safeParse(data);
|
|
3731
|
+
if (parsed.success) return ActionsStore.entryOf(id, parsed.data);
|
|
3732
|
+
this.logger?.warn("internal action skipped — its stored body no longer parses; save it again", { meta: {
|
|
3733
|
+
actionId: internalActionId(id),
|
|
3734
|
+
reason: parsed.error.issues.slice(0, 3).map((issue) => `${issue.path.join(".")}: ${issue.message}`).join("; ")
|
|
3735
|
+
} });
|
|
3736
|
+
return null;
|
|
3737
|
+
}
|
|
3738
|
+
async list() {
|
|
3739
|
+
const out = [];
|
|
3699
3740
|
let cursor;
|
|
3700
3741
|
do {
|
|
3701
3742
|
const page = await this.actions.query({ ...cursor === void 0 ? {} : { cursor } });
|
|
3702
3743
|
for (const row of page.records) {
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
await this.actions.put({
|
|
3706
|
-
id: row.id,
|
|
3707
|
-
data: {
|
|
3708
|
-
...row.data,
|
|
3709
|
-
steps
|
|
3710
|
-
}
|
|
3711
|
-
});
|
|
3712
|
-
moved += 1;
|
|
3744
|
+
const entry = this.readable(row.id, row.data);
|
|
3745
|
+
if (entry !== null) out.push(entry);
|
|
3713
3746
|
}
|
|
3714
3747
|
cursor = page.nextCursor ?? void 0;
|
|
3715
3748
|
} while (cursor !== void 0);
|
|
3716
|
-
return
|
|
3749
|
+
return out;
|
|
3717
3750
|
}
|
|
3718
3751
|
async get(actionId) {
|
|
3719
3752
|
if (!isInternalActionId(actionId)) return null;
|
|
3720
3753
|
const row = await this.actions.get(uuidOf(actionId));
|
|
3721
|
-
return row === null ? null :
|
|
3754
|
+
return row === null ? null : this.readable(row.id, row.data);
|
|
3755
|
+
}
|
|
3756
|
+
/** Whether a row is stored under this id, readable or not. */
|
|
3757
|
+
async exists(actionId) {
|
|
3758
|
+
if (!isInternalActionId(actionId)) return false;
|
|
3759
|
+
return await this.actions.get(uuidOf(actionId)) !== null;
|
|
3722
3760
|
}
|
|
3723
3761
|
async create(input) {
|
|
3724
3762
|
const id = this.newId();
|
|
@@ -3916,8 +3954,20 @@ function invokeCapOver(api) {
|
|
|
3916
3954
|
};
|
|
3917
3955
|
}
|
|
3918
3956
|
/**
|
|
3919
|
-
*
|
|
3920
|
-
*
|
|
3957
|
+
* What each named device offers, from its OWN binding map (`getBindingsBatch`,
|
|
3958
|
+
* D12): one batched read of just the devices a step names, by cap name (D13).
|
|
3959
|
+
*/
|
|
3960
|
+
function boundCapsOver(api) {
|
|
3961
|
+
return { boundCapsOf: async (deviceIds) => {
|
|
3962
|
+
const current = api();
|
|
3963
|
+
if (current === void 0) throw new Error("core-blocks: no ctx.api on this node — device bindings cannot be read");
|
|
3964
|
+
const rows = await current.deviceManager.getBindingsBatch.query({ deviceIds: [...deviceIds] });
|
|
3965
|
+
return new Map(rows.map((row) => [row.deviceId, row.entries.map((entry) => entry.capName)]));
|
|
3966
|
+
} };
|
|
3967
|
+
}
|
|
3968
|
+
/**
|
|
3969
|
+
* The device registry as the target resolver reads it: the devices bound to a
|
|
3970
|
+
* cap (`listDeviceIdsByCaps`, D13) and the slim listing for type and room.
|
|
3921
3971
|
*/
|
|
3922
3972
|
function directoryOver(api) {
|
|
3923
3973
|
const need = () => {
|
|
@@ -3948,11 +3998,13 @@ function buildActionsRuntime(deps) {
|
|
|
3948
3998
|
const service = new ActionsService({
|
|
3949
3999
|
store: new ActionsStore({
|
|
3950
4000
|
actions: deps.records.kind(coreBlocksRecordKinds.actions),
|
|
3951
|
-
links: deps.records.kind(coreBlocksRecordKinds["action-links"])
|
|
4001
|
+
links: deps.records.kind(coreBlocksRecordKinds["action-links"]),
|
|
4002
|
+
logger: deps.logger.child("actions-store")
|
|
3952
4003
|
}),
|
|
3953
4004
|
ledger,
|
|
3954
4005
|
sources: sourcesOver(deps.api),
|
|
3955
4006
|
directory: deps.directory ?? directoryOver(deps.api),
|
|
4007
|
+
boundCaps: deps.boundCaps ?? boundCapsOver(deps.api),
|
|
3956
4008
|
invokeCap: invokeCapOver(deps.api),
|
|
3957
4009
|
templates: templateDoorOver(deps.api),
|
|
3958
4010
|
conditions: conditionDoorOver(deps.api),
|
|
@@ -4828,17 +4880,16 @@ var HoldManager = class {
|
|
|
4828
4880
|
async syncTargets(scheduler, run, point) {
|
|
4829
4881
|
const wanted = /* @__PURE__ */ new Map();
|
|
4830
4882
|
for (const step of point.steps) {
|
|
4831
|
-
if (step.kind !== "
|
|
4832
|
-
const normalized = normalizeCapStep(step);
|
|
4833
|
-
if (normalized.actionId === void 0) continue;
|
|
4883
|
+
if (step.kind !== "command") continue;
|
|
4834
4884
|
const resolved = resolveStepArgs(step.args ?? {}, {}, () => void 0);
|
|
4835
4885
|
const args = isPlainRecord$1(resolved) ? resolved : {};
|
|
4836
|
-
const effect = actionEffect(
|
|
4886
|
+
const effect = actionEffect(step.actionId, args);
|
|
4837
4887
|
if (effect === null) continue;
|
|
4888
|
+
const call = vocabCall(step.actionId, args);
|
|
4838
4889
|
let deviceIds;
|
|
4839
4890
|
try {
|
|
4840
|
-
deviceIds = (await this.deps.targets.resolve(
|
|
4841
|
-
actionId:
|
|
4891
|
+
deviceIds = (await this.deps.targets.resolve(step.target, step.actionId, {}, {
|
|
4892
|
+
actionId: step.actionId,
|
|
4842
4893
|
owner: `scheduler:${scheduler.id}`
|
|
4843
4894
|
})).deviceIds;
|
|
4844
4895
|
} catch (err) {
|
|
@@ -4855,9 +4906,9 @@ var HoldManager = class {
|
|
|
4855
4906
|
wanted.set(key, known !== void 0 && known.value === effect.value ? known : {
|
|
4856
4907
|
key,
|
|
4857
4908
|
deviceId,
|
|
4858
|
-
cap:
|
|
4859
|
-
method:
|
|
4860
|
-
args,
|
|
4909
|
+
cap: call.cap,
|
|
4910
|
+
method: call.method,
|
|
4911
|
+
args: call.args,
|
|
4861
4912
|
field: effect.field,
|
|
4862
4913
|
value: effect.value,
|
|
4863
4914
|
status: "pending",
|
|
@@ -5295,14 +5346,12 @@ var SchedulerEngine = class {
|
|
|
5295
5346
|
async holdSources(s, point) {
|
|
5296
5347
|
const out = [];
|
|
5297
5348
|
for (const step of point.steps) {
|
|
5298
|
-
if (step.kind !== "
|
|
5299
|
-
const
|
|
5300
|
-
if (normalized.actionId === void 0) continue;
|
|
5301
|
-
const effect = actionEffect(normalized.actionId, step.args);
|
|
5349
|
+
if (step.kind !== "command") continue;
|
|
5350
|
+
const effect = actionEffect(step.actionId, step.args);
|
|
5302
5351
|
if (effect === null) continue;
|
|
5303
5352
|
try {
|
|
5304
|
-
const resolved = await this.deps.targets.resolve(
|
|
5305
|
-
actionId:
|
|
5353
|
+
const resolved = await this.deps.targets.resolve(step.target, step.actionId, {}, {
|
|
5354
|
+
actionId: step.actionId,
|
|
5306
5355
|
owner: `scheduler:${s.id}`
|
|
5307
5356
|
});
|
|
5308
5357
|
for (const deviceId of resolved.deviceIds) out.push({
|
|
@@ -5642,8 +5691,29 @@ var SchedulersService = class {
|
|
|
5642
5691
|
} });
|
|
5643
5692
|
throw new SchedulerError("invalid-scheduler", message);
|
|
5644
5693
|
}
|
|
5694
|
+
await this.requireOffered(prepared);
|
|
5645
5695
|
return prepared;
|
|
5646
5696
|
}
|
|
5697
|
+
/** A step naming a device whose own bindings lack its action's cap is refused at save (D12). */
|
|
5698
|
+
async requireOffered(scheduler) {
|
|
5699
|
+
const steps = scheduler.profiles.flatMap((p) => p.points.flatMap((point) => point.steps));
|
|
5700
|
+
try {
|
|
5701
|
+
await assertStepsOffered(steps, this.deps.boundCaps);
|
|
5702
|
+
} catch (err) {
|
|
5703
|
+
if (err instanceof VocabActionError) {
|
|
5704
|
+
this.deps.logger.warn("scheduler save refused — a device does not offer the action", {
|
|
5705
|
+
...err.deviceId === void 0 ? {} : { tags: { deviceId: err.deviceId } },
|
|
5706
|
+
meta: {
|
|
5707
|
+
scheduler: scheduler.name,
|
|
5708
|
+
actionId: err.actionId,
|
|
5709
|
+
reason: err.reason
|
|
5710
|
+
}
|
|
5711
|
+
});
|
|
5712
|
+
throw new SchedulerError("invalid-scheduler", err.message);
|
|
5713
|
+
}
|
|
5714
|
+
throw err;
|
|
5715
|
+
}
|
|
5716
|
+
}
|
|
5647
5717
|
async create(input) {
|
|
5648
5718
|
const prepared = await this.prepare(input.scheduler);
|
|
5649
5719
|
const scheduler = await this.deps.store.create(prepared);
|
|
@@ -5780,15 +5850,13 @@ var SchedulersService = class {
|
|
|
5780
5850
|
if (point.mode !== "hold") continue;
|
|
5781
5851
|
const effects = [];
|
|
5782
5852
|
for (const step of point.steps) {
|
|
5783
|
-
if (step.kind !== "
|
|
5784
|
-
const normalized = normalizeCapStep(step);
|
|
5785
|
-
if (normalized.actionId === void 0) continue;
|
|
5853
|
+
if (step.kind !== "command") continue;
|
|
5786
5854
|
const resolved = resolveStepArgs(step.args ?? {}, {}, () => void 0);
|
|
5787
|
-
const effect = actionEffect(
|
|
5855
|
+
const effect = actionEffect(step.actionId, isPlainRecord(resolved) ? resolved : {});
|
|
5788
5856
|
if (effect === null) continue;
|
|
5789
5857
|
try {
|
|
5790
|
-
const { deviceIds } = await this.deps.targets.resolve(
|
|
5791
|
-
actionId:
|
|
5858
|
+
const { deviceIds } = await this.deps.targets.resolve(step.target, step.actionId, {}, {
|
|
5859
|
+
actionId: step.actionId,
|
|
5792
5860
|
owner: "scheduler-conflicts"
|
|
5793
5861
|
});
|
|
5794
5862
|
for (const deviceId of deviceIds) effects.push({
|
|
@@ -5974,6 +6042,7 @@ function buildSchedulersRuntime(deps) {
|
|
|
5974
6042
|
ledger: deps.ledger,
|
|
5975
6043
|
host,
|
|
5976
6044
|
targets,
|
|
6045
|
+
boundCaps: deps.boundCaps ?? boundCapsOver(deps.api),
|
|
5977
6046
|
units: capUnitResolver(ALL_CAPABILITY_DEFINITIONS),
|
|
5978
6047
|
logger: deps.logger.child("schedulers")
|
|
5979
6048
|
});
|
|
@@ -9090,7 +9159,6 @@ var CoreBlocksAddon = class extends BaseAddon {
|
|
|
9090
9159
|
this.schedulers = schedulers;
|
|
9091
9160
|
armSchedulerEngine(schedulers.engine, this.ctx.logger.child("scheduler"), { isDisposed: () => this.disposed });
|
|
9092
9161
|
this.sweepRunsLedger();
|
|
9093
|
-
this.migrateActionTargets();
|
|
9094
9162
|
this.remoteRuntime = this.buildRemote(records);
|
|
9095
9163
|
this.fanPresets = this.buildFanPresets();
|
|
9096
9164
|
this.installDeviceCallRedirect();
|
|
@@ -9568,13 +9636,6 @@ var CoreBlocksAddon = class extends BaseAddon {
|
|
|
9568
9636
|
this.ctx.logger.warn("runs ledger sweep failed — orphan rows stay until the next start", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
9569
9637
|
}
|
|
9570
9638
|
}
|
|
9571
|
-
async migrateActionTargets() {
|
|
9572
|
-
try {
|
|
9573
|
-
await this.actions?.service.migrateTargets();
|
|
9574
|
-
} catch (err) {
|
|
9575
|
-
this.ctx.logger.warn("internal actions could not be rewritten to the target shape — they are still read as it", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
9576
|
-
}
|
|
9577
|
-
}
|
|
9578
9639
|
requireStore() {
|
|
9579
9640
|
if (this.store === null) throw new Error("core-blocks: not initialized");
|
|
9580
9641
|
return this.store;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* step that leads to no state, a sun point on a site with no location — never
|
|
8
8
|
* stored as a point that would silently do nothing.
|
|
9
9
|
*/
|
|
10
|
-
import { type ActionTargetResolver, type AutomationRunTrace, type ISchedulersProvider, type IScopedLogger, type Scheduler, type SchedulerConflict, type SchedulerInput, type SchedulerPreview, type SchedulerStatus, type UnitResolver } from "@camstack/types";
|
|
10
|
+
import { type ActionTargetResolver, type AutomationRunTrace, type BoundCapsReader, type ISchedulersProvider, type IScopedLogger, type Scheduler, type SchedulerConflict, type SchedulerInput, type SchedulerPreview, type SchedulerStatus, type UnitResolver } from "@camstack/types";
|
|
11
11
|
import { type RunsLedger } from "../runs-ledger.js";
|
|
12
12
|
import type { SchedulerEngine } from "./scheduler-engine.js";
|
|
13
13
|
import type { SchedulersStore } from "./scheduler-store.js";
|
|
@@ -18,6 +18,8 @@ export interface SchedulersServiceDeps {
|
|
|
18
18
|
readonly ledger: RunsLedger;
|
|
19
19
|
readonly host: Pick<SchedulerHost, "readSite">;
|
|
20
20
|
readonly targets: ActionTargetResolver;
|
|
21
|
+
/** Each named device's own binding map, for the save check (D12). */
|
|
22
|
+
readonly boundCaps: BoundCapsReader;
|
|
21
23
|
readonly units: UnitResolver;
|
|
22
24
|
readonly logger: IScopedLogger;
|
|
23
25
|
readonly now?: () => number;
|
|
@@ -34,6 +36,8 @@ export declare class SchedulersService implements ISchedulersProvider {
|
|
|
34
36
|
}>;
|
|
35
37
|
/** Units and targets in the stored shape, then the author-time rules. Throws a typed refusal. */
|
|
36
38
|
private prepare;
|
|
39
|
+
/** A step naming a device whose own bindings lack its action's cap is refused at save (D12). */
|
|
40
|
+
private requireOffered;
|
|
37
41
|
create(input: {
|
|
38
42
|
scheduler: SchedulerInput;
|
|
39
43
|
}): Promise<{
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* records access, the runs ledger and the actions' target resolver, plus
|
|
4
4
|
* `ctx.api` (the site, device state, device calls) and the event bus.
|
|
5
5
|
*/
|
|
6
|
-
import { type AddonApi, type DeviceDirectory, type IEventBus, type IScopedLogger, type RecordsAccess } from "@camstack/types";
|
|
6
|
+
import { type AddonApi, type BoundCapsReader, type DeviceDirectory, type IEventBus, type IScopedLogger, type RecordsAccess } from "@camstack/types";
|
|
7
7
|
import { type RunsLedger } from "../runs-ledger.js";
|
|
8
8
|
import { SchedulerEngine } from "./scheduler-engine.js";
|
|
9
9
|
import { SchedulersService } from "./scheduler-service.js";
|
|
@@ -22,6 +22,7 @@ export interface SchedulersRuntimeDeps {
|
|
|
22
22
|
readonly logger: IScopedLogger;
|
|
23
23
|
readonly ledger: RunsLedger;
|
|
24
24
|
readonly directory?: DeviceDirectory;
|
|
25
|
+
readonly boundCaps?: BoundCapsReader;
|
|
25
26
|
/** A spec swaps these. */
|
|
26
27
|
readonly host?: SchedulerHost;
|
|
27
28
|
readonly clock?: SchedulerClock;
|
|
@@ -3,8 +3,8 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
7
|
-
const require_capture_engine = require("../../capture-engine-
|
|
6
|
+
const require_dist = require("../../dist-DNDhIlAe.js");
|
|
7
|
+
const require_capture_engine = require("../../capture-engine-BM9nGdvv.js");
|
|
8
8
|
const require_retention = require("../../retention-BcOSL6b9.js");
|
|
9
9
|
let node_crypto = require("node:crypto");
|
|
10
10
|
//#region src/builtins/device-history/capture/point-writer.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as catalogMetrics, c as DeviceDirectory, d as identityOf, f as subjectIdOf, i as capSeriesKey, l as isRealDeviceType, n as CaptureEngine, o as readPath, r as capItemSeriesKey, s as readUnit, t as CAP_KEY_PREFIX, u as SeriesRegistry } from "../../capture-engine-
|
|
1
|
+
import { Ar as deviceRunsCapability, Bc as isReadingQuantity, Dr as deviceHistoryCapability, Ec as emitReadiness, Mc as historyUnitFor, Nr as deviceTransitionsCapability, Ns as InvalidRecordError, On as armRemovalReconcile, Ss as BaseAddon, V as DEVICE_HISTORY_ENERGY_KEY, Ys as RecordTooLargeError, et as DeviceRunSchema, kr as deviceRemovalHookCapability, ks as DeviceTransitionSchema, vt as HISTORY_CATALOG, wc as defineRecordKinds, wl as EventCategory, xl as DeviceType, xs as wattMillisecondsToKwh, yt as HISTORY_ITEM_CATALOG } from "../../dist-DY7OGObz.mjs";
|
|
2
|
+
import { a as catalogMetrics, c as DeviceDirectory, d as identityOf, f as subjectIdOf, i as capSeriesKey, l as isRealDeviceType, n as CaptureEngine, o as readPath, r as capItemSeriesKey, s as readUnit, t as CAP_KEY_PREFIX, u as SeriesRegistry } from "../../capture-engine-Bshtl7Kd.mjs";
|
|
3
3
|
import { a as FIVE_MINUTES_MS, c as bucketEndOf, i as DAY_MS, l as bucketStartOf, n as RetentionJob, o as HOUR_MS, r as DepartureTracker, s as ROLLUP_GRACE_MS, t as DEFAULT_RETENTION, u as floorTo } from "../../retention-CUOVI1p7.mjs";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
5
5
|
//#region src/builtins/device-history/capture/point-writer.ts
|
|
@@ -50,31 +50,6 @@ export interface DeviceFormSecretsDeps {
|
|
|
50
50
|
}
|
|
51
51
|
type IDeviceManagerProvider = InferProvider<typeof deviceManagerCapability>;
|
|
52
52
|
export declare function getDeviceAggregate(deps: AggregationDeps, deviceId: number, kind: "settings" | "live"): Promise<ContributionShape | null>;
|
|
53
|
-
/**
|
|
54
|
-
* System-scoped per-device contributions — the deliberate exception to
|
|
55
|
-
* binding-driven aggregation (D12).
|
|
56
|
-
*
|
|
57
|
-
* A `scope: 'system'` cap with `exposesDeviceSettings: true` holds per-device
|
|
58
|
-
* state but is NOT bound per-device: it is a system addon, not a BaseDevice,
|
|
59
|
-
* so it never calls `registerNativeCap` and never appears in
|
|
60
|
-
* `getBindings(deviceId)`. The binding-driven loop therefore skips it and its
|
|
61
|
-
* per-device panel never renders. Two such caps ship today:
|
|
62
|
-
* - `stream-broker` (singleton) — the RTSP-restream / pre-buffer settings
|
|
63
|
-
* tab, scoped to the cameras whose streams it serves.
|
|
64
|
-
* - `device-export` (collection) — the "Export" panel; a device can be
|
|
65
|
-
* exposed to MULTIPLE exporters at once (Alexa + HomeKit + HA-MQTT).
|
|
66
|
-
*
|
|
67
|
-
* D12 bans fanning a per-device call out to every same-named provider of a
|
|
68
|
-
* `scope: 'device'` cap, because vendor providers SHARE cap names
|
|
69
|
-
* (`stream-params`/`ptz` from reolink AND hikvision). System caps are NOT
|
|
70
|
-
* vendor-shared — a system cap name maps to one active provider (singleton)
|
|
71
|
-
* or one declared collection — so consulting the cap's own provider(s)
|
|
72
|
-
* directly is safe. Each provider gates internally by deviceId and returns
|
|
73
|
-
* null for devices it does not own.
|
|
74
|
-
*
|
|
75
|
-
* `seenCaps` skips any system cap that already contributed via a binding so
|
|
76
|
-
* its section is never duplicated.
|
|
77
|
-
*/
|
|
78
53
|
export declare function collectSystemDeviceContributions(deps: AggregationDeps, deviceId: number, kind: "settings" | "live", seenCaps: ReadonlySet<string>): Promise<ContributionShape[]>;
|
|
79
54
|
/**
|
|
80
55
|
* D14: framework-derived device-config contribution.
|