@camstack/types 1.2.576 → 1.2.578
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/capabilities/air-quality-sensor.cap.d.ts +2 -0
- package/dist/capabilities/capability-definition.d.ts +22 -0
- package/dist/capabilities/climate-control.cap.d.ts +6 -0
- package/dist/capabilities/energy-system.cap.d.ts +7 -0
- package/dist/capabilities/heat-pump-status.cap.d.ts +4 -0
- package/dist/capabilities/humidity-sensor.cap.d.ts +2 -0
- package/dist/capabilities/index.d.ts +1 -1
- package/dist/capabilities/power-meter.cap.d.ts +2 -0
- package/dist/capabilities/stream-params.cap.d.ts +4 -0
- package/dist/capabilities/temperature-sensor.cap.d.ts +2 -0
- package/dist/capabilities/water-heater.cap.d.ts +2 -0
- package/dist/capabilities/weather-station.cap.d.ts +10 -0
- package/dist/device-template-catalogue.d.ts +39 -0
- package/dist/device-template-catalogue.js +135 -6
- package/dist/device-template-catalogue.mjs +134 -7
- package/dist/generated/history-catalog.d.ts +6 -1
- package/dist/history/primary-series.d.ts +10 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +405 -264
- package/dist/index.mjs +402 -266
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { c as UNIT_TABLE, o as unitDimension, s as unitsForDimension } from "./convert-BwMfbk5b.mjs";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
//#region src/device-template-catalogue.ts
|
|
3
4
|
/**
|
|
@@ -30,6 +31,29 @@ var DEVICE_TEMPLATE_PARAM_TYPES = [
|
|
|
30
31
|
"number",
|
|
31
32
|
"boolean"
|
|
32
33
|
];
|
|
34
|
+
/**
|
|
35
|
+
* Where the values a parameter takes come from, when a fixed set makes sense.
|
|
36
|
+
* `units-of-field` is the units in the dimension of the piped field's unit;
|
|
37
|
+
* `choices` is a named list (a time pattern); `range` is the numbers
|
|
38
|
+
* `min…max` by `step`. An absent source means free input.
|
|
39
|
+
*/
|
|
40
|
+
var deviceTemplateParamValuesSchemaValue = z.discriminatedUnion("kind", [
|
|
41
|
+
z.object({ kind: z.literal("units-of-field") }),
|
|
42
|
+
z.object({
|
|
43
|
+
kind: z.literal("choices"),
|
|
44
|
+
options: z.array(z.object({
|
|
45
|
+
value: z.string(),
|
|
46
|
+
labelKey: z.string().min(1)
|
|
47
|
+
})).min(1)
|
|
48
|
+
}),
|
|
49
|
+
z.object({
|
|
50
|
+
kind: z.literal("range"),
|
|
51
|
+
min: z.number(),
|
|
52
|
+
max: z.number(),
|
|
53
|
+
step: z.number().positive()
|
|
54
|
+
})
|
|
55
|
+
]);
|
|
56
|
+
var deviceTemplateParamValuesSchema = deviceTemplateParamValuesSchemaValue;
|
|
33
57
|
var deviceTemplateParamSchema = z.object({
|
|
34
58
|
name: z.string().min(1),
|
|
35
59
|
type: z.enum(DEVICE_TEMPLATE_PARAM_TYPES),
|
|
@@ -38,7 +62,8 @@ var deviceTemplateParamSchema = z.object({
|
|
|
38
62
|
z.string(),
|
|
39
63
|
z.number(),
|
|
40
64
|
z.boolean()
|
|
41
|
-
]).optional()
|
|
65
|
+
]).optional(),
|
|
66
|
+
values: deviceTemplateParamValuesSchemaValue.optional()
|
|
42
67
|
});
|
|
43
68
|
var deviceTemplateCatalogueEntrySchema = z.object({
|
|
44
69
|
name: z.string().min(1),
|
|
@@ -48,8 +73,8 @@ var deviceTemplateCatalogueEntrySchema = z.object({
|
|
|
48
73
|
descriptionKey: z.string().min(1),
|
|
49
74
|
exampleKey: z.string().min(1)
|
|
50
75
|
});
|
|
51
|
-
function param(name, type, optional, fallback) {
|
|
52
|
-
|
|
76
|
+
function param(name, type, optional, fallback, values) {
|
|
77
|
+
const base = fallback === void 0 ? {
|
|
53
78
|
name,
|
|
54
79
|
type,
|
|
55
80
|
optional
|
|
@@ -59,6 +84,10 @@ function param(name, type, optional, fallback) {
|
|
|
59
84
|
optional,
|
|
60
85
|
default: fallback
|
|
61
86
|
};
|
|
87
|
+
return values === void 0 ? base : {
|
|
88
|
+
...base,
|
|
89
|
+
values
|
|
90
|
+
};
|
|
62
91
|
}
|
|
63
92
|
function entry(name, kind, category, params) {
|
|
64
93
|
return {
|
|
@@ -70,12 +99,71 @@ function entry(name, kind, category, params) {
|
|
|
70
99
|
exampleKey: `uiLibrary.deviceTemplateCatalogue.${name}.example`
|
|
71
100
|
};
|
|
72
101
|
}
|
|
73
|
-
var DIGITS = param("digits", "number", true, 0
|
|
102
|
+
var DIGITS = param("digits", "number", true, 0, {
|
|
103
|
+
kind: "range",
|
|
104
|
+
min: 0,
|
|
105
|
+
max: 4,
|
|
106
|
+
step: 1
|
|
107
|
+
});
|
|
108
|
+
var UNITS_OF_FIELD = { kind: "units-of-field" };
|
|
109
|
+
/** Named time patterns: the engine's tokens are `YYYY MM DD HH mm ss`. */
|
|
110
|
+
var TIME_PATTERNS = [
|
|
111
|
+
[
|
|
112
|
+
"hm",
|
|
113
|
+
"HH:mm",
|
|
114
|
+
"Hours and minutes (14:05)",
|
|
115
|
+
"Ore e minuti (14:05)"
|
|
116
|
+
],
|
|
117
|
+
[
|
|
118
|
+
"hms",
|
|
119
|
+
"HH:mm:ss",
|
|
120
|
+
"Hours, minutes, seconds (14:05:09)",
|
|
121
|
+
"Ore, minuti, secondi (14:05:09)"
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
"dm",
|
|
125
|
+
"DD/MM",
|
|
126
|
+
"Day and month (31/12)",
|
|
127
|
+
"Giorno e mese (31/12)"
|
|
128
|
+
],
|
|
129
|
+
[
|
|
130
|
+
"dmy",
|
|
131
|
+
"DD/MM/YYYY",
|
|
132
|
+
"Day, month, year (31/12/2026)",
|
|
133
|
+
"Giorno, mese, anno (31/12/2026)"
|
|
134
|
+
],
|
|
135
|
+
[
|
|
136
|
+
"dmyhm",
|
|
137
|
+
"DD/MM/YYYY HH:mm",
|
|
138
|
+
"Date and time (31/12/2026 14:05)",
|
|
139
|
+
"Data e ora (31/12/2026 14:05)"
|
|
140
|
+
],
|
|
141
|
+
[
|
|
142
|
+
"iso",
|
|
143
|
+
"YYYY-MM-DD",
|
|
144
|
+
"ISO date (2026-12-31)",
|
|
145
|
+
"Data ISO (2026-12-31)"
|
|
146
|
+
],
|
|
147
|
+
[
|
|
148
|
+
"isohms",
|
|
149
|
+
"YYYY-MM-DD HH:mm:ss",
|
|
150
|
+
"ISO date and time (2026-12-31 14:05:09)",
|
|
151
|
+
"Data e ora ISO (2026-12-31 14:05:09)"
|
|
152
|
+
]
|
|
153
|
+
];
|
|
154
|
+
var TIME_PATTERN_KEY = (id) => `uiLibrary.deviceTemplateCatalogue.choice.time.${id}`;
|
|
155
|
+
var TIME_PATTERN_VALUES = {
|
|
156
|
+
kind: "choices",
|
|
157
|
+
options: TIME_PATTERNS.map(([id, pattern]) => ({
|
|
158
|
+
value: pattern,
|
|
159
|
+
labelKey: TIME_PATTERN_KEY(id)
|
|
160
|
+
}))
|
|
161
|
+
};
|
|
74
162
|
var FALLBACK_TEXT = param("fallback", "string", false);
|
|
75
163
|
var FALSY = param("falsy", "boolean", true, false);
|
|
76
164
|
/** Every name the engine allows, in the order operators meet them. */
|
|
77
165
|
var DEVICE_TEMPLATE_CATALOGUE = [
|
|
78
|
-
entry("unit", "filter", "unit", [param("symbol", "string", false), param("from", "string", true)]),
|
|
166
|
+
entry("unit", "filter", "unit", [param("symbol", "string", false, void 0, UNITS_OF_FIELD), param("from", "string", true, void 0, UNITS_OF_FIELD)]),
|
|
79
167
|
entry("round", "filter", "number", [DIGITS]),
|
|
80
168
|
entry("trunc", "filter", "number", [DIGITS]),
|
|
81
169
|
entry("onoff", "filter", "state", []),
|
|
@@ -111,7 +199,7 @@ var DEVICE_TEMPLATE_CATALOGUE = [
|
|
|
111
199
|
param("killwords", "boolean", true, false),
|
|
112
200
|
param("end", "string", true, "…")
|
|
113
201
|
]),
|
|
114
|
-
entry("time", "filter", "time", [param("pattern", "string", false)]),
|
|
202
|
+
entry("time", "filter", "time", [param("pattern", "string", false, void 0, TIME_PATTERN_VALUES)]),
|
|
115
203
|
entry("range", "global", "loop", [
|
|
116
204
|
param("stop", "number", false),
|
|
117
205
|
param("start", "number", true, 0),
|
|
@@ -279,6 +367,10 @@ function buildText() {
|
|
|
279
367
|
it: row.example[1]
|
|
280
368
|
};
|
|
281
369
|
}
|
|
370
|
+
for (const [id, , en, it] of TIME_PATTERNS) out[TIME_PATTERN_KEY(id)] = {
|
|
371
|
+
en,
|
|
372
|
+
it
|
|
373
|
+
};
|
|
282
374
|
return out;
|
|
283
375
|
}
|
|
284
376
|
/** English and Italian for every description and example key. */
|
|
@@ -342,5 +434,40 @@ function deviceTemplateCatalogueMarkdown() {
|
|
|
342
434
|
function escapeCell(text) {
|
|
343
435
|
return text.replaceAll("|", "\\|");
|
|
344
436
|
}
|
|
437
|
+
function allUnitGroups() {
|
|
438
|
+
const dimensions = [];
|
|
439
|
+
for (const spec of Object.values(UNIT_TABLE)) if (!dimensions.includes(spec.dimension)) dimensions.push(spec.dimension);
|
|
440
|
+
return dimensions.map((dimension) => ({
|
|
441
|
+
group: dimension,
|
|
442
|
+
choices: unitsForDimension(dimension).map((value) => ({ value }))
|
|
443
|
+
}));
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* The values a parameter offers. `fieldUnit` is the unit of the piped field:
|
|
447
|
+
* `units-of-field` narrows to its dimension, and lists every unit grouped by
|
|
448
|
+
* dimension when the unit is unknown. Empty when the parameter is free input.
|
|
449
|
+
*/
|
|
450
|
+
function deviceTemplateParamChoices(source, fieldUnit) {
|
|
451
|
+
if (source === void 0) return [];
|
|
452
|
+
if (source.kind === "choices") return [{
|
|
453
|
+
group: null,
|
|
454
|
+
choices: source.options.map((o) => ({ ...o }))
|
|
455
|
+
}];
|
|
456
|
+
if (source.kind === "range") {
|
|
457
|
+
const out = [];
|
|
458
|
+
const steps = Math.floor((source.max - source.min) / source.step + 1e-9);
|
|
459
|
+
for (let i = 0; i <= steps; i += 1) out.push({ value: String(source.min + i * source.step) });
|
|
460
|
+
return [{
|
|
461
|
+
group: null,
|
|
462
|
+
choices: out
|
|
463
|
+
}];
|
|
464
|
+
}
|
|
465
|
+
const dimension = fieldUnit === void 0 ? void 0 : unitDimension(fieldUnit);
|
|
466
|
+
if (dimension === void 0) return allUnitGroups();
|
|
467
|
+
return [{
|
|
468
|
+
group: dimension,
|
|
469
|
+
choices: unitsForDimension(dimension).map((value) => ({ value }))
|
|
470
|
+
}];
|
|
471
|
+
}
|
|
345
472
|
//#endregion
|
|
346
|
-
export { DEVICE_TEMPLATE_CATALOGUE, DEVICE_TEMPLATE_CATALOGUE_CATEGORIES, DEVICE_TEMPLATE_CATALOGUE_KINDS, DEVICE_TEMPLATE_CATALOGUE_TEXT, DEVICE_TEMPLATE_PARAM_TYPES, deviceTemplateCallableBounds, deviceTemplateCameraValues, deviceTemplateCatalogueEntrySchema, deviceTemplateCatalogueMarkdown, deviceTemplateCatalogueSentence, deviceTemplateFilterMaxParams, deviceTemplateFilterNames, deviceTemplateParamSchema, deviceTemplateRootVariables, deviceTemplateSignature };
|
|
473
|
+
export { DEVICE_TEMPLATE_CATALOGUE, DEVICE_TEMPLATE_CATALOGUE_CATEGORIES, DEVICE_TEMPLATE_CATALOGUE_KINDS, DEVICE_TEMPLATE_CATALOGUE_TEXT, DEVICE_TEMPLATE_PARAM_TYPES, deviceTemplateCallableBounds, deviceTemplateCameraValues, deviceTemplateCatalogueEntrySchema, deviceTemplateCatalogueMarkdown, deviceTemplateCatalogueSentence, deviceTemplateFilterMaxParams, deviceTemplateFilterNames, deviceTemplateParamChoices, deviceTemplateParamSchema, deviceTemplateParamValuesSchema, deviceTemplateRootVariables, deviceTemplateSignature };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CapabilityHistoryField, CapabilityHistoryItems } from '../capabilities/capability-definition.js';
|
|
1
|
+
import type { CapabilityHistoryField, CapabilityHistoryItems, CapabilityHistoryPrimary } from '../capabilities/capability-definition.js';
|
|
2
2
|
/**
|
|
3
3
|
* Cap history catalog, projected from every `*.cap.ts` `history` block.
|
|
4
4
|
* 46 caps with series (124 series), 38 caps answered `'none'`.
|
|
@@ -11,6 +11,11 @@ export declare const HISTORY_CATALOG: Readonly<Record<string, Readonly<Record<st
|
|
|
11
11
|
* the series key is `cap:<capName>.<path>[].<field>`.
|
|
12
12
|
*/
|
|
13
13
|
export declare const HISTORY_ITEM_CATALOG: Readonly<Record<string, CapabilityHistoryItems>>;
|
|
14
|
+
/**
|
|
15
|
+
* The series a device card trends, per cap (`history.primary` + `history.priority`):
|
|
16
|
+
* 6 caps. The card shows the primary of the enabled cap with the highest priority.
|
|
17
|
+
*/
|
|
18
|
+
export declare const HISTORY_PRIMARY: Readonly<Record<string, CapabilityHistoryPrimary>>;
|
|
14
19
|
/** Caps that declared `history: 'none'`, sorted. */
|
|
15
20
|
export declare const HISTORY_NONE_CAPS: readonly string[];
|
|
16
21
|
/** The series specs of `capName`; empty for a `'none'` cap or an unknown one. */
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The history series key of a cap's declared primary field; `null` when it declares none. */
|
|
2
|
+
export declare function primarySeriesKey(cap: string): string | null;
|
|
3
|
+
export interface PickPrimarySeriesInput {
|
|
4
|
+
/** The caps enabled on the device (its hero layout's bindings). A disabled cap is absent. */
|
|
5
|
+
readonly enabledCaps: readonly string[];
|
|
6
|
+
/** Whether the device has points for a series key. */
|
|
7
|
+
readonly hasData: (key: string) => boolean;
|
|
8
|
+
}
|
|
9
|
+
/** The card series of a device: the data-bearing primary of the highest-priority enabled cap. */
|
|
10
|
+
export declare function pickPrimarySeriesKey(input: PickPrimarySeriesInput): string | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -315,8 +315,8 @@ export { EventCategory, isOwnerOnlyEventCategory, OWNER_ONLY_EVENT_CATEGORIES, p
|
|
|
315
315
|
export * from './enums/index.js';
|
|
316
316
|
export type { CompileResult, EvaluateExpressionSourceResult, ExpressionBinaryOperator, ExpressionBindingSource, ExpressionBuiltin, ExpressionEvalHooks, ExpressionEvalOptions, ExpressionFieldBinding, ExpressionGlobalBinding, ExpressionLiteralBinding, ExpressionLogicalOperator, ExpressionNode, ExpressionNodePath, ExpressionSource, ExpressionSourceInput, ExpressionUnaryOperator, ExpressionValue, CountCallState, RoseCallState, StatefulCallState, StatefulCallInvocation, StatefulExpressionEnvironment, StatefulExpressionMemory, StatefulExpressionBuiltin, Keyword, ParsedExpression, Punctuator, Token, } from './expression/index.js';
|
|
317
317
|
export { DEVICE_TEMPLATE_BUDGET_MS, DEVICE_TEMPLATE_FILTERS, DEVICE_TEMPLATE_MAX_LENGTH, DEVICE_TEMPLATE_MAX_OUTPUT, DEVICE_TEMPLATE_NOW_ALIAS, DEVICE_TEMPLATE_THIS_ALIAS, DEVICE_TEMPLATE_VALUES_CAP, DEVICE_TEMPLATE_UNAVAILABLE, DEVICE_TEMPLATE_REFUSAL_REASONS, DEVICE_TEMPLATE_TRACE_REASONS, DeviceTemplateRefusalSchema, DeviceTemplateRenderSchema, DeviceTemplateSchema, DeviceTemplateThisDeviceSchema, DeviceTemplateTraceEntrySchema, DeviceTemplateValueSchema, resolveTemplateRef, templateCapKey, } from './expression/device-template.js';
|
|
318
|
-
export { DEVICE_TEMPLATE_CATALOGUE, DEVICE_TEMPLATE_CATALOGUE_CATEGORIES, DEVICE_TEMPLATE_CATALOGUE_KINDS, DEVICE_TEMPLATE_CATALOGUE_TEXT, DEVICE_TEMPLATE_PARAM_TYPES, deviceTemplateCallableBounds, deviceTemplateCameraValues, deviceTemplateCatalogueEntrySchema, deviceTemplateCatalogueMarkdown, deviceTemplateCatalogueSentence, deviceTemplateFilterMaxParams, deviceTemplateFilterNames, deviceTemplateParamSchema, deviceTemplateRootVariables, deviceTemplateSignature, } from './device-template-catalogue.js';
|
|
319
|
-
export type { DeviceTemplateCallableBounds, DeviceTemplateCatalogueCategory, DeviceTemplateCatalogueEntry, DeviceTemplateCatalogueKind, DeviceTemplateCatalogueText, DeviceTemplateParam, DeviceTemplateParamType, } from './device-template-catalogue.js';
|
|
318
|
+
export { DEVICE_TEMPLATE_CATALOGUE, DEVICE_TEMPLATE_CATALOGUE_CATEGORIES, DEVICE_TEMPLATE_CATALOGUE_KINDS, DEVICE_TEMPLATE_CATALOGUE_TEXT, DEVICE_TEMPLATE_PARAM_TYPES, deviceTemplateCallableBounds, deviceTemplateCameraValues, deviceTemplateCatalogueEntrySchema, deviceTemplateCatalogueMarkdown, deviceTemplateCatalogueSentence, deviceTemplateFilterMaxParams, deviceTemplateFilterNames, deviceTemplateParamChoices, deviceTemplateParamSchema, deviceTemplateParamValuesSchema, deviceTemplateRootVariables, deviceTemplateSignature, } from './device-template-catalogue.js';
|
|
319
|
+
export type { DeviceTemplateCallableBounds, DeviceTemplateCatalogueCategory, DeviceTemplateCatalogueEntry, DeviceTemplateCatalogueKind, DeviceTemplateCatalogueText, DeviceTemplateParam, DeviceTemplateParamChoice, DeviceTemplateParamChoiceGroup, DeviceTemplateParamType, DeviceTemplateParamValues, } from './device-template-catalogue.js';
|
|
320
320
|
export type { DeviceTemplateFilter, DeviceTemplateRef, DeviceTemplateRefusal, DeviceTemplateRefusalReason, DeviceTemplateRender, DeviceTemplateThisDevice, DeviceTemplateTraceEntry, DeviceTemplateTraceReason, DeviceTemplateView, ResolvedTemplateRef, } from './expression/device-template.js';
|
|
321
321
|
export { compileExpression, compileExpressionSafe, cloneStatefulExpressionMemory, createExpressionScope, createStatefulExpressionMemory, EXPRESSION_BUILTIN_NAMES, EXPRESSION_BUILTINS, EXPRESSION_COMPILE_CACHE_CAPACITY, EXPRESSION_IDENTIFIER_RE, EXPRESSION_INJECTED_NOW, ExpressionBindingSourceSchema, ExpressionEvalError, ExpressionFieldBindingSchema, ExpressionGlobalBindingSchema, ExpressionLiteralBindingSchema, ExpressionParseError, ExpressionSourceSchema, evaluateAst, evaluateCount, disarmRoseMemory, evaluateExpressionSource, evaluateRose, evaluateStatefulExpressionCall, isStatefulBuiltin, MAX_EXPRESSION_AST_NODES, MAX_EXPRESSION_BINDINGS, MAX_EXPRESSION_CALL_ARGS, MAX_EXPRESSION_EVAL_STEPS, MAX_EXPRESSION_SOURCE_LENGTH, parseExpression, RESERVED_BINDING_NAMES, toExpressionValue, tokenize, validateExpressionSource, } from './expression/index.js';
|
|
322
322
|
export type { AddonApi, AppRouter } from './generated/addon-api.js';
|
|
@@ -335,7 +335,9 @@ export { CAP_PROVIDER_KIND_MAP, getCapsByProviderKind, PROVIDER_KIND_CAP_NAMES,
|
|
|
335
335
|
export type { RuntimeStatePolicy } from './generated/runtime-state-durability.js';
|
|
336
336
|
export { isRestoredCap, RESTORED_CAP_NAMES, RUNTIME_STATE_POLICY, runtimeStatePolicyFor, } from './generated/runtime-state-durability.js';
|
|
337
337
|
export { BucketAccumulator, bucketStartOf, type ClosedHistoryBucket, HISTORY_BUCKET_MS, MAX_REQUEUED_BUCKETS_PER_SERIES, } from './history/bucket-accumulator.js';
|
|
338
|
-
export {
|
|
338
|
+
export { pickPrimarySeriesKey, primarySeriesKey } from './history/primary-series.js';
|
|
339
|
+
export type { PickPrimarySeriesInput } from './history/primary-series.js';
|
|
340
|
+
export { HISTORY_CATALOG, HISTORY_ITEM_CATALOG, HISTORY_PRIMARY, HISTORY_NONE_CAPS, historyFieldsFor, } from './generated/history-catalog.js';
|
|
339
341
|
export { CAP_CUSTOMIZE_CATALOG } from './generated/customize-catalog.js';
|
|
340
342
|
export type { CustomizeCatalog, CustomizeCatalogField, CustomizeCatalogSource, CustomizeCatalogTarget, CustomizeCatalogTransform, } from './capabilities/customize-catalog.js';
|
|
341
343
|
export { CAP_RUNTIME_FIELD_UNITS } from './generated/customize-catalog.js';
|