camstreamerlib 4.0.0-beta.3 → 4.0.0-beta.30
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 +47 -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 +33 -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 +16 -14
- package/cjs/CamStreamerAPI.js +32 -32
- package/cjs/CamSwitcherAPI.d.ts +42 -37
- package/cjs/CamSwitcherAPI.js +123 -114
- package/cjs/CamSwitcherEvents.d.ts +1 -1
- package/cjs/PlaneTrackerAPI.d.ts +42 -0
- package/cjs/PlaneTrackerAPI.js +211 -0
- package/cjs/VapixAPI.d.ts +56 -43
- 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 +5 -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/WsEventClient.d.ts +1 -1
- package/cjs/node/index.d.ts +2 -0
- package/cjs/node/index.js +18 -1
- package/cjs/types/CamOverlayAPI/CamOverlayAPI.d.ts +3073 -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 +5 -5
- 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 +636 -519
- 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 +47 -26
- package/esm/CamOverlayAPI.js +169 -86
- 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 +33 -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 +16 -14
- package/esm/CamStreamerAPI.js +32 -32
- package/esm/CamSwitcherAPI.d.ts +42 -37
- package/esm/CamSwitcherAPI.js +116 -107
- package/esm/CamSwitcherEvents.d.ts +1 -1
- package/esm/PlaneTrackerAPI.d.ts +42 -0
- package/esm/PlaneTrackerAPI.js +207 -0
- package/esm/VapixAPI.d.ts +56 -43
- 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 +5 -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/WsEventClient.d.ts +1 -1
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +2 -0
- package/esm/types/CamOverlayAPI/CamOverlayAPI.d.ts +3073 -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 +5 -5
- 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 +636 -519
- 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/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/types/CamOverlayAPI.d.ts +0 -188
- package/esm/types/CamOverlayAPI.js +0 -44
package/esm/CamSwitcherAPI.js
CHANGED
|
@@ -1,123 +1,131 @@
|
|
|
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
|
-
async generateSilence(sampleRate, channels) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
static getClipPreviewUrlPath = (id, storage) => `${BASE_PATH}/clip_preview.cgi?clip_name=${id}&storage=${storage}`;
|
|
23
|
+
async generateSilence(sampleRate, channels, options) {
|
|
24
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
25
|
+
await agent.get({
|
|
26
|
+
path: `${BASE_PATH}/generate_silence.cgi`,
|
|
27
|
+
parameters: {
|
|
28
|
+
sample_rate: sampleRate.toString(),
|
|
29
|
+
channels,
|
|
30
|
+
},
|
|
31
|
+
timeout: options?.timeout,
|
|
25
32
|
});
|
|
26
33
|
}
|
|
27
|
-
async checkCameraTime() {
|
|
28
|
-
const data = await this.get(`${
|
|
34
|
+
async checkCameraTime(options) {
|
|
35
|
+
const data = await this.get(`${BASE_PATH}/camera_time.cgi`, undefined, options);
|
|
29
36
|
return z.boolean().parse(data);
|
|
30
37
|
}
|
|
31
|
-
async
|
|
32
|
-
const data = await this.get(`${
|
|
38
|
+
async getNetworkCameraList(options) {
|
|
39
|
+
const data = await this.get(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
|
|
33
40
|
return networkCameraListSchema.parse(data);
|
|
34
41
|
}
|
|
35
|
-
async getMaxFps(source) {
|
|
36
|
-
const data = await this.get(`${
|
|
42
|
+
async getMaxFps(source, options) {
|
|
43
|
+
const data = await this.get(`${BASE_PATH}/get_max_framerate.cgi`, {
|
|
37
44
|
video_source: source.toString(),
|
|
38
|
-
});
|
|
45
|
+
}, options);
|
|
39
46
|
return z.number().parse(data);
|
|
40
47
|
}
|
|
41
|
-
async getStorageInfo() {
|
|
42
|
-
const data = await this.get(`${
|
|
48
|
+
async getStorageInfo(options) {
|
|
49
|
+
const data = await this.get(`${BASE_PATH}/get_storage.cgi`, undefined, options);
|
|
43
50
|
return storageInfoListSchema.parse(data);
|
|
44
51
|
}
|
|
45
|
-
async wsAuthorization() {
|
|
46
|
-
const data = await this.get(`${
|
|
52
|
+
async wsAuthorization(options) {
|
|
53
|
+
const data = await this.get(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
|
|
47
54
|
return z.string().parse(data);
|
|
48
55
|
}
|
|
49
|
-
async getOutputInfo() {
|
|
50
|
-
const data = await this.get(`${
|
|
56
|
+
async getOutputInfo(options) {
|
|
57
|
+
const data = await this.get(`${BASE_PATH}/output_info.cgi`, undefined, options);
|
|
51
58
|
return outputInfoSchema.parse(data);
|
|
52
59
|
}
|
|
53
|
-
async getAudioPushInfo() {
|
|
54
|
-
const data = await this.get(`${
|
|
60
|
+
async getAudioPushInfo(options) {
|
|
61
|
+
const data = await this.get(`${BASE_PATH}/audio_push_info.cgi`, undefined, options);
|
|
55
62
|
return audioPushInfoSchema.parse(data);
|
|
56
63
|
}
|
|
57
|
-
async getStreamSaveList() {
|
|
58
|
-
const data = await this.get(`${
|
|
64
|
+
async getStreamSaveList(options) {
|
|
65
|
+
const data = await this.get(`${BASE_PATH}/streams.cgi`, { action: 'get' }, options);
|
|
59
66
|
return streamSaveLoadSchema.parse(data);
|
|
60
67
|
}
|
|
61
|
-
async getClipSaveList() {
|
|
62
|
-
const data = await this.get(`${
|
|
68
|
+
async getClipSaveList(options) {
|
|
69
|
+
const data = await this.get(`${BASE_PATH}/clips.cgi`, { action: 'get' }, options);
|
|
63
70
|
return clipSaveLoadSchema.parse(data);
|
|
64
71
|
}
|
|
65
|
-
async getPlaylistSaveList() {
|
|
66
|
-
const data = await this.get(`${
|
|
72
|
+
async getPlaylistSaveList(options) {
|
|
73
|
+
const data = await this.get(`${BASE_PATH}/playlists.cgi`, { action: 'get' }, options);
|
|
67
74
|
return playlistSaveLoadSchema.parse(data);
|
|
68
75
|
}
|
|
69
|
-
async getTrackerSaveList() {
|
|
70
|
-
const data = await this.get(`${
|
|
76
|
+
async getTrackerSaveList(options) {
|
|
77
|
+
const data = await this.get(`${BASE_PATH}/trackers.cgi`, { action: 'get' }, options);
|
|
71
78
|
return trackerSaveLoadSchema.parse(data);
|
|
72
79
|
}
|
|
73
|
-
async setStreamSaveList(data) {
|
|
74
|
-
return await this.set(`${
|
|
80
|
+
async setStreamSaveList(data, options) {
|
|
81
|
+
return await this.set(`${BASE_PATH}/streams.cgi`, data, { action: 'set' }, options);
|
|
75
82
|
}
|
|
76
|
-
async setClipSaveList(data) {
|
|
77
|
-
return await this.set(`${
|
|
83
|
+
async setClipSaveList(data, options) {
|
|
84
|
+
return await this.set(`${BASE_PATH}/clips.cgi`, data, { action: 'set' }, options);
|
|
78
85
|
}
|
|
79
|
-
async setPlaylistSaveList(data) {
|
|
80
|
-
return await this.set(`${
|
|
86
|
+
async setPlaylistSaveList(data, options) {
|
|
87
|
+
return await this.set(`${BASE_PATH}/playlists.cgi`, data, { action: 'set' }, options);
|
|
81
88
|
}
|
|
82
|
-
async setTrackerSaveList(data) {
|
|
83
|
-
return await this.set(`${
|
|
89
|
+
async setTrackerSaveList(data, options) {
|
|
90
|
+
return await this.set(`${BASE_PATH}/trackers.cgi`, data, { action: 'set' }, options);
|
|
84
91
|
}
|
|
85
|
-
async playlistSwitch(playlistName) {
|
|
86
|
-
await this.get(`${
|
|
92
|
+
async playlistSwitch(playlistName, options) {
|
|
93
|
+
await this.get(`${BASE_PATH}/playlist_switch.cgi`, { playlist_name: playlistName }, options);
|
|
87
94
|
}
|
|
88
|
-
async playlistQueuePush(playlistName) {
|
|
89
|
-
await this.get(`${
|
|
95
|
+
async playlistQueuePush(playlistName, options) {
|
|
96
|
+
await this.get(`${BASE_PATH}/playlist_queue_push.cgi`, { playlist_name: playlistName }, options);
|
|
90
97
|
}
|
|
91
|
-
async playlistQueueClear() {
|
|
92
|
-
await this.get(`${
|
|
98
|
+
async playlistQueueClear(options) {
|
|
99
|
+
await this.get(`${BASE_PATH}/playlist_queue_clear.cgi`, undefined, options);
|
|
93
100
|
}
|
|
94
|
-
async playlistQueueList() {
|
|
95
|
-
const data = await this.get(`${
|
|
101
|
+
async playlistQueueList(options) {
|
|
102
|
+
const data = await this.get(`${BASE_PATH}/playlist_queue_list.cgi`, undefined, options);
|
|
96
103
|
return playlistQueueSchema.parse(data).playlistQueueList;
|
|
97
104
|
}
|
|
98
|
-
async playlistQueuePlayNext() {
|
|
99
|
-
await this.get(`${
|
|
105
|
+
async playlistQueuePlayNext(options) {
|
|
106
|
+
await this.get(`${BASE_PATH}/playlist_queue_play_next.cgi`, undefined, options);
|
|
100
107
|
}
|
|
101
|
-
async addNewClip(file, clipType, storage, id, fileName) {
|
|
102
|
-
const
|
|
108
|
+
async addNewClip(file, clipType, storage, id, fileName, options) {
|
|
109
|
+
const path = `${BASE_PATH}/clip_upload.cgi?storage=${storage}`;
|
|
110
|
+
const formData = new this.CustomFormData();
|
|
103
111
|
formData.append('clip_name', id);
|
|
104
112
|
formData.append('clip_type', clipType);
|
|
105
113
|
formData.append('file', file, fileName);
|
|
106
|
-
const
|
|
107
|
-
const res = await
|
|
114
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
115
|
+
const res = await agent.post({ path, data: formData, timeout: options?.timeout });
|
|
108
116
|
const output = (await res.json());
|
|
109
117
|
if (output.status !== 200) {
|
|
110
118
|
throw new AddNewClipError(output.message);
|
|
111
119
|
}
|
|
112
120
|
}
|
|
113
|
-
removeClip(id, storage) {
|
|
114
|
-
return this.get(`${
|
|
121
|
+
removeClip(id, storage, options) {
|
|
122
|
+
return this.get(`${BASE_PATH}/clip_remove.cgi`, { clip_name: id, storage }, options);
|
|
115
123
|
}
|
|
116
|
-
async getClipList() {
|
|
117
|
-
const data = await this.get(`${
|
|
124
|
+
async getClipList(options) {
|
|
125
|
+
const data = await this.get(`${BASE_PATH}/clip_list.cgi`, undefined, options);
|
|
118
126
|
return clipListSchema.parse(data).clip_list;
|
|
119
127
|
}
|
|
120
|
-
setCamSwitchOptions(data, cameraFWVersion) {
|
|
128
|
+
setCamSwitchOptions(data, cameraFWVersion, options) {
|
|
121
129
|
const bitrateVapixParams = parseBitrateOptionsToBitrateVapixParams(cameraFWVersion, data.bitrateMode, data);
|
|
122
130
|
const saveData = {
|
|
123
131
|
video: {
|
|
@@ -135,9 +143,9 @@ export class CamSwitcherAPI {
|
|
|
135
143
|
},
|
|
136
144
|
keyboard: data.keyboard,
|
|
137
145
|
};
|
|
138
|
-
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.SETTINGS, saveData);
|
|
146
|
+
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.SETTINGS, saveData, options);
|
|
139
147
|
}
|
|
140
|
-
setGlobalAudioSettings(settings) {
|
|
148
|
+
setGlobalAudioSettings(settings, options) {
|
|
141
149
|
let acceptedType = 'NONE';
|
|
142
150
|
if (settings.type === 'source' && settings.source) {
|
|
143
151
|
if (isClip(settings.source)) {
|
|
@@ -153,9 +161,9 @@ export class CamSwitcherAPI {
|
|
|
153
161
|
clip_name: settings.source,
|
|
154
162
|
storage: settings.storage,
|
|
155
163
|
};
|
|
156
|
-
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.MASTER_AUDIO, data);
|
|
164
|
+
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.MASTER_AUDIO, data, options);
|
|
157
165
|
}
|
|
158
|
-
setSecondaryAudioSettings(settings) {
|
|
166
|
+
setSecondaryAudioSettings(settings, options) {
|
|
159
167
|
const data = {
|
|
160
168
|
type: settings.type,
|
|
161
169
|
stream_name: settings.streamName ?? '',
|
|
@@ -164,19 +172,19 @@ export class CamSwitcherAPI {
|
|
|
164
172
|
secondary_audio_level: settings.secondaryAudioLevel,
|
|
165
173
|
master_audio_level: settings.masterAudioLevel,
|
|
166
174
|
};
|
|
167
|
-
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.SECONDARY_AUDIO, data);
|
|
175
|
+
return this.setParamFromCameraJSON(CSW_PARAM_NAMES.SECONDARY_AUDIO, data, options);
|
|
168
176
|
}
|
|
169
|
-
setDefaultPlaylist(id) {
|
|
177
|
+
setDefaultPlaylist(id, options) {
|
|
170
178
|
const value = JSON.stringify({ default_playlist_id: id });
|
|
171
179
|
return this.vapixAgent.setParameter({
|
|
172
180
|
[CSW_PARAM_NAMES.DEFAULT_PLAYLIST]: value,
|
|
173
|
-
},
|
|
181
|
+
}, options);
|
|
174
182
|
}
|
|
175
|
-
setPermanentRtspUrlToken(token) {
|
|
176
|
-
return this.vapixAgent.setParameter({ [CSW_PARAM_NAMES.RTSP_TOKEN]: token },
|
|
183
|
+
setPermanentRtspUrlToken(token, options) {
|
|
184
|
+
return this.vapixAgent.setParameter({ [CSW_PARAM_NAMES.RTSP_TOKEN]: token }, options);
|
|
177
185
|
}
|
|
178
|
-
async getCamSwitchOptions() {
|
|
179
|
-
const saveData = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SETTINGS);
|
|
186
|
+
async getCamSwitchOptions(options) {
|
|
187
|
+
const saveData = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SETTINGS, options);
|
|
180
188
|
if (isNullish(saveData.video)) {
|
|
181
189
|
return saveData;
|
|
182
190
|
}
|
|
@@ -201,12 +209,12 @@ export class CamSwitcherAPI {
|
|
|
201
209
|
keyboard: saveData.keyboard,
|
|
202
210
|
};
|
|
203
211
|
}
|
|
204
|
-
async getGlobalAudioSettings() {
|
|
212
|
+
async getGlobalAudioSettings(options) {
|
|
205
213
|
const settings = {
|
|
206
214
|
type: 'fromSource',
|
|
207
215
|
source: 'fromSource',
|
|
208
216
|
};
|
|
209
|
-
const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.MASTER_AUDIO);
|
|
217
|
+
const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.MASTER_AUDIO, options);
|
|
210
218
|
if (res.type === 'STREAM') {
|
|
211
219
|
settings.type = 'source';
|
|
212
220
|
settings.source = res.stream_name;
|
|
@@ -218,8 +226,8 @@ export class CamSwitcherAPI {
|
|
|
218
226
|
}
|
|
219
227
|
return settings;
|
|
220
228
|
}
|
|
221
|
-
async getSecondaryAudioSettings() {
|
|
222
|
-
const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SECONDARY_AUDIO);
|
|
229
|
+
async getSecondaryAudioSettings(options) {
|
|
230
|
+
const res = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SECONDARY_AUDIO, options);
|
|
223
231
|
const settings = {
|
|
224
232
|
type: res.type ?? 'NONE',
|
|
225
233
|
streamName: res.stream_name,
|
|
@@ -230,13 +238,14 @@ export class CamSwitcherAPI {
|
|
|
230
238
|
};
|
|
231
239
|
return settings;
|
|
232
240
|
}
|
|
233
|
-
async getPermanentRtspUrlToken() {
|
|
241
|
+
async getPermanentRtspUrlToken(options) {
|
|
234
242
|
const paramName = CSW_PARAM_NAMES.RTSP_TOKEN;
|
|
235
|
-
const res = await this.vapixAgent.getParameter([paramName],
|
|
243
|
+
const res = await this.vapixAgent.getParameter([paramName], options);
|
|
236
244
|
return res[paramName] ?? '';
|
|
237
245
|
}
|
|
238
|
-
async get(path, parameters
|
|
239
|
-
const
|
|
246
|
+
async get(path, parameters, options) {
|
|
247
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
248
|
+
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
240
249
|
if (res.ok) {
|
|
241
250
|
const d = (await res.json());
|
|
242
251
|
return d.data;
|
|
@@ -245,8 +254,9 @@ export class CamSwitcherAPI {
|
|
|
245
254
|
throw new Error(await responseStringify(res));
|
|
246
255
|
}
|
|
247
256
|
}
|
|
248
|
-
async set(path, data, parameters
|
|
249
|
-
const
|
|
257
|
+
async set(path, data, parameters, options) {
|
|
258
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
259
|
+
const res = await agent.post({ path, data: JSON.stringify(data), parameters, timeout: options?.timeout });
|
|
250
260
|
if (res.ok) {
|
|
251
261
|
const parsed = await res.json();
|
|
252
262
|
return parsed.message === 'OK';
|
|
@@ -255,13 +265,13 @@ export class CamSwitcherAPI {
|
|
|
255
265
|
throw new Error(await responseStringify(res));
|
|
256
266
|
}
|
|
257
267
|
}
|
|
258
|
-
setParamFromCameraJSON(paramName, data) {
|
|
268
|
+
setParamFromCameraJSON(paramName, data, options) {
|
|
259
269
|
const params = {};
|
|
260
270
|
params[paramName] = JSON.stringify(data);
|
|
261
|
-
return this.vapixAgent.setParameter(params,
|
|
271
|
+
return this.vapixAgent.setParameter(params, options);
|
|
262
272
|
}
|
|
263
|
-
async getParamFromCameraAndJSONParse(paramName) {
|
|
264
|
-
const data = await this.vapixAgent.getParameter([paramName],
|
|
273
|
+
async getParamFromCameraAndJSONParse(paramName, options) {
|
|
274
|
+
const data = await this.vapixAgent.getParameter([paramName], options);
|
|
265
275
|
if (data[paramName] !== undefined) {
|
|
266
276
|
try {
|
|
267
277
|
if (data[paramName] === '') {
|
|
@@ -277,6 +287,9 @@ export class CamSwitcherAPI {
|
|
|
277
287
|
}
|
|
278
288
|
throw new Error("Error: no parametr '" + paramName + "' was found");
|
|
279
289
|
}
|
|
290
|
+
getAgent(proxyParams) {
|
|
291
|
+
return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
|
|
292
|
+
}
|
|
280
293
|
}
|
|
281
294
|
const CSW_PARAM_NAMES = {
|
|
282
295
|
SETTINGS: 'Camswitcher.Settings',
|
|
@@ -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,42 @@
|
|
|
1
|
+
import { IClient, TBlobResponse, TParameters, TResponse } from './internal/types';
|
|
2
|
+
import { ICAO, TApiUser, TExportDataType, TImportDataType } from './types/PlaneTrackerAPI';
|
|
3
|
+
import { THttpRequestOptions } from './types/common';
|
|
4
|
+
export declare class PlaneTrackerAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
5
|
+
private client;
|
|
6
|
+
private apiUser;
|
|
7
|
+
constructor(client: Client, apiUser: TApiUser);
|
|
8
|
+
static getProxyUrlPath: () => string;
|
|
9
|
+
checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
|
|
10
|
+
resetPtzCalibration: (options?: THttpRequestOptions) => Promise<TResponse>;
|
|
11
|
+
resetFocusCalibration: (options?: THttpRequestOptions) => Promise<TResponse>;
|
|
12
|
+
serverRunCheck: (options?: THttpRequestOptions) => Promise<TResponse>;
|
|
13
|
+
getLiveViewAlias: (rtspUrl: string, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
14
|
+
fetchCameraSettings: (options?: THttpRequestOptions) => Promise<any>;
|
|
15
|
+
setCameraSettings: (settingsJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
16
|
+
fetchServerSettings: (options?: THttpRequestOptions) => Promise<any>;
|
|
17
|
+
exportAppSettings: (dataType: TExportDataType, options?: THttpRequestOptions) => Promise<TBlobResponse<Client>>;
|
|
18
|
+
importAppSettings: (dataType: TImportDataType, formData: FormData, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
19
|
+
fetchFlightInfo: (icao: ICAO, options?: THttpRequestOptions) => Promise<any>;
|
|
20
|
+
getTrackingMode: (options?: THttpRequestOptions) => Promise<any>;
|
|
21
|
+
setTrackingMode: (modeJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
22
|
+
startTrackingPlane: (icao: ICAO, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
23
|
+
stopTrackingPlane: (options?: THttpRequestOptions) => Promise<TResponse>;
|
|
24
|
+
getPriorityList: (options?: THttpRequestOptions) => Promise<any>;
|
|
25
|
+
setPriorityList: (priorityListJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
26
|
+
getWhiteList: (options?: THttpRequestOptions) => Promise<any>;
|
|
27
|
+
setWhiteList: (whiteListJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
28
|
+
getBlackList: (options?: THttpRequestOptions) => Promise<any>;
|
|
29
|
+
setBlackList: (blackListJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
30
|
+
fetchMapInfo: (options?: THttpRequestOptions) => Promise<any>;
|
|
31
|
+
getZones: (options?: THttpRequestOptions) => Promise<any>;
|
|
32
|
+
setZones: (zonesJsonString: string, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
33
|
+
goToCoordinates: (lat: number, lon: number, alt?: number, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
34
|
+
checkGenetecConnection: (params: TParameters, options?: THttpRequestOptions) => Promise<TResponse>;
|
|
35
|
+
getGenetecCameraList: (params: TParameters, options?: THttpRequestOptions) => Promise<any>;
|
|
36
|
+
private _getJson;
|
|
37
|
+
private _getBlob;
|
|
38
|
+
private parseBlobResponse;
|
|
39
|
+
private _postJsonEncoded;
|
|
40
|
+
private _postUrlEncoded;
|
|
41
|
+
private getAgent;
|
|
42
|
+
}
|
|
@@ -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
|
+
async checkCameraTime(options) {
|
|
15
|
+
const response = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
|
|
16
|
+
return z.boolean().parse(response.state);
|
|
17
|
+
}
|
|
18
|
+
resetPtzCalibration = async (options) => {
|
|
19
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
20
|
+
return await agent.get({
|
|
21
|
+
path: `${BASE_PATH}/package/resetPtzCalibration.cgi`,
|
|
22
|
+
parameters: this.apiUser,
|
|
23
|
+
timeout: options?.timeout,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
resetFocusCalibration = async (options) => {
|
|
27
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
28
|
+
return await agent.get({
|
|
29
|
+
path: `${BASE_PATH}/package/resetFocusCalibration.cgi`,
|
|
30
|
+
parameters: this.apiUser,
|
|
31
|
+
timeout: options?.timeout,
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
serverRunCheck = async (options) => {
|
|
35
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
36
|
+
return await agent.get({ path: `${BASE_PATH}/package/serverRunCheck.cgi`, timeout: options?.timeout });
|
|
37
|
+
};
|
|
38
|
+
getLiveViewAlias = async (rtspUrl, options) => {
|
|
39
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
40
|
+
return await agent.get({
|
|
41
|
+
path: `${BASE_PATH}/getLiveViewAlias.cgi`,
|
|
42
|
+
parameters: { rtsp_url: rtspUrl },
|
|
43
|
+
timeout: options?.timeout,
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
fetchCameraSettings = async (options) => {
|
|
47
|
+
return await this._getJson(`${BASE_PATH}/package_camera_settings.cgi`, { action: 'get' }, options);
|
|
48
|
+
};
|
|
49
|
+
setCameraSettings = async (settingsJsonString, options) => {
|
|
50
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package_camera_settings.cgi`, settingsJsonString, {
|
|
51
|
+
action: 'set',
|
|
52
|
+
}, options);
|
|
53
|
+
};
|
|
54
|
+
fetchServerSettings = async (options) => {
|
|
55
|
+
return await this._getJson(`${BASE_PATH}/package_server_settings.cgi`, { action: 'get' }, options);
|
|
56
|
+
};
|
|
57
|
+
exportAppSettings = async (dataType, options) => {
|
|
58
|
+
return await this._getBlob(`${BASE_PATH}/package_data.cgi`, { action: 'EXPORT', dataType }, options);
|
|
59
|
+
};
|
|
60
|
+
importAppSettings = async (dataType, formData, options) => {
|
|
61
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
62
|
+
return await agent.post({
|
|
63
|
+
path: `${BASE_PATH}/package_data.cgi`,
|
|
64
|
+
data: formData,
|
|
65
|
+
parameters: { action: 'IMPORT', dataType },
|
|
66
|
+
timeout: options?.timeout,
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
fetchFlightInfo = async (icao, options) => {
|
|
70
|
+
return await this._getJson(`${BASE_PATH}/package/flightInfo.cgi`, { icao: encodeURIComponent(icao) }, options);
|
|
71
|
+
};
|
|
72
|
+
getTrackingMode = async (options) => {
|
|
73
|
+
return await this._getJson(`${BASE_PATH}/package/getTrackingMode.cgi`, undefined, options);
|
|
74
|
+
};
|
|
75
|
+
setTrackingMode = async (modeJsonString, options) => {
|
|
76
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package/setTrackingMode.cgi`, modeJsonString, this.apiUser, options);
|
|
77
|
+
};
|
|
78
|
+
startTrackingPlane = async (icao, options) => {
|
|
79
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
80
|
+
return await agent.get({
|
|
81
|
+
path: `${BASE_PATH}/package/trackIcao.cgi`,
|
|
82
|
+
parameters: { icao, ...this.apiUser },
|
|
83
|
+
timeout: options?.timeout,
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
stopTrackingPlane = async (options) => {
|
|
87
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
88
|
+
return await agent.get({
|
|
89
|
+
path: `${BASE_PATH}/package/resetIcao.cgi`,
|
|
90
|
+
parameters: this.apiUser,
|
|
91
|
+
timeout: options?.timeout,
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
getPriorityList = async (options) => {
|
|
95
|
+
return await this._getJson(`${BASE_PATH}/package/getPriorityList.cgi`, undefined, options);
|
|
96
|
+
};
|
|
97
|
+
setPriorityList = async (priorityListJsonString, options) => {
|
|
98
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package/setPriorityList.cgi`, priorityListJsonString, this.apiUser, options);
|
|
99
|
+
};
|
|
100
|
+
getWhiteList = async (options) => {
|
|
101
|
+
return await this._getJson(`${BASE_PATH}/package/getWhiteList.cgi`, undefined, options);
|
|
102
|
+
};
|
|
103
|
+
setWhiteList = async (whiteListJsonString, options) => {
|
|
104
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, whiteListJsonString, this.apiUser, options);
|
|
105
|
+
};
|
|
106
|
+
getBlackList = async (options) => {
|
|
107
|
+
return await this._getJson(`${BASE_PATH}/package/getBlackList.cgi`, undefined, options);
|
|
108
|
+
};
|
|
109
|
+
setBlackList = async (blackListJsonString, options) => {
|
|
110
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, blackListJsonString, this.apiUser, options);
|
|
111
|
+
};
|
|
112
|
+
fetchMapInfo = async (options) => {
|
|
113
|
+
return await this._getJson(`${BASE_PATH}/package/getMapInfo.cgi`, undefined, options);
|
|
114
|
+
};
|
|
115
|
+
getZones = async (options) => {
|
|
116
|
+
return await this._getJson(`${BASE_PATH}/package/getZones.cgi`, undefined, options);
|
|
117
|
+
};
|
|
118
|
+
setZones = async (zonesJsonString, options) => {
|
|
119
|
+
return await this._postJsonEncoded(`${BASE_PATH}/package/setZones.cgi`, zonesJsonString, this.apiUser, options);
|
|
120
|
+
};
|
|
121
|
+
goToCoordinates = async (lat, lon, alt, options) => {
|
|
122
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
123
|
+
return await agent.get({
|
|
124
|
+
path: `${BASE_PATH}/package/goToCoordinates.cgi`,
|
|
125
|
+
parameters: { lat, lon, alt, ...this.apiUser },
|
|
126
|
+
timeout: options?.timeout,
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
checkGenetecConnection = async (params, options) => {
|
|
130
|
+
return await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, params, options);
|
|
131
|
+
};
|
|
132
|
+
getGenetecCameraList = async (params, options) => {
|
|
133
|
+
const res = await this._postUrlEncoded(`${BASE_PATH}/package/getGenetecCameraList.cgi`, params, options);
|
|
134
|
+
return await res.json();
|
|
135
|
+
};
|
|
136
|
+
async _getJson(path, parameters, options) {
|
|
137
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
138
|
+
const res = await agent.get({
|
|
139
|
+
path,
|
|
140
|
+
parameters,
|
|
141
|
+
timeout: options?.timeout,
|
|
142
|
+
});
|
|
143
|
+
if (res.ok) {
|
|
144
|
+
return await res.json();
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
throw new Error(await responseStringify(res));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async _getBlob(path, parameters, options) {
|
|
151
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
152
|
+
const res = await agent.get({
|
|
153
|
+
path,
|
|
154
|
+
parameters,
|
|
155
|
+
timeout: options?.timeout,
|
|
156
|
+
});
|
|
157
|
+
if (res.ok) {
|
|
158
|
+
return await this.parseBlobResponse(res);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
throw new Error(await responseStringify(res));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async parseBlobResponse(response) {
|
|
165
|
+
try {
|
|
166
|
+
return (await response.blob());
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
throw new ParsingBlobError(err);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async _postJsonEncoded(path, data, parameters, options) {
|
|
173
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
174
|
+
const res = await agent.post({
|
|
175
|
+
path,
|
|
176
|
+
data,
|
|
177
|
+
parameters,
|
|
178
|
+
headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' },
|
|
179
|
+
timeout: options?.timeout,
|
|
180
|
+
});
|
|
181
|
+
if (res.ok) {
|
|
182
|
+
return res;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
throw new Error(await responseStringify(res));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
async _postUrlEncoded(path, params, options) {
|
|
189
|
+
const data = paramToUrl(params);
|
|
190
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
191
|
+
const res = await agent.post({
|
|
192
|
+
path,
|
|
193
|
+
data,
|
|
194
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
195
|
+
timeout: options?.timeout,
|
|
196
|
+
});
|
|
197
|
+
if (res.ok) {
|
|
198
|
+
return res;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
throw new Error(await responseStringify(res));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
getAgent(proxyParams) {
|
|
205
|
+
return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
|
|
206
|
+
}
|
|
207
|
+
}
|