camstreamerlib 4.0.0-beta.4 → 4.0.0-beta.41
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/README.md +112 -0
- package/cjs/CamOverlayAPI.js +135 -92
- package/cjs/CamScripterAPI.js +52 -42
- package/cjs/CamStreamerAPI.js +83 -39
- package/cjs/CamSwitcherAPI.js +141 -123
- package/cjs/CamSwitcherEvents.js +4 -60
- package/cjs/PlaneTrackerAPI.js +210 -0
- package/cjs/VapixAPI.js +323 -233
- package/cjs/{CreatePackage.js → bin/CreatePackage.js} +22 -19
- package/cjs/errors/errors.js +78 -1
- package/cjs/index.js +17 -4
- package/cjs/internal/ProxyClient.js +28 -32
- package/cjs/internal/WsEvents.js +72 -0
- package/cjs/internal/types.js +2 -0
- package/cjs/internal/utils.js +22 -3
- package/cjs/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +7 -4
- package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +33 -0
- package/cjs/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +5 -17
- package/cjs/node/CamOverlayPainter/ResourceManager.js +72 -0
- package/cjs/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +7 -4
- package/cjs/node/DefaultClient.js +10 -12
- package/cjs/{internal → node}/Digest.js +8 -5
- package/cjs/node/HttpRequestSender.js +14 -4
- package/cjs/node/HttpServer.js +15 -12
- package/cjs/{VapixEvents.js → node/VapixEvents.js} +1 -1
- package/cjs/node/WsClient.js +12 -9
- package/cjs/node/events/AxisCameraStationEvents.js +53 -0
- package/cjs/node/events/GenetecAgent.js +123 -0
- package/cjs/node/index.js +38 -5
- package/cjs/types/CamOverlayAPI/CamOverlayAPI.js +92 -0
- package/cjs/types/CamOverlayAPI/accuweatherSchema.js +47 -0
- package/cjs/types/CamOverlayAPI/customGraphicsSchema.js +72 -0
- package/cjs/types/CamOverlayAPI/imagesSchema.js +9 -0
- package/cjs/types/CamOverlayAPI/index.js +27 -0
- package/cjs/types/CamOverlayAPI/infotickerSchema.js +26 -0
- package/cjs/types/CamOverlayAPI/pipSchema.js +39 -0
- package/cjs/types/CamOverlayAPI/ptzCompassSchema.js +25 -0
- package/cjs/types/CamOverlayAPI/ptzSchema.js +12 -0
- package/cjs/types/CamOverlayAPI/scoreBoardSchema.js +132 -0
- package/cjs/types/CamOverlayAPI/screenSharingSchema.js +8 -0
- package/cjs/types/CamOverlayAPI/serviceCommonTypes.js +91 -0
- package/cjs/types/CamOverlayAPI/webCameraSharingSchema.js +8 -0
- package/cjs/types/CamOverlayDrawingAPI.js +2 -0
- package/cjs/types/CamOverlayPainter.js +14 -0
- package/cjs/types/CamScripterAPI.js +22 -7
- package/cjs/types/CamScripterAPICameraEventsGenerator.js +2 -0
- package/cjs/types/CamStreamerAPI.js +34 -3
- package/cjs/types/CamSwitcherAPI.js +38 -1
- package/cjs/types/CamSwitcherEvents.js +8 -0
- package/cjs/types/GenetecAgent.js +31 -0
- package/cjs/types/PlaneTrackerAPI.js +286 -0
- package/cjs/types/VapixAPI.js +71 -13
- package/cjs/types/VapixEvents.js +2 -0
- package/cjs/web/DefaultClient.js +22 -10
- package/cjs/web/WsClient.js +3 -3
- package/esm/CamOverlayAPI.js +131 -88
- package/esm/CamScripterAPI.js +48 -38
- package/esm/CamStreamerAPI.js +81 -38
- package/esm/CamSwitcherAPI.js +137 -119
- package/esm/CamSwitcherEvents.js +5 -61
- package/esm/PlaneTrackerAPI.js +206 -0
- package/esm/VapixAPI.js +315 -225
- package/esm/{CreatePackage.js → bin/CreatePackage.js} +3 -3
- package/esm/errors/errors.js +66 -0
- package/esm/index.js +12 -3
- package/esm/internal/ProxyClient.js +28 -32
- package/esm/internal/WsEvents.js +68 -0
- package/esm/internal/utils.js +17 -1
- package/esm/{CamOverlayDrawingAPI.js → node/CamOverlayDrawingAPI.js} +2 -2
- package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Frame.js +33 -0
- package/esm/{CamOverlayPainter → node/CamOverlayPainter}/Painter.js +2 -13
- package/esm/{CamOverlayPainter → node/CamOverlayPainter}/ResourceManager.js +7 -5
- package/esm/{CamScripterAPICameraEventsGenerator.js → node/CamScripterAPICameraEventsGenerator.js} +2 -2
- package/esm/node/DefaultClient.js +10 -12
- package/esm/{internal → node}/Digest.js +1 -1
- package/esm/node/HttpRequestSender.js +14 -4
- package/esm/node/HttpServer.js +5 -5
- package/esm/{VapixEvents.js → node/VapixEvents.js} +1 -1
- package/esm/node/WsClient.js +3 -3
- package/esm/{events → node/events}/AxisCameraStationEvents.js +18 -13
- package/esm/node/events/GenetecAgent.js +119 -0
- package/esm/node/index.js +17 -2
- package/esm/types/CamOverlayAPI/CamOverlayAPI.js +76 -0
- package/esm/types/CamOverlayAPI/accuweatherSchema.js +44 -0
- package/esm/types/CamOverlayAPI/customGraphicsSchema.js +69 -0
- package/esm/types/CamOverlayAPI/imagesSchema.js +6 -0
- package/esm/types/CamOverlayAPI/index.js +11 -0
- package/esm/types/CamOverlayAPI/infotickerSchema.js +23 -0
- package/esm/types/CamOverlayAPI/pipSchema.js +36 -0
- package/esm/types/CamOverlayAPI/ptzCompassSchema.js +22 -0
- package/esm/types/CamOverlayAPI/ptzSchema.js +9 -0
- package/esm/types/CamOverlayAPI/scoreBoardSchema.js +129 -0
- package/esm/types/CamOverlayAPI/screenSharingSchema.js +5 -0
- package/esm/types/CamOverlayAPI/serviceCommonTypes.js +88 -0
- package/esm/types/CamOverlayAPI/webCameraSharingSchema.js +5 -0
- package/esm/types/CamOverlayPainter.js +11 -0
- package/esm/types/CamScripterAPI.js +21 -6
- package/esm/types/CamScripterAPICameraEventsGenerator.js +1 -0
- package/esm/types/CamStreamerAPI.js +33 -2
- package/esm/types/CamSwitcherAPI.js +38 -1
- package/esm/types/CamSwitcherEvents.js +8 -0
- package/esm/types/GenetecAgent.js +28 -0
- package/esm/types/PlaneTrackerAPI.js +283 -0
- package/esm/types/VapixAPI.js +70 -12
- package/esm/types/VapixEvents.js +1 -0
- package/esm/web/DefaultClient.js +22 -10
- package/esm/web/WsClient.js +3 -3
- package/package.json +30 -12
- package/types/CamOverlayAPI.d.ts +865 -0
- package/types/CamScripterAPI.d.ts +47 -0
- package/types/CamStreamerAPI.d.ts +64 -0
- package/types/CamSwitcherAPI.d.ts +167 -0
- package/types/CamSwitcherEvents.d.ts +8 -0
- package/types/PlaneTrackerAPI.d.ts +230 -0
- package/types/VapixAPI.d.ts +118 -0
- package/types/bin/CreatePackage.d.ts +1 -0
- package/types/errors/errors.d.ts +68 -0
- package/types/index.d.ts +20 -0
- package/types/internal/ProxyClient.d.ts +10 -0
- package/types/internal/WsEvents.d.ts +41 -0
- package/types/internal/types.d.ts +45 -0
- package/{cjs → types}/internal/utils.d.ts +4 -1
- package/{cjs → types}/internal/versionCompare.d.ts +2 -2
- package/types/node/CamOverlayDrawingAPI.d.ts +41 -0
- package/{esm → types/node}/CamOverlayPainter/Frame.d.ts +8 -37
- package/{cjs → types/node}/CamOverlayPainter/Painter.d.ts +5 -21
- package/types/node/CamOverlayPainter/ResourceManager.d.ts +15 -0
- package/types/node/CamScripterAPICameraEventsGenerator.d.ts +31 -0
- package/types/node/DefaultClient.d.ts +16 -0
- package/{esm → types}/node/HttpRequestSender.d.ts +1 -0
- package/{cjs → types}/node/HttpServer.d.ts +2 -2
- package/types/node/VapixEvents.d.ts +16 -0
- package/{cjs → types}/node/WsClient.d.ts +3 -2
- package/types/node/events/AxisCameraStationEvents.d.ts +12 -0
- package/types/node/events/GenetecAgent.d.ts +16 -0
- package/types/node/index.d.ts +17 -0
- package/types/types/CamOverlayAPI/CamOverlayAPI.d.ts +4321 -0
- package/types/types/CamOverlayAPI/accuweatherSchema.d.ts +84 -0
- package/types/types/CamOverlayAPI/customGraphicsSchema.d.ts +700 -0
- package/types/types/CamOverlayAPI/imagesSchema.d.ts +95 -0
- package/types/types/CamOverlayAPI/index.d.ts +11 -0
- package/types/types/CamOverlayAPI/infotickerSchema.d.ts +96 -0
- package/types/types/CamOverlayAPI/pipSchema.d.ts +125 -0
- package/types/types/CamOverlayAPI/ptzCompassSchema.d.ts +93 -0
- package/types/types/CamOverlayAPI/ptzSchema.d.ts +118 -0
- package/types/types/CamOverlayAPI/scoreBoardSchema.d.ts +357 -0
- package/types/types/CamOverlayAPI/screenSharingSchema.d.ts +58 -0
- package/types/types/CamOverlayAPI/serviceCommonTypes.d.ts +145 -0
- package/types/types/CamOverlayAPI/webCameraSharingSchema.d.ts +58 -0
- package/types/types/CamOverlayDrawingAPI.d.ts +48 -0
- package/types/types/CamOverlayPainter.d.ts +76 -0
- package/types/types/CamScripterAPI.d.ts +130 -0
- package/types/types/CamScripterAPICameraEventsGenerator.d.ts +45 -0
- package/types/types/CamStreamerAPI.d.ts +272 -0
- package/{esm → types}/types/CamSwitcherAPI.d.ts +115 -36
- package/{cjs → types}/types/CamSwitcherEvents.d.ts +77 -0
- package/{esm/events → types/types}/GenetecAgent.d.ts +47 -47
- package/types/types/PlaneTrackerAPI.d.ts +890 -0
- package/{cjs → types}/types/VapixAPI.d.ts +647 -465
- package/types/types/VapixEvents.d.ts +15 -0
- package/{esm → types}/types/common.d.ts +15 -5
- package/types/web/DefaultClient.d.ts +6 -0
- package/cjs/CamOverlayAPI.d.ts +0 -31
- package/cjs/CamOverlayDrawingAPI.d.ts +0 -86
- package/cjs/CamOverlayPainter/Frame.d.ts +0 -96
- package/cjs/CamOverlayPainter/ResourceManager.d.ts +0 -14
- package/cjs/CamOverlayPainter/ResourceManager.js +0 -46
- package/cjs/CamScripterAPI.d.ts +0 -19
- package/cjs/CamScripterAPICameraEventsGenerator.d.ts +0 -74
- package/cjs/CamStreamerAPI.d.ts +0 -16
- package/cjs/CamSwitcherAPI.d.ts +0 -48
- package/cjs/CamSwitcherEvents.d.ts +0 -18
- package/cjs/VapixAPI.d.ts +0 -66
- package/cjs/VapixEvents.d.ts +0 -43
- package/cjs/errors/errors.d.ts +0 -34
- package/cjs/events/AxisCameraStationEvents.d.ts +0 -9
- package/cjs/events/AxisCameraStationEvents.js +0 -48
- package/cjs/events/GenetecAgent.d.ts +0 -174
- package/cjs/events/GenetecAgent.js +0 -123
- package/cjs/index.d.ts +0 -11
- package/cjs/internal/ProxyClient.d.ts +0 -11
- package/cjs/internal/common.d.ts +0 -39
- package/cjs/internal/common.js +0 -27
- package/cjs/node/DefaultClient.d.ts +0 -15
- package/cjs/node/HttpRequestSender.d.ts +0 -28
- package/cjs/node/WsEventClient.d.ts +0 -13
- package/cjs/node/WsEventClient.js +0 -22
- package/cjs/types/CamOverlayAPI.d.ts +0 -188
- package/cjs/types/CamOverlayAPI.js +0 -47
- package/cjs/types/CamScripterAPI.d.ts +0 -67
- package/cjs/types/CamStreamerAPI.d.ts +0 -139
- package/cjs/types/CamSwitcherAPI.d.ts +0 -814
- package/cjs/types/common.d.ts +0 -37
- package/cjs/web/DefaultClient.d.ts +0 -6
- package/cjs/web/index.d.ts +0 -2
- package/esm/CamOverlayAPI.d.ts +0 -31
- package/esm/CamOverlayDrawingAPI.d.ts +0 -86
- package/esm/CamOverlayPainter/Painter.d.ts +0 -48
- package/esm/CamOverlayPainter/ResourceManager.d.ts +0 -14
- package/esm/CamScripterAPI.d.ts +0 -19
- package/esm/CamScripterAPICameraEventsGenerator.d.ts +0 -74
- package/esm/CamStreamerAPI.d.ts +0 -16
- package/esm/CamSwitcherAPI.d.ts +0 -48
- package/esm/CamSwitcherEvents.d.ts +0 -18
- package/esm/VapixAPI.d.ts +0 -66
- package/esm/VapixEvents.d.ts +0 -43
- package/esm/errors/errors.d.ts +0 -34
- package/esm/events/AxisCameraStationEvents.d.ts +0 -9
- package/esm/events/GenetecAgent.js +0 -119
- package/esm/index.d.ts +0 -11
- package/esm/internal/Digest.d.ts +0 -4
- package/esm/internal/ProxyClient.d.ts +0 -11
- package/esm/internal/common.d.ts +0 -39
- package/esm/internal/common.js +0 -20
- package/esm/internal/constants.d.ts +0 -1
- package/esm/internal/transformers.d.ts +0 -5
- package/esm/internal/utils.d.ts +0 -11
- package/esm/internal/versionCompare.d.ts +0 -6
- package/esm/node/DefaultClient.d.ts +0 -15
- package/esm/node/HttpServer.d.ts +0 -21
- package/esm/node/WsClient.d.ts +0 -39
- package/esm/node/WsEventClient.d.ts +0 -13
- package/esm/node/WsEventClient.js +0 -18
- package/esm/node/index.d.ts +0 -2
- package/esm/types/CamOverlayAPI.d.ts +0 -188
- package/esm/types/CamOverlayAPI.js +0 -44
- package/esm/types/CamScripterAPI.d.ts +0 -67
- package/esm/types/CamStreamerAPI.d.ts +0 -139
- package/esm/types/CamSwitcherEvents.d.ts +0 -491
- package/esm/types/VapixAPI.d.ts +0 -1683
- package/esm/web/DefaultClient.d.ts +0 -6
- package/esm/web/WsClient.d.ts +0 -13
- package/esm/web/index.d.ts +0 -2
- /package/{cjs/CreatePackage.d.ts → esm/internal/types.js} +0 -0
- /package/esm/{CreatePackage.d.ts → types/CamOverlayDrawingAPI.js} +0 -0
- /package/{cjs → types}/internal/constants.d.ts +0 -0
- /package/{cjs → types}/internal/transformers.d.ts +0 -0
- /package/{cjs/internal → types/node}/Digest.d.ts +0 -0
- /package/{cjs → types}/web/WsClient.d.ts +0 -0
- /package/{cjs/node → types/web}/index.d.ts +0 -0
package/esm/CamSwitcherAPI.js
CHANGED
|
@@ -1,123 +1,141 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { AddNewClipError } from './errors/errors';
|
|
3
|
-
import { isNullish, responseStringify } from './internal/
|
|
4
|
-
import { storageInfoListSchema, outputInfoSchema, audioPushInfoSchema, clipListSchema, playlistQueueSchema, streamSaveLoadSchema, clipSaveLoadSchema, playlistSaveLoadSchema, trackerSaveLoadSchema, } from './types/CamSwitcherAPI';
|
|
5
|
-
import { networkCameraListSchema } from './types/common';
|
|
2
|
+
import { AddNewClipError, JsonParseError, ParameterNotFoundError } from './errors/errors';
|
|
3
|
+
import { isClip, isNullish, responseStringify } from './internal/utils';
|
|
4
|
+
import { storageInfoListSchema, outputInfoSchema, audioPushInfoSchema, clipListSchema, playlistQueueSchema, streamSaveLoadSchema, clipSaveLoadSchema, playlistSaveLoadSchema, trackerSaveLoadSchema, secondaryAudioSettingsSchema, globalAudioSettingsSchema, } from './types/CamSwitcherAPI';
|
|
5
|
+
import { networkCameraListSchema, } from './types/common';
|
|
6
6
|
import { VapixAPI } from './VapixAPI';
|
|
7
7
|
import { isFirmwareVersionAtLeast } from './internal/versionCompare';
|
|
8
|
-
import { isClip } from './internal/utils';
|
|
9
8
|
import { FIRMWARE_WITH_BITRATE_MODES_SUPPORT } from './internal/constants';
|
|
10
|
-
|
|
9
|
+
import { ProxyClient } from './internal/ProxyClient';
|
|
10
|
+
const BASE_PATH = '/local/camswitcher/api';
|
|
11
11
|
export class CamSwitcherAPI {
|
|
12
12
|
client;
|
|
13
|
+
CustomFormData;
|
|
13
14
|
vapixAgent;
|
|
14
|
-
constructor(client) {
|
|
15
|
+
constructor(client, CustomFormData = FormData) {
|
|
15
16
|
this.client = client;
|
|
16
|
-
this.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
static
|
|
20
|
-
static
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
this.CustomFormData = CustomFormData;
|
|
18
|
+
this.vapixAgent = new VapixAPI(client);
|
|
19
|
+
}
|
|
20
|
+
static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
|
|
21
|
+
static getWsEventsPath = () => `/local/camswitcher/events`;
|
|
22
|
+
static getClipPreviewPath = (id, storage) => `${BASE_PATH}/clip_preview.cgi?clip_name=${id}&storage=${storage}`;
|
|
23
|
+
getClient(proxyParams) {
|
|
24
|
+
return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
|
|
25
|
+
}
|
|
26
|
+
async checkCameraTime(options) {
|
|
27
|
+
const res = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
|
|
28
|
+
return z.boolean().parse(res.data);
|
|
29
|
+
}
|
|
30
|
+
async getNetworkCameraList(options) {
|
|
31
|
+
const res = await this._getJson(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
|
|
32
|
+
return networkCameraListSchema.parse(res.data);
|
|
33
|
+
}
|
|
34
|
+
async generateSilence(sampleRate, channels, options) {
|
|
35
|
+
const agent = this.getClient(options?.proxyParams);
|
|
36
|
+
await agent.get({
|
|
37
|
+
path: `${BASE_PATH}/generate_silence.cgi`,
|
|
38
|
+
parameters: {
|
|
39
|
+
sample_rate: sampleRate.toString(),
|
|
40
|
+
channels,
|
|
41
|
+
},
|
|
42
|
+
timeout: options?.timeout,
|
|
25
43
|
});
|
|
26
44
|
}
|
|
27
|
-
async
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const data = await this.get(`${baseUrl}/network_camera_list.cgi`);
|
|
33
|
-
return networkCameraListSchema.parse(data);
|
|
34
|
-
}
|
|
35
|
-
async getMaxFps(source) {
|
|
36
|
-
const data = await this.get(`${baseUrl}/get_max_framerate.cgi`, {
|
|
37
|
-
video_source: source.toString(),
|
|
38
|
-
});
|
|
39
|
-
return z.number().parse(data);
|
|
45
|
+
async getMaxFps(source, options) {
|
|
46
|
+
const res = await this._getJson(`${BASE_PATH}/get_max_framerate.cgi`, {
|
|
47
|
+
video_source: source,
|
|
48
|
+
}, options);
|
|
49
|
+
return z.number().parse(res.data);
|
|
40
50
|
}
|
|
41
|
-
async getStorageInfo() {
|
|
42
|
-
const
|
|
43
|
-
return storageInfoListSchema.parse(data);
|
|
51
|
+
async getStorageInfo(options) {
|
|
52
|
+
const res = await this._getJson(`${BASE_PATH}/get_storage.cgi`, undefined, options);
|
|
53
|
+
return storageInfoListSchema.parse(res.data);
|
|
44
54
|
}
|
|
45
|
-
async wsAuthorization() {
|
|
46
|
-
const
|
|
47
|
-
return z.string().parse(data);
|
|
55
|
+
async wsAuthorization(options) {
|
|
56
|
+
const res = await this._getJson(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
|
|
57
|
+
return z.string().parse(res.data);
|
|
48
58
|
}
|
|
49
|
-
async getOutputInfo() {
|
|
50
|
-
const
|
|
51
|
-
return outputInfoSchema.parse(data);
|
|
59
|
+
async getOutputInfo(options) {
|
|
60
|
+
const res = await this._getJson(`${BASE_PATH}/output_info.cgi`, undefined, options);
|
|
61
|
+
return outputInfoSchema.parse(res.data);
|
|
52
62
|
}
|
|
53
|
-
async getAudioPushInfo() {
|
|
54
|
-
const
|
|
55
|
-
return audioPushInfoSchema.parse(data);
|
|
63
|
+
async getAudioPushInfo(options) {
|
|
64
|
+
const res = await this._getJson(`${BASE_PATH}/audio_push_info.cgi`, undefined, options);
|
|
65
|
+
return audioPushInfoSchema.parse(res.data);
|
|
56
66
|
}
|
|
57
|
-
async getStreamSaveList() {
|
|
58
|
-
const
|
|
59
|
-
return streamSaveLoadSchema.parse(data);
|
|
67
|
+
async getStreamSaveList(options) {
|
|
68
|
+
const res = await this._getJson(`${BASE_PATH}/streams.cgi`, { action: 'get' }, options);
|
|
69
|
+
return streamSaveLoadSchema.parse(res.data);
|
|
60
70
|
}
|
|
61
|
-
async getClipSaveList() {
|
|
62
|
-
const
|
|
63
|
-
return clipSaveLoadSchema.parse(data);
|
|
71
|
+
async getClipSaveList(options) {
|
|
72
|
+
const res = await this._getJson(`${BASE_PATH}/clips.cgi`, { action: 'get' }, options);
|
|
73
|
+
return clipSaveLoadSchema.parse(res.data);
|
|
64
74
|
}
|
|
65
|
-
async getPlaylistSaveList() {
|
|
66
|
-
const
|
|
67
|
-
return playlistSaveLoadSchema.parse(data);
|
|
75
|
+
async getPlaylistSaveList(options) {
|
|
76
|
+
const res = await this._getJson(`${BASE_PATH}/playlists.cgi`, { action: 'get' }, options);
|
|
77
|
+
return playlistSaveLoadSchema.parse(res.data);
|
|
68
78
|
}
|
|
69
|
-
async getTrackerSaveList() {
|
|
70
|
-
const
|
|
71
|
-
return trackerSaveLoadSchema.parse(data);
|
|
79
|
+
async getTrackerSaveList(options) {
|
|
80
|
+
const res = await this._getJson(`${BASE_PATH}/trackers.cgi`, { action: 'get' }, options);
|
|
81
|
+
return trackerSaveLoadSchema.parse(res.data);
|
|
72
82
|
}
|
|
73
|
-
async setStreamSaveList(data) {
|
|
74
|
-
|
|
83
|
+
async setStreamSaveList(data, options) {
|
|
84
|
+
await this._post(`${BASE_PATH}/streams.cgi`, data, { action: 'set' }, options);
|
|
75
85
|
}
|
|
76
|
-
async setClipSaveList(data) {
|
|
77
|
-
|
|
86
|
+
async setClipSaveList(data, options) {
|
|
87
|
+
await this._post(`${BASE_PATH}/clips.cgi`, data, { action: 'set' }, options);
|
|
78
88
|
}
|
|
79
|
-
async setPlaylistSaveList(data) {
|
|
80
|
-
|
|
89
|
+
async setPlaylistSaveList(data, options) {
|
|
90
|
+
await this._post(`${BASE_PATH}/playlists.cgi`, data, { action: 'set' }, options);
|
|
81
91
|
}
|
|
82
|
-
async setTrackerSaveList(data) {
|
|
83
|
-
|
|
92
|
+
async setTrackerSaveList(data, options) {
|
|
93
|
+
await this._post(`${BASE_PATH}/trackers.cgi`, data, { action: 'set' }, options);
|
|
84
94
|
}
|
|
85
|
-
async playlistSwitch(playlistName) {
|
|
86
|
-
await this.
|
|
95
|
+
async playlistSwitch(playlistName, options) {
|
|
96
|
+
await this._getJson(`${BASE_PATH}/playlist_switch.cgi`, { playlist_name: playlistName }, options);
|
|
87
97
|
}
|
|
88
|
-
async playlistQueuePush(playlistName) {
|
|
89
|
-
await this.
|
|
98
|
+
async playlistQueuePush(playlistName, options) {
|
|
99
|
+
await this._getJson(`${BASE_PATH}/playlist_queue_push.cgi`, { playlist_name: playlistName }, options);
|
|
90
100
|
}
|
|
91
|
-
async playlistQueueClear() {
|
|
92
|
-
await this.
|
|
101
|
+
async playlistQueueClear(options) {
|
|
102
|
+
await this._getJson(`${BASE_PATH}/playlist_queue_clear.cgi`, undefined, options);
|
|
93
103
|
}
|
|
94
|
-
async playlistQueueList() {
|
|
95
|
-
const
|
|
96
|
-
return playlistQueueSchema.parse(data).playlistQueueList;
|
|
104
|
+
async playlistQueueList(options) {
|
|
105
|
+
const res = await this._getJson(`${BASE_PATH}/playlist_queue_list.cgi`, undefined, options);
|
|
106
|
+
return playlistQueueSchema.parse(res.data).playlistQueueList;
|
|
97
107
|
}
|
|
98
|
-
async playlistQueuePlayNext() {
|
|
99
|
-
await this.
|
|
108
|
+
async playlistQueuePlayNext(options) {
|
|
109
|
+
await this._getJson(`${BASE_PATH}/playlist_queue_play_next.cgi`, undefined, options);
|
|
100
110
|
}
|
|
101
|
-
async addNewClip(file, clipType, storage,
|
|
102
|
-
const
|
|
103
|
-
formData.
|
|
111
|
+
async addNewClip(file, clipType, storage, clipId, fileName, options) {
|
|
112
|
+
const path = `${BASE_PATH}/clip_upload.cgi`;
|
|
113
|
+
const formData = new this.CustomFormData();
|
|
114
|
+
formData.append('clip_name', clipId);
|
|
104
115
|
formData.append('clip_type', clipType);
|
|
105
116
|
formData.append('file', file, fileName);
|
|
106
|
-
const
|
|
107
|
-
const res = await
|
|
117
|
+
const agent = this.getClient(options?.proxyParams);
|
|
118
|
+
const res = await agent.post({
|
|
119
|
+
path,
|
|
120
|
+
data: formData,
|
|
121
|
+
parameters: {
|
|
122
|
+
storage: storage,
|
|
123
|
+
},
|
|
124
|
+
timeout: options?.timeout,
|
|
125
|
+
});
|
|
108
126
|
const output = (await res.json());
|
|
109
127
|
if (output.status !== 200) {
|
|
110
128
|
throw new AddNewClipError(output.message);
|
|
111
129
|
}
|
|
112
130
|
}
|
|
113
|
-
removeClip(
|
|
114
|
-
|
|
131
|
+
async removeClip(clipId, storage, options) {
|
|
132
|
+
await this._getJson(`${BASE_PATH}/clip_remove.cgi`, { clip_name: clipId, storage }, options);
|
|
115
133
|
}
|
|
116
|
-
async getClipList() {
|
|
117
|
-
const
|
|
118
|
-
return clipListSchema.parse(data).clip_list;
|
|
134
|
+
async getClipList(options) {
|
|
135
|
+
const res = await this._getJson(`${BASE_PATH}/clip_list.cgi`, undefined, options);
|
|
136
|
+
return clipListSchema.parse(res.data).clip_list;
|
|
119
137
|
}
|
|
120
|
-
setCamSwitchOptions(data, cameraFWVersion) {
|
|
138
|
+
setCamSwitchOptions(data, cameraFWVersion, options) {
|
|
121
139
|
const bitrateVapixParams = parseBitrateOptionsToBitrateVapixParams(cameraFWVersion, data.bitrateMode, data);
|
|
122
140
|
const saveData = {
|
|
123
141
|
video: {
|
|
@@ -135,9 +153,9 @@ export class CamSwitcherAPI {
|
|
|
135
153
|
},
|
|
136
154
|
keyboard: data.keyboard,
|
|
137
155
|
};
|
|
138
|
-
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.SETTINGS, saveData);
|
|
156
|
+
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.SETTINGS, saveData, options);
|
|
139
157
|
}
|
|
140
|
-
setGlobalAudioSettings(settings) {
|
|
158
|
+
setGlobalAudioSettings(settings, options) {
|
|
141
159
|
let acceptedType = 'NONE';
|
|
142
160
|
if (settings.type === 'source' && settings.source) {
|
|
143
161
|
if (isClip(settings.source)) {
|
|
@@ -153,9 +171,9 @@ export class CamSwitcherAPI {
|
|
|
153
171
|
clip_name: settings.source,
|
|
154
172
|
storage: settings.storage,
|
|
155
173
|
};
|
|
156
|
-
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.MASTER_AUDIO, data);
|
|
174
|
+
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.MASTER_AUDIO, data, options);
|
|
157
175
|
}
|
|
158
|
-
setSecondaryAudioSettings(settings) {
|
|
176
|
+
setSecondaryAudioSettings(settings, options) {
|
|
159
177
|
const data = {
|
|
160
178
|
type: settings.type,
|
|
161
179
|
stream_name: settings.streamName ?? '',
|
|
@@ -164,19 +182,19 @@ export class CamSwitcherAPI {
|
|
|
164
182
|
secondary_audio_level: settings.secondaryAudioLevel,
|
|
165
183
|
master_audio_level: settings.masterAudioLevel,
|
|
166
184
|
};
|
|
167
|
-
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.SECONDARY_AUDIO, data);
|
|
185
|
+
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.SECONDARY_AUDIO, data, options);
|
|
168
186
|
}
|
|
169
|
-
setDefaultPlaylist(
|
|
170
|
-
const value = JSON.stringify({ default_playlist_id:
|
|
187
|
+
setDefaultPlaylist(playlistId, options) {
|
|
188
|
+
const value = JSON.stringify({ default_playlist_id: playlistId });
|
|
171
189
|
return this.vapixAgent.setParameter({
|
|
172
190
|
[CSW_PARAM_NAMES.DEFAULT_PLAYLIST]: value,
|
|
173
|
-
},
|
|
191
|
+
}, options);
|
|
174
192
|
}
|
|
175
|
-
setPermanentRtspUrlToken(token) {
|
|
176
|
-
return this.vapixAgent.setParameter({ [CSW_PARAM_NAMES.RTSP_TOKEN]: token },
|
|
193
|
+
setPermanentRtspUrlToken(token, options) {
|
|
194
|
+
return this.vapixAgent.setParameter({ [CSW_PARAM_NAMES.RTSP_TOKEN]: token }, options);
|
|
177
195
|
}
|
|
178
|
-
async getCamSwitchOptions() {
|
|
179
|
-
const saveData = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SETTINGS);
|
|
196
|
+
async getCamSwitchOptions(options) {
|
|
197
|
+
const saveData = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SETTINGS, options);
|
|
180
198
|
if (isNullish(saveData.video)) {
|
|
181
199
|
return saveData;
|
|
182
200
|
}
|
|
@@ -201,12 +219,12 @@ export class CamSwitcherAPI {
|
|
|
201
219
|
keyboard: saveData.keyboard,
|
|
202
220
|
};
|
|
203
221
|
}
|
|
204
|
-
async getGlobalAudioSettings() {
|
|
222
|
+
async getGlobalAudioSettings(options) {
|
|
205
223
|
const settings = {
|
|
206
224
|
type: 'fromSource',
|
|
207
225
|
source: 'fromSource',
|
|
208
226
|
};
|
|
209
|
-
const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.MASTER_AUDIO);
|
|
227
|
+
const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.MASTER_AUDIO, options);
|
|
210
228
|
if (res.type === 'STREAM') {
|
|
211
229
|
settings.type = 'source';
|
|
212
230
|
settings.source = res.stream_name;
|
|
@@ -216,10 +234,10 @@ export class CamSwitcherAPI {
|
|
|
216
234
|
settings.source = res.clip_name;
|
|
217
235
|
settings.storage = res.storage;
|
|
218
236
|
}
|
|
219
|
-
return settings;
|
|
237
|
+
return globalAudioSettingsSchema.parse(settings);
|
|
220
238
|
}
|
|
221
|
-
async getSecondaryAudioSettings() {
|
|
222
|
-
const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SECONDARY_AUDIO);
|
|
239
|
+
async getSecondaryAudioSettings(options) {
|
|
240
|
+
const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SECONDARY_AUDIO, options);
|
|
223
241
|
const settings = {
|
|
224
242
|
type: res.type ?? 'NONE',
|
|
225
243
|
streamName: res.stream_name,
|
|
@@ -228,40 +246,40 @@ export class CamSwitcherAPI {
|
|
|
228
246
|
secondaryAudioLevel: res.secondary_audio_level ?? 1,
|
|
229
247
|
masterAudioLevel: res.master_audio_level ?? 1,
|
|
230
248
|
};
|
|
231
|
-
return settings;
|
|
249
|
+
return secondaryAudioSettingsSchema.parse(settings);
|
|
232
250
|
}
|
|
233
|
-
async getPermanentRtspUrlToken() {
|
|
251
|
+
async getPermanentRtspUrlToken(options) {
|
|
234
252
|
const paramName = CSW_PARAM_NAMES.RTSP_TOKEN;
|
|
235
|
-
const res = await this.vapixAgent.getParameter([paramName],
|
|
236
|
-
return res[paramName] ?? '';
|
|
253
|
+
const res = await this.vapixAgent.getParameter([paramName], options);
|
|
254
|
+
return z.string().parse(res[paramName] ?? '');
|
|
237
255
|
}
|
|
238
|
-
async
|
|
239
|
-
const
|
|
256
|
+
async _getJson(path, parameters, options) {
|
|
257
|
+
const agent = this.getClient(options?.proxyParams);
|
|
258
|
+
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
240
259
|
if (res.ok) {
|
|
241
|
-
|
|
242
|
-
return d.data;
|
|
260
|
+
return await res.json();
|
|
243
261
|
}
|
|
244
262
|
else {
|
|
245
263
|
throw new Error(await responseStringify(res));
|
|
246
264
|
}
|
|
247
265
|
}
|
|
248
|
-
async
|
|
249
|
-
const
|
|
266
|
+
async _post(path, data, parameters, options, headers) {
|
|
267
|
+
const agent = this.getClient(options?.proxyParams);
|
|
268
|
+
const res = await agent.post({ path, data, parameters, timeout: options?.timeout, headers });
|
|
250
269
|
if (res.ok) {
|
|
251
|
-
|
|
252
|
-
return parsed.message === 'OK';
|
|
270
|
+
return await res.json();
|
|
253
271
|
}
|
|
254
272
|
else {
|
|
255
273
|
throw new Error(await responseStringify(res));
|
|
256
274
|
}
|
|
257
275
|
}
|
|
258
|
-
setParamFromCameraJSON(paramName, data) {
|
|
276
|
+
setParamFromCameraJSON(paramName, data, options) {
|
|
259
277
|
const params = {};
|
|
260
278
|
params[paramName] = JSON.stringify(data);
|
|
261
|
-
return this.vapixAgent.setParameter(params,
|
|
279
|
+
return this.vapixAgent.setParameter(params, options);
|
|
262
280
|
}
|
|
263
|
-
async getParamFromCameraAndJSONParse(paramName) {
|
|
264
|
-
const data = await this.vapixAgent.getParameter([paramName],
|
|
281
|
+
async getParamFromCameraAndJSONParse(paramName, options) {
|
|
282
|
+
const data = await this.vapixAgent.getParameter([paramName], options);
|
|
265
283
|
if (data[paramName] !== undefined) {
|
|
266
284
|
try {
|
|
267
285
|
if (data[paramName] === '') {
|
|
@@ -272,10 +290,10 @@ export class CamSwitcherAPI {
|
|
|
272
290
|
}
|
|
273
291
|
}
|
|
274
292
|
catch {
|
|
275
|
-
throw new
|
|
293
|
+
throw new JsonParseError(paramName, data[paramName]);
|
|
276
294
|
}
|
|
277
295
|
}
|
|
278
|
-
throw new
|
|
296
|
+
throw new ParameterNotFoundError(paramName);
|
|
279
297
|
}
|
|
280
298
|
}
|
|
281
299
|
const CSW_PARAM_NAMES = {
|
|
@@ -289,7 +307,7 @@ const parseBitrateOptionsToBitrateVapixParams = (firmWareVersion, bitrateMode, c
|
|
|
289
307
|
if (!isFirmwareVersionAtLeast(firmWareVersion, FIRMWARE_WITH_BITRATE_MODES_SUPPORT)) {
|
|
290
308
|
return `videomaxbitrate=${cameraOptions.maximumBitRate}`;
|
|
291
309
|
}
|
|
292
|
-
if (bitrateMode ===
|
|
310
|
+
if (bitrateMode === undefined) {
|
|
293
311
|
return '';
|
|
294
312
|
}
|
|
295
313
|
const data = {
|
package/esm/CamSwitcherEvents.js
CHANGED
|
@@ -1,63 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
ws
|
|
5
|
-
|
|
6
|
-
setWebsocket(ws) {
|
|
7
|
-
if (this.ws) {
|
|
8
|
-
this.ws.destroy();
|
|
9
|
-
}
|
|
10
|
-
this.ws = ws;
|
|
11
|
-
this.ws.onmessage = (e) => this.onMessage(e);
|
|
12
|
-
}
|
|
13
|
-
resendInitData() {
|
|
14
|
-
const request = {
|
|
15
|
-
command: 'sendInitData',
|
|
16
|
-
};
|
|
17
|
-
this.ws?.send(JSON.stringify(request));
|
|
18
|
-
}
|
|
19
|
-
addListener(type, listener, id) {
|
|
20
|
-
const typeList = this.listeners[type];
|
|
21
|
-
if (typeList === undefined) {
|
|
22
|
-
this.listeners[type] = { [id]: listener };
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
typeList[id] = listener;
|
|
26
|
-
}
|
|
27
|
-
removeListener(type, id) {
|
|
28
|
-
const typeList = this.listeners[type];
|
|
29
|
-
if (typeList) {
|
|
30
|
-
delete typeList[id];
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
onMessage(evt) {
|
|
34
|
-
if (this.isDestroyed) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
try {
|
|
38
|
-
const eventData = JSON.parse(evt.data);
|
|
39
|
-
const data = cswEventsSchema.parse(eventData);
|
|
40
|
-
if (data.type === 'init') {
|
|
41
|
-
this.processMessage(data.data, true);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
this.processMessage(data, false);
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
console.error('Error parsing event data:', evt.data, error);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
processMessage(event, isInit) {
|
|
51
|
-
const listeners = this.listeners[event.type];
|
|
52
|
-
const list = Object.values(listeners ?? {});
|
|
53
|
-
list.forEach((listener) => listener(event, isInit));
|
|
54
|
-
}
|
|
55
|
-
destroy() {
|
|
56
|
-
this.isDestroyed = true;
|
|
57
|
-
if (this.ws) {
|
|
58
|
-
this.ws.destroy();
|
|
59
|
-
this.ws = null;
|
|
60
|
-
}
|
|
61
|
-
this.listeners = {};
|
|
1
|
+
import { WsEvents } from './internal/WsEvents';
|
|
2
|
+
import { cswEventsSchema } from './types/CamSwitcherEvents';
|
|
3
|
+
export class CamSwitcherEvents extends WsEvents {
|
|
4
|
+
constructor(ws) {
|
|
5
|
+
super(cswEventsSchema, ws);
|
|
62
6
|
}
|
|
63
7
|
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { responseStringify } from './internal/utils';
|
|
3
|
+
import { blackListSchema, cameraSettingsSchema, flightInfoSchema, mapInfoSchema, priorityListSchema, serverSettingsSchema, trackingModeSchema, whiteListSchema, wsAliasResponseSchema, zonesSchema, } from './types/PlaneTrackerAPI';
|
|
4
|
+
import { ImportSettingsError, ParsingBlobError, ResetCalibrationError } from './errors/errors';
|
|
5
|
+
import { ProxyClient } from './internal/ProxyClient';
|
|
6
|
+
import { cameraListSchema } from './types/GenetecAgent';
|
|
7
|
+
const BASE_PATH = '/local/planetracker';
|
|
8
|
+
export class PlaneTrackerAPI {
|
|
9
|
+
client;
|
|
10
|
+
apiUser;
|
|
11
|
+
constructor(client, apiUser) {
|
|
12
|
+
this.client = client;
|
|
13
|
+
this.apiUser = apiUser;
|
|
14
|
+
}
|
|
15
|
+
static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
|
|
16
|
+
getClient(proxyParams) {
|
|
17
|
+
return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
|
|
18
|
+
}
|
|
19
|
+
async checkCameraTime(options) {
|
|
20
|
+
const res = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
|
|
21
|
+
return z.boolean().parse(res.state);
|
|
22
|
+
}
|
|
23
|
+
async resetPtzCalibration(options) {
|
|
24
|
+
const agent = this.getClient(options?.proxyParams);
|
|
25
|
+
const res = await agent.get({
|
|
26
|
+
path: `${BASE_PATH}/package/resetPtzCalibration.cgi`,
|
|
27
|
+
parameters: this.apiUser,
|
|
28
|
+
timeout: options?.timeout,
|
|
29
|
+
});
|
|
30
|
+
if (!res.ok) {
|
|
31
|
+
throw new ResetCalibrationError('PTZ', await responseStringify(res));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async resetFocusCalibration(options) {
|
|
35
|
+
const agent = this.getClient(options?.proxyParams);
|
|
36
|
+
const res = await agent.get({
|
|
37
|
+
path: `${BASE_PATH}/package/resetFocusCalibration.cgi`,
|
|
38
|
+
parameters: this.apiUser,
|
|
39
|
+
timeout: options?.timeout,
|
|
40
|
+
});
|
|
41
|
+
if (!res.ok) {
|
|
42
|
+
throw new ResetCalibrationError('FOCUS', await responseStringify(res));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async serverRunCheck(options) {
|
|
46
|
+
const agent = this.getClient(options?.proxyParams);
|
|
47
|
+
return await agent.get({ path: `${BASE_PATH}/package/serverRunCheck.cgi`, timeout: options?.timeout });
|
|
48
|
+
}
|
|
49
|
+
async getLiveViewAlias(rtspUrl, options) {
|
|
50
|
+
const agent = this.getClient(options?.proxyParams);
|
|
51
|
+
const res = await agent.get({
|
|
52
|
+
path: `${BASE_PATH}/getLiveViewAlias.cgi`,
|
|
53
|
+
parameters: { rtsp_url: rtspUrl },
|
|
54
|
+
timeout: options?.timeout,
|
|
55
|
+
});
|
|
56
|
+
return wsAliasResponseSchema.parse(await res.json());
|
|
57
|
+
}
|
|
58
|
+
async fetchCameraSettings(options) {
|
|
59
|
+
const res = await this._getJson(`${BASE_PATH}/package_camera_settings.cgi`, { action: 'get' }, options);
|
|
60
|
+
return cameraSettingsSchema.parse(res);
|
|
61
|
+
}
|
|
62
|
+
async setCameraSettings(settings, options) {
|
|
63
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package_camera_settings.cgi`, settings, {
|
|
64
|
+
action: 'set',
|
|
65
|
+
}, options);
|
|
66
|
+
}
|
|
67
|
+
async fetchServerSettings(options) {
|
|
68
|
+
const res = await this._getJson(`${BASE_PATH}/package_server_settings.cgi`, { action: 'get' }, options);
|
|
69
|
+
return serverSettingsSchema.parse(res);
|
|
70
|
+
}
|
|
71
|
+
async exportAppSettings(dataType, options) {
|
|
72
|
+
return await this._getBlob(`${BASE_PATH}/package_data.cgi`, { action: 'EXPORT', dataType }, options);
|
|
73
|
+
}
|
|
74
|
+
async importAppSettings(dataType, formData, options) {
|
|
75
|
+
const agent = this.getClient(options?.proxyParams);
|
|
76
|
+
const res = await agent.post({
|
|
77
|
+
path: `${BASE_PATH}/package_data.cgi`,
|
|
78
|
+
data: formData,
|
|
79
|
+
parameters: { action: 'IMPORT', dataType },
|
|
80
|
+
timeout: options?.timeout,
|
|
81
|
+
});
|
|
82
|
+
if (!res.ok) {
|
|
83
|
+
throw new ImportSettingsError(await responseStringify(res));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async fetchFlightInfo(icao, options) {
|
|
87
|
+
const res = await this._getJson(`${BASE_PATH}/package/flightInfo.cgi`, { icao }, options);
|
|
88
|
+
return flightInfoSchema.parse(res);
|
|
89
|
+
}
|
|
90
|
+
async getTrackingMode(options) {
|
|
91
|
+
const res = await this._getJson(`${BASE_PATH}/package/getTrackingMode.cgi`, undefined, options);
|
|
92
|
+
return trackingModeSchema.parse(res);
|
|
93
|
+
}
|
|
94
|
+
async setTrackingMode(mode, options) {
|
|
95
|
+
await this._postJsonEncoded(`${BASE_PATH}/package/setTrackingMode.cgi`, { mode }, this.apiUser, options);
|
|
96
|
+
}
|
|
97
|
+
async startTrackingPlane(icao, options) {
|
|
98
|
+
const agent = this.getClient(options?.proxyParams);
|
|
99
|
+
await agent.get({
|
|
100
|
+
path: `${BASE_PATH}/package/trackIcao.cgi`,
|
|
101
|
+
parameters: { icao, ...this.apiUser },
|
|
102
|
+
timeout: options?.timeout,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
async stopTrackingPlane(options) {
|
|
106
|
+
const agent = this.getClient(options?.proxyParams);
|
|
107
|
+
await agent.get({
|
|
108
|
+
path: `${BASE_PATH}/package/resetIcao.cgi`,
|
|
109
|
+
parameters: this.apiUser,
|
|
110
|
+
timeout: options?.timeout,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
async getPriorityList(options) {
|
|
114
|
+
const res = await this._getJson(`${BASE_PATH}/package/getPriorityList.cgi`, undefined, options);
|
|
115
|
+
return priorityListSchema.parse(res);
|
|
116
|
+
}
|
|
117
|
+
async setPriorityList(priorityList, options) {
|
|
118
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package/setPriorityList.cgi`, { priorityList }, this.apiUser, options);
|
|
119
|
+
}
|
|
120
|
+
async getWhiteList(options) {
|
|
121
|
+
const res = await this._getJson(`${BASE_PATH}/package/getWhiteList.cgi`, undefined, options);
|
|
122
|
+
return whiteListSchema.parse(res);
|
|
123
|
+
}
|
|
124
|
+
async setWhiteList(whiteList, options) {
|
|
125
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, { whiteList }, this.apiUser, options);
|
|
126
|
+
}
|
|
127
|
+
async getBlackList(options) {
|
|
128
|
+
const res = await this._getJson(`${BASE_PATH}/package/getBlackList.cgi`, undefined, options);
|
|
129
|
+
return blackListSchema.parse(res);
|
|
130
|
+
}
|
|
131
|
+
async setBlackList(blackList, options) {
|
|
132
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, { blackList }, this.apiUser, options);
|
|
133
|
+
}
|
|
134
|
+
async fetchMapInfo(options) {
|
|
135
|
+
const res = await this._getJson(`${BASE_PATH}/package/getMapInfo.cgi`, undefined, options);
|
|
136
|
+
return mapInfoSchema.parse(res);
|
|
137
|
+
}
|
|
138
|
+
async getZones(options) {
|
|
139
|
+
const res = await this._getJson(`${BASE_PATH}/package/getZones.cgi`, undefined, options);
|
|
140
|
+
return zonesSchema.parse(res);
|
|
141
|
+
}
|
|
142
|
+
async setZones(zones, options) {
|
|
143
|
+
await this._postJsonEncoded(`${BASE_PATH}/package/setZones.cgi`, { zones }, this.apiUser, options);
|
|
144
|
+
}
|
|
145
|
+
async goToCoordinates(lat, lon, alt, options) {
|
|
146
|
+
const agent = this.getClient(options?.proxyParams);
|
|
147
|
+
return await agent.get({
|
|
148
|
+
path: `${BASE_PATH}/package/goToCoordinates.cgi`,
|
|
149
|
+
parameters: { lat, lon, alt, ...this.apiUser },
|
|
150
|
+
timeout: options?.timeout,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
async checkGenetecConnection(params, options) {
|
|
154
|
+
return await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, '', params, options);
|
|
155
|
+
}
|
|
156
|
+
async getGenetecCameraList(params, options) {
|
|
157
|
+
const res = await this._postUrlEncoded(`${BASE_PATH}/package/getGenetecCameraList.cgi`, '', params, options);
|
|
158
|
+
return cameraListSchema.parse(res);
|
|
159
|
+
}
|
|
160
|
+
async _getJson(path, parameters, options, headers) {
|
|
161
|
+
const agent = this.getClient(options?.proxyParams);
|
|
162
|
+
const res = await agent.get({ path, parameters, timeout: options?.timeout, headers });
|
|
163
|
+
if (res.ok) {
|
|
164
|
+
return await res.json();
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
throw new Error(await responseStringify(res));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
async _post(path, data, parameters, options, headers) {
|
|
171
|
+
const agent = this.getClient(options?.proxyParams);
|
|
172
|
+
const res = await agent.post({ path, data, parameters, headers, timeout: options?.timeout });
|
|
173
|
+
if (res.ok) {
|
|
174
|
+
return await res.json();
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
throw new Error(await responseStringify(res));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async _getBlob(path, parameters, options) {
|
|
181
|
+
const agent = this.getClient(options?.proxyParams);
|
|
182
|
+
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
183
|
+
if (res.ok) {
|
|
184
|
+
return await this.parseBlobResponse(res);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
throw new Error(await responseStringify(res));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
async parseBlobResponse(response) {
|
|
191
|
+
try {
|
|
192
|
+
return (await response.blob());
|
|
193
|
+
}
|
|
194
|
+
catch (err) {
|
|
195
|
+
throw new ParsingBlobError(err);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
async _postUrlEncoded(path, data, parameters, options, headers) {
|
|
199
|
+
const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
200
|
+
return this._post(path, data, parameters, options, { ...baseHeaders, ...headers });
|
|
201
|
+
}
|
|
202
|
+
async _postJsonEncoded(path, data, parameters, options, headers) {
|
|
203
|
+
const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
|
|
204
|
+
return this._post(path, data, parameters, options, { ...baseHeaders, ...headers });
|
|
205
|
+
}
|
|
206
|
+
}
|