camstreamerlib 4.0.0-beta.39 → 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 (39) hide show
  1. package/README.md +46 -50
  2. package/cjs/CamOverlayAPI.js +7 -3
  3. package/cjs/CamScripterAPI.js +6 -11
  4. package/cjs/CamStreamerAPI.js +5 -4
  5. package/cjs/CamSwitcherAPI.js +16 -16
  6. package/cjs/PlaneTrackerAPI.js +16 -16
  7. package/cjs/VapixAPI.js +4 -4
  8. package/cjs/errors/errors.js +57 -1
  9. package/cjs/index.js +13 -11
  10. package/cjs/node/index.js +2 -0
  11. package/cjs/types/CamOverlayAPI/CamOverlayAPI.js +4 -4
  12. package/cjs/types/CamScripterAPI.js +2 -2
  13. package/cjs/types/PlaneTrackerAPI.js +3 -1
  14. package/esm/CamOverlayAPI.js +8 -4
  15. package/esm/CamScripterAPI.js +7 -12
  16. package/esm/CamStreamerAPI.js +5 -4
  17. package/esm/CamSwitcherAPI.js +17 -17
  18. package/esm/PlaneTrackerAPI.js +16 -16
  19. package/esm/VapixAPI.js +5 -5
  20. package/esm/errors/errors.js +48 -0
  21. package/esm/index.js +9 -7
  22. package/esm/node/index.js +2 -0
  23. package/esm/types/CamOverlayAPI/CamOverlayAPI.js +3 -3
  24. package/esm/types/CamScripterAPI.js +1 -1
  25. package/esm/types/PlaneTrackerAPI.js +3 -1
  26. package/package.json +1 -1
  27. package/types/CamOverlayAPI.d.ts +2 -2
  28. package/types/CamScripterAPI.d.ts +7 -22
  29. package/types/CamStreamerAPI.d.ts +3 -9
  30. package/types/CamSwitcherAPI.d.ts +7 -7
  31. package/types/PlaneTrackerAPI.d.ts +18 -16
  32. package/types/VapixAPI.d.ts +1 -1
  33. package/types/errors/errors.d.ts +25 -1
  34. package/types/index.d.ts +9 -7
  35. package/types/node/index.d.ts +2 -0
  36. package/types/types/CamOverlayAPI/CamOverlayAPI.d.ts +2 -2
  37. package/types/types/CamScripterAPI.d.ts +4 -6
  38. package/types/types/CamStreamerAPI.d.ts +0 -2
  39. package/types/types/PlaneTrackerAPI.d.ts +10 -0
package/README.md CHANGED
@@ -15,37 +15,65 @@ Examples of CamScripter packages can be found at https://github.com/CamStreamer/
15
15
  npm install camstreamerlib
16
16
  ```
17
17
 
18
- # Documentation for ACAP and Camera API
18
+ ## Documentation for ACAP and Camera API
19
19
 
20
- - [VapixAPI](doc/VapixAPI.md) is a module to access Axis camera VAPIX interface.
21
20
 
22
- - [CamStreamerAPI](doc/CamStreamerAPI.md) is a module for easy control of video streaming in the CamStreamer ACAP application (RTMP, HLS, SRT and MPEG-TS protocols).
21
+ | API | Description |
22
+ | ------------- | ------------- |
23
+ | [VapixAPI](doc/VapixAPI.md) | Module to access Axis camera VAPIX interface. |
24
+ | [CamStreamerAPI](doc/CamStreamerAPI.md) | Module for easy control of video streaming in the CamStreamer ACAP application (RTMP, HLS, SRT and MPEG-TS protocols). |
25
+ | [CamOverlayAPI](doc/CamOverlayAPI.md) | Module to access CamOverlay API. |
26
+ | [CamScripterAPI](doc/CamScripterAPI.md) | Module to access CamScripter API. |
27
+ | [CamSwitcherAPI](doc/CamSwitcherAPI.md) | Module to access CamSwitcher API. |
28
+ | [PlaneTrackerAPI](doc/PlaneTrackerAPI.md) | Module to access PlaneTracker API. |
23
29
 
24
- - [CamOverlayAPI](doc/CamOverlayAPI.md) is a module to access CamOverlay API.
30
+ ## Documentation for Node.js modules
25
31
 
26
- - [CamScripterAPI](doc/CamScripterAPI.md) is a module to access CamScripter API.
32
+ | Module | Description |
33
+ | ------------- | ------------- |
34
+ | [HttpServer](doc/HttpServer.md) | Module for processing HTTP requests in your scripts. It also automatically serves up the content from html directory or you can register paths which you can process by your own (e.g. `http://$CAMERA_IP/local/camscripter/proxy/$MY_PACKAGE_NAME/control.cgi`). |
35
+ | [VapixEvents](doc/VapixEvents.md) | Module which allows receiving camera events from the VAPIX API. |
36
+ | [CamOverlayDrawingAPI](doc/CamOverlayDrawingAPI.md) | Module for easy control of CamOverlay drawing API. For more details on supported video overlay drawing functions see https://camstreamer.com/camoverlay-api1 |
37
+ | [CamOverlayPainter](doc/CamOverlayPainter.md) | Contains three modules which makes easier to use CamOverlayDrawingAPI. |
38
+ | [CamScripterAPICameraEventsGenerator](doc/CamScripterAPICameraEventsGenerator.md) | Module which allows generating events on an Axis camera. These events can be used for triggers in the Axis camera rule engine (events/actions). It is also an easy way how to integrate events and metadata in VMS systems which support Axis camera events. |
39
+ | [CamSwitcherEvents](doc/CamSwitcherEvents.md) | Module which allows receiving events from CamSwitcher ACAP application. |
40
+ | [GenetecAgent](doc/GenetecAgent.md) | Module which allows receiving and sending data to Genetec VMS. |
27
41
 
28
- - [CamSwitcherAPI](doc/CamSwitcherAPI.md) is a module to access CamSwitcher API.
29
42
 
30
- - [PlaneTrackerAPI](doc/PlaneTrackerAPI.md) is a module to access PlaneTracker API.
43
+ ## Breaking changes when moving from version 3.\*.\* to 4.\*.\* (latest)
31
44
 
32
- # Documentation for Node.js modules
33
-
34
- - [HttpServer](doc/HttpServer.md) is a module for processing HTTP requests in your scripts. It also automatically serves up the content from html directory or you can register paths which you can process by your own (e.g. http://$CAMERA_IP/local/camscripter/proxy/$MY_PACKAGE_NAME/control.cgi).
45
+ ...
35
46
 
36
- - [VapixEvents](doc/VapixEvents.md) is a module which allows receiving camera events from the VAPIX API.
37
47
 
38
- - [CamOverlayDrawingAPI](doc/CamOverlayDrawingAPI.md) is a module for easy control of CamOverlay drawing API. For more details on supported video overlay drawing functions see https://camstreamer.com/camoverlay-api1
48
+ ## Breaking changes when moving from version 2.\*.\* to 3.\*.\*
39
49
 
40
- - [CamOverlayPainter/](doc/CamOverlayPainter.md) contains three modules which makes easier to use CamOverlayDrawingAPI.
50
+ - CamStreamerlib requiers Node.js version 18 or higher.
51
+ - CamOverlayDrawingAPI tries to reconnect when the websocket is closed. You don't have to do it manually.
52
+ > [!NOTE]
53
+ > However, events `open` and `close` are still emitted in case you need to react to them.
54
+ - Files `common.ts`, `Digest.ts`, `HttpRequest.ts` and `WsClient.ts` moved to a folder internal.
55
+ - Removed function `httpRequest()`. Use `sendRequest()` instead. It uses the same interface except for the "noWaitForData" parameter.
56
+ > [!IMPORTANT]
57
+ > It returns (Response object)[https://developer.mozilla.org/en-US/docs/Web/API/Response] which doesn't contain data by default.
58
+ > If you need to wait for data, you can call for example the function `await res.text()`.
59
+ > This change affects the function `vapixGet` from (CameraVapix)[doc/CameraVapix.md] too.
41
60
 
42
- - [CamScripterAPICameraEventsGenerator](doc/CamScripterAPICameraEventsGenerator.md) is a module which allows generating events on an Axis camera. These events can be used for triggers in the Axis camera rule engine (events/actions). It is also an easy way how to integrate events and metadata in VMS systems which support Axis camera events.
61
+ ## Breaking changes when moving from version 1.\*.\* to 2.\*.\*
43
62
 
44
- - [CamSwitcherEvents](doc/CamSwitcherEvents.md) is a module which allows receiving events from CamSwitcher ACAP application.
63
+ - Renamed file HTTPRequest.ts to HttpRequest.ts
64
+ - Removed deprecated protocol attribute from all options objects (use tls instead).
65
+ - Removed RTSP
66
+ > [!IMPORTANT]
67
+ > Previously CameraVapix.ts supported both WebSocket and RTSP.
68
+ > Starting with version 2.0.0, it supports WebSocket only.
69
+ - ServiceID shouldn't be passed to CamOverlayAPI by the options object. Pass it as a parameter.
70
+ - Renamed CamOverlayDrawingAPI event msg to message.
71
+ - Drawing services extracted from CamOverlayAPI.ts to a separate file.
72
+ > [!IMPORTANT]
73
+ > Please read [CamOverlayAPI](doc/CamOverlayAPI.md) and [CamOverlayDrawingAPI](doc/CamOverlayDrawingAPI.md) for more information.
45
74
 
46
- - [GenetecAgent](doc/GenetecAgent.md) is a module which allows receiving and sending data to Genetec VMS.
47
75
 
48
- ## For Developers
76
+ # For Developers
49
77
 
50
78
  ### Publishing to npm repository
51
79
 
@@ -81,36 +109,4 @@ The zip package is created in the current directory. You can choose different lo
81
109
  "scripts": {
82
110
  "create-package": "node node_modules/camstreamerlib/bin/CreatePackage.js -i -e=react"
83
111
  }
84
- ```
85
-
86
- ### Breaking changes when moving from version 3.\*.\* to 4.\*.\*
87
-
88
- ...
89
-
90
-
91
- ### Breaking changes when moving from version 2.\*.\* to 3.\*.\*
92
-
93
- - CamStreamerlib requiers Node.js version 18 or higher.
94
- - CamOverlayDrawingAPI tries to reconnect when the websocket is closed. You don't have to do it manually.
95
- > [!IMPORTANT]
96
- > However, events `open` and `close` are still emitted in case you need to react to them.
97
- - Files common.ts, Digest.ts, HttpRequest.ts and WsClient.ts moved to a folder internal.
98
- - Removed function httpRequest(). Use sendRequest() instead. It uses the same interface except for the "noWaitForData" parameter.
99
- > [!IMPORTANT]
100
- > It returns (Response object)[https://developer.mozilla.org/en-US/docs/Web/API/Response] which doesn't contain data by default.
101
- > If you need to wait for data, you can call for example the function `await res.text()`.
102
- > This change affects the function `vapixGet` from (CameraVapix)[doc/CameraVapix.md] too.
103
-
104
- ### Breaking changes when moving from version 1.\*.\* to 2.\*.\*
105
-
106
- - Renamed file HTTPRequest.ts to HttpRequest.ts
107
- - Removed deprecated protocol attribute from all options objects (use tls instead).
108
- - Removed RTSP
109
- > [!IMPORTANT]
110
- > Previously CameraVapix.ts supported both WebSocket and RTSP.
111
- > Starting with version 2.0.0, it supports WebSocket only.
112
- - ServiceID shouldn't be passed to CamOverlayAPI by the options object. Pass it as a parameter.
113
- - Renamed CamOverlayDrawingAPI event msg to message.
114
- - Drawing services extracted from CamOverlayAPI.ts to a separate file.
115
- > [!IMPORTANT]
116
- > Please read [CamOverlayAPI](doc/CamOverlayAPI.md) and [CamOverlayDrawingAPI](doc/CamOverlayDrawingAPI.md) for more information.
112
+ ```
@@ -53,7 +53,7 @@ class CamOverlayAPI {
53
53
  async getFileStorage(fileType, options) {
54
54
  const res = await this._getJson(`${BASE_PATH}/upload_${fileType}.cgi`, { action: 'get_storage' }, options);
55
55
  if (res.code !== 200) {
56
- throw new Error('Error occured while fetching file storage data');
56
+ throw new errors_1.StorageDataFetchError(res);
57
57
  }
58
58
  return CamOverlayAPI_1.storageDataListSchema.parse(res.list);
59
59
  }
@@ -68,7 +68,11 @@ class CamOverlayAPI {
68
68
  }
69
69
  async isEnabled(serviceId, options) {
70
70
  const agent = this.getClient(options?.proxyParams);
71
- const res = await agent.get({ path: `${BASE_PATH}/services.cgi?action=get`, timeout: options?.timeout });
71
+ const res = await agent.get({
72
+ path: `${BASE_PATH}/services.cgi`,
73
+ parameters: { action: 'get' },
74
+ timeout: options?.timeout,
75
+ });
72
76
  if (res.ok) {
73
77
  const data = JSON.parse(await res.text());
74
78
  for (const service of data.services) {
@@ -145,7 +149,7 @@ class CamOverlayAPI {
145
149
  async promiseCGUpdate(serviceId, action, params = {}, contentType, data, options) {
146
150
  const path = `${BASE_PATH}/customGraphics.cgi`;
147
151
  let headers = {};
148
- if (contentType !== undefined && data) {
152
+ if (contentType !== undefined && data !== undefined) {
149
153
  headers = { 'Content-Type': contentType };
150
154
  }
151
155
  const agent = this.getClient(options?.proxyParams);
@@ -25,41 +25,36 @@ class CamScripterAPI {
25
25
  }
26
26
  async getStorageInfo(options) {
27
27
  const res = await this._getJson(`${BASE_PATH}/package/get_storage.cgi`, undefined, options);
28
- return CamScripterAPI_1.storageSchema.parse(res);
28
+ return CamScripterAPI_1.cameraStorageSchema.parse(res);
29
29
  }
30
30
  async getPackageList(options) {
31
31
  const res = await this._getJson(`${BASE_PATH}/package/list.cgi`, undefined, options);
32
32
  return CamScripterAPI_1.packageInfoListSchema.parse(res);
33
33
  }
34
34
  async installPackages(formData, storage, options) {
35
- const res = await this._post(`${BASE_PATH}/package/install.cgi`, formData, { storage: storage }, options);
36
- return CamScripterAPI_1.camscripterApiResponseSchema.parse(res);
35
+ await this._post(`${BASE_PATH}/package/install.cgi`, formData, { storage: storage }, options);
37
36
  }
38
37
  async uninstallPackage(packageId, options) {
39
- const res = await this._getJson(`${BASE_PATH}/package/remove.cgi`, { package_name: packageId }, options);
40
- return CamScripterAPI_1.camscripterApiResponseSchema.parse(res);
38
+ await this._getJson(`${BASE_PATH}/package/remove.cgi`, { package_name: packageId }, options);
41
39
  }
42
40
  async importSettings(packageId, formData, options) {
43
- const res = await this._post(`${BASE_PATH}/package/data.cgi`, formData, {
41
+ await this._post(`${BASE_PATH}/package/data.cgi`, formData, {
44
42
  action: 'IMPORT',
45
43
  package_name: packageId,
46
44
  }, options);
47
- return CamScripterAPI_1.camscripterApiResponseSchema.parse(res);
48
45
  }
49
46
  async exportSettings(packageId, formData, options) {
50
- const res = await this._post(`${BASE_PATH}/package/data.cgi`, formData, {
47
+ await this._post(`${BASE_PATH}/package/data.cgi`, formData, {
51
48
  action: 'EXPORT',
52
49
  package_name: packageId,
53
50
  }, options);
54
- return CamScripterAPI_1.camscripterApiResponseSchema.parse(res);
55
51
  }
56
52
  async getNodejsStatus(options) {
57
53
  const res = await this._getJson(`${BASE_PATH}/diagnostics.cgi`, undefined, options);
58
54
  return CamScripterAPI_1.nodeStateSchema.parse(res);
59
55
  }
60
56
  async installNodejs(storage, options) {
61
- const res = await this._getJson(`${BASE_PATH}/node_update.cgi`, { storage: storage }, options);
62
- return CamScripterAPI_1.camscripterApiResponseSchema.parse(res);
57
+ await this._getJson(`${BASE_PATH}/node_update.cgi`, { storage: storage }, options);
63
58
  }
64
59
  async _getJson(path, parameters, options) {
65
60
  const agent = this.getClient(options?.proxyParams);
@@ -5,6 +5,7 @@ const zod_1 = require("zod");
5
5
  const ProxyClient_1 = require("./internal/ProxyClient");
6
6
  const utils_1 = require("./internal/utils");
7
7
  const CamStreamerAPI_1 = require("./types/CamStreamerAPI");
8
+ const errors_1 = require("./errors/errors");
8
9
  const BASE_PATH = '/local/camstreamer';
9
10
  class CamStreamerAPI {
10
11
  client;
@@ -17,14 +18,14 @@ class CamStreamerAPI {
17
18
  async wsAuthorization(options) {
18
19
  const res = await this._getJson(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
19
20
  if (res.status !== 200) {
20
- throw new Error(`Server error on ws authorization: ${res.message}`);
21
+ throw new errors_1.WsAuthorizationError(res.message);
21
22
  }
22
23
  return zod_1.z.string().parse(res.data);
23
24
  }
24
25
  async getUtcTime(options) {
25
26
  const res = await this._getJson(`${BASE_PATH}/get_utc_time.cgi`, undefined, options);
26
27
  if (res.status !== 200) {
27
- throw new Error(`Server error on get UTC time: ${res.message}`);
28
+ throw new errors_1.UtcTimeFetchError(res.message);
28
29
  }
29
30
  return zod_1.z.number().parse(res.data);
30
31
  }
@@ -49,7 +50,7 @@ class CamStreamerAPI {
49
50
  }
50
51
  async setStream(streamId, params, options) {
51
52
  const { streamDelay, startTime, stopTime, ...rest } = params;
52
- return await this._getJson(`${BASE_PATH}/stream/set.cgi`, {
53
+ await this._getJson(`${BASE_PATH}/stream/set.cgi`, {
53
54
  stream_id: streamId,
54
55
  streamDelay: streamDelay ?? '',
55
56
  startTime: startTime ?? null,
@@ -58,7 +59,7 @@ class CamStreamerAPI {
58
59
  }, options);
59
60
  }
60
61
  async setStreamParameter(streamId, paramName, value, options) {
61
- return await this._getJson(`${BASE_PATH}/stream/set.cgi`, { stream_id: streamId, [paramName]: value }, options);
62
+ await this._getJson(`${BASE_PATH}/stream/set.cgi`, { stream_id: streamId, [paramName]: value }, options);
62
63
  }
63
64
  async isStreaming(streamId, options) {
64
65
  const res = await this._getJson(`${BASE_PATH}/get_streamstat.cgi`, { stream_id: streamId }, options);
@@ -26,6 +26,14 @@ class CamSwitcherAPI {
26
26
  getClient(proxyParams) {
27
27
  return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
28
28
  }
29
+ async checkCameraTime(options) {
30
+ const res = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
31
+ return zod_1.z.boolean().parse(res.data);
32
+ }
33
+ async getNetworkCameraList(options) {
34
+ const res = await this._getJson(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
35
+ return common_1.networkCameraListSchema.parse(res.data);
36
+ }
29
37
  async generateSilence(sampleRate, channels, options) {
30
38
  const agent = this.getClient(options?.proxyParams);
31
39
  await agent.get({
@@ -37,14 +45,6 @@ class CamSwitcherAPI {
37
45
  timeout: options?.timeout,
38
46
  });
39
47
  }
40
- async checkCameraTime(options) {
41
- const res = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
42
- return zod_1.z.boolean().parse(res.data);
43
- }
44
- async getNetworkCameraList(options) {
45
- const res = await this._getJson(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
46
- return common_1.networkCameraListSchema.parse(res.data);
47
- }
48
48
  async getMaxFps(source, options) {
49
49
  const res = await this._getJson(`${BASE_PATH}/get_max_framerate.cgi`, {
50
50
  video_source: source,
@@ -84,16 +84,16 @@ class CamSwitcherAPI {
84
84
  return CamSwitcherAPI_1.trackerSaveLoadSchema.parse(res.data);
85
85
  }
86
86
  async setStreamSaveList(data, options) {
87
- return await this._post(`${BASE_PATH}/streams.cgi`, data, { action: 'set' }, options);
87
+ await this._post(`${BASE_PATH}/streams.cgi`, data, { action: 'set' }, options);
88
88
  }
89
89
  async setClipSaveList(data, options) {
90
- return await this._post(`${BASE_PATH}/clips.cgi`, data, { action: 'set' }, options);
90
+ await this._post(`${BASE_PATH}/clips.cgi`, data, { action: 'set' }, options);
91
91
  }
92
92
  async setPlaylistSaveList(data, options) {
93
- return await this._post(`${BASE_PATH}/playlists.cgi`, data, { action: 'set' }, options);
93
+ await this._post(`${BASE_PATH}/playlists.cgi`, data, { action: 'set' }, options);
94
94
  }
95
95
  async setTrackerSaveList(data, options) {
96
- return await this._post(`${BASE_PATH}/trackers.cgi`, data, { action: 'set' }, options);
96
+ await this._post(`${BASE_PATH}/trackers.cgi`, data, { action: 'set' }, options);
97
97
  }
98
98
  async playlistSwitch(playlistName, options) {
99
99
  await this._getJson(`${BASE_PATH}/playlist_switch.cgi`, { playlist_name: playlistName }, options);
@@ -131,8 +131,8 @@ class CamSwitcherAPI {
131
131
  throw new errors_1.AddNewClipError(output.message);
132
132
  }
133
133
  }
134
- removeClip(clipId, storage, options) {
135
- return this._getJson(`${BASE_PATH}/clip_remove.cgi`, { clip_name: clipId, storage }, options);
134
+ async removeClip(clipId, storage, options) {
135
+ await this._getJson(`${BASE_PATH}/clip_remove.cgi`, { clip_name: clipId, storage }, options);
136
136
  }
137
137
  async getClipList(options) {
138
138
  const res = await this._getJson(`${BASE_PATH}/clip_list.cgi`, undefined, options);
@@ -293,10 +293,10 @@ class CamSwitcherAPI {
293
293
  }
294
294
  }
295
295
  catch {
296
- throw new Error('Error: in JSON parsing of ' + paramName + '. Cannot parse: ' + data[paramName]);
296
+ throw new errors_1.JsonParseError(paramName, data[paramName]);
297
297
  }
298
298
  }
299
- throw new Error("Error: no parametr '" + paramName + "' was found");
299
+ throw new errors_1.ParameterNotFoundError(paramName);
300
300
  }
301
301
  }
302
302
  exports.CamSwitcherAPI = CamSwitcherAPI;
@@ -25,7 +25,7 @@ class PlaneTrackerAPI {
25
25
  }
26
26
  async resetPtzCalibration(options) {
27
27
  const agent = this.getClient(options?.proxyParams);
28
- return await agent.get({
28
+ await agent.get({
29
29
  path: `${BASE_PATH}/package/resetPtzCalibration.cgi`,
30
30
  parameters: this.apiUser,
31
31
  timeout: options?.timeout,
@@ -33,7 +33,7 @@ class PlaneTrackerAPI {
33
33
  }
34
34
  async resetFocusCalibration(options) {
35
35
  const agent = this.getClient(options?.proxyParams);
36
- return await agent.get({
36
+ await agent.get({
37
37
  path: `${BASE_PATH}/package/resetFocusCalibration.cgi`,
38
38
  parameters: this.apiUser,
39
39
  timeout: options?.timeout,
@@ -41,11 +41,11 @@ class PlaneTrackerAPI {
41
41
  }
42
42
  async serverRunCheck(options) {
43
43
  const agent = this.getClient(options?.proxyParams);
44
- return await agent.get({ path: `${BASE_PATH}/package/serverRunCheck.cgi`, timeout: options?.timeout });
44
+ await agent.get({ path: `${BASE_PATH}/package/serverRunCheck.cgi`, timeout: options?.timeout });
45
45
  }
46
46
  async getLiveViewAlias(rtspUrl, options) {
47
47
  const agent = this.getClient(options?.proxyParams);
48
- return await agent.get({
48
+ await agent.get({
49
49
  path: `${BASE_PATH}/getLiveViewAlias.cgi`,
50
50
  parameters: { rtsp_url: rtspUrl },
51
51
  timeout: options?.timeout,
@@ -55,8 +55,8 @@ class PlaneTrackerAPI {
55
55
  const res = await this._getJson(`${BASE_PATH}/package_camera_settings.cgi`, { action: 'get' }, options);
56
56
  return PlaneTrackerAPI_1.cameraSettingsSchema.parse(res);
57
57
  }
58
- async setCameraSettings(settingsJsonString, options) {
59
- return await this._postJsonEncoded(`${BASE_PATH}/package_camera_settings.cgi`, settingsJsonString, {
58
+ async setCameraSettings(settings, options) {
59
+ await this._postJsonEncoded(`${BASE_PATH}/package_camera_settings.cgi`, settings, {
60
60
  action: 'set',
61
61
  }, options);
62
62
  }
@@ -69,7 +69,7 @@ class PlaneTrackerAPI {
69
69
  }
70
70
  async importAppSettings(dataType, formData, options) {
71
71
  const agent = this.getClient(options?.proxyParams);
72
- return await agent.post({
72
+ await agent.post({
73
73
  path: `${BASE_PATH}/package_data.cgi`,
74
74
  data: formData,
75
75
  parameters: { action: 'IMPORT', dataType },
@@ -85,11 +85,11 @@ class PlaneTrackerAPI {
85
85
  return PlaneTrackerAPI_1.trackingModeSchema.parse(res);
86
86
  }
87
87
  async setTrackingMode(mode, options) {
88
- return await this._postJsonEncoded(`${BASE_PATH}/package/setTrackingMode.cgi`, { mode }, this.apiUser, options);
88
+ await this._postJsonEncoded(`${BASE_PATH}/package/setTrackingMode.cgi`, { mode }, this.apiUser, options);
89
89
  }
90
90
  async startTrackingPlane(icao, options) {
91
91
  const agent = this.getClient(options?.proxyParams);
92
- return await agent.get({
92
+ await agent.get({
93
93
  path: `${BASE_PATH}/package/trackIcao.cgi`,
94
94
  parameters: { icao, ...this.apiUser },
95
95
  timeout: options?.timeout,
@@ -97,7 +97,7 @@ class PlaneTrackerAPI {
97
97
  }
98
98
  async stopTrackingPlane(options) {
99
99
  const agent = this.getClient(options?.proxyParams);
100
- return await agent.get({
100
+ await agent.get({
101
101
  path: `${BASE_PATH}/package/resetIcao.cgi`,
102
102
  parameters: this.apiUser,
103
103
  timeout: options?.timeout,
@@ -108,21 +108,21 @@ class PlaneTrackerAPI {
108
108
  return PlaneTrackerAPI_1.priorityListSchema.parse(res);
109
109
  }
110
110
  async setPriorityList(priorityList, options) {
111
- return await this._postJsonEncoded(`${BASE_PATH}/package/setPriorityList.cgi`, { priorityList }, this.apiUser, options);
111
+ await this._postJsonEncoded(`${BASE_PATH}/package/setPriorityList.cgi`, { priorityList }, this.apiUser, options);
112
112
  }
113
113
  async getWhiteList(options) {
114
114
  const res = await this._getJson(`${BASE_PATH}/package/getWhiteList.cgi`, undefined, options);
115
115
  return PlaneTrackerAPI_1.whiteListSchema.parse(res);
116
116
  }
117
117
  async setWhiteList(whiteList, options) {
118
- return await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, { whiteList }, this.apiUser, options);
118
+ await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, { whiteList }, this.apiUser, options);
119
119
  }
120
120
  async getBlackList(options) {
121
121
  const res = await this._getJson(`${BASE_PATH}/package/getBlackList.cgi`, undefined, options);
122
122
  return PlaneTrackerAPI_1.blackListSchema.parse(res);
123
123
  }
124
124
  async setBlackList(blackList, options) {
125
- return await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, { blackList }, this.apiUser, options);
125
+ await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, { blackList }, this.apiUser, options);
126
126
  }
127
127
  async fetchMapInfo(options) {
128
128
  const res = await this._getJson(`${BASE_PATH}/package/getMapInfo.cgi`, undefined, options);
@@ -133,18 +133,18 @@ class PlaneTrackerAPI {
133
133
  return PlaneTrackerAPI_1.zonesSchema.parse(res);
134
134
  }
135
135
  async setZones(zones, options) {
136
- return await this._postJsonEncoded(`${BASE_PATH}/package/setZones.cgi`, { zones }, this.apiUser, options);
136
+ await this._postJsonEncoded(`${BASE_PATH}/package/setZones.cgi`, { zones }, this.apiUser, options);
137
137
  }
138
138
  async goToCoordinates(lat, lon, alt, options) {
139
139
  const agent = this.getClient(options?.proxyParams);
140
- return await agent.get({
140
+ await agent.get({
141
141
  path: `${BASE_PATH}/package/goToCoordinates.cgi`,
142
142
  parameters: { lat, lon, alt, ...this.apiUser },
143
143
  timeout: options?.timeout,
144
144
  });
145
145
  }
146
146
  async checkGenetecConnection(params, options) {
147
- return await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, '', params, options);
147
+ await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, '', params, options);
148
148
  }
149
149
  async getGenetecCameraList(params, options) {
150
150
  const res = await this._postUrlEncoded(`${BASE_PATH}/package/getGenetecCameraList.cgi`, '', params, options);
package/cjs/VapixAPI.js CHANGED
@@ -195,7 +195,7 @@ class VapixAPI {
195
195
  const json = await resV2.json();
196
196
  const data = VapixAPI_1.timeZoneSchema.parse(json);
197
197
  if (data.status === 'error') {
198
- throw new Error(data.error.message);
198
+ throw new errors_1.TimezoneFetchError(data.error.message);
199
199
  }
200
200
  return data.data.activeTimeZone;
201
201
  }
@@ -205,7 +205,7 @@ class VapixAPI {
205
205
  }
206
206
  const data = await this.getDateTimeInfo(options);
207
207
  if (data.data.timeZone === undefined) {
208
- throw new Error('Time zone not setup on the device');
208
+ throw new errors_1.TimezoneNotSetupError();
209
209
  }
210
210
  return zod_1.z.string().parse(data.data.timeZone);
211
211
  }
@@ -255,7 +255,7 @@ class VapixAPI {
255
255
  }, undefined, options);
256
256
  const responseText = await res.text();
257
257
  if (responseText.startsWith('# Error')) {
258
- throw new Error(responseText);
258
+ throw new errors_1.SettingParameterError(responseText);
259
259
  }
260
260
  }
261
261
  async getGuardTourList(options) {
@@ -479,7 +479,7 @@ class VapixAPI {
479
479
  }
480
480
  const text = await res.text();
481
481
  if (text.length > 5) {
482
- throw new Error('installing error: ' + text);
482
+ throw new errors_1.ApplicationAPIError('INSTALL', text);
483
483
  }
484
484
  }
485
485
  static parseParameters = (response) => {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PtzNotSupportedError = exports.AddNewClipError = exports.FetchDeviceInfoError = exports.NoDeviceInfoError = exports.MaxFPSError = exports.SDCardJobError = exports.SDCardActionError = exports.ApplicationAPIError = exports.ParsingBlobError = exports.ServiceNotFoundError = exports.ServiceUnavailableError = void 0;
3
+ exports.TimezoneFetchError = exports.TimezoneNotSetupError = exports.UtcTimeFetchError = exports.WsAuthorizationError = exports.StorageDataFetchError = exports.PtzNotSupportedError = exports.AddNewClipError = exports.FetchDeviceInfoError = exports.NoDeviceInfoError = exports.MaxFPSError = exports.SDCardJobError = exports.SDCardActionError = exports.ApplicationAPIError = exports.SettingParameterError = exports.ParameterNotFoundError = exports.JsonParseError = exports.ParsingBlobError = exports.ServiceNotFoundError = exports.ServiceUnavailableError = void 0;
4
4
  class ServiceUnavailableError extends Error {
5
5
  constructor() {
6
6
  super('Service is unavailable.');
@@ -22,6 +22,27 @@ class ParsingBlobError extends Error {
22
22
  }
23
23
  }
24
24
  exports.ParsingBlobError = ParsingBlobError;
25
+ class JsonParseError extends Error {
26
+ constructor(paramName, data) {
27
+ super(`Error: in JSON parsing of ${paramName}. Cannot parse: ${data}`);
28
+ this.name = 'JsonParseError';
29
+ }
30
+ }
31
+ exports.JsonParseError = JsonParseError;
32
+ class ParameterNotFoundError extends Error {
33
+ constructor(paramName) {
34
+ super(`Error: no parameter '${paramName}' was found`);
35
+ this.name = 'ParameterNotFoundError';
36
+ }
37
+ }
38
+ exports.ParameterNotFoundError = ParameterNotFoundError;
39
+ class SettingParameterError extends Error {
40
+ constructor(message) {
41
+ super(`Error setting parameter to camera: ${message}`);
42
+ this.name = 'SettingParameterError';
43
+ }
44
+ }
45
+ exports.SettingParameterError = SettingParameterError;
25
46
  class ApplicationAPIError extends Error {
26
47
  constructor(action, res) {
27
48
  super(`[APP ${action}] Error: ` + res);
@@ -84,3 +105,38 @@ class PtzNotSupportedError extends Error {
84
105
  }
85
106
  }
86
107
  exports.PtzNotSupportedError = PtzNotSupportedError;
108
+ class StorageDataFetchError extends Error {
109
+ constructor(err) {
110
+ super('Error fetching storage data: ' + err);
111
+ this.name = 'StorageDataFetchError';
112
+ }
113
+ }
114
+ exports.StorageDataFetchError = StorageDataFetchError;
115
+ class WsAuthorizationError extends Error {
116
+ constructor(message) {
117
+ super('Server error on ws authorization: ' + message);
118
+ this.name = 'WsAuthorizationError';
119
+ }
120
+ }
121
+ exports.WsAuthorizationError = WsAuthorizationError;
122
+ class UtcTimeFetchError extends Error {
123
+ constructor(message) {
124
+ super('Server error on get UTC time: ' + message);
125
+ this.name = 'UtcTimeFetchError';
126
+ }
127
+ }
128
+ exports.UtcTimeFetchError = UtcTimeFetchError;
129
+ class TimezoneNotSetupError extends Error {
130
+ constructor() {
131
+ super('Time zone not setup on the device');
132
+ this.name = 'TimezoneNotSetupError';
133
+ }
134
+ }
135
+ exports.TimezoneNotSetupError = TimezoneNotSetupError;
136
+ class TimezoneFetchError extends Error {
137
+ constructor(err) {
138
+ super('Error fetching time zone information: ' + err);
139
+ this.name = 'TimezoneFetchError';
140
+ }
141
+ }
142
+ exports.TimezoneFetchError = TimezoneFetchError;
package/cjs/index.js CHANGED
@@ -14,29 +14,31 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.PlaneTrackerAPI = exports.CamStreamerAPI = exports.CamScripterAPI = exports.CamOverlayAPI = exports.VapixAPI = exports.CamSwitcherEvents = exports.CamSwitcherAPI = void 0;
17
+ exports.VapixAPI = exports.PlaneTrackerAPI = exports.CamSwitcherEvents = exports.CamSwitcherAPI = exports.CamStreamerAPI = exports.CamScripterAPI = exports.CamOverlayAPI = void 0;
18
18
  __exportStar(require("./internal/types"), exports);
19
19
  __exportStar(require("./internal/constants"), exports);
20
20
  __exportStar(require("./internal/utils"), exports);
21
21
  __exportStar(require("./internal/versionCompare"), exports);
22
22
  __exportStar(require("./internal/ProxyClient"), exports);
23
23
  __exportStar(require("./types/common"), exports);
24
- var CamSwitcherAPI_1 = require("./CamSwitcherAPI");
25
- Object.defineProperty(exports, "CamSwitcherAPI", { enumerable: true, get: function () { return CamSwitcherAPI_1.CamSwitcherAPI; } });
26
- var CamSwitcherEvents_1 = require("./CamSwitcherEvents");
27
- Object.defineProperty(exports, "CamSwitcherEvents", { enumerable: true, get: function () { return CamSwitcherEvents_1.CamSwitcherEvents; } });
28
- var VapixAPI_1 = require("./VapixAPI");
29
- Object.defineProperty(exports, "VapixAPI", { enumerable: true, get: function () { return VapixAPI_1.VapixAPI; } });
30
24
  var CamOverlayAPI_1 = require("./CamOverlayAPI");
31
25
  Object.defineProperty(exports, "CamOverlayAPI", { enumerable: true, get: function () { return CamOverlayAPI_1.CamOverlayAPI; } });
26
+ __exportStar(require("./types/CamOverlayAPI"), exports);
32
27
  var CamScripterAPI_1 = require("./CamScripterAPI");
33
28
  Object.defineProperty(exports, "CamScripterAPI", { enumerable: true, get: function () { return CamScripterAPI_1.CamScripterAPI; } });
29
+ __exportStar(require("./types/CamScripterAPI"), exports);
34
30
  var CamStreamerAPI_1 = require("./CamStreamerAPI");
35
31
  Object.defineProperty(exports, "CamStreamerAPI", { enumerable: true, get: function () { return CamStreamerAPI_1.CamStreamerAPI; } });
32
+ __exportStar(require("./types/CamStreamerAPI"), exports);
33
+ var CamSwitcherAPI_1 = require("./CamSwitcherAPI");
34
+ Object.defineProperty(exports, "CamSwitcherAPI", { enumerable: true, get: function () { return CamSwitcherAPI_1.CamSwitcherAPI; } });
35
+ __exportStar(require("./types/CamSwitcherAPI"), exports);
36
+ var CamSwitcherEvents_1 = require("./CamSwitcherEvents");
37
+ Object.defineProperty(exports, "CamSwitcherEvents", { enumerable: true, get: function () { return CamSwitcherEvents_1.CamSwitcherEvents; } });
38
+ __exportStar(require("./types/CamSwitcherEvents"), exports);
36
39
  var PlaneTrackerAPI_1 = require("./PlaneTrackerAPI");
37
40
  Object.defineProperty(exports, "PlaneTrackerAPI", { enumerable: true, get: function () { return PlaneTrackerAPI_1.PlaneTrackerAPI; } });
38
- __exportStar(require("./types/CamSwitcherEvents"), exports);
39
- __exportStar(require("./types/CamSwitcherAPI"), exports);
40
- __exportStar(require("./types/VapixAPI"), exports);
41
- __exportStar(require("./types/CamOverlayAPI"), exports);
42
41
  __exportStar(require("./types/PlaneTrackerAPI"), exports);
42
+ var VapixAPI_1 = require("./VapixAPI");
43
+ Object.defineProperty(exports, "VapixAPI", { enumerable: true, get: function () { return VapixAPI_1.VapixAPI; } });
44
+ __exportStar(require("./types/VapixAPI"), exports);
package/cjs/node/index.js CHANGED
@@ -18,8 +18,10 @@ exports.VapixEvents = exports.CamScripterAPICameraEventsGenerator = exports.CamO
18
18
  __exportStar(require("./DefaultClient"), exports);
19
19
  __exportStar(require("./WsClient"), exports);
20
20
  __exportStar(require("./HttpServer"), exports);
21
+ __exportStar(require("./HttpRequestSender"), exports);
21
22
  __exportStar(require("./events/AxisCameraStationEvents"), exports);
22
23
  __exportStar(require("./events/GenetecAgent"), exports);
24
+ __exportStar(require("../types/GenetecAgent"), exports);
23
25
  var ResourceManager_1 = require("./CamOverlayPainter/ResourceManager");
24
26
  Object.defineProperty(exports, "ResourceManager", { enumerable: true, get: function () { return ResourceManager_1.ResourceManager; } });
25
27
  var Painter_1 = require("./CamOverlayPainter/Painter");
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fileDataSchema = exports.fileListSchema = exports.fileSchema = exports.storageResponseSchema = exports.storageDataListSchema = exports.storageSchema = exports.ImageType = exports.isScoreOverview = exports.isBaseballScoreBoardAutomatic = exports.isBaseballScoreBoard = exports.isScoreBoard = exports.isWebCameraSharing = exports.isScreenSharing = exports.isPtz = exports.isPtzCompass = exports.isPip = exports.isInfoticker = exports.isImages = exports.isCustomGraphics = exports.isAccuweather = exports.serviceListSchema = exports.servicesSchema = exports.wsResponseSchema = void 0;
3
+ exports.fileDataSchema = exports.fileListSchema = exports.fileSchema = exports.storageResponseSchema = exports.storageDataListSchema = exports.fileStorageTypeSchema = exports.ImageType = exports.isScoreOverview = exports.isBaseballScoreBoardAutomatic = exports.isBaseballScoreBoard = exports.isScoreBoard = exports.isWebCameraSharing = exports.isScreenSharing = exports.isPtz = exports.isPtzCompass = exports.isPip = exports.isInfoticker = exports.isImages = exports.isCustomGraphics = exports.isAccuweather = exports.serviceListSchema = exports.servicesSchema = exports.wsResponseSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const infotickerSchema_1 = require("./infotickerSchema");
6
6
  const accuweatherSchema_1 = require("./accuweatherSchema");
@@ -65,7 +65,7 @@ var ImageType;
65
65
  ImageType[ImageType["PNG"] = 0] = "PNG";
66
66
  ImageType[ImageType["JPEG"] = 1] = "JPEG";
67
67
  })(ImageType || (exports.ImageType = ImageType = {}));
68
- exports.storageSchema = zod_1.z.union([
68
+ exports.fileStorageTypeSchema = zod_1.z.union([
69
69
  zod_1.z.literal('flash'),
70
70
  zod_1.z.literal('SD0'),
71
71
  zod_1.z.literal('ftp'),
@@ -73,7 +73,7 @@ exports.storageSchema = zod_1.z.union([
73
73
  zod_1.z.literal('url'),
74
74
  ]);
75
75
  exports.storageDataListSchema = zod_1.z.array(zod_1.z.object({
76
- type: exports.storageSchema,
76
+ type: exports.fileStorageTypeSchema,
77
77
  state: zod_1.z.string(),
78
78
  }));
79
79
  exports.storageResponseSchema = zod_1.z.object({
@@ -83,7 +83,7 @@ exports.storageResponseSchema = zod_1.z.object({
83
83
  exports.fileSchema = zod_1.z.object({
84
84
  name: zod_1.z.string(),
85
85
  path: zod_1.z.string().url(),
86
- storage: exports.storageSchema,
86
+ storage: exports.fileStorageTypeSchema,
87
87
  });
88
88
  exports.fileListSchema = zod_1.z.array(exports.fileSchema);
89
89
  exports.fileDataSchema = zod_1.z.object({