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
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cameraTimeResponseSchema = exports.camscripterApiResponseSchema = exports.storageSchema = exports.packageConfigSchema = exports.packageInfoListSchema = exports.nodeStateSchema = void 0;
3
+ exports.cameraTimeResponseSchema = exports.camscripterApiResponseSchema = exports.cameraStorageSchema = exports.packageConfigSchema = exports.packageInfoListSchema = exports.nodeStateSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.nodeStateSchema = zod_1.z.object({
6
6
  node_state: zod_1.z.union([zod_1.z.literal('OK'), zod_1.z.literal('NOT_INSTALLED'), zod_1.z.literal('NOT_FOUND')]),
@@ -18,7 +18,7 @@ exports.packageInfoListSchema = zod_1.z.array(zod_1.z.object({
18
18
  }),
19
19
  }));
20
20
  exports.packageConfigSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.object({ enabled: zod_1.z.boolean() }));
21
- exports.storageSchema = zod_1.z.union([
21
+ exports.cameraStorageSchema = zod_1.z.union([
22
22
  zod_1.z.tuple([
23
23
  zod_1.z.object({ type: zod_1.z.literal('INTERNAL'), capacity_mb: zod_1.z.number() }),
24
24
  zod_1.z.object({ type: zod_1.z.literal('SD_CARD'), capacity_mb: zod_1.z.number() }),
@@ -95,8 +95,10 @@ exports.cameraSettingsSchema = zod_1.z.object({
95
95
  trackingConfig: zod_1.z
96
96
  .object({
97
97
  prioritizeEmergency: zod_1.z.boolean(),
98
+ guardTourEnabled: zod_1.z.boolean().default(false),
99
+ guardTourId: zod_1.z.number().int().nonnegative().default(0),
98
100
  })
99
- .default({ prioritizeEmergency: true }),
101
+ .default({ prioritizeEmergency: true, guardTourEnabled: false, guardTourId: 0 }),
100
102
  overlayText: zod_1.z
101
103
  .object({
102
104
  displayIcao: zod_1.z.boolean().optional(),
@@ -1,5 +1,5 @@
1
1
  import { paramToUrl, responseStringify } from './internal/utils';
2
- import { ParsingBlobError, ServiceNotFoundError } from './errors/errors';
2
+ import { ParsingBlobError, ServiceNotFoundError, StorageDataFetchError } from './errors/errors';
3
3
  import { networkCameraListSchema } from './types/common';
4
4
  import { z } from 'zod';
5
5
  import { ProxyClient } from './internal/ProxyClient';
@@ -50,7 +50,7 @@ export class CamOverlayAPI {
50
50
  async getFileStorage(fileType, options) {
51
51
  const res = await this._getJson(`${BASE_PATH}/upload_${fileType}.cgi`, { action: 'get_storage' }, options);
52
52
  if (res.code !== 200) {
53
- throw new Error('Error occured while fetching file storage data');
53
+ throw new StorageDataFetchError(res);
54
54
  }
55
55
  return storageDataListSchema.parse(res.list);
56
56
  }
@@ -65,7 +65,11 @@ export class CamOverlayAPI {
65
65
  }
66
66
  async isEnabled(serviceId, options) {
67
67
  const agent = this.getClient(options?.proxyParams);
68
- const res = await agent.get({ path: `${BASE_PATH}/services.cgi?action=get`, timeout: options?.timeout });
68
+ const res = await agent.get({
69
+ path: `${BASE_PATH}/services.cgi`,
70
+ parameters: { action: 'get' },
71
+ timeout: options?.timeout,
72
+ });
69
73
  if (res.ok) {
70
74
  const data = JSON.parse(await res.text());
71
75
  for (const service of data.services) {
@@ -142,7 +146,7 @@ export class CamOverlayAPI {
142
146
  async promiseCGUpdate(serviceId, action, params = {}, contentType, data, options) {
143
147
  const path = `${BASE_PATH}/customGraphics.cgi`;
144
148
  let headers = {};
145
- if (contentType !== undefined && data) {
149
+ if (contentType !== undefined && data !== undefined) {
146
150
  headers = { 'Content-Type': contentType };
147
151
  }
148
152
  const agent = this.getClient(options?.proxyParams);
@@ -1,6 +1,6 @@
1
1
  import { ProxyClient } from './internal/ProxyClient';
2
2
  import { responseStringify } from './internal/utils';
3
- import { cameraTimeResponseSchema, camscripterApiResponseSchema, nodeStateSchema, packageInfoListSchema, storageSchema, } from './types/CamScripterAPI';
3
+ import { cameraTimeResponseSchema, nodeStateSchema, packageInfoListSchema, cameraStorageSchema, } from './types/CamScripterAPI';
4
4
  import { networkCameraListSchema } from './types/common';
5
5
  const BASE_PATH = '/local/camscripter';
6
6
  export class CamScripterAPI {
@@ -22,41 +22,36 @@ export class CamScripterAPI {
22
22
  }
23
23
  async getStorageInfo(options) {
24
24
  const res = await this._getJson(`${BASE_PATH}/package/get_storage.cgi`, undefined, options);
25
- return storageSchema.parse(res);
25
+ return cameraStorageSchema.parse(res);
26
26
  }
27
27
  async getPackageList(options) {
28
28
  const res = await this._getJson(`${BASE_PATH}/package/list.cgi`, undefined, options);
29
29
  return packageInfoListSchema.parse(res);
30
30
  }
31
31
  async installPackages(formData, storage, options) {
32
- const res = await this._post(`${BASE_PATH}/package/install.cgi`, formData, { storage: storage }, options);
33
- return camscripterApiResponseSchema.parse(res);
32
+ await this._post(`${BASE_PATH}/package/install.cgi`, formData, { storage: storage }, options);
34
33
  }
35
34
  async uninstallPackage(packageId, options) {
36
- const res = await this._getJson(`${BASE_PATH}/package/remove.cgi`, { package_name: packageId }, options);
37
- return camscripterApiResponseSchema.parse(res);
35
+ await this._getJson(`${BASE_PATH}/package/remove.cgi`, { package_name: packageId }, options);
38
36
  }
39
37
  async importSettings(packageId, formData, options) {
40
- const res = await this._post(`${BASE_PATH}/package/data.cgi`, formData, {
38
+ await this._post(`${BASE_PATH}/package/data.cgi`, formData, {
41
39
  action: 'IMPORT',
42
40
  package_name: packageId,
43
41
  }, options);
44
- return camscripterApiResponseSchema.parse(res);
45
42
  }
46
43
  async exportSettings(packageId, formData, options) {
47
- const res = await this._post(`${BASE_PATH}/package/data.cgi`, formData, {
44
+ await this._post(`${BASE_PATH}/package/data.cgi`, formData, {
48
45
  action: 'EXPORT',
49
46
  package_name: packageId,
50
47
  }, options);
51
- return camscripterApiResponseSchema.parse(res);
52
48
  }
53
49
  async getNodejsStatus(options) {
54
50
  const res = await this._getJson(`${BASE_PATH}/diagnostics.cgi`, undefined, options);
55
51
  return nodeStateSchema.parse(res);
56
52
  }
57
53
  async installNodejs(storage, options) {
58
- const res = await this._getJson(`${BASE_PATH}/node_update.cgi`, { storage: storage }, options);
59
- return camscripterApiResponseSchema.parse(res);
54
+ await this._getJson(`${BASE_PATH}/node_update.cgi`, { storage: storage }, options);
60
55
  }
61
56
  async _getJson(path, parameters, options) {
62
57
  const agent = this.getClient(options?.proxyParams);
@@ -2,6 +2,7 @@ import { z } from 'zod';
2
2
  import { ProxyClient } from './internal/ProxyClient';
3
3
  import { responseStringify } from './internal/utils';
4
4
  import { cameraStreamSchema } from './types/CamStreamerAPI';
5
+ import { UtcTimeFetchError, WsAuthorizationError } from './errors/errors';
5
6
  const BASE_PATH = '/local/camstreamer';
6
7
  export class CamStreamerAPI {
7
8
  client;
@@ -14,14 +15,14 @@ export class CamStreamerAPI {
14
15
  async wsAuthorization(options) {
15
16
  const res = await this._getJson(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
16
17
  if (res.status !== 200) {
17
- throw new Error(`Server error on ws authorization: ${res.message}`);
18
+ throw new WsAuthorizationError(res.message);
18
19
  }
19
20
  return z.string().parse(res.data);
20
21
  }
21
22
  async getUtcTime(options) {
22
23
  const res = await this._getJson(`${BASE_PATH}/get_utc_time.cgi`, undefined, options);
23
24
  if (res.status !== 200) {
24
- throw new Error(`Server error on get UTC time: ${res.message}`);
25
+ throw new UtcTimeFetchError(res.message);
25
26
  }
26
27
  return z.number().parse(res.data);
27
28
  }
@@ -46,7 +47,7 @@ export class CamStreamerAPI {
46
47
  }
47
48
  async setStream(streamId, params, options) {
48
49
  const { streamDelay, startTime, stopTime, ...rest } = params;
49
- return await this._getJson(`${BASE_PATH}/stream/set.cgi`, {
50
+ await this._getJson(`${BASE_PATH}/stream/set.cgi`, {
50
51
  stream_id: streamId,
51
52
  streamDelay: streamDelay ?? '',
52
53
  startTime: startTime ?? null,
@@ -55,7 +56,7 @@ export class CamStreamerAPI {
55
56
  }, options);
56
57
  }
57
58
  async setStreamParameter(streamId, paramName, value, options) {
58
- return await this._getJson(`${BASE_PATH}/stream/set.cgi`, { stream_id: streamId, [paramName]: value }, options);
59
+ await this._getJson(`${BASE_PATH}/stream/set.cgi`, { stream_id: streamId, [paramName]: value }, options);
59
60
  }
60
61
  async isStreaming(streamId, options) {
61
62
  const res = await this._getJson(`${BASE_PATH}/get_streamstat.cgi`, { stream_id: streamId }, options);
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { AddNewClipError } from './errors/errors';
2
+ import { AddNewClipError, JsonParseError, ParameterNotFoundError } from './errors/errors';
3
3
  import { isClip, isNullish, responseStringify } from './internal/utils';
4
4
  import { storageInfoListSchema, outputInfoSchema, audioPushInfoSchema, clipListSchema, playlistQueueSchema, streamSaveLoadSchema, clipSaveLoadSchema, playlistSaveLoadSchema, trackerSaveLoadSchema, secondaryAudioSettingsSchema, globalAudioSettingsSchema, } from './types/CamSwitcherAPI';
5
5
  import { networkCameraListSchema, } from './types/common';
@@ -23,6 +23,14 @@ export class CamSwitcherAPI {
23
23
  getClient(proxyParams) {
24
24
  return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
25
25
  }
26
+ async checkCameraTime(options) {
27
+ const res = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
28
+ return z.boolean().parse(res.data);
29
+ }
30
+ async getNetworkCameraList(options) {
31
+ const res = await this._getJson(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
32
+ return networkCameraListSchema.parse(res.data);
33
+ }
26
34
  async generateSilence(sampleRate, channels, options) {
27
35
  const agent = this.getClient(options?.proxyParams);
28
36
  await agent.get({
@@ -34,14 +42,6 @@ export class CamSwitcherAPI {
34
42
  timeout: options?.timeout,
35
43
  });
36
44
  }
37
- async checkCameraTime(options) {
38
- const res = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
39
- return z.boolean().parse(res.data);
40
- }
41
- async getNetworkCameraList(options) {
42
- const res = await this._getJson(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
43
- return networkCameraListSchema.parse(res.data);
44
- }
45
45
  async getMaxFps(source, options) {
46
46
  const res = await this._getJson(`${BASE_PATH}/get_max_framerate.cgi`, {
47
47
  video_source: source,
@@ -81,16 +81,16 @@ export class CamSwitcherAPI {
81
81
  return trackerSaveLoadSchema.parse(res.data);
82
82
  }
83
83
  async setStreamSaveList(data, options) {
84
- return await this._post(`${BASE_PATH}/streams.cgi`, data, { action: 'set' }, options);
84
+ await this._post(`${BASE_PATH}/streams.cgi`, data, { action: 'set' }, options);
85
85
  }
86
86
  async setClipSaveList(data, options) {
87
- return await this._post(`${BASE_PATH}/clips.cgi`, data, { action: 'set' }, options);
87
+ await this._post(`${BASE_PATH}/clips.cgi`, data, { action: 'set' }, options);
88
88
  }
89
89
  async setPlaylistSaveList(data, options) {
90
- return await this._post(`${BASE_PATH}/playlists.cgi`, data, { action: 'set' }, options);
90
+ await this._post(`${BASE_PATH}/playlists.cgi`, data, { action: 'set' }, options);
91
91
  }
92
92
  async setTrackerSaveList(data, options) {
93
- return await this._post(`${BASE_PATH}/trackers.cgi`, data, { action: 'set' }, options);
93
+ await this._post(`${BASE_PATH}/trackers.cgi`, data, { action: 'set' }, options);
94
94
  }
95
95
  async playlistSwitch(playlistName, options) {
96
96
  await this._getJson(`${BASE_PATH}/playlist_switch.cgi`, { playlist_name: playlistName }, options);
@@ -128,8 +128,8 @@ export class CamSwitcherAPI {
128
128
  throw new AddNewClipError(output.message);
129
129
  }
130
130
  }
131
- removeClip(clipId, storage, options) {
132
- return this._getJson(`${BASE_PATH}/clip_remove.cgi`, { clip_name: clipId, storage }, options);
131
+ async removeClip(clipId, storage, options) {
132
+ await this._getJson(`${BASE_PATH}/clip_remove.cgi`, { clip_name: clipId, storage }, options);
133
133
  }
134
134
  async getClipList(options) {
135
135
  const res = await this._getJson(`${BASE_PATH}/clip_list.cgi`, undefined, options);
@@ -290,10 +290,10 @@ export class CamSwitcherAPI {
290
290
  }
291
291
  }
292
292
  catch {
293
- throw new Error('Error: in JSON parsing of ' + paramName + '. Cannot parse: ' + data[paramName]);
293
+ throw new JsonParseError(paramName, data[paramName]);
294
294
  }
295
295
  }
296
- throw new Error("Error: no parametr '" + paramName + "' was found");
296
+ throw new ParameterNotFoundError(paramName);
297
297
  }
298
298
  }
299
299
  const CSW_PARAM_NAMES = {
@@ -22,7 +22,7 @@ export class PlaneTrackerAPI {
22
22
  }
23
23
  async resetPtzCalibration(options) {
24
24
  const agent = this.getClient(options?.proxyParams);
25
- return await agent.get({
25
+ await agent.get({
26
26
  path: `${BASE_PATH}/package/resetPtzCalibration.cgi`,
27
27
  parameters: this.apiUser,
28
28
  timeout: options?.timeout,
@@ -30,7 +30,7 @@ export class PlaneTrackerAPI {
30
30
  }
31
31
  async resetFocusCalibration(options) {
32
32
  const agent = this.getClient(options?.proxyParams);
33
- return await agent.get({
33
+ await agent.get({
34
34
  path: `${BASE_PATH}/package/resetFocusCalibration.cgi`,
35
35
  parameters: this.apiUser,
36
36
  timeout: options?.timeout,
@@ -38,11 +38,11 @@ export class PlaneTrackerAPI {
38
38
  }
39
39
  async serverRunCheck(options) {
40
40
  const agent = this.getClient(options?.proxyParams);
41
- return await agent.get({ path: `${BASE_PATH}/package/serverRunCheck.cgi`, timeout: options?.timeout });
41
+ await agent.get({ path: `${BASE_PATH}/package/serverRunCheck.cgi`, timeout: options?.timeout });
42
42
  }
43
43
  async getLiveViewAlias(rtspUrl, options) {
44
44
  const agent = this.getClient(options?.proxyParams);
45
- return await agent.get({
45
+ await agent.get({
46
46
  path: `${BASE_PATH}/getLiveViewAlias.cgi`,
47
47
  parameters: { rtsp_url: rtspUrl },
48
48
  timeout: options?.timeout,
@@ -52,8 +52,8 @@ export class PlaneTrackerAPI {
52
52
  const res = await this._getJson(`${BASE_PATH}/package_camera_settings.cgi`, { action: 'get' }, options);
53
53
  return cameraSettingsSchema.parse(res);
54
54
  }
55
- async setCameraSettings(settingsJsonString, options) {
56
- return await this._postJsonEncoded(`${BASE_PATH}/package_camera_settings.cgi`, settingsJsonString, {
55
+ async setCameraSettings(settings, options) {
56
+ await this._postJsonEncoded(`${BASE_PATH}/package_camera_settings.cgi`, settings, {
57
57
  action: 'set',
58
58
  }, options);
59
59
  }
@@ -66,7 +66,7 @@ export class PlaneTrackerAPI {
66
66
  }
67
67
  async importAppSettings(dataType, formData, options) {
68
68
  const agent = this.getClient(options?.proxyParams);
69
- return await agent.post({
69
+ await agent.post({
70
70
  path: `${BASE_PATH}/package_data.cgi`,
71
71
  data: formData,
72
72
  parameters: { action: 'IMPORT', dataType },
@@ -82,11 +82,11 @@ export class PlaneTrackerAPI {
82
82
  return trackingModeSchema.parse(res);
83
83
  }
84
84
  async setTrackingMode(mode, options) {
85
- return await this._postJsonEncoded(`${BASE_PATH}/package/setTrackingMode.cgi`, { mode }, this.apiUser, options);
85
+ await this._postJsonEncoded(`${BASE_PATH}/package/setTrackingMode.cgi`, { mode }, this.apiUser, options);
86
86
  }
87
87
  async startTrackingPlane(icao, options) {
88
88
  const agent = this.getClient(options?.proxyParams);
89
- return await agent.get({
89
+ await agent.get({
90
90
  path: `${BASE_PATH}/package/trackIcao.cgi`,
91
91
  parameters: { icao, ...this.apiUser },
92
92
  timeout: options?.timeout,
@@ -94,7 +94,7 @@ export class PlaneTrackerAPI {
94
94
  }
95
95
  async stopTrackingPlane(options) {
96
96
  const agent = this.getClient(options?.proxyParams);
97
- return await agent.get({
97
+ await agent.get({
98
98
  path: `${BASE_PATH}/package/resetIcao.cgi`,
99
99
  parameters: this.apiUser,
100
100
  timeout: options?.timeout,
@@ -105,21 +105,21 @@ export class PlaneTrackerAPI {
105
105
  return priorityListSchema.parse(res);
106
106
  }
107
107
  async setPriorityList(priorityList, options) {
108
- return await this._postJsonEncoded(`${BASE_PATH}/package/setPriorityList.cgi`, { priorityList }, this.apiUser, options);
108
+ await this._postJsonEncoded(`${BASE_PATH}/package/setPriorityList.cgi`, { priorityList }, this.apiUser, options);
109
109
  }
110
110
  async getWhiteList(options) {
111
111
  const res = await this._getJson(`${BASE_PATH}/package/getWhiteList.cgi`, undefined, options);
112
112
  return whiteListSchema.parse(res);
113
113
  }
114
114
  async setWhiteList(whiteList, options) {
115
- return await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, { whiteList }, this.apiUser, options);
115
+ await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, { whiteList }, this.apiUser, options);
116
116
  }
117
117
  async getBlackList(options) {
118
118
  const res = await this._getJson(`${BASE_PATH}/package/getBlackList.cgi`, undefined, options);
119
119
  return blackListSchema.parse(res);
120
120
  }
121
121
  async setBlackList(blackList, options) {
122
- return await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, { blackList }, this.apiUser, options);
122
+ await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, { blackList }, this.apiUser, options);
123
123
  }
124
124
  async fetchMapInfo(options) {
125
125
  const res = await this._getJson(`${BASE_PATH}/package/getMapInfo.cgi`, undefined, options);
@@ -130,18 +130,18 @@ export class PlaneTrackerAPI {
130
130
  return zonesSchema.parse(res);
131
131
  }
132
132
  async setZones(zones, options) {
133
- return await this._postJsonEncoded(`${BASE_PATH}/package/setZones.cgi`, { zones }, this.apiUser, options);
133
+ await this._postJsonEncoded(`${BASE_PATH}/package/setZones.cgi`, { zones }, this.apiUser, options);
134
134
  }
135
135
  async goToCoordinates(lat, lon, alt, options) {
136
136
  const agent = this.getClient(options?.proxyParams);
137
- return await agent.get({
137
+ await agent.get({
138
138
  path: `${BASE_PATH}/package/goToCoordinates.cgi`,
139
139
  parameters: { lat, lon, alt, ...this.apiUser },
140
140
  timeout: options?.timeout,
141
141
  });
142
142
  }
143
143
  async checkGenetecConnection(params, options) {
144
- return await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, '', params, options);
144
+ await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, '', params, options);
145
145
  }
146
146
  async getGenetecCameraList(params, options) {
147
147
  const res = await this._postUrlEncoded(`${BASE_PATH}/package/getGenetecCameraList.cgi`, '', params, options);
package/esm/VapixAPI.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { arrayToUrl, isNullish, paramToUrl, responseStringify } from './internal/utils';
2
2
  import { sdCardWatchedStatuses, APP_IDS, maxFpsResponseSchema, dateTimeinfoSchema, audioDeviceRequestSchema, audioSampleRatesResponseSchema, timeZoneSchema, getPortsResponseSchema, guardTourSchema, ptzOverviewSchema, cameraPTZItemDataSchema, applicationListSchema, sdCardInfoSchema, } from './types/VapixAPI';
3
- import { ApplicationAPIError, MaxFPSError, NoDeviceInfoError, PtzNotSupportedError, SDCardActionError, SDCardJobError, } from './errors/errors';
3
+ import { ApplicationAPIError, MaxFPSError, NoDeviceInfoError, PtzNotSupportedError, SDCardActionError, SDCardJobError, SettingParameterError, TimezoneFetchError, TimezoneNotSetupError, } from './errors/errors';
4
4
  import { ProxyClient } from './internal/ProxyClient';
5
5
  import { z } from 'zod';
6
6
  import { XMLParser } from 'fast-xml-parser';
@@ -192,7 +192,7 @@ export class VapixAPI {
192
192
  const json = await resV2.json();
193
193
  const data = timeZoneSchema.parse(json);
194
194
  if (data.status === 'error') {
195
- throw new Error(data.error.message);
195
+ throw new TimezoneFetchError(data.error.message);
196
196
  }
197
197
  return data.data.activeTimeZone;
198
198
  }
@@ -202,7 +202,7 @@ export class VapixAPI {
202
202
  }
203
203
  const data = await this.getDateTimeInfo(options);
204
204
  if (data.data.timeZone === undefined) {
205
- throw new Error('Time zone not setup on the device');
205
+ throw new TimezoneNotSetupError();
206
206
  }
207
207
  return z.string().parse(data.data.timeZone);
208
208
  }
@@ -252,7 +252,7 @@ export class VapixAPI {
252
252
  }, undefined, options);
253
253
  const responseText = await res.text();
254
254
  if (responseText.startsWith('# Error')) {
255
- throw new Error(responseText);
255
+ throw new SettingParameterError(responseText);
256
256
  }
257
257
  }
258
258
  async getGuardTourList(options) {
@@ -476,7 +476,7 @@ export class VapixAPI {
476
476
  }
477
477
  const text = await res.text();
478
478
  if (text.length > 5) {
479
- throw new Error('installing error: ' + text);
479
+ throw new ApplicationAPIError('INSTALL', text);
480
480
  }
481
481
  }
482
482
  static parseParameters = (response) => {
@@ -16,6 +16,24 @@ export class ParsingBlobError extends Error {
16
16
  this.name = 'ParsingBlobError';
17
17
  }
18
18
  }
19
+ export class JsonParseError extends Error {
20
+ constructor(paramName, data) {
21
+ super(`Error: in JSON parsing of ${paramName}. Cannot parse: ${data}`);
22
+ this.name = 'JsonParseError';
23
+ }
24
+ }
25
+ export class ParameterNotFoundError extends Error {
26
+ constructor(paramName) {
27
+ super(`Error: no parameter '${paramName}' was found`);
28
+ this.name = 'ParameterNotFoundError';
29
+ }
30
+ }
31
+ export class SettingParameterError extends Error {
32
+ constructor(message) {
33
+ super(`Error setting parameter to camera: ${message}`);
34
+ this.name = 'SettingParameterError';
35
+ }
36
+ }
19
37
  export class ApplicationAPIError extends Error {
20
38
  constructor(action, res) {
21
39
  super(`[APP ${action}] Error: ` + res);
@@ -70,3 +88,33 @@ export class PtzNotSupportedError extends Error {
70
88
  this.name = 'PtzNotSupportedError';
71
89
  }
72
90
  }
91
+ export class StorageDataFetchError extends Error {
92
+ constructor(err) {
93
+ super('Error fetching storage data: ' + err);
94
+ this.name = 'StorageDataFetchError';
95
+ }
96
+ }
97
+ export class WsAuthorizationError extends Error {
98
+ constructor(message) {
99
+ super('Server error on ws authorization: ' + message);
100
+ this.name = 'WsAuthorizationError';
101
+ }
102
+ }
103
+ export class UtcTimeFetchError extends Error {
104
+ constructor(message) {
105
+ super('Server error on get UTC time: ' + message);
106
+ this.name = 'UtcTimeFetchError';
107
+ }
108
+ }
109
+ export class TimezoneNotSetupError extends Error {
110
+ constructor() {
111
+ super('Time zone not setup on the device');
112
+ this.name = 'TimezoneNotSetupError';
113
+ }
114
+ }
115
+ export class TimezoneFetchError extends Error {
116
+ constructor(err) {
117
+ super('Error fetching time zone information: ' + err);
118
+ this.name = 'TimezoneFetchError';
119
+ }
120
+ }
package/esm/index.js CHANGED
@@ -4,15 +4,17 @@ export * from './internal/utils';
4
4
  export * from './internal/versionCompare';
5
5
  export * from './internal/ProxyClient';
6
6
  export * from './types/common';
7
- export { CamSwitcherAPI } from './CamSwitcherAPI';
8
- export { CamSwitcherEvents } from './CamSwitcherEvents';
9
- export { VapixAPI } from './VapixAPI';
10
7
  export { CamOverlayAPI } from './CamOverlayAPI';
8
+ export * from './types/CamOverlayAPI';
11
9
  export { CamScripterAPI } from './CamScripterAPI';
10
+ export * from './types/CamScripterAPI';
12
11
  export { CamStreamerAPI } from './CamStreamerAPI';
13
- export { PlaneTrackerAPI } from './PlaneTrackerAPI';
14
- export * from './types/CamSwitcherEvents';
12
+ export * from './types/CamStreamerAPI';
13
+ export { CamSwitcherAPI } from './CamSwitcherAPI';
15
14
  export * from './types/CamSwitcherAPI';
16
- export * from './types/VapixAPI';
17
- export * from './types/CamOverlayAPI';
15
+ export { CamSwitcherEvents } from './CamSwitcherEvents';
16
+ export * from './types/CamSwitcherEvents';
17
+ export { PlaneTrackerAPI } from './PlaneTrackerAPI';
18
18
  export * from './types/PlaneTrackerAPI';
19
+ export { VapixAPI } from './VapixAPI';
20
+ export * from './types/VapixAPI';
package/esm/node/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  export * from './DefaultClient';
2
2
  export * from './WsClient';
3
3
  export * from './HttpServer';
4
+ export * from './HttpRequestSender';
4
5
  export * from './events/AxisCameraStationEvents';
5
6
  export * from './events/GenetecAgent';
7
+ export * from '../types/GenetecAgent';
6
8
  export { ResourceManager } from './CamOverlayPainter/ResourceManager';
7
9
  export { Painter } from './CamOverlayPainter/Painter';
8
10
  export { Frame } from './CamOverlayPainter/Frame';
@@ -49,7 +49,7 @@ export var ImageType;
49
49
  ImageType[ImageType["PNG"] = 0] = "PNG";
50
50
  ImageType[ImageType["JPEG"] = 1] = "JPEG";
51
51
  })(ImageType || (ImageType = {}));
52
- export const storageSchema = z.union([
52
+ export const fileStorageTypeSchema = z.union([
53
53
  z.literal('flash'),
54
54
  z.literal('SD0'),
55
55
  z.literal('ftp'),
@@ -57,7 +57,7 @@ export const storageSchema = z.union([
57
57
  z.literal('url'),
58
58
  ]);
59
59
  export const storageDataListSchema = z.array(z.object({
60
- type: storageSchema,
60
+ type: fileStorageTypeSchema,
61
61
  state: z.string(),
62
62
  }));
63
63
  export const storageResponseSchema = z.object({
@@ -67,7 +67,7 @@ export const storageResponseSchema = z.object({
67
67
  export const fileSchema = z.object({
68
68
  name: z.string(),
69
69
  path: z.string().url(),
70
- storage: storageSchema,
70
+ storage: fileStorageTypeSchema,
71
71
  });
72
72
  export const fileListSchema = z.array(fileSchema);
73
73
  export const fileDataSchema = z.object({
@@ -15,7 +15,7 @@ export const packageInfoListSchema = z.array(z.object({
15
15
  }),
16
16
  }));
17
17
  export const packageConfigSchema = z.record(z.string(), z.object({ enabled: z.boolean() }));
18
- export const storageSchema = z.union([
18
+ export const cameraStorageSchema = z.union([
19
19
  z.tuple([
20
20
  z.object({ type: z.literal('INTERNAL'), capacity_mb: z.number() }),
21
21
  z.object({ type: z.literal('SD_CARD'), capacity_mb: z.number() }),
@@ -92,8 +92,10 @@ export const cameraSettingsSchema = z.object({
92
92
  trackingConfig: z
93
93
  .object({
94
94
  prioritizeEmergency: z.boolean(),
95
+ guardTourEnabled: z.boolean().default(false),
96
+ guardTourId: z.number().int().nonnegative().default(0),
95
97
  })
96
- .default({ prioritizeEmergency: true }),
98
+ .default({ prioritizeEmergency: true, guardTourEnabled: false, guardTourId: 0 }),
97
99
  overlayText: z
98
100
  .object({
99
101
  displayIcao: z.boolean().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camstreamerlib",
3
- "version": "4.0.0-beta.39",
3
+ "version": "4.0.0-beta.40",
4
4
  "description": "Helper library for CamStreamer ACAP applications.",
5
5
  "prettier": "@camstreamer/prettier-config",
6
6
  "engine": {
@@ -1,7 +1,7 @@
1
1
  import { IClient, TBlobResponse, TResponse } from './internal/types';
2
2
  import { THttpRequestOptions, TProxyParams } from './types/common';
3
3
  import { ProxyClient } from './internal/ProxyClient';
4
- import { ImageType, TCoordinates, TField, TFile, TFileType, TStorage, TService } from './types/CamOverlayAPI';
4
+ import { ImageType, TCoordinates, TField, TFile, TFileType, TFileStorageType, TService } from './types/CamOverlayAPI';
5
5
  export declare class CamOverlayAPI<Client extends IClient<TResponse, any>> {
6
6
  private client;
7
7
  constructor(client: Client);
@@ -21,7 +21,7 @@ export declare class CamOverlayAPI<Client extends IClient<TResponse, any>> {
21
21
  name: string;
22
22
  storage: "url" | "flash" | "SD0" | "ftp" | "samba";
23
23
  }[]>;
24
- uploadFile(fileType: TFileType, formData: Parameters<Client['post']>[0]['data'], storage: TStorage, options?: THttpRequestOptions): Promise<void>;
24
+ uploadFile(fileType: TFileType, formData: Parameters<Client['post']>[0]['data'], storage: TFileStorageType, options?: THttpRequestOptions): Promise<void>;
25
25
  removeFile(fileType: TFileType, fileParams: TFile, options?: THttpRequestOptions): Promise<void>;
26
26
  getFileStorage(fileType: TFileType, options?: THttpRequestOptions): Promise<{
27
27
  type: "url" | "flash" | "SD0" | "ftp" | "samba";
@@ -1,9 +1,9 @@
1
1
  import { ProxyClient } from './internal/ProxyClient';
2
2
  import { IClient, TResponse } from './internal/types';
3
- import { TStorageType } from './types/CamScripterAPI';
3
+ import { TCameraStorageType } from './types/CamScripterAPI';
4
4
  import { THttpRequestOptions, TProxyParams } from './types/common';
5
5
  export declare class CamScripterAPI<Client extends IClient<TResponse, any>> {
6
- client: Client;
6
+ private client;
7
7
  constructor(client: Client);
8
8
  static getProxyPath: () => string;
9
9
  getClient(proxyParams?: TProxyParams): Client | ProxyClient<Client>;
@@ -34,29 +34,14 @@ export declare class CamScripterAPI<Client extends IClient<TResponse, any>> {
34
34
  required_camscripter_rbi_version?: string | undefined;
35
35
  };
36
36
  }[]>;
37
- installPackages(formData: Parameters<Client['post']>[0]['data'], storage: TStorageType, options?: THttpRequestOptions): Promise<{
38
- status: number;
39
- message: string;
40
- }>;
41
- uninstallPackage(packageId: string, options?: THttpRequestOptions): Promise<{
42
- status: number;
43
- message: string;
44
- }>;
45
- importSettings(packageId: string, formData: Parameters<Client['post']>[0]['data'], options?: THttpRequestOptions): Promise<{
46
- status: number;
47
- message: string;
48
- }>;
49
- exportSettings(packageId: string, formData: Parameters<Client['post']>[0]['data'], options?: THttpRequestOptions): Promise<{
50
- status: number;
51
- message: string;
52
- }>;
37
+ installPackages(formData: Parameters<Client['post']>[0]['data'], storage: TCameraStorageType, options?: THttpRequestOptions): Promise<void>;
38
+ uninstallPackage(packageId: string, options?: THttpRequestOptions): Promise<void>;
39
+ importSettings(packageId: string, formData: Parameters<Client['post']>[0]['data'], options?: THttpRequestOptions): Promise<void>;
40
+ exportSettings(packageId: string, formData: Parameters<Client['post']>[0]['data'], options?: THttpRequestOptions): Promise<void>;
53
41
  getNodejsStatus(options?: THttpRequestOptions): Promise<{
54
42
  node_state: "OK" | "NOT_INSTALLED" | "NOT_FOUND";
55
43
  }>;
56
- installNodejs(storage: TStorageType, options?: THttpRequestOptions): Promise<{
57
- status: number;
58
- message: string;
59
- }>;
44
+ installNodejs(storage: TCameraStorageType, options?: THttpRequestOptions): Promise<void>;
60
45
  private _getJson;
61
46
  private _post;
62
47
  }