@zenfs/core 0.7.1 → 0.7.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.
|
@@ -2,33 +2,27 @@ import { FileSystem } from '../filesystem.js';
|
|
|
2
2
|
import { type RequiredKeys } from '../utils.js';
|
|
3
3
|
type OptionType = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Resolves the type of Backend.options from the options interface
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The basic JavaScript type(s) for this option.
|
|
10
|
-
*/
|
|
11
|
-
type: OptionType | readonly OptionType[];
|
|
12
|
-
/**
|
|
13
|
-
* Whether or not the option is required (optional can be set to null or undefined). Defaults to false.
|
|
14
|
-
*/
|
|
15
|
-
required: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Description of the option. Used in error messages and documentation.
|
|
18
|
-
*/
|
|
19
|
-
description: string;
|
|
20
|
-
/**
|
|
21
|
-
* A custom validation function to check if the option is valid.
|
|
22
|
-
* When async, resolves if valid and rejects if not.
|
|
23
|
-
* When sync, it will throw an error if not valid.
|
|
24
|
-
*/
|
|
25
|
-
validator?(opt: T): void | Promise<void>;
|
|
26
|
-
}
|
|
27
|
-
type InferOptionsConfig<T> = {
|
|
7
|
+
type OptionsConfig<T> = {
|
|
28
8
|
[K in keyof T]: {
|
|
29
|
-
|
|
9
|
+
/**
|
|
10
|
+
* The basic JavaScript type(s) for this option.
|
|
11
|
+
*/
|
|
12
|
+
type: OptionType | readonly OptionType[];
|
|
13
|
+
/**
|
|
14
|
+
* Description of the option. Used in error messages and documentation.
|
|
15
|
+
*/
|
|
30
16
|
description: string;
|
|
17
|
+
/**
|
|
18
|
+
* Whether or not the option is required (optional can be set to null or undefined). Defaults to false.
|
|
19
|
+
*/
|
|
31
20
|
required: K extends RequiredKeys<T> ? true : false;
|
|
21
|
+
/**
|
|
22
|
+
* A custom validation function to check if the option is valid.
|
|
23
|
+
* When async, resolves if valid and rejects if not.
|
|
24
|
+
* When sync, it will throw an error if not valid.
|
|
25
|
+
*/
|
|
32
26
|
validator?(opt: T[K]): void | Promise<void>;
|
|
33
27
|
};
|
|
34
28
|
};
|
|
@@ -47,7 +41,7 @@ export interface Backend<FS extends FileSystem = FileSystem, TOptions extends ob
|
|
|
47
41
|
/**
|
|
48
42
|
* Describes all of the options available for this backend.
|
|
49
43
|
*/
|
|
50
|
-
options:
|
|
44
|
+
options: OptionsConfig<TOptions>;
|
|
51
45
|
/**
|
|
52
46
|
* Whether the backend is available in the current environment.
|
|
53
47
|
* It supports checking synchronously and asynchronously
|