camstreamerlib 4.0.0-beta.3 → 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 +8 -2
- package/cjs/CamOverlayAPI.d.ts +47 -26
- package/cjs/CamOverlayAPI.js +171 -88
- package/cjs/CamOverlayDrawingAPI.d.ts +2 -47
- package/cjs/CamOverlayDrawingAPI.js +6 -3
- package/cjs/CamOverlayPainter/Frame.d.ts +8 -37
- package/cjs/CamOverlayPainter/Frame.js +33 -0
- package/cjs/CamOverlayPainter/Painter.d.ts +16 -10
- package/cjs/CamOverlayPainter/Painter.js +6 -5
- package/cjs/CamOverlayPainter/ResourceManager.d.ts +3 -2
- package/cjs/CamOverlayPainter/ResourceManager.js +8 -11
- package/cjs/CamScripterAPI.d.ts +33 -16
- package/cjs/CamScripterAPI.js +50 -41
- package/cjs/CamScripterAPICameraEventsGenerator.d.ts +1 -1
- package/cjs/CamScripterAPICameraEventsGenerator.js +6 -3
- package/cjs/CamStreamerAPI.d.ts +16 -14
- package/cjs/CamStreamerAPI.js +32 -32
- package/cjs/CamSwitcherAPI.d.ts +42 -37
- package/cjs/CamSwitcherAPI.js +123 -114
- package/cjs/CamSwitcherEvents.d.ts +1 -1
- package/cjs/PlaneTrackerAPI.d.ts +42 -0
- package/cjs/PlaneTrackerAPI.js +211 -0
- package/cjs/VapixAPI.d.ts +56 -43
- package/cjs/VapixAPI.js +305 -216
- package/cjs/VapixEvents.d.ts +1 -1
- package/cjs/VapixEvents.js +3 -3
- package/cjs/errors/errors.d.ts +3 -0
- package/cjs/errors/errors.js +8 -1
- package/cjs/events/AxisCameraStationEvents.d.ts +5 -4
- package/cjs/events/AxisCameraStationEvents.js +23 -18
- package/cjs/events/GenetecAgent.d.ts +6 -3
- package/cjs/events/GenetecAgent.js +30 -19
- package/cjs/index.d.ts +14 -1
- package/cjs/index.js +23 -2
- package/cjs/internal/Digest.js +6 -6
- package/cjs/internal/ProxyClient.d.ts +8 -9
- package/cjs/internal/ProxyClient.js +25 -29
- package/cjs/internal/types.d.ts +42 -0
- package/cjs/internal/types.js +2 -0
- package/cjs/internal/utils.d.ts +4 -1
- package/cjs/internal/utils.js +22 -3
- package/cjs/internal/versionCompare.d.ts +2 -2
- package/cjs/node/DefaultClient.d.ts +5 -6
- package/cjs/node/DefaultClient.js +12 -14
- package/cjs/node/HttpRequestSender.d.ts +1 -0
- package/cjs/node/HttpRequestSender.js +13 -3
- package/cjs/node/HttpServer.js +1 -1
- package/cjs/node/WsClient.d.ts +2 -1
- package/cjs/node/WsEventClient.d.ts +1 -1
- package/cjs/node/index.d.ts +2 -0
- package/cjs/node/index.js +18 -1
- package/cjs/types/CamOverlayAPI/CamOverlayAPI.d.ts +3073 -0
- package/cjs/types/CamOverlayAPI/CamOverlayAPI.js +127 -0
- package/cjs/types/CamOverlayAPI/accuweatherSchema.d.ts +114 -0
- package/cjs/types/CamOverlayAPI/accuweatherSchema.js +50 -0
- package/cjs/types/CamOverlayAPI/customGraphicsSchema.d.ts +783 -0
- package/cjs/types/CamOverlayAPI/customGraphicsSchema.js +75 -0
- package/cjs/types/CamOverlayAPI/imagesSchema.d.ts +122 -0
- package/cjs/types/CamOverlayAPI/imagesSchema.js +12 -0
- package/cjs/types/CamOverlayAPI/index.d.ts +9 -0
- package/cjs/types/CamOverlayAPI/index.js +25 -0
- package/cjs/types/CamOverlayAPI/infotickerSchema.d.ts +130 -0
- package/cjs/types/CamOverlayAPI/infotickerSchema.js +29 -0
- package/cjs/types/CamOverlayAPI/pipSchema.d.ts +166 -0
- package/cjs/types/CamOverlayAPI/pipSchema.js +42 -0
- package/cjs/types/CamOverlayAPI/ptzCompassSchema.d.ts +126 -0
- package/cjs/types/CamOverlayAPI/ptzCompassSchema.js +28 -0
- package/cjs/types/CamOverlayAPI/ptzSchema.d.ts +146 -0
- package/cjs/types/CamOverlayAPI/ptzSchema.js +15 -0
- package/cjs/types/CamOverlayAPI/screenSharingSchema.d.ts +79 -0
- package/cjs/types/CamOverlayAPI/screenSharingSchema.js +11 -0
- package/cjs/types/CamOverlayAPI/webCameraSharingSchema.d.ts +79 -0
- 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/CamScripterAPI.d.ts +82 -17
- package/cjs/types/CamScripterAPI.js +22 -7
- package/cjs/types/CamStreamerAPI.d.ts +16 -5
- package/cjs/types/CamStreamerAPI.js +5 -1
- package/cjs/types/CamSwitcherAPI.d.ts +5 -5
- package/cjs/types/CamSwitcherEvents.d.ts +77 -0
- package/cjs/types/CamSwitcherEvents.js +8 -0
- package/cjs/types/PlaneTrackerAPI.d.ts +8 -0
- package/cjs/types/PlaneTrackerAPI.js +2 -0
- package/cjs/types/VapixAPI.d.ts +636 -519
- package/cjs/types/VapixAPI.js +62 -24
- package/cjs/types/common.d.ts +14 -5
- package/cjs/web/DefaultClient.d.ts +5 -5
- package/cjs/web/DefaultClient.js +22 -10
- package/cjs/web/WsClient.js +2 -2
- package/esm/CamOverlayAPI.d.ts +47 -26
- package/esm/CamOverlayAPI.js +169 -86
- package/esm/CamOverlayDrawingAPI.d.ts +2 -47
- package/esm/CamOverlayDrawingAPI.js +6 -3
- package/esm/CamOverlayPainter/Frame.d.ts +8 -37
- package/esm/CamOverlayPainter/Frame.js +33 -0
- package/esm/CamOverlayPainter/Painter.d.ts +16 -10
- package/esm/CamOverlayPainter/Painter.js +5 -3
- package/esm/CamOverlayPainter/ResourceManager.d.ts +3 -2
- package/esm/CamOverlayPainter/ResourceManager.js +7 -11
- package/esm/CamScripterAPI.d.ts +33 -16
- package/esm/CamScripterAPI.js +46 -37
- package/esm/CamScripterAPICameraEventsGenerator.d.ts +1 -1
- package/esm/CamScripterAPICameraEventsGenerator.js +6 -3
- package/esm/CamStreamerAPI.d.ts +16 -14
- package/esm/CamStreamerAPI.js +32 -32
- package/esm/CamSwitcherAPI.d.ts +42 -37
- package/esm/CamSwitcherAPI.js +116 -107
- package/esm/CamSwitcherEvents.d.ts +1 -1
- package/esm/PlaneTrackerAPI.d.ts +42 -0
- package/esm/PlaneTrackerAPI.js +207 -0
- package/esm/VapixAPI.d.ts +56 -43
- package/esm/VapixAPI.js +297 -208
- package/esm/VapixEvents.d.ts +1 -1
- package/esm/VapixEvents.js +3 -3
- package/esm/errors/errors.d.ts +3 -0
- package/esm/errors/errors.js +6 -0
- package/esm/events/AxisCameraStationEvents.d.ts +5 -4
- package/esm/events/AxisCameraStationEvents.js +18 -13
- package/esm/events/GenetecAgent.d.ts +6 -3
- package/esm/events/GenetecAgent.js +20 -9
- package/esm/index.d.ts +14 -1
- package/esm/index.js +14 -1
- package/esm/internal/Digest.js +6 -6
- package/esm/internal/ProxyClient.d.ts +8 -9
- package/esm/internal/ProxyClient.js +25 -29
- package/esm/internal/types.d.ts +42 -0
- package/esm/internal/types.js +1 -0
- package/esm/internal/utils.d.ts +4 -1
- package/esm/internal/utils.js +17 -1
- package/esm/internal/versionCompare.d.ts +2 -2
- package/esm/node/DefaultClient.d.ts +5 -6
- package/esm/node/DefaultClient.js +12 -14
- package/esm/node/HttpRequestSender.d.ts +1 -0
- package/esm/node/HttpRequestSender.js +13 -3
- package/esm/node/HttpServer.js +1 -1
- package/esm/node/WsClient.d.ts +2 -1
- package/esm/node/WsEventClient.d.ts +1 -1
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +2 -0
- package/esm/types/CamOverlayAPI/CamOverlayAPI.d.ts +3073 -0
- package/esm/types/CamOverlayAPI/CamOverlayAPI.js +124 -0
- package/esm/types/CamOverlayAPI/accuweatherSchema.d.ts +114 -0
- package/esm/types/CamOverlayAPI/accuweatherSchema.js +46 -0
- package/esm/types/CamOverlayAPI/customGraphicsSchema.d.ts +783 -0
- package/esm/types/CamOverlayAPI/customGraphicsSchema.js +71 -0
- package/esm/types/CamOverlayAPI/imagesSchema.d.ts +122 -0
- package/esm/types/CamOverlayAPI/imagesSchema.js +8 -0
- package/esm/types/CamOverlayAPI/index.d.ts +9 -0
- package/esm/types/CamOverlayAPI/index.js +9 -0
- package/esm/types/CamOverlayAPI/infotickerSchema.d.ts +130 -0
- package/esm/types/CamOverlayAPI/infotickerSchema.js +25 -0
- package/esm/types/CamOverlayAPI/pipSchema.d.ts +166 -0
- package/esm/types/CamOverlayAPI/pipSchema.js +38 -0
- package/esm/types/CamOverlayAPI/ptzCompassSchema.d.ts +126 -0
- package/esm/types/CamOverlayAPI/ptzCompassSchema.js +24 -0
- package/esm/types/CamOverlayAPI/ptzSchema.d.ts +146 -0
- package/esm/types/CamOverlayAPI/ptzSchema.js +11 -0
- package/esm/types/CamOverlayAPI/screenSharingSchema.d.ts +79 -0
- package/esm/types/CamOverlayAPI/screenSharingSchema.js +7 -0
- package/esm/types/CamOverlayAPI/webCameraSharingSchema.d.ts +79 -0
- 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/CamScripterAPI.d.ts +82 -17
- package/esm/types/CamScripterAPI.js +21 -6
- package/esm/types/CamStreamerAPI.d.ts +16 -5
- package/esm/types/CamStreamerAPI.js +4 -0
- package/esm/types/CamSwitcherAPI.d.ts +5 -5
- package/esm/types/CamSwitcherEvents.d.ts +77 -0
- package/esm/types/CamSwitcherEvents.js +8 -0
- package/esm/types/PlaneTrackerAPI.d.ts +8 -0
- package/esm/types/PlaneTrackerAPI.js +1 -0
- package/esm/types/VapixAPI.d.ts +636 -519
- package/esm/types/VapixAPI.js +61 -23
- package/esm/types/common.d.ts +14 -5
- package/esm/web/DefaultClient.d.ts +5 -5
- package/esm/web/DefaultClient.js +22 -10
- package/esm/web/WsClient.js +2 -2
- package/package.json +9 -8
- package/cjs/internal/common.d.ts +0 -39
- package/cjs/internal/common.js +0 -27
- package/cjs/types/CamOverlayAPI.d.ts +0 -188
- package/cjs/types/CamOverlayAPI.js +0 -47
- package/esm/internal/common.d.ts +0 -39
- package/esm/internal/common.js +0 -20
- package/esm/types/CamOverlayAPI.d.ts +0 -188
- package/esm/types/CamOverlayAPI.js +0 -44
package/cjs/VapixEvents.d.ts
CHANGED
package/cjs/VapixEvents.js
CHANGED
|
@@ -42,10 +42,10 @@ class VapixEvents extends eventemitter2_1.EventEmitter2 {
|
|
|
42
42
|
this.ws.on('open', () => {
|
|
43
43
|
const topics = [];
|
|
44
44
|
const eventNames = this.eventNames();
|
|
45
|
-
for (
|
|
46
|
-
if (!this.isReservedEventName(
|
|
45
|
+
for (const eventName of eventNames) {
|
|
46
|
+
if (!this.isReservedEventName(eventName)) {
|
|
47
47
|
const topic = {
|
|
48
|
-
topicFilter:
|
|
48
|
+
topicFilter: eventName,
|
|
49
49
|
};
|
|
50
50
|
topics.push(topic);
|
|
51
51
|
}
|
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;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { HttpOptions } from '../internal/types';
|
|
2
|
+
import { THttpRequestOptions } from '../types/common';
|
|
3
3
|
export declare class AxisCameraStationEvents {
|
|
4
4
|
private sourceKey;
|
|
5
5
|
private client;
|
|
6
|
-
constructor(
|
|
7
|
-
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>;
|
|
8
8
|
private getDate;
|
|
9
|
+
private getAgent;
|
|
9
10
|
}
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AxisCameraStationEvents = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const utils_1 = require("../internal/utils");
|
|
5
|
+
const ProxyClient_1 = require("../internal/ProxyClient");
|
|
6
|
+
const node_1 = require("../node");
|
|
6
7
|
class AxisCameraStationEvents {
|
|
7
8
|
sourceKey;
|
|
8
9
|
client;
|
|
9
|
-
constructor(
|
|
10
|
+
constructor(clientOptions, sourceKey) {
|
|
10
11
|
this.sourceKey = sourceKey;
|
|
11
|
-
|
|
12
|
-
this.client = opt;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
this.client = new DefaultClient_1.DefaultClient(opt);
|
|
16
|
-
}
|
|
12
|
+
this.client = new node_1.DefaultClient(clientOptions);
|
|
17
13
|
}
|
|
18
|
-
async sendEvent(data, eventType) {
|
|
14
|
+
async sendEvent(data, eventType, options) {
|
|
19
15
|
const dateString = this.getDate();
|
|
20
16
|
const event = {
|
|
21
17
|
addExternalDataRequest: {
|
|
@@ -26,9 +22,15 @@ class AxisCameraStationEvents {
|
|
|
26
22
|
},
|
|
27
23
|
};
|
|
28
24
|
const eventData = JSON.stringify(event);
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
'
|
|
25
|
+
const agent = this.getAgent(options?.proxyParams);
|
|
26
|
+
const res = await agent.post({
|
|
27
|
+
path: '/Acs/Api/ExternalDataFacade/AddExternalData',
|
|
28
|
+
data: eventData,
|
|
29
|
+
headers: {
|
|
30
|
+
'Content-Type': 'application/json',
|
|
31
|
+
'Content-Length': eventData.length.toString(),
|
|
32
|
+
},
|
|
33
|
+
timeout: options?.timeout,
|
|
32
34
|
});
|
|
33
35
|
if (!res.ok) {
|
|
34
36
|
throw new Error(`ACS status code: ${res.status}`);
|
|
@@ -37,12 +39,15 @@ class AxisCameraStationEvents {
|
|
|
37
39
|
getDate() {
|
|
38
40
|
const date = new Date();
|
|
39
41
|
const year = date.getUTCFullYear();
|
|
40
|
-
const month = (0,
|
|
41
|
-
const day = (0,
|
|
42
|
-
const hours = (0,
|
|
43
|
-
const minutes = (0,
|
|
44
|
-
const seconds = (0,
|
|
42
|
+
const month = (0, utils_1.pad)(date.getUTCMonth() + 1, 2);
|
|
43
|
+
const day = (0, utils_1.pad)(date.getUTCDate(), 2);
|
|
44
|
+
const hours = (0, utils_1.pad)(date.getUTCHours(), 2);
|
|
45
|
+
const minutes = (0, utils_1.pad)(date.getUTCMinutes(), 2);
|
|
46
|
+
const seconds = (0, utils_1.pad)(date.getUTCSeconds(), 2);
|
|
45
47
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
46
48
|
}
|
|
49
|
+
getAgent(proxyParams) {
|
|
50
|
+
return proxyParams ? new ProxyClient_1.ProxyClient(this.client, proxyParams) : this.client;
|
|
51
|
+
}
|
|
47
52
|
}
|
|
48
53
|
exports.AxisCameraStationEvents = AxisCameraStationEvents;
|
|
@@ -148,14 +148,16 @@ export declare const cameraDetailsResponseSchema: z.ZodObject<{
|
|
|
148
148
|
export type TCameraDetailsResponse = z.infer<typeof cameraDetailsResponseSchema>;
|
|
149
149
|
export type TCameraDetail = z.infer<typeof cameraDetailSchema>;
|
|
150
150
|
export type TParams = Array<'Guid' | 'Name' | 'EntityType'>;
|
|
151
|
+
export type TProtocol = 'http' | 'https' | 'https_insecure';
|
|
151
152
|
export type GenetecAgentOptions = {
|
|
152
|
-
protocol?:
|
|
153
|
+
protocol?: TProtocol;
|
|
153
154
|
ip?: string;
|
|
154
155
|
port?: number;
|
|
155
|
-
|
|
156
|
+
baseUri?: string;
|
|
156
157
|
user?: string;
|
|
157
158
|
pass?: string;
|
|
158
|
-
|
|
159
|
+
appId?: string;
|
|
160
|
+
timeout?: number;
|
|
159
161
|
};
|
|
160
162
|
export declare class GenetecAgent {
|
|
161
163
|
private settings;
|
|
@@ -170,5 +172,6 @@ export declare class GenetecAgent {
|
|
|
170
172
|
sendBookmark(guids: string[], bookmarkText: string): Promise<Response>;
|
|
171
173
|
private getRequestOptions;
|
|
172
174
|
private getTimeStamp;
|
|
175
|
+
private fetchWithTimeout;
|
|
173
176
|
}
|
|
174
177
|
export {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GenetecAgent = exports.cameraDetailsResponseSchema = exports.cameraDetailSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
5
|
+
const utils_1 = require("../internal/utils");
|
|
6
6
|
const ACTION = 'AddCameraBookmark';
|
|
7
7
|
const GET_CAMERAS_URL = 'report/EntityConfiguration?q=EntityTypes@Camera';
|
|
8
8
|
const GET_CAMERAS_DETAILS_URL = '/entity?q=';
|
|
@@ -37,27 +37,28 @@ class GenetecAgent {
|
|
|
37
37
|
protocol: options.protocol ?? 'http',
|
|
38
38
|
ip: options.ip ?? '127.0.0.1',
|
|
39
39
|
port: options.port ?? 80,
|
|
40
|
-
|
|
40
|
+
baseUri: options.baseUri ?? 'WebSdk',
|
|
41
41
|
user: options.user ?? 'root',
|
|
42
42
|
pass: options.pass ?? '',
|
|
43
|
-
|
|
43
|
+
appId: options.appId ?? '',
|
|
44
|
+
timeout: options.timeout ?? 10000,
|
|
44
45
|
};
|
|
45
|
-
this.baseUrl = `${this.settings.protocol}://${this.settings.ip}:${this.settings.port}/${this.settings.
|
|
46
|
-
this.credentials = btoa(`${this.settings.user};${this.settings.
|
|
46
|
+
this.baseUrl = `${this.settings.protocol}://${this.settings.ip}:${this.settings.port}/${this.settings.baseUri}`;
|
|
47
|
+
this.credentials = btoa(`${this.settings.user};${this.settings.appId}:${this.settings.pass}`);
|
|
47
48
|
}
|
|
48
49
|
async checkConnection() {
|
|
49
50
|
const requestOptions = this.getRequestOptions('GET');
|
|
50
|
-
const res = await
|
|
51
|
+
const res = await this.fetchWithTimeout(`${this.baseUrl}/`, requestOptions);
|
|
51
52
|
if (!res.ok) {
|
|
52
|
-
throw new Error(await (0,
|
|
53
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
53
54
|
}
|
|
54
55
|
return connectionResponseSchema.parse(await res.json());
|
|
55
56
|
}
|
|
56
57
|
async getAllCameraGuids() {
|
|
57
58
|
const requestOptions = this.getRequestOptions('GET');
|
|
58
|
-
const res = await
|
|
59
|
+
const res = await this.fetchWithTimeout(`${this.baseUrl}/${GET_CAMERAS_URL}`, requestOptions);
|
|
59
60
|
if (!res.ok) {
|
|
60
|
-
throw new Error(await (0,
|
|
61
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
61
62
|
}
|
|
62
63
|
return cameraGuidsResponseSchema.parse(await res.json());
|
|
63
64
|
}
|
|
@@ -75,9 +76,9 @@ class GenetecAgent {
|
|
|
75
76
|
for (const guid of camerasGuids) {
|
|
76
77
|
camerasDetailsUrl.push(`entity=${guid},${params}`);
|
|
77
78
|
}
|
|
78
|
-
const res = await
|
|
79
|
+
const res = await this.fetchWithTimeout(`${this.baseUrl}/${GET_CAMERAS_DETAILS_URL}${camerasDetailsUrl.join(',')}`, requestOptions);
|
|
79
80
|
if (!res.ok) {
|
|
80
|
-
throw new Error(await (0,
|
|
81
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
81
82
|
}
|
|
82
83
|
const data = exports.cameraDetailsResponseSchema.parse(await res.json());
|
|
83
84
|
const resultArray = Array.isArray(data.Rsp.Result) ? data.Rsp.Result : [data.Rsp.Result];
|
|
@@ -92,9 +93,9 @@ class GenetecAgent {
|
|
|
92
93
|
for (const guid of guids) {
|
|
93
94
|
cameraEntitiesUrl.push(`${ACTION}(${guid},${timeStamp},${bookmarkText})`);
|
|
94
95
|
}
|
|
95
|
-
const res = await
|
|
96
|
+
const res = await this.fetchWithTimeout(`${this.baseUrl}/action?q=${cameraEntitiesUrl.join(',')}`, requestOptions);
|
|
96
97
|
if (!res.ok) {
|
|
97
|
-
throw new Error(await (0,
|
|
98
|
+
throw new Error(await (0, utils_1.responseStringify)(res));
|
|
98
99
|
}
|
|
99
100
|
return res;
|
|
100
101
|
}
|
|
@@ -111,13 +112,23 @@ class GenetecAgent {
|
|
|
111
112
|
getTimeStamp() {
|
|
112
113
|
const date = new Date();
|
|
113
114
|
const year = date.getUTCFullYear();
|
|
114
|
-
const month = (0,
|
|
115
|
-
const day = (0,
|
|
116
|
-
const hours = (0,
|
|
117
|
-
const minutes = (0,
|
|
118
|
-
const seconds = (0,
|
|
119
|
-
const miliSeconds = (0,
|
|
115
|
+
const month = (0, utils_1.pad)(date.getUTCMonth() + 1, 2);
|
|
116
|
+
const day = (0, utils_1.pad)(date.getUTCDate(), 2);
|
|
117
|
+
const hours = (0, utils_1.pad)(date.getUTCHours(), 2);
|
|
118
|
+
const minutes = (0, utils_1.pad)(date.getUTCMinutes(), 2);
|
|
119
|
+
const seconds = (0, utils_1.pad)(date.getUTCSeconds(), 2);
|
|
120
|
+
const miliSeconds = (0, utils_1.pad)(date.getUTCMilliseconds(), 2);
|
|
120
121
|
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${miliSeconds}Z`;
|
|
121
122
|
}
|
|
123
|
+
async fetchWithTimeout(url, options) {
|
|
124
|
+
const controller = new AbortController();
|
|
125
|
+
const timeoutId = setTimeout(() => controller.abort(), this.settings.timeout);
|
|
126
|
+
try {
|
|
127
|
+
return await fetch(url, { ...options, signal: controller.signal });
|
|
128
|
+
}
|
|
129
|
+
finally {
|
|
130
|
+
clearTimeout(timeoutId);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
122
133
|
}
|
|
123
134
|
exports.GenetecAgent = GenetecAgent;
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './internal/
|
|
1
|
+
export * from './internal/types';
|
|
2
2
|
export * from './internal/constants';
|
|
3
3
|
export * from './internal/utils';
|
|
4
4
|
export * from './internal/versionCompare';
|
|
@@ -6,6 +6,19 @@ 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';
|
|
10
|
+
export { CamScripterAPI } from './CamScripterAPI';
|
|
11
|
+
export { CamStreamerAPI } from './CamStreamerAPI';
|
|
12
|
+
export { PlaneTrackerAPI } from './PlaneTrackerAPI';
|
|
9
13
|
export * from './types/CamSwitcherEvents';
|
|
10
14
|
export * from './types/CamSwitcherAPI';
|
|
11
15
|
export * from './types/VapixAPI';
|
|
16
|
+
export * from './types/CamOverlayAPI';
|
|
17
|
+
export * from './types/CamOverlayAPI/CamOverlayAPI';
|
|
18
|
+
export * from './types/PlaneTrackerAPI';
|
|
19
|
+
export { Frame } from './CamOverlayPainter/Frame';
|
|
20
|
+
export { Painter } from './CamOverlayPainter/Painter';
|
|
21
|
+
export { ResourceManager } from './CamOverlayPainter/ResourceManager';
|
|
22
|
+
export * from './types/CamOverlayPainter';
|
|
23
|
+
export { CamOverlayDrawingAPI } from './CamOverlayDrawingAPI';
|
|
24
|
+
export * from './types/CamOverlayDrawingAPI';
|
package/cjs/index.js
CHANGED
|
@@ -14,8 +14,8 @@ 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;
|
|
18
|
-
__exportStar(require("./internal/
|
|
17
|
+
exports.CamOverlayDrawingAPI = exports.ResourceManager = exports.Painter = exports.Frame = exports.PlaneTrackerAPI = exports.CamStreamerAPI = exports.CamScripterAPI = exports.CamOverlayAPI = exports.VapixAPI = exports.CamSwitcherEvents = exports.CamSwitcherAPI = void 0;
|
|
18
|
+
__exportStar(require("./internal/types"), exports);
|
|
19
19
|
__exportStar(require("./internal/constants"), exports);
|
|
20
20
|
__exportStar(require("./internal/utils"), exports);
|
|
21
21
|
__exportStar(require("./internal/versionCompare"), exports);
|
|
@@ -26,6 +26,27 @@ 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; } });
|
|
31
|
+
var CamScripterAPI_1 = require("./CamScripterAPI");
|
|
32
|
+
Object.defineProperty(exports, "CamScripterAPI", { enumerable: true, get: function () { return CamScripterAPI_1.CamScripterAPI; } });
|
|
33
|
+
var CamStreamerAPI_1 = require("./CamStreamerAPI");
|
|
34
|
+
Object.defineProperty(exports, "CamStreamerAPI", { enumerable: true, get: function () { return CamStreamerAPI_1.CamStreamerAPI; } });
|
|
35
|
+
var PlaneTrackerAPI_1 = require("./PlaneTrackerAPI");
|
|
36
|
+
Object.defineProperty(exports, "PlaneTrackerAPI", { enumerable: true, get: function () { return PlaneTrackerAPI_1.PlaneTrackerAPI; } });
|
|
29
37
|
__exportStar(require("./types/CamSwitcherEvents"), exports);
|
|
30
38
|
__exportStar(require("./types/CamSwitcherAPI"), exports);
|
|
31
39
|
__exportStar(require("./types/VapixAPI"), exports);
|
|
40
|
+
__exportStar(require("./types/CamOverlayAPI"), exports);
|
|
41
|
+
__exportStar(require("./types/CamOverlayAPI/CamOverlayAPI"), exports);
|
|
42
|
+
__exportStar(require("./types/PlaneTrackerAPI"), exports);
|
|
43
|
+
var Frame_1 = require("./CamOverlayPainter/Frame");
|
|
44
|
+
Object.defineProperty(exports, "Frame", { enumerable: true, get: function () { return Frame_1.Frame; } });
|
|
45
|
+
var Painter_1 = require("./CamOverlayPainter/Painter");
|
|
46
|
+
Object.defineProperty(exports, "Painter", { enumerable: true, get: function () { return Painter_1.Painter; } });
|
|
47
|
+
var ResourceManager_1 = require("./CamOverlayPainter/ResourceManager");
|
|
48
|
+
Object.defineProperty(exports, "ResourceManager", { enumerable: true, get: function () { return ResourceManager_1.ResourceManager; } });
|
|
49
|
+
__exportStar(require("./types/CamOverlayPainter"), exports);
|
|
50
|
+
var CamOverlayDrawingAPI_1 = require("./CamOverlayDrawingAPI");
|
|
51
|
+
Object.defineProperty(exports, "CamOverlayDrawingAPI", { enumerable: true, get: function () { return CamOverlayDrawingAPI_1.CamOverlayDrawingAPI; } });
|
|
52
|
+
__exportStar(require("./types/CamOverlayDrawingAPI"), exports);
|
package/cjs/internal/Digest.js
CHANGED
|
@@ -7,17 +7,17 @@ class Digest {
|
|
|
7
7
|
getAuthHeader(user, pass, method, uri, wwwAuthenticateHeader) {
|
|
8
8
|
const digestItems = {};
|
|
9
9
|
const digestArr = wwwAuthenticateHeader.substring(wwwAuthenticateHeader.indexOf('Digest') + 6).split(',');
|
|
10
|
-
for (
|
|
11
|
-
const pos =
|
|
12
|
-
const key =
|
|
13
|
-
const value =
|
|
10
|
+
for (const arg of digestArr) {
|
|
11
|
+
const pos = arg.indexOf('=');
|
|
12
|
+
const key = arg.substring(0, pos).trim();
|
|
13
|
+
const value = arg.substring(pos + 1).trim();
|
|
14
14
|
digestItems[key] = value.replace(/"/g, '');
|
|
15
15
|
}
|
|
16
16
|
const HA1 = crypto.createHash('md5').update(`${user}:${digestItems['realm']}:${pass}`).digest('hex');
|
|
17
17
|
const HA2 = crypto.createHash('md5').update(`${method}:${uri}`).digest('hex');
|
|
18
18
|
const ncValue = ('00000000' + this.nonceCount.toString(16)).slice(-8);
|
|
19
19
|
let response;
|
|
20
|
-
if (digestItems['qop']) {
|
|
20
|
+
if (digestItems['qop'] !== undefined) {
|
|
21
21
|
response = crypto
|
|
22
22
|
.createHash('md5')
|
|
23
23
|
.update(`${HA1}:${digestItems['nonce']}:${ncValue}:162d50aa594e9648:auth:${HA2}`)
|
|
@@ -32,7 +32,7 @@ class Digest {
|
|
|
32
32
|
`nonce="${digestItems['nonce']}",` +
|
|
33
33
|
`uri="${uri}",` +
|
|
34
34
|
`response="${response}"`;
|
|
35
|
-
if (digestItems['qop']) {
|
|
35
|
+
if (digestItems['qop'] !== undefined) {
|
|
36
36
|
header += `,qop=auth,nc=${ncValue},cnonce="162d50aa594e9648"`;
|
|
37
37
|
}
|
|
38
38
|
this.nonceCount++;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
post: (proxy: TProxyParam, path: string, data: string | Buffer | FormData, parameters?: TParameters, headers?: Record<string, string>) => Promise<import("./common").TResponse>;
|
|
1
|
+
import { IClient, TGetParams, TPostParams, TResponse } from './types';
|
|
2
|
+
import { TProxyParams } from '../types/common';
|
|
3
|
+
export declare class ProxyClient<Client extends IClient<TResponse> = IClient<TResponse>> {
|
|
4
|
+
private client;
|
|
5
|
+
private proxyParams;
|
|
6
|
+
constructor(client: Client, proxyParams: TProxyParams);
|
|
7
|
+
get: (params: TGetParams) => Promise<TResponse>;
|
|
8
|
+
post: (params: TPostParams) => Promise<TResponse>;
|
|
10
9
|
private getReal;
|
|
11
10
|
}
|
|
@@ -4,40 +4,36 @@ exports.ProxyClient = void 0;
|
|
|
4
4
|
const utils_1 = require("./utils");
|
|
5
5
|
class ProxyClient {
|
|
6
6
|
client;
|
|
7
|
-
|
|
8
|
-
constructor(client,
|
|
7
|
+
proxyParams;
|
|
8
|
+
constructor(client, proxyParams) {
|
|
9
9
|
this.client = client;
|
|
10
|
-
this.
|
|
10
|
+
this.proxyParams = proxyParams;
|
|
11
11
|
}
|
|
12
|
-
get = (
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
12
|
+
get = (params) => {
|
|
13
|
+
const { path, parameters, headers, timeout } = params;
|
|
14
|
+
const targetPath = (0, utils_1.addParametersToPath)(path, parameters);
|
|
15
|
+
const { realPath, realHeaders } = this.getReal(targetPath, headers);
|
|
16
|
+
return this.client.get({ path: realPath, headers: realHeaders, timeout });
|
|
16
17
|
};
|
|
17
|
-
post = (
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
18
|
+
post = (params) => {
|
|
19
|
+
const { path, data, parameters, headers, timeout } = params;
|
|
20
|
+
const targetPath = (0, utils_1.addParametersToPath)(path, parameters);
|
|
21
|
+
const { realPath, realHeaders } = this.getReal(targetPath, headers);
|
|
22
|
+
return this.client.post({ path: realPath, data, headers: realHeaders, timeout });
|
|
21
23
|
};
|
|
22
|
-
getReal = (
|
|
23
|
-
if (proxy !== null) {
|
|
24
|
-
return {
|
|
25
|
-
realUrl: this.getProxyUrl(),
|
|
26
|
-
realHeaders: {
|
|
27
|
-
...(headers ?? {}),
|
|
28
|
-
'x-target-camera-protocol': proxy.port === 443 ? 'https' : 'http',
|
|
29
|
-
'x-target-camera-path': url,
|
|
30
|
-
'x-target-camera-ip': proxy.ip,
|
|
31
|
-
'x-target-camera-mdns': proxy.mdnsName,
|
|
32
|
-
'x-target-camera-port': String(proxy.port),
|
|
33
|
-
'x-target-camera-pass': encodeURIComponent(proxy.pass),
|
|
34
|
-
'x-target-camera-user': encodeURIComponent(proxy.user),
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
}
|
|
24
|
+
getReal = (targetPath, headers) => {
|
|
38
25
|
return {
|
|
39
|
-
|
|
40
|
-
realHeaders:
|
|
26
|
+
realPath: this.proxyParams.path,
|
|
27
|
+
realHeaders: {
|
|
28
|
+
...(headers ?? {}),
|
|
29
|
+
'x-target-camera-protocol': this.proxyParams.target.port === 443 ? 'https' : 'http',
|
|
30
|
+
'x-target-camera-path': targetPath,
|
|
31
|
+
'x-target-camera-ip': this.proxyParams.target.ip,
|
|
32
|
+
'x-target-camera-mdns': this.proxyParams.target.mdnsName,
|
|
33
|
+
'x-target-camera-port': String(this.proxyParams.target.port),
|
|
34
|
+
'x-target-camera-pass': this.proxyParams.target.pass,
|
|
35
|
+
'x-target-camera-user': this.proxyParams.target.user,
|
|
36
|
+
},
|
|
41
37
|
};
|
|
42
38
|
};
|
|
43
39
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Response as UndiciResponse } from 'undici';
|
|
4
|
+
export type Options = {
|
|
5
|
+
ip?: string;
|
|
6
|
+
port?: number;
|
|
7
|
+
user?: string;
|
|
8
|
+
pass?: string;
|
|
9
|
+
tls?: boolean;
|
|
10
|
+
tlsInsecure?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type HttpOptions = Options & {
|
|
13
|
+
keepAlive?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type WsOptions = Options;
|
|
16
|
+
export type TParameters = Record<string, string | number | boolean | null | undefined>;
|
|
17
|
+
export type TResponse = Response | UndiciResponse;
|
|
18
|
+
export type TGetParams = {
|
|
19
|
+
path: string;
|
|
20
|
+
parameters?: TParameters;
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
timeout?: number;
|
|
23
|
+
};
|
|
24
|
+
export type TPostParams = {
|
|
25
|
+
path: string;
|
|
26
|
+
data: string | Buffer | FormData;
|
|
27
|
+
parameters?: TParameters;
|
|
28
|
+
headers?: Record<string, string>;
|
|
29
|
+
timeout?: number;
|
|
30
|
+
};
|
|
31
|
+
export interface IClient<TRes extends TResponse> {
|
|
32
|
+
get: (params: TGetParams) => Promise<TRes>;
|
|
33
|
+
post: (params: TPostParams) => Promise<TRes>;
|
|
34
|
+
}
|
|
35
|
+
export type TBlobResponse<Client extends IClient<TResponse>> = Awaited<ReturnType<Awaited<ReturnType<Client['get']>>['blob']>>;
|
|
36
|
+
export interface IWebsocket<Event extends {
|
|
37
|
+
readonly data: string;
|
|
38
|
+
}> {
|
|
39
|
+
destroy: () => void;
|
|
40
|
+
onmessage: null | ((event: Event) => void);
|
|
41
|
+
send: (data: string) => void;
|
|
42
|
+
}
|
package/cjs/internal/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TPlaylistPlayType } from '../types/CamSwitcherAPI';
|
|
2
|
-
import { TParameters } from './
|
|
2
|
+
import { TParameters, TResponse } from './types';
|
|
3
3
|
export declare const addParametersToPath: (path: string, params?: TParameters) => string;
|
|
4
4
|
export declare const paramToUrl: (params?: TParameters) => string;
|
|
5
5
|
export declare const arrayToUrl: (arr: string | string[]) => string;
|
|
@@ -9,3 +9,6 @@ export declare const isClip: (id?: string) => boolean;
|
|
|
9
9
|
export declare const isTracker: (id?: string) => boolean;
|
|
10
10
|
export declare const isPlaylist: (id?: string) => boolean;
|
|
11
11
|
export declare const isLoopPlayType: (playType: TPlaylistPlayType) => boolean;
|
|
12
|
+
export declare function responseStringify(res: TResponse): Promise<string>;
|
|
13
|
+
export declare function pad(num: number, size: number): string;
|
|
14
|
+
export declare function isNullish<T>(value: T | undefined | null): value is undefined | null;
|
package/cjs/internal/utils.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isLoopPlayType = exports.isPlaylist = exports.isTracker = exports.isClip = exports.isStream = exports.isCamera = exports.arrayToUrl = exports.paramToUrl = exports.addParametersToPath = void 0;
|
|
4
|
-
const common_1 = require("./common");
|
|
3
|
+
exports.isNullish = exports.pad = exports.responseStringify = exports.isLoopPlayType = exports.isPlaylist = exports.isTracker = exports.isClip = exports.isStream = exports.isCamera = exports.arrayToUrl = exports.paramToUrl = exports.addParametersToPath = void 0;
|
|
5
4
|
const addParametersToPath = (path, params) => {
|
|
6
5
|
if (params === undefined || Object.keys(params).length === 0) {
|
|
7
6
|
return path;
|
|
@@ -17,7 +16,7 @@ const paramToUrl = (params) => {
|
|
|
17
16
|
let output = '';
|
|
18
17
|
for (const key in params) {
|
|
19
18
|
const value = params[key];
|
|
20
|
-
if (
|
|
19
|
+
if (isNullish(value)) {
|
|
21
20
|
continue;
|
|
22
21
|
}
|
|
23
22
|
output += `${encodeURIComponent(key)}=${encodeURIComponent(value)}&`;
|
|
@@ -44,3 +43,23 @@ const isPlaylist = (id) => id?.charAt(0) === 'p';
|
|
|
44
43
|
exports.isPlaylist = isPlaylist;
|
|
45
44
|
const isLoopPlayType = (playType) => playType.includes('LOOP');
|
|
46
45
|
exports.isLoopPlayType = isLoopPlayType;
|
|
46
|
+
async function responseStringify(res) {
|
|
47
|
+
return JSON.stringify({
|
|
48
|
+
status: res.status,
|
|
49
|
+
body: await res.text(),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.responseStringify = responseStringify;
|
|
53
|
+
function pad(num, size) {
|
|
54
|
+
const sign = Math.sign(num) === -1 ? '-' : '';
|
|
55
|
+
return (sign +
|
|
56
|
+
new Array(size)
|
|
57
|
+
.concat([Math.abs(num)])
|
|
58
|
+
.join('0')
|
|
59
|
+
.slice(-size));
|
|
60
|
+
}
|
|
61
|
+
exports.pad = pad;
|
|
62
|
+
function isNullish(value) {
|
|
63
|
+
return value === null || value === undefined;
|
|
64
|
+
}
|
|
65
|
+
exports.isNullish = isNullish;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const assertVersionString: (s: string, msg?: string) => void;
|
|
2
2
|
export declare const isFirmwareVersionAtLeast: (version: string, compareVersion: string) => boolean;
|
|
3
3
|
export declare const isVersionAtLeast: (version: string, compareVersion: string) => boolean;
|
|
4
|
-
export declare const firmwareVersionCompare: (a: string, b: string) =>
|
|
5
|
-
export declare const versionCompare: (a: string, b: string) =>
|
|
4
|
+
export declare const firmwareVersionCompare: (a: string, b: string) => 0 | 1 | -1;
|
|
5
|
+
export declare const versionCompare: (a: string, b: string) => 0 | 1 | -1;
|
|
6
6
|
export declare const fixVersionToDots: (version: string) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
export declare class DefaultClient implements IClient {
|
|
1
|
+
import { IClient, HttpOptions, TGetParams, TPostParams } from '../internal/types';
|
|
2
|
+
import { Response as UndiciResponse } from 'undici';
|
|
3
|
+
export declare class DefaultClient implements IClient<UndiciResponse> {
|
|
4
4
|
private tls;
|
|
5
5
|
private ip;
|
|
6
6
|
private port;
|
|
@@ -8,8 +8,7 @@ export declare class DefaultClient implements IClient {
|
|
|
8
8
|
private pass;
|
|
9
9
|
private httpRequestSender;
|
|
10
10
|
constructor(opt?: HttpOptions);
|
|
11
|
-
get
|
|
12
|
-
|
|
13
|
-
post(path: string, data: string | FormData | Buffer, parameters?: TParameters, headers?: Record<string, string>): Promise<import("undici").Response>;
|
|
11
|
+
get: (params: TGetParams) => Promise<UndiciResponse>;
|
|
12
|
+
post: (params: TPostParams) => Promise<UndiciResponse>;
|
|
14
13
|
private getBaseConnectionParams;
|
|
15
14
|
}
|
|
@@ -25,29 +25,27 @@ class DefaultClient {
|
|
|
25
25
|
}
|
|
26
26
|
this.httpRequestSender = new HttpRequestSender_1.HttpRequestSender(agentOptions);
|
|
27
27
|
}
|
|
28
|
-
get
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
async get(path, parameters = {}, headers) {
|
|
32
|
-
const options = this.getBaseConnectionParams('GET', path, parameters);
|
|
33
|
-
options.headers = headers;
|
|
28
|
+
get = (params) => {
|
|
29
|
+
const { path, parameters, headers, timeout } = params;
|
|
30
|
+
const options = this.getBaseConnectionParams('GET', path, parameters, headers, timeout);
|
|
34
31
|
return this.httpRequestSender.sendRequest(options);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
options
|
|
32
|
+
};
|
|
33
|
+
post = (params) => {
|
|
34
|
+
const { path, data, parameters, headers, timeout } = params;
|
|
35
|
+
const options = this.getBaseConnectionParams('POST', path, parameters, headers, timeout);
|
|
39
36
|
return this.httpRequestSender.sendRequest(options, data);
|
|
40
|
-
}
|
|
41
|
-
getBaseConnectionParams(method, path, params) {
|
|
42
|
-
let pathName = (0, utils_1.addParametersToPath)(path, params);
|
|
37
|
+
};
|
|
38
|
+
getBaseConnectionParams(method, path, params, headers, timeout) {
|
|
43
39
|
return {
|
|
44
40
|
method: method,
|
|
45
41
|
protocol: this.tls ? 'https:' : 'http:',
|
|
46
42
|
host: this.ip,
|
|
47
43
|
port: this.port,
|
|
48
|
-
path:
|
|
44
|
+
path: (0, utils_1.addParametersToPath)(path, params),
|
|
49
45
|
user: this.user,
|
|
50
46
|
pass: this.pass,
|
|
47
|
+
headers,
|
|
48
|
+
timeout,
|
|
51
49
|
};
|
|
52
50
|
}
|
|
53
51
|
}
|