@photostructure/fs-metadata 0.3.3 → 0.5.0

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 (183) hide show
  1. package/C++_REVIEW_TODO.md +291 -0
  2. package/CHANGELOG.md +33 -1
  3. package/CLAUDE.md +169 -0
  4. package/CONTRIBUTING.md +25 -0
  5. package/coverage/base.css +224 -0
  6. package/coverage/block-navigation.js +87 -0
  7. package/coverage/favicon.png +0 -0
  8. package/coverage/index.html +131 -0
  9. package/coverage/lcov-report/base.css +224 -0
  10. package/coverage/lcov-report/block-navigation.js +87 -0
  11. package/coverage/lcov-report/favicon.png +0 -0
  12. package/coverage/lcov-report/index.html +131 -0
  13. package/coverage/lcov-report/prettify.css +1 -0
  14. package/coverage/lcov-report/prettify.js +2 -0
  15. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  16. package/coverage/lcov-report/sorter.js +196 -0
  17. package/coverage/lcov-report/src/array.ts.html +217 -0
  18. package/coverage/lcov-report/src/async.ts.html +547 -0
  19. package/coverage/lcov-report/src/debuglog.ts.html +187 -0
  20. package/coverage/lcov-report/src/defer.ts.html +175 -0
  21. package/coverage/lcov-report/src/dirname.ts.html +124 -0
  22. package/coverage/lcov-report/src/error.ts.html +322 -0
  23. package/coverage/lcov-report/src/fs.ts.html +316 -0
  24. package/coverage/lcov-report/src/glob.ts.html +472 -0
  25. package/coverage/lcov-report/src/hidden.ts.html +724 -0
  26. package/coverage/lcov-report/src/index.html +521 -0
  27. package/coverage/lcov-report/src/index.ts.html +676 -0
  28. package/coverage/lcov-report/src/linux/dev_disk.ts.html +316 -0
  29. package/coverage/lcov-report/src/linux/index.html +146 -0
  30. package/coverage/lcov-report/src/linux/mount_points.ts.html +364 -0
  31. package/coverage/lcov-report/src/linux/mtab.ts.html +493 -0
  32. package/coverage/lcov-report/src/mount_point.ts.html +106 -0
  33. package/coverage/lcov-report/src/number.ts.html +148 -0
  34. package/coverage/lcov-report/src/object.ts.html +265 -0
  35. package/coverage/lcov-report/src/options.ts.html +475 -0
  36. package/coverage/lcov-report/src/path.ts.html +268 -0
  37. package/coverage/lcov-report/src/platform.ts.html +112 -0
  38. package/coverage/lcov-report/src/random.ts.html +205 -0
  39. package/coverage/lcov-report/src/remote_info.ts.html +553 -0
  40. package/coverage/lcov-report/src/stack_path.ts.html +298 -0
  41. package/coverage/lcov-report/src/string.ts.html +382 -0
  42. package/coverage/lcov-report/src/string_enum.ts.html +208 -0
  43. package/coverage/lcov-report/src/system_volume.ts.html +301 -0
  44. package/coverage/lcov-report/src/unc.ts.html +274 -0
  45. package/coverage/lcov-report/src/units.ts.html +274 -0
  46. package/coverage/lcov-report/src/uuid.ts.html +157 -0
  47. package/coverage/lcov-report/src/volume_health_status.ts.html +259 -0
  48. package/coverage/lcov-report/src/volume_metadata.ts.html +787 -0
  49. package/coverage/lcov-report/src/volume_mount_points.ts.html +388 -0
  50. package/coverage/lcov.info +3581 -0
  51. package/coverage/prettify.css +1 -0
  52. package/coverage/prettify.js +2 -0
  53. package/coverage/sort-arrow-sprite.png +0 -0
  54. package/coverage/sorter.js +196 -0
  55. package/coverage/src/array.ts.html +217 -0
  56. package/coverage/src/async.ts.html +547 -0
  57. package/coverage/src/debuglog.ts.html +187 -0
  58. package/coverage/src/defer.ts.html +175 -0
  59. package/coverage/src/dirname.ts.html +124 -0
  60. package/coverage/src/error.ts.html +322 -0
  61. package/coverage/src/fs.ts.html +316 -0
  62. package/coverage/src/glob.ts.html +472 -0
  63. package/coverage/src/hidden.ts.html +724 -0
  64. package/coverage/src/index.html +521 -0
  65. package/coverage/src/index.ts.html +676 -0
  66. package/coverage/src/linux/dev_disk.ts.html +316 -0
  67. package/coverage/src/linux/index.html +146 -0
  68. package/coverage/src/linux/mount_points.ts.html +364 -0
  69. package/coverage/src/linux/mtab.ts.html +493 -0
  70. package/coverage/src/mount_point.ts.html +106 -0
  71. package/coverage/src/number.ts.html +148 -0
  72. package/coverage/src/object.ts.html +265 -0
  73. package/coverage/src/options.ts.html +475 -0
  74. package/coverage/src/path.ts.html +268 -0
  75. package/coverage/src/platform.ts.html +112 -0
  76. package/coverage/src/random.ts.html +205 -0
  77. package/coverage/src/remote_info.ts.html +553 -0
  78. package/coverage/src/stack_path.ts.html +298 -0
  79. package/coverage/src/string.ts.html +382 -0
  80. package/coverage/src/string_enum.ts.html +208 -0
  81. package/coverage/src/system_volume.ts.html +301 -0
  82. package/coverage/src/unc.ts.html +274 -0
  83. package/coverage/src/units.ts.html +274 -0
  84. package/coverage/src/uuid.ts.html +157 -0
  85. package/coverage/src/volume_health_status.ts.html +259 -0
  86. package/coverage/src/volume_metadata.ts.html +787 -0
  87. package/coverage/src/volume_mount_points.ts.html +388 -0
  88. package/jest.config.cjs +67 -6
  89. package/package.json +51 -40
  90. package/prebuilds/linux-x64/@photostructure+fs-metadata.glibc.node +0 -0
  91. package/scripts/check-memory.mjs +243 -0
  92. package/scripts/clang-tidy.mjs +73 -0
  93. package/scripts/is-platform.mjs +12 -0
  94. package/scripts/post-build.mjs +21 -0
  95. package/scripts/run-asan.sh +92 -0
  96. package/scripts/valgrind-test.mjs +83 -0
  97. package/scripts/valgrind.sh +70 -0
  98. package/src/async.ts +3 -3
  99. package/src/binding.cpp +3 -3
  100. package/src/darwin/hidden.cpp +14 -0
  101. package/src/darwin/raii_utils.h +85 -0
  102. package/src/darwin/volume_metadata.cpp +35 -60
  103. package/src/darwin/volume_mount_points.cpp +31 -22
  104. package/src/error.ts +3 -3
  105. package/src/fs.ts +1 -1
  106. package/src/glob.ts +2 -2
  107. package/src/hidden.ts +6 -6
  108. package/src/index.ts +19 -23
  109. package/src/linux/blkid_cache.cpp +15 -12
  110. package/src/linux/dev_disk.ts +2 -2
  111. package/src/linux/gio_mount_points.cpp +7 -7
  112. package/src/linux/gio_utils.cpp +19 -8
  113. package/src/linux/gio_volume_metadata.cpp +15 -15
  114. package/src/linux/mount_points.ts +9 -9
  115. package/src/linux/mtab.ts +7 -7
  116. package/src/linux/volume_metadata.cpp +6 -1
  117. package/src/object.ts +9 -4
  118. package/src/options.ts +4 -4
  119. package/src/path.ts +4 -4
  120. package/src/remote_info.ts +5 -5
  121. package/src/system_volume.ts +8 -8
  122. package/src/test-utils/assert.ts +2 -2
  123. package/src/test-utils/debuglog-child.ts +1 -3
  124. package/src/test-utils/debuglog-enabled-child.ts +10 -0
  125. package/src/test-utils/hidden-tests.ts +1 -1
  126. package/src/test-utils/platform.ts +3 -3
  127. package/src/types/native_bindings.ts +3 -3
  128. package/src/types/volume_metadata.ts +2 -2
  129. package/src/unc.ts +2 -2
  130. package/src/uuid.ts +1 -1
  131. package/src/volume_health_status.ts +6 -6
  132. package/src/volume_metadata.ts +20 -23
  133. package/src/volume_mount_points.ts +12 -17
  134. package/src/windows/drive_status.h +30 -13
  135. package/src/windows/hidden.cpp +12 -0
  136. package/src/windows/volume_metadata.cpp +17 -7
  137. package/tsup.config.ts +8 -2
  138. package/dist/index.cjs +0 -1439
  139. package/dist/index.cjs.map +0 -1
  140. package/dist/index.mjs +0 -1396
  141. package/dist/index.mjs.map +0 -1
  142. package/dist/types/array.d.ts +0 -25
  143. package/dist/types/async.d.ts +0 -42
  144. package/dist/types/debuglog.d.ts +0 -3
  145. package/dist/types/defer.d.ts +0 -10
  146. package/dist/types/dirname.d.ts +0 -1
  147. package/dist/types/error.d.ts +0 -17
  148. package/dist/types/fs.d.ts +0 -22
  149. package/dist/types/glob.d.ts +0 -17
  150. package/dist/types/hidden.d.ts +0 -29
  151. package/dist/types/index.d.ts +0 -91
  152. package/dist/types/linux/dev_disk.d.ts +0 -13
  153. package/dist/types/linux/mount_points.d.ts +0 -6
  154. package/dist/types/linux/mtab.d.ts +0 -47
  155. package/dist/types/mount_point.d.ts +0 -2
  156. package/dist/types/number.d.ts +0 -3
  157. package/dist/types/object.d.ts +0 -13
  158. package/dist/types/options.d.ts +0 -33
  159. package/dist/types/path.d.ts +0 -17
  160. package/dist/types/platform.d.ts +0 -4
  161. package/dist/types/random.d.ts +0 -12
  162. package/dist/types/remote_info.d.ts +0 -6
  163. package/dist/types/stack_path.d.ts +0 -2
  164. package/dist/types/string.d.ts +0 -37
  165. package/dist/types/string_enum.d.ts +0 -19
  166. package/dist/types/system_volume.d.ts +0 -14
  167. package/dist/types/types/hidden_metadata.d.ts +0 -32
  168. package/dist/types/types/mount_point.d.ts +0 -46
  169. package/dist/types/types/native_bindings.d.ts +0 -51
  170. package/dist/types/types/options.d.ts +0 -47
  171. package/dist/types/types/remote_info.d.ts +0 -33
  172. package/dist/types/types/volume_metadata.d.ts +0 -46
  173. package/dist/types/unc.d.ts +0 -11
  174. package/dist/types/units.d.ts +0 -38
  175. package/dist/types/uuid.d.ts +0 -16
  176. package/dist/types/volume_health_status.d.ts +0 -24
  177. package/dist/types/volume_metadata.d.ts +0 -8
  178. package/dist/types/volume_mount_points.d.ts +0 -6
  179. package/jest.config.base.cjs +0 -63
  180. package/prebuilds/darwin-arm64/@photostructure+fs-metadata.glibc.node +0 -0
  181. package/prebuilds/linux-arm64/@photostructure+fs-metadata.musl.node +0 -0
  182. package/prebuilds/linux-x64/@photostructure+fs-metadata.musl.node +0 -0
  183. package/prebuilds/win32-x64/@photostructure+fs-metadata.glibc.node +0 -0
@@ -1,13 +0,0 @@
1
- /**
2
- * Check if a value is an object
3
- */
4
- export declare function isObject(value: unknown): value is object;
5
- /**
6
- * Map a value to another value, or undefined if the value is undefined
7
- */
8
- export declare function map<T, U>(obj: T | undefined, fn: (value: T) => U): U | undefined;
9
- /**
10
- * Omit the specified fields from an object
11
- */
12
- export declare function omit<T extends object, K extends keyof T>(obj: T, ...keys: K[]): Omit<T, K>;
13
- export declare function compactValues<T extends object>(obj: T | undefined): Partial<T>;
@@ -1,33 +0,0 @@
1
- import type { Options } from "./types/options.js";
2
- /**
3
- * Default timeout in milliseconds for {@link Options.timeoutMs}.
4
- *
5
- * Note that this timeout may be insufficient for some devices, like spun-down
6
- * optical drives or network shares that need to spin up or reconnect.
7
- */
8
- export declare const TimeoutMsDefault: 5000;
9
- /**
10
- * System paths and globs that indicate system volumes
11
- */
12
- export declare const SystemPathPatternsDefault: string[];
13
- /**
14
- * Filesystem types that indicate system volumes
15
- */
16
- export declare const SystemFsTypesDefault: readonly ["autofs", "binfmt_misc", "cgroup", "cgroup2", "configfs", "debugfs", "devpts", "devtmpfs", "efivarfs", "fusectl", "fuse.snapfuse", "hugetlbfs", "mqueue", "none", "proc", "pstore", "rootfs", "securityfs", "snap*", "squashfs", "sysfs", "tmpfs"];
17
- export declare const LinuxMountTablePathsDefault: readonly ["/proc/self/mounts", "/proc/mounts", "/etc/mtab"];
18
- /**
19
- * Should {@link getAllVolumeMetadata} include system volumes by
20
- * default?
21
- */
22
- export declare const IncludeSystemVolumesDefault: boolean;
23
- /**
24
- * Default {@link Options} object.
25
- *
26
- * @see {@link optionsWithDefaults} for creating an options object with default values
27
- */
28
- export declare const OptionsDefault: Options;
29
- /**
30
- * Create an {@link Options} object using default values from
31
- * {@link OptionsDefault} for missing fields.
32
- */
33
- export declare function optionsWithDefaults<T extends Options>(overrides?: Partial<T>): T;
@@ -1,17 +0,0 @@
1
- export declare function normalizePath(mountPoint: string | undefined): string | undefined;
2
- /**
3
- * Normalizes a Linux or macOS mount point by removing any trailing slashes.
4
- * This is a no-op for root mount points.
5
- */
6
- export declare function normalizePosixPath(mountPoint: string | undefined): string | undefined;
7
- /**
8
- * Normalizes a Windows mount point by ensuring drive letters end with a
9
- * backslash.
10
- */
11
- export declare function normalizeWindowsPath(mountPoint: string): string;
12
- /**
13
- * @return true if `path` is the root directory--this is platform-specific. Only
14
- * "/" on linux/macOS is considered a root directory. On Windows, the root
15
- * directory is a drive letter followed by a colon, e.g. "C:\".
16
- */
17
- export declare function isRootDirectory(path: string): boolean;
@@ -1,4 +0,0 @@
1
- export declare const isLinux: boolean;
2
- export declare const isWindows: boolean;
3
- export declare const isMacOS: boolean;
4
- export declare const isArm: boolean;
@@ -1,12 +0,0 @@
1
- /**
2
- * @return a random character `[a-z]`
3
- */
4
- export declare function randomLetter(): string;
5
- export declare function randomLetters(length: number): string;
6
- /**
7
- * Shuffle an array using the Fisher-Yates (Knuth) algorithm.
8
- * @param a The array to shuffle
9
- * @returns A shallow shuffled copy of `a`
10
- */
11
- export declare function shuffle<T>(a: T[]): T[];
12
- export declare function pickRandom<T>(a: T[]): T;
@@ -1,6 +0,0 @@
1
- import { RemoteInfo } from "./types/remote_info.js";
2
- export declare function isRemoteInfo(obj: unknown): obj is RemoteInfo;
3
- export declare function normalizeFsType(fstype: string): string;
4
- export declare function isRemoteFsType(fstype: string | undefined): boolean;
5
- export declare function parseURL(s: string): URL | undefined;
6
- export declare function extractRemoteInfo(fsSpec: string | undefined): RemoteInfo | undefined;
@@ -1,2 +0,0 @@
1
- export declare function getCallerDirname(): string;
2
- export declare function extractCallerPath(stack: string): string;
@@ -1,37 +0,0 @@
1
- export declare function isString(input: unknown): input is string;
2
- export declare function toS(input: unknown): string;
3
- /**
4
- * @return true iff the input is a string and has at least one non-whitespace character
5
- */
6
- export declare function isNotBlank(input: unknown): input is string;
7
- /**
8
- * @return true iff the input is not a string or only has non-whitespace characters
9
- */
10
- export declare function isBlank(input: unknown): input is undefined;
11
- export declare function toNotBlank(input: unknown): string | undefined;
12
- /**
13
- * Decodes a string containing octal (\000-\377) and/or hexadecimal
14
- * (\x00-\xFF) escape sequences
15
- * @param input The string containing escape sequences to decode
16
- * @returns The decoded string with escape sequences converted to their
17
- * corresponding characters
18
- * @throws Error if an invalid escape sequence is encountered
19
- */
20
- export declare function decodeEscapeSequences(input: string): string;
21
- export declare function encodeEscapeSequences(input: string): string;
22
- /**
23
- * Sort an array of strings using the locale-aware collation algorithm.
24
- *
25
- * @param arr The array of strings to sort. The original array **is sorted in
26
- * place**.
27
- */
28
- export declare function sortByLocale(arr: string[], locales?: Intl.LocalesArgument, options?: Intl.CollatorOptions): string[];
29
- /**
30
- * Sort an array of objects using the locale-aware collation algorithm.
31
- *
32
- * @param arr The array of objects to sort.
33
- * @param fn The function to extract the key to sort by from each object.
34
- * @param locales The locales to use for sorting.
35
- * @param options The collation options to use for sorting.
36
- */
37
- export declare function sortObjectsByLocale<T>(arr: T[], fn: (key: T) => string, locales?: Intl.LocalesArgument, options?: Intl.CollatorOptions): T[];
@@ -1,19 +0,0 @@
1
- export type StringEnumType<T extends string> = {
2
- [K in T]: K;
3
- };
4
- export type StringEnum<T extends string> = StringEnumType<T> & {
5
- values: T[];
6
- size: number;
7
- get(s: string | undefined): T | undefined;
8
- };
9
- export type StringEnumKeys<Type> = Type extends StringEnum<infer X> ? X : never;
10
- /**
11
- * Create a string enum with the given values.
12
-
13
- Example usage:
14
-
15
- export const Directions = stringEnum("North", "South", "East", "West")
16
- export type Direction = StringEnumKeys<typeof Directions>
17
-
18
- */
19
- export declare function stringEnum<T extends string>(...o: T[]): StringEnum<T>;
@@ -1,14 +0,0 @@
1
- import type { MountPoint } from "./types/mount_point.js";
2
- import type { Options } from "./types/options.js";
3
- /**
4
- * Configuration for system volume detection
5
- *
6
- * @see {@link MountPoint.isSystemVolume}
7
- */
8
- export type SystemVolumeConfig = Pick<Options, "systemPathPatterns" | "systemFsTypes">;
9
- /**
10
- * Determines if a mount point represents a system volume based on its path and
11
- * filesystem type
12
- */
13
- export declare function isSystemVolume(mountPoint: string, fstype: string | undefined, config?: Partial<SystemVolumeConfig>): boolean;
14
- export declare function assignSystemVolume(mp: MountPoint, config: Partial<SystemVolumeConfig>): void;
@@ -1,32 +0,0 @@
1
- /**
2
- * Represents the detailed state of a file or directory's hidden attribute
3
- */
4
- export interface HiddenMetadata {
5
- /**
6
- * Whether the item is considered hidden by any method
7
- */
8
- hidden: boolean;
9
- /**
10
- * Whether the item has a dot prefix (POSIX-style hidden). Windows doesn't
11
- * care about dot prefixes.
12
- */
13
- dotPrefix: boolean;
14
- /**
15
- * Whether the item has system hidden flags set, like via `chflags` on macOS
16
- * or on Windows via `GetFileAttributesW`
17
- */
18
- systemFlag: boolean;
19
- /**
20
- * Indicates which hiding methods are supported on the current platform
21
- */
22
- supported: {
23
- /**
24
- * Whether dot prefix hiding is supported on the current operating system
25
- */
26
- dotPrefix: boolean;
27
- /**
28
- * Whether system flag hiding is supported
29
- */
30
- systemFlag: boolean;
31
- };
32
- }
@@ -1,46 +0,0 @@
1
- import type { VolumeHealthStatus } from "../volume_health_status";
2
- /**
3
- * A mount point is a location in the file system where a volume is mounted.
4
- *
5
- * @see https://en.wikipedia.org/wiki/Mount_(computing)
6
- */
7
- export interface MountPoint {
8
- /**
9
- * Mount location (like "/" or "C:\").
10
- */
11
- mountPoint: string;
12
- /**
13
- * The type of file system on the volume, like `ext4`, `apfs`, or `ntfs`.
14
- *
15
- * Note: on Windows this may show as "ntfs" for remote filesystems, as that
16
- * is how the filesystem is presented to the OS.
17
- */
18
- fstype?: string;
19
- /**
20
- * On Windows, returns the health status of the volume.
21
- *
22
- * Note that this is only available on Windows, as both Linux and macOS are
23
- * prohibitively expensive, requiring forking `fsck -N` or `diskutil
24
- * verifyVolume`.
25
- *
26
- * If there are non-critical errors while extracting metadata, those error
27
- * messages may be added to this field (say, from blkid or gio).
28
- *
29
- * @see {@link VolumeHealthStatuses} for values returned by Windows.
30
- */
31
- status?: VolumeHealthStatus | string;
32
- /**
33
- * Indicates if this volume is primarily for system use (e.g., swap, snap
34
- * loopbacks, EFI boot, or only system directories).
35
- *
36
- * Note: This is a best-effort classification and is not 100% accurate.
37
- *
38
- * @see {@link Options.systemPathPatterns} and {@link Options.systemFsTypes}
39
- */
40
- isSystemVolume?: boolean;
41
- /**
42
- * If there are non-critical errors while extracting metadata, those errors
43
- * may be added to this field.
44
- */
45
- error?: Error | string;
46
- }
@@ -1,51 +0,0 @@
1
- import type { MountPoint } from "./mount_point.js";
2
- import type { Options } from "./options.js";
3
- import type { VolumeMetadata } from "./volume_metadata.js";
4
- export interface NativeBindings {
5
- /**
6
- * Enable or disable debug logging. Set automatically if the `NODE_DEBUG`
7
- * environment matches `fs-meta`, `fs-metadata`, or
8
- * `photostructure:fs-metadata`.
9
- */
10
- setDebugLogging(enabled: boolean): void;
11
- /**
12
- * Sets a prefix for debug log messages. Defaults to the shortest enabled
13
- * debug log context, plus the process ID.
14
- */
15
- setDebugPrefix(prefix: string): void;
16
- /**
17
- * This is only available on macOS and Windows--Linux only hides files via
18
- * filename (if basename starts with a dot).
19
- */
20
- isHidden(path: string): Promise<boolean>;
21
- /**
22
- * This is only available on macOS and Windows--Linux only hides files via
23
- * filename (if basename starts with a dot).
24
- *
25
- * @param path The path to the file or directory to hide or unhide
26
- * @param hidden If true, the file or directory will be hidden; if false, it
27
- * will be unhidden
28
- * @throws {Error} If the operation fails
29
- */
30
- setHidden(path: string, hidden: boolean): Promise<void>;
31
- /**
32
- * This is only available on macOS and Windows--Linux directly reads from the
33
- * proc mounts table.
34
- */
35
- getVolumeMountPoints(options?: Pick<Options, "timeoutMs">): Promise<MountPoint[]>;
36
- /**
37
- * This is only available on Linux, and only if libglib-2.0 is installed.
38
- */
39
- getGioMountPoints?(): Promise<MountPoint[]>;
40
- /**
41
- * This is only a partial implementation for most platforms, to minimize
42
- * native code when possible. The javascript side handles a bunch of
43
- * subsequent parsing and extraction logic.
44
- */
45
- getVolumeMetadata(options: GetVolumeMetadataOptions): Promise<VolumeMetadata>;
46
- }
47
- export type GetVolumeMetadataOptions = {
48
- mountPoint: string;
49
- device?: string;
50
- } & Partial<Pick<Options, "timeoutMs">>;
51
- export type NativeBindingsFn = () => NativeBindings | Promise<NativeBindings>;
@@ -1,47 +0,0 @@
1
- /**
2
- * Configuration options for filesystem operations.
3
- *
4
- * @see {@link optionsWithDefaults} for creating an options object with default values
5
- * @see {@link OptionsDefault} for the default values
6
- */
7
- export interface Options {
8
- /**
9
- * Timeout in milliseconds for filesystem operations.
10
- *
11
- * Disable timeouts by setting this to 0.
12
- *
13
- * @see {@link TimeoutMsDefault}.
14
- */
15
- timeoutMs: number;
16
- /**
17
- * Maximum number of concurrent filesystem operations.
18
- *
19
- * Defaults to {@link https://nodejs.org/api/os.html#osavailableparallelism | availableParallelism}.
20
- */
21
- maxConcurrency: number;
22
- /**
23
- * On Linux and macOS, mount point pathnames that matches any of these glob
24
- * patterns will have {@link MountPoint.isSystemVolume} set to true.
25
- *
26
- * @see {@link SystemPathPatternsDefault} for the default value
27
- */
28
- systemPathPatterns: string[];
29
- /**
30
- * On Linux and macOS, volumes whose filesystem matches any of these strings
31
- * will have {@link MountPoint.isSystemVolume} set to true.
32
- *
33
- * @see {@link SystemFsTypesDefault} for the default value
34
- */
35
- systemFsTypes: string[];
36
- /**
37
- * On Linux, use the first mount point table in this array that is readable.
38
- *
39
- * @see {@link LinuxMountTablePathsDefault} for the default values
40
- */
41
- linuxMountTablePaths: string[];
42
- /**
43
- * Should system volumes be included in result arrays? Defaults to true on
44
- * Windows and false elsewhere.
45
- */
46
- includeSystemVolumes: boolean;
47
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * Represents remote filesystem information.
3
- */
4
- export interface RemoteInfo {
5
- /**
6
- * We can sometimes fetch a URI of the resource (like "smb://server/share" or
7
- * "file:///media/user/usb")
8
- */
9
- uri?: string;
10
- /**
11
- * Protocol used to access the share.
12
- */
13
- protocol?: string;
14
- /**
15
- * Does the protocol seem to be a remote filesystem?
16
- */
17
- remote: boolean;
18
- /**
19
- * If remote, may include the username used to access the share.
20
- *
21
- * This will be undefined on NFS and other remote filesystem types that do
22
- * authentication out of band.
23
- */
24
- remoteUser?: string;
25
- /**
26
- * If remote, the ip or hostname hosting the share (like "rusty" or "10.1.1.3")
27
- */
28
- remoteHost?: string;
29
- /**
30
- * If remote, the name of the share (like "homes")
31
- */
32
- remoteShare?: string;
33
- }
@@ -1,46 +0,0 @@
1
- import type { MountPoint } from "./mount_point.js";
2
- import type { RemoteInfo } from "./remote_info.js";
3
- /**
4
- * Metadata associated to a volume.
5
- *
6
- * @see https://en.wikipedia.org/wiki/Volume_(computing)
7
- */
8
- export interface VolumeMetadata extends RemoteInfo, MountPoint {
9
- /**
10
- * The name of the partition
11
- */
12
- label?: string;
13
- /**
14
- * Total size in bytes
15
- */
16
- size?: number;
17
- /**
18
- * Used size in bytes
19
- */
20
- used?: number;
21
- /**
22
- * Available size in bytes
23
- */
24
- available?: number;
25
- /**
26
- * Path to the device or service that the mountpoint is from.
27
- *
28
- * Examples include `/dev/sda1`, `nfs-server:/export`,
29
- * `//username@remoteHost/remoteShare`, or `//cifs-server/share`.
30
- *
31
- * May be undefined for remote volumes.
32
- */
33
- mountFrom?: string;
34
- /**
35
- * The name of the mount. This may match the resolved mountPoint.
36
- */
37
- mountName?: string;
38
- /**
39
- * UUID for the volume, like "c9b08f6e-b392-11ef-bf19-4b13bb7db4b4".
40
- *
41
- * On windows, this _may_ be the 128-bit volume UUID, but if that is not
42
- * available, like in the case of remote volumes, we fallback to the 32-bit
43
- * volume serial number, rendered in lowercase hexadecimal.
44
- */
45
- uuid?: string;
46
- }
@@ -1,11 +0,0 @@
1
- import { RemoteInfo } from "./types/remote_info.js";
2
- /**
3
- * Checks if a string is formatted as a valid UNC path.
4
- * A valid UNC path starts with double backslashes or slashes,
5
- * followed by a server/host name, and then a share name.
6
- * The path must use consistent slashes (all forward or all backward).
7
- *
8
- * @param path - The string to check
9
- * @returns boolean - True if the string is a valid UNC path, false otherwise
10
- */
11
- export declare function parseUNCPath(path: string | null | undefined): RemoteInfo | undefined;
@@ -1,38 +0,0 @@
1
- /**
2
- * Milliseconds in a second
3
- */
4
- export declare const SecondMs = 1000;
5
- /**
6
- * Milliseconds in a minute
7
- */
8
- export declare const MinuteMs: number;
9
- /**
10
- * Milliseconds in an hour
11
- */
12
- export declare const HourMs: number;
13
- /**
14
- * Milliseconds in a day
15
- */
16
- export declare const DayMs: number;
17
- /**
18
- * Kibibyte (KiB) = 1024 bytes
19
- * @see https://en.wikipedia.org/wiki/Kibibyte
20
- */
21
- export declare const KiB = 1024;
22
- /**
23
- * Mebibyte (MiB) = 1024 KiB
24
- * @see https://en.wikipedia.org/wiki/Mebibyte
25
- */
26
- export declare const MiB: number;
27
- /**
28
- * Gibibyte (GiB)= 1024 MiB
29
- * @see https://en.wikipedia.org/wiki/Gibibyte
30
- */
31
- export declare const GiB: number;
32
- /**
33
- * Tebibyte (TiB) = 1024 GiB
34
- *
35
- * @see https://en.wikipedia.org/wiki/Byte#Multiple-byte_units
36
- */
37
- export declare const TiB: number;
38
- export declare function fmtBytes(bytes: number): string;
@@ -1,16 +0,0 @@
1
- /**
2
- * Some volume UUIDs are short, like, `ABCD1234`.
3
- *
4
- * Some volume UUIDs are in hexadecimal, but others and use G-Z. We will allow
5
- * that.
6
- *
7
- * Some Windows syscalls wrap the UUID in a "\\\\?\\Volume{...}\\" prefix and
8
- * suffix. This function will strip out that prefix and suffix.
9
- *
10
- * We will ignore any UUID-ish string that is not at least 8 characters long
11
- * (and return `undefined` if no other, longer uuid-ish string is found).
12
- *
13
- * UUIDs cannot start with a hyphen, and can only contain a-z, 0-9, and hyphens
14
- * (case-insensitive).
15
- */
16
- export declare function extractUUID(uuid: string | undefined): string | undefined;
@@ -1,24 +0,0 @@
1
- import { canReaddir } from "./fs.js";
2
- import { StringEnumKeys } from "./string_enum.js";
3
- /**
4
- * Health statuses for volumes (mostly applicable to Windows).
5
- *
6
- * - `healthy`: Volume is "OK": accessible and functioning normally
7
- * - `timeout`: Volume could not be accessed before the specified timeout. It
8
- * may be inaccessible or disconnected.
9
- * - `inaccessible`: Volume exists but can't be accessed (permissions/locks)
10
- * - `disconnected`: Network volume that's offline
11
- * - `unknown`: Status can't be determined
12
- */
13
- export declare const VolumeHealthStatuses: import("./string_enum.js").StringEnum<"healthy" | "timeout" | "inaccessible" | "disconnected" | "unknown">;
14
- export type VolumeHealthStatus = StringEnumKeys<typeof VolumeHealthStatuses>;
15
- /**
16
- * Attempt to read a directory to determine if it's accessible, and if an error
17
- * is thrown, convert to a health status.
18
- * @returns the "health status" of the directory, based on the success of `readdir(dir)`.
19
- * @throws never
20
- */
21
- export declare function directoryStatus(dir: string, timeoutMs: number, canReaddirImpl?: typeof canReaddir): Promise<{
22
- status: VolumeHealthStatus;
23
- error?: Error;
24
- }>;
@@ -1,8 +0,0 @@
1
- import type { GetVolumeMetadataOptions, NativeBindingsFn } from "./types/native_bindings.js";
2
- import type { Options } from "./types/options.js";
3
- import type { VolumeMetadata } from "./types/volume_metadata.js";
4
- export declare function getVolumeMetadataImpl(o: GetVolumeMetadataOptions & Options, nativeFn: NativeBindingsFn): Promise<VolumeMetadata>;
5
- export declare function getAllVolumeMetadataImpl(opts: Required<Options> & {
6
- includeSystemVolumes?: boolean;
7
- maxConcurrency?: number;
8
- }, nativeFn: NativeBindingsFn): Promise<VolumeMetadata[]>;
@@ -1,6 +0,0 @@
1
- import { SystemVolumeConfig } from "./system_volume.js";
2
- import type { MountPoint } from "./types/mount_point.js";
3
- import type { NativeBindingsFn } from "./types/native_bindings.js";
4
- import type { Options } from "./types/options.js";
5
- export type GetVolumeMountPointOptions = Partial<Pick<Options, "timeoutMs" | "linuxMountTablePaths" | "maxConcurrency" | "includeSystemVolumes"> & SystemVolumeConfig>;
6
- export declare function getVolumeMountPointsImpl(opts: Required<GetVolumeMountPointOptions>, nativeFn: NativeBindingsFn): Promise<MountPoint[]>;
@@ -1,63 +0,0 @@
1
- // @ts-check
2
-
3
- // jest.config.base.cjs
4
-
5
- const { argv, platform } = require("node:process");
6
-
7
- const otherPlatforms = ["linux", "darwin", "windows"]
8
- .filter((ea) => ea !== (platform === "win32" ? "windows" : platform))
9
- .map((ea) => `/${ea}/`);
10
-
11
- /** @type {import('ts-jest').JestConfigWithTsJest} */
12
- const baseConfig = {
13
- testEnvironment: "jest-environment-node",
14
- roots: ["<rootDir>/src"],
15
- coverageProvider: "v8",
16
- moduleNameMapper: {
17
- "^(\\.{1,2}/.*)\\.js$": "$1",
18
- },
19
- moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
20
- verbose: true,
21
- silent: false,
22
- randomize: true,
23
- setupFilesAfterEnv: [
24
- "jest-extended/all",
25
- "<rootDir>/src/test-utils/jest-matchers.ts",
26
- ],
27
- collectCoverage: !argv.includes("--no-coverage"),
28
- coverageDirectory: "coverage",
29
- coverageReporters: ["text", "lcov", "html"],
30
- collectCoverageFrom: [
31
- "src/**/*.ts",
32
- // We have to include dist/*js because there are integration tests that
33
- // import/require the root package directory:
34
- "dist/*js",
35
- ],
36
- coveragePathIgnorePatterns: [
37
- "exports",
38
- "setup",
39
- "/test-utils/",
40
- "\.d.ts$",
41
- "/types/",
42
- ...otherPlatforms,
43
- ],
44
- coverageThreshold: {
45
- // As of 20250106 on linux:
46
- // % Stmts | % Branch | % Funcs | % Lines
47
- // 93.63 | 87.05 | 91.86 | 93.63
48
- // As of 20250106 on darwin:
49
- // % Stmts | % Branch | % Funcs | % Lines
50
- // 85.91 | 84.03 | 88.69 | 85.91
51
- // As of 20250106 on windows:
52
- // % Stmts | % Branch | % Funcs | % Lines
53
- // 85.91 | 84.03 | 88.69 | 85.91
54
- global: {
55
- statements: 80,
56
- branches: 80,
57
- functions: 80,
58
- lines: 80,
59
- },
60
- },
61
- };
62
-
63
- module.exports = baseConfig;