@camstack/sdk 0.1.35 → 0.1.36

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/nvr.d.ts CHANGED
@@ -4,20 +4,8 @@
4
4
  * These are the canonical types from the proxy's providers/types.ts,
5
5
  * now owned by the SDK so both app and proxy can share them.
6
6
  */
7
- export interface StreamOption {
8
- /** Unique identifier for this option (e.g. "auto", "cam_main", "mjpeg"). */
9
- id: string;
10
- /** Display label (e.g. "Auto", "High (WebRTC)", "MJPEG"). */
11
- label: string;
12
- /** Streaming technology. */
13
- method: "webrtc" | "mjpeg" | "hls" | "rtsp";
14
- /** go2rtc stream name (required for WebRTC). */
15
- streamName?: string;
16
- /** Raw source URL (RTSP, etc.) — for display/copy in admin UI. */
17
- sourceUrl?: string;
18
- /** Group label for UI separators (e.g. "go2rtc", "Frigate", "Scrypted"). */
19
- group?: string;
20
- }
7
+ import type { StreamSourceEntry } from '@camstack/types';
8
+ export type { StreamSourceEntry };
21
9
  export interface NvrCamera {
22
10
  name: string;
23
11
  /** Display label (may differ from internal name). */
@@ -27,8 +15,8 @@ export interface NvrCamera {
27
15
  hasPtz: boolean;
28
16
  /** Available stream names for this camera (e.g. ["cam_main", "cam_sub"]). */
29
17
  streams: string[];
30
- /** Available streaming options with method and quality info. Always includes "Auto". */
31
- streamOptions: StreamOption[];
18
+ /** Available streaming options. */
19
+ streamOptions: StreamSourceEntry[];
32
20
  /** Accessories/actions available on this camera (siren, floodlight, PTZ, etc.). */
33
21
  accessories?: CameraAccessory[];
34
22
  }
@@ -282,4 +270,3 @@ export interface ProviderConfigs {
282
270
  }>;
283
271
  enabledDetectionSources?: string[];
284
272
  }
285
- export {};
@@ -0,0 +1,230 @@
1
+ /**
2
+ * System — single, unified entry point for the camstack client API.
3
+ *
4
+ * Devices are returned as typed `DeviceProxy` objects (auto-injecting
5
+ * `deviceId` + `nodeId`), system caps are exposed as typed namespaces
6
+ * (`system.userManagement`, `system.storage`, etc.), and live events
7
+ * flow through a single `subscribeEvent` helper.
8
+ *
9
+ * The escape hatches (`trpcClient`, `wsClient`) are still public so the
10
+ * ui-library Provider can seed React Query with the same WS connection
11
+ * — a future phase will narrow the surface further.
12
+ */
13
+ import { createWSClient, type TRPCClient } from '@trpc/client';
14
+ import type { DeviceProxy, DeviceQueryFilters, DeviceLifecycleListener, SystemProxy } from '@camstack/types';
15
+ import type { BackendAppRouter } from './backend-router.js';
16
+ import type { BackendConnectionState } from './types.js';
17
+ /**
18
+ * Canonical user-info shape returned by `getMe()`. Mirrors the server's
19
+ * `auth.me` output — kept narrow so SDK consumers don't need the full
20
+ * tRPC inference chain to type a login flow.
21
+ */
22
+ export interface UserInfo {
23
+ readonly id: string;
24
+ readonly username: string;
25
+ readonly role: string;
26
+ readonly permissions?: {
27
+ readonly allowedAddons?: ReadonlyArray<string> | '*';
28
+ readonly allowedDevices?: Readonly<Record<string, ReadonlyArray<string> | '*'>>;
29
+ };
30
+ }
31
+ export interface SystemConfig {
32
+ /** Backend server URL (e.g. "http://localhost:4443"). */
33
+ readonly serverUrl: string;
34
+ /** JWT token for authentication. */
35
+ readonly token?: string;
36
+ /** Use WebSocket transport (default: true in browser, false in Node). */
37
+ readonly useWebSocket?: boolean;
38
+ /** Optional per-event connection-state callback. */
39
+ readonly onConnectionChange?: (state: BackendConnectionState) => void;
40
+ /** Initial WS reconnect delay in ms (default 2000, capped via maxRetryDelayMs). */
41
+ readonly retryDelayMs?: number;
42
+ /** Max WS reconnect delay in ms (default 30_000). */
43
+ readonly maxRetryDelayMs?: number;
44
+ }
45
+ type ConnectionListener = (state: BackendConnectionState, version: number) => void;
46
+ export interface SystemLiveEvent<TData = unknown> {
47
+ readonly id: string;
48
+ readonly timestamp: Date | string;
49
+ readonly source: {
50
+ readonly type: string;
51
+ readonly id: string | number;
52
+ };
53
+ readonly category: string;
54
+ readonly data: TData;
55
+ }
56
+ export type SystemLiveEventListener<TData = unknown> = (event: SystemLiveEvent<TData>) => void;
57
+ type TrpcClient = TRPCClient<BackendAppRouter>;
58
+ type TrpcWsClient = ReturnType<typeof createWSClient>;
59
+ export declare class System {
60
+ readonly serverUrl: string;
61
+ private readonly useWs;
62
+ private readonly baseRetryMs;
63
+ private readonly maxRetryMs;
64
+ private readonly onConnectionChange;
65
+ private token;
66
+ private _trpcClient;
67
+ private _wsClient;
68
+ private mirror;
69
+ private mirrorInit;
70
+ private connected;
71
+ private connectedPromise;
72
+ private _systemProxy;
73
+ private _connectionVersion;
74
+ private readonly connectionListeners;
75
+ constructor(config: SystemConfig);
76
+ get connectionVersion(): number;
77
+ /**
78
+ * Subscribe to connection-state transitions. Called with `('connected'
79
+ * | 'disconnected' | 'connecting', version)` whenever the SDK opens,
80
+ * closes, or starts a manual reconnect. Listener errors are swallowed
81
+ * so a misbehaving consumer cannot break the SDK's event loop.
82
+ */
83
+ subscribeConnectionEvents(cb: ConnectionListener): () => void;
84
+ private emitConnectionEvent;
85
+ /**
86
+ * Wait until the underlying tRPC transport is connected AND the
87
+ * server has responded to a cheap auth round-trip (`auth.me`). This
88
+ * is the canonical "ready to issue queries" gate.
89
+ *
90
+ * Why a probe, not just `ws.readyState === OPEN`?
91
+ * The WS handshake completes asynchronously: tRPC's `wsLink`
92
+ * queues outgoing messages and only flushes them after `open()`
93
+ * resolves (post `connectionParams` send). On the server, the
94
+ * tRPC context is created lazily once the connectionParams
95
+ * message is received. A query fired between WS-open and
96
+ * connection-params-processed is technically queued by tRPC, but
97
+ * the auth context for that query is only resolved once the
98
+ * handshake message is decoded server-side. A probe round-trip is
99
+ * the safest way to confirm both sides have agreed on the auth
100
+ * identity before the React tree starts firing parallel queries
101
+ * (which can otherwise land before any addon-side service
102
+ * discovery has settled, returning empty results that get cached).
103
+ *
104
+ * Idempotent — concurrent callers await the same in-flight Promise.
105
+ * Bounded by `timeoutMs` (default 15s) — beyond which a
106
+ * `Error('System.awaitConnected: probe timed out after Xms')` is
107
+ * thrown so the host can render a clear error state instead of
108
+ * hanging on a bricked socket.
109
+ */
110
+ awaitConnected(timeoutMs?: number): Promise<void>;
111
+ /**
112
+ * Warm-boot the device mirror. Awaits the transport probe first
113
+ * (`awaitConnected`) so the three mirror round-trips
114
+ * (`getAllBindings` + `getAllSnapshots` + `listAll`) cannot race
115
+ * against the WS auth handshake. Subsequent `getDevice(id)` calls
116
+ * are sync; live `device.*` event subscriptions keep the caches
117
+ * fresh.
118
+ *
119
+ * Idempotent — concurrent callers await the same in-flight Promise.
120
+ */
121
+ init(timeoutMs?: number): Promise<void>;
122
+ /** Promise that resolves once `init()` has completed. */
123
+ awaitReady(): Promise<void>;
124
+ /** True after `init()` resolves. */
125
+ isReady(): boolean;
126
+ /** True after the transport probe has succeeded at least once. */
127
+ isConnected(): boolean;
128
+ /**
129
+ * Force a fresh WebSocket handshake. Tears down the wsClient + tRPC
130
+ * client + mirror (the mirror captures the tRPC reference at
131
+ * construction time and would otherwise dispatch through a closed
132
+ * client) and rebuilds them. No-op for HTTP transport.
133
+ */
134
+ reconnect(): void;
135
+ /** Tear down WS connection + mirror. The instance is unusable afterwards. */
136
+ close(): void;
137
+ private disposeMirror;
138
+ login(username: string, password: string): Promise<{
139
+ token: string;
140
+ }>;
141
+ logout(): Promise<void>;
142
+ getMe(): Promise<UserInfo>;
143
+ /** Update the auth token (e.g. after login or token refresh). */
144
+ setToken(token: string): void;
145
+ /**
146
+ * Synchronous snapshot of every device matching the optional filters.
147
+ * Backed by the `SystemMirror` warm-boot cache — call `init()` first
148
+ * (or `awaitReady()`) before invoking. Returns an empty array if the
149
+ * mirror has not yet been booted.
150
+ *
151
+ * Each returned proxy has `binding` populated from the mirror's
152
+ * binding cache (Phase 5 dedup), so consumers no longer need to
153
+ * make a separate `deviceManager.getBindings` round-trip.
154
+ */
155
+ listDevices(filters?: DeviceQueryFilters): readonly DeviceProxy[];
156
+ /**
157
+ * Sync lookup by numeric id. `null` if the mirror has not been booted
158
+ * or the device is unknown.
159
+ */
160
+ getDevice(deviceId: number): DeviceProxy | null;
161
+ /** Sync lookup by display name (exact match). */
162
+ getDeviceByName(name: string): DeviceProxy | null;
163
+ /** Sync lookup by stableId. */
164
+ getDeviceByStableId(stableId: string): DeviceProxy | null;
165
+ /**
166
+ * Resolve when a device with `deviceId` becomes available. Resolves
167
+ * immediately if already known; rejects with a timeout error
168
+ * otherwise (default 30s).
169
+ */
170
+ waitForDevice(deviceId: number, timeoutMs?: number): Promise<DeviceProxy>;
171
+ /** Subscribe to `device.registered` events. */
172
+ onDeviceAdded(cb: DeviceLifecycleListener): () => void;
173
+ /** Subscribe to `device.unregistered` events. */
174
+ onDeviceRemoved(cb: DeviceLifecycleListener): () => void;
175
+ /**
176
+ * Patch the proxy's `binding` field from the mirror's cache. The
177
+ * generated `createDeviceProxy()` already sets `binding` to the
178
+ * binding it was constructed with — this is a defensive overwrite
179
+ * that uses the latest cached entry in case a `binding-changed`
180
+ * event landed between proxy creation and access.
181
+ */
182
+ private attachBinding;
183
+ /** Fetch the latest cached binding from the mirror, or `null`. */
184
+ private lookupBinding;
185
+ get addonPages(): SystemProxy['addonPages'];
186
+ get addonSettings(): SystemProxy['addonSettings'];
187
+ get alerts(): SystemProxy['alerts'];
188
+ get audioAnalyzer(): SystemProxy['audioAnalyzer'];
189
+ get audioCodec(): SystemProxy['audioCodec'];
190
+ get backup(): SystemProxy['backup'];
191
+ get decoder(): SystemProxy['decoder'];
192
+ get deviceManager(): SystemProxy['deviceManager'];
193
+ get deviceProvider(): SystemProxy['deviceProvider'];
194
+ get deviceState(): SystemProxy['deviceState'];
195
+ get metricsProvider(): SystemProxy['metricsProvider'];
196
+ get notificationOutput(): SystemProxy['notificationOutput'];
197
+ get pipelineExecutor(): SystemProxy['pipelineExecutor'];
198
+ get pipelineOrchestrator(): SystemProxy['pipelineOrchestrator'];
199
+ get pipelineRunner(): SystemProxy['pipelineRunner'];
200
+ get platformProbe(): SystemProxy['platformProbe'];
201
+ get recordingEngine(): SystemProxy['recordingEngine'];
202
+ get settingsStore(): SystemProxy['settingsStore'];
203
+ get storage(): SystemProxy['storage'];
204
+ get streamBroker(): SystemProxy['streamBroker'];
205
+ get turnProvider(): SystemProxy['turnProvider'];
206
+ get userManagement(): SystemProxy['userManagement'];
207
+ /**
208
+ * Subscribe to a single event category. Returns an unsubscribe
209
+ * handle. Errors thrown by the listener are swallowed so a single
210
+ * misbehaving consumer cannot tear down the WS subscription.
211
+ *
212
+ * Categories should be values from the `EventCategory` enum
213
+ * (`@camstack/types`) — passing a raw string works for forward-compat
214
+ * but loses type safety. The SDK forwards the value verbatim to the
215
+ * server's `live.onEvent` subscription.
216
+ */
217
+ subscribeEvent<TData = unknown>(category: string, cb: SystemLiveEventListener<TData>): () => void;
218
+ /** Direct tRPC client. Read once per call; rebuilt on `reconnect()`. */
219
+ get trpcClient(): TrpcClient;
220
+ /**
221
+ * Underlying WSClient (or `null` for HTTP transport). Used by
222
+ * advanced consumers that need direct access to the WebSocket
223
+ * (e.g. for keep-alive metrics). Rebuilt on `reconnect()`.
224
+ */
225
+ get wsClient(): TrpcWsClient | null;
226
+ private buildTrpcClient;
227
+ }
228
+ /** Create a `System` instance. Convenience factory. */
229
+ export declare function createSystem(config: SystemConfig): System;
230
+ export {};
@@ -167,11 +167,3 @@ export interface ReelEventsResult {
167
167
  events: ReelEvent[];
168
168
  total: number;
169
169
  }
170
- /** @deprecated Use DetectionEvent instead. */
171
- export type TimelineDetectionEvent = DetectionEvent;
172
- /** @deprecated Use MotionItem instead. */
173
- export type TimelineMotionItem = MotionItem;
174
- /** @deprecated Use TimelineArtifact instead. */
175
- export type TimelineArtifactItem = TimelineArtifact;
176
- /** @deprecated Use TimelineCluster instead. */
177
- export type TimelineClusterFromServer = TimelineCluster;
package/dist/types.d.ts CHANGED
@@ -32,13 +32,6 @@ export interface DirectClientConfig {
32
32
  username?: string;
33
33
  password?: string;
34
34
  }
35
- export interface BackendClientConfig {
36
- /** Backend server URL (e.g. "http://localhost:4443") */
37
- readonly serverUrl: string;
38
- /** JWT token for authentication */
39
- readonly token?: string;
40
- /** Connection timeout in ms (default: 10000) */
41
- readonly connectTimeoutMs?: number;
42
- }
35
+ export type BackendConnectionState = 'connected' | 'disconnected' | 'connecting';
43
36
  export type CamStackClientConfig = ProxyClientConfig | DirectClientConfig;
44
37
  export declare function isProxyConfig(config: CamStackClientConfig): config is ProxyClientConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/sdk",
3
- "version": "0.1.35",
3
+ "version": "0.1.36",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -32,6 +32,7 @@
32
32
  "@trpc/server": "^11.16.0",
33
33
  "@types/node": "^22.19.13",
34
34
  "tsup": "^8.5.1",
35
- "typescript": "^5.7.0"
35
+ "typescript": "^5.7.0",
36
+ "zod": "^4.3.6"
36
37
  }
37
38
  }
@@ -1,315 +0,0 @@
1
- /**
2
- * Backend client — connects directly to the CamStack NestJS backend via tRPC.
3
- *
4
- * Use this when the client needs to talk to the backend server directly
5
- * (admin UI, local agent, embedded mode) rather than going through the proxy.
6
- *
7
- * Features: full typed access to all backend tRPC routes (auth, devices, providers,
8
- * pipeline, agents, addons, bridge pipeline, recording, events, live subscriptions).
9
- */
10
- import { createTRPCClient } from "@trpc/client";
11
- import type { BackendAppRouter } from "./backend-router.js";
12
- export type SettingsSection = 'server' | 'auth' | 'features' | 'storage' | 'logging' | 'addons' | 'recording' | 'streaming' | 'ffmpeg' | 'detection' | 'backup' | 'retention';
13
- export interface BackendClientConfig {
14
- /** Backend server URL (e.g. "http://localhost:4443") */
15
- readonly serverUrl: string;
16
- /** JWT token for authentication */
17
- readonly token?: string;
18
- /** Connection timeout in ms (default: 10000) */
19
- readonly connectTimeoutMs?: number;
20
- /** Use WebSocket for all queries/mutations (default: true in browser, false in Node) */
21
- readonly useWebSocket?: boolean;
22
- }
23
- export declare class BackendClient {
24
- /** Raw tRPC client — for advanced usage / direct path access */
25
- readonly trpc: ReturnType<typeof createTRPCClient<BackendAppRouter>>;
26
- readonly serverUrl: string;
27
- private token;
28
- private wsClient;
29
- constructor(config: BackendClientConfig);
30
- /** Update the auth token (e.g. after login) */
31
- setToken(token: string): void;
32
- /** Close the WebSocket connection (if using WS transport) */
33
- close(): void;
34
- login(username: string, password: string): Promise<{
35
- token: string;
36
- user: {
37
- id: string;
38
- username: string;
39
- role: import("@camstack/types").UserRole;
40
- };
41
- }>;
42
- getMe(): Promise<import("@camstack/types").AuthenticatedUser>;
43
- logout(): Promise<{
44
- success: boolean;
45
- }>;
46
- getSystemInfo(): Promise<{
47
- version: string;
48
- uptime: number;
49
- nodeVersion: string;
50
- platform: NodeJS.Platform;
51
- features: import("@camstack/types").FeatureManifest;
52
- }>;
53
- getFeatureFlags(): Promise<import("@camstack/types").FeatureManifest>;
54
- listProviders(): Promise<readonly import("@camstack/types").ProviderListItem[]>;
55
- getProvider(providerId: string): Promise<{
56
- id: string;
57
- type: string;
58
- name: string;
59
- discoveryMode: "auto" | "manual" | "both";
60
- status: import("@camstack/types").ProviderStatus;
61
- deviceCount: number;
62
- }>;
63
- startProvider(providerId: string): Promise<{
64
- success: boolean;
65
- }>;
66
- stopProvider(providerId: string): Promise<{
67
- success: boolean;
68
- }>;
69
- listProviderTypes(): Promise<{
70
- addonId: string;
71
- name: string;
72
- description: string;
73
- iconUrl: string | null;
74
- color: string;
75
- instanceMode: "unique" | "multiple";
76
- discoveryMode: "auto" | "manual" | "both";
77
- existingInstances: {
78
- id: string;
79
- name: string;
80
- }[];
81
- canAdd: boolean;
82
- }[]>;
83
- listDevices(): Promise<{
84
- id: string;
85
- name: string;
86
- providerId: string;
87
- type: import("@camstack/types").DeviceType;
88
- capabilities: import("@camstack/types").DeviceCapabilityName[];
89
- state: import("@camstack/types").DeviceState;
90
- }[]>;
91
- getDevice(deviceId: string): Promise<{
92
- id: string;
93
- name: string;
94
- providerId: string;
95
- type: import("@camstack/types").DeviceType;
96
- capabilities: import("@camstack/types").DeviceCapabilityName[];
97
- state: import("@camstack/types").DeviceState;
98
- metadata: import("@camstack/types").DeviceMetadata;
99
- }>;
100
- discoverDevices(providerId: string): Promise<import("@camstack/types").DiscoveredDevice[]>;
101
- adoptDevice(providerId: string, externalId: string): Promise<import("@camstack/types").IDevice>;
102
- createDevice(providerId: string, config: Record<string, unknown>): Promise<import("@camstack/types").IDevice>;
103
- /** Returns the URL path for a static asset served by an addon. */
104
- getAddonAssetUrl(addonId: string, assetPath: string): string;
105
- listAddons(): Promise<{
106
- manifest: import("@camstack/types").AddonManifest & {
107
- packageName: string;
108
- packageVersion: string;
109
- packageDisplayName?: string;
110
- protected?: boolean;
111
- removable?: boolean;
112
- };
113
- declaration?: import("@camstack/types").AddonDeclaration;
114
- hasConfigSchema: boolean;
115
- source: "core" | "installed" | "workspace";
116
- installSource?: "npm" | "workspace";
117
- }[]>;
118
- getAddonConfigSchema(addonId: string): Promise<import("@camstack/types").ConfigUISchema | null>;
119
- getAddonConfig(addonId: string): Promise<Record<string, unknown>>;
120
- updateAddonConfig(addonId: string, config: Record<string, unknown>): Promise<{
121
- success: boolean;
122
- }>;
123
- getAddonLogs(addonId: string, options?: {
124
- limit?: number;
125
- level?: 'debug' | 'info' | 'warn' | 'error';
126
- }): Promise<import("@camstack/types").LogEntry[]>;
127
- listKnownFaces(): Promise<{
128
- id: string;
129
- label: string;
130
- group?: string;
131
- cropBase64: string;
132
- createdAt: number;
133
- updatedAt: number;
134
- source?: string;
135
- metadata?: Readonly<Record<string, unknown>>;
136
- }[]>;
137
- registerFace(label: string, cropBase64: string, group?: string): Promise<never>;
138
- listPipelines(): Promise<{
139
- id: string;
140
- packageName: string;
141
- slot: import("@camstack/types").PipelineSlot | null;
142
- }[]>;
143
- getPipelineStatus(deviceId: string): Promise<import("@camstack/types").PipelineConfig | null>;
144
- listAgents(): Promise<readonly import("@camstack/types").AgentListItem[]>;
145
- dispatchTask(agentId: string, task: Record<string, unknown>): Promise<import("@camstack/types").AgentTaskResult>;
146
- getProcessTree(): Promise<{
147
- id: string;
148
- name: string;
149
- pid: number;
150
- state: "running";
151
- cpuPercent: number;
152
- memoryPercent: number;
153
- memoryMB: number;
154
- isHub: boolean;
155
- platform: string;
156
- arch: string;
157
- host: string;
158
- capabilities: string[];
159
- installedAddons: string[];
160
- pythonRuntimes: string[];
161
- connectedSince: number;
162
- subProcesses: unknown[];
163
- }[]>;
164
- bridgeListAddons(): Promise<{
165
- id: string;
166
- packageName: string;
167
- slot: import("@camstack/types").PipelineSlot | null;
168
- }[]>;
169
- bridgeGetPipeline(deviceId: string): Promise<import("@camstack/types").PipelineConfig | null>;
170
- bridgeSetPipeline(deviceId: string, config: {
171
- video: unknown[];
172
- audio?: unknown;
173
- }): Promise<{
174
- success: boolean;
175
- }>;
176
- bridgeValidatePipeline(config: {
177
- video: unknown[];
178
- audio?: unknown;
179
- }): Promise<import("@camstack/types").ValidationResult>;
180
- bridgeGetAddonConfig(addonId: string): Promise<Record<string, unknown>>;
181
- bridgeSetAddonConfig(addonId: string, config: Record<string, unknown>): Promise<{
182
- success: boolean;
183
- }>;
184
- bridgeListPackages(): Promise<import("@camstack/types").InstalledPackage[]>;
185
- bridgeListAddonsPackages(): Promise<{
186
- manifest: import("@camstack/types").AddonManifest & {
187
- packageName: string;
188
- packageVersion: string;
189
- packageDisplayName?: string;
190
- protected?: boolean;
191
- removable?: boolean;
192
- };
193
- declaration?: import("@camstack/types").AddonDeclaration;
194
- hasConfigSchema: boolean;
195
- source: "core" | "installed" | "workspace";
196
- installSource?: "npm" | "workspace";
197
- }[]>;
198
- bridgeInstallPackage(packageName: string, version?: string): Promise<{
199
- success: boolean;
200
- loaded: string[];
201
- failed: string[];
202
- }>;
203
- bridgeUninstallPackage(packageName: string): Promise<{
204
- success: boolean;
205
- }>;
206
- getRecordingConfig(deviceId: string): Promise<unknown>;
207
- getRecordingPolicy(deviceId: string): Promise<unknown>;
208
- getRecordingPolicyStatus(deviceId: string): Promise<{
209
- deviceId: string;
210
- policyExists: boolean;
211
- enabled: any;
212
- mode: any;
213
- isRecording: boolean;
214
- }>;
215
- getRecordingSegments(deviceId: string, streamId: string, startTime: number, endTime: number): Promise<unknown>;
216
- getEvents(deviceId: string, options?: {
217
- limit?: number;
218
- offset?: number;
219
- }): Promise<import("@camstack/types").EventQueryResult>;
220
- getLogs(options?: {
221
- level?: 'debug' | 'info' | 'warn' | 'error';
222
- limit?: number;
223
- since?: number;
224
- until?: number;
225
- scope?: string[];
226
- }): Promise<import("@camstack/types").LogEntry[]>;
227
- replEval(code: string, scope?: {
228
- type: 'system';
229
- } | {
230
- type: 'device';
231
- deviceId: string;
232
- } | {
233
- type: 'provider';
234
- providerId: string;
235
- } | {
236
- type: 'addon';
237
- addonId: string;
238
- }): Promise<import("@camstack/types").ReplResult>;
239
- listUsers(): Promise<Omit<import("@camstack/types").UserRecord, "passwordHash">[]>;
240
- createUser(username: string, password: string, role: 'super_admin' | 'admin' | 'viewer'): Promise<{
241
- id: string;
242
- username: string;
243
- role: import("@camstack/types").UserRole;
244
- allowedProviders: string[] | "*";
245
- allowedDevices: Record<string, string[] | "*">;
246
- createdAt: number;
247
- updatedAt: number;
248
- }>;
249
- getTrackingSessions(deviceId?: string): Promise<{
250
- trackId: string;
251
- deviceId: string;
252
- className: string;
253
- label: string | undefined;
254
- firstSeen: number;
255
- lastSeen: number;
256
- totalFrames: number;
257
- state: string;
258
- globalId: string | undefined;
259
- positions: readonly {
260
- readonly x: number;
261
- readonly y: number;
262
- readonly t: number;
263
- }[];
264
- hasEmbedding: boolean;
265
- hasCrop: boolean;
266
- }[]>;
267
- listProcesses(): Promise<(import("@camstack/types").ManagedProcessStatus | {
268
- id: string;
269
- label: string;
270
- state: "running" | "stopped" | "crashed" | "starting";
271
- pid?: number;
272
- stats?: {
273
- pid: number;
274
- cpu: number;
275
- memory: number;
276
- uptime: number;
277
- restartCount: number;
278
- };
279
- restartCount: number;
280
- mode: "forked" | "in-process";
281
- })[]>;
282
- enableProvider(providerId: string): Promise<{
283
- success: boolean;
284
- }>;
285
- disableProvider(providerId: string): Promise<{
286
- success: boolean;
287
- }>;
288
- /** Fetch the UI schema for a single section, or all sections if omitted. */
289
- getSettingsSchema(section?: SettingsSection): Promise<{
290
- section: "auth" | "features" | "server" | "storage" | "logging" | "addons" | "recording" | "streaming" | "ffmpeg" | "detection" | "backup" | "retention";
291
- schema: import("@camstack/types").ConfigUISchema | null;
292
- readOnly: boolean;
293
- tabs?: undefined;
294
- schemas?: undefined;
295
- } | {
296
- tabs: readonly import("@camstack/types").SettingsTabDef[];
297
- schemas: Record<string, unknown>;
298
- section?: undefined;
299
- schema?: undefined;
300
- readOnly?: undefined;
301
- }>;
302
- getSettings(section: SettingsSection): Promise<{
303
- section: "auth" | "features" | "server" | "storage" | "logging" | "addons" | "recording" | "streaming" | "ffmpeg" | "detection" | "backup" | "retention";
304
- data: Record<string, unknown>;
305
- }>;
306
- updateSettings(section: SettingsSection, data: Record<string, unknown>): Promise<{
307
- success: boolean;
308
- section: "auth" | "features" | "server" | "storage" | "logging" | "addons" | "recording" | "streaming" | "ffmpeg" | "detection" | "backup" | "retention";
309
- }>;
310
- }
311
- /**
312
- * Create a BackendClient instance with the given config.
313
- * Convenience factory function.
314
- */
315
- export declare function createBackendClient(config: BackendClientConfig): BackendClient;