camstreamerlib 4.0.0-beta.2 → 4.0.0-beta.21

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 (238) hide show
  1. package/README.md +5 -1
  2. package/cjs/CamOverlayAPI.d.ts +629 -0
  3. package/cjs/CamOverlayAPI.js +255 -0
  4. package/{CamOverlayDrawingAPI.d.ts → cjs/CamOverlayDrawingAPI.d.ts} +1 -1
  5. package/cjs/CamOverlayDrawingAPI.js +235 -0
  6. package/cjs/CamOverlayPainter/Frame.js +301 -0
  7. package/{CamOverlayPainter → cjs/CamOverlayPainter}/Painter.d.ts +14 -3
  8. package/cjs/CamOverlayPainter/Painter.js +171 -0
  9. package/cjs/CamOverlayPainter/ResourceManager.js +46 -0
  10. package/cjs/CamScripterAPI.d.ts +36 -0
  11. package/cjs/CamScripterAPI.js +73 -0
  12. package/{CamScripterAPICameraEventsGenerator.d.ts → cjs/CamScripterAPICameraEventsGenerator.d.ts} +1 -1
  13. package/cjs/CamScripterAPICameraEventsGenerator.js +162 -0
  14. package/{CamStreamerAPI.d.ts → cjs/CamStreamerAPI.d.ts} +5 -5
  15. package/cjs/CamStreamerAPI.js +59 -0
  16. package/{CamSwitcherAPI.d.ts → cjs/CamSwitcherAPI.d.ts} +10 -6
  17. package/cjs/CamSwitcherAPI.js +351 -0
  18. package/{CamSwitcherEvents.d.ts → cjs/CamSwitcherEvents.d.ts} +2 -2
  19. package/cjs/CamSwitcherEvents.js +67 -0
  20. package/cjs/CreatePackage.js +106 -0
  21. package/cjs/PlaneTrackerAPI.d.ts +47 -0
  22. package/cjs/PlaneTrackerAPI.js +176 -0
  23. package/{VapixAPI.d.ts → cjs/VapixAPI.d.ts} +19 -7
  24. package/cjs/VapixAPI.js +491 -0
  25. package/{VapixEvents.d.ts → cjs/VapixEvents.d.ts} +1 -1
  26. package/cjs/VapixEvents.js +88 -0
  27. package/{errors → cjs/errors}/errors.d.ts +3 -0
  28. package/cjs/errors/errors.js +86 -0
  29. package/{events → cjs/events}/AxisCameraStationEvents.d.ts +3 -2
  30. package/cjs/events/AxisCameraStationEvents.js +48 -0
  31. package/{events → cjs/events}/GenetecAgent.d.ts +4 -3
  32. package/cjs/events/GenetecAgent.js +123 -0
  33. package/cjs/index.d.ts +18 -0
  34. package/cjs/index.js +42 -0
  35. package/cjs/internal/Digest.js +42 -0
  36. package/cjs/internal/ProxyClient.d.ts +11 -0
  37. package/cjs/internal/ProxyClient.js +46 -0
  38. package/cjs/internal/constants.js +4 -0
  39. package/cjs/internal/transformers.js +32 -0
  40. package/cjs/internal/types.d.ts +35 -0
  41. package/cjs/internal/types.js +2 -0
  42. package/{internal → cjs/internal}/utils.d.ts +5 -1
  43. package/cjs/internal/utils.js +69 -0
  44. package/{internal → cjs/internal}/versionCompare.d.ts +2 -2
  45. package/cjs/internal/versionCompare.js +53 -0
  46. package/cjs/models/CamOverlayAPI/accuweatherSchema.d.ts +84 -0
  47. package/cjs/models/CamOverlayAPI/accuweatherSchema.js +48 -0
  48. package/cjs/models/CamOverlayAPI/constants.d.ts +11 -0
  49. package/cjs/models/CamOverlayAPI/constants.js +14 -0
  50. package/cjs/models/CamOverlayAPI/customGraphicsSchema.d.ts +699 -0
  51. package/cjs/models/CamOverlayAPI/customGraphicsSchema.js +73 -0
  52. package/cjs/models/CamOverlayAPI/fileSchema.d.ts +28 -0
  53. package/cjs/models/CamOverlayAPI/fileSchema.js +17 -0
  54. package/cjs/models/CamOverlayAPI/imagesSchema.d.ts +95 -0
  55. package/cjs/models/CamOverlayAPI/imagesSchema.js +10 -0
  56. package/cjs/models/CamOverlayAPI/index.d.ts +13 -0
  57. package/cjs/models/CamOverlayAPI/index.js +29 -0
  58. package/cjs/models/CamOverlayAPI/infotickerSchema.d.ts +96 -0
  59. package/cjs/models/CamOverlayAPI/infotickerSchema.js +27 -0
  60. package/cjs/models/CamOverlayAPI/pipSchema.d.ts +125 -0
  61. package/cjs/models/CamOverlayAPI/pipSchema.js +40 -0
  62. package/cjs/models/CamOverlayAPI/ptzCompassSchema.d.ts +93 -0
  63. package/cjs/models/CamOverlayAPI/ptzCompassSchema.js +26 -0
  64. package/cjs/models/CamOverlayAPI/ptzSchema.d.ts +118 -0
  65. package/cjs/models/CamOverlayAPI/ptzSchema.js +13 -0
  66. package/cjs/models/CamOverlayAPI/screenSharingSchema.d.ts +58 -0
  67. package/cjs/models/CamOverlayAPI/screenSharingSchema.js +9 -0
  68. package/cjs/models/CamOverlayAPI/webCameraSharingSchema.d.ts +58 -0
  69. package/cjs/models/CamOverlayAPI/webCameraSharingSchema.js +9 -0
  70. package/cjs/models/CamOverlayAPI/widgetCommonSchema.d.ts +126 -0
  71. package/cjs/models/CamOverlayAPI/widgetCommonSchema.js +76 -0
  72. package/cjs/models/CamOverlayAPI/widgetsSchema.d.ts +2823 -0
  73. package/cjs/models/CamOverlayAPI/widgetsSchema.js +27 -0
  74. package/cjs/node/DefaultClient.d.ts +16 -0
  75. package/cjs/node/DefaultClient.js +56 -0
  76. package/cjs/node/HttpRequestSender.js +89 -0
  77. package/cjs/node/HttpServer.js +96 -0
  78. package/{node → cjs/node}/WsClient.d.ts +1 -1
  79. package/cjs/node/WsClient.js +149 -0
  80. package/{node → cjs/node}/WsEventClient.d.ts +1 -1
  81. package/cjs/node/WsEventClient.js +22 -0
  82. package/cjs/node/index.d.ts +2 -0
  83. package/cjs/node/index.js +7 -0
  84. package/cjs/types/CamOverlayAPI.d.ts +328 -0
  85. package/cjs/types/CamOverlayAPI.js +26 -0
  86. package/{types → cjs/types}/CamScripterAPI.d.ts +66 -7
  87. package/cjs/types/CamScripterAPI.js +35 -0
  88. package/{types → cjs/types}/CamStreamerAPI.d.ts +16 -5
  89. package/cjs/types/CamStreamerAPI.js +32 -0
  90. package/{types → cjs/types}/CamSwitcherAPI.d.ts +5 -5
  91. package/cjs/types/CamSwitcherAPI.js +137 -0
  92. package/{types/CamswitcherEvents.d.ts → cjs/types/CamSwitcherEvents.d.ts} +77 -0
  93. package/cjs/types/CamSwitcherEvents.js +70 -0
  94. package/cjs/types/PlaneTrackerAPI.d.ts +2 -0
  95. package/cjs/types/PlaneTrackerAPI.js +2 -0
  96. package/{types → cjs/types}/VapixAPI.d.ts +479 -519
  97. package/cjs/types/VapixAPI.js +139 -0
  98. package/cjs/types/common.js +14 -0
  99. package/cjs/web/DefaultClient.d.ts +6 -0
  100. package/cjs/web/DefaultClient.js +22 -0
  101. package/cjs/web/WsClient.js +62 -0
  102. package/cjs/web/index.d.ts +2 -0
  103. package/cjs/web/index.js +7 -0
  104. package/esm/CamOverlayAPI.d.ts +629 -0
  105. package/esm/CamOverlayAPI.js +251 -0
  106. package/esm/CamOverlayDrawingAPI.d.ts +86 -0
  107. package/{CamOverlayDrawingAPI.js → esm/CamOverlayDrawingAPI.js} +6 -3
  108. package/esm/CamOverlayPainter/Frame.d.ts +96 -0
  109. package/esm/CamOverlayPainter/Painter.d.ts +48 -0
  110. package/{CamOverlayPainter → esm/CamOverlayPainter}/Painter.js +4 -1
  111. package/esm/CamOverlayPainter/ResourceManager.d.ts +14 -0
  112. package/{CamOverlayPainter → esm/CamOverlayPainter}/ResourceManager.js +6 -10
  113. package/esm/CamScripterAPI.d.ts +36 -0
  114. package/esm/CamScripterAPI.js +69 -0
  115. package/esm/CamScripterAPICameraEventsGenerator.d.ts +74 -0
  116. package/{CamScripterAPICameraEventsGenerator.js → esm/CamScripterAPICameraEventsGenerator.js} +6 -3
  117. package/esm/CamStreamerAPI.d.ts +16 -0
  118. package/{CamStreamerAPI.js → esm/CamStreamerAPI.js} +4 -10
  119. package/esm/CamSwitcherAPI.d.ts +52 -0
  120. package/{CamSwitcherAPI.js → esm/CamSwitcherAPI.js} +24 -27
  121. package/esm/CamSwitcherEvents.d.ts +18 -0
  122. package/{CamSwitcherEvents.js → esm/CamSwitcherEvents.js} +1 -1
  123. package/esm/CreatePackage.d.ts +1 -0
  124. package/esm/PlaneTrackerAPI.d.ts +47 -0
  125. package/esm/PlaneTrackerAPI.js +172 -0
  126. package/esm/VapixAPI.d.ts +78 -0
  127. package/{VapixAPI.js → esm/VapixAPI.js} +93 -60
  128. package/esm/VapixEvents.d.ts +43 -0
  129. package/{VapixEvents.js → esm/VapixEvents.js} +3 -3
  130. package/esm/errors/errors.d.ts +37 -0
  131. package/{errors → esm/errors}/errors.js +6 -0
  132. package/esm/events/AxisCameraStationEvents.d.ts +10 -0
  133. package/{events → esm/events}/AxisCameraStationEvents.js +1 -1
  134. package/esm/events/GenetecAgent.d.ts +175 -0
  135. package/{events → esm/events}/GenetecAgent.js +5 -5
  136. package/esm/index.d.ts +18 -0
  137. package/esm/index.js +18 -0
  138. package/esm/internal/Digest.d.ts +4 -0
  139. package/{internal → esm/internal}/Digest.js +6 -6
  140. package/esm/internal/ProxyClient.d.ts +11 -0
  141. package/{internal → esm/internal}/ProxyClient.js +6 -4
  142. package/esm/internal/constants.d.ts +1 -0
  143. package/esm/internal/transformers.d.ts +5 -0
  144. package/esm/internal/types.d.ts +35 -0
  145. package/esm/internal/types.js +1 -0
  146. package/esm/internal/utils.d.ts +15 -0
  147. package/{internal → esm/internal}/utils.js +20 -1
  148. package/esm/internal/versionCompare.d.ts +6 -0
  149. package/esm/models/CamOverlayAPI/accuweatherSchema.d.ts +84 -0
  150. package/esm/models/CamOverlayAPI/accuweatherSchema.js +45 -0
  151. package/esm/models/CamOverlayAPI/constants.d.ts +11 -0
  152. package/esm/models/CamOverlayAPI/constants.js +11 -0
  153. package/esm/models/CamOverlayAPI/customGraphicsSchema.d.ts +699 -0
  154. package/esm/models/CamOverlayAPI/customGraphicsSchema.js +70 -0
  155. package/esm/models/CamOverlayAPI/fileSchema.d.ts +28 -0
  156. package/esm/models/CamOverlayAPI/fileSchema.js +14 -0
  157. package/esm/models/CamOverlayAPI/imagesSchema.d.ts +95 -0
  158. package/esm/models/CamOverlayAPI/imagesSchema.js +7 -0
  159. package/esm/models/CamOverlayAPI/index.d.ts +13 -0
  160. package/esm/models/CamOverlayAPI/index.js +13 -0
  161. package/esm/models/CamOverlayAPI/infotickerSchema.d.ts +96 -0
  162. package/esm/models/CamOverlayAPI/infotickerSchema.js +24 -0
  163. package/esm/models/CamOverlayAPI/pipSchema.d.ts +125 -0
  164. package/esm/models/CamOverlayAPI/pipSchema.js +37 -0
  165. package/esm/models/CamOverlayAPI/ptzCompassSchema.d.ts +93 -0
  166. package/esm/models/CamOverlayAPI/ptzCompassSchema.js +23 -0
  167. package/esm/models/CamOverlayAPI/ptzSchema.d.ts +118 -0
  168. package/esm/models/CamOverlayAPI/ptzSchema.js +10 -0
  169. package/esm/models/CamOverlayAPI/screenSharingSchema.d.ts +58 -0
  170. package/esm/models/CamOverlayAPI/screenSharingSchema.js +6 -0
  171. package/esm/models/CamOverlayAPI/webCameraSharingSchema.d.ts +58 -0
  172. package/esm/models/CamOverlayAPI/webCameraSharingSchema.js +6 -0
  173. package/esm/models/CamOverlayAPI/widgetCommonSchema.d.ts +126 -0
  174. package/esm/models/CamOverlayAPI/widgetCommonSchema.js +73 -0
  175. package/esm/models/CamOverlayAPI/widgetsSchema.d.ts +2823 -0
  176. package/esm/models/CamOverlayAPI/widgetsSchema.js +24 -0
  177. package/esm/node/DefaultClient.d.ts +16 -0
  178. package/{node → esm/node}/DefaultClient.js +9 -7
  179. package/esm/node/HttpRequestSender.d.ts +28 -0
  180. package/esm/node/HttpServer.d.ts +21 -0
  181. package/{node → esm/node}/HttpServer.js +1 -1
  182. package/esm/node/WsClient.d.ts +39 -0
  183. package/esm/node/WsEventClient.d.ts +13 -0
  184. package/esm/node/index.d.ts +2 -0
  185. package/esm/node/index.js +2 -0
  186. package/esm/types/CamOverlayAPI.d.ts +328 -0
  187. package/esm/types/CamOverlayAPI.js +14 -0
  188. package/esm/types/CamScripterAPI.d.ts +126 -0
  189. package/esm/types/CamScripterAPI.js +32 -0
  190. package/esm/types/CamStreamerAPI.d.ts +150 -0
  191. package/{types → esm/types}/CamStreamerAPI.js +4 -0
  192. package/esm/types/CamSwitcherAPI.d.ts +814 -0
  193. package/esm/types/CamSwitcherEvents.d.ts +568 -0
  194. package/{types/CamswitcherEvents.js → esm/types/CamSwitcherEvents.js} +8 -0
  195. package/esm/types/PlaneTrackerAPI.d.ts +2 -0
  196. package/esm/types/PlaneTrackerAPI.js +1 -0
  197. package/esm/types/VapixAPI.d.ts +1664 -0
  198. package/{types → esm/types}/VapixAPI.js +30 -23
  199. package/esm/types/common.d.ts +37 -0
  200. package/esm/web/DefaultClient.d.ts +6 -0
  201. package/{web → esm/web}/DefaultClient.js +6 -4
  202. package/esm/web/WsClient.d.ts +13 -0
  203. package/{web → esm/web}/WsClient.js +2 -2
  204. package/esm/web/index.d.ts +2 -0
  205. package/esm/web/index.js +2 -0
  206. package/package.json +6 -6
  207. package/CamOverlayAPI.d.ts +0 -31
  208. package/CamOverlayAPI.js +0 -172
  209. package/CamScripterAPI.d.ts +0 -19
  210. package/CamScripterAPI.js +0 -66
  211. package/internal/ProxyClient.d.ts +0 -11
  212. package/internal/common.d.ts +0 -40
  213. package/internal/common.js +0 -23
  214. package/node/DefaultClient.d.ts +0 -15
  215. package/types/CamOverlayAPI.d.ts +0 -188
  216. package/types/CamOverlayAPI.js +0 -44
  217. package/types/CamScripterAPI.js +0 -17
  218. package/web/DefaultClient.d.ts +0 -6
  219. package/{CamOverlayPainter → cjs/CamOverlayPainter}/Frame.d.ts +0 -0
  220. package/{CamOverlayPainter → cjs/CamOverlayPainter}/ResourceManager.d.ts +0 -0
  221. package/{CreatePackage.d.ts → cjs/CreatePackage.d.ts} +0 -0
  222. package/{internal → cjs/internal}/Digest.d.ts +0 -0
  223. package/{internal → cjs/internal}/constants.d.ts +0 -0
  224. package/{internal → cjs/internal}/transformers.d.ts +0 -0
  225. package/{node → cjs/node}/HttpRequestSender.d.ts +0 -0
  226. package/{node → cjs/node}/HttpServer.d.ts +0 -0
  227. package/{types → cjs/types}/common.d.ts +2 -2
  228. /package/{web → cjs/web}/WsClient.d.ts +0 -0
  229. /package/{CamOverlayPainter → esm/CamOverlayPainter}/Frame.js +0 -0
  230. /package/{CreatePackage.js → esm/CreatePackage.js} +0 -0
  231. /package/{internal → esm/internal}/constants.js +0 -0
  232. /package/{internal → esm/internal}/transformers.js +0 -0
  233. /package/{internal → esm/internal}/versionCompare.js +0 -0
  234. /package/{node → esm/node}/HttpRequestSender.js +0 -0
  235. /package/{node → esm/node}/WsClient.js +0 -0
  236. /package/{node → esm/node}/WsEventClient.js +0 -0
  237. /package/{types → esm/types}/CamSwitcherAPI.js +0 -0
  238. /package/{types → esm/types}/common.js +0 -0
@@ -0,0 +1,78 @@
1
+ import { IClient, TParameters, TResponse } from './internal/types';
2
+ import { TAudioSampleRates, TSDCardInfo, TPtzOverview, TCameraPTZItem, TCameraPTZItemData, TAudioDevice } from './types/VapixAPI';
3
+ import { ProxyClient } from './internal/ProxyClient';
4
+ import { TCameraImageConfig, TProxyParam } from './types/common';
5
+ export declare class VapixAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
6
+ client: ProxyClient<Client>;
7
+ constructor(client: Client, getProxyUrl: () => string);
8
+ getUrlEncoded(proxy: TProxyParam, path: string, parameters?: TParameters, headers?: Record<string, string>): Promise<TResponse>;
9
+ postJson(proxy: TProxyParam, path: string, jsonData: Record<string, any>, headers?: Record<string, string>): Promise<TResponse>;
10
+ getCameraImage(params: TCameraImageConfig, proxy?: TProxyParam): Promise<TResponse>;
11
+ getEventDeclarations(proxy?: TProxyParam): Promise<string>;
12
+ getSupportedAudioSampleRate(proxy?: TProxyParam): Promise<TAudioSampleRates[]>;
13
+ performAutofocus(proxy?: TProxyParam): Promise<void>;
14
+ checkSDCard(proxy?: TProxyParam): Promise<TSDCardInfo>;
15
+ mountSDCard(proxy?: TProxyParam): Promise<number>;
16
+ unmountSDCard(proxy?: TProxyParam): Promise<number>;
17
+ private _doSDCardMountAction;
18
+ fetchSDCardJobProgress(jobId: number, proxy?: TProxyParam): Promise<number>;
19
+ downloadCameraReport(proxy?: TProxyParam): Promise<TResponse>;
20
+ getSystemLog(proxy?: TProxyParam): Promise<TResponse>;
21
+ getMaxFps(channel: number, proxy?: TProxyParam): Promise<number>;
22
+ getTimezone(proxy?: TProxyParam): Promise<string>;
23
+ getDateTimeInfo(proxy?: TProxyParam): Promise<{
24
+ data: {
25
+ dateTime: string;
26
+ dstEnabled: boolean;
27
+ localDateTime: string;
28
+ posixTimeZone: string;
29
+ timeZone?: string | undefined;
30
+ };
31
+ }>;
32
+ getDevicesSettings(proxy?: TProxyParam): Promise<TAudioDevice[]>;
33
+ fetchRemoteDeviceInfo<T extends Record<string, any>>(payload: T, proxy?: TProxyParam): Promise<any>;
34
+ getHeaders(proxy?: TProxyParam): Promise<Record<string, string>>;
35
+ setHeaders(headers: Record<string, string>, proxy?: TProxyParam): Promise<TResponse>;
36
+ getParameter(paramNames: string | string[], proxy?: TProxyParam): Promise<Record<string, string>>;
37
+ setParameter(params: Record<string, string | number | boolean>, proxy?: TProxyParam): Promise<boolean>;
38
+ getGuardTourList(proxy?: TProxyParam): Promise<{
39
+ name: string;
40
+ id: string;
41
+ running: string;
42
+ tour: {
43
+ moveSpeed?: unknown;
44
+ position?: unknown;
45
+ presetNbr?: unknown;
46
+ waitTime?: unknown;
47
+ waitTimeViewType?: unknown;
48
+ }[];
49
+ camNbr?: unknown;
50
+ randomEnabled?: unknown;
51
+ timeBetweenSequences?: unknown;
52
+ }[]>;
53
+ setGuardTourEnabled(guardTourID: string, enable: boolean, proxy?: TProxyParam): Promise<boolean>;
54
+ getPTZPresetList(channel: number, proxy?: TProxyParam): Promise<string[]>;
55
+ listPTZ(camera: number, proxy?: TProxyParam): Promise<TCameraPTZItem[]>;
56
+ listPtzVideoSourceOverview(proxy?: TProxyParam): Promise<TPtzOverview>;
57
+ goToPreset(channel: number, presetName: string, proxy?: TProxyParam): Promise<TResponse>;
58
+ getPtzPosition(camera: number, proxy?: TProxyParam): Promise<TCameraPTZItemData>;
59
+ getInputState(port: number, proxy?: TProxyParam): Promise<boolean>;
60
+ setOutputState(port: number, active: boolean, proxy?: TProxyParam): Promise<TResponse>;
61
+ getApplicationList(proxy?: TProxyParam): Promise<{
62
+ appId: "CamStreamer" | "CamSwitcher" | "CamOverlay" | "CamScripter" | "PlaneTracker" | "Ndihxplugin" | "SportTracker" | null;
63
+ Name: string;
64
+ NiceName: string;
65
+ Vendor: string;
66
+ Version: string;
67
+ License: string;
68
+ Status: string;
69
+ ApplicationID?: string | undefined;
70
+ ConfigurationPage?: string | undefined;
71
+ VendorHomePage?: string | undefined;
72
+ LicenseName?: string | undefined;
73
+ }[]>;
74
+ startApplication(applicationID: string, proxy?: TProxyParam): Promise<void>;
75
+ restartApplication(applicationID: string, proxy?: TProxyParam): Promise<void>;
76
+ stopApplication(applicationID: string, proxy?: TProxyParam): Promise<void>;
77
+ installApplication(data: Blob, fileName: string): Promise<void>;
78
+ }
@@ -1,17 +1,16 @@
1
1
  import * as prettifyXml from 'prettify-xml';
2
- import { parseStringPromise } from 'xml2js';
3
- import { isNullish, responseStringify } from './internal/common';
4
- import { sdCardWatchedStatuses, APP_IDS, maxFpsResponseSchema, dateTimeinfoSchema, audioDeviceRequestSchema, audioSampleRatesResponseSchema, } from './types/VapixAPI';
5
- import { ApplicationAPIError, MaxFPSError, NoDeviceInfoError, SDCardActionError, SDCardJobError, } from './errors/errors';
2
+ import { arrayToUrl, isNullish, paramToUrl, responseStringify } from './internal/utils';
3
+ import { sdCardWatchedStatuses, APP_IDS, maxFpsResponseSchema, dateTimeinfoSchema, audioDeviceRequestSchema, audioSampleRatesResponseSchema, timeZoneSchema, } from './types/VapixAPI';
4
+ import { ApplicationAPIError, MaxFPSError, NoDeviceInfoError, PtzNotSupportedError, SDCardActionError, SDCardJobError, } from './errors/errors';
6
5
  import { ProxyClient } from './internal/ProxyClient';
7
- import { arrayToUrl, paramToUrl } from './internal/utils';
8
6
  import { z } from 'zod';
7
+ import { XMLParser } from 'fast-xml-parser';
9
8
  export class VapixAPI {
10
9
  client;
11
10
  constructor(client, getProxyUrl) {
12
11
  this.client = new ProxyClient(client, getProxyUrl);
13
12
  }
14
- async getUrlEncoded(proxy = null, path, parameters, headers = {}) {
13
+ async getUrlEncoded(proxy, path, parameters, headers = {}) {
15
14
  const data = paramToUrl(parameters);
16
15
  const head = { ...headers, 'Content-Type': 'application/x-www-form-urlencoded' };
17
16
  const res = await this.client.post(proxy, path, data, {}, head);
@@ -20,7 +19,7 @@ export class VapixAPI {
20
19
  }
21
20
  return res;
22
21
  }
23
- async postJson(proxy = null, path, jsonData, headers = {}) {
22
+ async postJson(proxy, path, jsonData, headers = {}) {
24
23
  const data = JSON.stringify(jsonData);
25
24
  const head = { ...headers, 'Content-Type': 'application/json' };
26
25
  const res = await this.client.post(proxy, path, data, {}, head);
@@ -48,8 +47,8 @@ export class VapixAPI {
48
47
  }
49
48
  async getSupportedAudioSampleRate(proxy = null) {
50
49
  const url = '/axis-cgi/audio/streamingcapabilities.cgi';
51
- const formData = { apiVersion: '1.0', method: 'list' };
52
- const res = await this.postJson(proxy, url, formData);
50
+ const jsonData = { apiVersion: '1.0', method: 'list' };
51
+ const res = await this.postJson(proxy, url, jsonData);
53
52
  const encoders = audioSampleRatesResponseSchema.parse(await res.json()).data.encoders;
54
53
  const data = encoders.aac ?? encoders.AAC ?? [];
55
54
  return data.map((item) => {
@@ -75,7 +74,7 @@ export class VapixAPI {
75
74
  await this.postJson(proxy, '/axis-cgi/opticscontrol.cgi', data);
76
75
  }
77
76
  catch (err) {
78
- await this.postJson(proxy, '/axis-cgi/opticssetup.cgi', {
77
+ await this.getUrlEncoded(proxy, '/axis-cgi/opticssetup.cgi', {
79
78
  autofocus: 'perform',
80
79
  source: '1',
81
80
  });
@@ -85,11 +84,13 @@ export class VapixAPI {
85
84
  const res = await this.getUrlEncoded(proxy, '/axis-cgi/disks/list.cgi', {
86
85
  diskid: 'SD_DISK',
87
86
  });
88
- const result = await parseStringPromise(await res.text(), {
89
- ignoreAttrs: false,
90
- mergeAttrs: true,
91
- explicitArray: false,
87
+ const xmlText = await res.text();
88
+ const parser = new XMLParser({
89
+ ignoreAttributes: false,
90
+ attributeNamePrefix: '',
91
+ allowBooleanAttributes: true,
92
92
  });
93
+ const result = parser.parse(xmlText);
93
94
  const data = result.root.disks.disk;
94
95
  return {
95
96
  totalSize: parseInt(data.totalsize),
@@ -108,11 +109,13 @@ export class VapixAPI {
108
109
  action: action,
109
110
  diskid: 'SD_DISK',
110
111
  });
111
- const result = await parseStringPromise(await res.text(), {
112
- ignoreAttrs: false,
113
- mergeAttrs: true,
114
- explicitArray: false,
112
+ const textXml = await res.text();
113
+ const parser = new XMLParser({
114
+ ignoreAttributes: false,
115
+ attributeNamePrefix: '',
116
+ allowBooleanAttributes: true,
115
117
  });
118
+ const result = parser.parse(textXml);
116
119
  const job = result.root.job;
117
120
  if (job.result !== 'OK') {
118
121
  throw new SDCardActionError(action, await responseStringify(res));
@@ -124,12 +127,13 @@ export class VapixAPI {
124
127
  jobid: String(jobId),
125
128
  diskid: 'SD_DISK',
126
129
  });
127
- const result = await parseStringPromise(await res.text(), {
128
- ignoreAttrs: false,
129
- mergeAttrs: true,
130
- explicitArray: false,
130
+ const textXml = await res.text();
131
+ const parser = new XMLParser({
132
+ ignoreAttributes: false,
133
+ attributeNamePrefix: '',
134
+ allowBooleanAttributes: true,
131
135
  });
132
- const job = result.root.job;
136
+ const job = parser.parse(textXml).root.job;
133
137
  if (job.result !== 'OK') {
134
138
  throw new SDCardJobError();
135
139
  }
@@ -164,9 +168,27 @@ export class VapixAPI {
164
168
  return captureMode.maxFPS;
165
169
  }
166
170
  async getTimezone(proxy = null) {
167
- const data = { apiVersion: '1.0', method: 'getDateTimeInfo' };
168
- const res = await this.postJson(proxy, '/axis-cgi/time.cgi', data);
169
- return (await res.json())?.timeZone ?? 'Europe/Prague';
171
+ try {
172
+ const resV2 = await this.client.get(proxy, '/config/rest/time/v2/timeZone');
173
+ if (!resV2.ok) {
174
+ throw new Error(await responseStringify(resV2));
175
+ }
176
+ const json = await resV2.json();
177
+ const data = timeZoneSchema.parse(json);
178
+ if (data.status === 'error') {
179
+ throw new Error(data.error.message);
180
+ }
181
+ return data.data.activeTimeZone;
182
+ }
183
+ catch (error) {
184
+ console.warn('Failed to fetch time zone data from time API v2:', error instanceof Error ? error.message : JSON.stringify(error));
185
+ console.warn('Falling back to deprecated time API v1');
186
+ }
187
+ const data = await this.getDateTimeInfo(proxy);
188
+ if (data.data.timeZone === undefined) {
189
+ throw new Error('Time zone not setup on the device');
190
+ }
191
+ return data.data.timeZone;
170
192
  }
171
193
  async getDateTimeInfo(proxy = null) {
172
194
  const data = { apiVersion: '1.0', method: 'getDateTimeInfo' };
@@ -177,7 +199,7 @@ export class VapixAPI {
177
199
  const data = { apiVersion: '1.0', method: 'getDevicesSettings' };
178
200
  const res = await this.postJson(proxy, '/axis-cgi/audiodevicecontrol.cgi', data);
179
201
  const result = audioDeviceRequestSchema.parse(await res.json());
180
- return result.devices.map((device) => ({
202
+ return result.data.devices.map((device) => ({
181
203
  ...device,
182
204
  inputs: (device.inputs || []).sort((a, b) => a.id.localeCompare(b.id)),
183
205
  outputs: (device.outputs || []).sort((a, b) => a.id.localeCompare(b.id)),
@@ -185,15 +207,11 @@ export class VapixAPI {
185
207
  }
186
208
  async fetchRemoteDeviceInfo(payload, proxy = null) {
187
209
  const res = await this.postJson(proxy, '/axis-cgi/basicdeviceinfo.cgi', payload);
188
- const result = await parseStringPromise(await res.text(), {
189
- ignoreAttrs: false,
190
- mergeAttrs: true,
191
- explicitArray: false,
192
- });
193
- if (isNullish(result.body.data)) {
210
+ const json = await res.json();
211
+ if (isNullish(json.data)) {
194
212
  throw new NoDeviceInfoError();
195
213
  }
196
- return result.data;
214
+ return json.data;
197
215
  }
198
216
  async getHeaders(proxy = null) {
199
217
  const data = { apiVersion: '1.0', method: 'list' };
@@ -231,9 +249,9 @@ export class VapixAPI {
231
249
  const gTour = {
232
250
  id: gTourBaseName,
233
251
  camNbr: response[gTourBaseName + '.CamNbr'],
234
- name: response[gTourBaseName + '.Name'],
252
+ name: response[gTourBaseName + '.Name'] ?? 'Guard Tour ' + (i + 1),
235
253
  randomEnabled: response[gTourBaseName + '.RandomEnabled'],
236
- running: response[gTourBaseName + '.Running'],
254
+ running: response[gTourBaseName + '.Running'] ?? 'no',
237
255
  timeBetweenSequences: response[gTourBaseName + '.TimeBetweenSequences'],
238
256
  tour: [],
239
257
  };
@@ -289,17 +307,29 @@ export class VapixAPI {
289
307
  query: 'presetposcamdata',
290
308
  format: 'json',
291
309
  });
292
- return parseCameraPtzResponse(await response.text())[camera] ?? [];
310
+ const text = await response.text();
311
+ if (text === '') {
312
+ throw new PtzNotSupportedError();
313
+ }
314
+ return parseCameraPtzResponse(text)[camera] ?? [];
293
315
  }
294
316
  async listPtzVideoSourceOverview(proxy = null) {
295
317
  const response = await this.getUrlEncoded(proxy, '/axis-cgi/com/ptz.cgi', {
296
318
  query: 'presetposall',
297
319
  format: 'json',
298
320
  });
299
- const data = parseCameraPtzResponse(await response.text());
321
+ const text = await response.text();
322
+ if (text === '') {
323
+ throw new PtzNotSupportedError();
324
+ }
325
+ const data = parseCameraPtzResponse(text);
300
326
  const res = {};
301
- Object.keys(data).forEach((camera) => {
302
- res[Number(camera) - 1] = data[Number(camera)].map(({ data: itemData, ...d }) => d);
327
+ Object.keys(data)
328
+ .map(Number)
329
+ .forEach((camera) => {
330
+ if (data[camera] !== undefined) {
331
+ res[camera - 1] = data[camera]?.map(({ data: itemData, ...d }) => d);
332
+ }
303
333
  });
304
334
  return res;
305
335
  }
@@ -323,26 +353,29 @@ export class VapixAPI {
323
353
  }
324
354
  async getInputState(port, proxy = null) {
325
355
  const response = await (await this.getUrlEncoded(proxy, '/axis-cgi/io/port.cgi', { checkactive: port.toString() })).text();
326
- return response.split('=')[1].indexOf('active') === 0;
356
+ return response.split('=')[1]?.indexOf('active') === 0;
327
357
  }
328
358
  async setOutputState(port, active, proxy = null) {
329
359
  return this.getUrlEncoded(proxy, '/axis-cgi/io/port.cgi', { action: active ? `${port}:/` : `${port}:\\` });
330
360
  }
331
361
  async getApplicationList(proxy = null) {
332
- const res = await this.getUrlEncoded(proxy, '/axis-cgi/applications/list.cgi');
362
+ const res = await this.client.get(proxy, '/axis-cgi/applications/list.cgi');
333
363
  const xml = await res.text();
334
- const result = (await parseStringPromise(xml));
335
- const apps = [];
336
- for (let i = 0; i < result.reply.application.length; i++) {
337
- apps.push({
338
- ...result.reply.application[i].$,
339
- appId: APP_IDS.find((id) => id.toLowerCase() === result.reply.application[i].$.Name.toLowerCase()) ?? null,
340
- });
341
- }
342
- return apps;
364
+ const parser = new XMLParser({
365
+ ignoreAttributes: false,
366
+ attributeNamePrefix: '',
367
+ allowBooleanAttributes: true,
368
+ });
369
+ const result = parser.parse(xml);
370
+ return result.reply.application.map((app) => {
371
+ return {
372
+ ...app,
373
+ appId: APP_IDS.find((id) => id.toLowerCase() === app.Name.toLowerCase()) ?? null,
374
+ };
375
+ });
343
376
  }
344
377
  async startApplication(applicationID, proxy = null) {
345
- const res = await this.getUrlEncoded(proxy, '/axis-cgi/applications/control.cgi', {
378
+ const res = await this.client.get(proxy, '/axis-cgi/applications/control.cgi', {
346
379
  package: applicationID.toLowerCase(),
347
380
  action: 'start',
348
381
  });
@@ -352,7 +385,7 @@ export class VapixAPI {
352
385
  }
353
386
  }
354
387
  async restartApplication(applicationID, proxy = null) {
355
- const res = await this.getUrlEncoded(proxy, '/axis-cgi/applications/control.cgi', {
388
+ const res = await this.client.get(proxy, '/axis-cgi/applications/control.cgi', {
356
389
  package: applicationID.toLowerCase(),
357
390
  action: 'restart',
358
391
  });
@@ -362,7 +395,7 @@ export class VapixAPI {
362
395
  }
363
396
  }
364
397
  async stopApplication(applicationID, proxy = null) {
365
- const res = await this.getUrlEncoded(proxy, '/axis-cgi/applications/control.cgi', {
398
+ const res = await this.client.get(proxy, '/axis-cgi/applications/control.cgi', {
366
399
  package: applicationID.toLowerCase(),
367
400
  action: 'stop',
368
401
  });
@@ -389,14 +422,14 @@ export class VapixAPI {
389
422
  const parseParameters = (response) => {
390
423
  const params = {};
391
424
  const lines = response.split(/[\r\n]/);
392
- for (let i = 0; i < lines.length; i++) {
393
- if (lines[i].length === 0 || lines[i].substring(0, 7) === '# Error') {
425
+ for (const line of lines) {
426
+ if (line.length === 0 || line.substring(0, 7) === '# Error') {
394
427
  continue;
395
428
  }
396
- const delimiterPos = lines[i].indexOf('=');
429
+ const delimiterPos = line.indexOf('=');
397
430
  if (delimiterPos !== -1) {
398
- const paramName = lines[i].substring(0, delimiterPos);
399
- const paramValue = lines[i].substring(delimiterPos + 1);
431
+ const paramName = line.substring(0, delimiterPos).replace('root.', '');
432
+ const paramValue = line.substring(delimiterPos + 1);
400
433
  params[paramName] = paramValue;
401
434
  }
402
435
  }
@@ -442,7 +475,7 @@ const parsePtz = (parsed) => {
442
475
  };
443
476
  res.push({
444
477
  id,
445
- name: data[0],
478
+ name: data[0] ?? 'Preset ' + id,
446
479
  data: {
447
480
  pan: getValue('pan'),
448
481
  tilt: getValue('tilt'),
@@ -0,0 +1,43 @@
1
+ import { EventEmitter2 as EventEmitter } from 'eventemitter2';
2
+ import { WsOptions } from './internal/types';
3
+ export type VapixEventsOptions = WsOptions;
4
+ type TEventMessage = {
5
+ apiVersion: string;
6
+ method: string;
7
+ params: {
8
+ notification: {
9
+ timestamp: number;
10
+ topic: string;
11
+ message: {
12
+ source: Record<string, string>;
13
+ data: Record<string, string>;
14
+ key: Record<string, string>;
15
+ };
16
+ };
17
+ };
18
+ };
19
+ export interface VapixEvents {
20
+ on(event: 'open', listener: () => void): this;
21
+ on(event: 'close', listener: () => void): this;
22
+ on(event: 'error', listener: (err: Error) => void): this;
23
+ on(event: string, listener: (data: TEventMessage) => void): this;
24
+ emit(event: 'open'): boolean;
25
+ emit(event: 'close'): boolean;
26
+ emit(event: 'error', err: Error): boolean;
27
+ emit(event: string, msg: TEventMessage): boolean;
28
+ }
29
+ export declare class VapixEvents extends EventEmitter {
30
+ private tls;
31
+ private tlsInsecure;
32
+ private ip;
33
+ private port;
34
+ private user;
35
+ private pass;
36
+ private ws;
37
+ constructor(options?: VapixEventsOptions);
38
+ connect(): void;
39
+ disconnect(): void;
40
+ private createWsClient;
41
+ private isReservedEventName;
42
+ }
43
+ export {};
@@ -39,10 +39,10 @@ export class VapixEvents extends EventEmitter {
39
39
  this.ws.on('open', () => {
40
40
  const topics = [];
41
41
  const eventNames = this.eventNames();
42
- for (let i = 0; i < eventNames.length; i++) {
43
- if (!this.isReservedEventName(eventNames[i])) {
42
+ for (const eventName of eventNames) {
43
+ if (!this.isReservedEventName(eventName)) {
44
44
  const topic = {
45
- topicFilter: eventNames[i],
45
+ topicFilter: eventName,
46
46
  };
47
47
  topics.push(topic);
48
48
  }
@@ -0,0 +1,37 @@
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 declare class PtzNotSupportedError extends Error {
35
+ constructor();
36
+ }
37
+ export {};
@@ -64,3 +64,9 @@ export class AddNewClipError extends Error {
64
64
  this.name = 'AddNewClipError';
65
65
  }
66
66
  }
67
+ export class PtzNotSupportedError extends Error {
68
+ constructor() {
69
+ super('Ptz not supported.');
70
+ this.name = 'PtzNotSupportedError';
71
+ }
72
+ }
@@ -0,0 +1,10 @@
1
+ import { IClient, HttpOptions } from '../internal/types';
2
+ import { Response } from 'undici';
3
+ export type AcsEventsOptions = HttpOptions;
4
+ export declare class AxisCameraStationEvents {
5
+ private sourceKey;
6
+ private client;
7
+ constructor(sourceKey: string, opt?: AcsEventsOptions | IClient<Response>);
8
+ sendEvent(data: Record<string, string>, eventType: string): Promise<void>;
9
+ private getDate;
10
+ }
@@ -1,5 +1,5 @@
1
1
  import { DefaultClient } from '../node/DefaultClient';
2
- import { isClient, pad } from '../internal/common';
2
+ import { isClient, pad } from '../internal/utils';
3
3
  export class AxisCameraStationEvents {
4
4
  sourceKey;
5
5
  client;