@camstack/types 1.2.420 → 1.2.422
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/dist/addon.js +2 -2
- package/dist/addon.mjs +2 -2
- package/dist/capabilities/composer.cap.d.ts +129 -21
- package/dist/capabilities/core-blocks.cap.d.ts +929 -151
- package/dist/capabilities/index.d.ts +3 -1
- package/dist/capabilities/meter.cap.d.ts +53 -0
- package/dist/capabilities/power-meter.cap.d.ts +1 -1
- package/dist/capabilities/running-state.cap.d.ts +1 -1
- package/dist/client.js +12 -1
- package/dist/client.mjs +12 -1
- package/dist/composition/composition-report.d.ts +45 -0
- package/dist/composition/composition.d.ts +196 -7
- package/dist/composition/helpers/appliance.d.ts +28 -0
- package/dist/composition/helpers/compile-history.d.ts +13 -0
- package/dist/composition/helpers/compile.d.ts +3 -2
- package/dist/composition/helpers/energy.d.ts +8 -0
- package/dist/composition/helpers/history-math.d.ts +39 -0
- package/dist/composition/helpers/history-window.d.ts +71 -0
- package/dist/composition/helpers/index.d.ts +7 -2
- package/dist/composition/helpers/save.d.ts +1 -1
- package/dist/composition/helpers/source-pick.d.ts +2 -0
- package/dist/composition/helpers/spec.d.ts +39 -6
- package/dist/{composition-re1aezX9.js → composition-CPRAP41h.js} +924 -7
- package/dist/{composition-OhpuespA.mjs → composition-CpETZ4HL.mjs} +679 -8
- package/dist/device/appliance-export.d.ts +25 -0
- package/dist/device/cap-vocabulary/entries/sensors.d.ts +1 -1
- package/dist/device/cap-vocabulary/types.d.ts +10 -0
- package/dist/device/device-type.d.ts +8 -2
- package/dist/{err-msg-BXKzRBwg.mjs → err-msg-DIorGYeC.mjs} +7 -1
- package/dist/{err-msg-BhVbr0NX.js → err-msg-U7lLUMNz.js} +7 -1
- package/dist/generated/addon-api.d.ts +14 -0
- package/dist/generated/addon-cap-facts.d.ts +1 -1
- package/dist/generated/cap-status-types.d.ts +3 -1
- package/dist/generated/capability-router-map.d.ts +5 -2
- package/dist/generated/customize-catalog.d.ts +2 -2
- package/dist/generated/device-local-state.d.ts +3 -0
- package/dist/generated/device-proxy.d.ts +3 -0
- package/dist/generated/device-scoped-caps.d.ts +1 -1
- package/dist/generated/history-catalog.d.ts +1 -1
- package/dist/generated/method-access-map.d.ts +1 -1
- package/dist/generated/method-device-selectors.d.ts +1 -1
- package/dist/generated/runtime-state-durability.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1063 -562
- package/dist/index.mjs +1013 -563
- package/dist/node.js +2 -2
- package/dist/node.mjs +2 -2
- package/dist/{sleep-bykKrTgu.mjs → sleep-0sD_LHLI.mjs} +10 -1
- package/dist/{sleep-YJ6FVsUu.js → sleep-CEKGW7A5.js} +10 -1
- package/package.json +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { HistoryTier } from './history-window.js';
|
|
2
|
+
export declare const STATISTIC_STATS: readonly ['min', 'max', 'mean', 'sum', 'count', 'change'];
|
|
3
|
+
export type StatisticStat = (typeof STATISTIC_STATS)[number];
|
|
4
|
+
export declare const SERIES_KINDS: readonly ['gauge', 'counter', 'boolean'];
|
|
5
|
+
export type SeriesKind = (typeof SERIES_KINDS)[number];
|
|
6
|
+
export interface SeriesPoint {
|
|
7
|
+
readonly t: number;
|
|
8
|
+
readonly value: number | null;
|
|
9
|
+
readonly twMean: number | null;
|
|
10
|
+
readonly twMs: number | null;
|
|
11
|
+
readonly min: number | null;
|
|
12
|
+
readonly max: number | null;
|
|
13
|
+
readonly last: number | null;
|
|
14
|
+
readonly delta: number | null;
|
|
15
|
+
}
|
|
16
|
+
export interface SeriesBefore {
|
|
17
|
+
readonly t: number;
|
|
18
|
+
readonly value: number | null;
|
|
19
|
+
}
|
|
20
|
+
export interface SeriesRead {
|
|
21
|
+
readonly kind: SeriesKind;
|
|
22
|
+
readonly tier: HistoryTier;
|
|
23
|
+
readonly from: number;
|
|
24
|
+
readonly to: number;
|
|
25
|
+
readonly before: SeriesBefore | null;
|
|
26
|
+
readonly points: readonly SeriesPoint[];
|
|
27
|
+
readonly truncated: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface HistoryValue {
|
|
30
|
+
/** `hold` keeps the last published number. `null` is a known gap (D393). */
|
|
31
|
+
readonly write: 'number' | 'null' | 'hold';
|
|
32
|
+
readonly value: number | null;
|
|
33
|
+
readonly included: number;
|
|
34
|
+
readonly excluded: number;
|
|
35
|
+
readonly reason: string | null;
|
|
36
|
+
}
|
|
37
|
+
export declare function evaluateStatistic(stat: StatisticStat, read: SeriesRead): HistoryValue;
|
|
38
|
+
export type IntegralScale = 'energy-kwh' | 'per-second';
|
|
39
|
+
export declare function integrateReading(read: SeriesRead, scale: IntegralScale): HistoryValue;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The range a statistics or integral helper asks history for (D944).
|
|
3
|
+
*
|
|
4
|
+
* Calendar edges are the hub's timezone, never UTC midnight: a day is 23, 24
|
|
5
|
+
* or 25 hours across a DST change. A tier is eligible only when its retention
|
|
6
|
+
* is strictly longer than the longest that range can be. Forever qualifies.
|
|
7
|
+
* Equal to a tier's retention is a refusal, not a short answer.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
export declare const MINUTE_MS: number;
|
|
11
|
+
export declare const HOUR_MS: number;
|
|
12
|
+
export declare const DAY_MS: number;
|
|
13
|
+
export declare const ROLLING_SPANS: readonly ['1h', '24h', '2d', '7d', '30d', 'custom'];
|
|
14
|
+
export type RollingSpan = (typeof ROLLING_SPANS)[number];
|
|
15
|
+
export declare const CALENDAR_PERIODS: readonly ['today', 'yesterday', 'this-week', 'this-month'];
|
|
16
|
+
export type CalendarPeriod = (typeof CALENDAR_PERIODS)[number];
|
|
17
|
+
export declare const HISTORY_TIERS: readonly ['raw', '5m', '1h', '1d'];
|
|
18
|
+
export type HistoryTier = (typeof HISTORY_TIERS)[number];
|
|
19
|
+
export declare const RESET_PERIODS: readonly ['never', 'daily', 'weekly', 'monthly'];
|
|
20
|
+
export type ResetPeriod = (typeof RESET_PERIODS)[number];
|
|
21
|
+
export declare const MIN_CUSTOM_MINUTES: number;
|
|
22
|
+
/** Faster than this is not a history query. Rolling windows at most this often. */
|
|
23
|
+
export declare const HISTORY_FAST_MS: number;
|
|
24
|
+
export declare const HISTORY_SLOW_MS: number;
|
|
25
|
+
export interface HistoryRetention {
|
|
26
|
+
readonly rawMs: number;
|
|
27
|
+
readonly fiveMinuteMs: number;
|
|
28
|
+
readonly hourMs: number;
|
|
29
|
+
/** `null` keeps the daily tier forever. */
|
|
30
|
+
readonly dayMs: number | null;
|
|
31
|
+
}
|
|
32
|
+
/** The device-history defaults: raw 7 d, 5 m 30 d, 1 h 365 d, 1 d forever. */
|
|
33
|
+
export declare const DEFAULT_HISTORY_RETENTION: HistoryRetention;
|
|
34
|
+
export type RollingWindow = {
|
|
35
|
+
readonly kind: 'rolling';
|
|
36
|
+
readonly span: RollingSpan;
|
|
37
|
+
readonly customMinutes?: number;
|
|
38
|
+
};
|
|
39
|
+
export declare const RollingWindowSchema: z.ZodType<RollingWindow>;
|
|
40
|
+
export type CalendarWindow = {
|
|
41
|
+
readonly kind: 'calendar';
|
|
42
|
+
readonly period: CalendarPeriod;
|
|
43
|
+
};
|
|
44
|
+
export declare const CalendarWindowSchema: z.ZodType<CalendarWindow>;
|
|
45
|
+
export type StatisticWindow = RollingWindow | CalendarWindow;
|
|
46
|
+
export declare const StatisticWindowSchema: z.ZodType<StatisticWindow>;
|
|
47
|
+
export interface OpenRange {
|
|
48
|
+
readonly from: number;
|
|
49
|
+
readonly to: number;
|
|
50
|
+
}
|
|
51
|
+
export interface HistoryTierReady {
|
|
52
|
+
readonly ok: true;
|
|
53
|
+
readonly tier: HistoryTier;
|
|
54
|
+
readonly maxDurationMs: number;
|
|
55
|
+
}
|
|
56
|
+
export interface HistoryTierRefused {
|
|
57
|
+
readonly ok: false;
|
|
58
|
+
readonly reason: string;
|
|
59
|
+
}
|
|
60
|
+
export type HistoryTierPlan = HistoryTierReady | HistoryTierRefused;
|
|
61
|
+
export declare function rollingDurationMs(window: RollingWindow): number | null;
|
|
62
|
+
/** Longest the window can be. Calendar periods use their full length, not the elapsed part. */
|
|
63
|
+
export declare function maxDurationMs(window: StatisticWindow): number | null;
|
|
64
|
+
export declare function planStatisticTier(window: StatisticWindow, retention: HistoryRetention): HistoryTierPlan;
|
|
65
|
+
export declare function planResetTier(reset: ResetPeriod, retention: HistoryRetention): HistoryTierPlan;
|
|
66
|
+
export declare function openStatistic(window: StatisticWindow, now: number, timeZone: string): OpenRange | null;
|
|
67
|
+
export declare function openReset(reset: ResetPeriod, now: number, timeZone: string): OpenRange | null;
|
|
68
|
+
/** The next hub-local midnight, strictly after `now`. Monday is one of these. */
|
|
69
|
+
export declare function nextLocalMidnight(now: number, timeZone: string): number | null;
|
|
70
|
+
export declare function statisticCadenceMs(window: StatisticWindow): number;
|
|
71
|
+
export declare function integralCadenceMs(tier: HistoryTier): number;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
export { FAN_OUT_CONCURRENCY, LIGHT_SHARED_CAPS, type FanOutCall, type FanOutFailed, type FanOutMember, type FanOutMemberResult, type FanOutOk, type LightSharedCap, activeForReducer, fanOutTargets, reducerForActive, runFanOut, sharedColorModes, sharedLightCaps, } from './actuator.js';
|
|
2
2
|
export { type AggregateCounts, type AggregateEmpty, type AggregateOutcome, type AggregatePublish, type AggregateReadResult, type AggregateUnavailable, type AggregateValue, type EvaluateAggregateInput, evaluateAggregate, } from './aggregate.js';
|
|
3
|
+
export { APPLIANCE_DEFAULTS, APPLIANCE_KINDS, APPLIANCE_TEMPLATE_ID, type ApplianceDefaults, type ApplianceKind, applianceDeviceType, isApplianceKind, sourcePickForAppliance, } from './appliance.js';
|
|
3
4
|
export { type GroupTemplate, type HelperAccept, type HelperCompanion, GROUP_TEMPLATES, groupTemplate, } from './catalog.js';
|
|
4
5
|
export { type HelperCompileResult, type HelperCompiled, type HelperRefused, compileHelper, sameHelperBody, templateDeviceType, } from './compile.js';
|
|
6
|
+
export { declaredSeriesKind, integralDraft, statisticDraft } from './compile-history.js';
|
|
7
|
+
export { KWH_PER_WATT_MS, wattMillisecondsToKwh } from './energy.js';
|
|
8
|
+
export { type HistoryValue, type IntegralScale, type SeriesBefore, type SeriesKind, type SeriesPoint, type SeriesRead, STATISTIC_STATS, SERIES_KINDS, evaluateStatistic, integrateReading, } from './history-math.js';
|
|
9
|
+
export { type CalendarPeriod, type CalendarWindow, type HistoryRetention, type HistoryTier, type HistoryTierPlan, type OpenRange, type ResetPeriod, type RollingSpan, type RollingWindow, type StatisticWindow, CALENDAR_PERIODS, CalendarWindowSchema, DAY_MS, DEFAULT_HISTORY_RETENTION, HISTORY_FAST_MS, HISTORY_SLOW_MS, HISTORY_TIERS, HOUR_MS, MINUTE_MS, MIN_CUSTOM_MINUTES, RESET_PERIODS, ROLLING_SPANS, RollingWindowSchema, StatisticWindowSchema, integralCadenceMs, maxDurationMs, nextLocalMidnight, openReset, openStatistic, planResetTier, planStatisticTier, rollingDurationMs, statisticCadenceMs, } from './history-window.js';
|
|
5
10
|
export { type HelperMemberFact, helperSaveProblems, } from './save.js';
|
|
6
|
-
export { type SourcePick, type SourcePickAccept, type SourcePickHistory, type SourcePickRequest, sourcePickForTemplate, } from './source-pick.js';
|
|
7
|
-
export { ACTIVE_CRITERIA, AGGREGATE_REDUCERS, ActiveCriterionSchema, AggregateReducerSchema, BINARY_AGGREGATES, GROUP_TEMPLATE_IDS, GroupHelperSpecSchema, GroupTemplateIdSchema, HelperMemberSchema, HelperSpecSchema, MAX_HELPER_MEMBERS, NUMERIC_AGGREGATES, type ActiveCriterion, type AggregateReducer, type BinaryAggregate, type GroupHelperSpec, type GroupTemplateId, type HelperMember, type HelperSpec, type NumericAggregate, } from './spec.js';
|
|
11
|
+
export { type SourcePick, type SourcePickAccept, type SourcePickHistory, type SourcePickRequest, sourcePickForHistory, sourcePickForTemplate, } from './source-pick.js';
|
|
12
|
+
export { ACTIVE_CRITERIA, AGGREGATE_REDUCERS, ActiveCriterionSchema, AggregateReducerSchema, BINARY_AGGREGATES, GROUP_TEMPLATE_IDS, ApplianceHelperSpecSchema, GroupHelperSpecSchema, GroupTemplateIdSchema, HelperMemberSchema, HelperSpecSchema, INTEGRAL_OUTPUTS, IntegralHelperSpecSchema, MAX_HELPER_MEMBERS, helperMembers, NUMERIC_AGGREGATES, StatisticHelperSpecSchema, type ActiveCriterion, type AggregateReducer, type BinaryAggregate, type ApplianceHelperSpec, type GroupHelperSpec, type GroupTemplateId, type HelperMember, type HelperSpec, type IntegralHelperSpec, type IntegralOutput, type NumericAggregate, type StatisticHelperSpec, type StatisticStat, } from './spec.js';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Save-time checks a pure compile cannot make: the compiled features must be
|
|
3
3
|
* this spec's, and members that report a quantity must share one (D944 §4).
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import { DeviceType } from '../../device/device-type.js';
|
|
6
6
|
import type { ReadingQuantity } from '../../units/quantity.js';
|
|
7
7
|
import { type Composition } from '../composition.js';
|
|
8
8
|
import type { CompositionProblem } from '../composition-report.js';
|
|
@@ -38,3 +38,5 @@ export interface SourcePick {
|
|
|
38
38
|
}
|
|
39
39
|
/** What the member step asks the selector for this template. */
|
|
40
40
|
export declare function sourcePickForTemplate(template: GroupTemplate): SourcePickRequest;
|
|
41
|
+
/** A statistic or integral reads one field that declares history. */
|
|
42
|
+
export declare function sourcePickForHistory(kind: 'statistic' | 'integral'): SourcePickRequest;
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
* features are a projection; the editor never edits the expression.
|
|
4
4
|
*/
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
+
import { APPLIANCE_TEMPLATE_ID } from './appliance.js';
|
|
7
|
+
import { STATISTIC_STATS } from './history-math.js';
|
|
8
|
+
import { type ResetPeriod, type StatisticWindow } from './history-window.js';
|
|
6
9
|
import { CompositionSourceRefSchema } from '../source-ref.js';
|
|
7
10
|
/** A group may name more members than an expression call (the 16-arg cap). */
|
|
8
11
|
export declare const MAX_HELPER_MEMBERS: number;
|
|
@@ -27,10 +30,7 @@ export declare const HelperMemberSchema: z.ZodObject<{
|
|
|
27
30
|
fieldPath: z.ZodString;
|
|
28
31
|
}>;
|
|
29
32
|
export type HelperMember = z.infer<typeof HelperMemberSchema>;
|
|
30
|
-
/**
|
|
31
|
-
* Phase 1a is groups only. Math, integral and statistics stay off this union
|
|
32
|
-
* until the composer can run them — a control must not save a spec it cannot.
|
|
33
|
-
*/
|
|
33
|
+
/** A group, a statistic, or an integral (D944). The composer runs all three. */
|
|
34
34
|
export declare const GroupHelperSpecSchema: z.ZodObject<{
|
|
35
35
|
kind: z.ZodLiteral<'group'>;
|
|
36
36
|
templateId: typeof GroupTemplateIdSchema;
|
|
@@ -39,5 +39,38 @@ export declare const GroupHelperSpecSchema: z.ZodObject<{
|
|
|
39
39
|
active: z.ZodOptional<typeof ActiveCriterionSchema>;
|
|
40
40
|
}>;
|
|
41
41
|
export type GroupHelperSpec = z.infer<typeof GroupHelperSpecSchema>;
|
|
42
|
-
export declare const
|
|
43
|
-
|
|
42
|
+
export declare const ApplianceHelperSpecSchema: z.ZodObject<{
|
|
43
|
+
kind: z.ZodLiteral<'appliance'>;
|
|
44
|
+
templateId: z.ZodLiteral<typeof APPLIANCE_TEMPLATE_ID>;
|
|
45
|
+
appliance: z.ZodEnum<{
|
|
46
|
+
washer: 'washer';
|
|
47
|
+
dryer: 'dryer';
|
|
48
|
+
dishwasher: 'dishwasher';
|
|
49
|
+
}>;
|
|
50
|
+
thresholdWatts: z.ZodNumber;
|
|
51
|
+
startDwellMs: z.ZodNumber;
|
|
52
|
+
stopDwellMs: z.ZodNumber;
|
|
53
|
+
member: typeof HelperMemberSchema;
|
|
54
|
+
}>;
|
|
55
|
+
export type ApplianceHelperSpec = z.infer<typeof ApplianceHelperSpecSchema>;
|
|
56
|
+
export type StatisticStat = (typeof STATISTIC_STATS)[number];
|
|
57
|
+
export type StatisticHelperSpec = {
|
|
58
|
+
readonly kind: 'statistic';
|
|
59
|
+
readonly stat: StatisticStat;
|
|
60
|
+
readonly window: StatisticWindow;
|
|
61
|
+
readonly source: HelperMember;
|
|
62
|
+
};
|
|
63
|
+
export declare const StatisticHelperSpecSchema: z.ZodType<StatisticHelperSpec>;
|
|
64
|
+
export declare const INTEGRAL_OUTPUTS: readonly ['energy', 'meter'];
|
|
65
|
+
export type IntegralOutput = (typeof INTEGRAL_OUTPUTS)[number];
|
|
66
|
+
export type IntegralHelperSpec = {
|
|
67
|
+
readonly kind: 'integral';
|
|
68
|
+
readonly reset: ResetPeriod;
|
|
69
|
+
readonly output: IntegralOutput;
|
|
70
|
+
readonly source: HelperMember;
|
|
71
|
+
};
|
|
72
|
+
export declare const IntegralHelperSpecSchema: z.ZodType<IntegralHelperSpec>;
|
|
73
|
+
export type HelperSpec = GroupHelperSpec | ApplianceHelperSpec | StatisticHelperSpec | IntegralHelperSpec;
|
|
74
|
+
export declare const HelperSpecSchema: z.ZodType<HelperSpec>;
|
|
75
|
+
/** Every member a helper reads. A group has many; the others have one. */
|
|
76
|
+
export declare function helperMembers(spec: HelperSpec): readonly HelperMember[];
|