@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
|
@@ -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");
|
|
@@ -2786,6 +2786,75 @@ var ADDON_MIGRATIONS = [
|
|
|
2786
2786
|
}
|
|
2787
2787
|
];
|
|
2788
2788
|
//#endregion
|
|
2789
|
+
//#region src/builtins/core-blocks/device-template-door.ts
|
|
2790
|
+
function templateDoorOver(api) {
|
|
2791
|
+
const need = () => {
|
|
2792
|
+
const current = api();
|
|
2793
|
+
if (current === void 0) throw new Error("no ctx.api on this node — templates cannot be rendered");
|
|
2794
|
+
return current;
|
|
2795
|
+
};
|
|
2796
|
+
return {
|
|
2797
|
+
render: async (templates, allowedDeviceIds) => {
|
|
2798
|
+
return (await need().deviceManager.renderDeviceTemplates.query({
|
|
2799
|
+
templates: [...templates],
|
|
2800
|
+
...allowedDeviceIds === void 0 ? {} : { allowedDeviceIds: [...allowedDeviceIds] }
|
|
2801
|
+
})).results;
|
|
2802
|
+
},
|
|
2803
|
+
check: async (templates, allowedDeviceIds) => {
|
|
2804
|
+
return (await need().deviceManager.checkDeviceTemplates.query({
|
|
2805
|
+
templates: [...templates],
|
|
2806
|
+
...allowedDeviceIds === void 0 ? {} : { allowedDeviceIds: [...allowedDeviceIds] }
|
|
2807
|
+
})).results;
|
|
2808
|
+
}
|
|
2809
|
+
};
|
|
2810
|
+
}
|
|
2811
|
+
/** The renderer a step run is given, bound to the devices its caller may read (`undefined` = all). */
|
|
2812
|
+
function stepRenderer(door, allowedDeviceIds) {
|
|
2813
|
+
if (door === void 0) return void 0;
|
|
2814
|
+
return (templates) => door.render(templates, allowedDeviceIds);
|
|
2815
|
+
}
|
|
2816
|
+
//#endregion
|
|
2817
|
+
//#region src/builtins/core-blocks/step-condition-door.ts
|
|
2818
|
+
/**
|
|
2819
|
+
* The core-blocks side of a conditional step (#472): a step's `if` is read on a
|
|
2820
|
+
* mirror filled over `ctx.api` (`deviceState.getCapSlice`), the same state
|
|
2821
|
+
* every other consumer of the ONE `when` tree reads. A run on behalf of a
|
|
2822
|
+
* non-admin may only branch on devices that caller can see — a branch is an
|
|
2823
|
+
* answer, and an out-of-scope answer is a leak — so a tree naming any other
|
|
2824
|
+
* device (or a stable id, which cannot be proven) reads `unknown`: neither side
|
|
2825
|
+
* runs, and the trace says why.
|
|
2826
|
+
*/
|
|
2827
|
+
function conditionDoorOver(api) {
|
|
2828
|
+
return (readable) => async (when) => {
|
|
2829
|
+
const current = api();
|
|
2830
|
+
if (current === void 0) return {
|
|
2831
|
+
result: "unknown",
|
|
2832
|
+
reason: "this node has no ctx.api to read state through"
|
|
2833
|
+
};
|
|
2834
|
+
if (readable !== void 0) {
|
|
2835
|
+
if (require_dist.collectWhenMirrorSources(when).filter((source) => source.kind === "stable" || !readable.includes(source.deviceId)).length > 0) return {
|
|
2836
|
+
result: "unknown",
|
|
2837
|
+
reason: "the condition reads a device this caller was not proven to see"
|
|
2838
|
+
};
|
|
2839
|
+
}
|
|
2840
|
+
return require_dist.evaluateStepCondition(when, {
|
|
2841
|
+
fetchSlice: (deviceId, cap) => current.deviceState.getCapSlice.query({
|
|
2842
|
+
deviceId,
|
|
2843
|
+
capName: cap
|
|
2844
|
+
}),
|
|
2845
|
+
fetchStableIds: async () => require_dist.stableIdMapOf(await current.deviceManager.listAll.query({}))
|
|
2846
|
+
});
|
|
2847
|
+
};
|
|
2848
|
+
}
|
|
2849
|
+
/** The evaluator a step run is given; `undefined` when the consumer has no door. */
|
|
2850
|
+
function stepConditionEvaluator(door, readable) {
|
|
2851
|
+
return door === void 0 ? void 0 : door(readable);
|
|
2852
|
+
}
|
|
2853
|
+
/** The `evaluateCondition` dep of a step run, or nothing (a guarded step then reads `unknown`). */
|
|
2854
|
+
function conditionDeps(evaluator) {
|
|
2855
|
+
return evaluator === void 0 ? {} : { evaluateCondition: evaluator };
|
|
2856
|
+
}
|
|
2857
|
+
//#endregion
|
|
2789
2858
|
//#region src/builtins/core-blocks/runs-ledger.ts
|
|
2790
2859
|
/**
|
|
2791
2860
|
* The hub's runs ledger: what each automation block and each Action run DID.
|
|
@@ -2989,6 +3058,8 @@ var ActionsService = class {
|
|
|
2989
3058
|
newRunId;
|
|
2990
3059
|
units;
|
|
2991
3060
|
targets;
|
|
3061
|
+
templates;
|
|
3062
|
+
conditions;
|
|
2992
3063
|
running = /* @__PURE__ */ new Map();
|
|
2993
3064
|
maxRunMs;
|
|
2994
3065
|
stopGraceMs;
|
|
@@ -3005,6 +3076,8 @@ var ActionsService = class {
|
|
|
3005
3076
|
this.stopGraceMs = deps.stopGraceMs ?? STOP_GRACE_MS;
|
|
3006
3077
|
this.units = deps.units ?? require_dist.capUnitResolver(require_dist.ALL_CAPABILITY_DEFINITIONS);
|
|
3007
3078
|
this.targets = new require_dist.ActionTargetResolver(deps.directory, deps.logger);
|
|
3079
|
+
this.templates = deps.templates;
|
|
3080
|
+
this.conditions = deps.conditions;
|
|
3008
3081
|
}
|
|
3009
3082
|
/** One-shot at boot: stored steps written before D983 are rewritten to the target shape. */
|
|
3010
3083
|
async migrateTargets() {
|
|
@@ -3086,12 +3159,37 @@ var ActionsService = class {
|
|
|
3086
3159
|
});
|
|
3087
3160
|
throw new require_dist.ActionError("not-linked", reason);
|
|
3088
3161
|
}
|
|
3162
|
+
/**
|
|
3163
|
+
* The devices a run's templates may read. An admin (or an in-process block)
|
|
3164
|
+
* reads any (`undefined`); a non-admin only the camera the scope gate proved
|
|
3165
|
+
* it may see — fail-closed, because the gate proves nothing about any other.
|
|
3166
|
+
*/
|
|
3167
|
+
readableDevices(input) {
|
|
3168
|
+
if (input.caller === void 0 || input.caller.isAdmin) return void 0;
|
|
3169
|
+
return input.deviceId === void 0 ? [] : [input.deviceId];
|
|
3170
|
+
}
|
|
3171
|
+
/** A non-admin run is refused up front when a template names a device outside `readable`. */
|
|
3172
|
+
async checkTemplateScope(entry, readable, deviceId) {
|
|
3173
|
+
if (readable === void 0 || entry.source !== "internal" || this.templates === void 0) return;
|
|
3174
|
+
const templates = require_dist.collectDeviceTemplates(entry.steps ?? []);
|
|
3175
|
+
if (templates.length === 0) return;
|
|
3176
|
+
const outside = (await this.templates.check(templates, readable)).flatMap((c) => c.ok ? c.aliases.filter((a) => !a.allowed) : []);
|
|
3177
|
+
if (outside.length === 0) return;
|
|
3178
|
+
const reason = `a template names ${[...new Set(outside.map((a) => a.alias))].join(", ")}, which this caller was not proven to see`;
|
|
3179
|
+
this.logger.warn(`action run refused — ${reason}`, {
|
|
3180
|
+
...deviceId === void 0 ? {} : { tags: { deviceId } },
|
|
3181
|
+
meta: { actionId: entry.id }
|
|
3182
|
+
});
|
|
3183
|
+
throw new require_dist.ActionError("template-scope", reason);
|
|
3184
|
+
}
|
|
3089
3185
|
async run(input) {
|
|
3090
3186
|
await this.authorize(input.caller, input.actionId, input.deviceId, "run");
|
|
3091
3187
|
const entry = await this.find(input.actionId);
|
|
3092
3188
|
if (entry === null) throw new require_dist.ActionError("not-found", `no action "${input.actionId}"`);
|
|
3093
3189
|
const resolved = require_dist.resolveActionVariables(entry.variables, input.variables);
|
|
3094
3190
|
if (!resolved.ok) throw new require_dist.ActionError("invalid-variables", resolved.error);
|
|
3191
|
+
const readable = this.readableDevices(input);
|
|
3192
|
+
await this.checkTemplateScope(entry, readable, input.deviceId);
|
|
3095
3193
|
const runId = this.newRunId();
|
|
3096
3194
|
const startedAt = this.now();
|
|
3097
3195
|
const trigger = this.triggerOf(input, resolved.values);
|
|
@@ -3136,7 +3234,7 @@ var ActionsService = class {
|
|
|
3136
3234
|
lastRunAt: startedAt,
|
|
3137
3235
|
lastError: null
|
|
3138
3236
|
});
|
|
3139
|
-
const done = this.execute(entry, resolved.values, runId, startedAt, trigger, token);
|
|
3237
|
+
const done = this.execute(entry, resolved.values, runId, startedAt, trigger, token, readable);
|
|
3140
3238
|
if (input.wait === true) return done;
|
|
3141
3239
|
return {
|
|
3142
3240
|
runId,
|
|
@@ -3157,13 +3255,13 @@ var ActionsService = class {
|
|
|
3157
3255
|
};
|
|
3158
3256
|
}
|
|
3159
3257
|
/** Never rejects: a run's failure is its outcome. */
|
|
3160
|
-
async execute(entry, values, runId, startedAt, trigger, token) {
|
|
3258
|
+
async execute(entry, values, runId, startedAt, trigger, token, readable) {
|
|
3161
3259
|
let outcome = "failed";
|
|
3162
3260
|
let steps = [];
|
|
3163
3261
|
let message;
|
|
3164
3262
|
const deadline = this.armDeadline(entry.id, runId, token);
|
|
3165
3263
|
try {
|
|
3166
|
-
const running = require_dist.runSteps(this.runnableFor(entry, values, token, runId), {
|
|
3264
|
+
const running = require_dist.runSteps(this.runnableFor(entry, values, token, runId, readable), {
|
|
3167
3265
|
pathPrefix: "steps",
|
|
3168
3266
|
isAborted: () => token.aborted,
|
|
3169
3267
|
abortReason: "the run was stopped",
|
|
@@ -3178,6 +3276,17 @@ var ActionsService = class {
|
|
|
3178
3276
|
error: failure.message
|
|
3179
3277
|
}
|
|
3180
3278
|
});
|
|
3279
|
+
},
|
|
3280
|
+
onGuardUnknown: (skipped) => {
|
|
3281
|
+
this.logger.warn("action step skipped — its condition could not be read", {
|
|
3282
|
+
...skipped.deviceId === void 0 ? {} : { tags: { deviceId: skipped.deviceId } },
|
|
3283
|
+
meta: {
|
|
3284
|
+
actionId: entry.id,
|
|
3285
|
+
runId,
|
|
3286
|
+
step: skipped.index,
|
|
3287
|
+
reason: skipped.reason
|
|
3288
|
+
}
|
|
3289
|
+
});
|
|
3181
3290
|
}
|
|
3182
3291
|
});
|
|
3183
3292
|
const result = await Promise.race([running, deadline.expired]);
|
|
@@ -3267,7 +3376,7 @@ var ActionsService = class {
|
|
|
3267
3376
|
}
|
|
3268
3377
|
};
|
|
3269
3378
|
}
|
|
3270
|
-
runnableFor(entry, values, token, runId) {
|
|
3379
|
+
runnableFor(entry, values, token, runId, readable) {
|
|
3271
3380
|
if (entry.source === "internal") return require_dist.buildActionSteps(entry.steps ?? [], values, {
|
|
3272
3381
|
invokeCap: (call) => this.invokeCap({
|
|
3273
3382
|
...call,
|
|
@@ -3280,6 +3389,8 @@ var ActionsService = class {
|
|
|
3280
3389
|
sleep: (ms) => token.sleep(ms),
|
|
3281
3390
|
resolveTarget: (target, actionId, vars, origin) => this.targets.resolve(target, actionId, vars, origin),
|
|
3282
3391
|
owner: entry.id,
|
|
3392
|
+
renderTemplates: stepRenderer(this.templates, readable),
|
|
3393
|
+
...conditionDeps(stepConditionEvaluator(this.conditions, readable)),
|
|
3283
3394
|
onMissingVar: (name) => this.logger.warn("action template referenced a variable that was never set", { meta: {
|
|
3284
3395
|
actionId: entry.id,
|
|
3285
3396
|
variable: name
|
|
@@ -3759,6 +3870,8 @@ function buildActionsRuntime(deps) {
|
|
|
3759
3870
|
sources: sourcesOver(deps.api),
|
|
3760
3871
|
directory: deps.directory ?? directoryOver(deps.api),
|
|
3761
3872
|
invokeCap: invokeCapOver(deps.api),
|
|
3873
|
+
templates: templateDoorOver(deps.api),
|
|
3874
|
+
conditions: conditionDoorOver(deps.api),
|
|
3762
3875
|
emit: (event) => deps.eventBus.emit({
|
|
3763
3876
|
id: (0, node_crypto.randomUUID)(),
|
|
3764
3877
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -5259,6 +5372,8 @@ var SchedulerEngine = class {
|
|
|
5259
5372
|
}),
|
|
5260
5373
|
resolveTarget: (target, actionId, v, origin) => this.deps.targets.resolve(target, actionId, v, origin),
|
|
5261
5374
|
owner: `scheduler:${scheduler.id}`,
|
|
5375
|
+
renderTemplates: stepRenderer(this.deps.templates),
|
|
5376
|
+
...conditionDeps(stepConditionEvaluator(this.deps.conditions)),
|
|
5262
5377
|
onMissingVar: () => void 0
|
|
5263
5378
|
}), {
|
|
5264
5379
|
pathPrefix: "steps",
|
|
@@ -5274,6 +5389,16 @@ var SchedulerEngine = class {
|
|
|
5274
5389
|
error: failure.message
|
|
5275
5390
|
}
|
|
5276
5391
|
});
|
|
5392
|
+
},
|
|
5393
|
+
onGuardUnknown: (skipped) => {
|
|
5394
|
+
this.deps.logger.warn("scheduler edge step skipped — its condition could not be read", {
|
|
5395
|
+
...skipped.deviceId === void 0 ? {} : { tags: { deviceId: skipped.deviceId } },
|
|
5396
|
+
meta: {
|
|
5397
|
+
...vars,
|
|
5398
|
+
step: skipped.index,
|
|
5399
|
+
reason: skipped.reason
|
|
5400
|
+
}
|
|
5401
|
+
});
|
|
5277
5402
|
}
|
|
5278
5403
|
});
|
|
5279
5404
|
steps = result.steps;
|
|
@@ -5709,6 +5834,8 @@ function buildSchedulersRuntime(deps) {
|
|
|
5709
5834
|
store,
|
|
5710
5835
|
host,
|
|
5711
5836
|
targets,
|
|
5837
|
+
templates: templateDoorOver(deps.api),
|
|
5838
|
+
conditions: conditionDoorOver(deps.api),
|
|
5712
5839
|
logger: deps.logger.child("engine"),
|
|
5713
5840
|
record: (schedulerId, trace) => deps.ledger.report(schedulerOwner(schedulerId), {
|
|
5714
5841
|
trace,
|
|
@@ -7379,6 +7506,8 @@ var FanPresetsService = class {
|
|
|
7379
7506
|
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
7380
7507
|
resolveTarget: async (target) => ({ deviceIds: target.kind === "devices" ? target.ids : [] }),
|
|
7381
7508
|
owner: `fan-preset:${deviceId}/${presetId}`,
|
|
7509
|
+
renderTemplates: stepRenderer(this.deps.templates, [deviceId]),
|
|
7510
|
+
...conditionDeps(stepConditionEvaluator(this.deps.conditions, [deviceId])),
|
|
7382
7511
|
onMissingVar: () => void 0
|
|
7383
7512
|
}), {
|
|
7384
7513
|
pathPrefix: "steps",
|
|
@@ -7395,6 +7524,17 @@ var FanPresetsService = class {
|
|
|
7395
7524
|
error: failure.message
|
|
7396
7525
|
}
|
|
7397
7526
|
});
|
|
7527
|
+
},
|
|
7528
|
+
onGuardUnknown: (skipped) => {
|
|
7529
|
+
this.deps.logger.warn("fan preset step skipped — its condition could not be read", {
|
|
7530
|
+
tags: { deviceId: skipped.deviceId ?? deviceId },
|
|
7531
|
+
meta: {
|
|
7532
|
+
fanDeviceId: deviceId,
|
|
7533
|
+
presetId,
|
|
7534
|
+
step: skipped.index,
|
|
7535
|
+
reason: skipped.reason
|
|
7536
|
+
}
|
|
7537
|
+
});
|
|
7398
7538
|
}
|
|
7399
7539
|
});
|
|
7400
7540
|
const steps = result.steps.map((trace, index) => ({
|
|
@@ -7736,6 +7876,8 @@ function buildFanPresetsRuntime(deps) {
|
|
|
7736
7876
|
devices,
|
|
7737
7877
|
readings: fanPresetsReadingsOver(deps.api, deps.logger.child("fan-presets")),
|
|
7738
7878
|
invoke: invokeCapOver(deps.api),
|
|
7879
|
+
templates: templateDoorOver(deps.api),
|
|
7880
|
+
conditions: conditionDoorOver(deps.api),
|
|
7739
7881
|
logger: deps.logger.child("fan-presets")
|
|
7740
7882
|
});
|
|
7741
7883
|
return {
|
|
@@ -8358,6 +8500,25 @@ async function refuseRetarget(deps, blockId, patch) {
|
|
|
8358
8500
|
if (patch.name !== void 0) return refuseSave(deps, subject, pinned, NO_NAME_OF_ITS_OWN);
|
|
8359
8501
|
if (next === null || require_dist.compositionSourceKey(next) !== require_dist.compositionSourceKey(pinned)) return refuseSave(deps, subject, pinned, DEVICE_IS_FIXED);
|
|
8360
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
|
+
}
|
|
8361
8522
|
/** The block customizing `device`, found by TARGET — never by its derived name (rule 4). */
|
|
8362
8523
|
function customizationOf(blocks, device) {
|
|
8363
8524
|
const key = require_dist.compositionSourceKey(device);
|
|
@@ -8406,10 +8567,12 @@ function buildCompositionApi(deps) {
|
|
|
8406
8567
|
blockId
|
|
8407
8568
|
}, judged.validation, judged.memberDeviceIds);
|
|
8408
8569
|
}
|
|
8570
|
+
const previous = deps.store.get(blockId);
|
|
8409
8571
|
const updated = await deps.store.updateComposition(blockId, block);
|
|
8572
|
+
await followComposedRename(deps, previous, block.name);
|
|
8410
8573
|
deps.logger.info("composition updated", { meta: {
|
|
8411
8574
|
blockId,
|
|
8412
|
-
by: caller
|
|
8575
|
+
by: caller?.userId ?? "system"
|
|
8413
8576
|
} });
|
|
8414
8577
|
if (block.composition !== void 0) {
|
|
8415
8578
|
const unreleased = (await deps.convergeForClaims()).filter((claim) => claim.owner === blockId);
|
|
@@ -8487,6 +8650,40 @@ function buildCompositionApi(deps) {
|
|
|
8487
8650
|
};
|
|
8488
8651
|
}
|
|
8489
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
|
|
8490
8687
|
//#region src/builtins/core-blocks/extract-settings-schema.ts
|
|
8491
8688
|
/**
|
|
8492
8689
|
* Read an optional `settingsSchema` named export from a compiled block bundle.
|
|
@@ -9303,6 +9500,15 @@ var CoreBlocksAddon = class extends require_dist.BaseAddon {
|
|
|
9303
9500
|
logger: this.ctx.logger.child("running-proposal")
|
|
9304
9501
|
},
|
|
9305
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),
|
|
9306
9512
|
capabilityDefinitions: require_dist.ALL_CAPABILITY_DEFINITIONS
|
|
9307
9513
|
});
|
|
9308
9514
|
}
|