@camstack/types 1.2.557 → 1.2.558
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 +9 -0
- package/dist/addon.js +2 -2
- package/dist/addon.mjs +2 -2
- package/dist/automation/action-target.d.ts +8 -0
- package/dist/{composed-stable-id-CDNLq7Y8.js → composed-stable-id-BmJ_5GiE.js} +5 -0
- package/dist/{composed-stable-id-CPp3votu.mjs → composed-stable-id-iddnCQ51.mjs} +5 -0
- package/dist/composition/composition.d.ts +8 -0
- package/dist/composition/helpers/index.d.ts +1 -1
- package/dist/composition/helpers/save.d.ts +2 -0
- package/dist/composition/helpers/source-pick.d.ts +11 -5
- package/dist/composition/validate-composition.d.ts +2 -0
- package/dist/device/device-kind.d.ts +36 -0
- package/dist/device/device-type.d.ts +5 -0
- package/dist/device/hero/hero-look.d.ts +6 -0
- package/dist/device/hero/hero-scene.d.ts +1 -0
- package/dist/device/index.d.ts +1 -1
- package/dist/{implemented-methods-5YMDeE3f.mjs → implemented-methods-CSTk6zYK.mjs} +147 -2
- package/dist/{implemented-methods-Cj65uy2F.js → implemented-methods-CfaRR_ki.js} +212 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +273 -253
- package/dist/index.mjs +259 -247
- package/dist/node.js +2 -2
- package/dist/node.mjs +2 -2
- package/dist/{sleep-DyIxjZZt.mjs → sleep-BvVGLl30.mjs} +8 -1
- package/dist/{sleep-1RkA30Y1.js → sleep-CyWfD1LJ.js} +8 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_sleep = require("./sleep-
|
|
2
|
+
const require_sleep = require("./sleep-CyWfD1LJ.js");
|
|
3
3
|
const require_event_category = require("./event-category-Ps2LC8dN.js");
|
|
4
|
-
const require_composed_stable_id = require("./composed-stable-id-
|
|
5
|
-
const require_implemented_methods = require("./implemented-methods-
|
|
4
|
+
const require_composed_stable_id = require("./composed-stable-id-BmJ_5GiE.js");
|
|
5
|
+
const require_implemented_methods = require("./implemented-methods-CfaRR_ki.js");
|
|
6
6
|
const require_node_color = require("./node-color.js");
|
|
7
7
|
const require_convert = require("./convert-BmtM6K-5.js");
|
|
8
8
|
const require_enums = require("./enums.js");
|
|
@@ -10122,7 +10122,7 @@ var DeviceTokenScopeSchema = zod.z.object({
|
|
|
10122
10122
|
function migrateLegacyTokenScope(raw) {
|
|
10123
10123
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
10124
10124
|
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
10125
|
-
if (Reflect.get(raw, "selector") !== void 0) return raw;
|
|
10125
|
+
if (Reflect.get(raw, "selector") !== void 0) return canonicalSelectorTypes(raw);
|
|
10126
10126
|
const targets = Reflect.get(raw, "targets");
|
|
10127
10127
|
if (!Array.isArray(targets)) return raw;
|
|
10128
10128
|
return {
|
|
@@ -10134,6 +10134,27 @@ function migrateLegacyTokenScope(raw) {
|
|
|
10134
10134
|
access: Reflect.get(raw, "access")
|
|
10135
10135
|
};
|
|
10136
10136
|
}
|
|
10137
|
+
/**
|
|
10138
|
+
* A stored `types` selector may name a type D1033 retired (`thermostat`). The
|
|
10139
|
+
* grant is read back through this same preprocess, so the retired name is
|
|
10140
|
+
* rewritten to its canonical type here and {@link DeviceSelectorSchema} itself
|
|
10141
|
+
* stays a strict enum on the wire.
|
|
10142
|
+
*/
|
|
10143
|
+
function canonicalSelectorTypes(raw) {
|
|
10144
|
+
const selector = Reflect.get(raw, "selector");
|
|
10145
|
+
if (selector === null || typeof selector !== "object") return raw;
|
|
10146
|
+
if (Reflect.get(selector, "kind") !== "types") return raw;
|
|
10147
|
+
const types = Reflect.get(selector, "types");
|
|
10148
|
+
if (!Array.isArray(types)) return raw;
|
|
10149
|
+
const canonical = types.map((t) => typeof t === "string" ? require_implemented_methods.canonicalStoredDeviceType(t) : t);
|
|
10150
|
+
return {
|
|
10151
|
+
...raw,
|
|
10152
|
+
selector: {
|
|
10153
|
+
...selector,
|
|
10154
|
+
types: canonical
|
|
10155
|
+
}
|
|
10156
|
+
};
|
|
10157
|
+
}
|
|
10137
10158
|
var TokenScopeSchema = zod.z.preprocess(migrateLegacyTokenScope, zod.z.discriminatedUnion("type", [
|
|
10138
10159
|
zod.z.object({
|
|
10139
10160
|
type: zod.z.literal("category"),
|
|
@@ -31047,6 +31068,36 @@ var ActionTargetSchema = zod.z.discriminatedUnion("kind", [
|
|
|
31047
31068
|
name: zod.z.string().min(1)
|
|
31048
31069
|
})
|
|
31049
31070
|
]);
|
|
31071
|
+
/**
|
|
31072
|
+
* A STORED list of steps, read back: a `domain` target may name a device type
|
|
31073
|
+
* D1033 retired (`thermostat`). The step schema stays a strict enum on the
|
|
31074
|
+
* wire, so the store rewrites the retired name to its canonical type before
|
|
31075
|
+
* it parses the row — on the step and on each step of its `else` list. Any
|
|
31076
|
+
* other value is returned untouched, for the schema to judge.
|
|
31077
|
+
*/
|
|
31078
|
+
function canonicalStoredStepTargets(steps) {
|
|
31079
|
+
if (!Array.isArray(steps)) return steps;
|
|
31080
|
+
return steps.map(canonicalStoredStep);
|
|
31081
|
+
}
|
|
31082
|
+
function canonicalStoredStep(step) {
|
|
31083
|
+
if (step === null || typeof step !== "object" || Array.isArray(step)) return step;
|
|
31084
|
+
const target = Reflect.get(step, "target");
|
|
31085
|
+
const elseSteps = Reflect.get(step, "else");
|
|
31086
|
+
return {
|
|
31087
|
+
...step,
|
|
31088
|
+
...target === void 0 ? {} : { target: canonicalStoredTarget(target) },
|
|
31089
|
+
...elseSteps === void 0 ? {} : { else: canonicalStoredStepTargets(elseSteps) }
|
|
31090
|
+
};
|
|
31091
|
+
}
|
|
31092
|
+
function canonicalStoredTarget(target) {
|
|
31093
|
+
if (target === null || typeof target !== "object" || Array.isArray(target)) return target;
|
|
31094
|
+
const deviceType = Reflect.get(target, "deviceType");
|
|
31095
|
+
if (typeof deviceType !== "string") return target;
|
|
31096
|
+
return {
|
|
31097
|
+
...target,
|
|
31098
|
+
deviceType: require_implemented_methods.canonicalStoredDeviceType(deviceType)
|
|
31099
|
+
};
|
|
31100
|
+
}
|
|
31050
31101
|
/** The events after which a cached domain is stale. */
|
|
31051
31102
|
var ACTION_TARGET_INVALIDATION_EVENTS = [
|
|
31052
31103
|
require_event_category.EventCategory.DeviceRegistered,
|
|
@@ -48986,95 +49037,6 @@ function groupTemplate(id) {
|
|
|
48986
49037
|
return BY_ID.get(id) ?? null;
|
|
48987
49038
|
}
|
|
48988
49039
|
//#endregion
|
|
48989
|
-
//#region src/composition/helpers/actuator.ts
|
|
48990
|
-
/**
|
|
48991
|
-
* Actuator groups (D944 phase 1b). The active boolean is the binary reducer
|
|
48992
|
-
* with unknown members left out. A command is one call per member that binds
|
|
48993
|
-
* the cap, including members that are offline. One failure does not cancel
|
|
48994
|
-
* the others.
|
|
48995
|
-
*/
|
|
48996
|
-
/** Caps a light group may expose, in display order. Switch is the active state. */
|
|
48997
|
-
var LIGHT_SHARED_CAPS = [
|
|
48998
|
-
"switch",
|
|
48999
|
-
"brightness",
|
|
49000
|
-
"color"
|
|
49001
|
-
];
|
|
49002
|
-
var COLOR_MODE_FEATURES = [
|
|
49003
|
-
require_composed_stable_id.DeviceFeature.LightColorRgb,
|
|
49004
|
-
require_composed_stable_id.DeviceFeature.LightColorHsv,
|
|
49005
|
-
require_composed_stable_id.DeviceFeature.LightColorMired
|
|
49006
|
-
];
|
|
49007
|
-
/** How many member calls run at once. The rest wait; none are dropped. */
|
|
49008
|
-
var FAN_OUT_CONCURRENCY = 4;
|
|
49009
|
-
/** `at-least-one` is any included member on; `all` is every included member on. */
|
|
49010
|
-
function reducerForActive(active) {
|
|
49011
|
-
return active === "all" ? "all" : "any";
|
|
49012
|
-
}
|
|
49013
|
-
function activeForReducer(reducer) {
|
|
49014
|
-
return reducer === "all" ? "all" : "at-least-one";
|
|
49015
|
-
}
|
|
49016
|
-
/**
|
|
49017
|
-
* Caps every member binds, from {@link LIGHT_SHARED_CAPS}. An empty member
|
|
49018
|
-
* list shares nothing. A member that lacks colour drops colour from the group.
|
|
49019
|
-
*/
|
|
49020
|
-
function sharedLightCaps(memberCaps) {
|
|
49021
|
-
if (memberCaps.length === 0) return [];
|
|
49022
|
-
return LIGHT_SHARED_CAPS.filter((cap) => memberCaps.every((bound) => bound.includes(cap)));
|
|
49023
|
-
}
|
|
49024
|
-
/**
|
|
49025
|
-
* Colour modes every member advertises. Offline does not remove a mode:
|
|
49026
|
-
* the caller passes device features, not liveness. No members → no mode.
|
|
49027
|
-
*/
|
|
49028
|
-
function sharedColorModes(memberFeatures) {
|
|
49029
|
-
if (memberFeatures.length === 0) return [];
|
|
49030
|
-
return COLOR_MODE_FEATURES.filter((mode) => memberFeatures.every((features) => features.includes(mode)));
|
|
49031
|
-
}
|
|
49032
|
-
/**
|
|
49033
|
-
* One call per member that binds `cap`. Offline members stay in the list.
|
|
49034
|
-
* A member without the cap is not called — the command cannot reach it.
|
|
49035
|
-
*/
|
|
49036
|
-
function fanOutTargets(members, cap, method, args) {
|
|
49037
|
-
return members.flatMap((member) => member.caps.includes(cap) ? [{
|
|
49038
|
-
deviceId: member.deviceId,
|
|
49039
|
-
cap,
|
|
49040
|
-
method,
|
|
49041
|
-
args: { ...args }
|
|
49042
|
-
}] : []);
|
|
49043
|
-
}
|
|
49044
|
-
/**
|
|
49045
|
-
* Run every call. A throw is that member's result; the other calls still run.
|
|
49046
|
-
* At most {@link FAN_OUT_CONCURRENCY} are in flight.
|
|
49047
|
-
*/
|
|
49048
|
-
async function runFanOut(calls, invoke) {
|
|
49049
|
-
const results = [];
|
|
49050
|
-
let next = 0;
|
|
49051
|
-
const worker = async () => {
|
|
49052
|
-
for (;;) {
|
|
49053
|
-
const index = next;
|
|
49054
|
-
next += 1;
|
|
49055
|
-
const call = calls[index];
|
|
49056
|
-
if (call === void 0) return;
|
|
49057
|
-
try {
|
|
49058
|
-
await invoke(call);
|
|
49059
|
-
results[index] = {
|
|
49060
|
-
deviceId: call.deviceId,
|
|
49061
|
-
ok: true
|
|
49062
|
-
};
|
|
49063
|
-
} catch (err) {
|
|
49064
|
-
const error = err instanceof Error ? err.message : String(err);
|
|
49065
|
-
results[index] = {
|
|
49066
|
-
deviceId: call.deviceId,
|
|
49067
|
-
ok: false,
|
|
49068
|
-
error
|
|
49069
|
-
};
|
|
49070
|
-
}
|
|
49071
|
-
}
|
|
49072
|
-
};
|
|
49073
|
-
const width = Math.min(4, calls.length);
|
|
49074
|
-
await Promise.all(Array.from({ length: width }, () => worker()));
|
|
49075
|
-
return results;
|
|
49076
|
-
}
|
|
49077
|
-
//#endregion
|
|
49078
49040
|
//#region src/generated/history-catalog.ts
|
|
49079
49041
|
/**
|
|
49080
49042
|
* Cap history catalog, projected from every `*.cap.ts` `history` block.
|
|
@@ -49600,6 +49562,200 @@ function historyFieldsFor(capName) {
|
|
|
49600
49562
|
return HISTORY_CATALOG[capName] ?? {};
|
|
49601
49563
|
}
|
|
49602
49564
|
//#endregion
|
|
49565
|
+
//#region src/composition/helpers/source-pick.ts
|
|
49566
|
+
/**
|
|
49567
|
+
* The request the common source selector (#236) accepts for a helper (D944 §5).
|
|
49568
|
+
* The selector's layout is not specified here. Groups ask for one device type
|
|
49569
|
+
* and the catalog field; they do not opt into incompatible fields.
|
|
49570
|
+
*/
|
|
49571
|
+
/**
|
|
49572
|
+
* Does a device of this type and role answer the request's device types?
|
|
49573
|
+
*
|
|
49574
|
+
* The one gate both the member picker and the save use. No types = any device.
|
|
49575
|
+
* A relay driving a lamp (`switch-light`) is a switch AND a light member: it
|
|
49576
|
+
* joins a light group with its on/off only, and a command it cannot do
|
|
49577
|
+
* (brightness, colour) skips it like any member that lacks the cap.
|
|
49578
|
+
*/
|
|
49579
|
+
function sourcePickAcceptsDevice(request, deviceType, role) {
|
|
49580
|
+
return memberKindAccepted(request.deviceTypes, deviceType, role);
|
|
49581
|
+
}
|
|
49582
|
+
/** `sourcePickAcceptsDevice` over a bare list of member types. */
|
|
49583
|
+
function memberKindAccepted(allowed, deviceType, role) {
|
|
49584
|
+
if (allowed.length === 0) return true;
|
|
49585
|
+
if (allowed.some((type) => type === deviceType)) return true;
|
|
49586
|
+
return require_implemented_methods.isSwitchLight(deviceType, role) && allowed.includes(require_composed_stable_id.DeviceType.Light);
|
|
49587
|
+
}
|
|
49588
|
+
/** What the member step asks the selector for this template. */
|
|
49589
|
+
function sourcePickForTemplate(template) {
|
|
49590
|
+
const valueKind = template.family === "numeric" ? "number" : template.activeWhen === void 0 ? "boolean" : "state";
|
|
49591
|
+
return {
|
|
49592
|
+
fieldChoice: template.family === "numeric" ? "first-match" : "operator",
|
|
49593
|
+
purpose: "member",
|
|
49594
|
+
multiple: true,
|
|
49595
|
+
max: 64,
|
|
49596
|
+
deviceTypes: [...template.memberDeviceTypes],
|
|
49597
|
+
accept: template.accept.map((field) => ({
|
|
49598
|
+
...field,
|
|
49599
|
+
valueKind
|
|
49600
|
+
})),
|
|
49601
|
+
history: {
|
|
49602
|
+
required: false,
|
|
49603
|
+
minRetentionMs: null
|
|
49604
|
+
},
|
|
49605
|
+
mustBindCaps: template.family === "actuator" ? template.accept.map((field) => field.cap) : [],
|
|
49606
|
+
exclude: []
|
|
49607
|
+
};
|
|
49608
|
+
}
|
|
49609
|
+
/** A statistic or integral reads one field that declares history. */
|
|
49610
|
+
function sourcePickForHistory(kind) {
|
|
49611
|
+
return {
|
|
49612
|
+
fieldChoice: "operator",
|
|
49613
|
+
purpose: "historised",
|
|
49614
|
+
multiple: false,
|
|
49615
|
+
max: 1,
|
|
49616
|
+
deviceTypes: [],
|
|
49617
|
+
accept: historyAccept(kind),
|
|
49618
|
+
history: {
|
|
49619
|
+
required: true,
|
|
49620
|
+
minRetentionMs: null
|
|
49621
|
+
},
|
|
49622
|
+
mustBindCaps: [],
|
|
49623
|
+
exclude: []
|
|
49624
|
+
};
|
|
49625
|
+
}
|
|
49626
|
+
function historyAccept(kind) {
|
|
49627
|
+
const fields = [];
|
|
49628
|
+
for (const cap of Object.keys(HISTORY_CATALOG)) for (const [fieldPath, field] of Object.entries(historyFieldsFor(cap))) {
|
|
49629
|
+
if (field.kind === "enum") continue;
|
|
49630
|
+
if (kind === "integral" && field.kind !== "gauge") continue;
|
|
49631
|
+
fields.push({
|
|
49632
|
+
cap,
|
|
49633
|
+
fieldPath,
|
|
49634
|
+
valueKind: field.kind === "boolean" ? "boolean" : "number"
|
|
49635
|
+
});
|
|
49636
|
+
}
|
|
49637
|
+
return fields;
|
|
49638
|
+
}
|
|
49639
|
+
/**
|
|
49640
|
+
* What the input step asks the selector for a math helper. A threshold reads
|
|
49641
|
+
* one number, a difference or a ratio two, a sum and an expression several.
|
|
49642
|
+
* A derivative reads one historised number.
|
|
49643
|
+
*/
|
|
49644
|
+
function sourcePickForMath(kind) {
|
|
49645
|
+
if (kind === "derivative") return {
|
|
49646
|
+
...sourcePickForHistory("statistic"),
|
|
49647
|
+
accept: numericAccept()
|
|
49648
|
+
};
|
|
49649
|
+
const multiple = kind === "sum" || kind === "expression";
|
|
49650
|
+
const max = kind === "difference" || kind === "ratio" ? 2 : multiple ? 64 : 1;
|
|
49651
|
+
return {
|
|
49652
|
+
fieldChoice: "operator",
|
|
49653
|
+
purpose: "reading",
|
|
49654
|
+
multiple: multiple || max > 1,
|
|
49655
|
+
max,
|
|
49656
|
+
deviceTypes: [],
|
|
49657
|
+
accept: numericAccept(),
|
|
49658
|
+
history: {
|
|
49659
|
+
required: false,
|
|
49660
|
+
minRetentionMs: null
|
|
49661
|
+
},
|
|
49662
|
+
mustBindCaps: [],
|
|
49663
|
+
exclude: []
|
|
49664
|
+
};
|
|
49665
|
+
}
|
|
49666
|
+
function numericAccept() {
|
|
49667
|
+
return historyAccept("statistic").filter((field) => field.valueKind === "number");
|
|
49668
|
+
}
|
|
49669
|
+
//#endregion
|
|
49670
|
+
//#region src/composition/helpers/actuator.ts
|
|
49671
|
+
/**
|
|
49672
|
+
* Actuator groups (D944 phase 1b). The active boolean is the binary reducer
|
|
49673
|
+
* with unknown members left out. A command is one call per member that binds
|
|
49674
|
+
* the cap, including members that are offline. One failure does not cancel
|
|
49675
|
+
* the others.
|
|
49676
|
+
*/
|
|
49677
|
+
/** Caps a light group may expose, in display order. Switch is the active state. */
|
|
49678
|
+
var LIGHT_SHARED_CAPS = [
|
|
49679
|
+
"switch",
|
|
49680
|
+
"brightness",
|
|
49681
|
+
"color"
|
|
49682
|
+
];
|
|
49683
|
+
var COLOR_MODE_FEATURES = [
|
|
49684
|
+
require_composed_stable_id.DeviceFeature.LightColorRgb,
|
|
49685
|
+
require_composed_stable_id.DeviceFeature.LightColorHsv,
|
|
49686
|
+
require_composed_stable_id.DeviceFeature.LightColorMired
|
|
49687
|
+
];
|
|
49688
|
+
/** How many member calls run at once. The rest wait; none are dropped. */
|
|
49689
|
+
var FAN_OUT_CONCURRENCY = 4;
|
|
49690
|
+
/** `at-least-one` is any included member on; `all` is every included member on. */
|
|
49691
|
+
function reducerForActive(active) {
|
|
49692
|
+
return active === "all" ? "all" : "any";
|
|
49693
|
+
}
|
|
49694
|
+
function activeForReducer(reducer) {
|
|
49695
|
+
return reducer === "all" ? "all" : "at-least-one";
|
|
49696
|
+
}
|
|
49697
|
+
/**
|
|
49698
|
+
* Caps every member binds, from {@link LIGHT_SHARED_CAPS}. An empty member
|
|
49699
|
+
* list shares nothing. A member that lacks colour drops colour from the group.
|
|
49700
|
+
*/
|
|
49701
|
+
function sharedLightCaps(memberCaps) {
|
|
49702
|
+
if (memberCaps.length === 0) return [];
|
|
49703
|
+
return LIGHT_SHARED_CAPS.filter((cap) => memberCaps.every((bound) => bound.includes(cap)));
|
|
49704
|
+
}
|
|
49705
|
+
/**
|
|
49706
|
+
* Colour modes every member advertises. Offline does not remove a mode:
|
|
49707
|
+
* the caller passes device features, not liveness. No members → no mode.
|
|
49708
|
+
*/
|
|
49709
|
+
function sharedColorModes(memberFeatures) {
|
|
49710
|
+
if (memberFeatures.length === 0) return [];
|
|
49711
|
+
return COLOR_MODE_FEATURES.filter((mode) => memberFeatures.every((features) => features.includes(mode)));
|
|
49712
|
+
}
|
|
49713
|
+
/**
|
|
49714
|
+
* One call per member that binds `cap`. Offline members stay in the list.
|
|
49715
|
+
* A member without the cap is not called — the command cannot reach it.
|
|
49716
|
+
*/
|
|
49717
|
+
function fanOutTargets(members, cap, method, args) {
|
|
49718
|
+
return members.flatMap((member) => member.caps.includes(cap) ? [{
|
|
49719
|
+
deviceId: member.deviceId,
|
|
49720
|
+
cap,
|
|
49721
|
+
method,
|
|
49722
|
+
args: { ...args }
|
|
49723
|
+
}] : []);
|
|
49724
|
+
}
|
|
49725
|
+
/**
|
|
49726
|
+
* Run every call. A throw is that member's result; the other calls still run.
|
|
49727
|
+
* At most {@link FAN_OUT_CONCURRENCY} are in flight.
|
|
49728
|
+
*/
|
|
49729
|
+
async function runFanOut(calls, invoke) {
|
|
49730
|
+
const results = [];
|
|
49731
|
+
let next = 0;
|
|
49732
|
+
const worker = async () => {
|
|
49733
|
+
for (;;) {
|
|
49734
|
+
const index = next;
|
|
49735
|
+
next += 1;
|
|
49736
|
+
const call = calls[index];
|
|
49737
|
+
if (call === void 0) return;
|
|
49738
|
+
try {
|
|
49739
|
+
await invoke(call);
|
|
49740
|
+
results[index] = {
|
|
49741
|
+
deviceId: call.deviceId,
|
|
49742
|
+
ok: true
|
|
49743
|
+
};
|
|
49744
|
+
} catch (err) {
|
|
49745
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
49746
|
+
results[index] = {
|
|
49747
|
+
deviceId: call.deviceId,
|
|
49748
|
+
ok: false,
|
|
49749
|
+
error
|
|
49750
|
+
};
|
|
49751
|
+
}
|
|
49752
|
+
}
|
|
49753
|
+
};
|
|
49754
|
+
const width = Math.min(4, calls.length);
|
|
49755
|
+
await Promise.all(Array.from({ length: width }, () => worker()));
|
|
49756
|
+
return results;
|
|
49757
|
+
}
|
|
49758
|
+
//#endregion
|
|
49603
49759
|
//#region src/composition/helpers/compile-history.ts
|
|
49604
49760
|
/**
|
|
49605
49761
|
* Project a statistics or integral helper onto a new device (D944 §3).
|
|
@@ -50195,8 +50351,10 @@ function deviceTypeProblems(spec, facts) {
|
|
|
50195
50351
|
const template = groupTemplate(spec.templateId);
|
|
50196
50352
|
if (template === null) return [];
|
|
50197
50353
|
return spec.members.flatMap((member, index) => {
|
|
50198
|
-
const
|
|
50199
|
-
|
|
50354
|
+
const fact = facts.get(require_implemented_methods.compositionSourceKey(member.source));
|
|
50355
|
+
const deviceType = fact?.deviceType;
|
|
50356
|
+
if (deviceType === void 0) return [];
|
|
50357
|
+
if (memberKindAccepted(template.memberDeviceTypes, deviceType, fact?.role)) return [];
|
|
50200
50358
|
return [problem("member-constraint", `helper.members[${index}]`, `a ${template.id} group takes ${template.memberDeviceTypes.join(" or ")} devices; this member is a ${deviceType}`)];
|
|
50201
50359
|
});
|
|
50202
50360
|
}
|
|
@@ -51060,6 +51218,7 @@ function validateComposition(composition, ctx) {
|
|
|
51060
51218
|
});
|
|
51061
51219
|
const facts = new Map([...ctx.sources].flatMap(([key, source]) => source.kind === "found" ? [[key, {
|
|
51062
51220
|
deviceType: source.deviceType,
|
|
51221
|
+
role: source.role,
|
|
51063
51222
|
quantity: source.quantity
|
|
51064
51223
|
}]] : []));
|
|
51065
51224
|
const problems = [
|
|
@@ -60241,6 +60400,7 @@ var HERO_SCENE_BY_ROLE = {
|
|
|
60241
60400
|
[require_composed_stable_id.DeviceRole.Outlet]: "plug",
|
|
60242
60401
|
[require_composed_stable_id.DeviceRole.SwitchHeater]: "heater",
|
|
60243
60402
|
[require_composed_stable_id.DeviceRole.SwitchFan]: "fan",
|
|
60403
|
+
[require_composed_stable_id.DeviceRole.SwitchLight]: "light",
|
|
60244
60404
|
[require_composed_stable_id.DeviceRole.ClimateAc]: "ac",
|
|
60245
60405
|
[require_composed_stable_id.DeviceRole.ClimateThermostat]: "inherit",
|
|
60246
60406
|
[require_composed_stable_id.DeviceRole.ClimateFloor]: "inherit",
|
|
@@ -100001,89 +100161,6 @@ function evaluateAggregate(input) {
|
|
|
100001
100161
|
};
|
|
100002
100162
|
}
|
|
100003
100163
|
//#endregion
|
|
100004
|
-
//#region src/composition/helpers/source-pick.ts
|
|
100005
|
-
/** What the member step asks the selector for this template. */
|
|
100006
|
-
function sourcePickForTemplate(template) {
|
|
100007
|
-
const valueKind = template.family === "numeric" ? "number" : template.activeWhen === void 0 ? "boolean" : "state";
|
|
100008
|
-
return {
|
|
100009
|
-
fieldChoice: template.family === "numeric" ? "first-match" : "operator",
|
|
100010
|
-
purpose: "member",
|
|
100011
|
-
multiple: true,
|
|
100012
|
-
max: 64,
|
|
100013
|
-
deviceTypes: [...template.memberDeviceTypes],
|
|
100014
|
-
accept: template.accept.map((field) => ({
|
|
100015
|
-
...field,
|
|
100016
|
-
valueKind
|
|
100017
|
-
})),
|
|
100018
|
-
history: {
|
|
100019
|
-
required: false,
|
|
100020
|
-
minRetentionMs: null
|
|
100021
|
-
},
|
|
100022
|
-
mustBindCaps: template.family === "actuator" ? template.accept.map((field) => field.cap) : [],
|
|
100023
|
-
exclude: []
|
|
100024
|
-
};
|
|
100025
|
-
}
|
|
100026
|
-
/** A statistic or integral reads one field that declares history. */
|
|
100027
|
-
function sourcePickForHistory(kind) {
|
|
100028
|
-
return {
|
|
100029
|
-
fieldChoice: "operator",
|
|
100030
|
-
purpose: "historised",
|
|
100031
|
-
multiple: false,
|
|
100032
|
-
max: 1,
|
|
100033
|
-
deviceTypes: [],
|
|
100034
|
-
accept: historyAccept(kind),
|
|
100035
|
-
history: {
|
|
100036
|
-
required: true,
|
|
100037
|
-
minRetentionMs: null
|
|
100038
|
-
},
|
|
100039
|
-
mustBindCaps: [],
|
|
100040
|
-
exclude: []
|
|
100041
|
-
};
|
|
100042
|
-
}
|
|
100043
|
-
function historyAccept(kind) {
|
|
100044
|
-
const fields = [];
|
|
100045
|
-
for (const cap of Object.keys(HISTORY_CATALOG)) for (const [fieldPath, field] of Object.entries(historyFieldsFor(cap))) {
|
|
100046
|
-
if (field.kind === "enum") continue;
|
|
100047
|
-
if (kind === "integral" && field.kind !== "gauge") continue;
|
|
100048
|
-
fields.push({
|
|
100049
|
-
cap,
|
|
100050
|
-
fieldPath,
|
|
100051
|
-
valueKind: field.kind === "boolean" ? "boolean" : "number"
|
|
100052
|
-
});
|
|
100053
|
-
}
|
|
100054
|
-
return fields;
|
|
100055
|
-
}
|
|
100056
|
-
/**
|
|
100057
|
-
* What the input step asks the selector for a math helper. A threshold reads
|
|
100058
|
-
* one number, a difference or a ratio two, a sum and an expression several.
|
|
100059
|
-
* A derivative reads one historised number.
|
|
100060
|
-
*/
|
|
100061
|
-
function sourcePickForMath(kind) {
|
|
100062
|
-
if (kind === "derivative") return {
|
|
100063
|
-
...sourcePickForHistory("statistic"),
|
|
100064
|
-
accept: numericAccept()
|
|
100065
|
-
};
|
|
100066
|
-
const multiple = kind === "sum" || kind === "expression";
|
|
100067
|
-
const max = kind === "difference" || kind === "ratio" ? 2 : multiple ? 64 : 1;
|
|
100068
|
-
return {
|
|
100069
|
-
fieldChoice: "operator",
|
|
100070
|
-
purpose: "reading",
|
|
100071
|
-
multiple: multiple || max > 1,
|
|
100072
|
-
max,
|
|
100073
|
-
deviceTypes: [],
|
|
100074
|
-
accept: numericAccept(),
|
|
100075
|
-
history: {
|
|
100076
|
-
required: false,
|
|
100077
|
-
minRetentionMs: null
|
|
100078
|
-
},
|
|
100079
|
-
mustBindCaps: [],
|
|
100080
|
-
exclude: []
|
|
100081
|
-
};
|
|
100082
|
-
}
|
|
100083
|
-
function numericAccept() {
|
|
100084
|
-
return historyAccept("statistic").filter((field) => field.valueKind === "number");
|
|
100085
|
-
}
|
|
100086
|
-
//#endregion
|
|
100087
100164
|
//#region src/composition/customize/field-source.ts
|
|
100088
100165
|
function fromRead(source, cap, fieldPath) {
|
|
100089
100166
|
return {
|
|
@@ -105270,73 +105347,6 @@ function widenDeviceConstructor(ctor) {
|
|
|
105270
105347
|
return ctor;
|
|
105271
105348
|
}
|
|
105272
105349
|
//#endregion
|
|
105273
|
-
//#region src/device/device-kind.ts
|
|
105274
|
-
/**
|
|
105275
|
-
* A device's KIND is its type plus its role (D1033): the type is the set of
|
|
105276
|
-
* controls it has, the role says which thing it is among the devices that
|
|
105277
|
-
* share those controls. A plug-in heater is a `switch` with role
|
|
105278
|
-
* `switch-heater`; an air conditioner and a radiator valve are both `climate`,
|
|
105279
|
-
* told apart by their `climate-*` role.
|
|
105280
|
-
*/
|
|
105281
|
-
/**
|
|
105282
|
-
* Type values a persisted row may still carry after the type was retired, and
|
|
105283
|
-
* the type each one is read as. The row is rewritten by the next registration
|
|
105284
|
-
* of the device (its provider stamps the live type), so this is a read alias,
|
|
105285
|
-
* not a migration.
|
|
105286
|
-
*
|
|
105287
|
-
* `heater` is deliberately absent: the only heaters were composed devices the
|
|
105288
|
-
* operator deletes. Such a row stays an unknown type, which every reader
|
|
105289
|
-
* treats as a generic device.
|
|
105290
|
-
*/
|
|
105291
|
-
var RETIRED_DEVICE_TYPES = { thermostat: require_composed_stable_id.DeviceType.Climate };
|
|
105292
|
-
/** The live type a stored `type` value stands for (itself unless retired). */
|
|
105293
|
-
function canonicalStoredDeviceType(stored) {
|
|
105294
|
-
return RETIRED_DEVICE_TYPES[stored] ?? stored;
|
|
105295
|
-
}
|
|
105296
|
-
/** The `climate-*` roles, in the order the role picker lists them. */
|
|
105297
|
-
var CLIMATE_ROLES = [
|
|
105298
|
-
require_composed_stable_id.DeviceRole.ClimateThermostat,
|
|
105299
|
-
require_composed_stable_id.DeviceRole.ClimateAc,
|
|
105300
|
-
require_composed_stable_id.DeviceRole.ClimateRadiator,
|
|
105301
|
-
require_composed_stable_id.DeviceRole.ClimateFloor,
|
|
105302
|
-
require_composed_stable_id.DeviceRole.ClimateHeater,
|
|
105303
|
-
require_composed_stable_id.DeviceRole.ClimateHeatPumpCircuit
|
|
105304
|
-
];
|
|
105305
|
-
function isClimateRole(role) {
|
|
105306
|
-
return CLIMATE_ROLES.some((candidate) => candidate === role);
|
|
105307
|
-
}
|
|
105308
|
-
/**
|
|
105309
|
-
* Which climate device this is. A climate device with no role, or a role that
|
|
105310
|
-
* is not a climate one, is a room thermostat: that is what most of them are,
|
|
105311
|
-
* and it is the presentation a thermostat had before the types were folded.
|
|
105312
|
-
*/
|
|
105313
|
-
function climateRoleOf(role) {
|
|
105314
|
-
return role !== null && role !== void 0 && isClimateRole(role) ? role : require_composed_stable_id.DeviceRole.ClimateThermostat;
|
|
105315
|
-
}
|
|
105316
|
-
/** An air conditioner: exports present it as an AC unit, not a thermostat. */
|
|
105317
|
-
function isAirConditioner(type, role) {
|
|
105318
|
-
return type === require_composed_stable_id.DeviceType.Climate && climateRoleOf(role) === require_composed_stable_id.DeviceRole.ClimateAc;
|
|
105319
|
-
}
|
|
105320
|
-
/**
|
|
105321
|
-
* Is a capability offered on a device of this type and role?
|
|
105322
|
-
*
|
|
105323
|
-
* Fails open where the old type-only gate did: no `deviceTypes` (or an empty
|
|
105324
|
-
* list) applies to every device, and an unknown type never filters (a failed
|
|
105325
|
-
* meta read must not destroy work, D49). A type the cap's `deviceRoles` names
|
|
105326
|
-
* is offered only to the roles listed there; an unknown role is NOT one of
|
|
105327
|
-
* them, so a `switch` whose role could not be read is not a heater.
|
|
105328
|
-
*/
|
|
105329
|
-
function capAppliesToDeviceKind(gate, deviceType, role) {
|
|
105330
|
-
if (deviceType === void 0) return true;
|
|
105331
|
-
const types = gate?.deviceTypes;
|
|
105332
|
-
if (!types || types.length === 0) return true;
|
|
105333
|
-
const type = types.find((candidate) => candidate === deviceType);
|
|
105334
|
-
if (type === void 0) return false;
|
|
105335
|
-
const roles = gate?.deviceRoles?.[type];
|
|
105336
|
-
if (roles === void 0) return true;
|
|
105337
|
-
return role !== null && role !== void 0 && roles.some((candidate) => candidate === role);
|
|
105338
|
-
}
|
|
105339
|
-
//#endregion
|
|
105340
105350
|
//#region src/device/device-control-resolution.ts
|
|
105341
105351
|
/**
|
|
105342
105352
|
* Device-control RESOLUTION LOGIC — the single, presentation-free source of
|
|
@@ -105424,7 +105434,7 @@ var DEVICE_TYPE_VALUES = new Set(Object.values(require_composed_stable_id.Device
|
|
|
105424
105434
|
*/
|
|
105425
105435
|
function resolveDeviceControlKind(type, role) {
|
|
105426
105436
|
if (!DEVICE_TYPE_VALUES.has(type)) return null;
|
|
105427
|
-
if (isAirConditioner(type, role)) return "climate";
|
|
105437
|
+
if (require_implemented_methods.isAirConditioner(type, role)) return "climate";
|
|
105428
105438
|
if (type === require_composed_stable_id.DeviceType.Switch && role === require_composed_stable_id.DeviceRole.SwitchHeater) return "heater";
|
|
105429
105439
|
return DEVICE_TYPE_CONTROL_KIND[type];
|
|
105430
105440
|
}
|
|
@@ -108441,7 +108451,8 @@ function isDeviceType$1(type) {
|
|
|
108441
108451
|
/** The layout of a type; a type this build does not know gets the default. */
|
|
108442
108452
|
function resolveHeroLayout(type, role = null) {
|
|
108443
108453
|
if (type === require_composed_stable_id.DeviceType.Switch && role === require_composed_stable_id.DeviceRole.SwitchHeater) return HEATER_LAYOUT;
|
|
108444
|
-
|
|
108454
|
+
const live = require_implemented_methods.canonicalStoredDeviceType(type);
|
|
108455
|
+
return isDeviceType$1(live) ? HERO_LAYOUT_BY_TYPE[live] : HERO_LAYOUT_DEFAULT;
|
|
108445
108456
|
}
|
|
108446
108457
|
//#endregion
|
|
108447
108458
|
//#region src/device/hero/hero-look.ts
|
|
@@ -109183,6 +109194,7 @@ var HERO_LOOK_BY_ROLE = {
|
|
|
109183
109194
|
[require_composed_stable_id.DeviceRole.Outlet]: "inherit",
|
|
109184
109195
|
[require_composed_stable_id.DeviceRole.SwitchHeater]: HEATER_LOOK,
|
|
109185
109196
|
[require_composed_stable_id.DeviceRole.SwitchFan]: FAN_LOOK,
|
|
109197
|
+
[require_composed_stable_id.DeviceRole.SwitchLight]: LIGHT_LOOK,
|
|
109186
109198
|
[require_composed_stable_id.DeviceRole.ClimateAc]: "inherit",
|
|
109187
109199
|
[require_composed_stable_id.DeviceRole.ClimateThermostat]: "inherit",
|
|
109188
109200
|
[require_composed_stable_id.DeviceRole.ClimateFloor]: "inherit",
|
|
@@ -109246,7 +109258,7 @@ function resolveHeroLook(role, type, state, mode = null) {
|
|
|
109246
109258
|
const byMode = HERO_MODE_LOOK[mode];
|
|
109247
109259
|
if (byMode !== null) return byMode;
|
|
109248
109260
|
}
|
|
109249
|
-
if (isAirConditioner(type, role)) return CLIMATE_LOOK[state];
|
|
109261
|
+
if (require_implemented_methods.isAirConditioner(type, role)) return CLIMATE_LOOK[state];
|
|
109250
109262
|
return ((isDeviceType(type) ? HERO_LOOK_BY_TYPE[type] : void 0) ?? HERO_LOOK_DEFAULT)[state];
|
|
109251
109263
|
}
|
|
109252
109264
|
/** Every look the model declares, for the exhaustiveness guard and its spec. */
|
|
@@ -139645,7 +139657,7 @@ exports.CATALOG_LANGS = CATALOG_LANGS;
|
|
|
139645
139657
|
exports.CHOOSE_BRANCHES_MAX = CHOOSE_BRANCHES_MAX;
|
|
139646
139658
|
exports.CIVIL_TWILIGHT_ALTITUDE_DEG = CIVIL_TWILIGHT_ALTITUDE_DEG;
|
|
139647
139659
|
exports.CLASS_MAP_MACRO_TARGETS = CLASS_MAP_MACRO_TARGETS;
|
|
139648
|
-
exports.CLIMATE_ROLES = CLIMATE_ROLES;
|
|
139660
|
+
exports.CLIMATE_ROLES = require_implemented_methods.CLIMATE_ROLES;
|
|
139649
139661
|
exports.CLIP_BROKER_PACED_RATES = CLIP_BROKER_PACED_RATES;
|
|
139650
139662
|
exports.CLIP_LABEL_EVENT_FETCH_LIMIT = CLIP_LABEL_EVENT_FETCH_LIMIT;
|
|
139651
139663
|
exports.CLIP_PLAYBACK_OPTIONS = CLIP_PLAYBACK_OPTIONS;
|
|
@@ -141705,6 +141717,7 @@ exports.StorageReadChunkInputSchema = ReadChunkInputSchema;
|
|
|
141705
141717
|
exports.StorageTableSchema = StorageTableSchema;
|
|
141706
141718
|
exports.StorageTestLocationResultSchema = TestLocationResultSchema;
|
|
141707
141719
|
exports.StorageWriteChunkInputSchema = WriteChunkInputSchema;
|
|
141720
|
+
exports.StoredDeviceTypeSchema = require_implemented_methods.StoredDeviceTypeSchema;
|
|
141708
141721
|
exports.StoredRecordKindDeclarationSchema = require_sleep.StoredRecordKindDeclarationSchema;
|
|
141709
141722
|
exports.StreamCodecSchema = StreamCodecSchema;
|
|
141710
141723
|
exports.StreamFormatSchema = StreamFormatSchema;
|
|
@@ -142111,9 +142124,11 @@ exports.canConvertUnit = require_convert.canConvertUnit;
|
|
|
142111
142124
|
exports.canonicalEgressPlan = canonicalEgressPlan;
|
|
142112
142125
|
exports.canonicalIconKey = canonicalIconKey;
|
|
142113
142126
|
exports.canonicalJson = canonicalJson;
|
|
142114
|
-
exports.
|
|
142127
|
+
exports.canonicalStoredBlockTarget = require_implemented_methods.canonicalStoredBlockTarget;
|
|
142128
|
+
exports.canonicalStoredDeviceType = require_implemented_methods.canonicalStoredDeviceType;
|
|
142129
|
+
exports.canonicalStoredStepTargets = canonicalStoredStepTargets;
|
|
142115
142130
|
exports.canonicalizeAppCallback = canonicalizeAppCallback;
|
|
142116
|
-
exports.capAppliesToDeviceKind = capAppliesToDeviceKind;
|
|
142131
|
+
exports.capAppliesToDeviceKind = require_implemented_methods.capAppliesToDeviceKind;
|
|
142117
142132
|
exports.capUnitResolver = capUnitResolver;
|
|
142118
142133
|
exports.capabilityScopesOf = capabilityScopesOf;
|
|
142119
142134
|
exports.capacityForModel = capacityForModel;
|
|
@@ -142143,7 +142158,7 @@ exports.clearKnownSecrets = require_sleep.clearKnownSecrets;
|
|
|
142143
142158
|
exports.clearModelBoundOverrides = clearModelBoundOverrides;
|
|
142144
142159
|
exports.clearModelBoundSetting = clearModelBoundSetting;
|
|
142145
142160
|
exports.climateControlCapability = climateControlCapability;
|
|
142146
|
-
exports.climateRoleOf = climateRoleOf;
|
|
142161
|
+
exports.climateRoleOf = require_implemented_methods.climateRoleOf;
|
|
142147
142162
|
exports.clipEventLabelDepsFromApi = clipEventLabelDepsFromApi;
|
|
142148
142163
|
exports.clipExportFailure = clipExportFailure;
|
|
142149
142164
|
exports.clipExportFailureOf = clipExportFailureOf;
|
|
@@ -142574,7 +142589,7 @@ exports.irSourceProblem = irSourceProblem;
|
|
|
142574
142589
|
exports.irTransmitterCapability = irTransmitterCapability;
|
|
142575
142590
|
exports.isAddonInstanceId = isAddonInstanceId;
|
|
142576
142591
|
exports.isAgentOnlyPlacement = isAgentOnlyPlacement;
|
|
142577
|
-
exports.isAirConditioner = isAirConditioner;
|
|
142592
|
+
exports.isAirConditioner = require_implemented_methods.isAirConditioner;
|
|
142578
142593
|
exports.isAlarmControllableCap = isAlarmControllableCap;
|
|
142579
142594
|
exports.isAlertEpisodeOpen = isAlertEpisodeOpen;
|
|
142580
142595
|
exports.isAlertEpisodeSeverity = isAlertEpisodeSeverity;
|
|
@@ -142629,6 +142644,7 @@ exports.isNode = isNode;
|
|
|
142629
142644
|
exports.isOauthLandingReason = isOauthLandingReason;
|
|
142630
142645
|
exports.isObjectInput = isObjectInput;
|
|
142631
142646
|
exports.isOccupancyRule = isOccupancyRule;
|
|
142647
|
+
exports.isOutlet = require_implemented_methods.isOutlet;
|
|
142632
142648
|
exports.isOwnerOnlyEventCategory = require_event_category.isOwnerOnlyEventCategory;
|
|
142633
142649
|
exports.isPlugApplianceType = isPlugApplianceType;
|
|
142634
142650
|
exports.isPositionTicking = isPositionTicking;
|
|
@@ -142662,6 +142678,9 @@ exports.isSourceCap = require_implemented_methods.isSourceCap;
|
|
|
142662
142678
|
exports.isStateLabelKey = isStateLabelKey;
|
|
142663
142679
|
exports.isStatefulBuiltin = require_implemented_methods.isStatefulBuiltin;
|
|
142664
142680
|
exports.isStorageLocationMode = isStorageLocationMode;
|
|
142681
|
+
exports.isSwitchFan = require_implemented_methods.isSwitchFan;
|
|
142682
|
+
exports.isSwitchHeater = require_implemented_methods.isSwitchHeater;
|
|
142683
|
+
exports.isSwitchLight = require_implemented_methods.isSwitchLight;
|
|
142665
142684
|
exports.isSystemDelivery = isSystemDelivery;
|
|
142666
142685
|
exports.isSystemEventFamily = isSystemEventFamily;
|
|
142667
142686
|
exports.isSystemEventRecoveryKind = isSystemEventRecoveryKind;
|
|
@@ -143213,6 +143232,7 @@ exports.smokeCapability = smokeCapability;
|
|
|
143213
143232
|
exports.smtpProviderCapability = smtpProviderCapability;
|
|
143214
143233
|
exports.smtpSinceKey = smtpSinceKey;
|
|
143215
143234
|
exports.snapshotCapability = snapshotCapability;
|
|
143235
|
+
exports.sourcePickAcceptsDevice = sourcePickAcceptsDevice;
|
|
143216
143236
|
exports.sourcePickForHistory = sourcePickForHistory;
|
|
143217
143237
|
exports.sourcePickForMath = sourcePickForMath;
|
|
143218
143238
|
exports.sourcePickForTemplate = sourcePickForTemplate;
|