@camstack/sdk 1.2.128 → 1.2.131

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.
@@ -1,169 +1,169 @@
1
1
  /**
2
- * Timeline & event types — shared between CamStack app and proxy.
3
- *
4
- * Names are unified: the proxy's naming convention is canonical.
5
- * The app re-exports aliases for backward compatibility where needed.
6
- */
2
+ * Timeline & event types — shared between CamStack app and proxy.
3
+ *
4
+ * Names are unified: the proxy's naming convention is canonical.
5
+ * The app re-exports aliases for backward compatibility where needed.
6
+ */
7
7
  /** Severity: alert = notable, detection = regular. */
8
- export type TimelineEventSeverity = 'alert' | 'detection';
8
+ export type TimelineEventSeverity = "alert" | "detection";
9
9
  /** Motion fragment type: start/end from event boundaries, update from motion API. */
10
- export type MotionFragmentType = 'start' | 'end' | 'update';
10
+ export type MotionFragmentType = "start" | "end" | "update";
11
11
  /**
12
- * A detection event for timeline display and grouping.
13
- * Unified from app's TimelineDetectionEvent and proxy's DetectionEvent.
14
- */
12
+ * A detection event for timeline display and grouping.
13
+ * Unified from app's TimelineDetectionEvent and proxy's DetectionEvent.
14
+ */
15
15
  export interface DetectionEvent {
16
- id?: string;
17
- timestamp: number;
18
- source?: string;
19
- classes?: string[];
20
- /** @deprecated Use `classes` instead. Kept for backward compat with some app code. */
21
- detectionClasses?: string[];
22
- label?: string;
23
- thumbnailUrl?: string;
24
- imageUrl?: string;
25
- videoUrl?: string;
26
- gifUrl?: string;
27
- severity?: TimelineEventSeverity;
28
- deviceName?: string;
29
- deviceId?: string;
30
- ruleType?: string;
31
- croppedThumbnailUrl?: string;
32
- [key: string]: unknown;
16
+ id?: string;
17
+ timestamp: number;
18
+ source?: string;
19
+ classes?: string[];
20
+ /** @deprecated Use `classes` instead. Kept for backward compat with some app code. */
21
+ detectionClasses?: string[];
22
+ label?: string;
23
+ thumbnailUrl?: string;
24
+ imageUrl?: string;
25
+ videoUrl?: string;
26
+ gifUrl?: string;
27
+ severity?: TimelineEventSeverity;
28
+ deviceName?: string;
29
+ deviceId?: string;
30
+ ruleType?: string;
31
+ croppedThumbnailUrl?: string;
32
+ [key: string]: unknown;
33
33
  }
34
34
  /**
35
- * Motion on/off item for timeline bar.
36
- * Unified from app's TimelineMotionItem and proxy's MotionItem.
37
- */
35
+ * Motion on/off item for timeline bar.
36
+ * Unified from app's TimelineMotionItem and proxy's MotionItem.
37
+ */
38
38
  export interface MotionItem {
39
- timestamp: number;
40
- deviceId?: string;
41
- motion: 'on' | 'off';
42
- /** Fragment type or "motion" | "audio" (AN audio thresholds). */
43
- type?: MotionFragmentType | 'motion' | 'audio' | string;
44
- /** For type "audio": level 1–5 (threshold crossed). */
45
- level?: number;
46
- /** For type "audio": dBFS at threshold crossing. */
47
- dBFS?: number;
39
+ timestamp: number;
40
+ deviceId?: string;
41
+ motion: "on" | "off";
42
+ /** Fragment type or "motion" | "audio" (AN audio thresholds). */
43
+ type?: MotionFragmentType | "motion" | "audio" | string;
44
+ /** For type "audio": level 1–5 (threshold crossed). */
45
+ level?: number;
46
+ /** For type "audio": dBFS at threshold crossing. */
47
+ dBFS?: number;
48
48
  }
49
49
  /**
50
- * Rule artifact for timeline.
51
- * Unified from app's TimelineArtifactItem and proxy's TimelineArtifact.
52
- */
50
+ * Rule artifact for timeline.
51
+ * Unified from app's TimelineArtifactItem and proxy's TimelineArtifact.
52
+ */
53
53
  export interface TimelineArtifact {
54
- ruleName: string;
55
- ruleType?: string;
56
- timestamp: number;
57
- imageUrl?: string;
58
- gifUrl?: string;
59
- videoUrl?: string;
54
+ ruleName: string;
55
+ ruleType?: string;
56
+ timestamp: number;
57
+ imageUrl?: string;
58
+ gifUrl?: string;
59
+ videoUrl?: string;
60
60
  }
61
61
  /** Audio level segment for timeline bar. */
62
62
  export interface AudioLevelSegment {
63
- start: number;
64
- end: number;
65
- level: number;
66
- dBFS?: number;
63
+ start: number;
64
+ end: number;
65
+ level: number;
66
+ dBFS?: number;
67
67
  }
68
68
  /** Recording segment for timeline bar (where recording exists). */
69
69
  export interface TimelineRecordingSegment {
70
- start: number;
71
- end: number;
70
+ start: number;
71
+ end: number;
72
72
  }
73
73
  /** Day data for timeline (events, motion, artifacts). */
74
74
  export interface CameraDayDataResponse {
75
- events: DetectionEvent[];
76
- motion: MotionItem[];
77
- artifacts: TimelineArtifact[];
78
- recordings?: TimelineRecordingSegment[];
75
+ events: DetectionEvent[];
76
+ motion: MotionItem[];
77
+ artifacts: TimelineArtifact[];
78
+ recordings?: TimelineRecordingSegment[];
79
79
  }
80
80
  /** Clustered day data response (server-side bucketing). */
81
81
  export interface ClusteredDayDataResponse {
82
- clusters: TimelineCluster[];
83
- motion: MotionItem[];
84
- artifacts: TimelineArtifact[];
85
- motionSegments?: TimelineRecordingSegment[];
86
- audioLevelSegments?: AudioLevelSegment[];
87
- recordings?: TimelineRecordingSegment[];
82
+ clusters: TimelineCluster[];
83
+ motion: MotionItem[];
84
+ artifacts: TimelineArtifact[];
85
+ motionSegments?: TimelineRecordingSegment[];
86
+ audioLevelSegments?: AudioLevelSegment[];
87
+ recordings?: TimelineRecordingSegment[];
88
88
  }
89
89
  /** A time-bucketed cluster of detection events. */
90
90
  export interface TimelineCluster {
91
- events: DetectionEvent[];
92
- representative: DetectionEvent;
93
- classes: string[];
94
- labels: string[];
95
- startMs: number;
96
- endMs: number;
91
+ events: DetectionEvent[];
92
+ representative: DetectionEvent;
93
+ classes: string[];
94
+ labels: string[];
95
+ startMs: number;
96
+ endMs: number;
97
97
  }
98
98
  /** A group of related detection events with a representative. */
99
99
  export interface DetectionGroup {
100
- events: DetectionEvent[];
101
- representative: DetectionEvent;
102
- classes: string[];
103
- labels: string[];
100
+ events: DetectionEvent[];
101
+ representative: DetectionEvent;
102
+ classes: string[];
103
+ labels: string[];
104
104
  }
105
105
  /** Query for clustered day data. */
106
106
  export interface ClusteredDayDataQuery {
107
- camera: string;
108
- days: string[];
109
- bucketMs?: number;
110
- enabledClasses?: string[];
111
- classFilter?: string;
107
+ camera: string;
108
+ days: string[];
109
+ bucketMs?: number;
110
+ enabledClasses?: string[];
111
+ classFilter?: string;
112
112
  }
113
113
  /** Query for grouped events. */
114
114
  export interface GroupedEventsQuery {
115
- after?: number;
116
- before?: number;
117
- limit?: number;
118
- offset?: number;
119
- cameras?: string[];
120
- detectionClasses?: string[];
121
- eventSource?: string;
122
- filter?: string;
123
- groupingRange?: number;
115
+ after?: number;
116
+ before?: number;
117
+ limit?: number;
118
+ offset?: number;
119
+ cameras?: string[];
120
+ detectionClasses?: string[];
121
+ eventSource?: string;
122
+ filter?: string;
123
+ groupingRange?: number;
124
124
  }
125
125
  /** Result of grouped events query. */
126
126
  export interface GroupedEventsResult {
127
- groups: DetectionGroup[];
128
- total: number;
129
- ruleArtifacts?: DetectionGroup[];
127
+ groups: DetectionGroup[];
128
+ total: number;
129
+ ruleArtifacts?: DetectionGroup[];
130
130
  }
131
131
  /** Query for events within a cluster time range. */
132
132
  export interface ClusterEventsQuery {
133
- camera: string;
134
- startMs: number;
135
- endMs: number;
133
+ camera: string;
134
+ startMs: number;
135
+ endMs: number;
136
136
  }
137
137
  /** Result of cluster events query. */
138
138
  export interface ClusterEventsResult {
139
- events: DetectionEvent[];
139
+ events: DetectionEvent[];
140
140
  }
141
141
  /** A reel event (carousel-friendly). All timestamps are in **seconds** (Unix epoch). */
142
142
  export interface ReelEvent {
143
- id: string;
144
- camera: string;
145
- cameraName: string;
146
- label: string;
147
- /** Unix timestamp in **seconds** (not milliseconds). */
148
- startTime: number;
149
- thumbnail?: string;
150
- croppedThumbnailUrl?: string;
151
- hasClip?: boolean;
152
- gifUrl?: string;
153
- videoUrl?: string;
154
- imageUrl?: string;
155
- classes?: string[];
143
+ id: string;
144
+ camera: string;
145
+ cameraName: string;
146
+ label: string;
147
+ /** Unix timestamp in **seconds** (not milliseconds). */
148
+ startTime: number;
149
+ thumbnail?: string;
150
+ croppedThumbnailUrl?: string;
151
+ hasClip?: boolean;
152
+ gifUrl?: string;
153
+ videoUrl?: string;
154
+ imageUrl?: string;
155
+ classes?: string[];
156
156
  }
157
157
  /** Query for reel events. */
158
158
  export interface ReelEventsQuery {
159
- limit?: number;
160
- offset?: number;
161
- cameras?: string[];
162
- eventSource?: string;
163
- detectionClasses?: string[];
159
+ limit?: number;
160
+ offset?: number;
161
+ cameras?: string[];
162
+ eventSource?: string;
163
+ detectionClasses?: string[];
164
164
  }
165
165
  /** Result of reel events query. */
166
166
  export interface ReelEventsResult {
167
- events: ReelEvent[];
168
- total: number;
167
+ events: ReelEvent[];
168
+ total: number;
169
169
  }
package/dist/types.d.ts CHANGED
@@ -1,37 +1,37 @@
1
1
  /**
2
- * SDK client configuration types.
3
- *
4
- * NVR types are now in nvr.ts (shared across app and proxy).
5
- */
2
+ * SDK client configuration types.
3
+ *
4
+ * NVR types are now in nvr.ts (shared across app and proxy).
5
+ */
6
6
  export interface HlsInfo {
7
- hlsUrl: string;
7
+ hlsUrl: string;
8
8
  }
9
9
  /** Public provider info (returned by providers.list). */
10
10
  export interface ProviderInfo {
11
- id: string;
12
- type: string;
13
- name: string;
11
+ id: string;
12
+ type: string;
13
+ name: string;
14
14
  }
15
15
  export interface ProxyClientConfig {
16
- /**
17
- * Primary proxy URL (e.g. "http://192.168.10.100:4000").
18
- * Can also be an array of URLs to race.
19
- * The first successful connection wins.
20
- */
21
- proxyUrl: string | string[];
22
- /** Optional auth token for admin endpoints. */
23
- token?: string;
24
- /** Transport: "websocket" (default) or "http" (REST fallback). */
25
- transport?: 'websocket' | 'http';
26
- /** Connection timeout per URL in ms (default: 10000). */
27
- connectTimeoutMs?: number;
16
+ /**
17
+ * Primary proxy URL (e.g. "http://192.168.10.100:4000").
18
+ * Can also be an array of URLs to race.
19
+ * The first successful connection wins.
20
+ */
21
+ proxyUrl: string | string[];
22
+ /** Optional auth token for admin endpoints. */
23
+ token?: string;
24
+ /** Transport: "websocket" (default) or "http" (REST fallback). */
25
+ transport?: "websocket" | "http";
26
+ /** Connection timeout per URL in ms (default: 10000). */
27
+ connectTimeoutMs?: number;
28
28
  }
29
29
  export interface DirectClientConfig {
30
- directUrl: string;
31
- type: 'direct';
32
- username?: string;
33
- password?: string;
30
+ directUrl: string;
31
+ type: "direct";
32
+ username?: string;
33
+ password?: string;
34
34
  }
35
- export type BackendConnectionState = 'connected' | 'disconnected' | 'connecting';
35
+ export type BackendConnectionState = "connected" | "disconnected" | "connecting";
36
36
  export type CamStackClientConfig = ProxyClientConfig | DirectClientConfig;
37
37
  export declare function isProxyConfig(config: CamStackClientConfig): config is ProxyClientConfig;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@camstack/sdk",
3
- "version": "1.2.128",
3
+ "version": "1.2.131",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
7
- "types": "dist/sdk/src/index.d.ts",
7
+ "types": "dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
- "types": "./dist/sdk/src/index.d.ts",
10
+ "types": "./dist/index.d.ts",
11
11
  "import": "./dist/index.js",
12
12
  "require": "./dist/index.cjs"
13
13
  }
@@ -21,7 +21,7 @@
21
21
  "dist"
22
22
  ],
23
23
  "scripts": {
24
- "build": "vite build && tsc -p tsconfig.build.json",
24
+ "build": "vite build && npx tsx ../../scripts/emit-isolated-dts.ts --root . --src src --out dist",
25
25
  "typecheck": "tsc --noEmit -p tsconfig.spec.json",
26
26
  "test": "vitest run",
27
27
  "publish:npm": "npm publish --access public"
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,13 +0,0 @@
1
- /**
2
- * `subscribeEvent` fans one WS subscription out to N listeners.
3
- *
4
- * Measured on the viewer's boot: ~40 tRPC subscriptions before first paint,
5
- * of which 24 were twelve camera cards subscribing to the SAME two motion
6
- * categories and filtering by deviceId inside their own callbacks. Each was a
7
- * separate handshake on a transport that does not batch.
8
- *
9
- * The tests exercise the real `System` with a stubbed tRPC client, so
10
- * what is asserted is the number of `live.onEvent.subscribe` calls the SDK
11
- * actually makes — not a mock of the deduping itself.
12
- */
13
- export {};