@camstack/types 1.2.366 → 1.2.368
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 +12 -2
- package/dist/addon.mjs +12 -2
- package/dist/capabilities/device-history.cap.d.ts +444 -0
- package/dist/capabilities/index.d.ts +3 -1
- package/dist/client.js +15 -0
- package/dist/client.mjs +15 -0
- package/dist/generated/addon-api.d.ts +78 -0
- package/dist/generated/cap-input-defaults.d.ts +1 -1
- package/dist/generated/capability-router-map.d.ts +5 -2
- package/dist/generated/device-proxy.d.ts +2 -0
- package/dist/generated/method-access-map.d.ts +1 -1
- package/dist/generated/method-device-selectors.d.ts +2 -2
- package/dist/generated/system-proxy.d.ts +2 -0
- package/dist/history/bucket-accumulator.d.ts +53 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +449 -1
- package/dist/index.mjs +440 -2
- package/dist/{sleep-DxJdzHni.mjs → sleep--g-h2_c_.mjs} +7 -0
- package/dist/{sleep-NZlEFYGX.js → sleep-CXlc9YJ5.js} +7 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_sleep = require("./sleep-
|
|
2
|
+
const require_sleep = require("./sleep-CXlc9YJ5.js");
|
|
3
3
|
const require_event_category = require("./event-category-T43rdQWR.js");
|
|
4
4
|
const require_composition = require("./composition-DCYnv4I6.js");
|
|
5
5
|
const require_node_color = require("./node-color.js");
|
|
@@ -13877,6 +13877,243 @@ var keychainCapability = {
|
|
|
13877
13877
|
}
|
|
13878
13878
|
};
|
|
13879
13879
|
//#endregion
|
|
13880
|
+
//#region src/capabilities/device-history.cap.ts
|
|
13881
|
+
/**
|
|
13882
|
+
* device-history — the ONE mechanism for numeric history (D850).
|
|
13883
|
+
*
|
|
13884
|
+
* A device value is recorded because its capability says so (the `history`
|
|
13885
|
+
* block of a `*.cap.ts`, captured hub-side from `DeviceStateChanged`); any
|
|
13886
|
+
* other series is DECLARED by the addon that produces it and fed with points
|
|
13887
|
+
* (`record`) or closed five-minute buckets (`recordBuckets`). Rollups 5m / 1h /
|
|
13888
|
+
* 1d are computed here and nowhere else. Storage is `history.db` (D851).
|
|
13889
|
+
*
|
|
13890
|
+
* Who the PRODUCER is: `declareSeries`, `record` and `recordBuckets` are owner
|
|
13891
|
+
* checked against the `callerAddonId` the transport stamps into a call that
|
|
13892
|
+
* crossed a process (never in an input schema, so a session cannot supply it).
|
|
13893
|
+
* A call with no stamp is refused `not-owner`. The methods are `admin` so a
|
|
13894
|
+
* non-admin session never reaches them; an addon's `ctx.api` call bypasses the
|
|
13895
|
+
* tier by design.
|
|
13896
|
+
*/
|
|
13897
|
+
/** Whose history: a real device, or a cluster node (load, memory). */
|
|
13898
|
+
var DeviceHistorySubjectSchema = zod.z.discriminatedUnion("kind", [zod.z.object({
|
|
13899
|
+
kind: zod.z.literal("device"),
|
|
13900
|
+
deviceId: zod.z.number().int()
|
|
13901
|
+
}), zod.z.object({
|
|
13902
|
+
kind: zod.z.literal("node"),
|
|
13903
|
+
nodeId: zod.z.string().min(1)
|
|
13904
|
+
})]);
|
|
13905
|
+
var DeviceHistoryKindSchema = zod.z.enum([
|
|
13906
|
+
"gauge",
|
|
13907
|
+
"counter",
|
|
13908
|
+
"boolean"
|
|
13909
|
+
]);
|
|
13910
|
+
var DeviceHistoryResolutionSchema = zod.z.enum([
|
|
13911
|
+
"raw",
|
|
13912
|
+
"5m",
|
|
13913
|
+
"1h",
|
|
13914
|
+
"1d"
|
|
13915
|
+
]);
|
|
13916
|
+
/** Why a producer's point or bucket was not stored. Counted, never silent (D391). */
|
|
13917
|
+
var DeviceHistoryRefusalReasonSchema = zod.z.enum([
|
|
13918
|
+
"undeclared",
|
|
13919
|
+
"not-owner",
|
|
13920
|
+
"opted-out",
|
|
13921
|
+
"not-a-real-device",
|
|
13922
|
+
"rate",
|
|
13923
|
+
"ingest-mismatch",
|
|
13924
|
+
"out-of-range"
|
|
13925
|
+
]);
|
|
13926
|
+
var RefusalSchema = zod.z.object({
|
|
13927
|
+
key: zod.z.string(),
|
|
13928
|
+
reason: DeviceHistoryRefusalReasonSchema,
|
|
13929
|
+
count: zod.z.number().int()
|
|
13930
|
+
});
|
|
13931
|
+
var IngestResultSchema = zod.z.object({
|
|
13932
|
+
accepted: zod.z.number().int(),
|
|
13933
|
+
refused: zod.z.array(RefusalSchema).readonly()
|
|
13934
|
+
});
|
|
13935
|
+
var SeriesInfoSchema = zod.z.object({
|
|
13936
|
+
key: zod.z.string(),
|
|
13937
|
+
scope: zod.z.string(),
|
|
13938
|
+
kind: DeviceHistoryKindSchema,
|
|
13939
|
+
/** `null` is unknown (a `unitFrom` series whose device does not state a unit right now), never a guess. */
|
|
13940
|
+
unit: zod.z.string().nullable(),
|
|
13941
|
+
displayName: zod.z.string(),
|
|
13942
|
+
source: zod.z.enum(["cap", "addon"]),
|
|
13943
|
+
firstTs: zod.z.number(),
|
|
13944
|
+
lastTs: zod.z.number()
|
|
13945
|
+
});
|
|
13946
|
+
var QueryPointSchema = zod.z.object({
|
|
13947
|
+
/** Raw: the point's time. Rollup: the bucket start. */
|
|
13948
|
+
t: zod.z.number(),
|
|
13949
|
+
samples: zod.z.number().int(),
|
|
13950
|
+
/** `sum / samples`. */
|
|
13951
|
+
mean: zod.z.number().nullable(),
|
|
13952
|
+
/** Time-weighted mean (`tw_sum / tw_ms`); `null` for bucket-ingested series. For a boolean: the fraction of time true. */
|
|
13953
|
+
twMean: zod.z.number().nullable(),
|
|
13954
|
+
min: zod.z.number(),
|
|
13955
|
+
max: zod.z.number(),
|
|
13956
|
+
/** `null` is unknown, never zero (D393). */
|
|
13957
|
+
last: zod.z.number().nullable()
|
|
13958
|
+
});
|
|
13959
|
+
var QuerySeriesSchema = zod.z.object({
|
|
13960
|
+
scope: zod.z.string(),
|
|
13961
|
+
/** The last point STRICTLY BEFORE `from` in the chosen tier, so a step chart can start at the held value. */
|
|
13962
|
+
before: zod.z.object({
|
|
13963
|
+
t: zod.z.number(),
|
|
13964
|
+
value: zod.z.number().nullable()
|
|
13965
|
+
}).nullable(),
|
|
13966
|
+
points: zod.z.array(QueryPointSchema).readonly()
|
|
13967
|
+
});
|
|
13968
|
+
/** The window part of a query, shared by the device and node forms. */
|
|
13969
|
+
var QueryWindowShape = {
|
|
13970
|
+
key: zod.z.string(),
|
|
13971
|
+
scope: zod.z.string().optional(),
|
|
13972
|
+
from: zod.z.number(),
|
|
13973
|
+
to: zod.z.number(),
|
|
13974
|
+
resolution: zod.z.union([DeviceHistoryResolutionSchema, zod.z.literal("auto")]).default("auto"),
|
|
13975
|
+
maxPoints: zod.z.number().int().positive().max(5e3).default(1e3)
|
|
13976
|
+
};
|
|
13977
|
+
var QueryResultSchema = zod.z.object({
|
|
13978
|
+
resolution: DeviceHistoryResolutionSchema,
|
|
13979
|
+
series: zod.z.array(QuerySeriesSchema).readonly(),
|
|
13980
|
+
truncated: zod.z.boolean()
|
|
13981
|
+
});
|
|
13982
|
+
var TierStatusSchema = zod.z.object({
|
|
13983
|
+
tier: DeviceHistoryResolutionSchema,
|
|
13984
|
+
/** `null` until the first background count answered. */
|
|
13985
|
+
rows: zod.z.number().int().nullable(),
|
|
13986
|
+
/** `rows` times a fixed per-row estimate — approximate, labelled so. */
|
|
13987
|
+
approxBytes: zod.z.number().nullable(),
|
|
13988
|
+
countedAt: zod.z.number().nullable()
|
|
13989
|
+
});
|
|
13990
|
+
/** Operator/diagnostic view: rows per tier, last runs, refusals and drops since boot. */
|
|
13991
|
+
var DeviceHistoryStatusSchema = zod.z.object({
|
|
13992
|
+
startedAt: zod.z.number(),
|
|
13993
|
+
/** The store is declared, series loaded and the first reconcile has answered. */
|
|
13994
|
+
ready: zod.z.boolean(),
|
|
13995
|
+
series: zod.z.number().int(),
|
|
13996
|
+
metrics: zod.z.number().int(),
|
|
13997
|
+
optedOutDevices: zod.z.number().int(),
|
|
13998
|
+
tiers: zod.z.array(TierStatusSchema).readonly(),
|
|
13999
|
+
capture: zod.z.object({
|
|
14000
|
+
eventsSeen: zod.z.number().int(),
|
|
14001
|
+
pointsEmitted: zod.z.number().int(),
|
|
14002
|
+
pointsWritten: zod.z.number().int(),
|
|
14003
|
+
pointsDropped: zod.z.number().int(),
|
|
14004
|
+
bufferDepth: zod.z.number().int(),
|
|
14005
|
+
trailingEmitted: zod.z.number().int(),
|
|
14006
|
+
reconciledPoints: zod.z.number().int(),
|
|
14007
|
+
reconcileRuns: zod.z.number().int(),
|
|
14008
|
+
reconcileFailures: zod.z.number().int(),
|
|
14009
|
+
lastReconcileAt: zod.z.number().nullable(),
|
|
14010
|
+
lastFlushAt: zod.z.number().nullable(),
|
|
14011
|
+
flushFailures: zod.z.number().int(),
|
|
14012
|
+
skipped: zod.z.record(zod.z.string(), zod.z.number().int())
|
|
14013
|
+
}),
|
|
14014
|
+
ingest: zod.z.object({
|
|
14015
|
+
accepted: zod.z.number().int(),
|
|
14016
|
+
refused: zod.z.record(zod.z.string(), zod.z.number().int())
|
|
14017
|
+
}),
|
|
14018
|
+
rollup: zod.z.object({
|
|
14019
|
+
last5mAt: zod.z.number().nullable(),
|
|
14020
|
+
last1hAt: zod.z.number().nullable(),
|
|
14021
|
+
last1dAt: zod.z.number().nullable(),
|
|
14022
|
+
errors: zod.z.number().int(),
|
|
14023
|
+
dirty5m: zod.z.number().int(),
|
|
14024
|
+
dirty1h: zod.z.number().int(),
|
|
14025
|
+
dirty1d: zod.z.number().int()
|
|
14026
|
+
}),
|
|
14027
|
+
retention: zod.z.object({
|
|
14028
|
+
lastRunAt: zod.z.number().nullable(),
|
|
14029
|
+
deleted: zod.z.record(zod.z.string(), zod.z.number().int()),
|
|
14030
|
+
purgedSeries: zod.z.number().int()
|
|
14031
|
+
}),
|
|
14032
|
+
directory: zod.z.object({
|
|
14033
|
+
devices: zod.z.number().int(),
|
|
14034
|
+
lastRefreshAt: zod.z.number().nullable()
|
|
14035
|
+
})
|
|
14036
|
+
});
|
|
14037
|
+
var deviceHistoryCapability = {
|
|
14038
|
+
name: "device-history",
|
|
14039
|
+
scope: "system",
|
|
14040
|
+
mode: "singleton",
|
|
14041
|
+
methods: {
|
|
14042
|
+
/**
|
|
14043
|
+
* The series a DEVICE has, and their span. `deviceId` is a flat top-level field
|
|
14044
|
+
* on purpose: the generated device selector (and so the scope gate) only sees
|
|
14045
|
+
* top-level ids, and a nested `subject.deviceId` would let a principal limited
|
|
14046
|
+
* to one device read another's history. Node series are the admin-only
|
|
14047
|
+
* `listNodeSeries` / `queryNode`.
|
|
14048
|
+
*/
|
|
14049
|
+
listSeries: require_sleep.method(zod.z.object({ deviceId: zod.z.number().int() }), zod.z.array(SeriesInfoSchema).readonly()),
|
|
14050
|
+
listNodeSeries: require_sleep.method(zod.z.object({ nodeId: zod.z.string().min(1) }), zod.z.array(SeriesInfoSchema).readonly(), { auth: "admin" }),
|
|
14051
|
+
/**
|
|
14052
|
+
* One series (or every scope of it) at one resolution. `auto` picks the
|
|
14053
|
+
* finest tier whose retention covers `from` and whose point count fits
|
|
14054
|
+
* `maxPoints`; when even the coarsest tier does not fit, the newest
|
|
14055
|
+
* `maxPoints` points are returned and `truncated` is true.
|
|
14056
|
+
*/
|
|
14057
|
+
query: require_sleep.method(zod.z.object({
|
|
14058
|
+
deviceId: zod.z.number().int(),
|
|
14059
|
+
...QueryWindowShape
|
|
14060
|
+
}), QueryResultSchema),
|
|
14061
|
+
queryNode: require_sleep.method(zod.z.object({
|
|
14062
|
+
nodeId: zod.z.string().min(1),
|
|
14063
|
+
...QueryWindowShape
|
|
14064
|
+
}), QueryResultSchema, { auth: "admin" }),
|
|
14065
|
+
/** Producer: declare (idempotent) a series key this addon owns: `addon:<callerAddonId>/<name>`. */
|
|
14066
|
+
declareSeries: require_sleep.method(zod.z.object({
|
|
14067
|
+
name: zod.z.string().regex(/^[a-z0-9-]+$/),
|
|
14068
|
+
subjectKind: zod.z.enum(["device", "node"]),
|
|
14069
|
+
kind: DeviceHistoryKindSchema,
|
|
14070
|
+
unit: zod.z.string().optional(),
|
|
14071
|
+
displayName: zod.z.string().min(1),
|
|
14072
|
+
ingest: zod.z.enum(["points", "buckets"])
|
|
14073
|
+
}), zod.z.object({ key: zod.z.string() }), {
|
|
14074
|
+
kind: "mutation",
|
|
14075
|
+
auth: "admin"
|
|
14076
|
+
}),
|
|
14077
|
+
/** Producer: points. Low rate: at most one per 10 s per series, sustained. */
|
|
14078
|
+
record: require_sleep.method(zod.z.object({ points: zod.z.array(zod.z.object({
|
|
14079
|
+
key: zod.z.string(),
|
|
14080
|
+
subject: DeviceHistorySubjectSchema,
|
|
14081
|
+
scope: zod.z.string().default(""),
|
|
14082
|
+
ts: zod.z.number(),
|
|
14083
|
+
value: zod.z.number()
|
|
14084
|
+
})).max(5e3) }), IngestResultSchema, {
|
|
14085
|
+
kind: "mutation",
|
|
14086
|
+
auth: "admin"
|
|
14087
|
+
}),
|
|
14088
|
+
/** Producer: CLOSED five-minute buckets. Idempotent upsert keyed (series, bucketStart). */
|
|
14089
|
+
recordBuckets: require_sleep.method(zod.z.object({ buckets: zod.z.array(zod.z.object({
|
|
14090
|
+
key: zod.z.string(),
|
|
14091
|
+
subject: DeviceHistorySubjectSchema,
|
|
14092
|
+
scope: zod.z.string().default(""),
|
|
14093
|
+
bucketStart: zod.z.number(),
|
|
14094
|
+
samples: zod.z.number().int().positive(),
|
|
14095
|
+
sum: zod.z.number(),
|
|
14096
|
+
min: zod.z.number(),
|
|
14097
|
+
max: zod.z.number(),
|
|
14098
|
+
last: zod.z.number().nullable(),
|
|
14099
|
+
lastTs: zod.z.number().nullable()
|
|
14100
|
+
})).max(5e3) }), IngestResultSchema, {
|
|
14101
|
+
kind: "mutation",
|
|
14102
|
+
auth: "admin"
|
|
14103
|
+
}),
|
|
14104
|
+
/** Per-device opt-out. This addon IS the authority: the switch stores nothing elsewhere (D62). */
|
|
14105
|
+
getDeviceEnabled: require_sleep.method(zod.z.object({ deviceId: zod.z.number().int() }), zod.z.object({ enabled: zod.z.boolean() })),
|
|
14106
|
+
setDeviceEnabled: require_sleep.method(zod.z.object({
|
|
14107
|
+
deviceId: zod.z.number().int(),
|
|
14108
|
+
enabled: zod.z.boolean()
|
|
14109
|
+
}), zod.z.object({ enabled: zod.z.boolean() }), {
|
|
14110
|
+
kind: "mutation",
|
|
14111
|
+
auth: "admin"
|
|
14112
|
+
}),
|
|
14113
|
+
getStatus: require_sleep.method(zod.z.object({}), DeviceHistoryStatusSchema, { auth: "admin" })
|
|
14114
|
+
}
|
|
14115
|
+
};
|
|
14116
|
+
//#endregion
|
|
13880
14117
|
//#region src/capabilities/device-credentials.cap.ts
|
|
13881
14118
|
var DeviceCaStatusSchema = zod.z.discriminatedUnion("state", [
|
|
13882
14119
|
zod.z.object({ state: zod.z.literal("absent") }),
|
|
@@ -77465,6 +77702,66 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
77465
77702
|
addonId: null,
|
|
77466
77703
|
access: "create"
|
|
77467
77704
|
},
|
|
77705
|
+
"deviceHistory.declareSeries": {
|
|
77706
|
+
capName: "device-history",
|
|
77707
|
+
capScope: "system",
|
|
77708
|
+
addonId: null,
|
|
77709
|
+
access: "create"
|
|
77710
|
+
},
|
|
77711
|
+
"deviceHistory.getDeviceEnabled": {
|
|
77712
|
+
capName: "device-history",
|
|
77713
|
+
capScope: "system",
|
|
77714
|
+
addonId: null,
|
|
77715
|
+
access: "view"
|
|
77716
|
+
},
|
|
77717
|
+
"deviceHistory.getStatus": {
|
|
77718
|
+
capName: "device-history",
|
|
77719
|
+
capScope: "system",
|
|
77720
|
+
addonId: null,
|
|
77721
|
+
access: "view"
|
|
77722
|
+
},
|
|
77723
|
+
"deviceHistory.listNodeSeries": {
|
|
77724
|
+
capName: "device-history",
|
|
77725
|
+
capScope: "system",
|
|
77726
|
+
addonId: null,
|
|
77727
|
+
access: "view"
|
|
77728
|
+
},
|
|
77729
|
+
"deviceHistory.listSeries": {
|
|
77730
|
+
capName: "device-history",
|
|
77731
|
+
capScope: "system",
|
|
77732
|
+
addonId: null,
|
|
77733
|
+
access: "view"
|
|
77734
|
+
},
|
|
77735
|
+
"deviceHistory.query": {
|
|
77736
|
+
capName: "device-history",
|
|
77737
|
+
capScope: "system",
|
|
77738
|
+
addonId: null,
|
|
77739
|
+
access: "view"
|
|
77740
|
+
},
|
|
77741
|
+
"deviceHistory.queryNode": {
|
|
77742
|
+
capName: "device-history",
|
|
77743
|
+
capScope: "system",
|
|
77744
|
+
addonId: null,
|
|
77745
|
+
access: "view"
|
|
77746
|
+
},
|
|
77747
|
+
"deviceHistory.record": {
|
|
77748
|
+
capName: "device-history",
|
|
77749
|
+
capScope: "system",
|
|
77750
|
+
addonId: null,
|
|
77751
|
+
access: "create"
|
|
77752
|
+
},
|
|
77753
|
+
"deviceHistory.recordBuckets": {
|
|
77754
|
+
capName: "device-history",
|
|
77755
|
+
capScope: "system",
|
|
77756
|
+
addonId: null,
|
|
77757
|
+
access: "create"
|
|
77758
|
+
},
|
|
77759
|
+
"deviceHistory.setDeviceEnabled": {
|
|
77760
|
+
capName: "device-history",
|
|
77761
|
+
capScope: "system",
|
|
77762
|
+
addonId: null,
|
|
77763
|
+
access: "create"
|
|
77764
|
+
},
|
|
77468
77765
|
"deviceManager.addLocation": {
|
|
77469
77766
|
capName: "device-manager",
|
|
77470
77767
|
capScope: "system",
|
|
@@ -83846,6 +84143,7 @@ var KNOWN_CAP_NAMES = [
|
|
|
83846
84143
|
"device-discovery",
|
|
83847
84144
|
"device-export",
|
|
83848
84145
|
"device-extension",
|
|
84146
|
+
"device-history",
|
|
83849
84147
|
"device-manager",
|
|
83850
84148
|
"device-ops",
|
|
83851
84149
|
"device-provider",
|
|
@@ -84084,6 +84382,7 @@ var SYSTEM_CAP_NAMES = [
|
|
|
84084
84382
|
"device-adoption",
|
|
84085
84383
|
"device-credentials",
|
|
84086
84384
|
"device-export",
|
|
84385
|
+
"device-history",
|
|
84087
84386
|
"device-manager",
|
|
84088
84387
|
"device-provider",
|
|
84089
84388
|
"device-state",
|
|
@@ -86114,6 +86413,7 @@ var CAPABILITY_NAMES = {
|
|
|
86114
86413
|
deviceDiscovery: "device-discovery",
|
|
86115
86414
|
deviceExport: "device-export",
|
|
86116
86415
|
deviceExtension: "device-extension",
|
|
86416
|
+
deviceHistory: "device-history",
|
|
86117
86417
|
deviceManager: "device-manager",
|
|
86118
86418
|
deviceOps: "device-ops",
|
|
86119
86419
|
deviceProvider: "device-provider",
|
|
@@ -86451,6 +86751,10 @@ var CAPABILITY_ROUTER_KEYS = [
|
|
|
86451
86751
|
key: "deviceExtension",
|
|
86452
86752
|
name: "device-extension"
|
|
86453
86753
|
},
|
|
86754
|
+
{
|
|
86755
|
+
key: "deviceHistory",
|
|
86756
|
+
name: "device-history"
|
|
86757
|
+
},
|
|
86454
86758
|
{
|
|
86455
86759
|
key: "deviceManager",
|
|
86456
86760
|
name: "device-manager"
|
|
@@ -86988,6 +87292,7 @@ var ALL_CAPABILITY_DEFINITIONS = [
|
|
|
86988
87292
|
deviceDiscoveryCapability,
|
|
86989
87293
|
deviceExportCapability,
|
|
86990
87294
|
deviceExtensionCapability,
|
|
87295
|
+
deviceHistoryCapability,
|
|
86991
87296
|
deviceManagerCapability,
|
|
86992
87297
|
require_sleep.deviceOpsCapability,
|
|
86993
87298
|
deviceProviderCapability,
|
|
@@ -87573,6 +87878,26 @@ var METHOD_DEVICE_SELECTORS = Object.freeze({
|
|
|
87573
87878
|
form: "single",
|
|
87574
87879
|
optional: false
|
|
87575
87880
|
}],
|
|
87881
|
+
"deviceHistory.getDeviceEnabled": [{
|
|
87882
|
+
name: "deviceId",
|
|
87883
|
+
form: "single",
|
|
87884
|
+
optional: false
|
|
87885
|
+
}],
|
|
87886
|
+
"deviceHistory.listSeries": [{
|
|
87887
|
+
name: "deviceId",
|
|
87888
|
+
form: "single",
|
|
87889
|
+
optional: false
|
|
87890
|
+
}],
|
|
87891
|
+
"deviceHistory.query": [{
|
|
87892
|
+
name: "deviceId",
|
|
87893
|
+
form: "single",
|
|
87894
|
+
optional: false
|
|
87895
|
+
}],
|
|
87896
|
+
"deviceHistory.setDeviceEnabled": [{
|
|
87897
|
+
name: "deviceId",
|
|
87898
|
+
form: "single",
|
|
87899
|
+
optional: false
|
|
87900
|
+
}],
|
|
87576
87901
|
"deviceManager.adoptionRelease": [{
|
|
87577
87902
|
name: "camDeviceId",
|
|
87578
87903
|
form: "single",
|
|
@@ -89755,6 +90080,10 @@ var SYSTEM_SCOPE_DEVICE_METHODS = [
|
|
|
89755
90080
|
"deviceExport.applyDeviceSettingsPatch",
|
|
89756
90081
|
"deviceExport.getDeviceLiveContribution",
|
|
89757
90082
|
"deviceExport.getDeviceSettingsContribution",
|
|
90083
|
+
"deviceHistory.getDeviceEnabled",
|
|
90084
|
+
"deviceHistory.listSeries",
|
|
90085
|
+
"deviceHistory.query",
|
|
90086
|
+
"deviceHistory.setDeviceEnabled",
|
|
89758
90087
|
"deviceManager.adoptionRelease",
|
|
89759
90088
|
"deviceManager.adoptionResync",
|
|
89760
90089
|
"deviceManager.applyInitialMeta",
|
|
@@ -90289,6 +90618,107 @@ var RESTORED_CAP_NAMES = [
|
|
|
90289
90618
|
"zones"
|
|
90290
90619
|
];
|
|
90291
90620
|
//#endregion
|
|
90621
|
+
//#region src/history/bucket-accumulator.ts
|
|
90622
|
+
/** Width of a bucket the history store accepts. */
|
|
90623
|
+
var HISTORY_BUCKET_MS = 5 * 6e4;
|
|
90624
|
+
/** One hour of failed deliveries per series is retried; older buckets are dropped. */
|
|
90625
|
+
var MAX_REQUEUED_BUCKETS_PER_SERIES = 12;
|
|
90626
|
+
function bucketStartOf(at) {
|
|
90627
|
+
return Math.floor(at / HISTORY_BUCKET_MS) * HISTORY_BUCKET_MS;
|
|
90628
|
+
}
|
|
90629
|
+
function subjectId(subject) {
|
|
90630
|
+
return subject.kind === "device" ? `d:${subject.deviceId}` : `n:${subject.nodeId}`;
|
|
90631
|
+
}
|
|
90632
|
+
function seriesIdentity(key, subject, scope) {
|
|
90633
|
+
return `${key}\u0000${subjectId(subject)}\u0000${scope}`;
|
|
90634
|
+
}
|
|
90635
|
+
function toClosed(b) {
|
|
90636
|
+
return {
|
|
90637
|
+
key: b.key,
|
|
90638
|
+
subject: b.subject,
|
|
90639
|
+
scope: b.scope,
|
|
90640
|
+
bucketStart: b.bucketStart,
|
|
90641
|
+
samples: b.samples,
|
|
90642
|
+
sum: b.sum,
|
|
90643
|
+
min: b.min,
|
|
90644
|
+
max: b.max,
|
|
90645
|
+
last: b.last,
|
|
90646
|
+
lastTs: b.lastTs
|
|
90647
|
+
};
|
|
90648
|
+
}
|
|
90649
|
+
var BucketAccumulator = class {
|
|
90650
|
+
open = /* @__PURE__ */ new Map();
|
|
90651
|
+
requeued = /* @__PURE__ */ new Map();
|
|
90652
|
+
/** Add one observation. A non-finite value or timestamp is ignored (never counted as 0). */
|
|
90653
|
+
note(key, subject, scope, value, at) {
|
|
90654
|
+
if (!Number.isFinite(value) || !Number.isFinite(at)) return;
|
|
90655
|
+
const bucketStart = bucketStartOf(at);
|
|
90656
|
+
const id = `${seriesIdentity(key, subject, scope)}\u0000${bucketStart}`;
|
|
90657
|
+
const existing = this.open.get(id);
|
|
90658
|
+
if (existing === void 0) {
|
|
90659
|
+
this.open.set(id, {
|
|
90660
|
+
key,
|
|
90661
|
+
subject,
|
|
90662
|
+
scope,
|
|
90663
|
+
bucketStart,
|
|
90664
|
+
samples: 1,
|
|
90665
|
+
sum: value,
|
|
90666
|
+
min: value,
|
|
90667
|
+
max: value,
|
|
90668
|
+
last: value,
|
|
90669
|
+
lastTs: at
|
|
90670
|
+
});
|
|
90671
|
+
return;
|
|
90672
|
+
}
|
|
90673
|
+
existing.samples += 1;
|
|
90674
|
+
existing.sum += value;
|
|
90675
|
+
if (value < existing.min) existing.min = value;
|
|
90676
|
+
if (value > existing.max) existing.max = value;
|
|
90677
|
+
if (at >= existing.lastTs) {
|
|
90678
|
+
existing.last = value;
|
|
90679
|
+
existing.lastTs = at;
|
|
90680
|
+
}
|
|
90681
|
+
}
|
|
90682
|
+
/**
|
|
90683
|
+
* Buckets whose window ended at or before `now`, oldest first, requeued ones
|
|
90684
|
+
* included. They leave the accumulator: delivery is the caller's.
|
|
90685
|
+
*/
|
|
90686
|
+
takeClosed(now) {
|
|
90687
|
+
const out = [];
|
|
90688
|
+
for (const [id, bucket] of this.open) if (bucket.bucketStart + 3e5 <= now) {
|
|
90689
|
+
out.push(toClosed(bucket));
|
|
90690
|
+
this.open.delete(id);
|
|
90691
|
+
}
|
|
90692
|
+
for (const list of this.requeued.values()) out.push(...list);
|
|
90693
|
+
this.requeued.clear();
|
|
90694
|
+
return out.toSorted((a, b) => a.bucketStart - b.bucketStart);
|
|
90695
|
+
}
|
|
90696
|
+
/**
|
|
90697
|
+
* Put undelivered buckets back for the next `takeClosed`. Keeps the newest
|
|
90698
|
+
* {@link MAX_REQUEUED_BUCKETS_PER_SERIES} per series and returns the buckets
|
|
90699
|
+
* it dropped (empty when none).
|
|
90700
|
+
*/
|
|
90701
|
+
requeue(buckets) {
|
|
90702
|
+
const dropped = [];
|
|
90703
|
+
for (const bucket of buckets) {
|
|
90704
|
+
const id = seriesIdentity(bucket.key, bucket.subject, bucket.scope);
|
|
90705
|
+
const list = [...this.requeued.get(id) ?? [], bucket].toSorted((a, b) => a.bucketStart - b.bucketStart);
|
|
90706
|
+
while (list.length > 12) {
|
|
90707
|
+
const oldest = list.shift();
|
|
90708
|
+
if (oldest !== void 0) dropped.push(oldest);
|
|
90709
|
+
}
|
|
90710
|
+
this.requeued.set(id, list);
|
|
90711
|
+
}
|
|
90712
|
+
return dropped;
|
|
90713
|
+
}
|
|
90714
|
+
/** Buckets currently held (open plus requeued) — for a gauge in the producer's own status. */
|
|
90715
|
+
pendingBucketCount() {
|
|
90716
|
+
let n = this.open.size;
|
|
90717
|
+
for (const list of this.requeued.values()) n += list.length;
|
|
90718
|
+
return n;
|
|
90719
|
+
}
|
|
90720
|
+
};
|
|
90721
|
+
//#endregion
|
|
90292
90722
|
//#region src/generated/history-catalog.ts
|
|
90293
90723
|
/**
|
|
90294
90724
|
* Cap history catalog, projected from every `*.cap.ts` `history` block.
|
|
@@ -90878,6 +91308,14 @@ function createSystemProxy(api) {
|
|
|
90878
91308
|
exposeDevice: (input) => dispatch("deviceExport", "exposeDevice", "mutation", input),
|
|
90879
91309
|
unexposeDevice: (input) => dispatch("deviceExport", "unexposeDevice", "mutation", input)
|
|
90880
91310
|
},
|
|
91311
|
+
deviceHistory: {
|
|
91312
|
+
listNodeSeries: (input) => dispatch("deviceHistory", "listNodeSeries", "query", input),
|
|
91313
|
+
queryNode: (input) => dispatch("deviceHistory", "queryNode", "query", input),
|
|
91314
|
+
declareSeries: (input) => dispatch("deviceHistory", "declareSeries", "mutation", input),
|
|
91315
|
+
record: (input) => dispatch("deviceHistory", "record", "mutation", input),
|
|
91316
|
+
recordBuckets: (input) => dispatch("deviceHistory", "recordBuckets", "mutation", input),
|
|
91317
|
+
getStatus: (input) => dispatch("deviceHistory", "getStatus", "query", input)
|
|
91318
|
+
},
|
|
90881
91319
|
deviceManager: {
|
|
90882
91320
|
allocateDeviceId: (input) => dispatch("deviceManager", "allocateDeviceId", "mutation", input),
|
|
90883
91321
|
migrateDevice: (input) => dispatch("deviceManager", "migrateDevice", "mutation", input),
|
|
@@ -100068,6 +100506,7 @@ exports.BrokerSubscribeInputSchema = SubscribeInputSchema;
|
|
|
100068
100506
|
exports.BrokerSubscribeResultSchema = SubscribeResultSchema;
|
|
100069
100507
|
exports.BrokerTestConnectionResultSchema = TestConnectionResultSchema;
|
|
100070
100508
|
exports.BrokerUnsubscribeInputSchema = UnsubscribeInputSchema;
|
|
100509
|
+
exports.BucketAccumulator = BucketAccumulator;
|
|
100071
100510
|
exports.BulkRecordSchema = BulkRecordSchema;
|
|
100072
100511
|
exports.CAMERA_SENSORS_NOT_LOADED = CAMERA_SENSORS_NOT_LOADED;
|
|
100073
100512
|
exports.CAMERA_SENSORS_SETTINGS_KEY = CAMERA_SENSORS_SETTINGS_KEY;
|
|
@@ -100397,6 +100836,11 @@ exports.DeviceExportExposeInputSchema = ExposeInputSchema;
|
|
|
100397
100836
|
exports.DeviceExportStatusSchema = DeviceExportStatusSchema;
|
|
100398
100837
|
exports.DeviceExportUnexposeInputSchema = UnexposeInputSchema;
|
|
100399
100838
|
exports.DeviceFeature = require_err_msg.DeviceFeature;
|
|
100839
|
+
exports.DeviceHistoryKindSchema = DeviceHistoryKindSchema;
|
|
100840
|
+
exports.DeviceHistoryRefusalReasonSchema = DeviceHistoryRefusalReasonSchema;
|
|
100841
|
+
exports.DeviceHistoryResolutionSchema = DeviceHistoryResolutionSchema;
|
|
100842
|
+
exports.DeviceHistoryStatusSchema = DeviceHistoryStatusSchema;
|
|
100843
|
+
exports.DeviceHistorySubjectSchema = DeviceHistorySubjectSchema;
|
|
100400
100844
|
exports.DeviceInfoSchema = DeviceInfoSchema;
|
|
100401
100845
|
exports.DeviceModelChoiceSchema = DeviceModelChoiceSchema;
|
|
100402
100846
|
exports.DeviceNetworkStatsSchema = DeviceNetworkStatsSchema;
|
|
@@ -100558,6 +101002,7 @@ exports.HAP_AUDIO_VBV_KBITS = HAP_AUDIO_VBV_KBITS;
|
|
|
100558
101002
|
exports.HAP_KEYFRAME_INTERVAL_SEC = HAP_KEYFRAME_INTERVAL_SEC;
|
|
100559
101003
|
exports.HF_BASE_URL = require_sleep.HF_BASE_URL;
|
|
100560
101004
|
exports.HF_REPO = require_sleep.HF_REPO;
|
|
101005
|
+
exports.HISTORY_BUCKET_MS = HISTORY_BUCKET_MS;
|
|
100561
101006
|
exports.HISTORY_CATALOG = HISTORY_CATALOG;
|
|
100562
101007
|
exports.HISTORY_DEFAULT_MIN_INTERVAL_MS = require_sleep.HISTORY_DEFAULT_MIN_INTERVAL_MS;
|
|
100563
101008
|
exports.HISTORY_NONE_CAPS = HISTORY_NONE_CAPS;
|
|
@@ -100732,6 +101177,7 @@ exports.MAX_EXPRESSION_EVAL_STEPS = require_composition.MAX_EXPRESSION_EVAL_STEP
|
|
|
100732
101177
|
exports.MAX_EXPRESSION_SOURCE_LENGTH = require_composition.MAX_EXPRESSION_SOURCE_LENGTH;
|
|
100733
101178
|
exports.MAX_KEYS = MAX_KEYS;
|
|
100734
101179
|
exports.MAX_REASONS_PER_KEY = MAX_REASONS_PER_KEY;
|
|
101180
|
+
exports.MAX_REQUEUED_BUCKETS_PER_SERIES = MAX_REQUEUED_BUCKETS_PER_SERIES;
|
|
100735
101181
|
exports.MAX_SENSOR_TRIGGER_DEVICES = MAX_SENSOR_TRIGGER_DEVICES;
|
|
100736
101182
|
exports.MAX_TRACK_DEBUG_NOTE_LEN = MAX_TRACK_DEBUG_NOTE_LEN;
|
|
100737
101183
|
exports.MAX_TRACK_PURITIES = MAX_TRACK_PURITIES;
|
|
@@ -101734,6 +102180,7 @@ exports.binaryCapability = binaryCapability;
|
|
|
101734
102180
|
exports.bindAddonActions = bindAddonActions;
|
|
101735
102181
|
exports.brightnessCapability = brightnessCapability;
|
|
101736
102182
|
exports.brokerCapability = brokerCapability;
|
|
102183
|
+
exports.bucketStartOf = bucketStartOf;
|
|
101737
102184
|
exports.buildAddonRouteProvider = buildAddonRouteProvider;
|
|
101738
102185
|
exports.buildAudioArgs = require_composition.buildAudioArgs;
|
|
101739
102186
|
exports.buildBenchStepTree = buildBenchStepTree;
|
|
@@ -101901,6 +102348,7 @@ exports.deviceDiscoveryCapability = deviceDiscoveryCapability;
|
|
|
101901
102348
|
exports.deviceDoFamily = deviceDoFamily;
|
|
101902
102349
|
exports.deviceExportCapability = deviceExportCapability;
|
|
101903
102350
|
exports.deviceExtensionCapability = deviceExtensionCapability;
|
|
102351
|
+
exports.deviceHistoryCapability = deviceHistoryCapability;
|
|
101904
102352
|
exports.deviceManagerCapability = deviceManagerCapability;
|
|
101905
102353
|
exports.deviceMatchesProfile = deviceMatchesProfile;
|
|
101906
102354
|
exports.deviceOpsCapability = require_sleep.deviceOpsCapability;
|