@camstack/server 1.2.821 → 1.2.823
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/dist/api/trpc/generated-cap-routers.js +20 -0
- package/package.json +9 -10
- package/system/dist/addon-runner.js +18 -13
- package/system/dist/addon-runner.mjs +19 -14
- package/system/dist/addon-utils.mjs +1 -1
- package/system/dist/{agent-https-N6Or6UAu.mjs → agent-https-CDl7mB_F.mjs} +1 -1
- package/system/dist/{agent-https-Bp5yzi8b.js → agent-https-Df53Fvk1.js} +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 +4 -4
- 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 +5 -5
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +3 -3
- 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 +5 -5
- 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/composed-device-set.d.ts +5 -1
- package/system/dist/builtins/composer/composed-device.d.ts +4 -0
- package/system/dist/builtins/composer/composed-name.d.ts +30 -0
- package/system/dist/builtins/composer/composer.addon.js +94 -6
- package/system/dist/builtins/composer/composer.addon.mjs +94 -6
- package/system/dist/builtins/composer/composer.d.ts +13 -0
- 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 +16 -0
- package/system/dist/builtins/core-blocks/composition-api.d.ts +6 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +214 -8
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +214 -8
- package/system/dist/builtins/core-blocks/device-template-door.d.ts +25 -0
- package/system/dist/builtins/core-blocks/fan-presets-service.d.ts +5 -0
- package/system/dist/builtins/core-blocks/rename-composition-block.d.ts +16 -0
- package/system/dist/builtins/core-blocks/scheduler/scheduler-engine.d.ts +5 -0
- package/system/dist/builtins/core-blocks/step-condition-door.d.ts +19 -0
- package/system/dist/builtins/core-blocks/sync-composed-device-name.d.ts +19 -0
- 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-manager.addon.d.ts +7 -0
- package/system/dist/builtins/device-manager/device-manager.addon.js +691 -4
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +689 -3
- package/system/dist/builtins/device-manager/device-template/template-host.d.ts +60 -0
- package/system/dist/builtins/device-manager/device-template-actions.d.ts +33 -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 +5 -5
- 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 +10 -10
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +10 -10
- 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 +20 -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 +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 +9 -9
- package/system/dist/builtins/system-config/system-config.addon.mjs +287 -287
- 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-4lB0sLCf.js → capture-engine-C0Z5rwCO.js} +1 -1
- package/system/dist/{capture-engine-Cz7z5d36.mjs → capture-engine-D_GQBgrZ.mjs} +1 -1
- package/system/dist/{composition-sources-C9gEj25e.js → composition-sources-DIZx3mW3.js} +1 -1
- package/system/dist/{composition-sources-C0e2g_VP.mjs → composition-sources-mx-2yCDv.mjs} +1 -1
- package/system/dist/{constants-CZMy7dor.mjs → constants-BQlx9HDp.mjs} +1 -1
- package/system/dist/{constants-Cq3B9yzj.js → constants-CAOcKiWT.js} +1 -1
- package/system/dist/{coral-accelerators-DBlgWB8k.mjs → coral-accelerators-BW3OcrLD.mjs} +6 -6
- package/system/dist/{custom-action-registry-B9zFBNVa.mjs → custom-action-registry-N7flBDwT.mjs} +37 -37
- package/system/dist/{device-ca-BenyQXJV.js → device-ca-93LsCF_Q.js} +1 -1
- package/system/dist/{device-ca-BmQ6N-A-.mjs → device-ca-CK6GTnNh.mjs} +1 -1
- package/system/dist/device-template-worker.js +5 -7032
- package/system/dist/device-template-worker.mjs +1 -7026
- package/system/dist/{dist-DuKMbGBM.mjs → dist-BQiyo22b.mjs} +667 -50
- package/system/dist/{dist-M5VX8Hqf.js → dist-izXDzt4g.js} +714 -49
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-k3pOKWyZ.js → hub-mdns-ciao-Dt_tgvol.js} +2 -2
- package/system/dist/{hub-mdns-ciao-CXBfBwAy.mjs → hub-mdns-ciao-srpOrqIP.mjs} +2 -2
- package/system/dist/index.js +26 -21
- package/system/dist/index.mjs +238 -233
- package/system/dist/{legacy-integration-rows-door-mIpR3e6X.js → legacy-integration-rows-door-BH43eDu6.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-C13OeuW9.mjs → legacy-integration-rows-door-wu2GWY6U.mjs} +1 -1
- package/system/dist/rename-composition-block-6oLQVzft.js +112 -0
- package/system/dist/rename-composition-block-CH6ZoSJA.mjs +101 -0
- package/system/dist/{restore-archive-DDeQFJN5.mjs → restore-archive-C4rR2SYV.mjs} +154 -154
- package/system/dist/{restore-archive-CCgt7SZ8.js → restore-archive-DpZ2PbLN.js} +7 -7
- package/system/dist/template-protocol-BmMM5VBf.mjs +7033 -0
- package/system/dist/template-protocol-CTP4eAo_.js +7059 -0
- package/system/dist/{wal-maintenance-Cj7xe4wN.mjs → wal-maintenance-CNfp0HHX.mjs} +0 -0
- package/system/dist/{wal-maintenance-D5M6hl53.js → wal-maintenance-DAA2qJja.js} +0 -0
- package/system/package.json +1 -1
|
@@ -3,10 +3,11 @@ 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_composition_sources = require("../../composition-sources-
|
|
8
|
-
const require_capture_engine = require("../../capture-engine-
|
|
6
|
+
const require_dist = require("../../dist-izXDzt4g.js");
|
|
7
|
+
const require_composition_sources = require("../../composition-sources-DIZx3mW3.js");
|
|
8
|
+
const require_capture_engine = require("../../capture-engine-C0Z5rwCO.js");
|
|
9
9
|
const require_retention = require("../../retention-BcOSL6b9.js");
|
|
10
|
+
const require_rename_composition_block = require("../../rename-composition-block-6oLQVzft.js");
|
|
10
11
|
let zod = require("zod");
|
|
11
12
|
//#region src/builtins/composer/actuator-invoke.ts
|
|
12
13
|
/**
|
|
@@ -166,6 +167,10 @@ var ComposedDevice = class extends require_dist.BaseDevice {
|
|
|
166
167
|
derivesWater;
|
|
167
168
|
/** The `consumables` items the composition last wrote — the derived water item is added to these. */
|
|
168
169
|
composedItems = [];
|
|
170
|
+
/** The row's flag, read at use: a restart loads it with the meta, and a system rename never sets it. */
|
|
171
|
+
get userNamed() {
|
|
172
|
+
return this.ctx.deviceMeta.userNamed === true;
|
|
173
|
+
}
|
|
169
174
|
get features() {
|
|
170
175
|
return [...new Set([...this.sharedFeatures, ...this.boundFeatures])];
|
|
171
176
|
}
|
|
@@ -870,6 +875,15 @@ function copyMember(member) {
|
|
|
870
875
|
};
|
|
871
876
|
}
|
|
872
877
|
//#endregion
|
|
878
|
+
//#region src/builtins/composer/composed-name.ts
|
|
879
|
+
function composedNameAuthority(deviceName, blockName, remembered) {
|
|
880
|
+
if (remembered === null) return "device";
|
|
881
|
+
if (remembered.nameOwed === blockName) return "block";
|
|
882
|
+
if (blockName !== remembered.blockName) return "block";
|
|
883
|
+
if (deviceName !== blockName && remembered.appliedName === deviceName) return "device";
|
|
884
|
+
return "block";
|
|
885
|
+
}
|
|
886
|
+
//#endregion
|
|
873
887
|
//#region src/builtins/composer/composed-device-set.ts
|
|
874
888
|
/**
|
|
875
889
|
* The composed devices the composer DECLARED (D659): one row per `new`-target
|
|
@@ -4414,6 +4428,11 @@ var Composer = class {
|
|
|
4414
4428
|
/** Applies never interleave: each one reads and replaces the whole live set. */
|
|
4415
4429
|
applyChain = Promise.resolve();
|
|
4416
4430
|
/**
|
|
4431
|
+
* Block names an editor rename still owes the device row. In memory only:
|
|
4432
|
+
* a restart has no entry, and the row's name wins (see `composedNameAuthority`).
|
|
4433
|
+
*/
|
|
4434
|
+
nameOwed = /* @__PURE__ */ new Map();
|
|
4435
|
+
/**
|
|
4417
4436
|
* Runtimes built by an apply and not started yet: that apply's sync starts
|
|
4418
4437
|
* them, with their sources tracked. An event in between never does (N-5) —
|
|
4419
4438
|
* it would start one on sources "not tracked yet".
|
|
@@ -4714,7 +4733,11 @@ var Composer = class {
|
|
|
4714
4733
|
continue;
|
|
4715
4734
|
}
|
|
4716
4735
|
const device = p.target.kind === "existing" ? null : this.composed.get(require_dist.composedDeviceStableId(p.block.id));
|
|
4717
|
-
const appliedName = device === null ? null : p.block.name === null ? previous?.appliedName ?? device.name : await this.applyName(device, p.block.name, previous
|
|
4736
|
+
const appliedName = device === null ? null : p.block.name === null ? previous?.appliedName ?? device.name : await this.applyName(device, p.block.id, p.block.name, previous === void 0 ? null : {
|
|
4737
|
+
appliedName: previous.appliedName,
|
|
4738
|
+
blockName: previous.planned.block.name,
|
|
4739
|
+
nameOwed: this.nameOwed.get(p.block.id) ?? null
|
|
4740
|
+
});
|
|
4718
4741
|
if (previous?.runtime != null && previous.device === device && sameTarget(previous.planned.target, p.target) && previous.planned.block.updatedAt === p.block.updatedAt && previous.planned.block.enabled === p.block.enabled && !restart.has(p.block.id)) {
|
|
4719
4742
|
next.set(p.block.id, {
|
|
4720
4743
|
planned: p,
|
|
@@ -4854,7 +4877,44 @@ var Composer = class {
|
|
|
4854
4877
|
if (previous.runtime === null) return previous.heldFields;
|
|
4855
4878
|
return heldFieldsOf(previous.runtime.state().fields, `the composition no longer plans — the field keeps its last value on the device: ${p.problems.join("; ")}`);
|
|
4856
4879
|
}
|
|
4857
|
-
async applyName(device, name,
|
|
4880
|
+
async applyName(device, blockId, name, remembered) {
|
|
4881
|
+
if (device.userNamed === true && device.name !== name) {
|
|
4882
|
+
if (composedNameAuthority(device.name, name, remembered) === "device") {
|
|
4883
|
+
this.nameOwed.delete(blockId);
|
|
4884
|
+
this.deps.logger.info("composed device keeps the name the operator gave it", {
|
|
4885
|
+
tags: { deviceId: device.id },
|
|
4886
|
+
meta: {
|
|
4887
|
+
name: device.name,
|
|
4888
|
+
blockName: name
|
|
4889
|
+
}
|
|
4890
|
+
});
|
|
4891
|
+
await this.syncBlockName(device.id, blockId, device.name);
|
|
4892
|
+
return device.name;
|
|
4893
|
+
}
|
|
4894
|
+
if (!(remembered?.nameOwed === name) && remembered?.appliedName === name) return name;
|
|
4895
|
+
try {
|
|
4896
|
+
await this.deps.devices.setName(device.id, name, { stampUserNamed: true });
|
|
4897
|
+
this.nameOwed.delete(blockId);
|
|
4898
|
+
this.deps.logger.info("composed device renamed after its block", {
|
|
4899
|
+
tags: { deviceId: device.id },
|
|
4900
|
+
meta: { name }
|
|
4901
|
+
});
|
|
4902
|
+
return name;
|
|
4903
|
+
} catch (err) {
|
|
4904
|
+
this.nameOwed.set(blockId, name);
|
|
4905
|
+
this.deps.logger.warn("composed block was renamed but the device name was not written — retried on the next apply", {
|
|
4906
|
+
tags: { deviceId: device.id },
|
|
4907
|
+
meta: {
|
|
4908
|
+
blockId,
|
|
4909
|
+
name,
|
|
4910
|
+
error: require_dist.errMsg(err)
|
|
4911
|
+
}
|
|
4912
|
+
});
|
|
4913
|
+
return remembered?.appliedName ?? device.name;
|
|
4914
|
+
}
|
|
4915
|
+
}
|
|
4916
|
+
this.nameOwed.delete(blockId);
|
|
4917
|
+
const applied = remembered?.appliedName ?? null;
|
|
4858
4918
|
if ((applied ?? device.name) === name) return name;
|
|
4859
4919
|
try {
|
|
4860
4920
|
await this.deps.devices.setName(device.id, name);
|
|
@@ -4874,6 +4934,23 @@ var Composer = class {
|
|
|
4874
4934
|
return applied ?? device.name;
|
|
4875
4935
|
}
|
|
4876
4936
|
}
|
|
4937
|
+
/** The block follows the name that was kept. A missed write is retried on the next apply. */
|
|
4938
|
+
async syncBlockName(deviceId, blockId, name) {
|
|
4939
|
+
const sync = this.deps.syncBlockName;
|
|
4940
|
+
if (sync === void 0) return;
|
|
4941
|
+
try {
|
|
4942
|
+
await sync(deviceId, blockId, name);
|
|
4943
|
+
} catch (err) {
|
|
4944
|
+
this.deps.logger.warn("composed device kept its name but the block was not updated — retried on the next apply", {
|
|
4945
|
+
tags: { deviceId },
|
|
4946
|
+
meta: {
|
|
4947
|
+
blockId,
|
|
4948
|
+
name,
|
|
4949
|
+
error: require_dist.errMsg(err)
|
|
4950
|
+
}
|
|
4951
|
+
});
|
|
4952
|
+
}
|
|
4953
|
+
}
|
|
4877
4954
|
async syncSources(rebuilt) {
|
|
4878
4955
|
const requests = trackedSourceRequests(this.live.values());
|
|
4879
4956
|
const changed = await this.syncTracker(requests, rebuilt.reset);
|
|
@@ -6101,7 +6178,7 @@ var ComposerAddon = class extends require_dist.BaseAddon {
|
|
|
6101
6178
|
return { devices: handles };
|
|
6102
6179
|
},
|
|
6103
6180
|
devices: {
|
|
6104
|
-
setName: (deviceId, name) => devices.setName(deviceId, name),
|
|
6181
|
+
setName: (deviceId, name, write) => devices.setName(deviceId, name, { stampUserNamed: write?.stampUserNamed === true }),
|
|
6105
6182
|
decommission: (deviceId) => devices.decommission(deviceId),
|
|
6106
6183
|
applyDerivedSpec: (deviceId, derived) => devices.applyDerivedSpec(deviceId, derived)
|
|
6107
6184
|
},
|
|
@@ -6180,6 +6257,17 @@ var ComposerAddon = class extends require_dist.BaseAddon {
|
|
|
6180
6257
|
...args
|
|
6181
6258
|
});
|
|
6182
6259
|
},
|
|
6260
|
+
syncBlockName: async (deviceId, blockId, name) => {
|
|
6261
|
+
const blocks = this.ctx.api;
|
|
6262
|
+
if (blocks === void 0) {
|
|
6263
|
+
this.ctx.logger.warn("composed device kept its name but the block was not updated — no api on this runner", {
|
|
6264
|
+
tags: { deviceId },
|
|
6265
|
+
meta: { blockId }
|
|
6266
|
+
});
|
|
6267
|
+
return;
|
|
6268
|
+
}
|
|
6269
|
+
await require_rename_composition_block.renameCompositionBlock(blocks, this.ctx.logger, deviceId, blockId, name);
|
|
6270
|
+
},
|
|
6183
6271
|
boundCapNames: async (deviceId) => {
|
|
6184
6272
|
try {
|
|
6185
6273
|
return (await api.deviceManager.getBindings.query({ deviceId })).entries.map((entry) => entry.capName);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { $
|
|
2
|
-
import { i as parseDeviceStateChanged, n as normalizedNativeOwner, r as isRecord$4 } from "../../composition-sources-
|
|
3
|
-
import { i as capSeriesKey } from "../../capture-engine-
|
|
1
|
+
import { $o as openReset, An as buildCapabilityLookup, Ao as HISTORY_FAST_MS, Bo as compositionItemFieldPath, Cc as isReadingQuantity, Co as withDefaultRunning, Di as mediaPlayerFeaturesOfRoles, Ei as mediaPlayerCapability, Eo as COMPOSER_ADDON_ID, Fr as fanControlCapability, Go as evaluateDerivative, Ha as sharedActuatorMethods, Ho as compositionSourceKey, Io as cloneStatefulExpressionMemory, Ir as fanOutTargets, It as PetFountainStatusSchema, Ji as petFountainCapability, Jo as historyRetentionFromSettings, Ki as parseColorInput, Kn as colorCapability, Ko as evaluateStatistic, Kr as groupCommandsCapability, Lo as composedDeviceRef, Mo as HOUR_MS, Nr as expressionContainsBuiltinCall, On as brightnessCapability, Or as evaluateCompositionField, Pi as motionCapability, Po as MINUTE_MS, Qn as consumablesCapability, Qo as nextLocalMidnight, Ro as composedDeviceStableId, Rr as featureForwards, Ta as resolveMutate, Ua as sharedColorModes, Un as climateControlCapability, Uo as createStatefulExpressionMemory, Va as sharedActuatorFeatures, Vo as compositionSliceKey, Wo as disarmRoseMemory, Xn as compositionFieldKey, Xo as isForwardInputRef, Yi as petFountainWaterItem, Yn as composerCapability, Yo as integrateReading, Z as DeclaredDevices, Zi as planComposition, Zo as isHistoryHelper, _t as HvacModeSchema, al as EventCategory, ct as FanDirectionSchema, es as openStatistic, ft as GroupCommandResultSchema, h as BaseDevice, i as ACTUATOR_TEMPLATE_IDS, ia as processTimeZoneOr, il as featuresOfBoundCaps, io as switchCapability, ir as coverCapability, is as toExpressionValue, ja as runFanOut, jo as HISTORY_SLOW_MS, k as ConsumableItemSchema, ki as methodRefusal, ko as DEFAULT_HISTORY_RETENTION, nc as createEvent, nl as DeviceType, ns as planStatisticTier, os as BaseAddon, qr as groupTemplate, r as ACTUATOR_METHODS, rl as errMsg, rs as statisticCadenceMs, s as ALL_CAPABILITY_DEFINITIONS, ts as planResetTier, ui as kebabToCamel, ur as declaredSeriesKind, vo as valveCapability, x as COMPOSED_ITEM_FIXED_FIELDS, yi as lockControlCapability, zo as compositionFeatureEnabled } from "../../dist-BQiyo22b.mjs";
|
|
2
|
+
import { i as parseDeviceStateChanged, n as normalizedNativeOwner, r as isRecord$4 } from "../../composition-sources-mx-2yCDv.mjs";
|
|
3
|
+
import { i as capSeriesKey } from "../../capture-engine-D_GQBgrZ.mjs";
|
|
4
4
|
import { i as DAY_MS, t as DEFAULT_RETENTION } from "../../retention-CUOVI1p7.mjs";
|
|
5
|
+
import { n as renameCompositionBlock } from "../../rename-composition-block-CH6ZoSJA.mjs";
|
|
5
6
|
import { z } from "zod";
|
|
6
7
|
//#region src/builtins/composer/actuator-invoke.ts
|
|
7
8
|
/**
|
|
@@ -161,6 +162,10 @@ var ComposedDevice = class extends BaseDevice {
|
|
|
161
162
|
derivesWater;
|
|
162
163
|
/** The `consumables` items the composition last wrote — the derived water item is added to these. */
|
|
163
164
|
composedItems = [];
|
|
165
|
+
/** The row's flag, read at use: a restart loads it with the meta, and a system rename never sets it. */
|
|
166
|
+
get userNamed() {
|
|
167
|
+
return this.ctx.deviceMeta.userNamed === true;
|
|
168
|
+
}
|
|
164
169
|
get features() {
|
|
165
170
|
return [...new Set([...this.sharedFeatures, ...this.boundFeatures])];
|
|
166
171
|
}
|
|
@@ -865,6 +870,15 @@ function copyMember(member) {
|
|
|
865
870
|
};
|
|
866
871
|
}
|
|
867
872
|
//#endregion
|
|
873
|
+
//#region src/builtins/composer/composed-name.ts
|
|
874
|
+
function composedNameAuthority(deviceName, blockName, remembered) {
|
|
875
|
+
if (remembered === null) return "device";
|
|
876
|
+
if (remembered.nameOwed === blockName) return "block";
|
|
877
|
+
if (blockName !== remembered.blockName) return "block";
|
|
878
|
+
if (deviceName !== blockName && remembered.appliedName === deviceName) return "device";
|
|
879
|
+
return "block";
|
|
880
|
+
}
|
|
881
|
+
//#endregion
|
|
868
882
|
//#region src/builtins/composer/composed-device-set.ts
|
|
869
883
|
/**
|
|
870
884
|
* The composed devices the composer DECLARED (D659): one row per `new`-target
|
|
@@ -4409,6 +4423,11 @@ var Composer = class {
|
|
|
4409
4423
|
/** Applies never interleave: each one reads and replaces the whole live set. */
|
|
4410
4424
|
applyChain = Promise.resolve();
|
|
4411
4425
|
/**
|
|
4426
|
+
* Block names an editor rename still owes the device row. In memory only:
|
|
4427
|
+
* a restart has no entry, and the row's name wins (see `composedNameAuthority`).
|
|
4428
|
+
*/
|
|
4429
|
+
nameOwed = /* @__PURE__ */ new Map();
|
|
4430
|
+
/**
|
|
4412
4431
|
* Runtimes built by an apply and not started yet: that apply's sync starts
|
|
4413
4432
|
* them, with their sources tracked. An event in between never does (N-5) —
|
|
4414
4433
|
* it would start one on sources "not tracked yet".
|
|
@@ -4709,7 +4728,11 @@ var Composer = class {
|
|
|
4709
4728
|
continue;
|
|
4710
4729
|
}
|
|
4711
4730
|
const device = p.target.kind === "existing" ? null : this.composed.get(composedDeviceStableId(p.block.id));
|
|
4712
|
-
const appliedName = device === null ? null : p.block.name === null ? previous?.appliedName ?? device.name : await this.applyName(device, p.block.name, previous
|
|
4731
|
+
const appliedName = device === null ? null : p.block.name === null ? previous?.appliedName ?? device.name : await this.applyName(device, p.block.id, p.block.name, previous === void 0 ? null : {
|
|
4732
|
+
appliedName: previous.appliedName,
|
|
4733
|
+
blockName: previous.planned.block.name,
|
|
4734
|
+
nameOwed: this.nameOwed.get(p.block.id) ?? null
|
|
4735
|
+
});
|
|
4713
4736
|
if (previous?.runtime != null && previous.device === device && sameTarget(previous.planned.target, p.target) && previous.planned.block.updatedAt === p.block.updatedAt && previous.planned.block.enabled === p.block.enabled && !restart.has(p.block.id)) {
|
|
4714
4737
|
next.set(p.block.id, {
|
|
4715
4738
|
planned: p,
|
|
@@ -4849,7 +4872,44 @@ var Composer = class {
|
|
|
4849
4872
|
if (previous.runtime === null) return previous.heldFields;
|
|
4850
4873
|
return heldFieldsOf(previous.runtime.state().fields, `the composition no longer plans — the field keeps its last value on the device: ${p.problems.join("; ")}`);
|
|
4851
4874
|
}
|
|
4852
|
-
async applyName(device, name,
|
|
4875
|
+
async applyName(device, blockId, name, remembered) {
|
|
4876
|
+
if (device.userNamed === true && device.name !== name) {
|
|
4877
|
+
if (composedNameAuthority(device.name, name, remembered) === "device") {
|
|
4878
|
+
this.nameOwed.delete(blockId);
|
|
4879
|
+
this.deps.logger.info("composed device keeps the name the operator gave it", {
|
|
4880
|
+
tags: { deviceId: device.id },
|
|
4881
|
+
meta: {
|
|
4882
|
+
name: device.name,
|
|
4883
|
+
blockName: name
|
|
4884
|
+
}
|
|
4885
|
+
});
|
|
4886
|
+
await this.syncBlockName(device.id, blockId, device.name);
|
|
4887
|
+
return device.name;
|
|
4888
|
+
}
|
|
4889
|
+
if (!(remembered?.nameOwed === name) && remembered?.appliedName === name) return name;
|
|
4890
|
+
try {
|
|
4891
|
+
await this.deps.devices.setName(device.id, name, { stampUserNamed: true });
|
|
4892
|
+
this.nameOwed.delete(blockId);
|
|
4893
|
+
this.deps.logger.info("composed device renamed after its block", {
|
|
4894
|
+
tags: { deviceId: device.id },
|
|
4895
|
+
meta: { name }
|
|
4896
|
+
});
|
|
4897
|
+
return name;
|
|
4898
|
+
} catch (err) {
|
|
4899
|
+
this.nameOwed.set(blockId, name);
|
|
4900
|
+
this.deps.logger.warn("composed block was renamed but the device name was not written — retried on the next apply", {
|
|
4901
|
+
tags: { deviceId: device.id },
|
|
4902
|
+
meta: {
|
|
4903
|
+
blockId,
|
|
4904
|
+
name,
|
|
4905
|
+
error: errMsg(err)
|
|
4906
|
+
}
|
|
4907
|
+
});
|
|
4908
|
+
return remembered?.appliedName ?? device.name;
|
|
4909
|
+
}
|
|
4910
|
+
}
|
|
4911
|
+
this.nameOwed.delete(blockId);
|
|
4912
|
+
const applied = remembered?.appliedName ?? null;
|
|
4853
4913
|
if ((applied ?? device.name) === name) return name;
|
|
4854
4914
|
try {
|
|
4855
4915
|
await this.deps.devices.setName(device.id, name);
|
|
@@ -4869,6 +4929,23 @@ var Composer = class {
|
|
|
4869
4929
|
return applied ?? device.name;
|
|
4870
4930
|
}
|
|
4871
4931
|
}
|
|
4932
|
+
/** The block follows the name that was kept. A missed write is retried on the next apply. */
|
|
4933
|
+
async syncBlockName(deviceId, blockId, name) {
|
|
4934
|
+
const sync = this.deps.syncBlockName;
|
|
4935
|
+
if (sync === void 0) return;
|
|
4936
|
+
try {
|
|
4937
|
+
await sync(deviceId, blockId, name);
|
|
4938
|
+
} catch (err) {
|
|
4939
|
+
this.deps.logger.warn("composed device kept its name but the block was not updated — retried on the next apply", {
|
|
4940
|
+
tags: { deviceId },
|
|
4941
|
+
meta: {
|
|
4942
|
+
blockId,
|
|
4943
|
+
name,
|
|
4944
|
+
error: errMsg(err)
|
|
4945
|
+
}
|
|
4946
|
+
});
|
|
4947
|
+
}
|
|
4948
|
+
}
|
|
4872
4949
|
async syncSources(rebuilt) {
|
|
4873
4950
|
const requests = trackedSourceRequests(this.live.values());
|
|
4874
4951
|
const changed = await this.syncTracker(requests, rebuilt.reset);
|
|
@@ -6096,7 +6173,7 @@ var ComposerAddon = class extends BaseAddon {
|
|
|
6096
6173
|
return { devices: handles };
|
|
6097
6174
|
},
|
|
6098
6175
|
devices: {
|
|
6099
|
-
setName: (deviceId, name) => devices.setName(deviceId, name),
|
|
6176
|
+
setName: (deviceId, name, write) => devices.setName(deviceId, name, { stampUserNamed: write?.stampUserNamed === true }),
|
|
6100
6177
|
decommission: (deviceId) => devices.decommission(deviceId),
|
|
6101
6178
|
applyDerivedSpec: (deviceId, derived) => devices.applyDerivedSpec(deviceId, derived)
|
|
6102
6179
|
},
|
|
@@ -6175,6 +6252,17 @@ var ComposerAddon = class extends BaseAddon {
|
|
|
6175
6252
|
...args
|
|
6176
6253
|
});
|
|
6177
6254
|
},
|
|
6255
|
+
syncBlockName: async (deviceId, blockId, name) => {
|
|
6256
|
+
const blocks = this.ctx.api;
|
|
6257
|
+
if (blocks === void 0) {
|
|
6258
|
+
this.ctx.logger.warn("composed device kept its name but the block was not updated — no api on this runner", {
|
|
6259
|
+
tags: { deviceId },
|
|
6260
|
+
meta: { blockId }
|
|
6261
|
+
});
|
|
6262
|
+
return;
|
|
6263
|
+
}
|
|
6264
|
+
await renameCompositionBlock(blocks, this.ctx.logger, deviceId, blockId, name);
|
|
6265
|
+
},
|
|
6178
6266
|
boundCapNames: async (deviceId) => {
|
|
6179
6267
|
try {
|
|
6180
6268
|
return (await api.deviceManager.getBindings.query({ deviceId })).entries.map((entry) => entry.capName);
|
|
@@ -135,6 +135,12 @@ export interface ComposerDeps {
|
|
|
135
135
|
* Absent in tests that predate it.
|
|
136
136
|
*/
|
|
137
137
|
readonly boundCapNames?: (deviceId: number) => Promise<readonly string[] | null>;
|
|
138
|
+
/**
|
|
139
|
+
* Write a composition block's name so it matches the operator's device name.
|
|
140
|
+
* Absent in tests that predate the operator-rename repair: the name is kept
|
|
141
|
+
* and the block is reconciled on the next apply that has the port.
|
|
142
|
+
*/
|
|
143
|
+
readonly syncBlockName?: (deviceId: number, blockId: string, name: string) => Promise<void>;
|
|
138
144
|
}
|
|
139
145
|
/** The configured zone, else the process zone when usable, else `UTC` (an empty `TZ` reads `Etc/Unknown`). */
|
|
140
146
|
export declare function resolveComposerTimeZone(configured: string | undefined, logger: IScopedLogger): string;
|
|
@@ -165,6 +171,11 @@ export declare class Composer {
|
|
|
165
171
|
/** Applies never interleave: each one reads and replaces the whole live set. */
|
|
166
172
|
private applyChain;
|
|
167
173
|
/**
|
|
174
|
+
* Block names an editor rename still owes the device row. In memory only:
|
|
175
|
+
* a restart has no entry, and the row's name wins (see `composedNameAuthority`).
|
|
176
|
+
*/
|
|
177
|
+
private readonly nameOwed;
|
|
178
|
+
/**
|
|
168
179
|
* Runtimes built by an apply and not started yet: that apply's sync starts
|
|
169
180
|
* them, with their sources tracked. An event in between never does (N-5) —
|
|
170
181
|
* it would start one on sources "not tracked yet".
|
|
@@ -211,6 +222,8 @@ export declare class Composer {
|
|
|
211
222
|
private onClaimEvent;
|
|
212
223
|
private heldFieldsFor;
|
|
213
224
|
private applyName;
|
|
225
|
+
/** The block follows the name that was kept. A missed write is retried on the next apply. */
|
|
226
|
+
private syncBlockName;
|
|
214
227
|
private syncSources;
|
|
215
228
|
/** A failed sync leaves the tracker as it was: the runtimes read what it holds. */
|
|
216
229
|
private syncTracker;
|
|
@@ -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-izXDzt4g.js");
|
|
7
7
|
const require_formatter = require("../../formatter-xbxeV4GD.js");
|
|
8
8
|
//#region src/builtins/console-logging/console-destination.ts
|
|
9
9
|
var LEVEL_RANK = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { os as BaseAddon, xi as logDestinationCapability } from "../../dist-BQiyo22b.mjs";
|
|
2
2
|
import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
|
|
3
3
|
//#region src/builtins/console-logging/console-destination.ts
|
|
4
4
|
var LEVEL_RANK = {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type ActionEntry, type ActionLinks, type ActionRunChanged, type ActionRunResult, type ActionVariableValue, type AutomationRunTrace, type DeviceDirectory, type CapCall, type IActionsProvider, type IScopedLogger, type UnitResolver, type UnitWarning } from "@camstack/types";
|
|
2
2
|
import type { ActionsStore } from "./actions-store.js";
|
|
3
|
+
import { type DeviceTemplateDoor } from "./device-template-door.js";
|
|
4
|
+
import { type StepConditionDoor } from "./step-condition-door.js";
|
|
3
5
|
import { type RunsLedger } from "./runs-ledger.js";
|
|
4
6
|
/** The `action-source` providers, reached through `ctx.api`. */
|
|
5
7
|
export interface ActionSources {
|
|
@@ -31,6 +33,10 @@ export interface ActionsServiceDeps {
|
|
|
31
33
|
readonly maxRunMs?: number;
|
|
32
34
|
/** How long a stopped run is given to wind down before its call is answered anyway. */
|
|
33
35
|
readonly stopGraceMs?: number;
|
|
36
|
+
/** The device template renderer (D1021); absent where there is none, and a templated step then fails. */
|
|
37
|
+
readonly templates?: DeviceTemplateDoor;
|
|
38
|
+
/** Reads a conditional step's `if` (#472). */
|
|
39
|
+
readonly conditions?: StepConditionDoor;
|
|
34
40
|
}
|
|
35
41
|
type RunInput = Parameters<IActionsProvider["run"]>[0];
|
|
36
42
|
type GetInput = Parameters<IActionsProvider["get"]>[0];
|
|
@@ -45,6 +51,8 @@ export declare class ActionsService implements IActionsProvider {
|
|
|
45
51
|
private readonly newRunId;
|
|
46
52
|
private readonly units;
|
|
47
53
|
private readonly targets;
|
|
54
|
+
private readonly templates;
|
|
55
|
+
private readonly conditions;
|
|
48
56
|
private readonly running;
|
|
49
57
|
private readonly maxRunMs;
|
|
50
58
|
private readonly stopGraceMs;
|
|
@@ -78,6 +86,14 @@ export declare class ActionsService implements IActionsProvider {
|
|
|
78
86
|
* camera has to link the action. Refused with `not-linked`, and logged.
|
|
79
87
|
*/
|
|
80
88
|
private authorize;
|
|
89
|
+
/**
|
|
90
|
+
* The devices a run's templates may read. An admin (or an in-process block)
|
|
91
|
+
* reads any (`undefined`); a non-admin only the camera the scope gate proved
|
|
92
|
+
* it may see — fail-closed, because the gate proves nothing about any other.
|
|
93
|
+
*/
|
|
94
|
+
private readableDevices;
|
|
95
|
+
/** A non-admin run is refused up front when a template names a device outside `readable`. */
|
|
96
|
+
private checkTemplateScope;
|
|
81
97
|
run(input: RunInput): Promise<ActionRunResult>;
|
|
82
98
|
private triggerOf;
|
|
83
99
|
/** Never rejects: a run's failure is its outcome. */
|
|
@@ -40,6 +40,12 @@ export interface CompositionApiDeps {
|
|
|
40
40
|
/** The history reads behind `proposeRunningThreshold`. */
|
|
41
41
|
readonly runningProposal: RunningProposalPorts;
|
|
42
42
|
readonly logger: IScopedLogger;
|
|
43
|
+
/**
|
|
44
|
+
* After an operator renames a composed device's block, write that name onto
|
|
45
|
+
* the device row (stamped). Absent in tests that predate it: the block save
|
|
46
|
+
* still lands, and the composer retries the device write on its next apply.
|
|
47
|
+
*/
|
|
48
|
+
readonly writeComposedDeviceName?: (blockId: string, name: string) => Promise<void>;
|
|
43
49
|
/** Every capability definition — the listing is derived from them, never from the registry's live state. */
|
|
44
50
|
readonly capabilityDefinitions: readonly CapabilityDefinition[];
|
|
45
51
|
}
|