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,78 @@
|
|
|
1
|
+
import { IClient, TParameters, TResponse } from './internal/types';
|
|
2
|
+
import { TAudioSampleRates, TSDCardInfo, TPtzOverview, TCameraPTZItem, TCameraPTZItemData, TAudioDevice } from './types/VapixAPI';
|
|
3
|
+
import { ProxyClient } from './internal/ProxyClient';
|
|
4
|
+
import { TCameraImageConfig, TProxyParam } from './types/common';
|
|
5
|
+
export declare class VapixAPI<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
6
|
+
client: ProxyClient<Client>;
|
|
7
|
+
constructor(client: Client, getProxyUrl: () => string);
|
|
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
|
+
getEventDeclarations(proxy?: TProxyParam): Promise<string>;
|
|
12
|
+
getSupportedAudioSampleRate(proxy?: TProxyParam): Promise<TAudioSampleRates[]>;
|
|
13
|
+
performAutofocus(proxy?: TProxyParam): Promise<void>;
|
|
14
|
+
checkSDCard(proxy?: TProxyParam): Promise<TSDCardInfo>;
|
|
15
|
+
mountSDCard(proxy?: TProxyParam): Promise<number>;
|
|
16
|
+
unmountSDCard(proxy?: TProxyParam): Promise<number>;
|
|
17
|
+
private _doSDCardMountAction;
|
|
18
|
+
fetchSDCardJobProgress(jobId: number, proxy?: TProxyParam): Promise<number>;
|
|
19
|
+
downloadCameraReport(proxy?: TProxyParam): Promise<TResponse>;
|
|
20
|
+
getSystemLog(proxy?: TProxyParam): Promise<TResponse>;
|
|
21
|
+
getMaxFps(channel: number, proxy?: TProxyParam): Promise<number>;
|
|
22
|
+
getTimezone(proxy?: TProxyParam): Promise<string>;
|
|
23
|
+
getDateTimeInfo(proxy?: TProxyParam): Promise<{
|
|
24
|
+
data: {
|
|
25
|
+
dateTime: string;
|
|
26
|
+
dstEnabled: boolean;
|
|
27
|
+
localDateTime: string;
|
|
28
|
+
posixTimeZone: string;
|
|
29
|
+
timeZone?: string | undefined;
|
|
30
|
+
};
|
|
31
|
+
}>;
|
|
32
|
+
getDevicesSettings(proxy?: TProxyParam): Promise<TAudioDevice[]>;
|
|
33
|
+
fetchRemoteDeviceInfo<T extends Record<string, any>>(payload: T, proxy?: TProxyParam): Promise<any>;
|
|
34
|
+
getHeaders(proxy?: TProxyParam): Promise<Record<string, string>>;
|
|
35
|
+
setHeaders(headers: Record<string, string>, proxy?: TProxyParam): Promise<TResponse>;
|
|
36
|
+
getParameter(paramNames: string | string[], proxy?: TProxyParam): Promise<Record<string, string>>;
|
|
37
|
+
setParameter(params: Record<string, string | number | boolean>, proxy?: TProxyParam): Promise<boolean>;
|
|
38
|
+
getGuardTourList(proxy?: TProxyParam): Promise<{
|
|
39
|
+
name: string;
|
|
40
|
+
id: string;
|
|
41
|
+
running: string;
|
|
42
|
+
tour: {
|
|
43
|
+
moveSpeed?: unknown;
|
|
44
|
+
position?: unknown;
|
|
45
|
+
presetNbr?: unknown;
|
|
46
|
+
waitTime?: unknown;
|
|
47
|
+
waitTimeViewType?: unknown;
|
|
48
|
+
}[];
|
|
49
|
+
camNbr?: unknown;
|
|
50
|
+
randomEnabled?: unknown;
|
|
51
|
+
timeBetweenSequences?: unknown;
|
|
52
|
+
}[]>;
|
|
53
|
+
setGuardTourEnabled(guardTourID: string, enable: boolean, proxy?: TProxyParam): Promise<boolean>;
|
|
54
|
+
getPTZPresetList(channel: number, proxy?: TProxyParam): Promise<string[]>;
|
|
55
|
+
listPTZ(camera: number, proxy?: TProxyParam): Promise<TCameraPTZItem[]>;
|
|
56
|
+
listPtzVideoSourceOverview(proxy?: TProxyParam): Promise<TPtzOverview>;
|
|
57
|
+
goToPreset(channel: number, presetName: string, proxy?: TProxyParam): Promise<TResponse>;
|
|
58
|
+
getPtzPosition(camera: number, proxy?: TProxyParam): Promise<TCameraPTZItemData>;
|
|
59
|
+
getInputState(port: number, proxy?: TProxyParam): Promise<boolean>;
|
|
60
|
+
setOutputState(port: number, active: boolean, proxy?: TProxyParam): Promise<TResponse>;
|
|
61
|
+
getApplicationList(proxy?: TProxyParam): Promise<{
|
|
62
|
+
appId: "CamStreamer" | "CamSwitcher" | "CamOverlay" | "CamScripter" | "PlaneTracker" | "Ndihxplugin" | "SportTracker" | null;
|
|
63
|
+
Name: string;
|
|
64
|
+
NiceName: string;
|
|
65
|
+
Vendor: string;
|
|
66
|
+
Version: string;
|
|
67
|
+
License: string;
|
|
68
|
+
Status: string;
|
|
69
|
+
ApplicationID?: string | undefined;
|
|
70
|
+
ConfigurationPage?: string | undefined;
|
|
71
|
+
VendorHomePage?: string | undefined;
|
|
72
|
+
LicenseName?: string | undefined;
|
|
73
|
+
}[]>;
|
|
74
|
+
startApplication(applicationID: string, proxy?: TProxyParam): Promise<void>;
|
|
75
|
+
restartApplication(applicationID: string, proxy?: TProxyParam): Promise<void>;
|
|
76
|
+
stopApplication(applicationID: string, proxy?: TProxyParam): Promise<void>;
|
|
77
|
+
installApplication(data: Blob, fileName: string): Promise<void>;
|
|
78
|
+
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import * as prettifyXml from 'prettify-xml';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { ApplicationAPIError, MaxFPSError, NoDeviceInfoError, SDCardActionError, SDCardJobError, } from './errors/errors';
|
|
2
|
+
import { arrayToUrl, isNullish, paramToUrl, responseStringify } from './internal/utils';
|
|
3
|
+
import { sdCardWatchedStatuses, APP_IDS, maxFpsResponseSchema, dateTimeinfoSchema, audioDeviceRequestSchema, audioSampleRatesResponseSchema, timeZoneSchema, } from './types/VapixAPI';
|
|
4
|
+
import { ApplicationAPIError, MaxFPSError, NoDeviceInfoError, PtzNotSupportedError, SDCardActionError, SDCardJobError, } from './errors/errors';
|
|
6
5
|
import { ProxyClient } from './internal/ProxyClient';
|
|
7
|
-
import { arrayToUrl, paramToUrl } from './internal/utils';
|
|
8
6
|
import { z } from 'zod';
|
|
7
|
+
import { XMLParser } from 'fast-xml-parser';
|
|
9
8
|
export class VapixAPI {
|
|
10
9
|
client;
|
|
11
10
|
constructor(client, getProxyUrl) {
|
|
12
11
|
this.client = new ProxyClient(client, getProxyUrl);
|
|
13
12
|
}
|
|
14
|
-
async getUrlEncoded(proxy
|
|
13
|
+
async getUrlEncoded(proxy, path, parameters, headers = {}) {
|
|
15
14
|
const data = paramToUrl(parameters);
|
|
16
15
|
const head = { ...headers, 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
17
16
|
const res = await this.client.post(proxy, path, data, {}, head);
|
|
@@ -20,7 +19,7 @@ export class VapixAPI {
|
|
|
20
19
|
}
|
|
21
20
|
return res;
|
|
22
21
|
}
|
|
23
|
-
async postJson(proxy
|
|
22
|
+
async postJson(proxy, path, jsonData, headers = {}) {
|
|
24
23
|
const data = JSON.stringify(jsonData);
|
|
25
24
|
const head = { ...headers, 'Content-Type': 'application/json' };
|
|
26
25
|
const res = await this.client.post(proxy, path, data, {}, head);
|
|
@@ -48,8 +47,8 @@ export class VapixAPI {
|
|
|
48
47
|
}
|
|
49
48
|
async getSupportedAudioSampleRate(proxy = null) {
|
|
50
49
|
const url = '/axis-cgi/audio/streamingcapabilities.cgi';
|
|
51
|
-
const
|
|
52
|
-
const res = await this.postJson(proxy, url,
|
|
50
|
+
const jsonData = { apiVersion: '1.0', method: 'list' };
|
|
51
|
+
const res = await this.postJson(proxy, url, jsonData);
|
|
53
52
|
const encoders = audioSampleRatesResponseSchema.parse(await res.json()).data.encoders;
|
|
54
53
|
const data = encoders.aac ?? encoders.AAC ?? [];
|
|
55
54
|
return data.map((item) => {
|
|
@@ -75,7 +74,7 @@ export class VapixAPI {
|
|
|
75
74
|
await this.postJson(proxy, '/axis-cgi/opticscontrol.cgi', data);
|
|
76
75
|
}
|
|
77
76
|
catch (err) {
|
|
78
|
-
await this.
|
|
77
|
+
await this.getUrlEncoded(proxy, '/axis-cgi/opticssetup.cgi', {
|
|
79
78
|
autofocus: 'perform',
|
|
80
79
|
source: '1',
|
|
81
80
|
});
|
|
@@ -85,11 +84,13 @@ export class VapixAPI {
|
|
|
85
84
|
const res = await this.getUrlEncoded(proxy, '/axis-cgi/disks/list.cgi', {
|
|
86
85
|
diskid: 'SD_DISK',
|
|
87
86
|
});
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
const xmlText = await res.text();
|
|
88
|
+
const parser = new XMLParser({
|
|
89
|
+
ignoreAttributes: false,
|
|
90
|
+
attributeNamePrefix: '',
|
|
91
|
+
allowBooleanAttributes: true,
|
|
92
92
|
});
|
|
93
|
+
const result = parser.parse(xmlText);
|
|
93
94
|
const data = result.root.disks.disk;
|
|
94
95
|
return {
|
|
95
96
|
totalSize: parseInt(data.totalsize),
|
|
@@ -108,11 +109,13 @@ export class VapixAPI {
|
|
|
108
109
|
action: action,
|
|
109
110
|
diskid: 'SD_DISK',
|
|
110
111
|
});
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
const textXml = await res.text();
|
|
113
|
+
const parser = new XMLParser({
|
|
114
|
+
ignoreAttributes: false,
|
|
115
|
+
attributeNamePrefix: '',
|
|
116
|
+
allowBooleanAttributes: true,
|
|
115
117
|
});
|
|
118
|
+
const result = parser.parse(textXml);
|
|
116
119
|
const job = result.root.job;
|
|
117
120
|
if (job.result !== 'OK') {
|
|
118
121
|
throw new SDCardActionError(action, await responseStringify(res));
|
|
@@ -124,12 +127,13 @@ export class VapixAPI {
|
|
|
124
127
|
jobid: String(jobId),
|
|
125
128
|
diskid: 'SD_DISK',
|
|
126
129
|
});
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
const textXml = await res.text();
|
|
131
|
+
const parser = new XMLParser({
|
|
132
|
+
ignoreAttributes: false,
|
|
133
|
+
attributeNamePrefix: '',
|
|
134
|
+
allowBooleanAttributes: true,
|
|
131
135
|
});
|
|
132
|
-
const job =
|
|
136
|
+
const job = parser.parse(textXml).root.job;
|
|
133
137
|
if (job.result !== 'OK') {
|
|
134
138
|
throw new SDCardJobError();
|
|
135
139
|
}
|
|
@@ -164,9 +168,27 @@ export class VapixAPI {
|
|
|
164
168
|
return captureMode.maxFPS;
|
|
165
169
|
}
|
|
166
170
|
async getTimezone(proxy = null) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
171
|
+
try {
|
|
172
|
+
const resV2 = await this.client.get(proxy, '/config/rest/time/v2/timeZone');
|
|
173
|
+
if (!resV2.ok) {
|
|
174
|
+
throw new Error(await responseStringify(resV2));
|
|
175
|
+
}
|
|
176
|
+
const json = await resV2.json();
|
|
177
|
+
const data = timeZoneSchema.parse(json);
|
|
178
|
+
if (data.status === 'error') {
|
|
179
|
+
throw new Error(data.error.message);
|
|
180
|
+
}
|
|
181
|
+
return data.data.activeTimeZone;
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
console.warn('Failed to fetch time zone data from time API v2:', error instanceof Error ? error.message : JSON.stringify(error));
|
|
185
|
+
console.warn('Falling back to deprecated time API v1');
|
|
186
|
+
}
|
|
187
|
+
const data = await this.getDateTimeInfo(proxy);
|
|
188
|
+
if (data.data.timeZone === undefined) {
|
|
189
|
+
throw new Error('Time zone not setup on the device');
|
|
190
|
+
}
|
|
191
|
+
return data.data.timeZone;
|
|
170
192
|
}
|
|
171
193
|
async getDateTimeInfo(proxy = null) {
|
|
172
194
|
const data = { apiVersion: '1.0', method: 'getDateTimeInfo' };
|
|
@@ -177,7 +199,7 @@ export class VapixAPI {
|
|
|
177
199
|
const data = { apiVersion: '1.0', method: 'getDevicesSettings' };
|
|
178
200
|
const res = await this.postJson(proxy, '/axis-cgi/audiodevicecontrol.cgi', data);
|
|
179
201
|
const result = audioDeviceRequestSchema.parse(await res.json());
|
|
180
|
-
return result.devices.map((device) => ({
|
|
202
|
+
return result.data.devices.map((device) => ({
|
|
181
203
|
...device,
|
|
182
204
|
inputs: (device.inputs || []).sort((a, b) => a.id.localeCompare(b.id)),
|
|
183
205
|
outputs: (device.outputs || []).sort((a, b) => a.id.localeCompare(b.id)),
|
|
@@ -185,15 +207,11 @@ export class VapixAPI {
|
|
|
185
207
|
}
|
|
186
208
|
async fetchRemoteDeviceInfo(payload, proxy = null) {
|
|
187
209
|
const res = await this.postJson(proxy, '/axis-cgi/basicdeviceinfo.cgi', payload);
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
mergeAttrs: true,
|
|
191
|
-
explicitArray: false,
|
|
192
|
-
});
|
|
193
|
-
if (isNullish(result.body.data)) {
|
|
210
|
+
const json = await res.json();
|
|
211
|
+
if (isNullish(json.data)) {
|
|
194
212
|
throw new NoDeviceInfoError();
|
|
195
213
|
}
|
|
196
|
-
return
|
|
214
|
+
return json.data;
|
|
197
215
|
}
|
|
198
216
|
async getHeaders(proxy = null) {
|
|
199
217
|
const data = { apiVersion: '1.0', method: 'list' };
|
|
@@ -231,9 +249,9 @@ export class VapixAPI {
|
|
|
231
249
|
const gTour = {
|
|
232
250
|
id: gTourBaseName,
|
|
233
251
|
camNbr: response[gTourBaseName + '.CamNbr'],
|
|
234
|
-
name: response[gTourBaseName + '.Name'],
|
|
252
|
+
name: response[gTourBaseName + '.Name'] ?? 'Guard Tour ' + (i + 1),
|
|
235
253
|
randomEnabled: response[gTourBaseName + '.RandomEnabled'],
|
|
236
|
-
running: response[gTourBaseName + '.Running'],
|
|
254
|
+
running: response[gTourBaseName + '.Running'] ?? 'no',
|
|
237
255
|
timeBetweenSequences: response[gTourBaseName + '.TimeBetweenSequences'],
|
|
238
256
|
tour: [],
|
|
239
257
|
};
|
|
@@ -289,17 +307,29 @@ export class VapixAPI {
|
|
|
289
307
|
query: 'presetposcamdata',
|
|
290
308
|
format: 'json',
|
|
291
309
|
});
|
|
292
|
-
|
|
310
|
+
const text = await response.text();
|
|
311
|
+
if (text === '') {
|
|
312
|
+
throw new PtzNotSupportedError();
|
|
313
|
+
}
|
|
314
|
+
return parseCameraPtzResponse(text)[camera] ?? [];
|
|
293
315
|
}
|
|
294
316
|
async listPtzVideoSourceOverview(proxy = null) {
|
|
295
317
|
const response = await this.getUrlEncoded(proxy, '/axis-cgi/com/ptz.cgi', {
|
|
296
318
|
query: 'presetposall',
|
|
297
319
|
format: 'json',
|
|
298
320
|
});
|
|
299
|
-
const
|
|
321
|
+
const text = await response.text();
|
|
322
|
+
if (text === '') {
|
|
323
|
+
throw new PtzNotSupportedError();
|
|
324
|
+
}
|
|
325
|
+
const data = parseCameraPtzResponse(text);
|
|
300
326
|
const res = {};
|
|
301
|
-
Object.keys(data)
|
|
302
|
-
|
|
327
|
+
Object.keys(data)
|
|
328
|
+
.map(Number)
|
|
329
|
+
.forEach((camera) => {
|
|
330
|
+
if (data[camera] !== undefined) {
|
|
331
|
+
res[camera - 1] = data[camera]?.map(({ data: itemData, ...d }) => d);
|
|
332
|
+
}
|
|
303
333
|
});
|
|
304
334
|
return res;
|
|
305
335
|
}
|
|
@@ -323,26 +353,29 @@ export class VapixAPI {
|
|
|
323
353
|
}
|
|
324
354
|
async getInputState(port, proxy = null) {
|
|
325
355
|
const response = await (await this.getUrlEncoded(proxy, '/axis-cgi/io/port.cgi', { checkactive: port.toString() })).text();
|
|
326
|
-
return response.split('=')[1]
|
|
356
|
+
return response.split('=')[1]?.indexOf('active') === 0;
|
|
327
357
|
}
|
|
328
358
|
async setOutputState(port, active, proxy = null) {
|
|
329
359
|
return this.getUrlEncoded(proxy, '/axis-cgi/io/port.cgi', { action: active ? `${port}:/` : `${port}:\\` });
|
|
330
360
|
}
|
|
331
361
|
async getApplicationList(proxy = null) {
|
|
332
|
-
const res = await this.
|
|
362
|
+
const res = await this.client.get(proxy, '/axis-cgi/applications/list.cgi');
|
|
333
363
|
const xml = await res.text();
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
364
|
+
const parser = new XMLParser({
|
|
365
|
+
ignoreAttributes: false,
|
|
366
|
+
attributeNamePrefix: '',
|
|
367
|
+
allowBooleanAttributes: true,
|
|
368
|
+
});
|
|
369
|
+
const result = parser.parse(xml);
|
|
370
|
+
return result.reply.application.map((app) => {
|
|
371
|
+
return {
|
|
372
|
+
...app,
|
|
373
|
+
appId: APP_IDS.find((id) => id.toLowerCase() === app.Name.toLowerCase()) ?? null,
|
|
374
|
+
};
|
|
375
|
+
});
|
|
343
376
|
}
|
|
344
377
|
async startApplication(applicationID, proxy = null) {
|
|
345
|
-
const res = await this.
|
|
378
|
+
const res = await this.client.get(proxy, '/axis-cgi/applications/control.cgi', {
|
|
346
379
|
package: applicationID.toLowerCase(),
|
|
347
380
|
action: 'start',
|
|
348
381
|
});
|
|
@@ -352,7 +385,7 @@ export class VapixAPI {
|
|
|
352
385
|
}
|
|
353
386
|
}
|
|
354
387
|
async restartApplication(applicationID, proxy = null) {
|
|
355
|
-
const res = await this.
|
|
388
|
+
const res = await this.client.get(proxy, '/axis-cgi/applications/control.cgi', {
|
|
356
389
|
package: applicationID.toLowerCase(),
|
|
357
390
|
action: 'restart',
|
|
358
391
|
});
|
|
@@ -362,7 +395,7 @@ export class VapixAPI {
|
|
|
362
395
|
}
|
|
363
396
|
}
|
|
364
397
|
async stopApplication(applicationID, proxy = null) {
|
|
365
|
-
const res = await this.
|
|
398
|
+
const res = await this.client.get(proxy, '/axis-cgi/applications/control.cgi', {
|
|
366
399
|
package: applicationID.toLowerCase(),
|
|
367
400
|
action: 'stop',
|
|
368
401
|
});
|
|
@@ -389,14 +422,14 @@ export class VapixAPI {
|
|
|
389
422
|
const parseParameters = (response) => {
|
|
390
423
|
const params = {};
|
|
391
424
|
const lines = response.split(/[\r\n]/);
|
|
392
|
-
for (
|
|
393
|
-
if (
|
|
425
|
+
for (const line of lines) {
|
|
426
|
+
if (line.length === 0 || line.substring(0, 7) === '# Error') {
|
|
394
427
|
continue;
|
|
395
428
|
}
|
|
396
|
-
const delimiterPos =
|
|
429
|
+
const delimiterPos = line.indexOf('=');
|
|
397
430
|
if (delimiterPos !== -1) {
|
|
398
|
-
const paramName =
|
|
399
|
-
const paramValue =
|
|
431
|
+
const paramName = line.substring(0, delimiterPos).replace('root.', '');
|
|
432
|
+
const paramValue = line.substring(delimiterPos + 1);
|
|
400
433
|
params[paramName] = paramValue;
|
|
401
434
|
}
|
|
402
435
|
}
|
|
@@ -442,7 +475,7 @@ const parsePtz = (parsed) => {
|
|
|
442
475
|
};
|
|
443
476
|
res.push({
|
|
444
477
|
id,
|
|
445
|
-
name: data[0],
|
|
478
|
+
name: data[0] ?? 'Preset ' + id,
|
|
446
479
|
data: {
|
|
447
480
|
pan: getValue('pan'),
|
|
448
481
|
tilt: getValue('tilt'),
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { EventEmitter2 as EventEmitter } from 'eventemitter2';
|
|
2
|
+
import { WsOptions } from './internal/types';
|
|
3
|
+
export type VapixEventsOptions = WsOptions;
|
|
4
|
+
type TEventMessage = {
|
|
5
|
+
apiVersion: string;
|
|
6
|
+
method: string;
|
|
7
|
+
params: {
|
|
8
|
+
notification: {
|
|
9
|
+
timestamp: number;
|
|
10
|
+
topic: string;
|
|
11
|
+
message: {
|
|
12
|
+
source: Record<string, string>;
|
|
13
|
+
data: Record<string, string>;
|
|
14
|
+
key: Record<string, string>;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export interface VapixEvents {
|
|
20
|
+
on(event: 'open', listener: () => void): this;
|
|
21
|
+
on(event: 'close', listener: () => void): this;
|
|
22
|
+
on(event: 'error', listener: (err: Error) => void): this;
|
|
23
|
+
on(event: string, listener: (data: TEventMessage) => void): this;
|
|
24
|
+
emit(event: 'open'): boolean;
|
|
25
|
+
emit(event: 'close'): boolean;
|
|
26
|
+
emit(event: 'error', err: Error): boolean;
|
|
27
|
+
emit(event: string, msg: TEventMessage): boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare class VapixEvents extends EventEmitter {
|
|
30
|
+
private tls;
|
|
31
|
+
private tlsInsecure;
|
|
32
|
+
private ip;
|
|
33
|
+
private port;
|
|
34
|
+
private user;
|
|
35
|
+
private pass;
|
|
36
|
+
private ws;
|
|
37
|
+
constructor(options?: VapixEventsOptions);
|
|
38
|
+
connect(): void;
|
|
39
|
+
disconnect(): void;
|
|
40
|
+
private createWsClient;
|
|
41
|
+
private isReservedEventName;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -39,10 +39,10 @@ export class VapixEvents extends EventEmitter {
|
|
|
39
39
|
this.ws.on('open', () => {
|
|
40
40
|
const topics = [];
|
|
41
41
|
const eventNames = this.eventNames();
|
|
42
|
-
for (
|
|
43
|
-
if (!this.isReservedEventName(
|
|
42
|
+
for (const eventName of eventNames) {
|
|
43
|
+
if (!this.isReservedEventName(eventName)) {
|
|
44
44
|
const topic = {
|
|
45
|
-
topicFilter:
|
|
45
|
+
topicFilter: eventName,
|
|
46
46
|
};
|
|
47
47
|
topics.push(topic);
|
|
48
48
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare class ServiceUnavailableError extends Error {
|
|
2
|
+
constructor();
|
|
3
|
+
}
|
|
4
|
+
export declare class ServiceNotFoundError extends Error {
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
7
|
+
export declare class ParsingBlobError extends Error {
|
|
8
|
+
constructor(err: unknown);
|
|
9
|
+
}
|
|
10
|
+
type TApplicationAPIAction = 'START' | 'RESTART' | 'STOP';
|
|
11
|
+
export declare class ApplicationAPIError extends Error {
|
|
12
|
+
constructor(action: TApplicationAPIAction, res: string);
|
|
13
|
+
}
|
|
14
|
+
type TSDCardAction = 'MOUNT' | 'UNMOUNT';
|
|
15
|
+
export declare class SDCardActionError extends Error {
|
|
16
|
+
constructor(action: TSDCardAction, res: string);
|
|
17
|
+
}
|
|
18
|
+
export declare class SDCardJobError extends Error {
|
|
19
|
+
constructor();
|
|
20
|
+
}
|
|
21
|
+
type TMaxFPSErrorType = 'MALFORMED_REPLY' | 'CHANNEL_NOT_FOUND' | 'CAPTURE_MODE_NOT_FOUND' | 'FPS_NOT_SPECIFIED';
|
|
22
|
+
export declare class MaxFPSError extends Error {
|
|
23
|
+
constructor(state: TMaxFPSErrorType);
|
|
24
|
+
}
|
|
25
|
+
export declare class NoDeviceInfoError extends Error {
|
|
26
|
+
constructor();
|
|
27
|
+
}
|
|
28
|
+
export declare class FetchDeviceInfoError extends Error {
|
|
29
|
+
constructor(err: unknown);
|
|
30
|
+
}
|
|
31
|
+
export declare class AddNewClipError extends Error {
|
|
32
|
+
constructor(message: string);
|
|
33
|
+
}
|
|
34
|
+
export declare class PtzNotSupportedError extends Error {
|
|
35
|
+
constructor();
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IClient, HttpOptions } from '../internal/types';
|
|
2
|
+
import { Response } from 'undici';
|
|
3
|
+
export type AcsEventsOptions = HttpOptions;
|
|
4
|
+
export declare class AxisCameraStationEvents {
|
|
5
|
+
private sourceKey;
|
|
6
|
+
private client;
|
|
7
|
+
constructor(sourceKey: string, opt?: AcsEventsOptions | IClient<Response>);
|
|
8
|
+
sendEvent(data: Record<string, string>, eventType: string): Promise<void>;
|
|
9
|
+
private getDate;
|
|
10
|
+
}
|