@camstack/types 1.2.421 → 1.2.423
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 +1 -1
- package/dist/addon.mjs +1 -1
- package/dist/capabilities/composer.cap.d.ts +129 -57
- package/dist/capabilities/core-blocks.cap.d.ts +936 -410
- package/dist/capabilities/index.d.ts +3 -1
- package/dist/capabilities/meter.cap.d.ts +53 -0
- package/dist/capabilities/notification-rules.cap.d.ts +12 -0
- package/dist/client.js +17 -1
- package/dist/client.mjs +17 -1
- package/dist/composition/composition-report.d.ts +45 -0
- package/dist/composition/composition.d.ts +196 -19
- package/dist/composition/helpers/compile-history.d.ts +13 -0
- package/dist/composition/helpers/compile.d.ts +2 -1
- 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 +6 -2
- package/dist/composition/helpers/source-pick.d.ts +2 -0
- package/dist/composition/helpers/spec.d.ts +23 -10
- package/dist/{composition-B3Hkb6v7.js → composition-CPRAP41h.js} +792 -8
- package/dist/{composition-B2rw5L29.mjs → composition-CpETZ4HL.mjs} +595 -9
- package/dist/device/cap-vocabulary/entries/sensors.d.ts +1 -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/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.js +761 -447
- package/dist/index.mjs +723 -448
- package/dist/node.js +1 -1
- package/dist/node.mjs +1 -1
- 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
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { DeviceType } from '../../device/device-type.js';
|
|
6
6
|
import { type Composition } from '../composition.js';
|
|
7
7
|
import type { CompositionProblem } from '../composition-report.js';
|
|
8
|
+
import { type HistoryRetention } from './history-window.js';
|
|
8
9
|
import { type HelperSpec } from './spec.js';
|
|
9
10
|
export interface HelperCompiled {
|
|
10
11
|
readonly ok: true;
|
|
@@ -16,7 +17,7 @@ export interface HelperRefused {
|
|
|
16
17
|
}
|
|
17
18
|
export type HelperCompileResult = HelperCompiled | HelperRefused;
|
|
18
19
|
/** Compile a helper template to a new-device composition. Refusals are named. */
|
|
19
|
-
export declare function compileHelper(spec: HelperSpec): HelperCompileResult;
|
|
20
|
+
export declare function compileHelper(spec: HelperSpec, retention?: HistoryRetention): HelperCompileResult;
|
|
20
21
|
/** The built body, ignoring `helper`, so a save can demand one writer. */
|
|
21
22
|
export declare function sameHelperBody(stored: Composition, compiled: Composition): boolean;
|
|
22
23
|
export declare function templateDeviceType(spec: HelperSpec): DeviceType | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Watts integrated over time, in kWh (D944).
|
|
3
|
+
*
|
|
4
|
+
* 1 kWh = 1 000 W × 3 600 000 ms. The history energy series uses the same
|
|
5
|
+
* factor (`tw_sum / 3.6e9`), so a chart and an integral helper cannot diverge.
|
|
6
|
+
*/
|
|
7
|
+
export declare const KWH_PER_WATT_MS: number;
|
|
8
|
+
export declare function wattMillisecondsToKwh(wattMilliseconds: number): number;
|
|
@@ -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;
|
|
@@ -3,6 +3,10 @@ export { type AggregateCounts, type AggregateEmpty, type AggregateOutcome, type
|
|
|
3
3
|
export { APPLIANCE_DEFAULTS, APPLIANCE_KINDS, APPLIANCE_TEMPLATE_ID, type ApplianceDefaults, type ApplianceKind, applianceDeviceType, isApplianceKind, sourcePickForAppliance, } from './appliance.js';
|
|
4
4
|
export { type GroupTemplate, type HelperAccept, type HelperCompanion, GROUP_TEMPLATES, groupTemplate, } from './catalog.js';
|
|
5
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';
|
|
6
10
|
export { type HelperMemberFact, helperSaveProblems, } from './save.js';
|
|
7
|
-
export { type SourcePick, type SourcePickAccept, type SourcePickHistory, type SourcePickRequest, sourcePickForTemplate, } from './source-pick.js';
|
|
8
|
-
export { ACTIVE_CRITERIA, AGGREGATE_REDUCERS, ActiveCriterionSchema, AggregateReducerSchema, BINARY_AGGREGATES, GROUP_TEMPLATE_IDS, ApplianceHelperSpecSchema, GroupHelperSpecSchema, GroupTemplateIdSchema, HelperMemberSchema, HelperSpecSchema, MAX_HELPER_MEMBERS, helperMembers, NUMERIC_AGGREGATES, type ActiveCriterion, type AggregateReducer, type BinaryAggregate, type ApplianceHelperSpec, 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';
|
|
@@ -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;
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { z } from 'zod';
|
|
6
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';
|
|
7
9
|
import { CompositionSourceRefSchema } from '../source-ref.js';
|
|
8
10
|
/** A group may name more members than an expression call (the 16-arg cap). */
|
|
9
11
|
export declare const MAX_HELPER_MEMBERS: number;
|
|
@@ -28,10 +30,7 @@ export declare const HelperMemberSchema: z.ZodObject<{
|
|
|
28
30
|
fieldPath: z.ZodString;
|
|
29
31
|
}>;
|
|
30
32
|
export type HelperMember = z.infer<typeof HelperMemberSchema>;
|
|
31
|
-
/**
|
|
32
|
-
* Phase 1a is groups only. Math, integral and statistics stay off this union
|
|
33
|
-
* until the composer can run them — a control must not save a spec it cannot.
|
|
34
|
-
*/
|
|
33
|
+
/** A group, a statistic, or an integral (D944). The composer runs all three. */
|
|
35
34
|
export declare const GroupHelperSpecSchema: z.ZodObject<{
|
|
36
35
|
kind: z.ZodLiteral<'group'>;
|
|
37
36
|
templateId: typeof GroupTemplateIdSchema;
|
|
@@ -54,10 +53,24 @@ export declare const ApplianceHelperSpecSchema: z.ZodObject<{
|
|
|
54
53
|
member: typeof HelperMemberSchema;
|
|
55
54
|
}>;
|
|
56
55
|
export type ApplianceHelperSpec = z.infer<typeof ApplianceHelperSpecSchema>;
|
|
57
|
-
export
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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. */
|
|
63
76
|
export declare function helperMembers(spec: HelperSpec): readonly HelperMember[];
|