camstreamerlib 4.0.0-beta.36 → 4.0.0-beta.38

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 (101) hide show
  1. package/cjs/CamOverlayAPI.js +52 -79
  2. package/cjs/CamScripterAPI.js +30 -24
  3. package/cjs/CamStreamerAPI.js +30 -33
  4. package/cjs/CamSwitcherAPI.js +57 -52
  5. package/cjs/PlaneTrackerAPI.js +55 -66
  6. package/cjs/VapixAPI.js +23 -22
  7. package/cjs/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +1 -1
  8. package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +4 -14
  9. package/cjs/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +1 -1
  10. package/cjs/{VapixEvents.js → node/VapixEvents.js} +1 -1
  11. package/cjs/node/events/GenetecAgent.js +5 -27
  12. package/cjs/node/index.js +17 -0
  13. package/cjs/types/CamOverlayAPI/CamOverlayAPI.js +18 -18
  14. package/cjs/types/CamOverlayAPI/accuweatherSchema.js +7 -7
  15. package/cjs/types/CamOverlayAPI/customGraphicsSchema.js +5 -5
  16. package/cjs/types/CamOverlayAPI/imagesSchema.js +4 -4
  17. package/cjs/types/CamOverlayAPI/index.js +1 -1
  18. package/cjs/types/CamOverlayAPI/infotickerSchema.js +6 -6
  19. package/cjs/types/CamOverlayAPI/pipSchema.js +4 -4
  20. package/cjs/types/CamOverlayAPI/ptzCompassSchema.js +4 -4
  21. package/cjs/types/CamOverlayAPI/ptzSchema.js +4 -4
  22. package/cjs/types/CamOverlayAPI/scoreBoardSchema.js +8 -8
  23. package/cjs/types/CamOverlayAPI/screenSharingSchema.js +3 -3
  24. package/cjs/types/CamOverlayAPI/{widgetCommonTypes.js → serviceCommonTypes.js} +8 -4
  25. package/cjs/types/CamOverlayAPI/webCameraSharingSchema.js +3 -3
  26. package/cjs/types/CamOverlayPainter.js +12 -0
  27. package/cjs/types/CamScripterAPICameraEventsGenerator.js +2 -0
  28. package/cjs/types/CamSwitcherAPI.js +38 -1
  29. package/cjs/types/GenetecAgent.js +31 -0
  30. package/cjs/types/PlaneTrackerAPI.js +277 -0
  31. package/cjs/types/VapixAPI.js +20 -2
  32. package/cjs/types/VapixEvents.js +2 -0
  33. package/esm/CamOverlayAPI.js +53 -80
  34. package/esm/CamScripterAPI.js +30 -24
  35. package/esm/CamStreamerAPI.js +30 -30
  36. package/esm/CamSwitcherAPI.js +58 -53
  37. package/esm/PlaneTrackerAPI.js +56 -67
  38. package/esm/VapixAPI.js +24 -23
  39. package/esm/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +1 -1
  40. package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +1 -11
  41. package/esm/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +1 -1
  42. package/esm/{VapixEvents.js → node/VapixEvents.js} +1 -1
  43. package/esm/node/events/GenetecAgent.js +1 -23
  44. package/esm/node/index.js +10 -0
  45. package/esm/types/CamOverlayAPI/CamOverlayAPI.js +17 -17
  46. package/esm/types/CamOverlayAPI/accuweatherSchema.js +3 -3
  47. package/esm/types/CamOverlayAPI/customGraphicsSchema.js +3 -3
  48. package/esm/types/CamOverlayAPI/imagesSchema.js +3 -3
  49. package/esm/types/CamOverlayAPI/index.js +1 -1
  50. package/esm/types/CamOverlayAPI/infotickerSchema.js +3 -3
  51. package/esm/types/CamOverlayAPI/pipSchema.js +3 -3
  52. package/esm/types/CamOverlayAPI/ptzCompassSchema.js +3 -3
  53. package/esm/types/CamOverlayAPI/ptzSchema.js +3 -3
  54. package/esm/types/CamOverlayAPI/scoreBoardSchema.js +5 -5
  55. package/esm/types/CamOverlayAPI/screenSharingSchema.js +2 -2
  56. package/esm/types/CamOverlayAPI/{widgetCommonTypes.js → serviceCommonTypes.js} +7 -3
  57. package/esm/types/CamOverlayAPI/webCameraSharingSchema.js +2 -2
  58. package/esm/types/CamOverlayPainter.js +11 -1
  59. package/esm/types/CamSwitcherAPI.js +38 -1
  60. package/esm/types/GenetecAgent.js +28 -0
  61. package/esm/types/PlaneTrackerAPI.js +276 -1
  62. package/esm/types/VapixAPI.js +19 -1
  63. package/esm/types/VapixEvents.js +1 -0
  64. package/package.json +1 -1
  65. package/types/CamOverlayAPI.d.ts +836 -10
  66. package/types/CamScripterAPI.d.ts +34 -9
  67. package/types/CamStreamerAPI.d.ts +27 -5
  68. package/types/CamSwitcherAPI.d.ts +136 -23
  69. package/types/PlaneTrackerAPI.d.ts +201 -20
  70. package/types/VapixAPI.d.ts +46 -12
  71. package/types/bin/CreatePackage.d.ts +1 -0
  72. package/types/{CamOverlayDrawingAPI.d.ts → node/CamOverlayDrawingAPI.d.ts} +1 -1
  73. package/types/{CamOverlayPainter → node/CamOverlayPainter}/Frame.d.ts +2 -2
  74. package/types/{CamOverlayPainter → node/CamOverlayPainter}/Painter.d.ts +2 -13
  75. package/types/{CamOverlayPainter → node/CamOverlayPainter}/ResourceManager.d.ts +1 -1
  76. package/types/node/CamScripterAPICameraEventsGenerator.d.ts +31 -0
  77. package/types/node/VapixEvents.d.ts +16 -0
  78. package/types/node/events/GenetecAgent.d.ts +1 -144
  79. package/types/node/index.d.ts +10 -0
  80. package/types/types/CamOverlayAPI/CamOverlayAPI.d.ts +20 -20
  81. package/types/types/CamOverlayAPI/index.d.ts +1 -1
  82. package/types/types/CamOverlayAPI/{widgetCommonTypes.d.ts → serviceCommonTypes.d.ts} +6 -2
  83. package/types/types/CamOverlayDrawingAPI.d.ts +3 -13
  84. package/types/types/CamOverlayPainter.d.ts +12 -10
  85. package/types/types/CamScripterAPICameraEventsGenerator.d.ts +45 -0
  86. package/types/types/CamStreamerAPI.d.ts +2 -2
  87. package/types/types/CamSwitcherAPI.d.ts +111 -30
  88. package/types/types/GenetecAgent.d.ts +174 -0
  89. package/types/types/PlaneTrackerAPI.d.ts +859 -0
  90. package/types/types/VapixAPI.d.ts +54 -8
  91. package/types/types/VapixEvents.d.ts +15 -0
  92. package/types/types/common.d.ts +1 -0
  93. package/types/CamScripterAPICameraEventsGenerator.d.ts +0 -74
  94. package/types/VapixEvents.d.ts +0 -43
  95. /package/cjs/{CreatePackage.js → bin/CreatePackage.js} +0 -0
  96. /package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +0 -0
  97. /package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/ResourceManager.js +0 -0
  98. /package/esm/{CreatePackage.js → bin/CreatePackage.js} +0 -0
  99. /package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +0 -0
  100. /package/esm/{CamOverlayPainter → node/CamOverlayPainter}/ResourceManager.js +0 -0
  101. /package/{types/CreatePackage.d.ts → esm/types/CamScripterAPICameraEventsGenerator.js} +0 -0
@@ -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;
@@ -1,30 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GenetecAgent = void 0;
4
- const zod_1 = require("zod");
5
4
  const utils_1 = require("../../internal/utils");
6
- const successResponseSchema = zod_1.z.object({
7
- Rsp: zod_1.z.object({
8
- Status: zod_1.z.literal('Ok'),
9
- }),
10
- });
11
- const cameraGuidsResponseSchema = zod_1.z.object({
12
- Rsp: zod_1.z.object({
13
- Status: zod_1.z.literal('Ok'),
14
- Result: zod_1.z.array(zod_1.z.object({ Guid: zod_1.z.string() })),
15
- }),
16
- });
17
- const cameraDetailSchema = zod_1.z.object({
18
- Guid: zod_1.z.string().optional(),
19
- Name: zod_1.z.string().optional(),
20
- EntityType: zod_1.z.string().optional(),
21
- });
22
- const cameraDetailsResponseSchema = zod_1.z.object({
23
- Rsp: zod_1.z.object({
24
- Status: zod_1.z.literal('Ok'),
25
- Result: zod_1.z.union([zod_1.z.array(cameraDetailSchema), cameraDetailSchema]),
26
- }),
27
- });
5
+ const GenetecAgent_1 = require("../../types/GenetecAgent");
28
6
  class GenetecAgent {
29
7
  settings;
30
8
  baseUrl;
@@ -50,7 +28,7 @@ class GenetecAgent {
50
28
  throw new Error(await (0, utils_1.responseStringify)(res));
51
29
  }
52
30
  const responseBody = await res.text();
53
- const result = await successResponseSchema.safeParseAsync(JSON.parse(responseBody));
31
+ const result = await GenetecAgent_1.successResponseSchema.safeParseAsync(JSON.parse(responseBody));
54
32
  if (!result.success) {
55
33
  throw new Error('Genetec connection test failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
56
34
  }
@@ -64,7 +42,7 @@ class GenetecAgent {
64
42
  throw new Error(await (0, utils_1.responseStringify)(res));
65
43
  }
66
44
  const responseBody = await res.text();
67
- const result = await cameraGuidsResponseSchema.safeParseAsync(JSON.parse(responseBody));
45
+ const result = await GenetecAgent_1.cameraGuidsResponseSchema.safeParseAsync(JSON.parse(responseBody));
68
46
  if (!result.success) {
69
47
  throw new Error('Genetec get camera guids failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
70
48
  }
@@ -85,7 +63,7 @@ class GenetecAgent {
85
63
  throw new Error(await (0, utils_1.responseStringify)(res));
86
64
  }
87
65
  const responseBody = await res.text();
88
- const result = await cameraDetailsResponseSchema.safeParseAsync(JSON.parse(responseBody));
66
+ const result = await GenetecAgent_1.cameraDetailsResponseSchema.safeParseAsync(JSON.parse(responseBody));
89
67
  if (!result.success) {
90
68
  throw new Error('Genetec get camera details failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
91
69
  }
@@ -105,7 +83,7 @@ class GenetecAgent {
105
83
  throw new Error(await (0, utils_1.responseStringify)(res));
106
84
  }
107
85
  const responseBody = await res.text();
108
- const result = await successResponseSchema.safeParseAsync(JSON.parse(responseBody));
86
+ const result = await GenetecAgent_1.successResponseSchema.safeParseAsync(JSON.parse(responseBody));
109
87
  if (!result.success) {
110
88
  throw new Error('Genetec send bookmark failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
111
89
  }
package/cjs/node/index.js CHANGED
@@ -14,8 +14,25 @@ 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.VapixEvents = exports.CamScripterAPICameraEventsGenerator = exports.CamOverlayDrawingAPI = exports.Frame = exports.Painter = exports.ResourceManager = void 0;
17
18
  __exportStar(require("./DefaultClient"), exports);
18
19
  __exportStar(require("./WsClient"), exports);
19
20
  __exportStar(require("./HttpServer"), exports);
20
21
  __exportStar(require("./events/AxisCameraStationEvents"), exports);
21
22
  __exportStar(require("./events/GenetecAgent"), exports);
23
+ var ResourceManager_1 = require("./CamOverlayPainter/ResourceManager");
24
+ Object.defineProperty(exports, "ResourceManager", { enumerable: true, get: function () { return ResourceManager_1.ResourceManager; } });
25
+ var Painter_1 = require("./CamOverlayPainter/Painter");
26
+ Object.defineProperty(exports, "Painter", { enumerable: true, get: function () { return Painter_1.Painter; } });
27
+ var Frame_1 = require("./CamOverlayPainter/Frame");
28
+ Object.defineProperty(exports, "Frame", { enumerable: true, get: function () { return Frame_1.Frame; } });
29
+ __exportStar(require("../types/CamOverlayPainter"), exports);
30
+ var CamOverlayDrawingAPI_1 = require("./CamOverlayDrawingAPI");
31
+ Object.defineProperty(exports, "CamOverlayDrawingAPI", { enumerable: true, get: function () { return CamOverlayDrawingAPI_1.CamOverlayDrawingAPI; } });
32
+ __exportStar(require("../types/CamOverlayDrawingAPI"), exports);
33
+ var CamScripterAPICameraEventsGenerator_1 = require("./CamScripterAPICameraEventsGenerator");
34
+ Object.defineProperty(exports, "CamScripterAPICameraEventsGenerator", { enumerable: true, get: function () { return CamScripterAPICameraEventsGenerator_1.CamScripterAPICameraEventsGenerator; } });
35
+ __exportStar(require("../types/CamScripterAPICameraEventsGenerator"), exports);
36
+ var VapixEvents_1 = require("./VapixEvents");
37
+ Object.defineProperty(exports, "VapixEvents", { enumerable: true, get: function () { return VapixEvents_1.VapixEvents; } });
38
+ __exportStar(require("../types/VapixEvents"), exports);
@@ -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.widgetListSchema = exports.widgetsSchema = exports.WSResponseSchema = void 0;
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;
4
4
  const zod_1 = require("zod");
5
5
  const infotickerSchema_1 = require("./infotickerSchema");
6
6
  const accuweatherSchema_1 = require("./accuweatherSchema");
@@ -12,11 +12,11 @@ const customGraphicsSchema_1 = require("./customGraphicsSchema");
12
12
  const screenSharingSchema_1 = require("./screenSharingSchema");
13
13
  const webCameraSharingSchema_1 = require("./webCameraSharingSchema");
14
14
  const scoreBoardSchema_1 = require("./scoreBoardSchema");
15
- exports.WSResponseSchema = zod_1.z.object({
15
+ exports.wsResponseSchema = zod_1.z.object({
16
16
  status: zod_1.z.number(),
17
17
  message: zod_1.z.string(),
18
18
  });
19
- exports.widgetsSchema = zod_1.z.discriminatedUnion('name', [
19
+ exports.servicesSchema = zod_1.z.discriminatedUnion('name', [
20
20
  infotickerSchema_1.infoTickerSchema,
21
21
  accuweatherSchema_1.accuweatherSchema,
22
22
  ptzCompassSchema_1.ptzCompassSchema,
@@ -31,34 +31,34 @@ exports.widgetsSchema = zod_1.z.discriminatedUnion('name', [
31
31
  scoreBoardSchema_1.baseballScoreBoardAutomaticSchema,
32
32
  scoreBoardSchema_1.scoreOverviewSchema,
33
33
  ]);
34
- exports.widgetListSchema = zod_1.z.object({
35
- services: zod_1.z.array(exports.widgetsSchema),
34
+ exports.serviceListSchema = zod_1.z.object({
35
+ services: zod_1.z.array(exports.servicesSchema),
36
36
  });
37
- const isAccuweather = (widget) => widget.name === 'accuweather';
37
+ const isAccuweather = (service) => service.name === 'accuweather';
38
38
  exports.isAccuweather = isAccuweather;
39
- const isCustomGraphics = (widget) => widget.name === 'customGraphics';
39
+ const isCustomGraphics = (service) => service.name === 'customGraphics';
40
40
  exports.isCustomGraphics = isCustomGraphics;
41
- const isImages = (widget) => widget.name === 'images';
41
+ const isImages = (service) => service.name === 'images';
42
42
  exports.isImages = isImages;
43
- const isInfoticker = (widget) => widget.name === 'infoticker';
43
+ const isInfoticker = (service) => service.name === 'infoticker';
44
44
  exports.isInfoticker = isInfoticker;
45
- const isPip = (widget) => widget.name === 'pip';
45
+ const isPip = (service) => service.name === 'pip';
46
46
  exports.isPip = isPip;
47
- const isPtzCompass = (widget) => widget.name === 'ptzCompass';
47
+ const isPtzCompass = (service) => service.name === 'ptzCompass';
48
48
  exports.isPtzCompass = isPtzCompass;
49
- const isPtz = (widget) => widget.name === 'ptz';
49
+ const isPtz = (service) => service.name === 'ptz';
50
50
  exports.isPtz = isPtz;
51
- const isScreenSharing = (widget) => widget.name === 'screenSharing';
51
+ const isScreenSharing = (service) => service.name === 'screenSharing';
52
52
  exports.isScreenSharing = isScreenSharing;
53
- const isWebCameraSharing = (widget) => widget.name === 'web_camera';
53
+ const isWebCameraSharing = (service) => service.name === 'web_camera';
54
54
  exports.isWebCameraSharing = isWebCameraSharing;
55
- const isScoreBoard = (widget) => widget.name === 'scoreBoard';
55
+ const isScoreBoard = (service) => service.name === 'scoreBoard';
56
56
  exports.isScoreBoard = isScoreBoard;
57
- const isBaseballScoreBoard = (widget) => widget.name === 'baseballScoreBoard';
57
+ const isBaseballScoreBoard = (service) => service.name === 'baseballScoreBoard';
58
58
  exports.isBaseballScoreBoard = isBaseballScoreBoard;
59
- const isBaseballScoreBoardAutomatic = (widget) => widget.name === 'myBallBaseballWidgets';
59
+ const isBaseballScoreBoardAutomatic = (service) => service.name === 'myBallBaseballWidgets';
60
60
  exports.isBaseballScoreBoardAutomatic = isBaseballScoreBoardAutomatic;
61
- const isScoreOverview = (widget) => widget.name === 'scoreOverview';
61
+ const isScoreOverview = (service) => service.name === 'scoreOverview';
62
62
  exports.isScoreOverview = isScoreOverview;
63
63
  var ImageType;
64
64
  (function (ImageType) {
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.accuweatherSchema = void 0;
4
4
  const zod_1 = require("zod");
5
- const widgetCommonTypes_1 = require("./widgetCommonTypes");
6
- exports.accuweatherSchema = widgetCommonTypes_1.widgetCommonSchema.extend({
7
- name: zod_1.z.literal(widgetCommonTypes_1.allowedWidgetNames.accuweather),
5
+ const serviceCommonTypes_1 = require("./serviceCommonTypes");
6
+ exports.accuweatherSchema = serviceCommonTypes_1.serviceCommonSchema.extend({
7
+ name: zod_1.z.literal(serviceCommonTypes_1.serviceNames.accuweather),
8
8
  location: zod_1.z.string(),
9
9
  locationName: zod_1.z.string(),
10
10
  title: zod_1.z.string(),
@@ -21,12 +21,12 @@ exports.accuweatherSchema = widgetCommonTypes_1.widgetCommonSchema.extend({
21
21
  zod_1.z.literal('140,150,168,0.95'),
22
22
  ]),
23
23
  clockType: zod_1.z.union([zod_1.z.literal('12h'), zod_1.z.literal('24h')]),
24
- lang: widgetCommonTypes_1.languageSchema,
25
- font: widgetCommonTypes_1.fontSchema,
26
- units: widgetCommonTypes_1.weatherUnitSchema,
24
+ lang: serviceCommonTypes_1.languageSchema,
25
+ font: serviceCommonTypes_1.fontSchema,
26
+ units: serviceCommonTypes_1.weatherUnitSchema,
27
27
  pos_x: zod_1.z.number(),
28
28
  pos_y: zod_1.z.number(),
29
- coordSystem: widgetCommonTypes_1.coordinateSystemSchema,
29
+ coordSystem: serviceCommonTypes_1.coordinateSystemSchema,
30
30
  layout: zod_1.z.union([
31
31
  zod_1.z.literal('0'),
32
32
  zod_1.z.literal('1'),