camstreamerlib 4.0.0-beta.61 → 4.0.0-beta.63
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.
- package/cjs/CamOverlayAPI.js +5 -5
- package/cjs/CamScripterAPI.js +3 -3
- package/cjs/CamStreamerAPI.js +1 -2
- package/cjs/CamSwitcherAPI.js +2 -2
- package/cjs/PlaneTrackerAPI.js +8 -8
- package/cjs/VapixAPI.js +10 -10
- package/cjs/errors/errors.js +32 -17
- package/cjs/internal/utils.js +1 -8
- package/cjs/node/events/GenetecAgent.js +5 -4
- package/cjs/types/ws/PlaneTrackerEvents.js +2 -0
- package/esm/CamOverlayAPI.js +7 -7
- package/esm/CamScripterAPI.js +3 -3
- package/esm/CamStreamerAPI.js +2 -3
- package/esm/CamSwitcherAPI.js +4 -4
- package/esm/PlaneTrackerAPI.js +10 -10
- package/esm/VapixAPI.js +12 -12
- package/esm/errors/errors.js +30 -16
- package/esm/internal/utils.js +0 -6
- package/esm/node/events/GenetecAgent.js +6 -5
- package/esm/types/ws/PlaneTrackerEvents.js +2 -0
- package/package.json +1 -1
- package/types/errors/errors.d.ts +17 -9
- package/types/internal/utils.d.ts +1 -2
- package/types/types/ws/PlaneTrackerEvents.d.ts +40 -0
package/cjs/CamOverlayAPI.js
CHANGED
|
@@ -83,7 +83,7 @@ class CamOverlayAPI {
|
|
|
83
83
|
throw new errors_1.ServiceNotFoundError();
|
|
84
84
|
}
|
|
85
85
|
else {
|
|
86
|
-
throw new
|
|
86
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
async getSingleService(serviceId, options) {
|
|
@@ -165,7 +165,7 @@ class CamOverlayAPI {
|
|
|
165
165
|
timeout: options?.timeout,
|
|
166
166
|
});
|
|
167
167
|
if (!res.ok) {
|
|
168
|
-
throw new
|
|
168
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
async _getJson(path, parameters, options) {
|
|
@@ -175,7 +175,7 @@ class CamOverlayAPI {
|
|
|
175
175
|
return await res.json();
|
|
176
176
|
}
|
|
177
177
|
else {
|
|
178
|
-
throw new
|
|
178
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
async _post(path, data, parameters, options, headers) {
|
|
@@ -185,7 +185,7 @@ class CamOverlayAPI {
|
|
|
185
185
|
return await res.json();
|
|
186
186
|
}
|
|
187
187
|
else {
|
|
188
|
-
throw new
|
|
188
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
async _getBlob(path, parameters, options) {
|
|
@@ -195,7 +195,7 @@ class CamOverlayAPI {
|
|
|
195
195
|
return await this.parseBlobResponse(res);
|
|
196
196
|
}
|
|
197
197
|
else {
|
|
198
|
-
throw new
|
|
198
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
async parseBlobResponse(response) {
|
package/cjs/CamScripterAPI.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CamScripterAPI = void 0;
|
|
4
|
+
const errors_1 = require("./errors/errors");
|
|
4
5
|
const ProxyClient_1 = require("./internal/ProxyClient");
|
|
5
|
-
const utils_1 = require("./internal/utils");
|
|
6
6
|
const CamScripterAPI_1 = require("./types/CamScripterAPI");
|
|
7
7
|
const common_1 = require("./types/common");
|
|
8
8
|
const BASE_PATH = '/local/camscripter';
|
|
@@ -63,7 +63,7 @@ class CamScripterAPI {
|
|
|
63
63
|
return await res.json();
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
66
|
-
throw new
|
|
66
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
async _post(path, data, parameters, options, headers) {
|
|
@@ -73,7 +73,7 @@ class CamScripterAPI {
|
|
|
73
73
|
return await res.json();
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
|
-
throw new
|
|
76
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
}
|
package/cjs/CamStreamerAPI.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseCameraStreamResponse = exports.CamStreamerAPI = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const ProxyClient_1 = require("./internal/ProxyClient");
|
|
6
|
-
const utils_1 = require("./internal/utils");
|
|
7
6
|
const CamStreamerAPI_1 = require("./types/CamStreamerAPI");
|
|
8
7
|
const errors_1 = require("./errors/errors");
|
|
9
8
|
const BASE_PATH = '/local/camstreamer';
|
|
@@ -76,7 +75,7 @@ class CamStreamerAPI {
|
|
|
76
75
|
return await res.json();
|
|
77
76
|
}
|
|
78
77
|
else {
|
|
79
|
-
throw new
|
|
78
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
}
|
package/cjs/CamSwitcherAPI.js
CHANGED
|
@@ -263,7 +263,7 @@ class CamSwitcherAPI {
|
|
|
263
263
|
return await res.json();
|
|
264
264
|
}
|
|
265
265
|
else {
|
|
266
|
-
throw new
|
|
266
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
269
|
async _post(path, data, parameters, options, headers) {
|
|
@@ -273,7 +273,7 @@ class CamSwitcherAPI {
|
|
|
273
273
|
return await res.json();
|
|
274
274
|
}
|
|
275
275
|
else {
|
|
276
|
-
throw new
|
|
276
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
setParamFromCameraJSON(paramName, data, options) {
|
package/cjs/PlaneTrackerAPI.js
CHANGED
|
@@ -45,7 +45,7 @@ class PlaneTrackerAPI {
|
|
|
45
45
|
timeout: options?.timeout,
|
|
46
46
|
});
|
|
47
47
|
if (!res.ok) {
|
|
48
|
-
throw new errors_1.ResetCalibrationError('PTZ',
|
|
48
|
+
throw new errors_1.ResetCalibrationError('PTZ', res);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
async resetFocusCalibration(options) {
|
|
@@ -56,7 +56,7 @@ class PlaneTrackerAPI {
|
|
|
56
56
|
timeout: options?.timeout,
|
|
57
57
|
});
|
|
58
58
|
if (!res.ok) {
|
|
59
|
-
throw new errors_1.ResetCalibrationError('FOCUS',
|
|
59
|
+
throw new errors_1.ResetCalibrationError('FOCUS', res);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
async fetchCameraSettings(options) {
|
|
@@ -84,7 +84,7 @@ class PlaneTrackerAPI {
|
|
|
84
84
|
timeout: options?.timeout,
|
|
85
85
|
});
|
|
86
86
|
if (!res.ok) {
|
|
87
|
-
throw new errors_1.ImportSettingsError(
|
|
87
|
+
throw new errors_1.ImportSettingsError(res);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
async fetchFlightInfo(icao, options) {
|
|
@@ -168,7 +168,7 @@ class PlaneTrackerAPI {
|
|
|
168
168
|
throw new errors_1.InvalidAltitudeError();
|
|
169
169
|
}
|
|
170
170
|
if (res.status === 400) {
|
|
171
|
-
throw new errors_1.BadRequestError(
|
|
171
|
+
throw new errors_1.BadRequestError(res);
|
|
172
172
|
}
|
|
173
173
|
if (res.status === 500) {
|
|
174
174
|
throw new errors_1.ServerError();
|
|
@@ -189,7 +189,7 @@ class PlaneTrackerAPI {
|
|
|
189
189
|
return await res.json();
|
|
190
190
|
}
|
|
191
191
|
else {
|
|
192
|
-
throw new
|
|
192
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
async _getBlob(path, parameters, options) {
|
|
@@ -199,7 +199,7 @@ class PlaneTrackerAPI {
|
|
|
199
199
|
return await this.parseBlobResponse(res);
|
|
200
200
|
}
|
|
201
201
|
else {
|
|
202
|
-
throw new
|
|
202
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
async parseBlobResponse(response) {
|
|
@@ -224,7 +224,7 @@ class PlaneTrackerAPI {
|
|
|
224
224
|
return res;
|
|
225
225
|
}
|
|
226
226
|
else {
|
|
227
|
-
throw new
|
|
227
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
async _postUrlEncoded(path, params, options) {
|
|
@@ -240,7 +240,7 @@ class PlaneTrackerAPI {
|
|
|
240
240
|
return res;
|
|
241
241
|
}
|
|
242
242
|
else {
|
|
243
|
-
throw new
|
|
243
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
}
|
package/cjs/VapixAPI.js
CHANGED
|
@@ -23,7 +23,7 @@ class VapixAPI {
|
|
|
23
23
|
const agent = this.getClient(options?.proxyParams);
|
|
24
24
|
const res = await agent.post({ path, data, headers: head, timeout: options?.timeout });
|
|
25
25
|
if (!res.ok) {
|
|
26
|
-
throw new
|
|
26
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
27
27
|
}
|
|
28
28
|
return res;
|
|
29
29
|
}
|
|
@@ -33,7 +33,7 @@ class VapixAPI {
|
|
|
33
33
|
const agent = this.getClient(options?.proxyParams);
|
|
34
34
|
const res = await agent.post({ path, data, headers: head, timeout: options?.timeout });
|
|
35
35
|
if (!res.ok) {
|
|
36
|
-
throw new
|
|
36
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
37
37
|
}
|
|
38
38
|
return res;
|
|
39
39
|
}
|
|
@@ -59,7 +59,7 @@ class VapixAPI {
|
|
|
59
59
|
headers: { 'Content-Type': 'application/soap+xml' },
|
|
60
60
|
});
|
|
61
61
|
if (!res.ok) {
|
|
62
|
-
throw new
|
|
62
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
63
63
|
}
|
|
64
64
|
return await res.text();
|
|
65
65
|
}
|
|
@@ -136,7 +136,7 @@ class VapixAPI {
|
|
|
136
136
|
const result = parser.parse(textXml);
|
|
137
137
|
const job = result.root.job;
|
|
138
138
|
if (job.result !== 'OK') {
|
|
139
|
-
throw new errors_1.SDCardActionError(action,
|
|
139
|
+
throw new errors_1.SDCardActionError(action, job.description);
|
|
140
140
|
}
|
|
141
141
|
return Number(job.jobid);
|
|
142
142
|
}
|
|
@@ -153,7 +153,7 @@ class VapixAPI {
|
|
|
153
153
|
});
|
|
154
154
|
const job = parser.parse(textXml).root.job;
|
|
155
155
|
if (job.result !== 'OK') {
|
|
156
|
-
throw new errors_1.SDCardJobError();
|
|
156
|
+
throw new errors_1.SDCardJobError(job.description);
|
|
157
157
|
}
|
|
158
158
|
return Number(job.progress);
|
|
159
159
|
}
|
|
@@ -190,7 +190,7 @@ class VapixAPI {
|
|
|
190
190
|
const agent = this.getClient(options?.proxyParams);
|
|
191
191
|
const resV2 = await agent.get({ path: '/config/rest/time/v2/timeZone', timeout: options?.timeout });
|
|
192
192
|
if (!resV2.ok) {
|
|
193
|
-
throw new
|
|
193
|
+
throw new errors_1.ErrorWithResponse(resV2);
|
|
194
194
|
}
|
|
195
195
|
const json = await resV2.json();
|
|
196
196
|
const data = VapixAPI_1.timeZoneSchema.parse(json);
|
|
@@ -429,7 +429,7 @@ class VapixAPI {
|
|
|
429
429
|
});
|
|
430
430
|
const text = (await res.text()).trim().toLowerCase();
|
|
431
431
|
if (text !== 'ok' && !(text.startsWith('error:') && text.substring(7) === '6')) {
|
|
432
|
-
throw new errors_1.ApplicationAPIError('START',
|
|
432
|
+
throw new errors_1.ApplicationAPIError('START', text);
|
|
433
433
|
}
|
|
434
434
|
}
|
|
435
435
|
async restartApplication(applicationId, options) {
|
|
@@ -444,7 +444,7 @@ class VapixAPI {
|
|
|
444
444
|
});
|
|
445
445
|
const text = (await res.text()).trim().toLowerCase();
|
|
446
446
|
if (text !== 'ok') {
|
|
447
|
-
throw new errors_1.ApplicationAPIError('RESTART',
|
|
447
|
+
throw new errors_1.ApplicationAPIError('RESTART', text);
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
async stopApplication(applicationId, options) {
|
|
@@ -459,7 +459,7 @@ class VapixAPI {
|
|
|
459
459
|
});
|
|
460
460
|
const text = (await res.text()).trim().toLowerCase();
|
|
461
461
|
if (text !== 'ok' && !(text.startsWith('error:') && text.substring(7) === '6')) {
|
|
462
|
-
throw new errors_1.ApplicationAPIError('STOP',
|
|
462
|
+
throw new errors_1.ApplicationAPIError('STOP', text);
|
|
463
463
|
}
|
|
464
464
|
}
|
|
465
465
|
async installApplication(data, fileName, options) {
|
|
@@ -475,7 +475,7 @@ class VapixAPI {
|
|
|
475
475
|
timeout: options?.timeout ?? 120000,
|
|
476
476
|
});
|
|
477
477
|
if (!res.ok) {
|
|
478
|
-
throw new
|
|
478
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
479
479
|
}
|
|
480
480
|
const text = await res.text();
|
|
481
481
|
if (text.length > 5) {
|
package/cjs/errors/errors.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BadRequestError = exports.ServerError = exports.InvalidAltitudeError = exports.InvalidLatLngError = exports.CannotSetCoordsInAutoModeError = exports.ImportSettingsError = exports.ResetCalibrationError = exports.TimezoneFetchError = exports.TimezoneNotSetupError = exports.UtcTimeFetchError = exports.WsAuthorizationError = exports.StorageDataFetchError = exports.PtzNotSupportedError = exports.AddNewClipError = exports.FetchDeviceInfoError = exports.NoDeviceInfoError = exports.MaxFPSError = exports.SDCardJobError = exports.SDCardActionError = exports.ApplicationAPIError = exports.SettingParameterError = exports.ParameterNotFoundError = exports.JsonParseError = exports.ParsingBlobError = exports.ServiceNotFoundError = exports.ServiceUnavailableError = void 0;
|
|
3
|
+
exports.BadRequestError = exports.ServerError = exports.InvalidAltitudeError = exports.InvalidLatLngError = exports.CannotSetCoordsInAutoModeError = exports.ImportSettingsError = exports.ResetCalibrationError = exports.TimezoneFetchError = exports.TimezoneNotSetupError = exports.UtcTimeFetchError = exports.WsAuthorizationError = exports.StorageDataFetchError = exports.PtzNotSupportedError = exports.AddNewClipError = exports.FetchDeviceInfoError = exports.NoDeviceInfoError = exports.MaxFPSError = exports.SDCardJobError = exports.SDCardActionError = exports.ApplicationAPIError = exports.SettingParameterError = exports.ParameterNotFoundError = exports.JsonParseError = exports.ParsingBlobError = exports.ServiceNotFoundError = exports.ServiceUnavailableError = exports.ErrorWithResponse = void 0;
|
|
4
|
+
class ErrorWithResponse extends Error {
|
|
5
|
+
res;
|
|
6
|
+
constructor(res) {
|
|
7
|
+
super(res.statusText);
|
|
8
|
+
this.res = res;
|
|
9
|
+
this.name = 'ErrorWithResponse';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.ErrorWithResponse = ErrorWithResponse;
|
|
4
13
|
class ServiceUnavailableError extends Error {
|
|
5
14
|
constructor() {
|
|
6
15
|
super('Service is unavailable.');
|
|
@@ -44,22 +53,26 @@ class SettingParameterError extends Error {
|
|
|
44
53
|
}
|
|
45
54
|
exports.SettingParameterError = SettingParameterError;
|
|
46
55
|
class ApplicationAPIError extends Error {
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
action;
|
|
57
|
+
constructor(action, reason) {
|
|
58
|
+
super(`Error performing application action '${action}': ${reason}`);
|
|
59
|
+
this.action = action;
|
|
49
60
|
this.name = 'ApplicationAPIError';
|
|
50
61
|
}
|
|
51
62
|
}
|
|
52
63
|
exports.ApplicationAPIError = ApplicationAPIError;
|
|
53
64
|
class SDCardActionError extends Error {
|
|
54
|
-
|
|
55
|
-
|
|
65
|
+
action;
|
|
66
|
+
constructor(action, reason) {
|
|
67
|
+
super(`Error performing SD card action '${action}': ${reason}`);
|
|
68
|
+
this.action = action;
|
|
56
69
|
this.name = 'SDCardActionError';
|
|
57
70
|
}
|
|
58
71
|
}
|
|
59
72
|
exports.SDCardActionError = SDCardActionError;
|
|
60
73
|
class SDCardJobError extends Error {
|
|
61
|
-
constructor() {
|
|
62
|
-
super(
|
|
74
|
+
constructor(reason) {
|
|
75
|
+
super(`Error while fetching SD card job progress: ${reason}`);
|
|
63
76
|
this.name = 'SDCardJobError';
|
|
64
77
|
}
|
|
65
78
|
}
|
|
@@ -140,16 +153,18 @@ class TimezoneFetchError extends Error {
|
|
|
140
153
|
}
|
|
141
154
|
}
|
|
142
155
|
exports.TimezoneFetchError = TimezoneFetchError;
|
|
143
|
-
class ResetCalibrationError extends
|
|
144
|
-
|
|
145
|
-
|
|
156
|
+
class ResetCalibrationError extends ErrorWithResponse {
|
|
157
|
+
type;
|
|
158
|
+
constructor(type, res) {
|
|
159
|
+
super(res);
|
|
160
|
+
this.type = type;
|
|
146
161
|
this.name = 'ResetCalibrationError';
|
|
147
162
|
}
|
|
148
163
|
}
|
|
149
164
|
exports.ResetCalibrationError = ResetCalibrationError;
|
|
150
|
-
class ImportSettingsError extends
|
|
151
|
-
constructor(
|
|
152
|
-
super(
|
|
165
|
+
class ImportSettingsError extends ErrorWithResponse {
|
|
166
|
+
constructor(res) {
|
|
167
|
+
super(res);
|
|
153
168
|
this.name = 'ImportSettingsError';
|
|
154
169
|
}
|
|
155
170
|
}
|
|
@@ -182,10 +197,10 @@ class ServerError extends Error {
|
|
|
182
197
|
}
|
|
183
198
|
}
|
|
184
199
|
exports.ServerError = ServerError;
|
|
185
|
-
class BadRequestError extends
|
|
186
|
-
constructor(
|
|
187
|
-
super(
|
|
188
|
-
this.name = '
|
|
200
|
+
class BadRequestError extends ErrorWithResponse {
|
|
201
|
+
constructor(res) {
|
|
202
|
+
super(res);
|
|
203
|
+
this.name = 'BadRequestError';
|
|
189
204
|
}
|
|
190
205
|
}
|
|
191
206
|
exports.BadRequestError = BadRequestError;
|
package/cjs/internal/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNullish = exports.pad = exports.
|
|
3
|
+
exports.isNullish = exports.pad = exports.isLoopPlayType = exports.isPlaylist = exports.isTracker = exports.isClip = exports.isStream = exports.isCamera = exports.arrayToUrl = exports.paramToUrl = exports.addParametersToPath = void 0;
|
|
4
4
|
const addParametersToPath = (path, params) => {
|
|
5
5
|
if (params === undefined || Object.keys(params).length === 0) {
|
|
6
6
|
return path;
|
|
@@ -43,13 +43,6 @@ const isPlaylist = (id) => id?.charAt(0) === 'p';
|
|
|
43
43
|
exports.isPlaylist = isPlaylist;
|
|
44
44
|
const isLoopPlayType = (playType) => playType.includes('LOOP');
|
|
45
45
|
exports.isLoopPlayType = isLoopPlayType;
|
|
46
|
-
async function responseStringify(res) {
|
|
47
|
-
return JSON.stringify({
|
|
48
|
-
status: res.status,
|
|
49
|
-
body: await res.text(),
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
exports.responseStringify = responseStringify;
|
|
53
46
|
function pad(num, size) {
|
|
54
47
|
const sign = Math.sign(num) === -1 ? '-' : '';
|
|
55
48
|
return (sign +
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GenetecAgent = void 0;
|
|
4
|
+
const errors_1 = require("../../errors/errors");
|
|
4
5
|
const utils_1 = require("../../internal/utils");
|
|
5
6
|
const GenetecAgent_1 = require("../../types/GenetecAgent");
|
|
6
7
|
class GenetecAgent {
|
|
@@ -25,7 +26,7 @@ class GenetecAgent {
|
|
|
25
26
|
const requestOptions = this.getRequestOptions('GET');
|
|
26
27
|
const res = await this.fetchWithTimeout(new URL(this.baseUrl), requestOptions);
|
|
27
28
|
if (!res.ok) {
|
|
28
|
-
throw new
|
|
29
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
29
30
|
}
|
|
30
31
|
const responseBody = await res.text();
|
|
31
32
|
const result = await GenetecAgent_1.successResponseSchema.safeParseAsync(JSON.parse(responseBody));
|
|
@@ -39,7 +40,7 @@ class GenetecAgent {
|
|
|
39
40
|
url.searchParams.set('q', 'EntityTypes@Camera');
|
|
40
41
|
const res = await this.fetchWithTimeout(url, requestOptions);
|
|
41
42
|
if (!res.ok) {
|
|
42
|
-
throw new
|
|
43
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
43
44
|
}
|
|
44
45
|
const responseBody = await res.text();
|
|
45
46
|
const result = await GenetecAgent_1.cameraGuidsResponseSchema.safeParseAsync(JSON.parse(responseBody));
|
|
@@ -60,7 +61,7 @@ class GenetecAgent {
|
|
|
60
61
|
url.searchParams.set('q', chunk.map((item) => `entity=${item.Guid},${params}`).join(','));
|
|
61
62
|
const res = await this.fetchWithTimeout(url, requestOptions);
|
|
62
63
|
if (!res.ok) {
|
|
63
|
-
throw new
|
|
64
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
64
65
|
}
|
|
65
66
|
const responseBody = await res.text();
|
|
66
67
|
const result = await GenetecAgent_1.cameraDetailsResponseSchema.safeParseAsync(JSON.parse(responseBody));
|
|
@@ -80,7 +81,7 @@ class GenetecAgent {
|
|
|
80
81
|
url.searchParams.set('q', guids.map((guid) => `AddCameraBookmark(${guid},${timeStamp},${bookmarkText})`).join(','));
|
|
81
82
|
const res = await this.fetchWithTimeout(url, requestOptions);
|
|
82
83
|
if (!res.ok) {
|
|
83
|
-
throw new
|
|
84
|
+
throw new errors_1.ErrorWithResponse(res);
|
|
84
85
|
}
|
|
85
86
|
const responseBody = await res.text();
|
|
86
87
|
const result = await GenetecAgent_1.successResponseSchema.safeParseAsync(JSON.parse(responseBody));
|
|
@@ -17,6 +17,8 @@ const apiFlightDataSchema = zod_1.z.object({
|
|
|
17
17
|
priorityListed: zod_1.z.boolean(),
|
|
18
18
|
autoSelectionIgnored: zod_1.z.boolean(),
|
|
19
19
|
signalQuality: zod_1.z.number(),
|
|
20
|
+
emitterCategorySet: zod_1.z.number().default(4),
|
|
21
|
+
emitterCategory: zod_1.z.number().default(3),
|
|
20
22
|
emergencyState: zod_1.z.boolean(),
|
|
21
23
|
emergencyStatusMessage: zod_1.z.string(),
|
|
22
24
|
});
|
package/esm/CamOverlayAPI.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { paramToUrl
|
|
2
|
-
import { ParsingBlobError, ServiceNotFoundError, StorageDataFetchError } from './errors/errors';
|
|
1
|
+
import { paramToUrl } from './internal/utils';
|
|
2
|
+
import { ParsingBlobError, ErrorWithResponse, 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';
|
|
@@ -80,7 +80,7 @@ export class CamOverlayAPI {
|
|
|
80
80
|
throw new ServiceNotFoundError();
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
|
-
throw new
|
|
83
|
+
throw new ErrorWithResponse(res);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
async getSingleService(serviceId, options) {
|
|
@@ -162,7 +162,7 @@ export class CamOverlayAPI {
|
|
|
162
162
|
timeout: options?.timeout,
|
|
163
163
|
});
|
|
164
164
|
if (!res.ok) {
|
|
165
|
-
throw new
|
|
165
|
+
throw new ErrorWithResponse(res);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
async _getJson(path, parameters, options) {
|
|
@@ -172,7 +172,7 @@ export class CamOverlayAPI {
|
|
|
172
172
|
return await res.json();
|
|
173
173
|
}
|
|
174
174
|
else {
|
|
175
|
-
throw new
|
|
175
|
+
throw new ErrorWithResponse(res);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
async _post(path, data, parameters, options, headers) {
|
|
@@ -182,7 +182,7 @@ export class CamOverlayAPI {
|
|
|
182
182
|
return await res.json();
|
|
183
183
|
}
|
|
184
184
|
else {
|
|
185
|
-
throw new
|
|
185
|
+
throw new ErrorWithResponse(res);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
async _getBlob(path, parameters, options) {
|
|
@@ -192,7 +192,7 @@ export class CamOverlayAPI {
|
|
|
192
192
|
return await this.parseBlobResponse(res);
|
|
193
193
|
}
|
|
194
194
|
else {
|
|
195
|
-
throw new
|
|
195
|
+
throw new ErrorWithResponse(res);
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
async parseBlobResponse(response) {
|
package/esm/CamScripterAPI.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { ErrorWithResponse } from './errors/errors';
|
|
1
2
|
import { ProxyClient } from './internal/ProxyClient';
|
|
2
|
-
import { responseStringify } from './internal/utils';
|
|
3
3
|
import { cameraTimeResponseSchema, nodeStateSchema, packageInfoListSchema, cameraStorageSchema, } from './types/CamScripterAPI';
|
|
4
4
|
import { networkCameraListSchema } from './types/common';
|
|
5
5
|
const BASE_PATH = '/local/camscripter';
|
|
@@ -60,7 +60,7 @@ export class CamScripterAPI {
|
|
|
60
60
|
return await res.json();
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
|
-
throw new
|
|
63
|
+
throw new ErrorWithResponse(res);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
async _post(path, data, parameters, options, headers) {
|
|
@@ -70,7 +70,7 @@ export class CamScripterAPI {
|
|
|
70
70
|
return await res.json();
|
|
71
71
|
}
|
|
72
72
|
else {
|
|
73
|
-
throw new
|
|
73
|
+
throw new ErrorWithResponse(res);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}
|
package/esm/CamStreamerAPI.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { ProxyClient } from './internal/ProxyClient';
|
|
3
|
-
import { responseStringify } from './internal/utils';
|
|
4
3
|
import { cameraStreamSchema } from './types/CamStreamerAPI';
|
|
5
|
-
import { UtcTimeFetchError, WsAuthorizationError } from './errors/errors';
|
|
4
|
+
import { ErrorWithResponse, UtcTimeFetchError, WsAuthorizationError } from './errors/errors';
|
|
6
5
|
const BASE_PATH = '/local/camstreamer';
|
|
7
6
|
export class CamStreamerAPI {
|
|
8
7
|
client;
|
|
@@ -73,7 +72,7 @@ export class CamStreamerAPI {
|
|
|
73
72
|
return await res.json();
|
|
74
73
|
}
|
|
75
74
|
else {
|
|
76
|
-
throw new
|
|
75
|
+
throw new ErrorWithResponse(res);
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
}
|
package/esm/CamSwitcherAPI.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { AddNewClipError, JsonParseError, ParameterNotFoundError } from './errors/errors';
|
|
3
|
-
import { isClip, isNullish
|
|
2
|
+
import { AddNewClipError, JsonParseError, ParameterNotFoundError, ErrorWithResponse } from './errors/errors';
|
|
3
|
+
import { isClip, isNullish } 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';
|
|
6
6
|
import { VapixAPI } from './VapixAPI';
|
|
@@ -260,7 +260,7 @@ export class CamSwitcherAPI {
|
|
|
260
260
|
return await res.json();
|
|
261
261
|
}
|
|
262
262
|
else {
|
|
263
|
-
throw new
|
|
263
|
+
throw new ErrorWithResponse(res);
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
async _post(path, data, parameters, options, headers) {
|
|
@@ -270,7 +270,7 @@ export class CamSwitcherAPI {
|
|
|
270
270
|
return await res.json();
|
|
271
271
|
}
|
|
272
272
|
else {
|
|
273
|
-
throw new
|
|
273
|
+
throw new ErrorWithResponse(res);
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
setParamFromCameraJSON(paramName, data, options) {
|
package/esm/PlaneTrackerAPI.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { paramToUrl
|
|
2
|
+
import { paramToUrl } from './internal/utils';
|
|
3
3
|
import { blackListSchema, cameraSettingsSchema, flightInfoSchema, getIcaoSchema, mapInfoSchema, priorityListSchema, serverSettingsSchema, trackingModeSchema, whiteListSchema, wsAliasResponseSchema, zonesSchema, } from './types/PlaneTrackerAPI';
|
|
4
|
-
import { CannotSetCoordsInAutoModeError, ImportSettingsError, InvalidAltitudeError, InvalidLatLngError, ParsingBlobError, ResetCalibrationError, ServerError, BadRequestError, } from './errors/errors';
|
|
4
|
+
import { CannotSetCoordsInAutoModeError, ImportSettingsError, InvalidAltitudeError, InvalidLatLngError, ParsingBlobError, ResetCalibrationError, ServerError, BadRequestError, ErrorWithResponse, } from './errors/errors';
|
|
5
5
|
import { ProxyClient } from './internal/ProxyClient';
|
|
6
6
|
import { cameraListSchema } from './types/GenetecAgent';
|
|
7
7
|
const BASE_PATH = '/local/planetracker';
|
|
@@ -42,7 +42,7 @@ export class PlaneTrackerAPI {
|
|
|
42
42
|
timeout: options?.timeout,
|
|
43
43
|
});
|
|
44
44
|
if (!res.ok) {
|
|
45
|
-
throw new ResetCalibrationError('PTZ',
|
|
45
|
+
throw new ResetCalibrationError('PTZ', res);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
async resetFocusCalibration(options) {
|
|
@@ -53,7 +53,7 @@ export class PlaneTrackerAPI {
|
|
|
53
53
|
timeout: options?.timeout,
|
|
54
54
|
});
|
|
55
55
|
if (!res.ok) {
|
|
56
|
-
throw new ResetCalibrationError('FOCUS',
|
|
56
|
+
throw new ResetCalibrationError('FOCUS', res);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
async fetchCameraSettings(options) {
|
|
@@ -81,7 +81,7 @@ export class PlaneTrackerAPI {
|
|
|
81
81
|
timeout: options?.timeout,
|
|
82
82
|
});
|
|
83
83
|
if (!res.ok) {
|
|
84
|
-
throw new ImportSettingsError(
|
|
84
|
+
throw new ImportSettingsError(res);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
async fetchFlightInfo(icao, options) {
|
|
@@ -165,7 +165,7 @@ export class PlaneTrackerAPI {
|
|
|
165
165
|
throw new InvalidAltitudeError();
|
|
166
166
|
}
|
|
167
167
|
if (res.status === 400) {
|
|
168
|
-
throw new BadRequestError(
|
|
168
|
+
throw new BadRequestError(res);
|
|
169
169
|
}
|
|
170
170
|
if (res.status === 500) {
|
|
171
171
|
throw new ServerError();
|
|
@@ -186,7 +186,7 @@ export class PlaneTrackerAPI {
|
|
|
186
186
|
return await res.json();
|
|
187
187
|
}
|
|
188
188
|
else {
|
|
189
|
-
throw new
|
|
189
|
+
throw new ErrorWithResponse(res);
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
async _getBlob(path, parameters, options) {
|
|
@@ -196,7 +196,7 @@ export class PlaneTrackerAPI {
|
|
|
196
196
|
return await this.parseBlobResponse(res);
|
|
197
197
|
}
|
|
198
198
|
else {
|
|
199
|
-
throw new
|
|
199
|
+
throw new ErrorWithResponse(res);
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
async parseBlobResponse(response) {
|
|
@@ -221,7 +221,7 @@ export class PlaneTrackerAPI {
|
|
|
221
221
|
return res;
|
|
222
222
|
}
|
|
223
223
|
else {
|
|
224
|
-
throw new
|
|
224
|
+
throw new ErrorWithResponse(res);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
async _postUrlEncoded(path, params, options) {
|
|
@@ -237,7 +237,7 @@ export class PlaneTrackerAPI {
|
|
|
237
237
|
return res;
|
|
238
238
|
}
|
|
239
239
|
else {
|
|
240
|
-
throw new
|
|
240
|
+
throw new ErrorWithResponse(res);
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
}
|
package/esm/VapixAPI.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { arrayToUrl, isNullish, paramToUrl
|
|
1
|
+
import { arrayToUrl, isNullish, paramToUrl } 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, SettingParameterError, TimezoneFetchError, TimezoneNotSetupError, } from './errors/errors';
|
|
3
|
+
import { ApplicationAPIError, MaxFPSError, NoDeviceInfoError, PtzNotSupportedError, ErrorWithResponse, 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';
|
|
@@ -20,7 +20,7 @@ export class VapixAPI {
|
|
|
20
20
|
const agent = this.getClient(options?.proxyParams);
|
|
21
21
|
const res = await agent.post({ path, data, headers: head, timeout: options?.timeout });
|
|
22
22
|
if (!res.ok) {
|
|
23
|
-
throw new
|
|
23
|
+
throw new ErrorWithResponse(res);
|
|
24
24
|
}
|
|
25
25
|
return res;
|
|
26
26
|
}
|
|
@@ -30,7 +30,7 @@ export class VapixAPI {
|
|
|
30
30
|
const agent = this.getClient(options?.proxyParams);
|
|
31
31
|
const res = await agent.post({ path, data, headers: head, timeout: options?.timeout });
|
|
32
32
|
if (!res.ok) {
|
|
33
|
-
throw new
|
|
33
|
+
throw new ErrorWithResponse(res);
|
|
34
34
|
}
|
|
35
35
|
return res;
|
|
36
36
|
}
|
|
@@ -56,7 +56,7 @@ export class VapixAPI {
|
|
|
56
56
|
headers: { 'Content-Type': 'application/soap+xml' },
|
|
57
57
|
});
|
|
58
58
|
if (!res.ok) {
|
|
59
|
-
throw new
|
|
59
|
+
throw new ErrorWithResponse(res);
|
|
60
60
|
}
|
|
61
61
|
return await res.text();
|
|
62
62
|
}
|
|
@@ -133,7 +133,7 @@ export class VapixAPI {
|
|
|
133
133
|
const result = parser.parse(textXml);
|
|
134
134
|
const job = result.root.job;
|
|
135
135
|
if (job.result !== 'OK') {
|
|
136
|
-
throw new SDCardActionError(action,
|
|
136
|
+
throw new SDCardActionError(action, job.description);
|
|
137
137
|
}
|
|
138
138
|
return Number(job.jobid);
|
|
139
139
|
}
|
|
@@ -150,7 +150,7 @@ export class VapixAPI {
|
|
|
150
150
|
});
|
|
151
151
|
const job = parser.parse(textXml).root.job;
|
|
152
152
|
if (job.result !== 'OK') {
|
|
153
|
-
throw new SDCardJobError();
|
|
153
|
+
throw new SDCardJobError(job.description);
|
|
154
154
|
}
|
|
155
155
|
return Number(job.progress);
|
|
156
156
|
}
|
|
@@ -187,7 +187,7 @@ export class VapixAPI {
|
|
|
187
187
|
const agent = this.getClient(options?.proxyParams);
|
|
188
188
|
const resV2 = await agent.get({ path: '/config/rest/time/v2/timeZone', timeout: options?.timeout });
|
|
189
189
|
if (!resV2.ok) {
|
|
190
|
-
throw new
|
|
190
|
+
throw new ErrorWithResponse(resV2);
|
|
191
191
|
}
|
|
192
192
|
const json = await resV2.json();
|
|
193
193
|
const data = timeZoneSchema.parse(json);
|
|
@@ -426,7 +426,7 @@ export class VapixAPI {
|
|
|
426
426
|
});
|
|
427
427
|
const text = (await res.text()).trim().toLowerCase();
|
|
428
428
|
if (text !== 'ok' && !(text.startsWith('error:') && text.substring(7) === '6')) {
|
|
429
|
-
throw new ApplicationAPIError('START',
|
|
429
|
+
throw new ApplicationAPIError('START', text);
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
432
|
async restartApplication(applicationId, options) {
|
|
@@ -441,7 +441,7 @@ export class VapixAPI {
|
|
|
441
441
|
});
|
|
442
442
|
const text = (await res.text()).trim().toLowerCase();
|
|
443
443
|
if (text !== 'ok') {
|
|
444
|
-
throw new ApplicationAPIError('RESTART',
|
|
444
|
+
throw new ApplicationAPIError('RESTART', text);
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
447
|
async stopApplication(applicationId, options) {
|
|
@@ -456,7 +456,7 @@ export class VapixAPI {
|
|
|
456
456
|
});
|
|
457
457
|
const text = (await res.text()).trim().toLowerCase();
|
|
458
458
|
if (text !== 'ok' && !(text.startsWith('error:') && text.substring(7) === '6')) {
|
|
459
|
-
throw new ApplicationAPIError('STOP',
|
|
459
|
+
throw new ApplicationAPIError('STOP', text);
|
|
460
460
|
}
|
|
461
461
|
}
|
|
462
462
|
async installApplication(data, fileName, options) {
|
|
@@ -472,7 +472,7 @@ export class VapixAPI {
|
|
|
472
472
|
timeout: options?.timeout ?? 120000,
|
|
473
473
|
});
|
|
474
474
|
if (!res.ok) {
|
|
475
|
-
throw new
|
|
475
|
+
throw new ErrorWithResponse(res);
|
|
476
476
|
}
|
|
477
477
|
const text = await res.text();
|
|
478
478
|
if (text.length > 5) {
|
package/esm/errors/errors.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
export class ErrorWithResponse extends Error {
|
|
2
|
+
res;
|
|
3
|
+
constructor(res) {
|
|
4
|
+
super(res.statusText);
|
|
5
|
+
this.res = res;
|
|
6
|
+
this.name = 'ErrorWithResponse';
|
|
7
|
+
}
|
|
8
|
+
}
|
|
1
9
|
export class ServiceUnavailableError extends Error {
|
|
2
10
|
constructor() {
|
|
3
11
|
super('Service is unavailable.');
|
|
@@ -35,20 +43,24 @@ export class SettingParameterError extends Error {
|
|
|
35
43
|
}
|
|
36
44
|
}
|
|
37
45
|
export class ApplicationAPIError extends Error {
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
action;
|
|
47
|
+
constructor(action, reason) {
|
|
48
|
+
super(`Error performing application action '${action}': ${reason}`);
|
|
49
|
+
this.action = action;
|
|
40
50
|
this.name = 'ApplicationAPIError';
|
|
41
51
|
}
|
|
42
52
|
}
|
|
43
53
|
export class SDCardActionError extends Error {
|
|
44
|
-
|
|
45
|
-
|
|
54
|
+
action;
|
|
55
|
+
constructor(action, reason) {
|
|
56
|
+
super(`Error performing SD card action '${action}': ${reason}`);
|
|
57
|
+
this.action = action;
|
|
46
58
|
this.name = 'SDCardActionError';
|
|
47
59
|
}
|
|
48
60
|
}
|
|
49
61
|
export class SDCardJobError extends Error {
|
|
50
|
-
constructor() {
|
|
51
|
-
super(
|
|
62
|
+
constructor(reason) {
|
|
63
|
+
super(`Error while fetching SD card job progress: ${reason}`);
|
|
52
64
|
this.name = 'SDCardJobError';
|
|
53
65
|
}
|
|
54
66
|
}
|
|
@@ -118,15 +130,17 @@ export class TimezoneFetchError extends Error {
|
|
|
118
130
|
this.name = 'TimezoneFetchError';
|
|
119
131
|
}
|
|
120
132
|
}
|
|
121
|
-
export class ResetCalibrationError extends
|
|
122
|
-
|
|
123
|
-
|
|
133
|
+
export class ResetCalibrationError extends ErrorWithResponse {
|
|
134
|
+
type;
|
|
135
|
+
constructor(type, res) {
|
|
136
|
+
super(res);
|
|
137
|
+
this.type = type;
|
|
124
138
|
this.name = 'ResetCalibrationError';
|
|
125
139
|
}
|
|
126
140
|
}
|
|
127
|
-
export class ImportSettingsError extends
|
|
128
|
-
constructor(
|
|
129
|
-
super(
|
|
141
|
+
export class ImportSettingsError extends ErrorWithResponse {
|
|
142
|
+
constructor(res) {
|
|
143
|
+
super(res);
|
|
130
144
|
this.name = 'ImportSettingsError';
|
|
131
145
|
}
|
|
132
146
|
}
|
|
@@ -154,9 +168,9 @@ export class ServerError extends Error {
|
|
|
154
168
|
this.name = 'ServerError';
|
|
155
169
|
}
|
|
156
170
|
}
|
|
157
|
-
export class BadRequestError extends
|
|
158
|
-
constructor(
|
|
159
|
-
super(
|
|
160
|
-
this.name = '
|
|
171
|
+
export class BadRequestError extends ErrorWithResponse {
|
|
172
|
+
constructor(res) {
|
|
173
|
+
super(res);
|
|
174
|
+
this.name = 'BadRequestError';
|
|
161
175
|
}
|
|
162
176
|
}
|
package/esm/internal/utils.js
CHANGED
|
@@ -31,12 +31,6 @@ export const isClip = (id) => id?.charAt(0) === 's';
|
|
|
31
31
|
export const isTracker = (id) => id?.charAt(0) === 't';
|
|
32
32
|
export const isPlaylist = (id) => id?.charAt(0) === 'p';
|
|
33
33
|
export const isLoopPlayType = (playType) => playType.includes('LOOP');
|
|
34
|
-
export async function responseStringify(res) {
|
|
35
|
-
return JSON.stringify({
|
|
36
|
-
status: res.status,
|
|
37
|
-
body: await res.text(),
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
34
|
export function pad(num, size) {
|
|
41
35
|
const sign = Math.sign(num) === -1 ? '-' : '';
|
|
42
36
|
return (sign +
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ErrorWithResponse } from '../../errors/errors';
|
|
2
|
+
import { pad } from '../../internal/utils';
|
|
2
3
|
import { cameraDetailsResponseSchema, cameraGuidsResponseSchema, successResponseSchema, } from '../../types/GenetecAgent';
|
|
3
4
|
export class GenetecAgent {
|
|
4
5
|
settings;
|
|
@@ -22,7 +23,7 @@ export class GenetecAgent {
|
|
|
22
23
|
const requestOptions = this.getRequestOptions('GET');
|
|
23
24
|
const res = await this.fetchWithTimeout(new URL(this.baseUrl), requestOptions);
|
|
24
25
|
if (!res.ok) {
|
|
25
|
-
throw new
|
|
26
|
+
throw new ErrorWithResponse(res);
|
|
26
27
|
}
|
|
27
28
|
const responseBody = await res.text();
|
|
28
29
|
const result = await successResponseSchema.safeParseAsync(JSON.parse(responseBody));
|
|
@@ -36,7 +37,7 @@ export class GenetecAgent {
|
|
|
36
37
|
url.searchParams.set('q', 'EntityTypes@Camera');
|
|
37
38
|
const res = await this.fetchWithTimeout(url, requestOptions);
|
|
38
39
|
if (!res.ok) {
|
|
39
|
-
throw new
|
|
40
|
+
throw new ErrorWithResponse(res);
|
|
40
41
|
}
|
|
41
42
|
const responseBody = await res.text();
|
|
42
43
|
const result = await cameraGuidsResponseSchema.safeParseAsync(JSON.parse(responseBody));
|
|
@@ -57,7 +58,7 @@ export class GenetecAgent {
|
|
|
57
58
|
url.searchParams.set('q', chunk.map((item) => `entity=${item.Guid},${params}`).join(','));
|
|
58
59
|
const res = await this.fetchWithTimeout(url, requestOptions);
|
|
59
60
|
if (!res.ok) {
|
|
60
|
-
throw new
|
|
61
|
+
throw new ErrorWithResponse(res);
|
|
61
62
|
}
|
|
62
63
|
const responseBody = await res.text();
|
|
63
64
|
const result = await cameraDetailsResponseSchema.safeParseAsync(JSON.parse(responseBody));
|
|
@@ -77,7 +78,7 @@ export class GenetecAgent {
|
|
|
77
78
|
url.searchParams.set('q', guids.map((guid) => `AddCameraBookmark(${guid},${timeStamp},${bookmarkText})`).join(','));
|
|
78
79
|
const res = await this.fetchWithTimeout(url, requestOptions);
|
|
79
80
|
if (!res.ok) {
|
|
80
|
-
throw new
|
|
81
|
+
throw new ErrorWithResponse(res);
|
|
81
82
|
}
|
|
82
83
|
const responseBody = await res.text();
|
|
83
84
|
const result = await successResponseSchema.safeParseAsync(JSON.parse(responseBody));
|
|
@@ -14,6 +14,8 @@ const apiFlightDataSchema = z.object({
|
|
|
14
14
|
priorityListed: z.boolean(),
|
|
15
15
|
autoSelectionIgnored: z.boolean(),
|
|
16
16
|
signalQuality: z.number(),
|
|
17
|
+
emitterCategorySet: z.number().default(4),
|
|
18
|
+
emitterCategory: z.number().default(3),
|
|
17
19
|
emergencyState: z.boolean(),
|
|
18
20
|
emergencyStatusMessage: z.string(),
|
|
19
21
|
});
|
package/package.json
CHANGED
package/types/errors/errors.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { TResponse } from '../internal/types';
|
|
2
|
+
export declare class ErrorWithResponse<T extends TResponse> extends Error {
|
|
3
|
+
res: T;
|
|
4
|
+
constructor(res: T);
|
|
5
|
+
}
|
|
1
6
|
export declare class ServiceUnavailableError extends Error {
|
|
2
7
|
constructor();
|
|
3
8
|
}
|
|
@@ -18,14 +23,16 @@ export declare class SettingParameterError extends Error {
|
|
|
18
23
|
}
|
|
19
24
|
type TApplicationAPIAction = 'START' | 'RESTART' | 'STOP' | 'INSTALL';
|
|
20
25
|
export declare class ApplicationAPIError extends Error {
|
|
21
|
-
|
|
26
|
+
action: TApplicationAPIAction;
|
|
27
|
+
constructor(action: TApplicationAPIAction, reason: string);
|
|
22
28
|
}
|
|
23
29
|
type TSDCardAction = 'MOUNT' | 'UNMOUNT';
|
|
24
30
|
export declare class SDCardActionError extends Error {
|
|
25
|
-
|
|
31
|
+
action: TSDCardAction;
|
|
32
|
+
constructor(action: TSDCardAction, reason: string);
|
|
26
33
|
}
|
|
27
34
|
export declare class SDCardJobError extends Error {
|
|
28
|
-
constructor();
|
|
35
|
+
constructor(reason: string);
|
|
29
36
|
}
|
|
30
37
|
type TMaxFPSErrorType = 'MALFORMED_REPLY' | 'CHANNEL_NOT_FOUND' | 'CAPTURE_MODE_NOT_FOUND' | 'FPS_NOT_SPECIFIED';
|
|
31
38
|
export declare class MaxFPSError extends Error {
|
|
@@ -59,11 +66,12 @@ export declare class TimezoneFetchError extends Error {
|
|
|
59
66
|
constructor(err: unknown);
|
|
60
67
|
}
|
|
61
68
|
type TCalibrationType = 'PTZ' | 'FOCUS';
|
|
62
|
-
export declare class ResetCalibrationError extends
|
|
63
|
-
|
|
69
|
+
export declare class ResetCalibrationError<T extends TResponse> extends ErrorWithResponse<T> {
|
|
70
|
+
type: TCalibrationType;
|
|
71
|
+
constructor(type: TCalibrationType, res: T);
|
|
64
72
|
}
|
|
65
|
-
export declare class ImportSettingsError extends
|
|
66
|
-
constructor(
|
|
73
|
+
export declare class ImportSettingsError<T extends TResponse> extends ErrorWithResponse<T> {
|
|
74
|
+
constructor(res: T);
|
|
67
75
|
}
|
|
68
76
|
export declare class CannotSetCoordsInAutoModeError extends Error {
|
|
69
77
|
constructor();
|
|
@@ -77,7 +85,7 @@ export declare class InvalidAltitudeError extends Error {
|
|
|
77
85
|
export declare class ServerError extends Error {
|
|
78
86
|
constructor();
|
|
79
87
|
}
|
|
80
|
-
export declare class BadRequestError extends
|
|
81
|
-
constructor(
|
|
88
|
+
export declare class BadRequestError<T extends TResponse> extends ErrorWithResponse<T> {
|
|
89
|
+
constructor(res: T);
|
|
82
90
|
}
|
|
83
91
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TPlaylistPlayType } from '../types/CamSwitcherAPI';
|
|
2
|
-
import { TParameters
|
|
2
|
+
import { TParameters } from './types';
|
|
3
3
|
export declare const addParametersToPath: (path: string, params?: TParameters) => string;
|
|
4
4
|
export declare const paramToUrl: (params?: TParameters) => string;
|
|
5
5
|
export declare const arrayToUrl: (arr: string | string[]) => string;
|
|
@@ -9,6 +9,5 @@ export declare const isClip: (id?: string) => boolean;
|
|
|
9
9
|
export declare const isTracker: (id?: string) => boolean;
|
|
10
10
|
export declare const isPlaylist: (id?: string) => boolean;
|
|
11
11
|
export declare const isLoopPlayType: (playType: TPlaylistPlayType) => boolean;
|
|
12
|
-
export declare function responseStringify(res: TResponse): Promise<string>;
|
|
13
12
|
export declare function pad(num: number, size: number): string;
|
|
14
13
|
export declare function isNullish<T>(value: T | undefined | null): value is undefined | null;
|
|
@@ -13,6 +13,8 @@ declare const apiFlightDataSchema: z.ZodObject<{
|
|
|
13
13
|
priorityListed: z.ZodBoolean;
|
|
14
14
|
autoSelectionIgnored: z.ZodBoolean;
|
|
15
15
|
signalQuality: z.ZodNumber;
|
|
16
|
+
emitterCategorySet: z.ZodDefault<z.ZodNumber>;
|
|
17
|
+
emitterCategory: z.ZodDefault<z.ZodNumber>;
|
|
16
18
|
emergencyState: z.ZodBoolean;
|
|
17
19
|
emergencyStatusMessage: z.ZodString;
|
|
18
20
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -29,6 +31,8 @@ declare const apiFlightDataSchema: z.ZodObject<{
|
|
|
29
31
|
priorityListed: boolean;
|
|
30
32
|
autoSelectionIgnored: boolean;
|
|
31
33
|
signalQuality: number;
|
|
34
|
+
emitterCategorySet: number;
|
|
35
|
+
emitterCategory: number;
|
|
32
36
|
emergencyState: boolean;
|
|
33
37
|
emergencyStatusMessage: string;
|
|
34
38
|
}, {
|
|
@@ -47,6 +51,8 @@ declare const apiFlightDataSchema: z.ZodObject<{
|
|
|
47
51
|
signalQuality: number;
|
|
48
52
|
emergencyState: boolean;
|
|
49
53
|
emergencyStatusMessage: string;
|
|
54
|
+
emitterCategorySet?: number | undefined;
|
|
55
|
+
emitterCategory?: number | undefined;
|
|
50
56
|
}>;
|
|
51
57
|
declare const apiUserSchema: z.ZodObject<{
|
|
52
58
|
userId: z.ZodString;
|
|
@@ -707,6 +713,8 @@ declare const ptrEventsDataSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
|
|
|
707
713
|
priorityListed: z.ZodBoolean;
|
|
708
714
|
autoSelectionIgnored: z.ZodBoolean;
|
|
709
715
|
signalQuality: z.ZodNumber;
|
|
716
|
+
emitterCategorySet: z.ZodDefault<z.ZodNumber>;
|
|
717
|
+
emitterCategory: z.ZodDefault<z.ZodNumber>;
|
|
710
718
|
emergencyState: z.ZodBoolean;
|
|
711
719
|
emergencyStatusMessage: z.ZodString;
|
|
712
720
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -723,6 +731,8 @@ declare const ptrEventsDataSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
|
|
|
723
731
|
priorityListed: boolean;
|
|
724
732
|
autoSelectionIgnored: boolean;
|
|
725
733
|
signalQuality: number;
|
|
734
|
+
emitterCategorySet: number;
|
|
735
|
+
emitterCategory: number;
|
|
726
736
|
emergencyState: boolean;
|
|
727
737
|
emergencyStatusMessage: string;
|
|
728
738
|
}, {
|
|
@@ -741,6 +751,8 @@ declare const ptrEventsDataSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
|
|
|
741
751
|
signalQuality: number;
|
|
742
752
|
emergencyState: boolean;
|
|
743
753
|
emergencyStatusMessage: string;
|
|
754
|
+
emitterCategorySet?: number | undefined;
|
|
755
|
+
emitterCategory?: number | undefined;
|
|
744
756
|
}>, "many">;
|
|
745
757
|
}, "strip", z.ZodTypeAny, {
|
|
746
758
|
type: "FLIGHT_LIST";
|
|
@@ -758,6 +770,8 @@ declare const ptrEventsDataSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
|
|
|
758
770
|
priorityListed: boolean;
|
|
759
771
|
autoSelectionIgnored: boolean;
|
|
760
772
|
signalQuality: number;
|
|
773
|
+
emitterCategorySet: number;
|
|
774
|
+
emitterCategory: number;
|
|
761
775
|
emergencyState: boolean;
|
|
762
776
|
emergencyStatusMessage: string;
|
|
763
777
|
}[];
|
|
@@ -779,6 +793,8 @@ declare const ptrEventsDataSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
|
|
|
779
793
|
signalQuality: number;
|
|
780
794
|
emergencyState: boolean;
|
|
781
795
|
emergencyStatusMessage: string;
|
|
796
|
+
emitterCategorySet?: number | undefined;
|
|
797
|
+
emitterCategory?: number | undefined;
|
|
782
798
|
}[];
|
|
783
799
|
}>, z.ZodObject<{
|
|
784
800
|
type: z.ZodLiteral<"USER_ACTION">;
|
|
@@ -972,6 +988,8 @@ export declare const ptrEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
972
988
|
priorityListed: z.ZodBoolean;
|
|
973
989
|
autoSelectionIgnored: z.ZodBoolean;
|
|
974
990
|
signalQuality: z.ZodNumber;
|
|
991
|
+
emitterCategorySet: z.ZodDefault<z.ZodNumber>;
|
|
992
|
+
emitterCategory: z.ZodDefault<z.ZodNumber>;
|
|
975
993
|
emergencyState: z.ZodBoolean;
|
|
976
994
|
emergencyStatusMessage: z.ZodString;
|
|
977
995
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -988,6 +1006,8 @@ export declare const ptrEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
988
1006
|
priorityListed: boolean;
|
|
989
1007
|
autoSelectionIgnored: boolean;
|
|
990
1008
|
signalQuality: number;
|
|
1009
|
+
emitterCategorySet: number;
|
|
1010
|
+
emitterCategory: number;
|
|
991
1011
|
emergencyState: boolean;
|
|
992
1012
|
emergencyStatusMessage: string;
|
|
993
1013
|
}, {
|
|
@@ -1006,6 +1026,8 @@ export declare const ptrEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
1006
1026
|
signalQuality: number;
|
|
1007
1027
|
emergencyState: boolean;
|
|
1008
1028
|
emergencyStatusMessage: string;
|
|
1029
|
+
emitterCategorySet?: number | undefined;
|
|
1030
|
+
emitterCategory?: number | undefined;
|
|
1009
1031
|
}>, "many">;
|
|
1010
1032
|
}, "strip", z.ZodTypeAny, {
|
|
1011
1033
|
type: "FLIGHT_LIST";
|
|
@@ -1023,6 +1045,8 @@ export declare const ptrEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
1023
1045
|
priorityListed: boolean;
|
|
1024
1046
|
autoSelectionIgnored: boolean;
|
|
1025
1047
|
signalQuality: number;
|
|
1048
|
+
emitterCategorySet: number;
|
|
1049
|
+
emitterCategory: number;
|
|
1026
1050
|
emergencyState: boolean;
|
|
1027
1051
|
emergencyStatusMessage: string;
|
|
1028
1052
|
}[];
|
|
@@ -1044,6 +1068,8 @@ export declare const ptrEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
1044
1068
|
signalQuality: number;
|
|
1045
1069
|
emergencyState: boolean;
|
|
1046
1070
|
emergencyStatusMessage: string;
|
|
1071
|
+
emitterCategorySet?: number | undefined;
|
|
1072
|
+
emitterCategory?: number | undefined;
|
|
1047
1073
|
}[];
|
|
1048
1074
|
}>, z.ZodObject<{
|
|
1049
1075
|
type: z.ZodLiteral<"USER_ACTION">;
|
|
@@ -1213,6 +1239,8 @@ export declare const ptrEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
1213
1239
|
priorityListed: boolean;
|
|
1214
1240
|
autoSelectionIgnored: boolean;
|
|
1215
1241
|
signalQuality: number;
|
|
1242
|
+
emitterCategorySet: number;
|
|
1243
|
+
emitterCategory: number;
|
|
1216
1244
|
emergencyState: boolean;
|
|
1217
1245
|
emergencyStatusMessage: string;
|
|
1218
1246
|
}[];
|
|
@@ -1283,6 +1311,8 @@ export declare const ptrEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
1283
1311
|
signalQuality: number;
|
|
1284
1312
|
emergencyState: boolean;
|
|
1285
1313
|
emergencyStatusMessage: string;
|
|
1314
|
+
emitterCategorySet?: number | undefined;
|
|
1315
|
+
emitterCategory?: number | undefined;
|
|
1286
1316
|
}[];
|
|
1287
1317
|
} | {
|
|
1288
1318
|
params: {
|
|
@@ -1371,6 +1401,8 @@ export declare const ptrEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
1371
1401
|
priorityListed: z.ZodBoolean;
|
|
1372
1402
|
autoSelectionIgnored: z.ZodBoolean;
|
|
1373
1403
|
signalQuality: z.ZodNumber;
|
|
1404
|
+
emitterCategorySet: z.ZodDefault<z.ZodNumber>;
|
|
1405
|
+
emitterCategory: z.ZodDefault<z.ZodNumber>;
|
|
1374
1406
|
emergencyState: z.ZodBoolean;
|
|
1375
1407
|
emergencyStatusMessage: z.ZodString;
|
|
1376
1408
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -1387,6 +1419,8 @@ export declare const ptrEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
1387
1419
|
priorityListed: boolean;
|
|
1388
1420
|
autoSelectionIgnored: boolean;
|
|
1389
1421
|
signalQuality: number;
|
|
1422
|
+
emitterCategorySet: number;
|
|
1423
|
+
emitterCategory: number;
|
|
1390
1424
|
emergencyState: boolean;
|
|
1391
1425
|
emergencyStatusMessage: string;
|
|
1392
1426
|
}, {
|
|
@@ -1405,6 +1439,8 @@ export declare const ptrEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
1405
1439
|
signalQuality: number;
|
|
1406
1440
|
emergencyState: boolean;
|
|
1407
1441
|
emergencyStatusMessage: string;
|
|
1442
|
+
emitterCategorySet?: number | undefined;
|
|
1443
|
+
emitterCategory?: number | undefined;
|
|
1408
1444
|
}>, "many">;
|
|
1409
1445
|
}, "strip", z.ZodTypeAny, {
|
|
1410
1446
|
type: "FLIGHT_LIST";
|
|
@@ -1422,6 +1458,8 @@ export declare const ptrEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
1422
1458
|
priorityListed: boolean;
|
|
1423
1459
|
autoSelectionIgnored: boolean;
|
|
1424
1460
|
signalQuality: number;
|
|
1461
|
+
emitterCategorySet: number;
|
|
1462
|
+
emitterCategory: number;
|
|
1425
1463
|
emergencyState: boolean;
|
|
1426
1464
|
emergencyStatusMessage: string;
|
|
1427
1465
|
}[];
|
|
@@ -1443,6 +1481,8 @@ export declare const ptrEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
1443
1481
|
signalQuality: number;
|
|
1444
1482
|
emergencyState: boolean;
|
|
1445
1483
|
emergencyStatusMessage: string;
|
|
1484
|
+
emitterCategorySet?: number | undefined;
|
|
1485
|
+
emitterCategory?: number | undefined;
|
|
1446
1486
|
}[];
|
|
1447
1487
|
}>, z.ZodObject<{
|
|
1448
1488
|
type: z.ZodLiteral<"USER_ACTION">;
|