camstreamerlib 4.0.0-beta.10 → 4.0.0-beta.11
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/cjs/CamOverlayAPI.d.ts +100 -100
- package/cjs/CamOverlayAPI.js +9 -10
- package/cjs/CamOverlayDrawingAPI.d.ts +1 -1
- package/cjs/CamScripterAPI.d.ts +2 -2
- package/cjs/CamScripterAPI.js +5 -5
- package/cjs/CamScripterAPICameraEventsGenerator.d.ts +1 -1
- package/cjs/CamStreamerAPI.d.ts +5 -5
- package/cjs/CamStreamerAPI.js +4 -10
- package/cjs/CamSwitcherAPI.d.ts +2 -2
- package/cjs/CamSwitcherAPI.js +9 -10
- package/cjs/CamSwitcherEvents.d.ts +1 -1
- package/cjs/VapixAPI.d.ts +11 -11
- package/cjs/VapixAPI.js +11 -12
- package/cjs/VapixEvents.d.ts +1 -1
- package/cjs/events/AxisCameraStationEvents.d.ts +3 -2
- package/cjs/events/AxisCameraStationEvents.js +7 -7
- package/cjs/events/GenetecAgent.js +11 -11
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/internal/ProxyClient.d.ts +4 -4
- package/cjs/internal/types.d.ts +35 -0
- package/cjs/internal/types.js +2 -0
- package/cjs/internal/utils.d.ts +5 -1
- package/cjs/internal/utils.js +26 -3
- package/cjs/internal/versionCompare.d.ts +2 -2
- package/cjs/models/CamOverlayAPI/accuweatherSchema.d.ts +8 -8
- package/cjs/models/CamOverlayAPI/customGraphicsSchema.d.ts +40 -40
- package/cjs/models/CamOverlayAPI/imagesSchema.d.ts +12 -12
- package/cjs/models/CamOverlayAPI/infotickerSchema.d.ts +12 -12
- package/cjs/models/CamOverlayAPI/pipSchema.d.ts +10 -10
- package/cjs/models/CamOverlayAPI/ptzCompassSchema.d.ts +8 -8
- package/cjs/models/CamOverlayAPI/ptzSchema.d.ts +15 -15
- package/cjs/models/CamOverlayAPI/screenSharingSchema.d.ts +10 -10
- package/cjs/models/CamOverlayAPI/webCameraSharingSchema.d.ts +10 -10
- package/cjs/models/CamOverlayAPI/widgetCommonSchema.d.ts +16 -16
- package/cjs/models/CamOverlayAPI/widgetsSchema.d.ts +320 -320
- package/cjs/node/DefaultClient.d.ts +5 -4
- package/cjs/node/DefaultClient.js +4 -2
- package/cjs/node/WsClient.d.ts +1 -1
- package/cjs/node/WsEventClient.d.ts +1 -1
- package/cjs/types/CamOverlayAPI.d.ts +48 -48
- package/cjs/types/CamScripterAPI.d.ts +1 -1
- package/cjs/types/CamStreamerAPI.d.ts +1 -1
- package/cjs/types/CamSwitcherAPI.d.ts +49 -49
- package/cjs/types/VapixAPI.d.ts +85 -85
- package/cjs/types/common.d.ts +2 -2
- package/cjs/web/DefaultClient.d.ts +5 -4
- package/cjs/web/DefaultClient.js +4 -2
- package/esm/CamOverlayAPI.d.ts +100 -100
- package/esm/CamOverlayAPI.js +2 -3
- package/esm/CamOverlayDrawingAPI.d.ts +1 -1
- package/esm/CamScripterAPI.d.ts +2 -2
- package/esm/CamScripterAPI.js +1 -1
- package/esm/CamScripterAPICameraEventsGenerator.d.ts +1 -1
- package/esm/CamStreamerAPI.d.ts +5 -5
- package/esm/CamStreamerAPI.js +4 -10
- package/esm/CamSwitcherAPI.d.ts +2 -2
- package/esm/CamSwitcherAPI.js +1 -2
- package/esm/CamSwitcherEvents.d.ts +1 -1
- package/esm/VapixAPI.d.ts +11 -11
- package/esm/VapixAPI.js +1 -2
- package/esm/VapixEvents.d.ts +1 -1
- package/esm/events/AxisCameraStationEvents.d.ts +3 -2
- package/esm/events/AxisCameraStationEvents.js +1 -1
- package/esm/events/GenetecAgent.js +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/internal/ProxyClient.d.ts +4 -4
- package/esm/internal/types.d.ts +35 -0
- package/esm/internal/types.js +1 -0
- package/esm/internal/utils.d.ts +5 -1
- package/esm/internal/utils.js +20 -1
- package/esm/internal/versionCompare.d.ts +2 -2
- package/esm/models/CamOverlayAPI/accuweatherSchema.d.ts +8 -8
- package/esm/models/CamOverlayAPI/customGraphicsSchema.d.ts +40 -40
- package/esm/models/CamOverlayAPI/imagesSchema.d.ts +12 -12
- package/esm/models/CamOverlayAPI/infotickerSchema.d.ts +12 -12
- package/esm/models/CamOverlayAPI/pipSchema.d.ts +10 -10
- package/esm/models/CamOverlayAPI/ptzCompassSchema.d.ts +8 -8
- package/esm/models/CamOverlayAPI/ptzSchema.d.ts +15 -15
- package/esm/models/CamOverlayAPI/screenSharingSchema.d.ts +10 -10
- package/esm/models/CamOverlayAPI/webCameraSharingSchema.d.ts +10 -10
- package/esm/models/CamOverlayAPI/widgetCommonSchema.d.ts +16 -16
- package/esm/models/CamOverlayAPI/widgetsSchema.d.ts +320 -320
- package/esm/node/DefaultClient.d.ts +5 -4
- package/esm/node/DefaultClient.js +4 -2
- package/esm/node/WsClient.d.ts +1 -1
- package/esm/node/WsEventClient.d.ts +1 -1
- package/esm/types/CamOverlayAPI.d.ts +48 -48
- package/esm/types/CamScripterAPI.d.ts +1 -1
- package/esm/types/CamStreamerAPI.d.ts +1 -1
- package/esm/types/CamSwitcherAPI.d.ts +49 -49
- package/esm/types/VapixAPI.d.ts +85 -85
- package/esm/types/common.d.ts +2 -2
- package/esm/web/DefaultClient.d.ts +5 -4
- package/esm/web/DefaultClient.js +4 -2
- package/package.json +1 -1
- package/cjs/internal/common.d.ts +0 -34
- package/cjs/internal/common.js +0 -27
- package/esm/internal/common.d.ts +0 -34
- package/esm/internal/common.js +0 -20
package/cjs/CamScripterAPI.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CamOverlayAPI = void 0;
|
|
4
|
-
const
|
|
4
|
+
const utils_1 = require("./internal/utils");
|
|
5
5
|
const CamScripterAPI_1 = require("./types/CamScripterAPI");
|
|
6
|
-
const
|
|
6
|
+
const common_1 = require("./types/common");
|
|
7
7
|
class CamOverlayAPI {
|
|
8
8
|
client;
|
|
9
9
|
constructor(client) {
|
|
@@ -18,7 +18,7 @@ class CamOverlayAPI {
|
|
|
18
18
|
}
|
|
19
19
|
async getNetworkCameraList() {
|
|
20
20
|
const response = await this.get('/local/camscripter/network_camera_list.cgi');
|
|
21
|
-
return
|
|
21
|
+
return common_1.networkCameraListSchema.parse(response.camera_list);
|
|
22
22
|
}
|
|
23
23
|
async getPackageList() {
|
|
24
24
|
const data = await this.get('/local/camscripter/package/list.cgi');
|
|
@@ -48,7 +48,7 @@ class CamOverlayAPI {
|
|
|
48
48
|
return await res.json();
|
|
49
49
|
}
|
|
50
50
|
else {
|
|
51
|
-
throw new Error(await (0,
|
|
51
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
async post(path, data, params) {
|
|
@@ -57,7 +57,7 @@ class CamOverlayAPI {
|
|
|
57
57
|
return await res.json();
|
|
58
58
|
}
|
|
59
59
|
else {
|
|
60
|
-
throw new Error(await (0,
|
|
60
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as EventEmitter from 'events';
|
|
3
|
-
import { WsOptions } from './internal/
|
|
3
|
+
import { WsOptions } from './internal/types';
|
|
4
4
|
export type CamScripterOptions = WsOptions;
|
|
5
5
|
export type TDeclaration = {
|
|
6
6
|
type?: '' | 'SOURCE' | 'DATA';
|
package/cjs/CamStreamerAPI.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { IClient } from './internal/
|
|
2
|
-
import {
|
|
3
|
-
export declare class CamStreamerAPI {
|
|
4
|
-
|
|
5
|
-
constructor(
|
|
1
|
+
import { IClient, TResponse } from './internal/types';
|
|
2
|
+
import { TStreamAttributes, TStreamList } from './types/CamStreamerAPI';
|
|
3
|
+
export declare class CamStreamerAPI<Client extends IClient<TResponse>> {
|
|
4
|
+
client: Client;
|
|
5
|
+
constructor(client: Client);
|
|
6
6
|
getStreamList(): Promise<TStreamList>;
|
|
7
7
|
getStream(streamID: string): Promise<TStreamAttributes>;
|
|
8
8
|
getStreamParameter(streamID: string, paramName: string): Promise<string>;
|
package/cjs/CamStreamerAPI.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CamStreamerAPI = void 0;
|
|
4
|
-
const
|
|
5
|
-
const DefaultClient_1 = require("./node/DefaultClient");
|
|
4
|
+
const utils_1 = require("./internal/utils");
|
|
6
5
|
const CamStreamerAPI_1 = require("./types/CamStreamerAPI");
|
|
7
6
|
class CamStreamerAPI {
|
|
8
7
|
client;
|
|
9
|
-
constructor(
|
|
10
|
-
|
|
11
|
-
this.client = options;
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
this.client = new DefaultClient_1.DefaultClient(options);
|
|
15
|
-
}
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
16
10
|
}
|
|
17
11
|
async getStreamList() {
|
|
18
12
|
const streamListRes = await this.get('/local/camstreamer/stream/list.cgi');
|
|
@@ -58,7 +52,7 @@ class CamStreamerAPI {
|
|
|
58
52
|
return await res.json();
|
|
59
53
|
}
|
|
60
54
|
else {
|
|
61
|
-
throw new Error(await (0,
|
|
55
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
62
56
|
}
|
|
63
57
|
}
|
|
64
58
|
}
|
package/cjs/CamSwitcherAPI.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IClient } from './internal/
|
|
1
|
+
import { IClient, TResponse } from './internal/types';
|
|
2
2
|
import { TAudioPushInfo, TOutputInfo, TStorageInfo, TStreamSaveList, TClipList, TStreamSaveLoadList, TClipSaveLoadList, TPlaylistSaveLoadList, TTrackerSaveList, TrackerSaveLoadList, TClipSaveList, TPlaylistSaveList, TCameraOptions, TGlobalAudioSettings, TSecondaryAudioSettings } from './types/CamSwitcherAPI';
|
|
3
3
|
import { TAudioChannel, TNetworkCamera, TStorageType } from './types/common';
|
|
4
|
-
export declare class CamSwitcherAPI<Client extends IClient = IClient
|
|
4
|
+
export declare class CamSwitcherAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
5
5
|
client: Client;
|
|
6
6
|
private CustomFormData;
|
|
7
7
|
private vapixAgent;
|
package/cjs/CamSwitcherAPI.js
CHANGED
|
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CamSwitcherAPI = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const errors_1 = require("./errors/errors");
|
|
6
|
-
const
|
|
6
|
+
const utils_1 = require("./internal/utils");
|
|
7
7
|
const CamSwitcherAPI_1 = require("./types/CamSwitcherAPI");
|
|
8
|
-
const
|
|
8
|
+
const common_1 = require("./types/common");
|
|
9
9
|
const VapixAPI_1 = require("./VapixAPI");
|
|
10
10
|
const versionCompare_1 = require("./internal/versionCompare");
|
|
11
|
-
const utils_1 = require("./internal/utils");
|
|
12
11
|
const constants_1 = require("./internal/constants");
|
|
13
12
|
const baseUrl = '/local/camswitcher/api';
|
|
14
13
|
class CamSwitcherAPI {
|
|
@@ -35,7 +34,7 @@ class CamSwitcherAPI {
|
|
|
35
34
|
}
|
|
36
35
|
async getIpListFromNetworkCheck() {
|
|
37
36
|
const data = await this.get(`${baseUrl}/network_camera_list.cgi`);
|
|
38
|
-
return
|
|
37
|
+
return common_1.networkCameraListSchema.parse(data);
|
|
39
38
|
}
|
|
40
39
|
async getMaxFps(source) {
|
|
41
40
|
const data = await this.get(`${baseUrl}/get_max_framerate.cgi`, {
|
|
@@ -182,21 +181,21 @@ class CamSwitcherAPI {
|
|
|
182
181
|
}
|
|
183
182
|
async getCamSwitchOptions() {
|
|
184
183
|
const saveData = await this.getParamFromCameraAndJSONParse(CSW_PARAM_NAMES.SETTINGS);
|
|
185
|
-
if ((0,
|
|
184
|
+
if ((0, utils_1.isNullish)(saveData.video)) {
|
|
186
185
|
return saveData;
|
|
187
186
|
}
|
|
188
|
-
if (!(0,
|
|
187
|
+
if (!(0, utils_1.isNullish)(saveData.video?.bitrateVapixParams)) {
|
|
189
188
|
const bitrateOptions = parseVapixParamsToBitrateOptions(saveData.video.bitrateVapixParams);
|
|
190
189
|
saveData.video.bitrateMode = bitrateOptions.bitrateMode;
|
|
191
190
|
saveData.video.maximumBitRate = bitrateOptions.maximumBitRate;
|
|
192
191
|
saveData.video.retentionTime = bitrateOptions.retentionTime;
|
|
193
192
|
saveData.video.bitRateLimit = bitrateOptions.bitRateLimit;
|
|
194
193
|
}
|
|
195
|
-
if (!(0,
|
|
194
|
+
if (!(0, utils_1.isNullish)(saveData.video?.bitrateLimit)) {
|
|
196
195
|
saveData.video.maximumBitRate = saveData.video.bitrateLimit;
|
|
197
196
|
saveData.video.bitrateMode = 'MBR';
|
|
198
197
|
}
|
|
199
|
-
if (!(0,
|
|
198
|
+
if (!(0, utils_1.isNullish)(saveData.video?.videoClipQuality)) {
|
|
200
199
|
saveData.video.maximumBitRate = saveData.video.videoClipQuality;
|
|
201
200
|
}
|
|
202
201
|
return {
|
|
@@ -247,7 +246,7 @@ class CamSwitcherAPI {
|
|
|
247
246
|
return d.data;
|
|
248
247
|
}
|
|
249
248
|
else {
|
|
250
|
-
throw new Error(await (0,
|
|
249
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
251
250
|
}
|
|
252
251
|
}
|
|
253
252
|
async set(path, data, parameters = {}) {
|
|
@@ -257,7 +256,7 @@ class CamSwitcherAPI {
|
|
|
257
256
|
return parsed.message === 'OK';
|
|
258
257
|
}
|
|
259
258
|
else {
|
|
260
|
-
throw new Error(await (0,
|
|
259
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
261
260
|
}
|
|
262
261
|
}
|
|
263
262
|
setParamFromCameraJSON(paramName, data) {
|
|
@@ -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 {
|
package/cjs/VapixAPI.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { IClient, TParameters } from './internal/
|
|
1
|
+
import { IClient, TParameters, TResponse } from './internal/types';
|
|
2
2
|
import { TAudioSampleRates, TSDCardInfo, TPtzOverview, TCameraPTZItem, TCameraPTZItemData, TAudioDevice } from './types/VapixAPI';
|
|
3
3
|
import { ProxyClient } from './internal/ProxyClient';
|
|
4
4
|
import { TCameraImageConfig, TProxyParam } from './types/common';
|
|
5
|
-
export declare class VapixAPI<Client extends IClient = IClient
|
|
5
|
+
export declare class VapixAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
6
6
|
client: ProxyClient<Client>;
|
|
7
7
|
constructor(client: Client, getProxyUrl: () => string);
|
|
8
|
-
getUrlEncoded(proxy: TProxyParam, path: string, parameters?: TParameters, headers?: Record<string, string>): Promise<
|
|
9
|
-
postJson(proxy: TProxyParam, path: string, jsonData: Record<string, any>, headers?: Record<string, string>): Promise<
|
|
10
|
-
getCameraImage(params: TCameraImageConfig, proxy?: TProxyParam): Promise<
|
|
8
|
+
getUrlEncoded(proxy: TProxyParam, path: string, parameters?: TParameters, headers?: Record<string, string>): Promise<TResponse>;
|
|
9
|
+
postJson(proxy: TProxyParam, path: string, jsonData: Record<string, any>, headers?: Record<string, string>): Promise<TResponse>;
|
|
10
|
+
getCameraImage(params: TCameraImageConfig, proxy?: TProxyParam): Promise<TResponse>;
|
|
11
11
|
getEventDeclarations(proxy?: TProxyParam): Promise<string>;
|
|
12
12
|
getSupportedAudioSampleRate(proxy?: TProxyParam): Promise<TAudioSampleRates[]>;
|
|
13
13
|
performAutofocus(proxy?: TProxyParam): Promise<void>;
|
|
@@ -16,8 +16,8 @@ export declare class VapixAPI<Client extends IClient = IClient> {
|
|
|
16
16
|
unmountSDCard(proxy?: TProxyParam): Promise<number>;
|
|
17
17
|
private _doSDCardMountAction;
|
|
18
18
|
fetchSDCardJobProgress(jobId: number, proxy?: TProxyParam): Promise<number>;
|
|
19
|
-
downloadCameraReport(proxy?: TProxyParam): Promise<
|
|
20
|
-
getSystemLog(proxy?: TProxyParam): Promise<
|
|
19
|
+
downloadCameraReport(proxy?: TProxyParam): Promise<TResponse>;
|
|
20
|
+
getSystemLog(proxy?: TProxyParam): Promise<TResponse>;
|
|
21
21
|
getMaxFps(channel: number, proxy?: TProxyParam): Promise<number>;
|
|
22
22
|
getTimezone(proxy?: TProxyParam): Promise<string>;
|
|
23
23
|
getDateTimeInfo(proxy?: TProxyParam): Promise<{
|
|
@@ -32,12 +32,12 @@ export declare class VapixAPI<Client extends IClient = IClient> {
|
|
|
32
32
|
getDevicesSettings(proxy?: TProxyParam): Promise<TAudioDevice[]>;
|
|
33
33
|
fetchRemoteDeviceInfo<T extends Record<string, any>>(payload: T, proxy?: TProxyParam): Promise<any>;
|
|
34
34
|
getHeaders(proxy?: TProxyParam): Promise<Record<string, string>>;
|
|
35
|
-
setHeaders(headers: Record<string, string>, proxy?: TProxyParam): Promise<
|
|
35
|
+
setHeaders(headers: Record<string, string>, proxy?: TProxyParam): Promise<TResponse>;
|
|
36
36
|
getParameter(paramNames: string | string[], proxy?: TProxyParam): Promise<Record<string, string>>;
|
|
37
37
|
setParameter(params: Record<string, string | number | boolean>, proxy?: TProxyParam): Promise<boolean>;
|
|
38
38
|
getGuardTourList(proxy?: TProxyParam): Promise<{
|
|
39
|
-
id: string;
|
|
40
39
|
name: string;
|
|
40
|
+
id: string;
|
|
41
41
|
running: string;
|
|
42
42
|
tour: {
|
|
43
43
|
moveSpeed?: unknown;
|
|
@@ -54,10 +54,10 @@ export declare class VapixAPI<Client extends IClient = IClient> {
|
|
|
54
54
|
getPTZPresetList(channel: number, proxy?: TProxyParam): Promise<string[]>;
|
|
55
55
|
listPTZ(camera: number, proxy?: TProxyParam): Promise<TCameraPTZItem[]>;
|
|
56
56
|
listPtzVideoSourceOverview(proxy?: TProxyParam): Promise<TPtzOverview>;
|
|
57
|
-
goToPreset(channel: number, presetName: string, proxy?: TProxyParam): Promise<
|
|
57
|
+
goToPreset(channel: number, presetName: string, proxy?: TProxyParam): Promise<TResponse>;
|
|
58
58
|
getPtzPosition(camera: number, proxy?: TProxyParam): Promise<TCameraPTZItemData>;
|
|
59
59
|
getInputState(port: number, proxy?: TProxyParam): Promise<boolean>;
|
|
60
|
-
setOutputState(port: number, active: boolean, proxy?: TProxyParam): Promise<
|
|
60
|
+
setOutputState(port: number, active: boolean, proxy?: TProxyParam): Promise<TResponse>;
|
|
61
61
|
getApplicationList(proxy?: TProxyParam): Promise<{
|
|
62
62
|
appId: "CamStreamer" | "CamSwitcher" | "CamOverlay" | "CamScripter" | "PlaneTracker" | "Ndihxplugin" | "SportTracker" | null;
|
|
63
63
|
Name: string;
|
package/cjs/VapixAPI.js
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VapixAPI = void 0;
|
|
4
4
|
const prettifyXml = require("prettify-xml");
|
|
5
|
-
const
|
|
5
|
+
const utils_1 = require("./internal/utils");
|
|
6
6
|
const VapixAPI_1 = require("./types/VapixAPI");
|
|
7
7
|
const errors_1 = require("./errors/errors");
|
|
8
8
|
const ProxyClient_1 = require("./internal/ProxyClient");
|
|
9
|
-
const utils_1 = require("./internal/utils");
|
|
10
9
|
const zod_1 = require("zod");
|
|
11
10
|
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
12
11
|
class VapixAPI {
|
|
@@ -19,7 +18,7 @@ class VapixAPI {
|
|
|
19
18
|
const head = { ...headers, 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
20
19
|
const res = await this.client.post(proxy, path, data, {}, head);
|
|
21
20
|
if (!res.ok) {
|
|
22
|
-
throw new Error(await (0,
|
|
21
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
23
22
|
}
|
|
24
23
|
return res;
|
|
25
24
|
}
|
|
@@ -28,7 +27,7 @@ class VapixAPI {
|
|
|
28
27
|
const head = { ...headers, 'Content-Type': 'application/json' };
|
|
29
28
|
const res = await this.client.post(proxy, path, data, {}, head);
|
|
30
29
|
if (!res.ok) {
|
|
31
|
-
throw new Error(await (0,
|
|
30
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
32
31
|
}
|
|
33
32
|
return res;
|
|
34
33
|
}
|
|
@@ -44,7 +43,7 @@ class VapixAPI {
|
|
|
44
43
|
'</s:Envelope>';
|
|
45
44
|
const res = await this.client.post(proxy, '/vapix/services', data, { 'Content-Type': 'application/soap+xml' });
|
|
46
45
|
if (!res.ok) {
|
|
47
|
-
throw new Error(await (0,
|
|
46
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
48
47
|
}
|
|
49
48
|
const declarations = await res.text();
|
|
50
49
|
return prettifyXml(declarations);
|
|
@@ -122,7 +121,7 @@ class VapixAPI {
|
|
|
122
121
|
const result = parser.parse(textXml);
|
|
123
122
|
const job = result.root.job;
|
|
124
123
|
if (job.result !== 'OK') {
|
|
125
|
-
throw new errors_1.SDCardActionError(action, await (0,
|
|
124
|
+
throw new errors_1.SDCardActionError(action, await (0, utils_1.responseStringify)(res));
|
|
126
125
|
}
|
|
127
126
|
return Number(job.jobid);
|
|
128
127
|
}
|
|
@@ -166,7 +165,7 @@ class VapixAPI {
|
|
|
166
165
|
if (captureMode === undefined) {
|
|
167
166
|
throw new errors_1.MaxFPSError('CAPTURE_MODE_NOT_FOUND');
|
|
168
167
|
}
|
|
169
|
-
if ((0,
|
|
168
|
+
if ((0, utils_1.isNullish)(captureMode.maxFPS)) {
|
|
170
169
|
throw new errors_1.MaxFPSError('FPS_NOT_SPECIFIED');
|
|
171
170
|
}
|
|
172
171
|
return captureMode.maxFPS;
|
|
@@ -200,7 +199,7 @@ class VapixAPI {
|
|
|
200
199
|
allowBooleanAttributes: true,
|
|
201
200
|
});
|
|
202
201
|
const result = parser.parse(textXml);
|
|
203
|
-
if ((0,
|
|
202
|
+
if ((0, utils_1.isNullish)(result.body.data)) {
|
|
204
203
|
throw new errors_1.NoDeviceInfoError();
|
|
205
204
|
}
|
|
206
205
|
return result.data;
|
|
@@ -373,7 +372,7 @@ class VapixAPI {
|
|
|
373
372
|
});
|
|
374
373
|
const text = (await res.text()).trim().toLowerCase();
|
|
375
374
|
if (text !== 'ok' && !(text.startsWith('error:') && text.substring(7) === '6')) {
|
|
376
|
-
throw new errors_1.ApplicationAPIError('START', await (0,
|
|
375
|
+
throw new errors_1.ApplicationAPIError('START', await (0, utils_1.responseStringify)(res));
|
|
377
376
|
}
|
|
378
377
|
}
|
|
379
378
|
async restartApplication(applicationID, proxy = null) {
|
|
@@ -383,7 +382,7 @@ class VapixAPI {
|
|
|
383
382
|
});
|
|
384
383
|
const text = (await res.text()).trim().toLowerCase();
|
|
385
384
|
if (text !== 'ok') {
|
|
386
|
-
throw new errors_1.ApplicationAPIError('RESTART', await (0,
|
|
385
|
+
throw new errors_1.ApplicationAPIError('RESTART', await (0, utils_1.responseStringify)(res));
|
|
387
386
|
}
|
|
388
387
|
}
|
|
389
388
|
async stopApplication(applicationID, proxy = null) {
|
|
@@ -393,7 +392,7 @@ class VapixAPI {
|
|
|
393
392
|
});
|
|
394
393
|
const text = (await res.text()).trim().toLowerCase();
|
|
395
394
|
if (text !== 'ok' && !(text.startsWith('error:') && text.substring(7) === '6')) {
|
|
396
|
-
throw new errors_1.ApplicationAPIError('STOP', await (0,
|
|
395
|
+
throw new errors_1.ApplicationAPIError('STOP', await (0, utils_1.responseStringify)(res));
|
|
397
396
|
}
|
|
398
397
|
}
|
|
399
398
|
async installApplication(data, fileName) {
|
|
@@ -403,7 +402,7 @@ class VapixAPI {
|
|
|
403
402
|
contentType: 'application/octet-stream',
|
|
404
403
|
});
|
|
405
404
|
if (!res.ok) {
|
|
406
|
-
throw new Error(await (0,
|
|
405
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
407
406
|
}
|
|
408
407
|
const text = await res.text();
|
|
409
408
|
if (text.length > 5) {
|
package/cjs/VapixEvents.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { IClient, HttpOptions } from '../internal/
|
|
1
|
+
import { IClient, HttpOptions } from '../internal/types';
|
|
2
|
+
import { Response } from 'undici';
|
|
2
3
|
export type AcsEventsOptions = HttpOptions;
|
|
3
4
|
export declare class AxisCameraStationEvents {
|
|
4
5
|
private sourceKey;
|
|
5
6
|
private client;
|
|
6
|
-
constructor(sourceKey: string, opt?: AcsEventsOptions | IClient);
|
|
7
|
+
constructor(sourceKey: string, opt?: AcsEventsOptions | IClient<Response>);
|
|
7
8
|
sendEvent(data: Record<string, string>, eventType: string): Promise<void>;
|
|
8
9
|
private getDate;
|
|
9
10
|
}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AxisCameraStationEvents = void 0;
|
|
4
4
|
const DefaultClient_1 = require("../node/DefaultClient");
|
|
5
|
-
const
|
|
5
|
+
const utils_1 = require("../internal/utils");
|
|
6
6
|
class AxisCameraStationEvents {
|
|
7
7
|
sourceKey;
|
|
8
8
|
client;
|
|
9
9
|
constructor(sourceKey, opt = {}) {
|
|
10
10
|
this.sourceKey = sourceKey;
|
|
11
|
-
if ((0,
|
|
11
|
+
if ((0, utils_1.isClient)(opt)) {
|
|
12
12
|
this.client = opt;
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
@@ -37,11 +37,11 @@ class AxisCameraStationEvents {
|
|
|
37
37
|
getDate() {
|
|
38
38
|
const date = new Date();
|
|
39
39
|
const year = date.getUTCFullYear();
|
|
40
|
-
const month = (0,
|
|
41
|
-
const day = (0,
|
|
42
|
-
const hours = (0,
|
|
43
|
-
const minutes = (0,
|
|
44
|
-
const seconds = (0,
|
|
40
|
+
const month = (0, utils_1.pad)(date.getUTCMonth() + 1, 2);
|
|
41
|
+
const day = (0, utils_1.pad)(date.getUTCDate(), 2);
|
|
42
|
+
const hours = (0, utils_1.pad)(date.getUTCHours(), 2);
|
|
43
|
+
const minutes = (0, utils_1.pad)(date.getUTCMinutes(), 2);
|
|
44
|
+
const seconds = (0, utils_1.pad)(date.getUTCSeconds(), 2);
|
|
45
45
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GenetecAgent = exports.cameraDetailsResponseSchema = exports.cameraDetailSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
5
|
+
const utils_1 = require("../internal/utils");
|
|
6
6
|
const ACTION = 'AddCameraBookmark';
|
|
7
7
|
const GET_CAMERAS_URL = 'report/EntityConfiguration?q=EntityTypes@Camera';
|
|
8
8
|
const GET_CAMERAS_DETAILS_URL = '/entity?q=';
|
|
@@ -49,7 +49,7 @@ class GenetecAgent {
|
|
|
49
49
|
const requestOptions = this.getRequestOptions('GET');
|
|
50
50
|
const res = await fetch(`${this.baseUrl}/`, requestOptions);
|
|
51
51
|
if (!res.ok) {
|
|
52
|
-
throw new Error(await (0,
|
|
52
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
53
53
|
}
|
|
54
54
|
return connectionResponseSchema.parse(await res.json());
|
|
55
55
|
}
|
|
@@ -57,7 +57,7 @@ class GenetecAgent {
|
|
|
57
57
|
const requestOptions = this.getRequestOptions('GET');
|
|
58
58
|
const res = await fetch(`${this.baseUrl}/${GET_CAMERAS_URL}`, requestOptions);
|
|
59
59
|
if (!res.ok) {
|
|
60
|
-
throw new Error(await (0,
|
|
60
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
61
61
|
}
|
|
62
62
|
return cameraGuidsResponseSchema.parse(await res.json());
|
|
63
63
|
}
|
|
@@ -77,7 +77,7 @@ class GenetecAgent {
|
|
|
77
77
|
}
|
|
78
78
|
const res = await fetch(`${this.baseUrl}/${GET_CAMERAS_DETAILS_URL}${camerasDetailsUrl.join(',')}`, requestOptions);
|
|
79
79
|
if (!res.ok) {
|
|
80
|
-
throw new Error(await (0,
|
|
80
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
81
81
|
}
|
|
82
82
|
const data = exports.cameraDetailsResponseSchema.parse(await res.json());
|
|
83
83
|
const resultArray = Array.isArray(data.Rsp.Result) ? data.Rsp.Result : [data.Rsp.Result];
|
|
@@ -94,7 +94,7 @@ class GenetecAgent {
|
|
|
94
94
|
}
|
|
95
95
|
const res = await fetch(`${this.baseUrl}/action?q=${cameraEntitiesUrl.join(',')}`, requestOptions);
|
|
96
96
|
if (!res.ok) {
|
|
97
|
-
throw new Error(await (0,
|
|
97
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
98
98
|
}
|
|
99
99
|
return res;
|
|
100
100
|
}
|
|
@@ -111,12 +111,12 @@ class GenetecAgent {
|
|
|
111
111
|
getTimeStamp() {
|
|
112
112
|
const date = new Date();
|
|
113
113
|
const year = date.getUTCFullYear();
|
|
114
|
-
const month = (0,
|
|
115
|
-
const day = (0,
|
|
116
|
-
const hours = (0,
|
|
117
|
-
const minutes = (0,
|
|
118
|
-
const seconds = (0,
|
|
119
|
-
const miliSeconds = (0,
|
|
114
|
+
const month = (0, utils_1.pad)(date.getUTCMonth() + 1, 2);
|
|
115
|
+
const day = (0, utils_1.pad)(date.getUTCDate(), 2);
|
|
116
|
+
const hours = (0, utils_1.pad)(date.getUTCHours(), 2);
|
|
117
|
+
const minutes = (0, utils_1.pad)(date.getUTCMinutes(), 2);
|
|
118
|
+
const seconds = (0, utils_1.pad)(date.getUTCSeconds(), 2);
|
|
119
|
+
const miliSeconds = (0, utils_1.pad)(date.getUTCMilliseconds(), 2);
|
|
120
120
|
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${miliSeconds}Z`;
|
|
121
121
|
}
|
|
122
122
|
}
|
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.CamOverlayAPI = exports.VapixAPI = exports.CamSwitcherEvents = exports.CamSwitcherAPI = void 0;
|
|
18
|
-
__exportStar(require("./internal/
|
|
18
|
+
__exportStar(require("./internal/types"), exports);
|
|
19
19
|
__exportStar(require("./internal/constants"), exports);
|
|
20
20
|
__exportStar(require("./internal/utils"), exports);
|
|
21
21
|
__exportStar(require("./internal/versionCompare"), exports);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { IClient } from './
|
|
2
|
+
import { IClient, TResponse } from './types';
|
|
3
3
|
import { TProxyParam } from '../types/common';
|
|
4
|
-
export declare class ProxyClient<Client extends IClient = IClient
|
|
4
|
+
export declare class ProxyClient<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
5
5
|
client: Client;
|
|
6
6
|
getProxyUrl: () => string;
|
|
7
7
|
constructor(client: Client, getProxyUrl: () => string);
|
|
8
|
-
get: (proxy: TProxyParam, url: string, parameters?: import("./
|
|
9
|
-
post: (proxy: TProxyParam, url: string, data: string | Buffer | FormData, parameters?: import("./
|
|
8
|
+
get: (proxy: TProxyParam, url: string, parameters?: import("./types").TParameters | undefined, headers?: Record<string, string> | undefined) => Promise<TResponse>;
|
|
9
|
+
post: (proxy: TProxyParam, url: string, data: string | Buffer | FormData, parameters?: import("./types").TParameters | undefined, headers?: Record<string, string> | undefined) => Promise<TResponse>;
|
|
10
10
|
private getReal;
|
|
11
11
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Response as UndiciResponse } from 'undici';
|
|
3
|
+
export type Options = {
|
|
4
|
+
ip?: string;
|
|
5
|
+
port?: number;
|
|
6
|
+
user?: string;
|
|
7
|
+
pass?: string;
|
|
8
|
+
tls?: boolean;
|
|
9
|
+
tlsInsecure?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type HttpOptions = Options & {
|
|
12
|
+
keepAlive?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type WsOptions = Options;
|
|
15
|
+
export type TParameters = Record<string, string | number | boolean | null | undefined>;
|
|
16
|
+
export type TResponse = Response | UndiciResponse;
|
|
17
|
+
export type TGetParams = [url: string, parameters?: TParameters, headers?: Record<string, string>];
|
|
18
|
+
export type TPostParams = [
|
|
19
|
+
url: string,
|
|
20
|
+
data: string | Buffer | FormData,
|
|
21
|
+
parameters?: TParameters,
|
|
22
|
+
headers?: Record<string, string>
|
|
23
|
+
];
|
|
24
|
+
export interface IClient<TRes extends TResponse> {
|
|
25
|
+
get: (...params: TGetParams) => Promise<TRes>;
|
|
26
|
+
post: (...params: TPostParams) => Promise<TRes>;
|
|
27
|
+
}
|
|
28
|
+
export type TBlobResponse<Client extends IClient<TResponse>> = Awaited<ReturnType<Awaited<ReturnType<Client['get']>>['blob']>>;
|
|
29
|
+
export interface IWebsocket<Event extends {
|
|
30
|
+
readonly data: string;
|
|
31
|
+
}> {
|
|
32
|
+
destroy: () => void;
|
|
33
|
+
onmessage: null | ((event: Event) => void);
|
|
34
|
+
send: (data: string) => void;
|
|
35
|
+
}
|
package/cjs/internal/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TPlaylistPlayType } from '../types/CamSwitcherAPI';
|
|
2
|
-
import { TParameters } from './
|
|
2
|
+
import { IClient, Options, TParameters, TResponse } from './types';
|
|
3
3
|
export declare const addParametersToPath: (path: string, params?: TParameters) => string;
|
|
4
4
|
export declare const paramToUrl: (params?: TParameters) => string;
|
|
5
5
|
export declare const arrayToUrl: (arr: string | string[]) => string;
|
|
@@ -9,3 +9,7 @@ export declare const isClip: (id?: string) => boolean;
|
|
|
9
9
|
export declare const isTracker: (id?: string) => boolean;
|
|
10
10
|
export declare const isPlaylist: (id?: string) => boolean;
|
|
11
11
|
export declare const isLoopPlayType: (playType: TPlaylistPlayType) => boolean;
|
|
12
|
+
export declare function isClient(arg?: Options | IClient<TResponse>): arg is IClient<TResponse>;
|
|
13
|
+
export declare function responseStringify(res: TResponse): Promise<string>;
|
|
14
|
+
export declare function pad(num: number, size: number): string;
|
|
15
|
+
export declare function isNullish<T>(value: T | undefined | null): value is undefined | null;
|
package/cjs/internal/utils.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isLoopPlayType = exports.isPlaylist = exports.isTracker = exports.isClip = exports.isStream = exports.isCamera = exports.arrayToUrl = exports.paramToUrl = exports.addParametersToPath = void 0;
|
|
4
|
-
const common_1 = require("./common");
|
|
3
|
+
exports.isNullish = exports.pad = exports.responseStringify = exports.isClient = exports.isLoopPlayType = exports.isPlaylist = exports.isTracker = exports.isClip = exports.isStream = exports.isCamera = exports.arrayToUrl = exports.paramToUrl = exports.addParametersToPath = void 0;
|
|
5
4
|
const addParametersToPath = (path, params) => {
|
|
6
5
|
if (params === undefined || Object.keys(params).length === 0) {
|
|
7
6
|
return path;
|
|
@@ -17,7 +16,7 @@ const paramToUrl = (params) => {
|
|
|
17
16
|
let output = '';
|
|
18
17
|
for (const key in params) {
|
|
19
18
|
const value = params[key];
|
|
20
|
-
if (
|
|
19
|
+
if (isNullish(value)) {
|
|
21
20
|
continue;
|
|
22
21
|
}
|
|
23
22
|
output += `${encodeURIComponent(key)}=${encodeURIComponent(value)}&`;
|
|
@@ -44,3 +43,27 @@ const isPlaylist = (id) => id?.charAt(0) === 'p';
|
|
|
44
43
|
exports.isPlaylist = isPlaylist;
|
|
45
44
|
const isLoopPlayType = (playType) => playType.includes('LOOP');
|
|
46
45
|
exports.isLoopPlayType = isLoopPlayType;
|
|
46
|
+
function isClient(arg = {}) {
|
|
47
|
+
return 'get' in arg && 'post' in arg;
|
|
48
|
+
}
|
|
49
|
+
exports.isClient = isClient;
|
|
50
|
+
async function responseStringify(res) {
|
|
51
|
+
return JSON.stringify({
|
|
52
|
+
status: res.status,
|
|
53
|
+
body: await res.text(),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.responseStringify = responseStringify;
|
|
57
|
+
function pad(num, size) {
|
|
58
|
+
const sign = Math.sign(num) === -1 ? '-' : '';
|
|
59
|
+
return (sign +
|
|
60
|
+
new Array(size)
|
|
61
|
+
.concat([Math.abs(num)])
|
|
62
|
+
.join('0')
|
|
63
|
+
.slice(-size));
|
|
64
|
+
}
|
|
65
|
+
exports.pad = pad;
|
|
66
|
+
function isNullish(value) {
|
|
67
|
+
return value === null || value === undefined;
|
|
68
|
+
}
|
|
69
|
+
exports.isNullish = isNullish;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const assertVersionString: (s: string, msg?: string) => void;
|
|
2
2
|
export declare const isFirmwareVersionAtLeast: (version: string, compareVersion: string) => boolean;
|
|
3
3
|
export declare const isVersionAtLeast: (version: string, compareVersion: string) => boolean;
|
|
4
|
-
export declare const firmwareVersionCompare: (a: string, b: string) =>
|
|
5
|
-
export declare const versionCompare: (a: string, b: string) =>
|
|
4
|
+
export declare const firmwareVersionCompare: (a: string, b: string) => 0 | 1 | -1;
|
|
5
|
+
export declare const versionCompare: (a: string, b: string) => 0 | 1 | -1;
|
|
6
6
|
export declare const fixVersionToDots: (version: string) => string;
|