camstreamerlib 4.0.0-beta.97 → 4.0.1
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 +44 -15
- package/cjs/CamOverlayAPI.d.ts +147 -109
- package/cjs/CamOverlayAPI.js +14 -63
- package/cjs/CamScripterAPI.d.ts +5 -8
- package/cjs/CamScripterAPI.js +11 -29
- package/cjs/CamStreamerAPI.d.ts +2745 -589
- package/cjs/CamStreamerAPI.js +68 -76
- package/cjs/CamSwitcherAPI.d.ts +23 -22
- package/cjs/CamSwitcherAPI.js +30 -88
- package/cjs/PlaneTrackerAPI.d.ts +28 -30
- package/cjs/PlaneTrackerAPI.js +20 -75
- package/cjs/VapixAPI.d.ts +36 -23
- package/cjs/VapixAPI.js +227 -106
- package/cjs/errors/errors.d.ts +11 -5
- package/cjs/errors/errors.js +5 -1
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +1 -0
- package/cjs/internal/BasicAPI.d.ts +15 -0
- package/cjs/internal/BasicAPI.js +93 -0
- package/cjs/internal/WsEvents.d.ts +1 -0
- package/cjs/internal/WsEvents.js +5 -0
- package/cjs/internal/constants.d.ts +1 -0
- package/cjs/internal/constants.js +2 -1
- package/cjs/internal/convertors.d.ts +6 -0
- package/cjs/internal/convertors.js +115 -0
- package/cjs/internal/transformers.js +8 -8
- package/cjs/internal/types.d.ts +3 -0
- package/cjs/internal/versionCompare.d.ts +2 -2
- package/cjs/types/CamOverlayAPI/CamOverlayAPI.d.ts +894 -374
- package/cjs/types/CamOverlayAPI/CamOverlayAPI.js +54 -11
- package/cjs/types/CamOverlayAPI/accuweatherSchema.d.ts +10 -10
- package/cjs/types/CamOverlayAPI/customGraphicsSchema.d.ts +40 -40
- package/cjs/types/CamOverlayAPI/htmlOverlaySchema.d.ts +81 -0
- package/cjs/types/CamOverlayAPI/htmlOverlaySchema.js +21 -0
- package/cjs/types/CamOverlayAPI/imagesSchema.d.ts +10 -10
- package/cjs/types/CamOverlayAPI/index.d.ts +1 -0
- package/cjs/types/CamOverlayAPI/index.js +1 -0
- package/cjs/types/CamOverlayAPI/infotickerSchema.d.ts +8 -8
- package/cjs/types/CamOverlayAPI/pipSchema.d.ts +8 -8
- package/cjs/types/CamOverlayAPI/ptzCompassSchema.d.ts +10 -10
- package/cjs/types/CamOverlayAPI/ptzSchema.d.ts +13 -13
- package/cjs/types/CamOverlayAPI/scoreBoardSchema.d.ts +18 -18
- package/cjs/types/CamOverlayAPI/screenSharingSchema.d.ts +8 -8
- package/cjs/types/CamOverlayAPI/serviceCommonTypes.d.ts +17 -16
- package/cjs/types/CamOverlayAPI/serviceCommonTypes.js +6 -3
- package/cjs/types/CamOverlayAPI/webCameraSharingSchema.d.ts +8 -8
- package/cjs/types/CamScripterAPI.d.ts +0 -11
- package/cjs/types/CamScripterAPI.js +1 -5
- package/cjs/types/CamStreamerAPI/CamStreamerAPI.d.ts +19642 -3073
- package/cjs/types/CamStreamerAPI/CamStreamerAPI.js +126 -57
- package/cjs/types/CamStreamerAPI/facebookSchema.d.ts +434 -52
- package/cjs/types/CamStreamerAPI/facebookSchema.js +13 -1
- package/cjs/types/CamStreamerAPI/index.d.ts +1 -3
- package/cjs/types/CamStreamerAPI/index.js +1 -3
- package/cjs/types/CamStreamerAPI/oldStreamSchema.d.ts +47 -47
- package/cjs/types/CamStreamerAPI/oldStreamSchema.js +1 -1
- package/cjs/types/CamStreamerAPI/streamCommonTypes.d.ts +430 -219
- package/cjs/types/CamStreamerAPI/streamCommonTypes.js +116 -58
- package/cjs/types/CamStreamerAPI/streamsSchema.d.ts +8812 -0
- package/cjs/types/CamStreamerAPI/streamsSchema.js +81 -0
- package/cjs/types/CamStreamerAPI/windySchema.d.ts +394 -52
- package/cjs/types/CamStreamerAPI/windySchema.js +9 -1
- package/cjs/types/CamStreamerAPI/youtubeSchema.d.ts +402 -52
- package/cjs/types/CamStreamerAPI/youtubeSchema.js +12 -1
- package/cjs/types/CamSwitcherAPI.d.ts +96 -91
- package/cjs/types/CamSwitcherAPI.js +9 -9
- package/cjs/types/GenetecAgent.d.ts +2 -2
- package/cjs/types/PlaneTrackerAPI.d.ts +60 -47
- package/cjs/types/PlaneTrackerAPI.js +5 -2
- package/cjs/types/VapixAPI.d.ts +51 -32
- package/cjs/types/VapixAPI.js +10 -3
- package/cjs/types/common.d.ts +27 -0
- package/cjs/types/common.js +13 -1
- package/cjs/types/ws/CamStreamerEvents.d.ts +110 -77
- package/cjs/types/ws/CamStreamerEvents.js +11 -7
- package/cjs/types/ws/CamSwitcherEvents.d.ts +8 -8
- package/cjs/types/ws/PlaneTrackerEvents.d.ts +3 -3
- package/esm/CamOverlayAPI.js +16 -65
- package/esm/CamScripterAPI.js +9 -30
- package/esm/CamStreamerAPI.js +70 -78
- package/esm/CamSwitcherAPI.js +31 -89
- package/esm/PlaneTrackerAPI.js +21 -76
- package/esm/VapixAPI.js +228 -107
- package/esm/errors/errors.js +5 -1
- package/esm/index.js +1 -0
- package/esm/internal/BasicAPI.js +89 -0
- package/esm/internal/WsEvents.js +5 -0
- package/esm/internal/constants.js +1 -0
- package/esm/internal/convertors.js +108 -0
- package/esm/internal/transformers.js +1 -1
- package/esm/types/CamOverlayAPI/CamOverlayAPI.js +47 -10
- package/esm/types/CamOverlayAPI/htmlOverlaySchema.js +18 -0
- package/esm/types/CamOverlayAPI/index.js +1 -0
- package/esm/types/CamOverlayAPI/serviceCommonTypes.js +6 -3
- package/esm/types/CamScripterAPI.js +0 -4
- package/esm/types/CamStreamerAPI/CamStreamerAPI.js +109 -41
- package/esm/types/CamStreamerAPI/facebookSchema.js +13 -1
- package/esm/types/CamStreamerAPI/index.js +1 -3
- package/esm/types/CamStreamerAPI/oldStreamSchema.js +1 -1
- package/esm/types/CamStreamerAPI/streamCommonTypes.js +116 -58
- package/esm/types/CamStreamerAPI/streamsSchema.js +75 -0
- package/esm/types/CamStreamerAPI/windySchema.js +9 -1
- package/esm/types/CamStreamerAPI/youtubeSchema.js +12 -1
- package/esm/types/CamSwitcherAPI.js +8 -8
- package/esm/types/PlaneTrackerAPI.js +5 -2
- package/esm/types/VapixAPI.js +9 -2
- package/esm/types/common.js +12 -0
- package/esm/types/ws/CamStreamerEvents.js +11 -7
- package/package.json +4 -4
- package/types/CamOverlayAPI.d.ts +147 -109
- package/types/CamScripterAPI.d.ts +5 -8
- package/types/CamStreamerAPI.d.ts +2745 -589
- package/types/CamSwitcherAPI.d.ts +23 -22
- package/types/PlaneTrackerAPI.d.ts +28 -30
- package/types/VapixAPI.d.ts +36 -23
- package/types/errors/errors.d.ts +11 -5
- package/types/index.d.ts +1 -0
- package/types/internal/BasicAPI.d.ts +15 -0
- package/types/internal/WsEvents.d.ts +1 -0
- package/types/internal/constants.d.ts +1 -0
- package/types/internal/convertors.d.ts +6 -0
- package/types/internal/types.d.ts +3 -0
- package/types/internal/versionCompare.d.ts +2 -2
- package/types/types/CamOverlayAPI/CamOverlayAPI.d.ts +894 -374
- package/types/types/CamOverlayAPI/accuweatherSchema.d.ts +10 -10
- package/types/types/CamOverlayAPI/customGraphicsSchema.d.ts +40 -40
- package/types/types/CamOverlayAPI/htmlOverlaySchema.d.ts +81 -0
- package/types/types/CamOverlayAPI/imagesSchema.d.ts +10 -10
- package/types/types/CamOverlayAPI/index.d.ts +1 -0
- package/types/types/CamOverlayAPI/infotickerSchema.d.ts +8 -8
- package/types/types/CamOverlayAPI/pipSchema.d.ts +8 -8
- package/types/types/CamOverlayAPI/ptzCompassSchema.d.ts +10 -10
- package/types/types/CamOverlayAPI/ptzSchema.d.ts +13 -13
- package/types/types/CamOverlayAPI/scoreBoardSchema.d.ts +18 -18
- package/types/types/CamOverlayAPI/screenSharingSchema.d.ts +8 -8
- package/types/types/CamOverlayAPI/serviceCommonTypes.d.ts +17 -16
- package/types/types/CamOverlayAPI/webCameraSharingSchema.d.ts +8 -8
- package/types/types/CamScripterAPI.d.ts +0 -11
- package/types/types/CamStreamerAPI/CamStreamerAPI.d.ts +19642 -3073
- package/types/types/CamStreamerAPI/facebookSchema.d.ts +434 -52
- package/types/types/CamStreamerAPI/index.d.ts +1 -3
- package/types/types/CamStreamerAPI/oldStreamSchema.d.ts +47 -47
- package/types/types/CamStreamerAPI/streamCommonTypes.d.ts +430 -219
- package/types/types/CamStreamerAPI/streamsSchema.d.ts +8812 -0
- package/types/types/CamStreamerAPI/windySchema.d.ts +394 -52
- package/types/types/CamStreamerAPI/youtubeSchema.d.ts +402 -52
- package/types/types/CamSwitcherAPI.d.ts +96 -91
- package/types/types/GenetecAgent.d.ts +2 -2
- package/types/types/PlaneTrackerAPI.d.ts +60 -47
- package/types/types/VapixAPI.d.ts +51 -32
- package/types/types/common.d.ts +27 -0
- package/types/types/ws/CamStreamerEvents.d.ts +110 -77
- package/types/types/ws/CamSwitcherEvents.d.ts +8 -8
- package/types/types/ws/PlaneTrackerEvents.d.ts +3 -3
- package/cjs/types/CamStreamerAPI/churchSchema.d.ts +0 -202
- package/cjs/types/CamStreamerAPI/churchSchema.js +0 -11
- package/cjs/types/CamStreamerAPI/daCastSchema.d.ts +0 -202
- package/cjs/types/CamStreamerAPI/daCastSchema.js +0 -11
- package/cjs/types/CamStreamerAPI/dailymotionSchema.d.ts +0 -202
- package/cjs/types/CamStreamerAPI/dailymotionSchema.js +0 -11
- package/cjs/types/CamStreamerAPI/gameChangerSchema.d.ts +0 -202
- package/cjs/types/CamStreamerAPI/gameChangerSchema.js +0 -11
- package/cjs/types/CamStreamerAPI/hlsPullSchema.d.ts +0 -202
- package/cjs/types/CamStreamerAPI/hlsPullSchema.js +0 -11
- package/cjs/types/CamStreamerAPI/hlsPushSchema.d.ts +0 -202
- package/cjs/types/CamStreamerAPI/hlsPushSchema.js +0 -11
- package/cjs/types/CamStreamerAPI/ibmSchema.d.ts +0 -202
- package/cjs/types/CamStreamerAPI/ibmSchema.js +0 -11
- package/cjs/types/CamStreamerAPI/microsoftAzureSchema.d.ts +0 -202
- package/cjs/types/CamStreamerAPI/microsoftAzureSchema.js +0 -11
- package/cjs/types/CamStreamerAPI/microsoftStreamSchema.d.ts +0 -202
- package/cjs/types/CamStreamerAPI/microsoftStreamSchema.js +0 -11
- package/cjs/types/CamStreamerAPI/mpegDvbSchema.d.ts +0 -250
- package/cjs/types/CamStreamerAPI/mpegDvbSchema.js +0 -27
- package/cjs/types/CamStreamerAPI/rtmpSchema.d.ts +0 -211
- package/cjs/types/CamStreamerAPI/rtmpSchema.js +0 -14
- package/cjs/types/CamStreamerAPI/sdCardSchema.d.ts +0 -202
- package/cjs/types/CamStreamerAPI/sdCardSchema.js +0 -11
- package/cjs/types/CamStreamerAPI/srtSchema.d.ts +0 -202
- package/cjs/types/CamStreamerAPI/srtSchema.js +0 -11
- package/cjs/types/CamStreamerAPI/twitchSchema.d.ts +0 -202
- package/cjs/types/CamStreamerAPI/twitchSchema.js +0 -11
- package/cjs/types/CamStreamerAPI/vimeoSchema.d.ts +0 -202
- package/cjs/types/CamStreamerAPI/vimeoSchema.js +0 -11
- package/cjs/types/CamStreamerAPI/wowzaSchema.d.ts +0 -202
- package/cjs/types/CamStreamerAPI/wowzaSchema.js +0 -11
- package/esm/types/CamStreamerAPI/churchSchema.js +0 -5
- package/esm/types/CamStreamerAPI/daCastSchema.js +0 -5
- package/esm/types/CamStreamerAPI/dailymotionSchema.js +0 -5
- package/esm/types/CamStreamerAPI/gameChangerSchema.js +0 -5
- package/esm/types/CamStreamerAPI/hlsPullSchema.js +0 -5
- package/esm/types/CamStreamerAPI/hlsPushSchema.js +0 -5
- package/esm/types/CamStreamerAPI/ibmSchema.js +0 -5
- package/esm/types/CamStreamerAPI/microsoftAzureSchema.js +0 -5
- package/esm/types/CamStreamerAPI/microsoftStreamSchema.js +0 -5
- package/esm/types/CamStreamerAPI/mpegDvbSchema.js +0 -21
- package/esm/types/CamStreamerAPI/rtmpSchema.js +0 -8
- package/esm/types/CamStreamerAPI/sdCardSchema.js +0 -5
- package/esm/types/CamStreamerAPI/srtSchema.js +0 -5
- package/esm/types/CamStreamerAPI/twitchSchema.js +0 -5
- package/esm/types/CamStreamerAPI/vimeoSchema.js +0 -5
- package/esm/types/CamStreamerAPI/wowzaSchema.js +0 -5
- package/types/types/CamStreamerAPI/churchSchema.d.ts +0 -202
- package/types/types/CamStreamerAPI/daCastSchema.d.ts +0 -202
- package/types/types/CamStreamerAPI/dailymotionSchema.d.ts +0 -202
- package/types/types/CamStreamerAPI/gameChangerSchema.d.ts +0 -202
- package/types/types/CamStreamerAPI/hlsPullSchema.d.ts +0 -202
- package/types/types/CamStreamerAPI/hlsPushSchema.d.ts +0 -202
- package/types/types/CamStreamerAPI/ibmSchema.d.ts +0 -202
- package/types/types/CamStreamerAPI/microsoftAzureSchema.d.ts +0 -202
- package/types/types/CamStreamerAPI/microsoftStreamSchema.d.ts +0 -202
- package/types/types/CamStreamerAPI/mpegDvbSchema.d.ts +0 -250
- package/types/types/CamStreamerAPI/rtmpSchema.d.ts +0 -211
- package/types/types/CamStreamerAPI/sdCardSchema.d.ts +0 -202
- package/types/types/CamStreamerAPI/srtSchema.d.ts +0 -202
- package/types/types/CamStreamerAPI/twitchSchema.d.ts +0 -202
- package/types/types/CamStreamerAPI/vimeoSchema.d.ts +0 -202
- package/types/types/CamStreamerAPI/wowzaSchema.d.ts +0 -202
package/esm/CamScripterAPI.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { BasicAPI } from './internal/BasicAPI';
|
|
3
|
+
import { nodeStateSchema, packageInfoListSchema, cameraStorageSchema } from './types/CamScripterAPI';
|
|
4
4
|
import { networkCameraListSchema } from './types/common';
|
|
5
5
|
const BASE_PATH = '/local/camscripter';
|
|
6
|
-
export class CamScripterAPI {
|
|
7
|
-
client;
|
|
8
|
-
constructor(client) {
|
|
9
|
-
this.client = client;
|
|
10
|
-
}
|
|
6
|
+
export class CamScripterAPI extends BasicAPI {
|
|
11
7
|
static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
async checkAPIAvailable(options) {
|
|
9
|
+
await this._getJson(`${BASE_PATH}/api_check.cgi`, undefined, options);
|
|
14
10
|
}
|
|
15
11
|
async checkCameraTime(options) {
|
|
16
12
|
const res = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
|
|
17
|
-
return
|
|
13
|
+
return z.boolean().parse(res.state);
|
|
18
14
|
}
|
|
19
15
|
async getNetworkCameraList(options) {
|
|
20
16
|
const res = await this._getJson(`${BASE_PATH}/network_camera_list.cgi`, undefined, options);
|
|
@@ -53,24 +49,7 @@ export class CamScripterAPI {
|
|
|
53
49
|
async installNodejs(storage, options) {
|
|
54
50
|
await this._getJson(`${BASE_PATH}/node_update.cgi`, { storage: storage }, options);
|
|
55
51
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
59
|
-
if (res.ok) {
|
|
60
|
-
return await res.json();
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
throw new ErrorWithResponse(res);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
async _post(path, data, parameters, options, headers) {
|
|
67
|
-
const agent = this.getClient(options?.proxyParams);
|
|
68
|
-
const res = await agent.post({ path, data, parameters, headers, timeout: options?.timeout });
|
|
69
|
-
if (res.ok) {
|
|
70
|
-
return await res.json();
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
throw new ErrorWithResponse(res);
|
|
74
|
-
}
|
|
52
|
+
downloadReport(options) {
|
|
53
|
+
return this._getText(`${BASE_PATH}/report.cgi`, undefined, options);
|
|
75
54
|
}
|
|
76
55
|
}
|
package/esm/CamStreamerAPI.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ErrorWithResponse, UtcTimeFetchError, WsAuthorizationError, MigrationError, ParsingBlobError, } from './errors/errors';
|
|
2
|
+
import { audioFileListSchema, diagnosticsSchema, srtStreamStatisticsSchema, storageListSchema, streamSchema, streamStatsSchema, } from './types/CamStreamerAPI/CamStreamerAPI';
|
|
3
|
+
import { UtcTimeFetchError, WsAuthorizationError, MigrationError } from './errors/errors';
|
|
5
4
|
import { oldStringStreamSchema, oldStringStreamSchemaWithId, } from './types/CamStreamerAPI/oldStreamSchema';
|
|
6
|
-
import {
|
|
5
|
+
import { BasicAPI } from './internal/BasicAPI';
|
|
6
|
+
import { streamPlatforms } from './types/CamStreamerAPI';
|
|
7
7
|
const BASE_PATH = '/local/camstreamer';
|
|
8
|
-
export class CamStreamerAPI {
|
|
9
|
-
client;
|
|
10
|
-
constructor(client) {
|
|
11
|
-
this.client = client;
|
|
12
|
-
}
|
|
8
|
+
export class CamStreamerAPI extends BasicAPI {
|
|
13
9
|
static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
static getWsEventsPath = () => `${BASE_PATH}/events`;
|
|
11
|
+
async checkAPIAvailable(options) {
|
|
12
|
+
await this._getJson(`${BASE_PATH}/api_check.cgi`, undefined, options);
|
|
13
|
+
}
|
|
14
|
+
async checkCameraTime(options) {
|
|
15
|
+
const res = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
|
|
16
|
+
return z.boolean().parse(res.data?.state);
|
|
16
17
|
}
|
|
17
18
|
async wsAuthorization(options) {
|
|
18
19
|
const res = await this._getJson(`${BASE_PATH}/ws_authorization.cgi`, undefined, options);
|
|
@@ -28,19 +29,35 @@ export class CamStreamerAPI {
|
|
|
28
29
|
}
|
|
29
30
|
return z.number().parse(res.data);
|
|
30
31
|
}
|
|
32
|
+
async getMaxFps(source = 0, options) {
|
|
33
|
+
return await this._getJson(`${BASE_PATH}/get_max_framerate.cgi`, { video_source: source.toString() }, options);
|
|
34
|
+
}
|
|
35
|
+
async isCSPassValid(pass, options) {
|
|
36
|
+
const res = await this._getJson(`${BASE_PATH}/check_pass.cgi`, { pass }, options);
|
|
37
|
+
return res.data === '1';
|
|
38
|
+
}
|
|
39
|
+
async getCamStreamerAppLog(options) {
|
|
40
|
+
return await this._getText(`${BASE_PATH}/view_log.cgi`, undefined, options);
|
|
41
|
+
}
|
|
31
42
|
async getStreamList(options) {
|
|
32
43
|
const res = await this._getJson(`${BASE_PATH}/stream_list.cgi`, { action: 'get' }, options);
|
|
33
44
|
const oldStreamListRecord = z.record(z.string(), oldStringStreamSchema).safeParse(res.data);
|
|
34
45
|
if (oldStreamListRecord.success) {
|
|
35
|
-
const data = Object.entries(oldStreamListRecord.data).map(([
|
|
36
|
-
|
|
46
|
+
const data = Object.entries(oldStreamListRecord.data).map(([streamId, streamData]) => ({
|
|
47
|
+
streamId,
|
|
37
48
|
...parseCameraStreamResponse(streamData),
|
|
38
49
|
}));
|
|
39
|
-
throw new MigrationError([], data);
|
|
50
|
+
throw new MigrationError([], data, [], []);
|
|
40
51
|
}
|
|
41
52
|
const newStreamData = [];
|
|
53
|
+
const unknownStreamData = [];
|
|
42
54
|
const oldStreamData = [];
|
|
55
|
+
const invalidStreamData = [];
|
|
43
56
|
for (const streamData of res.data.streamList) {
|
|
57
|
+
if (streamData.platform !== undefined && !Object.values(streamPlatforms).includes(streamData.platform)) {
|
|
58
|
+
unknownStreamData.push(streamData);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
44
61
|
const newStreamParse = streamSchema.safeParse(streamData);
|
|
45
62
|
if (newStreamParse.success) {
|
|
46
63
|
newStreamData.push(newStreamParse.data);
|
|
@@ -49,20 +66,20 @@ export class CamStreamerAPI {
|
|
|
49
66
|
const oldStreamParse = oldStringStreamSchemaWithId.safeParse(streamData);
|
|
50
67
|
if (oldStreamParse.success) {
|
|
51
68
|
oldStreamData.push({
|
|
52
|
-
|
|
69
|
+
streamId: oldStreamParse.data.streamId,
|
|
53
70
|
...parseCameraStreamResponse(oldStreamParse.data),
|
|
54
71
|
});
|
|
55
72
|
continue;
|
|
56
73
|
}
|
|
57
|
-
|
|
74
|
+
invalidStreamData.push(streamData);
|
|
58
75
|
}
|
|
59
|
-
if (oldStreamData.length > 0) {
|
|
60
|
-
throw new MigrationError(newStreamData, oldStreamData);
|
|
76
|
+
if (oldStreamData.length > 0 || invalidStreamData.length > 0) {
|
|
77
|
+
throw new MigrationError(newStreamData, oldStreamData, invalidStreamData, unknownStreamData);
|
|
61
78
|
}
|
|
62
|
-
return newStreamData;
|
|
79
|
+
return [...newStreamData, ...unknownStreamData];
|
|
63
80
|
}
|
|
64
81
|
async setStreamList(streamList, options) {
|
|
65
|
-
await this._postJsonEncoded(`${BASE_PATH}/stream_list.cgi`,
|
|
82
|
+
await this._postJsonEncoded(`${BASE_PATH}/stream_list.cgi`, { streamList }, {
|
|
66
83
|
action: 'set',
|
|
67
84
|
}, options);
|
|
68
85
|
}
|
|
@@ -73,17 +90,30 @@ export class CamStreamerAPI {
|
|
|
73
90
|
return newStream.data;
|
|
74
91
|
}
|
|
75
92
|
const oldStream = oldStringStreamSchema.passthrough().parse(res.data);
|
|
76
|
-
throw new MigrationError([], [{
|
|
93
|
+
throw new MigrationError([], [{ streamId, ...parseCameraStreamResponse(oldStream) }], [], []);
|
|
77
94
|
}
|
|
78
95
|
async setStream(streamId, streamData, options) {
|
|
79
|
-
await this._postJsonEncoded(`${BASE_PATH}/stream_list.cgi`,
|
|
96
|
+
await this._postJsonEncoded(`${BASE_PATH}/stream_list.cgi`, streamData, {
|
|
80
97
|
action: 'set',
|
|
81
98
|
stream_id: streamId,
|
|
82
99
|
}, options);
|
|
83
100
|
}
|
|
84
|
-
async
|
|
101
|
+
async getStreamNetworkStatistics(streamId, options) {
|
|
85
102
|
const res = await this._getJson(`${BASE_PATH}/get_streamstat.cgi`, { stream_id: streamId }, options);
|
|
86
|
-
return res.data
|
|
103
|
+
return streamStatsSchema.parse(res.data);
|
|
104
|
+
}
|
|
105
|
+
async getSrtStreamStatistics(streamId, options) {
|
|
106
|
+
const res = await this._getJson(`${BASE_PATH}/srt_statistics.cgi`, { stream_id: streamId }, options);
|
|
107
|
+
return srtStreamStatisticsSchema.parse(res.data);
|
|
108
|
+
}
|
|
109
|
+
async setStreamEnabled(streamId, enabled, options) {
|
|
110
|
+
await this._postUrlEncoded(`${BASE_PATH}/set_stream_enabled.cgi`, { stream_id: streamId, enabled: enabled ? 1 : 0 }, options);
|
|
111
|
+
}
|
|
112
|
+
async setStreamActive(streamId, active, options) {
|
|
113
|
+
await this._postUrlEncoded(`${BASE_PATH}/set_stream_active.cgi`, { stream_id: streamId, active: active ? 1 : 0 }, options);
|
|
114
|
+
}
|
|
115
|
+
async deleteStream(streamId, options) {
|
|
116
|
+
await this._postUrlEncoded(`${BASE_PATH}/remove.cgi`, { stream_id: streamId }, options);
|
|
87
117
|
}
|
|
88
118
|
async listFiles(options) {
|
|
89
119
|
const res = await this._getJson(`${BASE_PATH}/upload_audio.cgi`, { action: 'list' }, options);
|
|
@@ -96,7 +126,7 @@ export class CamStreamerAPI {
|
|
|
96
126
|
}, options);
|
|
97
127
|
}
|
|
98
128
|
async removeFile(fileParams, options) {
|
|
99
|
-
await this._postUrlEncoded(`${BASE_PATH}/upload_audio.cgi`, { action: 'remove', ...fileParams }, options
|
|
129
|
+
await this._postUrlEncoded(`${BASE_PATH}/upload_audio.cgi`, { action: 'remove', ...fileParams }, options);
|
|
100
130
|
}
|
|
101
131
|
async getFileStorage(options) {
|
|
102
132
|
const res = await this._getJson(`${BASE_PATH}/upload_audio.cgi`, { action: 'get_storage' }, options);
|
|
@@ -105,59 +135,21 @@ export class CamStreamerAPI {
|
|
|
105
135
|
async getFileFromCamera(path, options) {
|
|
106
136
|
return await this._getBlob(`${BASE_PATH}/audio.cgi`, { path }, options);
|
|
107
137
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
throw new ErrorWithResponse(res);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
async parseBlobResponse(response) {
|
|
129
|
-
try {
|
|
130
|
-
return (await response.blob());
|
|
131
|
-
}
|
|
132
|
-
catch (err) {
|
|
133
|
-
throw new ParsingBlobError(err);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
async _postUrlEncoded(path, parameters, options, headers) {
|
|
137
|
-
const data = paramToUrl(parameters);
|
|
138
|
-
const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
139
|
-
return this._post(path, data, undefined, options, { ...baseHeaders, ...headers });
|
|
140
|
-
}
|
|
141
|
-
async _postJsonEncoded(path, data, parameters, options, headers) {
|
|
142
|
-
const agent = this.getClient(options?.proxyParams);
|
|
143
|
-
const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
|
|
144
|
-
return agent.post({
|
|
145
|
-
path,
|
|
146
|
-
data,
|
|
147
|
-
parameters,
|
|
148
|
-
timeout: options?.timeout,
|
|
149
|
-
headers: { ...baseHeaders, ...headers },
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
async _post(path, data, parameters, options, headers) {
|
|
153
|
-
const agent = this.getClient(options?.proxyParams);
|
|
154
|
-
const res = await agent.post({ path, data, parameters, headers, timeout: options?.timeout });
|
|
155
|
-
if (res.ok) {
|
|
156
|
-
return await res.json();
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
throw new ErrorWithResponse(res);
|
|
160
|
-
}
|
|
138
|
+
downloadReport(options) {
|
|
139
|
+
return this._getText(`${BASE_PATH}/report.cgi`, undefined, options);
|
|
140
|
+
}
|
|
141
|
+
async getDiagnostics(params, options) {
|
|
142
|
+
const convertedParams = {
|
|
143
|
+
camerainfo: params.camerainfo ? '1' : '0',
|
|
144
|
+
checkserver: params.checkserver ? '1' : '0',
|
|
145
|
+
checkservertime: params.checkservertime ? '1' : '0',
|
|
146
|
+
speedtest: params.speedtest ? '1' : '0',
|
|
147
|
+
pingtest: params.pingtest ? '1' : '0',
|
|
148
|
+
videoHostPort: params.videoHostPort,
|
|
149
|
+
audioHostPort: params.audioHostPort,
|
|
150
|
+
};
|
|
151
|
+
const res = await this._getJson(`${BASE_PATH}/diagnostics.cgi`, convertedParams, options);
|
|
152
|
+
return diagnosticsSchema.parse(res);
|
|
161
153
|
}
|
|
162
154
|
}
|
|
163
155
|
export const parseCameraStreamResponse = (cameraStreamData) => {
|
package/esm/CamSwitcherAPI.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { AddNewClipError, JsonParseError, ParameterNotFoundError
|
|
2
|
+
import { AddNewClipError, JsonParseError, ParameterNotFoundError } from './errors/errors';
|
|
3
|
+
import { parseBitrateOptionsToVapixParams, parseVapixParamsToBitrateOptions } from './internal/convertors';
|
|
3
4
|
import { isClip, isNullish } from './internal/utils';
|
|
4
|
-
import { storageInfoListSchema, outputInfoSchema, audioPushInfoSchema, clipListSchema, playlistQueueSchema, streamSaveLoadSchema, clipSaveLoadSchema, playlistSaveLoadSchema, trackerSaveLoadSchema, secondaryAudioSettingsSchema, globalAudioSettingsSchema, } from './types/CamSwitcherAPI';
|
|
5
|
+
import { storageInfoListSchema, outputInfoSchema, audioPushInfoSchema, clipListSchema, playlistQueueSchema, streamSaveLoadSchema, clipSaveLoadSchema, playlistSaveLoadSchema, trackerSaveLoadSchema, secondaryAudioSettingsSchema, globalAudioSettingsSchema, clipFilesListSchema, } from './types/CamSwitcherAPI';
|
|
5
6
|
import { networkCameraListSchema, } from './types/common';
|
|
6
7
|
import { VapixAPI } from './VapixAPI';
|
|
7
|
-
import {
|
|
8
|
-
import { FIRMWARE_WITH_BITRATE_MODES_SUPPORT } from './internal/constants';
|
|
9
|
-
import { ProxyClient } from './internal/ProxyClient';
|
|
8
|
+
import { BasicAPI } from './internal/BasicAPI';
|
|
10
9
|
const BASE_PATH = '/local/camswitcher/api';
|
|
11
|
-
export class CamSwitcherAPI {
|
|
12
|
-
client;
|
|
10
|
+
export class CamSwitcherAPI extends BasicAPI {
|
|
13
11
|
CustomFormData;
|
|
14
12
|
vapixAgent;
|
|
15
13
|
constructor(client, CustomFormData = FormData) {
|
|
16
|
-
|
|
14
|
+
super(client);
|
|
17
15
|
this.CustomFormData = CustomFormData;
|
|
18
16
|
this.vapixAgent = new VapixAPI(client);
|
|
19
17
|
}
|
|
20
18
|
static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
|
|
21
19
|
static getWsEventsPath = () => `/local/camswitcher/events`;
|
|
22
20
|
static getClipPreviewPath = (clipId, storage) => `${BASE_PATH}/clip_preview.cgi?clip_name=${clipId}&storage=${storage}`;
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
async checkAPIAvailable(options) {
|
|
22
|
+
await this._getJson(`${BASE_PATH}/api_check.cgi`, undefined, options);
|
|
25
23
|
}
|
|
26
24
|
async checkCameraTime(options) {
|
|
27
25
|
const res = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
|
|
@@ -136,7 +134,13 @@ export class CamSwitcherAPI {
|
|
|
136
134
|
return clipListSchema.parse(res.data).clip_list;
|
|
137
135
|
}
|
|
138
136
|
setCamSwitchOptions(data, cameraFWVersion, options) {
|
|
139
|
-
const
|
|
137
|
+
const bitrateData = {
|
|
138
|
+
bitrateMode: data.bitrateMode,
|
|
139
|
+
maximumBitRate: data.maximumBitRate,
|
|
140
|
+
retentionTime: data.retentionTime,
|
|
141
|
+
bitRateLimit: data.bitRateLimit,
|
|
142
|
+
};
|
|
143
|
+
const bitrateVapixParams = parseBitrateOptionsToVapixParams(cameraFWVersion, data.bitrateMode, bitrateData);
|
|
140
144
|
const saveData = {
|
|
141
145
|
video: {
|
|
142
146
|
resolution: data.resolution,
|
|
@@ -253,25 +257,8 @@ export class CamSwitcherAPI {
|
|
|
253
257
|
const res = await this.vapixAgent.getParameter([paramName], options);
|
|
254
258
|
return z.string().parse(res[paramName] ?? '');
|
|
255
259
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
259
|
-
if (res.ok) {
|
|
260
|
-
return await res.json();
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
throw new ErrorWithResponse(res);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
async _post(path, data, parameters, options, headers) {
|
|
267
|
-
const agent = this.getClient(options?.proxyParams);
|
|
268
|
-
const res = await agent.post({ path, data, parameters, timeout: options?.timeout, headers });
|
|
269
|
-
if (res.ok) {
|
|
270
|
-
return await res.json();
|
|
271
|
-
}
|
|
272
|
-
else {
|
|
273
|
-
throw new ErrorWithResponse(res);
|
|
274
|
-
}
|
|
260
|
+
downloadReport(options) {
|
|
261
|
+
return this._getText(`${BASE_PATH}/report.cgi`, undefined, options);
|
|
275
262
|
}
|
|
276
263
|
setParamFromCameraJSON(paramName, data, options) {
|
|
277
264
|
const params = {};
|
|
@@ -295,6 +282,20 @@ export class CamSwitcherAPI {
|
|
|
295
282
|
}
|
|
296
283
|
throw new ParameterNotFoundError(paramName);
|
|
297
284
|
}
|
|
285
|
+
async getUploadedFileList(clipName, storage, options) {
|
|
286
|
+
const res = await this._getJson(`${BASE_PATH}/clip_files.cgi`, { clip_name: clipName, storage }, options);
|
|
287
|
+
return clipFilesListSchema.parse(res).data.files;
|
|
288
|
+
}
|
|
289
|
+
async downloadClipFile(fileName, storage, options) {
|
|
290
|
+
return await this._getBlob(`${BASE_PATH}/clip_download_file.cgi`, { file_name: fileName, storage }, options);
|
|
291
|
+
}
|
|
292
|
+
async uploadClipFiles(files, storage, options) {
|
|
293
|
+
const formData = new FormData();
|
|
294
|
+
for (const file of files) {
|
|
295
|
+
formData.append(file.name, file);
|
|
296
|
+
}
|
|
297
|
+
await this._post(`${BASE_PATH}/clip_upload_file.cgi`, formData, { storage }, options);
|
|
298
|
+
}
|
|
298
299
|
}
|
|
299
300
|
const CSW_PARAM_NAMES = {
|
|
300
301
|
SETTINGS: 'Camswitcher.Settings',
|
|
@@ -303,62 +304,3 @@ const CSW_PARAM_NAMES = {
|
|
|
303
304
|
RTSP_TOKEN: 'Camswitcher.RTSPAccessToken',
|
|
304
305
|
DEFAULT_PLAYLIST: 'Camswitcher.DefaultPlaylist',
|
|
305
306
|
};
|
|
306
|
-
const parseBitrateOptionsToBitrateVapixParams = (firmWareVersion, bitrateMode, cameraOptions) => {
|
|
307
|
-
if (!isFirmwareVersionAtLeast(firmWareVersion, FIRMWARE_WITH_BITRATE_MODES_SUPPORT)) {
|
|
308
|
-
return `videomaxbitrate=${cameraOptions.maximumBitRate}`;
|
|
309
|
-
}
|
|
310
|
-
if (bitrateMode === undefined) {
|
|
311
|
-
return '';
|
|
312
|
-
}
|
|
313
|
-
const data = {
|
|
314
|
-
VBR: 'videobitratemode=vbr',
|
|
315
|
-
MBR: `videobitratemode=mbr&videomaxbitrate=${cameraOptions.maximumBitRate}`,
|
|
316
|
-
ABR: `videobitratemode=abr&videoabrtargetbitrate=${cameraOptions.maximumBitRate}&videoabrretentiontime=${cameraOptions.retentionTime}&videoabrmaxbitrate=${cameraOptions.bitRateLimit}`,
|
|
317
|
-
};
|
|
318
|
-
return data[bitrateMode];
|
|
319
|
-
};
|
|
320
|
-
const parseVapixParamsToBitrateOptions = (bitrateVapixParams) => {
|
|
321
|
-
const params = {};
|
|
322
|
-
const searchParams = new URLSearchParams(bitrateVapixParams);
|
|
323
|
-
searchParams.forEach((value, key) => {
|
|
324
|
-
params[key] = value;
|
|
325
|
-
});
|
|
326
|
-
const bitrateMode = params['videobitratemode'] !== undefined ? params['videobitratemode'].toUpperCase() : undefined;
|
|
327
|
-
const hasLowerFw = bitrateMode === undefined && params['videomaxbitrate'] !== undefined;
|
|
328
|
-
if (hasLowerFw) {
|
|
329
|
-
const maximumBitRate = parseInt(params['videomaxbitrate'] ?? '0', 10);
|
|
330
|
-
return {
|
|
331
|
-
bitrateMode: 'MBR',
|
|
332
|
-
maximumBitRate: maximumBitRate,
|
|
333
|
-
retentionTime: 1,
|
|
334
|
-
bitRateLimit: Math.floor(maximumBitRate * 1.1),
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
if (bitrateMode === 'ABR') {
|
|
338
|
-
const maximumBitRate = parseInt(params['videoabrtargetbitrate'] ?? '0', 10);
|
|
339
|
-
const retentionTime = parseInt(params['videoabrretentiontime'] ?? '0', 10);
|
|
340
|
-
const bitRateLimit = parseInt(params['videoabrmaxbitrate'] ?? '0', 10);
|
|
341
|
-
return {
|
|
342
|
-
bitrateMode,
|
|
343
|
-
maximumBitRate,
|
|
344
|
-
retentionTime,
|
|
345
|
-
bitRateLimit,
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
else if (bitrateMode === 'MBR') {
|
|
349
|
-
const maximumBitRate = params['videomaxbitrate'] !== undefined ? parseInt(params['videomaxbitrate'], 10) : null;
|
|
350
|
-
const oldMaximumBitrateParamValue = parseInt(params['videombrmaxbitrate'] ?? '0', 10);
|
|
351
|
-
return {
|
|
352
|
-
bitrateMode: bitrateMode,
|
|
353
|
-
maximumBitRate: maximumBitRate ?? oldMaximumBitrateParamValue,
|
|
354
|
-
retentionTime: 1,
|
|
355
|
-
bitRateLimit: Math.floor(maximumBitRate ?? oldMaximumBitrateParamValue * 1.1),
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
return {
|
|
359
|
-
bitrateMode: bitrateMode,
|
|
360
|
-
retentionTime: 1,
|
|
361
|
-
maximumBitRate: 0,
|
|
362
|
-
bitRateLimit: 0,
|
|
363
|
-
};
|
|
364
|
-
};
|
package/esm/PlaneTrackerAPI.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { paramToUrl } from './internal/utils';
|
|
3
2
|
import { blackListSchema, cameraSettingsSchema, flightInfoSchema, getIcaoSchema, mapInfoSchema, priorityListSchema, serverSettingsSchema, trackingModeSchema, typePriorityListSchema, whiteListSchema, wsAliasResponseSchema, zonesSchema, } from './types/PlaneTrackerAPI';
|
|
4
|
-
import { CannotSetCoordsInAutoModeError, ImportSettingsError, InvalidAltitudeError, InvalidLatLngError,
|
|
5
|
-
import { ProxyClient } from './internal/ProxyClient';
|
|
3
|
+
import { CannotSetCoordsInAutoModeError, ImportSettingsError, InvalidAltitudeError, InvalidLatLngError, ResetCalibrationError, ServerError, BadRequestError, } from './errors/errors';
|
|
6
4
|
import { cameraListSchema } from './types/GenetecAgent';
|
|
5
|
+
import { BasicAPI } from './internal/BasicAPI';
|
|
7
6
|
const BASE_PATH = '/local/planetracker';
|
|
8
|
-
export class PlaneTrackerAPI {
|
|
9
|
-
client;
|
|
7
|
+
export class PlaneTrackerAPI extends BasicAPI {
|
|
10
8
|
apiUser;
|
|
11
9
|
constructor(client, apiUser) {
|
|
12
|
-
|
|
10
|
+
super(client);
|
|
13
11
|
this.apiUser = apiUser;
|
|
14
12
|
}
|
|
15
13
|
static getProxyPath = () => `${BASE_PATH}/proxy.cgi`;
|
|
16
14
|
static getWsEventsPath = () => `${BASE_PATH}/package/ws`;
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
async checkAPIAvailable(options) {
|
|
16
|
+
await this._getJson(`${BASE_PATH}/api_check.cgi`, undefined, options);
|
|
19
17
|
}
|
|
20
18
|
async checkCameraTime(options) {
|
|
21
19
|
const res = await this._getJson(`${BASE_PATH}/camera_time.cgi`, undefined, options);
|
|
@@ -23,7 +21,11 @@ export class PlaneTrackerAPI {
|
|
|
23
21
|
}
|
|
24
22
|
async serverRunCheck(options) {
|
|
25
23
|
const agent = this.getClient(options?.proxyParams);
|
|
26
|
-
|
|
24
|
+
const res = await agent.get({
|
|
25
|
+
path: `${BASE_PATH}/package/serverRunCheck.cgi`,
|
|
26
|
+
timeout: options?.timeout,
|
|
27
|
+
});
|
|
28
|
+
return res.status === 200;
|
|
27
29
|
}
|
|
28
30
|
async getLiveViewAlias(rtspUrl, options) {
|
|
29
31
|
const agent = this.getClient(options?.proxyParams);
|
|
@@ -61,7 +63,7 @@ export class PlaneTrackerAPI {
|
|
|
61
63
|
return cameraSettingsSchema.parse(res);
|
|
62
64
|
}
|
|
63
65
|
async setCameraSettings(settings, options) {
|
|
64
|
-
|
|
66
|
+
await this._postJsonEncoded(`${BASE_PATH}/package_camera_settings.cgi`, settings, {
|
|
65
67
|
action: 'set',
|
|
66
68
|
}, options);
|
|
67
69
|
}
|
|
@@ -120,28 +122,28 @@ export class PlaneTrackerAPI {
|
|
|
120
122
|
return priorityListSchema.parse(res).priorityList;
|
|
121
123
|
}
|
|
122
124
|
async setPriorityList(priorityList, options) {
|
|
123
|
-
|
|
125
|
+
await this._postJsonEncoded(`${BASE_PATH}/package/setPriorityList.cgi`, { priorityList }, this.apiUser, options);
|
|
124
126
|
}
|
|
125
127
|
async getTypePriorityList(options) {
|
|
126
128
|
const res = await this._getJson(`${BASE_PATH}/package/getTypePriorityList.cgi`, undefined, options);
|
|
127
129
|
return typePriorityListSchema.parse(res).typePriorityList;
|
|
128
130
|
}
|
|
129
131
|
async setTypePriorityList(typePriorityList, options) {
|
|
130
|
-
|
|
132
|
+
await this._postJsonEncoded(`${BASE_PATH}/package/setTypePriorityList.cgi`, { typePriorityList }, this.apiUser, options);
|
|
131
133
|
}
|
|
132
134
|
async getWhiteList(options) {
|
|
133
135
|
const res = await this._getJson(`${BASE_PATH}/package/getWhiteList.cgi`, undefined, options);
|
|
134
136
|
return whiteListSchema.parse(res).whiteList;
|
|
135
137
|
}
|
|
136
138
|
async setWhiteList(whiteList, options) {
|
|
137
|
-
|
|
139
|
+
await this._postJsonEncoded(`${BASE_PATH}/package/setWhiteList.cgi`, { whiteList }, this.apiUser, options);
|
|
138
140
|
}
|
|
139
141
|
async getBlackList(options) {
|
|
140
142
|
const res = await this._getJson(`${BASE_PATH}/package/getBlackList.cgi`, undefined, options);
|
|
141
143
|
return blackListSchema.parse(res).blackList;
|
|
142
144
|
}
|
|
143
145
|
async setBlackList(blackList, options) {
|
|
144
|
-
|
|
146
|
+
await this._postJsonEncoded(`${BASE_PATH}/package/setBlackList.cgi`, { blackList }, this.apiUser, options);
|
|
145
147
|
}
|
|
146
148
|
async fetchMapInfo(options) {
|
|
147
149
|
const res = await this._getJson(`${BASE_PATH}/package/getMapInfo.cgi`, undefined, options);
|
|
@@ -179,72 +181,15 @@ export class PlaneTrackerAPI {
|
|
|
179
181
|
}
|
|
180
182
|
}
|
|
181
183
|
}
|
|
184
|
+
downloadReport(options) {
|
|
185
|
+
return this._getText(`${BASE_PATH}/report.cgi`, undefined, options);
|
|
186
|
+
}
|
|
182
187
|
async checkGenetecConnection(params, options) {
|
|
183
|
-
|
|
188
|
+
const res = await this._postUrlEncoded(`${BASE_PATH}/package/checkGenetecConnection.cgi`, params, options);
|
|
189
|
+
return res.status === 200;
|
|
184
190
|
}
|
|
185
191
|
async getGenetecCameraList(params, options) {
|
|
186
192
|
const res = await this._postUrlEncoded(`${BASE_PATH}/package/getGenetecCameraList.cgi`, params, options);
|
|
187
193
|
return cameraListSchema.parse(await res.json());
|
|
188
194
|
}
|
|
189
|
-
async _getJson(path, parameters, options, headers) {
|
|
190
|
-
const agent = this.getClient(options?.proxyParams);
|
|
191
|
-
const res = await agent.get({ path, parameters, timeout: options?.timeout, headers });
|
|
192
|
-
if (res.ok) {
|
|
193
|
-
return await res.json();
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
throw new ErrorWithResponse(res);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
async _getBlob(path, parameters, options) {
|
|
200
|
-
const agent = this.getClient(options?.proxyParams);
|
|
201
|
-
const res = await agent.get({ path, parameters, timeout: options?.timeout });
|
|
202
|
-
if (res.ok) {
|
|
203
|
-
return await this.parseBlobResponse(res);
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
throw new ErrorWithResponse(res);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
async parseBlobResponse(response) {
|
|
210
|
-
try {
|
|
211
|
-
return (await response.blob());
|
|
212
|
-
}
|
|
213
|
-
catch (err) {
|
|
214
|
-
throw new ParsingBlobError(err);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
async _postJsonEncoded(path, data, parameters, options) {
|
|
218
|
-
const agent = this.getClient(options?.proxyParams);
|
|
219
|
-
const jsonData = JSON.stringify(data);
|
|
220
|
-
const res = await agent.post({
|
|
221
|
-
path,
|
|
222
|
-
data: jsonData,
|
|
223
|
-
parameters,
|
|
224
|
-
headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' },
|
|
225
|
-
timeout: options?.timeout,
|
|
226
|
-
});
|
|
227
|
-
if (res.ok) {
|
|
228
|
-
return res;
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
throw new ErrorWithResponse(res);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
async _postUrlEncoded(path, params, options) {
|
|
235
|
-
const data = paramToUrl(params);
|
|
236
|
-
const agent = this.getClient(options?.proxyParams);
|
|
237
|
-
const res = await agent.post({
|
|
238
|
-
path,
|
|
239
|
-
data,
|
|
240
|
-
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
241
|
-
timeout: options?.timeout,
|
|
242
|
-
});
|
|
243
|
-
if (res.ok) {
|
|
244
|
-
return res;
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
throw new ErrorWithResponse(res);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
195
|
}
|