camstreamerlib 4.0.0-beta.2 → 4.0.0-beta.21
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 +5 -1
- package/cjs/CamOverlayAPI.d.ts +629 -0
- package/cjs/CamOverlayAPI.js +255 -0
- package/{CamOverlayDrawingAPI.d.ts → cjs/CamOverlayDrawingAPI.d.ts} +1 -1
- package/cjs/CamOverlayDrawingAPI.js +235 -0
- package/cjs/CamOverlayPainter/Frame.js +301 -0
- package/{CamOverlayPainter → cjs/CamOverlayPainter}/Painter.d.ts +14 -3
- package/cjs/CamOverlayPainter/Painter.js +171 -0
- package/cjs/CamOverlayPainter/ResourceManager.js +46 -0
- package/cjs/CamScripterAPI.d.ts +36 -0
- package/cjs/CamScripterAPI.js +73 -0
- package/{CamScripterAPICameraEventsGenerator.d.ts → cjs/CamScripterAPICameraEventsGenerator.d.ts} +1 -1
- package/cjs/CamScripterAPICameraEventsGenerator.js +162 -0
- package/{CamStreamerAPI.d.ts → cjs/CamStreamerAPI.d.ts} +5 -5
- package/cjs/CamStreamerAPI.js +59 -0
- package/{CamSwitcherAPI.d.ts → cjs/CamSwitcherAPI.d.ts} +10 -6
- package/cjs/CamSwitcherAPI.js +351 -0
- package/{CamSwitcherEvents.d.ts → cjs/CamSwitcherEvents.d.ts} +2 -2
- package/cjs/CamSwitcherEvents.js +67 -0
- package/cjs/CreatePackage.js +106 -0
- package/cjs/PlaneTrackerAPI.d.ts +47 -0
- package/cjs/PlaneTrackerAPI.js +176 -0
- package/{VapixAPI.d.ts → cjs/VapixAPI.d.ts} +19 -7
- package/cjs/VapixAPI.js +491 -0
- package/{VapixEvents.d.ts → cjs/VapixEvents.d.ts} +1 -1
- package/cjs/VapixEvents.js +88 -0
- package/{errors → cjs/errors}/errors.d.ts +3 -0
- package/cjs/errors/errors.js +86 -0
- package/{events → cjs/events}/AxisCameraStationEvents.d.ts +3 -2
- package/cjs/events/AxisCameraStationEvents.js +48 -0
- package/{events → cjs/events}/GenetecAgent.d.ts +4 -3
- package/cjs/events/GenetecAgent.js +123 -0
- package/cjs/index.d.ts +18 -0
- package/cjs/index.js +42 -0
- package/cjs/internal/Digest.js +42 -0
- package/cjs/internal/ProxyClient.d.ts +11 -0
- package/cjs/internal/ProxyClient.js +46 -0
- package/cjs/internal/constants.js +4 -0
- package/cjs/internal/transformers.js +32 -0
- package/cjs/internal/types.d.ts +35 -0
- package/cjs/internal/types.js +2 -0
- package/{internal → cjs/internal}/utils.d.ts +5 -1
- package/cjs/internal/utils.js +69 -0
- package/{internal → cjs/internal}/versionCompare.d.ts +2 -2
- package/cjs/internal/versionCompare.js +53 -0
- package/cjs/models/CamOverlayAPI/accuweatherSchema.d.ts +84 -0
- package/cjs/models/CamOverlayAPI/accuweatherSchema.js +48 -0
- package/cjs/models/CamOverlayAPI/constants.d.ts +11 -0
- package/cjs/models/CamOverlayAPI/constants.js +14 -0
- package/cjs/models/CamOverlayAPI/customGraphicsSchema.d.ts +699 -0
- package/cjs/models/CamOverlayAPI/customGraphicsSchema.js +73 -0
- package/cjs/models/CamOverlayAPI/fileSchema.d.ts +28 -0
- package/cjs/models/CamOverlayAPI/fileSchema.js +17 -0
- package/cjs/models/CamOverlayAPI/imagesSchema.d.ts +95 -0
- package/cjs/models/CamOverlayAPI/imagesSchema.js +10 -0
- package/cjs/models/CamOverlayAPI/index.d.ts +13 -0
- package/cjs/models/CamOverlayAPI/index.js +29 -0
- package/cjs/models/CamOverlayAPI/infotickerSchema.d.ts +96 -0
- package/cjs/models/CamOverlayAPI/infotickerSchema.js +27 -0
- package/cjs/models/CamOverlayAPI/pipSchema.d.ts +125 -0
- package/cjs/models/CamOverlayAPI/pipSchema.js +40 -0
- package/cjs/models/CamOverlayAPI/ptzCompassSchema.d.ts +93 -0
- package/cjs/models/CamOverlayAPI/ptzCompassSchema.js +26 -0
- package/cjs/models/CamOverlayAPI/ptzSchema.d.ts +118 -0
- package/cjs/models/CamOverlayAPI/ptzSchema.js +13 -0
- package/cjs/models/CamOverlayAPI/screenSharingSchema.d.ts +58 -0
- package/cjs/models/CamOverlayAPI/screenSharingSchema.js +9 -0
- package/cjs/models/CamOverlayAPI/webCameraSharingSchema.d.ts +58 -0
- package/cjs/models/CamOverlayAPI/webCameraSharingSchema.js +9 -0
- package/cjs/models/CamOverlayAPI/widgetCommonSchema.d.ts +126 -0
- package/cjs/models/CamOverlayAPI/widgetCommonSchema.js +76 -0
- package/cjs/models/CamOverlayAPI/widgetsSchema.d.ts +2823 -0
- package/cjs/models/CamOverlayAPI/widgetsSchema.js +27 -0
- package/cjs/node/DefaultClient.d.ts +16 -0
- package/cjs/node/DefaultClient.js +56 -0
- package/cjs/node/HttpRequestSender.js +89 -0
- package/cjs/node/HttpServer.js +96 -0
- package/{node → cjs/node}/WsClient.d.ts +1 -1
- package/cjs/node/WsClient.js +149 -0
- package/{node → cjs/node}/WsEventClient.d.ts +1 -1
- package/cjs/node/WsEventClient.js +22 -0
- package/cjs/node/index.d.ts +2 -0
- package/cjs/node/index.js +7 -0
- package/cjs/types/CamOverlayAPI.d.ts +328 -0
- package/cjs/types/CamOverlayAPI.js +26 -0
- package/{types → cjs/types}/CamScripterAPI.d.ts +66 -7
- package/cjs/types/CamScripterAPI.js +35 -0
- package/{types → cjs/types}/CamStreamerAPI.d.ts +16 -5
- package/cjs/types/CamStreamerAPI.js +32 -0
- package/{types → cjs/types}/CamSwitcherAPI.d.ts +5 -5
- package/cjs/types/CamSwitcherAPI.js +137 -0
- package/{types/CamswitcherEvents.d.ts → cjs/types/CamSwitcherEvents.d.ts} +77 -0
- package/cjs/types/CamSwitcherEvents.js +70 -0
- package/cjs/types/PlaneTrackerAPI.d.ts +2 -0
- package/cjs/types/PlaneTrackerAPI.js +2 -0
- package/{types → cjs/types}/VapixAPI.d.ts +479 -519
- package/cjs/types/VapixAPI.js +139 -0
- package/cjs/types/common.js +14 -0
- package/cjs/web/DefaultClient.d.ts +6 -0
- package/cjs/web/DefaultClient.js +22 -0
- package/cjs/web/WsClient.js +62 -0
- package/cjs/web/index.d.ts +2 -0
- package/cjs/web/index.js +7 -0
- package/esm/CamOverlayAPI.d.ts +629 -0
- package/esm/CamOverlayAPI.js +251 -0
- package/esm/CamOverlayDrawingAPI.d.ts +86 -0
- package/{CamOverlayDrawingAPI.js → esm/CamOverlayDrawingAPI.js} +6 -3
- package/esm/CamOverlayPainter/Frame.d.ts +96 -0
- package/esm/CamOverlayPainter/Painter.d.ts +48 -0
- package/{CamOverlayPainter → esm/CamOverlayPainter}/Painter.js +4 -1
- package/esm/CamOverlayPainter/ResourceManager.d.ts +14 -0
- package/{CamOverlayPainter → esm/CamOverlayPainter}/ResourceManager.js +6 -10
- package/esm/CamScripterAPI.d.ts +36 -0
- package/esm/CamScripterAPI.js +69 -0
- package/esm/CamScripterAPICameraEventsGenerator.d.ts +74 -0
- package/{CamScripterAPICameraEventsGenerator.js → esm/CamScripterAPICameraEventsGenerator.js} +6 -3
- package/esm/CamStreamerAPI.d.ts +16 -0
- package/{CamStreamerAPI.js → esm/CamStreamerAPI.js} +4 -10
- package/esm/CamSwitcherAPI.d.ts +52 -0
- package/{CamSwitcherAPI.js → esm/CamSwitcherAPI.js} +24 -27
- package/esm/CamSwitcherEvents.d.ts +18 -0
- package/{CamSwitcherEvents.js → esm/CamSwitcherEvents.js} +1 -1
- package/esm/CreatePackage.d.ts +1 -0
- package/esm/PlaneTrackerAPI.d.ts +47 -0
- package/esm/PlaneTrackerAPI.js +172 -0
- package/esm/VapixAPI.d.ts +78 -0
- package/{VapixAPI.js → esm/VapixAPI.js} +93 -60
- package/esm/VapixEvents.d.ts +43 -0
- package/{VapixEvents.js → esm/VapixEvents.js} +3 -3
- package/esm/errors/errors.d.ts +37 -0
- package/{errors → esm/errors}/errors.js +6 -0
- package/esm/events/AxisCameraStationEvents.d.ts +10 -0
- package/{events → esm/events}/AxisCameraStationEvents.js +1 -1
- package/esm/events/GenetecAgent.d.ts +175 -0
- package/{events → esm/events}/GenetecAgent.js +5 -5
- package/esm/index.d.ts +18 -0
- package/esm/index.js +18 -0
- package/esm/internal/Digest.d.ts +4 -0
- package/{internal → esm/internal}/Digest.js +6 -6
- package/esm/internal/ProxyClient.d.ts +11 -0
- package/{internal → esm/internal}/ProxyClient.js +6 -4
- package/esm/internal/constants.d.ts +1 -0
- package/esm/internal/transformers.d.ts +5 -0
- package/esm/internal/types.d.ts +35 -0
- package/esm/internal/types.js +1 -0
- package/esm/internal/utils.d.ts +15 -0
- package/{internal → esm/internal}/utils.js +20 -1
- package/esm/internal/versionCompare.d.ts +6 -0
- package/esm/models/CamOverlayAPI/accuweatherSchema.d.ts +84 -0
- package/esm/models/CamOverlayAPI/accuweatherSchema.js +45 -0
- package/esm/models/CamOverlayAPI/constants.d.ts +11 -0
- package/esm/models/CamOverlayAPI/constants.js +11 -0
- package/esm/models/CamOverlayAPI/customGraphicsSchema.d.ts +699 -0
- package/esm/models/CamOverlayAPI/customGraphicsSchema.js +70 -0
- package/esm/models/CamOverlayAPI/fileSchema.d.ts +28 -0
- package/esm/models/CamOverlayAPI/fileSchema.js +14 -0
- package/esm/models/CamOverlayAPI/imagesSchema.d.ts +95 -0
- package/esm/models/CamOverlayAPI/imagesSchema.js +7 -0
- package/esm/models/CamOverlayAPI/index.d.ts +13 -0
- package/esm/models/CamOverlayAPI/index.js +13 -0
- package/esm/models/CamOverlayAPI/infotickerSchema.d.ts +96 -0
- package/esm/models/CamOverlayAPI/infotickerSchema.js +24 -0
- package/esm/models/CamOverlayAPI/pipSchema.d.ts +125 -0
- package/esm/models/CamOverlayAPI/pipSchema.js +37 -0
- package/esm/models/CamOverlayAPI/ptzCompassSchema.d.ts +93 -0
- package/esm/models/CamOverlayAPI/ptzCompassSchema.js +23 -0
- package/esm/models/CamOverlayAPI/ptzSchema.d.ts +118 -0
- package/esm/models/CamOverlayAPI/ptzSchema.js +10 -0
- package/esm/models/CamOverlayAPI/screenSharingSchema.d.ts +58 -0
- package/esm/models/CamOverlayAPI/screenSharingSchema.js +6 -0
- package/esm/models/CamOverlayAPI/webCameraSharingSchema.d.ts +58 -0
- package/esm/models/CamOverlayAPI/webCameraSharingSchema.js +6 -0
- package/esm/models/CamOverlayAPI/widgetCommonSchema.d.ts +126 -0
- package/esm/models/CamOverlayAPI/widgetCommonSchema.js +73 -0
- package/esm/models/CamOverlayAPI/widgetsSchema.d.ts +2823 -0
- package/esm/models/CamOverlayAPI/widgetsSchema.js +24 -0
- package/esm/node/DefaultClient.d.ts +16 -0
- package/{node → esm/node}/DefaultClient.js +9 -7
- package/esm/node/HttpRequestSender.d.ts +28 -0
- package/esm/node/HttpServer.d.ts +21 -0
- package/{node → esm/node}/HttpServer.js +1 -1
- package/esm/node/WsClient.d.ts +39 -0
- package/esm/node/WsEventClient.d.ts +13 -0
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +2 -0
- package/esm/types/CamOverlayAPI.d.ts +328 -0
- package/esm/types/CamOverlayAPI.js +14 -0
- package/esm/types/CamScripterAPI.d.ts +126 -0
- package/esm/types/CamScripterAPI.js +32 -0
- package/esm/types/CamStreamerAPI.d.ts +150 -0
- package/{types → esm/types}/CamStreamerAPI.js +4 -0
- package/esm/types/CamSwitcherAPI.d.ts +814 -0
- package/esm/types/CamSwitcherEvents.d.ts +568 -0
- package/{types/CamswitcherEvents.js → esm/types/CamSwitcherEvents.js} +8 -0
- package/esm/types/PlaneTrackerAPI.d.ts +2 -0
- package/esm/types/PlaneTrackerAPI.js +1 -0
- package/esm/types/VapixAPI.d.ts +1664 -0
- package/{types → esm/types}/VapixAPI.js +30 -23
- package/esm/types/common.d.ts +37 -0
- package/esm/web/DefaultClient.d.ts +6 -0
- package/{web → esm/web}/DefaultClient.js +6 -4
- package/esm/web/WsClient.d.ts +13 -0
- package/{web → esm/web}/WsClient.js +2 -2
- package/esm/web/index.d.ts +2 -0
- package/esm/web/index.js +2 -0
- package/package.json +6 -6
- package/CamOverlayAPI.d.ts +0 -31
- package/CamOverlayAPI.js +0 -172
- package/CamScripterAPI.d.ts +0 -19
- package/CamScripterAPI.js +0 -66
- package/internal/ProxyClient.d.ts +0 -11
- package/internal/common.d.ts +0 -40
- package/internal/common.js +0 -23
- package/node/DefaultClient.d.ts +0 -15
- package/types/CamOverlayAPI.d.ts +0 -188
- package/types/CamOverlayAPI.js +0 -44
- package/types/CamScripterAPI.js +0 -17
- package/web/DefaultClient.d.ts +0 -6
- package/{CamOverlayPainter → cjs/CamOverlayPainter}/Frame.d.ts +0 -0
- package/{CamOverlayPainter → cjs/CamOverlayPainter}/ResourceManager.d.ts +0 -0
- package/{CreatePackage.d.ts → cjs/CreatePackage.d.ts} +0 -0
- package/{internal → cjs/internal}/Digest.d.ts +0 -0
- package/{internal → cjs/internal}/constants.d.ts +0 -0
- package/{internal → cjs/internal}/transformers.d.ts +0 -0
- package/{node → cjs/node}/HttpRequestSender.d.ts +0 -0
- package/{node → cjs/node}/HttpServer.d.ts +0 -0
- package/{types → cjs/types}/common.d.ts +2 -2
- /package/{web → cjs/web}/WsClient.d.ts +0 -0
- /package/{CamOverlayPainter → esm/CamOverlayPainter}/Frame.js +0 -0
- /package/{CreatePackage.js → esm/CreatePackage.js} +0 -0
- /package/{internal → esm/internal}/constants.js +0 -0
- /package/{internal → esm/internal}/transformers.js +0 -0
- /package/{internal → esm/internal}/versionCompare.js +0 -0
- /package/{node → esm/node}/HttpRequestSender.js +0 -0
- /package/{node → esm/node}/WsClient.js +0 -0
- /package/{node → esm/node}/WsEventClient.js +0 -0
- /package/{types → esm/types}/CamSwitcherAPI.js +0 -0
- /package/{types → esm/types}/common.js +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { responseStringify } from './internal/utils';
|
|
2
|
+
import { cameraTimeResponseSchema, camscripterApiResponseSchema, nodeStateSchema, packageInfoListSchema, storageSchema, } from './types/CamScripterAPI';
|
|
3
|
+
import { networkCameraListSchema } from './types/common';
|
|
4
|
+
export const BASE_URL = '/local/camscripter/package';
|
|
5
|
+
export class CamScripterAPI {
|
|
6
|
+
client;
|
|
7
|
+
constructor(client) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
}
|
|
10
|
+
static getProxyUrlPath = () => `${BASE_URL}/proxy.cgi`;
|
|
11
|
+
async checkCameraTime() {
|
|
12
|
+
const data = await this.get(`${BASE_URL}/camera_time.cgi`);
|
|
13
|
+
return cameraTimeResponseSchema.parse(data).state;
|
|
14
|
+
}
|
|
15
|
+
async getStorageInfo() {
|
|
16
|
+
const data = await this.get(`${BASE_URL}/get_storage.cgi`);
|
|
17
|
+
return storageSchema.parse(data);
|
|
18
|
+
}
|
|
19
|
+
async getNetworkCameraList() {
|
|
20
|
+
const data = await this.get(`${BASE_URL}/network_camera_list.cgi`);
|
|
21
|
+
return networkCameraListSchema.parse(data.camera_list);
|
|
22
|
+
}
|
|
23
|
+
async getPackageList() {
|
|
24
|
+
const data = await this.get(`${BASE_URL}/list.cgi`);
|
|
25
|
+
return packageInfoListSchema.parse(data);
|
|
26
|
+
}
|
|
27
|
+
async installPackages(formData, storage) {
|
|
28
|
+
const data = await this.post(`${BASE_URL}/install.cgi?storage=${storage}`, formData);
|
|
29
|
+
return camscripterApiResponseSchema.parse(data);
|
|
30
|
+
}
|
|
31
|
+
async uninstallPackage(packageId) {
|
|
32
|
+
const data = await this.get(`${BASE_URL}/remove.cgi?package_name=${packageId}`);
|
|
33
|
+
return camscripterApiResponseSchema.parse(data);
|
|
34
|
+
}
|
|
35
|
+
async importSettings(packageId, formData) {
|
|
36
|
+
const data = await this.post(`${BASE_URL}/data.cgi?action=IMPORT&package_name=${packageId}`, formData);
|
|
37
|
+
return camscripterApiResponseSchema.parse(data);
|
|
38
|
+
}
|
|
39
|
+
async exportSettings(packageId, formData) {
|
|
40
|
+
const data = await this.post(`${BASE_URL}/data.cgi?action=EXPORT&package_name=${packageId}`, formData);
|
|
41
|
+
return camscripterApiResponseSchema.parse(data);
|
|
42
|
+
}
|
|
43
|
+
async getNodejsStatus() {
|
|
44
|
+
const data = await this.get(`${BASE_URL}/diagnostics.cgi`);
|
|
45
|
+
return nodeStateSchema.parse(data);
|
|
46
|
+
}
|
|
47
|
+
async installNodejs(storage) {
|
|
48
|
+
const data = await this.get(`${BASE_URL}/node_update.cgi?storage=${storage}`);
|
|
49
|
+
return camscripterApiResponseSchema.parse(data);
|
|
50
|
+
}
|
|
51
|
+
async get(path, params) {
|
|
52
|
+
const res = await this.client.get(path, params);
|
|
53
|
+
if (res.ok) {
|
|
54
|
+
return await res.json();
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
throw new Error(await responseStringify(res));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async post(path, data, params) {
|
|
61
|
+
const res = await this.client.post(path, data, params);
|
|
62
|
+
if (res.ok) {
|
|
63
|
+
return await res.json();
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
throw new Error(await responseStringify(res));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as EventEmitter from 'events';
|
|
3
|
+
import { WsOptions } from './internal/types';
|
|
4
|
+
export type CamScripterOptions = WsOptions;
|
|
5
|
+
export type TDeclaration = {
|
|
6
|
+
type?: '' | 'SOURCE' | 'DATA';
|
|
7
|
+
namespace: string;
|
|
8
|
+
key: string;
|
|
9
|
+
value: string | boolean | number;
|
|
10
|
+
value_type: 'STRING' | 'INT' | 'BOOL' | 'DOUBLE';
|
|
11
|
+
key_nice_name?: string;
|
|
12
|
+
value_nice_name?: string;
|
|
13
|
+
};
|
|
14
|
+
export type TEventDeclaration = {
|
|
15
|
+
declaration_id: string;
|
|
16
|
+
stateless: boolean;
|
|
17
|
+
declaration: TDeclaration[];
|
|
18
|
+
};
|
|
19
|
+
export type TEventUndeclaration = {
|
|
20
|
+
declaration_id: string;
|
|
21
|
+
};
|
|
22
|
+
export type TEventData = {
|
|
23
|
+
namespace: string;
|
|
24
|
+
key: string;
|
|
25
|
+
value: string | boolean | number;
|
|
26
|
+
value_type: 'STRING' | 'INT' | 'BOOL' | 'DOUBLE';
|
|
27
|
+
};
|
|
28
|
+
export type TEvent = {
|
|
29
|
+
declaration_id: string;
|
|
30
|
+
event_data: TEventData[];
|
|
31
|
+
};
|
|
32
|
+
export type TResponse = {
|
|
33
|
+
call_id: number;
|
|
34
|
+
message: string;
|
|
35
|
+
};
|
|
36
|
+
export type TErrorResponse = {
|
|
37
|
+
error: string;
|
|
38
|
+
call_id?: number;
|
|
39
|
+
};
|
|
40
|
+
export interface CamScripterAPICameraEventsGenerator {
|
|
41
|
+
on(event: 'open', listener: () => void): this;
|
|
42
|
+
on(event: 'close', listener: () => void): this;
|
|
43
|
+
on(event: 'error', listener: (err: Error) => void): this;
|
|
44
|
+
emit(event: 'open'): boolean;
|
|
45
|
+
emit(event: 'close'): boolean;
|
|
46
|
+
emit(event: 'error', err: Error): boolean;
|
|
47
|
+
}
|
|
48
|
+
export declare class CamScripterAPICameraEventsGenerator extends EventEmitter {
|
|
49
|
+
private tls;
|
|
50
|
+
private tlsInsecure;
|
|
51
|
+
private ip;
|
|
52
|
+
private port;
|
|
53
|
+
private user;
|
|
54
|
+
private pass;
|
|
55
|
+
private callId;
|
|
56
|
+
private sendMessages;
|
|
57
|
+
private timeoutCheckTimer;
|
|
58
|
+
private wsConnected;
|
|
59
|
+
private ws;
|
|
60
|
+
constructor(options?: CamScripterOptions);
|
|
61
|
+
connect(): void;
|
|
62
|
+
disconnect(): void;
|
|
63
|
+
declareEvent(eventDeclaration: TEventDeclaration): Promise<TResponse>;
|
|
64
|
+
undeclareEvent(eventUndeclaration: TEventUndeclaration): Promise<TResponse>;
|
|
65
|
+
sendEvent(event: TEvent): Promise<TResponse>;
|
|
66
|
+
private createWsClient;
|
|
67
|
+
private incomingWsMessageHandler;
|
|
68
|
+
private sendMessage;
|
|
69
|
+
private startMsgsTimeoutCheck;
|
|
70
|
+
private stopMsgsTimeoutCheck;
|
|
71
|
+
private reconnectWithError;
|
|
72
|
+
private reportErr;
|
|
73
|
+
private reportClose;
|
|
74
|
+
}
|
package/{CamScripterAPICameraEventsGenerator.js → esm/CamScripterAPICameraEventsGenerator.js}
RENAMED
|
@@ -88,10 +88,10 @@ export class CamScripterAPICameraEventsGenerator extends EventEmitter {
|
|
|
88
88
|
}
|
|
89
89
|
if (dataJSON.call_id !== undefined) {
|
|
90
90
|
if (errorResponse !== undefined) {
|
|
91
|
-
this.sendMessages[dataJSON.call_id]
|
|
91
|
+
this.sendMessages[dataJSON.call_id]?.reject(new Error(errorResponse.error));
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
|
-
this.sendMessages[dataJSON.call_id]
|
|
94
|
+
this.sendMessages[dataJSON.call_id]?.resolve(dataJSON);
|
|
95
95
|
}
|
|
96
96
|
delete this.sendMessages[dataJSON.call_id];
|
|
97
97
|
}
|
|
@@ -124,6 +124,9 @@ export class CamScripterAPICameraEventsGenerator extends EventEmitter {
|
|
|
124
124
|
const now = Date.now();
|
|
125
125
|
for (const callId in this.sendMessages) {
|
|
126
126
|
const msg = this.sendMessages[callId];
|
|
127
|
+
if (!msg) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
127
130
|
if (now - msg.sentTimestamp > 10000) {
|
|
128
131
|
reconnect = true;
|
|
129
132
|
msg.reject(new Error('Message timeout'));
|
|
@@ -147,7 +150,7 @@ export class CamScripterAPICameraEventsGenerator extends EventEmitter {
|
|
|
147
150
|
}
|
|
148
151
|
reportClose() {
|
|
149
152
|
for (const callId in this.sendMessages) {
|
|
150
|
-
this.sendMessages[callId]
|
|
153
|
+
this.sendMessages[callId]?.reject(new Error('Connection lost'));
|
|
151
154
|
}
|
|
152
155
|
this.sendMessages = {};
|
|
153
156
|
this.emit('close');
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IClient, TResponse } from './internal/types';
|
|
2
|
+
import { TStreamAttributes, TStreamList } from './types/CamStreamerAPI';
|
|
3
|
+
export declare class CamStreamerAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
4
|
+
client: Client;
|
|
5
|
+
constructor(client: Client);
|
|
6
|
+
getStreamList(): Promise<TStreamList>;
|
|
7
|
+
getStream(streamID: string): Promise<TStreamAttributes>;
|
|
8
|
+
getStreamParameter(streamID: string, paramName: string): Promise<string>;
|
|
9
|
+
setStream(streamID: string, params: Partial<TStreamAttributes>): Promise<void>;
|
|
10
|
+
setStreamParameter(streamID: string, paramName: string, value: string): Promise<void>;
|
|
11
|
+
isStreaming(streamID: string): Promise<boolean>;
|
|
12
|
+
deleteStream(streamID: string): Promise<void>;
|
|
13
|
+
wsAutoratization(): Promise<string>;
|
|
14
|
+
getUtcTime(): Promise<number>;
|
|
15
|
+
private get;
|
|
16
|
+
}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { streamAttributesSchema, streamListSchema, } from './types/CamStreamerAPI';
|
|
1
|
+
import { responseStringify } from './internal/utils';
|
|
2
|
+
import { streamAttributesSchema, streamListSchema } from './types/CamStreamerAPI';
|
|
4
3
|
export class CamStreamerAPI {
|
|
5
4
|
client;
|
|
6
|
-
constructor(
|
|
7
|
-
|
|
8
|
-
this.client = options;
|
|
9
|
-
}
|
|
10
|
-
else {
|
|
11
|
-
this.client = new DefaultClient(options);
|
|
12
|
-
}
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
13
7
|
}
|
|
14
8
|
async getStreamList() {
|
|
15
9
|
const streamListRes = await this.get('/local/camstreamer/stream/list.cgi');
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { IClient, TResponse } from './internal/types';
|
|
2
|
+
import { TAudioPushInfo, TOutputInfo, TStorageInfo, TStreamSaveList, TClipList, TStreamSaveLoadList, TClipSaveLoadList, TPlaylistSaveLoadList, TTrackerSaveList, TrackerSaveLoadList, TClipSaveList, TPlaylistSaveList, TCameraOptions, TGlobalAudioSettings, TSecondaryAudioSettings } from './types/CamSwitcherAPI';
|
|
3
|
+
import { TAudioChannel, TNetworkCamera, TStorageType } from './types/common';
|
|
4
|
+
export declare class CamSwitcherAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
5
|
+
client: Client;
|
|
6
|
+
private CustomFormData;
|
|
7
|
+
private vapixAgent;
|
|
8
|
+
constructor(client: Client, CustomFormData?: {
|
|
9
|
+
new (form?: HTMLFormElement | undefined, submitter?: HTMLElement | null | undefined): FormData;
|
|
10
|
+
prototype: FormData;
|
|
11
|
+
});
|
|
12
|
+
static getProxyUrlPath: () => string;
|
|
13
|
+
static getWsEventsUrlPath: () => string;
|
|
14
|
+
static getClipPreviewUrlPath: (id: string, storage: TStorageType) => string;
|
|
15
|
+
generateSilence(sampleRate: number, channels: TAudioChannel): Promise<void>;
|
|
16
|
+
checkCameraTime(): Promise<boolean>;
|
|
17
|
+
getIpListFromNetworkCheck(): Promise<TNetworkCamera[]>;
|
|
18
|
+
getMaxFps(source: number): Promise<number>;
|
|
19
|
+
getStorageInfo(): Promise<TStorageInfo[]>;
|
|
20
|
+
wsAuthorization(): Promise<string>;
|
|
21
|
+
getOutputInfo(): Promise<TOutputInfo>;
|
|
22
|
+
getAudioPushInfo(): Promise<TAudioPushInfo>;
|
|
23
|
+
getStreamSaveList(): Promise<TStreamSaveLoadList>;
|
|
24
|
+
getClipSaveList(): Promise<TClipSaveLoadList>;
|
|
25
|
+
getPlaylistSaveList(): Promise<TPlaylistSaveLoadList>;
|
|
26
|
+
getTrackerSaveList(): Promise<TrackerSaveLoadList>;
|
|
27
|
+
setStreamSaveList(data: TStreamSaveList): Promise<boolean>;
|
|
28
|
+
setClipSaveList(data: TClipSaveList): Promise<boolean>;
|
|
29
|
+
setPlaylistSaveList(data: TPlaylistSaveList): Promise<boolean>;
|
|
30
|
+
setTrackerSaveList(data: TTrackerSaveList): Promise<boolean>;
|
|
31
|
+
playlistSwitch(playlistName: string): Promise<void>;
|
|
32
|
+
playlistQueuePush(playlistName: string): Promise<void>;
|
|
33
|
+
playlistQueueClear(): Promise<void>;
|
|
34
|
+
playlistQueueList(): Promise<string[]>;
|
|
35
|
+
playlistQueuePlayNext(): Promise<void>;
|
|
36
|
+
addNewClip(file: any, clipType: 'video' | 'audio', storage: TStorageType, id: string, fileName?: string): Promise<void>;
|
|
37
|
+
removeClip(id: string, storage: TStorageType): Promise<any>;
|
|
38
|
+
getClipList(): Promise<TClipList>;
|
|
39
|
+
setCamSwitchOptions(data: TCameraOptions, cameraFWVersion: string): Promise<boolean>;
|
|
40
|
+
setGlobalAudioSettings(settings: TGlobalAudioSettings): Promise<boolean>;
|
|
41
|
+
setSecondaryAudioSettings(settings: TSecondaryAudioSettings): Promise<boolean>;
|
|
42
|
+
setDefaultPlaylist(id: string): Promise<boolean>;
|
|
43
|
+
setPermanentRtspUrlToken(token: string): Promise<boolean>;
|
|
44
|
+
getCamSwitchOptions(): Promise<Partial<TCameraOptions>>;
|
|
45
|
+
getGlobalAudioSettings(): Promise<TGlobalAudioSettings>;
|
|
46
|
+
getSecondaryAudioSettings(): Promise<TSecondaryAudioSettings>;
|
|
47
|
+
getPermanentRtspUrlToken(): Promise<string>;
|
|
48
|
+
private get;
|
|
49
|
+
private set;
|
|
50
|
+
private setParamFromCameraJSON;
|
|
51
|
+
private getParamFromCameraAndJSONParse;
|
|
52
|
+
}
|
|
@@ -1,23 +1,24 @@
|
|
|
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
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
|
const baseUrl = '/local/camswitcher/api';
|
|
11
10
|
export class CamSwitcherAPI {
|
|
12
11
|
client;
|
|
12
|
+
CustomFormData;
|
|
13
13
|
vapixAgent;
|
|
14
|
-
constructor(client) {
|
|
14
|
+
constructor(client, CustomFormData = FormData) {
|
|
15
15
|
this.client = client;
|
|
16
|
+
this.CustomFormData = CustomFormData;
|
|
16
17
|
this.vapixAgent = new VapixAPI(client, () => '');
|
|
17
18
|
}
|
|
18
|
-
static
|
|
19
|
-
static
|
|
20
|
-
static
|
|
19
|
+
static getProxyUrlPath = () => `${baseUrl}/proxy.cgi`;
|
|
20
|
+
static getWsEventsUrlPath = () => `/local/camswitcher/events`;
|
|
21
|
+
static getClipPreviewUrlPath = (id, storage) => `${baseUrl}/clip_preview.cgi?clip_name=${id}&storage=${storage}`;
|
|
21
22
|
async generateSilence(sampleRate, channels) {
|
|
22
23
|
await this.client.get(`${baseUrl}/generate_silence.cgi`, {
|
|
23
24
|
sample_rate: sampleRate.toString(),
|
|
@@ -99,7 +100,7 @@ export class CamSwitcherAPI {
|
|
|
99
100
|
await this.get(`${baseUrl}/playlist_queue_play_next.cgi`);
|
|
100
101
|
}
|
|
101
102
|
async addNewClip(file, clipType, storage, id, fileName) {
|
|
102
|
-
const formData = new
|
|
103
|
+
const formData = new this.CustomFormData();
|
|
103
104
|
formData.append('clip_name', id);
|
|
104
105
|
formData.append('clip_type', clipType);
|
|
105
106
|
formData.append('file', file, fileName);
|
|
@@ -292,16 +293,12 @@ const parseBitrateOptionsToBitrateVapixParams = (firmWareVersion, bitrateMode, c
|
|
|
292
293
|
if (bitrateMode === null) {
|
|
293
294
|
return '';
|
|
294
295
|
}
|
|
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.');
|
|
296
|
+
const data = {
|
|
297
|
+
VBR: 'videobitratemode=vbr',
|
|
298
|
+
MBR: `videobitratemode=mbr&videomaxbitrate=${cameraOptions.maximumBitRate}`,
|
|
299
|
+
ABR: `videobitratemode=abr&videoabrtargetbitrate=${cameraOptions.maximumBitRate}&videoabrretentiontime=${cameraOptions.retentionTime}&videoabrmaxbitrate=${cameraOptions.bitRateLimit}`,
|
|
300
|
+
};
|
|
301
|
+
return data[bitrateMode];
|
|
305
302
|
};
|
|
306
303
|
const parseVapixParamsToBitrateOptions = (bitrateVapixParams) => {
|
|
307
304
|
const params = {};
|
|
@@ -312,7 +309,7 @@ const parseVapixParamsToBitrateOptions = (bitrateVapixParams) => {
|
|
|
312
309
|
const bitrateMode = params['videobitratemode'] !== undefined ? params['videobitratemode'].toUpperCase() : undefined;
|
|
313
310
|
const hasLowerFw = bitrateMode === undefined && params['videomaxbitrate'] !== undefined;
|
|
314
311
|
if (hasLowerFw) {
|
|
315
|
-
const maximumBitRate = parseInt(params['videomaxbitrate'], 10);
|
|
312
|
+
const maximumBitRate = parseInt(params['videomaxbitrate'] ?? '0', 10);
|
|
316
313
|
return {
|
|
317
314
|
bitrateMode: 'MBR',
|
|
318
315
|
maximumBitRate: maximumBitRate,
|
|
@@ -321,19 +318,19 @@ const parseVapixParamsToBitrateOptions = (bitrateVapixParams) => {
|
|
|
321
318
|
};
|
|
322
319
|
}
|
|
323
320
|
if (bitrateMode === 'ABR') {
|
|
324
|
-
const maximumBitRate = parseInt(params['videoabrtargetbitrate'], 10);
|
|
325
|
-
const retentionTime = parseInt(params['videoabrretentiontime'], 10);
|
|
326
|
-
const
|
|
321
|
+
const maximumBitRate = parseInt(params['videoabrtargetbitrate'] ?? '0', 10);
|
|
322
|
+
const retentionTime = parseInt(params['videoabrretentiontime'] ?? '0', 10);
|
|
323
|
+
const bitRateLimit = parseInt(params['videoabrmaxbitrate'] ?? '0', 10);
|
|
327
324
|
return {
|
|
328
|
-
bitrateMode
|
|
329
|
-
maximumBitRate
|
|
330
|
-
retentionTime
|
|
331
|
-
bitRateLimit
|
|
325
|
+
bitrateMode,
|
|
326
|
+
maximumBitRate,
|
|
327
|
+
retentionTime,
|
|
328
|
+
bitRateLimit,
|
|
332
329
|
};
|
|
333
330
|
}
|
|
334
331
|
else if (bitrateMode === 'MBR') {
|
|
335
|
-
const maximumBitRate = parseInt(params['videomaxbitrate'], 10);
|
|
336
|
-
const oldMaximumBitrateParamValue = parseInt(params['videombrmaxbitrate'], 10);
|
|
332
|
+
const maximumBitRate = params['videomaxbitrate'] !== undefined ? parseInt(params['videomaxbitrate'], 10) : null;
|
|
333
|
+
const oldMaximumBitrateParamValue = parseInt(params['videombrmaxbitrate'] ?? '0', 10);
|
|
337
334
|
return {
|
|
338
335
|
bitrateMode: bitrateMode,
|
|
339
336
|
maximumBitRate: maximumBitRate ?? oldMaximumBitrateParamValue,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IWebsocket } from './internal/types';
|
|
2
|
+
import { TCamSwitcherEventOfType, TCamSwitcherEventType } from './types/CamSwitcherEvents';
|
|
3
|
+
type TListenerFunction<T extends TCamSwitcherEventType> = (data: TCamSwitcherEventOfType<T>, isInit: boolean) => void;
|
|
4
|
+
export declare class CamSwitcherEvents<Event extends {
|
|
5
|
+
data: string;
|
|
6
|
+
}> {
|
|
7
|
+
isDestroyed: boolean;
|
|
8
|
+
private ws;
|
|
9
|
+
private listeners;
|
|
10
|
+
setWebsocket(ws: IWebsocket<Event>): void;
|
|
11
|
+
resendInitData(): void;
|
|
12
|
+
addListener<T extends TCamSwitcherEventType>(type: T, listener: TListenerFunction<T>, id: string): void;
|
|
13
|
+
removeListener<T extends TCamSwitcherEventType>(type: T, id: string): void;
|
|
14
|
+
private onMessage;
|
|
15
|
+
private processMessage;
|
|
16
|
+
destroy(): void;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { IClient, TBlobResponse, TParameters, TResponse } from './internal/types';
|
|
2
|
+
import { TExportDataType, TImportDataType } from './types/PlaneTrackerAPI';
|
|
3
|
+
export type TApiUser = {
|
|
4
|
+
userId: string;
|
|
5
|
+
userName: string;
|
|
6
|
+
userPriority: number;
|
|
7
|
+
};
|
|
8
|
+
type ICAO = string;
|
|
9
|
+
export declare const BASE_URL = "/local/planetracker";
|
|
10
|
+
export declare class PlaneTrackerAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
11
|
+
private client;
|
|
12
|
+
private apiUser;
|
|
13
|
+
private _apiUserQuery;
|
|
14
|
+
constructor(client: Client, apiUser: TApiUser);
|
|
15
|
+
static getProxyUrlPath: () => string;
|
|
16
|
+
checkCameraTime(): Promise<boolean>;
|
|
17
|
+
fetchCameraSettings: () => Promise<any>;
|
|
18
|
+
setCameraSettings: (settingsJsonString: string) => Promise<TResponse>;
|
|
19
|
+
fetchServerSettings: () => Promise<any>;
|
|
20
|
+
fetchMapInfo: () => Promise<any>;
|
|
21
|
+
fetchFlightInfo: (icao: ICAO) => Promise<any>;
|
|
22
|
+
getZones: () => Promise<any>;
|
|
23
|
+
setZones: (zonesJsonString: string) => Promise<TResponse>;
|
|
24
|
+
getPriorityList: () => Promise<any>;
|
|
25
|
+
setPriorityList: (priorityListJsonString: string) => Promise<TResponse>;
|
|
26
|
+
getWhiteList: () => Promise<any>;
|
|
27
|
+
setWhiteList: (whiteListJsonString: string) => Promise<TResponse>;
|
|
28
|
+
getBlackList: () => Promise<any>;
|
|
29
|
+
setBlackList: (blackListJsonString: string) => Promise<TResponse>;
|
|
30
|
+
getTrackingMode: () => Promise<any>;
|
|
31
|
+
setTrackingMode: (modeJsonString: string) => Promise<TResponse>;
|
|
32
|
+
startTrackingPlane: (icao: ICAO) => Promise<TResponse>;
|
|
33
|
+
stopTrackingPlane: () => Promise<TResponse>;
|
|
34
|
+
goToCoordinates: (lat: number, lon: number, alt?: number) => Promise<TResponse>;
|
|
35
|
+
exportAppSettings: (dataType: TExportDataType) => Promise<TBlobResponse<Client>>;
|
|
36
|
+
importAppSettings: (dataType: TImportDataType, formData: FormData) => Promise<TResponse>;
|
|
37
|
+
resetPtzCalibration: () => Promise<TResponse>;
|
|
38
|
+
checkGenetecConnection: (params: TParameters) => Promise<TResponse>;
|
|
39
|
+
getGenetecCameraList: (params: TParameters) => Promise<any>;
|
|
40
|
+
serverRunCheck: () => Promise<TResponse>;
|
|
41
|
+
private _getJson;
|
|
42
|
+
private _getBlob;
|
|
43
|
+
private parseBlobResponse;
|
|
44
|
+
private _postJsonEncoded;
|
|
45
|
+
private _postUrlEncoded;
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { paramToUrl, responseStringify } from './internal/utils';
|
|
3
|
+
import { ParsingBlobError } from './errors/errors';
|
|
4
|
+
export const BASE_URL = '/local/planetracker';
|
|
5
|
+
export class PlaneTrackerAPI {
|
|
6
|
+
client;
|
|
7
|
+
apiUser;
|
|
8
|
+
_apiUserQuery;
|
|
9
|
+
constructor(client, apiUser) {
|
|
10
|
+
this.client = client;
|
|
11
|
+
this.apiUser = apiUser;
|
|
12
|
+
this._apiUserQuery = paramToUrl(this.apiUser);
|
|
13
|
+
}
|
|
14
|
+
static getProxyUrlPath = () => `${BASE_URL}/proxy.cgi`;
|
|
15
|
+
async checkCameraTime() {
|
|
16
|
+
const responseSchema = z.discriminatedUnion('state', [
|
|
17
|
+
z.object({
|
|
18
|
+
state: z.literal(true),
|
|
19
|
+
code: z.number(),
|
|
20
|
+
}),
|
|
21
|
+
z.object({
|
|
22
|
+
state: z.literal(false),
|
|
23
|
+
code: z.number(),
|
|
24
|
+
reason: z.union([
|
|
25
|
+
z.literal('INVALID_TIME'),
|
|
26
|
+
z.literal('COULDNT_RESOLVE_HOST'),
|
|
27
|
+
z.literal('CONNECTION_ERROR'),
|
|
28
|
+
]),
|
|
29
|
+
message: z.string(),
|
|
30
|
+
}),
|
|
31
|
+
]);
|
|
32
|
+
const response = await this._getJson(`${BASE_URL}/camera_time.cgi`);
|
|
33
|
+
const cameraTime = responseSchema.parse(response);
|
|
34
|
+
if (!cameraTime.state) {
|
|
35
|
+
console.error(`Camera time check failed: ${cameraTime.reason} - ${cameraTime.message}`);
|
|
36
|
+
}
|
|
37
|
+
return cameraTime.state;
|
|
38
|
+
}
|
|
39
|
+
fetchCameraSettings = async () => {
|
|
40
|
+
return await this._getJson(`${BASE_URL}/package_camera_settings.cgi`, { action: 'get' });
|
|
41
|
+
};
|
|
42
|
+
setCameraSettings = async (settingsJsonString) => {
|
|
43
|
+
return await this._postJsonEncoded(`${BASE_URL}/package_camera_settings.cgi`, settingsJsonString, {
|
|
44
|
+
action: 'set',
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
fetchServerSettings = async () => {
|
|
48
|
+
return await this._getJson(`${BASE_URL}/package_server_settings.cgi`, { action: 'get' });
|
|
49
|
+
};
|
|
50
|
+
fetchMapInfo = async () => {
|
|
51
|
+
return await this._getJson(`${BASE_URL}/package/getMapInfo.cgi`);
|
|
52
|
+
};
|
|
53
|
+
fetchFlightInfo = async (icao) => {
|
|
54
|
+
return await this._getJson(`${BASE_URL}/package/flightInfo.cgi`, { icao: encodeURIComponent(icao) });
|
|
55
|
+
};
|
|
56
|
+
getZones = async () => {
|
|
57
|
+
return await this._getJson(`${BASE_URL}/package/getZones.cgi`);
|
|
58
|
+
};
|
|
59
|
+
setZones = async (zonesJsonString) => {
|
|
60
|
+
return await this._postJsonEncoded(`${BASE_URL}/package/setZones.cgi?${this._apiUserQuery}`, zonesJsonString);
|
|
61
|
+
};
|
|
62
|
+
getPriorityList = async () => {
|
|
63
|
+
return await this._getJson(`${BASE_URL}/package/getPriorityList.cgi`);
|
|
64
|
+
};
|
|
65
|
+
setPriorityList = async (priorityListJsonString) => {
|
|
66
|
+
return await this._postJsonEncoded(`${BASE_URL}/package/setPriorityList.cgi?${this._apiUserQuery}`, priorityListJsonString);
|
|
67
|
+
};
|
|
68
|
+
getWhiteList = async () => {
|
|
69
|
+
return await this._getJson(`${BASE_URL}/package/getWhiteList.cgi`);
|
|
70
|
+
};
|
|
71
|
+
setWhiteList = async (whiteListJsonString) => {
|
|
72
|
+
return await this._postJsonEncoded(`${BASE_URL}/package/setWhiteList.cgi?${this._apiUserQuery}`, whiteListJsonString);
|
|
73
|
+
};
|
|
74
|
+
getBlackList = async () => {
|
|
75
|
+
return await this._getJson(`${BASE_URL}/package/getBlackList.cgi`);
|
|
76
|
+
};
|
|
77
|
+
setBlackList = async (blackListJsonString) => {
|
|
78
|
+
return await this._postJsonEncoded(`${BASE_URL}/package/setBlackList.cgi?${this._apiUserQuery}`, blackListJsonString);
|
|
79
|
+
};
|
|
80
|
+
getTrackingMode = async () => {
|
|
81
|
+
return await this._getJson(`${BASE_URL}/package/getTrackingMode.cgi`);
|
|
82
|
+
};
|
|
83
|
+
setTrackingMode = async (modeJsonString) => {
|
|
84
|
+
return await this._postJsonEncoded(`${BASE_URL}/package/setTrackingMode.cgi?${this._apiUserQuery}`, modeJsonString);
|
|
85
|
+
};
|
|
86
|
+
startTrackingPlane = async (icao) => {
|
|
87
|
+
return await this.client.get(`${BASE_URL}/package/trackIcao.cgi`, {
|
|
88
|
+
icao: encodeURIComponent(icao),
|
|
89
|
+
userId: encodeURIComponent(this.apiUser.userId),
|
|
90
|
+
userName: encodeURIComponent(this.apiUser.userName),
|
|
91
|
+
userPriority: this.apiUser.userPriority,
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
stopTrackingPlane = async () => {
|
|
95
|
+
return await this.client.get(`${BASE_URL}/package/resetIcao.cgi?${this._apiUserQuery}`);
|
|
96
|
+
};
|
|
97
|
+
goToCoordinates = async (lat, lon, alt) => {
|
|
98
|
+
const url = `${BASE_URL}/package/goToCoordinates.cgi?lat=${lat}&lon=${lon}&${this._apiUserQuery}`;
|
|
99
|
+
return await this.client.get(`${url}${alt !== undefined ? `&alt=${alt}` : ''}`);
|
|
100
|
+
};
|
|
101
|
+
exportAppSettings = async (dataType) => {
|
|
102
|
+
return await this._getBlob(`${BASE_URL}/package_data.cgi`, { action: 'EXPORT', dataType });
|
|
103
|
+
};
|
|
104
|
+
importAppSettings = async (dataType, formData) => {
|
|
105
|
+
return await this.client.post(`${BASE_URL}/package_data.cgi`, formData, { action: 'IMPORT', dataType });
|
|
106
|
+
};
|
|
107
|
+
resetPtzCalibration = async () => {
|
|
108
|
+
return await this.client.get(`${BASE_URL}/package/resetPtzCalibration.cgi`, {
|
|
109
|
+
userId: encodeURIComponent(this.apiUser.userId),
|
|
110
|
+
userName: encodeURIComponent(this.apiUser.userName),
|
|
111
|
+
userPriority: this.apiUser.userPriority,
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
checkGenetecConnection = async (params) => {
|
|
115
|
+
return await this._postUrlEncoded(`${BASE_URL}/package/checkGenetecConnection.cgi`, params);
|
|
116
|
+
};
|
|
117
|
+
getGenetecCameraList = async (params) => {
|
|
118
|
+
const res = await this._postUrlEncoded(`${BASE_URL}/package/getGenetecCameraList.cgi`, params);
|
|
119
|
+
return await res.json();
|
|
120
|
+
};
|
|
121
|
+
serverRunCheck = async () => {
|
|
122
|
+
return await this.client.get(`${BASE_URL}/package/serverRunCheck.cgi`);
|
|
123
|
+
};
|
|
124
|
+
async _getJson(...args) {
|
|
125
|
+
const res = await this.client.get(...args);
|
|
126
|
+
if (res.ok) {
|
|
127
|
+
return await res.json();
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
throw new Error(await responseStringify(res));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
async _getBlob(...args) {
|
|
134
|
+
const res = await this.client.get(...args);
|
|
135
|
+
if (res.ok) {
|
|
136
|
+
return await this.parseBlobResponse(res);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
throw new Error(await responseStringify(res));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async parseBlobResponse(response) {
|
|
143
|
+
try {
|
|
144
|
+
return (await response.blob());
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
throw new ParsingBlobError(err);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async _postJsonEncoded(...args) {
|
|
151
|
+
const [path, data, params, headers] = args;
|
|
152
|
+
const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
|
|
153
|
+
const res = await this.client.post(path, data, params, { ...baseHeaders, ...headers });
|
|
154
|
+
if (res.ok) {
|
|
155
|
+
return res;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
throw new Error(await responseStringify(res));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async _postUrlEncoded(path, params, headers) {
|
|
162
|
+
const data = paramToUrl(params);
|
|
163
|
+
const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
164
|
+
const res = await this.client.post(path, data, {}, { ...baseHeaders, ...headers });
|
|
165
|
+
if (res.ok) {
|
|
166
|
+
return res;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
throw new Error(await responseStringify(res));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|