camstreamerlib 4.0.0-beta.162 → 4.0.0-beta.164

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,13 +1,8 @@
1
1
  # CamStreamerLib - BETA
2
2
 
3
- **This is beta version of CamStreamerLib v4, dont use it on production. Is going to be changed significantly.**
3
+ Web and Node.js helper library for CamStreamer ACAP applications.
4
4
 
5
- **The documentation is in progress**
6
-
7
- Node.js helper library for CamStreamer ACAP applications.
8
-
9
- The library is primarily developed for the CamScripter ACAP application running directly in Axis cameras.
10
- Examples of CamScripter packages can be found at https://github.com/CamStreamer/CamScripterApp_examples
5
+ The library is primarily developed for ACAP applications running directly in Axis cameras.
11
6
 
12
7
  ## Installation
13
8
 
@@ -26,7 +21,7 @@ npm install camstreamerlib
26
21
  | [CamSwitcherAPI](doc/CamSwitcherAPI.md) | Module to access CamSwitcher API. |
27
22
  | [PlaneTrackerAPI](doc/PlaneTrackerAPI.md) | Module to access PlaneTracker API. |
28
23
  | [CamStreamerEvents](doc/ws/CamStreamerEvents.md) | Module which allows receiving events from CamStreamer ACAP application. |
29
- | [OverlayEvents](doc/ws/OverlayEvents.md) | Module which allows receiving events from Overlay ACAP application. |
24
+ | [CamOverlayEvents](doc/ws/CamOverlayEvents.md) | Module which allows receiving events from CamOverlay ACAP application. |
30
25
  | [CamSwitcherEvents](doc/ws/CamSwitcherEvents.md) | Module which allows receiving events from CamSwitcher ACAP application. |
31
26
  | [PlaneTrackerEvents](doc/ws/PlaneTrackerEvents.md) | Module which allows receiving events from PlaneTracker ACAP application. |
32
27
 
@@ -56,11 +51,11 @@ npm install camstreamerlib
56
51
 
57
52
  ### ACAP API Class Constructors Updated
58
53
 
59
- All ACAP API classes now **require a client instance to be passed into their constructors** instead of options object.
54
+ All ACAP API classes now **require a client instance to be passed into their constructors** instead of `options` object.
60
55
 
61
56
  - This change improves flexibility by allowing you to use either the Node or Web client, depending on your environment.
62
57
 
63
- Example (before → now):
58
+ **Example (before → now)**:
64
59
 
65
60
  ```typescript
66
61
  // Before
@@ -78,6 +73,12 @@ const coApi = new CamOverlayAPI({
78
73
  import { DefaultClient } from 'camstreamerlib/web';
79
74
  import { CamOverlayAPI } from 'camstreamerlib';
80
75
 
76
+ // Use DefaultClient in constructor
77
+ const coApi = new CamOverlayAPI(
78
+ new DefaultClient()
79
+ );
80
+
81
+ // Or adjust DefaultClient default values with your own
81
82
  const coApi = new CamOverlayAPI(
82
83
  new DefaultClient({
83
84
  tls: false,
@@ -109,17 +110,43 @@ import { Painter } from 'camstreamerlib/node';
109
110
  import { DefaultClient } from 'camstreamerlib/web';
110
111
  ```
111
112
 
112
- > Note: To ensure compatibility, set the module resolution in your projects tsconfig.json to `"moduleResolution": "bundler"`.
113
+ > :information_source: Note: To ensure compatibility, set the module resolution in your web projects tsconfig.json to `"moduleResolution": "bundler"`.
113
114
 
114
- ### Class and Method Refactored
115
+ ### Classes and Methods Refactored
115
116
 
116
117
  - **CameraVapix API** has been renamed to [**VapixAPI**](doc/VapixAPI.md).
117
118
  - **DefaultAgent** has been refactored into two separate classes - one for node, one for web as [**DefaultClient**](doc/Client.md)
118
119
  - Several method names and parameter names across the library have been updated for consistency and clarity.
120
+ - New API modules and endpoints have been introduced, providing extended functionality and better coverage of the underlying service.
119
121
 
120
- > Please refer to [the documentation](#documentation-for-acap-and-camera-api).
122
+ ### Stream List Migration
121
123
 
122
- - New API modules and endpoints have been introduced, providing extended functionality and better coverage of the underlying service.
124
+ - `CamStreamerAPI.getStreamList()` and `getStream()` now throw a **`MigrationError`** when old-format (v3) stream data is detected on the camera.
125
+ - `MigrationError` provides four arrays to help you handle the transition: `.valid`, `.old`, `.invalid`, and `.unknown`.
126
+
127
+ ```typescript
128
+ import { MigrationError } from 'camstreamerlib';
129
+
130
+ try {
131
+ const streams = await csApi.getStreamList();
132
+ } catch (e) {
133
+ if (e instanceof MigrationError) {
134
+ console.log('Valid streams:', e.valid);
135
+ console.log('Old-format streams needing migration:', e.old);
136
+ }
137
+ }
138
+ ```
139
+
140
+ ### CreatePackage Script Path Changed
141
+
142
+ - The path to the `CreatePackage` script changed from `camstreamerlib/CreatePackage.js` to `camstreamerlib/bin/CreatePackage.js`.
143
+ - Update any `package.json` scripts accordingly:
144
+
145
+ ```json
146
+ "scripts": {
147
+ "create-package": "node node_modules/camstreamerlib/bin/CreatePackage.js"
148
+ }
149
+ ```
123
150
 
124
151
  <hr/>
125
152
  </details>
@@ -204,3 +231,5 @@ The zip package is created in the current directory. You can choose different lo
204
231
  "create-package": "node node_modules/camstreamerlib/bin/CreatePackage.js -i -e=react"
205
232
  }
206
233
  ```
234
+
235
+ > :warning: Path to `CreatePackage` script has changed from `camstreamerlib/CreatePackage.js` to `camstreamerlib/bin/CreatePackage.js` (from v.4.0.0)
@@ -31,6 +31,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
31
31
  enabled: boolean;
32
32
  active: boolean;
33
33
  title: string;
34
+ callApi: boolean;
34
35
  trigger: {
35
36
  type: "manual";
36
37
  port?: number | undefined;
@@ -120,6 +121,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
120
121
  enabled: boolean;
121
122
  active: boolean;
122
123
  title: string;
124
+ callApi: boolean;
123
125
  trigger: {
124
126
  type: "manual";
125
127
  port?: number | undefined;
@@ -214,6 +216,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
214
216
  enabled: boolean;
215
217
  active: boolean;
216
218
  title: string;
219
+ callApi: boolean;
217
220
  trigger: {
218
221
  type: "manual";
219
222
  port?: number | undefined;
@@ -311,6 +314,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
311
314
  enabled: boolean;
312
315
  active: boolean;
313
316
  title: string;
317
+ callApi: boolean;
314
318
  trigger: {
315
319
  type: "manual";
316
320
  port?: number | undefined;
@@ -397,6 +401,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
397
401
  enabled: boolean;
398
402
  active: boolean;
399
403
  title: string;
404
+ callApi: boolean;
400
405
  trigger: {
401
406
  type: "manual";
402
407
  port?: number | undefined;
@@ -483,6 +488,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
483
488
  enabled: boolean;
484
489
  active: boolean;
485
490
  title: string;
491
+ callApi: boolean;
486
492
  trigger: {
487
493
  type: "manual";
488
494
  port?: number | undefined;
@@ -569,6 +575,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
569
575
  enabled: boolean;
570
576
  active: boolean;
571
577
  title: string;
578
+ callApi: boolean;
572
579
  trigger: {
573
580
  type: "manual";
574
581
  port?: number | undefined;
@@ -655,6 +662,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
655
662
  enabled: boolean;
656
663
  active: boolean;
657
664
  title: string;
665
+ callApi: boolean;
658
666
  trigger: {
659
667
  type: "manual";
660
668
  port?: number | undefined;
@@ -741,6 +749,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
741
749
  enabled: boolean;
742
750
  active: boolean;
743
751
  title: string;
752
+ callApi: boolean;
744
753
  trigger: {
745
754
  type: "manual";
746
755
  port?: number | undefined;
@@ -827,6 +836,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
827
836
  enabled: boolean;
828
837
  active: boolean;
829
838
  title: string;
839
+ callApi: boolean;
830
840
  trigger: {
831
841
  type: "manual";
832
842
  port?: number | undefined;
@@ -913,6 +923,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
913
923
  enabled: boolean;
914
924
  active: boolean;
915
925
  title: string;
926
+ callApi: boolean;
916
927
  trigger: {
917
928
  type: "manual";
918
929
  port?: number | undefined;
@@ -999,6 +1010,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
999
1010
  enabled: boolean;
1000
1011
  active: boolean;
1001
1012
  title: string;
1013
+ callApi: boolean;
1002
1014
  trigger: {
1003
1015
  type: "manual";
1004
1016
  port?: number | undefined;
@@ -1085,6 +1097,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1085
1097
  enabled: boolean;
1086
1098
  active: boolean;
1087
1099
  title: string;
1100
+ callApi: boolean;
1088
1101
  trigger: {
1089
1102
  type: "manual";
1090
1103
  port?: number | undefined;
@@ -1171,6 +1184,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1171
1184
  enabled: boolean;
1172
1185
  active: boolean;
1173
1186
  title: string;
1187
+ callApi: boolean;
1174
1188
  trigger: {
1175
1189
  type: "manual";
1176
1190
  port?: number | undefined;
@@ -1257,6 +1271,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1257
1271
  enabled: boolean;
1258
1272
  active: boolean;
1259
1273
  title: string;
1274
+ callApi: boolean;
1260
1275
  trigger: {
1261
1276
  type: "manual";
1262
1277
  port?: number | undefined;
@@ -1343,6 +1358,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1343
1358
  enabled: boolean;
1344
1359
  active: boolean;
1345
1360
  title: string;
1361
+ callApi: boolean;
1346
1362
  trigger: {
1347
1363
  type: "manual";
1348
1364
  port?: number | undefined;
@@ -1429,6 +1445,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1429
1445
  enabled: boolean;
1430
1446
  active: boolean;
1431
1447
  title: string;
1448
+ callApi: boolean;
1432
1449
  trigger: {
1433
1450
  type: "manual";
1434
1451
  port?: number | undefined;
@@ -1515,6 +1532,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1515
1532
  enabled: boolean;
1516
1533
  active: boolean;
1517
1534
  title: string;
1535
+ callApi: boolean;
1518
1536
  trigger: {
1519
1537
  type: "manual";
1520
1538
  port?: number | undefined;
@@ -1601,6 +1619,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1601
1619
  enabled: boolean;
1602
1620
  active: boolean;
1603
1621
  title: string;
1622
+ callApi: boolean;
1604
1623
  trigger: {
1605
1624
  type: "manual";
1606
1625
  port?: number | undefined;
@@ -1687,6 +1706,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1687
1706
  enabled: boolean;
1688
1707
  active: boolean;
1689
1708
  title: string;
1709
+ callApi: boolean;
1690
1710
  trigger: {
1691
1711
  type: "manual";
1692
1712
  port?: number | undefined;
@@ -1784,6 +1804,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1784
1804
  enabled: boolean;
1785
1805
  active: boolean;
1786
1806
  title: string;
1807
+ callApi: boolean;
1787
1808
  trigger: {
1788
1809
  type: "manual";
1789
1810
  port?: number | undefined;
@@ -1873,6 +1894,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1873
1894
  enabled: boolean;
1874
1895
  active: boolean;
1875
1896
  title: string;
1897
+ callApi: boolean;
1876
1898
  trigger: {
1877
1899
  type: "manual";
1878
1900
  port?: number | undefined;
@@ -1967,6 +1989,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
1967
1989
  enabled: boolean;
1968
1990
  active: boolean;
1969
1991
  title: string;
1992
+ callApi: boolean;
1970
1993
  trigger: {
1971
1994
  type: "manual";
1972
1995
  port?: number | undefined;
@@ -2064,6 +2087,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2064
2087
  enabled: boolean;
2065
2088
  active: boolean;
2066
2089
  title: string;
2090
+ callApi: boolean;
2067
2091
  trigger: {
2068
2092
  type: "manual";
2069
2093
  port?: number | undefined;
@@ -2150,6 +2174,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2150
2174
  enabled: boolean;
2151
2175
  active: boolean;
2152
2176
  title: string;
2177
+ callApi: boolean;
2153
2178
  trigger: {
2154
2179
  type: "manual";
2155
2180
  port?: number | undefined;
@@ -2236,6 +2261,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2236
2261
  enabled: boolean;
2237
2262
  active: boolean;
2238
2263
  title: string;
2264
+ callApi: boolean;
2239
2265
  trigger: {
2240
2266
  type: "manual";
2241
2267
  port?: number | undefined;
@@ -2322,6 +2348,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2322
2348
  enabled: boolean;
2323
2349
  active: boolean;
2324
2350
  title: string;
2351
+ callApi: boolean;
2325
2352
  trigger: {
2326
2353
  type: "manual";
2327
2354
  port?: number | undefined;
@@ -2408,6 +2435,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2408
2435
  enabled: boolean;
2409
2436
  active: boolean;
2410
2437
  title: string;
2438
+ callApi: boolean;
2411
2439
  trigger: {
2412
2440
  type: "manual";
2413
2441
  port?: number | undefined;
@@ -2494,6 +2522,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2494
2522
  enabled: boolean;
2495
2523
  active: boolean;
2496
2524
  title: string;
2525
+ callApi: boolean;
2497
2526
  trigger: {
2498
2527
  type: "manual";
2499
2528
  port?: number | undefined;
@@ -2580,6 +2609,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2580
2609
  enabled: boolean;
2581
2610
  active: boolean;
2582
2611
  title: string;
2612
+ callApi: boolean;
2583
2613
  trigger: {
2584
2614
  type: "manual";
2585
2615
  port?: number | undefined;
@@ -2666,6 +2696,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2666
2696
  enabled: boolean;
2667
2697
  active: boolean;
2668
2698
  title: string;
2699
+ callApi: boolean;
2669
2700
  trigger: {
2670
2701
  type: "manual";
2671
2702
  port?: number | undefined;
@@ -2752,6 +2783,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2752
2783
  enabled: boolean;
2753
2784
  active: boolean;
2754
2785
  title: string;
2786
+ callApi: boolean;
2755
2787
  trigger: {
2756
2788
  type: "manual";
2757
2789
  port?: number | undefined;
@@ -2838,6 +2870,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2838
2870
  enabled: boolean;
2839
2871
  active: boolean;
2840
2872
  title: string;
2873
+ callApi: boolean;
2841
2874
  trigger: {
2842
2875
  type: "manual";
2843
2876
  port?: number | undefined;
@@ -2924,6 +2957,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
2924
2957
  enabled: boolean;
2925
2958
  active: boolean;
2926
2959
  title: string;
2960
+ callApi: boolean;
2927
2961
  trigger: {
2928
2962
  type: "manual";
2929
2963
  port?: number | undefined;
@@ -3010,6 +3044,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
3010
3044
  enabled: boolean;
3011
3045
  active: boolean;
3012
3046
  title: string;
3047
+ callApi: boolean;
3013
3048
  trigger: {
3014
3049
  type: "manual";
3015
3050
  port?: number | undefined;
@@ -3096,6 +3131,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
3096
3131
  enabled: boolean;
3097
3132
  active: boolean;
3098
3133
  title: string;
3134
+ callApi: boolean;
3099
3135
  trigger: {
3100
3136
  type: "manual";
3101
3137
  port?: number | undefined;
@@ -3182,6 +3218,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
3182
3218
  enabled: boolean;
3183
3219
  active: boolean;
3184
3220
  title: string;
3221
+ callApi: boolean;
3185
3222
  trigger: {
3186
3223
  type: "manual";
3187
3224
  port?: number | undefined;
@@ -3268,6 +3305,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
3268
3305
  enabled: boolean;
3269
3306
  active: boolean;
3270
3307
  title: string;
3308
+ callApi: boolean;
3271
3309
  trigger: {
3272
3310
  type: "manual";
3273
3311
  port?: number | undefined;
@@ -3354,6 +3392,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
3354
3392
  enabled: boolean;
3355
3393
  active: boolean;
3356
3394
  title: string;
3395
+ callApi: boolean;
3357
3396
  trigger: {
3358
3397
  type: "manual";
3359
3398
  port?: number | undefined;
@@ -3440,6 +3479,7 @@ export declare class CamStreamerAPI<Client extends IClient<TResponse, any>> exte
3440
3479
  enabled: boolean;
3441
3480
  active: boolean;
3442
3481
  title: string;
3482
+ callApi: boolean;
3443
3483
  trigger: {
3444
3484
  type: "manual";
3445
3485
  port?: number | undefined;
package/cjs/VapixAPI.d.ts CHANGED
@@ -17,15 +17,6 @@ export declare class VapixAPI<Client extends IClient<TResponse, any>> extends Ba
17
17
  bitRates: number[];
18
18
  }[]>;
19
19
  performAutofocus(options?: THttpRequestOptions): Promise<void>;
20
- checkSDCard(options?: THttpRequestOptions): Promise<{
21
- status: "OK" | "connected" | "disconnected";
22
- totalSize: number;
23
- freeSize: number;
24
- }>;
25
- mountSDCard(options?: THttpRequestOptions): Promise<number>;
26
- unmountSDCard(options?: THttpRequestOptions): Promise<number>;
27
- private _doSDCardMountAction;
28
- fetchSDCardJobProgress(jobId: number, options?: THttpRequestOptions): Promise<number>;
29
20
  downloadCameraReport(options?: THttpRequestOptions): Promise<string>;
30
21
  getSystemLog(options?: THttpRequestOptions): Promise<string>;
31
22
  getMaxFps(channel: number, options?: THttpRequestOptions): Promise<number>;
@@ -43,6 +34,15 @@ export declare class VapixAPI<Client extends IClient<TResponse, any>> extends Ba
43
34
  fetchRemoteDeviceInfo<T extends Record<string, any>>(payload: T, options?: THttpRequestOptions): Promise<any>;
44
35
  getHeaders(options?: THttpRequestOptions): Promise<Record<string, string>>;
45
36
  setHeaders(headers: Record<string, string>, options?: THttpRequestOptions): Promise<void>;
37
+ checkSDCard(options?: THttpRequestOptions): Promise<{
38
+ status: "OK" | "connected" | "disconnected";
39
+ totalSize: number;
40
+ freeSize: number;
41
+ }>;
42
+ mountSDCard(options?: THttpRequestOptions): Promise<number>;
43
+ unmountSDCard(options?: THttpRequestOptions): Promise<number>;
44
+ private _doSDCardMountAction;
45
+ fetchSDCardJobProgress(jobId: number, options?: THttpRequestOptions): Promise<number>;
46
46
  getParameter(paramNames: string | string[], options?: THttpRequestOptions): Promise<Record<string, string>>;
47
47
  setParameter(params: Record<string, string | number | boolean>, options?: THttpRequestOptions): Promise<void>;
48
48
  getGuardTourList(options?: THttpRequestOptions): Promise<{
package/cjs/VapixAPI.js CHANGED
@@ -98,65 +98,6 @@ class VapixAPI extends BasicAPI_1.BasicAPI {
98
98
  }, options);
99
99
  }
100
100
  }
101
- async checkSDCard(options) {
102
- const res = await this._postUrlEncoded('/axis-cgi/disks/list.cgi', {
103
- diskid: 'SD_DISK',
104
- }, options);
105
- const xmlText = await res.text();
106
- const parser = new fast_xml_parser_1.XMLParser({
107
- ignoreAttributes: false,
108
- attributeNamePrefix: '',
109
- allowBooleanAttributes: true,
110
- });
111
- const result = parser.parse(xmlText);
112
- const data = result.root.disks.disk;
113
- return VapixAPI_1.sdCardInfoSchema.parse({
114
- totalSize: parseInt(data.totalsize),
115
- freeSize: parseInt(data.freesize),
116
- status: VapixAPI_1.sdCardWatchedStatuses.includes(data.status) ? data.status : 'disconnected',
117
- });
118
- }
119
- mountSDCard(options) {
120
- return this._doSDCardMountAction('MOUNT', options);
121
- }
122
- unmountSDCard(options) {
123
- return this._doSDCardMountAction('UNMOUNT', options);
124
- }
125
- async _doSDCardMountAction(action, options) {
126
- const res = await this._postUrlEncoded('/axis-cgi/disks/mount.cgi', {
127
- action: action,
128
- diskid: 'SD_DISK',
129
- }, options);
130
- const textXml = await res.text();
131
- const parser = new fast_xml_parser_1.XMLParser({
132
- ignoreAttributes: false,
133
- attributeNamePrefix: '',
134
- allowBooleanAttributes: true,
135
- });
136
- const result = parser.parse(textXml);
137
- const job = result.root.job;
138
- if (job.result !== 'OK') {
139
- throw new errors_1.SDCardActionError(action, job.description);
140
- }
141
- return Number(job.jobid);
142
- }
143
- async fetchSDCardJobProgress(jobId, options) {
144
- const res = await this._postUrlEncoded('/axis-cgi/disks/job.cgi', {
145
- jobid: String(jobId),
146
- diskid: 'SD_DISK',
147
- }, options);
148
- const textXml = await res.text();
149
- const parser = new fast_xml_parser_1.XMLParser({
150
- ignoreAttributes: false,
151
- attributeNamePrefix: '',
152
- allowBooleanAttributes: true,
153
- });
154
- const job = parser.parse(textXml).root.job;
155
- if (job.result !== 'OK') {
156
- throw new errors_1.SDCardJobError(job.description);
157
- }
158
- return Number(job.progress);
159
- }
160
101
  downloadCameraReport(options) {
161
102
  return this._getText('/axis-cgi/serverreport.cgi', { mode: 'text' }, options);
162
103
  }
@@ -242,6 +183,65 @@ class VapixAPI extends BasicAPI_1.BasicAPI {
242
183
  const data = { apiVersion: '1.0', method: 'set', params: headers };
243
184
  await this._postJsonEncoded('/axis-cgi/customhttpheader.cgi', data, undefined, options);
244
185
  }
186
+ async checkSDCard(options) {
187
+ const res = await this._postUrlEncoded('/axis-cgi/disks/list.cgi', {
188
+ diskid: 'SD_DISK',
189
+ }, options);
190
+ const xmlText = await res.text();
191
+ const parser = new fast_xml_parser_1.XMLParser({
192
+ ignoreAttributes: false,
193
+ attributeNamePrefix: '',
194
+ allowBooleanAttributes: true,
195
+ });
196
+ const result = parser.parse(xmlText);
197
+ const data = result.root.disks.disk;
198
+ return VapixAPI_1.sdCardInfoSchema.parse({
199
+ totalSize: parseInt(data.totalsize),
200
+ freeSize: parseInt(data.freesize),
201
+ status: VapixAPI_1.sdCardWatchedStatuses.includes(data.status) ? data.status : 'disconnected',
202
+ });
203
+ }
204
+ mountSDCard(options) {
205
+ return this._doSDCardMountAction('MOUNT', options);
206
+ }
207
+ unmountSDCard(options) {
208
+ return this._doSDCardMountAction('UNMOUNT', options);
209
+ }
210
+ async _doSDCardMountAction(action, options) {
211
+ const res = await this._postUrlEncoded('/axis-cgi/disks/mount.cgi', {
212
+ action: action,
213
+ diskid: 'SD_DISK',
214
+ }, options);
215
+ const textXml = await res.text();
216
+ const parser = new fast_xml_parser_1.XMLParser({
217
+ ignoreAttributes: false,
218
+ attributeNamePrefix: '',
219
+ allowBooleanAttributes: true,
220
+ });
221
+ const result = parser.parse(textXml);
222
+ const job = result.root.job;
223
+ if (job.result !== 'OK') {
224
+ throw new errors_1.SDCardActionError(action, job.description);
225
+ }
226
+ return Number(job.jobid);
227
+ }
228
+ async fetchSDCardJobProgress(jobId, options) {
229
+ const res = await this._postUrlEncoded('/disks/job.cgi', {
230
+ jobid: String(jobId),
231
+ diskid: 'SD_DISK',
232
+ }, options);
233
+ const textXml = await res.text();
234
+ const parser = new fast_xml_parser_1.XMLParser({
235
+ ignoreAttributes: false,
236
+ attributeNamePrefix: '',
237
+ allowBooleanAttributes: true,
238
+ });
239
+ const job = parser.parse(textXml).root.job;
240
+ if (job.result !== 'OK') {
241
+ throw new errors_1.SDCardJobError(job.description);
242
+ }
243
+ return Number(job.progress);
244
+ }
245
245
  async getParameter(paramNames, options) {
246
246
  const response = await this._postUrlEncoded('/axis-cgi/param.cgi', {
247
247
  action: 'list',