@camstack/server 1.2.822 → 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 +6 -0
- package/package.json +8 -9
- 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-C4yxMErF.mjs → agent-https-CDl7mB_F.mjs} +1 -1
- package/system/dist/{agent-https-SGBI0xP8.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/composition-api.d.ts +6 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +68 -4
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +68 -4
- package/system/dist/builtins/core-blocks/rename-composition-block.d.ts +16 -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.js +37 -3
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +37 -3
- 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 +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +115 -115
- 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-6MVUyUry.js → capture-engine-C0Z5rwCO.js} +1 -1
- package/system/dist/{capture-engine-BSjE-CQA.mjs → capture-engine-D_GQBgrZ.mjs} +1 -1
- package/system/dist/{composition-sources-BBAOXZdC.js → composition-sources-DIZx3mW3.js} +1 -1
- package/system/dist/{composition-sources-C8T9DRbZ.mjs → composition-sources-mx-2yCDv.mjs} +1 -1
- package/system/dist/{constants-CReG6K4k.mjs → constants-BQlx9HDp.mjs} +1 -1
- package/system/dist/{constants-v0g9--wN.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-BFcBTfff.js → device-ca-93LsCF_Q.js} +1 -1
- package/system/dist/{device-ca-cX8qUs2s.mjs → device-ca-CK6GTnNh.mjs} +1 -1
- package/system/dist/{dist-DjBZ1HhF.mjs → dist-BQiyo22b.mjs} +76 -26
- package/system/dist/{dist-C2czR9xK.js → dist-izXDzt4g.js} +81 -25
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-CpCleue0.js → hub-mdns-ciao-Dt_tgvol.js} +2 -2
- package/system/dist/{hub-mdns-ciao-Cnr8xiSd.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-DhW6mPZj.js → legacy-integration-rows-door-BH43eDu6.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-CGajkVPh.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-eA7L58KT.mjs → restore-archive-C4rR2SYV.mjs} +94 -94
- package/system/dist/{restore-archive-BLab80kx.js → restore-archive-DpZ2PbLN.js} +1 -1
- package/system/dist/{wal-maintenance-DeBxoOFh.mjs → wal-maintenance-CNfp0HHX.mjs} +0 -0
- package/system/dist/{wal-maintenance-DhnSF7K-.js → wal-maintenance-DAA2qJja.js} +0 -0
- package/system/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
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, ct as FanDirectionSchema, es as openStatistic, ft as GroupCommandResultSchema, h as BaseDevice, i as ACTUATOR_TEMPLATE_IDS, ia as processTimeZoneOr, il as
|
|
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 { os as BaseAddon, xi as logDestinationCapability } from "../../dist-
|
|
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 = {
|
|
@@ -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
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
3
|
-
const require_dist = require("../../dist-
|
|
3
|
+
const require_dist = require("../../dist-izXDzt4g.js");
|
|
4
4
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
5
|
-
const require_composition_sources = require("../../composition-sources-
|
|
6
|
-
const require_capture_engine = require("../../capture-engine-
|
|
5
|
+
const require_composition_sources = require("../../composition-sources-DIZx3mW3.js");
|
|
6
|
+
const require_capture_engine = require("../../capture-engine-C0Z5rwCO.js");
|
|
7
7
|
const require_prefix_range = require("../../prefix-range-D_KueXbQ.js");
|
|
8
8
|
const require_prefix_walk = require("../../prefix-walk-Dv6MLZlM.js");
|
|
9
9
|
let zod = require("zod");
|
|
@@ -8500,6 +8500,25 @@ async function refuseRetarget(deps, blockId, patch) {
|
|
|
8500
8500
|
if (patch.name !== void 0) return refuseSave(deps, subject, pinned, NO_NAME_OF_ITS_OWN);
|
|
8501
8501
|
if (next === null || require_dist.compositionSourceKey(next) !== require_dist.compositionSourceKey(pinned)) return refuseSave(deps, subject, pinned, DEVICE_IS_FIXED);
|
|
8502
8502
|
}
|
|
8503
|
+
/**
|
|
8504
|
+
* An editor rename of a composed device (not a customization, not a create)
|
|
8505
|
+
* writes the device name after the block has been saved. A failed device
|
|
8506
|
+
* write is logged and does not fail the save.
|
|
8507
|
+
*/
|
|
8508
|
+
async function followComposedRename(deps, previous, name) {
|
|
8509
|
+
const write = deps.writeComposedDeviceName;
|
|
8510
|
+
if (write === void 0 || previous === null || name === void 0 || name === previous.name) return;
|
|
8511
|
+
const composition = require_dist.coreBlockComposition(previous);
|
|
8512
|
+
if (composition === null || existingTarget(composition) !== null) return;
|
|
8513
|
+
try {
|
|
8514
|
+
await write(previous.id, name);
|
|
8515
|
+
} catch (err) {
|
|
8516
|
+
deps.logger.warn("composed block was renamed but the device name was not written — retried on the next apply", { meta: {
|
|
8517
|
+
blockId: previous.id,
|
|
8518
|
+
error: require_dist.errMsg(err)
|
|
8519
|
+
} });
|
|
8520
|
+
}
|
|
8521
|
+
}
|
|
8503
8522
|
/** The block customizing `device`, found by TARGET — never by its derived name (rule 4). */
|
|
8504
8523
|
function customizationOf(blocks, device) {
|
|
8505
8524
|
const key = require_dist.compositionSourceKey(device);
|
|
@@ -8548,10 +8567,12 @@ function buildCompositionApi(deps) {
|
|
|
8548
8567
|
blockId
|
|
8549
8568
|
}, judged.validation, judged.memberDeviceIds);
|
|
8550
8569
|
}
|
|
8570
|
+
const previous = deps.store.get(blockId);
|
|
8551
8571
|
const updated = await deps.store.updateComposition(blockId, block);
|
|
8572
|
+
await followComposedRename(deps, previous, block.name);
|
|
8552
8573
|
deps.logger.info("composition updated", { meta: {
|
|
8553
8574
|
blockId,
|
|
8554
|
-
by: caller
|
|
8575
|
+
by: caller?.userId ?? "system"
|
|
8555
8576
|
} });
|
|
8556
8577
|
if (block.composition !== void 0) {
|
|
8557
8578
|
const unreleased = (await deps.convergeForClaims()).filter((claim) => claim.owner === blockId);
|
|
@@ -8629,6 +8650,40 @@ function buildCompositionApi(deps) {
|
|
|
8629
8650
|
};
|
|
8630
8651
|
}
|
|
8631
8652
|
//#endregion
|
|
8653
|
+
//#region src/builtins/core-blocks/sync-composed-device-name.ts
|
|
8654
|
+
/**
|
|
8655
|
+
* An operator rename in the composition editor writes the composed device's
|
|
8656
|
+
* name as well, stamped, so the row and the block agree. The device is the
|
|
8657
|
+
* row whose stable id is `composed-<blockId>` under the composer addon.
|
|
8658
|
+
* A failure is logged and swallowed: the block save has already landed, and
|
|
8659
|
+
* the composer's next apply retries the device write.
|
|
8660
|
+
*/
|
|
8661
|
+
async function writeComposedDeviceName(port, logger, blockId, name) {
|
|
8662
|
+
const stableId = require_dist.composedDeviceStableId(blockId);
|
|
8663
|
+
let deviceId = null;
|
|
8664
|
+
try {
|
|
8665
|
+
const row = (await port.listPersistedByAddon(require_dist.COMPOSER_ADDON_ID)).find((candidate) => candidate.stableId === stableId);
|
|
8666
|
+
if (row === void 0) {
|
|
8667
|
+
logger.warn("composed block was renamed but its device row was not found — retried on the next apply", { meta: {
|
|
8668
|
+
blockId,
|
|
8669
|
+
stableId
|
|
8670
|
+
} });
|
|
8671
|
+
return;
|
|
8672
|
+
}
|
|
8673
|
+
deviceId = row.id;
|
|
8674
|
+
if (row.name === name) return;
|
|
8675
|
+
await port.setOperatorName(row.id, name);
|
|
8676
|
+
} catch (err) {
|
|
8677
|
+
logger.warn("composed block was renamed but the device name was not written — retried on the next apply", {
|
|
8678
|
+
...deviceId === null ? {} : { tags: { deviceId } },
|
|
8679
|
+
meta: {
|
|
8680
|
+
blockId,
|
|
8681
|
+
error: require_dist.errMsg(err)
|
|
8682
|
+
}
|
|
8683
|
+
});
|
|
8684
|
+
}
|
|
8685
|
+
}
|
|
8686
|
+
//#endregion
|
|
8632
8687
|
//#region src/builtins/core-blocks/extract-settings-schema.ts
|
|
8633
8688
|
/**
|
|
8634
8689
|
* Read an optional `settingsSchema` named export from a compiled block bundle.
|
|
@@ -9445,6 +9500,15 @@ var CoreBlocksAddon = class extends require_dist.BaseAddon {
|
|
|
9445
9500
|
logger: this.ctx.logger.child("running-proposal")
|
|
9446
9501
|
},
|
|
9447
9502
|
logger: this.ctx.logger.child("compositions"),
|
|
9503
|
+
writeComposedDeviceName: (blockId, name) => writeComposedDeviceName({
|
|
9504
|
+
listPersistedByAddon: async (addonId) => requireApi().deviceManager.listPersistedByAddon.query({ addonId }),
|
|
9505
|
+
setOperatorName: async (deviceId, deviceName) => {
|
|
9506
|
+
await requireApi().deviceManager.setName.mutate({
|
|
9507
|
+
deviceId,
|
|
9508
|
+
name: deviceName
|
|
9509
|
+
});
|
|
9510
|
+
}
|
|
9511
|
+
}, this.ctx.logger.child("compositions"), blockId, name),
|
|
9448
9512
|
capabilityDefinitions: require_dist.ALL_CAPABILITY_DEFINITIONS
|
|
9449
9513
|
});
|
|
9450
9514
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $i as powerSourceCapability, $n as coreBlockAddonId, $t as SchedulerSchema, A as ControlStatusSchema, An as buildCapabilityLookup, Ar as evaluateWhenTree, As as RecordIntegrationInstances, Br as findChannelSource, C as CORE_BLOCKS_ADDON_ID, Da as resolveRemoteSource, Do as CompositionSchema, Ec as isSecretMarker, Fa as schedulersCapability, Fi as nextOccurrence, Ga as siteFor, Gn as collectWhenMirrorSources, Hn as checkTemplatePayload, Ho as compositionSourceKey, Hs as actionEffect, Ii as normalizeActionUnits, Jn as compileScalarOverride, Jo as historyRetentionFromSettings, Jr as heroLayoutCapability, Jt as RunningStateStatusSchema, Kt as RemoteAssumedStateSchema, Li as normalizeCapStep, Lo as composedDeviceRef, Lr as fanPresetsCapability, Lt as PowerSourceInfoSchema, Ma as runSteps, Nn as buildHeroModel, No as HelperMemberSchema, O as ConditionMirror, Oc as isSecretRefOwnedBy, Oo as DAY_MS, Ot as MediaPlayerStatusSchema, Qs as collectSecretMarkerRefs, Qt as SchedulerError, R as DEFAULT_HOLD_OVERRIDE, Ri as normalizeCoreBlockWrite, Rn as capUnitResolver, S as COMPOSER_RUNNER_ID, Sn as appendTrace, So as weekdayOfLocalDate, To as zoneOnlySite, Ui as occurrenceOn, Ut as REMOTE_MEDIA_COMMANDS, Vc as resolveSecretMarkers, Vt as QuantityUnitError, Wc as secretTreeFromSchema, Wn as collectDeviceTemplates, Xr as internalActionId, Ya as stableIdMapOf, Yc as transformSecretWrite, Yr as integrationInstancesCapability, Z as DeclaredDevices, Zc as vocabActionIdFor, Zi as planComposition, Zn as compositionSourceRefs, _o as validateSchedulerInput, aa as projectDeviceRow, ai as isInternalActionId, at as FAN_CAPTURE_FIELDS, ba as resolveCoreBlockFiles, bi as lockDoorLinkOfComposition, c as ActionError, ca as readStoredRemoteConfig, cn as TemplateKindSchema, co as timedRunLimitOf, d as ActionVariableSchema, do as timedRunSeconds, ea as powerSourceLinkOfComposition, er as coreBlockComposition, fa as remoteCapability, fn as actionSourceCapability, fo as toTimings, ga as resolveActionVariables, gc as hydrateSchema, gi as localDateOf, ha as replacedFieldKeys, hn as addonIdOfActionId, ho as validateComposition, ic as defineAddonMigrations,
|
|
1
|
+
import { $i as powerSourceCapability, $n as coreBlockAddonId, $t as SchedulerSchema, A as ControlStatusSchema, An as buildCapabilityLookup, Ar as evaluateWhenTree, As as RecordIntegrationInstances, Br as findChannelSource, C as CORE_BLOCKS_ADDON_ID, Da as resolveRemoteSource, Do as CompositionSchema, Ec as isSecretMarker, Eo as COMPOSER_ADDON_ID, Fa as schedulersCapability, Fi as nextOccurrence, Ga as siteFor, Gn as collectWhenMirrorSources, Hn as checkTemplatePayload, Ho as compositionSourceKey, Hs as actionEffect, Ii as normalizeActionUnits, Jn as compileScalarOverride, Jo as historyRetentionFromSettings, Jr as heroLayoutCapability, Jt as RunningStateStatusSchema, Kt as RemoteAssumedStateSchema, Li as normalizeCapStep, Lo as composedDeviceRef, Lr as fanPresetsCapability, Lt as PowerSourceInfoSchema, Ma as runSteps, Nn as buildHeroModel, No as HelperMemberSchema, O as ConditionMirror, Oc as isSecretRefOwnedBy, Oo as DAY_MS, Ot as MediaPlayerStatusSchema, Qs as collectSecretMarkerRefs, Qt as SchedulerError, R as DEFAULT_HOLD_OVERRIDE, Ri as normalizeCoreBlockWrite, Rn as capUnitResolver, Ro as composedDeviceStableId, S as COMPOSER_RUNNER_ID, Sn as appendTrace, So as weekdayOfLocalDate, To as zoneOnlySite, Ui as occurrenceOn, Ut as REMOTE_MEDIA_COMMANDS, Vc as resolveSecretMarkers, Vt as QuantityUnitError, Wc as secretTreeFromSchema, Wn as collectDeviceTemplates, Xr as internalActionId, Ya as stableIdMapOf, Yc as transformSecretWrite, Yr as integrationInstancesCapability, Z as DeclaredDevices, Zc as vocabActionIdFor, Zi as planComposition, Zn as compositionSourceRefs, _o as validateSchedulerInput, aa as projectDeviceRow, ai as isInternalActionId, al as EventCategory$1, at as FAN_CAPTURE_FIELDS, ba as resolveCoreBlockFiles, bi as lockDoorLinkOfComposition, c as ActionError, ca as readStoredRemoteConfig, cn as TemplateKindSchema, co as timedRunLimitOf, d as ActionVariableSchema, do as timedRunSeconds, ea as powerSourceLinkOfComposition, er as coreBlockComposition, fa as remoteCapability, fn as actionSourceCapability, fo as toTimings, ga as resolveActionVariables, gc as hydrateSchema, gi as localDateOf, ha as replacedFieldKeys, hn as addonIdOfActionId, ho as validateComposition, ic as defineAddonMigrations, it as EMPTY_REMOTE_CONFIG, j as CoreBlockSchema, ka as resolveStepArgs, kn as buildActionSteps, kr as evaluateStepCondition, l as ActionStepSchema, lo as timedRunMaxIn, lt as FanPresetSchema, m as BUILTIN_REMOTE_COMPONENTS, ma as remoteSourceSteps, mn as actionsCapability, mr as describeComposableCaps, n as ACTION_TARGET_INVALIDATION_EVENTS, na as problemsBlockSave, nl as DeviceType$1, nr as coreBlockSourceKind, nt as EMPTY_AUTOMATION_STATE, oa as proposeRunningThreshold, oc as defineEntryKind, oo as templateCapability, or as customKeyOfRole, os as BaseAddon, p as AutomationStateDocSchema, pa as remoteLayoutComponentsCapability, pn as actionWaitTotalMs, qo as helperMembers, qt as RemoteLayoutPayloadSchema, rl as errMsg$1, rr as coreBlocksCapability, rt as EMPTY_REMOTE_ASSUMED_STATE, s as ALL_CAPABILITY_DEFINITIONS, sc as defineRecordKinds, sn as SwitchStatusSchema, so as timedRunCapability, st as FanControlStatusSchema, tc as commandOrigin, tr as coreBlockIdFromAddonId, u as ActionTargetResolver, uc as entryBody, ui as kebabToCamel, uo as timedRunQuickRun, vt as IDLE_ACTION_STATUS, w as CORE_BLOCK_ADDON_PREFIX, xa as resolveHeroLayout, ya as resolveCoreBlockEntry, yt as INTERNAL_ACTION_PREFIX, za as seedInstanceOnce, zi as normalizeStepTargets } from "../../dist-BQiyo22b.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-mx-2yCDv.mjs";
|
|
4
|
+
import { i as capSeriesKey } from "../../capture-engine-D_GQBgrZ.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 { createRequire } from "node:module";
|
|
@@ -8484,6 +8484,25 @@ async function refuseRetarget(deps, blockId, patch) {
|
|
|
8484
8484
|
if (patch.name !== void 0) return refuseSave(deps, subject, pinned, NO_NAME_OF_ITS_OWN);
|
|
8485
8485
|
if (next === null || compositionSourceKey(next) !== compositionSourceKey(pinned)) return refuseSave(deps, subject, pinned, DEVICE_IS_FIXED);
|
|
8486
8486
|
}
|
|
8487
|
+
/**
|
|
8488
|
+
* An editor rename of a composed device (not a customization, not a create)
|
|
8489
|
+
* writes the device name after the block has been saved. A failed device
|
|
8490
|
+
* write is logged and does not fail the save.
|
|
8491
|
+
*/
|
|
8492
|
+
async function followComposedRename(deps, previous, name) {
|
|
8493
|
+
const write = deps.writeComposedDeviceName;
|
|
8494
|
+
if (write === void 0 || previous === null || name === void 0 || name === previous.name) return;
|
|
8495
|
+
const composition = coreBlockComposition(previous);
|
|
8496
|
+
if (composition === null || existingTarget(composition) !== null) return;
|
|
8497
|
+
try {
|
|
8498
|
+
await write(previous.id, name);
|
|
8499
|
+
} catch (err) {
|
|
8500
|
+
deps.logger.warn("composed block was renamed but the device name was not written — retried on the next apply", { meta: {
|
|
8501
|
+
blockId: previous.id,
|
|
8502
|
+
error: errMsg$1(err)
|
|
8503
|
+
} });
|
|
8504
|
+
}
|
|
8505
|
+
}
|
|
8487
8506
|
/** The block customizing `device`, found by TARGET — never by its derived name (rule 4). */
|
|
8488
8507
|
function customizationOf(blocks, device) {
|
|
8489
8508
|
const key = compositionSourceKey(device);
|
|
@@ -8532,10 +8551,12 @@ function buildCompositionApi(deps) {
|
|
|
8532
8551
|
blockId
|
|
8533
8552
|
}, judged.validation, judged.memberDeviceIds);
|
|
8534
8553
|
}
|
|
8554
|
+
const previous = deps.store.get(blockId);
|
|
8535
8555
|
const updated = await deps.store.updateComposition(blockId, block);
|
|
8556
|
+
await followComposedRename(deps, previous, block.name);
|
|
8536
8557
|
deps.logger.info("composition updated", { meta: {
|
|
8537
8558
|
blockId,
|
|
8538
|
-
by: caller
|
|
8559
|
+
by: caller?.userId ?? "system"
|
|
8539
8560
|
} });
|
|
8540
8561
|
if (block.composition !== void 0) {
|
|
8541
8562
|
const unreleased = (await deps.convergeForClaims()).filter((claim) => claim.owner === blockId);
|
|
@@ -8613,6 +8634,40 @@ function buildCompositionApi(deps) {
|
|
|
8613
8634
|
};
|
|
8614
8635
|
}
|
|
8615
8636
|
//#endregion
|
|
8637
|
+
//#region src/builtins/core-blocks/sync-composed-device-name.ts
|
|
8638
|
+
/**
|
|
8639
|
+
* An operator rename in the composition editor writes the composed device's
|
|
8640
|
+
* name as well, stamped, so the row and the block agree. The device is the
|
|
8641
|
+
* row whose stable id is `composed-<blockId>` under the composer addon.
|
|
8642
|
+
* A failure is logged and swallowed: the block save has already landed, and
|
|
8643
|
+
* the composer's next apply retries the device write.
|
|
8644
|
+
*/
|
|
8645
|
+
async function writeComposedDeviceName(port, logger, blockId, name) {
|
|
8646
|
+
const stableId = composedDeviceStableId(blockId);
|
|
8647
|
+
let deviceId = null;
|
|
8648
|
+
try {
|
|
8649
|
+
const row = (await port.listPersistedByAddon(COMPOSER_ADDON_ID)).find((candidate) => candidate.stableId === stableId);
|
|
8650
|
+
if (row === void 0) {
|
|
8651
|
+
logger.warn("composed block was renamed but its device row was not found — retried on the next apply", { meta: {
|
|
8652
|
+
blockId,
|
|
8653
|
+
stableId
|
|
8654
|
+
} });
|
|
8655
|
+
return;
|
|
8656
|
+
}
|
|
8657
|
+
deviceId = row.id;
|
|
8658
|
+
if (row.name === name) return;
|
|
8659
|
+
await port.setOperatorName(row.id, name);
|
|
8660
|
+
} catch (err) {
|
|
8661
|
+
logger.warn("composed block was renamed but the device name was not written — retried on the next apply", {
|
|
8662
|
+
...deviceId === null ? {} : { tags: { deviceId } },
|
|
8663
|
+
meta: {
|
|
8664
|
+
blockId,
|
|
8665
|
+
error: errMsg$1(err)
|
|
8666
|
+
}
|
|
8667
|
+
});
|
|
8668
|
+
}
|
|
8669
|
+
}
|
|
8670
|
+
//#endregion
|
|
8616
8671
|
//#region src/builtins/core-blocks/extract-settings-schema.ts
|
|
8617
8672
|
/**
|
|
8618
8673
|
* Read an optional `settingsSchema` named export from a compiled block bundle.
|
|
@@ -9429,6 +9484,15 @@ var CoreBlocksAddon = class extends BaseAddon {
|
|
|
9429
9484
|
logger: this.ctx.logger.child("running-proposal")
|
|
9430
9485
|
},
|
|
9431
9486
|
logger: this.ctx.logger.child("compositions"),
|
|
9487
|
+
writeComposedDeviceName: (blockId, name) => writeComposedDeviceName({
|
|
9488
|
+
listPersistedByAddon: async (addonId) => requireApi().deviceManager.listPersistedByAddon.query({ addonId }),
|
|
9489
|
+
setOperatorName: async (deviceId, deviceName) => {
|
|
9490
|
+
await requireApi().deviceManager.setName.mutate({
|
|
9491
|
+
deviceId,
|
|
9492
|
+
name: deviceName
|
|
9493
|
+
});
|
|
9494
|
+
}
|
|
9495
|
+
}, this.ctx.logger.child("compositions"), blockId, name),
|
|
9432
9496
|
capabilityDefinitions: ALL_CAPABILITY_DEFINITIONS
|
|
9433
9497
|
});
|
|
9434
9498
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An operator rename of a composed device writes the composition block's
|
|
3
|
+
* name, so the next composer apply does not put the old name back (D659).
|
|
4
|
+
* Name-only: the composition body is not touched, and a customization (which
|
|
5
|
+
* has no name of its own) is never a composed device.
|
|
6
|
+
*/
|
|
7
|
+
import { type AddonApi, type IScopedLogger } from "@camstack/types";
|
|
8
|
+
/** The block id behind a composed device, or null when the row is not one. */
|
|
9
|
+
export declare function composedBlockIdOf(addonId: string, stableId: string): string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Make the stored block name `name`. A conflict with a save that landed
|
|
12
|
+
* between the read and the write is retried once. A failure is logged and
|
|
13
|
+
* swallowed: the device rename has already landed, and the composer's next
|
|
14
|
+
* apply writes the block again.
|
|
15
|
+
*/
|
|
16
|
+
export declare function renameCompositionBlock(api: AddonApi, logger: IScopedLogger, deviceId: number, blockId: string, name: string): Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An operator rename in the composition editor writes the composed device's
|
|
3
|
+
* name as well, stamped, so the row and the block agree. The device is the
|
|
4
|
+
* row whose stable id is `composed-<blockId>` under the composer addon.
|
|
5
|
+
* A failure is logged and swallowed: the block save has already landed, and
|
|
6
|
+
* the composer's next apply retries the device write.
|
|
7
|
+
*/
|
|
8
|
+
import { type IScopedLogger } from "@camstack/types";
|
|
9
|
+
export interface ComposedDeviceNameRow {
|
|
10
|
+
readonly id: number;
|
|
11
|
+
readonly stableId: string;
|
|
12
|
+
readonly name: string;
|
|
13
|
+
}
|
|
14
|
+
/** The device-manager calls this needs. `setOperatorName` stamps `userNamed`. */
|
|
15
|
+
export interface ComposedDeviceNamePort {
|
|
16
|
+
listPersistedByAddon(addonId: string): Promise<readonly ComposedDeviceNameRow[]>;
|
|
17
|
+
setOperatorName(deviceId: number, name: string): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export declare function writeComposedDeviceName(port: ComposedDeviceNamePort, logger: IScopedLogger, blockId: string, name: string): Promise<void>;
|
|
@@ -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-izXDzt4g.js");
|
|
7
|
+
const require_capture_engine = require("../../capture-engine-C0Z5rwCO.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 { Cc as isReadingQuantity, Cn as armRemovalReconcile, Ns as RecordTooLargeError, Q as DeviceRunSchema, V as DEVICE_HISTORY_ENERGY_KEY, _s as InvalidRecordError, as as wattMillisecondsToKwh, br as deviceRemovalHookCapability, hc as historyUnitFor,
|
|
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 { Cc as isReadingQuantity, Cn as armRemovalReconcile, Ns as RecordTooLargeError, Q as DeviceRunSchema, V as DEVICE_HISTORY_ENERGY_KEY, _s as InvalidRecordError, al as EventCategory, as as wattMillisecondsToKwh, br as deviceRemovalHookCapability, hc as historyUnitFor, lc as emitReadiness, mt as HISTORY_ITEM_CATALOG, nl as DeviceType, os as BaseAddon, ps as DeviceTransitionSchema, pt as HISTORY_CATALOG, sc as defineRecordKinds, vr as deviceHistoryCapability, wr as deviceTransitionsCapability, xr as deviceRunsCapability } from "../../dist-BQiyo22b.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-D_GQBgrZ.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
|
|
@@ -3,9 +3,10 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-izXDzt4g.js");
|
|
7
7
|
const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
|
|
8
8
|
const require_log_redactor = require("../../log-redactor-BhIEMaG9.js");
|
|
9
|
+
const require_rename_composition_block = require("../../rename-composition-block-6oLQVzft.js");
|
|
9
10
|
const require_prefix_range = require("../../prefix-range-D_KueXbQ.js");
|
|
10
11
|
const require_prefix_walk = require("../../prefix-walk-Dv6MLZlM.js");
|
|
11
12
|
const require_retired_settings_keys = require("../../retired-settings-keys-C8nOOr5H.js");
|
|
@@ -6884,6 +6885,7 @@ async function loadMeta(pctx, input) {
|
|
|
6884
6885
|
addonId,
|
|
6885
6886
|
type: m.type,
|
|
6886
6887
|
name: m.name,
|
|
6888
|
+
...m.userNamed !== void 0 ? { userNamed: m.userNamed } : {},
|
|
6887
6889
|
location: m.location ?? null,
|
|
6888
6890
|
disabled: m.disabled ?? false,
|
|
6889
6891
|
parentDeviceId: m.parentDeviceId,
|
|
@@ -6902,17 +6904,28 @@ async function loadMeta(pctx, input) {
|
|
|
6902
6904
|
*/
|
|
6903
6905
|
async function setName(pctx, input) {
|
|
6904
6906
|
const { deviceId, name } = input;
|
|
6907
|
+
const stamp = input.stampUserNamed !== false;
|
|
6905
6908
|
const cascaded = [];
|
|
6909
|
+
let keptOperatorName = null;
|
|
6910
|
+
let blockId = null;
|
|
6906
6911
|
await pctx.metaStore.withMetaWriteLock(async () => {
|
|
6907
6912
|
const persisted = await pctx.metaStore.resolvePersistedById(deviceId);
|
|
6908
6913
|
if (!persisted) throw new Error(`[device-manager] setName: unknown device id=${deviceId}`);
|
|
6909
6914
|
const { meta: m } = persisted;
|
|
6910
6915
|
const oldName = m.name;
|
|
6911
|
-
|
|
6916
|
+
if (!stamp && m.userNamed === true && oldName !== name) {
|
|
6917
|
+
keptOperatorName = oldName;
|
|
6918
|
+
return;
|
|
6919
|
+
}
|
|
6920
|
+
blockId = stamp ? require_rename_composition_block.composedBlockIdOf(m.addonId, m.stableId) : null;
|
|
6921
|
+
await pctx.metaStore.rows.patch(deviceId, stamp ? {
|
|
6912
6922
|
name,
|
|
6913
6923
|
userNamed: true
|
|
6924
|
+
} : {
|
|
6925
|
+
name,
|
|
6926
|
+
userNamed: false
|
|
6914
6927
|
});
|
|
6915
|
-
if (oldName.length > 0 && oldName !== name) {
|
|
6928
|
+
if (stamp && oldName.length > 0 && oldName !== name) {
|
|
6916
6929
|
const candidates = /* @__PURE__ */ new Map();
|
|
6917
6930
|
for (const row of await pctx.metaStore.rows.listByParent(deviceId)) candidates.set(row.meta.id, row.meta);
|
|
6918
6931
|
for (const row of await pctx.metaStore.rows.listAll()) if (row.meta.linkDeviceId === deviceId) candidates.set(row.meta.id, row.meta);
|
|
@@ -6928,6 +6941,16 @@ async function setName(pctx, input) {
|
|
|
6928
6941
|
}
|
|
6929
6942
|
}
|
|
6930
6943
|
});
|
|
6944
|
+
if (keptOperatorName !== null) {
|
|
6945
|
+
pctx.host.ctx.logger.info("composed device keeps the name the operator gave it", {
|
|
6946
|
+
tags: { deviceId },
|
|
6947
|
+
meta: {
|
|
6948
|
+
name: keptOperatorName,
|
|
6949
|
+
requested: name
|
|
6950
|
+
}
|
|
6951
|
+
});
|
|
6952
|
+
return;
|
|
6953
|
+
}
|
|
6931
6954
|
pctx.host.ctx.eventBus.emit({
|
|
6932
6955
|
id: (0, node_crypto.randomUUID)(),
|
|
6933
6956
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -6956,6 +6979,17 @@ async function setName(pctx, input) {
|
|
|
6956
6979
|
value: child.name
|
|
6957
6980
|
}
|
|
6958
6981
|
});
|
|
6982
|
+
if (blockId !== null) {
|
|
6983
|
+
const api = pctx.host.ctx.api;
|
|
6984
|
+
if (api === void 0) {
|
|
6985
|
+
pctx.host.ctx.logger.warn("composed rename did not reach the block — no api on this node, retried on the next apply", {
|
|
6986
|
+
tags: { deviceId },
|
|
6987
|
+
meta: { blockId }
|
|
6988
|
+
});
|
|
6989
|
+
return;
|
|
6990
|
+
}
|
|
6991
|
+
await require_rename_composition_block.renameCompositionBlock(api, pctx.host.ctx.logger, deviceId, blockId, name);
|
|
6992
|
+
}
|
|
6959
6993
|
}
|
|
6960
6994
|
/**
|
|
6961
6995
|
* Every descendant of `rootId`, walked via `parentDeviceId` chains.
|