camstreamerlib 4.0.5 → 4.0.7
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.
- package/cjs/PlaneTrackerAPI.d.ts +28 -10
- package/cjs/PlaneTrackerAPI.js +6 -13
- package/cjs/types/PlaneTrackerAPI.d.ts +150 -22
- package/cjs/types/PlaneTrackerAPI.js +40 -7
- package/cjs/types/ws/PlaneTrackerEvents.d.ts +265 -161
- package/cjs/types/ws/PlaneTrackerEvents.js +62 -81
- package/cjs/ws/PlaneTrackerEvents.d.ts +3 -4
- package/cjs/ws/PlaneTrackerEvents.js +2 -2
- package/esm/PlaneTrackerAPI.js +7 -14
- package/esm/types/PlaneTrackerAPI.js +39 -6
- package/esm/types/ws/PlaneTrackerEvents.js +62 -81
- package/esm/ws/PlaneTrackerEvents.js +3 -3
- package/package.json +1 -1
- package/types/PlaneTrackerAPI.d.ts +28 -10
- package/types/types/PlaneTrackerAPI.d.ts +150 -22
- package/types/types/ws/PlaneTrackerEvents.d.ts +265 -161
- package/types/ws/PlaneTrackerEvents.d.ts +3 -4
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ptrEventsSchema = exports.
|
|
3
|
+
exports.ptrEventsSchema = exports.wsUserActionData = exports.EUserActions = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const PlaneTrackerAPI_1 = require("../PlaneTrackerAPI");
|
|
6
|
-
const
|
|
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,6 +26,13 @@ const apiFlightDataSchema = zod_1.z.object({
|
|
|
23
26
|
emergencyState: zod_1.z.boolean(),
|
|
24
27
|
emergencyStatusMessage: zod_1.z.string(),
|
|
25
28
|
});
|
|
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(),
|
|
35
|
+
});
|
|
26
36
|
const apiUserSchema = zod_1.z.object({
|
|
27
37
|
userId: zod_1.z.string(),
|
|
28
38
|
userName: zod_1.z.string(),
|
|
@@ -34,78 +44,53 @@ const apiStringUserSchema = zod_1.z.object({
|
|
|
34
44
|
userName: zod_1.z.string(),
|
|
35
45
|
userPriority: zod_1.z.string(),
|
|
36
46
|
});
|
|
37
|
-
var
|
|
38
|
-
(function (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
PlaneTrackerUserActions["SET_WHITE_LIST"] = "setWhiteList.cgi";
|
|
55
|
-
PlaneTrackerUserActions["GO_TO_COORDINATES"] = "goToCoordinates.cgi";
|
|
56
|
-
PlaneTrackerUserActions["SET_TRACKING_MODE"] = "setTrackingMode.cgi";
|
|
57
|
-
PlaneTrackerUserActions["SET_ZONES"] = "setZones.cgi";
|
|
58
|
-
PlaneTrackerUserActions["RESET_PTZ_CALIBRATION"] = "resetPtzCalibration.cgi";
|
|
59
|
-
PlaneTrackerUserActions["LOCK_API"] = "lockApi.cgi";
|
|
60
|
-
PlaneTrackerUserActions["UNLOCK_API"] = "unlockApi.cgi";
|
|
61
|
-
})(PlaneTrackerUserActions || (exports.PlaneTrackerUserActions = PlaneTrackerUserActions = {}));
|
|
62
|
-
exports.planeTrackerUserActionData = zod_1.z.discriminatedUnion('cgi', [
|
|
63
|
-
zod_1.z.object({
|
|
64
|
-
cgi: zod_1.z.literal(PlaneTrackerUserActions.TRACK_ICAO),
|
|
47
|
+
var EUserActions;
|
|
48
|
+
(function (EUserActions) {
|
|
49
|
+
EUserActions["TRACK_ICAO"] = "trackIcao.cgi";
|
|
50
|
+
EUserActions["RESET_ICAO"] = "resetIcao.cgi";
|
|
51
|
+
EUserActions["SET_PRIORITY_LIST"] = "setPriorityList.cgi";
|
|
52
|
+
EUserActions["SET_BLACK_LIST"] = "setBlackList.cgi";
|
|
53
|
+
EUserActions["SET_WHITE_LIST"] = "setWhiteList.cgi";
|
|
54
|
+
EUserActions["GO_TO_COORDINATES"] = "goToCoordinates.cgi";
|
|
55
|
+
EUserActions["SET_TRACKING_MODE"] = "setTrackingMode.cgi";
|
|
56
|
+
EUserActions["SET_ZONES"] = "setZones.cgi";
|
|
57
|
+
EUserActions["RESET_PTZ_CALIBRATION"] = "resetPtzCalibration.cgi";
|
|
58
|
+
EUserActions["LOCK_API"] = "lockApi.cgi";
|
|
59
|
+
EUserActions["UNLOCK_API"] = "unlockApi.cgi";
|
|
60
|
+
})(EUserActions || (exports.EUserActions = EUserActions = {}));
|
|
61
|
+
exports.wsUserActionData = zod_1.z.discriminatedUnion('cgi', [
|
|
62
|
+
zod_1.z.object({
|
|
63
|
+
cgi: zod_1.z.literal(EUserActions.TRACK_ICAO),
|
|
65
64
|
ip: zod_1.z.string(),
|
|
66
65
|
params: apiStringUserSchema.extend({
|
|
67
66
|
icao: zod_1.z.string(),
|
|
68
67
|
}),
|
|
69
68
|
}),
|
|
70
69
|
zod_1.z.object({
|
|
71
|
-
cgi: zod_1.z.literal(
|
|
70
|
+
cgi: zod_1.z.literal(EUserActions.RESET_ICAO),
|
|
72
71
|
ip: zod_1.z.string(),
|
|
73
72
|
params: apiStringUserSchema,
|
|
74
73
|
}),
|
|
75
74
|
zod_1.z.object({
|
|
76
|
-
cgi: zod_1.z.literal(
|
|
75
|
+
cgi: zod_1.z.literal(EUserActions.SET_PRIORITY_LIST),
|
|
77
76
|
ip: zod_1.z.string(),
|
|
78
77
|
params: apiStringUserSchema,
|
|
79
|
-
postJsonBody:
|
|
80
|
-
priorityList: zod_1.z.array(zod_1.z.string()),
|
|
81
|
-
}),
|
|
78
|
+
postJsonBody: PlaneTrackerAPI_1.priorityListSchema,
|
|
82
79
|
}),
|
|
83
80
|
zod_1.z.object({
|
|
84
|
-
cgi: zod_1.z.literal(
|
|
81
|
+
cgi: zod_1.z.literal(EUserActions.SET_BLACK_LIST),
|
|
85
82
|
ip: zod_1.z.string(),
|
|
86
83
|
params: apiStringUserSchema,
|
|
87
|
-
postJsonBody:
|
|
88
|
-
typePriorityList: zod_1.z.array(zod_1.z.string()),
|
|
89
|
-
}),
|
|
84
|
+
postJsonBody: PlaneTrackerAPI_1.blackListSchema,
|
|
90
85
|
}),
|
|
91
86
|
zod_1.z.object({
|
|
92
|
-
cgi: zod_1.z.literal(
|
|
87
|
+
cgi: zod_1.z.literal(EUserActions.SET_WHITE_LIST),
|
|
93
88
|
ip: zod_1.z.string(),
|
|
94
89
|
params: apiStringUserSchema,
|
|
95
|
-
postJsonBody:
|
|
96
|
-
blackList: zod_1.z.array(zod_1.z.string()),
|
|
97
|
-
}),
|
|
90
|
+
postJsonBody: PlaneTrackerAPI_1.whiteListSchema,
|
|
98
91
|
}),
|
|
99
92
|
zod_1.z.object({
|
|
100
|
-
cgi: zod_1.z.literal(
|
|
101
|
-
ip: zod_1.z.string(),
|
|
102
|
-
params: apiStringUserSchema,
|
|
103
|
-
postJsonBody: zod_1.z.object({
|
|
104
|
-
whiteList: zod_1.z.array(zod_1.z.string()),
|
|
105
|
-
}),
|
|
106
|
-
}),
|
|
107
|
-
zod_1.z.object({
|
|
108
|
-
cgi: zod_1.z.literal(PlaneTrackerUserActions.GO_TO_COORDINATES),
|
|
93
|
+
cgi: zod_1.z.literal(EUserActions.GO_TO_COORDINATES),
|
|
109
94
|
ip: zod_1.z.string(),
|
|
110
95
|
params: apiStringUserSchema.extend({
|
|
111
96
|
lat: zod_1.z.string(),
|
|
@@ -113,44 +98,41 @@ exports.planeTrackerUserActionData = zod_1.z.discriminatedUnion('cgi', [
|
|
|
113
98
|
}),
|
|
114
99
|
}),
|
|
115
100
|
zod_1.z.object({
|
|
116
|
-
cgi: zod_1.z.literal(
|
|
101
|
+
cgi: zod_1.z.literal(EUserActions.SET_TRACKING_MODE),
|
|
117
102
|
ip: zod_1.z.string(),
|
|
118
103
|
params: apiStringUserSchema,
|
|
119
104
|
postJsonBody: PlaneTrackerAPI_1.trackingModeSchema,
|
|
120
105
|
}),
|
|
121
106
|
zod_1.z.object({
|
|
122
|
-
cgi: zod_1.z.literal(
|
|
107
|
+
cgi: zod_1.z.literal(EUserActions.SET_ZONES),
|
|
123
108
|
ip: zod_1.z.string(),
|
|
124
109
|
params: apiStringUserSchema,
|
|
125
110
|
postJsonBody: PlaneTrackerAPI_1.zonesSchema,
|
|
126
111
|
}),
|
|
127
112
|
zod_1.z.object({
|
|
128
|
-
cgi: zod_1.z.literal(
|
|
113
|
+
cgi: zod_1.z.literal(EUserActions.RESET_PTZ_CALIBRATION),
|
|
129
114
|
ip: zod_1.z.string(),
|
|
130
115
|
params: apiStringUserSchema,
|
|
131
116
|
}),
|
|
132
117
|
zod_1.z.object({
|
|
133
|
-
cgi: zod_1.z.literal(
|
|
118
|
+
cgi: zod_1.z.literal(EUserActions.LOCK_API),
|
|
134
119
|
ip: zod_1.z.string(),
|
|
135
120
|
params: apiStringUserSchema.extend({
|
|
136
121
|
timeout: zod_1.z.string(),
|
|
137
122
|
}),
|
|
138
123
|
}),
|
|
139
124
|
zod_1.z.object({
|
|
140
|
-
cgi: zod_1.z.literal(
|
|
125
|
+
cgi: zod_1.z.literal(EUserActions.UNLOCK_API),
|
|
141
126
|
ip: zod_1.z.string(),
|
|
142
127
|
params: apiStringUserSchema,
|
|
143
128
|
}),
|
|
144
129
|
]);
|
|
145
|
-
const
|
|
146
|
-
zod_1.z
|
|
130
|
+
const eventsDataSchema = zod_1.z.discriminatedUnion('type', [
|
|
131
|
+
zod_1.z
|
|
132
|
+
.object({
|
|
147
133
|
type: zod_1.z.literal('CAMERA_POSITION'),
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
azimuth: zod_1.z.number().min(0).max(360),
|
|
151
|
-
elevation: zod_1.z.number().min(-90).max(90),
|
|
152
|
-
fov: zod_1.z.number(),
|
|
153
|
-
}),
|
|
134
|
+
})
|
|
135
|
+
.merge(wsCameraPositionDataSchema),
|
|
154
136
|
zod_1.z.object({
|
|
155
137
|
type: zod_1.z.literal('TRACKING_START'),
|
|
156
138
|
icao: zod_1.z.string(),
|
|
@@ -160,7 +142,7 @@ const ptrEventsDataSchema = zod_1.z.discriminatedUnion('type', [
|
|
|
160
142
|
}),
|
|
161
143
|
zod_1.z.object({
|
|
162
144
|
type: zod_1.z.literal('FLIGHT_LIST'),
|
|
163
|
-
list: zod_1.z.array(
|
|
145
|
+
list: zod_1.z.array(wsApiFlightDataSchema),
|
|
164
146
|
}),
|
|
165
147
|
zod_1.z.object({
|
|
166
148
|
type: zod_1.z.literal('USER_ACTION'),
|
|
@@ -171,18 +153,17 @@ const ptrEventsDataSchema = zod_1.z.discriminatedUnion('type', [
|
|
|
171
153
|
timeout: zod_1.z.string().optional(),
|
|
172
154
|
}),
|
|
173
155
|
cgi: zod_1.z.enum([
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
PlaneTrackerUserActions.UNLOCK_API,
|
|
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,
|
|
186
167
|
]),
|
|
187
168
|
postJsonBody: zod_1.z.any(),
|
|
188
169
|
}),
|
|
@@ -202,6 +183,6 @@ const ptrEventsDataSchema = zod_1.z.discriminatedUnion('type', [
|
|
|
202
183
|
}),
|
|
203
184
|
]);
|
|
204
185
|
exports.ptrEventsSchema = zod_1.z.discriminatedUnion('type', [
|
|
205
|
-
zod_1.z.object({ type: zod_1.z.literal('init'), data:
|
|
206
|
-
...
|
|
186
|
+
zod_1.z.object({ type: zod_1.z.literal('init'), data: eventsDataSchema }),
|
|
187
|
+
...eventsDataSchema.options,
|
|
207
188
|
]);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { IWsClient } from '../internal/types';
|
|
2
2
|
import { WsEvents } from '../internal/WsEvents';
|
|
3
|
-
import { TApiUser } from '../types/
|
|
4
|
-
|
|
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
|
}
|
|
@@ -8,9 +8,9 @@ class PlaneTrackerEvents extends WsEvents_1.WsEvents {
|
|
|
8
8
|
constructor(ws, _apiUser) {
|
|
9
9
|
super((data) => {
|
|
10
10
|
const parsedData = PlaneTrackerEvents_1.ptrEventsSchema.parse(data);
|
|
11
|
-
if (parsedData.type ===
|
|
11
|
+
if (parsedData.type === 'USER_ACTION') {
|
|
12
12
|
const { type, ...actionData } = parsedData;
|
|
13
|
-
const userAction = PlaneTrackerEvents_1.
|
|
13
|
+
const userAction = PlaneTrackerEvents_1.wsUserActionData.parse(actionData);
|
|
14
14
|
return { ...userAction, type };
|
|
15
15
|
}
|
|
16
16
|
return parsedData;
|
package/esm/PlaneTrackerAPI.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { blackListSchema, cameraSettingsSchema, flightInfoSchema, getIcaoSchema, mapInfoSchema, priorityListSchema, serverSettingsSchema, trackingModeSchema,
|
|
2
|
+
import { blackListSchema, cameraSettingsSchema, 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';
|
|
@@ -118,31 +118,24 @@ export class PlaneTrackerAPI extends BasicAPI {
|
|
|
118
118
|
}
|
|
119
119
|
async getPriorityList(options) {
|
|
120
120
|
const res = await this._getJson(`${BASE_PATH}/package/getPriorityList.cgi`, undefined, options);
|
|
121
|
-
return priorityListSchema.parse(res)
|
|
121
|
+
return priorityListSchema.parse(res);
|
|
122
122
|
}
|
|
123
123
|
async setPriorityList(priorityList, options) {
|
|
124
|
-
await this._postJsonEncoded(`${BASE_PATH}/package/setPriorityList.cgi`,
|
|
125
|
-
}
|
|
126
|
-
async getTypePriorityList(options) {
|
|
127
|
-
const res = await this._getJson(`${BASE_PATH}/package/getTypePriorityList.cgi`, undefined, options);
|
|
128
|
-
return typePriorityListSchema.parse(res).typePriorityList;
|
|
129
|
-
}
|
|
130
|
-
async setTypePriorityList(typePriorityList, options) {
|
|
131
|
-
await this._postJsonEncoded(`${BASE_PATH}/package/setTypePriorityList.cgi`, { typePriorityList }, this.apiUser, options);
|
|
124
|
+
await this._postJsonEncoded(`${BASE_PATH}/package/setPriorityList.cgi`, priorityList, this.apiUser, options);
|
|
132
125
|
}
|
|
133
126
|
async getWhiteList(options) {
|
|
134
127
|
const res = await this._getJson(`${BASE_PATH}/package/getWhiteList.cgi`, undefined, options);
|
|
135
|
-
return whiteListSchema.parse(res)
|
|
128
|
+
return whiteListSchema.parse(res);
|
|
136
129
|
}
|
|
137
130
|
async setWhiteList(whiteList, options) {
|
|
138
|
-
await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`,
|
|
131
|
+
await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, whiteList, this.apiUser, options);
|
|
139
132
|
}
|
|
140
133
|
async getBlackList(options) {
|
|
141
134
|
const res = await this._getJson(`${BASE_PATH}/package/getBlackList.cgi`, undefined, options);
|
|
142
|
-
return blackListSchema.parse(res)
|
|
135
|
+
return blackListSchema.parse(res);
|
|
143
136
|
}
|
|
144
137
|
async setBlackList(blackList, options) {
|
|
145
|
-
await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`,
|
|
138
|
+
await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, blackList, this.apiUser, options);
|
|
146
139
|
}
|
|
147
140
|
async fetchMapInfo(options) {
|
|
148
141
|
const res = await this._getJson(`${BASE_PATH}/package/getMapInfo.cgi`, undefined, options);
|
|
@@ -277,17 +277,24 @@ export const flightInfoSchema = z.object({
|
|
|
277
277
|
}))
|
|
278
278
|
.optional(),
|
|
279
279
|
});
|
|
280
|
-
export const
|
|
281
|
-
|
|
280
|
+
export const listEntryDomainSchema = z.enum(['adsb', 'remoteId']);
|
|
281
|
+
export const listEntryIdTypeSchema = z.enum(['icao', 'type_icao', 'drone_mac', 'operator_mac', 'category']);
|
|
282
|
+
export const listEntrySchema = z.object({
|
|
283
|
+
domain: listEntryDomainSchema,
|
|
284
|
+
idType: listEntryIdTypeSchema,
|
|
285
|
+
idValue: z.string().min(1),
|
|
282
286
|
});
|
|
283
|
-
export const
|
|
284
|
-
|
|
287
|
+
export const priorityListEntrySchema = listEntrySchema.extend({
|
|
288
|
+
priority: z.number().int().min(1),
|
|
285
289
|
});
|
|
286
290
|
export const whiteListSchema = z.object({
|
|
287
|
-
|
|
291
|
+
list: z.array(listEntrySchema).default([]),
|
|
288
292
|
});
|
|
289
293
|
export const blackListSchema = z.object({
|
|
290
|
-
|
|
294
|
+
list: z.array(listEntrySchema).default([]),
|
|
295
|
+
});
|
|
296
|
+
export const priorityListSchema = z.object({
|
|
297
|
+
list: z.array(priorityListEntrySchema).default([]),
|
|
291
298
|
});
|
|
292
299
|
export const mapTypeSchema = z.enum(['roadmap', 'satellite']);
|
|
293
300
|
export const mapInfoSchema = z.object({
|
|
@@ -316,3 +323,29 @@ export const zonesSchema = z.object({
|
|
|
316
323
|
}))
|
|
317
324
|
.default([]),
|
|
318
325
|
});
|
|
326
|
+
export const domainIdSchema = z.enum(['adsb', 'remoteId']);
|
|
327
|
+
export const ADSB_CATEGORY_IDS = {
|
|
328
|
+
A_LIGHT: 'A_LIGHT',
|
|
329
|
+
A_SMALL: 'A_SMALL',
|
|
330
|
+
A_LARGE: 'A_LARGE',
|
|
331
|
+
A_HIGH_VORTEX: 'A_HIGH_VORTEX',
|
|
332
|
+
A_HEAVY: 'A_HEAVY',
|
|
333
|
+
A_HIGH_PERF: 'A_HIGH_PERF',
|
|
334
|
+
A_ROTORCRAFT: 'A_ROTORCRAFT',
|
|
335
|
+
B_GLIDER: 'B_GLIDER',
|
|
336
|
+
B_LIGHTER_THAN_AIR: 'B_LIGHTER_THAN_AIR',
|
|
337
|
+
B_PARACHUTIST: 'B_PARACHUTIST',
|
|
338
|
+
B_ULTRALIGHT: 'B_ULTRALIGHT',
|
|
339
|
+
B_UAV: 'B_UAV',
|
|
340
|
+
B_SPACE: 'B_SPACE',
|
|
341
|
+
C_SURFACE_EMERGENCY: 'C_SURFACE_EMERGENCY',
|
|
342
|
+
C_SERVICE_VEHICLE: 'C_SERVICE_VEHICLE',
|
|
343
|
+
C_POINT_OBSTACLE: 'C_POINT_OBSTACLE',
|
|
344
|
+
C_CLUSTER_OBSTACLE: 'C_CLUSTER_OBSTACLE',
|
|
345
|
+
C_LINE_OBSTACLE: 'C_LINE_OBSTACLE',
|
|
346
|
+
UNKNOWN: 'UNKNOWN',
|
|
347
|
+
};
|
|
348
|
+
export const REMOTE_ID_CATEGORY_IDS = {
|
|
349
|
+
DRONE: 'DRONE',
|
|
350
|
+
OPERATOR: 'OPERATOR',
|
|
351
|
+
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { trackingModeSchema, zonesSchema } from '../PlaneTrackerAPI';
|
|
3
|
-
const
|
|
2
|
+
import { blackListSchema, priorityListSchema, trackingModeSchema, whiteListSchema, zonesSchema, domainIdSchema, } from '../PlaneTrackerAPI';
|
|
3
|
+
const wsApiFlightDataSchema = z.object({
|
|
4
|
+
targetId: z.string(),
|
|
4
5
|
icao: z.string(),
|
|
6
|
+
domain: domainIdSchema,
|
|
7
|
+
categoryId: z.string(),
|
|
8
|
+
groupId: z.string().optional(),
|
|
5
9
|
lat: z.number(),
|
|
6
10
|
lon: z.number(),
|
|
7
11
|
heading: z.number(),
|
|
@@ -12,7 +16,6 @@ const apiFlightDataSchema = z.object({
|
|
|
12
16
|
whiteListed: z.boolean(),
|
|
13
17
|
blackListed: z.boolean(),
|
|
14
18
|
priorityListed: z.boolean(),
|
|
15
|
-
typePriorityListed: z.boolean().default(false),
|
|
16
19
|
autoSelectionIgnored: z.boolean(),
|
|
17
20
|
signalQuality: z.number(),
|
|
18
21
|
emitterCategorySet: z.number().default(4),
|
|
@@ -20,6 +23,13 @@ const apiFlightDataSchema = z.object({
|
|
|
20
23
|
emergencyState: z.boolean(),
|
|
21
24
|
emergencyStatusMessage: z.string(),
|
|
22
25
|
});
|
|
26
|
+
const wsCameraPositionDataSchema = z.object({
|
|
27
|
+
lat: z.number(),
|
|
28
|
+
lon: z.number(),
|
|
29
|
+
azimuth: z.number().min(0).max(360),
|
|
30
|
+
elevation: z.number().min(-90).max(90),
|
|
31
|
+
fov: z.number(),
|
|
32
|
+
});
|
|
23
33
|
const apiUserSchema = z.object({
|
|
24
34
|
userId: z.string(),
|
|
25
35
|
userName: z.string(),
|
|
@@ -31,78 +41,53 @@ const apiStringUserSchema = z.object({
|
|
|
31
41
|
userName: z.string(),
|
|
32
42
|
userPriority: z.string(),
|
|
33
43
|
});
|
|
34
|
-
export var
|
|
35
|
-
(function (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
PlaneTrackerUserActions["SET_WHITE_LIST"] = "setWhiteList.cgi";
|
|
52
|
-
PlaneTrackerUserActions["GO_TO_COORDINATES"] = "goToCoordinates.cgi";
|
|
53
|
-
PlaneTrackerUserActions["SET_TRACKING_MODE"] = "setTrackingMode.cgi";
|
|
54
|
-
PlaneTrackerUserActions["SET_ZONES"] = "setZones.cgi";
|
|
55
|
-
PlaneTrackerUserActions["RESET_PTZ_CALIBRATION"] = "resetPtzCalibration.cgi";
|
|
56
|
-
PlaneTrackerUserActions["LOCK_API"] = "lockApi.cgi";
|
|
57
|
-
PlaneTrackerUserActions["UNLOCK_API"] = "unlockApi.cgi";
|
|
58
|
-
})(PlaneTrackerUserActions || (PlaneTrackerUserActions = {}));
|
|
59
|
-
export const planeTrackerUserActionData = z.discriminatedUnion('cgi', [
|
|
60
|
-
z.object({
|
|
61
|
-
cgi: z.literal(PlaneTrackerUserActions.TRACK_ICAO),
|
|
44
|
+
export var EUserActions;
|
|
45
|
+
(function (EUserActions) {
|
|
46
|
+
EUserActions["TRACK_ICAO"] = "trackIcao.cgi";
|
|
47
|
+
EUserActions["RESET_ICAO"] = "resetIcao.cgi";
|
|
48
|
+
EUserActions["SET_PRIORITY_LIST"] = "setPriorityList.cgi";
|
|
49
|
+
EUserActions["SET_BLACK_LIST"] = "setBlackList.cgi";
|
|
50
|
+
EUserActions["SET_WHITE_LIST"] = "setWhiteList.cgi";
|
|
51
|
+
EUserActions["GO_TO_COORDINATES"] = "goToCoordinates.cgi";
|
|
52
|
+
EUserActions["SET_TRACKING_MODE"] = "setTrackingMode.cgi";
|
|
53
|
+
EUserActions["SET_ZONES"] = "setZones.cgi";
|
|
54
|
+
EUserActions["RESET_PTZ_CALIBRATION"] = "resetPtzCalibration.cgi";
|
|
55
|
+
EUserActions["LOCK_API"] = "lockApi.cgi";
|
|
56
|
+
EUserActions["UNLOCK_API"] = "unlockApi.cgi";
|
|
57
|
+
})(EUserActions || (EUserActions = {}));
|
|
58
|
+
export const wsUserActionData = z.discriminatedUnion('cgi', [
|
|
59
|
+
z.object({
|
|
60
|
+
cgi: z.literal(EUserActions.TRACK_ICAO),
|
|
62
61
|
ip: z.string(),
|
|
63
62
|
params: apiStringUserSchema.extend({
|
|
64
63
|
icao: z.string(),
|
|
65
64
|
}),
|
|
66
65
|
}),
|
|
67
66
|
z.object({
|
|
68
|
-
cgi: z.literal(
|
|
67
|
+
cgi: z.literal(EUserActions.RESET_ICAO),
|
|
69
68
|
ip: z.string(),
|
|
70
69
|
params: apiStringUserSchema,
|
|
71
70
|
}),
|
|
72
71
|
z.object({
|
|
73
|
-
cgi: z.literal(
|
|
72
|
+
cgi: z.literal(EUserActions.SET_PRIORITY_LIST),
|
|
74
73
|
ip: z.string(),
|
|
75
74
|
params: apiStringUserSchema,
|
|
76
|
-
postJsonBody:
|
|
77
|
-
priorityList: z.array(z.string()),
|
|
78
|
-
}),
|
|
75
|
+
postJsonBody: priorityListSchema,
|
|
79
76
|
}),
|
|
80
77
|
z.object({
|
|
81
|
-
cgi: z.literal(
|
|
78
|
+
cgi: z.literal(EUserActions.SET_BLACK_LIST),
|
|
82
79
|
ip: z.string(),
|
|
83
80
|
params: apiStringUserSchema,
|
|
84
|
-
postJsonBody:
|
|
85
|
-
typePriorityList: z.array(z.string()),
|
|
86
|
-
}),
|
|
81
|
+
postJsonBody: blackListSchema,
|
|
87
82
|
}),
|
|
88
83
|
z.object({
|
|
89
|
-
cgi: z.literal(
|
|
84
|
+
cgi: z.literal(EUserActions.SET_WHITE_LIST),
|
|
90
85
|
ip: z.string(),
|
|
91
86
|
params: apiStringUserSchema,
|
|
92
|
-
postJsonBody:
|
|
93
|
-
blackList: z.array(z.string()),
|
|
94
|
-
}),
|
|
87
|
+
postJsonBody: whiteListSchema,
|
|
95
88
|
}),
|
|
96
89
|
z.object({
|
|
97
|
-
cgi: z.literal(
|
|
98
|
-
ip: z.string(),
|
|
99
|
-
params: apiStringUserSchema,
|
|
100
|
-
postJsonBody: z.object({
|
|
101
|
-
whiteList: z.array(z.string()),
|
|
102
|
-
}),
|
|
103
|
-
}),
|
|
104
|
-
z.object({
|
|
105
|
-
cgi: z.literal(PlaneTrackerUserActions.GO_TO_COORDINATES),
|
|
90
|
+
cgi: z.literal(EUserActions.GO_TO_COORDINATES),
|
|
106
91
|
ip: z.string(),
|
|
107
92
|
params: apiStringUserSchema.extend({
|
|
108
93
|
lat: z.string(),
|
|
@@ -110,44 +95,41 @@ export const planeTrackerUserActionData = z.discriminatedUnion('cgi', [
|
|
|
110
95
|
}),
|
|
111
96
|
}),
|
|
112
97
|
z.object({
|
|
113
|
-
cgi: z.literal(
|
|
98
|
+
cgi: z.literal(EUserActions.SET_TRACKING_MODE),
|
|
114
99
|
ip: z.string(),
|
|
115
100
|
params: apiStringUserSchema,
|
|
116
101
|
postJsonBody: trackingModeSchema,
|
|
117
102
|
}),
|
|
118
103
|
z.object({
|
|
119
|
-
cgi: z.literal(
|
|
104
|
+
cgi: z.literal(EUserActions.SET_ZONES),
|
|
120
105
|
ip: z.string(),
|
|
121
106
|
params: apiStringUserSchema,
|
|
122
107
|
postJsonBody: zonesSchema,
|
|
123
108
|
}),
|
|
124
109
|
z.object({
|
|
125
|
-
cgi: z.literal(
|
|
110
|
+
cgi: z.literal(EUserActions.RESET_PTZ_CALIBRATION),
|
|
126
111
|
ip: z.string(),
|
|
127
112
|
params: apiStringUserSchema,
|
|
128
113
|
}),
|
|
129
114
|
z.object({
|
|
130
|
-
cgi: z.literal(
|
|
115
|
+
cgi: z.literal(EUserActions.LOCK_API),
|
|
131
116
|
ip: z.string(),
|
|
132
117
|
params: apiStringUserSchema.extend({
|
|
133
118
|
timeout: z.string(),
|
|
134
119
|
}),
|
|
135
120
|
}),
|
|
136
121
|
z.object({
|
|
137
|
-
cgi: z.literal(
|
|
122
|
+
cgi: z.literal(EUserActions.UNLOCK_API),
|
|
138
123
|
ip: z.string(),
|
|
139
124
|
params: apiStringUserSchema,
|
|
140
125
|
}),
|
|
141
126
|
]);
|
|
142
|
-
const
|
|
143
|
-
z
|
|
127
|
+
const eventsDataSchema = z.discriminatedUnion('type', [
|
|
128
|
+
z
|
|
129
|
+
.object({
|
|
144
130
|
type: z.literal('CAMERA_POSITION'),
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
azimuth: z.number().min(0).max(360),
|
|
148
|
-
elevation: z.number().min(-90).max(90),
|
|
149
|
-
fov: z.number(),
|
|
150
|
-
}),
|
|
131
|
+
})
|
|
132
|
+
.merge(wsCameraPositionDataSchema),
|
|
151
133
|
z.object({
|
|
152
134
|
type: z.literal('TRACKING_START'),
|
|
153
135
|
icao: z.string(),
|
|
@@ -157,7 +139,7 @@ const ptrEventsDataSchema = z.discriminatedUnion('type', [
|
|
|
157
139
|
}),
|
|
158
140
|
z.object({
|
|
159
141
|
type: z.literal('FLIGHT_LIST'),
|
|
160
|
-
list: z.array(
|
|
142
|
+
list: z.array(wsApiFlightDataSchema),
|
|
161
143
|
}),
|
|
162
144
|
z.object({
|
|
163
145
|
type: z.literal('USER_ACTION'),
|
|
@@ -168,18 +150,17 @@ const ptrEventsDataSchema = z.discriminatedUnion('type', [
|
|
|
168
150
|
timeout: z.string().optional(),
|
|
169
151
|
}),
|
|
170
152
|
cgi: z.enum([
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
PlaneTrackerUserActions.UNLOCK_API,
|
|
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,
|
|
183
164
|
]),
|
|
184
165
|
postJsonBody: z.any(),
|
|
185
166
|
}),
|
|
@@ -199,6 +180,6 @@ const ptrEventsDataSchema = z.discriminatedUnion('type', [
|
|
|
199
180
|
}),
|
|
200
181
|
]);
|
|
201
182
|
export const ptrEventsSchema = z.discriminatedUnion('type', [
|
|
202
|
-
z.object({ type: z.literal('init'), data:
|
|
203
|
-
...
|
|
183
|
+
z.object({ type: z.literal('init'), data: eventsDataSchema }),
|
|
184
|
+
...eventsDataSchema.options,
|
|
204
185
|
]);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { WsEvents } from '../internal/WsEvents';
|
|
2
|
-
import {
|
|
2
|
+
import { wsUserActionData, ptrEventsSchema } from '../types/ws/PlaneTrackerEvents';
|
|
3
3
|
export class PlaneTrackerEvents extends WsEvents {
|
|
4
4
|
_apiUser;
|
|
5
5
|
constructor(ws, _apiUser) {
|
|
6
6
|
super((data) => {
|
|
7
7
|
const parsedData = ptrEventsSchema.parse(data);
|
|
8
|
-
if (parsedData.type ===
|
|
8
|
+
if (parsedData.type === 'USER_ACTION') {
|
|
9
9
|
const { type, ...actionData } = parsedData;
|
|
10
|
-
const userAction =
|
|
10
|
+
const userAction = wsUserActionData.parse(actionData);
|
|
11
11
|
return { ...userAction, type };
|
|
12
12
|
}
|
|
13
13
|
return parsedData;
|