camstreamerlib 4.0.6 → 4.0.8

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,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ptrEventsSchema = exports.planeTrackerUserActionData = exports.PlaneTrackerUserActions = exports.PlaneTrackerWsEvents = void 0;
3
+ exports.ptrEventsSchema = exports.EUserActions = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const PlaneTrackerAPI_1 = require("../PlaneTrackerAPI");
6
- const apiFlightDataSchema = zod_1.z.object({
6
+ const wsApiFlightDataSchema = zod_1.z.object({
7
+ targetId: zod_1.z.string(),
7
8
  icao: zod_1.z.string(),
9
+ domain: PlaneTrackerAPI_1.domainIdSchema,
10
+ categoryId: zod_1.z.string(),
11
+ groupId: zod_1.z.string().optional(),
8
12
  lat: zod_1.z.number(),
9
13
  lon: zod_1.z.number(),
10
14
  heading: zod_1.z.number(),
@@ -15,7 +19,6 @@ const apiFlightDataSchema = zod_1.z.object({
15
19
  whiteListed: zod_1.z.boolean(),
16
20
  blackListed: zod_1.z.boolean(),
17
21
  priorityListed: zod_1.z.boolean(),
18
- typePriorityListed: zod_1.z.boolean().default(false),
19
22
  autoSelectionIgnored: zod_1.z.boolean(),
20
23
  signalQuality: zod_1.z.number(),
21
24
  emitterCategorySet: zod_1.z.number().default(4),
@@ -23,169 +26,134 @@ const apiFlightDataSchema = zod_1.z.object({
23
26
  emergencyState: zod_1.z.boolean(),
24
27
  emergencyStatusMessage: zod_1.z.string(),
25
28
  });
26
- const apiUserSchema = zod_1.z.object({
27
- userId: zod_1.z.string(),
28
- userName: zod_1.z.string(),
29
- userPriority: zod_1.z.number(),
30
- ip: zod_1.z.string(),
29
+ const wsCameraPositionDataSchema = zod_1.z.object({
30
+ lat: zod_1.z.number(),
31
+ lon: zod_1.z.number(),
32
+ azimuth: zod_1.z.number().min(0).max(360),
33
+ elevation: zod_1.z.number().min(-90).max(90),
34
+ fov: zod_1.z.number(),
31
35
  });
32
- const apiStringUserSchema = zod_1.z.object({
36
+ const userSchema = zod_1.z.object({
33
37
  userId: zod_1.z.string(),
34
38
  userName: zod_1.z.string(),
35
39
  userPriority: zod_1.z.string(),
36
40
  });
37
- var PlaneTrackerWsEvents;
38
- (function (PlaneTrackerWsEvents) {
39
- PlaneTrackerWsEvents["FLIGHT_LIST"] = "FLIGHT_LIST";
40
- PlaneTrackerWsEvents["CAMERA_POSITION"] = "CAMERA_POSITION";
41
- PlaneTrackerWsEvents["TRACKING_START"] = "TRACKING_START";
42
- PlaneTrackerWsEvents["TRACKING_STOP"] = "TRACKING_STOP";
43
- PlaneTrackerWsEvents["USER_ACTION"] = "USER_ACTION";
44
- PlaneTrackerWsEvents["CONNECTED_USERS"] = "CONNECTED_USERS";
45
- PlaneTrackerWsEvents["FORCE_TRACKING_STATUS"] = "FORCE_TRACKING_STATUS";
46
- })(PlaneTrackerWsEvents || (exports.PlaneTrackerWsEvents = PlaneTrackerWsEvents = {}));
47
- var PlaneTrackerUserActions;
48
- (function (PlaneTrackerUserActions) {
49
- PlaneTrackerUserActions["TRACK_ICAO"] = "trackIcao.cgi";
50
- PlaneTrackerUserActions["RESET_ICAO"] = "resetIcao.cgi";
51
- PlaneTrackerUserActions["SET_PRIORITY_LIST"] = "setPriorityList.cgi";
52
- PlaneTrackerUserActions["SET_BLACK_LIST"] = "setBlackList.cgi";
53
- PlaneTrackerUserActions["SET_WHITE_LIST"] = "setWhiteList.cgi";
54
- PlaneTrackerUserActions["GO_TO_COORDINATES"] = "goToCoordinates.cgi";
55
- PlaneTrackerUserActions["SET_TRACKING_MODE"] = "setTrackingMode.cgi";
56
- PlaneTrackerUserActions["SET_ZONES"] = "setZones.cgi";
57
- PlaneTrackerUserActions["RESET_PTZ_CALIBRATION"] = "resetPtzCalibration.cgi";
58
- PlaneTrackerUserActions["LOCK_API"] = "lockApi.cgi";
59
- PlaneTrackerUserActions["UNLOCK_API"] = "unlockApi.cgi";
60
- })(PlaneTrackerUserActions || (exports.PlaneTrackerUserActions = PlaneTrackerUserActions = {}));
61
- exports.planeTrackerUserActionData = zod_1.z.discriminatedUnion('cgi', [
41
+ const apiUserSchema = userSchema.extend({
42
+ ip: zod_1.z.string(),
43
+ userPriority: zod_1.z.number(),
44
+ });
45
+ var EUserActions;
46
+ (function (EUserActions) {
47
+ EUserActions["TRACK_ICAO"] = "trackIcao.cgi";
48
+ EUserActions["RESET_ICAO"] = "resetIcao.cgi";
49
+ EUserActions["SET_PRIORITY_LIST"] = "setPriorityList.cgi";
50
+ EUserActions["SET_BLACK_LIST"] = "setBlackList.cgi";
51
+ EUserActions["SET_WHITE_LIST"] = "setWhiteList.cgi";
52
+ EUserActions["GO_TO_COORDINATES"] = "goToCoordinates.cgi";
53
+ EUserActions["SET_TRACKING_MODE"] = "setTrackingMode.cgi";
54
+ EUserActions["SET_ZONES"] = "setZones.cgi";
55
+ EUserActions["RESET_PTZ_CALIBRATION"] = "resetPtzCalibration.cgi";
56
+ EUserActions["LOCK_API"] = "lockApi.cgi";
57
+ EUserActions["UNLOCK_API"] = "unlockApi.cgi";
58
+ })(EUserActions || (exports.EUserActions = EUserActions = {}));
59
+ const eventsDataSchema = zod_1.z.union([
60
+ zod_1.z.object({ type: zod_1.z.literal('CAMERA_POSITION') }).merge(wsCameraPositionDataSchema),
62
61
  zod_1.z.object({
63
- cgi: zod_1.z.literal(PlaneTrackerUserActions.TRACK_ICAO),
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) }),
70
+ zod_1.z.object({
71
+ type: zod_1.z.literal('USER_ACTION'),
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({
70
- cgi: zod_1.z.literal(PlaneTrackerUserActions.RESET_ICAO),
78
+ type: zod_1.z.literal('USER_ACTION'),
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({
75
- cgi: zod_1.z.literal(PlaneTrackerUserActions.SET_PRIORITY_LIST),
85
+ type: zod_1.z.literal('USER_ACTION'),
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({
81
- cgi: zod_1.z.literal(PlaneTrackerUserActions.SET_BLACK_LIST),
92
+ type: zod_1.z.literal('USER_ACTION'),
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({
87
- cgi: zod_1.z.literal(PlaneTrackerUserActions.SET_WHITE_LIST),
99
+ type: zod_1.z.literal('USER_ACTION'),
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({
93
- cgi: zod_1.z.literal(PlaneTrackerUserActions.GO_TO_COORDINATES),
106
+ type: zod_1.z.literal('USER_ACTION'),
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({
101
- cgi: zod_1.z.literal(PlaneTrackerUserActions.SET_TRACKING_MODE),
113
+ type: zod_1.z.literal('USER_ACTION'),
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({
107
- cgi: zod_1.z.literal(PlaneTrackerUserActions.SET_ZONES),
120
+ type: zod_1.z.literal('USER_ACTION'),
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({
113
- cgi: zod_1.z.literal(PlaneTrackerUserActions.RESET_PTZ_CALIBRATION),
114
- ip: zod_1.z.string(),
115
- params: apiStringUserSchema,
116
- }),
117
- zod_1.z.object({
118
- cgi: zod_1.z.literal(PlaneTrackerUserActions.LOCK_API),
127
+ type: zod_1.z.literal('USER_ACTION'),
128
+ cgi: zod_1.z.literal(EUserActions.RESET_PTZ_CALIBRATION),
119
129
  ip: zod_1.z.string(),
120
- params: apiStringUserSchema.extend({
121
- timeout: zod_1.z.string(),
122
- }),
130
+ params: userSchema,
131
+ postJsonBody: zod_1.z.any(),
123
132
  }),
124
133
  zod_1.z.object({
125
- cgi: zod_1.z.literal(PlaneTrackerUserActions.UNLOCK_API),
134
+ type: zod_1.z.literal('USER_ACTION'),
135
+ cgi: zod_1.z.literal(EUserActions.LOCK_API),
126
136
  ip: zod_1.z.string(),
127
- params: apiStringUserSchema,
128
- }),
129
- ]);
130
- const ptrEventsDataSchema = zod_1.z.discriminatedUnion('type', [
131
- zod_1.z.object({
132
- type: zod_1.z.literal('CAMERA_POSITION'),
133
- lat: zod_1.z.number(),
134
- lon: zod_1.z.number(),
135
- azimuth: zod_1.z.number().min(0).max(360),
136
- elevation: zod_1.z.number().min(-90).max(90),
137
- fov: zod_1.z.number(),
138
- }),
139
- zod_1.z.object({
140
- type: zod_1.z.literal('TRACKING_START'),
141
- icao: zod_1.z.string(),
142
- }),
143
- zod_1.z.object({
144
- type: zod_1.z.literal('TRACKING_STOP'),
145
- }),
146
- zod_1.z.object({
147
- type: zod_1.z.literal('FLIGHT_LIST'),
148
- list: zod_1.z.array(apiFlightDataSchema),
137
+ params: userSchema.extend({ timeout: zod_1.z.string() }),
138
+ postJsonBody: zod_1.z.any(),
149
139
  }),
150
140
  zod_1.z.object({
151
141
  type: zod_1.z.literal('USER_ACTION'),
142
+ cgi: zod_1.z.literal(EUserActions.UNLOCK_API),
152
143
  ip: zod_1.z.string(),
153
- params: apiStringUserSchema.extend({
154
- lat: zod_1.z.string().optional(),
155
- lon: zod_1.z.string().optional(),
156
- timeout: zod_1.z.string().optional(),
157
- }),
158
- cgi: zod_1.z.enum([
159
- PlaneTrackerUserActions.TRACK_ICAO,
160
- PlaneTrackerUserActions.RESET_ICAO,
161
- PlaneTrackerUserActions.SET_PRIORITY_LIST,
162
- PlaneTrackerUserActions.SET_BLACK_LIST,
163
- PlaneTrackerUserActions.SET_WHITE_LIST,
164
- PlaneTrackerUserActions.GO_TO_COORDINATES,
165
- PlaneTrackerUserActions.SET_TRACKING_MODE,
166
- PlaneTrackerUserActions.SET_ZONES,
167
- PlaneTrackerUserActions.RESET_PTZ_CALIBRATION,
168
- PlaneTrackerUserActions.LOCK_API,
169
- PlaneTrackerUserActions.UNLOCK_API,
170
- ]),
144
+ params: userSchema,
171
145
  postJsonBody: zod_1.z.any(),
172
146
  }),
173
- zod_1.z.object({
174
- type: zod_1.z.literal('CONNECTED_USERS'),
175
- users: zod_1.z.array(apiUserSchema),
176
- }),
147
+ zod_1.z.object({ type: zod_1.z.literal('CONNECTED_USERS'), users: zod_1.z.array(apiUserSchema) }),
177
148
  zod_1.z.object({
178
149
  type: zod_1.z.literal('FORCE_TRACKING_STATUS'),
179
150
  enabled: zod_1.z.boolean(),
180
151
  icao: zod_1.z.string().optional(),
152
+ targetId: zod_1.z.string().optional(),
181
153
  }),
182
- zod_1.z.object({
183
- type: zod_1.z.literal('API_LOCK_STATUS'),
184
- isLocked: zod_1.z.boolean(),
185
- user: apiUserSchema.optional(),
186
- }),
154
+ zod_1.z.object({ type: zod_1.z.literal('API_LOCK_STATUS'), isLocked: zod_1.z.boolean(), user: apiUserSchema.optional() }),
187
155
  ]);
188
- exports.ptrEventsSchema = zod_1.z.discriminatedUnion('type', [
189
- zod_1.z.object({ type: zod_1.z.literal('init'), data: ptrEventsDataSchema }),
190
- ...ptrEventsDataSchema.options,
156
+ exports.ptrEventsSchema = zod_1.z.union([
157
+ zod_1.z.object({ type: zod_1.z.literal('init'), data: eventsDataSchema }),
158
+ ...eventsDataSchema.options,
191
159
  ]);
@@ -1,9 +1,8 @@
1
1
  import { IWsClient } from '../internal/types';
2
2
  import { WsEvents } from '../internal/WsEvents';
3
- import { TApiUser } from '../types/PlaneTrackerAPI';
4
- import { TPlaneTrackerEvent } from '../types/ws/PlaneTrackerEvents';
5
- export declare class PlaneTrackerEvents extends WsEvents<TPlaneTrackerEvent> {
3
+ import { TEventData, TApiUser } from '../types/ws/PlaneTrackerEvents';
4
+ export declare class PlaneTrackerEvents extends WsEvents<TEventData> {
6
5
  private _apiUser;
7
- constructor(ws: IWsClient, _apiUser: TApiUser);
6
+ constructor(ws: IWsClient, _apiUser: Omit<TApiUser, 'ip'>);
8
7
  private sendInitMsg;
9
8
  }
@@ -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 === PlaneTrackerEvents_1.PlaneTrackerWsEvents.USER_ACTION) {
12
- const { type, ...actionData } = parsedData;
13
- const userAction = PlaneTrackerEvents_1.planeTrackerUserActionData.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);
@@ -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'),
@@ -323,3 +324,41 @@ export const zonesSchema = z.object({
323
324
  }))
324
325
  .default([]),
325
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);
340
+ export const ADSB_CATEGORY_IDS = {
341
+ A_LIGHT: 'A_LIGHT',
342
+ A_SMALL: 'A_SMALL',
343
+ A_LARGE: 'A_LARGE',
344
+ A_HIGH_VORTEX: 'A_HIGH_VORTEX',
345
+ A_HEAVY: 'A_HEAVY',
346
+ A_HIGH_PERF: 'A_HIGH_PERF',
347
+ A_ROTORCRAFT: 'A_ROTORCRAFT',
348
+ B_GLIDER: 'B_GLIDER',
349
+ B_LIGHTER_THAN_AIR: 'B_LIGHTER_THAN_AIR',
350
+ B_PARACHUTIST: 'B_PARACHUTIST',
351
+ B_ULTRALIGHT: 'B_ULTRALIGHT',
352
+ B_UAV: 'B_UAV',
353
+ B_SPACE: 'B_SPACE',
354
+ C_SURFACE_EMERGENCY: 'C_SURFACE_EMERGENCY',
355
+ C_SERVICE_VEHICLE: 'C_SERVICE_VEHICLE',
356
+ C_POINT_OBSTACLE: 'C_POINT_OBSTACLE',
357
+ C_CLUSTER_OBSTACLE: 'C_CLUSTER_OBSTACLE',
358
+ C_LINE_OBSTACLE: 'C_LINE_OBSTACLE',
359
+ UNKNOWN: 'UNKNOWN',
360
+ };
361
+ export const REMOTE_ID_CATEGORY_IDS = {
362
+ DRONE: 'DRONE',
363
+ OPERATOR: 'OPERATOR',
364
+ };