camstreamerlib 3.5.0 → 3.5.2
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/DefaultAgent.d.ts +2 -2
- package/DefaultAgent.js +6 -5
- package/events/GenetecAgent.d.ts +46 -4
- package/events/GenetecAgent.js +26 -15
- package/package.json +68 -68
package/DefaultAgent.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare class DefaultAgent implements IClient {
|
|
|
9
9
|
private pass;
|
|
10
10
|
private httpRequestSender;
|
|
11
11
|
constructor(opt?: HttpOptions);
|
|
12
|
-
get(path: string, parameters?: Record<string, string>, headers?: Record<string, string
|
|
13
|
-
post(path: string, data: string | Buffer | FormData, parameters?: Record<string, string>, headers?: Record<string, string
|
|
12
|
+
get(path: string, parameters?: Record<string, string>, headers?: Record<string, string>, timeout?: number): Promise<Response>;
|
|
13
|
+
post(path: string, data: string | Buffer | FormData, parameters?: Record<string, string>, headers?: Record<string, string>, timeout?: number): Promise<Response>;
|
|
14
14
|
private getBaseConnectionParams;
|
|
15
15
|
}
|
package/DefaultAgent.js
CHANGED
|
@@ -28,21 +28,21 @@ class DefaultAgent {
|
|
|
28
28
|
}
|
|
29
29
|
this.httpRequestSender = new HttpRequestSender_1.HttpRequestSender(agentOptions);
|
|
30
30
|
}
|
|
31
|
-
get(path, parameters = {}, headers) {
|
|
31
|
+
get(path, parameters = {}, headers, timeout) {
|
|
32
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
const options = this.getBaseConnectionParams('GET', path, parameters);
|
|
33
|
+
const options = this.getBaseConnectionParams('GET', path, parameters, timeout);
|
|
34
34
|
options.headers = headers;
|
|
35
35
|
return this.httpRequestSender.sendRequest(options);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
post(path, data, parameters = {}, headers) {
|
|
38
|
+
post(path, data, parameters = {}, headers, timeout) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const options = this.getBaseConnectionParams('POST', path, parameters);
|
|
40
|
+
const options = this.getBaseConnectionParams('POST', path, parameters, timeout);
|
|
41
41
|
options.headers = headers;
|
|
42
42
|
return this.httpRequestSender.sendRequest(options, data);
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
getBaseConnectionParams(method, path, params) {
|
|
45
|
+
getBaseConnectionParams(method, path, params, timeout) {
|
|
46
46
|
if (path.indexOf('?') === -1) {
|
|
47
47
|
path += '?';
|
|
48
48
|
}
|
|
@@ -61,6 +61,7 @@ class DefaultAgent {
|
|
|
61
61
|
path: path,
|
|
62
62
|
user: this.user,
|
|
63
63
|
pass: this.pass,
|
|
64
|
+
timeout,
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
67
|
}
|
package/events/GenetecAgent.d.ts
CHANGED
|
@@ -55,10 +55,23 @@ declare const connectionResponseSchema: z.ZodObject<{
|
|
|
55
55
|
};
|
|
56
56
|
}>;
|
|
57
57
|
export type TConnectionResponse = z.infer<typeof connectionResponseSchema>;
|
|
58
|
+
export declare const cameraDetailSchema: z.ZodObject<{
|
|
59
|
+
Guid: z.ZodOptional<z.ZodString>;
|
|
60
|
+
Name: z.ZodOptional<z.ZodString>;
|
|
61
|
+
EntityType: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
Guid?: string | undefined;
|
|
64
|
+
Name?: string | undefined;
|
|
65
|
+
EntityType?: string | undefined;
|
|
66
|
+
}, {
|
|
67
|
+
Guid?: string | undefined;
|
|
68
|
+
Name?: string | undefined;
|
|
69
|
+
EntityType?: string | undefined;
|
|
70
|
+
}>;
|
|
58
71
|
export declare const cameraDetailsResponseSchema: z.ZodObject<{
|
|
59
72
|
Rsp: z.ZodObject<{
|
|
60
73
|
Status: z.ZodString;
|
|
61
|
-
Result: z.ZodArray<z.ZodObject<{
|
|
74
|
+
Result: z.ZodUnion<[z.ZodArray<z.ZodObject<{
|
|
62
75
|
Guid: z.ZodOptional<z.ZodString>;
|
|
63
76
|
Name: z.ZodOptional<z.ZodString>;
|
|
64
77
|
EntityType: z.ZodOptional<z.ZodString>;
|
|
@@ -70,13 +83,29 @@ export declare const cameraDetailsResponseSchema: z.ZodObject<{
|
|
|
70
83
|
Guid?: string | undefined;
|
|
71
84
|
Name?: string | undefined;
|
|
72
85
|
EntityType?: string | undefined;
|
|
73
|
-
}>, "many"
|
|
86
|
+
}>, "many">, z.ZodObject<{
|
|
87
|
+
Guid: z.ZodOptional<z.ZodString>;
|
|
88
|
+
Name: z.ZodOptional<z.ZodString>;
|
|
89
|
+
EntityType: z.ZodOptional<z.ZodString>;
|
|
90
|
+
}, "strip", z.ZodTypeAny, {
|
|
91
|
+
Guid?: string | undefined;
|
|
92
|
+
Name?: string | undefined;
|
|
93
|
+
EntityType?: string | undefined;
|
|
94
|
+
}, {
|
|
95
|
+
Guid?: string | undefined;
|
|
96
|
+
Name?: string | undefined;
|
|
97
|
+
EntityType?: string | undefined;
|
|
98
|
+
}>]>;
|
|
74
99
|
}, "strip", z.ZodTypeAny, {
|
|
75
100
|
Status: string;
|
|
76
101
|
Result: {
|
|
77
102
|
Guid?: string | undefined;
|
|
78
103
|
Name?: string | undefined;
|
|
79
104
|
EntityType?: string | undefined;
|
|
105
|
+
} | {
|
|
106
|
+
Guid?: string | undefined;
|
|
107
|
+
Name?: string | undefined;
|
|
108
|
+
EntityType?: string | undefined;
|
|
80
109
|
}[];
|
|
81
110
|
}, {
|
|
82
111
|
Status: string;
|
|
@@ -84,6 +113,10 @@ export declare const cameraDetailsResponseSchema: z.ZodObject<{
|
|
|
84
113
|
Guid?: string | undefined;
|
|
85
114
|
Name?: string | undefined;
|
|
86
115
|
EntityType?: string | undefined;
|
|
116
|
+
} | {
|
|
117
|
+
Guid?: string | undefined;
|
|
118
|
+
Name?: string | undefined;
|
|
119
|
+
EntityType?: string | undefined;
|
|
87
120
|
}[];
|
|
88
121
|
}>;
|
|
89
122
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -93,6 +126,10 @@ export declare const cameraDetailsResponseSchema: z.ZodObject<{
|
|
|
93
126
|
Guid?: string | undefined;
|
|
94
127
|
Name?: string | undefined;
|
|
95
128
|
EntityType?: string | undefined;
|
|
129
|
+
} | {
|
|
130
|
+
Guid?: string | undefined;
|
|
131
|
+
Name?: string | undefined;
|
|
132
|
+
EntityType?: string | undefined;
|
|
96
133
|
}[];
|
|
97
134
|
};
|
|
98
135
|
}, {
|
|
@@ -102,11 +139,16 @@ export declare const cameraDetailsResponseSchema: z.ZodObject<{
|
|
|
102
139
|
Guid?: string | undefined;
|
|
103
140
|
Name?: string | undefined;
|
|
104
141
|
EntityType?: string | undefined;
|
|
142
|
+
} | {
|
|
143
|
+
Guid?: string | undefined;
|
|
144
|
+
Name?: string | undefined;
|
|
145
|
+
EntityType?: string | undefined;
|
|
105
146
|
}[];
|
|
106
147
|
};
|
|
107
148
|
}>;
|
|
108
149
|
export type TCameraDetailsResponse = z.infer<typeof cameraDetailsResponseSchema>;
|
|
109
|
-
type
|
|
150
|
+
export type TCameraDetail = z.infer<typeof cameraDetailSchema>;
|
|
151
|
+
export type TParams = Array<'Guid' | 'Name' | 'EntityType'>;
|
|
110
152
|
export type GenetecAgentOptions = {
|
|
111
153
|
protocol?: 'http' | 'https' | 'https_insecure';
|
|
112
154
|
ip?: string;
|
|
@@ -125,7 +167,7 @@ export declare class GenetecAgent {
|
|
|
125
167
|
getAllCameraGuids(): Promise<TCameraGuidsResponse>;
|
|
126
168
|
getCameraDetails(guids: {
|
|
127
169
|
Guid: string;
|
|
128
|
-
}[], parameters: TParams): Promise<
|
|
170
|
+
}[], parameters: TParams): Promise<TCameraDetail[]>;
|
|
129
171
|
sendBookmark(guids: string[], bookmarkText: string): Promise<Response>;
|
|
130
172
|
private getRequestOptions;
|
|
131
173
|
private getTimeStamp;
|
package/events/GenetecAgent.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.GenetecAgent = exports.cameraDetailsResponseSchema = void 0;
|
|
12
|
+
exports.GenetecAgent = exports.cameraDetailsResponseSchema = exports.cameraDetailSchema = void 0;
|
|
13
13
|
const zod_1 = require("zod");
|
|
14
14
|
const common_1 = require("../internal/common");
|
|
15
15
|
const ACTION = 'AddCameraBookmark';
|
|
@@ -26,14 +26,15 @@ const connectionResponseSchema = zod_1.z.object({
|
|
|
26
26
|
Status: zod_1.z.string(),
|
|
27
27
|
}),
|
|
28
28
|
});
|
|
29
|
+
exports.cameraDetailSchema = zod_1.z.object({
|
|
30
|
+
Guid: zod_1.z.string().optional(),
|
|
31
|
+
Name: zod_1.z.string().optional(),
|
|
32
|
+
EntityType: zod_1.z.string().optional(),
|
|
33
|
+
});
|
|
29
34
|
exports.cameraDetailsResponseSchema = zod_1.z.object({
|
|
30
35
|
Rsp: zod_1.z.object({
|
|
31
36
|
Status: zod_1.z.string(),
|
|
32
|
-
Result: zod_1.z.
|
|
33
|
-
Guid: zod_1.z.string().optional(),
|
|
34
|
-
Name: zod_1.z.string().optional(),
|
|
35
|
-
EntityType: zod_1.z.string().optional(),
|
|
36
|
-
})),
|
|
37
|
+
Result: zod_1.z.union([zod_1.z.array(exports.cameraDetailSchema), exports.cameraDetailSchema]),
|
|
37
38
|
}),
|
|
38
39
|
});
|
|
39
40
|
class GenetecAgent {
|
|
@@ -74,17 +75,27 @@ class GenetecAgent {
|
|
|
74
75
|
getCameraDetails(guids, parameters) {
|
|
75
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
77
|
const params = parameters.join(',');
|
|
77
|
-
|
|
78
|
-
const camerasDetailsUrl = [];
|
|
78
|
+
let camerasGuids = [];
|
|
79
79
|
const requestOptions = this.getRequestOptions('GET');
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
80
|
+
const allCameras = [];
|
|
81
|
+
const chunkSize = 10;
|
|
82
|
+
while (guids.length > 0) {
|
|
83
|
+
const chunk = guids.slice(0, chunkSize);
|
|
84
|
+
guids.splice(0, chunkSize);
|
|
85
|
+
camerasGuids = chunk.map((item) => item.Guid);
|
|
86
|
+
const camerasDetailsUrl = [];
|
|
87
|
+
for (const guid of camerasGuids) {
|
|
88
|
+
camerasDetailsUrl.push(`entity=${guid},${params}`);
|
|
89
|
+
}
|
|
90
|
+
const res = yield fetch(`${this.baseUrl}/${GET_CAMERAS_DETAILS_URL}${camerasDetailsUrl.join(',')}`, requestOptions);
|
|
91
|
+
if (!res.ok) {
|
|
92
|
+
throw new Error(yield (0, common_1.responseStringify)(res));
|
|
93
|
+
}
|
|
94
|
+
const data = exports.cameraDetailsResponseSchema.parse(yield res.json());
|
|
95
|
+
const resultArray = Array.isArray(data.Rsp.Result) ? data.Rsp.Result : [data.Rsp.Result];
|
|
96
|
+
allCameras.push(...resultArray);
|
|
86
97
|
}
|
|
87
|
-
return
|
|
98
|
+
return allCameras;
|
|
88
99
|
});
|
|
89
100
|
}
|
|
90
101
|
sendBookmark(guids, bookmarkText) {
|
package/package.json
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
2
|
+
"name": "camstreamerlib",
|
|
3
|
+
"version": "3.5.2",
|
|
4
|
+
"description": "Helper library for CamStreamer ACAP applications.",
|
|
5
|
+
"prettier": "@camstreamer/prettier-config",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"adm-zip": "^0.5.9",
|
|
8
|
+
"eventemitter2": "^5.0.1",
|
|
9
|
+
"prettify-xml": "^1.2.0",
|
|
10
|
+
"undici": "6.13.0",
|
|
11
|
+
"ws": "^8.18.0",
|
|
12
|
+
"xml2js": "^0.5.0",
|
|
13
|
+
"zod": "^3.24.3"
|
|
14
|
+
},
|
|
15
|
+
"engine": {
|
|
16
|
+
"node": ">=18.0.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@camstreamer/eslint-config": "^1.0.0",
|
|
20
|
+
"@camstreamer/prettier-config": "^2.0.4",
|
|
21
|
+
"@types/adm-zip": "^0.5.5",
|
|
22
|
+
"@types/jest": "^28.0.0",
|
|
23
|
+
"@types/node": "^18.19.39",
|
|
24
|
+
"@types/ws": "^8.5.10",
|
|
25
|
+
"@types/xml2js": "^0.4.14",
|
|
26
|
+
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
|
27
|
+
"@typescript-eslint/parser": "^6.8.0",
|
|
28
|
+
"eslint": "^8.51.0",
|
|
29
|
+
"eslint-plugin-deprecation": "^2.0.0",
|
|
30
|
+
"eslint-plugin-unused-imports": "^3.0.0",
|
|
31
|
+
"jest": "^28.1.3",
|
|
32
|
+
"npm-run-all": "^4.1.5",
|
|
33
|
+
"prettier": "^2.7.1",
|
|
34
|
+
"ts-jest": "^28.0.0",
|
|
35
|
+
"ts-node": "^10.7.0",
|
|
36
|
+
"typescript": "5.3.3"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"clean": "rimraf dist/*",
|
|
40
|
+
"build": "npm-run-all clean tsc copyPackage",
|
|
41
|
+
"tsc": "tsc",
|
|
42
|
+
"copyPackage": "cp -f LICENSE dist/ && cp -f README.md dist/ && cp -f package.json dist/",
|
|
43
|
+
"lint": "eslint \"src/**/*.ts\"",
|
|
44
|
+
"lint:fix": "eslint \"src/**/*.ts\" --fix",
|
|
45
|
+
"pretty": "prettier --write \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
|
|
46
|
+
"pretty:check": "prettier --check \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
|
|
47
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"/**/*.js",
|
|
51
|
+
"/**/*.ts"
|
|
52
|
+
],
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "git+https://github.com/CamStreamer/CamStreamerLib.git"
|
|
56
|
+
},
|
|
57
|
+
"keywords": [
|
|
58
|
+
"CamStreamer",
|
|
59
|
+
"CamOverlay",
|
|
60
|
+
"CamScripter",
|
|
61
|
+
"Camera",
|
|
62
|
+
"Axis"
|
|
63
|
+
],
|
|
64
|
+
"author": "CamStreamer s.r.o",
|
|
65
|
+
"license": "ISC",
|
|
66
|
+
"bugs": {
|
|
67
|
+
"url": "https://github.com/CamStreamer/CamStreamerLib/issues"
|
|
68
|
+
},
|
|
69
|
+
"homepage": "https://github.com/CamStreamer/CamStreamerLib#readme"
|
|
70
70
|
}
|