@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_composed_stable_id = require("./composed-stable-id-
|
|
1
|
+
const require_composed_stable_id = require("./composed-stable-id-BmJ_5GiE.js");
|
|
2
2
|
let zod = require("zod");
|
|
3
3
|
let node_crypto = require("node:crypto");
|
|
4
4
|
//#region src/ffmpeg/invocation.ts
|
|
@@ -934,6 +934,116 @@ function chooseFfmpegBinary(input) {
|
|
|
934
934
|
return null;
|
|
935
935
|
}
|
|
936
936
|
//#endregion
|
|
937
|
+
//#region src/device/device-kind.ts
|
|
938
|
+
/**
|
|
939
|
+
* A device's KIND is its type plus its role (D1033): the type is the set of
|
|
940
|
+
* controls it has, the role says which thing it is among the devices that
|
|
941
|
+
* share those controls. A plug-in heater is a `switch` with role
|
|
942
|
+
* `switch-heater`; an air conditioner and a radiator valve are both `climate`,
|
|
943
|
+
* told apart by their `climate-*` role.
|
|
944
|
+
*/
|
|
945
|
+
/**
|
|
946
|
+
* Type values a persisted row may still carry after the type was retired, and
|
|
947
|
+
* the type each one is read as. The row is rewritten by the next registration
|
|
948
|
+
* of the device (its provider stamps the live type), so this is a read alias,
|
|
949
|
+
* not a migration.
|
|
950
|
+
*
|
|
951
|
+
* `heater` is deliberately absent: the only heaters were composed devices the
|
|
952
|
+
* operator deletes. Such a row stays an unknown type, which every reader
|
|
953
|
+
* treats as a generic device.
|
|
954
|
+
*/
|
|
955
|
+
var RETIRED_DEVICE_TYPES = { thermostat: require_composed_stable_id.DeviceType.Climate };
|
|
956
|
+
/** The live type a stored `type` value stands for (itself unless retired). */
|
|
957
|
+
function canonicalStoredDeviceType(stored) {
|
|
958
|
+
return RETIRED_DEVICE_TYPES[stored] ?? stored;
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* The schema for a device type read back from STORAGE — a device config, a
|
|
962
|
+
* container's `entities[]`, a persisted identity. A retired type is read as its
|
|
963
|
+
* live type before the enum check, so a type retired after the record was
|
|
964
|
+
* written never fails the parse and never drops the device (D1033).
|
|
965
|
+
*
|
|
966
|
+
* Never on a schema that is also a WIRE input: a preprocess makes its input
|
|
967
|
+
* type `unknown`, which loosens the generated client. A store whose row schema
|
|
968
|
+
* is a wire schema (a grant, an action, a composition, a notification rule)
|
|
969
|
+
* keeps it strict and rewrites the row with {@link canonicalStoredDeviceType}
|
|
970
|
+
* where it reads the row back.
|
|
971
|
+
*/
|
|
972
|
+
var StoredDeviceTypeSchema = zod.z.preprocess((value) => typeof value === "string" ? canonicalStoredDeviceType(value) : value, zod.z.enum(require_composed_stable_id.DeviceType));
|
|
973
|
+
/** The `climate-*` roles, in the order the role picker lists them. */
|
|
974
|
+
var CLIMATE_ROLES = [
|
|
975
|
+
require_composed_stable_id.DeviceRole.ClimateThermostat,
|
|
976
|
+
require_composed_stable_id.DeviceRole.ClimateAc,
|
|
977
|
+
require_composed_stable_id.DeviceRole.ClimateRadiator,
|
|
978
|
+
require_composed_stable_id.DeviceRole.ClimateFloor,
|
|
979
|
+
require_composed_stable_id.DeviceRole.ClimateHeater,
|
|
980
|
+
require_composed_stable_id.DeviceRole.ClimateHeatPumpCircuit
|
|
981
|
+
];
|
|
982
|
+
function isClimateRole(role) {
|
|
983
|
+
return CLIMATE_ROLES.some((candidate) => candidate === role);
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Which climate device this is. A climate device with no role, or a role that
|
|
987
|
+
* is not a climate one, is a room thermostat: that is what most of them are,
|
|
988
|
+
* and it is the presentation a thermostat had before the types were folded.
|
|
989
|
+
*/
|
|
990
|
+
function climateRoleOf(role) {
|
|
991
|
+
return role !== null && role !== void 0 && isClimateRole(role) ? role : require_composed_stable_id.DeviceRole.ClimateThermostat;
|
|
992
|
+
}
|
|
993
|
+
/** An air conditioner: exports present it as an AC unit, not a thermostat. */
|
|
994
|
+
function isAirConditioner(type, role) {
|
|
995
|
+
return type === require_composed_stable_id.DeviceType.Climate && climateRoleOf(role) === require_composed_stable_id.DeviceRole.ClimateAc;
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* A relay driving an on/off-only lamp (a `switch` with role `switch-light`):
|
|
999
|
+
* drawn and exported as a light, with the switch's power only. The one place
|
|
1000
|
+
* that reads the role for it — a consumer asks this, never the role string.
|
|
1001
|
+
*/
|
|
1002
|
+
function isSwitchLight(type, role) {
|
|
1003
|
+
return type === require_composed_stable_id.DeviceType.Switch && role === require_composed_stable_id.DeviceRole.SwitchLight;
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* A smart plug (a `switch` with role `outlet`, D875): exported as a plug /
|
|
1007
|
+
* outlet. Exports ask this, never the role string.
|
|
1008
|
+
*/
|
|
1009
|
+
function isOutlet(type, role) {
|
|
1010
|
+
return type === require_composed_stable_id.DeviceType.Switch && role === require_composed_stable_id.DeviceRole.Outlet;
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* A plain fan behind a switch (a `switch` with role `switch-fan`): exported as
|
|
1014
|
+
* a fan with the switch's on/off only — no speed it does not have.
|
|
1015
|
+
*/
|
|
1016
|
+
function isSwitchFan(type, role) {
|
|
1017
|
+
return type === require_composed_stable_id.DeviceType.Switch && role === require_composed_stable_id.DeviceRole.SwitchFan;
|
|
1018
|
+
}
|
|
1019
|
+
/**
|
|
1020
|
+
* A plug-in heater behind a switch (a `switch` with role `switch-heater`): it
|
|
1021
|
+
* has power only, no setpoint and no room temperature, so an export never
|
|
1022
|
+
* presents it as a thermostat.
|
|
1023
|
+
*/
|
|
1024
|
+
function isSwitchHeater(type, role) {
|
|
1025
|
+
return type === require_composed_stable_id.DeviceType.Switch && role === require_composed_stable_id.DeviceRole.SwitchHeater;
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* Is a capability offered on a device of this type and role?
|
|
1029
|
+
*
|
|
1030
|
+
* Fails open where the old type-only gate did: no `deviceTypes` (or an empty
|
|
1031
|
+
* list) applies to every device, and an unknown type never filters (a failed
|
|
1032
|
+
* meta read must not destroy work, D49). A type the cap's `deviceRoles` names
|
|
1033
|
+
* is offered only to the roles listed there; an unknown role is NOT one of
|
|
1034
|
+
* them, so a `switch` whose role could not be read is not a heater.
|
|
1035
|
+
*/
|
|
1036
|
+
function capAppliesToDeviceKind(gate, deviceType, role) {
|
|
1037
|
+
if (deviceType === void 0) return true;
|
|
1038
|
+
const types = gate?.deviceTypes;
|
|
1039
|
+
if (!types || types.length === 0) return true;
|
|
1040
|
+
const type = types.find((candidate) => candidate === deviceType);
|
|
1041
|
+
if (type === void 0) return false;
|
|
1042
|
+
const roles = gate?.deviceRoles?.[type];
|
|
1043
|
+
if (roles === void 0) return true;
|
|
1044
|
+
return role !== null && role !== void 0 && roles.some((candidate) => candidate === role);
|
|
1045
|
+
}
|
|
1046
|
+
//#endregion
|
|
937
1047
|
//#region src/catalogs/sensor-active-state.ts
|
|
938
1048
|
/**
|
|
939
1049
|
* THE table "which boolean of this device type counts as HIGH", and the
|
|
@@ -3310,6 +3420,41 @@ var CompositionNewTargetSchema = zod.z.object({
|
|
|
3310
3420
|
type: zod.z.enum(require_composed_stable_id.DeviceType),
|
|
3311
3421
|
role: zod.z.enum(require_composed_stable_id.DeviceRole).optional()
|
|
3312
3422
|
});
|
|
3423
|
+
/**
|
|
3424
|
+
* A STORED block, read back: the `new` target of its composition may name a
|
|
3425
|
+
* device type D1033 retired (`thermostat`). {@link CompositionNewTargetSchema}
|
|
3426
|
+
* stays a strict enum on the wire, so the store rewrites the retired name to
|
|
3427
|
+
* its canonical type (`source.composition.target.type`) before it parses the
|
|
3428
|
+
* row. Anything else is returned untouched, for the schema to judge.
|
|
3429
|
+
*/
|
|
3430
|
+
function canonicalStoredBlockTarget(block) {
|
|
3431
|
+
if (!isPlainObject(block)) return block;
|
|
3432
|
+
const source = Reflect.get(block, "source");
|
|
3433
|
+
if (!isPlainObject(source)) return block;
|
|
3434
|
+
const composition = Reflect.get(source, "composition");
|
|
3435
|
+
if (!isPlainObject(composition)) return block;
|
|
3436
|
+
const target = Reflect.get(composition, "target");
|
|
3437
|
+
if (!isPlainObject(target)) return block;
|
|
3438
|
+
const type = Reflect.get(target, "type");
|
|
3439
|
+
if (typeof type !== "string") return block;
|
|
3440
|
+
const canonical = {
|
|
3441
|
+
...target,
|
|
3442
|
+
type: canonicalStoredDeviceType(type)
|
|
3443
|
+
};
|
|
3444
|
+
return {
|
|
3445
|
+
...block,
|
|
3446
|
+
source: {
|
|
3447
|
+
...source,
|
|
3448
|
+
composition: {
|
|
3449
|
+
...composition,
|
|
3450
|
+
target: canonical
|
|
3451
|
+
}
|
|
3452
|
+
}
|
|
3453
|
+
};
|
|
3454
|
+
}
|
|
3455
|
+
function isPlainObject(value) {
|
|
3456
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
3457
|
+
}
|
|
3313
3458
|
/** Customize an EXISTING device: each feature adds a capability or replaces fields of a native one (D663). */
|
|
3314
3459
|
var CompositionExistingTargetSchema = zod.z.object({
|
|
3315
3460
|
kind: zod.z.literal("existing"),
|
|
@@ -3463,6 +3608,12 @@ Object.defineProperty(exports, "CALENDAR_PERIODS", {
|
|
|
3463
3608
|
return CALENDAR_PERIODS;
|
|
3464
3609
|
}
|
|
3465
3610
|
});
|
|
3611
|
+
Object.defineProperty(exports, "CLIMATE_ROLES", {
|
|
3612
|
+
enumerable: true,
|
|
3613
|
+
get: function() {
|
|
3614
|
+
return CLIMATE_ROLES;
|
|
3615
|
+
}
|
|
3616
|
+
});
|
|
3466
3617
|
Object.defineProperty(exports, "COMPOSER_ADDON_ID", {
|
|
3467
3618
|
enumerable: true,
|
|
3468
3619
|
get: function() {
|
|
@@ -3961,6 +4112,12 @@ Object.defineProperty(exports, "StatisticWindowSchema", {
|
|
|
3961
4112
|
return StatisticWindowSchema;
|
|
3962
4113
|
}
|
|
3963
4114
|
});
|
|
4115
|
+
Object.defineProperty(exports, "StoredDeviceTypeSchema", {
|
|
4116
|
+
enumerable: true,
|
|
4117
|
+
get: function() {
|
|
4118
|
+
return StoredDeviceTypeSchema;
|
|
4119
|
+
}
|
|
4120
|
+
});
|
|
3964
4121
|
Object.defineProperty(exports, "ThresholdHelperSpecSchema", {
|
|
3965
4122
|
enumerable: true,
|
|
3966
4123
|
get: function() {
|
|
@@ -4003,12 +4160,36 @@ Object.defineProperty(exports, "canonicalHash", {
|
|
|
4003
4160
|
return canonicalHash;
|
|
4004
4161
|
}
|
|
4005
4162
|
});
|
|
4163
|
+
Object.defineProperty(exports, "canonicalStoredBlockTarget", {
|
|
4164
|
+
enumerable: true,
|
|
4165
|
+
get: function() {
|
|
4166
|
+
return canonicalStoredBlockTarget;
|
|
4167
|
+
}
|
|
4168
|
+
});
|
|
4169
|
+
Object.defineProperty(exports, "canonicalStoredDeviceType", {
|
|
4170
|
+
enumerable: true,
|
|
4171
|
+
get: function() {
|
|
4172
|
+
return canonicalStoredDeviceType;
|
|
4173
|
+
}
|
|
4174
|
+
});
|
|
4175
|
+
Object.defineProperty(exports, "capAppliesToDeviceKind", {
|
|
4176
|
+
enumerable: true,
|
|
4177
|
+
get: function() {
|
|
4178
|
+
return capAppliesToDeviceKind;
|
|
4179
|
+
}
|
|
4180
|
+
});
|
|
4006
4181
|
Object.defineProperty(exports, "chooseFfmpegBinary", {
|
|
4007
4182
|
enumerable: true,
|
|
4008
4183
|
get: function() {
|
|
4009
4184
|
return chooseFfmpegBinary;
|
|
4010
4185
|
}
|
|
4011
4186
|
});
|
|
4187
|
+
Object.defineProperty(exports, "climateRoleOf", {
|
|
4188
|
+
enumerable: true,
|
|
4189
|
+
get: function() {
|
|
4190
|
+
return climateRoleOf;
|
|
4191
|
+
}
|
|
4192
|
+
});
|
|
4012
4193
|
Object.defineProperty(exports, "cloneStatefulExpressionMemory", {
|
|
4013
4194
|
enumerable: true,
|
|
4014
4195
|
get: function() {
|
|
@@ -4219,6 +4400,12 @@ Object.defineProperty(exports, "invocationFromEncodeProfile", {
|
|
|
4219
4400
|
return invocationFromEncodeProfile;
|
|
4220
4401
|
}
|
|
4221
4402
|
});
|
|
4403
|
+
Object.defineProperty(exports, "isAirConditioner", {
|
|
4404
|
+
enumerable: true,
|
|
4405
|
+
get: function() {
|
|
4406
|
+
return isAirConditioner;
|
|
4407
|
+
}
|
|
4408
|
+
});
|
|
4222
4409
|
Object.defineProperty(exports, "isForwardInputRef", {
|
|
4223
4410
|
enumerable: true,
|
|
4224
4411
|
get: function() {
|
|
@@ -4231,6 +4418,12 @@ Object.defineProperty(exports, "isHistoryHelper", {
|
|
|
4231
4418
|
return isHistoryHelper;
|
|
4232
4419
|
}
|
|
4233
4420
|
});
|
|
4421
|
+
Object.defineProperty(exports, "isOutlet", {
|
|
4422
|
+
enumerable: true,
|
|
4423
|
+
get: function() {
|
|
4424
|
+
return isOutlet;
|
|
4425
|
+
}
|
|
4426
|
+
});
|
|
4234
4427
|
Object.defineProperty(exports, "isSoftwareDecode", {
|
|
4235
4428
|
enumerable: true,
|
|
4236
4429
|
get: function() {
|
|
@@ -4249,6 +4442,24 @@ Object.defineProperty(exports, "isStatefulBuiltin", {
|
|
|
4249
4442
|
return isStatefulBuiltin;
|
|
4250
4443
|
}
|
|
4251
4444
|
});
|
|
4445
|
+
Object.defineProperty(exports, "isSwitchFan", {
|
|
4446
|
+
enumerable: true,
|
|
4447
|
+
get: function() {
|
|
4448
|
+
return isSwitchFan;
|
|
4449
|
+
}
|
|
4450
|
+
});
|
|
4451
|
+
Object.defineProperty(exports, "isSwitchHeater", {
|
|
4452
|
+
enumerable: true,
|
|
4453
|
+
get: function() {
|
|
4454
|
+
return isSwitchHeater;
|
|
4455
|
+
}
|
|
4456
|
+
});
|
|
4457
|
+
Object.defineProperty(exports, "isSwitchLight", {
|
|
4458
|
+
enumerable: true,
|
|
4459
|
+
get: function() {
|
|
4460
|
+
return isSwitchLight;
|
|
4461
|
+
}
|
|
4462
|
+
});
|
|
4252
4463
|
Object.defineProperty(exports, "logBannerArgs", {
|
|
4253
4464
|
enumerable: true,
|
|
4254
4465
|
get: function() {
|
package/dist/index.d.ts
CHANGED
|
@@ -274,7 +274,7 @@ export { DeviceRuntimeState } from './device/device-runtime-state.js';
|
|
|
274
274
|
export type { SliceEventBus, SliceHandle, SliceHandleApi, SliceHandleSource, } from './device/device-state-handle.js';
|
|
275
275
|
export { createEventBusSliceSource, createLazyTrpcSource, createMirrorSource, createSliceHandle, } from './device/device-state-handle.js';
|
|
276
276
|
export { ChargingStatus, DeviceFeature, DeviceRole, DeviceType, featuresOfBoundCaps, } from './device/device-type.js';
|
|
277
|
-
export { capAppliesToDeviceKind, canonicalStoredDeviceType, CLIMATE_ROLES, climateRoleOf, isAirConditioner, type ClimateRole, type DeviceKindGate, } from './device/device-kind.js';
|
|
277
|
+
export { capAppliesToDeviceKind, canonicalStoredDeviceType, CLIMATE_ROLES, StoredDeviceTypeSchema, climateRoleOf, isAirConditioner, isOutlet, isSwitchFan, isSwitchHeater, isSwitchLight, type ClimateRole, type DeviceKindGate, } from './device/device-kind.js';
|
|
278
278
|
export type { CapBackedFeature, FeatureAuthority, FeatureDerivation, FeatureMissing, FeatureRequirement, FeatureSupplier, ReportedFeature, } from './device/device-feature-requirements.js';
|
|
279
279
|
export { DEVICE_FEATURE_REQUIREMENTS, deriveFeatureProvenance, isKernelDerivedFeature, reconcileReportedFeatures, settleDeviceFeatures, } from './device/device-feature-requirements.js';
|
|
280
280
|
export { implementedMethodsOf } from './device/implemented-methods.js';
|