camstreamerlib 4.0.0-beta.4 → 4.0.0-beta.40

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 (239) hide show
  1. package/README.md +112 -0
  2. package/cjs/CamOverlayAPI.js +135 -92
  3. package/cjs/CamScripterAPI.js +52 -42
  4. package/cjs/CamStreamerAPI.js +83 -39
  5. package/cjs/CamSwitcherAPI.js +141 -123
  6. package/cjs/CamSwitcherEvents.js +4 -60
  7. package/cjs/PlaneTrackerAPI.js +200 -0
  8. package/cjs/VapixAPI.js +323 -233
  9. package/cjs/{CreatePackage.js → bin/CreatePackage.js} +22 -19
  10. package/cjs/errors/errors.js +64 -1
  11. package/cjs/index.js +17 -4
  12. package/cjs/internal/ProxyClient.js +28 -32
  13. package/cjs/internal/WsEvents.js +72 -0
  14. package/cjs/internal/types.js +2 -0
  15. package/cjs/internal/utils.js +22 -3
  16. package/cjs/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +7 -4
  17. package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +33 -0
  18. package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +5 -17
  19. package/cjs/node/CamOverlayPainter/ResourceManager.js +72 -0
  20. package/cjs/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +7 -4
  21. package/cjs/node/DefaultClient.js +10 -12
  22. package/cjs/{internal → node}/Digest.js +8 -5
  23. package/cjs/node/HttpRequestSender.js +14 -4
  24. package/cjs/node/HttpServer.js +15 -12
  25. package/cjs/{VapixEvents.js → node/VapixEvents.js} +1 -1
  26. package/cjs/node/WsClient.js +12 -9
  27. package/cjs/node/events/AxisCameraStationEvents.js +53 -0
  28. package/cjs/node/events/GenetecAgent.js +123 -0
  29. package/cjs/node/index.js +38 -5
  30. package/cjs/types/CamOverlayAPI/CamOverlayAPI.js +92 -0
  31. package/cjs/types/CamOverlayAPI/accuweatherSchema.js +47 -0
  32. package/cjs/types/CamOverlayAPI/customGraphicsSchema.js +72 -0
  33. package/cjs/types/CamOverlayAPI/imagesSchema.js +9 -0
  34. package/cjs/types/CamOverlayAPI/index.js +27 -0
  35. package/cjs/types/CamOverlayAPI/infotickerSchema.js +26 -0
  36. package/cjs/types/CamOverlayAPI/pipSchema.js +39 -0
  37. package/cjs/types/CamOverlayAPI/ptzCompassSchema.js +25 -0
  38. package/cjs/types/CamOverlayAPI/ptzSchema.js +12 -0
  39. package/cjs/types/CamOverlayAPI/scoreBoardSchema.js +132 -0
  40. package/cjs/types/CamOverlayAPI/screenSharingSchema.js +8 -0
  41. package/cjs/types/CamOverlayAPI/serviceCommonTypes.js +91 -0
  42. package/cjs/types/CamOverlayAPI/webCameraSharingSchema.js +8 -0
  43. package/cjs/types/CamOverlayDrawingAPI.js +2 -0
  44. package/cjs/types/CamOverlayPainter.js +14 -0
  45. package/cjs/types/CamScripterAPI.js +22 -7
  46. package/cjs/types/CamScripterAPICameraEventsGenerator.js +2 -0
  47. package/cjs/types/CamStreamerAPI.js +34 -3
  48. package/cjs/types/CamSwitcherAPI.js +38 -1
  49. package/cjs/types/CamSwitcherEvents.js +8 -0
  50. package/cjs/types/GenetecAgent.js +31 -0
  51. package/cjs/types/PlaneTrackerAPI.js +281 -0
  52. package/cjs/types/VapixAPI.js +71 -13
  53. package/cjs/types/VapixEvents.js +2 -0
  54. package/cjs/web/DefaultClient.js +22 -10
  55. package/cjs/web/WsClient.js +3 -3
  56. package/esm/CamOverlayAPI.js +131 -88
  57. package/esm/CamScripterAPI.js +48 -38
  58. package/esm/CamStreamerAPI.js +81 -38
  59. package/esm/CamSwitcherAPI.js +137 -119
  60. package/esm/CamSwitcherEvents.js +5 -61
  61. package/esm/PlaneTrackerAPI.js +196 -0
  62. package/esm/VapixAPI.js +315 -225
  63. package/esm/{CreatePackage.js → bin/CreatePackage.js} +3 -3
  64. package/esm/errors/errors.js +54 -0
  65. package/esm/index.js +12 -3
  66. package/esm/internal/ProxyClient.js +28 -32
  67. package/esm/internal/WsEvents.js +68 -0
  68. package/esm/internal/utils.js +17 -1
  69. package/esm/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +2 -2
  70. package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +33 -0
  71. package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +2 -13
  72. package/esm/{CamOverlayPainter → node/CamOverlayPainter}/ResourceManager.js +7 -5
  73. package/esm/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +2 -2
  74. package/esm/node/DefaultClient.js +10 -12
  75. package/esm/{internal → node}/Digest.js +1 -1
  76. package/esm/node/HttpRequestSender.js +14 -4
  77. package/esm/node/HttpServer.js +5 -5
  78. package/esm/{VapixEvents.js → node/VapixEvents.js} +1 -1
  79. package/esm/node/WsClient.js +3 -3
  80. package/esm/{events → node/events}/AxisCameraStationEvents.js +18 -13
  81. package/esm/node/events/GenetecAgent.js +119 -0
  82. package/esm/node/index.js +17 -2
  83. package/esm/types/CamOverlayAPI/CamOverlayAPI.js +76 -0
  84. package/esm/types/CamOverlayAPI/accuweatherSchema.js +44 -0
  85. package/esm/types/CamOverlayAPI/customGraphicsSchema.js +69 -0
  86. package/esm/types/CamOverlayAPI/imagesSchema.js +6 -0
  87. package/esm/types/CamOverlayAPI/index.js +11 -0
  88. package/esm/types/CamOverlayAPI/infotickerSchema.js +23 -0
  89. package/esm/types/CamOverlayAPI/pipSchema.js +36 -0
  90. package/esm/types/CamOverlayAPI/ptzCompassSchema.js +22 -0
  91. package/esm/types/CamOverlayAPI/ptzSchema.js +9 -0
  92. package/esm/types/CamOverlayAPI/scoreBoardSchema.js +129 -0
  93. package/esm/types/CamOverlayAPI/screenSharingSchema.js +5 -0
  94. package/esm/types/CamOverlayAPI/serviceCommonTypes.js +88 -0
  95. package/esm/types/CamOverlayAPI/webCameraSharingSchema.js +5 -0
  96. package/esm/types/CamOverlayPainter.js +11 -0
  97. package/esm/types/CamScripterAPI.js +21 -6
  98. package/esm/types/CamScripterAPICameraEventsGenerator.js +1 -0
  99. package/esm/types/CamStreamerAPI.js +33 -2
  100. package/esm/types/CamSwitcherAPI.js +38 -1
  101. package/esm/types/CamSwitcherEvents.js +8 -0
  102. package/esm/types/GenetecAgent.js +28 -0
  103. package/esm/types/PlaneTrackerAPI.js +278 -0
  104. package/esm/types/VapixAPI.js +70 -12
  105. package/esm/types/VapixEvents.js +1 -0
  106. package/esm/web/DefaultClient.js +22 -10
  107. package/esm/web/WsClient.js +3 -3
  108. package/package.json +30 -12
  109. package/types/CamOverlayAPI.d.ts +865 -0
  110. package/types/CamScripterAPI.d.ts +47 -0
  111. package/types/CamStreamerAPI.d.ts +64 -0
  112. package/types/CamSwitcherAPI.d.ts +167 -0
  113. package/types/CamSwitcherEvents.d.ts +8 -0
  114. package/types/PlaneTrackerAPI.d.ts +226 -0
  115. package/types/VapixAPI.d.ts +118 -0
  116. package/types/bin/CreatePackage.d.ts +1 -0
  117. package/{esm → types}/errors/errors.d.ts +28 -1
  118. package/types/index.d.ts +20 -0
  119. package/types/internal/ProxyClient.d.ts +10 -0
  120. package/types/internal/WsEvents.d.ts +41 -0
  121. package/types/internal/types.d.ts +45 -0
  122. package/{cjs → types}/internal/utils.d.ts +4 -1
  123. package/{cjs → types}/internal/versionCompare.d.ts +2 -2
  124. package/types/node/CamOverlayDrawingAPI.d.ts +41 -0
  125. package/{esm → types/node}/CamOverlayPainter/Frame.d.ts +8 -37
  126. package/{cjs → types/node}/CamOverlayPainter/Painter.d.ts +5 -21
  127. package/types/node/CamOverlayPainter/ResourceManager.d.ts +15 -0
  128. package/types/node/CamScripterAPICameraEventsGenerator.d.ts +31 -0
  129. package/types/node/DefaultClient.d.ts +16 -0
  130. package/{esm → types}/node/HttpRequestSender.d.ts +1 -0
  131. package/{cjs → types}/node/HttpServer.d.ts +2 -2
  132. package/types/node/VapixEvents.d.ts +16 -0
  133. package/{cjs → types}/node/WsClient.d.ts +3 -2
  134. package/types/node/events/AxisCameraStationEvents.d.ts +12 -0
  135. package/types/node/events/GenetecAgent.d.ts +16 -0
  136. package/types/node/index.d.ts +17 -0
  137. package/types/types/CamOverlayAPI/CamOverlayAPI.d.ts +4321 -0
  138. package/types/types/CamOverlayAPI/accuweatherSchema.d.ts +84 -0
  139. package/types/types/CamOverlayAPI/customGraphicsSchema.d.ts +700 -0
  140. package/types/types/CamOverlayAPI/imagesSchema.d.ts +95 -0
  141. package/types/types/CamOverlayAPI/index.d.ts +11 -0
  142. package/types/types/CamOverlayAPI/infotickerSchema.d.ts +96 -0
  143. package/types/types/CamOverlayAPI/pipSchema.d.ts +125 -0
  144. package/types/types/CamOverlayAPI/ptzCompassSchema.d.ts +93 -0
  145. package/types/types/CamOverlayAPI/ptzSchema.d.ts +118 -0
  146. package/types/types/CamOverlayAPI/scoreBoardSchema.d.ts +357 -0
  147. package/types/types/CamOverlayAPI/screenSharingSchema.d.ts +58 -0
  148. package/types/types/CamOverlayAPI/serviceCommonTypes.d.ts +145 -0
  149. package/types/types/CamOverlayAPI/webCameraSharingSchema.d.ts +58 -0
  150. package/types/types/CamOverlayDrawingAPI.d.ts +48 -0
  151. package/types/types/CamOverlayPainter.d.ts +76 -0
  152. package/types/types/CamScripterAPI.d.ts +130 -0
  153. package/types/types/CamScripterAPICameraEventsGenerator.d.ts +45 -0
  154. package/types/types/CamStreamerAPI.d.ts +272 -0
  155. package/{esm → types}/types/CamSwitcherAPI.d.ts +115 -36
  156. package/{cjs → types}/types/CamSwitcherEvents.d.ts +77 -0
  157. package/{esm/events → types/types}/GenetecAgent.d.ts +47 -47
  158. package/types/types/PlaneTrackerAPI.d.ts +877 -0
  159. package/{cjs → types}/types/VapixAPI.d.ts +647 -465
  160. package/types/types/VapixEvents.d.ts +15 -0
  161. package/{esm → types}/types/common.d.ts +15 -5
  162. package/types/web/DefaultClient.d.ts +6 -0
  163. package/cjs/CamOverlayAPI.d.ts +0 -31
  164. package/cjs/CamOverlayDrawingAPI.d.ts +0 -86
  165. package/cjs/CamOverlayPainter/Frame.d.ts +0 -96
  166. package/cjs/CamOverlayPainter/ResourceManager.d.ts +0 -14
  167. package/cjs/CamOverlayPainter/ResourceManager.js +0 -46
  168. package/cjs/CamScripterAPI.d.ts +0 -19
  169. package/cjs/CamScripterAPICameraEventsGenerator.d.ts +0 -74
  170. package/cjs/CamStreamerAPI.d.ts +0 -16
  171. package/cjs/CamSwitcherAPI.d.ts +0 -48
  172. package/cjs/CamSwitcherEvents.d.ts +0 -18
  173. package/cjs/VapixAPI.d.ts +0 -66
  174. package/cjs/VapixEvents.d.ts +0 -43
  175. package/cjs/errors/errors.d.ts +0 -34
  176. package/cjs/events/AxisCameraStationEvents.d.ts +0 -9
  177. package/cjs/events/AxisCameraStationEvents.js +0 -48
  178. package/cjs/events/GenetecAgent.d.ts +0 -174
  179. package/cjs/events/GenetecAgent.js +0 -123
  180. package/cjs/index.d.ts +0 -11
  181. package/cjs/internal/ProxyClient.d.ts +0 -11
  182. package/cjs/internal/common.d.ts +0 -39
  183. package/cjs/internal/common.js +0 -27
  184. package/cjs/node/DefaultClient.d.ts +0 -15
  185. package/cjs/node/HttpRequestSender.d.ts +0 -28
  186. package/cjs/node/WsEventClient.d.ts +0 -13
  187. package/cjs/node/WsEventClient.js +0 -22
  188. package/cjs/types/CamOverlayAPI.d.ts +0 -188
  189. package/cjs/types/CamOverlayAPI.js +0 -47
  190. package/cjs/types/CamScripterAPI.d.ts +0 -67
  191. package/cjs/types/CamStreamerAPI.d.ts +0 -139
  192. package/cjs/types/CamSwitcherAPI.d.ts +0 -814
  193. package/cjs/types/common.d.ts +0 -37
  194. package/cjs/web/DefaultClient.d.ts +0 -6
  195. package/cjs/web/index.d.ts +0 -2
  196. package/esm/CamOverlayAPI.d.ts +0 -31
  197. package/esm/CamOverlayDrawingAPI.d.ts +0 -86
  198. package/esm/CamOverlayPainter/Painter.d.ts +0 -48
  199. package/esm/CamOverlayPainter/ResourceManager.d.ts +0 -14
  200. package/esm/CamScripterAPI.d.ts +0 -19
  201. package/esm/CamScripterAPICameraEventsGenerator.d.ts +0 -74
  202. package/esm/CamStreamerAPI.d.ts +0 -16
  203. package/esm/CamSwitcherAPI.d.ts +0 -48
  204. package/esm/CamSwitcherEvents.d.ts +0 -18
  205. package/esm/VapixAPI.d.ts +0 -66
  206. package/esm/VapixEvents.d.ts +0 -43
  207. package/esm/events/AxisCameraStationEvents.d.ts +0 -9
  208. package/esm/events/GenetecAgent.js +0 -119
  209. package/esm/index.d.ts +0 -11
  210. package/esm/internal/Digest.d.ts +0 -4
  211. package/esm/internal/ProxyClient.d.ts +0 -11
  212. package/esm/internal/common.d.ts +0 -39
  213. package/esm/internal/common.js +0 -20
  214. package/esm/internal/constants.d.ts +0 -1
  215. package/esm/internal/transformers.d.ts +0 -5
  216. package/esm/internal/utils.d.ts +0 -11
  217. package/esm/internal/versionCompare.d.ts +0 -6
  218. package/esm/node/DefaultClient.d.ts +0 -15
  219. package/esm/node/HttpServer.d.ts +0 -21
  220. package/esm/node/WsClient.d.ts +0 -39
  221. package/esm/node/WsEventClient.d.ts +0 -13
  222. package/esm/node/WsEventClient.js +0 -18
  223. package/esm/node/index.d.ts +0 -2
  224. package/esm/types/CamOverlayAPI.d.ts +0 -188
  225. package/esm/types/CamOverlayAPI.js +0 -44
  226. package/esm/types/CamScripterAPI.d.ts +0 -67
  227. package/esm/types/CamStreamerAPI.d.ts +0 -139
  228. package/esm/types/CamSwitcherEvents.d.ts +0 -491
  229. package/esm/types/VapixAPI.d.ts +0 -1683
  230. package/esm/web/DefaultClient.d.ts +0 -6
  231. package/esm/web/WsClient.d.ts +0 -13
  232. package/esm/web/index.d.ts +0 -2
  233. /package/{cjs/CreatePackage.d.ts → esm/internal/types.js} +0 -0
  234. /package/esm/{CreatePackage.d.ts → types/CamOverlayDrawingAPI.js} +0 -0
  235. /package/{cjs → types}/internal/constants.d.ts +0 -0
  236. /package/{cjs → types}/internal/transformers.d.ts +0 -0
  237. /package/{cjs/internal → types/node}/Digest.d.ts +0 -0
  238. /package/{cjs → types}/web/WsClient.d.ts +0 -0
  239. /package/{cjs/node → types/web}/index.d.ts +0 -0
@@ -0,0 +1,11 @@
1
+ export const COORD = {
2
+ top_left: [-1, -1],
3
+ center_left: [-1, 0],
4
+ bottom_left: [-1, 1],
5
+ top_center: [0, -1],
6
+ center: [0, 0],
7
+ bottom_center: [0, 1],
8
+ top_right: [1, -1],
9
+ center_right: [1, 0],
10
+ bottom_right: [1, 1],
11
+ };
@@ -1,4 +1,7 @@
1
1
  import { z } from 'zod';
2
+ export const nodeStateSchema = z.object({
3
+ node_state: z.union([z.literal('OK'), z.literal('NOT_INSTALLED'), z.literal('NOT_FOUND')]),
4
+ });
2
5
  export const packageInfoListSchema = z.array(z.object({
3
6
  storage: z.union([z.literal('SD_CARD'), z.literal('INTERNAL')]),
4
7
  manifest: z.object({
@@ -6,12 +9,24 @@ export const packageInfoListSchema = z.array(z.object({
6
9
  package_menu_name: z.string(),
7
10
  package_version: z.string(),
8
11
  vendor: z.string(),
9
- required_camscripter_version: z.string(),
10
- required_camscripter_rbi_version: z.string(),
12
+ required_camscripter_version: z.string().optional(),
13
+ required_camscripter_rbi_version: z.string().optional(),
11
14
  ui_link: z.string(),
12
15
  }),
13
16
  }));
14
- export const storageSchema = z.array(z.object({
15
- type: z.union([z.literal('INTERNAL'), z.literal('SD_CARD')]),
16
- capacity_mb: z.number(),
17
- }));
17
+ export const packageConfigSchema = z.record(z.string(), z.object({ enabled: z.boolean() }));
18
+ export const cameraStorageSchema = z.union([
19
+ z.tuple([
20
+ z.object({ type: z.literal('INTERNAL'), capacity_mb: z.number() }),
21
+ z.object({ type: z.literal('SD_CARD'), capacity_mb: z.number() }),
22
+ ]),
23
+ z.tuple([z.object({ type: z.literal('INTERNAL'), capacity_mb: z.number() })]),
24
+ ]);
25
+ export const camscripterApiResponseSchema = z.object({
26
+ status: z.number(),
27
+ message: z.string(),
28
+ });
29
+ export const cameraTimeResponseSchema = z.object({
30
+ state: z.boolean(),
31
+ code: z.number(),
32
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- export const streamAttributesSchema = z.object({
2
+ export const cameraStreamSchema = z.object({
3
3
  enabled: z.string(),
4
4
  active: z.string(),
5
5
  audioSource: z.string(),
@@ -22,4 +22,35 @@ export const streamAttributesSchema = z.object({
22
22
  startTime: z.string(),
23
23
  stopTime: z.string(),
24
24
  });
25
- export const streamListSchema = z.record(z.string(), streamAttributesSchema);
25
+ export const streamSchema = z.object({
26
+ enabled: z.union([z.literal(0), z.literal(1)]),
27
+ active: z.union([z.literal(0), z.literal(1)]),
28
+ audioSource: z.string(),
29
+ avSyncMsec: z.number().int(),
30
+ internalVapixParameters: z.string(),
31
+ userVapixParameters: z.string(),
32
+ outputParameters: z.string(),
33
+ outputType: z.union([z.literal('video'), z.literal('images'), z.literal('none')]),
34
+ mediaServerUrl: z.string(),
35
+ inputType: z.union([z.literal('CSw'), z.literal('CRS'), z.literal('RTSP_URL')]),
36
+ inputUrl: z.string(),
37
+ forceStereo: z.union([z.literal(0), z.literal(1)]),
38
+ streamDelay: z.number().nullable(),
39
+ statusLed: z.number(),
40
+ statusPort: z.string(),
41
+ callApi: z.number().int(),
42
+ trigger: z.string(),
43
+ schedule: z.string(),
44
+ prepareAhead: z.number().int(),
45
+ startTime: z.number().nullable(),
46
+ stopTime: z.number().nullable(),
47
+ });
48
+ export const cameraStreamResponseSchema = z.object({
49
+ data: cameraStreamSchema,
50
+ code: z.number(),
51
+ message: z.string(),
52
+ });
53
+ export const camstreamerServerResponseSchema = z.object({
54
+ code: z.number(),
55
+ message: z.string(),
56
+ });
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { toCamelCase, toCamelCaseDeep } from '../internal/transformers';
3
- import { storageTypeSchema, keyboardShortcutsSchema, h264ProfileSchema, audioChannelCountSchema, } from './common';
3
+ import { storageTypeSchema, keyboardShortcutsSchema, h264ProfileSchema, audioChannelCountSchema, keyboardShortcutSchema, } from './common';
4
4
  const channelTypeSchema = z.union([z.literal('audio'), z.literal('video'), z.literal('av')]);
5
5
  const playlistPlayTypeSchema = z.union([
6
6
  z.literal('PLAY_ALL'),
@@ -132,3 +132,40 @@ export const clipListSchema = z.object({
132
132
  ])),
133
133
  })),
134
134
  });
135
+ export const bitrateModeSchema = z.union([z.literal('VBR'), z.literal('MBR'), z.literal('ABR')]);
136
+ export const bitrateVapixParamsSchema = z.object({
137
+ bitrateMode: bitrateModeSchema,
138
+ maximumBitRate: z.number(),
139
+ retentionTime: z.number(),
140
+ bitRateLimit: z.number(),
141
+ });
142
+ export const cameraOptionsSchema = bitrateVapixParamsSchema
143
+ .extend({
144
+ resolution: z.string(),
145
+ h264Profile: h264ProfileSchema,
146
+ fps: z.number(),
147
+ compression: z.number().min(0).max(100),
148
+ govLength: z.number(),
149
+ bitrateVapixParams: z.string().nullable(),
150
+ audioSampleRate: z.number(),
151
+ audioChannelCount: audioChannelCountSchema,
152
+ keyboard: z.object({
153
+ fromSource: keyboardShortcutSchema,
154
+ none: keyboardShortcutSchema,
155
+ }),
156
+ })
157
+ .partial();
158
+ export const globalAudioSettingsTypeSchema = z.union([z.literal('fromSource'), z.literal('source')]);
159
+ export const globalAudioSettingsSchema = z.object({
160
+ type: globalAudioSettingsTypeSchema,
161
+ source: z.string(),
162
+ storage: z.string().optional(),
163
+ });
164
+ export const secondaryAudioSettingsSchema = z.object({
165
+ type: z.union([z.literal('CLIP'), z.literal('STREAM'), z.literal('NONE')]),
166
+ streamName: z.string().optional(),
167
+ clipName: z.string().optional(),
168
+ storage: storageTypeSchema,
169
+ secondaryAudioLevel: z.number(),
170
+ masterAudioLevel: z.number(),
171
+ });
@@ -16,6 +16,14 @@ const cswEventsDataSchema = z.discriminatedUnion('type', [
16
16
  clip_name: z.string().optional(),
17
17
  master_audio: z.boolean(),
18
18
  }),
19
+ z.object({
20
+ type: z.literal('StreamSwitchVideoError'),
21
+ playlist_name: z.string(),
22
+ playlist_active_stream: z.number(),
23
+ stream_name: z.string().optional(),
24
+ clip_name: z.string().optional(),
25
+ info: z.string(),
26
+ }),
19
27
  z.object({
20
28
  type: z.literal('StreamSwitchAudioError'),
21
29
  stream_name: z.string().optional(),
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ export const successResponseSchema = z.object({
3
+ Rsp: z.object({
4
+ Status: z.literal('Ok'),
5
+ }),
6
+ });
7
+ export const cameraGuidsResponseSchema = z.object({
8
+ Rsp: z.object({
9
+ Status: z.literal('Ok'),
10
+ Result: z.array(z.object({ Guid: z.string() })),
11
+ }),
12
+ });
13
+ export const cameraDetailSchema = z.object({
14
+ Guid: z.string().optional(),
15
+ Name: z.string().optional(),
16
+ EntityType: z.string().optional(),
17
+ });
18
+ export const cameraDetailsResponseSchema = z.object({
19
+ Rsp: z.object({
20
+ Status: z.literal('Ok'),
21
+ Result: z.union([z.array(cameraDetailSchema), cameraDetailSchema]),
22
+ }),
23
+ });
24
+ export const cameraListSchema = z.array(z.object({
25
+ index: z.number(),
26
+ value: z.string(),
27
+ label: z.string(),
28
+ }));
@@ -0,0 +1,278 @@
1
+ import { z } from 'zod';
2
+ export const connectionSchema = z.object({
3
+ protocol: z.union([z.literal('http'), z.literal('https'), z.literal('https_insecure')]),
4
+ ip: z.union([z.string().ip(), z.literal('')]),
5
+ port: z.number().positive().lt(65535),
6
+ user: z.string(),
7
+ pass: z.string(),
8
+ });
9
+ export const widgetSchema = z.object({
10
+ enabled: z.boolean().default(true),
11
+ coord: z.union([
12
+ z.literal('top_left'),
13
+ z.literal('top_right'),
14
+ z.literal('bottom_left'),
15
+ z.literal('bottom_right'),
16
+ ]),
17
+ posX: z.number().nonnegative(),
18
+ posY: z.number().nonnegative(),
19
+ scale: z.number().positive(),
20
+ });
21
+ const labelOptionsSchema = z.union([
22
+ z.literal('blank'),
23
+ z.literal('registration'),
24
+ z.literal('call_sign'),
25
+ z.literal('flight_number'),
26
+ z.literal('icao'),
27
+ ]);
28
+ const identificationLabelSchema = z.object({
29
+ firstRow: labelOptionsSchema,
30
+ secondRow: labelOptionsSchema,
31
+ thirdRow: labelOptionsSchema,
32
+ fourthRow: labelOptionsSchema,
33
+ opacity: z.number().positive(),
34
+ });
35
+ export const cameraSettingsSchema = z.object({
36
+ units: z.union([z.literal('metric'), z.literal('imperial')]).default('imperial'),
37
+ adsbSource: z
38
+ .object({
39
+ ip: z.union([z.string().ip(), z.literal('')]),
40
+ port: z.number().positive().lt(65535),
41
+ })
42
+ .default({ ip: '', port: 30334 }),
43
+ camera: connectionSchema.default({
44
+ protocol: 'http',
45
+ ip: '127.0.0.1',
46
+ port: 80,
47
+ user: 'root',
48
+ pass: '',
49
+ }),
50
+ cameraCalibrationProcessConfig: z
51
+ .object({
52
+ nightSkyCalibrationEnabled: z.boolean(),
53
+ scheduleNightSkyCalibrationTimestamp: z.number(),
54
+ })
55
+ .default({ nightSkyCalibrationEnabled: false, scheduleNightSkyCalibrationTimestamp: 0 }),
56
+ cameraConfig: z
57
+ .object({
58
+ maxZoomLevel: z.number().optional(),
59
+ defaultCaptureSizeMeters: z.number().positive().default(120),
60
+ captureSizeExtensionMeters: z.number().positive().default(80),
61
+ })
62
+ .default({
63
+ maxZoomLevel: 30,
64
+ defaultCaptureSizeMeters: 120,
65
+ captureSizeExtensionMeters: 80,
66
+ }),
67
+ stream: z
68
+ .object({
69
+ width: z.number().positive(),
70
+ height: z.number().positive(),
71
+ })
72
+ .default({ width: 1920, height: 1080 }),
73
+ imageConfig: z
74
+ .object({
75
+ dayAperture: z.number().nonnegative().min(0).max(100),
76
+ nightAperture: z.number().nonnegative().min(0).max(100),
77
+ })
78
+ .default({ dayAperture: 50, nightAperture: 0 }),
79
+ airportConfig: z
80
+ .object({
81
+ icao: z.string().default(''),
82
+ centerLat: z.number(),
83
+ centerLon: z.number(),
84
+ radius: z.number().nonnegative().default(10000),
85
+ })
86
+ .default({
87
+ icao: '',
88
+ centerLat: 0,
89
+ centerLon: 0,
90
+ radius: 10000,
91
+ }),
92
+ trackingConfig: z
93
+ .object({
94
+ prioritizeEmergency: z.boolean(),
95
+ guardTourEnabled: z.boolean().default(false),
96
+ guardTourId: z.number().int().nonnegative().default(0),
97
+ })
98
+ .default({ prioritizeEmergency: true, guardTourEnabled: false, guardTourId: 0 }),
99
+ overlayText: z
100
+ .object({
101
+ displayIcao: z.boolean().optional(),
102
+ displayRegistration: z.boolean().optional(),
103
+ displayFlightNumber: z.boolean().optional(),
104
+ displayAltitude: z.boolean().optional(),
105
+ displayVelocity: z.boolean().optional(),
106
+ displayDistance: z.boolean().optional(),
107
+ displayFOV: z.boolean().optional(),
108
+ displayPTError: z.boolean().optional(),
109
+ displayPTZSpeed: z.boolean().optional(),
110
+ displayVelocityData: z.boolean().optional(),
111
+ displaySignalQuality: z.boolean().optional(),
112
+ displayAutoTrackingInfo: z.boolean().optional(),
113
+ displayGPSCoords: z.boolean().optional(),
114
+ displayVapixQuery: z.boolean().optional(),
115
+ displayFocus: z.boolean().optional(),
116
+ displayAperture: z.boolean().optional(),
117
+ displaySunDistance: z.boolean().optional(),
118
+ displayTickTime: z.boolean().optional(),
119
+ displayAircraftInfo: z.boolean().optional(),
120
+ })
121
+ .optional(),
122
+ widget: widgetSchema.default({
123
+ enabled: true,
124
+ coord: 'top_right',
125
+ posX: 10,
126
+ posY: 10,
127
+ scale: 100,
128
+ }),
129
+ airportWidget: widgetSchema.default({
130
+ enabled: true,
131
+ coord: 'top_left',
132
+ posX: 10,
133
+ posY: 10,
134
+ scale: 100,
135
+ }),
136
+ fr24FlightInfoSource: z
137
+ .object({
138
+ enabled: z.boolean().default(false),
139
+ priority: z.number().int().positive().default(1),
140
+ apiToken: z.string().default(''),
141
+ validateFlights: z.boolean().default(true),
142
+ })
143
+ .default({
144
+ enabled: false,
145
+ priority: 1,
146
+ apiToken: '',
147
+ validateFlights: true,
148
+ }),
149
+ radarcapeFlightInfoSource: z
150
+ .object({
151
+ enabled: z.boolean().default(false),
152
+ priority: z.number().int().positive().default(2),
153
+ ip: z.union([z.string().ip(), z.literal('')]).default(''),
154
+ port: z.number().positive().lt(65535).default(80),
155
+ })
156
+ .default({
157
+ enabled: false,
158
+ priority: 2,
159
+ ip: '',
160
+ port: 80,
161
+ }),
162
+ identificationLabel: identificationLabelSchema.default({
163
+ firstRow: 'registration',
164
+ secondRow: 'blank',
165
+ thirdRow: 'blank',
166
+ fourthRow: 'blank',
167
+ opacity: 30,
168
+ }),
169
+ acs: connectionSchema
170
+ .extend({
171
+ enabled: z.boolean(),
172
+ sourceKey: z.string(),
173
+ })
174
+ .default({
175
+ enabled: false,
176
+ protocol: 'https_insecure',
177
+ ip: '',
178
+ port: 29204,
179
+ user: '',
180
+ pass: '',
181
+ sourceKey: '',
182
+ }),
183
+ genetec: connectionSchema
184
+ .extend({
185
+ enabled: z.boolean(),
186
+ baseUri: z.string().default(''),
187
+ appId: z.string().default(''),
188
+ cameraList: z.string().array().default([]),
189
+ })
190
+ .default({
191
+ enabled: false,
192
+ protocol: 'http',
193
+ ip: '',
194
+ port: 4590,
195
+ user: '',
196
+ pass: '',
197
+ baseUri: 'WebSdk',
198
+ appId: '',
199
+ cameraList: [],
200
+ }),
201
+ });
202
+ export const serverSettingsSchema = z.object({
203
+ cameraCalibration: z.object({
204
+ posLat: z.number(),
205
+ posLon: z.number(),
206
+ geoidHN: z.number(),
207
+ altitudeAmsl: z.number(),
208
+ rotationEast: z.number(),
209
+ rotationNorth: z.number(),
210
+ rotationUp: z.number(),
211
+ tiltTransformationCoefA: z.number(),
212
+ tiltCameraKnownPoint: z.number(),
213
+ tiltRealKnownPoint: z.number(),
214
+ }),
215
+ });
216
+ export const trackingModeSchema = z.object({
217
+ mode: z.union([z.literal('MANUAL'), z.literal('AUTOMATIC')]),
218
+ });
219
+ export const flightInfoSchema = z.object({
220
+ callsign: z.string().optional(),
221
+ flightNumber: z.string().optional(),
222
+ registration: z.string().optional(),
223
+ aircraftType: z.string().optional(),
224
+ airlines: z.string().optional(),
225
+ originAirport: z
226
+ .object({
227
+ icao: z.string().optional(),
228
+ iata: z.string().optional(),
229
+ city: z.string().optional(),
230
+ })
231
+ .optional(),
232
+ destinationAirport: z.object({
233
+ icao: z.string().optional(),
234
+ iata: z.string().optional(),
235
+ city: z.string().optional(),
236
+ }),
237
+ flightImages: z
238
+ .array(z.object({
239
+ src: z.string().optional(),
240
+ photographer: z.string().optional(),
241
+ }))
242
+ .optional(),
243
+ });
244
+ export const priorityListSchema = z.object({
245
+ priorityList: z.array(z.string()).default([]),
246
+ });
247
+ export const whiteListSchema = z.object({
248
+ whiteList: z.array(z.string()).default([]),
249
+ });
250
+ export const blackListSchema = z.object({
251
+ blackList: z.array(z.string()).default([]),
252
+ });
253
+ export const mapTypeSchema = z.enum(['roadmap', 'satellite']);
254
+ export const mapInfoSchema = z.object({
255
+ minZoom: z.number().nonnegative(),
256
+ maxZoom: z.number().nonnegative(),
257
+ mapTypes: z.array(mapTypeSchema),
258
+ tileSize: z.number().nonnegative(),
259
+ });
260
+ export const zonesSchema = z.object({
261
+ zones: z
262
+ .array(z.object({
263
+ enabled: z.boolean().default(true),
264
+ name: z.string().optional(),
265
+ area: z
266
+ .array(z.object({
267
+ lat: z.number(),
268
+ lon: z.number(),
269
+ }))
270
+ .nonempty(),
271
+ minAltitudeAmsl: z.number().optional(),
272
+ maxAltitudeAmsl: z.number().optional(),
273
+ minSpeedKmph: z.number().optional(),
274
+ maxSpeedKmph: z.number().optional(),
275
+ weight: z.number(),
276
+ }))
277
+ .default([]),
278
+ });
@@ -12,6 +12,19 @@ export const applicationSchema = z.object({
12
12
  VendorHomePage: z.string().optional(),
13
13
  LicenseName: z.string().optional(),
14
14
  });
15
+ export const applicationListSchema = z.array(applicationSchema.extend({
16
+ appId: z
17
+ .union([
18
+ z.literal('CamStreamer'),
19
+ z.literal('CamSwitcher'),
20
+ z.literal('CamOverlay'),
21
+ z.literal('CamScripter'),
22
+ z.literal('PlaneTracker'),
23
+ z.literal('Ndihxplugin'),
24
+ z.literal('SportTracker'),
25
+ ])
26
+ .nullable(),
27
+ }));
15
28
  export const APP_IDS = [
16
29
  'CamStreamer',
17
30
  'CamSwitcher',
@@ -19,15 +32,8 @@ export const APP_IDS = [
19
32
  'CamScripter',
20
33
  'PlaneTracker',
21
34
  'Ndihxplugin',
35
+ 'SportTracker',
22
36
  ];
23
- export const applicationListSchema = z.object({
24
- reply: z.object({
25
- $: z.object({ result: z.string() }),
26
- application: z.array(z.object({
27
- $: applicationSchema,
28
- })),
29
- }),
30
- });
31
37
  export const guardTourSchema = z.object({
32
38
  id: z.string(),
33
39
  camNbr: z.unknown(),
@@ -49,7 +55,12 @@ const audioSampleRatesSchema = z.object({
49
55
  });
50
56
  const audioSampleRatesOutSchema = audioSampleRatesSchema.transform(toCamelCaseDeep);
51
57
  export const sdCardWatchedStatuses = ['OK', 'connected', 'disconnected'];
52
- export const PtzOverviewSchema = z.record(z.number(), z.array(z.object({ id: z.number(), name: z.string() })));
58
+ export const sdCardInfoSchema = z.object({
59
+ status: z.enum(sdCardWatchedStatuses),
60
+ totalSize: z.number(),
61
+ freeSize: z.number(),
62
+ });
63
+ export const ptzOverviewSchema = z.record(z.number(), z.array(z.object({ id: z.number(), name: z.string() })));
53
64
  export const cameraPTZItemDataSchema = z.object({
54
65
  pan: z.number().optional(),
55
66
  tilt: z.number().optional(),
@@ -67,7 +78,7 @@ export const audioDeviceSignalingChannelTypeSchema = z.object({
67
78
  });
68
79
  export const audioDeviceSignalingTypeSchema = z.object({
69
80
  id: z.string(),
70
- powerType: z.string(),
81
+ powerType: z.string().optional(),
71
82
  channels: z.array(audioDeviceSignalingChannelTypeSchema),
72
83
  });
73
84
  export const audioDeviceConnectionTypeSchema = z.object({
@@ -94,7 +105,9 @@ const audioDeviceFromRequestSchema = z.object({
94
105
  inputs: z.array(audioDeviceInputOutputSchema).optional(),
95
106
  outputs: z.array(audioDeviceInputOutputSchema).optional(),
96
107
  });
97
- export const audioDeviceRequestSchema = z.object({ devices: z.array(audioDeviceFromRequestSchema) });
108
+ export const audioDeviceRequestSchema = z.object({
109
+ data: z.object({ devices: z.array(audioDeviceFromRequestSchema) }),
110
+ });
98
111
  export const maxFpsResponseSchema = z.object({
99
112
  data: z
100
113
  .array(z.object({
@@ -112,9 +125,23 @@ export const dateTimeinfoSchema = z.object({
112
125
  dstEnabled: z.boolean(),
113
126
  localDateTime: z.string(),
114
127
  posixTimeZone: z.string(),
115
- timeZone: z.string(),
128
+ timeZone: z.string().optional(),
116
129
  }),
117
130
  });
131
+ export const timeZoneSchema = z.discriminatedUnion('status', [
132
+ z.object({
133
+ status: z.literal('success'),
134
+ data: z.object({
135
+ activeTimeZone: z.string(),
136
+ }),
137
+ }),
138
+ z.object({
139
+ status: z.literal('error'),
140
+ error: z.object({
141
+ message: z.string(),
142
+ }),
143
+ }),
144
+ ]);
118
145
  export const audioSampleRatesResponseSchema = z.object({
119
146
  data: z.object({
120
147
  encoders: z
@@ -125,3 +152,34 @@ export const audioSampleRatesResponseSchema = z.object({
125
152
  .partial(),
126
153
  }),
127
154
  });
155
+ export const portStatusSchema = z.object({
156
+ port: z.string(),
157
+ state: z.enum(['open', 'closed']),
158
+ configurable: z.boolean(),
159
+ readonly: z.boolean().optional(),
160
+ usage: z.string(),
161
+ direction: z.enum(['input', 'output']),
162
+ name: z.string(),
163
+ normalState: z.enum(['open', 'closed']),
164
+ });
165
+ export const getPortsResponseSchema = z.object({
166
+ apiVersion: z.string(),
167
+ context: z.string(),
168
+ method: z.literal('getPorts'),
169
+ data: z.object({
170
+ numberOfPorts: z.number(),
171
+ items: z.array(portStatusSchema),
172
+ }),
173
+ });
174
+ export const portSetSchema = z.object({
175
+ port: z.string(),
176
+ state: z.enum(['open', 'closed']),
177
+ usage: z.string().optional(),
178
+ direction: z.enum(['input', 'output']).optional(),
179
+ name: z.string().optional(),
180
+ normalState: z.enum(['open', 'closed']).optional(),
181
+ });
182
+ export const portSequenceStateSchema = z.object({
183
+ state: z.enum(['open', 'closed']),
184
+ time: z.number().min(0).max(65535),
185
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -1,16 +1,28 @@
1
1
  import { addParametersToPath } from '../internal/utils';
2
2
  export class DefaultClient {
3
- get(url, parameters, headers) {
4
- return fetch(addParametersToPath(url, parameters), {
3
+ get = (params) => {
4
+ return this.fetchWithTimeout(addParametersToPath(params.path, params.parameters), {
5
5
  method: 'GET',
6
- headers: headers,
7
- });
8
- }
9
- post(url, data, parameters, headers) {
10
- return fetch(addParametersToPath(url, parameters), {
6
+ headers: params.headers,
7
+ }, params.timeout);
8
+ };
9
+ post = (params) => {
10
+ return this.fetchWithTimeout(addParametersToPath(params.path, params.parameters), {
11
11
  method: 'POST',
12
- body: data,
13
- headers: headers,
14
- });
12
+ body: params.data,
13
+ headers: params.headers,
14
+ }, params.timeout);
15
+ };
16
+ async fetchWithTimeout(url, options, timeout) {
17
+ const controller = new AbortController();
18
+ const timeoutId = timeout !== undefined ? setTimeout(() => controller.abort(), timeout) : null;
19
+ try {
20
+ return await fetch(url, { ...options, signal: controller.signal });
21
+ }
22
+ finally {
23
+ if (timeoutId) {
24
+ clearTimeout(timeoutId);
25
+ }
26
+ }
15
27
  }
16
28
  }
@@ -1,4 +1,4 @@
1
- const REFRESH_TIMEOUT = 5_000;
1
+ const REFRESH_TIMEOUT = 5000;
2
2
  export class WsClient {
3
3
  getUrl;
4
4
  getAuthToken;
@@ -27,7 +27,7 @@ export class WsClient {
27
27
  };
28
28
  ws.onmessage = (e) => this.onmessage(e);
29
29
  ws.onclose = () => {
30
- this.restartTimeout = setTimeout(() => this.init(), REFRESH_TIMEOUT);
30
+ this.restartTimeout = window.setTimeout(() => this.init(), REFRESH_TIMEOUT);
31
31
  };
32
32
  this.ws = ws;
33
33
  }
@@ -40,7 +40,7 @@ export class WsClient {
40
40
  this.destroyWebsocket();
41
41
  };
42
42
  destroyWebsocket() {
43
- if (this.restartTimeout) {
43
+ if (this.restartTimeout !== null) {
44
44
  clearTimeout(this.restartTimeout);
45
45
  this.restartTimeout = null;
46
46
  }