@signageos/front-applet 8.1.1 → 8.1.3

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.
Files changed (74) hide show
  1. package/dist/bundle.js +1 -1
  2. package/dist/bundle.js.map +1 -1
  3. package/docs/sos/browser.md +66 -14
  4. package/docs/sos/command.md +52 -6
  5. package/docs/sos/debug.md +17 -2
  6. package/docs/sos/deviceInfo.md +27 -0
  7. package/docs/sos/display.md +34 -3
  8. package/docs/sos/fileSystem.md +1135 -59
  9. package/docs/sos/index.md +36 -12
  10. package/docs/sos/input.md +42 -1
  11. package/docs/sos/native/mdc.md +65 -19
  12. package/docs/sos/offline/cache.md +14 -8
  13. package/docs/sos/stream.md +1172 -37
  14. package/docs/sos/sync.md +2 -2
  15. package/docs/sos/video.md +515 -22
  16. package/docs/sos_management/security.md +4 -2
  17. package/docs/sos_management/wifi.md +9 -9
  18. package/es6/FrontApplet/Browser/Browser.d.ts +25 -9
  19. package/es6/FrontApplet/Browser/Browser.js +25 -9
  20. package/es6/FrontApplet/Browser/Browser.js.map +1 -1
  21. package/es6/FrontApplet/Browser/IOpenLinkOptions.d.ts +7 -0
  22. package/es6/FrontApplet/Browser/IOpenLinkOptions.js.map +1 -1
  23. package/es6/FrontApplet/Browser/events.d.ts +6 -0
  24. package/es6/FrontApplet/Browser/events.js.map +1 -1
  25. package/es6/FrontApplet/Command/Command.d.ts +15 -6
  26. package/es6/FrontApplet/Command/Command.js +15 -6
  27. package/es6/FrontApplet/Command/Command.js.map +1 -1
  28. package/es6/FrontApplet/Command/ICommand.d.ts +7 -0
  29. package/es6/FrontApplet/Command/ICommandEvent.d.ts +6 -0
  30. package/es6/FrontApplet/Debug/Debug.d.ts +11 -3
  31. package/es6/FrontApplet/Debug/Debug.js +11 -3
  32. package/es6/FrontApplet/Debug/Debug.js.map +1 -1
  33. package/es6/FrontApplet/DeviceInfo/DeviceInfo.d.ts +15 -0
  34. package/es6/FrontApplet/DeviceInfo/DeviceInfo.js +16 -2
  35. package/es6/FrontApplet/DeviceInfo/DeviceInfo.js.map +1 -1
  36. package/es6/FrontApplet/Display/Display.d.ts +22 -14
  37. package/es6/FrontApplet/Display/Display.js +22 -14
  38. package/es6/FrontApplet/Display/Display.js.map +1 -1
  39. package/es6/FrontApplet/Display/IDisplay.d.ts +4 -0
  40. package/es6/FrontApplet/FileSystem/FileSystem.d.ts +429 -41
  41. package/es6/FrontApplet/FileSystem/FileSystem.js +427 -39
  42. package/es6/FrontApplet/FileSystem/FileSystem.js.map +1 -1
  43. package/es6/FrontApplet/FileSystem/HashAlgorithm.d.ts +4 -1
  44. package/es6/FrontApplet/FileSystem/types.d.ts +46 -0
  45. package/es6/FrontApplet/FileSystem/types.js.map +1 -1
  46. package/es6/FrontApplet/FrontApplet.d.ts +31 -7
  47. package/es6/FrontApplet/FrontApplet.js +32 -8
  48. package/es6/FrontApplet/FrontApplet.js.map +1 -1
  49. package/es6/FrontApplet/Input/IKeyUpEvent.d.ts +9 -0
  50. package/es6/FrontApplet/Input/IKeyUpEvent.js +6 -0
  51. package/es6/FrontApplet/Input/IKeyUpEvent.js.map +1 -1
  52. package/es6/FrontApplet/Input/Input.d.ts +17 -1
  53. package/es6/FrontApplet/Input/Input.js +17 -1
  54. package/es6/FrontApplet/Input/Input.js.map +1 -1
  55. package/es6/FrontApplet/NativeCommands/MDC/Mdc.d.ts +32 -11
  56. package/es6/FrontApplet/NativeCommands/MDC/Mdc.js +14 -11
  57. package/es6/FrontApplet/NativeCommands/MDC/Mdc.js.map +1 -1
  58. package/es6/FrontApplet/Stream/IStreamTrackInfo.d.ts +34 -0
  59. package/es6/FrontApplet/Stream/Stream.d.ts +245 -20
  60. package/es6/FrontApplet/Stream/Stream.js +245 -20
  61. package/es6/FrontApplet/Stream/Stream.js.map +1 -1
  62. package/es6/FrontApplet/Stream/StreamProtocol.d.ts +4 -0
  63. package/es6/FrontApplet/Stream/StreamProtocol.js +4 -0
  64. package/es6/FrontApplet/Stream/StreamProtocol.js.map +1 -1
  65. package/es6/FrontApplet/Stream/streamEventProperties.d.ts +11 -1
  66. package/es6/FrontApplet/Stream/streamEvents.d.ts +26 -0
  67. package/es6/FrontApplet/Video/IOptions.d.ts +41 -0
  68. package/es6/FrontApplet/Video/IVideoEvent.d.ts +8 -0
  69. package/es6/FrontApplet/Video/IVideoEvent.js.map +1 -1
  70. package/es6/FrontApplet/Video/IVideoProperties.d.ts +3 -0
  71. package/es6/FrontApplet/Video/Video.d.ts +256 -19
  72. package/es6/FrontApplet/Video/Video.js +258 -22
  73. package/es6/FrontApplet/Video/Video.js.map +1 -1
  74. package/package.json +1 -1
@@ -11,15 +11,35 @@ const EVENT_STORAGE_UNITS_CHANGED = 'storage_units_changed';
11
11
  * The `sos.fileSystem` API groups together methods for low-level access to the file system. The File System API supports both internal and
12
12
  * external storage.
13
13
  *
14
- * :::warning
15
- *
14
+ * :::warning Differences between File System API and Offline Cache API
16
15
  * File System directory structure is **PERSISTENT** and is **NOT** automatically deleted through `Applet Reload` power action!
17
16
  * Applet Reload only deletes `/data` directory which is reserved for simplified [Offline Cache API](./offline). Use
18
17
  * `deleteFile()` to clear the device storage file system.
18
+ * :::
19
19
  *
20
+ * :::info GitHub Example
21
+ * - [Example usage of File System API in Applet](https://github.com/signageos/applet-examples/tree/master/examples/content-js-api/file-system)
20
22
  * :::
21
23
  *
22
- * @tutorial https://developers.signageos.io/docs/applets/api-guides/offline-content#storing-files-permanently
24
+ *
25
+ * ## Storing files permanently
26
+ * To allow more low-level file operations, the applet SDK exposes the File System API. Files created using this API are permanent and are only removed on a factory reset or file system wipeout.
27
+ * The file system is also shared between all applets, which means you cannot rely on any file system structure on startup because a different applet on the device could have saved files you didn't expect.
28
+ * To mitigate this issue, create a directory for your applet and save all files inside it.
29
+ *
30
+ * @example
31
+ * import sos from '@signageos/front-applet';
32
+ *
33
+ * sos.onReady(async () => {
34
+ * const storageUnits = await sos.fileSystem.listStorageUnits();
35
+ * const rootPath = {
36
+ * filePath: '', // Empty string is used as an absolute path instead of "/"
37
+ * storageUnit: storageUnits.find((s) => !s.removable), // Find internal storage
38
+ * };
39
+ *
40
+ * // This will return files previous applets saved to the device
41
+ * const files = await sos.fileSystem.listFiles(rootPath);
42
+ * });
23
43
  */
24
44
  class FileSystem {
25
45
  messagePrefix;
@@ -35,6 +55,27 @@ class FileSystem {
35
55
  /**
36
56
  * The `listStorageUnits()` method lists all available storage units. All devices always have one internal storage device (with
37
57
  * `removable: false`) and zero or more external devices. The capacity values are in bytes.
58
+ *
59
+ * :::note
60
+ * This is a mandatory method that is required for all the other File System APIs. The other APIs require a storageUnit object that is retrieved from this method to manipulate with files on a correct storage location (internal/external).
61
+ * :::
62
+ *
63
+ * :::warning
64
+ * `storageUnit` is a dynamic object! It has to be always generated and retrieved by this JS API, as the values in type differ platform by platform. Never generate the object manually. `{"type":"internal"}` is for demonstration only.
65
+ * :::
66
+ *
67
+ * @returns {Promise<IStorageUnit[]>} An array of storage units available on the device.
68
+ * @throws InternalFileSystemError Unexpected error occurred when listing storage units.
69
+ * @since 2.1.0
70
+ *
71
+ * @example
72
+ * // Storage units are equivalent to disk volumes (C:, D: etc on Windows; /mnt/disc1, /mnt/disc2 on Unix)
73
+ * const storageUnits = await sos.fileSystem.listStorageUnits();
74
+ * const externalStorageUnits = storageUnits.filter((storageUnit) => storageUnit.removable);
75
+ * externalStorageUnits.forEach((storageUnit) => {
76
+ * console.log(`Storage Unit Type: ${storageUnit.type}`);
77
+ * console.log(`Capacity: ${storageUnit.capacity} bytes`);
78
+ * });
38
79
  */
39
80
  async listStorageUnits() {
40
81
  const { storageUnits } = await this.postMessage({
@@ -44,6 +85,19 @@ class FileSystem {
44
85
  }
45
86
  /**
46
87
  * A shorthand method for listing only the internal storage units (i.e. those with the `removable: false`). The capacity values are in bytes.
88
+ *
89
+ * @returns {Promise<IStorageUnit[]>} An array of internal storage units available on the device.
90
+ * @since 7.0.0
91
+ *
92
+ * @example
93
+ * // List internal storage units
94
+ * const internalStorageUnits = await sos.fileSystem.listInternalStorageUnits();
95
+ * internalStorageUnits.forEach((storageUnit) => {
96
+ * console.log(`Storage Unit Type: ${storageUnit.type}`);
97
+ * console.log(`Capacity: ${storageUnit.capacity} bytes`);
98
+ * console.log(`Free Space: ${storageUnit.freeSpace} bytes`);
99
+ * console.log(`Usable Space: ${storageUnit.usableSpace} bytes`);
100
+ * });
47
101
  */
48
102
  async listInternalStorageUnits() {
49
103
  const allStorageUnits = await this.listStorageUnits();
@@ -51,6 +105,10 @@ class FileSystem {
51
105
  }
52
106
  /**
53
107
  * The `onStorageUnitsChanged()` method sets up a listener, which is called whenever the list of storage units changes.
108
+ *
109
+ * @param listener The listener function to be called when the storage units change.
110
+ * @throws Error If `listener` is not a valid function.
111
+ * @since 2.1.0
54
112
  */
55
113
  onStorageUnitsChanged(listener) {
56
114
  (0, Validate_1.default)({ listener }).required().function();
@@ -64,7 +122,7 @@ class FileSystem {
64
122
  this.eventEmitter.removeListener(EVENT_STORAGE_UNITS_CHANGED, listener);
65
123
  }
66
124
  /**
67
- * The `removeAllListeners()` method removes all listeners, previously added by `removeAllListeners()`
125
+ * The `removeAllListeners()` method removes all listeners, previously added by `onStorageUnitsChanged()`
68
126
  */
69
127
  removeAllListeners() {
70
128
  this.eventEmitter.removeAllListeners(EVENT_STORAGE_UNITS_CHANGED);
@@ -72,7 +130,25 @@ class FileSystem {
72
130
  /**
73
131
  * The `listFiles()` method lists all files and directories in the specified path (nested files are not included).
74
132
  *
75
- * @throws If the path does not exist or it is a file.
133
+ * @param directoryPath The path to the directory where files will be listed.
134
+ * @returns {Promise<IFilePath[]>} A promise that resolves to an array of file paths in the specified directory.
135
+ * @throws Error If `directoryPath` is not a valid object or does not contain `storageUnit` and `filePath`.
136
+ * @throws Error If the path does not exist, or it is a file.
137
+ * @since 2.1.0
138
+ *
139
+ * @example
140
+ * // List files in the root directory of the internal storage unit
141
+ * const internalStorageUnit = (await sos.fileSystem.listInternalStorageUnits())[0];
142
+ * const directoryPath = {
143
+ * storageUnit: internalStorageUnit,
144
+ * filePath: '', // Empty string is used as an absolute path instead of "/"
145
+ * };
146
+ *
147
+ * const files = await sos.fileSystem.listFiles(directoryPath);
148
+ * console.log('Files in the root directory:', files.length);
149
+ * files.forEach((file) => {
150
+ * console.log(`File: ${file.filePath}`);
151
+ * });
76
152
  */
77
153
  async listFiles(directoryPath) {
78
154
  (0, Validate_1.default)({ directoryPath }).required().object(types_1.VIFilePath);
@@ -84,6 +160,21 @@ class FileSystem {
84
160
  }
85
161
  /**
86
162
  * The `exists()` method checks whether a file or directory exists.
163
+ *
164
+ * @param filePath The path to the file or directory to check.
165
+ * @returns {Promise<boolean>} A promise that resolves to `true` if the file or directory exists, `false` otherwise.
166
+ * @throws Error If the `filePath` is not a valid object or does not contain `storageUnit` and `filePath`.
167
+ * @throws Error If any error occurs during the existence check operation on the device.
168
+ * @since 2.1.0
169
+ *
170
+ * @example
171
+ * const filePath = {
172
+ * storageUnit: internalStorageUnit,
173
+ * filePath: 'path/to/file.txt',
174
+ * };
175
+ *
176
+ * const fileExists = await sos.fileSystem.exists(filePath);
177
+ * console.log(`File exists: ${fileExists}`); // Prints true if the file exists, false otherwise
87
178
  */
88
179
  async exists(filePath) {
89
180
  (0, Validate_1.default)({ filePath }).required().object(types_1.VIFilePath);
@@ -95,6 +186,28 @@ class FileSystem {
95
186
  }
96
187
  /**
97
188
  * The `getFile()` method returns runtime information about a file path, such as local url, last modified date or size.
189
+ *
190
+ * :::warning
191
+ * Return statement is a dynamic object! It has to be always generated and retrieved by this JS API, as the values in localUri differ platform by platform. Never generate the object manually. `{"localUri":"file://internal/path/to/file.txt"}` is for demonstration only.
192
+ * :::
193
+ *
194
+ * @param filePath The path to the file to be retrieved.
195
+ * @returns {Promise<IFile | null>} A promise that resolves to the file information or `null` if the file does not exist.
196
+ * @throws Error If the `filePath` is not a valid object or does not contain `storageUnit` and `filePath`.
197
+ * @throws Error If the file is a directory.
198
+ * @throws Error If any error occurs during the retrieval operation on the device.
199
+ * @since 2.1.0
200
+ *
201
+ * @example
202
+ * // Get file information
203
+ * const filePath = {
204
+ * storageUnit: internalStorageUnit,
205
+ * filePath: 'path/to/file.txt',
206
+ * };
207
+ *
208
+ * const fileInfo = await sos.fileSystem.getFile(filePath);
209
+ * console.log(JSON.stringify(fileInfo)); // Prints the file information
210
+ * console.log(fileInfo.localUri); // Prints the local URI of the file
98
211
  */
99
212
  async getFile(filePath) {
100
213
  (0, Validate_1.default)({ filePath }).required().object(types_1.VIFilePath);
@@ -111,10 +224,24 @@ class FileSystem {
111
224
  };
112
225
  }
113
226
  /**
114
- * The `writeFile()` method writes string content to the file specified by `filePath`. If the file does exist, it is created. If the directory
115
- * does not exist, an error is thrown.
227
+ * The `writeFile()` method writes string content to the file specified by `filePath`. If the file does exist, it is created.
228
+ *
229
+ * @param filePath The path to the file to be written.
230
+ * @param contents The content to be written to the file.
231
+ * @returns {Promise<void>} A promise that resolves when the content is written successfully.
232
+ * @throws Error If the parent directory does not exist or the `filePath` is a directory.
233
+ * @throws Error If the `filePath` is not a valid object or does not contain `storageUnit` and `filePath`.
234
+ * @throws Error If any error occurs during the write operation on the device.
235
+ * @since 3.2.0
116
236
  *
117
- * @throws If the parent directory does not exist or the `filePath` is a directory.
237
+ * @example
238
+ * const filePath = {
239
+ * storageUnit: internalStorageUnit,
240
+ * filePath: 'path/to/file.txt',
241
+ * };
242
+ *
243
+ * const contents = 'This is the content to write to the file.';
244
+ * await sos.fileSystem.writeFile(filePath, contents);
118
245
  */
119
246
  async writeFile(filePath, contents) {
120
247
  (0, Validate_1.default)({ filePath }).required().object(types_1.VIFilePath);
@@ -125,10 +252,30 @@ class FileSystem {
125
252
  });
126
253
  }
127
254
  /**
128
- * The `writeFile()` method appends string content to the file specified by `filePath`. If the file does exist, it is created. If the directory
129
- * does not exist, an error is thrown.
255
+ * The `appendFile()` method appends string content to the file specified by `filePath`.
256
+ * If the file does exist, it is created.
257
+ *
258
+ * :::note
259
+ * Only string can be appended to the file. If you want to append binary data, you have to convert it to a string first.
260
+ * :::
261
+ *
262
+ * @param filePath The path to the file to be appended.
263
+ * @param contents The content to be appended to the file.
264
+ * @returns {Promise<void>} A promise that resolves when the content is appended successfully.
265
+ * @throws Error If the parent directory does not exist.
266
+ * @throws Error If the `filePath` is a directory.
267
+ * @throws Error If the `filePath` is not a valid object or does not contain `storageUnit` and `filePath`.
268
+ * @throws Error If any error occurs during the append operation on the device.
269
+ * @since
270
+ *
271
+ * @example
272
+ * const filePath = {
273
+ * storageUnit: internalStorageUnit,
274
+ * filePath: 'path/to/file.txt',
275
+ * };
130
276
  *
131
- * @throws If the parent directory does not exist or the `filePath` is a directory.
277
+ * const contents = 'This is the content to append to the file.';
278
+ * await sos.fileSystem.appendFile(filePath, contents);
132
279
  */
133
280
  async appendFile(filePath, contents) {
134
281
  (0, Validate_1.default)({ filePath }).required().object(types_1.VIFilePath);
@@ -139,10 +286,25 @@ class FileSystem {
139
286
  });
140
287
  }
141
288
  /**
142
- * The `readFile()` method returns content of the file specified by `filePath`. The file has to be a text file, otherwise the content will be
143
- * mangled.
289
+ * The `readFile()` method returns content of the file specified by `filePath`.
290
+ * The file has to be a text file, otherwise the content will be mangled.
144
291
  *
145
- * @throws If the file does not exist.
292
+ * @param filePath The path to the file to be read.
293
+ * @returns {Promise<string>} A promise that resolves to the content of the file.
294
+ * @throws Error If the file does not exist.
295
+ * @throws Error If the `filePath` is not a valid object or does not contain `storageUnit` and `filePath`.
296
+ * @throws Error If the file is a directory.
297
+ * @throws Error If any error occurs during the read operation on the device.
298
+ * @since 3.3.0
299
+ *
300
+ * @example
301
+ * const filePath = {
302
+ * storageUnit: internalStorageUnit,
303
+ * filePath: 'path/to/file.txt',
304
+ * };
305
+ *
306
+ * const fileContent = await sos.fileSystem.readFile(filePath);
307
+ * console.log(`Content of the file: ${fileContent}`);
146
308
  */
147
309
  async readFile(filePath) {
148
310
  (0, Validate_1.default)({ filePath }).required().object(types_1.VIFilePath);
@@ -153,12 +315,32 @@ class FileSystem {
153
315
  return contents;
154
316
  }
155
317
  /**
156
- * The `copyFile()` method creates a copy of file at `sourceFilePath` to `destinationFilePath`.
318
+ * The `copyFile()` method creates a copy of file from `sourceFilePath` to `destinationFilePath`.
319
+ *
320
+ * @param sourceFilePath The path to the file to be copied.
321
+ * @param destinationFilePath The path where the file will be copied to.
322
+ * @param options Options for copying the file.
323
+ * @param options.overwrite If set to `true`, the method will overwrite the destination file if it already exists.
324
+ * @returns {Promise<void>} A promise that resolves when the file is copied successfully.
325
+ * @throws Error If the source file does not exist.
326
+ * @throws Error If parent of the destination file path does not exist.
327
+ * @throws Error If `options` object is not valid.
328
+ * @throws Error If any error occurs during the copy operation on the device.
329
+ * @since 2.1.0
330
+ *
331
+ * @example
332
+ * // Copy file from one directory to another and overwrite it if it already exists
333
+ * const sourceFilePath = {
334
+ * storageUnit: internalStorageUnit,
335
+ * filePath: 'path/to/source/file.txt',
336
+ * };
157
337
  *
158
- * @param options.overwrite If not set or set to `false`, an error will be thrown if `destinationFilePath` already exists.
338
+ * const destinationFilePath = {
339
+ * storageUnit: internalStorageUnit,
340
+ * filePath: 'path/to/destination/file.txt',
341
+ * };
159
342
  *
160
- * @throws If the source file does not exists or parent of the destination file path does not exists. It also throws if the
161
- * `options.overwrite` is not set and the destination file path already exists.
343
+ * await sos.fileSystem.copyFile(sourceFilePath, destinationFilePath, { overwrite: true });
162
344
  */
163
345
  async copyFile(sourceFilePath, destinationFilePath, options = {}) {
164
346
  (0, Validate_1.default)({ sourceFilePath }).required().object(types_1.VIFilePath);
@@ -174,8 +356,30 @@ class FileSystem {
174
356
  /**
175
357
  * The `moveFile()` method moves a file from `sourceFilePath` to `destinationFilePath`.
176
358
  *
177
- * @throws If the source file does not exists or parent of the destination file path does not exists. It also throws if the
178
- * `options.overwrite` is not set and the destination file path already exists.
359
+ * @param sourceFilePath The path to the file to be moved.
360
+ * @param destinationFilePath The path where the file will be moved to.
361
+ * @param options Options for moving the file.
362
+ * @param options.overwrite If set to `true`, the method will overwrite the destination file if it already exists.
363
+ * @returns {Promise<void>} A promise that resolves when the file is moved successfully.
364
+ * @throws Error If the source file does not exist or parent of the destination file path does not exist.
365
+ * @throws Error If the `options.overwrite` is not set and the destination file path already exists.
366
+ * @throws Error If deleting path does not exist.
367
+ * @throws Error If any error occurs during the move operation on the device.
368
+ * @since 2.1.0
369
+ *
370
+ * @example
371
+ * // Move file from one directory to another and overwrite it if it already exists
372
+ * const sourceFilePath = {
373
+ * storageUnit: internalStorageUnit,
374
+ * filePath: 'path/to/source/file.txt',
375
+ * };
376
+ *
377
+ * const destinationFilePath = {
378
+ * storageUnit: internalStorageUnit,
379
+ * filePath: 'path/to/destination/file.txt',
380
+ * };
381
+ *
382
+ * await sos.fileSystem.moveFile(sourceFilePath, destinationFilePath, { overwrite: true });
179
383
  */
180
384
  async moveFile(sourceFilePath, destinationFilePath, options = {}) {
181
385
  (0, Validate_1.default)({ sourceFilePath }).required().object(types_1.VIFilePath);
@@ -189,9 +393,31 @@ class FileSystem {
189
393
  });
190
394
  }
191
395
  /**
192
- * The `deleteFile()` method deletes the file specified by `filePath`. To remove a directory set `recursive` to `true`.
396
+ * The `deleteFile()` method deletes the file specified by `filePath`.
397
+ *
398
+ * @param filePath The path to the file or directory to be deleted.
399
+ * @param recursive If set to `true`, the method will delete the directory and all its contents recursively.
400
+ * @returns {Promise<void>} A promise that resolves when the file is deleted successfully.
401
+ * @throws Error If `filePath` is not a valid object or does not contain `storageUnit` and `filePath`.
402
+ * @throws Error If the file does not exist or if `recursive` is set to false and the file path is a directory.
403
+ * @throws Error If deleting path does not exist.
404
+ * @throws Error When is deleting directory and is not empty (not recursive).
405
+ * @since 2.1.0
406
+ *
407
+ * @example
408
+ * // Delete directory and all files inside
409
+ * //// First check, if there is such a directory
410
+ * if (await sos.fileSystem.exists({ storageUnit: internalStorageUnit, filePath: 'test-dir' })) {
411
+ * // Delete the directory and all it's content recursively
412
+ * await sos.fileSystem.deleteFile({ storageUnit: internalStorageUnit, filePath: 'test-dir' }, true);
413
+ * }
193
414
  *
194
- * @throws If the file does not exists or if `recursive` is set to false and the file path is a directory.
415
+ * // Delete file
416
+ * //// First check, if there is such a file
417
+ * if (await sos.fileSystem.exists({ storageUnit: internalStorageUnit, filePath: 'test-dir/downloaded-file.png' })) {
418
+ * // Delete the file
419
+ * await sos.fileSystem.deleteFile({ storageUnit: internalStorageUnit, filePath: 'test-dir/downloaded-file.png' }, false);
420
+ * }
195
421
  */
196
422
  async deleteFile(filePath, recursive) {
197
423
  (0, Validate_1.default)({ filePath }).required().object(types_1.VIFilePath);
@@ -203,17 +429,14 @@ class FileSystem {
203
429
  });
204
430
  }
205
431
  /**
206
- * The `downloadFile()` method download a file from `sourceUri` and saves it to the specified path. If the file already exists it is
207
- * overwritten. Optionally, headers for the download request may be specified. A HEAD request is always sent first to get `content-length`
208
- * of the downloaded file.
432
+ * The `downloadFile()` method download a file from `sourceUri` and saves it to the specified path. If the file already exists, the file will be
433
+ * overwritten. Optionally, headers for the download request may be specified.
209
434
  *
210
- * :::warning
211
- * - For every download request, our app makes HEAD request for `content-length` header on that downloaded file.
212
- * - Windows platform can download only files smaller then 4GB.
435
+ * :::danger
436
+ * For every download request, our Core Apps makes HEAD request for `content-length` header on that downloaded file. It's due to determining if device has enough space to download the file.
213
437
  * :::
214
438
  *
215
439
  * #### Encoding
216
- *
217
440
  * All downloads respect a standard of `Encoding` with optional compression of files. See [Mozilla standard Accept Encoding](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding) and [Content Encoding](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding).
218
441
  *
219
442
  * Download file method is always sending optional following headers:
@@ -243,7 +466,27 @@ class FileSystem {
243
466
  * - Raspberry Pi
244
467
  * - Windows
245
468
  *
246
- * @throws If the network request fails, parent directory does not exist, or the file path is a directory.
469
+ * @param filePath The path where the downloaded file will be saved.
470
+ * @param sourceUri The URI of the file to be downloaded.
471
+ * @param headers Key, value pairs of HTTP headers to send along with the request. Used when the target file is protected by a password or if any
472
+ * @returns {Promise<void>} A promise that resolves when the file is downloaded successfully.
473
+ * @throws Error If `filePath` is not a valid object or does not contain `storageUnit` and `filePath`.
474
+ * @throws Error If `sourceUri` is not a valid URI.
475
+ * @throws Error If `headers` is not a valid object.
476
+ * @throws Error If the parent directory of `filePath` does not exist.
477
+ * @throws Error If the network request fails.
478
+ * @since 2.1.0
479
+ *
480
+ * @example
481
+ * const filePath = {
482
+ * storageUnit: internalStorageUnit,
483
+ * filePath: 'path/to/downloaded/file.zip',
484
+ * };
485
+ * const sourceUri = 'https://example.com/path/to/file.zip';
486
+ * const headers = {
487
+ * 'Authorization': 'Bearer your_token_here',
488
+ * };
489
+ * await sos.fileSystem.downloadFile(filePath, sourceUri, headers);
247
490
  */
248
491
  async downloadFile(filePath, sourceUri, headers) {
249
492
  (0, Validate_1.default)({ filePath }).required().object(types_1.VIFilePath);
@@ -257,9 +500,33 @@ class FileSystem {
257
500
  });
258
501
  }
259
502
  /**
260
- * The `decompressFile()` method decompresses the file at `archiveFilePath` into a new file specified by `destinationDirectoryPath`.
503
+ * The `extractFile()` method extract (recursively) the archive file at `archiveFilePath` into a new file specified by `destinationDirectoryPath`.
261
504
  *
262
- * @throws If the archive file path does not exist, it is not a valid archive file or the destination directory does not exist.
505
+ * :::note
506
+ * - The directory/folder you are extracting your ZIP file into has to be created BEFORE you start extracting the ZIP.
507
+ * - Only supported extract method is `zip`.
508
+ * :::
509
+ *
510
+ * @param archiveFilePath The path to the archive file to be decompressed.
511
+ * @param destinationDirectoryPath The path to the directory where the decompressed files will be saved.
512
+ * @param method Extract method to use for extracting, e.g. 'zip'.
513
+ * @throws Error If the archive file path does not exist.
514
+ * @throws Error If it is not a valid archive file.
515
+ * @throws Error If destination directory does not exist.
516
+ * @since 2.1.0
517
+ *
518
+ * @example
519
+ * const archiveFilePath = {
520
+ * storageUnit: internalStorageUnit,
521
+ * filePath: 'path/to/archive.zip',
522
+ * };
523
+ *
524
+ * const destinationDirectoryPath = {
525
+ * storageUnit: internalStorageUnit,
526
+ * filePath: 'path/to/destination/directory',
527
+ * };
528
+ *
529
+ * await sos.fileSystem.extractFile(archiveFilePath, destinationDirectoryPath, 'zip');
263
530
  */
264
531
  async extractFile(archiveFilePath, destinationDirectoryPath, method) {
265
532
  (0, Validate_1.default)({ archiveFilePath }).required().object(types_1.VIFilePath);
@@ -273,13 +540,51 @@ class FileSystem {
273
540
  });
274
541
  }
275
542
  /**
276
- * The `createArchive()` method creates an arch file at `archiveFilePath` from `archiveEntries` files.
543
+ * The `createArchive()` method creates an archive file from selected files and directories.
277
544
  *
278
545
  * :::warning
546
+ * - Never start OR end the `filePath` with a slash - `/`.
547
+ * - It is a good practice to check if file exists - `exists()` prior creating it
548
+ * :::
279
549
  *
280
- * This function is available only on Tizen devices.
281
- *
550
+ * :::info
551
+ * - This function is available only on Tizen devices.
552
+ * - All files are added to the archive based on absolute path from root directory.
282
553
  * :::
554
+ *
555
+ * @param archiveFilePath The path where the archive file will be created.
556
+ * @param archiveEntries An array of file paths to be included in the archive.
557
+ * @returns {Promise<void>} A promise that resolves when the archive file is created successfully.
558
+ * @throws Error If `archiveFilePath` is not a valid object or does not contain `storageUnit` and `filePath`.
559
+ * @throws Error If `archiveEntries` is not a valid array of objects.
560
+ * @throws Error If the parent directory of `archiveFilePath` does not exist.
561
+ * @throws Error If any of the `archiveEntries` do not exist or are directories.
562
+ * @throws Error If creating the archive file fails.
563
+ * @throws Error If the platform does not support creating archive files.
564
+ * @since 5.12.0
565
+ *
566
+ * @example
567
+ * const archiveFilePath = {
568
+ * storageUnit: internalStorageUnit,
569
+ * filePath: 'path/to/archive.zip',
570
+ * };
571
+ *
572
+ * const archiveEntries = [
573
+ * {
574
+ * storageUnit: internalStorageUnit,
575
+ * filePath: 'path/to/file1.txt',
576
+ * },
577
+ * {
578
+ * storageUnit: internalStorageUnit,
579
+ * filePath: 'path/to/file2.txt',
580
+ * },
581
+ * {
582
+ * storageUnit: internalStorageUnit,
583
+ * filePath: 'path/to/directory1',
584
+ * },
585
+ * ];
586
+ *
587
+ * await sos.fileSystem.createArchive(archiveFilePath, archiveEntries);
283
588
  */
284
589
  async createArchive(archiveFilePath, archiveEntries) {
285
590
  (0, Validate_1.default)({ archiveFilePath }).required().object(types_1.VIFilePath);
@@ -293,7 +598,27 @@ class FileSystem {
293
598
  /**
294
599
  * The `getChecksumFile()` method computes a checksum of the file specified by `filePath`.
295
600
  *
296
- * @throws If the file does not exist or it is a directory.
601
+ * :::warning Tizen limitation
602
+ * If you are about to use the MD5 file validation it will automatically return on any Samsung Tizen - 2.4, 3.0 and 4.0.
603
+ * Reason: MD5 file checksum is not available on any Tizen displays due to the Samsung restriction.
604
+ * :::
605
+ *
606
+ * @param filePath The path to the file for which the checksum will be computed.
607
+ * @param hashType The type of hash algorithm to use for computing the checksum.
608
+ * @returns {Promise<string>} A promise that resolves to the computed checksum of the file.
609
+ * @throws Error If `filePath` is not a valid object or does not contain `storageUnit` and `filePath`.
610
+ * @throws Error If `hashType` is not a valid type or string.
611
+ * @throws Error If the file does not exist.
612
+ * @throws Error If `filepath` it is a directory
613
+ *
614
+ * @example
615
+ * const filePath = {
616
+ * storageUnit: internalStorageUnit,
617
+ * filePath: 'path/to/file.txt',
618
+ * };
619
+ *
620
+ * const checksum = await sos.fileSystem.getFileChecksum(filePath, 'md5');
621
+ * console.log(`Checksum of the file: ${checksum}`);
297
622
  */
298
623
  async getFileChecksum(filePath, hashType) {
299
624
  (0, Validate_1.default)({ filePath }).required().object(types_1.VIFilePath);
@@ -308,7 +633,26 @@ class FileSystem {
308
633
  /**
309
634
  * The `createDirectory()` method create a new directory at specified path.
310
635
  *
311
- * @throws If the directory already exists or its parent directory does not exist.
636
+ * :::warning
637
+ * - Never start OR end the filePath with a slash - `/`.
638
+ * - It is a good practice to check if directory exists - `isDirectory()` prior creating it.
639
+ * :::
640
+ *
641
+ * @param directoryPath The path where the new directory will be created.
642
+ * @returns {Promise<void>} A promise that resolves when the directory is created successfully.
643
+ * @throws Error If `directoryPath` is not a valid object or does not contain `storageUnit` and `filePath`.
644
+ * @throws Error If the directory already exists.
645
+ * @throws Error If parent directory does not exist.
646
+ * @since 2.1.0
647
+ *
648
+ * @example
649
+ * const internalStorageUnit = (await sos.fileSystem.listInternalStorageUnits())[0];
650
+ * const directoryPath = {
651
+ * storageUnit: internalStorageUnit,
652
+ * filePath: 'path/to/new/directory',
653
+ * };
654
+ *
655
+ * await sos.fileSystem.createDirectory(directoryPath);
312
656
  */
313
657
  async createDirectory(directoryPath) {
314
658
  (0, Validate_1.default)({ directoryPath }).required().object(types_1.VIFilePath);
@@ -320,7 +664,23 @@ class FileSystem {
320
664
  /**
321
665
  * The `isDirectory()` method checks whether the file path points to a directory.
322
666
  *
323
- * @throws If the file path does not exist.
667
+ * @param filePath The file path to check.
668
+ * @returns {Promise<boolean>} A promise that resolves to `true` if the file path is a directory, `false` otherwise.
669
+ * @throws Error If `filePath` is not a valid object or does not contain `storageUnit` and `filePath`.
670
+ * @throws Error If the file path does not exist.
671
+ * @since 2.1.0
672
+ *
673
+ * @example
674
+ * const filePath = {
675
+ * storageUnit: internalStorageUnit,
676
+ * filePath: 'path/to/directory',
677
+ * };
678
+ * const isDir = await sos.fileSystem.isDirectory(filePath);
679
+ * if (isDir) {
680
+ * console.log('The file path is a directory.');
681
+ * } else {
682
+ * console.log('The file path is not a directory.');
683
+ * }
324
684
  */
325
685
  async isDirectory(filePath) {
326
686
  (0, Validate_1.default)({ filePath }).required().object(types_1.VIFilePath);
@@ -331,7 +691,33 @@ class FileSystem {
331
691
  return isDirectory;
332
692
  }
333
693
  /**
334
- * The `link()` method creates a symbolic link to `sourceFilePath` (existing path) from `destinationFilePath` (new path).
694
+ * The `link()` method creates a symbolic link from `sourceFilePath` (existing path) to `destinationFilePath` (new path).
695
+ *
696
+ * :::note
697
+ * This method is only available on Linux devices.
698
+ * :::
699
+ *
700
+ * @param sourceFilePath The path to the existing file or directory that you want to link to.
701
+ * @param destinationFilePath The path where the symbolic link will be created.
702
+ * @throws Error If `sourceFilePath` or `destinationPath` is not a valid object or does not contain `storageUnit` and `filePath`.
703
+ * @throws Error If the `sourceFilePath` does not exist or if the `destinationFilePath` already exists.
704
+ * @throws Error The platform does not support linking directories.
705
+ * @returns {Promise<void>} A promise that resolves when the symbolic link is created successfully.
706
+ * @since 4.0.0
707
+ *
708
+ * @example
709
+ * const internalStorageUnit = (await sos.fileSystem.listInternalStorageUnits())[0];
710
+ * const sourceFilePath = {
711
+ * storageUnit: internalStorageUnit,
712
+ * filePath: 'path/to/existing/file.txt',
713
+ * };
714
+ *
715
+ * const destinationFilePath = {
716
+ * storageUnit: internalStorageUnit,
717
+ * filePath: 'path/to/symlink/file_link.txt',
718
+ * };
719
+ *
720
+ * await sos.fileSystem.link(sourceFilePath, destinationFilePath);
335
721
  */
336
722
  async link(sourceFilePath, destinationFilePath) {
337
723
  (0, Validate_1.default)({ sourceFilePath }).required().object(types_1.VIFilePath);
@@ -345,6 +731,8 @@ class FileSystem {
345
731
  /**
346
732
  * The `wipeout()` method is used to wipe out all data from the file system, later when action is finished the device is rebooted.
347
733
  *
734
+ * @returns {Promise<void>} A promise that resolves when the wipeout is complete.
735
+ *
348
736
  * :::danger
349
737
  * - Ensure that function is called only once, otherwise it will wipe out the file system again on applet start!
350
738
  * - This function is clearing internal file system storage, cache storage and cookies. Local storage will not be cleared.