camstreamerlib 4.0.0-beta.3 → 4.0.0-beta.31
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 +8 -2
- package/cjs/CamOverlayAPI.d.ts +48 -26
- package/cjs/CamOverlayAPI.js +171 -88
- package/cjs/CamOverlayDrawingAPI.d.ts +2 -47
- package/cjs/CamOverlayDrawingAPI.js +6 -3
- package/cjs/CamOverlayPainter/Frame.d.ts +8 -37
- package/cjs/CamOverlayPainter/Frame.js +33 -0
- package/cjs/CamOverlayPainter/Painter.d.ts +16 -10
- package/cjs/CamOverlayPainter/Painter.js +6 -5
- package/cjs/CamOverlayPainter/ResourceManager.d.ts +3 -2
- package/cjs/CamOverlayPainter/ResourceManager.js +8 -11
- package/cjs/CamScripterAPI.d.ts +34 -16
- package/cjs/CamScripterAPI.js +50 -41
- package/cjs/CamScripterAPICameraEventsGenerator.d.ts +1 -1
- package/cjs/CamScripterAPICameraEventsGenerator.js +6 -3
- package/cjs/CamStreamerAPI.d.ts +17 -14
- package/cjs/CamStreamerAPI.js +32 -32
- package/cjs/CamSwitcherAPI.d.ts +43 -37
- package/cjs/CamSwitcherAPI.js +123 -114
- package/cjs/CamSwitcherEvents.d.ts +1 -1
- package/cjs/PlaneTrackerAPI.d.ts +43 -0
- package/cjs/PlaneTrackerAPI.js +211 -0
- package/cjs/VapixAPI.d.ts +56 -42
- package/cjs/VapixAPI.js +305 -216
- package/cjs/VapixEvents.d.ts +1 -1
- package/cjs/VapixEvents.js +3 -3
- package/cjs/errors/errors.d.ts +3 -0
- package/cjs/errors/errors.js +8 -1
- package/cjs/events/AxisCameraStationEvents.d.ts +7 -4
- package/cjs/events/AxisCameraStationEvents.js +23 -18
- package/cjs/events/GenetecAgent.d.ts +6 -3
- package/cjs/events/GenetecAgent.js +30 -19
- package/cjs/index.d.ts +14 -1
- package/cjs/index.js +23 -2
- package/cjs/internal/Digest.js +6 -6
- package/cjs/internal/ProxyClient.d.ts +8 -9
- package/cjs/internal/ProxyClient.js +25 -29
- package/cjs/internal/types.d.ts +42 -0
- package/cjs/internal/types.js +2 -0
- package/cjs/internal/utils.d.ts +4 -1
- package/cjs/internal/utils.js +22 -3
- package/cjs/internal/versionCompare.d.ts +2 -2
- package/cjs/node/DefaultClient.d.ts +5 -6
- package/cjs/node/DefaultClient.js +12 -14
- package/cjs/node/HttpRequestSender.d.ts +1 -0
- package/cjs/node/HttpRequestSender.js +13 -3
- package/cjs/node/HttpServer.js +1 -1
- package/cjs/node/WsClient.d.ts +2 -1
- package/cjs/node/index.d.ts +2 -0
- package/cjs/node/index.js +18 -1
- package/cjs/types/CamOverlayAPI/CamOverlayAPI.d.ts +3071 -0
- package/cjs/types/CamOverlayAPI/CamOverlayAPI.js +127 -0
- package/cjs/types/CamOverlayAPI/accuweatherSchema.d.ts +114 -0
- package/cjs/types/CamOverlayAPI/accuweatherSchema.js +50 -0
- package/cjs/types/CamOverlayAPI/customGraphicsSchema.d.ts +783 -0
- package/cjs/types/CamOverlayAPI/customGraphicsSchema.js +75 -0
- package/cjs/types/CamOverlayAPI/imagesSchema.d.ts +122 -0
- package/cjs/types/CamOverlayAPI/imagesSchema.js +12 -0
- package/cjs/types/CamOverlayAPI/index.d.ts +9 -0
- package/cjs/types/CamOverlayAPI/index.js +25 -0
- package/cjs/types/CamOverlayAPI/infotickerSchema.d.ts +130 -0
- package/cjs/types/CamOverlayAPI/infotickerSchema.js +29 -0
- package/cjs/types/CamOverlayAPI/pipSchema.d.ts +166 -0
- package/cjs/types/CamOverlayAPI/pipSchema.js +42 -0
- package/cjs/types/CamOverlayAPI/ptzCompassSchema.d.ts +126 -0
- package/cjs/types/CamOverlayAPI/ptzCompassSchema.js +28 -0
- package/cjs/types/CamOverlayAPI/ptzSchema.d.ts +146 -0
- package/cjs/types/CamOverlayAPI/ptzSchema.js +15 -0
- package/cjs/types/CamOverlayAPI/screenSharingSchema.d.ts +79 -0
- package/cjs/types/CamOverlayAPI/screenSharingSchema.js +11 -0
- package/cjs/types/CamOverlayAPI/webCameraSharingSchema.d.ts +79 -0
- package/cjs/types/CamOverlayAPI/webCameraSharingSchema.js +11 -0
- package/cjs/types/CamOverlayDrawingAPI.d.ts +58 -0
- package/cjs/types/CamOverlayDrawingAPI.js +2 -0
- package/cjs/types/CamOverlayPainter.d.ts +74 -0
- package/cjs/types/CamOverlayPainter.js +2 -0
- package/cjs/types/CamScripterAPI.d.ts +82 -17
- package/cjs/types/CamScripterAPI.js +22 -7
- package/cjs/types/CamStreamerAPI.d.ts +16 -5
- package/cjs/types/CamStreamerAPI.js +5 -1
- package/cjs/types/CamSwitcherAPI.d.ts +4 -6
- package/cjs/types/CamSwitcherEvents.d.ts +77 -0
- package/cjs/types/CamSwitcherEvents.js +8 -0
- package/cjs/types/PlaneTrackerAPI.d.ts +8 -0
- package/cjs/types/PlaneTrackerAPI.js +2 -0
- package/cjs/types/VapixAPI.d.ts +635 -520
- package/cjs/types/VapixAPI.js +62 -24
- package/cjs/types/common.d.ts +14 -5
- package/cjs/web/DefaultClient.d.ts +5 -5
- package/cjs/web/DefaultClient.js +22 -10
- package/cjs/web/WsClient.js +2 -2
- package/esm/CamOverlayAPI.d.ts +48 -26
- package/esm/CamOverlayAPI.js +167 -84
- package/esm/CamOverlayDrawingAPI.d.ts +2 -47
- package/esm/CamOverlayDrawingAPI.js +6 -3
- package/esm/CamOverlayPainter/Frame.d.ts +8 -37
- package/esm/CamOverlayPainter/Frame.js +33 -0
- package/esm/CamOverlayPainter/Painter.d.ts +16 -10
- package/esm/CamOverlayPainter/Painter.js +5 -3
- package/esm/CamOverlayPainter/ResourceManager.d.ts +3 -2
- package/esm/CamOverlayPainter/ResourceManager.js +7 -11
- package/esm/CamScripterAPI.d.ts +34 -16
- package/esm/CamScripterAPI.js +46 -37
- package/esm/CamScripterAPICameraEventsGenerator.d.ts +1 -1
- package/esm/CamScripterAPICameraEventsGenerator.js +6 -3
- package/esm/CamStreamerAPI.d.ts +17 -14
- package/esm/CamStreamerAPI.js +32 -32
- package/esm/CamSwitcherAPI.d.ts +43 -37
- package/esm/CamSwitcherAPI.js +116 -107
- package/esm/CamSwitcherEvents.d.ts +1 -1
- package/esm/PlaneTrackerAPI.d.ts +43 -0
- package/esm/PlaneTrackerAPI.js +207 -0
- package/esm/VapixAPI.d.ts +56 -42
- package/esm/VapixAPI.js +297 -208
- package/esm/VapixEvents.d.ts +1 -1
- package/esm/VapixEvents.js +3 -3
- package/esm/errors/errors.d.ts +3 -0
- package/esm/errors/errors.js +6 -0
- package/esm/events/AxisCameraStationEvents.d.ts +7 -4
- package/esm/events/AxisCameraStationEvents.js +18 -13
- package/esm/events/GenetecAgent.d.ts +6 -3
- package/esm/events/GenetecAgent.js +20 -9
- package/esm/index.d.ts +14 -1
- package/esm/index.js +14 -1
- package/esm/internal/Digest.js +6 -6
- package/esm/internal/ProxyClient.d.ts +8 -9
- package/esm/internal/ProxyClient.js +25 -29
- package/esm/internal/types.d.ts +42 -0
- package/esm/internal/types.js +1 -0
- package/esm/internal/utils.d.ts +4 -1
- package/esm/internal/utils.js +17 -1
- package/esm/internal/versionCompare.d.ts +2 -2
- package/esm/node/DefaultClient.d.ts +5 -6
- package/esm/node/DefaultClient.js +12 -14
- package/esm/node/HttpRequestSender.d.ts +1 -0
- package/esm/node/HttpRequestSender.js +13 -3
- package/esm/node/HttpServer.js +1 -1
- package/esm/node/WsClient.d.ts +2 -1
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +2 -0
- package/esm/types/CamOverlayAPI/CamOverlayAPI.d.ts +3071 -0
- package/esm/types/CamOverlayAPI/CamOverlayAPI.js +124 -0
- package/esm/types/CamOverlayAPI/accuweatherSchema.d.ts +114 -0
- package/esm/types/CamOverlayAPI/accuweatherSchema.js +46 -0
- package/esm/types/CamOverlayAPI/customGraphicsSchema.d.ts +783 -0
- package/esm/types/CamOverlayAPI/customGraphicsSchema.js +71 -0
- package/esm/types/CamOverlayAPI/imagesSchema.d.ts +122 -0
- package/esm/types/CamOverlayAPI/imagesSchema.js +8 -0
- package/esm/types/CamOverlayAPI/index.d.ts +9 -0
- package/esm/types/CamOverlayAPI/index.js +9 -0
- package/esm/types/CamOverlayAPI/infotickerSchema.d.ts +130 -0
- package/esm/types/CamOverlayAPI/infotickerSchema.js +25 -0
- package/esm/types/CamOverlayAPI/pipSchema.d.ts +166 -0
- package/esm/types/CamOverlayAPI/pipSchema.js +38 -0
- package/esm/types/CamOverlayAPI/ptzCompassSchema.d.ts +126 -0
- package/esm/types/CamOverlayAPI/ptzCompassSchema.js +24 -0
- package/esm/types/CamOverlayAPI/ptzSchema.d.ts +146 -0
- package/esm/types/CamOverlayAPI/ptzSchema.js +11 -0
- package/esm/types/CamOverlayAPI/screenSharingSchema.d.ts +79 -0
- package/esm/types/CamOverlayAPI/screenSharingSchema.js +7 -0
- package/esm/types/CamOverlayAPI/webCameraSharingSchema.d.ts +79 -0
- package/esm/types/CamOverlayAPI/webCameraSharingSchema.js +7 -0
- package/esm/types/CamOverlayDrawingAPI.d.ts +58 -0
- package/esm/types/CamOverlayDrawingAPI.js +1 -0
- package/esm/types/CamOverlayPainter.d.ts +74 -0
- package/esm/types/CamOverlayPainter.js +1 -0
- package/esm/types/CamScripterAPI.d.ts +82 -17
- package/esm/types/CamScripterAPI.js +21 -6
- package/esm/types/CamStreamerAPI.d.ts +16 -5
- package/esm/types/CamStreamerAPI.js +4 -0
- package/esm/types/CamSwitcherAPI.d.ts +4 -6
- package/esm/types/CamSwitcherEvents.d.ts +77 -0
- package/esm/types/CamSwitcherEvents.js +8 -0
- package/esm/types/PlaneTrackerAPI.d.ts +8 -0
- package/esm/types/PlaneTrackerAPI.js +1 -0
- package/esm/types/VapixAPI.d.ts +635 -520
- package/esm/types/VapixAPI.js +61 -23
- package/esm/types/common.d.ts +14 -5
- package/esm/web/DefaultClient.d.ts +5 -5
- package/esm/web/DefaultClient.js +22 -10
- package/esm/web/WsClient.js +2 -2
- package/package.json +9 -8
- package/cjs/internal/common.d.ts +0 -39
- package/cjs/internal/common.js +0 -27
- 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/esm/internal/common.d.ts +0 -39
- package/esm/internal/common.js +0 -20
- package/esm/node/WsEventClient.d.ts +0 -13
- package/esm/node/WsEventClient.js +0 -18
- package/esm/types/CamOverlayAPI.d.ts +0 -188
- package/esm/types/CamOverlayAPI.js +0 -44
package/esm/CamSwitcherAPI.js
CHANGED
|
@@ -1,123 +1,134 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { AddNewClipError } from './errors/errors';
|
|
3
|
-
import { isNullish, responseStringify } from './internal/
|
|
3
|
+
import { isClip, isNullish, responseStringify } from './internal/utils';
|
|
4
4
|
import { storageInfoListSchema, outputInfoSchema, audioPushInfoSchema, clipListSchema, playlistQueueSchema, streamSaveLoadSchema, clipSaveLoadSchema, playlistSaveLoadSchema, trackerSaveLoadSchema, } from './types/CamSwitcherAPI';
|
|
5
|
-
import { networkCameraListSchema } from './types/common';
|
|
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
|
+
this.CustomFormData = CustomFormData;
|
|
18
|
+
this.vapixAgent = new VapixAPI(client);
|
|
17
19
|
}
|
|
18
|
-
static getProxyUrlPath = () => `${
|
|
20
|
+
static getProxyUrlPath = () => `${BASE_PATH}/proxy.cgi`;
|
|
19
21
|
static getWsEventsUrlPath = () => `/local/camswitcher/events`;
|
|
20
|
-
static getClipPreviewUrlPath = (id, storage) => `${
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
static getClipPreviewUrlPath = (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 generateSilence(sampleRate, channels, options) {
|
|
27
|
+
const agent = this.getClient(options?.proxyParams);
|
|
28
|
+
await agent.get({
|
|
29
|
+
path: `${BASE_PATH}/generate_silence.cgi`,
|
|
30
|
+
parameters: {
|
|
31
|
+
sample_rate: sampleRate.toString(),
|
|
32
|
+
channels,
|
|
33
|
+
},
|
|
34
|
+
timeout: options?.timeout,
|
|
25
35
|
});
|
|
26
36
|
}
|
|
27
|
-
async checkCameraTime() {
|
|
28
|
-
const data = await this.get(`${
|
|
37
|
+
async checkCameraTime(options) {
|
|
38
|
+
const data = await this.get(`${BASE_PATH}/camera_time.cgi`, undefined, options);
|
|
29
39
|
return z.boolean().parse(data);
|
|
30
40
|
}
|
|
31
|
-
async
|
|
32
|
-
const data = await this.get(`${
|
|
41
|
+
async getNetworkCameraList(options) {
|
|
42
|
+
const data = await this.get(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
|
|
33
43
|
return networkCameraListSchema.parse(data);
|
|
34
44
|
}
|
|
35
|
-
async getMaxFps(source) {
|
|
36
|
-
const data = await this.get(`${
|
|
45
|
+
async getMaxFps(source, options) {
|
|
46
|
+
const data = await this.get(`${BASE_PATH}/get_max_framerate.cgi`, {
|
|
37
47
|
video_source: source.toString(),
|
|
38
|
-
});
|
|
48
|
+
}, options);
|
|
39
49
|
return z.number().parse(data);
|
|
40
50
|
}
|
|
41
|
-
async getStorageInfo() {
|
|
42
|
-
const data = await this.get(`${
|
|
51
|
+
async getStorageInfo(options) {
|
|
52
|
+
const data = await this.get(`${BASE_PATH}/get_storage.cgi`, undefined, options);
|
|
43
53
|
return storageInfoListSchema.parse(data);
|
|
44
54
|
}
|
|
45
|
-
async wsAuthorization() {
|
|
46
|
-
const data = await this.get(`${
|
|
55
|
+
async wsAuthorization(options) {
|
|
56
|
+
const data = await this.get(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
|
|
47
57
|
return z.string().parse(data);
|
|
48
58
|
}
|
|
49
|
-
async getOutputInfo() {
|
|
50
|
-
const data = await this.get(`${
|
|
59
|
+
async getOutputInfo(options) {
|
|
60
|
+
const data = await this.get(`${BASE_PATH}/output_info.cgi`, undefined, options);
|
|
51
61
|
return outputInfoSchema.parse(data);
|
|
52
62
|
}
|
|
53
|
-
async getAudioPushInfo() {
|
|
54
|
-
const data = await this.get(`${
|
|
63
|
+
async getAudioPushInfo(options) {
|
|
64
|
+
const data = await this.get(`${BASE_PATH}/audio_push_info.cgi`, undefined, options);
|
|
55
65
|
return audioPushInfoSchema.parse(data);
|
|
56
66
|
}
|
|
57
|
-
async getStreamSaveList() {
|
|
58
|
-
const data = await this.get(`${
|
|
67
|
+
async getStreamSaveList(options) {
|
|
68
|
+
const data = await this.get(`${BASE_PATH}/streams.cgi`, { action: 'get' }, options);
|
|
59
69
|
return streamSaveLoadSchema.parse(data);
|
|
60
70
|
}
|
|
61
|
-
async getClipSaveList() {
|
|
62
|
-
const data = await this.get(`${
|
|
71
|
+
async getClipSaveList(options) {
|
|
72
|
+
const data = await this.get(`${BASE_PATH}/clips.cgi`, { action: 'get' }, options);
|
|
63
73
|
return clipSaveLoadSchema.parse(data);
|
|
64
74
|
}
|
|
65
|
-
async getPlaylistSaveList() {
|
|
66
|
-
const data = await this.get(`${
|
|
75
|
+
async getPlaylistSaveList(options) {
|
|
76
|
+
const data = await this.get(`${BASE_PATH}/playlists.cgi`, { action: 'get' }, options);
|
|
67
77
|
return playlistSaveLoadSchema.parse(data);
|
|
68
78
|
}
|
|
69
|
-
async getTrackerSaveList() {
|
|
70
|
-
const data = await this.get(`${
|
|
79
|
+
async getTrackerSaveList(options) {
|
|
80
|
+
const data = await this.get(`${BASE_PATH}/trackers.cgi`, { action: 'get' }, options);
|
|
71
81
|
return trackerSaveLoadSchema.parse(data);
|
|
72
82
|
}
|
|
73
|
-
async setStreamSaveList(data) {
|
|
74
|
-
return await this.set(`${
|
|
83
|
+
async setStreamSaveList(data, options) {
|
|
84
|
+
return await this.set(`${BASE_PATH}/streams.cgi`, data, { action: 'set' }, options);
|
|
75
85
|
}
|
|
76
|
-
async setClipSaveList(data) {
|
|
77
|
-
return await this.set(`${
|
|
86
|
+
async setClipSaveList(data, options) {
|
|
87
|
+
return await this.set(`${BASE_PATH}/clips.cgi`, data, { action: 'set' }, options);
|
|
78
88
|
}
|
|
79
|
-
async setPlaylistSaveList(data) {
|
|
80
|
-
return await this.set(`${
|
|
89
|
+
async setPlaylistSaveList(data, options) {
|
|
90
|
+
return await this.set(`${BASE_PATH}/playlists.cgi`, data, { action: 'set' }, options);
|
|
81
91
|
}
|
|
82
|
-
async setTrackerSaveList(data) {
|
|
83
|
-
return await this.set(`${
|
|
92
|
+
async setTrackerSaveList(data, options) {
|
|
93
|
+
return await this.set(`${BASE_PATH}/trackers.cgi`, data, { action: 'set' }, options);
|
|
84
94
|
}
|
|
85
|
-
async playlistSwitch(playlistName) {
|
|
86
|
-
await this.get(`${
|
|
95
|
+
async playlistSwitch(playlistName, options) {
|
|
96
|
+
await this.get(`${BASE_PATH}/playlist_switch.cgi`, { playlist_name: playlistName }, options);
|
|
87
97
|
}
|
|
88
|
-
async playlistQueuePush(playlistName) {
|
|
89
|
-
await this.get(`${
|
|
98
|
+
async playlistQueuePush(playlistName, options) {
|
|
99
|
+
await this.get(`${BASE_PATH}/playlist_queue_push.cgi`, { playlist_name: playlistName }, options);
|
|
90
100
|
}
|
|
91
|
-
async playlistQueueClear() {
|
|
92
|
-
await this.get(`${
|
|
101
|
+
async playlistQueueClear(options) {
|
|
102
|
+
await this.get(`${BASE_PATH}/playlist_queue_clear.cgi`, undefined, options);
|
|
93
103
|
}
|
|
94
|
-
async playlistQueueList() {
|
|
95
|
-
const data = await this.get(`${
|
|
104
|
+
async playlistQueueList(options) {
|
|
105
|
+
const data = await this.get(`${BASE_PATH}/playlist_queue_list.cgi`, undefined, options);
|
|
96
106
|
return playlistQueueSchema.parse(data).playlistQueueList;
|
|
97
107
|
}
|
|
98
|
-
async playlistQueuePlayNext() {
|
|
99
|
-
await this.get(`${
|
|
108
|
+
async playlistQueuePlayNext(options) {
|
|
109
|
+
await this.get(`${BASE_PATH}/playlist_queue_play_next.cgi`, undefined, options);
|
|
100
110
|
}
|
|
101
|
-
async addNewClip(file, clipType, storage, id, fileName) {
|
|
102
|
-
const
|
|
111
|
+
async addNewClip(file, clipType, storage, id, fileName, options) {
|
|
112
|
+
const path = `${BASE_PATH}/clip_upload.cgi?storage=${storage}`;
|
|
113
|
+
const formData = new this.CustomFormData();
|
|
103
114
|
formData.append('clip_name', id);
|
|
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({ path, data: formData, timeout: options?.timeout });
|
|
108
119
|
const output = (await res.json());
|
|
109
120
|
if (output.status !== 200) {
|
|
110
121
|
throw new AddNewClipError(output.message);
|
|
111
122
|
}
|
|
112
123
|
}
|
|
113
|
-
removeClip(id, storage) {
|
|
114
|
-
return this.get(`${
|
|
124
|
+
removeClip(id, storage, options) {
|
|
125
|
+
return this.get(`${BASE_PATH}/clip_remove.cgi`, { clip_name: id, storage }, options);
|
|
115
126
|
}
|
|
116
|
-
async getClipList() {
|
|
117
|
-
const data = await this.get(`${
|
|
127
|
+
async getClipList(options) {
|
|
128
|
+
const data = await this.get(`${BASE_PATH}/clip_list.cgi`, undefined, options);
|
|
118
129
|
return clipListSchema.parse(data).clip_list;
|
|
119
130
|
}
|
|
120
|
-
setCamSwitchOptions(data, cameraFWVersion) {
|
|
131
|
+
setCamSwitchOptions(data, cameraFWVersion, options) {
|
|
121
132
|
const bitrateVapixParams = parseBitrateOptionsToBitrateVapixParams(cameraFWVersion, data.bitrateMode, data);
|
|
122
133
|
const saveData = {
|
|
123
134
|
video: {
|
|
@@ -135,9 +146,9 @@ export class CamSwitcherAPI {
|
|
|
135
146
|
},
|
|
136
147
|
keyboard: data.keyboard,
|
|
137
148
|
};
|
|
138
|
-
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.SETTINGS, saveData);
|
|
149
|
+
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.SETTINGS, saveData, options);
|
|
139
150
|
}
|
|
140
|
-
setGlobalAudioSettings(settings) {
|
|
151
|
+
setGlobalAudioSettings(settings, options) {
|
|
141
152
|
let acceptedType = 'NONE';
|
|
142
153
|
if (settings.type === 'source' && settings.source) {
|
|
143
154
|
if (isClip(settings.source)) {
|
|
@@ -153,9 +164,9 @@ export class CamSwitcherAPI {
|
|
|
153
164
|
clip_name: settings.source,
|
|
154
165
|
storage: settings.storage,
|
|
155
166
|
};
|
|
156
|
-
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.MASTER_AUDIO, data);
|
|
167
|
+
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.MASTER_AUDIO, data, options);
|
|
157
168
|
}
|
|
158
|
-
setSecondaryAudioSettings(settings) {
|
|
169
|
+
setSecondaryAudioSettings(settings, options) {
|
|
159
170
|
const data = {
|
|
160
171
|
type: settings.type,
|
|
161
172
|
stream_name: settings.streamName ?? '',
|
|
@@ -164,19 +175,19 @@ export class CamSwitcherAPI {
|
|
|
164
175
|
secondary_audio_level: settings.secondaryAudioLevel,
|
|
165
176
|
master_audio_level: settings.masterAudioLevel,
|
|
166
177
|
};
|
|
167
|
-
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.SECONDARY_AUDIO, data);
|
|
178
|
+
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.SECONDARY_AUDIO, data, options);
|
|
168
179
|
}
|
|
169
|
-
setDefaultPlaylist(id) {
|
|
180
|
+
setDefaultPlaylist(id, options) {
|
|
170
181
|
const value = JSON.stringify({ default_playlist_id: id });
|
|
171
182
|
return this.vapixAgent.setParameter({
|
|
172
183
|
[CSW_PARAM_NAMES.DEFAULT_PLAYLIST]: value,
|
|
173
|
-
},
|
|
184
|
+
}, options);
|
|
174
185
|
}
|
|
175
|
-
setPermanentRtspUrlToken(token) {
|
|
176
|
-
return this.vapixAgent.setParameter({ [CSW_PARAM_NAMES.RTSP_TOKEN]: token },
|
|
186
|
+
setPermanentRtspUrlToken(token, options) {
|
|
187
|
+
return this.vapixAgent.setParameter({ [CSW_PARAM_NAMES.RTSP_TOKEN]: token }, options);
|
|
177
188
|
}
|
|
178
|
-
async getCamSwitchOptions() {
|
|
179
|
-
const saveData = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SETTINGS);
|
|
189
|
+
async getCamSwitchOptions(options) {
|
|
190
|
+
const saveData = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SETTINGS, options);
|
|
180
191
|
if (isNullish(saveData.video)) {
|
|
181
192
|
return saveData;
|
|
182
193
|
}
|
|
@@ -201,12 +212,12 @@ export class CamSwitcherAPI {
|
|
|
201
212
|
keyboard: saveData.keyboard,
|
|
202
213
|
};
|
|
203
214
|
}
|
|
204
|
-
async getGlobalAudioSettings() {
|
|
215
|
+
async getGlobalAudioSettings(options) {
|
|
205
216
|
const settings = {
|
|
206
217
|
type: 'fromSource',
|
|
207
218
|
source: 'fromSource',
|
|
208
219
|
};
|
|
209
|
-
const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.MASTER_AUDIO);
|
|
220
|
+
const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.MASTER_AUDIO, options);
|
|
210
221
|
if (res.type === 'STREAM') {
|
|
211
222
|
settings.type = 'source';
|
|
212
223
|
settings.source = res.stream_name;
|
|
@@ -218,8 +229,8 @@ export class CamSwitcherAPI {
|
|
|
218
229
|
}
|
|
219
230
|
return settings;
|
|
220
231
|
}
|
|
221
|
-
async getSecondaryAudioSettings() {
|
|
222
|
-
const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SECONDARY_AUDIO);
|
|
232
|
+
async getSecondaryAudioSettings(options) {
|
|
233
|
+
const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SECONDARY_AUDIO, options);
|
|
223
234
|
const settings = {
|
|
224
235
|
type: res.type ?? 'NONE',
|
|
225
236
|
streamName: res.stream_name,
|
|
@@ -230,13 +241,14 @@ export class CamSwitcherAPI {
|
|
|
230
241
|
};
|
|
231
242
|
return settings;
|
|
232
243
|
}
|
|
233
|
-
async getPermanentRtspUrlToken() {
|
|
244
|
+
async getPermanentRtspUrlToken(options) {
|
|
234
245
|
const paramName = CSW_PARAM_NAMES.RTSP_TOKEN;
|
|
235
|
-
const res = await this.vapixAgent.getParameter([paramName],
|
|
246
|
+
const res = await this.vapixAgent.getParameter([paramName], options);
|
|
236
247
|
return res[paramName] ?? '';
|
|
237
248
|
}
|
|
238
|
-
async get(path, parameters
|
|
239
|
-
const
|
|
249
|
+
async get(path, parameters, options) {
|
|
250
|
+
const agent = this.getClient(options?.proxyParams);
|
|
251
|
+
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
240
252
|
if (res.ok) {
|
|
241
253
|
const d = (await res.json());
|
|
242
254
|
return d.data;
|
|
@@ -245,8 +257,9 @@ export class CamSwitcherAPI {
|
|
|
245
257
|
throw new Error(await responseStringify(res));
|
|
246
258
|
}
|
|
247
259
|
}
|
|
248
|
-
async set(path, data, parameters
|
|
249
|
-
const
|
|
260
|
+
async set(path, data, parameters, options) {
|
|
261
|
+
const agent = this.getClient(options?.proxyParams);
|
|
262
|
+
const res = await agent.post({ path, data: JSON.stringify(data), parameters, timeout: options?.timeout });
|
|
250
263
|
if (res.ok) {
|
|
251
264
|
const parsed = await res.json();
|
|
252
265
|
return parsed.message === 'OK';
|
|
@@ -255,13 +268,13 @@ export class CamSwitcherAPI {
|
|
|
255
268
|
throw new Error(await responseStringify(res));
|
|
256
269
|
}
|
|
257
270
|
}
|
|
258
|
-
setParamFromCameraJSON(paramName, data) {
|
|
271
|
+
setParamFromCameraJSON(paramName, data, options) {
|
|
259
272
|
const params = {};
|
|
260
273
|
params[paramName] = JSON.stringify(data);
|
|
261
|
-
return this.vapixAgent.setParameter(params,
|
|
274
|
+
return this.vapixAgent.setParameter(params, options);
|
|
262
275
|
}
|
|
263
|
-
async getParamFromCameraAndJSONParse(paramName) {
|
|
264
|
-
const data = await this.vapixAgent.getParameter([paramName],
|
|
276
|
+
async getParamFromCameraAndJSONParse(paramName, options) {
|
|
277
|
+
const data = await this.vapixAgent.getParameter([paramName], options);
|
|
265
278
|
if (data[paramName] !== undefined) {
|
|
266
279
|
try {
|
|
267
280
|
if (data[paramName] === '') {
|
|
@@ -292,16 +305,12 @@ const parseBitrateOptionsToBitrateVapixParams = (firmWareVersion, bitrateMode, c
|
|
|
292
305
|
if (bitrateMode === null) {
|
|
293
306
|
return '';
|
|
294
307
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
if (bitrateMode === 'ABR') {
|
|
302
|
-
return `videobitratemode=abr&videoabrtargetbitrate=${cameraOptions.maximumBitRate}&videoabrretentiontime=${cameraOptions.retentionTime}&videoabrmaxbitrate=${cameraOptions.bitRateLimit}`;
|
|
303
|
-
}
|
|
304
|
-
throw new Error('Unknown bitrateMode param in getVapixParams method.');
|
|
308
|
+
const data = {
|
|
309
|
+
VBR: 'videobitratemode=vbr',
|
|
310
|
+
MBR: `videobitratemode=mbr&videomaxbitrate=${cameraOptions.maximumBitRate}`,
|
|
311
|
+
ABR: `videobitratemode=abr&videoabrtargetbitrate=${cameraOptions.maximumBitRate}&videoabrretentiontime=${cameraOptions.retentionTime}&videoabrmaxbitrate=${cameraOptions.bitRateLimit}`,
|
|
312
|
+
};
|
|
313
|
+
return data[bitrateMode];
|
|
305
314
|
};
|
|
306
315
|
const parseVapixParamsToBitrateOptions = (bitrateVapixParams) => {
|
|
307
316
|
const params = {};
|
|
@@ -312,7 +321,7 @@ const parseVapixParamsToBitrateOptions = (bitrateVapixParams) => {
|
|
|
312
321
|
const bitrateMode = params['videobitratemode'] !== undefined ? params['videobitratemode'].toUpperCase() : undefined;
|
|
313
322
|
const hasLowerFw = bitrateMode === undefined && params['videomaxbitrate'] !== undefined;
|
|
314
323
|
if (hasLowerFw) {
|
|
315
|
-
const maximumBitRate = parseInt(params['videomaxbitrate'], 10);
|
|
324
|
+
const maximumBitRate = parseInt(params['videomaxbitrate'] ?? '0', 10);
|
|
316
325
|
return {
|
|
317
326
|
bitrateMode: 'MBR',
|
|
318
327
|
maximumBitRate: maximumBitRate,
|
|
@@ -321,19 +330,19 @@ const parseVapixParamsToBitrateOptions = (bitrateVapixParams) => {
|
|
|
321
330
|
};
|
|
322
331
|
}
|
|
323
332
|
if (bitrateMode === 'ABR') {
|
|
324
|
-
const maximumBitRate = parseInt(params['videoabrtargetbitrate'], 10);
|
|
325
|
-
const retentionTime = parseInt(params['videoabrretentiontime'], 10);
|
|
326
|
-
const
|
|
333
|
+
const maximumBitRate = parseInt(params['videoabrtargetbitrate'] ?? '0', 10);
|
|
334
|
+
const retentionTime = parseInt(params['videoabrretentiontime'] ?? '0', 10);
|
|
335
|
+
const bitRateLimit = parseInt(params['videoabrmaxbitrate'] ?? '0', 10);
|
|
327
336
|
return {
|
|
328
|
-
bitrateMode
|
|
329
|
-
maximumBitRate
|
|
330
|
-
retentionTime
|
|
331
|
-
bitRateLimit
|
|
337
|
+
bitrateMode,
|
|
338
|
+
maximumBitRate,
|
|
339
|
+
retentionTime,
|
|
340
|
+
bitRateLimit,
|
|
332
341
|
};
|
|
333
342
|
}
|
|
334
343
|
else if (bitrateMode === 'MBR') {
|
|
335
|
-
const maximumBitRate = parseInt(params['videomaxbitrate'], 10);
|
|
336
|
-
const oldMaximumBitrateParamValue = parseInt(params['videombrmaxbitrate'], 10);
|
|
344
|
+
const maximumBitRate = params['videomaxbitrate'] !== undefined ? parseInt(params['videomaxbitrate'], 10) : null;
|
|
345
|
+
const oldMaximumBitrateParamValue = parseInt(params['videombrmaxbitrate'] ?? '0', 10);
|
|
337
346
|
return {
|
|
338
347
|
bitrateMode: bitrateMode,
|
|
339
348
|
maximumBitRate: maximumBitRate ?? oldMaximumBitrateParamValue,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IWebsocket } from './internal/
|
|
1
|
+
import { IWebsocket } from './internal/types';
|
|
2
2
|
import { TCamSwitcherEventOfType, TCamSwitcherEventType } from './types/CamSwitcherEvents';
|
|
3
3
|
type TListenerFunction<T extends TCamSwitcherEventType> = (data: TCamSwitcherEventOfType<T>, isInit: boolean) => void;
|
|
4
4
|
export declare class CamSwitcherEvents<Event extends {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { IClient, TBlobResponse, TParameters, TResponse } from './internal/types';
|
|
2
|
+
import { ICAO, TApiUser, TExportDataType, TImportDataType } from './types/PlaneTrackerAPI';
|
|
3
|
+
import { THttpRequestOptions, TProxyParams } from './types/common';
|
|
4
|
+
import { ProxyClient } from './internal/ProxyClient';
|
|
5
|
+
export declare class PlaneTrackerAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
6
|
+
private client;
|
|
7
|
+
private apiUser;
|
|
8
|
+
constructor(client: Client, apiUser: TApiUser);
|
|
9
|
+
static getProxyUrlPath: () => string;
|
|
10
|
+
getClient(proxyParams?: TProxyParams): Client | ProxyClient<Client>;
|
|
11
|
+
checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
|
|
12
|
+
resetPtzCalibration: (options?: THttpRequestOptions) => Promise<TResponse>;
|
|
13
|
+
resetFocusCalibration: (options?: THttpRequestOptions) => Promise<TResponse>;
|
|
14
|
+
serverRunCheck: (options?: THttpRequestOptions) => Promise<TResponse>;
|
|
15
|
+
getLiveViewAlias: (rtspUrl: string, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
16
|
+
fetchCameraSettings: (options?: THttpRequestOptions) => Promise<any>;
|
|
17
|
+
setCameraSettings: (settingsJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
18
|
+
fetchServerSettings: (options?: THttpRequestOptions) => Promise<any>;
|
|
19
|
+
exportAppSettings: (dataType: TExportDataType, options?: THttpRequestOptions) => Promise<TBlobResponse<Client>>;
|
|
20
|
+
importAppSettings: (dataType: TImportDataType, formData: FormData, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
21
|
+
fetchFlightInfo: (icao: ICAO, options?: THttpRequestOptions) => Promise<any>;
|
|
22
|
+
getTrackingMode: (options?: THttpRequestOptions) => Promise<any>;
|
|
23
|
+
setTrackingMode: (modeJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
24
|
+
startTrackingPlane: (icao: ICAO, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
25
|
+
stopTrackingPlane: (options?: THttpRequestOptions) => Promise<TResponse>;
|
|
26
|
+
getPriorityList: (options?: THttpRequestOptions) => Promise<any>;
|
|
27
|
+
setPriorityList: (priorityListJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
28
|
+
getWhiteList: (options?: THttpRequestOptions) => Promise<any>;
|
|
29
|
+
setWhiteList: (whiteListJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
30
|
+
getBlackList: (options?: THttpRequestOptions) => Promise<any>;
|
|
31
|
+
setBlackList: (blackListJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
32
|
+
fetchMapInfo: (options?: THttpRequestOptions) => Promise<any>;
|
|
33
|
+
getZones: (options?: THttpRequestOptions) => Promise<any>;
|
|
34
|
+
setZones: (zonesJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
35
|
+
goToCoordinates: (lat: number, lon: number, alt?: number, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
36
|
+
checkGenetecConnection: (params: TParameters, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
37
|
+
getGenetecCameraList: (params: TParameters, options?: THttpRequestOptions) => Promise<any>;
|
|
38
|
+
private _getJson;
|
|
39
|
+
private _getBlob;
|
|
40
|
+
private parseBlobResponse;
|
|
41
|
+
private _postJsonEncoded;
|
|
42
|
+
private _postUrlEncoded;
|
|
43
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { paramToUrl, responseStringify } from './internal/utils';
|
|
3
|
+
import { ParsingBlobError } from './errors/errors';
|
|
4
|
+
import { ProxyClient } from './internal/ProxyClient';
|
|
5
|
+
const BASE_PATH = '/local/planetracker';
|
|
6
|
+
export class PlaneTrackerAPI {
|
|
7
|
+
client;
|
|
8
|
+
apiUser;
|
|
9
|
+
constructor(client, apiUser) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
this.apiUser = apiUser;
|
|
12
|
+
}
|
|
13
|
+
static getProxyUrlPath = () => `${BASE_PATH}/proxy.cgi`;
|
|
14
|
+
getClient(proxyParams) {
|
|
15
|
+
return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
|
|
16
|
+
}
|
|
17
|
+
async checkCameraTime(options) {
|
|
18
|
+
const response = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
|
|
19
|
+
return z.boolean().parse(response.state);
|
|
20
|
+
}
|
|
21
|
+
resetPtzCalibration = async (options) => {
|
|
22
|
+
const agent = this.getClient(options?.proxyParams);
|
|
23
|
+
return await agent.get({
|
|
24
|
+
path: `${BASE_PATH}/package/resetPtzCalibration.cgi`,
|
|
25
|
+
parameters: this.apiUser,
|
|
26
|
+
timeout: options?.timeout,
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
resetFocusCalibration = async (options) => {
|
|
30
|
+
const agent = this.getClient(options?.proxyParams);
|
|
31
|
+
return await agent.get({
|
|
32
|
+
path: `${BASE_PATH}/package/resetFocusCalibration.cgi`,
|
|
33
|
+
parameters: this.apiUser,
|
|
34
|
+
timeout: options?.timeout,
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
serverRunCheck = async (options) => {
|
|
38
|
+
const agent = this.getClient(options?.proxyParams);
|
|
39
|
+
return await agent.get({ path: `${BASE_PATH}/package/serverRunCheck.cgi`, timeout: options?.timeout });
|
|
40
|
+
};
|
|
41
|
+
getLiveViewAlias = async (rtspUrl, options) => {
|
|
42
|
+
const agent = this.getClient(options?.proxyParams);
|
|
43
|
+
return await agent.get({
|
|
44
|
+
path: `${BASE_PATH}/getLiveViewAlias.cgi`,
|
|
45
|
+
parameters: { rtsp_url: rtspUrl },
|
|
46
|
+
timeout: options?.timeout,
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
fetchCameraSettings = async (options) => {
|
|
50
|
+
return await this._getJson(`${BASE_PATH}/package_camera_settings.cgi`, { action: 'get' }, options);
|
|
51
|
+
};
|
|
52
|
+
setCameraSettings = async (settingsJsonString, options) => {
|
|
53
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package_camera_settings.cgi`, settingsJsonString, {
|
|
54
|
+
action: 'set',
|
|
55
|
+
}, options);
|
|
56
|
+
};
|
|
57
|
+
fetchServerSettings = async (options) => {
|
|
58
|
+
return await this._getJson(`${BASE_PATH}/package_server_settings.cgi`, { action: 'get' }, options);
|
|
59
|
+
};
|
|
60
|
+
exportAppSettings = async (dataType, options) => {
|
|
61
|
+
return await this._getBlob(`${BASE_PATH}/package_data.cgi`, { action: 'EXPORT', dataType }, options);
|
|
62
|
+
};
|
|
63
|
+
importAppSettings = async (dataType, formData, options) => {
|
|
64
|
+
const agent = this.getClient(options?.proxyParams);
|
|
65
|
+
return await agent.post({
|
|
66
|
+
path: `${BASE_PATH}/package_data.cgi`,
|
|
67
|
+
data: formData,
|
|
68
|
+
parameters: { action: 'IMPORT', dataType },
|
|
69
|
+
timeout: options?.timeout,
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
fetchFlightInfo = async (icao, options) => {
|
|
73
|
+
return await this._getJson(`${BASE_PATH}/package/flightInfo.cgi`, { icao: encodeURIComponent(icao) }, options);
|
|
74
|
+
};
|
|
75
|
+
getTrackingMode = async (options) => {
|
|
76
|
+
return await this._getJson(`${BASE_PATH}/package/getTrackingMode.cgi`, undefined, options);
|
|
77
|
+
};
|
|
78
|
+
setTrackingMode = async (modeJsonString, options) => {
|
|
79
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package/setTrackingMode.cgi`, modeJsonString, this.apiUser, options);
|
|
80
|
+
};
|
|
81
|
+
startTrackingPlane = async (icao, options) => {
|
|
82
|
+
const agent = this.getClient(options?.proxyParams);
|
|
83
|
+
return await agent.get({
|
|
84
|
+
path: `${BASE_PATH}/package/trackIcao.cgi`,
|
|
85
|
+
parameters: { icao, ...this.apiUser },
|
|
86
|
+
timeout: options?.timeout,
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
stopTrackingPlane = async (options) => {
|
|
90
|
+
const agent = this.getClient(options?.proxyParams);
|
|
91
|
+
return await agent.get({
|
|
92
|
+
path: `${BASE_PATH}/package/resetIcao.cgi`,
|
|
93
|
+
parameters: this.apiUser,
|
|
94
|
+
timeout: options?.timeout,
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
getPriorityList = async (options) => {
|
|
98
|
+
return await this._getJson(`${BASE_PATH}/package/getPriorityList.cgi`, undefined, options);
|
|
99
|
+
};
|
|
100
|
+
setPriorityList = async (priorityListJsonString, options) => {
|
|
101
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package/setPriorityList.cgi`, priorityListJsonString, this.apiUser, options);
|
|
102
|
+
};
|
|
103
|
+
getWhiteList = async (options) => {
|
|
104
|
+
return await this._getJson(`${BASE_PATH}/package/getWhiteList.cgi`, undefined, options);
|
|
105
|
+
};
|
|
106
|
+
setWhiteList = async (whiteListJsonString, options) => {
|
|
107
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, whiteListJsonString, this.apiUser, options);
|
|
108
|
+
};
|
|
109
|
+
getBlackList = async (options) => {
|
|
110
|
+
return await this._getJson(`${BASE_PATH}/package/getBlackList.cgi`, undefined, options);
|
|
111
|
+
};
|
|
112
|
+
setBlackList = async (blackListJsonString, options) => {
|
|
113
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, blackListJsonString, this.apiUser, options);
|
|
114
|
+
};
|
|
115
|
+
fetchMapInfo = async (options) => {
|
|
116
|
+
return await this._getJson(`${BASE_PATH}/package/getMapInfo.cgi`, undefined, options);
|
|
117
|
+
};
|
|
118
|
+
getZones = async (options) => {
|
|
119
|
+
return await this._getJson(`${BASE_PATH}/package/getZones.cgi`, undefined, options);
|
|
120
|
+
};
|
|
121
|
+
setZones = async (zonesJsonString, options) => {
|
|
122
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package/setZones.cgi`, zonesJsonString, this.apiUser, options);
|
|
123
|
+
};
|
|
124
|
+
goToCoordinates = async (lat, lon, alt, options) => {
|
|
125
|
+
const agent = this.getClient(options?.proxyParams);
|
|
126
|
+
return await agent.get({
|
|
127
|
+
path: `${BASE_PATH}/package/goToCoordinates.cgi`,
|
|
128
|
+
parameters: { lat, lon, alt, ...this.apiUser },
|
|
129
|
+
timeout: options?.timeout,
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
checkGenetecConnection = async (params, options) => {
|
|
133
|
+
return await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, params, options);
|
|
134
|
+
};
|
|
135
|
+
getGenetecCameraList = async (params, options) => {
|
|
136
|
+
const res = await this._postUrlEncoded(`${BASE_PATH}/package/getGenetecCameraList.cgi`, params, options);
|
|
137
|
+
return await res.json();
|
|
138
|
+
};
|
|
139
|
+
async _getJson(path, parameters, options) {
|
|
140
|
+
const agent = this.getClient(options?.proxyParams);
|
|
141
|
+
const res = await agent.get({
|
|
142
|
+
path,
|
|
143
|
+
parameters,
|
|
144
|
+
timeout: options?.timeout,
|
|
145
|
+
});
|
|
146
|
+
if (res.ok) {
|
|
147
|
+
return await res.json();
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
throw new Error(await responseStringify(res));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async _getBlob(path, parameters, options) {
|
|
154
|
+
const agent = this.getClient(options?.proxyParams);
|
|
155
|
+
const res = await agent.get({
|
|
156
|
+
path,
|
|
157
|
+
parameters,
|
|
158
|
+
timeout: options?.timeout,
|
|
159
|
+
});
|
|
160
|
+
if (res.ok) {
|
|
161
|
+
return await this.parseBlobResponse(res);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
throw new Error(await responseStringify(res));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
async parseBlobResponse(response) {
|
|
168
|
+
try {
|
|
169
|
+
return (await response.blob());
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
throw new ParsingBlobError(err);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
async _postJsonEncoded(path, data, parameters, options) {
|
|
176
|
+
const agent = this.getClient(options?.proxyParams);
|
|
177
|
+
const res = await agent.post({
|
|
178
|
+
path,
|
|
179
|
+
data,
|
|
180
|
+
parameters,
|
|
181
|
+
headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' },
|
|
182
|
+
timeout: options?.timeout,
|
|
183
|
+
});
|
|
184
|
+
if (res.ok) {
|
|
185
|
+
return res;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
throw new Error(await responseStringify(res));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
async _postUrlEncoded(path, params, options) {
|
|
192
|
+
const data = paramToUrl(params);
|
|
193
|
+
const agent = this.getClient(options?.proxyParams);
|
|
194
|
+
const res = await agent.post({
|
|
195
|
+
path,
|
|
196
|
+
data,
|
|
197
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
198
|
+
timeout: options?.timeout,
|
|
199
|
+
});
|
|
200
|
+
if (res.ok) {
|
|
201
|
+
return res;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
throw new Error(await responseStringify(res));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|