@camstack/server 1.2.822 → 1.2.824
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 +0 -45
- package/package.json +11 -11
- package/system/dist/addon-runner.js +42 -15
- package/system/dist/addon-runner.mjs +43 -16
- package/system/dist/addon-utils.d.ts +1 -0
- package/system/dist/addon-utils.js +2 -0
- package/system/dist/addon-utils.mjs +2 -1
- package/system/dist/{agent-https-SGBI0xP8.js → agent-https-B2nqARmj.js} +1 -1
- package/system/dist/{agent-https-C4yxMErF.mjs → agent-https-BBO2OtNH.mjs} +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/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 +8 -0
- package/system/dist/builtins/core-blocks/composition-api.d.ts +6 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +143 -23
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +144 -24
- package/system/dist/builtins/core-blocks/record-kinds.d.ts +1 -0
- 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 +43 -4
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +43 -4
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/local-network.addon.js +2 -2
- package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/cap-call-scope-8eiugfLl.js +46 -0
- package/system/dist/cap-call-scope-Bic6Ekfw.mjs +30 -0
- package/system/dist/{capture-engine-BSjE-CQA.mjs → capture-engine-C-rHYVFq.mjs} +1 -1
- package/system/dist/{capture-engine-6MVUyUry.js → capture-engine-DP4HbT3W.js} +1 -1
- package/system/dist/{composition-sources-C8T9DRbZ.mjs → composition-sources-CL9JFN4y.mjs} +1 -1
- package/system/dist/{composition-sources-BBAOXZdC.js → composition-sources-CM9c_jAj.js} +1 -1
- package/system/dist/{constants-CReG6K4k.mjs → constants-DzGFnCKZ.mjs} +1 -1
- package/system/dist/{constants-v0g9--wN.js → constants-jk7JccZ0.js} +1 -1
- package/system/dist/{device-ca-BFcBTfff.js → device-ca-B7_R5WJh.js} +1 -1
- package/system/dist/{device-ca-cX8qUs2s.mjs → device-ca-DZ_OQiCc.mjs} +1 -1
- package/system/dist/{dist-DjBZ1HhF.mjs → dist-BgRMQHuL.mjs} +171 -184
- package/system/dist/{dist-C2czR9xK.js → dist-BpTL3uNe.js} +188 -183
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-mdns-ciao-Cnr8xiSd.mjs → hub-mdns-ciao-DIcBingB.mjs} +2 -2
- package/system/dist/{hub-mdns-ciao-CpCleue0.js → hub-mdns-ciao-DPUaYAD3.js} +2 -2
- package/system/dist/index.d.ts +1 -0
- package/system/dist/index.js +65 -42
- package/system/dist/index.mjs +64 -44
- package/system/dist/kernel/cap-call-scope.d.ts +10 -0
- package/system/dist/kernel/transport/cap-route-resolver.d.ts +27 -1
- package/system/dist/kernel/transport/child-cap-protocol.d.ts +1 -1
- package/system/dist/kernel/transport/parent-unowned-call.d.ts +0 -11
- package/system/dist/{legacy-integration-rows-door-CGajkVPh.mjs → legacy-integration-rows-door-1GnkpMgH.mjs} +1 -1
- package/system/dist/{legacy-integration-rows-door-DhW6mPZj.js → legacy-integration-rows-door-DYNePgj4.js} +1 -1
- package/system/dist/rename-composition-block-Cp0_nwAI.mjs +101 -0
- package/system/dist/rename-composition-block-Dn2z4fnA.js +112 -0
- package/system/dist/{restore-archive-eA7L58KT.mjs → restore-archive-B3FEpUfz.mjs} +1 -1
- package/system/dist/{restore-archive-BLab80kx.js → restore-archive-BGa5pdp9.js} +1 -1
- package/system/dist/{wal-maintenance-DeBxoOFh.mjs → wal-maintenance-BLWLlVfF.mjs} +0 -0
- package/system/dist/{wal-maintenance-DhnSF7K-.js → wal-maintenance-GWFxnSnE.js} +0 -0
- package/system/package.json +1 -1
|
@@ -1,11 +1,12 @@
|
|
|
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-BpTL3uNe.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-CM9c_jAj.js");
|
|
6
|
+
const require_capture_engine = require("../../capture-engine-DP4HbT3W.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
|
+
const require_cap_call_scope = require("../../cap-call-scope-8eiugfLl.js");
|
|
9
10
|
let zod = require("zod");
|
|
10
11
|
let node_crypto = require("node:crypto");
|
|
11
12
|
let _camstack_types_node = require("@camstack/types/node");
|
|
@@ -594,6 +595,7 @@ var ActionRowBodySchema = zod.z.object({
|
|
|
594
595
|
name: zod.z.string().min(1).max(120),
|
|
595
596
|
steps: zod.z.array(require_dist.ActionStepSchema).min(1).max(50),
|
|
596
597
|
variables: zod.z.array(require_dist.ActionVariableSchema).max(20).optional(),
|
|
598
|
+
minDelaySec: require_dist.ActionMinDelaySecSchema.optional(),
|
|
597
599
|
createdAt: zod.z.number(),
|
|
598
600
|
updatedAt: zod.z.number()
|
|
599
601
|
});
|
|
@@ -3061,6 +3063,8 @@ var ActionsService = class {
|
|
|
3061
3063
|
templates;
|
|
3062
3064
|
conditions;
|
|
3063
3065
|
running = /* @__PURE__ */ new Map();
|
|
3066
|
+
/** Last run START per action — the throttle's memory. */
|
|
3067
|
+
lastStartedAt = /* @__PURE__ */ new Map();
|
|
3064
3068
|
maxRunMs;
|
|
3065
3069
|
stopGraceMs;
|
|
3066
3070
|
constructor(deps) {
|
|
@@ -3220,6 +3224,36 @@ var ActionsService = class {
|
|
|
3220
3224
|
message
|
|
3221
3225
|
};
|
|
3222
3226
|
}
|
|
3227
|
+
const throttled = this.throttleOf(entry, startedAt);
|
|
3228
|
+
if (throttled !== null) {
|
|
3229
|
+
this.logger.info("action run throttled", { meta: {
|
|
3230
|
+
actionId: entry.id,
|
|
3231
|
+
runId,
|
|
3232
|
+
minDelaySec: entry.minDelaySec,
|
|
3233
|
+
sinceLastMs: throttled.sinceLastMs
|
|
3234
|
+
} });
|
|
3235
|
+
await this.record(entry.id, {
|
|
3236
|
+
runId,
|
|
3237
|
+
startedAt,
|
|
3238
|
+
endedAt: startedAt,
|
|
3239
|
+
trigger: {
|
|
3240
|
+
...trigger,
|
|
3241
|
+
outcome: "pass",
|
|
3242
|
+
reason: throttled.message
|
|
3243
|
+
},
|
|
3244
|
+
conditions: [],
|
|
3245
|
+
steps: [],
|
|
3246
|
+
outcome: "skipped-cooldown",
|
|
3247
|
+
repeat: 1,
|
|
3248
|
+
lastAt: startedAt
|
|
3249
|
+
});
|
|
3250
|
+
return {
|
|
3251
|
+
runId,
|
|
3252
|
+
outcome: "skipped-cooldown",
|
|
3253
|
+
message: throttled.message
|
|
3254
|
+
};
|
|
3255
|
+
}
|
|
3256
|
+
this.lastStartedAt.set(entry.id, startedAt);
|
|
3223
3257
|
const token = new RunToken();
|
|
3224
3258
|
this.running.set(entry.id, {
|
|
3225
3259
|
runId,
|
|
@@ -3241,6 +3275,20 @@ var ActionsService = class {
|
|
|
3241
3275
|
outcome: "started"
|
|
3242
3276
|
};
|
|
3243
3277
|
}
|
|
3278
|
+
/**
|
|
3279
|
+
* The action's throttle (`minDelaySec`): null when this start is let through.
|
|
3280
|
+
* The stamp is memory — the authority at fire time (D49) — and a restart
|
|
3281
|
+
* forgets it, which only ever lets one extra run through.
|
|
3282
|
+
*/
|
|
3283
|
+
throttleOf(entry, at) {
|
|
3284
|
+
const windowMs = (entry.minDelaySec ?? 0) * 1e3;
|
|
3285
|
+
const last = this.lastStartedAt.get(entry.id);
|
|
3286
|
+
if (windowMs <= 0 || last === void 0 || at - last >= windowMs) return null;
|
|
3287
|
+
return {
|
|
3288
|
+
sinceLastMs: at - last,
|
|
3289
|
+
message: `throttled — the action may start at most every ${String(entry.minDelaySec)} s`
|
|
3290
|
+
};
|
|
3291
|
+
}
|
|
3244
3292
|
triggerOf(input, values) {
|
|
3245
3293
|
const vars = {};
|
|
3246
3294
|
for (const [name, value] of Object.entries(values)) vars[`var.${name}`] = value;
|
|
@@ -3377,25 +3425,29 @@ var ActionsService = class {
|
|
|
3377
3425
|
};
|
|
3378
3426
|
}
|
|
3379
3427
|
runnableFor(entry, values, token, runId, readable) {
|
|
3380
|
-
if (entry.source === "internal")
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3428
|
+
if (entry.source === "internal") {
|
|
3429
|
+
const ruleFire = require_dist.ruleFireOfClaim(require_cap_call_scope.readCurrentCommandOrigin());
|
|
3430
|
+
return require_dist.buildActionSteps(entry.steps ?? [], values, {
|
|
3431
|
+
invokeCap: (call) => this.invokeCap({
|
|
3432
|
+
...call,
|
|
3433
|
+
origin: {
|
|
3434
|
+
kind: "action",
|
|
3435
|
+
actionId: entry.id,
|
|
3436
|
+
runId,
|
|
3437
|
+
...ruleFire !== void 0 ? { ruleFire } : {}
|
|
3438
|
+
}
|
|
3439
|
+
}),
|
|
3440
|
+
sleep: (ms) => token.sleep(ms),
|
|
3441
|
+
resolveTarget: (target, actionId, vars, origin) => this.targets.resolve(target, actionId, vars, origin),
|
|
3442
|
+
owner: entry.id,
|
|
3443
|
+
renderTemplates: stepRenderer(this.templates, readable),
|
|
3444
|
+
...conditionDeps(stepConditionEvaluator(this.conditions, readable)),
|
|
3445
|
+
onMissingVar: (name) => this.logger.warn("action template referenced a variable that was never set", { meta: {
|
|
3385
3446
|
actionId: entry.id,
|
|
3386
|
-
|
|
3387
|
-
}
|
|
3388
|
-
})
|
|
3389
|
-
|
|
3390
|
-
resolveTarget: (target, actionId, vars, origin) => this.targets.resolve(target, actionId, vars, origin),
|
|
3391
|
-
owner: entry.id,
|
|
3392
|
-
renderTemplates: stepRenderer(this.templates, readable),
|
|
3393
|
-
...conditionDeps(stepConditionEvaluator(this.conditions, readable)),
|
|
3394
|
-
onMissingVar: (name) => this.logger.warn("action template referenced a variable that was never set", { meta: {
|
|
3395
|
-
actionId: entry.id,
|
|
3396
|
-
variable: name
|
|
3397
|
-
} })
|
|
3398
|
-
});
|
|
3447
|
+
variable: name
|
|
3448
|
+
} })
|
|
3449
|
+
});
|
|
3450
|
+
}
|
|
3399
3451
|
return [{
|
|
3400
3452
|
meta: { kind: "addon" },
|
|
3401
3453
|
run: () => this.sources.run({
|
|
@@ -3459,7 +3511,8 @@ var ActionsService = class {
|
|
|
3459
3511
|
const action = await this.store.update(input.actionId, {
|
|
3460
3512
|
name: patch.name ?? existing.name,
|
|
3461
3513
|
steps,
|
|
3462
|
-
...(patch.variables ?? existing.variables) === void 0 ? {} : { variables: patch.variables ?? existing.variables }
|
|
3514
|
+
...(patch.variables ?? existing.variables) === void 0 ? {} : { variables: patch.variables ?? existing.variables },
|
|
3515
|
+
...(patch.minDelaySec ?? existing.minDelaySec) === void 0 ? {} : { minDelaySec: patch.minDelaySec ?? existing.minDelaySec }
|
|
3463
3516
|
});
|
|
3464
3517
|
this.logger.info("internal action updated", { meta: { actionId: action.id } });
|
|
3465
3518
|
return {
|
|
@@ -3594,6 +3647,7 @@ var ActionsStore = class ActionsStore {
|
|
|
3594
3647
|
readOnly: false,
|
|
3595
3648
|
steps: require_dist.normalizeStepTargets(body.steps),
|
|
3596
3649
|
...body.variables === void 0 ? {} : { variables: body.variables },
|
|
3650
|
+
...body.minDelaySec === void 0 || body.minDelaySec === 0 ? {} : { minDelaySec: body.minDelaySec },
|
|
3597
3651
|
status: require_dist.IDLE_ACTION_STATUS
|
|
3598
3652
|
};
|
|
3599
3653
|
}
|
|
@@ -3645,6 +3699,7 @@ var ActionsStore = class ActionsStore {
|
|
|
3645
3699
|
name: input.name,
|
|
3646
3700
|
steps: input.steps,
|
|
3647
3701
|
...input.variables === void 0 ? {} : { variables: input.variables },
|
|
3702
|
+
...input.minDelaySec === void 0 || input.minDelaySec === 0 ? {} : { minDelaySec: input.minDelaySec },
|
|
3648
3703
|
createdAt: at,
|
|
3649
3704
|
updatedAt: at
|
|
3650
3705
|
};
|
|
@@ -3661,6 +3716,7 @@ var ActionsStore = class ActionsStore {
|
|
|
3661
3716
|
name: input.name,
|
|
3662
3717
|
steps: input.steps,
|
|
3663
3718
|
...input.variables === void 0 ? {} : { variables: input.variables },
|
|
3719
|
+
...input.minDelaySec === void 0 || input.minDelaySec === 0 ? {} : { minDelaySec: input.minDelaySec },
|
|
3664
3720
|
createdAt: existing.data.createdAt,
|
|
3665
3721
|
updatedAt: this.now()
|
|
3666
3722
|
};
|
|
@@ -8500,6 +8556,25 @@ async function refuseRetarget(deps, blockId, patch) {
|
|
|
8500
8556
|
if (patch.name !== void 0) return refuseSave(deps, subject, pinned, NO_NAME_OF_ITS_OWN);
|
|
8501
8557
|
if (next === null || require_dist.compositionSourceKey(next) !== require_dist.compositionSourceKey(pinned)) return refuseSave(deps, subject, pinned, DEVICE_IS_FIXED);
|
|
8502
8558
|
}
|
|
8559
|
+
/**
|
|
8560
|
+
* An editor rename of a composed device (not a customization, not a create)
|
|
8561
|
+
* writes the device name after the block has been saved. A failed device
|
|
8562
|
+
* write is logged and does not fail the save.
|
|
8563
|
+
*/
|
|
8564
|
+
async function followComposedRename(deps, previous, name) {
|
|
8565
|
+
const write = deps.writeComposedDeviceName;
|
|
8566
|
+
if (write === void 0 || previous === null || name === void 0 || name === previous.name) return;
|
|
8567
|
+
const composition = require_dist.coreBlockComposition(previous);
|
|
8568
|
+
if (composition === null || existingTarget(composition) !== null) return;
|
|
8569
|
+
try {
|
|
8570
|
+
await write(previous.id, name);
|
|
8571
|
+
} catch (err) {
|
|
8572
|
+
deps.logger.warn("composed block was renamed but the device name was not written — retried on the next apply", { meta: {
|
|
8573
|
+
blockId: previous.id,
|
|
8574
|
+
error: require_dist.errMsg(err)
|
|
8575
|
+
} });
|
|
8576
|
+
}
|
|
8577
|
+
}
|
|
8503
8578
|
/** The block customizing `device`, found by TARGET — never by its derived name (rule 4). */
|
|
8504
8579
|
function customizationOf(blocks, device) {
|
|
8505
8580
|
const key = require_dist.compositionSourceKey(device);
|
|
@@ -8548,10 +8623,12 @@ function buildCompositionApi(deps) {
|
|
|
8548
8623
|
blockId
|
|
8549
8624
|
}, judged.validation, judged.memberDeviceIds);
|
|
8550
8625
|
}
|
|
8626
|
+
const previous = deps.store.get(blockId);
|
|
8551
8627
|
const updated = await deps.store.updateComposition(blockId, block);
|
|
8628
|
+
await followComposedRename(deps, previous, block.name);
|
|
8552
8629
|
deps.logger.info("composition updated", { meta: {
|
|
8553
8630
|
blockId,
|
|
8554
|
-
by: caller
|
|
8631
|
+
by: caller?.userId ?? "system"
|
|
8555
8632
|
} });
|
|
8556
8633
|
if (block.composition !== void 0) {
|
|
8557
8634
|
const unreleased = (await deps.convergeForClaims()).filter((claim) => claim.owner === blockId);
|
|
@@ -8629,6 +8706,40 @@ function buildCompositionApi(deps) {
|
|
|
8629
8706
|
};
|
|
8630
8707
|
}
|
|
8631
8708
|
//#endregion
|
|
8709
|
+
//#region src/builtins/core-blocks/sync-composed-device-name.ts
|
|
8710
|
+
/**
|
|
8711
|
+
* An operator rename in the composition editor writes the composed device's
|
|
8712
|
+
* name as well, stamped, so the row and the block agree. The device is the
|
|
8713
|
+
* row whose stable id is `composed-<blockId>` under the composer addon.
|
|
8714
|
+
* A failure is logged and swallowed: the block save has already landed, and
|
|
8715
|
+
* the composer's next apply retries the device write.
|
|
8716
|
+
*/
|
|
8717
|
+
async function writeComposedDeviceName(port, logger, blockId, name) {
|
|
8718
|
+
const stableId = require_dist.composedDeviceStableId(blockId);
|
|
8719
|
+
let deviceId = null;
|
|
8720
|
+
try {
|
|
8721
|
+
const row = (await port.listPersistedByAddon(require_dist.COMPOSER_ADDON_ID)).find((candidate) => candidate.stableId === stableId);
|
|
8722
|
+
if (row === void 0) {
|
|
8723
|
+
logger.warn("composed block was renamed but its device row was not found — retried on the next apply", { meta: {
|
|
8724
|
+
blockId,
|
|
8725
|
+
stableId
|
|
8726
|
+
} });
|
|
8727
|
+
return;
|
|
8728
|
+
}
|
|
8729
|
+
deviceId = row.id;
|
|
8730
|
+
if (row.name === name) return;
|
|
8731
|
+
await port.setOperatorName(row.id, name);
|
|
8732
|
+
} catch (err) {
|
|
8733
|
+
logger.warn("composed block was renamed but the device name was not written — retried on the next apply", {
|
|
8734
|
+
...deviceId === null ? {} : { tags: { deviceId } },
|
|
8735
|
+
meta: {
|
|
8736
|
+
blockId,
|
|
8737
|
+
error: require_dist.errMsg(err)
|
|
8738
|
+
}
|
|
8739
|
+
});
|
|
8740
|
+
}
|
|
8741
|
+
}
|
|
8742
|
+
//#endregion
|
|
8632
8743
|
//#region src/builtins/core-blocks/extract-settings-schema.ts
|
|
8633
8744
|
/**
|
|
8634
8745
|
* Read an optional `settingsSchema` named export from a compiled block bundle.
|
|
@@ -9445,6 +9556,15 @@ var CoreBlocksAddon = class extends require_dist.BaseAddon {
|
|
|
9445
9556
|
logger: this.ctx.logger.child("running-proposal")
|
|
9446
9557
|
},
|
|
9447
9558
|
logger: this.ctx.logger.child("compositions"),
|
|
9559
|
+
writeComposedDeviceName: (blockId, name) => writeComposedDeviceName({
|
|
9560
|
+
listPersistedByAddon: async (addonId) => requireApi().deviceManager.listPersistedByAddon.query({ addonId }),
|
|
9561
|
+
setOperatorName: async (deviceId, deviceName) => {
|
|
9562
|
+
await requireApi().deviceManager.setName.mutate({
|
|
9563
|
+
deviceId,
|
|
9564
|
+
name: deviceName
|
|
9565
|
+
});
|
|
9566
|
+
}
|
|
9567
|
+
}, this.ctx.logger.child("compositions"), blockId, name),
|
|
9448
9568
|
capabilityDefinitions: require_dist.ALL_CAPABILITY_DEFINITIONS
|
|
9449
9569
|
});
|
|
9450
9570
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { $
|
|
1
|
+
import { $c as vocabActionIdFor, $s as collectSecretMarkerRefs, $t as SchedulerError, Aa as resolveStepArgs, An as buildActionSteps, Ar as evaluateStepCondition, Ba as seedInstanceOnce, Bi as normalizeStepTargets, C as COMPOSER_RUNNER_ID, Cn as appendTrace, Co as weekdayOfLocalDate, Dc as isSecretMarker, Do as COMPOSER_ADDON_ID, Eo as zoneOnlySite, Gn as collectDeviceTemplates, Hc as resolveSecretMarkers, Ht as QuantityUnitError, Ia as schedulersCapability, Ii as nextOccurrence, Jo as helperMembers, Jt as RemoteLayoutPayloadSchema, Ka as siteFor, Kc as secretTreeFromSchema, Kn as collectWhenMirrorSources, Li as normalizeActionUnits, M as CoreBlockSchema, Na as runSteps, Oa as resolveRemoteSource, Oo as CompositionSchema, Pn as buildHeroModel, Po as HelperMemberSchema, Q as DeclaredDevices, Qi as planComposition, Qn as compositionSourceRefs, Ri as normalizeCapStep, Ro as composedDeviceRef, Rr as fanPresetsCapability, Rt as PowerSourceInfoSchema, Sa as resolveHeroLayout, T as CORE_BLOCK_ADDON_PREFIX, Uc as ruleFireOfClaim, Un as checkTemplatePayload, Uo as compositionSourceKey, Us as actionEffect, Vr as findChannelSource, Wi as occurrenceOn, Wt as REMOTE_MEDIA_COMMANDS, Xa as stableIdMapOf, Xr as integrationInstancesCapability, Yn as compileScalarOverride, Yo as historyRetentionFromSettings, Yr as heroLayoutCapability, Yt as RunningStateStatusSchema, Zc as transformSecretWrite, Zr as internalActionId, _a as resolveActionVariables, _c as hydrateSchema, _i as localDateOf, ac as defineAddonMigrations, al as errMsg$1, at as EMPTY_REMOTE_CONFIG, ba as resolveCoreBlockEntry, bt as INTERNAL_ACTION_PREFIX, c as ActionError, cc as defineRecordKinds, cn as SwitchStatusSchema, co as timedRunCapability, ct as FanControlStatusSchema, d as ActionTargetResolver, dc as entryBody, di as kebabToCamel, do as timedRunQuickRun, ea as powerSourceCapability, en as SchedulerSchema, er as coreBlockAddonId, f as ActionVariableSchema, fo as timedRunSeconds, ga as replacedFieldKeys, gn as addonIdOfActionId, go as validateComposition, h as BUILTIN_REMOTE_COMPONENTS, ha as remoteSourceSteps, hn as actionsCapability, hr as describeComposableCaps, il as DeviceType$1, ir as coreBlocksCapability, it as EMPTY_REMOTE_ASSUMED_STATE, j as ControlStatusSchema, jn as buildCapabilityLookup, jr as evaluateWhenTree, js as RecordIntegrationInstances, k as ConditionMirror, kc as isSecretRefOwnedBy, ko as DAY_MS, kt as MediaPlayerStatusSchema, l as ActionMinDelaySecSchema, la as readStoredRemoteConfig, ln as TemplateKindSchema, lo as timedRunLimitOf, m as AutomationStateDocSchema, ma as remoteLayoutComponentsCapability, mn as actionWaitTotalMs, n as ACTION_TARGET_INVALIDATION_EVENTS, nc as commandOrigin$1, nr as coreBlockIdFromAddonId, oa as projectDeviceRow, oi as isInternalActionId, ot as FAN_CAPTURE_FIELDS, pa as remoteCapability, pn as actionSourceCapability, po as toTimings, qt as RemoteAssumedStateSchema, ra as problemsBlockSave, rr as coreBlockSourceKind, rt as EMPTY_AUTOMATION_STATE, s as ALL_CAPABILITY_DEFINITIONS, sa as proposeRunningThreshold, sc as defineEntryKind, sl as EventCategory$1, so as templateCapability, sr as customKeyOfRole, ss as BaseAddon, ta as powerSourceLinkOfComposition, tr as coreBlockComposition, u as ActionStepSchema, uo as timedRunMaxIn, ut as FanPresetSchema, vo as validateSchedulerInput, w as CORE_BLOCKS_ADDON_ID, xa as resolveCoreBlockFiles, xi as lockDoorLinkOfComposition, yt as IDLE_ACTION_STATUS, z as DEFAULT_HOLD_OVERRIDE, zi as normalizeCoreBlockWrite, zn as capUnitResolver, zo as composedDeviceStableId } from "../../dist-BgRMQHuL.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-CL9JFN4y.mjs";
|
|
4
|
+
import { i as capSeriesKey } from "../../capture-engine-C-rHYVFq.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
|
+
import { n as readCurrentCommandOrigin } from "../../cap-call-scope-Bic6Ekfw.mjs";
|
|
7
8
|
import { createRequire } from "node:module";
|
|
8
9
|
import { z } from "zod";
|
|
9
10
|
import { randomUUID } from "node:crypto";
|
|
@@ -589,6 +590,7 @@ var ActionRowBodySchema = z.object({
|
|
|
589
590
|
name: z.string().min(1).max(120),
|
|
590
591
|
steps: z.array(ActionStepSchema).min(1).max(50),
|
|
591
592
|
variables: z.array(ActionVariableSchema).max(20).optional(),
|
|
593
|
+
minDelaySec: ActionMinDelaySecSchema.optional(),
|
|
592
594
|
createdAt: z.number(),
|
|
593
595
|
updatedAt: z.number()
|
|
594
596
|
});
|
|
@@ -3055,6 +3057,8 @@ var ActionsService = class {
|
|
|
3055
3057
|
templates;
|
|
3056
3058
|
conditions;
|
|
3057
3059
|
running = /* @__PURE__ */ new Map();
|
|
3060
|
+
/** Last run START per action — the throttle's memory. */
|
|
3061
|
+
lastStartedAt = /* @__PURE__ */ new Map();
|
|
3058
3062
|
maxRunMs;
|
|
3059
3063
|
stopGraceMs;
|
|
3060
3064
|
constructor(deps) {
|
|
@@ -3214,6 +3218,36 @@ var ActionsService = class {
|
|
|
3214
3218
|
message
|
|
3215
3219
|
};
|
|
3216
3220
|
}
|
|
3221
|
+
const throttled = this.throttleOf(entry, startedAt);
|
|
3222
|
+
if (throttled !== null) {
|
|
3223
|
+
this.logger.info("action run throttled", { meta: {
|
|
3224
|
+
actionId: entry.id,
|
|
3225
|
+
runId,
|
|
3226
|
+
minDelaySec: entry.minDelaySec,
|
|
3227
|
+
sinceLastMs: throttled.sinceLastMs
|
|
3228
|
+
} });
|
|
3229
|
+
await this.record(entry.id, {
|
|
3230
|
+
runId,
|
|
3231
|
+
startedAt,
|
|
3232
|
+
endedAt: startedAt,
|
|
3233
|
+
trigger: {
|
|
3234
|
+
...trigger,
|
|
3235
|
+
outcome: "pass",
|
|
3236
|
+
reason: throttled.message
|
|
3237
|
+
},
|
|
3238
|
+
conditions: [],
|
|
3239
|
+
steps: [],
|
|
3240
|
+
outcome: "skipped-cooldown",
|
|
3241
|
+
repeat: 1,
|
|
3242
|
+
lastAt: startedAt
|
|
3243
|
+
});
|
|
3244
|
+
return {
|
|
3245
|
+
runId,
|
|
3246
|
+
outcome: "skipped-cooldown",
|
|
3247
|
+
message: throttled.message
|
|
3248
|
+
};
|
|
3249
|
+
}
|
|
3250
|
+
this.lastStartedAt.set(entry.id, startedAt);
|
|
3217
3251
|
const token = new RunToken();
|
|
3218
3252
|
this.running.set(entry.id, {
|
|
3219
3253
|
runId,
|
|
@@ -3235,6 +3269,20 @@ var ActionsService = class {
|
|
|
3235
3269
|
outcome: "started"
|
|
3236
3270
|
};
|
|
3237
3271
|
}
|
|
3272
|
+
/**
|
|
3273
|
+
* The action's throttle (`minDelaySec`): null when this start is let through.
|
|
3274
|
+
* The stamp is memory — the authority at fire time (D49) — and a restart
|
|
3275
|
+
* forgets it, which only ever lets one extra run through.
|
|
3276
|
+
*/
|
|
3277
|
+
throttleOf(entry, at) {
|
|
3278
|
+
const windowMs = (entry.minDelaySec ?? 0) * 1e3;
|
|
3279
|
+
const last = this.lastStartedAt.get(entry.id);
|
|
3280
|
+
if (windowMs <= 0 || last === void 0 || at - last >= windowMs) return null;
|
|
3281
|
+
return {
|
|
3282
|
+
sinceLastMs: at - last,
|
|
3283
|
+
message: `throttled — the action may start at most every ${String(entry.minDelaySec)} s`
|
|
3284
|
+
};
|
|
3285
|
+
}
|
|
3238
3286
|
triggerOf(input, values) {
|
|
3239
3287
|
const vars = {};
|
|
3240
3288
|
for (const [name, value] of Object.entries(values)) vars[`var.${name}`] = value;
|
|
@@ -3371,25 +3419,29 @@ var ActionsService = class {
|
|
|
3371
3419
|
};
|
|
3372
3420
|
}
|
|
3373
3421
|
runnableFor(entry, values, token, runId, readable) {
|
|
3374
|
-
if (entry.source === "internal")
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3422
|
+
if (entry.source === "internal") {
|
|
3423
|
+
const ruleFire = ruleFireOfClaim(readCurrentCommandOrigin());
|
|
3424
|
+
return buildActionSteps(entry.steps ?? [], values, {
|
|
3425
|
+
invokeCap: (call) => this.invokeCap({
|
|
3426
|
+
...call,
|
|
3427
|
+
origin: {
|
|
3428
|
+
kind: "action",
|
|
3429
|
+
actionId: entry.id,
|
|
3430
|
+
runId,
|
|
3431
|
+
...ruleFire !== void 0 ? { ruleFire } : {}
|
|
3432
|
+
}
|
|
3433
|
+
}),
|
|
3434
|
+
sleep: (ms) => token.sleep(ms),
|
|
3435
|
+
resolveTarget: (target, actionId, vars, origin) => this.targets.resolve(target, actionId, vars, origin),
|
|
3436
|
+
owner: entry.id,
|
|
3437
|
+
renderTemplates: stepRenderer(this.templates, readable),
|
|
3438
|
+
...conditionDeps(stepConditionEvaluator(this.conditions, readable)),
|
|
3439
|
+
onMissingVar: (name) => this.logger.warn("action template referenced a variable that was never set", { meta: {
|
|
3379
3440
|
actionId: entry.id,
|
|
3380
|
-
|
|
3381
|
-
}
|
|
3382
|
-
})
|
|
3383
|
-
|
|
3384
|
-
resolveTarget: (target, actionId, vars, origin) => this.targets.resolve(target, actionId, vars, origin),
|
|
3385
|
-
owner: entry.id,
|
|
3386
|
-
renderTemplates: stepRenderer(this.templates, readable),
|
|
3387
|
-
...conditionDeps(stepConditionEvaluator(this.conditions, readable)),
|
|
3388
|
-
onMissingVar: (name) => this.logger.warn("action template referenced a variable that was never set", { meta: {
|
|
3389
|
-
actionId: entry.id,
|
|
3390
|
-
variable: name
|
|
3391
|
-
} })
|
|
3392
|
-
});
|
|
3441
|
+
variable: name
|
|
3442
|
+
} })
|
|
3443
|
+
});
|
|
3444
|
+
}
|
|
3393
3445
|
return [{
|
|
3394
3446
|
meta: { kind: "addon" },
|
|
3395
3447
|
run: () => this.sources.run({
|
|
@@ -3453,7 +3505,8 @@ var ActionsService = class {
|
|
|
3453
3505
|
const action = await this.store.update(input.actionId, {
|
|
3454
3506
|
name: patch.name ?? existing.name,
|
|
3455
3507
|
steps,
|
|
3456
|
-
...(patch.variables ?? existing.variables) === void 0 ? {} : { variables: patch.variables ?? existing.variables }
|
|
3508
|
+
...(patch.variables ?? existing.variables) === void 0 ? {} : { variables: patch.variables ?? existing.variables },
|
|
3509
|
+
...(patch.minDelaySec ?? existing.minDelaySec) === void 0 ? {} : { minDelaySec: patch.minDelaySec ?? existing.minDelaySec }
|
|
3457
3510
|
});
|
|
3458
3511
|
this.logger.info("internal action updated", { meta: { actionId: action.id } });
|
|
3459
3512
|
return {
|
|
@@ -3588,6 +3641,7 @@ var ActionsStore = class ActionsStore {
|
|
|
3588
3641
|
readOnly: false,
|
|
3589
3642
|
steps: normalizeStepTargets(body.steps),
|
|
3590
3643
|
...body.variables === void 0 ? {} : { variables: body.variables },
|
|
3644
|
+
...body.minDelaySec === void 0 || body.minDelaySec === 0 ? {} : { minDelaySec: body.minDelaySec },
|
|
3591
3645
|
status: IDLE_ACTION_STATUS
|
|
3592
3646
|
};
|
|
3593
3647
|
}
|
|
@@ -3639,6 +3693,7 @@ var ActionsStore = class ActionsStore {
|
|
|
3639
3693
|
name: input.name,
|
|
3640
3694
|
steps: input.steps,
|
|
3641
3695
|
...input.variables === void 0 ? {} : { variables: input.variables },
|
|
3696
|
+
...input.minDelaySec === void 0 || input.minDelaySec === 0 ? {} : { minDelaySec: input.minDelaySec },
|
|
3642
3697
|
createdAt: at,
|
|
3643
3698
|
updatedAt: at
|
|
3644
3699
|
};
|
|
@@ -3655,6 +3710,7 @@ var ActionsStore = class ActionsStore {
|
|
|
3655
3710
|
name: input.name,
|
|
3656
3711
|
steps: input.steps,
|
|
3657
3712
|
...input.variables === void 0 ? {} : { variables: input.variables },
|
|
3713
|
+
...input.minDelaySec === void 0 || input.minDelaySec === 0 ? {} : { minDelaySec: input.minDelaySec },
|
|
3658
3714
|
createdAt: existing.data.createdAt,
|
|
3659
3715
|
updatedAt: this.now()
|
|
3660
3716
|
};
|
|
@@ -3822,7 +3878,7 @@ function invokeCapOver(api) {
|
|
|
3822
3878
|
...call.args,
|
|
3823
3879
|
deviceId: call.deviceId
|
|
3824
3880
|
};
|
|
3825
|
-
await Reflect.apply(mutate, procedure, call.origin === void 0 ? [input] : [input, commandOrigin(call.origin)]);
|
|
3881
|
+
await Reflect.apply(mutate, procedure, call.origin === void 0 ? [input] : [input, commandOrigin$1(call.origin)]);
|
|
3826
3882
|
};
|
|
3827
3883
|
}
|
|
3828
3884
|
/**
|
|
@@ -8484,6 +8540,25 @@ async function refuseRetarget(deps, blockId, patch) {
|
|
|
8484
8540
|
if (patch.name !== void 0) return refuseSave(deps, subject, pinned, NO_NAME_OF_ITS_OWN);
|
|
8485
8541
|
if (next === null || compositionSourceKey(next) !== compositionSourceKey(pinned)) return refuseSave(deps, subject, pinned, DEVICE_IS_FIXED);
|
|
8486
8542
|
}
|
|
8543
|
+
/**
|
|
8544
|
+
* An editor rename of a composed device (not a customization, not a create)
|
|
8545
|
+
* writes the device name after the block has been saved. A failed device
|
|
8546
|
+
* write is logged and does not fail the save.
|
|
8547
|
+
*/
|
|
8548
|
+
async function followComposedRename(deps, previous, name) {
|
|
8549
|
+
const write = deps.writeComposedDeviceName;
|
|
8550
|
+
if (write === void 0 || previous === null || name === void 0 || name === previous.name) return;
|
|
8551
|
+
const composition = coreBlockComposition(previous);
|
|
8552
|
+
if (composition === null || existingTarget(composition) !== null) return;
|
|
8553
|
+
try {
|
|
8554
|
+
await write(previous.id, name);
|
|
8555
|
+
} catch (err) {
|
|
8556
|
+
deps.logger.warn("composed block was renamed but the device name was not written — retried on the next apply", { meta: {
|
|
8557
|
+
blockId: previous.id,
|
|
8558
|
+
error: errMsg$1(err)
|
|
8559
|
+
} });
|
|
8560
|
+
}
|
|
8561
|
+
}
|
|
8487
8562
|
/** The block customizing `device`, found by TARGET — never by its derived name (rule 4). */
|
|
8488
8563
|
function customizationOf(blocks, device) {
|
|
8489
8564
|
const key = compositionSourceKey(device);
|
|
@@ -8532,10 +8607,12 @@ function buildCompositionApi(deps) {
|
|
|
8532
8607
|
blockId
|
|
8533
8608
|
}, judged.validation, judged.memberDeviceIds);
|
|
8534
8609
|
}
|
|
8610
|
+
const previous = deps.store.get(blockId);
|
|
8535
8611
|
const updated = await deps.store.updateComposition(blockId, block);
|
|
8612
|
+
await followComposedRename(deps, previous, block.name);
|
|
8536
8613
|
deps.logger.info("composition updated", { meta: {
|
|
8537
8614
|
blockId,
|
|
8538
|
-
by: caller
|
|
8615
|
+
by: caller?.userId ?? "system"
|
|
8539
8616
|
} });
|
|
8540
8617
|
if (block.composition !== void 0) {
|
|
8541
8618
|
const unreleased = (await deps.convergeForClaims()).filter((claim) => claim.owner === blockId);
|
|
@@ -8613,6 +8690,40 @@ function buildCompositionApi(deps) {
|
|
|
8613
8690
|
};
|
|
8614
8691
|
}
|
|
8615
8692
|
//#endregion
|
|
8693
|
+
//#region src/builtins/core-blocks/sync-composed-device-name.ts
|
|
8694
|
+
/**
|
|
8695
|
+
* An operator rename in the composition editor writes the composed device's
|
|
8696
|
+
* name as well, stamped, so the row and the block agree. The device is the
|
|
8697
|
+
* row whose stable id is `composed-<blockId>` under the composer addon.
|
|
8698
|
+
* A failure is logged and swallowed: the block save has already landed, and
|
|
8699
|
+
* the composer's next apply retries the device write.
|
|
8700
|
+
*/
|
|
8701
|
+
async function writeComposedDeviceName(port, logger, blockId, name) {
|
|
8702
|
+
const stableId = composedDeviceStableId(blockId);
|
|
8703
|
+
let deviceId = null;
|
|
8704
|
+
try {
|
|
8705
|
+
const row = (await port.listPersistedByAddon(COMPOSER_ADDON_ID)).find((candidate) => candidate.stableId === stableId);
|
|
8706
|
+
if (row === void 0) {
|
|
8707
|
+
logger.warn("composed block was renamed but its device row was not found — retried on the next apply", { meta: {
|
|
8708
|
+
blockId,
|
|
8709
|
+
stableId
|
|
8710
|
+
} });
|
|
8711
|
+
return;
|
|
8712
|
+
}
|
|
8713
|
+
deviceId = row.id;
|
|
8714
|
+
if (row.name === name) return;
|
|
8715
|
+
await port.setOperatorName(row.id, name);
|
|
8716
|
+
} catch (err) {
|
|
8717
|
+
logger.warn("composed block was renamed but the device name was not written — retried on the next apply", {
|
|
8718
|
+
...deviceId === null ? {} : { tags: { deviceId } },
|
|
8719
|
+
meta: {
|
|
8720
|
+
blockId,
|
|
8721
|
+
error: errMsg$1(err)
|
|
8722
|
+
}
|
|
8723
|
+
});
|
|
8724
|
+
}
|
|
8725
|
+
}
|
|
8726
|
+
//#endregion
|
|
8616
8727
|
//#region src/builtins/core-blocks/extract-settings-schema.ts
|
|
8617
8728
|
/**
|
|
8618
8729
|
* Read an optional `settingsSchema` named export from a compiled block bundle.
|
|
@@ -9429,6 +9540,15 @@ var CoreBlocksAddon = class extends BaseAddon {
|
|
|
9429
9540
|
logger: this.ctx.logger.child("running-proposal")
|
|
9430
9541
|
},
|
|
9431
9542
|
logger: this.ctx.logger.child("compositions"),
|
|
9543
|
+
writeComposedDeviceName: (blockId, name) => writeComposedDeviceName({
|
|
9544
|
+
listPersistedByAddon: async (addonId) => requireApi().deviceManager.listPersistedByAddon.query({ addonId }),
|
|
9545
|
+
setOperatorName: async (deviceId, deviceName) => {
|
|
9546
|
+
await requireApi().deviceManager.setName.mutate({
|
|
9547
|
+
deviceId,
|
|
9548
|
+
name: deviceName
|
|
9549
|
+
});
|
|
9550
|
+
}
|
|
9551
|
+
}, this.ctx.logger.child("compositions"), blockId, name),
|
|
9432
9552
|
capabilityDefinitions: ALL_CAPABILITY_DEFINITIONS
|
|
9433
9553
|
});
|
|
9434
9554
|
}
|
|
@@ -35,6 +35,7 @@ export type ActionRowBody = {
|
|
|
35
35
|
readonly name: string;
|
|
36
36
|
readonly steps: z.infer<typeof ActionStepSchema>[];
|
|
37
37
|
readonly variables?: z.infer<typeof ActionVariableSchema>[];
|
|
38
|
+
readonly minDelaySec?: number;
|
|
38
39
|
readonly createdAt: number;
|
|
39
40
|
readonly updatedAt: number;
|
|
40
41
|
};
|
|
@@ -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-BpTL3uNe.js");
|
|
7
|
+
const require_capture_engine = require("../../capture-engine-DP4HbT3W.js");
|
|
8
8
|
const require_retention = require("../../retention-BcOSL6b9.js");
|
|
9
9
|
let node_crypto = require("node:crypto");
|
|
10
10
|
//#region src/builtins/device-history/capture/point-writer.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as catalogMetrics, c as DeviceDirectory, d as identityOf, f as subjectIdOf, i as capSeriesKey, l as isRealDeviceType, n as CaptureEngine, o as readPath, r as capItemSeriesKey, s as readUnit, t as CAP_KEY_PREFIX, u as SeriesRegistry } from "../../capture-engine-
|
|
1
|
+
import { $ as DeviceRunSchema, H as DEVICE_HISTORY_ENERGY_KEY, Ps as RecordTooLargeError, Sr as deviceRunsCapability, Tr as deviceTransitionsCapability, cc as defineRecordKinds, gc as historyUnitFor, ht as HISTORY_ITEM_CATALOG, il as DeviceType, ms as DeviceTransitionSchema, mt as HISTORY_CATALOG, os as wattMillisecondsToKwh, sl as EventCategory, ss as BaseAddon, uc as emitReadiness, vs as InvalidRecordError, wc as isReadingQuantity, wn as armRemovalReconcile, xr as deviceRemovalHookCapability, yr as deviceHistoryCapability } from "../../dist-BgRMQHuL.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-C-rHYVFq.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
|