camstreamerlib 4.0.0-beta.61 → 4.0.0-beta.62

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.
@@ -83,7 +83,7 @@ class CamOverlayAPI {
83
83
  throw new errors_1.ServiceNotFoundError();
84
84
  }
85
85
  else {
86
- throw new Error(await (0, utils_1.responseStringify)(res));
86
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(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 Error(await (0, utils_1.responseStringify)(res));
168
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(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 Error(await (0, utils_1.responseStringify)(res));
178
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(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 Error(await (0, utils_1.responseStringify)(res));
188
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(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 Error(await (0, utils_1.responseStringify)(res));
198
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(res));
199
199
  }
200
200
  }
201
201
  async parseBlobResponse(response) {
@@ -1,6 +1,7 @@
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
6
  const utils_1 = require("./internal/utils");
6
7
  const CamScripterAPI_1 = require("./types/CamScripterAPI");
@@ -63,7 +64,7 @@ class CamScripterAPI {
63
64
  return await res.json();
64
65
  }
65
66
  else {
66
- throw new Error(await (0, utils_1.responseStringify)(res));
67
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(res));
67
68
  }
68
69
  }
69
70
  async _post(path, data, parameters, options, headers) {
@@ -73,7 +74,7 @@ class CamScripterAPI {
73
74
  return await res.json();
74
75
  }
75
76
  else {
76
- throw new Error(await (0, utils_1.responseStringify)(res));
77
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(res));
77
78
  }
78
79
  }
79
80
  }
@@ -76,7 +76,7 @@ class CamStreamerAPI {
76
76
  return await res.json();
77
77
  }
78
78
  else {
79
- throw new Error(await (0, utils_1.responseStringify)(res));
79
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(res));
80
80
  }
81
81
  }
82
82
  }
@@ -263,7 +263,7 @@ class CamSwitcherAPI {
263
263
  return await res.json();
264
264
  }
265
265
  else {
266
- throw new Error(await (0, utils_1.responseStringify)(res));
266
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(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 Error(await (0, utils_1.responseStringify)(res));
276
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(res));
277
277
  }
278
278
  }
279
279
  setParamFromCameraJSON(paramName, data, options) {
@@ -189,7 +189,7 @@ class PlaneTrackerAPI {
189
189
  return await res.json();
190
190
  }
191
191
  else {
192
- throw new Error(await (0, utils_1.responseStringify)(res));
192
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(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 Error(await (0, utils_1.responseStringify)(res));
202
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(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 Error(await (0, utils_1.responseStringify)(res));
227
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(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 Error(await (0, utils_1.responseStringify)(res));
243
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(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 Error(await (0, utils_1.responseStringify)(res));
26
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(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 Error(await (0, utils_1.responseStringify)(res));
36
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(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 Error(await (0, utils_1.responseStringify)(res));
62
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(res));
63
63
  }
64
64
  return await res.text();
65
65
  }
@@ -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 Error(await (0, utils_1.responseStringify)(resV2));
193
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(resV2));
194
194
  }
195
195
  const json = await resV2.json();
196
196
  const data = VapixAPI_1.timeZoneSchema.parse(json);
@@ -475,7 +475,7 @@ class VapixAPI {
475
475
  timeout: options?.timeout ?? 120000,
476
476
  });
477
477
  if (!res.ok) {
478
- throw new Error(await (0, utils_1.responseStringify)(res));
478
+ throw new errors_1.GeneralResponseNotOKError(await (0, utils_1.responseStringify)(res));
479
479
  }
480
480
  const text = await res.text();
481
481
  if (text.length > 5) {
@@ -1,6 +1,7 @@
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.GeneralResponseNotOKError = 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;
4
+ const utils_1 = require("../internal/utils");
4
5
  class ServiceUnavailableError extends Error {
5
6
  constructor() {
6
7
  super('Service is unavailable.');
@@ -189,3 +190,11 @@ class BadRequestError extends Error {
189
190
  }
190
191
  }
191
192
  exports.BadRequestError = BadRequestError;
193
+ class GeneralResponseNotOKError extends Error {
194
+ static messageSchema = utils_1.stringifiedResponseSchema;
195
+ constructor(stringifiedRes) {
196
+ super(stringifiedRes);
197
+ this.name = 'GeneralResponseNotOKError';
198
+ }
199
+ }
200
+ exports.GeneralResponseNotOKError = GeneralResponseNotOKError;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isNullish = exports.pad = exports.responseStringify = exports.isLoopPlayType = exports.isPlaylist = exports.isTracker = exports.isClip = exports.isStream = exports.isCamera = exports.arrayToUrl = exports.paramToUrl = exports.addParametersToPath = void 0;
6
+ exports.isNullish = exports.pad = exports.stringifiedResponseSchema = exports.responseStringify = exports.isLoopPlayType = exports.isPlaylist = exports.isTracker = exports.isClip = exports.isStream = exports.isCamera = exports.arrayToUrl = exports.paramToUrl = exports.addParametersToPath = void 0;
7
+ const zod_1 = __importDefault(require("zod"));
4
8
  const addParametersToPath = (path, params) => {
5
9
  if (params === undefined || Object.keys(params).length === 0) {
6
10
  return path;
@@ -50,6 +54,10 @@ async function responseStringify(res) {
50
54
  });
51
55
  }
52
56
  exports.responseStringify = responseStringify;
57
+ exports.stringifiedResponseSchema = zod_1.default.object({
58
+ status: zod_1.default.number(),
59
+ body: zod_1.default.string(),
60
+ });
53
61
  function pad(num, size) {
54
62
  const sign = Math.sign(num) === -1 ? '-' : '';
55
63
  return (sign +
@@ -1,5 +1,5 @@
1
1
  import { paramToUrl, responseStringify } from './internal/utils';
2
- import { ParsingBlobError, ServiceNotFoundError, StorageDataFetchError } from './errors/errors';
2
+ import { ParsingBlobError, GeneralResponseNotOKError, 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 Error(await responseStringify(res));
83
+ throw new GeneralResponseNotOKError(await responseStringify(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 Error(await responseStringify(res));
165
+ throw new GeneralResponseNotOKError(await responseStringify(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 Error(await responseStringify(res));
175
+ throw new GeneralResponseNotOKError(await responseStringify(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 Error(await responseStringify(res));
185
+ throw new GeneralResponseNotOKError(await responseStringify(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 Error(await responseStringify(res));
195
+ throw new GeneralResponseNotOKError(await responseStringify(res));
196
196
  }
197
197
  }
198
198
  async parseBlobResponse(response) {
@@ -1,3 +1,4 @@
1
+ import { GeneralResponseNotOKError } from './errors/errors';
1
2
  import { ProxyClient } from './internal/ProxyClient';
2
3
  import { responseStringify } from './internal/utils';
3
4
  import { cameraTimeResponseSchema, nodeStateSchema, packageInfoListSchema, cameraStorageSchema, } from './types/CamScripterAPI';
@@ -60,7 +61,7 @@ export class CamScripterAPI {
60
61
  return await res.json();
61
62
  }
62
63
  else {
63
- throw new Error(await responseStringify(res));
64
+ throw new GeneralResponseNotOKError(await responseStringify(res));
64
65
  }
65
66
  }
66
67
  async _post(path, data, parameters, options, headers) {
@@ -70,7 +71,7 @@ export class CamScripterAPI {
70
71
  return await res.json();
71
72
  }
72
73
  else {
73
- throw new Error(await responseStringify(res));
74
+ throw new GeneralResponseNotOKError(await responseStringify(res));
74
75
  }
75
76
  }
76
77
  }
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
  import { ProxyClient } from './internal/ProxyClient';
3
3
  import { responseStringify } from './internal/utils';
4
4
  import { cameraStreamSchema } from './types/CamStreamerAPI';
5
- import { UtcTimeFetchError, WsAuthorizationError } from './errors/errors';
5
+ import { GeneralResponseNotOKError, UtcTimeFetchError, WsAuthorizationError } from './errors/errors';
6
6
  const BASE_PATH = '/local/camstreamer';
7
7
  export class CamStreamerAPI {
8
8
  client;
@@ -73,7 +73,7 @@ export class CamStreamerAPI {
73
73
  return await res.json();
74
74
  }
75
75
  else {
76
- throw new Error(await responseStringify(res));
76
+ throw new GeneralResponseNotOKError(await responseStringify(res));
77
77
  }
78
78
  }
79
79
  }
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { AddNewClipError, JsonParseError, ParameterNotFoundError } from './errors/errors';
2
+ import { AddNewClipError, JsonParseError, ParameterNotFoundError, GeneralResponseNotOKError } from './errors/errors';
3
3
  import { isClip, isNullish, responseStringify } from './internal/utils';
4
4
  import { storageInfoListSchema, outputInfoSchema, audioPushInfoSchema, clipListSchema, playlistQueueSchema, streamSaveLoadSchema, clipSaveLoadSchema, playlistSaveLoadSchema, trackerSaveLoadSchema, secondaryAudioSettingsSchema, globalAudioSettingsSchema, } from './types/CamSwitcherAPI';
5
5
  import { networkCameraListSchema, } from './types/common';
@@ -260,7 +260,7 @@ export class CamSwitcherAPI {
260
260
  return await res.json();
261
261
  }
262
262
  else {
263
- throw new Error(await responseStringify(res));
263
+ throw new GeneralResponseNotOKError(await responseStringify(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 Error(await responseStringify(res));
273
+ throw new GeneralResponseNotOKError(await responseStringify(res));
274
274
  }
275
275
  }
276
276
  setParamFromCameraJSON(paramName, data, options) {
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { paramToUrl, responseStringify } 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, GeneralResponseNotOKError, } from './errors/errors';
5
5
  import { ProxyClient } from './internal/ProxyClient';
6
6
  import { cameraListSchema } from './types/GenetecAgent';
7
7
  const BASE_PATH = '/local/planetracker';
@@ -186,7 +186,7 @@ export class PlaneTrackerAPI {
186
186
  return await res.json();
187
187
  }
188
188
  else {
189
- throw new Error(await responseStringify(res));
189
+ throw new GeneralResponseNotOKError(await responseStringify(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 Error(await responseStringify(res));
199
+ throw new GeneralResponseNotOKError(await responseStringify(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 Error(await responseStringify(res));
224
+ throw new GeneralResponseNotOKError(await responseStringify(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 Error(await responseStringify(res));
240
+ throw new GeneralResponseNotOKError(await responseStringify(res));
241
241
  }
242
242
  }
243
243
  }
package/esm/VapixAPI.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { arrayToUrl, isNullish, paramToUrl, responseStringify } from './internal/utils';
2
2
  import { sdCardWatchedStatuses, APP_IDS, maxFpsResponseSchema, dateTimeinfoSchema, audioDeviceRequestSchema, audioSampleRatesResponseSchema, timeZoneSchema, getPortsResponseSchema, guardTourSchema, ptzOverviewSchema, cameraPTZItemDataSchema, applicationListSchema, sdCardInfoSchema, } from './types/VapixAPI';
3
- import { ApplicationAPIError, MaxFPSError, NoDeviceInfoError, PtzNotSupportedError, SDCardActionError, SDCardJobError, SettingParameterError, TimezoneFetchError, TimezoneNotSetupError, } from './errors/errors';
3
+ import { ApplicationAPIError, MaxFPSError, NoDeviceInfoError, PtzNotSupportedError, GeneralResponseNotOKError, 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 Error(await responseStringify(res));
23
+ throw new GeneralResponseNotOKError(await responseStringify(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 Error(await responseStringify(res));
33
+ throw new GeneralResponseNotOKError(await responseStringify(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 Error(await responseStringify(res));
59
+ throw new GeneralResponseNotOKError(await responseStringify(res));
60
60
  }
61
61
  return await res.text();
62
62
  }
@@ -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 Error(await responseStringify(resV2));
190
+ throw new GeneralResponseNotOKError(await responseStringify(resV2));
191
191
  }
192
192
  const json = await resV2.json();
193
193
  const data = timeZoneSchema.parse(json);
@@ -472,7 +472,7 @@ export class VapixAPI {
472
472
  timeout: options?.timeout ?? 120000,
473
473
  });
474
474
  if (!res.ok) {
475
- throw new Error(await responseStringify(res));
475
+ throw new GeneralResponseNotOKError(await responseStringify(res));
476
476
  }
477
477
  const text = await res.text();
478
478
  if (text.length > 5) {
@@ -1,3 +1,4 @@
1
+ import { stringifiedResponseSchema } from '../internal/utils';
1
2
  export class ServiceUnavailableError extends Error {
2
3
  constructor() {
3
4
  super('Service is unavailable.');
@@ -160,3 +161,10 @@ export class BadRequestError extends Error {
160
161
  this.name = 'UnknownError';
161
162
  }
162
163
  }
164
+ export class GeneralResponseNotOKError extends Error {
165
+ static messageSchema = stringifiedResponseSchema;
166
+ constructor(stringifiedRes) {
167
+ super(stringifiedRes);
168
+ this.name = 'GeneralResponseNotOKError';
169
+ }
170
+ }
@@ -1,3 +1,4 @@
1
+ import z from 'zod';
1
2
  export const addParametersToPath = (path, params) => {
2
3
  if (params === undefined || Object.keys(params).length === 0) {
3
4
  return path;
@@ -37,6 +38,10 @@ export async function responseStringify(res) {
37
38
  body: await res.text(),
38
39
  });
39
40
  }
41
+ export const stringifiedResponseSchema = z.object({
42
+ status: z.number(),
43
+ body: z.string(),
44
+ });
40
45
  export function pad(num, size) {
41
46
  const sign = Math.sign(num) === -1 ? '-' : '';
42
47
  return (sign +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camstreamerlib",
3
- "version": "4.0.0-beta.61",
3
+ "version": "4.0.0-beta.62",
4
4
  "description": "Helper library for CamStreamer ACAP applications.",
5
5
  "prettier": "@camstreamer/prettier-config",
6
6
  "engine": {
@@ -80,4 +80,17 @@ export declare class ServerError extends Error {
80
80
  export declare class BadRequestError extends Error {
81
81
  constructor(err: unknown);
82
82
  }
83
+ export declare class GeneralResponseNotOKError extends Error {
84
+ static messageSchema: import("zod").ZodObject<{
85
+ status: import("zod").ZodNumber;
86
+ body: import("zod").ZodString;
87
+ }, "strip", import("zod").ZodTypeAny, {
88
+ status: number;
89
+ body: string;
90
+ }, {
91
+ status: number;
92
+ body: string;
93
+ }>;
94
+ constructor(stringifiedRes: string);
95
+ }
83
96
  export {};
@@ -1,3 +1,4 @@
1
+ import z from 'zod';
1
2
  import { TPlaylistPlayType } from '../types/CamSwitcherAPI';
2
3
  import { TParameters, TResponse } from './types';
3
4
  export declare const addParametersToPath: (path: string, params?: TParameters) => string;
@@ -10,5 +11,15 @@ export declare const isTracker: (id?: string) => boolean;
10
11
  export declare const isPlaylist: (id?: string) => boolean;
11
12
  export declare const isLoopPlayType: (playType: TPlaylistPlayType) => boolean;
12
13
  export declare function responseStringify(res: TResponse): Promise<string>;
14
+ export declare const stringifiedResponseSchema: z.ZodObject<{
15
+ status: z.ZodNumber;
16
+ body: z.ZodString;
17
+ }, "strip", z.ZodTypeAny, {
18
+ status: number;
19
+ body: string;
20
+ }, {
21
+ status: number;
22
+ body: string;
23
+ }>;
13
24
  export declare function pad(num: number, size: number): string;
14
25
  export declare function isNullish<T>(value: T | undefined | null): value is undefined | null;