@camera.ui/browser 0.0.81 → 0.0.83

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.
Files changed (113) hide show
  1. package/dist/bundle.js +1 -1
  2. package/dist/types/packages/client/browser/src/client.d.ts +1 -7
  3. package/dist/types/packages/client/browser/src/proxy/cameraDevice.d.ts +4 -14
  4. package/dist/types/packages/client/browser/src/proxy/index.d.ts +0 -2
  5. package/dist/types/packages/client/browser/src/streaming/go2rts-session.d.ts +2 -0
  6. package/dist/types/server/src/api/database/index.d.ts +11 -8
  7. package/dist/types/server/src/api/database/migration.d.ts +12 -0
  8. package/dist/types/server/src/api/database/types.d.ts +22 -2
  9. package/dist/types/server/src/api/go2rtc/api/streams.d.ts +4 -4
  10. package/dist/types/server/src/api/go2rtc/types.d.ts +6 -2
  11. package/dist/types/server/src/api/schemas/backup.schema.d.ts +18 -18
  12. package/dist/types/server/src/api/schemas/cameras.schema.d.ts +116 -96
  13. package/dist/types/server/src/api/schemas/config.schema.d.ts +11 -11
  14. package/dist/types/server/src/api/schemas/go2rtc.schema.d.ts +60 -60
  15. package/dist/types/server/src/api/schemas/plugins.schema.d.ts +47 -0
  16. package/dist/types/server/src/api/schemas/users.schema.d.ts +499 -112
  17. package/dist/types/server/src/api/services/cameras.service.d.ts +1 -1
  18. package/dist/types/server/src/api/services/users.service.d.ts +12 -3
  19. package/dist/types/server/src/api/types/index.d.ts +41 -30
  20. package/dist/types/server/src/api.d.ts +3 -3
  21. package/dist/types/server/src/camera/controller.d.ts +11 -11
  22. package/dist/types/server/src/camera/device.d.ts +15 -3
  23. package/dist/types/server/src/camera/index.d.ts +23 -46
  24. package/dist/types/server/src/camera/interfaces/camera.d.ts +1 -1
  25. package/dist/types/server/src/camera/types.d.ts +2 -21
  26. package/dist/types/server/src/camera/videoFrame.d.ts +3 -3
  27. package/dist/types/server/src/decoder/types.d.ts +12 -10
  28. package/dist/types/server/src/decoder/worker.d.ts +3 -5
  29. package/dist/types/server/src/nats/connection.d.ts +17 -0
  30. package/dist/types/server/src/nats/error.d.ts +9 -0
  31. package/dist/types/server/src/nats/index.d.ts +12 -9
  32. package/dist/types/server/src/nats/messageQueue.d.ts +20 -0
  33. package/dist/types/server/src/nats/proxy/cameraDevice.d.ts +8 -19
  34. package/dist/types/server/src/nats/proxy/deviceManager.d.ts +6 -21
  35. package/dist/types/server/src/nats/server.d.ts +0 -1
  36. package/dist/types/server/src/nats/subscription.d.ts +12 -0
  37. package/dist/types/server/src/nats/types.d.ts +44 -102
  38. package/dist/types/server/src/nats/utils.d.ts +2 -4
  39. package/dist/types/server/src/plugins/index.d.ts +3 -5
  40. package/dist/types/server/src/plugins/interfaces/audioDetection.d.ts +7 -0
  41. package/dist/types/server/src/plugins/{base.d.ts → interfaces/base.d.ts} +2 -2
  42. package/dist/types/server/src/plugins/interfaces/motionDetection.d.ts +6 -0
  43. package/dist/types/server/src/plugins/interfaces/objectDetection.d.ts +7 -0
  44. package/dist/types/server/src/plugins/plugin.d.ts +4 -13
  45. package/dist/types/server/src/plugins/types.d.ts +16 -5
  46. package/dist/types/server/src/plugins/worker.d.ts +1 -1
  47. package/dist/types/server/src/polyglot/node/plugins/cameraStorage.d.ts +2 -2
  48. package/dist/types/server/src/polyglot/node/plugins/{api.d.ts → pluginApi.d.ts} +10 -17
  49. package/dist/types/server/src/polyglot/node/plugins/{logger.d.ts → pluginLogger.d.ts} +2 -0
  50. package/dist/types/server/src/polyglot/node/plugins/proxy/cameraDevice.d.ts +12 -26
  51. package/dist/types/server/src/polyglot/node/plugins/proxy/deviceManager.d.ts +6 -8
  52. package/dist/types/server/src/polyglot/node/plugins/schema.d.ts +14 -10
  53. package/dist/types/server/src/polyglot/node/plugins/storageController.d.ts +2 -2
  54. package/dist/types/server/src/services/config/index.d.ts +3 -2
  55. package/dist/types/server/src/services/config/types.d.ts +4 -4
  56. package/dist/types/server/src/services/logger/index.d.ts +2 -0
  57. package/dist/types/server/src/utils/ffmpeg.d.ts +2 -0
  58. package/dist/types/server/src/utils/pythonInstaller.d.ts +1 -1
  59. package/dist/types/server/src/utils/subscribed.d.ts +4 -4
  60. package/dist/types/server/src/utils/utils.d.ts +1 -2
  61. package/package.json +6 -6
  62. package/dist/types/packages/client/browser/src/proxy/pluginsManager.d.ts +0 -10
  63. package/dist/types/packages/client/browser/src/proxy/systemManager.d.ts +0 -10
  64. package/dist/types/server/src/api/controllers/api.controller.d.ts +0 -6
  65. package/dist/types/server/src/api/controllers/auth.controller.d.ts +0 -20
  66. package/dist/types/server/src/api/controllers/backup.controller.d.ts +0 -10
  67. package/dist/types/server/src/api/controllers/cameras.controller.d.ts +0 -33
  68. package/dist/types/server/src/api/controllers/config.controller.d.ts +0 -14
  69. package/dist/types/server/src/api/controllers/files.controller.d.ts +0 -8
  70. package/dist/types/server/src/api/controllers/frameWorkers.controller.d.ts +0 -16
  71. package/dist/types/server/src/api/controllers/plugins.controller.d.ts +0 -54
  72. package/dist/types/server/src/api/controllers/system.controller.d.ts +0 -14
  73. package/dist/types/server/src/api/controllers/users.controller.d.ts +0 -21
  74. package/dist/types/server/src/api/index.d.ts +0 -21
  75. package/dist/types/server/src/api/middlewares/authPermission.middleware.d.ts +0 -5
  76. package/dist/types/server/src/api/middlewares/authValidation.middleware.d.ts +0 -4
  77. package/dist/types/server/src/api/middlewares/pagination.middleware.d.ts +0 -3
  78. package/dist/types/server/src/api/plugins/cameraui.plugin.d.ts +0 -11
  79. package/dist/types/server/src/api/plugins/database.plugin.d.ts +0 -11
  80. package/dist/types/server/src/api/plugins/go2rtc.plugin.d.ts +0 -11
  81. package/dist/types/server/src/api/plugins/logger.plugin.d.ts +0 -7
  82. package/dist/types/server/src/api/plugins/socket.plugin.d.ts +0 -11
  83. package/dist/types/server/src/api/plugins/system.plugin.d.ts +0 -21
  84. package/dist/types/server/src/api/plugins/useragent.plugin.d.ts +0 -8
  85. package/dist/types/server/src/api/routes/api.routes.d.ts +0 -2
  86. package/dist/types/server/src/api/routes/auth.routes.d.ts +0 -2
  87. package/dist/types/server/src/api/routes/backup.routes.d.ts +0 -2
  88. package/dist/types/server/src/api/routes/cameras.routes.d.ts +0 -2
  89. package/dist/types/server/src/api/routes/config.routes.d.ts +0 -2
  90. package/dist/types/server/src/api/routes/files.routes.d.ts +0 -2
  91. package/dist/types/server/src/api/routes/frameWorkers.routes.d.ts +0 -2
  92. package/dist/types/server/src/api/routes/index.d.ts +0 -6
  93. package/dist/types/server/src/api/routes/plugins.routes.d.ts +0 -2
  94. package/dist/types/server/src/api/routes/system.routes.d.ts +0 -2
  95. package/dist/types/server/src/api/routes/users.routes.d.ts +0 -2
  96. package/dist/types/server/src/api/services/backup.service.d.ts +0 -10
  97. package/dist/types/server/src/api/utils/cert.d.ts +0 -11
  98. package/dist/types/server/src/api/utils/fetch.d.ts +0 -2
  99. package/dist/types/server/src/api/utils/moveFiles.d.ts +0 -1
  100. package/dist/types/server/src/camera/interfaces/audioDetection.d.ts +0 -10
  101. package/dist/types/server/src/camera/interfaces/motionDetection.d.ts +0 -10
  102. package/dist/types/server/src/camera/interfaces/objectDetection.d.ts +0 -10
  103. package/dist/types/server/src/decoder/ffmpeg.d.ts +0 -2
  104. package/dist/types/server/src/main.d.ts +0 -21
  105. package/dist/types/server/src/nats/proxy/index.d.ts +0 -4
  106. package/dist/types/server/src/nats/proxy/pluginsManager.d.ts +0 -12
  107. package/dist/types/server/src/nats/proxy/systemManager.d.ts +0 -8
  108. package/dist/types/server/src/nats/queue.d.ts +0 -17
  109. package/dist/types/server/src/polyglot/node/plugins/proxy/index.d.ts +0 -4
  110. package/dist/types/server/src/polyglot/node/plugins/proxy/pluginsManager.d.ts +0 -39
  111. package/dist/types/server/src/polyglot/node/plugins/proxy/queue.d.ts +0 -20
  112. package/dist/types/server/src/polyglot/node/plugins/proxy/systemManager.d.ts +0 -37
  113. /package/dist/types/server/src/polyglot/node/plugins/{config.d.ts → configService.d.ts} +0 -0
@@ -1,14 +1,8 @@
1
1
  import type { Camera } from '../../api/database/types.js';
2
- import type { CameraAudioDetectionInterface } from '../../camera/interfaces/audioDetection.js';
3
- import type { CameraInterface } from '../../camera/interfaces/camera.js';
4
- import type { CameraMotionDetectionInterface } from '../../camera/interfaces/motionDetection.js';
5
- import type { CameraObjectDetectionInterface } from '../../camera/interfaces/objectDetection.js';
6
- import type { CameraPrebufferInterface } from '../../camera/interfaces/prebuffer.js';
7
- import type { CameraPTZInterface } from '../../camera/interfaces/ptz.js';
8
- import type { CameraConfigInputSettings, Container, PrebufferState, SetValues, StateValues } from '../../camera/types.js';
2
+ import type { CameraConfigInputSettings, CameraInterfaces, Container, PrebufferState, SetValues, StateValues } from '../../camera/types.js';
9
3
  import type { IceServer } from '../../services/config/types.js';
10
4
  import type { MethodKeys, MethodType } from '../../types.js';
11
- import type { MessageQueue } from '../queue.js';
5
+ import type { MessageQueue } from '../messageQueue.js';
12
6
  import type { CameraDeviceProxyMethods, ProxyMessageStructure } from '../types.js';
13
7
  export declare class CameraDeviceProxy implements CameraDeviceProxyMethods {
14
8
  private api;
@@ -17,25 +11,20 @@ export declare class CameraDeviceProxy implements CameraDeviceProxyMethods {
17
11
  private pluginsService;
18
12
  private messageQueue;
19
13
  constructor(messageQueue: MessageQueue);
20
- connect(cameraId: string): void;
21
- disconnect(cameraId: string): void;
14
+ connect(cameraId: string, pluginId: string): void;
15
+ disconnect(cameraId: string, pluginId: string): void;
22
16
  getFfmpegPath(): string;
23
17
  getIceServers(): IceServer[];
24
- updateState<T extends keyof SetValues>(stateName: T, eventData: SetValues[T], cameraId: string): Promise<void>;
18
+ updateState<T extends keyof SetValues>(stateName: T, eventData: SetValues[T], cameraId: string, pluginId: string): Promise<void>;
25
19
  updatePrebufferState(sourceId: string, container: Container, state: PrebufferState, cameraId: string, pluginId: string): Promise<void>;
26
20
  addCameraSource(source: CameraConfigInputSettings, cameraId: string, pluginId: string): Promise<void>;
27
- updateCameraSource(id: string, source: Partial<CameraConfigInputSettings>, cameraId: string, pluginId: string): Promise<void>;
28
- removeCameraSource(id: string, cameraId: string, pluginId: string): Promise<void>;
21
+ updateCameraSource(sourceId: string, source: Partial<CameraConfigInputSettings>, cameraId: string, pluginId: string): Promise<void>;
22
+ removeCameraSource(sourceId: string, cameraId: string, pluginId: string): Promise<void>;
29
23
  refreshStates(cameraId: string): {
30
24
  camera: Camera;
31
25
  states: StateValues;
32
26
  cameraState: boolean;
33
27
  };
34
- onRequest<T extends MethodKeys<CameraInterface>>(delegateType: 'cameraDelegate', cameraId: string, fn: T, ...args: Parameters<MethodType<CameraInterface, T>>): Promise<ReturnType<MethodType<CameraInterface, T>>>;
35
- onRequest<T extends MethodKeys<CameraPrebufferInterface>>(delegateType: 'prebufferDelegate', cameraId: string, fn: T, ...args: Parameters<MethodType<CameraPrebufferInterface, T>>): Promise<ReturnType<MethodType<CameraPrebufferInterface, T>>>;
36
- onRequest<T extends MethodKeys<CameraPTZInterface>>(delegateType: 'ptzDelegate', cameraId: string, fn: T, ...args: Parameters<MethodType<CameraPTZInterface, T>>): Promise<ReturnType<MethodType<CameraPTZInterface, T>>>;
37
- onRequest<T extends MethodKeys<CameraMotionDetectionInterface>>(delegateType: 'motionDetectorDelegate', cameraId: string, fn: T, ...args: Parameters<MethodType<CameraMotionDetectionInterface, T>>): Promise<ReturnType<MethodType<CameraMotionDetectionInterface, T>>>;
38
- onRequest<T extends MethodKeys<CameraObjectDetectionInterface>>(delegateType: 'objectDetectorDelegate', cameraId: string, fn: T, ...args: Parameters<MethodType<CameraObjectDetectionInterface, T>>): Promise<ReturnType<MethodType<CameraObjectDetectionInterface, T>>>;
39
- onRequest<T extends MethodKeys<CameraAudioDetectionInterface>>(delegateType: 'audioDetectorDelegate', cameraId: string, fn: T, ...args: Parameters<MethodType<CameraAudioDetectionInterface, T>>): Promise<ReturnType<MethodType<CameraAudioDetectionInterface, T>>>;
28
+ onRequest<T extends keyof CameraInterfaces, K extends MethodKeys<CameraInterfaces[T]>>(cameraId: string, client: T, fn: K, ...args: Parameters<MethodType<CameraInterfaces[T], K>>): Promise<Awaited<ReturnType<MethodType<CameraInterfaces[T], K>>>>;
40
29
  handleMessage(message: ProxyMessageStructure): Promise<void | ProxyMessageStructure>;
41
30
  }
@@ -1,31 +1,16 @@
1
1
  import type { Camera } from '../../api/database/types.js';
2
2
  import type { CameraConfig } from '../../camera/types.js';
3
- import type { MessageQueue } from '../queue.js';
3
+ import type { MessageQueue } from '../messageQueue.js';
4
4
  import type { DeviceManagerServerProxyMethods, ProxyMessageStructure } from '../types.js';
5
5
  export declare class DeviceManagerProxy implements DeviceManagerServerProxyMethods {
6
6
  private camerasService;
7
7
  private pluginsService;
8
8
  private messageQueue;
9
9
  constructor(messageQueue: MessageQueue);
10
- getCameraByName(data: {
11
- name: string;
12
- pluginId: string;
13
- }): Camera | undefined;
14
- getCameraById(data: {
15
- id: string;
16
- pluginId: string;
17
- }): Camera | void;
18
- createCamera(data: {
19
- camera: CameraConfig;
20
- pluginId: string;
21
- }): Promise<Camera>;
22
- removeCameraByName(data: {
23
- name: string;
24
- pluginId: string;
25
- }): Promise<void>;
26
- removeCameraById(data: {
27
- id: string;
28
- pluginId: string;
29
- }): Promise<void>;
10
+ getCameraByName(cameraName: string): Camera | undefined;
11
+ getCameraById(cameraId: string): Camera | void;
12
+ createCamera(cameraConfig: CameraConfig, pluginId: string): Promise<Camera>;
13
+ removeCameraByName(cameraName: string, pluginId: string): Promise<void>;
14
+ removeCameraById(cameraId: string, pluginId: string): Promise<void>;
30
15
  handleMessage(message: ProxyMessageStructure): Promise<void | ProxyMessageStructure>;
31
16
  }
@@ -10,7 +10,6 @@ export declare class NatsServer {
10
10
  private clusterProcesses;
11
11
  private logger;
12
12
  private configService;
13
- private process;
14
13
  private tmpDir;
15
14
  private config;
16
15
  private manuallyKilled;
@@ -0,0 +1,12 @@
1
+ import { EventEmitter } from 'events';
2
+ import type { Msg, Subscription as NatsSubscription } from 'nats';
3
+ export declare interface ProxySubscription {
4
+ on(event: 'message', listener: (message: Msg) => void): this;
5
+ emit(event: 'message', message: Msg): boolean;
6
+ }
7
+ export declare class ProxySubscription extends EventEmitter implements ProxySubscription {
8
+ readonly subscriber: NatsSubscription;
9
+ constructor(subscriber: NatsSubscription);
10
+ listen(): Promise<void>;
11
+ close(): void;
12
+ }
@@ -1,15 +1,18 @@
1
1
  import type { Camera, VideoStreamingMode } from '../api/database/types.js';
2
2
  import type { CameraDevice } from '../camera/device.js';
3
3
  import type { CameraConfig, CameraConfigInputSettings, CameraDelegates, Container, PrebufferState, SetValues, StateValues } from '../camera/types.js';
4
- import type { BasePlugin } from '../plugins/base.js';
4
+ import type { AuthConfig } from '../decoder/types.js';
5
+ import type { AudioDetectionPlugin } from '../plugins/interfaces/audioDetection.js';
6
+ import type { BasePlugin } from '../plugins/interfaces/base.js';
7
+ import type { MotionDetectionPlugin } from '../plugins/interfaces/motionDetection.js';
8
+ import type { ObjectDetectionPlugin } from '../plugins/interfaces/objectDetection.js';
5
9
  import type { CameraExtension } from '../plugins/types.js';
6
- import type { CameraStorage } from '../polyglot/node/plugins/cameraStorage.js';
7
10
  import type { IceServer } from '../services/config/types.js';
8
- import type { MethodKeys } from '../types.js';
11
+ import type { DeserializedError, RemoteError } from './error.js';
9
12
  export interface QueueItem {
10
13
  message: ProxyMessageStructure;
11
14
  resolve: (response: any) => void;
12
- reject: (error: Error) => void;
15
+ reject: (error: RemoteError) => void;
13
16
  }
14
17
  export interface ProxyMessageStructure {
15
18
  requestId: string;
@@ -18,56 +21,24 @@ export interface ProxyMessageStructure {
18
21
  targetName?: string;
19
22
  pluginId: string;
20
23
  type: 'request' | 'reply';
21
- proxy: 'system' | 'device' | 'plugins' | 'camera';
22
- client: 'cameraFn' | 'pluginFn' | 'pluginStorage' | 'device' | 'system' | keyof CameraDelegates;
24
+ proxy: 'device' | 'camera' | 'plugin';
25
+ client: 'cameraFn' | 'pluginFn' | 'deviceFn' | 'storageFn' | keyof CameraDelegates;
23
26
  fn: string;
24
27
  args: any[];
25
28
  timeout: number;
26
29
  timestamp: number;
27
30
  response?: any;
28
- error?: any;
31
+ error?: DeserializedError;
29
32
  }
30
33
  export interface ProxyAuth {
31
- cluster: {
32
- user: string;
33
- pass: string;
34
- };
35
- server: {
36
- user: string;
37
- pass: string;
38
- };
34
+ cluster: AuthConfig;
35
+ server: AuthConfig;
39
36
  }
40
37
  export type WebsocketClientProxyEvent = 'updateDevice' | 'updateState';
41
38
  export interface StreamPayload {
42
39
  type: Exclude<VideoStreamingMode, 'webrtc' | 'webrtc/tcp'> | 'webrtc/offer' | 'webrtc/candidate';
43
40
  value: string;
44
41
  }
45
- export interface DeviceManagerServerProxyMethods {
46
- createCamera(data: {
47
- camera: CameraConfig;
48
- pluginId: string;
49
- }): Promise<Camera>;
50
- getCameraByName(data: {
51
- name: string;
52
- pluginId: string;
53
- }): Camera | void;
54
- getCameraById(data: {
55
- id: string;
56
- pluginId: string;
57
- }): Camera | void;
58
- removeCameraByName(data: {
59
- name: string;
60
- pluginId: string;
61
- }): Promise<void>;
62
- removeCameraById(data: {
63
- id: string;
64
- pluginId: string;
65
- }): Promise<void>;
66
- }
67
- export interface SystemManagerServerProxyMethods {
68
- }
69
- export interface PluginsManagerServerProxyMethods {
70
- }
71
42
  export interface CameraDeviceProxyMethods {
72
43
  connect(): void;
73
44
  disconnect(): void;
@@ -81,22 +52,38 @@ export interface CameraDeviceProxyMethods {
81
52
  cameraState: boolean;
82
53
  };
83
54
  addCameraSource(source: CameraConfigInputSettings): Promise<void>;
84
- updateCameraSource(id: string, source: Partial<CameraConfigInputSettings>): Promise<void>;
85
- removeCameraSource(id: string): Promise<void>;
55
+ updateCameraSource(sourceId: string, source: Partial<CameraConfigInputSettings>): Promise<void>;
56
+ removeCameraSource(sourceId: string): Promise<void>;
86
57
  }
87
- export type CameraDeviceProxyMethodNames = MethodKeys<CameraDeviceProxyMethods>;
88
- export interface DeviceManagerListenerMessagePayload {
89
- type: keyof DeviceManagerProxyEventCallbacks;
90
- data: DeviceManagerProxyEvents['cameraSelected'] | DeviceManagerProxyEvents['cameraDeselected'];
58
+ export interface CameraDeviceListenerStatePayload<K extends keyof StateValues> {
59
+ stateName: K;
60
+ data: {
61
+ newEvent: StateValues[K];
62
+ oldEvent: StateValues[K];
63
+ };
91
64
  }
92
- export interface DeviceManagerProxyMethods {
93
- getCameraByName(name: string): Promise<CameraDevice | undefined>;
94
- getCameraById(id: string): Promise<CameraDevice | undefined>;
95
- createCamera(camera: CameraConfig): Promise<CameraDevice>;
65
+ export interface CameraDeviceListenerMessagePayload {
66
+ type: 'removed' | 'updated' | 'cameraState' | 'prebufferState';
67
+ data?: any;
68
+ }
69
+ export interface DeviceManagerServerProxyMethods {
70
+ createCamera(camera: CameraConfig): Promise<Camera>;
71
+ getCameraByName(name: string): Camera | void;
72
+ getCameraById(id: string): Camera | void;
96
73
  removeCameraByName(name: string): Promise<void>;
97
74
  removeCameraById(id: string): Promise<void>;
98
75
  }
99
- export type DeviceManagerProxyMethodNames = MethodKeys<DeviceManagerProxyMethods>;
76
+ export interface DeviceManagerProxyMethods {
77
+ getCameraByName(cameraName: string): Promise<CameraDevice | undefined>;
78
+ getCameraById(cameraId: string): Promise<CameraDevice | undefined>;
79
+ createCamera(cameraConfig: CameraConfig): Promise<CameraDevice>;
80
+ removeCameraByName(cameraName: string): Promise<void>;
81
+ removeCameraById(cameraId: string): Promise<void>;
82
+ }
83
+ export interface DeviceManagerListenerMessagePayload {
84
+ type: keyof DeviceManagerProxyEventCallbacks;
85
+ data: DeviceManagerProxyEvents['cameraSelected'] | DeviceManagerProxyEvents['cameraDeselected'];
86
+ }
100
87
  export interface DeviceManagerProxyEvents {
101
88
  cameraSelected: {
102
89
  camera: Camera;
@@ -115,54 +102,9 @@ export interface DeviceManagerProxyGenericEvent<K extends keyof DeviceManagerPro
115
102
  type: K;
116
103
  data: DeviceManagerProxyEvents[K];
117
104
  }
118
- export interface SystemManagerListenerMessagePayload {
119
- type: keyof SystemManagerProxyEventCallbacks;
120
- data: any;
121
- }
122
- export interface SystemManagerProxyMethods {
123
- }
124
- export type SystemManagerProxyMethodNames = MethodKeys<SystemManagerProxyMethods>;
125
- export interface SystemManagerProxyMethodsListener {
126
- listen<E extends keyof SystemManagerProxyEventCallbacks>(eventType: E, callback: SystemManagerProxyEventCallbacks[E]): void;
127
- removeListener<E extends keyof SystemManagerProxyEventCallbacks>(eventType: E, callbackToRemove: SystemManagerProxyEventCallbacks[E]): void;
128
- removeAllListeners<E extends keyof SystemManagerProxyEventCallbacks>(eventType?: E): void;
129
- }
130
- export interface SystemManagerProxyEvents {
131
- }
132
- export type SystemManagerProxyEventCallbacks = {};
133
- export interface SystemManagerProxyGenericEvent<K extends keyof SystemManagerProxyEvents> {
134
- type: K;
135
- data: SystemManagerProxyEvents[K];
136
- }
137
- export interface PluginsManagerListenerMessagePayload {
138
- type: keyof PluginsManagerProxyEventCallbacks;
139
- data: any;
140
- }
141
- export interface PluginsManagerProxyMethods {
142
- }
143
- export type PluginsManagerProxyMethodNames = MethodKeys<PluginsManagerProxyMethods>;
144
- export interface PluginsManagerProxyMethodsListener {
145
- listen<E extends keyof PluginsManagerProxyEventCallbacks>(eventType: E, callback: PluginsManagerProxyEventCallbacks[E]): void;
146
- removeListener<E extends keyof PluginsManagerProxyEventCallbacks>(eventType: E, callbackToRemove: PluginsManagerProxyEventCallbacks[E]): void;
147
- removeAllListeners<E extends keyof PluginsManagerProxyEventCallbacks>(eventType?: E): void;
148
- }
149
- export interface PluginsManagerProxyEvents {
150
- }
151
- export type PluginsManagerProxyEventCallbacks = {};
152
- export interface PluginsManagerProxyGenericEvent<K extends keyof PluginsManagerProxyEvents> {
153
- type: K;
154
- data: PluginsManagerProxyEvents[K];
155
- }
156
- export type CallablePluginStorageMethods = Pick<CameraStorage, 'getConfig' | 'setConfig'>;
157
- export type CallablePluginMethods = Pick<BasePlugin, 'onFormSubmit'>;
158
- export interface CameraDeviceListenerStatePayload<K extends keyof StateValues> {
159
- stateName: K;
160
- data: {
161
- newEvent: StateValues[K];
162
- oldEvent: StateValues[K];
163
- };
164
- }
165
- export interface CameraDeviceListenerMessagePayload {
166
- type: 'removed' | 'updated' | 'cameraState' | 'prebufferState';
167
- data?: any;
105
+ export interface PluginMap {
106
+ base: BasePlugin;
107
+ motionDetection: MotionDetectionPlugin;
108
+ objectDetection: ObjectDetectionPlugin;
109
+ audioDetection: AudioDetectionPlugin;
168
110
  }
@@ -1,4 +1,2 @@
1
- export declare function generateSecureCredentials(): {
2
- user: string;
3
- pass: string;
4
- };
1
+ import type { AuthConfig } from '../decoder/types.js';
2
+ export declare function generateCredentials(): AuthConfig;
@@ -12,14 +12,14 @@ export declare class PluginManager {
12
12
  searchPaths: Set<string>;
13
13
  constructor();
14
14
  static isQualifiedPluginIdentifier(pluginName: string): boolean;
15
- static extractPluginScope(pluginName: string): string;
15
+ static extractPluginScope(pluginName: string): string | undefined;
16
16
  static extractPluginName(pluginName: string): string;
17
17
  static transformDisplaName(pluginName: string): string;
18
18
  static loadPackageJSON(installPath: string): IPackageJson;
19
19
  initializeInstalledPlugins(): Promise<void>;
20
20
  initializeInstalledPlugin(plugin: Plugin): Promise<void>;
21
- loadPlugin(absolutePath: string, pluginId?: string, storagePath?: string): Promise<Plugin>;
22
- removePlugin(plugin: Plugin, removeFromDb?: boolean, removeStorage?: boolean): Promise<void>;
21
+ loadPlugin(absolutePath: string): Promise<Plugin>;
22
+ removePlugin(plugin: Plugin, removeStorage?: boolean): Promise<void>;
23
23
  startPluginChild(pluginName: string): Promise<void>;
24
24
  stopPluginChild(pluginName: string): Promise<void>;
25
25
  initializePlugins(): Promise<void>;
@@ -27,6 +27,4 @@ export declare class PluginManager {
27
27
  private loadInstalledPlugins;
28
28
  private removeOrphanedPlugins;
29
29
  private handleDisabledPlugins;
30
- private loadDefaultPaths;
31
- private addNpmPrefixToSearchPaths;
32
30
  }
@@ -0,0 +1,7 @@
1
+ import { BasePlugin } from './base.js';
2
+ import type { AudioMetadata } from '../../decoder/types.js';
3
+ import type { AudioDetectionPluginResponse, RootSchema } from '../types.js';
4
+ export declare abstract class AudioDetectionPlugin extends BasePlugin {
5
+ abstract interfaceSchema(): RootSchema | void;
6
+ abstract detectAudio(audioPath: string, metadata: AudioMetadata, config: Record<string, any>): Promise<AudioDetectionPluginResponse>;
7
+ }
@@ -1,5 +1,5 @@
1
- import type { CameraDevice } from '../camera/device.js';
2
- import type { FormSubmitResponse } from './types.js';
1
+ import type { CameraDevice } from '../../camera/device.js';
2
+ import type { FormSubmitResponse } from '../types.js';
3
3
  export declare abstract class BasePlugin {
4
4
  abstract onFormSubmit(actionId: string, payload: any): Promise<FormSubmitResponse | void>;
5
5
  abstract configureCameras(cameras: CameraDevice[]): void;
@@ -0,0 +1,6 @@
1
+ import { BasePlugin } from './base.js';
2
+ import type { MotionDetectionPluginResponse, RootSchema } from '../types.js';
3
+ export declare abstract class MotionDetectionPlugin extends BasePlugin {
4
+ abstract interfaceSchema(): RootSchema | void;
5
+ abstract detectMotion(videoPath: string, config: Record<string, any>): Promise<MotionDetectionPluginResponse>;
6
+ }
@@ -0,0 +1,7 @@
1
+ import { BasePlugin } from './base.js';
2
+ import type { ImageMetadata } from '../../decoder/types.js';
3
+ import type { ObjectDetectionPluginResponse, RootSchema } from '../types.js';
4
+ export declare abstract class ObjectDetectionPlugin extends BasePlugin {
5
+ abstract interfaceSchema(): RootSchema | void;
6
+ abstract detectObjects(imagePath: string, metadata: ImageMetadata, config: Record<string, any>): Promise<ObjectDetectionPluginResponse>;
7
+ }
@@ -1,42 +1,33 @@
1
- import { PluginConfigService } from '../polyglot/node/plugins/config.js';
2
1
  import { PythonInstaller } from '../utils/pythonInstaller.js';
3
- import type { PluginConstructor } from '../api.js';
4
2
  import type { CameraUiPlugin, IPackageJson } from '../api/types/index.js';
5
3
  import type { PluginContract } from './types.js';
6
- export interface Context {
7
- engines?: Record<string, string>;
8
- dependencies?: Record<string, string>;
9
- }
10
4
  export declare class Plugin {
11
5
  private logger;
12
6
  private configService;
13
7
  private _disabled;
14
8
  private _info;
15
9
  private _contract;
16
- readonly main: string;
10
+ private loadContext;
17
11
  readonly id: string;
12
+ readonly main: string;
18
13
  readonly pluginName: string;
19
14
  readonly displayName: string;
20
15
  readonly scope?: string;
21
16
  readonly isPython: boolean;
22
- readonly isESM: boolean;
23
17
  readonly isSymLink: boolean;
24
18
  readonly installPath: string;
25
- readonly pythonInstallPath: string;
26
19
  readonly configFile: string;
27
20
  readonly storagePath: string;
28
21
  readonly py: PythonInstaller;
29
- readonly config: PluginConfigService;
30
- pluginConstructor?: PluginConstructor;
31
- private loadContext?;
32
22
  get contract(): PluginContract;
33
23
  get info(): CameraUiPlugin;
34
24
  set info(value: CameraUiPlugin);
35
25
  get disabled(): boolean;
36
26
  set disabled(value: boolean);
37
- constructor(pluginName: string, installPath: string, packageJSON: IPackageJson, pluginId: string, scope?: string, storagePath?: string);
27
+ constructor(pluginName: string, installPath: string, packageJSON: IPackageJson, pluginId: string, scope?: string);
38
28
  load(): Promise<void>;
39
29
  reparsePackageJson(): void;
40
30
  private parsePackageJson;
41
31
  private parseContract;
32
+ private getMainFile;
42
33
  }
@@ -1,4 +1,9 @@
1
1
  import type { Camera } from '../api/database/types.js';
2
+ import type { Detection } from '../camera/types.js';
3
+ export interface Context {
4
+ engines?: Record<string, string>;
5
+ dependencies?: Record<string, string>;
6
+ }
2
7
  export interface SchemaConfig {
3
8
  rootSchema: PluginRootSchema;
4
9
  config: Record<string, any>;
@@ -75,9 +80,9 @@ export interface JsonBaseSchema<T = any> {
75
80
  hidden?: boolean;
76
81
  group?: string;
77
82
  defaultValue?: T;
83
+ store?: boolean;
78
84
  }
79
85
  export interface PluginJsonBaseSchema<T = any> extends JsonBaseSchema<T> {
80
- store?: boolean;
81
86
  onSet?: (newValue: any, oldValue: any) => Promise<void>;
82
87
  onGet?: () => Promise<any>;
83
88
  }
@@ -134,13 +139,10 @@ export interface PluginJsonSchemaObject extends PluginJsonBaseSchema {
134
139
  export interface JsonSchemaObjectWithButtons extends JsonSchemaObject {
135
140
  buttons: [JsonSchemaButton, JsonSchemaButton?];
136
141
  }
137
- export interface JsonSchemaAnyOf {
138
- anyOf: JsonSchema[];
139
- }
140
142
  export interface JsonSchemaArray extends JsonBaseSchema {
141
143
  type: 'array';
142
144
  opened?: boolean;
143
- items?: JsonSchema | JsonSchemaAnyOf;
145
+ items?: JsonSchema;
144
146
  }
145
147
  export interface JsonSchemaButton {
146
148
  label: string;
@@ -171,4 +173,13 @@ export interface FormSubmitResponse {
171
173
  toast?: ToastMessage;
172
174
  schema?: FormSubmitSchema;
173
175
  }
176
+ export interface MotionDetectionPluginResponse {
177
+ filePath: string;
178
+ }
179
+ export interface ObjectDetectionPluginResponse {
180
+ detections: Detection[];
181
+ }
182
+ export interface AudioDetectionPluginResponse {
183
+ detected: boolean;
184
+ }
174
185
  export {};
@@ -30,6 +30,6 @@ export declare class PluginWorker {
30
30
  private handleClose;
31
31
  private reset;
32
32
  private updatePython;
33
- private listenToMessages;
33
+ private onChildMessage;
34
34
  private cleanedProcessEnv;
35
35
  }
@@ -1,5 +1,5 @@
1
1
  import type { PluginJsonSchema, PluginJsonSchemaForm, SchemaConfig } from '../../../plugins/types.js';
2
- import type { PluginAPI } from './api.js';
2
+ import type { API } from './pluginApi.js';
3
3
  export declare class CameraStorage {
4
4
  private cameraId;
5
5
  private instance;
@@ -8,7 +8,7 @@ export declare class CameraStorage {
8
8
  private _schema;
9
9
  private _values;
10
10
  get values(): Record<string, any>;
11
- constructor(api: PluginAPI, instance: any, cameraId: string, schema?: PluginJsonSchemaForm);
11
+ constructor(api: API, instance: any, cameraId: string, schema?: PluginJsonSchemaForm);
12
12
  /**
13
13
  * Initialize the storage.
14
14
  * This will load the configuration from the database.
@@ -1,11 +1,12 @@
1
1
  import { EventEmitter } from 'node:events';
2
- import { DeviceManager, PluginsManager, SystemManager } from './proxy/index.js';
2
+ import { PluginConfigService } from './configService.js';
3
3
  import { StorageController } from './storageController.js';
4
- import type { BasePlugin } from '../../../plugins/base.js';
5
- import type { Plugin } from '../../../plugins/plugin.js';
6
- import type { PluginConfigService } from './config.js';
7
- import type { PluginLogger } from './logger.js';
8
- export declare interface API {
4
+ import type { AuthConfig } from '../../../decoder/types.js';
5
+ import type { BasePlugin } from '../../../plugins/interfaces/base.js';
6
+ import type { PluginInfo } from '../../../plugins/types.js';
7
+ import type { PluginLogger } from './pluginLogger.js';
8
+ import type { DeviceManager } from './proxy/deviceManager.js';
9
+ export declare interface PluginAPI {
9
10
  on(event: 'finishLaunching', listener: () => void): this;
10
11
  on(event: 'shutdown', listener: () => void): this;
11
12
  once(event: 'finishLaunching', listener: () => void): this;
@@ -16,26 +17,18 @@ export declare interface API {
16
17
  removeListener(event: 'shutdown', listener: () => void): this;
17
18
  removeAllListeners(event?: string): this;
18
19
  readonly deviceManager: DeviceManager;
19
- readonly pluginsManager: PluginsManager;
20
- readonly systemManager: SystemManager;
21
20
  readonly storageController: StorageController;
22
21
  readonly configService: PluginConfigService;
23
22
  readonly storagePath: string;
24
23
  readonly configFile: string;
25
24
  }
26
- export declare class PluginAPI extends EventEmitter implements API {
27
- private initialized;
25
+ export declare class API extends EventEmitter implements PluginAPI {
28
26
  readonly deviceManager: DeviceManager;
29
- readonly pluginsManager: PluginsManager;
30
- readonly systemManager: SystemManager;
31
27
  readonly storageController: StorageController;
32
28
  readonly configService: PluginConfigService;
33
29
  readonly storagePath: string;
34
30
  readonly configFile: string;
35
31
  readonly plugin: BasePlugin;
36
- constructor(plugin: Plugin, logger: PluginLogger, proxyEndpoints: string[], auth: {
37
- user: string;
38
- pass: string;
39
- });
40
- init(): Promise<void>;
32
+ constructor(plugin: PluginInfo, storagePath: string, configFile: string, logger: PluginLogger, proxyEndpoints: string[], auth: AuthConfig);
33
+ private loadModule;
41
34
  }
@@ -12,5 +12,7 @@ export declare class PluginLogger {
12
12
  attention(...args: any[]): void;
13
13
  debug(...args: any[]): void;
14
14
  trace(...args: any[]): void;
15
+ private formatMessage;
16
+ private formattedArgs;
15
17
  private formatDateTime;
16
18
  }
@@ -1,20 +1,17 @@
1
1
  import { CameraDevice } from '../../../../camera/device.js';
2
- import { CameraAudioDetectionInterface } from '../../../../camera/interfaces/audioDetection.js';
3
2
  import { CameraInterface } from '../../../../camera/interfaces/camera.js';
4
- import { CameraMotionDetectionInterface } from '../../../../camera/interfaces/motionDetection.js';
5
- import { CameraObjectDetectionInterface } from '../../../../camera/interfaces/objectDetection.js';
6
3
  import { CameraPrebufferInterface } from '../../../../camera/interfaces/prebuffer.js';
7
4
  import { CameraPTZInterface } from '../../../../camera/interfaces/ptz.js';
8
5
  import { MotionFrame, VideoFrame } from '../../../../camera/videoFrame.js';
9
6
  import type { Camera } from '../../../../api/database/types.js';
10
- import type { CameraAudioDetectionDelegate, CameraConfigInputSettings, CameraDelegate, CameraDelegates, CameraMotionDetectionDelegate, CameraObjectDetectionDelegate, CameraPrebufferDelegate, CameraPTZDelegate, CameraSource, SetValues } from '../../../../camera/types.js';
11
- import type { VideoFrame as VideoFrameImp } from '../../../../decoder/types.js';
7
+ import type { CameraConfigInputSettings, CameraDelegates, CameraSource, SetValues } from '../../../../camera/types.js';
8
+ import type { AuthConfig, VideoFrame as VideoFrameImp } from '../../../../decoder/types.js';
12
9
  import type { CameraDeviceProxyMethods } from '../../../../nats/types.js';
13
10
  import type { PluginInfo } from '../../../../plugins/types.js';
14
11
  import type { IceServer } from '../../../../services/config/types.js';
15
12
  import type { MethodKeys, MethodType } from '../../../../types.js';
16
- import type { PluginAPI } from '../api.js';
17
- import type { PluginLogger } from '../logger.js';
13
+ import type { API } from '../pluginApi.js';
14
+ import type { PluginLogger } from '../pluginLogger.js';
18
15
  export declare class CameraDeviceProxy extends CameraDevice {
19
16
  private api;
20
17
  private initialized;
@@ -42,17 +39,11 @@ export declare class CameraDeviceProxy extends CameraDevice {
42
39
  private auth;
43
40
  private proxyEndpoints;
44
41
  private plugin;
45
- cameraDelegate: CameraInterface;
46
- prebufferDelegate: CameraPrebufferInterface;
47
- ptzDelegate: CameraPTZInterface;
48
- audioDetectorDelegate: CameraAudioDetectionInterface;
49
- motionDetectorDelegate: CameraMotionDetectionInterface;
50
- objectDetectorDelegate: CameraObjectDetectionInterface;
42
+ protected cameraDelegate: CameraInterface;
43
+ protected ptzDelegate: CameraPTZInterface;
44
+ protected prebufferDelegate: CameraPrebufferInterface;
51
45
  get sources(): CameraSource[];
52
- constructor(api: PluginAPI, logger: PluginLogger, camera: Camera, plugin: PluginInfo, proxyEndpoints: string[], auth: {
53
- user: string;
54
- pass: string;
55
- });
46
+ constructor(api: API, logger: PluginLogger, camera: Camera, plugin: PluginInfo, proxyEndpoints: string[], auth: AuthConfig);
56
47
  init(): Promise<void>;
57
48
  setDelegate<T extends keyof CameraDelegates>(name: T, delegate: CameraDelegates[T]): void;
58
49
  connect(): Promise<void>;
@@ -74,13 +65,8 @@ export declare class CameraDeviceProxy extends CameraDevice {
74
65
  private closeFrameSubscriber;
75
66
  private closeMotionFrameSubsciber;
76
67
  private requestHandler;
77
- private listenToMessages;
78
- private listenToSignalingMessages;
79
- onRequest<T extends MethodKeys<CameraDeviceProxyMethods>>(client: 'cameraFn', fn: T, args?: Parameters<MethodType<CameraDeviceProxyMethods, T>>, timeout?: number): Promise<any>;
80
- onRequest<T extends MethodKeys<CameraDelegate>>(client: 'cameraDelegate', fn: T, args?: Parameters<MethodType<CameraDelegate, T>>, timeout?: number): Promise<any>;
81
- onRequest<T extends MethodKeys<CameraPrebufferDelegate>>(client: 'prebufferDelegate', fn: T, args?: Parameters<MethodType<CameraPrebufferDelegate, T>>, timeout?: number): Promise<any>;
82
- onRequest<T extends MethodKeys<CameraPTZDelegate>>(client: 'ptzDelegate', fn: T, args?: Parameters<MethodType<CameraPTZDelegate, T>>, timeout?: number): Promise<any>;
83
- onRequest<T extends MethodKeys<CameraMotionDetectionDelegate>>(client: 'motionDetectorDelegate', fn: T, args?: Parameters<MethodType<CameraMotionDetectionDelegate, T>>, timeout?: number): Promise<any>;
84
- onRequest<T extends MethodKeys<CameraObjectDetectionDelegate>>(client: 'objectDetectorDelegate', fn: T, args?: Parameters<MethodType<CameraObjectDetectionDelegate, T>>, timeout?: number): Promise<any>;
85
- onRequest<T extends MethodKeys<CameraAudioDetectionDelegate>>(client: 'audioDetectorDelegate', fn: T, args?: Parameters<MethodType<CameraAudioDetectionDelegate, T>>, timeout?: number): Promise<any>;
68
+ private onProxyMessage;
69
+ private onSignalingMessage;
70
+ onRequest<T extends MethodKeys<CameraDeviceProxyMethods>>(client: 'cameraFn', fn: T, args?: Parameters<MethodType<CameraDeviceProxyMethods, T>>, timeout?: number): Promise<Awaited<ReturnType<MethodType<CameraDeviceProxyMethods, T>>>>;
71
+ onRequest<T extends keyof CameraDelegates, K extends MethodKeys<CameraDelegates[T]>>(client: T, fn: K, args: Parameters<MethodType<CameraDelegates[T], K>>, timeout?: number): Promise<Awaited<ReturnType<MethodType<CameraDelegates[T], K>>>>;
86
72
  }