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