camstreamerlib 4.0.0-beta.6 → 4.0.0-beta.61

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 (265) hide show
  1. package/README.md +142 -38
  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 +142 -124
  6. package/cjs/PlaneTrackerAPI.js +247 -0
  7. package/cjs/VapixAPI.js +323 -233
  8. package/cjs/{CreatePackage.js → bin/CreatePackage.js} +22 -19
  9. package/cjs/errors/errors.js +113 -1
  10. package/cjs/index.js +28 -5
  11. package/cjs/internal/ProxyClient.js +28 -32
  12. package/cjs/{CamSwitcherEvents.js → internal/WsEvents.js} +28 -22
  13. package/cjs/internal/types.js +2 -0
  14. package/cjs/internal/utils.js +22 -3
  15. package/cjs/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +17 -14
  16. package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +33 -0
  17. package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +5 -17
  18. package/cjs/node/CamOverlayPainter/ResourceManager.js +72 -0
  19. package/cjs/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +16 -13
  20. package/cjs/node/DefaultClient.js +10 -12
  21. package/cjs/{internal → node}/Digest.js +8 -5
  22. package/cjs/node/Digest.test.js +13 -0
  23. package/cjs/node/HttpRequestSender.js +14 -4
  24. package/cjs/node/HttpServer.js +15 -12
  25. package/cjs/{VapixEvents.js → node/VapixEvents.js} +10 -10
  26. package/cjs/node/WsClient.js +30 -20
  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 +26 -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 +24 -8
  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/GenetecAgent.js +31 -0
  50. package/cjs/types/PlaneTrackerAPI.js +310 -0
  51. package/cjs/types/VapixAPI.js +71 -13
  52. package/cjs/types/VapixEvents.js +2 -0
  53. package/cjs/types/common.js +4 -2
  54. package/cjs/types/ws/CamOverlayEvents.js +19 -0
  55. package/cjs/types/ws/CamStreamerEvents.js +32 -0
  56. package/cjs/types/{CamSwitcherEvents.js → ws/CamSwitcherEvents.js} +8 -0
  57. package/cjs/types/ws/PlaneTrackerEvents.js +194 -0
  58. package/cjs/web/DefaultClient.js +26 -10
  59. package/cjs/web/WsClient.js +16 -18
  60. package/cjs/ws/CamOverlayEvents.js +24 -0
  61. package/cjs/ws/CamStreamerEvents.js +24 -0
  62. package/cjs/ws/CamSwitcherEvents.js +24 -0
  63. package/cjs/ws/PlaneTrackerEvents.js +30 -0
  64. package/esm/CamOverlayAPI.js +131 -88
  65. package/esm/CamScripterAPI.js +48 -38
  66. package/esm/CamStreamerAPI.js +81 -38
  67. package/esm/CamSwitcherAPI.js +138 -120
  68. package/esm/PlaneTrackerAPI.js +243 -0
  69. package/esm/VapixAPI.js +315 -225
  70. package/esm/{CreatePackage.js → bin/CreatePackage.js} +3 -3
  71. package/esm/errors/errors.js +96 -0
  72. package/esm/index.js +20 -4
  73. package/esm/internal/ProxyClient.js +28 -32
  74. package/esm/{CamSwitcherEvents.js → internal/WsEvents.js} +26 -20
  75. package/esm/internal/utils.js +17 -1
  76. package/esm/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +12 -12
  77. package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +33 -0
  78. package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +2 -13
  79. package/esm/{CamOverlayPainter → node/CamOverlayPainter}/ResourceManager.js +7 -5
  80. package/esm/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +11 -11
  81. package/esm/node/DefaultClient.js +10 -12
  82. package/esm/{internal → node}/Digest.js +1 -1
  83. package/esm/node/Digest.test.js +11 -0
  84. package/esm/node/HttpRequestSender.js +14 -4
  85. package/esm/node/HttpServer.js +5 -5
  86. package/esm/{VapixEvents.js → node/VapixEvents.js} +10 -10
  87. package/esm/node/WsClient.js +22 -15
  88. package/esm/{events → node/events}/AxisCameraStationEvents.js +18 -13
  89. package/esm/node/events/GenetecAgent.js +119 -0
  90. package/esm/node/index.js +17 -2
  91. package/esm/types/CamOverlayAPI/CamOverlayAPI.js +76 -0
  92. package/esm/types/CamOverlayAPI/accuweatherSchema.js +44 -0
  93. package/esm/types/CamOverlayAPI/customGraphicsSchema.js +69 -0
  94. package/esm/types/CamOverlayAPI/imagesSchema.js +6 -0
  95. package/esm/types/CamOverlayAPI/index.js +11 -0
  96. package/esm/types/CamOverlayAPI/infotickerSchema.js +23 -0
  97. package/esm/types/CamOverlayAPI/pipSchema.js +36 -0
  98. package/esm/types/CamOverlayAPI/ptzCompassSchema.js +23 -0
  99. package/esm/types/CamOverlayAPI/ptzSchema.js +9 -0
  100. package/esm/types/CamOverlayAPI/scoreBoardSchema.js +129 -0
  101. package/esm/types/CamOverlayAPI/screenSharingSchema.js +5 -0
  102. package/esm/types/CamOverlayAPI/serviceCommonTypes.js +88 -0
  103. package/esm/types/CamOverlayAPI/webCameraSharingSchema.js +5 -0
  104. package/esm/types/CamOverlayPainter.js +11 -0
  105. package/esm/types/CamScripterAPI.js +23 -7
  106. package/esm/types/CamScripterAPICameraEventsGenerator.js +1 -0
  107. package/esm/types/CamStreamerAPI.js +33 -2
  108. package/esm/types/CamSwitcherAPI.js +38 -1
  109. package/esm/types/GenetecAgent.js +28 -0
  110. package/esm/types/PlaneTrackerAPI.js +307 -0
  111. package/esm/types/VapixAPI.js +70 -12
  112. package/esm/types/VapixEvents.js +1 -0
  113. package/esm/types/common.js +3 -1
  114. package/esm/types/ws/CamOverlayEvents.js +16 -0
  115. package/esm/types/ws/CamStreamerEvents.js +29 -0
  116. package/esm/types/{CamSwitcherEvents.js → ws/CamSwitcherEvents.js} +8 -0
  117. package/esm/types/ws/PlaneTrackerEvents.js +191 -0
  118. package/esm/web/DefaultClient.js +26 -10
  119. package/esm/web/WsClient.js +16 -18
  120. package/esm/ws/CamOverlayEvents.js +20 -0
  121. package/esm/ws/CamStreamerEvents.js +20 -0
  122. package/esm/ws/CamSwitcherEvents.js +20 -0
  123. package/esm/ws/PlaneTrackerEvents.js +26 -0
  124. package/package.json +29 -11
  125. package/types/CamOverlayAPI.d.ts +867 -0
  126. package/types/CamScripterAPI.d.ts +46 -0
  127. package/types/CamStreamerAPI.d.ts +64 -0
  128. package/types/CamSwitcherAPI.d.ts +167 -0
  129. package/types/PlaneTrackerAPI.d.ts +229 -0
  130. package/types/VapixAPI.d.ts +118 -0
  131. package/types/bin/CreatePackage.d.ts +1 -0
  132. package/types/errors/errors.d.ts +83 -0
  133. package/types/index.d.ts +27 -0
  134. package/types/internal/ProxyClient.d.ts +10 -0
  135. package/types/internal/WsEvents.d.ts +37 -0
  136. package/types/internal/types.d.ts +47 -0
  137. package/{cjs → types}/internal/utils.d.ts +4 -1
  138. package/{cjs → types}/internal/versionCompare.d.ts +2 -2
  139. package/types/node/CamOverlayDrawingAPI.d.ts +41 -0
  140. package/{esm → types/node}/CamOverlayPainter/Frame.d.ts +8 -37
  141. package/{cjs → types/node}/CamOverlayPainter/Painter.d.ts +5 -21
  142. package/types/node/CamOverlayPainter/ResourceManager.d.ts +15 -0
  143. package/types/node/CamScripterAPICameraEventsGenerator.d.ts +31 -0
  144. package/types/node/DefaultClient.d.ts +16 -0
  145. package/types/node/Digest.test.d.ts +1 -0
  146. package/{esm → types}/node/HttpRequestSender.d.ts +1 -0
  147. package/{cjs → types}/node/HttpServer.d.ts +2 -2
  148. package/types/node/VapixEvents.d.ts +16 -0
  149. package/types/node/WsClient.d.ts +30 -0
  150. package/types/node/events/AxisCameraStationEvents.d.ts +12 -0
  151. package/types/node/events/GenetecAgent.d.ts +16 -0
  152. package/types/node/index.d.ts +17 -0
  153. package/types/types/CamOverlayAPI/CamOverlayAPI.d.ts +4330 -0
  154. package/types/types/CamOverlayAPI/accuweatherSchema.d.ts +84 -0
  155. package/types/types/CamOverlayAPI/customGraphicsSchema.d.ts +700 -0
  156. package/types/types/CamOverlayAPI/imagesSchema.d.ts +95 -0
  157. package/types/types/CamOverlayAPI/index.d.ts +11 -0
  158. package/types/types/CamOverlayAPI/infotickerSchema.d.ts +96 -0
  159. package/types/types/CamOverlayAPI/pipSchema.d.ts +125 -0
  160. package/types/types/CamOverlayAPI/ptzCompassSchema.d.ts +96 -0
  161. package/types/types/CamOverlayAPI/ptzSchema.d.ts +118 -0
  162. package/types/types/CamOverlayAPI/scoreBoardSchema.d.ts +357 -0
  163. package/types/types/CamOverlayAPI/screenSharingSchema.d.ts +58 -0
  164. package/types/types/CamOverlayAPI/serviceCommonTypes.d.ts +145 -0
  165. package/types/types/CamOverlayAPI/webCameraSharingSchema.d.ts +58 -0
  166. package/types/types/CamOverlayDrawingAPI.d.ts +48 -0
  167. package/types/types/CamOverlayPainter.d.ts +76 -0
  168. package/types/types/CamScripterAPI.d.ts +130 -0
  169. package/types/types/CamScripterAPICameraEventsGenerator.d.ts +45 -0
  170. package/types/types/CamStreamerAPI.d.ts +272 -0
  171. package/{esm → types}/types/CamSwitcherAPI.d.ts +145 -66
  172. package/{esm/events → types/types}/GenetecAgent.d.ts +47 -47
  173. package/types/types/PlaneTrackerAPI.d.ts +918 -0
  174. package/{cjs → types}/types/VapixAPI.d.ts +647 -465
  175. package/types/types/VapixEvents.d.ts +15 -0
  176. package/{cjs → types}/types/common.d.ts +17 -5
  177. package/types/types/ws/CamOverlayEvents.d.ts +88 -0
  178. package/types/types/ws/CamStreamerEvents.d.ts +249 -0
  179. package/{cjs/types → types/types/ws}/CamSwitcherEvents.d.ts +77 -0
  180. package/types/types/ws/PlaneTrackerEvents.d.ts +1597 -0
  181. package/types/web/DefaultClient.d.ts +8 -0
  182. package/types/web/WsClient.d.ts +17 -0
  183. package/types/ws/CamOverlayEvents.d.ts +8 -0
  184. package/types/ws/CamStreamerEvents.d.ts +8 -0
  185. package/types/ws/CamSwitcherEvents.d.ts +8 -0
  186. package/types/ws/PlaneTrackerEvents.d.ts +9 -0
  187. package/cjs/CamOverlayAPI.d.ts +0 -31
  188. package/cjs/CamOverlayDrawingAPI.d.ts +0 -86
  189. package/cjs/CamOverlayPainter/Frame.d.ts +0 -96
  190. package/cjs/CamOverlayPainter/ResourceManager.d.ts +0 -14
  191. package/cjs/CamOverlayPainter/ResourceManager.js +0 -46
  192. package/cjs/CamScripterAPI.d.ts +0 -19
  193. package/cjs/CamScripterAPICameraEventsGenerator.d.ts +0 -74
  194. package/cjs/CamStreamerAPI.d.ts +0 -16
  195. package/cjs/CamSwitcherAPI.d.ts +0 -48
  196. package/cjs/CamSwitcherEvents.d.ts +0 -18
  197. package/cjs/VapixAPI.d.ts +0 -66
  198. package/cjs/VapixEvents.d.ts +0 -43
  199. package/cjs/errors/errors.d.ts +0 -34
  200. package/cjs/events/AxisCameraStationEvents.d.ts +0 -9
  201. package/cjs/events/AxisCameraStationEvents.js +0 -48
  202. package/cjs/events/GenetecAgent.d.ts +0 -174
  203. package/cjs/events/GenetecAgent.js +0 -123
  204. package/cjs/index.d.ts +0 -11
  205. package/cjs/internal/ProxyClient.d.ts +0 -11
  206. package/cjs/internal/common.d.ts +0 -39
  207. package/cjs/internal/common.js +0 -27
  208. package/cjs/node/DefaultClient.d.ts +0 -15
  209. package/cjs/node/HttpRequestSender.d.ts +0 -28
  210. package/cjs/node/WsClient.d.ts +0 -39
  211. package/cjs/node/WsEventClient.d.ts +0 -13
  212. package/cjs/node/WsEventClient.js +0 -22
  213. package/cjs/types/CamOverlayAPI.d.ts +0 -188
  214. package/cjs/types/CamOverlayAPI.js +0 -47
  215. package/cjs/types/CamScripterAPI.d.ts +0 -67
  216. package/cjs/types/CamStreamerAPI.d.ts +0 -139
  217. package/cjs/types/CamSwitcherAPI.d.ts +0 -814
  218. package/cjs/web/DefaultClient.d.ts +0 -6
  219. package/cjs/web/WsClient.d.ts +0 -13
  220. package/cjs/web/index.d.ts +0 -2
  221. package/esm/CamOverlayAPI.d.ts +0 -31
  222. package/esm/CamOverlayDrawingAPI.d.ts +0 -86
  223. package/esm/CamOverlayPainter/Painter.d.ts +0 -48
  224. package/esm/CamOverlayPainter/ResourceManager.d.ts +0 -14
  225. package/esm/CamScripterAPI.d.ts +0 -19
  226. package/esm/CamScripterAPICameraEventsGenerator.d.ts +0 -74
  227. package/esm/CamStreamerAPI.d.ts +0 -16
  228. package/esm/CamSwitcherAPI.d.ts +0 -48
  229. package/esm/CamSwitcherEvents.d.ts +0 -18
  230. package/esm/VapixAPI.d.ts +0 -66
  231. package/esm/VapixEvents.d.ts +0 -43
  232. package/esm/errors/errors.d.ts +0 -34
  233. package/esm/events/AxisCameraStationEvents.d.ts +0 -9
  234. package/esm/events/GenetecAgent.js +0 -119
  235. package/esm/index.d.ts +0 -11
  236. package/esm/internal/Digest.d.ts +0 -4
  237. package/esm/internal/ProxyClient.d.ts +0 -11
  238. package/esm/internal/common.d.ts +0 -39
  239. package/esm/internal/common.js +0 -20
  240. package/esm/internal/constants.d.ts +0 -1
  241. package/esm/internal/transformers.d.ts +0 -5
  242. package/esm/internal/utils.d.ts +0 -11
  243. package/esm/internal/versionCompare.d.ts +0 -6
  244. package/esm/node/DefaultClient.d.ts +0 -15
  245. package/esm/node/HttpServer.d.ts +0 -21
  246. package/esm/node/WsClient.d.ts +0 -39
  247. package/esm/node/WsEventClient.d.ts +0 -13
  248. package/esm/node/WsEventClient.js +0 -18
  249. package/esm/node/index.d.ts +0 -2
  250. package/esm/types/CamOverlayAPI.d.ts +0 -188
  251. package/esm/types/CamOverlayAPI.js +0 -44
  252. package/esm/types/CamScripterAPI.d.ts +0 -67
  253. package/esm/types/CamStreamerAPI.d.ts +0 -139
  254. package/esm/types/CamSwitcherEvents.d.ts +0 -491
  255. package/esm/types/VapixAPI.d.ts +0 -1683
  256. package/esm/types/common.d.ts +0 -37
  257. package/esm/web/DefaultClient.d.ts +0 -6
  258. package/esm/web/WsClient.d.ts +0 -13
  259. package/esm/web/index.d.ts +0 -2
  260. /package/{cjs/CreatePackage.d.ts → esm/internal/types.js} +0 -0
  261. /package/esm/{CreatePackage.d.ts → types/CamOverlayDrawingAPI.js} +0 -0
  262. /package/{cjs → types}/internal/constants.d.ts +0 -0
  263. /package/{cjs → types}/internal/transformers.d.ts +0 -0
  264. /package/{cjs/internal → types/node}/Digest.d.ts +0 -0
  265. /package/{cjs/node → types/web}/index.d.ts +0 -0
@@ -1,34 +0,0 @@
1
- export declare class ServiceUnavailableError extends Error {
2
- constructor();
3
- }
4
- export declare class ServiceNotFoundError extends Error {
5
- constructor();
6
- }
7
- export declare class ParsingBlobError extends Error {
8
- constructor(err: unknown);
9
- }
10
- type TApplicationAPIAction = 'START' | 'RESTART' | 'STOP';
11
- export declare class ApplicationAPIError extends Error {
12
- constructor(action: TApplicationAPIAction, res: string);
13
- }
14
- type TSDCardAction = 'MOUNT' | 'UNMOUNT';
15
- export declare class SDCardActionError extends Error {
16
- constructor(action: TSDCardAction, res: string);
17
- }
18
- export declare class SDCardJobError extends Error {
19
- constructor();
20
- }
21
- type TMaxFPSErrorType = 'MALFORMED_REPLY' | 'CHANNEL_NOT_FOUND' | 'CAPTURE_MODE_NOT_FOUND' | 'FPS_NOT_SPECIFIED';
22
- export declare class MaxFPSError extends Error {
23
- constructor(state: TMaxFPSErrorType);
24
- }
25
- export declare class NoDeviceInfoError extends Error {
26
- constructor();
27
- }
28
- export declare class FetchDeviceInfoError extends Error {
29
- constructor(err: unknown);
30
- }
31
- export declare class AddNewClipError extends Error {
32
- constructor(message: string);
33
- }
34
- export {};
@@ -1,9 +0,0 @@
1
- import { IClient, HttpOptions } from '../internal/common';
2
- export type AcsEventsOptions = HttpOptions;
3
- export declare class AxisCameraStationEvents {
4
- private sourceKey;
5
- private client;
6
- constructor(sourceKey: string, opt?: AcsEventsOptions | IClient);
7
- sendEvent(data: Record<string, string>, eventType: string): Promise<void>;
8
- private getDate;
9
- }
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AxisCameraStationEvents = void 0;
4
- const DefaultClient_1 = require("../node/DefaultClient");
5
- const common_1 = require("../internal/common");
6
- class AxisCameraStationEvents {
7
- sourceKey;
8
- client;
9
- constructor(sourceKey, opt = {}) {
10
- this.sourceKey = sourceKey;
11
- if ((0, common_1.isClient)(opt)) {
12
- this.client = opt;
13
- }
14
- else {
15
- this.client = new DefaultClient_1.DefaultClient(opt);
16
- }
17
- }
18
- async sendEvent(data, eventType) {
19
- const dateString = this.getDate();
20
- const event = {
21
- addExternalDataRequest: {
22
- occurrenceTime: dateString,
23
- source: this.sourceKey,
24
- externalDataType: eventType,
25
- data: data,
26
- },
27
- };
28
- const eventData = JSON.stringify(event);
29
- const res = await this.client.post('/Acs/Api/ExternalDataFacade/AddExternalData', eventData, undefined, {
30
- 'Content-Type': 'application/json',
31
- 'Content-Length': eventData.length.toString(),
32
- });
33
- if (!res.ok) {
34
- throw new Error(`ACS status code: ${res.status}`);
35
- }
36
- }
37
- getDate() {
38
- const date = new Date();
39
- const year = date.getUTCFullYear();
40
- const month = (0, common_1.pad)(date.getUTCMonth() + 1, 2);
41
- const day = (0, common_1.pad)(date.getUTCDate(), 2);
42
- const hours = (0, common_1.pad)(date.getUTCHours(), 2);
43
- const minutes = (0, common_1.pad)(date.getUTCMinutes(), 2);
44
- const seconds = (0, common_1.pad)(date.getUTCSeconds(), 2);
45
- return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
46
- }
47
- }
48
- exports.AxisCameraStationEvents = AxisCameraStationEvents;
@@ -1,174 +0,0 @@
1
- import { z } from 'zod';
2
- declare const cameraGuidsResponseSchema: z.ZodObject<{
3
- Rsp: z.ZodObject<{
4
- Status: z.ZodString;
5
- Result: z.ZodArray<z.ZodObject<{
6
- Guid: z.ZodString;
7
- }, "strip", z.ZodTypeAny, {
8
- Guid: string;
9
- }, {
10
- Guid: string;
11
- }>, "many">;
12
- }, "strip", z.ZodTypeAny, {
13
- Status: string;
14
- Result: {
15
- Guid: string;
16
- }[];
17
- }, {
18
- Status: string;
19
- Result: {
20
- Guid: string;
21
- }[];
22
- }>;
23
- }, "strip", z.ZodTypeAny, {
24
- Rsp: {
25
- Status: string;
26
- Result: {
27
- Guid: string;
28
- }[];
29
- };
30
- }, {
31
- Rsp: {
32
- Status: string;
33
- Result: {
34
- Guid: string;
35
- }[];
36
- };
37
- }>;
38
- export type TCameraGuidsResponse = z.infer<typeof cameraGuidsResponseSchema>;
39
- declare const connectionResponseSchema: z.ZodObject<{
40
- Rsp: z.ZodObject<{
41
- Status: z.ZodString;
42
- }, "strip", z.ZodTypeAny, {
43
- Status: string;
44
- }, {
45
- Status: string;
46
- }>;
47
- }, "strip", z.ZodTypeAny, {
48
- Rsp: {
49
- Status: string;
50
- };
51
- }, {
52
- Rsp: {
53
- Status: string;
54
- };
55
- }>;
56
- export type TConnectionResponse = z.infer<typeof connectionResponseSchema>;
57
- export declare const cameraDetailSchema: z.ZodObject<{
58
- Guid: z.ZodOptional<z.ZodString>;
59
- Name: z.ZodOptional<z.ZodString>;
60
- EntityType: z.ZodOptional<z.ZodString>;
61
- }, "strip", z.ZodTypeAny, {
62
- Name?: string | undefined;
63
- Guid?: string | undefined;
64
- EntityType?: string | undefined;
65
- }, {
66
- Name?: string | undefined;
67
- Guid?: string | undefined;
68
- EntityType?: string | undefined;
69
- }>;
70
- export declare const cameraDetailsResponseSchema: z.ZodObject<{
71
- Rsp: z.ZodObject<{
72
- Status: z.ZodString;
73
- Result: z.ZodUnion<[z.ZodArray<z.ZodObject<{
74
- Guid: z.ZodOptional<z.ZodString>;
75
- Name: z.ZodOptional<z.ZodString>;
76
- EntityType: z.ZodOptional<z.ZodString>;
77
- }, "strip", z.ZodTypeAny, {
78
- Name?: string | undefined;
79
- Guid?: string | undefined;
80
- EntityType?: string | undefined;
81
- }, {
82
- Name?: string | undefined;
83
- Guid?: string | undefined;
84
- EntityType?: string | undefined;
85
- }>, "many">, z.ZodObject<{
86
- Guid: z.ZodOptional<z.ZodString>;
87
- Name: z.ZodOptional<z.ZodString>;
88
- EntityType: z.ZodOptional<z.ZodString>;
89
- }, "strip", z.ZodTypeAny, {
90
- Name?: string | undefined;
91
- Guid?: string | undefined;
92
- EntityType?: string | undefined;
93
- }, {
94
- Name?: string | undefined;
95
- Guid?: string | undefined;
96
- EntityType?: string | undefined;
97
- }>]>;
98
- }, "strip", z.ZodTypeAny, {
99
- Status: string;
100
- Result: {
101
- Name?: string | undefined;
102
- Guid?: string | undefined;
103
- EntityType?: string | undefined;
104
- } | {
105
- Name?: string | undefined;
106
- Guid?: string | undefined;
107
- EntityType?: string | undefined;
108
- }[];
109
- }, {
110
- Status: string;
111
- Result: {
112
- Name?: string | undefined;
113
- Guid?: string | undefined;
114
- EntityType?: string | undefined;
115
- } | {
116
- Name?: string | undefined;
117
- Guid?: string | undefined;
118
- EntityType?: string | undefined;
119
- }[];
120
- }>;
121
- }, "strip", z.ZodTypeAny, {
122
- Rsp: {
123
- Status: string;
124
- Result: {
125
- Name?: string | undefined;
126
- Guid?: string | undefined;
127
- EntityType?: string | undefined;
128
- } | {
129
- Name?: string | undefined;
130
- Guid?: string | undefined;
131
- EntityType?: string | undefined;
132
- }[];
133
- };
134
- }, {
135
- Rsp: {
136
- Status: string;
137
- Result: {
138
- Name?: string | undefined;
139
- Guid?: string | undefined;
140
- EntityType?: string | undefined;
141
- } | {
142
- Name?: string | undefined;
143
- Guid?: string | undefined;
144
- EntityType?: string | undefined;
145
- }[];
146
- };
147
- }>;
148
- export type TCameraDetailsResponse = z.infer<typeof cameraDetailsResponseSchema>;
149
- export type TCameraDetail = z.infer<typeof cameraDetailSchema>;
150
- export type TParams = Array<'Guid' | 'Name' | 'EntityType'>;
151
- export type GenetecAgentOptions = {
152
- protocol?: 'http' | 'https' | 'https_insecure';
153
- ip?: string;
154
- port?: number;
155
- base_uri?: string;
156
- user?: string;
157
- pass?: string;
158
- app_id?: string;
159
- };
160
- export declare class GenetecAgent {
161
- private settings;
162
- private baseUrl;
163
- private credentials;
164
- constructor(options?: GenetecAgentOptions);
165
- checkConnection(): Promise<TConnectionResponse>;
166
- getAllCameraGuids(): Promise<TCameraGuidsResponse>;
167
- getCameraDetails(guids: {
168
- Guid: string;
169
- }[], parameters: TParams): Promise<TCameraDetail[]>;
170
- sendBookmark(guids: string[], bookmarkText: string): Promise<Response>;
171
- private getRequestOptions;
172
- private getTimeStamp;
173
- }
174
- export {};
@@ -1,123 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GenetecAgent = exports.cameraDetailsResponseSchema = exports.cameraDetailSchema = void 0;
4
- const zod_1 = require("zod");
5
- const common_1 = require("../internal/common");
6
- const ACTION = 'AddCameraBookmark';
7
- const GET_CAMERAS_URL = 'report/EntityConfiguration?q=EntityTypes@Camera';
8
- const GET_CAMERAS_DETAILS_URL = '/entity?q=';
9
- const cameraGuidsResponseSchema = zod_1.z.object({
10
- Rsp: zod_1.z.object({
11
- Status: zod_1.z.string(),
12
- Result: zod_1.z.array(zod_1.z.object({ Guid: zod_1.z.string() })),
13
- }),
14
- });
15
- const connectionResponseSchema = zod_1.z.object({
16
- Rsp: zod_1.z.object({
17
- Status: zod_1.z.string(),
18
- }),
19
- });
20
- exports.cameraDetailSchema = zod_1.z.object({
21
- Guid: zod_1.z.string().optional(),
22
- Name: zod_1.z.string().optional(),
23
- EntityType: zod_1.z.string().optional(),
24
- });
25
- exports.cameraDetailsResponseSchema = zod_1.z.object({
26
- Rsp: zod_1.z.object({
27
- Status: zod_1.z.string(),
28
- Result: zod_1.z.union([zod_1.z.array(exports.cameraDetailSchema), exports.cameraDetailSchema]),
29
- }),
30
- });
31
- class GenetecAgent {
32
- settings;
33
- baseUrl;
34
- credentials;
35
- constructor(options = {}) {
36
- this.settings = {
37
- protocol: options.protocol ?? 'http',
38
- ip: options.ip ?? '127.0.0.1',
39
- port: options.port ?? 80,
40
- base_uri: options.base_uri ?? 'WebSdk',
41
- user: options.user ?? 'root',
42
- pass: options.pass ?? '',
43
- app_id: options.app_id ?? '',
44
- };
45
- this.baseUrl = `${this.settings.protocol}://${this.settings.ip}:${this.settings.port}/${this.settings.base_uri}`;
46
- this.credentials = btoa(`${this.settings.user};${this.settings.app_id}:${this.settings.pass}`);
47
- }
48
- async checkConnection() {
49
- const requestOptions = this.getRequestOptions('GET');
50
- const res = await fetch(`${this.baseUrl}/`, requestOptions);
51
- if (!res.ok) {
52
- throw new Error(await (0, common_1.responseStringify)(res));
53
- }
54
- return connectionResponseSchema.parse(await res.json());
55
- }
56
- async getAllCameraGuids() {
57
- const requestOptions = this.getRequestOptions('GET');
58
- const res = await fetch(`${this.baseUrl}/${GET_CAMERAS_URL}`, requestOptions);
59
- if (!res.ok) {
60
- throw new Error(await (0, common_1.responseStringify)(res));
61
- }
62
- return cameraGuidsResponseSchema.parse(await res.json());
63
- }
64
- async getCameraDetails(guids, parameters) {
65
- const params = parameters.join(',');
66
- let camerasGuids = [];
67
- const requestOptions = this.getRequestOptions('GET');
68
- const allCameras = [];
69
- const chunkSize = 10;
70
- while (guids.length > 0) {
71
- const chunk = guids.slice(0, chunkSize);
72
- guids.splice(0, chunkSize);
73
- camerasGuids = chunk.map((item) => item.Guid);
74
- const camerasDetailsUrl = [];
75
- for (const guid of camerasGuids) {
76
- camerasDetailsUrl.push(`entity=${guid},${params}`);
77
- }
78
- const res = await fetch(`${this.baseUrl}/${GET_CAMERAS_DETAILS_URL}${camerasDetailsUrl.join(',')}`, requestOptions);
79
- if (!res.ok) {
80
- throw new Error(await (0, common_1.responseStringify)(res));
81
- }
82
- const data = exports.cameraDetailsResponseSchema.parse(await res.json());
83
- const resultArray = Array.isArray(data.Rsp.Result) ? data.Rsp.Result : [data.Rsp.Result];
84
- allCameras.push(...resultArray);
85
- }
86
- return allCameras;
87
- }
88
- async sendBookmark(guids, bookmarkText) {
89
- const cameraEntitiesUrl = [];
90
- const timeStamp = this.getTimeStamp();
91
- const requestOptions = this.getRequestOptions('POST');
92
- for (const guid of guids) {
93
- cameraEntitiesUrl.push(`${ACTION}(${guid},${timeStamp},${bookmarkText})`);
94
- }
95
- const res = await fetch(`${this.baseUrl}/action?q=${cameraEntitiesUrl.join(',')}`, requestOptions);
96
- if (!res.ok) {
97
- throw new Error(await (0, common_1.responseStringify)(res));
98
- }
99
- return res;
100
- }
101
- getRequestOptions(method) {
102
- return {
103
- method,
104
- headers: new Headers({
105
- Authorization: `Basic ${this.credentials}`,
106
- Accept: 'text/json',
107
- }),
108
- redirect: 'follow',
109
- };
110
- }
111
- getTimeStamp() {
112
- const date = new Date();
113
- const year = date.getUTCFullYear();
114
- const month = (0, common_1.pad)(date.getUTCMonth() + 1, 2);
115
- const day = (0, common_1.pad)(date.getUTCDate(), 2);
116
- const hours = (0, common_1.pad)(date.getUTCHours(), 2);
117
- const minutes = (0, common_1.pad)(date.getUTCMinutes(), 2);
118
- const seconds = (0, common_1.pad)(date.getUTCSeconds(), 2);
119
- const miliSeconds = (0, common_1.pad)(date.getUTCMilliseconds(), 2);
120
- return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${miliSeconds}Z`;
121
- }
122
- }
123
- exports.GenetecAgent = GenetecAgent;
package/cjs/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- export * from './internal/common';
2
- export * from './internal/constants';
3
- export * from './internal/utils';
4
- export * from './internal/versionCompare';
5
- export * from './types/common';
6
- export { CamSwitcherAPI } from './CamSwitcherAPI';
7
- export { CamSwitcherEvents } from './CamSwitcherEvents';
8
- export { VapixAPI } from './VapixAPI';
9
- export * from './types/CamSwitcherEvents';
10
- export * from './types/CamSwitcherAPI';
11
- export * from './types/VapixAPI';
@@ -1,11 +0,0 @@
1
- /// <reference types="node" />
2
- import { IClient, TParameters } from './common';
3
- import { TProxyParam } from '../types/common';
4
- export declare class ProxyClient<Client extends IClient = IClient> {
5
- client: Client;
6
- getProxyUrl: () => string;
7
- constructor(client: Client, getProxyUrl: () => string);
8
- get: (proxy: TProxyParam, path: string, parameters?: TParameters, headers?: Record<string, string>) => Promise<import("./common").TResponse>;
9
- post: (proxy: TProxyParam, path: string, data: string | Buffer | FormData, parameters?: TParameters, headers?: Record<string, string>) => Promise<import("./common").TResponse>;
10
- private getReal;
11
- }
@@ -1,39 +0,0 @@
1
- /// <reference types="node" />
2
- type Options = {
3
- ip?: string;
4
- port?: number;
5
- user?: string;
6
- pass?: string;
7
- tls?: boolean;
8
- tlsInsecure?: boolean;
9
- };
10
- export type HttpOptions = Options & {
11
- keepAlive?: boolean;
12
- };
13
- export type WsOptions = Options;
14
- export type TResponse = {
15
- ok: boolean;
16
- json: () => Promise<any>;
17
- text: () => Promise<string>;
18
- status: number;
19
- body: any | null;
20
- };
21
- export type TParameters = Record<string, string | number | boolean | null | undefined>;
22
- export type TGetFunction = (url: string, parameters?: TParameters, headers?: Record<string, string>) => Promise<TResponse>;
23
- export type TPostFunction = (url: string, data: string | Buffer | FormData, parameters?: TParameters, headers?: Record<string, string>) => Promise<TResponse>;
24
- export interface IClient {
25
- get: TGetFunction;
26
- post: TPostFunction;
27
- }
28
- export interface IWebsocket<Event extends {
29
- readonly data: string;
30
- }> {
31
- destroy: () => void;
32
- onmessage: null | ((event: Event) => void);
33
- send: (data: string) => void;
34
- }
35
- export declare function isClient(arg?: Options | IClient): arg is IClient;
36
- export declare function responseStringify(res: TResponse): Promise<string>;
37
- export declare function pad(num: number, size: number): string;
38
- export declare function isNullish<T>(value: T | undefined | null): value is undefined | null;
39
- export {};
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isNullish = exports.pad = exports.responseStringify = exports.isClient = void 0;
4
- function isClient(arg = {}) {
5
- return 'get' in arg && 'post' in arg;
6
- }
7
- exports.isClient = isClient;
8
- async function responseStringify(res) {
9
- return JSON.stringify({
10
- status: res.status,
11
- body: await res.text(),
12
- });
13
- }
14
- exports.responseStringify = responseStringify;
15
- function pad(num, size) {
16
- const sign = Math.sign(num) === -1 ? '-' : '';
17
- return (sign +
18
- new Array(size)
19
- .concat([Math.abs(num)])
20
- .join('0')
21
- .slice(-size));
22
- }
23
- exports.pad = pad;
24
- function isNullish(value) {
25
- return value === null || value === undefined;
26
- }
27
- exports.isNullish = isNullish;
@@ -1,15 +0,0 @@
1
- /// <reference types="node" />
2
- import { IClient, HttpOptions, TParameters } from '../internal/common';
3
- export declare class DefaultClient implements IClient {
4
- private tls;
5
- private ip;
6
- private port;
7
- private user;
8
- private pass;
9
- private httpRequestSender;
10
- constructor(opt?: HttpOptions);
11
- get url(): string;
12
- get(path: string, parameters?: TParameters, headers?: Record<string, string>): Promise<import("undici").Response>;
13
- post(path: string, data: string | FormData | Buffer, parameters?: TParameters, headers?: Record<string, string>): Promise<import("undici").Response>;
14
- private getBaseConnectionParams;
15
- }
@@ -1,28 +0,0 @@
1
- /// <reference types="node" />
2
- import { FormData as UndiciFormData, Response as UndiciResponse } from 'undici';
3
- export type HttpRequestOptions = {
4
- method?: string;
5
- protocol: string;
6
- host: string;
7
- port: number;
8
- path: string;
9
- user?: string;
10
- pass?: string;
11
- timeout?: number;
12
- headers?: Record<string, string>;
13
- };
14
- export type AgentOptions = {
15
- rejectUnaurhorized?: boolean;
16
- keepAlive?: boolean;
17
- };
18
- export declare class HttpRequestSender {
19
- private agent?;
20
- private authData?;
21
- constructor(agentOptions?: AgentOptions);
22
- sendRequest(options: HttpRequestOptions, postData?: Buffer | string | UndiciFormData): Promise<UndiciResponse>;
23
- private sendRequestWithAuth;
24
- private static getURL;
25
- private getAuthorization;
26
- private invalidateAuthorization;
27
- private static getAuthHeader;
28
- }
@@ -1,39 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import * as EventEmitter from 'events';
4
- import { WsOptions } from '../internal/common';
5
- export type WsClientOptions = WsOptions & {
6
- address: string;
7
- headers?: Record<string, string>;
8
- pingInterval?: number;
9
- protocol?: string;
10
- };
11
- export interface WsClient {
12
- on(event: 'open', listener: () => void): this;
13
- on(event: 'close', listener: () => void): this;
14
- on(event: 'message', listener: (data: Buffer) => void): this;
15
- on(event: 'error', listener: (err: Error) => void): this;
16
- emit(event: 'open'): boolean;
17
- emit(event: 'close'): boolean;
18
- emit(event: 'message', data: Buffer): boolean;
19
- emit(event: 'error', err: Error): boolean;
20
- }
21
- export declare class WsClient extends EventEmitter {
22
- private user;
23
- private pass;
24
- private address;
25
- private protocol?;
26
- private pingInterval;
27
- private wsOptions;
28
- private digestAddress;
29
- private isAlive;
30
- private pingTimer?;
31
- private ws?;
32
- private isClosed;
33
- constructor(options: WsClientOptions);
34
- open(wwwAuthenticateHeader?: string): void;
35
- send(data: Buffer | string): void;
36
- close(): void;
37
- reconnect(): void;
38
- private closeWsConnection;
39
- }
@@ -1,13 +0,0 @@
1
- import { IWebsocket } from '../internal/common';
2
- import { WsClientOptions } from './WsClient';
3
- type TEvent = {
4
- data: string;
5
- };
6
- export declare class WsEventClient implements IWebsocket<TEvent> {
7
- private wsClient;
8
- constructor(options: WsClientOptions);
9
- send: (data: string) => void;
10
- destroy: () => void;
11
- onmessage: ((event: TEvent) => void) | null;
12
- }
13
- export {};
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WsEventClient = void 0;
4
- const WsClient_1 = require("./WsClient");
5
- class WsEventClient {
6
- wsClient;
7
- constructor(options) {
8
- this.wsClient = new WsClient_1.WsClient(options);
9
- this.wsClient.on('message', (data) => {
10
- this.onmessage?.({ data: data.toString() });
11
- });
12
- }
13
- send = (data) => {
14
- this.wsClient.send(data);
15
- };
16
- destroy = () => {
17
- this.wsClient.close();
18
- this.onmessage = null;
19
- };
20
- onmessage = null;
21
- }
22
- exports.WsEventClient = WsEventClient;