camstreamerlib 4.0.0-beta.37 → 4.0.0-beta.39

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 (79) hide show
  1. package/README.md +38 -27
  2. package/cjs/CamOverlayAPI.js +42 -75
  3. package/cjs/CamScripterAPI.js +30 -24
  4. package/cjs/CamStreamerAPI.js +30 -33
  5. package/cjs/CamSwitcherAPI.js +57 -52
  6. package/cjs/PlaneTrackerAPI.js +55 -66
  7. package/cjs/VapixAPI.js +23 -22
  8. package/cjs/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +1 -1
  9. package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +4 -14
  10. package/cjs/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +1 -1
  11. package/cjs/{VapixEvents.js → node/VapixEvents.js} +1 -1
  12. package/cjs/node/events/GenetecAgent.js +5 -27
  13. package/cjs/node/index.js +17 -0
  14. package/cjs/types/CamOverlayAPI/CamOverlayAPI.js +2 -2
  15. package/cjs/types/CamOverlayAPI/scoreBoardSchema.js +6 -1
  16. package/cjs/types/CamOverlayPainter.js +12 -0
  17. package/cjs/types/CamScripterAPICameraEventsGenerator.js +2 -0
  18. package/cjs/types/CamSwitcherAPI.js +38 -1
  19. package/cjs/types/GenetecAgent.js +31 -0
  20. package/cjs/types/PlaneTrackerAPI.js +277 -0
  21. package/cjs/types/VapixAPI.js +20 -2
  22. package/cjs/types/VapixEvents.js +2 -0
  23. package/esm/CamOverlayAPI.js +43 -76
  24. package/esm/CamScripterAPI.js +30 -24
  25. package/esm/CamStreamerAPI.js +30 -30
  26. package/esm/CamSwitcherAPI.js +58 -53
  27. package/esm/PlaneTrackerAPI.js +56 -67
  28. package/esm/VapixAPI.js +24 -23
  29. package/esm/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +1 -1
  30. package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +1 -11
  31. package/esm/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +1 -1
  32. package/esm/{VapixEvents.js → node/VapixEvents.js} +1 -1
  33. package/esm/node/events/GenetecAgent.js +1 -23
  34. package/esm/node/index.js +10 -0
  35. package/esm/types/CamOverlayAPI/CamOverlayAPI.js +1 -1
  36. package/esm/types/CamOverlayAPI/scoreBoardSchema.js +6 -1
  37. package/esm/types/CamOverlayPainter.js +11 -1
  38. package/esm/types/CamSwitcherAPI.js +38 -1
  39. package/esm/types/GenetecAgent.js +28 -0
  40. package/esm/types/PlaneTrackerAPI.js +276 -1
  41. package/esm/types/VapixAPI.js +19 -1
  42. package/esm/types/VapixEvents.js +1 -0
  43. package/package.json +1 -1
  44. package/types/CamOverlayAPI.d.ts +24 -14
  45. package/types/CamScripterAPI.d.ts +34 -9
  46. package/types/CamStreamerAPI.d.ts +27 -5
  47. package/types/CamSwitcherAPI.d.ts +136 -23
  48. package/types/PlaneTrackerAPI.d.ts +201 -20
  49. package/types/VapixAPI.d.ts +46 -12
  50. package/types/bin/CreatePackage.d.ts +1 -0
  51. package/types/{CamOverlayDrawingAPI.d.ts → node/CamOverlayDrawingAPI.d.ts} +1 -1
  52. package/types/{CamOverlayPainter → node/CamOverlayPainter}/Frame.d.ts +2 -2
  53. package/types/{CamOverlayPainter → node/CamOverlayPainter}/Painter.d.ts +2 -13
  54. package/types/{CamOverlayPainter → node/CamOverlayPainter}/ResourceManager.d.ts +1 -1
  55. package/types/node/CamScripterAPICameraEventsGenerator.d.ts +31 -0
  56. package/types/node/VapixEvents.d.ts +16 -0
  57. package/types/node/events/GenetecAgent.d.ts +1 -144
  58. package/types/node/index.d.ts +10 -0
  59. package/types/types/CamOverlayAPI/CamOverlayAPI.d.ts +38 -38
  60. package/types/types/CamOverlayAPI/scoreBoardSchema.d.ts +13 -13
  61. package/types/types/CamOverlayDrawingAPI.d.ts +3 -13
  62. package/types/types/CamOverlayPainter.d.ts +12 -10
  63. package/types/types/CamScripterAPICameraEventsGenerator.d.ts +45 -0
  64. package/types/types/CamStreamerAPI.d.ts +2 -2
  65. package/types/types/CamSwitcherAPI.d.ts +111 -30
  66. package/types/types/GenetecAgent.d.ts +174 -0
  67. package/types/types/PlaneTrackerAPI.d.ts +859 -0
  68. package/types/types/VapixAPI.d.ts +54 -8
  69. package/types/types/VapixEvents.d.ts +15 -0
  70. package/types/types/common.d.ts +1 -0
  71. package/types/CamScripterAPICameraEventsGenerator.d.ts +0 -74
  72. package/types/VapixEvents.d.ts +0 -43
  73. /package/cjs/{CreatePackage.js → bin/CreatePackage.js} +0 -0
  74. /package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +0 -0
  75. /package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/ResourceManager.js +0 -0
  76. /package/esm/{CreatePackage.js → bin/CreatePackage.js} +0 -0
  77. /package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +0 -0
  78. /package/esm/{CamOverlayPainter → node/CamOverlayPainter}/ResourceManager.js +0 -0
  79. /package/{types/CreatePackage.d.ts → esm/types/CamScripterAPICameraEventsGenerator.js} +0 -0
@@ -20,9 +20,9 @@ class CamSwitcherAPI {
20
20
  this.CustomFormData = CustomFormData;
21
21
  this.vapixAgent = new VapixAPI_1.VapixAPI(client);
22
22
  }
23
- static getProxyUrlPath = () => `${BASE_PATH}/proxy.cgi`;
24
- static getWsEventsUrlPath = () => `/local/camswitcher/events`;
25
- static getClipPreviewUrlPath = (id, storage) => `${BASE_PATH}/clip_preview.cgi?clip_name=${id}&storage=${storage}`;
23
+ static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
24
+ static getWsEventsPath = () => `/local/camswitcher/events`;
25
+ static getClipPreviewPath = (id, storage) => `${BASE_PATH}/clip_preview.cgi?clip_name=${id}&storage=${storage}`;
26
26
  getClient(proxyParams) {
27
27
  return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
28
28
  }
@@ -38,98 +38,105 @@ class CamSwitcherAPI {
38
38
  });
39
39
  }
40
40
  async checkCameraTime(options) {
41
- const data = await this.get(`${BASE_PATH}/camera_time.cgi`, undefined, options);
42
- return zod_1.z.boolean().parse(data);
41
+ const res = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
42
+ return zod_1.z.boolean().parse(res.data);
43
43
  }
44
44
  async getNetworkCameraList(options) {
45
- const data = await this.get(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
46
- return common_1.networkCameraListSchema.parse(data);
45
+ const res = await this._getJson(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
46
+ return common_1.networkCameraListSchema.parse(res.data);
47
47
  }
48
48
  async getMaxFps(source, options) {
49
- const data = await this.get(`${BASE_PATH}/get_max_framerate.cgi`, {
50
- video_source: source.toString(),
49
+ const res = await this._getJson(`${BASE_PATH}/get_max_framerate.cgi`, {
50
+ video_source: source,
51
51
  }, options);
52
- return zod_1.z.number().parse(data);
52
+ return zod_1.z.number().parse(res.data);
53
53
  }
54
54
  async getStorageInfo(options) {
55
- const data = await this.get(`${BASE_PATH}/get_storage.cgi`, undefined, options);
56
- return CamSwitcherAPI_1.storageInfoListSchema.parse(data);
55
+ const res = await this._getJson(`${BASE_PATH}/get_storage.cgi`, undefined, options);
56
+ return CamSwitcherAPI_1.storageInfoListSchema.parse(res.data);
57
57
  }
58
58
  async wsAuthorization(options) {
59
- const data = await this.get(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
60
- return zod_1.z.string().parse(data);
59
+ const res = await this._getJson(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
60
+ return zod_1.z.string().parse(res.data);
61
61
  }
62
62
  async getOutputInfo(options) {
63
- const data = await this.get(`${BASE_PATH}/output_info.cgi`, undefined, options);
64
- return CamSwitcherAPI_1.outputInfoSchema.parse(data);
63
+ const res = await this._getJson(`${BASE_PATH}/output_info.cgi`, undefined, options);
64
+ return CamSwitcherAPI_1.outputInfoSchema.parse(res.data);
65
65
  }
66
66
  async getAudioPushInfo(options) {
67
- const data = await this.get(`${BASE_PATH}/audio_push_info.cgi`, undefined, options);
68
- return CamSwitcherAPI_1.audioPushInfoSchema.parse(data);
67
+ const res = await this._getJson(`${BASE_PATH}/audio_push_info.cgi`, undefined, options);
68
+ return CamSwitcherAPI_1.audioPushInfoSchema.parse(res.data);
69
69
  }
70
70
  async getStreamSaveList(options) {
71
- const data = await this.get(`${BASE_PATH}/streams.cgi`, { action: 'get' }, options);
72
- return CamSwitcherAPI_1.streamSaveLoadSchema.parse(data);
71
+ const res = await this._getJson(`${BASE_PATH}/streams.cgi`, { action: 'get' }, options);
72
+ return CamSwitcherAPI_1.streamSaveLoadSchema.parse(res.data);
73
73
  }
74
74
  async getClipSaveList(options) {
75
- const data = await this.get(`${BASE_PATH}/clips.cgi`, { action: 'get' }, options);
76
- return CamSwitcherAPI_1.clipSaveLoadSchema.parse(data);
75
+ const res = await this._getJson(`${BASE_PATH}/clips.cgi`, { action: 'get' }, options);
76
+ return CamSwitcherAPI_1.clipSaveLoadSchema.parse(res.data);
77
77
  }
78
78
  async getPlaylistSaveList(options) {
79
- const data = await this.get(`${BASE_PATH}/playlists.cgi`, { action: 'get' }, options);
80
- return CamSwitcherAPI_1.playlistSaveLoadSchema.parse(data);
79
+ const res = await this._getJson(`${BASE_PATH}/playlists.cgi`, { action: 'get' }, options);
80
+ return CamSwitcherAPI_1.playlistSaveLoadSchema.parse(res.data);
81
81
  }
82
82
  async getTrackerSaveList(options) {
83
- const data = await this.get(`${BASE_PATH}/trackers.cgi`, { action: 'get' }, options);
84
- return CamSwitcherAPI_1.trackerSaveLoadSchema.parse(data);
83
+ const res = await this._getJson(`${BASE_PATH}/trackers.cgi`, { action: 'get' }, options);
84
+ return CamSwitcherAPI_1.trackerSaveLoadSchema.parse(res.data);
85
85
  }
86
86
  async setStreamSaveList(data, options) {
87
- return await this.set(`${BASE_PATH}/streams.cgi`, data, { action: 'set' }, options);
87
+ return await this._post(`${BASE_PATH}/streams.cgi`, data, { action: 'set' }, options);
88
88
  }
89
89
  async setClipSaveList(data, options) {
90
- return await this.set(`${BASE_PATH}/clips.cgi`, data, { action: 'set' }, options);
90
+ return await this._post(`${BASE_PATH}/clips.cgi`, data, { action: 'set' }, options);
91
91
  }
92
92
  async setPlaylistSaveList(data, options) {
93
- return await this.set(`${BASE_PATH}/playlists.cgi`, data, { action: 'set' }, options);
93
+ return await this._post(`${BASE_PATH}/playlists.cgi`, data, { action: 'set' }, options);
94
94
  }
95
95
  async setTrackerSaveList(data, options) {
96
- return await this.set(`${BASE_PATH}/trackers.cgi`, data, { action: 'set' }, options);
96
+ return await this._post(`${BASE_PATH}/trackers.cgi`, data, { action: 'set' }, options);
97
97
  }
98
98
  async playlistSwitch(playlistName, options) {
99
- await this.get(`${BASE_PATH}/playlist_switch.cgi`, { playlist_name: playlistName }, options);
99
+ await this._getJson(`${BASE_PATH}/playlist_switch.cgi`, { playlist_name: playlistName }, options);
100
100
  }
101
101
  async playlistQueuePush(playlistName, options) {
102
- await this.get(`${BASE_PATH}/playlist_queue_push.cgi`, { playlist_name: playlistName }, options);
102
+ await this._getJson(`${BASE_PATH}/playlist_queue_push.cgi`, { playlist_name: playlistName }, options);
103
103
  }
104
104
  async playlistQueueClear(options) {
105
- await this.get(`${BASE_PATH}/playlist_queue_clear.cgi`, undefined, options);
105
+ await this._getJson(`${BASE_PATH}/playlist_queue_clear.cgi`, undefined, options);
106
106
  }
107
107
  async playlistQueueList(options) {
108
- const data = await this.get(`${BASE_PATH}/playlist_queue_list.cgi`, undefined, options);
109
- return CamSwitcherAPI_1.playlistQueueSchema.parse(data).playlistQueueList;
108
+ const res = await this._getJson(`${BASE_PATH}/playlist_queue_list.cgi`, undefined, options);
109
+ return CamSwitcherAPI_1.playlistQueueSchema.parse(res.data).playlistQueueList;
110
110
  }
111
111
  async playlistQueuePlayNext(options) {
112
- await this.get(`${BASE_PATH}/playlist_queue_play_next.cgi`, undefined, options);
112
+ await this._getJson(`${BASE_PATH}/playlist_queue_play_next.cgi`, undefined, options);
113
113
  }
114
114
  async addNewClip(file, clipType, storage, clipId, fileName, options) {
115
- const path = `${BASE_PATH}/clip_upload.cgi?storage=${storage}`;
115
+ const path = `${BASE_PATH}/clip_upload.cgi`;
116
116
  const formData = new this.CustomFormData();
117
117
  formData.append('clip_name', clipId);
118
118
  formData.append('clip_type', clipType);
119
119
  formData.append('file', file, fileName);
120
120
  const agent = this.getClient(options?.proxyParams);
121
- const res = await agent.post({ path, data: formData, timeout: options?.timeout });
121
+ const res = await agent.post({
122
+ path,
123
+ data: formData,
124
+ parameters: {
125
+ storage: storage,
126
+ },
127
+ timeout: options?.timeout,
128
+ });
122
129
  const output = (await res.json());
123
130
  if (output.status !== 200) {
124
131
  throw new errors_1.AddNewClipError(output.message);
125
132
  }
126
133
  }
127
134
  removeClip(clipId, storage, options) {
128
- return this.get(`${BASE_PATH}/clip_remove.cgi`, { clip_name: clipId, storage }, options);
135
+ return this._getJson(`${BASE_PATH}/clip_remove.cgi`, { clip_name: clipId, storage }, options);
129
136
  }
130
137
  async getClipList(options) {
131
- const data = await this.get(`${BASE_PATH}/clip_list.cgi`, undefined, options);
132
- return CamSwitcherAPI_1.clipListSchema.parse(data).clip_list;
138
+ const res = await this._getJson(`${BASE_PATH}/clip_list.cgi`, undefined, options);
139
+ return CamSwitcherAPI_1.clipListSchema.parse(res.data).clip_list;
133
140
  }
134
141
  setCamSwitchOptions(data, cameraFWVersion, options) {
135
142
  const bitrateVapixParams = parseBitrateOptionsToBitrateVapixParams(cameraFWVersion, data.bitrateMode, data);
@@ -230,7 +237,7 @@ class CamSwitcherAPI {
230
237
  settings.source = res.clip_name;
231
238
  settings.storage = res.storage;
232
239
  }
233
- return settings;
240
+ return CamSwitcherAPI_1.globalAudioSettingsSchema.parse(settings);
234
241
  }
235
242
  async getSecondaryAudioSettings(options) {
236
243
  const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SECONDARY_AUDIO, options);
@@ -242,30 +249,28 @@ class CamSwitcherAPI {
242
249
  secondaryAudioLevel: res.secondary_audio_level ?? 1,
243
250
  masterAudioLevel: res.master_audio_level ?? 1,
244
251
  };
245
- return settings;
252
+ return CamSwitcherAPI_1.secondaryAudioSettingsSchema.parse(settings);
246
253
  }
247
254
  async getPermanentRtspUrlToken(options) {
248
255
  const paramName = CSW_PARAM_NAMES.RTSP_TOKEN;
249
256
  const res = await this.vapixAgent.getParameter([paramName], options);
250
- return res[paramName] ?? '';
257
+ return zod_1.z.string().parse(res[paramName] ?? '');
251
258
  }
252
- async get(path, parameters, options) {
259
+ async _getJson(path, parameters, options) {
253
260
  const agent = this.getClient(options?.proxyParams);
254
261
  const res = await agent.get({ path, parameters, timeout: options?.timeout });
255
262
  if (res.ok) {
256
- const d = await res.json();
257
- return d.data;
263
+ return await res.json();
258
264
  }
259
265
  else {
260
266
  throw new Error(await (0, utils_1.responseStringify)(res));
261
267
  }
262
268
  }
263
- async set(path, data, parameters, options) {
269
+ async _post(path, data, parameters, options, headers) {
264
270
  const agent = this.getClient(options?.proxyParams);
265
- const res = await agent.post({ path, data: JSON.stringify(data), parameters, timeout: options?.timeout });
271
+ const res = await agent.post({ path, data, parameters, timeout: options?.timeout, headers });
266
272
  if (res.ok) {
267
- const parsed = await res.json();
268
- return parsed.message === 'OK';
273
+ return await res.json();
269
274
  }
270
275
  else {
271
276
  throw new Error(await (0, utils_1.responseStringify)(res));
@@ -306,7 +311,7 @@ const parseBitrateOptionsToBitrateVapixParams = (firmWareVersion, bitrateMode, c
306
311
  if (!(0, versionCompare_1.isFirmwareVersionAtLeast)(firmWareVersion, constants_1.FIRMWARE_WITH_BITRATE_MODES_SUPPORT)) {
307
312
  return `videomaxbitrate=${cameraOptions.maximumBitRate}`;
308
313
  }
309
- if (bitrateMode === null) {
314
+ if (bitrateMode === undefined) {
310
315
  return '';
311
316
  }
312
317
  const data = {
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PlaneTrackerAPI = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const utils_1 = require("./internal/utils");
6
+ const PlaneTrackerAPI_1 = require("./types/PlaneTrackerAPI");
6
7
  const errors_1 = require("./errors/errors");
7
8
  const ProxyClient_1 = require("./internal/ProxyClient");
9
+ const GenetecAgent_1 = require("./types/GenetecAgent");
8
10
  const BASE_PATH = '/local/planetracker';
9
11
  class PlaneTrackerAPI {
10
12
  client;
@@ -13,13 +15,13 @@ class PlaneTrackerAPI {
13
15
  this.client = client;
14
16
  this.apiUser = apiUser;
15
17
  }
16
- static getProxyUrlPath = () => `${BASE_PATH}/proxy.cgi`;
18
+ static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
17
19
  getClient(proxyParams) {
18
20
  return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
19
21
  }
20
22
  async checkCameraTime(options) {
21
- const response = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
22
- return zod_1.z.boolean().parse(response.state);
23
+ const res = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
24
+ return zod_1.z.boolean().parse(res.state);
23
25
  }
24
26
  async resetPtzCalibration(options) {
25
27
  const agent = this.getClient(options?.proxyParams);
@@ -50,7 +52,8 @@ class PlaneTrackerAPI {
50
52
  });
51
53
  }
52
54
  async fetchCameraSettings(options) {
53
- return await this._getJson(`${BASE_PATH}/package_camera_settings.cgi`, { action: 'get' }, options);
55
+ const res = await this._getJson(`${BASE_PATH}/package_camera_settings.cgi`, { action: 'get' }, options);
56
+ return PlaneTrackerAPI_1.cameraSettingsSchema.parse(res);
54
57
  }
55
58
  async setCameraSettings(settingsJsonString, options) {
56
59
  return await this._postJsonEncoded(`${BASE_PATH}/package_camera_settings.cgi`, settingsJsonString, {
@@ -58,7 +61,8 @@ class PlaneTrackerAPI {
58
61
  }, options);
59
62
  }
60
63
  async fetchServerSettings(options) {
61
- return await this._getJson(`${BASE_PATH}/package_server_settings.cgi`, { action: 'get' }, options);
64
+ const res = await this._getJson(`${BASE_PATH}/package_server_settings.cgi`, { action: 'get' }, options);
65
+ return PlaneTrackerAPI_1.serverSettingsSchema.parse(res);
62
66
  }
63
67
  async exportAppSettings(dataType, options) {
64
68
  return await this._getBlob(`${BASE_PATH}/package_data.cgi`, { action: 'EXPORT', dataType }, options);
@@ -73,13 +77,15 @@ class PlaneTrackerAPI {
73
77
  });
74
78
  }
75
79
  async fetchFlightInfo(icao, options) {
76
- return await this._getJson(`${BASE_PATH}/package/flightInfo.cgi`, { icao: encodeURIComponent(icao) }, options);
80
+ const res = await this._getJson(`${BASE_PATH}/package/flightInfo.cgi`, { icao }, options);
81
+ return PlaneTrackerAPI_1.flightInfoSchema.parse(res);
77
82
  }
78
83
  async getTrackingMode(options) {
79
- return await this._getJson(`${BASE_PATH}/package/getTrackingMode.cgi`, undefined, options);
84
+ const res = await this._getJson(`${BASE_PATH}/package/getTrackingMode.cgi`, undefined, options);
85
+ return PlaneTrackerAPI_1.trackingModeSchema.parse(res);
80
86
  }
81
- async setTrackingMode(modeJsonString, options) {
82
- return await this._postJsonEncoded(`${BASE_PATH}/package/setTrackingMode.cgi`, modeJsonString, this.apiUser, options);
87
+ async setTrackingMode(mode, options) {
88
+ return await this._postJsonEncoded(`${BASE_PATH}/package/setTrackingMode.cgi`, { mode }, this.apiUser, options);
83
89
  }
84
90
  async startTrackingPlane(icao, options) {
85
91
  const agent = this.getClient(options?.proxyParams);
@@ -98,31 +104,36 @@ class PlaneTrackerAPI {
98
104
  });
99
105
  }
100
106
  async getPriorityList(options) {
101
- return await this._getJson(`${BASE_PATH}/package/getPriorityList.cgi`, undefined, options);
107
+ const res = await this._getJson(`${BASE_PATH}/package/getPriorityList.cgi`, undefined, options);
108
+ return PlaneTrackerAPI_1.priorityListSchema.parse(res);
102
109
  }
103
- async setPriorityList(priorityListJsonString, options) {
104
- return await this._postJsonEncoded(`${BASE_PATH}/package/setPriorityList.cgi`, priorityListJsonString, this.apiUser, options);
110
+ async setPriorityList(priorityList, options) {
111
+ return await this._postJsonEncoded(`${BASE_PATH}/package/setPriorityList.cgi`, { priorityList }, this.apiUser, options);
105
112
  }
106
113
  async getWhiteList(options) {
107
- return await this._getJson(`${BASE_PATH}/package/getWhiteList.cgi`, undefined, options);
114
+ const res = await this._getJson(`${BASE_PATH}/package/getWhiteList.cgi`, undefined, options);
115
+ return PlaneTrackerAPI_1.whiteListSchema.parse(res);
108
116
  }
109
- async setWhiteList(whiteListJsonString, options) {
110
- return await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, whiteListJsonString, this.apiUser, options);
117
+ async setWhiteList(whiteList, options) {
118
+ return await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, { whiteList }, this.apiUser, options);
111
119
  }
112
120
  async getBlackList(options) {
113
- return await this._getJson(`${BASE_PATH}/package/getBlackList.cgi`, undefined, options);
121
+ const res = await this._getJson(`${BASE_PATH}/package/getBlackList.cgi`, undefined, options);
122
+ return PlaneTrackerAPI_1.blackListSchema.parse(res);
114
123
  }
115
- async setBlackList(blackListJsonString, options) {
116
- return await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, blackListJsonString, this.apiUser, options);
124
+ async setBlackList(blackList, options) {
125
+ return await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, { blackList }, this.apiUser, options);
117
126
  }
118
127
  async fetchMapInfo(options) {
119
- return await this._getJson(`${BASE_PATH}/package/getMapInfo.cgi`, undefined, options);
128
+ const res = await this._getJson(`${BASE_PATH}/package/getMapInfo.cgi`, undefined, options);
129
+ return PlaneTrackerAPI_1.mapInfoSchema.parse(res);
120
130
  }
121
131
  async getZones(options) {
122
- return await this._getJson(`${BASE_PATH}/package/getZones.cgi`, undefined, options);
132
+ const res = await this._getJson(`${BASE_PATH}/package/getZones.cgi`, undefined, options);
133
+ return PlaneTrackerAPI_1.zonesSchema.parse(res);
123
134
  }
124
- async setZones(zonesJsonString, options) {
125
- return await this._postJsonEncoded(`${BASE_PATH}/package/setZones.cgi`, zonesJsonString, this.apiUser, options);
135
+ async setZones(zones, options) {
136
+ return await this._postJsonEncoded(`${BASE_PATH}/package/setZones.cgi`, { zones }, this.apiUser, options);
126
137
  }
127
138
  async goToCoordinates(lat, lon, alt, options) {
128
139
  const agent = this.getClient(options?.proxyParams);
@@ -133,19 +144,25 @@ class PlaneTrackerAPI {
133
144
  });
134
145
  }
135
146
  async checkGenetecConnection(params, options) {
136
- return await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, params, options);
147
+ return await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, '', params, options);
137
148
  }
138
149
  async getGenetecCameraList(params, options) {
139
- const res = await this._postUrlEncoded(`${BASE_PATH}/package/getGenetecCameraList.cgi`, params, options);
140
- return await res.json();
150
+ const res = await this._postUrlEncoded(`${BASE_PATH}/package/getGenetecCameraList.cgi`, '', params, options);
151
+ return GenetecAgent_1.cameraListSchema.parse(res);
141
152
  }
142
- async _getJson(path, parameters, options) {
153
+ async _getJson(path, parameters, options, headers) {
143
154
  const agent = this.getClient(options?.proxyParams);
144
- const res = await agent.get({
145
- path,
146
- parameters,
147
- timeout: options?.timeout,
148
- });
155
+ const res = await agent.get({ path, parameters, timeout: options?.timeout, headers });
156
+ if (res.ok) {
157
+ return await res.json();
158
+ }
159
+ else {
160
+ throw new Error(await (0, utils_1.responseStringify)(res));
161
+ }
162
+ }
163
+ async _post(path, data, parameters, options, headers) {
164
+ const agent = this.getClient(options?.proxyParams);
165
+ const res = await agent.post({ path, data, parameters, headers, timeout: options?.timeout });
149
166
  if (res.ok) {
150
167
  return await res.json();
151
168
  }
@@ -155,11 +172,7 @@ class PlaneTrackerAPI {
155
172
  }
156
173
  async _getBlob(path, parameters, options) {
157
174
  const agent = this.getClient(options?.proxyParams);
158
- const res = await agent.get({
159
- path,
160
- parameters,
161
- timeout: options?.timeout,
162
- });
175
+ const res = await agent.get({ path, parameters, timeout: options?.timeout });
163
176
  if (res.ok) {
164
177
  return await this.parseBlobResponse(res);
165
178
  }
@@ -175,37 +188,13 @@ class PlaneTrackerAPI {
175
188
  throw new errors_1.ParsingBlobError(err);
176
189
  }
177
190
  }
178
- async _postJsonEncoded(path, data, parameters, options) {
179
- const agent = this.getClient(options?.proxyParams);
180
- const res = await agent.post({
181
- path,
182
- data,
183
- parameters,
184
- headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' },
185
- timeout: options?.timeout,
186
- });
187
- if (res.ok) {
188
- return res;
189
- }
190
- else {
191
- throw new Error(await (0, utils_1.responseStringify)(res));
192
- }
191
+ async _postUrlEncoded(path, data, parameters, options, headers) {
192
+ const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
193
+ return this._post(path, data, parameters, options, { ...baseHeaders, ...headers });
193
194
  }
194
- async _postUrlEncoded(path, params, options) {
195
- const data = (0, utils_1.paramToUrl)(params);
196
- const agent = this.getClient(options?.proxyParams);
197
- const res = await agent.post({
198
- path,
199
- data,
200
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
201
- timeout: options?.timeout,
202
- });
203
- if (res.ok) {
204
- return res;
205
- }
206
- else {
207
- throw new Error(await (0, utils_1.responseStringify)(res));
208
- }
195
+ async _postJsonEncoded(path, data, parameters, options, headers) {
196
+ const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
197
+ return this._post(path, data, parameters, options, { ...baseHeaders, ...headers });
209
198
  }
210
199
  }
211
200
  exports.PlaneTrackerAPI = PlaneTrackerAPI;
package/cjs/VapixAPI.js CHANGED
@@ -110,11 +110,11 @@ class VapixAPI {
110
110
  });
111
111
  const result = parser.parse(xmlText);
112
112
  const data = result.root.disks.disk;
113
- return {
113
+ return VapixAPI_1.sdCardInfoSchema.parse({
114
114
  totalSize: parseInt(data.totalsize),
115
115
  freeSize: parseInt(data.freesize),
116
116
  status: VapixAPI_1.sdCardWatchedStatuses.includes(data.status) ? data.status : 'disconnected',
117
- };
117
+ });
118
118
  }
119
119
  mountSDCard(options) {
120
120
  return this._doSDCardMountAction('MOUNT', options);
@@ -183,7 +183,7 @@ class VapixAPI {
183
183
  if ((0, utils_1.isNullish)(captureMode.maxFPS)) {
184
184
  throw new errors_1.MaxFPSError('FPS_NOT_SPECIFIED');
185
185
  }
186
- return captureMode.maxFPS;
186
+ return zod_1.z.number().parse(captureMode.maxFPS);
187
187
  }
188
188
  async getTimezone(options) {
189
189
  try {
@@ -207,7 +207,7 @@ class VapixAPI {
207
207
  if (data.data.timeZone === undefined) {
208
208
  throw new Error('Time zone not setup on the device');
209
209
  }
210
- return data.data.timeZone;
210
+ return zod_1.z.string().parse(data.data.timeZone);
211
211
  }
212
212
  async getDateTimeInfo(options) {
213
213
  const data = { apiVersion: '1.0', method: 'getDateTimeInfo' };
@@ -262,7 +262,7 @@ class VapixAPI {
262
262
  const gTourList = new Array();
263
263
  const response = await this.getParameter('GuardTour', options);
264
264
  for (let i = 0; i < 20; i++) {
265
- const gTourBaseName = 'root.GuardTour.G' + i;
265
+ const gTourBaseName = 'GuardTour.G' + i;
266
266
  if (gTourBaseName + '.CamNbr' in response) {
267
267
  const gTour = {
268
268
  id: gTourBaseName,
@@ -274,7 +274,7 @@ class VapixAPI {
274
274
  tour: [],
275
275
  };
276
276
  for (let j = 0; j < 100; j++) {
277
- const tourBaseName = 'root.GuardTour.G' + i + '.Tour.T' + j;
277
+ const tourBaseName = 'GuardTour.G' + i + '.Tour.T' + j;
278
278
  if (tourBaseName + '.MoveSpeed' in response) {
279
279
  const tour = {
280
280
  moveSpeed: response[tourBaseName + '.MoveSpeed'],
@@ -292,17 +292,17 @@ class VapixAPI {
292
292
  break;
293
293
  }
294
294
  }
295
- return gTourList;
295
+ return VapixAPI_1.guardTourSchema.parse(gTourList);
296
296
  }
297
- setGuardTourEnabled(guardTourID, enable, options) {
297
+ setGuardTourEnabled(guardTourId, enable, options) {
298
298
  const params = {};
299
- params[guardTourID + '.Running'] = enable ? 'yes' : 'no';
299
+ params[guardTourId + '.Running'] = enable ? 'yes' : 'no';
300
300
  return this.setParameter(params, options);
301
301
  }
302
302
  async getPTZPresetList(channel, options) {
303
303
  const res = await this.postUrlEncoded('/axis-cgi/com/ptz.cgi', {
304
304
  query: 'presetposcam',
305
- camera: channel.toString(),
305
+ camera: channel,
306
306
  }, undefined, options);
307
307
  const text = await res.text();
308
308
  const lines = text.split(/[\r\n]/);
@@ -316,7 +316,7 @@ class VapixAPI {
316
316
  }
317
317
  }
318
318
  }
319
- return positions;
319
+ return zod_1.z.array(zod_1.z.string()).parse(positions);
320
320
  }
321
321
  async listPTZ(camera, options) {
322
322
  const url = `/axis-cgi/com/ptz.cgi`;
@@ -350,7 +350,7 @@ class VapixAPI {
350
350
  res[camera - 1] = item.map(({ data: itemData, ...d }) => d);
351
351
  }
352
352
  });
353
- return res;
353
+ return VapixAPI_1.ptzOverviewSchema.parse(res);
354
354
  }
355
355
  goToPreset(channel, presetName, options) {
356
356
  return this.postUrlEncoded('/axis-cgi/com/ptz.cgi', {
@@ -364,11 +364,11 @@ class VapixAPI {
364
364
  camera: camera.toString(),
365
365
  }, undefined, options);
366
366
  const params = VapixAPI.parseParameters(await res.text());
367
- return {
367
+ return VapixAPI_1.cameraPTZItemDataSchema.parse({
368
368
  pan: Number(params.pan),
369
369
  tilt: Number(params.tilt),
370
370
  zoom: Number(params.zoom),
371
- };
371
+ });
372
372
  }
373
373
  async getPorts(options) {
374
374
  const res = await this.postJson('/axis-cgi/io/portmanagement.cgi', {
@@ -376,7 +376,7 @@ class VapixAPI {
376
376
  context: '',
377
377
  method: 'getPorts',
378
378
  }, undefined, options);
379
- const portResponseParsed = await VapixAPI_1.getPortsResponseSchema.parse(res.json());
379
+ const portResponseParsed = VapixAPI_1.getPortsResponseSchema.parse(await res.json());
380
380
  return portResponseParsed.data.items;
381
381
  }
382
382
  async setPorts(ports, options) {
@@ -409,19 +409,20 @@ class VapixAPI {
409
409
  if (!Array.isArray(apps)) {
410
410
  apps = [apps];
411
411
  }
412
- return apps.map((app) => {
412
+ const appList = apps.map((app) => {
413
413
  return {
414
414
  ...app,
415
415
  appId: VapixAPI_1.APP_IDS.find((id) => id.toLowerCase() === app.Name.toLowerCase()) ?? null,
416
416
  };
417
417
  });
418
+ return VapixAPI_1.applicationListSchema.parse(appList);
418
419
  }
419
- async startApplication(applicationID, options) {
420
+ async startApplication(applicationId, options) {
420
421
  const agent = this.getClient(options?.proxyParams);
421
422
  const res = await agent.get({
422
423
  path: '/axis-cgi/applications/control.cgi',
423
424
  parameters: {
424
- package: applicationID.toLowerCase(),
425
+ package: applicationId.toLowerCase(),
425
426
  action: 'start',
426
427
  },
427
428
  timeout: options?.timeout,
@@ -431,12 +432,12 @@ class VapixAPI {
431
432
  throw new errors_1.ApplicationAPIError('START', await (0, utils_1.responseStringify)(res));
432
433
  }
433
434
  }
434
- async restartApplication(applicationID, options) {
435
+ async restartApplication(applicationId, options) {
435
436
  const agent = this.getClient(options?.proxyParams);
436
437
  const res = await agent.get({
437
438
  path: '/axis-cgi/applications/control.cgi',
438
439
  parameters: {
439
- package: applicationID.toLowerCase(),
440
+ package: applicationId.toLowerCase(),
440
441
  action: 'restart',
441
442
  },
442
443
  timeout: options?.timeout,
@@ -446,12 +447,12 @@ class VapixAPI {
446
447
  throw new errors_1.ApplicationAPIError('RESTART', await (0, utils_1.responseStringify)(res));
447
448
  }
448
449
  }
449
- async stopApplication(applicationID, options) {
450
+ async stopApplication(applicationId, options) {
450
451
  const agent = this.getClient(options?.proxyParams);
451
452
  const res = await agent.get({
452
453
  path: '/axis-cgi/applications/control.cgi',
453
454
  parameters: {
454
- package: applicationID.toLowerCase(),
455
+ package: applicationId.toLowerCase(),
455
456
  action: 'stop',
456
457
  },
457
458
  timeout: options?.timeout,
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CamOverlayDrawingAPI = void 0;
7
7
  const events_1 = __importDefault(require("events"));
8
- const WsClient_1 = require("./node/WsClient");
8
+ const WsClient_1 = require("./WsClient");
9
9
  class CamOverlayDrawingAPI extends events_1.default {
10
10
  tls;
11
11
  tlsInsecure;
@@ -1,20 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Painter = exports.COORD = void 0;
3
+ exports.Painter = void 0;
4
4
  const CamOverlayDrawingAPI_1 = require("../CamOverlayDrawingAPI");
5
5
  const ResourceManager_1 = require("./ResourceManager");
6
6
  const Frame_1 = require("./Frame");
7
- exports.COORD = {
8
- top_left: [-1, -1],
9
- center_left: [-1, 0],
10
- bottom_left: [-1, 1],
11
- top_center: [0, -1],
12
- center: [0, 0],
13
- bottom_center: [0, 1],
14
- top_right: [1, -1],
15
- center_right: [1, 0],
16
- bottom_right: [1, 1],
17
- };
7
+ const CamOverlayPainter_1 = require("../../types/CamOverlayPainter");
18
8
  class Painter extends Frame_1.Frame {
19
9
  screenWidth;
20
10
  screenHeight;
@@ -25,7 +15,7 @@ class Painter extends Frame_1.Frame {
25
15
  layers = [];
26
16
  constructor(opt, coopt) {
27
17
  super(opt);
28
- this.coAlignment = exports.COORD[opt.coAlignment];
18
+ this.coAlignment = CamOverlayPainter_1.COORD[opt.coAlignment];
29
19
  this.screenWidth = opt.screenWidth;
30
20
  this.screenHeight = opt.screenHeight;
31
21
  this.cod = new CamOverlayDrawingAPI_1.CamOverlayDrawingAPI(coopt);
@@ -69,7 +59,7 @@ class Painter extends Frame_1.Frame {
69
59
  this.screenHeight = sh;
70
60
  }
71
61
  setCoAlignment(coAlignment) {
72
- this.coAlignment = exports.COORD[coAlignment];
62
+ this.coAlignment = CamOverlayPainter_1.COORD[coAlignment];
73
63
  }
74
64
  layoutChanged() {
75
65
  this.refreshLayers = true;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CamScripterAPICameraEventsGenerator = void 0;
7
7
  const events_1 = __importDefault(require("events"));
8
- const WsClient_1 = require("./node/WsClient");
8
+ const WsClient_1 = require("./WsClient");
9
9
  class CamScripterAPICameraEventsGenerator extends events_1.default {
10
10
  tls;
11
11
  tlsInsecure;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VapixEvents = void 0;
4
4
  const eventemitter2_1 = require("eventemitter2");
5
- const WsClient_1 = require("./node/WsClient");
5
+ const WsClient_1 = require("./WsClient");
6
6
  class VapixEvents extends eventemitter2_1.EventEmitter2 {
7
7
  tls;
8
8
  tlsInsecure;