camstreamerlib 4.0.0-beta.40 → 4.0.0-beta.41

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.
@@ -25,38 +25,45 @@ class PlaneTrackerAPI {
25
25
  }
26
26
  async resetPtzCalibration(options) {
27
27
  const agent = this.getClient(options?.proxyParams);
28
- await agent.get({
28
+ const res = await agent.get({
29
29
  path: `${BASE_PATH}/package/resetPtzCalibration.cgi`,
30
30
  parameters: this.apiUser,
31
31
  timeout: options?.timeout,
32
32
  });
33
+ if (!res.ok) {
34
+ throw new errors_1.ResetCalibrationError('PTZ', await (0, utils_1.responseStringify)(res));
35
+ }
33
36
  }
34
37
  async resetFocusCalibration(options) {
35
38
  const agent = this.getClient(options?.proxyParams);
36
- await agent.get({
39
+ const res = await agent.get({
37
40
  path: `${BASE_PATH}/package/resetFocusCalibration.cgi`,
38
41
  parameters: this.apiUser,
39
42
  timeout: options?.timeout,
40
43
  });
44
+ if (!res.ok) {
45
+ throw new errors_1.ResetCalibrationError('FOCUS', await (0, utils_1.responseStringify)(res));
46
+ }
41
47
  }
42
48
  async serverRunCheck(options) {
43
49
  const agent = this.getClient(options?.proxyParams);
44
- await agent.get({ path: `${BASE_PATH}/package/serverRunCheck.cgi`, timeout: options?.timeout });
50
+ return await agent.get({ path: `${BASE_PATH}/package/serverRunCheck.cgi`, timeout: options?.timeout });
45
51
  }
46
52
  async getLiveViewAlias(rtspUrl, options) {
47
53
  const agent = this.getClient(options?.proxyParams);
48
- await agent.get({
54
+ const res = await agent.get({
49
55
  path: `${BASE_PATH}/getLiveViewAlias.cgi`,
50
56
  parameters: { rtsp_url: rtspUrl },
51
57
  timeout: options?.timeout,
52
58
  });
59
+ return PlaneTrackerAPI_1.wsAliasResponseSchema.parse(await res.json());
53
60
  }
54
61
  async fetchCameraSettings(options) {
55
62
  const res = await this._getJson(`${BASE_PATH}/package_camera_settings.cgi`, { action: 'get' }, options);
56
63
  return PlaneTrackerAPI_1.cameraSettingsSchema.parse(res);
57
64
  }
58
65
  async setCameraSettings(settings, options) {
59
- await this._postJsonEncoded(`${BASE_PATH}/package_camera_settings.cgi`, settings, {
66
+ return await this._postJsonEncoded(`${BASE_PATH}/package_camera_settings.cgi`, settings, {
60
67
  action: 'set',
61
68
  }, options);
62
69
  }
@@ -69,12 +76,15 @@ class PlaneTrackerAPI {
69
76
  }
70
77
  async importAppSettings(dataType, formData, options) {
71
78
  const agent = this.getClient(options?.proxyParams);
72
- await agent.post({
79
+ const res = await agent.post({
73
80
  path: `${BASE_PATH}/package_data.cgi`,
74
81
  data: formData,
75
82
  parameters: { action: 'IMPORT', dataType },
76
83
  timeout: options?.timeout,
77
84
  });
85
+ if (!res.ok) {
86
+ throw new errors_1.ImportSettingsError(await (0, utils_1.responseStringify)(res));
87
+ }
78
88
  }
79
89
  async fetchFlightInfo(icao, options) {
80
90
  const res = await this._getJson(`${BASE_PATH}/package/flightInfo.cgi`, { icao }, options);
@@ -108,21 +118,21 @@ class PlaneTrackerAPI {
108
118
  return PlaneTrackerAPI_1.priorityListSchema.parse(res);
109
119
  }
110
120
  async setPriorityList(priorityList, options) {
111
- await this._postJsonEncoded(`${BASE_PATH}/package/setPriorityList.cgi`, { priorityList }, this.apiUser, options);
121
+ return await this._postJsonEncoded(`${BASE_PATH}/package/setPriorityList.cgi`, { priorityList }, this.apiUser, options);
112
122
  }
113
123
  async getWhiteList(options) {
114
124
  const res = await this._getJson(`${BASE_PATH}/package/getWhiteList.cgi`, undefined, options);
115
125
  return PlaneTrackerAPI_1.whiteListSchema.parse(res);
116
126
  }
117
127
  async setWhiteList(whiteList, options) {
118
- await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, { whiteList }, this.apiUser, options);
128
+ return await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, { whiteList }, this.apiUser, options);
119
129
  }
120
130
  async getBlackList(options) {
121
131
  const res = await this._getJson(`${BASE_PATH}/package/getBlackList.cgi`, undefined, options);
122
132
  return PlaneTrackerAPI_1.blackListSchema.parse(res);
123
133
  }
124
134
  async setBlackList(blackList, options) {
125
- await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, { blackList }, this.apiUser, options);
135
+ return await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, { blackList }, this.apiUser, options);
126
136
  }
127
137
  async fetchMapInfo(options) {
128
138
  const res = await this._getJson(`${BASE_PATH}/package/getMapInfo.cgi`, undefined, options);
@@ -137,14 +147,14 @@ class PlaneTrackerAPI {
137
147
  }
138
148
  async goToCoordinates(lat, lon, alt, options) {
139
149
  const agent = this.getClient(options?.proxyParams);
140
- await agent.get({
150
+ return await agent.get({
141
151
  path: `${BASE_PATH}/package/goToCoordinates.cgi`,
142
152
  parameters: { lat, lon, alt, ...this.apiUser },
143
153
  timeout: options?.timeout,
144
154
  });
145
155
  }
146
156
  async checkGenetecConnection(params, options) {
147
- await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, '', params, options);
157
+ return await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, '', params, options);
148
158
  }
149
159
  async getGenetecCameraList(params, options) {
150
160
  const res = await this._postUrlEncoded(`${BASE_PATH}/package/getGenetecCameraList.cgi`, '', params, options);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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.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
4
  class ServiceUnavailableError extends Error {
5
5
  constructor() {
6
6
  super('Service is unavailable.');
@@ -140,3 +140,17 @@ class TimezoneFetchError extends Error {
140
140
  }
141
141
  }
142
142
  exports.TimezoneFetchError = TimezoneFetchError;
143
+ class ResetCalibrationError extends Error {
144
+ constructor(type, err) {
145
+ super('Error resetting ' + type.toLowerCase() + ' calibration: ' + err);
146
+ this.name = 'ResetCalibrationError';
147
+ }
148
+ }
149
+ exports.ResetCalibrationError = ResetCalibrationError;
150
+ class ImportSettingsError extends Error {
151
+ constructor(err) {
152
+ super('Error importing settings: ' + err);
153
+ this.name = 'ImportSettingsError';
154
+ }
155
+ }
156
+ exports.ImportSettingsError = ImportSettingsError;
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.zonesSchema = exports.mapInfoSchema = exports.mapTypeSchema = exports.blackListSchema = exports.whiteListSchema = exports.priorityListSchema = exports.flightInfoSchema = exports.trackingModeSchema = exports.serverSettingsSchema = exports.cameraSettingsSchema = exports.widgetSchema = exports.connectionSchema = void 0;
3
+ exports.zonesSchema = exports.mapInfoSchema = exports.mapTypeSchema = exports.blackListSchema = exports.whiteListSchema = exports.priorityListSchema = exports.flightInfoSchema = exports.trackingModeSchema = exports.serverSettingsSchema = exports.cameraSettingsSchema = exports.widgetSchema = exports.connectionSchema = exports.wsAliasResponseSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ exports.wsAliasResponseSchema = zod_1.z.object({
6
+ alias: zod_1.z.string(),
7
+ ws: zod_1.z.string(),
8
+ ws_initial_message: zod_1.z.string(),
9
+ });
5
10
  exports.connectionSchema = zod_1.z.object({
6
11
  protocol: zod_1.z.union([zod_1.z.literal('http'), zod_1.z.literal('https'), zod_1.z.literal('https_insecure')]),
7
12
  ip: zod_1.z.union([zod_1.z.string().ip(), zod_1.z.literal('')]),
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { responseStringify } from './internal/utils';
3
- import { blackListSchema, cameraSettingsSchema, flightInfoSchema, mapInfoSchema, priorityListSchema, serverSettingsSchema, trackingModeSchema, whiteListSchema, zonesSchema, } from './types/PlaneTrackerAPI';
4
- import { ParsingBlobError } from './errors/errors';
3
+ import { blackListSchema, cameraSettingsSchema, flightInfoSchema, mapInfoSchema, priorityListSchema, serverSettingsSchema, trackingModeSchema, whiteListSchema, wsAliasResponseSchema, zonesSchema, } from './types/PlaneTrackerAPI';
4
+ import { ImportSettingsError, ParsingBlobError, ResetCalibrationError } from './errors/errors';
5
5
  import { ProxyClient } from './internal/ProxyClient';
6
6
  import { cameraListSchema } from './types/GenetecAgent';
7
7
  const BASE_PATH = '/local/planetracker';
@@ -22,38 +22,45 @@ export class PlaneTrackerAPI {
22
22
  }
23
23
  async resetPtzCalibration(options) {
24
24
  const agent = this.getClient(options?.proxyParams);
25
- await agent.get({
25
+ const res = await agent.get({
26
26
  path: `${BASE_PATH}/package/resetPtzCalibration.cgi`,
27
27
  parameters: this.apiUser,
28
28
  timeout: options?.timeout,
29
29
  });
30
+ if (!res.ok) {
31
+ throw new ResetCalibrationError('PTZ', await responseStringify(res));
32
+ }
30
33
  }
31
34
  async resetFocusCalibration(options) {
32
35
  const agent = this.getClient(options?.proxyParams);
33
- await agent.get({
36
+ const res = await agent.get({
34
37
  path: `${BASE_PATH}/package/resetFocusCalibration.cgi`,
35
38
  parameters: this.apiUser,
36
39
  timeout: options?.timeout,
37
40
  });
41
+ if (!res.ok) {
42
+ throw new ResetCalibrationError('FOCUS', await responseStringify(res));
43
+ }
38
44
  }
39
45
  async serverRunCheck(options) {
40
46
  const agent = this.getClient(options?.proxyParams);
41
- await agent.get({ path: `${BASE_PATH}/package/serverRunCheck.cgi`, timeout: options?.timeout });
47
+ return await agent.get({ path: `${BASE_PATH}/package/serverRunCheck.cgi`, timeout: options?.timeout });
42
48
  }
43
49
  async getLiveViewAlias(rtspUrl, options) {
44
50
  const agent = this.getClient(options?.proxyParams);
45
- await agent.get({
51
+ const res = await agent.get({
46
52
  path: `${BASE_PATH}/getLiveViewAlias.cgi`,
47
53
  parameters: { rtsp_url: rtspUrl },
48
54
  timeout: options?.timeout,
49
55
  });
56
+ return wsAliasResponseSchema.parse(await res.json());
50
57
  }
51
58
  async fetchCameraSettings(options) {
52
59
  const res = await this._getJson(`${BASE_PATH}/package_camera_settings.cgi`, { action: 'get' }, options);
53
60
  return cameraSettingsSchema.parse(res);
54
61
  }
55
62
  async setCameraSettings(settings, options) {
56
- await this._postJsonEncoded(`${BASE_PATH}/package_camera_settings.cgi`, settings, {
63
+ return await this._postJsonEncoded(`${BASE_PATH}/package_camera_settings.cgi`, settings, {
57
64
  action: 'set',
58
65
  }, options);
59
66
  }
@@ -66,12 +73,15 @@ export class PlaneTrackerAPI {
66
73
  }
67
74
  async importAppSettings(dataType, formData, options) {
68
75
  const agent = this.getClient(options?.proxyParams);
69
- await agent.post({
76
+ const res = await agent.post({
70
77
  path: `${BASE_PATH}/package_data.cgi`,
71
78
  data: formData,
72
79
  parameters: { action: 'IMPORT', dataType },
73
80
  timeout: options?.timeout,
74
81
  });
82
+ if (!res.ok) {
83
+ throw new ImportSettingsError(await responseStringify(res));
84
+ }
75
85
  }
76
86
  async fetchFlightInfo(icao, options) {
77
87
  const res = await this._getJson(`${BASE_PATH}/package/flightInfo.cgi`, { icao }, options);
@@ -105,21 +115,21 @@ export class PlaneTrackerAPI {
105
115
  return priorityListSchema.parse(res);
106
116
  }
107
117
  async setPriorityList(priorityList, options) {
108
- await this._postJsonEncoded(`${BASE_PATH}/package/setPriorityList.cgi`, { priorityList }, this.apiUser, options);
118
+ return await this._postJsonEncoded(`${BASE_PATH}/package/setPriorityList.cgi`, { priorityList }, this.apiUser, options);
109
119
  }
110
120
  async getWhiteList(options) {
111
121
  const res = await this._getJson(`${BASE_PATH}/package/getWhiteList.cgi`, undefined, options);
112
122
  return whiteListSchema.parse(res);
113
123
  }
114
124
  async setWhiteList(whiteList, options) {
115
- await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, { whiteList }, this.apiUser, options);
125
+ return await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, { whiteList }, this.apiUser, options);
116
126
  }
117
127
  async getBlackList(options) {
118
128
  const res = await this._getJson(`${BASE_PATH}/package/getBlackList.cgi`, undefined, options);
119
129
  return blackListSchema.parse(res);
120
130
  }
121
131
  async setBlackList(blackList, options) {
122
- await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, { blackList }, this.apiUser, options);
132
+ return await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, { blackList }, this.apiUser, options);
123
133
  }
124
134
  async fetchMapInfo(options) {
125
135
  const res = await this._getJson(`${BASE_PATH}/package/getMapInfo.cgi`, undefined, options);
@@ -134,14 +144,14 @@ export class PlaneTrackerAPI {
134
144
  }
135
145
  async goToCoordinates(lat, lon, alt, options) {
136
146
  const agent = this.getClient(options?.proxyParams);
137
- await agent.get({
147
+ return await agent.get({
138
148
  path: `${BASE_PATH}/package/goToCoordinates.cgi`,
139
149
  parameters: { lat, lon, alt, ...this.apiUser },
140
150
  timeout: options?.timeout,
141
151
  });
142
152
  }
143
153
  async checkGenetecConnection(params, options) {
144
- await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, '', params, options);
154
+ return await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, '', params, options);
145
155
  }
146
156
  async getGenetecCameraList(params, options) {
147
157
  const res = await this._postUrlEncoded(`${BASE_PATH}/package/getGenetecCameraList.cgi`, '', params, options);
@@ -118,3 +118,15 @@ export class TimezoneFetchError extends Error {
118
118
  this.name = 'TimezoneFetchError';
119
119
  }
120
120
  }
121
+ export class ResetCalibrationError extends Error {
122
+ constructor(type, err) {
123
+ super('Error resetting ' + type.toLowerCase() + ' calibration: ' + err);
124
+ this.name = 'ResetCalibrationError';
125
+ }
126
+ }
127
+ export class ImportSettingsError extends Error {
128
+ constructor(err) {
129
+ super('Error importing settings: ' + err);
130
+ this.name = 'ImportSettingsError';
131
+ }
132
+ }
@@ -1,4 +1,9 @@
1
1
  import { z } from 'zod';
2
+ export const wsAliasResponseSchema = z.object({
3
+ alias: z.string(),
4
+ ws: z.string(),
5
+ ws_initial_message: z.string(),
6
+ });
2
7
  export const connectionSchema = z.object({
3
8
  protocol: z.union([z.literal('http'), z.literal('https'), z.literal('https_insecure')]),
4
9
  ip: z.union([z.string().ip(), z.literal('')]),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camstreamerlib",
3
- "version": "4.0.0-beta.40",
3
+ "version": "4.0.0-beta.41",
4
4
  "description": "Helper library for CamStreamer ACAP applications.",
5
5
  "prettier": "@camstreamer/prettier-config",
6
6
  "engine": {
@@ -11,8 +11,12 @@ export declare class PlaneTrackerAPI<Client extends IClient<TResponse, any>> {
11
11
  checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
12
12
  resetPtzCalibration(options?: THttpRequestOptions): Promise<void>;
13
13
  resetFocusCalibration(options?: THttpRequestOptions): Promise<void>;
14
- serverRunCheck(options?: THttpRequestOptions): Promise<void>;
15
- getLiveViewAlias(rtspUrl: string, options?: THttpRequestOptions): Promise<void>;
14
+ serverRunCheck(options?: THttpRequestOptions): Promise<TResponse>;
15
+ getLiveViewAlias(rtspUrl: string, options?: THttpRequestOptions): Promise<{
16
+ ws: string;
17
+ ws_initial_message: string;
18
+ alias: string;
19
+ }>;
16
20
  fetchCameraSettings(options?: THttpRequestOptions): Promise<{
17
21
  camera: {
18
22
  ip: string;
@@ -129,7 +133,7 @@ export declare class PlaneTrackerAPI<Client extends IClient<TResponse, any>> {
129
133
  displayAircraftInfo?: boolean | undefined;
130
134
  } | undefined;
131
135
  }>;
132
- setCameraSettings(settings: TCameraSettings, options?: THttpRequestOptions): Promise<void>;
136
+ setCameraSettings(settings: TCameraSettings, options?: THttpRequestOptions): Promise<any>;
133
137
  fetchServerSettings(options?: THttpRequestOptions): Promise<{
134
138
  cameraCalibration: {
135
139
  posLat: number;
@@ -176,15 +180,15 @@ export declare class PlaneTrackerAPI<Client extends IClient<TResponse, any>> {
176
180
  getPriorityList(options?: THttpRequestOptions): Promise<{
177
181
  priorityList: string[];
178
182
  }>;
179
- setPriorityList(priorityList: TPriorityList['priorityList'], options?: THttpRequestOptions): Promise<void>;
183
+ setPriorityList(priorityList: TPriorityList['priorityList'], options?: THttpRequestOptions): Promise<any>;
180
184
  getWhiteList(options?: THttpRequestOptions): Promise<{
181
185
  whiteList: string[];
182
186
  }>;
183
- setWhiteList(whiteList: TWhiteList['whiteList'], options?: THttpRequestOptions): Promise<void>;
187
+ setWhiteList(whiteList: TWhiteList['whiteList'], options?: THttpRequestOptions): Promise<any>;
184
188
  getBlackList(options?: THttpRequestOptions): Promise<{
185
189
  blackList: string[];
186
190
  }>;
187
- setBlackList(blackList: TBlackList['blackList'], options?: THttpRequestOptions): Promise<void>;
191
+ setBlackList(blackList: TBlackList['blackList'], options?: THttpRequestOptions): Promise<any>;
188
192
  fetchMapInfo(options?: THttpRequestOptions): Promise<{
189
193
  minZoom: number;
190
194
  maxZoom: number;
@@ -210,8 +214,8 @@ export declare class PlaneTrackerAPI<Client extends IClient<TResponse, any>> {
210
214
  }[];
211
215
  }>;
212
216
  setZones(zones: TZones['zones'], options?: THttpRequestOptions): Promise<void>;
213
- goToCoordinates(lat: number, lon: number, alt?: number, options?: THttpRequestOptions): Promise<void>;
214
- checkGenetecConnection(params: TParameters, options?: THttpRequestOptions): Promise<void>;
217
+ goToCoordinates(lat: number, lon: number, alt?: number, options?: THttpRequestOptions): Promise<TResponse>;
218
+ checkGenetecConnection(params: TParameters, options?: THttpRequestOptions): Promise<any>;
215
219
  getGenetecCameraList(params: TParameters, options?: THttpRequestOptions): Promise<{
216
220
  value: string;
217
221
  index: number;
@@ -58,4 +58,11 @@ export declare class TimezoneNotSetupError extends Error {
58
58
  export declare class TimezoneFetchError extends Error {
59
59
  constructor(err: unknown);
60
60
  }
61
+ type TCalibrationType = 'PTZ' | 'FOCUS';
62
+ export declare class ResetCalibrationError extends Error {
63
+ constructor(type: TCalibrationType, err: unknown);
64
+ }
65
+ export declare class ImportSettingsError extends Error {
66
+ constructor(err: unknown);
67
+ }
61
68
  export {};
@@ -6,6 +6,19 @@ export type TApiUser = {
6
6
  userName: string;
7
7
  userPriority: number;
8
8
  };
9
+ export declare const wsAliasResponseSchema: z.ZodObject<{
10
+ alias: z.ZodString;
11
+ ws: z.ZodString;
12
+ ws_initial_message: z.ZodString;
13
+ }, "strip", z.ZodTypeAny, {
14
+ ws: string;
15
+ ws_initial_message: string;
16
+ alias: string;
17
+ }, {
18
+ ws: string;
19
+ ws_initial_message: string;
20
+ alias: string;
21
+ }>;
9
22
  export declare const connectionSchema: z.ZodObject<{
10
23
  protocol: z.ZodUnion<[z.ZodLiteral<"http">, z.ZodLiteral<"https">, z.ZodLiteral<"https_insecure">]>;
11
24
  ip: z.ZodUnion<[z.ZodString, z.ZodLiteral<"">]>;