camstreamerlib 4.0.0-beta.29 → 4.0.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/cjs/CamOverlayAPI.d.ts +38 -615
- package/cjs/CamOverlayAPI.js +128 -104
- package/cjs/CamOverlayDrawingAPI.d.ts +2 -47
- package/cjs/CamOverlayPainter/Frame.d.ts +8 -37
- package/cjs/CamOverlayPainter/Frame.js +33 -0
- package/cjs/CamOverlayPainter/Painter.d.ts +5 -10
- package/cjs/CamOverlayPainter/Painter.js +2 -4
- package/cjs/CamOverlayPainter/ResourceManager.d.ts +3 -2
- package/cjs/CamOverlayPainter/ResourceManager.js +2 -1
- package/cjs/CamScripterAPI.d.ts +12 -12
- package/cjs/CamScripterAPI.js +33 -27
- package/cjs/CamStreamerAPI.d.ts +11 -9
- package/cjs/CamStreamerAPI.js +28 -22
- package/cjs/CamSwitcherAPI.d.ts +35 -34
- package/cjs/CamSwitcherAPI.js +94 -82
- package/cjs/PlaneTrackerAPI.d.ts +30 -36
- package/cjs/PlaneTrackerAPI.js +132 -71
- package/cjs/VapixAPI.d.ts +43 -40
- package/cjs/VapixAPI.js +205 -183
- package/cjs/events/AxisCameraStationEvents.d.ts +5 -5
- package/cjs/events/AxisCameraStationEvents.js +17 -12
- package/cjs/events/GenetecAgent.d.ts +2 -0
- package/cjs/events/GenetecAgent.js +15 -4
- package/cjs/index.d.ts +7 -1
- package/cjs/index.js +12 -2
- package/cjs/internal/ProxyClient.d.ts +7 -8
- package/cjs/internal/ProxyClient.js +25 -31
- package/cjs/internal/types.d.ts +16 -9
- package/cjs/internal/utils.d.ts +1 -2
- package/cjs/internal/utils.js +1 -5
- package/cjs/node/DefaultClient.d.ts +3 -5
- package/cjs/node/DefaultClient.js +10 -14
- package/cjs/node/HttpRequestSender.d.ts +1 -0
- package/cjs/node/HttpRequestSender.js +13 -3
- package/cjs/node/WsClient.d.ts +1 -0
- package/cjs/node/index.d.ts +2 -0
- package/cjs/node/index.js +18 -1
- package/cjs/{models/CamOverlayAPI/widgetsSchema.d.ts → types/CamOverlayAPI/CamOverlayAPI.d.ts} +625 -375
- package/cjs/{models/CamOverlayAPI/widgetCommonSchema.js → types/CamOverlayAPI/CamOverlayAPI.js} +65 -14
- package/cjs/{models → types}/CamOverlayAPI/accuweatherSchema.d.ts +40 -10
- package/cjs/{models → types}/CamOverlayAPI/accuweatherSchema.js +11 -9
- package/cjs/{models → types}/CamOverlayAPI/customGraphicsSchema.d.ts +89 -5
- package/cjs/{models → types}/CamOverlayAPI/customGraphicsSchema.js +9 -7
- package/{esm/models → cjs/types}/CamOverlayAPI/imagesSchema.d.ts +40 -13
- package/cjs/types/CamOverlayAPI/imagesSchema.js +12 -0
- package/cjs/{models → types}/CamOverlayAPI/index.d.ts +0 -4
- package/cjs/{models → types}/CamOverlayAPI/index.js +0 -4
- package/{esm/models → cjs/types}/CamOverlayAPI/infotickerSchema.d.ts +43 -9
- package/cjs/{models → types}/CamOverlayAPI/infotickerSchema.js +10 -8
- package/{esm/models → cjs/types}/CamOverlayAPI/pipSchema.d.ts +48 -7
- package/cjs/{models → types}/CamOverlayAPI/pipSchema.js +8 -6
- package/{esm/models → cjs/types}/CamOverlayAPI/ptzCompassSchema.d.ts +40 -7
- package/cjs/{models → types}/CamOverlayAPI/ptzCompassSchema.js +8 -6
- package/cjs/{models → types}/CamOverlayAPI/ptzSchema.d.ts +42 -14
- package/cjs/types/CamOverlayAPI/ptzSchema.js +15 -0
- package/{esm/models → cjs/types}/CamOverlayAPI/screenSharingSchema.d.ts +26 -5
- package/cjs/types/CamOverlayAPI/screenSharingSchema.js +11 -0
- package/cjs/{models → types}/CamOverlayAPI/webCameraSharingSchema.d.ts +26 -5
- package/cjs/types/CamOverlayAPI/webCameraSharingSchema.js +11 -0
- package/cjs/types/CamOverlayDrawingAPI.d.ts +58 -0
- package/cjs/types/CamOverlayDrawingAPI.js +2 -0
- package/cjs/types/CamOverlayPainter.d.ts +74 -0
- package/cjs/types/CamOverlayPainter.js +2 -0
- package/cjs/types/CamStreamerAPI.d.ts +4 -4
- package/cjs/types/PlaneTrackerAPI.d.ts +6 -0
- package/cjs/types/common.d.ts +12 -3
- package/cjs/web/DefaultClient.d.ts +4 -4
- package/cjs/web/DefaultClient.js +21 -11
- package/esm/CamOverlayAPI.d.ts +38 -615
- package/esm/CamOverlayAPI.js +127 -103
- package/esm/CamOverlayDrawingAPI.d.ts +2 -47
- package/esm/CamOverlayPainter/Frame.d.ts +8 -37
- package/esm/CamOverlayPainter/Frame.js +33 -0
- package/esm/CamOverlayPainter/Painter.d.ts +5 -10
- package/esm/CamOverlayPainter/Painter.js +1 -2
- package/esm/CamOverlayPainter/ResourceManager.d.ts +3 -2
- package/esm/CamOverlayPainter/ResourceManager.js +1 -1
- package/esm/CamScripterAPI.d.ts +12 -12
- package/esm/CamScripterAPI.js +32 -26
- package/esm/CamStreamerAPI.d.ts +11 -9
- package/esm/CamStreamerAPI.js +28 -22
- package/esm/CamSwitcherAPI.d.ts +35 -34
- package/esm/CamSwitcherAPI.js +95 -83
- package/esm/PlaneTrackerAPI.d.ts +30 -36
- package/esm/PlaneTrackerAPI.js +131 -70
- package/esm/VapixAPI.d.ts +43 -40
- package/esm/VapixAPI.js +204 -182
- package/esm/events/AxisCameraStationEvents.d.ts +5 -5
- package/esm/events/AxisCameraStationEvents.js +18 -13
- package/esm/events/GenetecAgent.d.ts +2 -0
- package/esm/events/GenetecAgent.js +15 -4
- package/esm/index.d.ts +7 -1
- package/esm/index.js +7 -1
- package/esm/internal/ProxyClient.d.ts +7 -8
- package/esm/internal/ProxyClient.js +25 -31
- package/esm/internal/types.d.ts +16 -9
- package/esm/internal/utils.d.ts +1 -2
- package/esm/internal/utils.js +0 -3
- package/esm/node/DefaultClient.d.ts +3 -5
- package/esm/node/DefaultClient.js +10 -14
- package/esm/node/HttpRequestSender.d.ts +1 -0
- package/esm/node/HttpRequestSender.js +13 -3
- package/esm/node/WsClient.d.ts +1 -0
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +2 -0
- package/esm/{models/CamOverlayAPI/widgetsSchema.d.ts → types/CamOverlayAPI/CamOverlayAPI.d.ts} +625 -375
- package/esm/{models/CamOverlayAPI/widgetCommonSchema.js → types/CamOverlayAPI/CamOverlayAPI.js} +64 -13
- package/esm/{models → types}/CamOverlayAPI/accuweatherSchema.d.ts +40 -10
- package/esm/{models → types}/CamOverlayAPI/accuweatherSchema.js +3 -2
- package/esm/{models → types}/CamOverlayAPI/customGraphicsSchema.d.ts +89 -5
- package/esm/{models → types}/CamOverlayAPI/customGraphicsSchema.js +3 -2
- package/{cjs/models → esm/types}/CamOverlayAPI/imagesSchema.d.ts +40 -13
- package/esm/types/CamOverlayAPI/imagesSchema.js +8 -0
- package/esm/{models → types}/CamOverlayAPI/index.d.ts +0 -4
- package/esm/{models → types}/CamOverlayAPI/index.js +0 -4
- package/{cjs/models → esm/types}/CamOverlayAPI/infotickerSchema.d.ts +43 -9
- package/esm/{models → types}/CamOverlayAPI/infotickerSchema.js +3 -2
- package/{cjs/models → esm/types}/CamOverlayAPI/pipSchema.d.ts +48 -7
- package/esm/{models → types}/CamOverlayAPI/pipSchema.js +3 -2
- package/{cjs/models → esm/types}/CamOverlayAPI/ptzCompassSchema.d.ts +40 -7
- package/esm/{models → types}/CamOverlayAPI/ptzCompassSchema.js +3 -2
- package/esm/{models → types}/CamOverlayAPI/ptzSchema.d.ts +42 -14
- package/esm/{models → types}/CamOverlayAPI/ptzSchema.js +3 -2
- package/{cjs/models → esm/types}/CamOverlayAPI/screenSharingSchema.d.ts +26 -5
- package/esm/types/CamOverlayAPI/screenSharingSchema.js +7 -0
- package/esm/{models → types}/CamOverlayAPI/webCameraSharingSchema.d.ts +26 -5
- package/esm/types/CamOverlayAPI/webCameraSharingSchema.js +7 -0
- package/esm/types/CamOverlayDrawingAPI.d.ts +58 -0
- package/esm/types/CamOverlayDrawingAPI.js +1 -0
- package/esm/types/CamOverlayPainter.d.ts +74 -0
- package/esm/types/CamOverlayPainter.js +1 -0
- package/esm/types/CamStreamerAPI.d.ts +4 -4
- package/esm/types/PlaneTrackerAPI.d.ts +6 -0
- package/esm/types/common.d.ts +12 -3
- package/esm/web/DefaultClient.d.ts +4 -4
- package/esm/web/DefaultClient.js +21 -11
- package/package.json +2 -2
- package/cjs/models/CamOverlayAPI/constants.d.ts +0 -11
- package/cjs/models/CamOverlayAPI/constants.js +0 -14
- package/cjs/models/CamOverlayAPI/fileSchema.d.ts +0 -28
- package/cjs/models/CamOverlayAPI/fileSchema.js +0 -17
- package/cjs/models/CamOverlayAPI/imagesSchema.js +0 -10
- package/cjs/models/CamOverlayAPI/ptzSchema.js +0 -13
- package/cjs/models/CamOverlayAPI/screenSharingSchema.js +0 -9
- package/cjs/models/CamOverlayAPI/webCameraSharingSchema.js +0 -9
- package/cjs/models/CamOverlayAPI/widgetCommonSchema.d.ts +0 -126
- package/cjs/models/CamOverlayAPI/widgetsSchema.js +0 -27
- package/cjs/types/CamOverlayAPI.d.ts +0 -328
- package/cjs/types/CamOverlayAPI.js +0 -26
- package/esm/models/CamOverlayAPI/constants.d.ts +0 -11
- package/esm/models/CamOverlayAPI/constants.js +0 -11
- package/esm/models/CamOverlayAPI/fileSchema.d.ts +0 -28
- package/esm/models/CamOverlayAPI/fileSchema.js +0 -14
- package/esm/models/CamOverlayAPI/imagesSchema.js +0 -7
- package/esm/models/CamOverlayAPI/screenSharingSchema.js +0 -6
- package/esm/models/CamOverlayAPI/webCameraSharingSchema.js +0 -6
- package/esm/models/CamOverlayAPI/widgetCommonSchema.d.ts +0 -126
- package/esm/models/CamOverlayAPI/widgetsSchema.js +0 -24
- package/esm/types/CamOverlayAPI.d.ts +0 -328
- package/esm/types/CamOverlayAPI.js +0 -14
package/esm/VapixAPI.js
CHANGED
|
@@ -7,48 +7,56 @@ import { z } from 'zod';
|
|
|
7
7
|
import { XMLParser } from 'fast-xml-parser';
|
|
8
8
|
export class VapixAPI {
|
|
9
9
|
client;
|
|
10
|
-
constructor(client
|
|
11
|
-
this.client =
|
|
10
|
+
constructor(client) {
|
|
11
|
+
this.client = client;
|
|
12
12
|
}
|
|
13
|
-
async
|
|
13
|
+
async postUrlEncoded(path, parameters, headers, options) {
|
|
14
14
|
const data = paramToUrl(parameters);
|
|
15
15
|
const head = { ...headers, 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
16
|
-
const
|
|
16
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
17
|
+
const res = await agent.post({ path, data, headers: head, timeout: options?.timeout });
|
|
17
18
|
if (!res.ok) {
|
|
18
19
|
throw new Error(await responseStringify(res));
|
|
19
20
|
}
|
|
20
21
|
return res;
|
|
21
22
|
}
|
|
22
|
-
async postJson(
|
|
23
|
+
async postJson(path, jsonData, headers, options) {
|
|
23
24
|
const data = JSON.stringify(jsonData);
|
|
24
25
|
const head = { ...headers, 'Content-Type': 'application/json' };
|
|
25
|
-
const
|
|
26
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
27
|
+
const res = await agent.post({ path, data, headers: head, timeout: options?.timeout });
|
|
26
28
|
if (!res.ok) {
|
|
27
29
|
throw new Error(await responseStringify(res));
|
|
28
30
|
}
|
|
29
31
|
return res;
|
|
30
32
|
}
|
|
31
|
-
async getCameraImage(
|
|
32
|
-
|
|
33
|
+
async getCameraImage(parameters, options) {
|
|
34
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
35
|
+
return await agent.get({ path: '/axis-cgi/jpg/image.cgi', parameters, timeout: options?.timeout });
|
|
33
36
|
}
|
|
34
|
-
async getEventDeclarations(
|
|
37
|
+
async getEventDeclarations(options) {
|
|
35
38
|
const data = '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">' +
|
|
36
39
|
'<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
|
|
37
40
|
'xmlns:xsd="http://www.w3.org/2001/XMLSchema">' +
|
|
38
41
|
'<GetEventInstances xmlns="http://www.axis.com/vapix/ws/event1"/>' +
|
|
39
42
|
'</s:Body>' +
|
|
40
43
|
'</s:Envelope>';
|
|
41
|
-
const
|
|
44
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
45
|
+
const res = await agent.post({
|
|
46
|
+
path: '/vapix/services',
|
|
47
|
+
data,
|
|
48
|
+
headers: { 'Content-Type': 'application/soap+xml' },
|
|
49
|
+
});
|
|
42
50
|
if (!res.ok) {
|
|
43
51
|
throw new Error(await responseStringify(res));
|
|
44
52
|
}
|
|
45
53
|
const declarations = await res.text();
|
|
46
54
|
return prettifyXml(declarations);
|
|
47
55
|
}
|
|
48
|
-
async getSupportedAudioSampleRate(
|
|
49
|
-
const
|
|
56
|
+
async getSupportedAudioSampleRate(options) {
|
|
57
|
+
const path = '/axis-cgi/audio/streamingcapabilities.cgi';
|
|
50
58
|
const jsonData = { apiVersion: '1.0', method: 'list' };
|
|
51
|
-
const res = await this.postJson(
|
|
59
|
+
const res = await this.postJson(path, jsonData, undefined, options);
|
|
52
60
|
const encoders = audioSampleRatesResponseSchema.parse(await res.json()).data.encoders;
|
|
53
61
|
const data = encoders.aac ?? encoders.AAC ?? [];
|
|
54
62
|
return data.map((item) => {
|
|
@@ -58,7 +66,7 @@ export class VapixAPI {
|
|
|
58
66
|
};
|
|
59
67
|
});
|
|
60
68
|
}
|
|
61
|
-
async performAutofocus(
|
|
69
|
+
async performAutofocus(options) {
|
|
62
70
|
try {
|
|
63
71
|
const data = {
|
|
64
72
|
apiVersion: '1',
|
|
@@ -71,19 +79,19 @@ export class VapixAPI {
|
|
|
71
79
|
],
|
|
72
80
|
},
|
|
73
81
|
};
|
|
74
|
-
await this.postJson(
|
|
82
|
+
await this.postJson('/axis-cgi/opticscontrol.cgi', data, undefined, options);
|
|
75
83
|
}
|
|
76
84
|
catch (err) {
|
|
77
|
-
await this.
|
|
85
|
+
await this.postUrlEncoded('/axis-cgi/opticssetup.cgi', {
|
|
78
86
|
autofocus: 'perform',
|
|
79
87
|
source: '1',
|
|
80
|
-
});
|
|
88
|
+
}, undefined, options);
|
|
81
89
|
}
|
|
82
90
|
}
|
|
83
|
-
async checkSDCard(
|
|
84
|
-
const res = await this.
|
|
91
|
+
async checkSDCard(options) {
|
|
92
|
+
const res = await this.postUrlEncoded('/axis-cgi/disks/list.cgi', {
|
|
85
93
|
diskid: 'SD_DISK',
|
|
86
|
-
});
|
|
94
|
+
}, undefined, options);
|
|
87
95
|
const xmlText = await res.text();
|
|
88
96
|
const parser = new XMLParser({
|
|
89
97
|
ignoreAttributes: false,
|
|
@@ -98,17 +106,17 @@ export class VapixAPI {
|
|
|
98
106
|
status: sdCardWatchedStatuses.includes(data.status) ? data.status : 'disconnected',
|
|
99
107
|
};
|
|
100
108
|
}
|
|
101
|
-
mountSDCard(
|
|
102
|
-
return this._doSDCardMountAction('MOUNT',
|
|
109
|
+
mountSDCard(options) {
|
|
110
|
+
return this._doSDCardMountAction('MOUNT', options);
|
|
103
111
|
}
|
|
104
|
-
unmountSDCard(
|
|
105
|
-
return this._doSDCardMountAction('UNMOUNT',
|
|
112
|
+
unmountSDCard(options) {
|
|
113
|
+
return this._doSDCardMountAction('UNMOUNT', options);
|
|
106
114
|
}
|
|
107
|
-
async _doSDCardMountAction(action,
|
|
108
|
-
const res = await this.
|
|
115
|
+
async _doSDCardMountAction(action, options) {
|
|
116
|
+
const res = await this.postUrlEncoded('/axis-cgi/disks/mount.cgi', {
|
|
109
117
|
action: action,
|
|
110
118
|
diskid: 'SD_DISK',
|
|
111
|
-
});
|
|
119
|
+
}, undefined, options);
|
|
112
120
|
const textXml = await res.text();
|
|
113
121
|
const parser = new XMLParser({
|
|
114
122
|
ignoreAttributes: false,
|
|
@@ -122,11 +130,11 @@ export class VapixAPI {
|
|
|
122
130
|
}
|
|
123
131
|
return Number(job.jobid);
|
|
124
132
|
}
|
|
125
|
-
async fetchSDCardJobProgress(jobId,
|
|
126
|
-
const res = await this.
|
|
133
|
+
async fetchSDCardJobProgress(jobId, options) {
|
|
134
|
+
const res = await this.postUrlEncoded('/disks/job.cgi', {
|
|
127
135
|
jobid: String(jobId),
|
|
128
136
|
diskid: 'SD_DISK',
|
|
129
|
-
});
|
|
137
|
+
}, undefined, options);
|
|
130
138
|
const textXml = await res.text();
|
|
131
139
|
const parser = new XMLParser({
|
|
132
140
|
ignoreAttributes: false,
|
|
@@ -139,15 +147,15 @@ export class VapixAPI {
|
|
|
139
147
|
}
|
|
140
148
|
return Number(job.progress);
|
|
141
149
|
}
|
|
142
|
-
downloadCameraReport(
|
|
143
|
-
return this.
|
|
150
|
+
downloadCameraReport(options) {
|
|
151
|
+
return this.postUrlEncoded('/axis-cgi/serverreport.cgi', { mode: 'text' }, undefined, options);
|
|
144
152
|
}
|
|
145
|
-
getSystemLog(
|
|
146
|
-
return this.
|
|
153
|
+
getSystemLog(options) {
|
|
154
|
+
return this.postUrlEncoded('/axis-cgi/admin/systemlog.cgi', undefined, undefined, options);
|
|
147
155
|
}
|
|
148
|
-
async getMaxFps(channel,
|
|
156
|
+
async getMaxFps(channel, options) {
|
|
149
157
|
const data = { apiVersion: '1.0', method: 'getCaptureModes' };
|
|
150
|
-
const res = await this.postJson(
|
|
158
|
+
const res = await this.postJson('/axis-cgi/capturemode.cgi', data, undefined, options);
|
|
151
159
|
const response = maxFpsResponseSchema.parse(await res.json());
|
|
152
160
|
const channels = response.data;
|
|
153
161
|
if (channels === undefined) {
|
|
@@ -167,9 +175,10 @@ export class VapixAPI {
|
|
|
167
175
|
}
|
|
168
176
|
return captureMode.maxFPS;
|
|
169
177
|
}
|
|
170
|
-
async getTimezone(
|
|
178
|
+
async getTimezone(options) {
|
|
171
179
|
try {
|
|
172
|
-
const
|
|
180
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
181
|
+
const resV2 = await agent.get({ path: '/config/rest/time/v2/timeZone', timeout: options?.timeout });
|
|
173
182
|
if (!resV2.ok) {
|
|
174
183
|
throw new Error(await responseStringify(resV2));
|
|
175
184
|
}
|
|
@@ -184,20 +193,20 @@ export class VapixAPI {
|
|
|
184
193
|
console.warn('Failed to fetch time zone data from time API v2:', error instanceof Error ? error.message : JSON.stringify(error));
|
|
185
194
|
console.warn('Falling back to deprecated time API v1');
|
|
186
195
|
}
|
|
187
|
-
const data = await this.getDateTimeInfo(
|
|
196
|
+
const data = await this.getDateTimeInfo(options);
|
|
188
197
|
if (data.data.timeZone === undefined) {
|
|
189
198
|
throw new Error('Time zone not setup on the device');
|
|
190
199
|
}
|
|
191
200
|
return data.data.timeZone;
|
|
192
201
|
}
|
|
193
|
-
async getDateTimeInfo(
|
|
202
|
+
async getDateTimeInfo(options) {
|
|
194
203
|
const data = { apiVersion: '1.0', method: 'getDateTimeInfo' };
|
|
195
|
-
const res = await this.postJson(
|
|
204
|
+
const res = await this.postJson('/axis-cgi/time.cgi', data, undefined, options);
|
|
196
205
|
return dateTimeinfoSchema.parse(await res.json());
|
|
197
206
|
}
|
|
198
|
-
async getDevicesSettings(
|
|
207
|
+
async getDevicesSettings(options) {
|
|
199
208
|
const data = { apiVersion: '1.0', method: 'getDevicesSettings' };
|
|
200
|
-
const res = await this.postJson(
|
|
209
|
+
const res = await this.postJson('/axis-cgi/audiodevicecontrol.cgi', data, undefined, options);
|
|
201
210
|
const result = audioDeviceRequestSchema.parse(await res.json());
|
|
202
211
|
return result.data.devices.map((device) => ({
|
|
203
212
|
...device,
|
|
@@ -205,44 +214,44 @@ export class VapixAPI {
|
|
|
205
214
|
outputs: (device.outputs || []).sort((a, b) => a.id.localeCompare(b.id)),
|
|
206
215
|
}));
|
|
207
216
|
}
|
|
208
|
-
async fetchRemoteDeviceInfo(payload,
|
|
209
|
-
const res = await this.postJson(
|
|
217
|
+
async fetchRemoteDeviceInfo(payload, options) {
|
|
218
|
+
const res = await this.postJson('/axis-cgi/basicdeviceinfo.cgi', payload, undefined, options);
|
|
210
219
|
const json = await res.json();
|
|
211
220
|
if (isNullish(json.data)) {
|
|
212
221
|
throw new NoDeviceInfoError();
|
|
213
222
|
}
|
|
214
223
|
return json.data;
|
|
215
224
|
}
|
|
216
|
-
async getHeaders(
|
|
225
|
+
async getHeaders(options) {
|
|
217
226
|
const data = { apiVersion: '1.0', method: 'list' };
|
|
218
|
-
const res = await this.postJson(
|
|
227
|
+
const res = await this.postJson('/axis-cgi/customhttpheader.cgi', data, undefined, options);
|
|
219
228
|
return z.object({ data: z.record(z.string()) }).parse(await res.json()).data;
|
|
220
229
|
}
|
|
221
|
-
async setHeaders(headers,
|
|
230
|
+
async setHeaders(headers, options) {
|
|
222
231
|
const data = { apiVersion: '1.0', method: 'set', params: headers };
|
|
223
|
-
return this.postJson(
|
|
232
|
+
return this.postJson('/axis-cgi/customhttpheader.cgi', data, undefined, options);
|
|
224
233
|
}
|
|
225
|
-
async getParameter(paramNames,
|
|
226
|
-
const response = await this.
|
|
234
|
+
async getParameter(paramNames, options) {
|
|
235
|
+
const response = await this.postUrlEncoded('/axis-cgi/param.cgi', {
|
|
227
236
|
action: 'list',
|
|
228
237
|
group: arrayToUrl(paramNames),
|
|
229
|
-
});
|
|
230
|
-
return parseParameters(await response.text());
|
|
238
|
+
}, undefined, options);
|
|
239
|
+
return VapixAPI.parseParameters(await response.text());
|
|
231
240
|
}
|
|
232
|
-
async setParameter(params,
|
|
233
|
-
const res = await this.
|
|
241
|
+
async setParameter(params, options) {
|
|
242
|
+
const res = await this.postUrlEncoded('/axis-cgi/param.cgi', {
|
|
234
243
|
...params,
|
|
235
244
|
action: 'update',
|
|
236
|
-
});
|
|
245
|
+
}, undefined, options);
|
|
237
246
|
const responseText = await res.text();
|
|
238
247
|
if (responseText.startsWith('# Error')) {
|
|
239
248
|
throw new Error(responseText);
|
|
240
249
|
}
|
|
241
250
|
return true;
|
|
242
251
|
}
|
|
243
|
-
async getGuardTourList(
|
|
252
|
+
async getGuardTourList(options) {
|
|
244
253
|
const gTourList = new Array();
|
|
245
|
-
const response = await this.getParameter('GuardTour',
|
|
254
|
+
const response = await this.getParameter('GuardTour', options);
|
|
246
255
|
for (let i = 0; i < 20; i++) {
|
|
247
256
|
const gTourBaseName = 'root.GuardTour.G' + i;
|
|
248
257
|
if (gTourBaseName + '.CamNbr' in response) {
|
|
@@ -276,16 +285,16 @@ export class VapixAPI {
|
|
|
276
285
|
}
|
|
277
286
|
return gTourList;
|
|
278
287
|
}
|
|
279
|
-
setGuardTourEnabled(guardTourID, enable,
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
return this.setParameter(
|
|
288
|
+
setGuardTourEnabled(guardTourID, enable, options) {
|
|
289
|
+
const params = {};
|
|
290
|
+
params[guardTourID + '.Running'] = enable ? 'yes' : 'no';
|
|
291
|
+
return this.setParameter(params, options);
|
|
283
292
|
}
|
|
284
|
-
async getPTZPresetList(channel,
|
|
285
|
-
const res = await this.
|
|
293
|
+
async getPTZPresetList(channel, options) {
|
|
294
|
+
const res = await this.postUrlEncoded('/axis-cgi/com/ptz.cgi', {
|
|
286
295
|
query: 'presetposcam',
|
|
287
296
|
camera: channel.toString(),
|
|
288
|
-
});
|
|
297
|
+
}, undefined, options);
|
|
289
298
|
const text = await res.text();
|
|
290
299
|
const lines = text.split(/[\r\n]/);
|
|
291
300
|
const positions = [];
|
|
@@ -300,29 +309,29 @@ export class VapixAPI {
|
|
|
300
309
|
}
|
|
301
310
|
return positions;
|
|
302
311
|
}
|
|
303
|
-
async listPTZ(camera,
|
|
312
|
+
async listPTZ(camera, options) {
|
|
304
313
|
const url = `/axis-cgi/com/ptz.cgi`;
|
|
305
|
-
const response = await this.
|
|
314
|
+
const response = await this.postUrlEncoded(url, {
|
|
306
315
|
camera,
|
|
307
316
|
query: 'presetposcamdata',
|
|
308
317
|
format: 'json',
|
|
309
|
-
});
|
|
318
|
+
}, undefined, options);
|
|
310
319
|
const text = await response.text();
|
|
311
320
|
if (text === '') {
|
|
312
321
|
throw new PtzNotSupportedError();
|
|
313
322
|
}
|
|
314
|
-
return parseCameraPtzResponse(text)[camera] ?? [];
|
|
323
|
+
return VapixAPI.parseCameraPtzResponse(text)[camera] ?? [];
|
|
315
324
|
}
|
|
316
|
-
async listPtzVideoSourceOverview(
|
|
317
|
-
const response = await this.
|
|
325
|
+
async listPtzVideoSourceOverview(options) {
|
|
326
|
+
const response = await this.postUrlEncoded('/axis-cgi/com/ptz.cgi', {
|
|
318
327
|
query: 'presetposall',
|
|
319
328
|
format: 'json',
|
|
320
|
-
});
|
|
329
|
+
}, undefined, options);
|
|
321
330
|
const text = await response.text();
|
|
322
331
|
if (text === '') {
|
|
323
332
|
throw new PtzNotSupportedError();
|
|
324
333
|
}
|
|
325
|
-
const data = parseCameraPtzResponse(text);
|
|
334
|
+
const data = VapixAPI.parseCameraPtzResponse(text);
|
|
326
335
|
const res = {};
|
|
327
336
|
Object.keys(data)
|
|
328
337
|
.map(Number)
|
|
@@ -333,63 +342,52 @@ export class VapixAPI {
|
|
|
333
342
|
});
|
|
334
343
|
return res;
|
|
335
344
|
}
|
|
336
|
-
goToPreset(channel, presetName,
|
|
337
|
-
return this.
|
|
345
|
+
goToPreset(channel, presetName, options) {
|
|
346
|
+
return this.postUrlEncoded('/axis-cgi/com/ptz.cgi', {
|
|
338
347
|
camera: channel.toString(),
|
|
339
348
|
gotoserverpresetname: presetName,
|
|
340
|
-
});
|
|
349
|
+
}, undefined, options);
|
|
341
350
|
}
|
|
342
|
-
async getPtzPosition(camera,
|
|
343
|
-
const res = await this.
|
|
351
|
+
async getPtzPosition(camera, options) {
|
|
352
|
+
const res = await this.postUrlEncoded('/axis-cgi/com/ptz.cgi', {
|
|
344
353
|
query: 'position',
|
|
345
354
|
camera: camera.toString(),
|
|
346
|
-
});
|
|
347
|
-
const params = parseParameters(await res.text());
|
|
355
|
+
}, undefined, options);
|
|
356
|
+
const params = VapixAPI.parseParameters(await res.text());
|
|
348
357
|
return {
|
|
349
358
|
pan: Number(params.pan),
|
|
350
359
|
tilt: Number(params.tilt),
|
|
351
360
|
zoom: Number(params.zoom),
|
|
352
361
|
};
|
|
353
362
|
}
|
|
354
|
-
async getPorts(
|
|
355
|
-
const
|
|
363
|
+
async getPorts(options) {
|
|
364
|
+
const res = await this.postJson('/axis-cgi/io/portmanagement.cgi', {
|
|
356
365
|
apiVersion: '1.0',
|
|
357
366
|
context: '',
|
|
358
367
|
method: 'getPorts',
|
|
359
|
-
});
|
|
360
|
-
const res = await this.client.post(proxy, '/axis-cgi/io/portmanagement.cgi', body, {}, { 'Content-Type': 'application/json' });
|
|
361
|
-
if (!res.ok) {
|
|
362
|
-
throw new Error(await responseStringify(res));
|
|
363
|
-
}
|
|
368
|
+
}, undefined, options);
|
|
364
369
|
const portResponseParsed = await getPortsResponseSchema.parse(res.json());
|
|
365
370
|
return portResponseParsed.data.items;
|
|
366
371
|
}
|
|
367
|
-
async setPorts(ports,
|
|
368
|
-
|
|
372
|
+
async setPorts(ports, options) {
|
|
373
|
+
await this.postJson('/axis-cgi/io/portmanagement.cgi', {
|
|
369
374
|
apiVersion: '1.0',
|
|
370
375
|
context: '',
|
|
371
376
|
method: 'setPorts',
|
|
372
377
|
params: { ports },
|
|
373
|
-
});
|
|
374
|
-
const res = await this.client.post(proxy, '/axis-cgi/io/portmanagement.cgi', body, {}, { 'Content-Type': 'application/json' });
|
|
375
|
-
if (!res.ok) {
|
|
376
|
-
throw new Error(await responseStringify(res));
|
|
377
|
-
}
|
|
378
|
+
}, undefined, options);
|
|
378
379
|
}
|
|
379
|
-
async setPortStateSequence(port, sequence,
|
|
380
|
-
|
|
380
|
+
async setPortStateSequence(port, sequence, options) {
|
|
381
|
+
await this.postJson('/axis-cgi/io/portmanagement.cgi', {
|
|
381
382
|
apiVersion: '1.0',
|
|
382
383
|
context: '',
|
|
383
384
|
method: 'setStateSequence',
|
|
384
385
|
params: { port, sequence },
|
|
385
|
-
});
|
|
386
|
-
const res = await this.client.post(proxy, '/axis-cgi/io/portmanagement.cgi', body, {}, { 'Content-Type': 'application/json' });
|
|
387
|
-
if (!res.ok) {
|
|
388
|
-
throw new Error(await responseStringify(res));
|
|
389
|
-
}
|
|
386
|
+
}, undefined, options);
|
|
390
387
|
}
|
|
391
|
-
async getApplicationList(
|
|
392
|
-
const
|
|
388
|
+
async getApplicationList(options) {
|
|
389
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
390
|
+
const res = await agent.get({ path: '/axis-cgi/applications/list.cgi', timeout: options?.timeout });
|
|
393
391
|
const xml = await res.text();
|
|
394
392
|
const parser = new XMLParser({
|
|
395
393
|
ignoreAttributes: false,
|
|
@@ -408,41 +406,62 @@ export class VapixAPI {
|
|
|
408
406
|
};
|
|
409
407
|
});
|
|
410
408
|
}
|
|
411
|
-
async startApplication(applicationID,
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
|
|
409
|
+
async startApplication(applicationID, options) {
|
|
410
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
411
|
+
const res = await agent.get({
|
|
412
|
+
path: '/axis-cgi/applications/control.cgi',
|
|
413
|
+
parameters: {
|
|
414
|
+
package: applicationID.toLowerCase(),
|
|
415
|
+
action: 'start',
|
|
416
|
+
},
|
|
417
|
+
timeout: options?.timeout,
|
|
415
418
|
});
|
|
416
419
|
const text = (await res.text()).trim().toLowerCase();
|
|
417
420
|
if (text !== 'ok' && !(text.startsWith('error:') && text.substring(7) === '6')) {
|
|
418
421
|
throw new ApplicationAPIError('START', await responseStringify(res));
|
|
419
422
|
}
|
|
420
423
|
}
|
|
421
|
-
async restartApplication(applicationID,
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
424
|
+
async restartApplication(applicationID, options) {
|
|
425
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
426
|
+
const res = await agent.get({
|
|
427
|
+
path: '/axis-cgi/applications/control.cgi',
|
|
428
|
+
parameters: {
|
|
429
|
+
package: applicationID.toLowerCase(),
|
|
430
|
+
action: 'restart',
|
|
431
|
+
},
|
|
432
|
+
timeout: options?.timeout,
|
|
425
433
|
});
|
|
426
434
|
const text = (await res.text()).trim().toLowerCase();
|
|
427
435
|
if (text !== 'ok') {
|
|
428
436
|
throw new ApplicationAPIError('RESTART', await responseStringify(res));
|
|
429
437
|
}
|
|
430
438
|
}
|
|
431
|
-
async stopApplication(applicationID,
|
|
432
|
-
const
|
|
433
|
-
|
|
434
|
-
|
|
439
|
+
async stopApplication(applicationID, options) {
|
|
440
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
441
|
+
const res = await agent.get({
|
|
442
|
+
path: '/axis-cgi/applications/control.cgi',
|
|
443
|
+
parameters: {
|
|
444
|
+
package: applicationID.toLowerCase(),
|
|
445
|
+
action: 'stop',
|
|
446
|
+
},
|
|
447
|
+
timeout: options?.timeout,
|
|
435
448
|
});
|
|
436
449
|
const text = (await res.text()).trim().toLowerCase();
|
|
437
450
|
if (text !== 'ok' && !(text.startsWith('error:') && text.substring(7) === '6')) {
|
|
438
451
|
throw new ApplicationAPIError('STOP', await responseStringify(res));
|
|
439
452
|
}
|
|
440
453
|
}
|
|
441
|
-
async installApplication(data, fileName) {
|
|
454
|
+
async installApplication(data, fileName, options) {
|
|
442
455
|
const formData = new FormData();
|
|
443
456
|
formData.append('packfil', data, fileName);
|
|
444
|
-
const
|
|
445
|
-
|
|
457
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
458
|
+
const res = await agent.post({
|
|
459
|
+
path: '/axis-cgi/applications/upload.cgi',
|
|
460
|
+
data: formData,
|
|
461
|
+
headers: {
|
|
462
|
+
contentType: 'application/octet-stream',
|
|
463
|
+
},
|
|
464
|
+
timeout: options?.timeout ?? 120000,
|
|
446
465
|
});
|
|
447
466
|
if (!res.ok) {
|
|
448
467
|
throw new Error(await responseStringify(res));
|
|
@@ -452,70 +471,73 @@ export class VapixAPI {
|
|
|
452
471
|
throw new Error('installing error: ' + text);
|
|
453
472
|
}
|
|
454
473
|
}
|
|
455
|
-
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
return params;
|
|
471
|
-
};
|
|
472
|
-
const parseCameraPtzResponse = (response) => {
|
|
473
|
-
const json = JSON.parse(response);
|
|
474
|
-
const parsed = {};
|
|
475
|
-
Object.keys(json).forEach((key) => {
|
|
476
|
-
if (!key.startsWith('Camera ')) {
|
|
477
|
-
return;
|
|
478
|
-
}
|
|
479
|
-
const camera = Number(key.replace('Camera ', ''));
|
|
480
|
-
if (json[key].presets !== undefined) {
|
|
481
|
-
parsed[camera] = parsePtz(json[key].presets);
|
|
482
|
-
}
|
|
483
|
-
});
|
|
484
|
-
return parsed;
|
|
485
|
-
};
|
|
486
|
-
const parsePtz = (parsed) => {
|
|
487
|
-
const res = [];
|
|
488
|
-
parsed.forEach((value) => {
|
|
489
|
-
const delimiterPos = value.indexOf('=');
|
|
490
|
-
if (delimiterPos === -1) {
|
|
491
|
-
return;
|
|
492
|
-
}
|
|
493
|
-
if (!value.startsWith('presetposno')) {
|
|
494
|
-
return;
|
|
495
|
-
}
|
|
496
|
-
const id = Number(value.substring(11, delimiterPos));
|
|
497
|
-
if (Number.isNaN(id)) {
|
|
498
|
-
return;
|
|
474
|
+
static parseParameters = (response) => {
|
|
475
|
+
const params = {};
|
|
476
|
+
const lines = response.split(/[\r\n]/);
|
|
477
|
+
for (const line of lines) {
|
|
478
|
+
if (line.length === 0 || line.substring(0, 7) === '# Error') {
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
const delimiterPos = line.indexOf('=');
|
|
482
|
+
if (delimiterPos !== -1) {
|
|
483
|
+
const paramName = line.substring(0, delimiterPos).replace('root.', '');
|
|
484
|
+
const paramValue = line.substring(delimiterPos + 1);
|
|
485
|
+
params[paramName] = paramValue;
|
|
486
|
+
}
|
|
499
487
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
488
|
+
return params;
|
|
489
|
+
};
|
|
490
|
+
static parseCameraPtzResponse = (response) => {
|
|
491
|
+
const json = JSON.parse(response);
|
|
492
|
+
const parsed = {};
|
|
493
|
+
Object.keys(json).forEach((key) => {
|
|
494
|
+
if (!key.startsWith('Camera ')) {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
const camera = Number(key.replace('Camera ', ''));
|
|
498
|
+
if (json[key].presets !== undefined) {
|
|
499
|
+
parsed[camera] = VapixAPI.parsePtz(json[key].presets);
|
|
507
500
|
}
|
|
508
|
-
return 0;
|
|
509
|
-
};
|
|
510
|
-
res.push({
|
|
511
|
-
id,
|
|
512
|
-
name: data[0] ?? 'Preset ' + id,
|
|
513
|
-
data: {
|
|
514
|
-
pan: getValue('pan'),
|
|
515
|
-
tilt: getValue('tilt'),
|
|
516
|
-
zoom: getValue('zoom'),
|
|
517
|
-
},
|
|
518
501
|
});
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
502
|
+
return parsed;
|
|
503
|
+
};
|
|
504
|
+
static parsePtz = (parsed) => {
|
|
505
|
+
const res = [];
|
|
506
|
+
parsed.forEach((value) => {
|
|
507
|
+
const delimiterPos = value.indexOf('=');
|
|
508
|
+
if (delimiterPos === -1) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
if (!value.startsWith('presetposno')) {
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
const id = Number(value.substring(11, delimiterPos));
|
|
515
|
+
if (Number.isNaN(id)) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
const data = value.substring(delimiterPos + 1).split(':');
|
|
519
|
+
const getValue = (valueName) => {
|
|
520
|
+
for (const d of data) {
|
|
521
|
+
const p = d.split('=');
|
|
522
|
+
if (p[0] === valueName) {
|
|
523
|
+
return Number(p[1]);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return 0;
|
|
527
|
+
};
|
|
528
|
+
res.push({
|
|
529
|
+
id,
|
|
530
|
+
name: data[0] ?? 'Preset ' + id,
|
|
531
|
+
data: {
|
|
532
|
+
pan: getValue('pan'),
|
|
533
|
+
tilt: getValue('tilt'),
|
|
534
|
+
zoom: getValue('zoom'),
|
|
535
|
+
},
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
return res;
|
|
539
|
+
};
|
|
540
|
+
getAgent(proxyParams) {
|
|
541
|
+
return proxyParams ? new ProxyClient(this.client, proxyParams) : this.client;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export type AcsEventsOptions = HttpOptions;
|
|
1
|
+
import { HttpOptions } from '../internal/types';
|
|
2
|
+
import { THttpRequestOptions } from '../types/common';
|
|
4
3
|
export declare class AxisCameraStationEvents {
|
|
5
4
|
private sourceKey;
|
|
6
5
|
private client;
|
|
7
|
-
constructor(
|
|
8
|
-
sendEvent(data: Record<string, string>, eventType: string): Promise<void>;
|
|
6
|
+
constructor(clientOptions: HttpOptions, sourceKey: string);
|
|
7
|
+
sendEvent(data: Record<string, string>, eventType: string, options?: THttpRequestOptions): Promise<void>;
|
|
9
8
|
private getDate;
|
|
9
|
+
private getAgent;
|
|
10
10
|
}
|