camstreamerlib 4.0.0-beta.7 → 4.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/CamOverlayAPI.d.ts +614 -17
- package/cjs/CamOverlayAPI.js +124 -51
- package/cjs/CamScripterAPI.d.ts +4 -4
- package/cjs/CamScripterAPI.js +2 -8
- package/cjs/VapixAPI.d.ts +1 -1
- package/cjs/VapixAPI.js +13 -5
- package/cjs/errors/errors.d.ts +3 -0
- package/cjs/errors/errors.js +8 -1
- package/cjs/index.d.ts +3 -0
- package/cjs/index.js +5 -1
- package/cjs/internal/ProxyClient.d.ts +3 -3
- package/cjs/internal/ProxyClient.js +4 -2
- package/cjs/internal/common.d.ts +2 -2
- 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/types/CamOverlayAPI.d.ts +315 -175
- package/cjs/types/CamOverlayAPI.js +19 -40
- package/cjs/types/CamStreamerAPI.d.ts +4 -4
- package/cjs/types/CamSwitcherAPI.d.ts +44 -44
- package/cjs/types/VapixAPI.d.ts +84 -84
- package/cjs/web/DefaultClient.d.ts +7 -4
- package/cjs/web/DefaultClient.js +4 -4
- package/esm/CamOverlayAPI.d.ts +614 -17
- package/esm/CamOverlayAPI.js +124 -51
- package/esm/CamScripterAPI.d.ts +4 -4
- package/esm/CamScripterAPI.js +3 -9
- package/esm/VapixAPI.d.ts +1 -1
- package/esm/VapixAPI.js +14 -6
- package/esm/errors/errors.d.ts +3 -0
- package/esm/errors/errors.js +6 -0
- package/esm/index.d.ts +3 -0
- package/esm/index.js +3 -0
- package/esm/internal/ProxyClient.d.ts +3 -3
- package/esm/internal/ProxyClient.js +4 -2
- package/esm/internal/common.d.ts +2 -2
- 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/types/CamOverlayAPI.d.ts +315 -175
- package/esm/types/CamOverlayAPI.js +9 -39
- package/esm/types/CamStreamerAPI.d.ts +4 -4
- package/esm/types/CamSwitcherAPI.d.ts +44 -44
- package/esm/types/VapixAPI.d.ts +84 -84
- package/esm/web/DefaultClient.d.ts +7 -4
- package/esm/web/DefaultClient.js +4 -4
- package/package.json +1 -1
package/cjs/CamOverlayAPI.js
CHANGED
|
@@ -1,64 +1,116 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CamOverlayAPI = void 0;
|
|
3
|
+
exports.CamOverlayAPI = exports.BASE_URL = void 0;
|
|
4
4
|
const common_1 = require("./internal/common");
|
|
5
|
-
const DefaultClient_1 = require("./node/DefaultClient");
|
|
6
5
|
const CamOverlayAPI_1 = require("./types/CamOverlayAPI");
|
|
7
6
|
const errors_1 = require("./errors/errors");
|
|
8
7
|
const common_2 = require("./types/common");
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const widgetsSchema_1 = require("./models/CamOverlayAPI/widgetsSchema");
|
|
10
|
+
const fileSchema_1 = require("./models/CamOverlayAPI/fileSchema");
|
|
11
|
+
const utils_1 = require("./internal/utils");
|
|
12
|
+
exports.BASE_URL = '/local/camoverlay/api';
|
|
9
13
|
class CamOverlayAPI {
|
|
10
14
|
client;
|
|
11
|
-
constructor(
|
|
12
|
-
|
|
13
|
-
this.client = options;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
this.client = new DefaultClient_1.DefaultClient(options);
|
|
17
|
-
}
|
|
15
|
+
constructor(client) {
|
|
16
|
+
this.client = client;
|
|
18
17
|
}
|
|
18
|
+
static getProxyUrlPath = () => `${exports.BASE_URL}/proxy.cgi`;
|
|
19
|
+
static getFilePreviewPath = (path) => `${exports.BASE_URL}/file_preview.cgi?path=${encodeURIComponent(path)}`;
|
|
19
20
|
async checkCameraTime() {
|
|
20
|
-
const
|
|
21
|
+
const responseSchema = zod_1.z.discriminatedUnion('state', [
|
|
22
|
+
zod_1.z.object({
|
|
23
|
+
state: zod_1.z.literal(true),
|
|
24
|
+
code: zod_1.z.number(),
|
|
25
|
+
}),
|
|
26
|
+
zod_1.z.object({
|
|
27
|
+
state: zod_1.z.literal(false),
|
|
28
|
+
code: zod_1.z.number(),
|
|
29
|
+
reason: zod_1.z.union([
|
|
30
|
+
zod_1.z.literal('INVALID_TIME'),
|
|
31
|
+
zod_1.z.literal('COULDNT_RESOLVE_HOST'),
|
|
32
|
+
zod_1.z.literal('CONNECTION_ERROR'),
|
|
33
|
+
]),
|
|
34
|
+
message: zod_1.z.string(),
|
|
35
|
+
}),
|
|
36
|
+
]);
|
|
37
|
+
const response = await this._get(`${exports.BASE_URL}/camera_time.cgi`);
|
|
38
|
+
const cameraTime = responseSchema.parse(response);
|
|
39
|
+
if (!cameraTime.state) {
|
|
40
|
+
console.error(`Camera time check failed: ${cameraTime.reason} - ${cameraTime.message}`);
|
|
41
|
+
}
|
|
21
42
|
return cameraTime.state;
|
|
22
43
|
}
|
|
23
44
|
async getNetworkCameraList() {
|
|
24
|
-
const response = await this.
|
|
45
|
+
const response = await this._get(`${exports.BASE_URL}/network_camera_list.cgi`);
|
|
25
46
|
return common_2.networkCameraListSchema.parse(response.camera_list);
|
|
26
47
|
}
|
|
27
|
-
async
|
|
28
|
-
const
|
|
29
|
-
|
|
48
|
+
async wsAuthorization() {
|
|
49
|
+
const responseSchema = zod_1.z.object({
|
|
50
|
+
status: zod_1.z.number(),
|
|
51
|
+
message: zod_1.z.string(),
|
|
52
|
+
data: zod_1.z.string(),
|
|
53
|
+
});
|
|
54
|
+
const response = await this._get(`${exports.BASE_URL}/ws_authorization.cgi`);
|
|
55
|
+
return responseSchema.parse(response).data;
|
|
30
56
|
}
|
|
31
57
|
async getMjpegStreamImage(mjpegUrl) {
|
|
32
|
-
const res = await this.
|
|
58
|
+
const res = await this._get(`${exports.BASE_URL}/fetch_mjpeg_image.cgi?mjpeg_url=${encodeURIComponent(decodeURIComponent(mjpegUrl))}`);
|
|
33
59
|
return await this.parseBlobResponse(res);
|
|
34
60
|
}
|
|
35
61
|
async listFiles(fileType) {
|
|
36
|
-
const
|
|
37
|
-
|
|
62
|
+
const fileDataSchema = zod_1.z.object({
|
|
63
|
+
code: zod_1.z.number(),
|
|
64
|
+
list: fileSchema_1.fileListSchema,
|
|
65
|
+
});
|
|
66
|
+
const files = await this._get(`${exports.BASE_URL}/upload_${fileType}.cgi`, {
|
|
67
|
+
action: 'list',
|
|
68
|
+
});
|
|
69
|
+
return fileSchema_1.fileListSchema.parse(files.list);
|
|
38
70
|
}
|
|
39
|
-
async uploadFile(fileType,
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
71
|
+
async uploadFile(fileType, formData, storage) {
|
|
72
|
+
const path = `${exports.BASE_URL}/upload_${fileType}.cgi`;
|
|
73
|
+
await this._post(path, formData, {
|
|
74
|
+
action: 'upload',
|
|
75
|
+
storage: storage,
|
|
76
|
+
});
|
|
45
77
|
}
|
|
46
|
-
async removeFile(fileType,
|
|
47
|
-
const path =
|
|
48
|
-
await this.
|
|
78
|
+
async removeFile(fileType, fileParams) {
|
|
79
|
+
const path = `${exports.BASE_URL}/upload_${fileType}.cgi`;
|
|
80
|
+
await this._postUrlEncoded(path, {
|
|
81
|
+
action: 'remove',
|
|
82
|
+
...fileParams,
|
|
83
|
+
});
|
|
49
84
|
}
|
|
50
85
|
async getFileStorage(fileType) {
|
|
51
|
-
const
|
|
52
|
-
|
|
86
|
+
const storageDataListSchema = zod_1.z.array(zod_1.z.object({
|
|
87
|
+
type: fileSchema_1.storageSchema,
|
|
88
|
+
state: zod_1.z.string(),
|
|
89
|
+
}));
|
|
90
|
+
const responseSchema = zod_1.z.object({
|
|
91
|
+
code: zod_1.z.number(),
|
|
92
|
+
list: storageDataListSchema,
|
|
93
|
+
});
|
|
94
|
+
const data = await this._get(`${exports.BASE_URL}/upload_${fileType}.cgi`, {
|
|
95
|
+
action: 'get_storage',
|
|
96
|
+
});
|
|
97
|
+
if (data.code !== 200) {
|
|
98
|
+
throw new Error('Error occured while fetching file storage data');
|
|
99
|
+
}
|
|
100
|
+
return storageDataListSchema.parse(data.list);
|
|
101
|
+
}
|
|
102
|
+
async getFilePreviewFromCamera(path) {
|
|
103
|
+
const response = await this._get(CamOverlayAPI.getFilePreviewPath(path));
|
|
104
|
+
return await this.parseBlobResponse(response);
|
|
53
105
|
}
|
|
54
106
|
async updateInfoticker(serviceID, text) {
|
|
55
|
-
await this.
|
|
107
|
+
await this._get(`${exports.BASE_URL}/infoticker.cgi?service_id=${serviceID}&text=${text}`);
|
|
56
108
|
}
|
|
57
109
|
async setEnabled(serviceID, enabled) {
|
|
58
|
-
await this.
|
|
110
|
+
await this._post(`${exports.BASE_URL}/enabled.cgi?id_${serviceID}=${enabled ? 1 : 0}`, '');
|
|
59
111
|
}
|
|
60
112
|
async isEnabled(serviceID) {
|
|
61
|
-
const res = await this.client.get(
|
|
113
|
+
const res = await this.client.get(`${exports.BASE_URL}/services.cgi?action=get`);
|
|
62
114
|
if (res.ok) {
|
|
63
115
|
const data = JSON.parse(await res.text());
|
|
64
116
|
for (const service of data.services) {
|
|
@@ -72,27 +124,38 @@ class CamOverlayAPI {
|
|
|
72
124
|
throw new Error(await (0, common_1.responseStringify)(res));
|
|
73
125
|
}
|
|
74
126
|
}
|
|
75
|
-
async
|
|
76
|
-
const data = await this.
|
|
127
|
+
async getSingleWidget(serviceId) {
|
|
128
|
+
const data = await this._get(`${exports.BASE_URL}/services.cgi`, {
|
|
77
129
|
action: 'get',
|
|
78
130
|
service_id: serviceId.toString(),
|
|
79
131
|
});
|
|
80
|
-
return
|
|
132
|
+
return widgetsSchema_1.widgetsSchema.parse(data);
|
|
81
133
|
}
|
|
82
|
-
async
|
|
83
|
-
const
|
|
84
|
-
|
|
134
|
+
async getWidgets() {
|
|
135
|
+
const widgetList = await this._get(`${exports.BASE_URL}/services.cgi`, {
|
|
136
|
+
action: 'get',
|
|
137
|
+
});
|
|
138
|
+
const widgets = widgetList.services;
|
|
139
|
+
widgets.forEach((widget) => {
|
|
140
|
+
const parsedWidget = widgetsSchema_1.widgetsSchema.safeParse(widget);
|
|
141
|
+
if (!parsedWidget.success) {
|
|
142
|
+
console.warn(`[SERVICE SCHEMA MISMATCH]: Service ${widget.name} (${widget.id}) does not match the current schema, or is a hidden service.`);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return widgets;
|
|
85
146
|
}
|
|
86
|
-
async
|
|
87
|
-
const path =
|
|
88
|
-
await this.
|
|
147
|
+
async updateSingleWidget(widget) {
|
|
148
|
+
const path = `${exports.BASE_URL}/services.cgi`;
|
|
149
|
+
await this._postJsonEncoded(path, JSON.stringify(widget), {
|
|
89
150
|
action: 'set',
|
|
90
|
-
service_id:
|
|
151
|
+
service_id: widget.id.toString(),
|
|
91
152
|
});
|
|
92
153
|
}
|
|
93
|
-
async
|
|
94
|
-
const path =
|
|
95
|
-
await this.
|
|
154
|
+
async updateWidgets(widgets) {
|
|
155
|
+
const path = `${exports.BASE_URL}/services.cgi`;
|
|
156
|
+
await this._postJsonEncoded(path, JSON.stringify({ services: widgets }), {
|
|
157
|
+
action: 'set',
|
|
158
|
+
});
|
|
96
159
|
}
|
|
97
160
|
updateCGText(serviceID, fields) {
|
|
98
161
|
const params = {};
|
|
@@ -132,7 +195,7 @@ class CamOverlayAPI {
|
|
|
132
195
|
return this.promiseCGUpdate(serviceID, 'update_image', params, contentType, imageData);
|
|
133
196
|
}
|
|
134
197
|
async promiseCGUpdate(serviceID, action, params = {}, contentType, data) {
|
|
135
|
-
const path =
|
|
198
|
+
const path = `${exports.BASE_URL}/customGraphics.cgi`;
|
|
136
199
|
let headers = {};
|
|
137
200
|
if (contentType !== undefined && data) {
|
|
138
201
|
headers = { 'Content-Type': contentType };
|
|
@@ -146,24 +209,34 @@ class CamOverlayAPI {
|
|
|
146
209
|
throw new Error(await (0, common_1.responseStringify)(res));
|
|
147
210
|
}
|
|
148
211
|
}
|
|
149
|
-
async
|
|
150
|
-
const res = await this.client.get(
|
|
212
|
+
async _get(...args) {
|
|
213
|
+
const res = await this.client.get(...args);
|
|
151
214
|
if (res.ok) {
|
|
152
|
-
return await res.json();
|
|
215
|
+
return (await res.json());
|
|
153
216
|
}
|
|
154
217
|
else {
|
|
155
218
|
throw new Error(await (0, common_1.responseStringify)(res));
|
|
156
219
|
}
|
|
157
220
|
}
|
|
158
|
-
async
|
|
159
|
-
const res = await this.client.post(
|
|
221
|
+
async _post(...args) {
|
|
222
|
+
const res = await this.client.post(...args);
|
|
160
223
|
if (res.ok) {
|
|
161
|
-
return await res.json();
|
|
224
|
+
return (await res.json());
|
|
162
225
|
}
|
|
163
226
|
else {
|
|
164
227
|
throw new Error(await (0, common_1.responseStringify)(res));
|
|
165
228
|
}
|
|
166
229
|
}
|
|
230
|
+
async _postUrlEncoded(path, params, headers) {
|
|
231
|
+
const data = (0, utils_1.paramToUrl)(params);
|
|
232
|
+
const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
233
|
+
return this._post(path, data, {}, { ...baseHeaders, ...headers });
|
|
234
|
+
}
|
|
235
|
+
async _postJsonEncoded(...args) {
|
|
236
|
+
const [path, data, params, headers] = args;
|
|
237
|
+
const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
|
|
238
|
+
return this._post(path, data, params, { ...baseHeaders, ...headers });
|
|
239
|
+
}
|
|
167
240
|
async parseBlobResponse(response) {
|
|
168
241
|
try {
|
|
169
242
|
return await response.blob();
|
package/cjs/CamScripterAPI.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { IClient } from './internal/common';
|
|
2
|
-
import {
|
|
2
|
+
import { TNodeState, TPackageInfoList, TStorage, TStorageType } from './types/CamScripterAPI';
|
|
3
3
|
import { TNetworkCamera } from './types/common';
|
|
4
|
-
export declare class CamOverlayAPI {
|
|
5
|
-
|
|
6
|
-
constructor(
|
|
4
|
+
export declare class CamOverlayAPI<Client extends IClient = IClient> {
|
|
5
|
+
client: Client;
|
|
6
|
+
constructor(client: Client);
|
|
7
7
|
checkCameraTime(): Promise<boolean>;
|
|
8
8
|
getStorageInfo(): Promise<TStorage>;
|
|
9
9
|
getNetworkCameraList(): Promise<TNetworkCamera[]>;
|
package/cjs/CamScripterAPI.js
CHANGED
|
@@ -2,18 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CamOverlayAPI = void 0;
|
|
4
4
|
const common_1 = require("./internal/common");
|
|
5
|
-
const DefaultClient_1 = require("./node/DefaultClient");
|
|
6
5
|
const CamScripterAPI_1 = require("./types/CamScripterAPI");
|
|
7
6
|
const common_2 = require("./types/common");
|
|
8
7
|
class CamOverlayAPI {
|
|
9
8
|
client;
|
|
10
|
-
constructor(
|
|
11
|
-
|
|
12
|
-
this.client = options;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
this.client = new DefaultClient_1.DefaultClient(options);
|
|
16
|
-
}
|
|
9
|
+
constructor(client) {
|
|
10
|
+
this.client = client;
|
|
17
11
|
}
|
|
18
12
|
async checkCameraTime() {
|
|
19
13
|
return (await this.get('/local/camscripter/camera_time.cgi')).state;
|
package/cjs/VapixAPI.d.ts
CHANGED
|
@@ -36,8 +36,8 @@ export declare class VapixAPI<Client extends IClient = IClient> {
|
|
|
36
36
|
getParameter(paramNames: string | string[], proxy?: TProxyParam): Promise<Record<string, string>>;
|
|
37
37
|
setParameter(params: Record<string, string | number | boolean>, proxy?: TProxyParam): Promise<boolean>;
|
|
38
38
|
getGuardTourList(proxy?: TProxyParam): Promise<{
|
|
39
|
-
name: string;
|
|
40
39
|
id: string;
|
|
40
|
+
name: string;
|
|
41
41
|
running: string;
|
|
42
42
|
tour: {
|
|
43
43
|
moveSpeed?: unknown;
|
package/cjs/VapixAPI.js
CHANGED
|
@@ -51,8 +51,8 @@ class VapixAPI {
|
|
|
51
51
|
}
|
|
52
52
|
async getSupportedAudioSampleRate(proxy = null) {
|
|
53
53
|
const url = '/axis-cgi/audio/streamingcapabilities.cgi';
|
|
54
|
-
const
|
|
55
|
-
const res = await this.postJson(proxy, url,
|
|
54
|
+
const jsonData = { apiVersion: '1.0', method: 'list' };
|
|
55
|
+
const res = await this.postJson(proxy, url, jsonData);
|
|
56
56
|
const encoders = VapixAPI_1.audioSampleRatesResponseSchema.parse(await res.json()).data.encoders;
|
|
57
57
|
const data = encoders.aac ?? encoders.AAC ?? [];
|
|
58
58
|
return data.map((item) => {
|
|
@@ -78,7 +78,7 @@ class VapixAPI {
|
|
|
78
78
|
await this.postJson(proxy, '/axis-cgi/opticscontrol.cgi', data);
|
|
79
79
|
}
|
|
80
80
|
catch (err) {
|
|
81
|
-
await this.
|
|
81
|
+
await this.getUrlEncoded(proxy, '/axis-cgi/opticssetup.cgi', {
|
|
82
82
|
autofocus: 'perform',
|
|
83
83
|
source: '1',
|
|
84
84
|
});
|
|
@@ -292,14 +292,22 @@ class VapixAPI {
|
|
|
292
292
|
query: 'presetposcamdata',
|
|
293
293
|
format: 'json',
|
|
294
294
|
});
|
|
295
|
-
|
|
295
|
+
const text = await response.text();
|
|
296
|
+
if (text === '') {
|
|
297
|
+
throw new errors_1.PtzNotSupportedError();
|
|
298
|
+
}
|
|
299
|
+
return parseCameraPtzResponse(text)[camera] ?? [];
|
|
296
300
|
}
|
|
297
301
|
async listPtzVideoSourceOverview(proxy = null) {
|
|
298
302
|
const response = await this.getUrlEncoded(proxy, '/axis-cgi/com/ptz.cgi', {
|
|
299
303
|
query: 'presetposall',
|
|
300
304
|
format: 'json',
|
|
301
305
|
});
|
|
302
|
-
const
|
|
306
|
+
const text = await response.text();
|
|
307
|
+
if (text === '') {
|
|
308
|
+
throw new errors_1.PtzNotSupportedError();
|
|
309
|
+
}
|
|
310
|
+
const data = parseCameraPtzResponse(text);
|
|
303
311
|
const res = {};
|
|
304
312
|
Object.keys(data)
|
|
305
313
|
.map(Number)
|
package/cjs/errors/errors.d.ts
CHANGED
package/cjs/errors/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AddNewClipError = exports.FetchDeviceInfoError = exports.NoDeviceInfoError = exports.MaxFPSError = exports.SDCardJobError = exports.SDCardActionError = exports.ApplicationAPIError = exports.ParsingBlobError = exports.ServiceNotFoundError = exports.ServiceUnavailableError = void 0;
|
|
3
|
+
exports.PtzNotSupportedError = exports.AddNewClipError = exports.FetchDeviceInfoError = exports.NoDeviceInfoError = exports.MaxFPSError = exports.SDCardJobError = exports.SDCardActionError = exports.ApplicationAPIError = exports.ParsingBlobError = exports.ServiceNotFoundError = exports.ServiceUnavailableError = void 0;
|
|
4
4
|
class ServiceUnavailableError extends Error {
|
|
5
5
|
constructor() {
|
|
6
6
|
super('Service is unavailable.');
|
|
@@ -77,3 +77,10 @@ class AddNewClipError extends Error {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
exports.AddNewClipError = AddNewClipError;
|
|
80
|
+
class PtzNotSupportedError extends Error {
|
|
81
|
+
constructor() {
|
|
82
|
+
super('Ptz not supported.');
|
|
83
|
+
this.name = 'PtzNotSupportedError';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.PtzNotSupportedError = PtzNotSupportedError;
|
package/cjs/index.d.ts
CHANGED
|
@@ -6,6 +6,9 @@ export * from './types/common';
|
|
|
6
6
|
export { CamSwitcherAPI } from './CamSwitcherAPI';
|
|
7
7
|
export { CamSwitcherEvents } from './CamSwitcherEvents';
|
|
8
8
|
export { VapixAPI } from './VapixAPI';
|
|
9
|
+
export { CamOverlayAPI } from './CamOverlayAPI';
|
|
9
10
|
export * from './types/CamSwitcherEvents';
|
|
10
11
|
export * from './types/CamSwitcherAPI';
|
|
11
12
|
export * from './types/VapixAPI';
|
|
13
|
+
export * from './types/CamOverlayAPI';
|
|
14
|
+
export * from './models/CamOverlayAPI';
|
package/cjs/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.VapixAPI = exports.CamSwitcherEvents = exports.CamSwitcherAPI = void 0;
|
|
17
|
+
exports.CamOverlayAPI = exports.VapixAPI = exports.CamSwitcherEvents = exports.CamSwitcherAPI = void 0;
|
|
18
18
|
__exportStar(require("./internal/common"), exports);
|
|
19
19
|
__exportStar(require("./internal/constants"), exports);
|
|
20
20
|
__exportStar(require("./internal/utils"), exports);
|
|
@@ -26,6 +26,10 @@ var CamSwitcherEvents_1 = require("./CamSwitcherEvents");
|
|
|
26
26
|
Object.defineProperty(exports, "CamSwitcherEvents", { enumerable: true, get: function () { return CamSwitcherEvents_1.CamSwitcherEvents; } });
|
|
27
27
|
var VapixAPI_1 = require("./VapixAPI");
|
|
28
28
|
Object.defineProperty(exports, "VapixAPI", { enumerable: true, get: function () { return VapixAPI_1.VapixAPI; } });
|
|
29
|
+
var CamOverlayAPI_1 = require("./CamOverlayAPI");
|
|
30
|
+
Object.defineProperty(exports, "CamOverlayAPI", { enumerable: true, get: function () { return CamOverlayAPI_1.CamOverlayAPI; } });
|
|
29
31
|
__exportStar(require("./types/CamSwitcherEvents"), exports);
|
|
30
32
|
__exportStar(require("./types/CamSwitcherAPI"), exports);
|
|
31
33
|
__exportStar(require("./types/VapixAPI"), exports);
|
|
34
|
+
__exportStar(require("./types/CamOverlayAPI"), exports);
|
|
35
|
+
__exportStar(require("./models/CamOverlayAPI"), exports);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { IClient
|
|
2
|
+
import { IClient } from './common';
|
|
3
3
|
import { TProxyParam } from '../types/common';
|
|
4
4
|
export declare class ProxyClient<Client extends IClient = IClient> {
|
|
5
5
|
client: Client;
|
|
6
6
|
getProxyUrl: () => string;
|
|
7
7
|
constructor(client: Client, getProxyUrl: () => string);
|
|
8
|
-
get: (proxy: TProxyParam,
|
|
9
|
-
post: (proxy: TProxyParam,
|
|
8
|
+
get: (proxy: TProxyParam, url: string, parameters?: import("./common").TParameters | undefined, headers?: Record<string, string> | undefined) => Promise<import("./common").TResponse>;
|
|
9
|
+
post: (proxy: TProxyParam, url: string, data: string | Buffer | FormData, parameters?: import("./common").TParameters | undefined, headers?: Record<string, string> | undefined) => Promise<import("./common").TResponse>;
|
|
10
10
|
private getReal;
|
|
11
11
|
}
|
|
@@ -9,12 +9,14 @@ class ProxyClient {
|
|
|
9
9
|
this.client = client;
|
|
10
10
|
this.getProxyUrl = getProxyUrl;
|
|
11
11
|
}
|
|
12
|
-
get = (proxy,
|
|
12
|
+
get = (proxy, ...args) => {
|
|
13
|
+
const [path, parameters, headers] = args;
|
|
13
14
|
const url = (0, utils_1.addParametersToPath)(path, parameters);
|
|
14
15
|
const { realUrl, realHeaders } = this.getReal(proxy, url, headers);
|
|
15
16
|
return this.client.get(realUrl, {}, realHeaders);
|
|
16
17
|
};
|
|
17
|
-
post = (proxy,
|
|
18
|
+
post = (proxy, ...args) => {
|
|
19
|
+
const [path, data, parameters, headers] = args;
|
|
18
20
|
const url = (0, utils_1.addParametersToPath)(path, parameters);
|
|
19
21
|
const { realUrl, realHeaders } = this.getReal(proxy, url, headers);
|
|
20
22
|
return this.client.post(realUrl, data, {}, realHeaders);
|
package/cjs/internal/common.d.ts
CHANGED
|
@@ -19,8 +19,8 @@ export type TResponse = {
|
|
|
19
19
|
body: any | null;
|
|
20
20
|
};
|
|
21
21
|
export type TParameters = Record<string, string | number | boolean | null | undefined>;
|
|
22
|
-
export type TGetFunction = (url: string, parameters?: TParameters, headers?: Record<string, string>) => Promise<
|
|
23
|
-
export type TPostFunction = (url: string, data: string | Buffer | FormData, parameters?: TParameters, headers?: Record<string, string>) => Promise<
|
|
22
|
+
export type TGetFunction<TRes = TResponse> = (url: string, parameters?: TParameters, headers?: Record<string, string>) => Promise<TRes>;
|
|
23
|
+
export type TPostFunction<TRes = TResponse> = (url: string, data: string | Buffer | FormData, parameters?: TParameters, headers?: Record<string, string>) => Promise<TRes>;
|
|
24
24
|
export interface IClient {
|
|
25
25
|
get: TGetFunction;
|
|
26
26
|
post: TPostFunction;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const accuweatherSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodNumber;
|
|
4
|
+
enabled: z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>;
|
|
5
|
+
automationType: z.ZodUnion<[z.ZodLiteral<"time">, z.ZodLiteral<"manual">, z.ZodLiteral<"schedule">, z.ZodType<`input${number}`, z.ZodTypeDef, `input${number}`>]>;
|
|
6
|
+
invertInput: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
cameraList: z.ZodArray<z.ZodNumber, "many">;
|
|
8
|
+
camera: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
schedule: z.ZodOptional<z.ZodString>;
|
|
10
|
+
customName: z.ZodString;
|
|
11
|
+
zIndex: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
width: z.ZodNumber;
|
|
13
|
+
height: z.ZodNumber;
|
|
14
|
+
} & {
|
|
15
|
+
name: z.ZodLiteral<"accuweather">;
|
|
16
|
+
location: z.ZodString;
|
|
17
|
+
locationName: z.ZodString;
|
|
18
|
+
title: z.ZodString;
|
|
19
|
+
bgStartColor: z.ZodUnion<[z.ZodLiteral<"237,143,73,0.93">, z.ZodLiteral<"0,0,0,0.75">, z.ZodLiteral<"31,32,73,0.9">, z.ZodLiteral<"76,94,127,0.95">]>;
|
|
20
|
+
bgEndColor: z.ZodUnion<[z.ZodLiteral<"234,181,89,0.93">, z.ZodLiteral<"0,0,0,0.75">, z.ZodLiteral<"73,96,213,0.9">, z.ZodLiteral<"140,150,168,0.95">]>;
|
|
21
|
+
clockType: z.ZodUnion<[z.ZodLiteral<"12h">, z.ZodLiteral<"24h">]>;
|
|
22
|
+
lang: z.ZodUnion<[z.ZodLiteral<"en-us">, z.ZodLiteral<"fr-fr">, z.ZodLiteral<"ja-jp">, z.ZodLiteral<"pt-pt">, z.ZodLiteral<"es-es">, z.ZodLiteral<"de-de">, z.ZodLiteral<"ko-kr">, z.ZodLiteral<"zh-hk">, z.ZodLiteral<"zh-cn">, z.ZodLiteral<"nl-nl">, z.ZodLiteral<"cs-cz">, z.ZodLiteral<"ru-ru">, z.ZodLiteral<"sv-se">]>;
|
|
23
|
+
font: z.ZodUnion<[z.ZodLiteral<"classic">, z.ZodLiteral<"digital">, z.ZodType<string, z.ZodTypeDef, string>]>;
|
|
24
|
+
units: z.ZodUnion<[z.ZodLiteral<"Metric">, z.ZodLiteral<"Imperial">]>;
|
|
25
|
+
pos_x: z.ZodNumber;
|
|
26
|
+
pos_y: z.ZodNumber;
|
|
27
|
+
coordSystem: z.ZodUnion<[z.ZodLiteral<"top_left">, z.ZodLiteral<"top">, z.ZodLiteral<"top_right">, z.ZodLiteral<"left">, z.ZodLiteral<"center">, z.ZodLiteral<"right">, z.ZodLiteral<"bottom_left">, z.ZodLiteral<"bottom">, z.ZodLiteral<"bottom_right">]>;
|
|
28
|
+
layout: z.ZodUnion<[z.ZodLiteral<"0">, z.ZodLiteral<"1">, z.ZodLiteral<"2">, z.ZodLiteral<"3">, z.ZodLiteral<"4">, z.ZodLiteral<"5">, z.ZodLiteral<"6">, z.ZodLiteral<"7">, z.ZodLiteral<"8">, z.ZodLiteral<"9">, z.ZodLiteral<"10">, z.ZodLiteral<"11">, z.ZodLiteral<"12">, z.ZodLiteral<"13">]>;
|
|
29
|
+
scale: z.ZodNumber;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
id: number;
|
|
32
|
+
enabled: 0 | 1;
|
|
33
|
+
automationType: "time" | "manual" | "schedule" | `input${number}`;
|
|
34
|
+
cameraList: number[];
|
|
35
|
+
customName: string;
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
coordSystem: "top_left" | "top" | "top_right" | "left" | "center" | "right" | "bottom_left" | "bottom" | "bottom_right";
|
|
39
|
+
pos_x: number;
|
|
40
|
+
pos_y: number;
|
|
41
|
+
scale: number;
|
|
42
|
+
name: "accuweather";
|
|
43
|
+
font: string;
|
|
44
|
+
location: string;
|
|
45
|
+
locationName: string;
|
|
46
|
+
title: string;
|
|
47
|
+
bgStartColor: "237,143,73,0.93" | "0,0,0,0.75" | "31,32,73,0.9" | "76,94,127,0.95";
|
|
48
|
+
bgEndColor: "0,0,0,0.75" | "234,181,89,0.93" | "73,96,213,0.9" | "140,150,168,0.95";
|
|
49
|
+
clockType: "12h" | "24h";
|
|
50
|
+
lang: "en-us" | "fr-fr" | "ja-jp" | "pt-pt" | "es-es" | "de-de" | "ko-kr" | "zh-hk" | "zh-cn" | "nl-nl" | "cs-cz" | "ru-ru" | "sv-se";
|
|
51
|
+
units: "Metric" | "Imperial";
|
|
52
|
+
layout: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "13";
|
|
53
|
+
schedule?: string | undefined;
|
|
54
|
+
invertInput?: boolean | undefined;
|
|
55
|
+
camera?: number | undefined;
|
|
56
|
+
zIndex?: number | undefined;
|
|
57
|
+
}, {
|
|
58
|
+
id: number;
|
|
59
|
+
enabled: 0 | 1;
|
|
60
|
+
automationType: "time" | "manual" | "schedule" | `input${number}`;
|
|
61
|
+
cameraList: number[];
|
|
62
|
+
customName: string;
|
|
63
|
+
width: number;
|
|
64
|
+
height: number;
|
|
65
|
+
coordSystem: "top_left" | "top" | "top_right" | "left" | "center" | "right" | "bottom_left" | "bottom" | "bottom_right";
|
|
66
|
+
pos_x: number;
|
|
67
|
+
pos_y: number;
|
|
68
|
+
scale: number;
|
|
69
|
+
name: "accuweather";
|
|
70
|
+
font: string;
|
|
71
|
+
location: string;
|
|
72
|
+
locationName: string;
|
|
73
|
+
title: string;
|
|
74
|
+
bgStartColor: "237,143,73,0.93" | "0,0,0,0.75" | "31,32,73,0.9" | "76,94,127,0.95";
|
|
75
|
+
bgEndColor: "0,0,0,0.75" | "234,181,89,0.93" | "73,96,213,0.9" | "140,150,168,0.95";
|
|
76
|
+
clockType: "12h" | "24h";
|
|
77
|
+
lang: "en-us" | "fr-fr" | "ja-jp" | "pt-pt" | "es-es" | "de-de" | "ko-kr" | "zh-hk" | "zh-cn" | "nl-nl" | "cs-cz" | "ru-ru" | "sv-se";
|
|
78
|
+
units: "Metric" | "Imperial";
|
|
79
|
+
layout: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12" | "13";
|
|
80
|
+
schedule?: string | undefined;
|
|
81
|
+
invertInput?: boolean | undefined;
|
|
82
|
+
camera?: number | undefined;
|
|
83
|
+
zIndex?: number | undefined;
|
|
84
|
+
}>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.accuweatherSchema = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const widgetCommonSchema_1 = require("./widgetCommonSchema");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
exports.accuweatherSchema = widgetCommonSchema_1.widgetCommonSchema.extend({
|
|
8
|
+
name: zod_1.z.literal(constants_1.allowedWidgetNames.accuweather),
|
|
9
|
+
location: zod_1.z.string(),
|
|
10
|
+
locationName: zod_1.z.string(),
|
|
11
|
+
title: zod_1.z.string(),
|
|
12
|
+
bgStartColor: zod_1.z.union([
|
|
13
|
+
zod_1.z.literal('237,143,73,0.93'),
|
|
14
|
+
zod_1.z.literal('0,0,0,0.75'),
|
|
15
|
+
zod_1.z.literal('31,32,73,0.9'),
|
|
16
|
+
zod_1.z.literal('76,94,127,0.95'),
|
|
17
|
+
]),
|
|
18
|
+
bgEndColor: zod_1.z.union([
|
|
19
|
+
zod_1.z.literal('234,181,89,0.93'),
|
|
20
|
+
zod_1.z.literal('0,0,0,0.75'),
|
|
21
|
+
zod_1.z.literal('73,96,213,0.9'),
|
|
22
|
+
zod_1.z.literal('140,150,168,0.95'),
|
|
23
|
+
]),
|
|
24
|
+
clockType: zod_1.z.union([zod_1.z.literal('12h'), zod_1.z.literal('24h')]),
|
|
25
|
+
lang: widgetCommonSchema_1.languageSchema,
|
|
26
|
+
font: widgetCommonSchema_1.fontSchema,
|
|
27
|
+
units: widgetCommonSchema_1.weatherUnitSchema,
|
|
28
|
+
pos_x: zod_1.z.number(),
|
|
29
|
+
pos_y: zod_1.z.number(),
|
|
30
|
+
coordSystem: widgetCommonSchema_1.coordinateSystemSchema,
|
|
31
|
+
layout: zod_1.z.union([
|
|
32
|
+
zod_1.z.literal('0'),
|
|
33
|
+
zod_1.z.literal('1'),
|
|
34
|
+
zod_1.z.literal('2'),
|
|
35
|
+
zod_1.z.literal('3'),
|
|
36
|
+
zod_1.z.literal('4'),
|
|
37
|
+
zod_1.z.literal('5'),
|
|
38
|
+
zod_1.z.literal('6'),
|
|
39
|
+
zod_1.z.literal('7'),
|
|
40
|
+
zod_1.z.literal('8'),
|
|
41
|
+
zod_1.z.literal('9'),
|
|
42
|
+
zod_1.z.literal('10'),
|
|
43
|
+
zod_1.z.literal('11'),
|
|
44
|
+
zod_1.z.literal('12'),
|
|
45
|
+
zod_1.z.literal('13'),
|
|
46
|
+
]),
|
|
47
|
+
scale: zod_1.z.number().nonnegative(),
|
|
48
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const allowedWidgetNames: {
|
|
2
|
+
readonly accuweather: "accuweather";
|
|
3
|
+
readonly infoticker: "infoticker";
|
|
4
|
+
readonly customGraphics: "customGraphics";
|
|
5
|
+
readonly ptzCompass: "ptzCompass";
|
|
6
|
+
readonly images: "images";
|
|
7
|
+
readonly ptz: "ptz";
|
|
8
|
+
readonly pip: "pip";
|
|
9
|
+
readonly screenSharing: "screenSharing";
|
|
10
|
+
readonly web_camera: "web_camera";
|
|
11
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allowedWidgetNames = void 0;
|
|
4
|
+
exports.allowedWidgetNames = {
|
|
5
|
+
accuweather: 'accuweather',
|
|
6
|
+
infoticker: 'infoticker',
|
|
7
|
+
customGraphics: 'customGraphics',
|
|
8
|
+
ptzCompass: 'ptzCompass',
|
|
9
|
+
images: 'images',
|
|
10
|
+
ptz: 'ptz',
|
|
11
|
+
pip: 'pip',
|
|
12
|
+
screenSharing: 'screenSharing',
|
|
13
|
+
web_camera: 'web_camera',
|
|
14
|
+
};
|