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/esm/CamOverlayAPI.js
CHANGED
|
@@ -1,61 +1,113 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { fileListSchema, ImageType, serviceSchema, storageSchema, } from './types/CamOverlayAPI';
|
|
1
|
+
import { responseStringify } from './internal/common';
|
|
2
|
+
import { ImageType, } from './types/CamOverlayAPI';
|
|
4
3
|
import { ParsingBlobError, ServiceNotFoundError } from './errors/errors';
|
|
5
4
|
import { networkCameraListSchema } from './types/common';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { widgetsSchema } from './models/CamOverlayAPI/widgetsSchema';
|
|
7
|
+
import { fileListSchema, storageSchema } from './models/CamOverlayAPI/fileSchema';
|
|
8
|
+
import { paramToUrl } from './internal/utils';
|
|
9
|
+
export const BASE_URL = '/local/camoverlay/api';
|
|
6
10
|
export class CamOverlayAPI {
|
|
7
11
|
client;
|
|
8
|
-
constructor(
|
|
9
|
-
|
|
10
|
-
this.client = options;
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
this.client = new DefaultClient(options);
|
|
14
|
-
}
|
|
12
|
+
constructor(client) {
|
|
13
|
+
this.client = client;
|
|
15
14
|
}
|
|
15
|
+
static getProxyUrlPath = () => `${BASE_URL}/proxy.cgi`;
|
|
16
|
+
static getFilePreviewPath = (path) => `${BASE_URL}/file_preview.cgi?path=${encodeURIComponent(path)}`;
|
|
16
17
|
async checkCameraTime() {
|
|
17
|
-
const
|
|
18
|
+
const responseSchema = z.discriminatedUnion('state', [
|
|
19
|
+
z.object({
|
|
20
|
+
state: z.literal(true),
|
|
21
|
+
code: z.number(),
|
|
22
|
+
}),
|
|
23
|
+
z.object({
|
|
24
|
+
state: z.literal(false),
|
|
25
|
+
code: z.number(),
|
|
26
|
+
reason: z.union([
|
|
27
|
+
z.literal('INVALID_TIME'),
|
|
28
|
+
z.literal('COULDNT_RESOLVE_HOST'),
|
|
29
|
+
z.literal('CONNECTION_ERROR'),
|
|
30
|
+
]),
|
|
31
|
+
message: z.string(),
|
|
32
|
+
}),
|
|
33
|
+
]);
|
|
34
|
+
const response = await this._get(`${BASE_URL}/camera_time.cgi`);
|
|
35
|
+
const cameraTime = responseSchema.parse(response);
|
|
36
|
+
if (!cameraTime.state) {
|
|
37
|
+
console.error(`Camera time check failed: ${cameraTime.reason} - ${cameraTime.message}`);
|
|
38
|
+
}
|
|
18
39
|
return cameraTime.state;
|
|
19
40
|
}
|
|
20
41
|
async getNetworkCameraList() {
|
|
21
|
-
const response = await this.
|
|
42
|
+
const response = await this._get(`${BASE_URL}/network_camera_list.cgi`);
|
|
22
43
|
return networkCameraListSchema.parse(response.camera_list);
|
|
23
44
|
}
|
|
24
|
-
async
|
|
25
|
-
const
|
|
26
|
-
|
|
45
|
+
async wsAuthorization() {
|
|
46
|
+
const responseSchema = z.object({
|
|
47
|
+
status: z.number(),
|
|
48
|
+
message: z.string(),
|
|
49
|
+
data: z.string(),
|
|
50
|
+
});
|
|
51
|
+
const response = await this._get(`${BASE_URL}/ws_authorization.cgi`);
|
|
52
|
+
return responseSchema.parse(response).data;
|
|
27
53
|
}
|
|
28
54
|
async getMjpegStreamImage(mjpegUrl) {
|
|
29
|
-
const res = await this.
|
|
55
|
+
const res = await this._get(`${BASE_URL}/fetch_mjpeg_image.cgi?mjpeg_url=${encodeURIComponent(decodeURIComponent(mjpegUrl))}`);
|
|
30
56
|
return await this.parseBlobResponse(res);
|
|
31
57
|
}
|
|
32
58
|
async listFiles(fileType) {
|
|
33
|
-
const
|
|
59
|
+
const fileDataSchema = z.object({
|
|
60
|
+
code: z.number(),
|
|
61
|
+
list: fileListSchema,
|
|
62
|
+
});
|
|
63
|
+
const files = await this._get(`${BASE_URL}/upload_${fileType}.cgi`, {
|
|
64
|
+
action: 'list',
|
|
65
|
+
});
|
|
34
66
|
return fileListSchema.parse(files.list);
|
|
35
67
|
}
|
|
36
|
-
async uploadFile(fileType,
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
68
|
+
async uploadFile(fileType, formData, storage) {
|
|
69
|
+
const path = `${BASE_URL}/upload_${fileType}.cgi`;
|
|
70
|
+
await this._post(path, formData, {
|
|
71
|
+
action: 'upload',
|
|
72
|
+
storage: storage,
|
|
73
|
+
});
|
|
42
74
|
}
|
|
43
|
-
async removeFile(fileType,
|
|
44
|
-
const path =
|
|
45
|
-
await this.
|
|
75
|
+
async removeFile(fileType, fileParams) {
|
|
76
|
+
const path = `${BASE_URL}/upload_${fileType}.cgi`;
|
|
77
|
+
await this._postUrlEncoded(path, {
|
|
78
|
+
action: 'remove',
|
|
79
|
+
...fileParams,
|
|
80
|
+
});
|
|
46
81
|
}
|
|
47
82
|
async getFileStorage(fileType) {
|
|
48
|
-
const
|
|
49
|
-
|
|
83
|
+
const storageDataListSchema = z.array(z.object({
|
|
84
|
+
type: storageSchema,
|
|
85
|
+
state: z.string(),
|
|
86
|
+
}));
|
|
87
|
+
const responseSchema = z.object({
|
|
88
|
+
code: z.number(),
|
|
89
|
+
list: storageDataListSchema,
|
|
90
|
+
});
|
|
91
|
+
const data = await this._get(`${BASE_URL}/upload_${fileType}.cgi`, {
|
|
92
|
+
action: 'get_storage',
|
|
93
|
+
});
|
|
94
|
+
if (data.code !== 200) {
|
|
95
|
+
throw new Error('Error occured while fetching file storage data');
|
|
96
|
+
}
|
|
97
|
+
return storageDataListSchema.parse(data.list);
|
|
98
|
+
}
|
|
99
|
+
async getFilePreviewFromCamera(path) {
|
|
100
|
+
const response = await this._get(CamOverlayAPI.getFilePreviewPath(path));
|
|
101
|
+
return await this.parseBlobResponse(response);
|
|
50
102
|
}
|
|
51
103
|
async updateInfoticker(serviceID, text) {
|
|
52
|
-
await this.
|
|
104
|
+
await this._get(`${BASE_URL}/infoticker.cgi?service_id=${serviceID}&text=${text}`);
|
|
53
105
|
}
|
|
54
106
|
async setEnabled(serviceID, enabled) {
|
|
55
|
-
await this.
|
|
107
|
+
await this._post(`${BASE_URL}/enabled.cgi?id_${serviceID}=${enabled ? 1 : 0}`, '');
|
|
56
108
|
}
|
|
57
109
|
async isEnabled(serviceID) {
|
|
58
|
-
const res = await this.client.get(
|
|
110
|
+
const res = await this.client.get(`${BASE_URL}/services.cgi?action=get`);
|
|
59
111
|
if (res.ok) {
|
|
60
112
|
const data = JSON.parse(await res.text());
|
|
61
113
|
for (const service of data.services) {
|
|
@@ -69,27 +121,38 @@ export class CamOverlayAPI {
|
|
|
69
121
|
throw new Error(await responseStringify(res));
|
|
70
122
|
}
|
|
71
123
|
}
|
|
72
|
-
async
|
|
73
|
-
const data = await this.
|
|
124
|
+
async getSingleWidget(serviceId) {
|
|
125
|
+
const data = await this._get(`${BASE_URL}/services.cgi`, {
|
|
74
126
|
action: 'get',
|
|
75
127
|
service_id: serviceId.toString(),
|
|
76
128
|
});
|
|
77
|
-
return
|
|
129
|
+
return widgetsSchema.parse(data);
|
|
78
130
|
}
|
|
79
|
-
async
|
|
80
|
-
const
|
|
81
|
-
|
|
131
|
+
async getWidgets() {
|
|
132
|
+
const widgetList = await this._get(`${BASE_URL}/services.cgi`, {
|
|
133
|
+
action: 'get',
|
|
134
|
+
});
|
|
135
|
+
const widgets = widgetList.services;
|
|
136
|
+
widgets.forEach((widget) => {
|
|
137
|
+
const parsedWidget = widgetsSchema.safeParse(widget);
|
|
138
|
+
if (!parsedWidget.success) {
|
|
139
|
+
console.warn(`[SERVICE SCHEMA MISMATCH]: Service ${widget.name} (${widget.id}) does not match the current schema, or is a hidden service.`);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
return widgets;
|
|
82
143
|
}
|
|
83
|
-
async
|
|
84
|
-
const path =
|
|
85
|
-
await this.
|
|
144
|
+
async updateSingleWidget(widget) {
|
|
145
|
+
const path = `${BASE_URL}/services.cgi`;
|
|
146
|
+
await this._postJsonEncoded(path, JSON.stringify(widget), {
|
|
86
147
|
action: 'set',
|
|
87
|
-
service_id:
|
|
148
|
+
service_id: widget.id.toString(),
|
|
88
149
|
});
|
|
89
150
|
}
|
|
90
|
-
async
|
|
91
|
-
const path =
|
|
92
|
-
await this.
|
|
151
|
+
async updateWidgets(widgets) {
|
|
152
|
+
const path = `${BASE_URL}/services.cgi`;
|
|
153
|
+
await this._postJsonEncoded(path, JSON.stringify({ services: widgets }), {
|
|
154
|
+
action: 'set',
|
|
155
|
+
});
|
|
93
156
|
}
|
|
94
157
|
updateCGText(serviceID, fields) {
|
|
95
158
|
const params = {};
|
|
@@ -129,7 +192,7 @@ export class CamOverlayAPI {
|
|
|
129
192
|
return this.promiseCGUpdate(serviceID, 'update_image', params, contentType, imageData);
|
|
130
193
|
}
|
|
131
194
|
async promiseCGUpdate(serviceID, action, params = {}, contentType, data) {
|
|
132
|
-
const path =
|
|
195
|
+
const path = `${BASE_URL}/customGraphics.cgi`;
|
|
133
196
|
let headers = {};
|
|
134
197
|
if (contentType !== undefined && data) {
|
|
135
198
|
headers = { 'Content-Type': contentType };
|
|
@@ -143,24 +206,34 @@ export class CamOverlayAPI {
|
|
|
143
206
|
throw new Error(await responseStringify(res));
|
|
144
207
|
}
|
|
145
208
|
}
|
|
146
|
-
async
|
|
147
|
-
const res = await this.client.get(
|
|
209
|
+
async _get(...args) {
|
|
210
|
+
const res = await this.client.get(...args);
|
|
148
211
|
if (res.ok) {
|
|
149
|
-
return await res.json();
|
|
212
|
+
return (await res.json());
|
|
150
213
|
}
|
|
151
214
|
else {
|
|
152
215
|
throw new Error(await responseStringify(res));
|
|
153
216
|
}
|
|
154
217
|
}
|
|
155
|
-
async
|
|
156
|
-
const res = await this.client.post(
|
|
218
|
+
async _post(...args) {
|
|
219
|
+
const res = await this.client.post(...args);
|
|
157
220
|
if (res.ok) {
|
|
158
|
-
return await res.json();
|
|
221
|
+
return (await res.json());
|
|
159
222
|
}
|
|
160
223
|
else {
|
|
161
224
|
throw new Error(await responseStringify(res));
|
|
162
225
|
}
|
|
163
226
|
}
|
|
227
|
+
async _postUrlEncoded(path, params, headers) {
|
|
228
|
+
const data = paramToUrl(params);
|
|
229
|
+
const baseHeaders = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
230
|
+
return this._post(path, data, {}, { ...baseHeaders, ...headers });
|
|
231
|
+
}
|
|
232
|
+
async _postJsonEncoded(...args) {
|
|
233
|
+
const [path, data, params, headers] = args;
|
|
234
|
+
const baseHeaders = { 'Accept': 'application/json', 'Content-Type': 'application/json' };
|
|
235
|
+
return this._post(path, data, params, { ...baseHeaders, ...headers });
|
|
236
|
+
}
|
|
164
237
|
async parseBlobResponse(response) {
|
|
165
238
|
try {
|
|
166
239
|
return await response.blob();
|
package/esm/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/esm/CamScripterAPI.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DefaultClient } from './node/DefaultClient';
|
|
1
|
+
import { responseStringify } from './internal/common';
|
|
3
2
|
import { packageInfoListSchema, storageSchema, } from './types/CamScripterAPI';
|
|
4
3
|
import { networkCameraListSchema } from './types/common';
|
|
5
4
|
export class CamOverlayAPI {
|
|
6
5
|
client;
|
|
7
|
-
constructor(
|
|
8
|
-
|
|
9
|
-
this.client = options;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
this.client = new DefaultClient(options);
|
|
13
|
-
}
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
14
8
|
}
|
|
15
9
|
async checkCameraTime() {
|
|
16
10
|
return (await this.get('/local/camscripter/camera_time.cgi')).state;
|
package/esm/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/esm/VapixAPI.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as prettifyXml from 'prettify-xml';
|
|
|
2
2
|
import { parseStringPromise } from 'xml2js';
|
|
3
3
|
import { isNullish, responseStringify } from './internal/common';
|
|
4
4
|
import { sdCardWatchedStatuses, APP_IDS, maxFpsResponseSchema, dateTimeinfoSchema, audioDeviceRequestSchema, audioSampleRatesResponseSchema, } from './types/VapixAPI';
|
|
5
|
-
import { ApplicationAPIError, MaxFPSError, NoDeviceInfoError, SDCardActionError, SDCardJobError, } from './errors/errors';
|
|
5
|
+
import { ApplicationAPIError, MaxFPSError, NoDeviceInfoError, PtzNotSupportedError, SDCardActionError, SDCardJobError, } from './errors/errors';
|
|
6
6
|
import { ProxyClient } from './internal/ProxyClient';
|
|
7
7
|
import { arrayToUrl, paramToUrl } from './internal/utils';
|
|
8
8
|
import { z } from 'zod';
|
|
@@ -48,8 +48,8 @@ export class VapixAPI {
|
|
|
48
48
|
}
|
|
49
49
|
async getSupportedAudioSampleRate(proxy = null) {
|
|
50
50
|
const url = '/axis-cgi/audio/streamingcapabilities.cgi';
|
|
51
|
-
const
|
|
52
|
-
const res = await this.postJson(proxy, url,
|
|
51
|
+
const jsonData = { apiVersion: '1.0', method: 'list' };
|
|
52
|
+
const res = await this.postJson(proxy, url, jsonData);
|
|
53
53
|
const encoders = audioSampleRatesResponseSchema.parse(await res.json()).data.encoders;
|
|
54
54
|
const data = encoders.aac ?? encoders.AAC ?? [];
|
|
55
55
|
return data.map((item) => {
|
|
@@ -75,7 +75,7 @@ export class VapixAPI {
|
|
|
75
75
|
await this.postJson(proxy, '/axis-cgi/opticscontrol.cgi', data);
|
|
76
76
|
}
|
|
77
77
|
catch (err) {
|
|
78
|
-
await this.
|
|
78
|
+
await this.getUrlEncoded(proxy, '/axis-cgi/opticssetup.cgi', {
|
|
79
79
|
autofocus: 'perform',
|
|
80
80
|
source: '1',
|
|
81
81
|
});
|
|
@@ -289,14 +289,22 @@ export class VapixAPI {
|
|
|
289
289
|
query: 'presetposcamdata',
|
|
290
290
|
format: 'json',
|
|
291
291
|
});
|
|
292
|
-
|
|
292
|
+
const text = await response.text();
|
|
293
|
+
if (text === '') {
|
|
294
|
+
throw new PtzNotSupportedError();
|
|
295
|
+
}
|
|
296
|
+
return parseCameraPtzResponse(text)[camera] ?? [];
|
|
293
297
|
}
|
|
294
298
|
async listPtzVideoSourceOverview(proxy = null) {
|
|
295
299
|
const response = await this.getUrlEncoded(proxy, '/axis-cgi/com/ptz.cgi', {
|
|
296
300
|
query: 'presetposall',
|
|
297
301
|
format: 'json',
|
|
298
302
|
});
|
|
299
|
-
const
|
|
303
|
+
const text = await response.text();
|
|
304
|
+
if (text === '') {
|
|
305
|
+
throw new PtzNotSupportedError();
|
|
306
|
+
}
|
|
307
|
+
const data = parseCameraPtzResponse(text);
|
|
300
308
|
const res = {};
|
|
301
309
|
Object.keys(data)
|
|
302
310
|
.map(Number)
|
package/esm/errors/errors.d.ts
CHANGED
package/esm/errors/errors.js
CHANGED
package/esm/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/esm/index.js
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';
|
|
@@ -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
|
}
|
|
@@ -6,12 +6,14 @@ export class ProxyClient {
|
|
|
6
6
|
this.client = client;
|
|
7
7
|
this.getProxyUrl = getProxyUrl;
|
|
8
8
|
}
|
|
9
|
-
get = (proxy,
|
|
9
|
+
get = (proxy, ...args) => {
|
|
10
|
+
const [path, parameters, headers] = args;
|
|
10
11
|
const url = addParametersToPath(path, parameters);
|
|
11
12
|
const { realUrl, realHeaders } = this.getReal(proxy, url, headers);
|
|
12
13
|
return this.client.get(realUrl, {}, realHeaders);
|
|
13
14
|
};
|
|
14
|
-
post = (proxy,
|
|
15
|
+
post = (proxy, ...args) => {
|
|
16
|
+
const [path, data, parameters, headers] = args;
|
|
15
17
|
const url = addParametersToPath(path, parameters);
|
|
16
18
|
const { realUrl, realHeaders } = this.getReal(proxy, url, headers);
|
|
17
19
|
return this.client.post(realUrl, data, {}, realHeaders);
|
package/esm/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,45 @@
|
|
|
1
|
+
import { allowedWidgetNames } from './constants';
|
|
2
|
+
import { coordinateSystemSchema, fontSchema, languageSchema, weatherUnitSchema, widgetCommonSchema, } from './widgetCommonSchema';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export const accuweatherSchema = widgetCommonSchema.extend({
|
|
5
|
+
name: z.literal(allowedWidgetNames.accuweather),
|
|
6
|
+
location: z.string(),
|
|
7
|
+
locationName: z.string(),
|
|
8
|
+
title: z.string(),
|
|
9
|
+
bgStartColor: z.union([
|
|
10
|
+
z.literal('237,143,73,0.93'),
|
|
11
|
+
z.literal('0,0,0,0.75'),
|
|
12
|
+
z.literal('31,32,73,0.9'),
|
|
13
|
+
z.literal('76,94,127,0.95'),
|
|
14
|
+
]),
|
|
15
|
+
bgEndColor: z.union([
|
|
16
|
+
z.literal('234,181,89,0.93'),
|
|
17
|
+
z.literal('0,0,0,0.75'),
|
|
18
|
+
z.literal('73,96,213,0.9'),
|
|
19
|
+
z.literal('140,150,168,0.95'),
|
|
20
|
+
]),
|
|
21
|
+
clockType: z.union([z.literal('12h'), z.literal('24h')]),
|
|
22
|
+
lang: languageSchema,
|
|
23
|
+
font: fontSchema,
|
|
24
|
+
units: weatherUnitSchema,
|
|
25
|
+
pos_x: z.number(),
|
|
26
|
+
pos_y: z.number(),
|
|
27
|
+
coordSystem: coordinateSystemSchema,
|
|
28
|
+
layout: z.union([
|
|
29
|
+
z.literal('0'),
|
|
30
|
+
z.literal('1'),
|
|
31
|
+
z.literal('2'),
|
|
32
|
+
z.literal('3'),
|
|
33
|
+
z.literal('4'),
|
|
34
|
+
z.literal('5'),
|
|
35
|
+
z.literal('6'),
|
|
36
|
+
z.literal('7'),
|
|
37
|
+
z.literal('8'),
|
|
38
|
+
z.literal('9'),
|
|
39
|
+
z.literal('10'),
|
|
40
|
+
z.literal('11'),
|
|
41
|
+
z.literal('12'),
|
|
42
|
+
z.literal('13'),
|
|
43
|
+
]),
|
|
44
|
+
scale: z.number().nonnegative(),
|
|
45
|
+
});
|
|
@@ -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,11 @@
|
|
|
1
|
+
export const allowedWidgetNames = {
|
|
2
|
+
accuweather: 'accuweather',
|
|
3
|
+
infoticker: 'infoticker',
|
|
4
|
+
customGraphics: 'customGraphics',
|
|
5
|
+
ptzCompass: 'ptzCompass',
|
|
6
|
+
images: 'images',
|
|
7
|
+
ptz: 'ptz',
|
|
8
|
+
pip: 'pip',
|
|
9
|
+
screenSharing: 'screenSharing',
|
|
10
|
+
web_camera: 'web_camera',
|
|
11
|
+
};
|