@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
|
@@ -46,6 +46,7 @@ import type { deviceCredentialsCapability } from '../capabilities/device-credent
|
|
|
46
46
|
import type { deviceDiscoveryCapability } from '../capabilities/device-discovery.cap.js';
|
|
47
47
|
import type { deviceExportCapability } from '../capabilities/device-export.cap.js';
|
|
48
48
|
import type { deviceExtensionCapability } from '../capabilities/device-extension.cap.js';
|
|
49
|
+
import type { deviceHistoryCapability } from '../capabilities/device-history.cap.js';
|
|
49
50
|
import type { deviceManagerCapability } from '../capabilities/device-manager.cap.js';
|
|
50
51
|
import type { deviceOpsCapability } from '../capabilities/device-ops.cap.js';
|
|
51
52
|
import type { deviceProviderCapability } from '../capabilities/device-provider.cap.js';
|
|
@@ -2353,6 +2354,83 @@ export type AppRouter = TrpcCoreRouter<{
|
|
|
2353
2354
|
meta: object;
|
|
2354
2355
|
}>;
|
|
2355
2356
|
}>>;
|
|
2357
|
+
deviceHistory: TRPCBuiltRouter<{
|
|
2358
|
+
ctx: TrpcContext;
|
|
2359
|
+
meta: object;
|
|
2360
|
+
errorShape: AugmentedErrorShape;
|
|
2361
|
+
transformer: true;
|
|
2362
|
+
}, TRPCDecorateCreateRouterOptions<{
|
|
2363
|
+
listSeries: TRPCQueryProcedure<{
|
|
2364
|
+
input: {
|
|
2365
|
+
[x: string]: unknown;
|
|
2366
|
+
} & z.input<typeof deviceHistoryCapability.methods.listSeries.input>;
|
|
2367
|
+
output: z.infer<typeof deviceHistoryCapability.methods.listSeries.output>;
|
|
2368
|
+
meta: object;
|
|
2369
|
+
}>;
|
|
2370
|
+
listNodeSeries: TRPCQueryProcedure<{
|
|
2371
|
+
input: {
|
|
2372
|
+
[x: string]: unknown;
|
|
2373
|
+
} & z.input<typeof deviceHistoryCapability.methods.listNodeSeries.input>;
|
|
2374
|
+
output: z.infer<typeof deviceHistoryCapability.methods.listNodeSeries.output>;
|
|
2375
|
+
meta: object;
|
|
2376
|
+
}>;
|
|
2377
|
+
query: TRPCQueryProcedure<{
|
|
2378
|
+
input: {
|
|
2379
|
+
[x: string]: unknown;
|
|
2380
|
+
} & z.input<typeof deviceHistoryCapability.methods.query.input>;
|
|
2381
|
+
output: z.infer<typeof deviceHistoryCapability.methods.query.output>;
|
|
2382
|
+
meta: object;
|
|
2383
|
+
}>;
|
|
2384
|
+
queryNode: TRPCQueryProcedure<{
|
|
2385
|
+
input: {
|
|
2386
|
+
[x: string]: unknown;
|
|
2387
|
+
} & z.input<typeof deviceHistoryCapability.methods.queryNode.input>;
|
|
2388
|
+
output: z.infer<typeof deviceHistoryCapability.methods.queryNode.output>;
|
|
2389
|
+
meta: object;
|
|
2390
|
+
}>;
|
|
2391
|
+
declareSeries: TRPCMutationProcedure<{
|
|
2392
|
+
input: {
|
|
2393
|
+
[x: string]: unknown;
|
|
2394
|
+
} & z.input<typeof deviceHistoryCapability.methods.declareSeries.input>;
|
|
2395
|
+
output: z.infer<typeof deviceHistoryCapability.methods.declareSeries.output>;
|
|
2396
|
+
meta: object;
|
|
2397
|
+
}>;
|
|
2398
|
+
record: TRPCMutationProcedure<{
|
|
2399
|
+
input: {
|
|
2400
|
+
[x: string]: unknown;
|
|
2401
|
+
} & z.input<typeof deviceHistoryCapability.methods.record.input>;
|
|
2402
|
+
output: z.infer<typeof deviceHistoryCapability.methods.record.output>;
|
|
2403
|
+
meta: object;
|
|
2404
|
+
}>;
|
|
2405
|
+
recordBuckets: TRPCMutationProcedure<{
|
|
2406
|
+
input: {
|
|
2407
|
+
[x: string]: unknown;
|
|
2408
|
+
} & z.input<typeof deviceHistoryCapability.methods.recordBuckets.input>;
|
|
2409
|
+
output: z.infer<typeof deviceHistoryCapability.methods.recordBuckets.output>;
|
|
2410
|
+
meta: object;
|
|
2411
|
+
}>;
|
|
2412
|
+
getDeviceEnabled: TRPCQueryProcedure<{
|
|
2413
|
+
input: {
|
|
2414
|
+
[x: string]: unknown;
|
|
2415
|
+
} & z.input<typeof deviceHistoryCapability.methods.getDeviceEnabled.input>;
|
|
2416
|
+
output: z.infer<typeof deviceHistoryCapability.methods.getDeviceEnabled.output>;
|
|
2417
|
+
meta: object;
|
|
2418
|
+
}>;
|
|
2419
|
+
setDeviceEnabled: TRPCMutationProcedure<{
|
|
2420
|
+
input: {
|
|
2421
|
+
[x: string]: unknown;
|
|
2422
|
+
} & z.input<typeof deviceHistoryCapability.methods.setDeviceEnabled.input>;
|
|
2423
|
+
output: z.infer<typeof deviceHistoryCapability.methods.setDeviceEnabled.output>;
|
|
2424
|
+
meta: object;
|
|
2425
|
+
}>;
|
|
2426
|
+
getStatus: TRPCQueryProcedure<{
|
|
2427
|
+
input: {
|
|
2428
|
+
[x: string]: unknown;
|
|
2429
|
+
} & z.input<typeof deviceHistoryCapability.methods.getStatus.input>;
|
|
2430
|
+
output: z.infer<typeof deviceHistoryCapability.methods.getStatus.output>;
|
|
2431
|
+
meta: object;
|
|
2432
|
+
}>;
|
|
2433
|
+
}>>;
|
|
2356
2434
|
deviceManager: TRPCBuiltRouter<{
|
|
2357
2435
|
ctx: TrpcContext;
|
|
2358
2436
|
meta: object;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* Plain data, zero Zod: a forked runner must not import the schema barrel
|
|
12
12
|
* (~144MB RSS per runner — D28).
|
|
13
13
|
*
|
|
14
|
-
* Coverage:
|
|
14
|
+
* Coverage: 27 caps, 69 methods with defaults.
|
|
15
15
|
*/
|
|
16
16
|
export declare const CAP_INPUT_DEFAULTS: Readonly<Record<string, Readonly<Record<string, Readonly<Record<string, unknown>>>>>>;
|
|
17
17
|
/**
|
|
@@ -52,6 +52,7 @@ export { deviceCredentialsCapability } from '../capabilities/device-credentials.
|
|
|
52
52
|
export { deviceDiscoveryCapability } from '../capabilities/device-discovery.cap.js';
|
|
53
53
|
export { deviceExportCapability } from '../capabilities/device-export.cap.js';
|
|
54
54
|
export { deviceExtensionCapability } from '../capabilities/device-extension.cap.js';
|
|
55
|
+
export { deviceHistoryCapability } from '../capabilities/device-history.cap.js';
|
|
55
56
|
export { deviceManagerCapability } from '../capabilities/device-manager.cap.js';
|
|
56
57
|
export { deviceOpsCapability } from '../capabilities/device-ops.cap.js';
|
|
57
58
|
export { deviceProviderCapability } from '../capabilities/device-provider.cap.js';
|
|
@@ -225,6 +226,7 @@ export declare const CAPABILITY_NAMES: {
|
|
|
225
226
|
readonly deviceDiscovery: 'device-discovery';
|
|
226
227
|
readonly deviceExport: 'device-export';
|
|
227
228
|
readonly deviceExtension: 'device-extension';
|
|
229
|
+
readonly deviceHistory: 'device-history';
|
|
228
230
|
readonly deviceManager: 'device-manager';
|
|
229
231
|
readonly deviceOps: 'device-ops';
|
|
230
232
|
readonly deviceProvider: 'device-provider';
|
|
@@ -411,6 +413,7 @@ export interface CapabilityRouterMap<TRouter = unknown> {
|
|
|
411
413
|
readonly deviceDiscovery: TRouter;
|
|
412
414
|
readonly deviceExport: TRouter;
|
|
413
415
|
readonly deviceExtension: TRouter;
|
|
416
|
+
readonly deviceHistory: TRouter;
|
|
414
417
|
readonly deviceManager: TRouter;
|
|
415
418
|
readonly deviceOps: TRouter;
|
|
416
419
|
readonly deviceProvider: TRouter;
|
|
@@ -530,8 +533,8 @@ export interface CapabilityRouterMap<TRouter = unknown> {
|
|
|
530
533
|
readonly zoneRules: TRouter;
|
|
531
534
|
readonly zones: TRouter;
|
|
532
535
|
}
|
|
533
|
-
/** Capability names whose mode is `singleton` (
|
|
534
|
-
export declare const SINGLETON_CAPABILITY_NAMES: readonly ['accessories', 'addon-pages', 'addon-settings', 'addon-widgets', 'addons', 'admin-ui', 'air-quality-sensor', 'alarm-panel', 'alerts', 'ambient-light-sensor', 'audio-analysis', 'audio-analyzer', 'audio-codec', 'audio-metrics', 'automation-control', 'backup', 'battery', 'binary', 'brightness', 'button', 'calendars', 'camera-credentials', 'camera-grid-layout', 'camera-pipeline-config', 'camera-streams', 'carbon-monoxide', 'climate-control', 'color', 'composer', 'connectivity', 'consumables', 'contact', 'control', 'core-blocks', 'cover', 'database-snapshot', 'day-night', 'decoder', 'detection-pipeline', 'device-admin-link', 'device-adoption', 'device-credentials', 'device-discovery', 'device-manager', 'device-ops', 'device-state', 'device-status', 'doorbell', 'enum-sensor', 'event-emitter', 'face-gallery', 'fan-control', 'feature-probe', 'filesystem-browse', 'flood', 'gas', 'humidifier', 'humidity-sensor', 'image', 'image-settings', 'integrations', 'intercom', 'keychain', 'keychain-admin', 'lawn-mower-control', 'llm-runtime', 'local-network', 'lock-control', 'media-player', 'metrics-provider', 'model-convert', 'model-distributor', 'motion', 'motion-detection', 'motion-trigger', 'motion-zones', 'native-object-detection', 'navigation', 'network-link', 'network-quality', 'node-certificates', 'nodes', 'notification-rules', 'notifier', 'numeric-sensor', 'oidc-connections', 'osd', 'osd-manager', 'pet-feeder', 'pipeline-analytics', 'pipeline-executor', 'pipeline-orchestrator', 'pipeline-runner', 'plate-gallery', 'platform-probe', 'power-meter', 'presence', 'pressure-sensor', 'privacy-mask', 'ptz', 'ptz-autotrack', 'reboot', 'recording-archive', 'recording-export', 'recording-onboard', 'recording-signal', 'scene-monitor', 'script-runner', 'server-management', 'settings-store', 'smoke', 'snapshot', 'sso-bridge', 'storage', 'storage-migration', 'stream-broker', 'stream-catalog', 'stream-params', 'stream-signals', 'switch', 'system', 'tamper', 'temperature-sensor', 'terminal-session', 'toast', 'training', 'update', 'user-management', 'vacuum-control', 'valve', 'vector-store', 'vibration', 'viewer-ui', 'water-heater', 'weather', 'webrtc-session', 'zone-analytics', 'zone-rules', 'zones'];
|
|
536
|
+
/** Capability names whose mode is `singleton` (140 caps). */
|
|
537
|
+
export declare const SINGLETON_CAPABILITY_NAMES: readonly ['accessories', 'addon-pages', 'addon-settings', 'addon-widgets', 'addons', 'admin-ui', 'air-quality-sensor', 'alarm-panel', 'alerts', 'ambient-light-sensor', 'audio-analysis', 'audio-analyzer', 'audio-codec', 'audio-metrics', 'automation-control', 'backup', 'battery', 'binary', 'brightness', 'button', 'calendars', 'camera-credentials', 'camera-grid-layout', 'camera-pipeline-config', 'camera-streams', 'carbon-monoxide', 'climate-control', 'color', 'composer', 'connectivity', 'consumables', 'contact', 'control', 'core-blocks', 'cover', 'database-snapshot', 'day-night', 'decoder', 'detection-pipeline', 'device-admin-link', 'device-adoption', 'device-credentials', 'device-discovery', 'device-history', 'device-manager', 'device-ops', 'device-state', 'device-status', 'doorbell', 'enum-sensor', 'event-emitter', 'face-gallery', 'fan-control', 'feature-probe', 'filesystem-browse', 'flood', 'gas', 'humidifier', 'humidity-sensor', 'image', 'image-settings', 'integrations', 'intercom', 'keychain', 'keychain-admin', 'lawn-mower-control', 'llm-runtime', 'local-network', 'lock-control', 'media-player', 'metrics-provider', 'model-convert', 'model-distributor', 'motion', 'motion-detection', 'motion-trigger', 'motion-zones', 'native-object-detection', 'navigation', 'network-link', 'network-quality', 'node-certificates', 'nodes', 'notification-rules', 'notifier', 'numeric-sensor', 'oidc-connections', 'osd', 'osd-manager', 'pet-feeder', 'pipeline-analytics', 'pipeline-executor', 'pipeline-orchestrator', 'pipeline-runner', 'plate-gallery', 'platform-probe', 'power-meter', 'presence', 'pressure-sensor', 'privacy-mask', 'ptz', 'ptz-autotrack', 'reboot', 'recording-archive', 'recording-export', 'recording-onboard', 'recording-signal', 'scene-monitor', 'script-runner', 'server-management', 'settings-store', 'smoke', 'snapshot', 'sso-bridge', 'storage', 'storage-migration', 'stream-broker', 'stream-catalog', 'stream-params', 'stream-signals', 'switch', 'system', 'tamper', 'temperature-sensor', 'terminal-session', 'toast', 'training', 'update', 'user-management', 'vacuum-control', 'valve', 'vector-store', 'vibration', 'viewer-ui', 'water-heater', 'weather', 'webrtc-session', 'zone-analytics', 'zone-rules', 'zones'];
|
|
535
538
|
/** Union of singleton capability names (literal string union). */
|
|
536
539
|
export type SingletonCapabilityName = typeof SINGLETON_CAPABILITY_NAMES[number];
|
|
537
540
|
/** Capability names whose mode is `collection` (33 caps). */
|
|
@@ -94,6 +94,7 @@ import type { addonSettingsCapability } from '../capabilities/addon-settings.cap
|
|
|
94
94
|
import type { audioAnalyzerCapability } from '../capabilities/audio-analyzer.cap.js';
|
|
95
95
|
import type { deviceAdoptionCapability } from '../capabilities/device-adoption.cap.js';
|
|
96
96
|
import type { deviceExportCapability } from '../capabilities/device-export.cap.js';
|
|
97
|
+
import type { deviceHistoryCapability } from '../capabilities/device-history.cap.js';
|
|
97
98
|
import type { deviceManagerCapability } from '../capabilities/device-manager.cap.js';
|
|
98
99
|
import type { deviceStateCapability } from '../capabilities/device-state.cap.js';
|
|
99
100
|
import type { faceGalleryCapability } from '../capabilities/face-gallery.cap.js';
|
|
@@ -293,6 +294,7 @@ export interface DeviceProxy {
|
|
|
293
294
|
readonly audioAnalyzer: Pick<InferDeviceProxyCap<typeof audioAnalyzerCapability>, 'detachDevice'>;
|
|
294
295
|
readonly deviceAdoption: Pick<InferDeviceProxyCap<typeof deviceAdoptionCapability>, 'getStatus'>;
|
|
295
296
|
readonly deviceExport: Pick<InferDeviceProxyCap<typeof deviceExportCapability>, 'getDeviceSettingsContribution' | 'getDeviceLiveContribution' | 'applyDeviceSettingsPatch'>;
|
|
297
|
+
readonly deviceHistory: Pick<InferDeviceProxyCap<typeof deviceHistoryCapability>, 'listSeries' | 'query' | 'getDeviceEnabled' | 'setDeviceEnabled'>;
|
|
296
298
|
readonly deviceManager: Pick<InferDeviceProxyCap<typeof deviceManagerCapability>, 'loadConfig' | 'loadRuntimeState' | 'loadMeta' | 'setName' | 'setLocation' | 'setType' | 'setIntegrationId' | 'setLinkDeviceId' | 'setPrimaryChildEntityId' | 'setChildLayout' | 'setDisplay' | 'getWireableFields' | 'setRole' | 'applyInitialMeta' | 'setMetadata' | 'setDisabled' | 'getDevice' | 'getLinkedDevices' | 'getStreamSources' | 'getConfigSchema' | 'getSettingsSchema' | 'updateConfig' | 'enable' | 'disable' | 'remove' | 'getStreamProfileMap' | 'setStreamProfileMap' | 'probeStreams' | 'getBindings' | 'setWrapperActive' | 'getWrapperActivation' | 'getDeviceSettingsAggregate' | 'getDeviceLiveInfoAggregate' | 'getDeviceAggregate' | 'runDeviceAction' | 'updateDeviceField' | 'updateDeviceFieldsBatch' | 'testField' | 'getDeviceStatusAggregate'>;
|
|
297
299
|
readonly deviceState: Pick<InferDeviceProxyCap<typeof deviceStateCapability>, 'getSnapshot' | 'getCapSlice' | 'setCapSlice' | 'claimFields' | 'patchOwnedFields' | 'releaseClaim' | 'getNativeCapSlice'>;
|
|
298
300
|
readonly faceGallery: Pick<InferDeviceProxyCap<typeof faceGalleryCapability>, 'listRecentFaces' | 'getFaceByTrack'>;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* scope+access check inside `protectedProcedure` (see
|
|
7
7
|
* `server/backend/src/api/trpc/trpc.middleware.ts`).
|
|
8
8
|
*
|
|
9
|
-
* Coverage:
|
|
9
|
+
* Coverage: 1331 method paths across 173 capabilities.
|
|
10
10
|
*/
|
|
11
11
|
import type { CapabilityMethodAccess } from '../capabilities/capability-definition.js';
|
|
12
12
|
export interface MethodAccessRecord {
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* system-scope cap that takes a deviceId was previously never device-filtered
|
|
7
7
|
* — see the generator header).
|
|
8
8
|
*
|
|
9
|
-
* Coverage:
|
|
10
|
-
*
|
|
9
|
+
* Coverage: 524 methods carry a device reference, of which
|
|
10
|
+
* 169 are on SYSTEM-scope caps.
|
|
11
11
|
*
|
|
12
12
|
* Top-level fields, number arrays, and one-level arrays of objects carrying
|
|
13
13
|
* a numeric device field (targets[].deviceId) are all mapped; the matcher
|
|
@@ -16,6 +16,7 @@ import type { decoderCapability } from '../capabilities/decoder.cap.js';
|
|
|
16
16
|
import type { deviceAdoptionCapability } from '../capabilities/device-adoption.cap.js';
|
|
17
17
|
import type { deviceCredentialsCapability } from '../capabilities/device-credentials.cap.js';
|
|
18
18
|
import type { deviceExportCapability } from '../capabilities/device-export.cap.js';
|
|
19
|
+
import type { deviceHistoryCapability } from '../capabilities/device-history.cap.js';
|
|
19
20
|
import type { deviceManagerCapability } from '../capabilities/device-manager.cap.js';
|
|
20
21
|
import type { deviceProviderCapability } from '../capabilities/device-provider.cap.js';
|
|
21
22
|
import type { deviceStateCapability } from '../capabilities/device-state.cap.js';
|
|
@@ -76,6 +77,7 @@ export interface SystemProxy {
|
|
|
76
77
|
readonly deviceAdoption: Pick<InferProvider<typeof deviceAdoptionCapability>, 'listCandidateFilters' | 'listCandidates' | 'getCandidate' | 'refresh' | 'adopt' | 'release' | 'resync'>;
|
|
77
78
|
readonly deviceCredentials: Pick<InferProvider<typeof deviceCredentialsCapability>, 'listDeviceCredentials' | 'startEnrollment' | 'revokeDeviceCredential' | 'getDeviceCertificateSettings' | 'setDeviceCertificateSettings' | 'deleteDeviceCredential' | 'getDeviceCaStatus' | 'renameDeviceCredential'>;
|
|
78
79
|
readonly deviceExport: Pick<InferProvider<typeof deviceExportCapability>, 'getStatus' | 'listSupportedDeviceKinds' | 'listExposedDevices' | 'exposeDevice' | 'unexposeDevice'>;
|
|
80
|
+
readonly deviceHistory: Pick<InferProvider<typeof deviceHistoryCapability>, 'listNodeSeries' | 'queryNode' | 'declareSeries' | 'record' | 'recordBuckets' | 'getStatus'>;
|
|
79
81
|
readonly deviceManager: Pick<InferProvider<typeof deviceManagerCapability>, 'allocateDeviceId' | 'migrateDevice' | 'registerDevice' | 'removeDevice' | 'persistConfig' | 'getRoleDisplayDefaults' | 'setRoleDisplayDefaults' | 'listLocations' | 'addLocation' | 'removeLocation' | 'renameLocation' | 'listLocationIcons' | 'setLocationIcon' | 'listLocationDescriptions' | 'setLocationDescription' | 'listSiteZones' | 'setSiteZone' | 'removeSiteZone' | 'renameSiteZone' | 'setLocationZone' | 'listPersistedByAddon' | 'listAll' | 'getChildren' | 'getChildrenBatch' | 'getLinkedDevicesBatch' | 'removeByIntegration' | 'getBindingsBatch' | 'getAllBindings' | 'listDeviceIdsByCaps' | 'listWrappersForCap' | 'listBindableCapsForDeviceType' | 'discoverDevices' | 'adoptDevice' | 'getCreationSchema' | 'createDevice' | 'testCreationField' | 'adoptionListCandidateFilters' | 'adoptionListCandidates' | 'adoptionRefresh' | 'adoptionAdopt' | 'adoptionRelease' | 'adoptionStartJob' | 'adoptionListJobs' | 'adoptionCancelJob' | 'adoptionResync' | 'discoveryProviders' | 'discoverAllProviders' | 'discoverProvider' | 'providerCreationType' | 'providerDiscoveryParamsSchema' | 'getDeviceStatusAggregateBatch'>;
|
|
80
82
|
readonly deviceProvider: Pick<InferProvider<typeof deviceProviderCapability>, 'start' | 'stop' | 'getStatus' | 'getDevices' | 'reloadDevice' | 'supportsDiscovery' | 'discoverDevices' | 'getDiscoveryParamsSchema' | 'getManualCreationType' | 'adoptDiscoveredDevice' | 'supportsManualCreation' | 'getChildCreationSchema' | 'createDevice' | 'testCreationField'>;
|
|
81
83
|
readonly deviceState: Pick<InferProvider<typeof deviceStateCapability>, 'getAllSnapshots' | 'listClaims'>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Producer-side five-minute bucket accumulator (D850, plan §5.4).
|
|
3
|
+
*
|
|
4
|
+
* PURE: no I/O, no timers, the clock is a parameter. It lives in
|
|
5
|
+
* `@camstack/types` because it is bundled with every addon — an addon cannot
|
|
6
|
+
* import another addon, and an import from `@camstack/system` breaks on an
|
|
7
|
+
* older server. A producer that samples faster than `record` allows (once per
|
|
8
|
+
* 10 s per series) aggregates here and sends CLOSED buckets with
|
|
9
|
+
* `deviceHistory.recordBuckets`.
|
|
10
|
+
*
|
|
11
|
+
* The caller owns delivery: `takeClosed` hands buckets over, and a bucket the
|
|
12
|
+
* caller could not deliver goes back through `requeue`, which keeps at most
|
|
13
|
+
* {@link MAX_REQUEUED_BUCKETS_PER_SERIES} per series (one hour) and RETURNS what
|
|
14
|
+
* it had to drop so the caller can say so, with a `deviceId` tag (D58, D391).
|
|
15
|
+
*/
|
|
16
|
+
import type { DeviceHistorySubject } from '../capabilities/device-history.cap.js';
|
|
17
|
+
/** Width of a bucket the history store accepts. */
|
|
18
|
+
export declare const HISTORY_BUCKET_MS: number;
|
|
19
|
+
/** One hour of failed deliveries per series is retried; older buckets are dropped. */
|
|
20
|
+
export declare const MAX_REQUEUED_BUCKETS_PER_SERIES = 12;
|
|
21
|
+
/** A closed bucket, shaped exactly like one `recordBuckets` entry. */
|
|
22
|
+
export interface ClosedHistoryBucket {
|
|
23
|
+
readonly key: string;
|
|
24
|
+
readonly subject: DeviceHistorySubject;
|
|
25
|
+
readonly scope: string;
|
|
26
|
+
readonly bucketStart: number;
|
|
27
|
+
readonly samples: number;
|
|
28
|
+
readonly sum: number;
|
|
29
|
+
readonly min: number;
|
|
30
|
+
readonly max: number;
|
|
31
|
+
readonly last: number | null;
|
|
32
|
+
readonly lastTs: number | null;
|
|
33
|
+
}
|
|
34
|
+
export declare function bucketStartOf(at: number): number;
|
|
35
|
+
export declare class BucketAccumulator {
|
|
36
|
+
private readonly open;
|
|
37
|
+
private readonly requeued;
|
|
38
|
+
/** Add one observation. A non-finite value or timestamp is ignored (never counted as 0). */
|
|
39
|
+
note(key: string, subject: DeviceHistorySubject, scope: string, value: number, at: number): void;
|
|
40
|
+
/**
|
|
41
|
+
* Buckets whose window ended at or before `now`, oldest first, requeued ones
|
|
42
|
+
* included. They leave the accumulator: delivery is the caller's.
|
|
43
|
+
*/
|
|
44
|
+
takeClosed(now: number): readonly ClosedHistoryBucket[];
|
|
45
|
+
/**
|
|
46
|
+
* Put undelivered buckets back for the next `takeClosed`. Keeps the newest
|
|
47
|
+
* {@link MAX_REQUEUED_BUCKETS_PER_SERIES} per series and returns the buckets
|
|
48
|
+
* it dropped (empty when none).
|
|
49
|
+
*/
|
|
50
|
+
requeue(buckets: readonly ClosedHistoryBucket[]): readonly ClosedHistoryBucket[];
|
|
51
|
+
/** Buckets currently held (open plus requeued) — for a gauge in the producer's own status. */
|
|
52
|
+
pendingBucketCount(): number;
|
|
53
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -240,6 +240,7 @@ export { METHOD_DEVICE_SELECTORS, SYSTEM_SCOPE_DEVICE_METHODS, } from './generat
|
|
|
240
240
|
export { CAP_PROVIDER_KIND_MAP, getCapsByProviderKind, PROVIDER_KIND_CAP_NAMES, } from './generated/provider-kind-map.js';
|
|
241
241
|
export type { RuntimeStatePolicy } from './generated/runtime-state-durability.js';
|
|
242
242
|
export { isRestoredCap, RESTORED_CAP_NAMES, RUNTIME_STATE_POLICY, runtimeStatePolicyFor, } from './generated/runtime-state-durability.js';
|
|
243
|
+
export { BucketAccumulator, bucketStartOf, type ClosedHistoryBucket, HISTORY_BUCKET_MS, MAX_REQUEUED_BUCKETS_PER_SERIES, } from './history/bucket-accumulator.js';
|
|
243
244
|
export { HISTORY_CATALOG, HISTORY_NONE_CAPS, historyFieldsFor, } from './generated/history-catalog.js';
|
|
244
245
|
export type { ScopePresetId, ScopePresetSpec } from './generated/scope-presets.js';
|
|
245
246
|
export { SCOPE_PRESETS } from './generated/scope-presets.js';
|