camstreamerlib 4.0.15 → 4.0.17-979db019

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.
@@ -7,6 +7,9 @@ declare const wsApiFlightDataSchema: z.ZodObject<{
7
7
  groupId: z.ZodOptional<z.ZodString>;
8
8
  lat: z.ZodNumber;
9
9
  lon: z.ZodNumber;
10
+ observedLat: z.ZodNumber;
11
+ observedLon: z.ZodNumber;
12
+ positionTimestamp: z.ZodNumber;
10
13
  heading: z.ZodNumber;
11
14
  groundSpeed: z.ZodNumber;
12
15
  altitudeAMSL: z.ZodNumber;
@@ -28,6 +31,9 @@ declare const wsApiFlightDataSchema: z.ZodObject<{
28
31
  lat: number;
29
32
  lon: number;
30
33
  categoryId: string;
34
+ observedLat: number;
35
+ observedLon: number;
36
+ positionTimestamp: number;
31
37
  heading: number;
32
38
  groundSpeed: number;
33
39
  altitudeAMSL: number;
@@ -50,6 +56,9 @@ declare const wsApiFlightDataSchema: z.ZodObject<{
50
56
  lat: number;
51
57
  lon: number;
52
58
  categoryId: string;
59
+ observedLat: number;
60
+ observedLon: number;
61
+ positionTimestamp: number;
53
62
  heading: number;
54
63
  groundSpeed: number;
55
64
  altitudeAMSL: number;
@@ -72,18 +81,21 @@ declare const wsCameraPositionDataSchema: z.ZodObject<{
72
81
  azimuth: z.ZodNumber;
73
82
  elevation: z.ZodNumber;
74
83
  fov: z.ZodNumber;
84
+ sampledAt: z.ZodNumber;
75
85
  }, "strip", z.ZodTypeAny, {
76
86
  lat: number;
77
87
  lon: number;
78
88
  azimuth: number;
79
89
  elevation: number;
80
90
  fov: number;
91
+ sampledAt: number;
81
92
  }, {
82
93
  lat: number;
83
94
  lon: number;
84
95
  azimuth: number;
85
96
  elevation: number;
86
97
  fov: number;
98
+ sampledAt: number;
87
99
  }>;
88
100
  declare const apiUserSchema: z.ZodObject<{
89
101
  userId: z.ZodString;
@@ -107,6 +119,7 @@ export declare enum EUserActions {
107
119
  TRACK_ICAO = "trackIcao.cgi",
108
120
  TRACK_TARGET = "trackTarget.cgi",
109
121
  RESET_ICAO = "resetIcao.cgi",
122
+ RESET_TARGET = "resetTarget.cgi",
110
123
  SET_PRIORITY_LIST = "setPriorityList.cgi",
111
124
  SET_BLACK_LIST = "setBlackList.cgi",
112
125
  SET_WHITE_LIST = "setWhiteList.cgi",
@@ -125,6 +138,7 @@ declare const eventsDataSchema: z.ZodUnion<readonly [z.ZodObject<{
125
138
  azimuth: z.ZodNumber;
126
139
  elevation: z.ZodNumber;
127
140
  fov: z.ZodNumber;
141
+ sampledAt: z.ZodNumber;
128
142
  }, "strip", z.ZodTypeAny, {
129
143
  type: "CAMERA_POSITION";
130
144
  lat: number;
@@ -132,6 +146,7 @@ declare const eventsDataSchema: z.ZodUnion<readonly [z.ZodObject<{
132
146
  azimuth: number;
133
147
  elevation: number;
134
148
  fov: number;
149
+ sampledAt: number;
135
150
  }, {
136
151
  type: "CAMERA_POSITION";
137
152
  lat: number;
@@ -139,6 +154,7 @@ declare const eventsDataSchema: z.ZodUnion<readonly [z.ZodObject<{
139
154
  azimuth: number;
140
155
  elevation: number;
141
156
  fov: number;
157
+ sampledAt: number;
142
158
  }>, z.ZodObject<{
143
159
  type: z.ZodLiteral<"TRACKING_START">;
144
160
  icao: z.ZodString;
@@ -173,6 +189,9 @@ declare const eventsDataSchema: z.ZodUnion<readonly [z.ZodObject<{
173
189
  groupId: z.ZodOptional<z.ZodString>;
174
190
  lat: z.ZodNumber;
175
191
  lon: z.ZodNumber;
192
+ observedLat: z.ZodNumber;
193
+ observedLon: z.ZodNumber;
194
+ positionTimestamp: z.ZodNumber;
176
195
  heading: z.ZodNumber;
177
196
  groundSpeed: z.ZodNumber;
178
197
  altitudeAMSL: z.ZodNumber;
@@ -194,6 +213,9 @@ declare const eventsDataSchema: z.ZodUnion<readonly [z.ZodObject<{
194
213
  lat: number;
195
214
  lon: number;
196
215
  categoryId: string;
216
+ observedLat: number;
217
+ observedLon: number;
218
+ positionTimestamp: number;
197
219
  heading: number;
198
220
  groundSpeed: number;
199
221
  altitudeAMSL: number;
@@ -216,6 +238,9 @@ declare const eventsDataSchema: z.ZodUnion<readonly [z.ZodObject<{
216
238
  lat: number;
217
239
  lon: number;
218
240
  categoryId: string;
241
+ observedLat: number;
242
+ observedLon: number;
243
+ positionTimestamp: number;
219
244
  heading: number;
220
245
  groundSpeed: number;
221
246
  altitudeAMSL: number;
@@ -241,6 +266,9 @@ declare const eventsDataSchema: z.ZodUnion<readonly [z.ZodObject<{
241
266
  lat: number;
242
267
  lon: number;
243
268
  categoryId: string;
269
+ observedLat: number;
270
+ observedLon: number;
271
+ positionTimestamp: number;
244
272
  heading: number;
245
273
  groundSpeed: number;
246
274
  altitudeAMSL: number;
@@ -266,6 +294,9 @@ declare const eventsDataSchema: z.ZodUnion<readonly [z.ZodObject<{
266
294
  lat: number;
267
295
  lon: number;
268
296
  categoryId: string;
297
+ observedLat: number;
298
+ observedLon: number;
299
+ positionTimestamp: number;
269
300
  heading: number;
270
301
  groundSpeed: number;
271
302
  altitudeAMSL: number;
@@ -408,6 +439,44 @@ declare const eventsDataSchema: z.ZodUnion<readonly [z.ZodObject<{
408
439
  ip: string;
409
440
  cgi: EUserActions.RESET_ICAO;
410
441
  postJsonBody?: any;
442
+ }>, z.ZodObject<{
443
+ type: z.ZodLiteral<"USER_ACTION">;
444
+ cgi: z.ZodLiteral<EUserActions.RESET_TARGET>;
445
+ ip: z.ZodString;
446
+ params: z.ZodObject<{
447
+ userId: z.ZodString;
448
+ userName: z.ZodString;
449
+ userPriority: z.ZodString;
450
+ }, "strip", z.ZodTypeAny, {
451
+ userId: string;
452
+ userName: string;
453
+ userPriority: string;
454
+ }, {
455
+ userId: string;
456
+ userName: string;
457
+ userPriority: string;
458
+ }>;
459
+ postJsonBody: z.ZodAny;
460
+ }, "strip", z.ZodTypeAny, {
461
+ params: {
462
+ userId: string;
463
+ userName: string;
464
+ userPriority: string;
465
+ };
466
+ type: "USER_ACTION";
467
+ ip: string;
468
+ cgi: EUserActions.RESET_TARGET;
469
+ postJsonBody?: any;
470
+ }, {
471
+ params: {
472
+ userId: string;
473
+ userName: string;
474
+ userPriority: string;
475
+ };
476
+ type: "USER_ACTION";
477
+ ip: string;
478
+ cgi: EUserActions.RESET_TARGET;
479
+ postJsonBody?: any;
411
480
  }>, z.ZodObject<{
412
481
  type: z.ZodLiteral<"USER_ACTION">;
413
482
  cgi: z.ZodLiteral<EUserActions.SET_PRIORITY_LIST>;
@@ -1123,6 +1192,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
1123
1192
  azimuth: z.ZodNumber;
1124
1193
  elevation: z.ZodNumber;
1125
1194
  fov: z.ZodNumber;
1195
+ sampledAt: z.ZodNumber;
1126
1196
  }, "strip", z.ZodTypeAny, {
1127
1197
  type: "CAMERA_POSITION";
1128
1198
  lat: number;
@@ -1130,6 +1200,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
1130
1200
  azimuth: number;
1131
1201
  elevation: number;
1132
1202
  fov: number;
1203
+ sampledAt: number;
1133
1204
  }, {
1134
1205
  type: "CAMERA_POSITION";
1135
1206
  lat: number;
@@ -1137,6 +1208,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
1137
1208
  azimuth: number;
1138
1209
  elevation: number;
1139
1210
  fov: number;
1211
+ sampledAt: number;
1140
1212
  }>, z.ZodObject<{
1141
1213
  type: z.ZodLiteral<"TRACKING_START">;
1142
1214
  icao: z.ZodString;
@@ -1171,6 +1243,9 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
1171
1243
  groupId: z.ZodOptional<z.ZodString>;
1172
1244
  lat: z.ZodNumber;
1173
1245
  lon: z.ZodNumber;
1246
+ observedLat: z.ZodNumber;
1247
+ observedLon: z.ZodNumber;
1248
+ positionTimestamp: z.ZodNumber;
1174
1249
  heading: z.ZodNumber;
1175
1250
  groundSpeed: z.ZodNumber;
1176
1251
  altitudeAMSL: z.ZodNumber;
@@ -1192,6 +1267,9 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
1192
1267
  lat: number;
1193
1268
  lon: number;
1194
1269
  categoryId: string;
1270
+ observedLat: number;
1271
+ observedLon: number;
1272
+ positionTimestamp: number;
1195
1273
  heading: number;
1196
1274
  groundSpeed: number;
1197
1275
  altitudeAMSL: number;
@@ -1214,6 +1292,9 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
1214
1292
  lat: number;
1215
1293
  lon: number;
1216
1294
  categoryId: string;
1295
+ observedLat: number;
1296
+ observedLon: number;
1297
+ positionTimestamp: number;
1217
1298
  heading: number;
1218
1299
  groundSpeed: number;
1219
1300
  altitudeAMSL: number;
@@ -1239,6 +1320,9 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
1239
1320
  lat: number;
1240
1321
  lon: number;
1241
1322
  categoryId: string;
1323
+ observedLat: number;
1324
+ observedLon: number;
1325
+ positionTimestamp: number;
1242
1326
  heading: number;
1243
1327
  groundSpeed: number;
1244
1328
  altitudeAMSL: number;
@@ -1264,6 +1348,9 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
1264
1348
  lat: number;
1265
1349
  lon: number;
1266
1350
  categoryId: string;
1351
+ observedLat: number;
1352
+ observedLon: number;
1353
+ positionTimestamp: number;
1267
1354
  heading: number;
1268
1355
  groundSpeed: number;
1269
1356
  altitudeAMSL: number;
@@ -1406,6 +1493,44 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
1406
1493
  ip: string;
1407
1494
  cgi: EUserActions.RESET_ICAO;
1408
1495
  postJsonBody?: any;
1496
+ }>, z.ZodObject<{
1497
+ type: z.ZodLiteral<"USER_ACTION">;
1498
+ cgi: z.ZodLiteral<EUserActions.RESET_TARGET>;
1499
+ ip: z.ZodString;
1500
+ params: z.ZodObject<{
1501
+ userId: z.ZodString;
1502
+ userName: z.ZodString;
1503
+ userPriority: z.ZodString;
1504
+ }, "strip", z.ZodTypeAny, {
1505
+ userId: string;
1506
+ userName: string;
1507
+ userPriority: string;
1508
+ }, {
1509
+ userId: string;
1510
+ userName: string;
1511
+ userPriority: string;
1512
+ }>;
1513
+ postJsonBody: z.ZodAny;
1514
+ }, "strip", z.ZodTypeAny, {
1515
+ params: {
1516
+ userId: string;
1517
+ userName: string;
1518
+ userPriority: string;
1519
+ };
1520
+ type: "USER_ACTION";
1521
+ ip: string;
1522
+ cgi: EUserActions.RESET_TARGET;
1523
+ postJsonBody?: any;
1524
+ }, {
1525
+ params: {
1526
+ userId: string;
1527
+ userName: string;
1528
+ userPriority: string;
1529
+ };
1530
+ type: "USER_ACTION";
1531
+ ip: string;
1532
+ cgi: EUserActions.RESET_TARGET;
1533
+ postJsonBody?: any;
1409
1534
  }>, z.ZodObject<{
1410
1535
  type: z.ZodLiteral<"USER_ACTION">;
1411
1536
  cgi: z.ZodLiteral<EUserActions.SET_PRIORITY_LIST>;
@@ -2120,6 +2245,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2120
2245
  azimuth: number;
2121
2246
  elevation: number;
2122
2247
  fov: number;
2248
+ sampledAt: number;
2123
2249
  } | {
2124
2250
  type: "TRACKING_START";
2125
2251
  icao: string;
@@ -2137,6 +2263,9 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2137
2263
  lat: number;
2138
2264
  lon: number;
2139
2265
  categoryId: string;
2266
+ observedLat: number;
2267
+ observedLon: number;
2268
+ positionTimestamp: number;
2140
2269
  heading: number;
2141
2270
  groundSpeed: number;
2142
2271
  altitudeAMSL: number;
@@ -2185,6 +2314,16 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2185
2314
  ip: string;
2186
2315
  cgi: EUserActions.RESET_ICAO;
2187
2316
  postJsonBody?: any;
2317
+ } | {
2318
+ params: {
2319
+ userId: string;
2320
+ userName: string;
2321
+ userPriority: string;
2322
+ };
2323
+ type: "USER_ACTION";
2324
+ ip: string;
2325
+ cgi: EUserActions.RESET_TARGET;
2326
+ postJsonBody?: any;
2188
2327
  } | {
2189
2328
  params: {
2190
2329
  userId: string;
@@ -2349,6 +2488,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2349
2488
  azimuth: number;
2350
2489
  elevation: number;
2351
2490
  fov: number;
2491
+ sampledAt: number;
2352
2492
  } | {
2353
2493
  type: "TRACKING_START";
2354
2494
  icao: string;
@@ -2366,6 +2506,9 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2366
2506
  lat: number;
2367
2507
  lon: number;
2368
2508
  categoryId: string;
2509
+ observedLat: number;
2510
+ observedLon: number;
2511
+ positionTimestamp: number;
2369
2512
  heading: number;
2370
2513
  groundSpeed: number;
2371
2514
  altitudeAMSL: number;
@@ -2414,6 +2557,16 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2414
2557
  ip: string;
2415
2558
  cgi: EUserActions.RESET_ICAO;
2416
2559
  postJsonBody?: any;
2560
+ } | {
2561
+ params: {
2562
+ userId: string;
2563
+ userName: string;
2564
+ userPriority: string;
2565
+ };
2566
+ type: "USER_ACTION";
2567
+ ip: string;
2568
+ cgi: EUserActions.RESET_TARGET;
2569
+ postJsonBody?: any;
2417
2570
  } | {
2418
2571
  params: {
2419
2572
  userId: string;
@@ -2577,6 +2730,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2577
2730
  azimuth: z.ZodNumber;
2578
2731
  elevation: z.ZodNumber;
2579
2732
  fov: z.ZodNumber;
2733
+ sampledAt: z.ZodNumber;
2580
2734
  }, "strip", z.ZodTypeAny, {
2581
2735
  type: "CAMERA_POSITION";
2582
2736
  lat: number;
@@ -2584,6 +2738,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2584
2738
  azimuth: number;
2585
2739
  elevation: number;
2586
2740
  fov: number;
2741
+ sampledAt: number;
2587
2742
  }, {
2588
2743
  type: "CAMERA_POSITION";
2589
2744
  lat: number;
@@ -2591,6 +2746,7 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2591
2746
  azimuth: number;
2592
2747
  elevation: number;
2593
2748
  fov: number;
2749
+ sampledAt: number;
2594
2750
  }>, z.ZodObject<{
2595
2751
  type: z.ZodLiteral<"TRACKING_START">;
2596
2752
  icao: z.ZodString;
@@ -2625,6 +2781,9 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2625
2781
  groupId: z.ZodOptional<z.ZodString>;
2626
2782
  lat: z.ZodNumber;
2627
2783
  lon: z.ZodNumber;
2784
+ observedLat: z.ZodNumber;
2785
+ observedLon: z.ZodNumber;
2786
+ positionTimestamp: z.ZodNumber;
2628
2787
  heading: z.ZodNumber;
2629
2788
  groundSpeed: z.ZodNumber;
2630
2789
  altitudeAMSL: z.ZodNumber;
@@ -2646,6 +2805,9 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2646
2805
  lat: number;
2647
2806
  lon: number;
2648
2807
  categoryId: string;
2808
+ observedLat: number;
2809
+ observedLon: number;
2810
+ positionTimestamp: number;
2649
2811
  heading: number;
2650
2812
  groundSpeed: number;
2651
2813
  altitudeAMSL: number;
@@ -2668,6 +2830,9 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2668
2830
  lat: number;
2669
2831
  lon: number;
2670
2832
  categoryId: string;
2833
+ observedLat: number;
2834
+ observedLon: number;
2835
+ positionTimestamp: number;
2671
2836
  heading: number;
2672
2837
  groundSpeed: number;
2673
2838
  altitudeAMSL: number;
@@ -2693,6 +2858,9 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2693
2858
  lat: number;
2694
2859
  lon: number;
2695
2860
  categoryId: string;
2861
+ observedLat: number;
2862
+ observedLon: number;
2863
+ positionTimestamp: number;
2696
2864
  heading: number;
2697
2865
  groundSpeed: number;
2698
2866
  altitudeAMSL: number;
@@ -2718,6 +2886,9 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2718
2886
  lat: number;
2719
2887
  lon: number;
2720
2888
  categoryId: string;
2889
+ observedLat: number;
2890
+ observedLon: number;
2891
+ positionTimestamp: number;
2721
2892
  heading: number;
2722
2893
  groundSpeed: number;
2723
2894
  altitudeAMSL: number;
@@ -2860,6 +3031,44 @@ export declare const ptrEventsSchema: z.ZodUnion<readonly [z.ZodObject<{
2860
3031
  ip: string;
2861
3032
  cgi: EUserActions.RESET_ICAO;
2862
3033
  postJsonBody?: any;
3034
+ }>, z.ZodObject<{
3035
+ type: z.ZodLiteral<"USER_ACTION">;
3036
+ cgi: z.ZodLiteral<EUserActions.RESET_TARGET>;
3037
+ ip: z.ZodString;
3038
+ params: z.ZodObject<{
3039
+ userId: z.ZodString;
3040
+ userName: z.ZodString;
3041
+ userPriority: z.ZodString;
3042
+ }, "strip", z.ZodTypeAny, {
3043
+ userId: string;
3044
+ userName: string;
3045
+ userPriority: string;
3046
+ }, {
3047
+ userId: string;
3048
+ userName: string;
3049
+ userPriority: string;
3050
+ }>;
3051
+ postJsonBody: z.ZodAny;
3052
+ }, "strip", z.ZodTypeAny, {
3053
+ params: {
3054
+ userId: string;
3055
+ userName: string;
3056
+ userPriority: string;
3057
+ };
3058
+ type: "USER_ACTION";
3059
+ ip: string;
3060
+ cgi: EUserActions.RESET_TARGET;
3061
+ postJsonBody?: any;
3062
+ }, {
3063
+ params: {
3064
+ userId: string;
3065
+ userName: string;
3066
+ userPriority: string;
3067
+ };
3068
+ type: "USER_ACTION";
3069
+ ip: string;
3070
+ cgi: EUserActions.RESET_TARGET;
3071
+ postJsonBody?: any;
2863
3072
  }>, z.ZodObject<{
2864
3073
  type: z.ZodLiteral<"USER_ACTION">;
2865
3074
  cgi: z.ZodLiteral<EUserActions.SET_PRIORITY_LIST>;
@@ -11,6 +11,9 @@ const wsApiFlightDataSchema = zod_1.z.object({
11
11
  groupId: zod_1.z.string().optional(),
12
12
  lat: zod_1.z.number(),
13
13
  lon: zod_1.z.number(),
14
+ observedLat: zod_1.z.number(),
15
+ observedLon: zod_1.z.number(),
16
+ positionTimestamp: zod_1.z.number(),
14
17
  heading: zod_1.z.number(),
15
18
  groundSpeed: zod_1.z.number(),
16
19
  altitudeAMSL: zod_1.z.number(),
@@ -32,6 +35,7 @@ const wsCameraPositionDataSchema = zod_1.z.object({
32
35
  azimuth: zod_1.z.number().min(0).max(360),
33
36
  elevation: zod_1.z.number().min(-90).max(90),
34
37
  fov: zod_1.z.number(),
38
+ sampledAt: zod_1.z.number(),
35
39
  });
36
40
  const userSchema = zod_1.z.object({
37
41
  userId: zod_1.z.string(),
@@ -47,6 +51,7 @@ var EUserActions;
47
51
  EUserActions["TRACK_ICAO"] = "trackIcao.cgi";
48
52
  EUserActions["TRACK_TARGET"] = "trackTarget.cgi";
49
53
  EUserActions["RESET_ICAO"] = "resetIcao.cgi";
54
+ EUserActions["RESET_TARGET"] = "resetTarget.cgi";
50
55
  EUserActions["SET_PRIORITY_LIST"] = "setPriorityList.cgi";
51
56
  EUserActions["SET_BLACK_LIST"] = "setBlackList.cgi";
52
57
  EUserActions["SET_WHITE_LIST"] = "setWhiteList.cgi";
@@ -89,6 +94,13 @@ const eventsDataSchema = zod_1.z.union([
89
94
  params: userSchema,
90
95
  postJsonBody: zod_1.z.any(),
91
96
  }),
97
+ zod_1.z.object({
98
+ type: zod_1.z.literal('USER_ACTION'),
99
+ cgi: zod_1.z.literal(EUserActions.RESET_TARGET),
100
+ ip: zod_1.z.string(),
101
+ params: userSchema,
102
+ postJsonBody: zod_1.z.any(),
103
+ }),
92
104
  zod_1.z.object({
93
105
  type: zod_1.z.literal('USER_ACTION'),
94
106
  cgi: zod_1.z.literal(EUserActions.SET_PRIORITY_LIST),
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { blackListSchema, cameraSettingsSchema, domainListSchema, flightInfoSchema, getIcaoSchema, mapInfoSchema, priorityListSchema, serverSettingsSchema, trackingModeSchema, whiteListSchema, wsAliasResponseSchema, zonesSchema, } from './types/PlaneTrackerAPI';
2
+ import { blackListSchema, cameraSettingsSchema, domainListSchema, flightInfoSchema, getIcaoSchema, mapInfoSchema, milestoneCameraListSchema, 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';
@@ -193,6 +193,19 @@ export class PlaneTrackerAPI extends BasicAPI {
193
193
  }
194
194
  }
195
195
  }
196
+ async checkMilestoneConnection(params, options) {
197
+ try {
198
+ await this._postUrlEncoded(`${BASE_PATH}/package/checkMilestoneConnection.cgi`, { ...params }, options);
199
+ return true;
200
+ }
201
+ catch {
202
+ return false;
203
+ }
204
+ }
205
+ async getMilestoneCameraList(params, options) {
206
+ const res = await this._postUrlEncoded(`${BASE_PATH}/package/getMilestoneCameraList.cgi`, { ...params }, options);
207
+ return milestoneCameraListSchema.parse(await res.json());
208
+ }
196
209
  downloadReport(options) {
197
210
  return this._getText(`${BASE_PATH}/report.cgi`, undefined, options);
198
211
  }
@@ -0,0 +1,120 @@
1
+ import { ErrorWithResponse } from '../../errors/errors';
2
+ import { HttpRequestSender } from '../HttpRequestSender';
3
+ import { camerasResponseSchema, tokenResponseSchema, } from '../../types/MilestoneAgent';
4
+ const CLIENT_ID = 'GrantValidatorClient';
5
+ const PAGE_SIZE = 100;
6
+ const TOKEN_EXPIRY_MARGIN_SEC = 60;
7
+ export class MilestoneAgent {
8
+ settings;
9
+ protocol;
10
+ sender;
11
+ token;
12
+ constructor(options = {}) {
13
+ this.settings = {
14
+ protocol: options.protocol ?? 'https_insecure',
15
+ ip: options.ip ?? '127.0.0.1',
16
+ port: options.port ?? 443,
17
+ user: options.user ?? '',
18
+ pass: options.pass ?? '',
19
+ timeout: options.timeout ?? 10000,
20
+ };
21
+ this.protocol = this.settings.protocol === 'http' ? 'http:' : 'https:';
22
+ const tlsInsecure = this.settings.protocol === 'https_insecure';
23
+ this.sender = new HttpRequestSender({ rejectUnaurhorized: !tlsInsecure });
24
+ }
25
+ async checkConnection() {
26
+ await this.getToken(true);
27
+ await this.getCamerasPage(0, 1);
28
+ }
29
+ async getAllCameras() {
30
+ const cameras = [];
31
+ let page = 0;
32
+ for (;;) {
33
+ const pageCameras = await this.getCamerasPage(page, PAGE_SIZE);
34
+ cameras.push(...pageCameras);
35
+ if (pageCameras.length < PAGE_SIZE) {
36
+ break;
37
+ }
38
+ page += 1;
39
+ }
40
+ return cameras;
41
+ }
42
+ async sendBookmark(cameraId, bookmark) {
43
+ const token = await this.getToken();
44
+ const body = JSON.stringify({
45
+ ...bookmark,
46
+ devicePath: { type: 'cameras', id: cameraId },
47
+ });
48
+ const res = await this.sender.sendRequest(this.getRequestOptions('POST', '/api/rest/v1/bookmarks', token, {
49
+ 'Content-Type': 'application/json',
50
+ }), body);
51
+ if (!res.ok) {
52
+ throw new ErrorWithResponse(res);
53
+ }
54
+ }
55
+ async getCamerasPage(page, size) {
56
+ const token = await this.getToken();
57
+ const res = await this.sender.sendRequest(this.getRequestOptions('GET', `/api/rest/v1/cameras?page=${page}&size=${size}`, token));
58
+ if (!res.ok) {
59
+ throw new ErrorWithResponse(res);
60
+ }
61
+ const responseBody = await res.text();
62
+ const result = await camerasResponseSchema.safeParseAsync(JSON.parse(responseBody));
63
+ if (!result.success) {
64
+ throw new Error('Milestone get cameras failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
65
+ }
66
+ return result.data.array;
67
+ }
68
+ async getToken(forceRefresh = false) {
69
+ const nowSec = Date.now() / 1000;
70
+ if (!forceRefresh && this.token !== undefined && this.token.expiresAt > nowSec) {
71
+ return this.token.value;
72
+ }
73
+ const body = new URLSearchParams({
74
+ grant_type: 'password',
75
+ username: this.settings.user,
76
+ password: this.settings.pass,
77
+ client_id: CLIENT_ID,
78
+ }).toString();
79
+ const res = await this.sender.sendRequest({
80
+ method: 'POST',
81
+ protocol: this.protocol,
82
+ host: this.settings.ip,
83
+ port: this.settings.port,
84
+ path: '/idp/connect/token',
85
+ timeout: this.settings.timeout,
86
+ headers: {
87
+ 'Content-Type': 'application/x-www-form-urlencoded',
88
+ 'Accept': 'application/json',
89
+ },
90
+ }, body);
91
+ if (!res.ok) {
92
+ throw new ErrorWithResponse(res);
93
+ }
94
+ const responseBody = await res.text();
95
+ const result = await tokenResponseSchema.safeParseAsync(JSON.parse(responseBody));
96
+ if (!result.success) {
97
+ throw new Error('Milestone authorization failed: ' + JSON.stringify(result.error.issues) + '\n' + responseBody);
98
+ }
99
+ this.token = {
100
+ value: result.data.access_token,
101
+ expiresAt: nowSec + result.data.expires_in - TOKEN_EXPIRY_MARGIN_SEC,
102
+ };
103
+ return this.token.value;
104
+ }
105
+ getRequestOptions(method, path, token, extraHeaders) {
106
+ return {
107
+ method,
108
+ protocol: this.protocol,
109
+ host: this.settings.ip,
110
+ port: this.settings.port,
111
+ path,
112
+ timeout: this.settings.timeout,
113
+ headers: {
114
+ Authorization: `Bearer ${token}`,
115
+ Accept: 'application/json',
116
+ ...extraHeaders,
117
+ },
118
+ };
119
+ }
120
+ }
package/esm/node/index.js CHANGED
@@ -6,6 +6,8 @@ export * from './events/AxisCameraStationEvents';
6
6
  export * from './TimeZoneDaemon';
7
7
  export * from './events/GenetecAgent';
8
8
  export * from '../types/GenetecAgent';
9
+ export * from './events/MilestoneAgent';
10
+ export * from '../types/MilestoneAgent';
9
11
  export { ResourceManager } from './CamOverlayPainter/ResourceManager';
10
12
  export { Painter } from './CamOverlayPainter/Painter';
11
13
  export { Frame } from './CamOverlayPainter/Frame';
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+ export const tokenResponseSchema = z.object({
3
+ access_token: z.string(),
4
+ expires_in: z.number(),
5
+ token_type: z.string(),
6
+ });
7
+ export const milestoneCameraSchema = z.object({
8
+ id: z.string(),
9
+ name: z.string().optional(),
10
+ displayName: z.string().optional(),
11
+ enabled: z.boolean().optional(),
12
+ });
13
+ export const camerasResponseSchema = z.object({
14
+ array: z.array(milestoneCameraSchema),
15
+ });