camstreamerlib 4.0.7 → 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,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);
@@ -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',
@@ -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.8",
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: {
@@ -701,10 +701,13 @@ export type TServerSettings = z.infer<typeof serverSettingsSchema>;
701
701
  export type ICAO = string;
702
702
  export declare const getIcaoSchema: z.ZodObject<{
703
703
  icao: z.ZodString;
704
+ targetId: z.ZodString;
704
705
  }, "strip", z.ZodTypeAny, {
705
706
  icao: string;
707
+ targetId: string;
706
708
  }, {
707
709
  icao: string;
710
+ targetId: string;
708
711
  }>;
709
712
  export type TGetIcaoByOption = 'registration' | 'callsign';
710
713
  export declare const trackingModeSchema: z.ZodObject<{
@@ -1037,18 +1040,90 @@ export declare const zonesSchema: z.ZodObject<{
1037
1040
  export type TZones = z.infer<typeof zonesSchema>;
1038
1041
  export declare const domainIdSchema: z.ZodEnum<["adsb", "remoteId"]>;
1039
1042
  export type TDomainId = z.infer<typeof domainIdSchema>;
1040
- export type TCategoryIcon = 'small' | 'large' | 'heavy' | 'helicopter' | 'drone' | 'operator' | 'unknown';
1041
- export type TCategoryDescriptor = {
1043
+ declare const categoryIconSchema: z.ZodEnum<["small", "large", "heavy", "helicopter", "drone", "operator", "unknown"]>;
1044
+ export type TCategoryIcon = z.infer<typeof categoryIconSchema>;
1045
+ declare const categoryDescriptorSchema: z.ZodObject<{
1046
+ categoryId: z.ZodString;
1047
+ uiName: z.ZodString;
1048
+ icon: z.ZodEnum<["small", "large", "heavy", "helicopter", "drone", "operator", "unknown"]>;
1049
+ }, "strip", z.ZodTypeAny, {
1042
1050
  categoryId: string;
1043
1051
  uiName: string;
1044
- icon: TCategoryIcon;
1045
- };
1046
- export type TDomainDescriptor = {
1052
+ icon: "unknown" | "small" | "large" | "heavy" | "helicopter" | "drone" | "operator";
1053
+ }, {
1054
+ categoryId: string;
1047
1055
  uiName: string;
1048
- icon: TCategoryIcon;
1049
- categoryList: TCategoryDescriptor[];
1050
- };
1051
- export type TDomainList = Record<TDomainId, TDomainDescriptor>;
1056
+ icon: "unknown" | "small" | "large" | "heavy" | "helicopter" | "drone" | "operator";
1057
+ }>;
1058
+ export type TCategoryDescriptor = z.infer<typeof categoryDescriptorSchema>;
1059
+ declare const domainDescriptorSchema: z.ZodObject<{
1060
+ uiName: z.ZodString;
1061
+ icon: z.ZodEnum<["small", "large", "heavy", "helicopter", "drone", "operator", "unknown"]>;
1062
+ categoryList: z.ZodArray<z.ZodObject<{
1063
+ categoryId: z.ZodString;
1064
+ uiName: z.ZodString;
1065
+ icon: z.ZodEnum<["small", "large", "heavy", "helicopter", "drone", "operator", "unknown"]>;
1066
+ }, "strip", z.ZodTypeAny, {
1067
+ categoryId: string;
1068
+ uiName: string;
1069
+ icon: "unknown" | "small" | "large" | "heavy" | "helicopter" | "drone" | "operator";
1070
+ }, {
1071
+ categoryId: string;
1072
+ uiName: string;
1073
+ icon: "unknown" | "small" | "large" | "heavy" | "helicopter" | "drone" | "operator";
1074
+ }>, "many">;
1075
+ }, "strip", z.ZodTypeAny, {
1076
+ uiName: string;
1077
+ icon: "unknown" | "small" | "large" | "heavy" | "helicopter" | "drone" | "operator";
1078
+ categoryList: {
1079
+ categoryId: string;
1080
+ uiName: string;
1081
+ icon: "unknown" | "small" | "large" | "heavy" | "helicopter" | "drone" | "operator";
1082
+ }[];
1083
+ }, {
1084
+ uiName: string;
1085
+ icon: "unknown" | "small" | "large" | "heavy" | "helicopter" | "drone" | "operator";
1086
+ categoryList: {
1087
+ categoryId: string;
1088
+ uiName: string;
1089
+ icon: "unknown" | "small" | "large" | "heavy" | "helicopter" | "drone" | "operator";
1090
+ }[];
1091
+ }>;
1092
+ export type TDomainDescriptor = z.infer<typeof domainDescriptorSchema>;
1093
+ export declare const domainListSchema: z.ZodRecord<z.ZodEnum<["adsb", "remoteId"]>, z.ZodObject<{
1094
+ uiName: z.ZodString;
1095
+ icon: z.ZodEnum<["small", "large", "heavy", "helicopter", "drone", "operator", "unknown"]>;
1096
+ categoryList: z.ZodArray<z.ZodObject<{
1097
+ categoryId: z.ZodString;
1098
+ uiName: z.ZodString;
1099
+ icon: z.ZodEnum<["small", "large", "heavy", "helicopter", "drone", "operator", "unknown"]>;
1100
+ }, "strip", z.ZodTypeAny, {
1101
+ categoryId: string;
1102
+ uiName: string;
1103
+ icon: "unknown" | "small" | "large" | "heavy" | "helicopter" | "drone" | "operator";
1104
+ }, {
1105
+ categoryId: string;
1106
+ uiName: string;
1107
+ icon: "unknown" | "small" | "large" | "heavy" | "helicopter" | "drone" | "operator";
1108
+ }>, "many">;
1109
+ }, "strip", z.ZodTypeAny, {
1110
+ uiName: string;
1111
+ icon: "unknown" | "small" | "large" | "heavy" | "helicopter" | "drone" | "operator";
1112
+ categoryList: {
1113
+ categoryId: string;
1114
+ uiName: string;
1115
+ icon: "unknown" | "small" | "large" | "heavy" | "helicopter" | "drone" | "operator";
1116
+ }[];
1117
+ }, {
1118
+ uiName: string;
1119
+ icon: "unknown" | "small" | "large" | "heavy" | "helicopter" | "drone" | "operator";
1120
+ categoryList: {
1121
+ categoryId: string;
1122
+ uiName: string;
1123
+ icon: "unknown" | "small" | "large" | "heavy" | "helicopter" | "drone" | "operator";
1124
+ }[];
1125
+ }>>;
1126
+ export type TDomainList = z.infer<typeof domainListSchema>;
1052
1127
  export declare const ADSB_CATEGORY_IDS: {
1053
1128
  readonly A_LIGHT: "A_LIGHT";
1054
1129
  readonly A_SMALL: "A_SMALL";