camstreamerlib 4.0.34 → 4.0.35-2475d16

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.
@@ -14,6 +14,12 @@ export declare class CamOverlayAPI<Client extends IClient<TResponse, any>> exten
14
14
  }[]>;
15
15
  wsAuthorization(options?: THttpRequestOptions): Promise<string>;
16
16
  getMjpegStreamImage(mjpegUrl: string, options?: THttpRequestOptions): Promise<ReturnType<Awaited<ReturnType<Client["get"]>>["blob"]>>;
17
+ isViewerPassValid(pass: string, options?: THttpRequestOptions): Promise<boolean>;
18
+ getLiveViewAlias(rtspUrl: string, options?: THttpRequestOptions): Promise<{
19
+ alias: string;
20
+ ws: string;
21
+ ws_initial_message: string;
22
+ }>;
17
23
  listFiles<T extends TFileType>(fileType: T, options?: THttpRequestOptions): Promise<TFileList<T>>;
18
24
  uploadFile<T extends TFileType>(fileType: T, formData: Parameters<Client['post']>[0]['data'], storage: TFileStorageType<T>, options?: THttpRequestOptions): Promise<void>;
19
25
  removeFile<T extends TFileType>(fileType: T, fileParams: TFile<T>, options?: THttpRequestOptions): Promise<void>;
@@ -29,6 +29,22 @@ class CamOverlayAPI extends BasicAPI_1.BasicAPI {
29
29
  async getMjpegStreamImage(mjpegUrl, options) {
30
30
  return await this._getBlob(`${BASE_PATH}/fetch_mjpeg_image.cgi`, { mjpeg_url: decodeURIComponent(mjpegUrl) }, options);
31
31
  }
32
+ async isViewerPassValid(pass, options) {
33
+ const res = await this._getJson(`${BASE_PATH}/check_pass.cgi`, { pass }, options);
34
+ if (res.status !== 200) {
35
+ throw new Error(res.message);
36
+ }
37
+ return res.data === '1';
38
+ }
39
+ async getLiveViewAlias(rtspUrl, options) {
40
+ const agent = this.getClient(options?.proxyParams);
41
+ const res = await agent.get({
42
+ path: `${BASE_PATH}/getLiveViewAlias.cgi`,
43
+ parameters: { rtsp_url: rtspUrl },
44
+ timeout: options?.timeout,
45
+ });
46
+ return common_1.wsAliasResponseSchema.parse(await res.json());
47
+ }
32
48
  async listFiles(fileType, options) {
33
49
  const res = await this._getJson(`${BASE_PATH}/upload_${fileType}.cgi`, { action: 'list' }, options);
34
50
  return (0, CamOverlayAPI_1.getFileListSchema)(fileType).parse(res.list);
@@ -28,9 +28,9 @@ export declare class CamSwitcherAPI<Client extends IClient<TResponse, any>> exte
28
28
  }[]>;
29
29
  wsAuthorization(options?: THttpRequestOptions): Promise<string>;
30
30
  getOutputInfo(options?: THttpRequestOptions): Promise<{
31
- rtspUrl: string;
32
31
  ws: string;
33
32
  wsInitialMessage: string;
33
+ rtspUrl: string;
34
34
  }>;
35
35
  getAudioPushInfo(options?: THttpRequestOptions): Promise<{
36
36
  ws: string;
@@ -12,9 +12,9 @@ export declare class PlaneTrackerAPI<Client extends IClient<TResponse, any>> ext
12
12
  checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
13
13
  serverRunCheck(options?: THttpRequestOptions): Promise<boolean>;
14
14
  getLiveViewAlias(rtspUrl: string, options?: THttpRequestOptions): Promise<{
15
+ alias: string;
15
16
  ws: string;
16
17
  ws_initial_message: string;
17
- alias: string;
18
18
  }>;
19
19
  resetPtzCalibration(options?: THttpRequestOptions): Promise<void>;
20
20
  resetFocusCalibration(options?: THttpRequestOptions): Promise<void>;
@@ -4,6 +4,7 @@ exports.PlaneTrackerAPI = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const PlaneTrackerAPI_1 = require("./types/PlaneTrackerAPI");
6
6
  const errors_1 = require("./errors/errors");
7
+ const common_1 = require("./types/common");
7
8
  const BasicAPI_1 = require("./internal/BasicAPI");
8
9
  const PlaneTrackerEvents_1 = require("./types/ws/PlaneTrackerEvents");
9
10
  const BASE_PATH = '/local/planetracker';
@@ -37,7 +38,7 @@ class PlaneTrackerAPI extends BasicAPI_1.BasicAPI {
37
38
  parameters: { rtsp_url: rtspUrl },
38
39
  timeout: options?.timeout,
39
40
  });
40
- return PlaneTrackerAPI_1.wsAliasResponseSchema.parse(await res.json());
41
+ return common_1.wsAliasResponseSchema.parse(await res.json());
41
42
  }
42
43
  async resetPtzCalibration(options) {
43
44
  const agent = this.getClient(options?.proxyParams);
package/cjs/VapixAPI.js CHANGED
@@ -93,7 +93,9 @@ class VapixAPI extends BasicAPI_1.BasicAPI {
93
93
  };
94
94
  await this._postJsonEncoded('/axis-cgi/opticscontrol.cgi', data, undefined, options);
95
95
  }
96
- catch {
96
+ catch (error) {
97
+ console.warn('Failed to perform autofocus: ', error instanceof Error ? error.message : String(error));
98
+ console.warn('Falling back to deprecated optics setup API');
97
99
  await this._postUrlEncoded('/axis-cgi/opticssetup.cgi', {
98
100
  autofocus: 'perform',
99
101
  source: '1',
@@ -144,7 +146,7 @@ class VapixAPI extends BasicAPI_1.BasicAPI {
144
146
  return data.data.activeTimeZone;
145
147
  }
146
148
  catch (error) {
147
- console.warn('Failed to fetch time zone data from time API v2:', error instanceof Error ? error.message : JSON.stringify(error));
149
+ console.warn('Failed to fetch time zone data from time API v2:', error instanceof Error ? error.message : String(error));
148
150
  console.warn('Falling back to deprecated time API v1');
149
151
  }
150
152
  try {
@@ -563,17 +565,21 @@ class VapixAPI extends BasicAPI_1.BasicAPI {
563
565
  allowBooleanAttributes: true,
564
566
  });
565
567
  const result = parser.parse(xml);
566
- let apps = result.reply.application ?? [];
567
- if (!Array.isArray(apps)) {
568
- apps = [apps];
569
- }
570
- const appList = apps.map((app) => {
571
- return {
572
- ...app,
573
- appId: VapixAPI_1.ALL_APP_IDS.find((id) => id.toLowerCase() === app.Name.toLowerCase()) ?? null,
574
- };
575
- });
576
- return VapixAPI_1.applicationListSchema.parse(appList);
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;
577
583
  }
578
584
  async startApplication(applicationId, options) {
579
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
+ });
@@ -26,7 +26,7 @@ class ServiceNotFoundError extends Error {
26
26
  exports.ServiceNotFoundError = ServiceNotFoundError;
27
27
  class ParsingBlobError extends Error {
28
28
  constructor(err) {
29
- super('Error parsing response as Blob: ' + err);
29
+ super('Error parsing response as Blob: ' + String(err));
30
30
  this.name = 'ParsingBlobError';
31
31
  }
32
32
  }
@@ -99,7 +99,7 @@ class NoDeviceInfoError extends Error {
99
99
  exports.NoDeviceInfoError = NoDeviceInfoError;
100
100
  class FetchDeviceInfoError extends Error {
101
101
  constructor(err) {
102
- super('Error fetching remote camera data: ' + err);
102
+ super('Error fetching remote camera data: ' + String(err));
103
103
  this.name = 'NoDeviceInfoFromCameraError';
104
104
  }
105
105
  }
@@ -127,7 +127,7 @@ class PtzNotSupportedError extends Error {
127
127
  exports.PtzNotSupportedError = PtzNotSupportedError;
128
128
  class StorageDataFetchError extends Error {
129
129
  constructor(err) {
130
- super('Error fetching storage data: ' + err);
130
+ super('Error fetching storage data: ' + String(err));
131
131
  this.name = 'StorageDataFetchError';
132
132
  }
133
133
  }
@@ -155,7 +155,7 @@ class TimezoneNotSetupError extends Error {
155
155
  exports.TimezoneNotSetupError = TimezoneNotSetupError;
156
156
  class TimezoneFetchError extends Error {
157
157
  constructor(err) {
158
- super('Error fetching time zone information: ' + err);
158
+ super('Error fetching time zone information: ' + String(err));
159
159
  this.name = 'TimezoneFetchError';
160
160
  }
161
161
  }
@@ -25,21 +25,21 @@ export declare const outputInfoSchema: z.ZodEffects<z.ZodObject<{
25
25
  ws: z.ZodString;
26
26
  ws_initial_message: z.ZodString;
27
27
  }, "strip", z.ZodTypeAny, {
28
- rtsp_url: string;
29
28
  ws: string;
30
29
  ws_initial_message: string;
31
- }, {
32
30
  rtsp_url: string;
31
+ }, {
33
32
  ws: string;
34
33
  ws_initial_message: string;
34
+ rtsp_url: string;
35
35
  }>, {
36
- rtspUrl: string;
37
36
  ws: string;
38
37
  wsInitialMessage: string;
38
+ rtspUrl: string;
39
39
  }, {
40
- rtsp_url: string;
41
40
  ws: string;
42
41
  ws_initial_message: string;
42
+ rtsp_url: string;
43
43
  }>;
44
44
  export type TOutputInfo = z.infer<typeof outputInfoSchema>;
45
45
  export declare const audioPushInfoSchema: z.ZodEffects<z.ZodObject<{
@@ -1,19 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  export type TImportDataType = 'MAP_DATA' | 'SERVER_DATA' | 'ALL';
3
3
  export type TExportDataType = 'NIGHT_SKY_CALIBRATION_DATA' | 'ALL';
4
- export declare const wsAliasResponseSchema: z.ZodObject<{
5
- alias: z.ZodString;
6
- ws: z.ZodString;
7
- ws_initial_message: z.ZodString;
8
- }, "strip", z.ZodTypeAny, {
9
- ws: string;
10
- ws_initial_message: string;
11
- alias: string;
12
- }, {
13
- ws: string;
14
- ws_initial_message: string;
15
- alias: string;
16
- }>;
17
4
  export declare const connectionSchema: z.ZodObject<{
18
5
  protocol: z.ZodUnion<[z.ZodLiteral<"http">, z.ZodLiteral<"https">, z.ZodLiteral<"https_insecure">]>;
19
6
  ip: z.ZodUnion<[z.ZodString, z.ZodLiteral<"">]>;
@@ -1,12 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.REMOTE_ID_CATEGORY_IDS = exports.ADSB_CATEGORY_IDS = exports.domainListSchema = exports.zonesSchema = exports.zonePerimeterSchema = exports.domainIdSchema = exports.mapInfoSchema = exports.mapTypeSchema = exports.friendlyListSchema = exports.priorityListSchema = exports.blackListSchema = exports.whiteListSchema = exports.priorityListEntrySchema = exports.listEntrySchema = exports.listEntryIdTypeSchema = exports.listEntryDomainSchema = exports.flightInfoSchema = exports.trackingModeSchema = exports.getIcaoSchema = exports.serverSettingsSchema = exports.cameraSettingsSchema = exports.widgetSchema = exports.milestoneCameraListSchema = exports.connectionSchema = exports.wsAliasResponseSchema = void 0;
3
+ exports.REMOTE_ID_CATEGORY_IDS = exports.ADSB_CATEGORY_IDS = exports.domainListSchema = exports.zonesSchema = exports.zonePerimeterSchema = exports.domainIdSchema = exports.mapInfoSchema = exports.mapTypeSchema = exports.friendlyListSchema = exports.priorityListSchema = exports.blackListSchema = exports.whiteListSchema = exports.priorityListEntrySchema = exports.listEntrySchema = exports.listEntryIdTypeSchema = exports.listEntryDomainSchema = exports.flightInfoSchema = exports.trackingModeSchema = exports.getIcaoSchema = exports.serverSettingsSchema = exports.cameraSettingsSchema = exports.widgetSchema = exports.milestoneCameraListSchema = exports.connectionSchema = void 0;
4
4
  const zod_1 = require("zod");
5
- exports.wsAliasResponseSchema = zod_1.z.object({
6
- alias: zod_1.z.string(),
7
- ws: zod_1.z.string(),
8
- ws_initial_message: zod_1.z.string(),
9
- });
10
5
  exports.connectionSchema = zod_1.z.object({
11
6
  protocol: zod_1.z.union([zod_1.z.literal('http'), zod_1.z.literal('https'), zod_1.z.literal('https_insecure')]),
12
7
  ip: zod_1.z.union([zod_1.z.string().ip(), zod_1.z.literal('')]),
@@ -26,6 +26,19 @@ export declare const keyboardShortcutSchema: z.ZodNullable<z.ZodString>;
26
26
  export declare const keyboardShortcutsSchema: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>;
27
27
  export type TKeyboardShortcut = z.infer<typeof keyboardShortcutSchema>;
28
28
  export type TKeyboardShortcuts = z.infer<typeof keyboardShortcutsSchema>;
29
+ export declare const wsAliasResponseSchema: z.ZodObject<{
30
+ alias: z.ZodString;
31
+ ws: z.ZodString;
32
+ ws_initial_message: z.ZodString;
33
+ }, "strip", z.ZodTypeAny, {
34
+ alias: string;
35
+ ws: string;
36
+ ws_initial_message: string;
37
+ }, {
38
+ alias: string;
39
+ ws: string;
40
+ ws_initial_message: string;
41
+ }>;
29
42
  export type TProxyTarget = {
30
43
  ip: string;
31
44
  mdnsName: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fileSchema = exports.bitrateVapixParamsSchema = exports.bitrateModeSchema = exports.keyboardShortcutsSchema = exports.keyboardShortcutSchema = exports.networkCameraListSchema = exports.storageTypeSchema = exports.sdCardStorageTypeSchema = exports.flashStorageTypeSchema = exports.h264ProfileSchema = exports.audioChannelCountSchema = exports.audioChannelSchema = exports.booleanSchema = void 0;
3
+ exports.fileSchema = exports.bitrateVapixParamsSchema = exports.bitrateModeSchema = exports.wsAliasResponseSchema = exports.keyboardShortcutsSchema = exports.keyboardShortcutSchema = exports.networkCameraListSchema = exports.storageTypeSchema = exports.sdCardStorageTypeSchema = exports.flashStorageTypeSchema = exports.h264ProfileSchema = exports.audioChannelCountSchema = exports.audioChannelSchema = exports.booleanSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.booleanSchema = zod_1.z.union([zod_1.z.literal(0), zod_1.z.literal(1)]);
6
6
  exports.audioChannelSchema = zod_1.z.union([zod_1.z.literal('mono'), zod_1.z.literal('stereo')]);
@@ -15,6 +15,11 @@ exports.networkCameraListSchema = zod_1.z.array(zod_1.z.object({
15
15
  }));
16
16
  exports.keyboardShortcutSchema = zod_1.z.string().nullable();
17
17
  exports.keyboardShortcutsSchema = zod_1.z.record(exports.keyboardShortcutSchema);
18
+ exports.wsAliasResponseSchema = zod_1.z.object({
19
+ alias: zod_1.z.string(),
20
+ ws: zod_1.z.string(),
21
+ ws_initial_message: zod_1.z.string(),
22
+ });
18
23
  exports.bitrateModeSchema = zod_1.z.union([zod_1.z.literal('VBR'), zod_1.z.literal('MBR'), zod_1.z.literal('ABR')]);
19
24
  exports.bitrateVapixParamsSchema = zod_1.z.object({
20
25
  bitrateMode: exports.bitrateModeSchema,
@@ -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<{
@@ -1,5 +1,5 @@
1
1
  import { ErrorWithResponse, ServiceNotFoundError, StorageDataFetchError } from './errors/errors';
2
- import { networkCameraListSchema } from './types/common';
2
+ import { networkCameraListSchema, wsAliasResponseSchema } from './types/common';
3
3
  import { z } from 'zod';
4
4
  import { ImageType, serviceListSchema, servicesSchema, wsResponseSchema, getStorageDataListSchema, getFileListSchema, } from './types/CamOverlayAPI';
5
5
  import { BasicAPI } from './internal/BasicAPI';
@@ -26,6 +26,22 @@ export class CamOverlayAPI extends BasicAPI {
26
26
  async getMjpegStreamImage(mjpegUrl, options) {
27
27
  return await this._getBlob(`${BASE_PATH}/fetch_mjpeg_image.cgi`, { mjpeg_url: decodeURIComponent(mjpegUrl) }, options);
28
28
  }
29
+ async isViewerPassValid(pass, options) {
30
+ const res = await this._getJson(`${BASE_PATH}/check_pass.cgi`, { pass }, options);
31
+ if (res.status !== 200) {
32
+ throw new Error(res.message);
33
+ }
34
+ return res.data === '1';
35
+ }
36
+ async getLiveViewAlias(rtspUrl, options) {
37
+ const agent = this.getClient(options?.proxyParams);
38
+ const res = await agent.get({
39
+ path: `${BASE_PATH}/getLiveViewAlias.cgi`,
40
+ parameters: { rtsp_url: rtspUrl },
41
+ timeout: options?.timeout,
42
+ });
43
+ return wsAliasResponseSchema.parse(await res.json());
44
+ }
29
45
  async listFiles(fileType, options) {
30
46
  const res = await this._getJson(`${BASE_PATH}/upload_${fileType}.cgi`, { action: 'list' }, options);
31
47
  return getFileListSchema(fileType).parse(res.list);
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
- import { blackListSchema, cameraSettingsSchema, domainListSchema, flightInfoSchema, getIcaoSchema, mapInfoSchema, milestoneCameraListSchema, priorityListSchema, serverSettingsSchema, trackingModeSchema, whiteListSchema, wsAliasResponseSchema, zonesSchema, } from './types/PlaneTrackerAPI';
2
+ import { blackListSchema, cameraSettingsSchema, domainListSchema, flightInfoSchema, getIcaoSchema, mapInfoSchema, milestoneCameraListSchema, priorityListSchema, serverSettingsSchema, trackingModeSchema, whiteListSchema, zonesSchema, } from './types/PlaneTrackerAPI';
3
3
  import { CannotSetCoordsInAutoModeError, ImportSettingsError, InvalidAltitudeError, InvalidLatLngError, ResetCalibrationError, ServerError, BadRequestError, } from './errors/errors';
4
+ import { wsAliasResponseSchema } from './types/common';
4
5
  import { BasicAPI } from './internal/BasicAPI';
5
6
  import { apiUserInputSchema } from './types/ws/PlaneTrackerEvents';
6
7
  const BASE_PATH = '/local/planetracker';
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, applicationListSchema, sdCardInfoSchema, ALL_APP_IDS, allDateTimeInfoSchema, } from './types/VapixAPI';
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';
@@ -90,7 +90,9 @@ export class VapixAPI extends BasicAPI {
90
90
  };
91
91
  await this._postJsonEncoded('/axis-cgi/opticscontrol.cgi', data, undefined, options);
92
92
  }
93
- catch {
93
+ catch (error) {
94
+ console.warn('Failed to perform autofocus: ', error instanceof Error ? error.message : String(error));
95
+ console.warn('Falling back to deprecated optics setup API');
94
96
  await this._postUrlEncoded('/axis-cgi/opticssetup.cgi', {
95
97
  autofocus: 'perform',
96
98
  source: '1',
@@ -141,7 +143,7 @@ export class VapixAPI extends BasicAPI {
141
143
  return data.data.activeTimeZone;
142
144
  }
143
145
  catch (error) {
144
- console.warn('Failed to fetch time zone data from time API v2:', error instanceof Error ? error.message : JSON.stringify(error));
146
+ console.warn('Failed to fetch time zone data from time API v2:', error instanceof Error ? error.message : String(error));
145
147
  console.warn('Falling back to deprecated time API v1');
146
148
  }
147
149
  try {
@@ -560,17 +562,21 @@ export class VapixAPI extends BasicAPI {
560
562
  allowBooleanAttributes: true,
561
563
  });
562
564
  const result = parser.parse(xml);
563
- let apps = result.reply.application ?? [];
564
- if (!Array.isArray(apps)) {
565
- apps = [apps];
566
- }
567
- const appList = apps.map((app) => {
568
- return {
569
- ...app,
570
- appId: ALL_APP_IDS.find((id) => id.toLowerCase() === app.Name.toLowerCase()) ?? null,
571
- };
572
- });
573
- return applicationListSchema.parse(appList);
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;
574
580
  }
575
581
  async startApplication(applicationId, options) {
576
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
+ });
@@ -20,7 +20,7 @@ export class ServiceNotFoundError extends Error {
20
20
  }
21
21
  export class ParsingBlobError extends Error {
22
22
  constructor(err) {
23
- super('Error parsing response as Blob: ' + err);
23
+ super('Error parsing response as Blob: ' + String(err));
24
24
  this.name = 'ParsingBlobError';
25
25
  }
26
26
  }
@@ -84,7 +84,7 @@ export class NoDeviceInfoError extends Error {
84
84
  }
85
85
  export class FetchDeviceInfoError extends Error {
86
86
  constructor(err) {
87
- super('Error fetching remote camera data: ' + err);
87
+ super('Error fetching remote camera data: ' + String(err));
88
88
  this.name = 'NoDeviceInfoFromCameraError';
89
89
  }
90
90
  }
@@ -108,7 +108,7 @@ export class PtzNotSupportedError extends Error {
108
108
  }
109
109
  export class StorageDataFetchError extends Error {
110
110
  constructor(err) {
111
- super('Error fetching storage data: ' + err);
111
+ super('Error fetching storage data: ' + String(err));
112
112
  this.name = 'StorageDataFetchError';
113
113
  }
114
114
  }
@@ -132,7 +132,7 @@ export class TimezoneNotSetupError extends Error {
132
132
  }
133
133
  export class TimezoneFetchError extends Error {
134
134
  constructor(err) {
135
- super('Error fetching time zone information: ' + err);
135
+ super('Error fetching time zone information: ' + String(err));
136
136
  this.name = 'TimezoneFetchError';
137
137
  }
138
138
  }
@@ -1,9 +1,4 @@
1
1
  import { z } from 'zod';
2
- export const wsAliasResponseSchema = z.object({
3
- alias: z.string(),
4
- ws: z.string(),
5
- ws_initial_message: z.string(),
6
- });
7
2
  export const connectionSchema = z.object({
8
3
  protocol: z.union([z.literal('http'), z.literal('https'), z.literal('https_insecure')]),
9
4
  ip: z.union([z.string().ip(), z.literal('')]),
@@ -12,6 +12,11 @@ export const networkCameraListSchema = z.array(z.object({
12
12
  }));
13
13
  export const keyboardShortcutSchema = z.string().nullable();
14
14
  export const keyboardShortcutsSchema = z.record(keyboardShortcutSchema);
15
+ export const wsAliasResponseSchema = z.object({
16
+ alias: z.string(),
17
+ ws: z.string(),
18
+ ws_initial_message: z.string(),
19
+ });
15
20
  export const bitrateModeSchema = z.union([z.literal('VBR'), z.literal('MBR'), z.literal('ABR')]);
16
21
  export const bitrateVapixParamsSchema = z.object({
17
22
  bitrateMode: bitrateModeSchema,
package/package.json CHANGED
@@ -1,117 +1,114 @@
1
1
  {
2
- "name": "camstreamerlib",
3
- "version": "4.0.34",
4
- "description": "Helper library for CamStreamer ACAP applications.",
5
- "prettier": "@camstreamer/prettier-config",
6
- "engine": {
7
- "node": ">=18.0.0"
2
+ "name": "camstreamerlib",
3
+ "version": "4.0.35-2475d16",
4
+ "description": "Helper library for CamStreamer ACAP applications.",
5
+ "prettier": "@camstreamer/prettier-config",
6
+ "engine": {
7
+ "node": ">=18.0.0"
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"
8
70
  },
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"
71
+ "./web": {
72
+ "import": "./esm/web/index.js",
73
+ "require": "./cjs/web/index.js",
74
+ "types": "./types/web/index.d.ts"
17
75
  },
18
- "devDependencies": {
19
- "@camstreamer/eslint-config": "^1.0.2",
20
- "@camstreamer/prettier-config": "^2.0.4",
21
- "@types/adm-zip": "^0.5.5",
22
- "@types/jest": "^30.0.0",
23
- "@types/node": "^18.19.127",
24
- "@types/ws": "^8.5.10",
25
- "@typescript-eslint/eslint-plugin": "^8.71.1",
26
- "@typescript-eslint/parser": "^8.71.1",
27
- "esbuild": "^0.28.2",
28
- "eslint": "^8.51.0",
29
- "eslint-plugin-deprecation": "^2.0.0",
30
- "eslint-plugin-unused-imports": "^4.4.1",
31
- "jest": "^30.5.2",
32
- "npm-run-all": "^4.1.5",
33
- "prettier": "^2.7.1",
34
- "ts-jest": "^29.4.14",
35
- "ts-node": "^10.7.0",
36
- "typescript": "5.3.3"
76
+ "./node": {
77
+ "import": "./esm/node/index.js",
78
+ "require": "./cjs/node/index.js",
79
+ "types": "./types/node/index.d.ts"
37
80
  },
38
- "overrides": {
39
- "js-yaml": "^4.3.2",
40
- "browserslist": "^4.28.7",
41
- "eslint-plugin-deprecation": {
42
- "@typescript-eslint/utils": "^8.71.1"
43
- }
81
+ "./cjs/index": {
82
+ "import": "./esm/index.js",
83
+ "require": "./cjs/index.js",
84
+ "types": "./types/index.d.ts"
44
85
  },
45
- "scripts": {
46
- "clean": "rimraf dist/*",
47
- "build": "npm-run-all clean build:cjs build:esm copyPackage",
48
- "build:cjs": "tsc --project tsconfig.cjs.json",
49
- "build:esm": "tsc --project tsconfig.esm.json",
50
- "build:browser": "esbuild src/browser.index.ts --bundle --format=esm --platform=browser --target=es2022 --outfile=examples/camstreamerlib.js",
51
- "copyPackage": "cp -f LICENSE dist/ && cp -f README.md dist/ && cp -f package.json dist/ && cp -r -f examples dist/",
52
- "publishPackage": "./publish.sh",
53
- "lint": "eslint \"src/**/*.ts\"",
54
- "lint:fix": "eslint \"src/**/*.ts\" --fix",
55
- "pretty": "prettier --write \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
56
- "pretty:check": "prettier --check \"./{{src,doc}/**/*.{ts,tsx,md},README.md}\"",
57
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
58
- "audit": "npm audit --audit-level=high"
86
+ "./cjs/node": {
87
+ "import": "./esm/node/index.js",
88
+ "require": "./cjs/node/index.js",
89
+ "types": "./types/node/index.js"
59
90
  },
60
- "files": [
61
- "/**/*.js",
62
- "/**/*.ts",
63
- "/examples/**/*"
64
- ],
65
- "main": "./cjs/index.js",
66
- "module": "./esm/index.js",
67
- "types": "types/index.d.ts",
68
- "exports": {
69
- ".": {
70
- "import": "./esm/index.js",
71
- "require": "./cjs/index.js",
72
- "types": "./types/index.d.ts"
73
- },
74
- "./web": {
75
- "import": "./esm/web/index.js",
76
- "require": "./cjs/web/index.js",
77
- "types": "./types/web/index.d.ts"
78
- },
79
- "./node": {
80
- "import": "./esm/node/index.js",
81
- "require": "./cjs/node/index.js",
82
- "types": "./types/node/index.d.ts"
83
- },
84
- "./cjs/index": {
85
- "import": "./esm/index.js",
86
- "require": "./cjs/index.js",
87
- "types": "./types/index.d.ts"
88
- },
89
- "./cjs/node": {
90
- "import": "./esm/node/index.js",
91
- "require": "./cjs/node/index.js",
92
- "types": "./types/node/index.js"
93
- },
94
- "./cjs/node/index": {
95
- "import": "./esm/node/index.js",
96
- "require": "./cjs/node/index.js",
97
- "types": "./types/node/index.js"
98
- }
99
- },
100
- "repository": {
101
- "type": "git",
102
- "url": "git+https://github.com/CamStreamer/CamStreamerLib.git"
103
- },
104
- "keywords": [
105
- "CamStreamer",
106
- "CamOverlay",
107
- "CamScripter",
108
- "Camera",
109
- "Axis"
110
- ],
111
- "author": "CamStreamer s.r.o",
112
- "license": "ISC",
113
- "bugs": {
114
- "url": "https://github.com/CamStreamer/CamStreamerLib/issues"
115
- },
116
- "homepage": "https://github.com/CamStreamer/CamStreamerLib#readme"
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"
117
114
  }
@@ -14,6 +14,12 @@ export declare class CamOverlayAPI<Client extends IClient<TResponse, any>> exten
14
14
  }[]>;
15
15
  wsAuthorization(options?: THttpRequestOptions): Promise<string>;
16
16
  getMjpegStreamImage(mjpegUrl: string, options?: THttpRequestOptions): Promise<ReturnType<Awaited<ReturnType<Client["get"]>>["blob"]>>;
17
+ isViewerPassValid(pass: string, options?: THttpRequestOptions): Promise<boolean>;
18
+ getLiveViewAlias(rtspUrl: string, options?: THttpRequestOptions): Promise<{
19
+ alias: string;
20
+ ws: string;
21
+ ws_initial_message: string;
22
+ }>;
17
23
  listFiles<T extends TFileType>(fileType: T, options?: THttpRequestOptions): Promise<TFileList<T>>;
18
24
  uploadFile<T extends TFileType>(fileType: T, formData: Parameters<Client['post']>[0]['data'], storage: TFileStorageType<T>, options?: THttpRequestOptions): Promise<void>;
19
25
  removeFile<T extends TFileType>(fileType: T, fileParams: TFile<T>, options?: THttpRequestOptions): Promise<void>;
@@ -28,9 +28,9 @@ export declare class CamSwitcherAPI<Client extends IClient<TResponse, any>> exte
28
28
  }[]>;
29
29
  wsAuthorization(options?: THttpRequestOptions): Promise<string>;
30
30
  getOutputInfo(options?: THttpRequestOptions): Promise<{
31
- rtspUrl: string;
32
31
  ws: string;
33
32
  wsInitialMessage: string;
33
+ rtspUrl: string;
34
34
  }>;
35
35
  getAudioPushInfo(options?: THttpRequestOptions): Promise<{
36
36
  ws: string;
@@ -12,9 +12,9 @@ export declare class PlaneTrackerAPI<Client extends IClient<TResponse, any>> ext
12
12
  checkCameraTime(options?: THttpRequestOptions): Promise<boolean>;
13
13
  serverRunCheck(options?: THttpRequestOptions): Promise<boolean>;
14
14
  getLiveViewAlias(rtspUrl: string, options?: THttpRequestOptions): Promise<{
15
+ alias: string;
15
16
  ws: string;
16
17
  ws_initial_message: string;
17
- alias: string;
18
18
  }>;
19
19
  resetPtzCalibration(options?: THttpRequestOptions): Promise<void>;
20
20
  resetFocusCalibration(options?: THttpRequestOptions): Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -25,21 +25,21 @@ export declare const outputInfoSchema: z.ZodEffects<z.ZodObject<{
25
25
  ws: z.ZodString;
26
26
  ws_initial_message: z.ZodString;
27
27
  }, "strip", z.ZodTypeAny, {
28
- rtsp_url: string;
29
28
  ws: string;
30
29
  ws_initial_message: string;
31
- }, {
32
30
  rtsp_url: string;
31
+ }, {
33
32
  ws: string;
34
33
  ws_initial_message: string;
34
+ rtsp_url: string;
35
35
  }>, {
36
- rtspUrl: string;
37
36
  ws: string;
38
37
  wsInitialMessage: string;
38
+ rtspUrl: string;
39
39
  }, {
40
- rtsp_url: string;
41
40
  ws: string;
42
41
  ws_initial_message: string;
42
+ rtsp_url: string;
43
43
  }>;
44
44
  export type TOutputInfo = z.infer<typeof outputInfoSchema>;
45
45
  export declare const audioPushInfoSchema: z.ZodEffects<z.ZodObject<{
@@ -1,19 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  export type TImportDataType = 'MAP_DATA' | 'SERVER_DATA' | 'ALL';
3
3
  export type TExportDataType = 'NIGHT_SKY_CALIBRATION_DATA' | 'ALL';
4
- export declare const wsAliasResponseSchema: z.ZodObject<{
5
- alias: z.ZodString;
6
- ws: z.ZodString;
7
- ws_initial_message: z.ZodString;
8
- }, "strip", z.ZodTypeAny, {
9
- ws: string;
10
- ws_initial_message: string;
11
- alias: string;
12
- }, {
13
- ws: string;
14
- ws_initial_message: string;
15
- alias: string;
16
- }>;
17
4
  export declare const connectionSchema: z.ZodObject<{
18
5
  protocol: z.ZodUnion<[z.ZodLiteral<"http">, z.ZodLiteral<"https">, z.ZodLiteral<"https_insecure">]>;
19
6
  ip: z.ZodUnion<[z.ZodString, z.ZodLiteral<"">]>;
@@ -26,6 +26,19 @@ export declare const keyboardShortcutSchema: z.ZodNullable<z.ZodString>;
26
26
  export declare const keyboardShortcutsSchema: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>;
27
27
  export type TKeyboardShortcut = z.infer<typeof keyboardShortcutSchema>;
28
28
  export type TKeyboardShortcuts = z.infer<typeof keyboardShortcutsSchema>;
29
+ export declare const wsAliasResponseSchema: z.ZodObject<{
30
+ alias: z.ZodString;
31
+ ws: z.ZodString;
32
+ ws_initial_message: z.ZodString;
33
+ }, "strip", z.ZodTypeAny, {
34
+ alias: string;
35
+ ws: string;
36
+ ws_initial_message: string;
37
+ }, {
38
+ alias: string;
39
+ ws: string;
40
+ ws_initial_message: string;
41
+ }>;
29
42
  export type TProxyTarget = {
30
43
  ip: string;
31
44
  mdnsName: string;
@@ -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<{