camstreamerlib 4.0.7 → 4.0.9

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ptrEventsSchema = exports.wsUserActionData = exports.EUserActions = void 0;
3
+ exports.ptrEventsSchema = exports.EUserActions = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const PlaneTrackerAPI_1 = require("../PlaneTrackerAPI");
6
6
  const wsApiFlightDataSchema = zod_1.z.object({
@@ -33,17 +33,15 @@ const wsCameraPositionDataSchema = zod_1.z.object({
33
33
  elevation: zod_1.z.number().min(-90).max(90),
34
34
  fov: zod_1.z.number(),
35
35
  });
36
- const apiUserSchema = zod_1.z.object({
37
- userId: zod_1.z.string(),
38
- userName: zod_1.z.string(),
39
- userPriority: zod_1.z.number(),
40
- ip: zod_1.z.string(),
41
- });
42
- const apiStringUserSchema = zod_1.z.object({
36
+ const userSchema = zod_1.z.object({
43
37
  userId: zod_1.z.string(),
44
38
  userName: zod_1.z.string(),
45
39
  userPriority: zod_1.z.string(),
46
40
  });
41
+ const apiUserSchema = userSchema.extend({
42
+ ip: zod_1.z.string(),
43
+ userPriority: zod_1.z.number(),
44
+ });
47
45
  var EUserActions;
48
46
  (function (EUserActions) {
49
47
  EUserActions["TRACK_ICAO"] = "trackIcao.cgi";
@@ -58,131 +56,104 @@ var EUserActions;
58
56
  EUserActions["LOCK_API"] = "lockApi.cgi";
59
57
  EUserActions["UNLOCK_API"] = "unlockApi.cgi";
60
58
  })(EUserActions || (exports.EUserActions = EUserActions = {}));
61
- exports.wsUserActionData = zod_1.z.discriminatedUnion('cgi', [
59
+ const eventsDataSchema = zod_1.z.union([
60
+ zod_1.z.object({ type: zod_1.z.literal('CAMERA_POSITION') }).merge(wsCameraPositionDataSchema),
61
+ zod_1.z.object({
62
+ type: zod_1.z.literal('TRACKING_START'),
63
+ icao: zod_1.z.string(),
64
+ targetId: zod_1.z.string(),
65
+ domain: PlaneTrackerAPI_1.domainIdSchema,
66
+ categoryId: zod_1.z.string(),
67
+ }),
68
+ zod_1.z.object({ type: zod_1.z.literal('TRACKING_STOP') }),
69
+ zod_1.z.object({ type: zod_1.z.literal('FLIGHT_LIST'), list: zod_1.z.array(wsApiFlightDataSchema) }),
62
70
  zod_1.z.object({
71
+ type: zod_1.z.literal('USER_ACTION'),
63
72
  cgi: zod_1.z.literal(EUserActions.TRACK_ICAO),
64
73
  ip: zod_1.z.string(),
65
- params: apiStringUserSchema.extend({
66
- icao: zod_1.z.string(),
67
- }),
74
+ params: userSchema.extend({ icao: zod_1.z.string() }),
75
+ postJsonBody: zod_1.z.any(),
68
76
  }),
69
77
  zod_1.z.object({
78
+ type: zod_1.z.literal('USER_ACTION'),
70
79
  cgi: zod_1.z.literal(EUserActions.RESET_ICAO),
71
80
  ip: zod_1.z.string(),
72
- params: apiStringUserSchema,
81
+ params: userSchema,
82
+ postJsonBody: zod_1.z.any(),
73
83
  }),
74
84
  zod_1.z.object({
85
+ type: zod_1.z.literal('USER_ACTION'),
75
86
  cgi: zod_1.z.literal(EUserActions.SET_PRIORITY_LIST),
76
87
  ip: zod_1.z.string(),
77
- params: apiStringUserSchema,
88
+ params: userSchema,
78
89
  postJsonBody: PlaneTrackerAPI_1.priorityListSchema,
79
90
  }),
80
91
  zod_1.z.object({
92
+ type: zod_1.z.literal('USER_ACTION'),
81
93
  cgi: zod_1.z.literal(EUserActions.SET_BLACK_LIST),
82
94
  ip: zod_1.z.string(),
83
- params: apiStringUserSchema,
95
+ params: userSchema,
84
96
  postJsonBody: PlaneTrackerAPI_1.blackListSchema,
85
97
  }),
86
98
  zod_1.z.object({
99
+ type: zod_1.z.literal('USER_ACTION'),
87
100
  cgi: zod_1.z.literal(EUserActions.SET_WHITE_LIST),
88
101
  ip: zod_1.z.string(),
89
- params: apiStringUserSchema,
102
+ params: userSchema,
90
103
  postJsonBody: PlaneTrackerAPI_1.whiteListSchema,
91
104
  }),
92
105
  zod_1.z.object({
106
+ type: zod_1.z.literal('USER_ACTION'),
93
107
  cgi: zod_1.z.literal(EUserActions.GO_TO_COORDINATES),
94
108
  ip: zod_1.z.string(),
95
- params: apiStringUserSchema.extend({
96
- lat: zod_1.z.string(),
97
- lon: zod_1.z.string(),
98
- }),
109
+ params: userSchema.extend({ lat: zod_1.z.string(), lon: zod_1.z.string() }),
110
+ postJsonBody: zod_1.z.any(),
99
111
  }),
100
112
  zod_1.z.object({
113
+ type: zod_1.z.literal('USER_ACTION'),
101
114
  cgi: zod_1.z.literal(EUserActions.SET_TRACKING_MODE),
102
115
  ip: zod_1.z.string(),
103
- params: apiStringUserSchema,
116
+ params: userSchema,
104
117
  postJsonBody: PlaneTrackerAPI_1.trackingModeSchema,
105
118
  }),
106
119
  zod_1.z.object({
120
+ type: zod_1.z.literal('USER_ACTION'),
107
121
  cgi: zod_1.z.literal(EUserActions.SET_ZONES),
108
122
  ip: zod_1.z.string(),
109
- params: apiStringUserSchema,
123
+ params: userSchema,
110
124
  postJsonBody: PlaneTrackerAPI_1.zonesSchema,
111
125
  }),
112
126
  zod_1.z.object({
127
+ type: zod_1.z.literal('USER_ACTION'),
113
128
  cgi: zod_1.z.literal(EUserActions.RESET_PTZ_CALIBRATION),
114
129
  ip: zod_1.z.string(),
115
- params: apiStringUserSchema,
130
+ params: userSchema,
131
+ postJsonBody: zod_1.z.any(),
116
132
  }),
117
133
  zod_1.z.object({
134
+ type: zod_1.z.literal('USER_ACTION'),
118
135
  cgi: zod_1.z.literal(EUserActions.LOCK_API),
119
136
  ip: zod_1.z.string(),
120
- params: apiStringUserSchema.extend({
121
- timeout: zod_1.z.string(),
122
- }),
123
- }),
124
- zod_1.z.object({
125
- cgi: zod_1.z.literal(EUserActions.UNLOCK_API),
126
- ip: zod_1.z.string(),
127
- params: apiStringUserSchema,
128
- }),
129
- ]);
130
- const eventsDataSchema = zod_1.z.discriminatedUnion('type', [
131
- zod_1.z
132
- .object({
133
- type: zod_1.z.literal('CAMERA_POSITION'),
134
- })
135
- .merge(wsCameraPositionDataSchema),
136
- zod_1.z.object({
137
- type: zod_1.z.literal('TRACKING_START'),
138
- icao: zod_1.z.string(),
139
- }),
140
- zod_1.z.object({
141
- type: zod_1.z.literal('TRACKING_STOP'),
142
- }),
143
- zod_1.z.object({
144
- type: zod_1.z.literal('FLIGHT_LIST'),
145
- list: zod_1.z.array(wsApiFlightDataSchema),
137
+ params: userSchema.extend({ timeout: zod_1.z.string() }),
138
+ postJsonBody: zod_1.z.any(),
146
139
  }),
147
140
  zod_1.z.object({
148
141
  type: zod_1.z.literal('USER_ACTION'),
142
+ cgi: zod_1.z.literal(EUserActions.UNLOCK_API),
149
143
  ip: zod_1.z.string(),
150
- params: apiStringUserSchema.extend({
151
- lat: zod_1.z.string().optional(),
152
- lon: zod_1.z.string().optional(),
153
- timeout: zod_1.z.string().optional(),
154
- }),
155
- cgi: zod_1.z.enum([
156
- EUserActions.TRACK_ICAO,
157
- EUserActions.RESET_ICAO,
158
- EUserActions.SET_PRIORITY_LIST,
159
- EUserActions.SET_BLACK_LIST,
160
- EUserActions.SET_WHITE_LIST,
161
- EUserActions.GO_TO_COORDINATES,
162
- EUserActions.SET_TRACKING_MODE,
163
- EUserActions.SET_ZONES,
164
- EUserActions.RESET_PTZ_CALIBRATION,
165
- EUserActions.LOCK_API,
166
- EUserActions.UNLOCK_API,
167
- ]),
144
+ params: userSchema,
168
145
  postJsonBody: zod_1.z.any(),
169
146
  }),
170
- zod_1.z.object({
171
- type: zod_1.z.literal('CONNECTED_USERS'),
172
- users: zod_1.z.array(apiUserSchema),
173
- }),
147
+ zod_1.z.object({ type: zod_1.z.literal('CONNECTED_USERS'), users: zod_1.z.array(apiUserSchema) }),
174
148
  zod_1.z.object({
175
149
  type: zod_1.z.literal('FORCE_TRACKING_STATUS'),
176
150
  enabled: zod_1.z.boolean(),
177
151
  icao: zod_1.z.string().optional(),
152
+ targetId: zod_1.z.string().optional(),
178
153
  }),
179
- zod_1.z.object({
180
- type: zod_1.z.literal('API_LOCK_STATUS'),
181
- isLocked: zod_1.z.boolean(),
182
- user: apiUserSchema.optional(),
183
- }),
154
+ zod_1.z.object({ type: zod_1.z.literal('API_LOCK_STATUS'), isLocked: zod_1.z.boolean(), user: apiUserSchema.optional() }),
184
155
  ]);
185
- exports.ptrEventsSchema = zod_1.z.discriminatedUnion('type', [
156
+ exports.ptrEventsSchema = zod_1.z.union([
186
157
  zod_1.z.object({ type: zod_1.z.literal('init'), data: eventsDataSchema }),
187
158
  ...eventsDataSchema.options,
188
159
  ]);
@@ -6,15 +6,7 @@ const PlaneTrackerEvents_1 = require("../types/ws/PlaneTrackerEvents");
6
6
  class PlaneTrackerEvents extends WsEvents_1.WsEvents {
7
7
  _apiUser;
8
8
  constructor(ws, _apiUser) {
9
- super((data) => {
10
- const parsedData = PlaneTrackerEvents_1.ptrEventsSchema.parse(data);
11
- if (parsedData.type === 'USER_ACTION') {
12
- const { type, ...actionData } = parsedData;
13
- const userAction = PlaneTrackerEvents_1.wsUserActionData.parse(actionData);
14
- return { ...userAction, type };
15
- }
16
- return parsedData;
17
- }, ws);
9
+ super((data) => PlaneTrackerEvents_1.ptrEventsSchema.parse(data), ws);
18
10
  this._apiUser = _apiUser;
19
11
  this.ws.onOpen = this.sendInitMsg;
20
12
  }
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { blackListSchema, cameraSettingsSchema, flightInfoSchema, getIcaoSchema, mapInfoSchema, priorityListSchema, serverSettingsSchema, trackingModeSchema, whiteListSchema, wsAliasResponseSchema, zonesSchema, } from './types/PlaneTrackerAPI';
2
+ import { blackListSchema, cameraSettingsSchema, domainListSchema, flightInfoSchema, getIcaoSchema, mapInfoSchema, priorityListSchema, serverSettingsSchema, trackingModeSchema, whiteListSchema, wsAliasResponseSchema, zonesSchema, } from './types/PlaneTrackerAPI';
3
3
  import { CannotSetCoordsInAutoModeError, ImportSettingsError, InvalidAltitudeError, InvalidLatLngError, ResetCalibrationError, ServerError, BadRequestError, } from './errors/errors';
4
4
  import { BasicAPI } from './internal/BasicAPI';
5
5
  const BASE_PATH = '/local/planetracker';
@@ -85,8 +85,12 @@ export class PlaneTrackerAPI extends BasicAPI {
85
85
  throw new ImportSettingsError(res);
86
86
  }
87
87
  }
88
- async fetchFlightInfo(icao, options) {
89
- const res = await this._getJson(`${BASE_PATH}/package/flightInfo.cgi`, { icao }, options);
88
+ async getDomainList(options) {
89
+ const res = await this._getJson(`${BASE_PATH}/getDomainList.cgi`, { action: 'get' }, options);
90
+ return domainListSchema.parse(res);
91
+ }
92
+ async fetchFlightInfo(targetId, options) {
93
+ const res = await this._getJson(`${BASE_PATH}/package/flightInfo.cgi`, { targetId }, options);
90
94
  return flightInfoSchema.parse(res);
91
95
  }
92
96
  async getTrackingMode(options) {
@@ -112,9 +116,25 @@ export class PlaneTrackerAPI extends BasicAPI {
112
116
  timeout: options?.timeout,
113
117
  });
114
118
  }
119
+ async startTrackingTarget(targetId, options) {
120
+ const agent = this.getClient(options?.proxyParams);
121
+ await agent.get({
122
+ path: `${BASE_PATH}/package/trackTarget.cgi`,
123
+ parameters: { targetId, ...this.apiUser },
124
+ timeout: options?.timeout,
125
+ });
126
+ }
127
+ async stopTrackingTarget(options) {
128
+ const agent = this.getClient(options?.proxyParams);
129
+ await agent.get({
130
+ path: `${BASE_PATH}/package/resetTarget.cgi`,
131
+ parameters: this.apiUser,
132
+ timeout: options?.timeout,
133
+ });
134
+ }
115
135
  async getIcao(by, value, options) {
116
136
  const res = await this._getJson(`${BASE_PATH}/package/getIcao.cgi`, { [by]: value }, options);
117
- return getIcaoSchema.parse(res).icao;
137
+ return getIcaoSchema.parse(res).targetId;
118
138
  }
119
139
  async getPriorityList(options) {
120
140
  const res = await this._getJson(`${BASE_PATH}/package/getPriorityList.cgi`, undefined, options);
package/esm/VapixAPI.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { arrayToUrl, isNullish, paramToUrl } from './internal/utils';
2
- import { sdCardWatchedStatuses, maxFpsResponseSchema, dateTimeinfoSchema, audioDeviceRequestSchema, audioSampleRatesResponseSchema, timeZoneSchema, getPortsResponseSchema, guardTourSchema, ptzOverviewSchema, cameraPTZItemDataSchema, applicationListSchema, sdCardInfoSchema, ALL_APP_IDS, } from './types/VapixAPI';
2
+ import { sdCardWatchedStatuses, maxFpsResponseSchema, dateTimeinfoSchema, audioDeviceRequestSchema, audioSampleRatesResponseSchema, timeZoneSchema, getPortsResponseSchema, guardTourSchema, ptzOverviewSchema, cameraPTZItemDataSchema, applicationListSchema, sdCardInfoSchema, ALL_APP_IDS, allDateTimeInfoSchema, } from './types/VapixAPI';
3
3
  import { ApplicationAPIError, MaxFPSError, NoDeviceInfoError, PtzNotSupportedError, ErrorWithResponse, SDCardActionError, SDCardJobError, SettingParameterError, TimezoneFetchError, TimezoneNotSetupError, } from './errors/errors';
4
4
  import { z } from 'zod';
5
5
  import { XMLParser } from 'fast-xml-parser';
@@ -149,12 +149,17 @@ export class VapixAPI extends BasicAPI {
149
149
  console.warn('Failed to fetch time zone data from time API v2:', error instanceof Error ? error.message : JSON.stringify(error));
150
150
  console.warn('Falling back to deprecated time API v1');
151
151
  }
152
- const data = await this.getDateTimeInfo(options);
152
+ const data = await this.getAllDateTimeInfo(options);
153
153
  if (data.data.timeZone === undefined) {
154
154
  throw new TimezoneNotSetupError();
155
155
  }
156
156
  return z.string().parse(data.data.timeZone);
157
157
  }
158
+ async getAllDateTimeInfo(options) {
159
+ const data = { apiVersion: '1.0', method: 'getAll' };
160
+ const res = await this._postJsonEncoded('/axis-cgi/time.cgi', data, undefined, options);
161
+ return allDateTimeInfoSchema.parse(await res.json());
162
+ }
158
163
  async getDateTimeInfo(options) {
159
164
  const data = { apiVersion: '1.0', method: 'getDateTimeInfo' };
160
165
  const res = await this._postJsonEncoded('/axis-cgi/time.cgi', data, undefined, options);
@@ -72,8 +72,8 @@ export const parseVideoOptionsToVapixParams = (firmWareVersion, video) => {
72
72
  const nbrOfChannels = video.nbrOfChannels ? (video.audio === 1 ? `&nbrOfChannels=${video.nbrOfChannels}` : '') : '';
73
73
  const audioParams = `audio=${video.audio}${nbrOfChannels}`;
74
74
  const videoCodecParams = video.videoCodec === 'h264'
75
- ? `videoCodec=${video.videoCodec}&h264Profile=${video.h264Profile}`
76
- : `videoCodec=${video.videoCodec}`;
75
+ ? `videocodec=${video.videoCodec}&h264Profile=${video.h264Profile}`
76
+ : `videocodec=${video.videoCodec}`;
77
77
  const videoParams = `camera=${video.camera}&resolution=${video.resolution}&fps=${video.fps}&compression=${video.compression}&videokeyframeinterval=${video.govLength}&${videoCodecParams}${overlaysParams}`;
78
78
  return [videoParams, bitrateParams, audioParams].join('&');
79
79
  };
@@ -85,7 +85,7 @@ export const parseVapixParamsToVideoOptions = (internalVapixParams) => {
85
85
  params[key] = value;
86
86
  });
87
87
  let h264Profile = undefined;
88
- if (params['videoCodec'] === 'h264') {
88
+ if (params['videocodec'] === 'h264') {
89
89
  h264Profile = (params['h264Profile'] ?? 'high');
90
90
  }
91
91
  let nbrOfChannels = undefined;
@@ -99,7 +99,7 @@ export const parseVapixParamsToVideoOptions = (internalVapixParams) => {
99
99
  fps: parseInt(params['fps'] ?? '0', 10),
100
100
  compression: parseInt(params['compression'] ?? '0', 10),
101
101
  govLength: parseInt(params['videokeyframeinterval'] ?? '0', 10),
102
- videoCodec: (params['videoCodec'] ?? 'h264'),
102
+ videoCodec: (params['videocodec'] ?? 'h264'),
103
103
  h264Profile,
104
104
  audio: parseInt(params['audio'] ?? '0'),
105
105
  nbrOfChannels,
@@ -248,6 +248,7 @@ export const serverSettingsSchema = z.object({
248
248
  });
249
249
  export const getIcaoSchema = z.object({
250
250
  icao: z.string(),
251
+ targetId: z.string(),
251
252
  });
252
253
  export const trackingModeSchema = z.object({
253
254
  mode: z.union([z.literal('MANUAL'), z.literal('AUTOMATIC')]).default('AUTOMATIC'),
@@ -324,6 +325,18 @@ export const zonesSchema = z.object({
324
325
  .default([]),
325
326
  });
326
327
  export const domainIdSchema = z.enum(['adsb', 'remoteId']);
328
+ const categoryIconSchema = z.enum(['small', 'large', 'heavy', 'helicopter', 'drone', 'operator', 'unknown']);
329
+ const categoryDescriptorSchema = z.object({
330
+ categoryId: z.string(),
331
+ uiName: z.string(),
332
+ icon: categoryIconSchema,
333
+ });
334
+ const domainDescriptorSchema = z.object({
335
+ uiName: z.string(),
336
+ icon: categoryIconSchema,
337
+ categoryList: z.array(categoryDescriptorSchema),
338
+ });
339
+ export const domainListSchema = z.record(domainIdSchema, domainDescriptorSchema);
327
340
  export const ADSB_CATEGORY_IDS = {
328
341
  A_LIGHT: 'A_LIGHT',
329
342
  A_SMALL: 'A_SMALL',
@@ -120,13 +120,20 @@ export const maxFpsResponseSchema = z.object({
120
120
  }))
121
121
  .optional(),
122
122
  });
123
+ const timeInfoSchema = z.object({
124
+ dateTime: z.string(),
125
+ dstEnabled: z.boolean(),
126
+ localDateTime: z.string(),
127
+ posixTimeZone: z.string(),
128
+ timeZone: z.string().optional(),
129
+ });
123
130
  export const dateTimeinfoSchema = z.object({
124
- data: z.object({
125
- dateTime: z.string(),
126
- dstEnabled: z.boolean(),
127
- localDateTime: z.string(),
128
- posixTimeZone: z.string(),
129
- timeZone: z.string().optional(),
131
+ data: timeInfoSchema,
132
+ });
133
+ export const allDateTimeInfoSchema = z.object({
134
+ data: timeInfoSchema.extend({
135
+ maxYearSupported: z.number(),
136
+ timeZones: z.array(z.string()),
130
137
  }),
131
138
  });
132
139
  export const timeZoneSchema = z.discriminatedUnion('status', [
@@ -30,17 +30,15 @@ const wsCameraPositionDataSchema = z.object({
30
30
  elevation: z.number().min(-90).max(90),
31
31
  fov: z.number(),
32
32
  });
33
- const apiUserSchema = z.object({
34
- userId: z.string(),
35
- userName: z.string(),
36
- userPriority: z.number(),
37
- ip: z.string(),
38
- });
39
- const apiStringUserSchema = z.object({
33
+ const userSchema = z.object({
40
34
  userId: z.string(),
41
35
  userName: z.string(),
42
36
  userPriority: z.string(),
43
37
  });
38
+ const apiUserSchema = userSchema.extend({
39
+ ip: z.string(),
40
+ userPriority: z.number(),
41
+ });
44
42
  export var EUserActions;
45
43
  (function (EUserActions) {
46
44
  EUserActions["TRACK_ICAO"] = "trackIcao.cgi";
@@ -55,131 +53,104 @@ export var EUserActions;
55
53
  EUserActions["LOCK_API"] = "lockApi.cgi";
56
54
  EUserActions["UNLOCK_API"] = "unlockApi.cgi";
57
55
  })(EUserActions || (EUserActions = {}));
58
- export const wsUserActionData = z.discriminatedUnion('cgi', [
56
+ const eventsDataSchema = z.union([
57
+ z.object({ type: z.literal('CAMERA_POSITION') }).merge(wsCameraPositionDataSchema),
58
+ z.object({
59
+ type: z.literal('TRACKING_START'),
60
+ icao: z.string(),
61
+ targetId: z.string(),
62
+ domain: domainIdSchema,
63
+ categoryId: z.string(),
64
+ }),
65
+ z.object({ type: z.literal('TRACKING_STOP') }),
66
+ z.object({ type: z.literal('FLIGHT_LIST'), list: z.array(wsApiFlightDataSchema) }),
59
67
  z.object({
68
+ type: z.literal('USER_ACTION'),
60
69
  cgi: z.literal(EUserActions.TRACK_ICAO),
61
70
  ip: z.string(),
62
- params: apiStringUserSchema.extend({
63
- icao: z.string(),
64
- }),
71
+ params: userSchema.extend({ icao: z.string() }),
72
+ postJsonBody: z.any(),
65
73
  }),
66
74
  z.object({
75
+ type: z.literal('USER_ACTION'),
67
76
  cgi: z.literal(EUserActions.RESET_ICAO),
68
77
  ip: z.string(),
69
- params: apiStringUserSchema,
78
+ params: userSchema,
79
+ postJsonBody: z.any(),
70
80
  }),
71
81
  z.object({
82
+ type: z.literal('USER_ACTION'),
72
83
  cgi: z.literal(EUserActions.SET_PRIORITY_LIST),
73
84
  ip: z.string(),
74
- params: apiStringUserSchema,
85
+ params: userSchema,
75
86
  postJsonBody: priorityListSchema,
76
87
  }),
77
88
  z.object({
89
+ type: z.literal('USER_ACTION'),
78
90
  cgi: z.literal(EUserActions.SET_BLACK_LIST),
79
91
  ip: z.string(),
80
- params: apiStringUserSchema,
92
+ params: userSchema,
81
93
  postJsonBody: blackListSchema,
82
94
  }),
83
95
  z.object({
96
+ type: z.literal('USER_ACTION'),
84
97
  cgi: z.literal(EUserActions.SET_WHITE_LIST),
85
98
  ip: z.string(),
86
- params: apiStringUserSchema,
99
+ params: userSchema,
87
100
  postJsonBody: whiteListSchema,
88
101
  }),
89
102
  z.object({
103
+ type: z.literal('USER_ACTION'),
90
104
  cgi: z.literal(EUserActions.GO_TO_COORDINATES),
91
105
  ip: z.string(),
92
- params: apiStringUserSchema.extend({
93
- lat: z.string(),
94
- lon: z.string(),
95
- }),
106
+ params: userSchema.extend({ lat: z.string(), lon: z.string() }),
107
+ postJsonBody: z.any(),
96
108
  }),
97
109
  z.object({
110
+ type: z.literal('USER_ACTION'),
98
111
  cgi: z.literal(EUserActions.SET_TRACKING_MODE),
99
112
  ip: z.string(),
100
- params: apiStringUserSchema,
113
+ params: userSchema,
101
114
  postJsonBody: trackingModeSchema,
102
115
  }),
103
116
  z.object({
117
+ type: z.literal('USER_ACTION'),
104
118
  cgi: z.literal(EUserActions.SET_ZONES),
105
119
  ip: z.string(),
106
- params: apiStringUserSchema,
120
+ params: userSchema,
107
121
  postJsonBody: zonesSchema,
108
122
  }),
109
123
  z.object({
124
+ type: z.literal('USER_ACTION'),
110
125
  cgi: z.literal(EUserActions.RESET_PTZ_CALIBRATION),
111
126
  ip: z.string(),
112
- params: apiStringUserSchema,
127
+ params: userSchema,
128
+ postJsonBody: z.any(),
113
129
  }),
114
130
  z.object({
131
+ type: z.literal('USER_ACTION'),
115
132
  cgi: z.literal(EUserActions.LOCK_API),
116
133
  ip: z.string(),
117
- params: apiStringUserSchema.extend({
118
- timeout: z.string(),
119
- }),
120
- }),
121
- z.object({
122
- cgi: z.literal(EUserActions.UNLOCK_API),
123
- ip: z.string(),
124
- params: apiStringUserSchema,
125
- }),
126
- ]);
127
- const eventsDataSchema = z.discriminatedUnion('type', [
128
- z
129
- .object({
130
- type: z.literal('CAMERA_POSITION'),
131
- })
132
- .merge(wsCameraPositionDataSchema),
133
- z.object({
134
- type: z.literal('TRACKING_START'),
135
- icao: z.string(),
136
- }),
137
- z.object({
138
- type: z.literal('TRACKING_STOP'),
139
- }),
140
- z.object({
141
- type: z.literal('FLIGHT_LIST'),
142
- list: z.array(wsApiFlightDataSchema),
134
+ params: userSchema.extend({ timeout: z.string() }),
135
+ postJsonBody: z.any(),
143
136
  }),
144
137
  z.object({
145
138
  type: z.literal('USER_ACTION'),
139
+ cgi: z.literal(EUserActions.UNLOCK_API),
146
140
  ip: z.string(),
147
- params: apiStringUserSchema.extend({
148
- lat: z.string().optional(),
149
- lon: z.string().optional(),
150
- timeout: z.string().optional(),
151
- }),
152
- cgi: z.enum([
153
- EUserActions.TRACK_ICAO,
154
- EUserActions.RESET_ICAO,
155
- EUserActions.SET_PRIORITY_LIST,
156
- EUserActions.SET_BLACK_LIST,
157
- EUserActions.SET_WHITE_LIST,
158
- EUserActions.GO_TO_COORDINATES,
159
- EUserActions.SET_TRACKING_MODE,
160
- EUserActions.SET_ZONES,
161
- EUserActions.RESET_PTZ_CALIBRATION,
162
- EUserActions.LOCK_API,
163
- EUserActions.UNLOCK_API,
164
- ]),
141
+ params: userSchema,
165
142
  postJsonBody: z.any(),
166
143
  }),
167
- z.object({
168
- type: z.literal('CONNECTED_USERS'),
169
- users: z.array(apiUserSchema),
170
- }),
144
+ z.object({ type: z.literal('CONNECTED_USERS'), users: z.array(apiUserSchema) }),
171
145
  z.object({
172
146
  type: z.literal('FORCE_TRACKING_STATUS'),
173
147
  enabled: z.boolean(),
174
148
  icao: z.string().optional(),
149
+ targetId: z.string().optional(),
175
150
  }),
176
- z.object({
177
- type: z.literal('API_LOCK_STATUS'),
178
- isLocked: z.boolean(),
179
- user: apiUserSchema.optional(),
180
- }),
151
+ z.object({ type: z.literal('API_LOCK_STATUS'), isLocked: z.boolean(), user: apiUserSchema.optional() }),
181
152
  ]);
182
- export const ptrEventsSchema = z.discriminatedUnion('type', [
153
+ export const ptrEventsSchema = z.union([
183
154
  z.object({ type: z.literal('init'), data: eventsDataSchema }),
184
155
  ...eventsDataSchema.options,
185
156
  ]);
@@ -1,17 +1,9 @@
1
1
  import { WsEvents } from '../internal/WsEvents';
2
- import { wsUserActionData, ptrEventsSchema } from '../types/ws/PlaneTrackerEvents';
2
+ import { ptrEventsSchema } from '../types/ws/PlaneTrackerEvents';
3
3
  export class PlaneTrackerEvents extends WsEvents {
4
4
  _apiUser;
5
5
  constructor(ws, _apiUser) {
6
- super((data) => {
7
- const parsedData = ptrEventsSchema.parse(data);
8
- if (parsedData.type === 'USER_ACTION') {
9
- const { type, ...actionData } = parsedData;
10
- const userAction = wsUserActionData.parse(actionData);
11
- return { ...userAction, type };
12
- }
13
- return parsedData;
14
- }, ws);
6
+ super((data) => ptrEventsSchema.parse(data), ws);
15
7
  this._apiUser = _apiUser;
16
8
  this.ws.onOpen = this.sendInitMsg;
17
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camstreamerlib",
3
- "version": "4.0.7",
3
+ "version": "4.0.9",
4
4
  "description": "Helper library for CamStreamer ACAP applications.",
5
5
  "prettier": "@camstreamer/prettier-config",
6
6
  "engine": {
@@ -158,7 +158,16 @@ export declare class PlaneTrackerAPI<Client extends IClient<TResponse, any>> ext
158
158
  }>;
159
159
  exportAppSettings(dataType: TExportDataType, options?: THttpRequestOptions): Promise<ReturnType<Awaited<ReturnType<Client["get"]>>["blob"]>>;
160
160
  importAppSettings(dataType: TImportDataType, formData: Parameters<Client['post']>[0]['data'], options?: THttpRequestOptions): Promise<void>;
161
- fetchFlightInfo(icao: ICAO, options?: THttpRequestOptions): Promise<{
161
+ getDomainList(options?: THttpRequestOptions): Promise<Partial<Record<"adsb" | "remoteId", {
162
+ uiName: string;
163
+ icon: "unknown" | "small" | "large" | "heavy" | "helicopter" | "drone" | "operator";
164
+ categoryList: {
165
+ categoryId: string;
166
+ uiName: string;
167
+ icon: "unknown" | "small" | "large" | "heavy" | "helicopter" | "drone" | "operator";
168
+ }[];
169
+ }>>>;
170
+ fetchFlightInfo(targetId: string, options?: THttpRequestOptions): Promise<{
162
171
  destinationAirport: {
163
172
  icao?: string | undefined;
164
173
  iata?: string | undefined;
@@ -185,6 +194,8 @@ export declare class PlaneTrackerAPI<Client extends IClient<TResponse, any>> ext
185
194
  setTrackingMode(mode: TTrackingMode['mode'], options?: THttpRequestOptions): Promise<void>;
186
195
  startTrackingPlane(icao: ICAO, options?: THttpRequestOptions): Promise<void>;
187
196
  stopTrackingPlane(options?: THttpRequestOptions): Promise<void>;
197
+ startTrackingTarget(targetId: string, options?: THttpRequestOptions): Promise<void>;
198
+ stopTrackingTarget(options?: THttpRequestOptions): Promise<void>;
188
199
  getIcao(by: TGetIcaoByOption, value: string, options?: THttpRequestOptions): Promise<string>;
189
200
  getPriorityList(options?: THttpRequestOptions): Promise<{
190
201
  list: {
@@ -21,6 +21,17 @@ export declare class VapixAPI<Client extends IClient<TResponse, any>> extends Ba
21
21
  getSystemLog(options?: THttpRequestOptions): Promise<string>;
22
22
  getMaxFps(channel: number, options?: THttpRequestOptions): Promise<number>;
23
23
  getTimezone(options?: THttpRequestOptions): Promise<string>;
24
+ getAllDateTimeInfo(options?: THttpRequestOptions): Promise<{
25
+ data: {
26
+ dateTime: string;
27
+ dstEnabled: boolean;
28
+ localDateTime: string;
29
+ posixTimeZone: string;
30
+ maxYearSupported: number;
31
+ timeZones: string[];
32
+ timeZone?: string | undefined;
33
+ };
34
+ }>;
24
35
  getDateTimeInfo(options?: THttpRequestOptions): Promise<{
25
36
  data: {
26
37
  dateTime: string;