camstreamerlib 3.4.0 → 3.5.0
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/CamScripterAPICameraEventsGenerator.d.ts +1 -4
- package/CamScripterAPICameraEventsGenerator.js +2 -3
- package/HttpServer.d.ts +2 -0
- package/HttpServer.js +4 -3
- package/README.md +2 -0
- package/events/AxisCameraStationEvents.d.ts +1 -0
- package/events/AxisCameraStationEvents.js +11 -19
- package/events/GenetecAgent.d.ts +133 -0
- package/events/GenetecAgent.js +127 -0
- package/internal/common.d.ts +1 -0
- package/internal/common.js +10 -1
- package/package.json +3 -2
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as EventEmitter from 'events';
|
|
3
3
|
import { WsOptions } from './internal/common';
|
|
4
|
-
export type CamScripterOptions = WsOptions
|
|
5
|
-
camScripterAcapName?: string;
|
|
6
|
-
};
|
|
4
|
+
export type CamScripterOptions = WsOptions;
|
|
7
5
|
export type TDeclaration = {
|
|
8
6
|
type?: '' | 'SOURCE' | 'DATA';
|
|
9
7
|
namespace: string;
|
|
@@ -54,7 +52,6 @@ export declare class CamScripterAPICameraEventsGenerator extends EventEmitter {
|
|
|
54
52
|
private port;
|
|
55
53
|
private user;
|
|
56
54
|
private pass;
|
|
57
|
-
private camScripterAcapName;
|
|
58
55
|
private callId;
|
|
59
56
|
private sendMessages;
|
|
60
57
|
private timeoutCheckTimer;
|
|
@@ -5,7 +5,7 @@ const EventEmitter = require("events");
|
|
|
5
5
|
const WsClient_1 = require("./internal/WsClient");
|
|
6
6
|
class CamScripterAPICameraEventsGenerator extends EventEmitter {
|
|
7
7
|
constructor(options) {
|
|
8
|
-
var _a, _b, _c, _d, _e, _f
|
|
8
|
+
var _a, _b, _c, _d, _e, _f;
|
|
9
9
|
super();
|
|
10
10
|
this.tls = (_a = options === null || options === void 0 ? void 0 : options.tls) !== null && _a !== void 0 ? _a : false;
|
|
11
11
|
this.tlsInsecure = (_b = options === null || options === void 0 ? void 0 : options.tlsInsecure) !== null && _b !== void 0 ? _b : false;
|
|
@@ -13,7 +13,6 @@ class CamScripterAPICameraEventsGenerator extends EventEmitter {
|
|
|
13
13
|
this.port = (_d = options === null || options === void 0 ? void 0 : options.port) !== null && _d !== void 0 ? _d : (this.tls ? 443 : 80);
|
|
14
14
|
this.user = (_e = options === null || options === void 0 ? void 0 : options.user) !== null && _e !== void 0 ? _e : '';
|
|
15
15
|
this.pass = (_f = options === null || options === void 0 ? void 0 : options.pass) !== null && _f !== void 0 ? _f : '';
|
|
16
|
-
this.camScripterAcapName = (_g = options === null || options === void 0 ? void 0 : options.camScripterAcapName) !== null && _g !== void 0 ? _g : 'camscripter';
|
|
17
16
|
this.callId = 0;
|
|
18
17
|
this.sendMessages = {};
|
|
19
18
|
this.wsConnected = false;
|
|
@@ -57,7 +56,7 @@ class CamScripterAPICameraEventsGenerator extends EventEmitter {
|
|
|
57
56
|
tls: this.tls,
|
|
58
57
|
ip: this.ip,
|
|
59
58
|
port: this.port,
|
|
60
|
-
address: `/local
|
|
59
|
+
address: `/local/camscripter/ws`,
|
|
61
60
|
protocol: 'camera-events',
|
|
62
61
|
};
|
|
63
62
|
this.ws = new WsClient_1.WsClient(options);
|
package/HttpServer.d.ts
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
import * as http from 'http';
|
|
4
4
|
import * as EventEmitter from 'events';
|
|
5
5
|
export type HttpServerOptions = {
|
|
6
|
+
host?: string;
|
|
6
7
|
port?: number;
|
|
7
8
|
};
|
|
8
9
|
type TOnRequestCallback = (req: http.IncomingMessage, res: http.ServerResponse) => void;
|
|
9
10
|
export declare class HttpServer extends EventEmitter {
|
|
11
|
+
private host;
|
|
10
12
|
private port;
|
|
11
13
|
private registeredPaths;
|
|
12
14
|
private server;
|
package/HttpServer.js
CHANGED
|
@@ -8,9 +8,10 @@ const path = require("path");
|
|
|
8
8
|
const EventEmitter = require("events");
|
|
9
9
|
class HttpServer extends EventEmitter {
|
|
10
10
|
constructor(options) {
|
|
11
|
-
var _a, _b;
|
|
11
|
+
var _a, _b, _c, _d;
|
|
12
12
|
super();
|
|
13
|
-
this.
|
|
13
|
+
this.host = (_b = (_a = options === null || options === void 0 ? void 0 : options.host) !== null && _a !== void 0 ? _a : process.env.HTTP_HOST) !== null && _b !== void 0 ? _b : '0.0.0.0';
|
|
14
|
+
this.port = (_c = options === null || options === void 0 ? void 0 : options.port) !== null && _c !== void 0 ? _c : parseInt((_d = process.env.HTTP_PORT) !== null && _d !== void 0 ? _d : '80');
|
|
14
15
|
this.registeredPaths = new Map();
|
|
15
16
|
this.server = http.createServer((req, res) => {
|
|
16
17
|
var _a, _b;
|
|
@@ -66,7 +67,7 @@ class HttpServer extends EventEmitter {
|
|
|
66
67
|
this.server.on('error', (err) => {
|
|
67
68
|
this.emit('error', err);
|
|
68
69
|
});
|
|
69
|
-
this.server.listen(this.port);
|
|
70
|
+
this.server.listen(this.port, this.host);
|
|
70
71
|
this.sockets = {};
|
|
71
72
|
let idTracker = 0;
|
|
72
73
|
this.server.on('connection', (socket) => {
|
package/README.md
CHANGED
|
@@ -31,6 +31,8 @@ npm install camstreamerlib
|
|
|
31
31
|
|
|
32
32
|
- [VapixEvents](doc/VapixEvents.md) is a module which allows receiving camera events from the VAPIX API.
|
|
33
33
|
|
|
34
|
+
- [GenetecAgent](doc/GenetecAgent.md) is a module which allows receiving and sending data to Genetec VMS.
|
|
35
|
+
|
|
34
36
|
## For Developers
|
|
35
37
|
|
|
36
38
|
### Publishing to npm repository
|
|
@@ -12,24 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.AxisCameraStationEvents = void 0;
|
|
13
13
|
const DefaultAgent_1 = require("../DefaultAgent");
|
|
14
14
|
const common_1 = require("../internal/common");
|
|
15
|
-
function pad(num, size) {
|
|
16
|
-
const sign = Math.sign(num) === -1 ? '-' : '';
|
|
17
|
-
return (sign +
|
|
18
|
-
new Array(size)
|
|
19
|
-
.concat([Math.abs(num)])
|
|
20
|
-
.join('0')
|
|
21
|
-
.slice(-size));
|
|
22
|
-
}
|
|
23
|
-
function getDate() {
|
|
24
|
-
const date = new Date();
|
|
25
|
-
const year = date.getUTCFullYear();
|
|
26
|
-
const month = pad(date.getUTCMonth() + 1, 2);
|
|
27
|
-
const day = pad(date.getUTCDate(), 2);
|
|
28
|
-
const hours = pad(date.getUTCHours(), 2);
|
|
29
|
-
const minutes = pad(date.getUTCMinutes(), 2);
|
|
30
|
-
const seconds = pad(date.getUTCSeconds(), 2);
|
|
31
|
-
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
32
|
-
}
|
|
33
15
|
class AxisCameraStationEvents {
|
|
34
16
|
constructor(sourceKey, opt = {}) {
|
|
35
17
|
this.sourceKey = sourceKey;
|
|
@@ -42,7 +24,7 @@ class AxisCameraStationEvents {
|
|
|
42
24
|
}
|
|
43
25
|
sendEvent(data, eventType) {
|
|
44
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
const dateString = getDate();
|
|
27
|
+
const dateString = this.getDate();
|
|
46
28
|
const event = {
|
|
47
29
|
addExternalDataRequest: {
|
|
48
30
|
occurrenceTime: dateString,
|
|
@@ -61,5 +43,15 @@ class AxisCameraStationEvents {
|
|
|
61
43
|
}
|
|
62
44
|
});
|
|
63
45
|
}
|
|
46
|
+
getDate() {
|
|
47
|
+
const date = new Date();
|
|
48
|
+
const year = date.getUTCFullYear();
|
|
49
|
+
const month = (0, common_1.pad)(date.getUTCMonth() + 1, 2);
|
|
50
|
+
const day = (0, common_1.pad)(date.getUTCDate(), 2);
|
|
51
|
+
const hours = (0, common_1.pad)(date.getUTCHours(), 2);
|
|
52
|
+
const minutes = (0, common_1.pad)(date.getUTCMinutes(), 2);
|
|
53
|
+
const seconds = (0, common_1.pad)(date.getUTCSeconds(), 2);
|
|
54
|
+
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
55
|
+
}
|
|
64
56
|
}
|
|
65
57
|
exports.AxisCameraStationEvents = AxisCameraStationEvents;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
declare const cameraGuidsResponseSchema: z.ZodObject<{
|
|
4
|
+
Rsp: z.ZodObject<{
|
|
5
|
+
Status: z.ZodString;
|
|
6
|
+
Result: z.ZodArray<z.ZodObject<{
|
|
7
|
+
Guid: z.ZodString;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
Guid: string;
|
|
10
|
+
}, {
|
|
11
|
+
Guid: string;
|
|
12
|
+
}>, "many">;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
Status: string;
|
|
15
|
+
Result: {
|
|
16
|
+
Guid: string;
|
|
17
|
+
}[];
|
|
18
|
+
}, {
|
|
19
|
+
Status: string;
|
|
20
|
+
Result: {
|
|
21
|
+
Guid: string;
|
|
22
|
+
}[];
|
|
23
|
+
}>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
Rsp: {
|
|
26
|
+
Status: string;
|
|
27
|
+
Result: {
|
|
28
|
+
Guid: string;
|
|
29
|
+
}[];
|
|
30
|
+
};
|
|
31
|
+
}, {
|
|
32
|
+
Rsp: {
|
|
33
|
+
Status: string;
|
|
34
|
+
Result: {
|
|
35
|
+
Guid: string;
|
|
36
|
+
}[];
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
39
|
+
export type TCameraGuidsResponse = z.infer<typeof cameraGuidsResponseSchema>;
|
|
40
|
+
declare const connectionResponseSchema: z.ZodObject<{
|
|
41
|
+
Rsp: z.ZodObject<{
|
|
42
|
+
Status: z.ZodString;
|
|
43
|
+
}, "strip", z.ZodTypeAny, {
|
|
44
|
+
Status: string;
|
|
45
|
+
}, {
|
|
46
|
+
Status: string;
|
|
47
|
+
}>;
|
|
48
|
+
}, "strip", z.ZodTypeAny, {
|
|
49
|
+
Rsp: {
|
|
50
|
+
Status: string;
|
|
51
|
+
};
|
|
52
|
+
}, {
|
|
53
|
+
Rsp: {
|
|
54
|
+
Status: string;
|
|
55
|
+
};
|
|
56
|
+
}>;
|
|
57
|
+
export type TConnectionResponse = z.infer<typeof connectionResponseSchema>;
|
|
58
|
+
export declare const cameraDetailsResponseSchema: z.ZodObject<{
|
|
59
|
+
Rsp: z.ZodObject<{
|
|
60
|
+
Status: z.ZodString;
|
|
61
|
+
Result: z.ZodArray<z.ZodObject<{
|
|
62
|
+
Guid: z.ZodOptional<z.ZodString>;
|
|
63
|
+
Name: z.ZodOptional<z.ZodString>;
|
|
64
|
+
EntityType: z.ZodOptional<z.ZodString>;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
Guid?: string | undefined;
|
|
67
|
+
Name?: string | undefined;
|
|
68
|
+
EntityType?: string | undefined;
|
|
69
|
+
}, {
|
|
70
|
+
Guid?: string | undefined;
|
|
71
|
+
Name?: string | undefined;
|
|
72
|
+
EntityType?: string | undefined;
|
|
73
|
+
}>, "many">;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
Status: string;
|
|
76
|
+
Result: {
|
|
77
|
+
Guid?: string | undefined;
|
|
78
|
+
Name?: string | undefined;
|
|
79
|
+
EntityType?: string | undefined;
|
|
80
|
+
}[];
|
|
81
|
+
}, {
|
|
82
|
+
Status: string;
|
|
83
|
+
Result: {
|
|
84
|
+
Guid?: string | undefined;
|
|
85
|
+
Name?: string | undefined;
|
|
86
|
+
EntityType?: string | undefined;
|
|
87
|
+
}[];
|
|
88
|
+
}>;
|
|
89
|
+
}, "strip", z.ZodTypeAny, {
|
|
90
|
+
Rsp: {
|
|
91
|
+
Status: string;
|
|
92
|
+
Result: {
|
|
93
|
+
Guid?: string | undefined;
|
|
94
|
+
Name?: string | undefined;
|
|
95
|
+
EntityType?: string | undefined;
|
|
96
|
+
}[];
|
|
97
|
+
};
|
|
98
|
+
}, {
|
|
99
|
+
Rsp: {
|
|
100
|
+
Status: string;
|
|
101
|
+
Result: {
|
|
102
|
+
Guid?: string | undefined;
|
|
103
|
+
Name?: string | undefined;
|
|
104
|
+
EntityType?: string | undefined;
|
|
105
|
+
}[];
|
|
106
|
+
};
|
|
107
|
+
}>;
|
|
108
|
+
export type TCameraDetailsResponse = z.infer<typeof cameraDetailsResponseSchema>;
|
|
109
|
+
type TParams = Array<'Guid' | 'Name' | 'EntityType'>;
|
|
110
|
+
export type GenetecAgentOptions = {
|
|
111
|
+
protocol?: 'http' | 'https' | 'https_insecure';
|
|
112
|
+
ip?: string;
|
|
113
|
+
port?: number;
|
|
114
|
+
base_uri?: string;
|
|
115
|
+
user?: string;
|
|
116
|
+
pass?: string;
|
|
117
|
+
app_id?: string;
|
|
118
|
+
};
|
|
119
|
+
export declare class GenetecAgent {
|
|
120
|
+
private settings;
|
|
121
|
+
private baseUrl;
|
|
122
|
+
private credentials;
|
|
123
|
+
constructor(options?: GenetecAgentOptions);
|
|
124
|
+
checkConnection(): Promise<TConnectionResponse>;
|
|
125
|
+
getAllCameraGuids(): Promise<TCameraGuidsResponse>;
|
|
126
|
+
getCameraDetails(guids: {
|
|
127
|
+
Guid: string;
|
|
128
|
+
}[], parameters: TParams): Promise<TCameraDetailsResponse>;
|
|
129
|
+
sendBookmark(guids: string[], bookmarkText: string): Promise<Response>;
|
|
130
|
+
private getRequestOptions;
|
|
131
|
+
private getTimeStamp;
|
|
132
|
+
}
|
|
133
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.GenetecAgent = exports.cameraDetailsResponseSchema = void 0;
|
|
13
|
+
const zod_1 = require("zod");
|
|
14
|
+
const common_1 = require("../internal/common");
|
|
15
|
+
const ACTION = 'AddCameraBookmark';
|
|
16
|
+
const GET_CAMERAS_URL = 'report/EntityConfiguration?q=EntityTypes@Camera';
|
|
17
|
+
const GET_CAMERAS_DETAILS_URL = '/entity?q=';
|
|
18
|
+
const cameraGuidsResponseSchema = zod_1.z.object({
|
|
19
|
+
Rsp: zod_1.z.object({
|
|
20
|
+
Status: zod_1.z.string(),
|
|
21
|
+
Result: zod_1.z.array(zod_1.z.object({ Guid: zod_1.z.string() })),
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
const connectionResponseSchema = zod_1.z.object({
|
|
25
|
+
Rsp: zod_1.z.object({
|
|
26
|
+
Status: zod_1.z.string(),
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
exports.cameraDetailsResponseSchema = zod_1.z.object({
|
|
30
|
+
Rsp: zod_1.z.object({
|
|
31
|
+
Status: zod_1.z.string(),
|
|
32
|
+
Result: zod_1.z.array(zod_1.z.object({
|
|
33
|
+
Guid: zod_1.z.string().optional(),
|
|
34
|
+
Name: zod_1.z.string().optional(),
|
|
35
|
+
EntityType: zod_1.z.string().optional(),
|
|
36
|
+
})),
|
|
37
|
+
}),
|
|
38
|
+
});
|
|
39
|
+
class GenetecAgent {
|
|
40
|
+
constructor(options = {}) {
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
42
|
+
this.settings = {
|
|
43
|
+
protocol: (_a = options.protocol) !== null && _a !== void 0 ? _a : 'http',
|
|
44
|
+
ip: (_b = options.ip) !== null && _b !== void 0 ? _b : '127.0.0.1',
|
|
45
|
+
port: (_c = options.port) !== null && _c !== void 0 ? _c : 80,
|
|
46
|
+
base_uri: (_d = options.base_uri) !== null && _d !== void 0 ? _d : 'WebSdk',
|
|
47
|
+
user: (_e = options.user) !== null && _e !== void 0 ? _e : 'root',
|
|
48
|
+
pass: (_f = options.pass) !== null && _f !== void 0 ? _f : '',
|
|
49
|
+
app_id: (_g = options.app_id) !== null && _g !== void 0 ? _g : '',
|
|
50
|
+
};
|
|
51
|
+
this.baseUrl = `${this.settings.protocol}://${this.settings.ip}:${this.settings.port}/${this.settings.base_uri}`;
|
|
52
|
+
this.credentials = btoa(`${this.settings.user};${this.settings.app_id}:${this.settings.pass}`);
|
|
53
|
+
}
|
|
54
|
+
checkConnection() {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const requestOptions = this.getRequestOptions('GET');
|
|
57
|
+
const res = yield fetch(`${this.baseUrl}/`, requestOptions);
|
|
58
|
+
if (!res.ok) {
|
|
59
|
+
throw new Error(yield (0, common_1.responseStringify)(res));
|
|
60
|
+
}
|
|
61
|
+
return connectionResponseSchema.parse(yield res.json());
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
getAllCameraGuids() {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const requestOptions = this.getRequestOptions('GET');
|
|
67
|
+
const res = yield fetch(`${this.baseUrl}/${GET_CAMERAS_URL}`, requestOptions);
|
|
68
|
+
if (!res.ok) {
|
|
69
|
+
throw new Error(yield (0, common_1.responseStringify)(res));
|
|
70
|
+
}
|
|
71
|
+
return cameraGuidsResponseSchema.parse(yield res.json());
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
getCameraDetails(guids, parameters) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
const params = parameters.join(',');
|
|
77
|
+
const camerasGuids = guids.map((item) => item.Guid);
|
|
78
|
+
const camerasDetailsUrl = [];
|
|
79
|
+
const requestOptions = this.getRequestOptions('GET');
|
|
80
|
+
for (const guid of camerasGuids) {
|
|
81
|
+
camerasDetailsUrl.push(`entity=${guid},${params}`);
|
|
82
|
+
}
|
|
83
|
+
const res = yield fetch(`${this.baseUrl}/${GET_CAMERAS_DETAILS_URL}${camerasDetailsUrl.join(',')}`, requestOptions);
|
|
84
|
+
if (!res.ok) {
|
|
85
|
+
throw new Error(yield (0, common_1.responseStringify)(res));
|
|
86
|
+
}
|
|
87
|
+
return exports.cameraDetailsResponseSchema.parse(yield res.json());
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
sendBookmark(guids, bookmarkText) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const cameraEntitiesUrl = [];
|
|
93
|
+
const timeStamp = this.getTimeStamp();
|
|
94
|
+
const requestOptions = this.getRequestOptions('POST');
|
|
95
|
+
for (const guid of guids) {
|
|
96
|
+
cameraEntitiesUrl.push(`${ACTION}(${guid},${timeStamp},${bookmarkText})`);
|
|
97
|
+
}
|
|
98
|
+
const res = yield fetch(`${this.baseUrl}/action?q=${cameraEntitiesUrl.join(',')}`, requestOptions);
|
|
99
|
+
if (!res.ok) {
|
|
100
|
+
throw new Error(yield (0, common_1.responseStringify)(res));
|
|
101
|
+
}
|
|
102
|
+
return res;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
getRequestOptions(method) {
|
|
106
|
+
return {
|
|
107
|
+
method,
|
|
108
|
+
headers: new Headers({
|
|
109
|
+
Authorization: `Basic ${this.credentials}`,
|
|
110
|
+
Accept: 'text/json',
|
|
111
|
+
}),
|
|
112
|
+
redirect: 'follow',
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
getTimeStamp() {
|
|
116
|
+
const date = new Date();
|
|
117
|
+
const year = date.getUTCFullYear();
|
|
118
|
+
const month = (0, common_1.pad)(date.getUTCMonth() + 1, 2);
|
|
119
|
+
const day = (0, common_1.pad)(date.getUTCDate(), 2);
|
|
120
|
+
const hours = (0, common_1.pad)(date.getUTCHours(), 2);
|
|
121
|
+
const minutes = (0, common_1.pad)(date.getUTCMinutes(), 2);
|
|
122
|
+
const seconds = (0, common_1.pad)(date.getUTCSeconds(), 2);
|
|
123
|
+
const miliSeconds = (0, common_1.pad)(date.getUTCMilliseconds(), 2);
|
|
124
|
+
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}.${miliSeconds}Z`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.GenetecAgent = GenetecAgent;
|
package/internal/common.d.ts
CHANGED
|
@@ -21,4 +21,5 @@ export interface IClient {
|
|
|
21
21
|
export declare function isClient(arg?: Options | IClient): arg is IClient;
|
|
22
22
|
export declare function isBrowserEnvironment(): boolean;
|
|
23
23
|
export declare function responseStringify(res: Response): Promise<string>;
|
|
24
|
+
export declare function pad(num: number, size: number): string;
|
|
24
25
|
export {};
|
package/internal/common.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.responseStringify = exports.isBrowserEnvironment = exports.isClient = void 0;
|
|
12
|
+
exports.pad = exports.responseStringify = exports.isBrowserEnvironment = exports.isClient = void 0;
|
|
13
13
|
function isClient(arg = {}) {
|
|
14
14
|
return 'get' in arg && 'post' in arg;
|
|
15
15
|
}
|
|
@@ -27,3 +27,12 @@ function responseStringify(res) {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
exports.responseStringify = responseStringify;
|
|
30
|
+
function pad(num, size) {
|
|
31
|
+
const sign = Math.sign(num) === -1 ? '-' : '';
|
|
32
|
+
return (sign +
|
|
33
|
+
new Array(size)
|
|
34
|
+
.concat([Math.abs(num)])
|
|
35
|
+
.join('0')
|
|
36
|
+
.slice(-size));
|
|
37
|
+
}
|
|
38
|
+
exports.pad = pad;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "camstreamerlib",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "Helper library for CamStreamer ACAP applications.",
|
|
5
5
|
"prettier": "@camstreamer/prettier-config",
|
|
6
6
|
"dependencies": {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"prettify-xml": "^1.2.0",
|
|
10
10
|
"undici": "6.13.0",
|
|
11
11
|
"ws": "^8.18.0",
|
|
12
|
-
"xml2js": "^0.5.0"
|
|
12
|
+
"xml2js": "^0.5.0",
|
|
13
|
+
"zod": "^3.24.3"
|
|
13
14
|
},
|
|
14
15
|
"engine": {
|
|
15
16
|
"node": ">=18.0.0"
|