camstreamerlib 4.0.35-bc56d1e → 4.0.36
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/VapixAPI.js +15 -11
- package/cjs/VapixAPI.test.d.ts +1 -0
- package/cjs/VapixAPI.test.js +146 -0
- package/cjs/types/ws/CamSwitcherEvents.d.ts +8 -8
- package/esm/VapixAPI.js +16 -12
- package/esm/VapixAPI.test.js +144 -0
- package/package.json +107 -107
- package/types/VapixAPI.test.d.ts +1 -0
- package/types/types/ws/CamSwitcherEvents.d.ts +8 -8
package/cjs/VapixAPI.js
CHANGED
|
@@ -565,17 +565,21 @@ class VapixAPI extends BasicAPI_1.BasicAPI {
|
|
|
565
565
|
allowBooleanAttributes: true,
|
|
566
566
|
});
|
|
567
567
|
const result = parser.parse(xml);
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
|
|
568
|
+
const rawApps = result.reply.application ?? [];
|
|
569
|
+
const apps = Array.isArray(rawApps) ? rawApps : [rawApps];
|
|
570
|
+
const appList = [];
|
|
571
|
+
for (const app of apps) {
|
|
572
|
+
const parsedApp = VapixAPI_1.applicationSchema.safeParse(app);
|
|
573
|
+
if (!parsedApp.success) {
|
|
574
|
+
console.debug('Skipping invalid application entry:', app, parsedApp.error.issues);
|
|
575
|
+
continue;
|
|
576
|
+
}
|
|
577
|
+
appList.push({
|
|
578
|
+
...parsedApp.data,
|
|
579
|
+
appId: VapixAPI_1.ALL_APP_IDS.find((id) => id.toLowerCase() === parsedApp.data.Name.toLowerCase()) ?? null,
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
return appList;
|
|
579
583
|
}
|
|
580
584
|
async startApplication(applicationId, options) {
|
|
581
585
|
const agent = this.getClient(options?.proxyParams);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const VapixAPI_1 = require("./VapixAPI");
|
|
4
|
+
const globals_1 = require("@jest/globals");
|
|
5
|
+
const createApi = (xml) => {
|
|
6
|
+
const client = {
|
|
7
|
+
get: () => Promise.resolve(new Response(xml)),
|
|
8
|
+
post: () => Promise.reject(new Error('unused')),
|
|
9
|
+
};
|
|
10
|
+
return new VapixAPI_1.VapixAPI(client);
|
|
11
|
+
};
|
|
12
|
+
(0, globals_1.describe)('VapixAPI', () => {
|
|
13
|
+
(0, globals_1.describe)('getApplicationList', () => {
|
|
14
|
+
(0, globals_1.afterEach)(() => {
|
|
15
|
+
globals_1.jest.restoreAllMocks();
|
|
16
|
+
});
|
|
17
|
+
(0, globals_1.test)('skips the nameless entry of the live camera list', async () => {
|
|
18
|
+
const debugSpy = globals_1.jest.spyOn(console, 'debug').mockImplementation(() => { });
|
|
19
|
+
const api = createApi(`<reply result="ok">
|
|
20
|
+
<application Name="camstreamer" NiceName="CamStreamer App" Vendor="CamStreamer" Version="5.0-15" ApplicationID="413135" License="None" Status="Running" ConfigurationPage="local/camstreamer/settings.html" />
|
|
21
|
+
<application Name="" License="None" Status="Stopped" />
|
|
22
|
+
<application Name="vmd" NiceName="AXIS Video Motion Detection" Vendor="Axis Communications" Version="4.4-5" ApplicationID="143440" License="None" Status="Stopped" ConfigurationPage="local/vmd/config.html" VendorHomePage="http://www.axis.com" LicenseName="Proprietary" />
|
|
23
|
+
</reply>`);
|
|
24
|
+
await (0, globals_1.expect)(api.getApplicationList()).resolves.toEqual([
|
|
25
|
+
{
|
|
26
|
+
Name: 'camstreamer',
|
|
27
|
+
NiceName: 'CamStreamer App',
|
|
28
|
+
Vendor: 'CamStreamer',
|
|
29
|
+
Version: '5.0-15',
|
|
30
|
+
ApplicationID: '413135',
|
|
31
|
+
License: 'None',
|
|
32
|
+
Status: 'Running',
|
|
33
|
+
ConfigurationPage: 'local/camstreamer/settings.html',
|
|
34
|
+
appId: 'CamStreamer',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
Name: 'vmd',
|
|
38
|
+
NiceName: 'AXIS Video Motion Detection',
|
|
39
|
+
Vendor: 'Axis Communications',
|
|
40
|
+
Version: '4.4-5',
|
|
41
|
+
ApplicationID: '143440',
|
|
42
|
+
License: 'None',
|
|
43
|
+
Status: 'Stopped',
|
|
44
|
+
ConfigurationPage: 'local/vmd/config.html',
|
|
45
|
+
VendorHomePage: 'http://www.axis.com',
|
|
46
|
+
LicenseName: 'Proprietary',
|
|
47
|
+
appId: null,
|
|
48
|
+
},
|
|
49
|
+
]);
|
|
50
|
+
(0, globals_1.expect)(debugSpy).toHaveBeenCalledTimes(1);
|
|
51
|
+
(0, globals_1.expect)(debugSpy.mock.calls[0]).toContainEqual({ Name: '', License: 'None', Status: 'Stopped' });
|
|
52
|
+
});
|
|
53
|
+
globals_1.test.each([
|
|
54
|
+
{
|
|
55
|
+
name: 'an entry without a name',
|
|
56
|
+
xml: '<reply result="ok"><application Name="vmd" NiceName="AXIS Video Motion Detection" Vendor="Axis Communications" Version="4.4-5" License="None" Status="Stopped" /><application License="None" Status="Stopped" /></reply>',
|
|
57
|
+
expected: [
|
|
58
|
+
{
|
|
59
|
+
Name: 'vmd',
|
|
60
|
+
NiceName: 'AXIS Video Motion Detection',
|
|
61
|
+
Vendor: 'Axis Communications',
|
|
62
|
+
Version: '4.4-5',
|
|
63
|
+
License: 'None',
|
|
64
|
+
Status: 'Stopped',
|
|
65
|
+
appId: null,
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'a named entry missing informational fields',
|
|
71
|
+
xml: '<reply result="ok"><application Name="vmd" NiceName="AXIS Video Motion Detection" Vendor="Axis Communications" Version="4.4-5" License="None" Status="Stopped" /><application Name="broken" License="None" Status="Stopped" /></reply>',
|
|
72
|
+
expected: [
|
|
73
|
+
{
|
|
74
|
+
Name: 'vmd',
|
|
75
|
+
NiceName: 'AXIS Video Motion Detection',
|
|
76
|
+
Vendor: 'Axis Communications',
|
|
77
|
+
Version: '4.4-5',
|
|
78
|
+
License: 'None',
|
|
79
|
+
Status: 'Stopped',
|
|
80
|
+
appId: null,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
])('skips invalid entries individually: $name', async ({ xml, expected }) => {
|
|
85
|
+
const debugSpy = globals_1.jest.spyOn(console, 'debug').mockImplementation(() => { });
|
|
86
|
+
await (0, globals_1.expect)(createApi(xml).getApplicationList()).resolves.toEqual(expected);
|
|
87
|
+
(0, globals_1.expect)(debugSpy).toHaveBeenCalledTimes(1);
|
|
88
|
+
});
|
|
89
|
+
globals_1.test.each([
|
|
90
|
+
{
|
|
91
|
+
name: 'drops attributes outside the schema',
|
|
92
|
+
xml: '<reply result="ok"><application Name="camoverlay" NiceName="CamOverlay App" Vendor="CamStreamer" Version="3.0-1" License="None" Status="Running" Unexpected="value" /></reply>',
|
|
93
|
+
expected: [
|
|
94
|
+
{
|
|
95
|
+
Name: 'camoverlay',
|
|
96
|
+
NiceName: 'CamOverlay App',
|
|
97
|
+
Vendor: 'CamStreamer',
|
|
98
|
+
Version: '3.0-1',
|
|
99
|
+
License: 'None',
|
|
100
|
+
Status: 'Running',
|
|
101
|
+
appId: 'CamOverlay',
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'maps an application outside the core CamStreamer apps to its appId',
|
|
107
|
+
xml: '<reply result="ok"><application Name="sporttracker" NiceName="SportTracker App" Vendor="CamStreamer" Version="1.0-1" License="None" Status="Running" /></reply>',
|
|
108
|
+
expected: [
|
|
109
|
+
{
|
|
110
|
+
Name: 'sporttracker',
|
|
111
|
+
NiceName: 'SportTracker App',
|
|
112
|
+
Vendor: 'CamStreamer',
|
|
113
|
+
Version: '1.0-1',
|
|
114
|
+
License: 'None',
|
|
115
|
+
Status: 'Running',
|
|
116
|
+
appId: 'SportTracker',
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'maps a capitalised application name to its appId',
|
|
122
|
+
xml: '<reply result="ok"><application Name="CamOverlay" NiceName="CamOverlay App" Vendor="CamStreamer" Version="3.0-1" License="None" Status="Running" /></reply>',
|
|
123
|
+
expected: [
|
|
124
|
+
{
|
|
125
|
+
Name: 'CamOverlay',
|
|
126
|
+
NiceName: 'CamOverlay App',
|
|
127
|
+
Vendor: 'CamStreamer',
|
|
128
|
+
Version: '3.0-1',
|
|
129
|
+
License: 'None',
|
|
130
|
+
Status: 'Running',
|
|
131
|
+
appId: 'CamOverlay',
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: 'returns an empty list when the camera has no applications',
|
|
137
|
+
xml: '<reply result="ok"></reply>',
|
|
138
|
+
expected: [],
|
|
139
|
+
},
|
|
140
|
+
])('returns every valid entry with its appId and logs nothing: $name', async ({ xml, expected }) => {
|
|
141
|
+
const debugSpy = globals_1.jest.spyOn(console, 'debug').mockImplementation(() => { });
|
|
142
|
+
await (0, globals_1.expect)(createApi(xml).getApplicationList()).resolves.toEqual(expected);
|
|
143
|
+
(0, globals_1.expect)(debugSpy).not.toHaveBeenCalled();
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
});
|
|
@@ -54,15 +54,15 @@ declare const cswEventsDataSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
|
|
|
54
54
|
}, "strip", z.ZodTypeAny, {
|
|
55
55
|
type: "StreamSwitchVideoError";
|
|
56
56
|
playlist_name: string;
|
|
57
|
-
playlist_active_stream: number;
|
|
58
57
|
info: string;
|
|
58
|
+
playlist_active_stream: number;
|
|
59
59
|
stream_name?: string | undefined;
|
|
60
60
|
clip_name?: string | undefined;
|
|
61
61
|
}, {
|
|
62
62
|
type: "StreamSwitchVideoError";
|
|
63
63
|
playlist_name: string;
|
|
64
|
-
playlist_active_stream: number;
|
|
65
64
|
info: string;
|
|
65
|
+
playlist_active_stream: number;
|
|
66
66
|
stream_name?: string | undefined;
|
|
67
67
|
clip_name?: string | undefined;
|
|
68
68
|
}>, z.ZodObject<{
|
|
@@ -207,15 +207,15 @@ export declare const cswEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
207
207
|
}, "strip", z.ZodTypeAny, {
|
|
208
208
|
type: "StreamSwitchVideoError";
|
|
209
209
|
playlist_name: string;
|
|
210
|
-
playlist_active_stream: number;
|
|
211
210
|
info: string;
|
|
211
|
+
playlist_active_stream: number;
|
|
212
212
|
stream_name?: string | undefined;
|
|
213
213
|
clip_name?: string | undefined;
|
|
214
214
|
}, {
|
|
215
215
|
type: "StreamSwitchVideoError";
|
|
216
216
|
playlist_name: string;
|
|
217
|
-
playlist_active_stream: number;
|
|
218
217
|
info: string;
|
|
218
|
+
playlist_active_stream: number;
|
|
219
219
|
stream_name?: string | undefined;
|
|
220
220
|
clip_name?: string | undefined;
|
|
221
221
|
}>, z.ZodObject<{
|
|
@@ -323,8 +323,8 @@ export declare const cswEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
323
323
|
} | {
|
|
324
324
|
type: "StreamSwitchVideoError";
|
|
325
325
|
playlist_name: string;
|
|
326
|
-
playlist_active_stream: number;
|
|
327
326
|
info: string;
|
|
327
|
+
playlist_active_stream: number;
|
|
328
328
|
stream_name?: string | undefined;
|
|
329
329
|
clip_name?: string | undefined;
|
|
330
330
|
} | {
|
|
@@ -376,8 +376,8 @@ export declare const cswEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
376
376
|
} | {
|
|
377
377
|
type: "StreamSwitchVideoError";
|
|
378
378
|
playlist_name: string;
|
|
379
|
-
playlist_active_stream: number;
|
|
380
379
|
info: string;
|
|
380
|
+
playlist_active_stream: number;
|
|
381
381
|
stream_name?: string | undefined;
|
|
382
382
|
clip_name?: string | undefined;
|
|
383
383
|
} | {
|
|
@@ -464,15 +464,15 @@ export declare const cswEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
464
464
|
}, "strip", z.ZodTypeAny, {
|
|
465
465
|
type: "StreamSwitchVideoError";
|
|
466
466
|
playlist_name: string;
|
|
467
|
-
playlist_active_stream: number;
|
|
468
467
|
info: string;
|
|
468
|
+
playlist_active_stream: number;
|
|
469
469
|
stream_name?: string | undefined;
|
|
470
470
|
clip_name?: string | undefined;
|
|
471
471
|
}, {
|
|
472
472
|
type: "StreamSwitchVideoError";
|
|
473
473
|
playlist_name: string;
|
|
474
|
-
playlist_active_stream: number;
|
|
475
474
|
info: string;
|
|
475
|
+
playlist_active_stream: number;
|
|
476
476
|
stream_name?: string | undefined;
|
|
477
477
|
clip_name?: string | undefined;
|
|
478
478
|
}>, z.ZodObject<{
|
package/esm/VapixAPI.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { arrayToUrl, isNullish, paramToUrl } from './internal/utils';
|
|
2
|
-
import { sdCardWatchedStatuses, maxFpsResponseSchema, dateTimeinfoSchema, audioDeviceRequestSchema, audioSampleRatesResponseSchema, timeZoneSchema, getPortsResponseSchema, guardTourSchema, ptzOverviewSchema, cameraPTZItemDataSchema,
|
|
2
|
+
import { sdCardWatchedStatuses, maxFpsResponseSchema, dateTimeinfoSchema, audioDeviceRequestSchema, audioSampleRatesResponseSchema, applicationSchema, timeZoneSchema, getPortsResponseSchema, guardTourSchema, ptzOverviewSchema, cameraPTZItemDataSchema, sdCardInfoSchema, ALL_APP_IDS, allDateTimeInfoSchema, } from './types/VapixAPI';
|
|
3
3
|
import { ApplicationAPIError, MaxFPSError, NoDeviceInfoError, PtzNotSupportedError, ErrorWithResponse, SDCardActionError, SDCardJobError, SettingParameterError, TimezoneFetchError, } from './errors/errors';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { XMLParser } from 'fast-xml-parser';
|
|
@@ -562,17 +562,21 @@ export class VapixAPI extends BasicAPI {
|
|
|
562
562
|
allowBooleanAttributes: true,
|
|
563
563
|
});
|
|
564
564
|
const result = parser.parse(xml);
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
|
|
565
|
+
const rawApps = result.reply.application ?? [];
|
|
566
|
+
const apps = Array.isArray(rawApps) ? rawApps : [rawApps];
|
|
567
|
+
const appList = [];
|
|
568
|
+
for (const app of apps) {
|
|
569
|
+
const parsedApp = applicationSchema.safeParse(app);
|
|
570
|
+
if (!parsedApp.success) {
|
|
571
|
+
console.debug('Skipping invalid application entry:', app, parsedApp.error.issues);
|
|
572
|
+
continue;
|
|
573
|
+
}
|
|
574
|
+
appList.push({
|
|
575
|
+
...parsedApp.data,
|
|
576
|
+
appId: ALL_APP_IDS.find((id) => id.toLowerCase() === parsedApp.data.Name.toLowerCase()) ?? null,
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
return appList;
|
|
576
580
|
}
|
|
577
581
|
async startApplication(applicationId, options) {
|
|
578
582
|
const agent = this.getClient(options?.proxyParams);
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { VapixAPI } from './VapixAPI';
|
|
2
|
+
import { describe, test, expect, jest, afterEach } from '@jest/globals';
|
|
3
|
+
const createApi = (xml) => {
|
|
4
|
+
const client = {
|
|
5
|
+
get: () => Promise.resolve(new Response(xml)),
|
|
6
|
+
post: () => Promise.reject(new Error('unused')),
|
|
7
|
+
};
|
|
8
|
+
return new VapixAPI(client);
|
|
9
|
+
};
|
|
10
|
+
describe('VapixAPI', () => {
|
|
11
|
+
describe('getApplicationList', () => {
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
jest.restoreAllMocks();
|
|
14
|
+
});
|
|
15
|
+
test('skips the nameless entry of the live camera list', async () => {
|
|
16
|
+
const debugSpy = jest.spyOn(console, 'debug').mockImplementation(() => { });
|
|
17
|
+
const api = createApi(`<reply result="ok">
|
|
18
|
+
<application Name="camstreamer" NiceName="CamStreamer App" Vendor="CamStreamer" Version="5.0-15" ApplicationID="413135" License="None" Status="Running" ConfigurationPage="local/camstreamer/settings.html" />
|
|
19
|
+
<application Name="" License="None" Status="Stopped" />
|
|
20
|
+
<application Name="vmd" NiceName="AXIS Video Motion Detection" Vendor="Axis Communications" Version="4.4-5" ApplicationID="143440" License="None" Status="Stopped" ConfigurationPage="local/vmd/config.html" VendorHomePage="http://www.axis.com" LicenseName="Proprietary" />
|
|
21
|
+
</reply>`);
|
|
22
|
+
await expect(api.getApplicationList()).resolves.toEqual([
|
|
23
|
+
{
|
|
24
|
+
Name: 'camstreamer',
|
|
25
|
+
NiceName: 'CamStreamer App',
|
|
26
|
+
Vendor: 'CamStreamer',
|
|
27
|
+
Version: '5.0-15',
|
|
28
|
+
ApplicationID: '413135',
|
|
29
|
+
License: 'None',
|
|
30
|
+
Status: 'Running',
|
|
31
|
+
ConfigurationPage: 'local/camstreamer/settings.html',
|
|
32
|
+
appId: 'CamStreamer',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
Name: 'vmd',
|
|
36
|
+
NiceName: 'AXIS Video Motion Detection',
|
|
37
|
+
Vendor: 'Axis Communications',
|
|
38
|
+
Version: '4.4-5',
|
|
39
|
+
ApplicationID: '143440',
|
|
40
|
+
License: 'None',
|
|
41
|
+
Status: 'Stopped',
|
|
42
|
+
ConfigurationPage: 'local/vmd/config.html',
|
|
43
|
+
VendorHomePage: 'http://www.axis.com',
|
|
44
|
+
LicenseName: 'Proprietary',
|
|
45
|
+
appId: null,
|
|
46
|
+
},
|
|
47
|
+
]);
|
|
48
|
+
expect(debugSpy).toHaveBeenCalledTimes(1);
|
|
49
|
+
expect(debugSpy.mock.calls[0]).toContainEqual({ Name: '', License: 'None', Status: 'Stopped' });
|
|
50
|
+
});
|
|
51
|
+
test.each([
|
|
52
|
+
{
|
|
53
|
+
name: 'an entry without a name',
|
|
54
|
+
xml: '<reply result="ok"><application Name="vmd" NiceName="AXIS Video Motion Detection" Vendor="Axis Communications" Version="4.4-5" License="None" Status="Stopped" /><application License="None" Status="Stopped" /></reply>',
|
|
55
|
+
expected: [
|
|
56
|
+
{
|
|
57
|
+
Name: 'vmd',
|
|
58
|
+
NiceName: 'AXIS Video Motion Detection',
|
|
59
|
+
Vendor: 'Axis Communications',
|
|
60
|
+
Version: '4.4-5',
|
|
61
|
+
License: 'None',
|
|
62
|
+
Status: 'Stopped',
|
|
63
|
+
appId: null,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'a named entry missing informational fields',
|
|
69
|
+
xml: '<reply result="ok"><application Name="vmd" NiceName="AXIS Video Motion Detection" Vendor="Axis Communications" Version="4.4-5" License="None" Status="Stopped" /><application Name="broken" License="None" Status="Stopped" /></reply>',
|
|
70
|
+
expected: [
|
|
71
|
+
{
|
|
72
|
+
Name: 'vmd',
|
|
73
|
+
NiceName: 'AXIS Video Motion Detection',
|
|
74
|
+
Vendor: 'Axis Communications',
|
|
75
|
+
Version: '4.4-5',
|
|
76
|
+
License: 'None',
|
|
77
|
+
Status: 'Stopped',
|
|
78
|
+
appId: null,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
])('skips invalid entries individually: $name', async ({ xml, expected }) => {
|
|
83
|
+
const debugSpy = jest.spyOn(console, 'debug').mockImplementation(() => { });
|
|
84
|
+
await expect(createApi(xml).getApplicationList()).resolves.toEqual(expected);
|
|
85
|
+
expect(debugSpy).toHaveBeenCalledTimes(1);
|
|
86
|
+
});
|
|
87
|
+
test.each([
|
|
88
|
+
{
|
|
89
|
+
name: 'drops attributes outside the schema',
|
|
90
|
+
xml: '<reply result="ok"><application Name="camoverlay" NiceName="CamOverlay App" Vendor="CamStreamer" Version="3.0-1" License="None" Status="Running" Unexpected="value" /></reply>',
|
|
91
|
+
expected: [
|
|
92
|
+
{
|
|
93
|
+
Name: 'camoverlay',
|
|
94
|
+
NiceName: 'CamOverlay App',
|
|
95
|
+
Vendor: 'CamStreamer',
|
|
96
|
+
Version: '3.0-1',
|
|
97
|
+
License: 'None',
|
|
98
|
+
Status: 'Running',
|
|
99
|
+
appId: 'CamOverlay',
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: 'maps an application outside the core CamStreamer apps to its appId',
|
|
105
|
+
xml: '<reply result="ok"><application Name="sporttracker" NiceName="SportTracker App" Vendor="CamStreamer" Version="1.0-1" License="None" Status="Running" /></reply>',
|
|
106
|
+
expected: [
|
|
107
|
+
{
|
|
108
|
+
Name: 'sporttracker',
|
|
109
|
+
NiceName: 'SportTracker App',
|
|
110
|
+
Vendor: 'CamStreamer',
|
|
111
|
+
Version: '1.0-1',
|
|
112
|
+
License: 'None',
|
|
113
|
+
Status: 'Running',
|
|
114
|
+
appId: 'SportTracker',
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: 'maps a capitalised application name to its appId',
|
|
120
|
+
xml: '<reply result="ok"><application Name="CamOverlay" NiceName="CamOverlay App" Vendor="CamStreamer" Version="3.0-1" License="None" Status="Running" /></reply>',
|
|
121
|
+
expected: [
|
|
122
|
+
{
|
|
123
|
+
Name: 'CamOverlay',
|
|
124
|
+
NiceName: 'CamOverlay App',
|
|
125
|
+
Vendor: 'CamStreamer',
|
|
126
|
+
Version: '3.0-1',
|
|
127
|
+
License: 'None',
|
|
128
|
+
Status: 'Running',
|
|
129
|
+
appId: 'CamOverlay',
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: 'returns an empty list when the camera has no applications',
|
|
135
|
+
xml: '<reply result="ok"></reply>',
|
|
136
|
+
expected: [],
|
|
137
|
+
},
|
|
138
|
+
])('returns every valid entry with its appId and logs nothing: $name', async ({ xml, expected }) => {
|
|
139
|
+
const debugSpy = jest.spyOn(console, 'debug').mockImplementation(() => { });
|
|
140
|
+
await expect(createApi(xml).getApplicationList()).resolves.toEqual(expected);
|
|
141
|
+
expect(debugSpy).not.toHaveBeenCalled();
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
});
|
package/package.json
CHANGED
|
@@ -1,114 +1,114 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"adm-zip": "^0.6.0",
|
|
11
|
-
"eventemitter2": "^5.0.1",
|
|
12
|
-
"fast-xml-parser": "^5.3.6",
|
|
13
|
-
"type-fest": "^4.41.0",
|
|
14
|
-
"undici": "^6.28.1",
|
|
15
|
-
"ws": "^8.18.0",
|
|
16
|
-
"zod": "^3.25.76"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"@camstreamer/eslint-config": "^1.0.10",
|
|
20
|
-
"@camstreamer/prettier-config": "^2.0.4",
|
|
21
|
-
"@eslint/js": "^10.0.1",
|
|
22
|
-
"@types/adm-zip": "^0.5.5",
|
|
23
|
-
"@types/jest": "^30.0.0",
|
|
24
|
-
"@types/node": "^18.19.127",
|
|
25
|
-
"@types/ws": "^8.5.10",
|
|
26
|
-
"esbuild": "^0.28.2",
|
|
27
|
-
"eslint": "^10.12.0",
|
|
28
|
-
"eslint-plugin-unused-imports": "^4.4.1",
|
|
29
|
-
"globals": "^17.13.0",
|
|
30
|
-
"jest": "^30.5.2",
|
|
31
|
-
"npm-run-all": "^4.1.5",
|
|
32
|
-
"prettier": "^2.7.1",
|
|
33
|
-
"ts-jest": "^29.4.14",
|
|
34
|
-
"ts-node": "^10.7.0",
|
|
35
|
-
"typescript": "5.3.3",
|
|
36
|
-
"typescript-eslint": "^8.71.2"
|
|
37
|
-
},
|
|
38
|
-
"overrides": {
|
|
39
|
-
"js-yaml": "^4.3.2",
|
|
40
|
-
"browserslist": "^4.28.7"
|
|
41
|
-
},
|
|
42
|
-
"scripts": {
|
|
43
|
-
"clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
44
|
-
"build": "npm-run-all clean build:cjs build:esm copyPackage",
|
|
45
|
-
"build:cjs": "tsc --project tsconfig.cjs.json",
|
|
46
|
-
"build:esm": "tsc --project tsconfig.esm.json",
|
|
47
|
-
"build:browser": "esbuild src/browser.index.ts --bundle --format=esm --platform=browser --target=es2022 --outfile=examples/camstreamerlib.js",
|
|
48
|
-
"copyPackage": "cp -f LICENSE dist/ && cp -f README.md dist/ && cp -f package.json dist/ && cp -r -f examples dist/",
|
|
49
|
-
"publishPackage": "./publish.sh",
|
|
50
|
-
"lint": "eslint \"src/**/*.ts\"",
|
|
51
|
-
"lint:fix": "eslint \"src/**/*.ts\" --fix",
|
|
52
|
-
"pretty": "prettier --write \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
|
|
53
|
-
"pretty:check": "prettier --check \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
|
|
54
|
-
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
55
|
-
"audit": "npm audit --audit-level=high"
|
|
56
|
-
},
|
|
57
|
-
"files": [
|
|
58
|
-
"/**/*.js",
|
|
59
|
-
"/**/*.ts",
|
|
60
|
-
"/examples/**/*"
|
|
61
|
-
],
|
|
62
|
-
"main": "./cjs/index.js",
|
|
63
|
-
"module": "./esm/index.js",
|
|
64
|
-
"types": "types/index.d.ts",
|
|
65
|
-
"exports": {
|
|
66
|
-
".": {
|
|
67
|
-
"import": "./esm/index.js",
|
|
68
|
-
"require": "./cjs/index.js",
|
|
69
|
-
"types": "./types/index.d.ts"
|
|
2
|
+
"name": "camstreamerlib",
|
|
3
|
+
"version": "4.0.36",
|
|
4
|
+
"description": "Helper library for CamStreamer ACAP applications.",
|
|
5
|
+
"prettier": "@camstreamer/prettier-config",
|
|
6
|
+
"engine": {
|
|
7
|
+
"node": ">=18.0.0"
|
|
70
8
|
},
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"adm-zip": "^0.6.0",
|
|
11
|
+
"eventemitter2": "^5.0.1",
|
|
12
|
+
"fast-xml-parser": "^5.3.6",
|
|
13
|
+
"type-fest": "^4.41.0",
|
|
14
|
+
"undici": "^6.28.1",
|
|
15
|
+
"ws": "^8.18.0",
|
|
16
|
+
"zod": "^3.25.76"
|
|
75
17
|
},
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@camstreamer/eslint-config": "^1.0.10",
|
|
20
|
+
"@camstreamer/prettier-config": "^2.0.4",
|
|
21
|
+
"@eslint/js": "^10.0.1",
|
|
22
|
+
"@types/adm-zip": "^0.5.5",
|
|
23
|
+
"@types/jest": "^30.0.0",
|
|
24
|
+
"@types/node": "^18.19.127",
|
|
25
|
+
"@types/ws": "^8.5.10",
|
|
26
|
+
"esbuild": "^0.28.2",
|
|
27
|
+
"eslint": "^10.12.0",
|
|
28
|
+
"eslint-plugin-unused-imports": "^4.4.1",
|
|
29
|
+
"globals": "^17.13.0",
|
|
30
|
+
"jest": "^30.5.2",
|
|
31
|
+
"npm-run-all": "^4.1.5",
|
|
32
|
+
"prettier": "^2.7.1",
|
|
33
|
+
"ts-jest": "^29.4.14",
|
|
34
|
+
"ts-node": "^10.7.0",
|
|
35
|
+
"typescript": "5.3.3",
|
|
36
|
+
"typescript-eslint": "^8.71.2"
|
|
80
37
|
},
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"types": "./types/index.d.ts"
|
|
38
|
+
"overrides": {
|
|
39
|
+
"js-yaml": "^4.3.2",
|
|
40
|
+
"browserslist": "^4.28.7"
|
|
85
41
|
},
|
|
86
|
-
"
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
42
|
+
"scripts": {
|
|
43
|
+
"clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
44
|
+
"build": "npm-run-all clean build:cjs build:esm copyPackage",
|
|
45
|
+
"build:cjs": "tsc --project tsconfig.cjs.json",
|
|
46
|
+
"build:esm": "tsc --project tsconfig.esm.json",
|
|
47
|
+
"build:browser": "esbuild src/browser.index.ts --bundle --format=esm --platform=browser --target=es2022 --outfile=examples/camstreamerlib.js",
|
|
48
|
+
"copyPackage": "cp -f LICENSE dist/ && cp -f README.md dist/ && cp -f package.json dist/ && cp -r -f examples dist/",
|
|
49
|
+
"publishPackage": "./publish.sh",
|
|
50
|
+
"lint": "eslint \"src/**/*.ts\"",
|
|
51
|
+
"lint:fix": "eslint \"src/**/*.ts\" --fix",
|
|
52
|
+
"pretty": "prettier --write \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
|
|
53
|
+
"pretty:check": "prettier --check \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
|
|
54
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
55
|
+
"audit": "npm audit --audit-level=high"
|
|
90
56
|
},
|
|
91
|
-
"
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
57
|
+
"files": [
|
|
58
|
+
"/**/*.js",
|
|
59
|
+
"/**/*.ts",
|
|
60
|
+
"/examples/**/*"
|
|
61
|
+
],
|
|
62
|
+
"main": "./cjs/index.js",
|
|
63
|
+
"module": "./esm/index.js",
|
|
64
|
+
"types": "types/index.d.ts",
|
|
65
|
+
"exports": {
|
|
66
|
+
".": {
|
|
67
|
+
"import": "./esm/index.js",
|
|
68
|
+
"require": "./cjs/index.js",
|
|
69
|
+
"types": "./types/index.d.ts"
|
|
70
|
+
},
|
|
71
|
+
"./web": {
|
|
72
|
+
"import": "./esm/web/index.js",
|
|
73
|
+
"require": "./cjs/web/index.js",
|
|
74
|
+
"types": "./types/web/index.d.ts"
|
|
75
|
+
},
|
|
76
|
+
"./node": {
|
|
77
|
+
"import": "./esm/node/index.js",
|
|
78
|
+
"require": "./cjs/node/index.js",
|
|
79
|
+
"types": "./types/node/index.d.ts"
|
|
80
|
+
},
|
|
81
|
+
"./cjs/index": {
|
|
82
|
+
"import": "./esm/index.js",
|
|
83
|
+
"require": "./cjs/index.js",
|
|
84
|
+
"types": "./types/index.d.ts"
|
|
85
|
+
},
|
|
86
|
+
"./cjs/node": {
|
|
87
|
+
"import": "./esm/node/index.js",
|
|
88
|
+
"require": "./cjs/node/index.js",
|
|
89
|
+
"types": "./types/node/index.js"
|
|
90
|
+
},
|
|
91
|
+
"./cjs/node/index": {
|
|
92
|
+
"import": "./esm/node/index.js",
|
|
93
|
+
"require": "./cjs/node/index.js",
|
|
94
|
+
"types": "./types/node/index.js"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"repository": {
|
|
98
|
+
"type": "git",
|
|
99
|
+
"url": "git+https://github.com/CamStreamer/CamStreamerLib.git"
|
|
100
|
+
},
|
|
101
|
+
"keywords": [
|
|
102
|
+
"CamStreamer",
|
|
103
|
+
"CamOverlay",
|
|
104
|
+
"CamScripter",
|
|
105
|
+
"Camera",
|
|
106
|
+
"Axis"
|
|
107
|
+
],
|
|
108
|
+
"author": "CamStreamer s.r.o",
|
|
109
|
+
"license": "ISC",
|
|
110
|
+
"bugs": {
|
|
111
|
+
"url": "https://github.com/CamStreamer/CamStreamerLib/issues"
|
|
112
|
+
},
|
|
113
|
+
"homepage": "https://github.com/CamStreamer/CamStreamerLib#readme"
|
|
114
114
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -54,15 +54,15 @@ declare const cswEventsDataSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
|
|
|
54
54
|
}, "strip", z.ZodTypeAny, {
|
|
55
55
|
type: "StreamSwitchVideoError";
|
|
56
56
|
playlist_name: string;
|
|
57
|
-
playlist_active_stream: number;
|
|
58
57
|
info: string;
|
|
58
|
+
playlist_active_stream: number;
|
|
59
59
|
stream_name?: string | undefined;
|
|
60
60
|
clip_name?: string | undefined;
|
|
61
61
|
}, {
|
|
62
62
|
type: "StreamSwitchVideoError";
|
|
63
63
|
playlist_name: string;
|
|
64
|
-
playlist_active_stream: number;
|
|
65
64
|
info: string;
|
|
65
|
+
playlist_active_stream: number;
|
|
66
66
|
stream_name?: string | undefined;
|
|
67
67
|
clip_name?: string | undefined;
|
|
68
68
|
}>, z.ZodObject<{
|
|
@@ -207,15 +207,15 @@ export declare const cswEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
207
207
|
}, "strip", z.ZodTypeAny, {
|
|
208
208
|
type: "StreamSwitchVideoError";
|
|
209
209
|
playlist_name: string;
|
|
210
|
-
playlist_active_stream: number;
|
|
211
210
|
info: string;
|
|
211
|
+
playlist_active_stream: number;
|
|
212
212
|
stream_name?: string | undefined;
|
|
213
213
|
clip_name?: string | undefined;
|
|
214
214
|
}, {
|
|
215
215
|
type: "StreamSwitchVideoError";
|
|
216
216
|
playlist_name: string;
|
|
217
|
-
playlist_active_stream: number;
|
|
218
217
|
info: string;
|
|
218
|
+
playlist_active_stream: number;
|
|
219
219
|
stream_name?: string | undefined;
|
|
220
220
|
clip_name?: string | undefined;
|
|
221
221
|
}>, z.ZodObject<{
|
|
@@ -323,8 +323,8 @@ export declare const cswEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
323
323
|
} | {
|
|
324
324
|
type: "StreamSwitchVideoError";
|
|
325
325
|
playlist_name: string;
|
|
326
|
-
playlist_active_stream: number;
|
|
327
326
|
info: string;
|
|
327
|
+
playlist_active_stream: number;
|
|
328
328
|
stream_name?: string | undefined;
|
|
329
329
|
clip_name?: string | undefined;
|
|
330
330
|
} | {
|
|
@@ -376,8 +376,8 @@ export declare const cswEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
376
376
|
} | {
|
|
377
377
|
type: "StreamSwitchVideoError";
|
|
378
378
|
playlist_name: string;
|
|
379
|
-
playlist_active_stream: number;
|
|
380
379
|
info: string;
|
|
380
|
+
playlist_active_stream: number;
|
|
381
381
|
stream_name?: string | undefined;
|
|
382
382
|
clip_name?: string | undefined;
|
|
383
383
|
} | {
|
|
@@ -464,15 +464,15 @@ export declare const cswEventsSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
464
464
|
}, "strip", z.ZodTypeAny, {
|
|
465
465
|
type: "StreamSwitchVideoError";
|
|
466
466
|
playlist_name: string;
|
|
467
|
-
playlist_active_stream: number;
|
|
468
467
|
info: string;
|
|
468
|
+
playlist_active_stream: number;
|
|
469
469
|
stream_name?: string | undefined;
|
|
470
470
|
clip_name?: string | undefined;
|
|
471
471
|
}, {
|
|
472
472
|
type: "StreamSwitchVideoError";
|
|
473
473
|
playlist_name: string;
|
|
474
|
-
playlist_active_stream: number;
|
|
475
474
|
info: string;
|
|
475
|
+
playlist_active_stream: number;
|
|
476
476
|
stream_name?: string | undefined;
|
|
477
477
|
clip_name?: string | undefined;
|
|
478
478
|
}>, z.ZodObject<{
|