functype-os 1.21.0 → 1.21.1

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 (62) hide show
  1. package/README.md +12 -20
  2. package/dist/{ConfigResolver-p4Th3EPd.d.ts → ConfigResolver-DpDKZFFL.d.ts} +8 -6
  3. package/dist/{ConfigSource-D8Fi6vaG.d.ts → ConfigSource-BiNVyOgc.d.ts} +3 -1
  4. package/dist/{Env-eeHQ5oLF.d.ts → Env-CYRuNIYH.d.ts} +4 -2
  5. package/dist/{Fs-BkxuVfog.d.ts → Fs-CPL0SxYV.d.ts} +17 -15
  6. package/dist/{Layered-plQosjhw.d.ts → Layered-Bep7VzdC.d.ts} +4 -2
  7. package/dist/{PathExpander-Czw7TQBj.d.ts → PathExpander-DeA4vwTt.d.ts} +4 -2
  8. package/dist/{Platform-CxcnVBOy.d.ts → Platform-ceKNPX6R.d.ts} +3 -1
  9. package/dist/{Process-BqMq_szA.d.ts → Process-DsE1sS2Y.d.ts} +6 -4
  10. package/dist/{ProcessEnvSource-2Kv8VieC.d.ts → ProcessEnvSource-X4vDsn43.d.ts} +4 -2
  11. package/dist/{StaticSource-BgPzc1hx.d.ts → StaticSource-Bg-cIAL0.d.ts} +4 -2
  12. package/dist/{bootDiagnostics-CbmGG6s_.d.ts → bootDiagnostics-COdBMdp4.d.ts} +4 -2
  13. package/dist/config/ConfigResolver.d.ts +1 -1
  14. package/dist/config/ConfigResolver.js +1 -1
  15. package/dist/config/ConfigResolver.js.map +1 -1
  16. package/dist/config/ConfigSource.d.ts +1 -1
  17. package/dist/config/Layered.d.ts +1 -1
  18. package/dist/config/Layered.js.map +1 -1
  19. package/dist/config/ProcessEnvSource.d.ts +1 -1
  20. package/dist/config/ProcessEnvSource.js.map +1 -1
  21. package/dist/config/StaticSource.d.ts +1 -1
  22. package/dist/config/StaticSource.js.map +1 -1
  23. package/dist/config/bootDiagnostics.d.ts +1 -1
  24. package/dist/config/bootDiagnostics.js.map +1 -1
  25. package/dist/config/colors.d.ts +2 -0
  26. package/dist/config/colors.js.map +1 -1
  27. package/dist/config/consoleBootLogger.d.ts +1 -1
  28. package/dist/config/consoleBootLogger.js.map +1 -1
  29. package/dist/config/index.d.ts +8 -8
  30. package/dist/config/mask.d.ts +1 -1
  31. package/dist/config/mask.js.map +1 -1
  32. package/dist/{consoleBootLogger-Mp3WmMYH.d.ts → consoleBootLogger-DsdYgCch.d.ts} +3 -1
  33. package/dist/env/Env.d.ts +1 -1
  34. package/dist/env/Env.js.map +1 -1
  35. package/dist/env/index.d.ts +1 -1
  36. package/dist/env/index.js +1 -1
  37. package/dist/errors/errors.d.ts +1 -1
  38. package/dist/errors/errors.js.map +1 -1
  39. package/dist/errors/index.d.ts +1 -1
  40. package/dist/errors/index.js +1 -1
  41. package/dist/{errors-BIVj3Unk.d.ts → errors-uqbMcCFM.d.ts} +3 -1
  42. package/dist/fs/Fs.d.ts +1 -1
  43. package/dist/fs/Fs.js +1 -1
  44. package/dist/fs/Fs.js.map +1 -1
  45. package/dist/fs/index.d.ts +1 -1
  46. package/dist/fs/index.js +1 -1
  47. package/dist/index.d.ts +7 -7
  48. package/dist/{mask-O-SEN-kZ.d.ts → mask-BLjNp9FP.d.ts} +3 -1
  49. package/dist/path/PathExpander.d.ts +1 -1
  50. package/dist/path/PathExpander.js.map +1 -1
  51. package/dist/path/index.d.ts +1 -1
  52. package/dist/path/index.js +1 -1
  53. package/dist/platform/Platform.d.ts +1 -1
  54. package/dist/platform/Platform.js.map +1 -1
  55. package/dist/platform/index.d.ts +1 -1
  56. package/dist/platform/index.js +1 -1
  57. package/dist/process/Process.d.ts +1 -1
  58. package/dist/process/Process.js +1 -1
  59. package/dist/process/Process.js.map +1 -1
  60. package/dist/process/index.d.ts +1 -1
  61. package/dist/process/index.js +1 -1
  62. package/package.json +7 -7
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # functype-os
2
2
 
3
- Functional OS utilities for Node.js using [functype](https://github.com/jordanburke/functype) data structures. Wraps environment variables, path expansion, filesystem operations, platform detection, and config file resolution with `Option`, `Either`, `IO`, and `List`.
3
+ Functional OS utilities for Node.js using [functype](https://github.com/jordanburke/functype) data structures. Wraps environment variables, path expansion, filesystem operations, platform detection, and config file resolution with `Option`, `Either`, `Task`, and `List`.
4
4
 
5
5
  ## Install
6
6
 
@@ -46,25 +46,17 @@ Path.isAbsolute("/abs") // true
46
46
 
47
47
  ### Fs
48
48
 
49
- Async filesystem operations return a lazy `IO`: nothing touches the disk until you call `.run()`. Each `*Sync` method returns `Either` and runs immediately.
49
+ Async filesystem operations returning `TaskResult`.
50
50
 
51
51
  ```typescript
52
52
  import { Fs } from "functype-os"
53
53
 
54
- await Fs.exists("/path/to/file").run() // Either<never, boolean>
55
- await Fs.readFile("/path/to/file").run() // Either<FsError, string>
56
- await Fs.readFileOpt("/path/to/file").run() // Either<FsError, Option<string>> (None on ENOENT)
57
- await Fs.readdir("/path/to/dir").run() // Either<FsError, List<string>>
58
-
59
- // Being IO, they compose before anything runs:
60
- const copyConfig = Fs.readFile(src)
61
- .flatMap((text) => Fs.writeFile(dest, text))
62
- .retry(2)
63
- await copyConfig.run()
54
+ await Fs.exists("/path/to/file") // TaskResult<boolean>
55
+ await Fs.readFile("/path/to/file") // TaskResult<string>
56
+ await Fs.readFileOpt("/path/to/file") // TaskResult<Option<string>> (None on ENOENT)
57
+ await Fs.readdir("/path/to/dir") // TaskResult<List<string>>
64
58
  ```
65
59
 
66
- Forgetting `.run()` is a silent no-op: `await Fs.mkdir(dir)` awaits the `IO` value itself. The `@typescript-eslint/await-thenable` rule catches it when type-aware linting is on, as it is in ts-builds' functype preset.
67
-
68
60
  ### Platform
69
61
 
70
62
  OS and container/runtime detection with lazy-cached sync checks.
@@ -97,18 +89,18 @@ import { ConfigResolver } from "functype-os"
97
89
 
98
90
  const config = await ConfigResolver.resolve({
99
91
  candidates: ["./app.toml", "~/.config/app/config.toml", "$APPDATA/app/config.toml"],
100
- }).run()
101
- // Either<never, Option<string>> — Right(Some("/home/user/.config/app/config.toml"))
92
+ })
93
+ // TaskResult<Option<string>> — Ok(Some("/home/user/.config/app/config.toml"))
102
94
 
103
95
  const required = await ConfigResolver.resolveRequired({
104
96
  candidates: ["./app.toml", "~/.config/app/config.toml"],
105
- }).run()
106
- // Either<ConfigError, string> — Left(ConfigError) if none found
97
+ })
98
+ // TaskResult<string> — Err(ConfigError) if none found
107
99
 
108
100
  const all = await ConfigResolver.resolveAll({
109
101
  candidates: ["./a.toml", "./b.toml", "./c.toml"],
110
- }).run()
111
- // Either<never, List<string>> — all existing paths
102
+ })
103
+ // TaskResult<List<string>> — all existing paths
112
104
  ```
113
105
 
114
106
  ### Errors
@@ -1,15 +1,16 @@
1
- import { t as ConfigError } from "./errors-BIVj3Unk.js";
2
- import { Either, IO, List, Option } from "functype";
1
+ import { t as ConfigError } from "./errors-uqbMcCFM.js";
2
+ import { Either, List, Option, TaskResult } from "functype";
3
+ //#region src/config/ConfigResolver.d.ts
3
4
  declare const ConfigResolver: {
4
5
  resolve: (options: {
5
6
  readonly candidates: readonly string[];
6
- }) => IO<never, never, Option<string>>;
7
+ }) => TaskResult<Option<string>>;
7
8
  resolveRequired: (options: {
8
9
  readonly candidates: readonly string[];
9
- }) => IO<never, ConfigError, string>;
10
+ }) => TaskResult<string>;
10
11
  resolveAll: (options: {
11
12
  readonly candidates: readonly string[];
12
- }) => IO<never, never, List<string>>;
13
+ }) => TaskResult<List<string>>;
13
14
  resolveSync: (options: {
14
15
  readonly candidates: readonly string[];
15
16
  }) => Option<string>;
@@ -20,5 +21,6 @@ declare const ConfigResolver: {
20
21
  readonly candidates: readonly string[];
21
22
  }) => List<string>;
22
23
  };
24
+ //#endregion
23
25
  export { ConfigResolver as t };
24
- //# sourceMappingURL=ConfigResolver-p4Th3EPd.d.ts.map
26
+ //# sourceMappingURL=ConfigResolver-DpDKZFFL.d.ts.map
@@ -1,4 +1,5 @@
1
1
  import { Option } from "functype";
2
+ //#region src/config/ConfigSource.d.ts
2
3
  /**
3
4
  * Uniform contract for config lookup.
4
5
  *
@@ -28,5 +29,6 @@ interface ConfigSource {
28
29
  readonly name: string;
29
30
  get(key: string): Option<string>;
30
31
  }
32
+ //#endregion
31
33
  export { ConfigSource as t };
32
- //# sourceMappingURL=ConfigSource-D8Fi6vaG.d.ts.map
34
+ //# sourceMappingURL=ConfigSource-BiNVyOgc.d.ts.map
@@ -1,5 +1,6 @@
1
- import { n as EnvError } from "./errors-BIVj3Unk.js";
1
+ import { n as EnvError } from "./errors-uqbMcCFM.js";
2
2
  import { Either, List, Option } from "functype";
3
+ //#region src/env/Env.d.ts
3
4
  declare const EnvConstructor: (name: string) => Option<string>;
4
5
  declare const EnvCompanion: {
5
6
  get: (name: string) => Option<string>;
@@ -10,5 +11,6 @@ declare const EnvCompanion: {
10
11
  parse: <T>(name: string, parser: (value: string) => T) => Either<EnvError, T>;
11
12
  };
12
13
  declare const Env: typeof EnvConstructor & typeof EnvCompanion;
14
+ //#endregion
13
15
  export { Env as t };
14
- //# sourceMappingURL=Env-eeHQ5oLF.d.ts.map
16
+ //# sourceMappingURL=Env-CYRuNIYH.d.ts.map
@@ -1,5 +1,6 @@
1
- import { r as FsError } from "./errors-BIVj3Unk.js";
2
- import { Either, IO, List, Option } from "functype";
1
+ import { r as FsError } from "./errors-uqbMcCFM.js";
2
+ import { Either, List, Option, TaskResult } from "functype";
3
+ //#region src/fs/Fs.d.ts
3
4
  type FileInfo = {
4
5
  readonly size: number;
5
6
  readonly isFile: boolean;
@@ -11,20 +12,20 @@ type FileInfo = {
11
12
  readonly permissions: number;
12
13
  };
13
14
  declare const Fs: {
14
- exists: (p: string) => IO<never, never, boolean>;
15
- readFile: (p: string, encoding?: BufferEncoding) => IO<never, FsError, string>;
16
- readFileOpt: (p: string, encoding?: BufferEncoding) => IO<never, FsError, Option<string>>;
17
- stat: (p: string) => IO<never, FsError, FileInfo>;
18
- copyFile: (src: string, dest: string) => IO<never, FsError, void>;
19
- rename: (oldPath: string, newPath: string) => IO<never, FsError, void>;
20
- readdir: (p: string) => IO<never, FsError, List<string>>;
21
- glob: (dir: string, pattern: string) => IO<never, FsError, List<string>>;
22
- writeFile: (p: string, data: string, encoding?: BufferEncoding) => IO<never, FsError, void>;
23
- appendFile: (p: string, data: string, encoding?: BufferEncoding) => IO<never, FsError, void>;
15
+ exists: (p: string) => TaskResult<boolean>;
16
+ readFile: (p: string, encoding?: BufferEncoding) => TaskResult<string>;
17
+ readFileOpt: (p: string, encoding?: BufferEncoding) => TaskResult<Option<string>>;
18
+ stat: (p: string) => TaskResult<FileInfo>;
19
+ copyFile: (src: string, dest: string) => TaskResult<void>;
20
+ rename: (oldPath: string, newPath: string) => TaskResult<void>;
21
+ readdir: (p: string) => TaskResult<List<string>>;
22
+ glob: (dir: string, pattern: string) => TaskResult<List<string>>;
23
+ writeFile: (p: string, data: string, encoding?: BufferEncoding) => TaskResult<void>;
24
+ appendFile: (p: string, data: string, encoding?: BufferEncoding) => TaskResult<void>;
24
25
  mkdir: (p: string, options?: {
25
26
  recursive?: boolean;
26
- }) => IO<never, FsError, void>;
27
- unlink: (p: string) => IO<never, FsError, void>;
27
+ }) => TaskResult<void>;
28
+ unlink: (p: string) => TaskResult<void>;
28
29
  existsSync: (p: string) => boolean;
29
30
  readFileSync: (p: string, encoding?: BufferEncoding) => Either<FsError, string>;
30
31
  readFileOptSync: (p: string, encoding?: BufferEncoding) => Either<FsError, Option<string>>;
@@ -39,5 +40,6 @@ declare const Fs: {
39
40
  }) => Either<FsError, void>;
40
41
  unlinkSync: (p: string) => Either<FsError, void>;
41
42
  };
43
+ //#endregion
42
44
  export { Fs as n, FileInfo as t };
43
- //# sourceMappingURL=Fs-BkxuVfog.d.ts.map
45
+ //# sourceMappingURL=Fs-CPL0SxYV.d.ts.map
@@ -1,4 +1,5 @@
1
- import { t as ConfigSource } from "./ConfigSource-D8Fi6vaG.js";
1
+ import { t as ConfigSource } from "./ConfigSource-BiNVyOgc.js";
2
+ //#region src/config/Layered.d.ts
2
3
  /**
3
4
  * First-wins composition over N `ConfigSource`s.
4
5
  *
@@ -23,5 +24,6 @@ import { t as ConfigSource } from "./ConfigSource-D8Fi6vaG.js";
23
24
  * ```
24
25
  */
25
26
  declare const Layered: (sources: readonly ConfigSource[]) => ConfigSource;
27
+ //#endregion
26
28
  export { Layered as t };
27
- //# sourceMappingURL=Layered-plQosjhw.d.ts.map
29
+ //# sourceMappingURL=Layered-Bep7VzdC.d.ts.map
@@ -1,5 +1,6 @@
1
- import { a as PathError } from "./errors-BIVj3Unk.js";
1
+ import { a as PathError } from "./errors-uqbMcCFM.js";
2
2
  import { Either } from "functype";
3
+ //#region src/path/PathExpander.d.ts
3
4
  declare const expandTilde: (p: string) => string;
4
5
  declare const expandVars: (p: string) => Either<PathError, string>;
5
6
  declare const expandPath: (p: string) => Either<PathError, string>;
@@ -14,5 +15,6 @@ declare const Path: {
14
15
  extname: (p: string) => string;
15
16
  isAbsolute: (p: string) => boolean;
16
17
  };
18
+ //#endregion
17
19
  export { expandVars as i, expandPath as n, expandTilde as r, Path as t };
18
- //# sourceMappingURL=PathExpander-Czw7TQBj.d.ts.map
20
+ //# sourceMappingURL=PathExpander-DeA4vwTt.d.ts.map
@@ -1,4 +1,5 @@
1
1
  import { List, Option } from "functype";
2
+ //#region src/platform/Platform.d.ts
2
3
  type UserInfo = {
3
4
  readonly username: string;
4
5
  readonly uid: number;
@@ -33,5 +34,6 @@ declare const Platform: {
33
34
  homeDirs: () => List<string>;
34
35
  cloudStorageDirs: (home?: string) => List<CloudStorageDir>;
35
36
  };
37
+ //#endregion
36
38
  export { UserInfo as i, CloudStorageDir as n, Platform as r, CloudProvider as t };
37
- //# sourceMappingURL=Platform-CxcnVBOy.d.ts.map
39
+ //# sourceMappingURL=Platform-ceKNPX6R.d.ts.map
@@ -1,5 +1,6 @@
1
- import { o as ProcessError } from "./errors-BIVj3Unk.js";
2
- import { Either, IO } from "functype";
1
+ import { o as ProcessError } from "./errors-uqbMcCFM.js";
2
+ import { Either, TaskResult } from "functype";
3
+ //#region src/process/Process.d.ts
3
4
  type ExecResult = {
4
5
  readonly stdout: string;
5
6
  readonly stderr: string;
@@ -9,11 +10,12 @@ declare const Process: {
9
10
  exec: (command: string, options?: {
10
11
  timeout?: number;
11
12
  cwd?: string;
12
- }) => IO<never, ProcessError, ExecResult>;
13
+ }) => TaskResult<ExecResult>;
13
14
  execSync: (command: string, options?: {
14
15
  timeout?: number;
15
16
  cwd?: string;
16
17
  }) => Either<ProcessError, ExecResult>;
17
18
  };
19
+ //#endregion
18
20
  export { Process as n, ExecResult as t };
19
- //# sourceMappingURL=Process-BqMq_szA.d.ts.map
21
+ //# sourceMappingURL=Process-DsE1sS2Y.d.ts.map
@@ -1,4 +1,5 @@
1
- import { t as ConfigSource } from "./ConfigSource-D8Fi6vaG.js";
1
+ import { t as ConfigSource } from "./ConfigSource-BiNVyOgc.js";
2
+ //#region src/config/ProcessEnvSource.d.ts
2
3
  /**
3
4
  * Built-in `ConfigSource` backed by `process.env` via the existing `Env` wrapper.
4
5
  *
@@ -10,5 +11,6 @@ import { t as ConfigSource } from "./ConfigSource-D8Fi6vaG.js";
10
11
  * ```
11
12
  */
12
13
  declare const ProcessEnvSource: () => ConfigSource;
14
+ //#endregion
13
15
  export { ProcessEnvSource as t };
14
- //# sourceMappingURL=ProcessEnvSource-2Kv8VieC.d.ts.map
16
+ //# sourceMappingURL=ProcessEnvSource-X4vDsn43.d.ts.map
@@ -1,4 +1,5 @@
1
- import { t as ConfigSource } from "./ConfigSource-D8Fi6vaG.js";
1
+ import { t as ConfigSource } from "./ConfigSource-BiNVyOgc.js";
2
+ //#region src/config/StaticSource.d.ts
2
3
  /**
3
4
  * Built-in `ConfigSource` backed by an in-memory map.
4
5
  *
@@ -14,5 +15,6 @@ import { t as ConfigSource } from "./ConfigSource-D8Fi6vaG.js";
14
15
  * ```
15
16
  */
16
17
  declare const StaticSource: (entries: Readonly<Record<string, string>>, name?: string) => ConfigSource;
18
+ //#endregion
17
19
  export { StaticSource as t };
18
- //# sourceMappingURL=StaticSource-BgPzc1hx.d.ts.map
20
+ //# sourceMappingURL=StaticSource-Bg-cIAL0.d.ts.map
@@ -1,5 +1,6 @@
1
- import { t as ConfigSource } from "./ConfigSource-D8Fi6vaG.js";
1
+ import { t as ConfigSource } from "./ConfigSource-BiNVyOgc.js";
2
2
  import { Either, List, Logger } from "functype";
3
+ //#region src/config/bootDiagnostics.d.ts
3
4
  interface MissingKey {
4
5
  readonly key: string;
5
6
  readonly required: boolean;
@@ -64,5 +65,6 @@ interface BootDiagnosticsOptions {
64
65
  * ```
65
66
  */
66
67
  declare const bootDiagnostics: (opts: BootDiagnosticsOptions) => Either<List<MissingKey>, void>;
68
+ //#endregion
67
69
  export { MissingKey as n, bootDiagnostics as r, BootDiagnosticsOptions as t };
68
- //# sourceMappingURL=bootDiagnostics-CbmGG6s_.d.ts.map
70
+ //# sourceMappingURL=bootDiagnostics-COdBMdp4.d.ts.map
@@ -1,2 +1,2 @@
1
- import { t as ConfigResolver } from "../ConfigResolver-p4Th3EPd.js";
1
+ import { t as ConfigResolver } from "../ConfigResolver-DpDKZFFL.js";
2
2
  export { ConfigResolver };
@@ -1,2 +1,2 @@
1
- import{ConfigError as e}from"../errors/errors.js";import{Fs as t}from"../fs/Fs.js";import{expandPath as n}from"../path/PathExpander.js";import{IO as r,Left as i,List as a,Option as o,Right as s}from"functype";const c=e=>n(e).fold(()=>o(void 0),e=>o(e)),l=e=>e.headOption.fold(()=>r.succeed(o(void 0)),n=>t.exists(n).flatMap(t=>t?r.succeed(o(n)):l(e.tail))),u=e=>a(e.flatMap(e=>c(e).toArray())),d={resolve:e=>l(u(e.candidates)),resolveRequired:t=>d.resolve(t).flatMap(n=>n.fold(()=>r.fail(e(t.candidates)),e=>r.succeed(e))),resolveAll:e=>r.forEach(u(e.candidates).toArray(),e=>t.exists(e).map(t=>t?[e]:[])).map(e=>a(e.flat())),resolveSync:e=>u(e.candidates).find(t.existsSync),resolveRequiredSync:t=>d.resolveSync(t).fold(()=>i(e(t.candidates)),e=>s(e)),resolveAllSync:e=>u(e.candidates).filter(t.existsSync)};export{d as ConfigResolver};
1
+ import{ConfigError as e}from"../errors/errors.js";import{Fs as t}from"../fs/Fs.js";import{expandPath as n}from"../path/PathExpander.js";import{Err as r,Left as i,List as a,Ok as o,Option as s,Right as c}from"functype";const l=e=>n(e).fold(()=>s(void 0),e=>s(e)),u=async(e,n)=>{if(n>=e.length)return s(void 0);let r=e[n],i=l(r);if(i.isNone())return u(e,n+1);let a=await t.exists(i.orThrow());return a.isOk()&&a.value?i:u(e,n+1)},d=e=>a(e.flatMap(e=>l(e).toArray())),f={resolve:async e=>{let t=await u(e.candidates,0);return o(t)},resolveRequired:async t=>{let n=await f.resolve(t);return n.isErr()?r(n.error):n.orThrow().fold(()=>Promise.resolve(r(e(t.candidates))),e=>Promise.resolve(o(e)))},resolveAll:async e=>{let n=d(e.candidates).toArray(),r=(await Promise.all(n.map(async e=>{let n=await t.exists(e);return n.isOk()&&n.value?e:null}))).filter(e=>e!==null);return o(a(r))},resolveSync:e=>d(e.candidates).find(t.existsSync),resolveRequiredSync:t=>f.resolveSync(t).fold(()=>i(e(t.candidates)),e=>c(e)),resolveAllSync:e=>d(e.candidates).filter(t.existsSync)};export{f as ConfigResolver};
2
2
  //# sourceMappingURL=ConfigResolver.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigResolver.js","names":["ConfigErrorConstructor","tryExpandPath","expandPath","candidate","Option","v","findFirstExisting","candidates","IO","Fs","head","found","presentPaths","List","c","ConfigResolver","options","ConfigError","path","perPath","Left","Right"],"sources":["../../src/config/ConfigResolver.ts"],"sourcesContent":["import type { Either } from \"functype\"\nimport { IO, Left, List, Option, Right } from \"functype\"\n\nimport type { ConfigError } from \"../errors/errors\"\nimport { ConfigError as ConfigErrorConstructor } from \"../errors/errors\"\nimport { Fs } from \"../fs/Fs\"\nimport { expandPath } from \"../path/PathExpander\"\n\nconst tryExpandPath = (candidate: string): Option<string> => {\n const result = expandPath(candidate)\n return result.fold(\n () => Option<string>(undefined),\n (v) => Option(v),\n )\n}\n\n// Checks candidates in order and stops at the first that exists.\nconst findFirstExisting = (candidates: List<string>): IO<never, never, Option<string>> =>\n candidates.headOption.fold(\n () => IO.succeed(Option<string>(undefined)),\n (head) =>\n Fs.exists(head).flatMap((found) => (found ? IO.succeed(Option(head)) : findFirstExisting(candidates.tail))),\n )\n\n// Expand each candidate; drop entries whose env variables didn't resolve.\nconst presentPaths = (candidates: readonly string[]): List<string> =>\n List<string>(candidates.flatMap((c) => tryExpandPath(c).toArray() as string[]))\n\nexport const ConfigResolver = {\n // Async methods — return a lazy IO; nothing touches the filesystem until `.run()`\n\n resolve: (options: { readonly candidates: readonly string[] }): IO<never, never, Option<string>> =>\n findFirstExisting(presentPaths(options.candidates)),\n\n resolveRequired: (options: { readonly candidates: readonly string[] }): IO<never, ConfigError, string> =>\n ConfigResolver.resolve(options).flatMap((found) =>\n found.fold<IO<never, ConfigError, string>>(\n () => IO.fail(ConfigErrorConstructor(options.candidates)),\n (path) => IO.succeed(path),\n ),\n ),\n\n // Checks paths one at a time, in order. They're a handful of config candidates, so this\n // costs nothing measurable and keeps the result order stable.\n resolveAll: (options: { readonly candidates: readonly string[] }): IO<never, never, List<string>> =>\n IO.forEach(presentPaths(options.candidates).toArray(), (path) =>\n Fs.exists(path).map((found) => (found ? [path] : [])),\n ).map((perPath) => List<string>(perPath.flat())),\n\n // Sync methods — return Either<ConfigError, T>\n\n resolveSync: (options: { readonly candidates: readonly string[] }): Option<string> =>\n presentPaths(options.candidates).find(Fs.existsSync),\n\n resolveRequiredSync: (options: { readonly candidates: readonly string[] }): Either<ConfigError, string> => {\n const result = ConfigResolver.resolveSync(options)\n return result.fold(\n () => Left(ConfigErrorConstructor(options.candidates)),\n (v) => Right(v),\n )\n },\n\n resolveAllSync: (options: { readonly candidates: readonly string[] }): List<string> =>\n presentPaths(options.candidates).filter(Fs.existsSync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tryExpandPath","expandPath","candidate","Option","v","findFirstExistingAsync","startIndex","candidates","expanded","existsResult","Fs","presentPaths","List","c","ConfigResolver","found","options","Ok","result","Err","ConfigError","r","p","Left","Right"],"sources":["../../src/config/ConfigResolver.ts"],"sourcesContent":["import type { Either, TaskResult } from \"functype\"\nimport { Err, Left, List, Ok, Option, Right } from \"functype\"\n\nimport type { ConfigError } from \"../errors/errors\"\nimport { ConfigError as ConfigErrorConstructor } from \"../errors/errors\"\nimport { Fs } from \"../fs/Fs\"\nimport { expandPath } from \"../path/PathExpander\"\n\nconst tryExpandPath = (candidate: string): Option<string> => {\n const result = expandPath(candidate)\n return result.fold(\n () => Option<string>(undefined),\n (v) => Option(v),\n )\n}\n\nconst findFirstExistingAsync = async (candidates: readonly string[], startIndex: number): Promise<Option<string>> => {\n if (startIndex >= candidates.length) return Option<string>(undefined)\n const candidate = candidates[startIndex] as string\n const expanded = tryExpandPath(candidate)\n if (expanded.isNone()) return findFirstExistingAsync(candidates, startIndex + 1)\n const existsResult = await Fs.exists(expanded.orThrow())\n if (existsResult.isOk() && existsResult.value) return expanded\n return findFirstExistingAsync(candidates, startIndex + 1)\n}\n\n// Expand each candidate; drop entries whose env variables didn't resolve.\nconst presentPaths = (candidates: readonly string[]): List<string> =>\n List<string>(candidates.flatMap((c) => tryExpandPath(c).toArray() as string[]))\n\nexport const ConfigResolver = {\n // Async methods — return TaskResult<T>\n\n resolve: async (options: { readonly candidates: readonly string[] }): TaskResult<Option<string>> => {\n const found = await findFirstExistingAsync(options.candidates, 0)\n return Ok(found)\n },\n\n resolveRequired: async (options: { readonly candidates: readonly string[] }): TaskResult<string> => {\n const result = await ConfigResolver.resolve(options)\n if (result.isErr()) return Err(result.error)\n\n return result.orThrow().fold<TaskResult<string>>(\n () => Promise.resolve(Err(ConfigErrorConstructor(options.candidates))),\n (v) => Promise.resolve(Ok(v)),\n )\n },\n\n resolveAll: async (options: { readonly candidates: readonly string[] }): TaskResult<List<string>> => {\n const expanded = presentPaths(options.candidates).toArray()\n const checks = await Promise.all(\n expanded.map(async (p): Promise<string | null> => {\n const r = await Fs.exists(p)\n return r.isOk() && r.value ? p : null\n }),\n )\n const found = checks.filter((p): p is string => p !== null)\n return Ok(List<string>(found))\n },\n\n // Sync methods — return Either<ConfigError, T>\n\n resolveSync: (options: { readonly candidates: readonly string[] }): Option<string> =>\n presentPaths(options.candidates).find(Fs.existsSync),\n\n resolveRequiredSync: (options: { readonly candidates: readonly string[] }): Either<ConfigError, string> => {\n const result = ConfigResolver.resolveSync(options)\n return result.fold(\n () => Left(ConfigErrorConstructor(options.candidates)),\n (v) => Right(v),\n )\n },\n\n resolveAllSync: (options: { readonly candidates: readonly string[] }): List<string> =>\n presentPaths(options.candidates).filter(Fs.existsSync),\n}\n"],"mappings":"0NAQA,MAAMC,EAAiB,GACNC,EAAWC,CACd,CAAC,CAAC,SACNC,EAAe,IAAA,EAAS,EAC7B,GAAMA,EAAOC,CAAC,CACjB,EAGIC,EAAyB,MAAO,EAA+B,IAAgD,CACnH,GAAIC,GAAcC,EAAW,OAAQ,OAAOJ,EAAe,IAAA,EAAS,EACpE,IAAMD,EAAYK,EAAWD,GACvBE,EAAWR,EAAcE,CAAS,EACxC,GAAIM,EAAS,OAAO,EAAG,OAAOH,EAAuBE,EAAYD,EAAa,CAAC,EAC/E,IAAMG,EAAe,MAAMC,EAAG,OAAOF,EAAS,QAAQ,CAAC,EAEvD,OADIC,EAAa,KAAK,GAAKA,EAAa,MAAcD,EAC/CH,EAAuBE,EAAYD,EAAa,CAAC,CAC1D,EAGMK,EAAgB,GACpBC,EAAaL,EAAW,QAAS,GAAMP,EAAca,CAAC,CAAC,CAAC,QAAQ,CAAa,CAAC,EAEnEC,EAAiB,CAG5B,QAAS,KAAO,IAAoF,CAClG,IAAMC,EAAQ,MAAMV,EAAuBW,EAAQ,WAAY,CAAC,EAChE,OAAOC,EAAGF,CAAK,CACjB,EAEA,gBAAiB,KAAO,IAA4E,CAClG,IAAMG,EAAS,MAAMJ,EAAe,QAAQE,CAAO,EAGnD,OAFIE,EAAO,MAAM,EAAUC,EAAID,EAAO,KAAK,EAEpCA,EAAO,QAAQ,CAAC,CAAC,SAChB,QAAQ,QAAQC,EAAIpB,EAAuBiB,EAAQ,UAAU,CAAC,CAAC,EACpE,GAAM,QAAQ,QAAQC,EAAGb,CAAC,CAAC,CAC9B,CACF,EAEA,WAAY,KAAO,IAAkF,CACnG,IAAMI,EAAWG,EAAaK,EAAQ,UAAU,CAAC,CAAC,QAAQ,EAOpDD,GAAQ,MANO,QAAQ,IAC3BP,EAAS,IAAI,KAAO,IAA8B,CAChD,IAAMa,EAAI,MAAMX,EAAG,OAAOY,CAAC,EAC3B,OAAOD,EAAE,KAAK,GAAKA,EAAE,MAAQC,EAAI,IACnC,CAAC,CACH,EAAA,CACqB,OAAQ,GAAmBA,IAAM,IAAI,EAC1D,OAAOL,EAAGL,EAAaG,CAAK,CAAC,CAC/B,EAIA,YAAc,GACZJ,EAAaK,EAAQ,UAAU,CAAC,CAAC,KAAKN,EAAG,UAAU,EAErD,oBAAsB,GACLI,EAAe,YAAYE,CAC9B,CAAC,CAAC,SACNO,EAAKxB,EAAuBiB,EAAQ,UAAU,CAAC,EACpD,GAAMQ,EAAMpB,CAAC,CAChB,EAGF,eAAiB,GACfO,EAAaK,EAAQ,UAAU,CAAC,CAAC,OAAON,EAAG,UAAU,CACzD"}
@@ -1,2 +1,2 @@
1
- import { t as ConfigSource } from "../ConfigSource-D8Fi6vaG.js";
1
+ import { t as ConfigSource } from "../ConfigSource-BiNVyOgc.js";
2
2
  export { ConfigSource };
@@ -1,2 +1,2 @@
1
- import { t as Layered } from "../Layered-plQosjhw.js";
1
+ import { t as Layered } from "../Layered-Bep7VzdC.js";
2
2
  export { Layered };
@@ -1 +1 @@
1
- {"version":3,"file":"Layered.js","names":["OptionCtor","Layered","sources","s","acc","source","key","Option"],"sources":["../../src/config/Layered.ts"],"sourcesContent":["import type { Option } from \"functype\"\nimport { Option as OptionCtor } from \"functype\"\n\nimport type { ConfigSource } from \"./ConfigSource\"\n\n/**\n * First-wins composition over N `ConfigSource`s.\n *\n * Lookup walks the sources in order and returns the first `Some(value)` it\n * finds. Falls through to the next source when one returns `None`. The\n * composed source's `name` reflects the resolution chain\n * (e.g. `\"process.env > infisical > defaults\"`) so `bootDiagnostics` can echo\n * it in its header.\n *\n * Sensitivity (which keys to mask) is declared at diagnostics time, not at\n * source time — a `Layered([env, vault])` is structurally identical to any\n * other `ConfigSource`.\n *\n * @example\n * ```ts\n * const config = Layered([\n * ProcessEnvSource(),\n * await InfisicalSource({ token, env, projectId }),\n * StaticSource({ ENV: \"local\" }, \"defaults\"),\n * ])\n * // config.name === \"process.env > infisical > defaults\"\n * ```\n */\nexport const Layered = (sources: readonly ConfigSource[]): ConfigSource => ({\n name: sources.map((s) => s.name).join(\" > \"),\n get: (key) =>\n sources.reduce<Option<string>>(\n (acc, source) =>\n acc.fold(\n () => source.get(key),\n () => acc,\n ),\n OptionCtor<string>(undefined),\n ),\n})\n"],"mappings":"A,kCA4BA,MAAaC,EAAW,IAAoD,CAC1E,KAAMC,EAAQ,IAAK,GAAMC,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,EAC3C,IAAM,GACJD,EAAQ,QACL,EAAK,IACJE,EAAI,SACIC,EAAO,IAAIC,CAAG,MACdF,CACR,EACFJ,EAAmB,IAAA,EAAS,CAC9B,CACJ,G"}
1
+ {"version":3,"file":"Layered.js","names":["OptionCtor","Layered","sources","s","acc","source","key","Option"],"sources":["../../src/config/Layered.ts"],"sourcesContent":["import type { Option } from \"functype\"\nimport { Option as OptionCtor } from \"functype\"\n\nimport type { ConfigSource } from \"./ConfigSource\"\n\n/**\n * First-wins composition over N `ConfigSource`s.\n *\n * Lookup walks the sources in order and returns the first `Some(value)` it\n * finds. Falls through to the next source when one returns `None`. The\n * composed source's `name` reflects the resolution chain\n * (e.g. `\"process.env > infisical > defaults\"`) so `bootDiagnostics` can echo\n * it in its header.\n *\n * Sensitivity (which keys to mask) is declared at diagnostics time, not at\n * source time — a `Layered([env, vault])` is structurally identical to any\n * other `ConfigSource`.\n *\n * @example\n * ```ts\n * const config = Layered([\n * ProcessEnvSource(),\n * await InfisicalSource({ token, env, projectId }),\n * StaticSource({ ENV: \"local\" }, \"defaults\"),\n * ])\n * // config.name === \"process.env > infisical > defaults\"\n * ```\n */\nexport const Layered = (sources: readonly ConfigSource[]): ConfigSource => ({\n name: sources.map((s) => s.name).join(\" > \"),\n get: (key) =>\n sources.reduce<Option<string>>(\n (acc, source) =>\n acc.fold(\n () => source.get(key),\n () => acc,\n ),\n OptionCtor<string>(undefined),\n ),\n})\n"],"mappings":"kCA4BA,MAAaC,EAAW,IAAoD,CAC1E,KAAMC,EAAQ,IAAK,GAAMC,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,EAC3C,IAAM,GACJD,EAAQ,QACL,EAAK,IACJE,EAAI,SACIC,EAAO,IAAIC,CAAG,MACdF,CACR,EACFJ,EAAmB,IAAA,EAAS,CAC9B,CACJ"}
@@ -1,2 +1,2 @@
1
- import { t as ProcessEnvSource } from "../ProcessEnvSource-2Kv8VieC.js";
1
+ import { t as ProcessEnvSource } from "../ProcessEnvSource-X4vDsn43.js";
2
2
  export { ProcessEnvSource };
@@ -1 +1 @@
1
- {"version":3,"file":"ProcessEnvSource.js","names":["ProcessEnvSource","Env","key"],"sources":["../../src/config/ProcessEnvSource.ts"],"sourcesContent":["import { Env } from \"../env/Env\"\nimport type { ConfigSource } from \"./ConfigSource\"\n\n/**\n * Built-in `ConfigSource` backed by `process.env` via the existing `Env` wrapper.\n *\n * Use as the first layer of a `Layered` chain so env vars override vault and\n * default values:\n *\n * ```ts\n * const config = Layered([ProcessEnvSource(), await InfisicalSource(...), StaticSource(defaults)])\n * ```\n */\nexport const ProcessEnvSource = (): ConfigSource => ({\n name: \"process.env\",\n get: (key) => Env(key),\n})\n"],"mappings":"A,oCAaA,MAAaA,OAAwC,CACnD,KAAM,cACN,IAAM,GAAQC,EAAIC,CAAG,CACvB,G"}
1
+ {"version":3,"file":"ProcessEnvSource.js","names":["ProcessEnvSource","Env","key"],"sources":["../../src/config/ProcessEnvSource.ts"],"sourcesContent":["import { Env } from \"../env/Env\"\nimport type { ConfigSource } from \"./ConfigSource\"\n\n/**\n * Built-in `ConfigSource` backed by `process.env` via the existing `Env` wrapper.\n *\n * Use as the first layer of a `Layered` chain so env vars override vault and\n * default values:\n *\n * ```ts\n * const config = Layered([ProcessEnvSource(), await InfisicalSource(...), StaticSource(defaults)])\n * ```\n */\nexport const ProcessEnvSource = (): ConfigSource => ({\n name: \"process.env\",\n get: (key) => Env(key),\n})\n"],"mappings":"oCAaA,MAAaA,OAAwC,CACnD,KAAM,cACN,IAAM,GAAQC,EAAIC,CAAG,CACvB"}
@@ -1,2 +1,2 @@
1
- import { t as StaticSource } from "../StaticSource-BgPzc1hx.js";
1
+ import { t as StaticSource } from "../StaticSource-Bg-cIAL0.js";
2
2
  export { StaticSource };
@@ -1 +1 @@
1
- {"version":3,"file":"StaticSource.js","names":["StaticSource","Option","entries","key"],"sources":["../../src/config/StaticSource.ts"],"sourcesContent":["import { Option } from \"functype\"\n\nimport type { ConfigSource } from \"./ConfigSource\"\n\n/**\n * Built-in `ConfigSource` backed by an in-memory map.\n *\n * Useful for default values, test fixtures, or any static config layer that\n * doesn't need an external lookup. The `name` argument defaults to `\"static\"`\n * but should be set when composing multiple static sources for clearer\n * diagnostics output.\n *\n * @example\n * ```ts\n * const defaults = StaticSource({ ENV: \"local\", PORT: \"3000\" }, \"defaults\")\n * const config = Layered([ProcessEnvSource(), defaults])\n * ```\n */\nexport const StaticSource = (entries: Readonly<Record<string, string>>, name = \"static\"): ConfigSource => ({\n name,\n get: (key) => Option(entries[key]),\n})\n"],"mappings":"A,kCAkBA,MAAaA,GAAgB,EAA2C,EAAO,YAA4B,CACzG,OACA,IAAM,GAAQC,EAAOC,EAAQC,EAAI,CACnC,G"}
1
+ {"version":3,"file":"StaticSource.js","names":["StaticSource","Option","entries","key"],"sources":["../../src/config/StaticSource.ts"],"sourcesContent":["import { Option } from \"functype\"\n\nimport type { ConfigSource } from \"./ConfigSource\"\n\n/**\n * Built-in `ConfigSource` backed by an in-memory map.\n *\n * Useful for default values, test fixtures, or any static config layer that\n * doesn't need an external lookup. The `name` argument defaults to `\"static\"`\n * but should be set when composing multiple static sources for clearer\n * diagnostics output.\n *\n * @example\n * ```ts\n * const defaults = StaticSource({ ENV: \"local\", PORT: \"3000\" }, \"defaults\")\n * const config = Layered([ProcessEnvSource(), defaults])\n * ```\n */\nexport const StaticSource = (entries: Readonly<Record<string, string>>, name = \"static\"): ConfigSource => ({\n name,\n get: (key) => Option(entries[key]),\n})\n"],"mappings":"kCAkBA,MAAaA,GAAgB,EAA2C,EAAO,YAA4B,CACzG,OACA,IAAM,GAAQC,EAAOC,EAAQC,EAAI,CACnC"}
@@ -1,2 +1,2 @@
1
- import { n as MissingKey, r as bootDiagnostics, t as BootDiagnosticsOptions } from "../bootDiagnostics-CbmGG6s_.js";
1
+ import { n as MissingKey, r as bootDiagnostics, t as BootDiagnosticsOptions } from "../bootDiagnostics-COdBMdp4.js";
2
2
  export { BootDiagnosticsOptions, MissingKey, bootDiagnostics };
@@ -1 +1 @@
1
- {"version":3,"file":"bootDiagnostics.js","names":["bootDiagnostics","logger","opts","consoleBootLogger","required","sensitive","publicKeys","blue","missing","k","yellow","display","key","red","maskValue","v","green","vaultEnv","vaultEnvKey","hostEnv","magenta","Right","missingList","List","Left"],"sources":["../../src/config/bootDiagnostics.ts"],"sourcesContent":["import type { Either, List as ListType, Logger } from \"functype\"\nimport { Left, List, Right } from \"functype\"\n\nimport { blue, green, magenta, red, yellow } from \"./colors\"\nimport type { ConfigSource } from \"./ConfigSource\"\nimport { consoleBootLogger } from \"./consoleBootLogger\"\nimport { maskValue } from \"./mask\"\n\nexport interface MissingKey {\n readonly key: string\n readonly required: boolean\n}\n\nexport interface BootDiagnosticsOptions {\n /** The composed `ConfigSource` to inspect. */\n readonly source: ConfigSource\n /** Keys that MUST be present. Missing required keys produce a `Left`. */\n readonly required?: readonly string[]\n /** Keys to log with masked values (via {@link maskValue}). */\n readonly sensitive?: readonly string[]\n /** Keys to log with raw values. */\n readonly public?: readonly string[]\n /**\n * If provided with `vaultEnvKey`, compares the host environment string\n * (e.g. `process.env.NODE_ENV`) against the value at `vaultEnvKey` in the\n * source. Logs `✓` on match, an error-level message on mismatch.\n */\n readonly hostEnv?: string\n readonly vaultEnvKey?: string\n /**\n * `\"missing\"` triggers `process.exit(1)` after logging when any required key\n * is missing. `\"never\"` (default) returns `Left(missing)` and lets the caller\n * decide. Set to `\"missing\"` in production / staging boot paths to guarantee\n * fail-fast on misconfiguration.\n */\n readonly failOn?: \"missing\" | \"never\"\n /**\n * Logger to use. Defaults to {@link consoleBootLogger}. Any value satisfying\n * the core `Logger` interface from `functype` — including `DirectLogger`\n * from `functype-log/direct` — works without an adapter.\n */\n readonly logger?: Logger\n /** Service identifier shown in the diagnostics header. */\n readonly serviceName?: string\n}\n\n/**\n * Log a standardized boot diagnostics block and verify required-key presence.\n *\n * The block always emits, regardless of outcome — operational visibility (\"did\n * the deploy pick up my config?\") is the point. Sensitive keys are masked;\n * public keys are logged verbatim. An optional host-vs-vault env-mismatch\n * check catches the common deploy footgun where the host's `NODE_ENV` and the\n * vault's `ENV` (or equivalent) diverge.\n *\n * Returns `Either<List<MissingKey>, void>` so non-fatal callers can inspect\n * the result. Setting `failOn: \"missing\"` short-circuits to `process.exit(1)`\n * for production guards.\n *\n * @example\n * ```ts\n * const result = bootDiagnostics({\n * serviceName: \"cq-api\",\n * source: Layered([ProcessEnvSource(), await InfisicalSource(...)]),\n * required: [\"SUPABASE_URL\", \"SUPABASE_KEY\", \"OPENAI_API_KEY\"],\n * sensitive: [\"SUPABASE_URL\", \"SUPABASE_KEY\", \"OPENAI_API_KEY\"],\n * public: [\"ENV\", \"ENABLE_CHAT\"],\n * hostEnv: process.env.NODE_ENV ?? \"local\",\n * vaultEnvKey: \"ENV\",\n * failOn: process.env.NODE_ENV === \"production\" ? \"missing\" : \"never\",\n * })\n * ```\n */\nexport const bootDiagnostics = (opts: BootDiagnosticsOptions): Either<ListType<MissingKey>, void> => {\n const logger = opts.logger ?? consoleBootLogger\n const required = opts.required ?? []\n const sensitive = opts.sensitive ?? []\n const publicKeys = opts.public ?? []\n\n logger.info(`${blue(\"📦\")} Boot diagnostics: ${opts.serviceName ?? \"service\"}`)\n logger.info(` source: ${opts.source.name}`)\n\n const missing = required.filter((k) => opts.source.get(k).isEmpty)\n\n if (sensitive.length > 0) {\n logger.info(yellow(\"🔐 Sensitive:\"))\n sensitive.forEach((key) => {\n const value = opts.source.get(key)\n const display = value.fold(\n () => red(\"NOT_LOADED\"),\n (v) => maskValue(v),\n )\n logger.info(` ${key.padEnd(28)} ${display}`)\n })\n }\n\n if (publicKeys.length > 0) {\n logger.info(green(\"⚙️ Public:\"))\n publicKeys.forEach((key) => {\n const value = opts.source.get(key)\n const display = value.fold(\n () => red(\"NOT_LOADED\"),\n (v) => v,\n )\n logger.info(` ${key.padEnd(28)} ${display}`)\n })\n }\n\n if (opts.hostEnv !== undefined && opts.vaultEnvKey !== undefined) {\n const vaultEnv = opts.source.get(opts.vaultEnvKey)\n const { hostEnv } = opts\n const { vaultEnvKey } = opts\n vaultEnv.fold(\n () => {\n logger.warn(`Vault env key '${vaultEnvKey}' not present — skipping mismatch check`)\n return undefined\n },\n (v) => {\n if (v === hostEnv) {\n logger.info(`${magenta(\"🌍\")} Environment: ${hostEnv} (host) ↔ ${v} (vault) ${green(\"✓\")}`)\n } else {\n logger.error(`${magenta(\"🌍\")} Environment MISMATCH: host=${hostEnv} vault=${v}`, {\n hostEnv,\n vaultEnv: v,\n })\n }\n return undefined\n },\n )\n }\n\n if (missing.length === 0) {\n logger.info(green(\"✅ All required keys present\"))\n return Right<ListType<MissingKey>, void>(undefined)\n }\n\n logger.error(red(`❌ Missing required keys (${missing.length}):`))\n missing.forEach((key) => logger.error(` ${key}`))\n\n const missingList = List(missing.map((key): MissingKey => ({ key, required: true })))\n\n if (opts.failOn === \"missing\") {\n process.exit(1)\n }\n return Left<ListType<MissingKey>, void>(missingList)\n}\n"],"mappings":"A,sOAyEA,MAAaA,EAAmB,GAAqE,CACnG,IAAMC,EAASC,EAAK,QAAUC,EACxBC,EAAWF,EAAK,UAAY,CAAC,EAC7BG,EAAYH,EAAK,WAAa,CAAC,EAC/BI,EAAaJ,EAAK,QAAU,CAAC,EAEnCD,EAAO,KAAK,GAAGM,EAAK,IAAI,EAAE,qBAAqBL,EAAK,aAAe,WAAW,EAC9ED,EAAO,KAAK,cAAcC,EAAK,OAAO,MAAM,EAE5C,IAAMM,EAAUJ,EAAS,OAAQ,GAAMF,EAAK,OAAO,IAAIO,CAAC,CAAC,CAAC,OAAO,EA0BjE,GAxBIJ,EAAU,OAAS,IACrBJ,EAAO,KAAKS,EAAO,eAAe,CAAC,EACnCL,EAAU,QAAS,GAAQ,CAEzB,IAAMM,EADQT,EAAK,OAAO,IAAIU,CACV,CAAC,CAAC,SACdC,EAAI,YAAY,EACrB,GAAMC,EAAUC,CAAC,CACpB,EACAd,EAAO,KAAK,MAAMW,EAAI,OAAO,EAAE,EAAE,GAAGD,GAAS,CAC/C,CAAC,GAGCL,EAAW,OAAS,IACtBL,EAAO,KAAKe,EAAM,aAAa,CAAC,EAChCV,EAAW,QAAS,GAAQ,CAE1B,IAAMK,EADQT,EAAK,OAAO,IAAIU,CACV,CAAC,CAAC,SACdC,EAAI,YAAY,EACrB,GAAME,CACT,EACAd,EAAO,KAAK,MAAMW,EAAI,OAAO,EAAE,EAAE,GAAGD,GAAS,CAC/C,CAAC,GAGCT,EAAK,UAAY,IAAA,IAAaA,EAAK,cAAgB,IAAA,GAAW,CAChE,IAAMe,EAAWf,EAAK,OAAO,IAAIA,EAAK,WAAW,EAC3C,CAAE,WAAYA,EACd,CAAE,eAAgBA,EACxBe,EAAS,SACD,CACJhB,EAAO,KAAK,kBAAkBiB,EAAY,wCAAwC,CAEpF,EACC,GAAM,CACDH,IAAMI,EACRlB,EAAO,KAAK,GAAGmB,EAAQ,IAAI,EAAE,gBAAgBD,EAAQ,YAAYJ,EAAE,WAAWC,EAAM,GAAG,GAAG,EAE1Ff,EAAO,MAAM,GAAGmB,EAAQ,IAAI,EAAE,8BAA8BD,EAAQ,SAASJ,IAAK,CAChF,UACA,SAAUA,CACZ,CAAC,CAGL,CACF,CACF,CAEA,GAAIP,EAAQ,SAAW,EAErB,OADAP,EAAO,KAAKe,EAAM,6BAA6B,CAAC,EACzCK,EAAkC,IAAA,EAAS,EAGpDpB,EAAO,MAAMY,EAAI,4BAA4BL,EAAQ,OAAO,GAAG,CAAC,EAChEA,EAAQ,QAAS,GAAQP,EAAO,MAAM,MAAMW,GAAK,CAAC,EAElD,IAAMU,EAAcC,EAAKf,EAAQ,IAAK,IAAqB,CAAE,MAAK,SAAU,EAAK,EAAE,CAAC,EAKpF,OAHIN,EAAK,SAAW,WAClB,QAAQ,KAAK,CAAC,EAETsB,EAAiCF,CAAW,CACrD,E"}
1
+ {"version":3,"file":"bootDiagnostics.js","names":["bootDiagnostics","logger","opts","consoleBootLogger","required","sensitive","publicKeys","blue","missing","k","yellow","display","key","red","maskValue","v","green","vaultEnv","vaultEnvKey","hostEnv","magenta","Right","missingList","List","Left"],"sources":["../../src/config/bootDiagnostics.ts"],"sourcesContent":["import type { Either, List as ListType, Logger } from \"functype\"\nimport { Left, List, Right } from \"functype\"\n\nimport { blue, green, magenta, red, yellow } from \"./colors\"\nimport type { ConfigSource } from \"./ConfigSource\"\nimport { consoleBootLogger } from \"./consoleBootLogger\"\nimport { maskValue } from \"./mask\"\n\nexport interface MissingKey {\n readonly key: string\n readonly required: boolean\n}\n\nexport interface BootDiagnosticsOptions {\n /** The composed `ConfigSource` to inspect. */\n readonly source: ConfigSource\n /** Keys that MUST be present. Missing required keys produce a `Left`. */\n readonly required?: readonly string[]\n /** Keys to log with masked values (via {@link maskValue}). */\n readonly sensitive?: readonly string[]\n /** Keys to log with raw values. */\n readonly public?: readonly string[]\n /**\n * If provided with `vaultEnvKey`, compares the host environment string\n * (e.g. `process.env.NODE_ENV`) against the value at `vaultEnvKey` in the\n * source. Logs `✓` on match, an error-level message on mismatch.\n */\n readonly hostEnv?: string\n readonly vaultEnvKey?: string\n /**\n * `\"missing\"` triggers `process.exit(1)` after logging when any required key\n * is missing. `\"never\"` (default) returns `Left(missing)` and lets the caller\n * decide. Set to `\"missing\"` in production / staging boot paths to guarantee\n * fail-fast on misconfiguration.\n */\n readonly failOn?: \"missing\" | \"never\"\n /**\n * Logger to use. Defaults to {@link consoleBootLogger}. Any value satisfying\n * the core `Logger` interface from `functype` — including `DirectLogger`\n * from `functype-log/direct` — works without an adapter.\n */\n readonly logger?: Logger\n /** Service identifier shown in the diagnostics header. */\n readonly serviceName?: string\n}\n\n/**\n * Log a standardized boot diagnostics block and verify required-key presence.\n *\n * The block always emits, regardless of outcome — operational visibility (\"did\n * the deploy pick up my config?\") is the point. Sensitive keys are masked;\n * public keys are logged verbatim. An optional host-vs-vault env-mismatch\n * check catches the common deploy footgun where the host's `NODE_ENV` and the\n * vault's `ENV` (or equivalent) diverge.\n *\n * Returns `Either<List<MissingKey>, void>` so non-fatal callers can inspect\n * the result. Setting `failOn: \"missing\"` short-circuits to `process.exit(1)`\n * for production guards.\n *\n * @example\n * ```ts\n * const result = bootDiagnostics({\n * serviceName: \"cq-api\",\n * source: Layered([ProcessEnvSource(), await InfisicalSource(...)]),\n * required: [\"SUPABASE_URL\", \"SUPABASE_KEY\", \"OPENAI_API_KEY\"],\n * sensitive: [\"SUPABASE_URL\", \"SUPABASE_KEY\", \"OPENAI_API_KEY\"],\n * public: [\"ENV\", \"ENABLE_CHAT\"],\n * hostEnv: process.env.NODE_ENV ?? \"local\",\n * vaultEnvKey: \"ENV\",\n * failOn: process.env.NODE_ENV === \"production\" ? \"missing\" : \"never\",\n * })\n * ```\n */\nexport const bootDiagnostics = (opts: BootDiagnosticsOptions): Either<ListType<MissingKey>, void> => {\n const logger = opts.logger ?? consoleBootLogger\n const required = opts.required ?? []\n const sensitive = opts.sensitive ?? []\n const publicKeys = opts.public ?? []\n\n logger.info(`${blue(\"📦\")} Boot diagnostics: ${opts.serviceName ?? \"service\"}`)\n logger.info(` source: ${opts.source.name}`)\n\n const missing = required.filter((k) => opts.source.get(k).isEmpty)\n\n if (sensitive.length > 0) {\n logger.info(yellow(\"🔐 Sensitive:\"))\n sensitive.forEach((key) => {\n const value = opts.source.get(key)\n const display = value.fold(\n () => red(\"NOT_LOADED\"),\n (v) => maskValue(v),\n )\n logger.info(` ${key.padEnd(28)} ${display}`)\n })\n }\n\n if (publicKeys.length > 0) {\n logger.info(green(\"⚙️ Public:\"))\n publicKeys.forEach((key) => {\n const value = opts.source.get(key)\n const display = value.fold(\n () => red(\"NOT_LOADED\"),\n (v) => v,\n )\n logger.info(` ${key.padEnd(28)} ${display}`)\n })\n }\n\n if (opts.hostEnv !== undefined && opts.vaultEnvKey !== undefined) {\n const vaultEnv = opts.source.get(opts.vaultEnvKey)\n const { hostEnv } = opts\n const { vaultEnvKey } = opts\n vaultEnv.fold(\n () => {\n logger.warn(`Vault env key '${vaultEnvKey}' not present — skipping mismatch check`)\n return undefined\n },\n (v) => {\n if (v === hostEnv) {\n logger.info(`${magenta(\"🌍\")} Environment: ${hostEnv} (host) ↔ ${v} (vault) ${green(\"✓\")}`)\n } else {\n logger.error(`${magenta(\"🌍\")} Environment MISMATCH: host=${hostEnv} vault=${v}`, {\n hostEnv,\n vaultEnv: v,\n })\n }\n return undefined\n },\n )\n }\n\n if (missing.length === 0) {\n logger.info(green(\"✅ All required keys present\"))\n return Right<ListType<MissingKey>, void>(undefined)\n }\n\n logger.error(red(`❌ Missing required keys (${missing.length}):`))\n missing.forEach((key) => logger.error(` ${key}`))\n\n const missingList = List(missing.map((key): MissingKey => ({ key, required: true })))\n\n if (opts.failOn === \"missing\") {\n process.exit(1)\n }\n return Left<ListType<Miss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AQ,YAAYJ,EAAE,WAAWC,EAAM,GAAG,GAAG,EAE1Ff,EAAO,MAAM,GAAGmB,EAAQ,IAAI,EAAE,8BAA8BD,EAAQ,SAASJ,IAAK,CAChF,UACA,SAAUA,CACZ,CAAC,CAGL,CACF,CACF,CAEA,GAAIP,EAAQ,SAAW,EAErB,OADAP,EAAO,KAAKe,EAAM,6BAA6B,CAAC,EACzCK,EAAkC,IAAA,EAAS,EAGpDpB,EAAO,MAAMY,EAAI,4BAA4BL,EAAQ,OAAO,GAAG,CAAC,EAChEA,EAAQ,QAAS,GAAQP,EAAO,MAAM,MAAMW,GAAK,CAAC,EAElD,IAAMU,EAAcC,EAAKf,EAAQ,IAAK,IAAqB,CAAE,MAAK,SAAU,EAAK,EAAE,CAAC,EAKpF,OAHIN,EAAK,SAAW,WAClB,QAAQ,KAAK,CAAC,EAETsB,EAAiCF,CAAW,CACrD"}
@@ -1,3 +1,4 @@
1
+ //#region src/config/colors.d.ts
1
2
  /**
2
3
  * Internal raw-ANSI color helpers for boot diagnostics output.
3
4
  *
@@ -19,4 +20,5 @@ export declare const blue: (s: string) => string;
19
20
  export declare const magenta: (s: string) => string;
20
21
  export declare const cyan: (s: string) => string;
21
22
  export declare const gray: (s: string) => string;
23
+ //#endregion
22
24
  //# sourceMappingURL=colors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"colors.js","names":["shouldColor","wrap","code","s","red","green","yellow","blue","magenta","cyan","gray"],"sources":["../../src/config/colors.ts"],"sourcesContent":["/**\n * Internal raw-ANSI color helpers for boot diagnostics output.\n *\n * Respects established conventions:\n * - `NO_COLOR=1` (any value) → output uncolored, regardless of TTY. See\n * https://no-color.org/.\n * - `FORCE_COLOR=1` (any value) → output colored, regardless of TTY. Useful\n * for CI logs that pipe stdout but want the colors preserved.\n * - Default: color when `process.stdout.isTTY`, plain otherwise.\n *\n * Zero deps. ANSI escape codes haven't changed since 1979.\n *\n * @internal — not re-exported from the package barrel.\n */\n\nconst shouldColor = (): boolean => {\n if (process.env.NO_COLOR !== undefined) return false\n if (process.env.FORCE_COLOR !== undefined) return true\n return process.stdout.isTTY\n}\n\nconst wrap =\n (code: string) =>\n (s: string): string =>\n shouldColor() ? `\\x1b[${code}m${s}\\x1b[0m` : s\n\nexport const red = wrap(\"31\")\nexport const green = wrap(\"32\")\nexport const yellow = wrap(\"33\")\nexport const blue = wrap(\"34\")\nexport const magenta = wrap(\"35\")\nexport const cyan = wrap(\"36\")\nexport const gray = wrap(\"90\")\n"],"mappings":"AAeA,MAAMA,MACA,QAAQ,IAAI,WAAa,IAAA,GACzB,QAAQ,IAAI,cAAgB,IAAA,IACzB,QAAQ,OAAO,MAFyB,GAK3CC,EACH,GACA,GACCD,EAAY,EAAI,QAAQE,EAAK,GAAGC,EAAE,SAAWA,EAEpCC,EAAMH,EAAK,IAAI,EACfI,EAAQJ,EAAK,IAAI,EACjBK,EAASL,EAAK,IAAI,EAClBM,EAAON,EAAK,IAAI,EAChBO,EAAUP,EAAK,IAAI,EACnBQ,EAAOR,EAAK,IAAI,EAChBS,EAAOT,EAAK,IAAI,E"}
1
+ {"version":3,"file":"colors.js","names":["shouldColor","wrap","code","s","red","green","yellow","blue","magenta","cyan","gray"],"sources":["../../src/config/colors.ts"],"sourcesContent":["/**\n * Internal raw-ANSI color helpers for boot diagnostics output.\n *\n * Respects established conventions:\n * - `NO_COLOR=1` (any value) → output uncolored, regardless of TTY. See\n * https://no-color.org/.\n * - `FORCE_COLOR=1` (any value) → output colored, regardless of TTY. Useful\n * for CI logs that pipe stdout but want the colors preserved.\n * - Default: color when `process.stdout.isTTY`, plain otherwise.\n *\n * Zero deps. ANSI escape codes haven't changed since 1979.\n *\n * @internal — not re-exported from the package barrel.\n */\n\nconst shouldColor = (): boolean => {\n if (process.env.NO_COLOR !== undefined) return false\n if (process.env.FORCE_COLOR !== undefined) return true\n return process.stdout.isTTY\n}\n\nconst wrap =\n (code: string) =>\n (s: string): string =>\n shouldColor() ? `\\x1b[${code}m${s}\\x1b[0m` : s\n\nexport const red = wrap(\"31\")\nexport const green = wrap(\"32\")\nexport const yellow = wrap(\"33\")\nexport const blue = wrap(\"34\")\nexport const magenta = wrap(\"35\")\nexport const cyan = wrap(\"36\")\nexport const gray = wrap(\"90\")\n"],"mappings":"AAeA,MAAMA,MACA,QAAQ,IAAI,WAAa,IAAA,GACzB,QAAQ,IAAI,cAAgB,IAAA,IACzB,QAAQ,OAAO,MAFyB,GAK3CC,EACH,GACA,GACCD,EAAY,EAAI,QAAQE,EAAK,GAAGC,EAAE,SAAWA,EAEpCC,EAAMH,EAAK,IAAI,EACfI,EAAQJ,EAAK,IAAI,EACjBK,EAASL,EAAK,IAAI,EAClBM,EAAON,EAAK,IAAI,EAChBO,EAAUP,EAAK,IAAI,EACnBQ,EAAOR,EAAK,IAAI,EAChBS,EAAOT,EAAK,IAAI"}
@@ -1,2 +1,2 @@
1
- import { t as consoleBootLogger } from "../consoleBootLogger-Mp3WmMYH.js";
1
+ import { t as consoleBootLogger } from "../consoleBootLogger-DsdYgCch.js";
2
2
  export { consoleBootLogger };
@@ -1 +1 @@
1
- {"version":3,"file":"consoleBootLogger.js","names":["stamp","consoleBootLogger","gray","msg","meta","yellow","red"],"sources":["../../src/config/consoleBootLogger.ts"],"sourcesContent":["import type { Logger } from \"functype\"\n\nimport { gray, red, yellow } from \"./colors\"\n\nconst stamp = (): string => new Date().toISOString()\n\n/**\n * Default `Logger` impl for boot diagnostics — zero-dep, raw ANSI colors,\n * NO_COLOR / FORCE_COLOR / isTTY-respecting.\n *\n * All 4 methods of core `Logger` are present (debug included). For consumers\n * already using `functype-log`, pass `createDirectConsoleLogger()` from\n * `functype-log/direct` directly — its `DirectLogger` structurally satisfies\n * core `Logger` (no adapter required).\n *\n * @example\n * ```ts\n * import { bootDiagnostics, consoleBootLogger } from \"functype-os/config\"\n *\n * await bootDiagnostics({ source, required, logger: consoleBootLogger })\n * // (logger defaults to consoleBootLogger anyway — passed explicitly here\n * // to show the swap point for `createDirectConsoleLogger()` etc.)\n * ```\n */\nexport const consoleBootLogger: Logger = {\n debug: (msg, meta) => console.debug(`${gray(stamp())} ${gray(\"DEBUG\")} ${msg}`, meta ?? \"\"),\n info: (msg, meta) => console.log(`${gray(stamp())} ${msg}`, meta ?? \"\"),\n warn: (msg, meta) => console.warn(`${gray(stamp())} ${yellow(\"WARN\")} ${msg}`, meta ?? \"\"),\n error: (msg, meta) => console.error(`${gray(stamp())} ${red(\"ERROR\")} ${msg}`, meta ?? \"\"),\n}\n"],"mappings":"A,wDAIA,MAAMA,uBAAsB,IAAI,KAAK,EAAA,CAAE,YAAY,EAoBtCC,EAA4B,CACvC,OAAQ,EAAK,IAAS,QAAQ,MAAM,GAAGC,EAAKF,EAAM,CAAC,EAAE,GAAGE,EAAK,OAAO,EAAE,GAAGC,IAAOC,GAAQ,EAAE,EAC1F,MAAO,EAAK,IAAS,QAAQ,IAAI,GAAGF,EAAKF,EAAM,CAAC,EAAE,GAAGG,IAAOC,GAAQ,EAAE,EACtE,MAAO,EAAK,IAAS,QAAQ,KAAK,GAAGF,EAAKF,EAAM,CAAC,EAAE,GAAGK,EAAO,MAAM,EAAE,GAAGF,IAAOC,GAAQ,EAAE,EACzF,OAAQ,EAAK,IAAS,QAAQ,MAAM,GAAGF,EAAKF,EAAM,CAAC,EAAE,GAAGM,EAAI,OAAO,EAAE,GAAGH,IAAOC,GAAQ,EAAE,CAC3F,E"}
1
+ {"version":3,"file":"consoleBootLogger.js","names":["stamp","consoleBootLogger","gray","msg","meta","yellow","red"],"sources":["../../src/config/consoleBootLogger.ts"],"sourcesContent":["import type { Logger } from \"functype\"\n\nimport { gray, red, yellow } from \"./colors\"\n\nconst stamp = (): string => new Date().toISOString()\n\n/**\n * Default `Logger` impl for boot diagnostics — zero-dep, raw ANSI colors,\n * NO_COLOR / FORCE_COLOR / isTTY-respecting.\n *\n * All 4 methods of core `Logger` are present (debug included). For consumers\n * already using `functype-log`, pass `createDirectConsoleLogger()` from\n * `functype-log/direct` directly — its `DirectLogger` structurally satisfies\n * core `Logger` (no adapter required).\n *\n * @example\n * ```ts\n * import { bootDiagnostics, consoleBootLogger } from \"functype-os/config\"\n *\n * await bootDiagnostics({ source, required, logger: consoleBootLogger })\n * // (logger defaults to consoleBootLogger anyway — passed explicitly here\n * // to show the swap point for `createDirectConsoleLogger()` etc.)\n * ```\n */\nexport const consoleBootLogger: Logger = {\n debug: (msg, meta) => console.debug(`${gray(stamp())} ${gray(\"DEBUG\")} ${msg}`, meta ?? \"\"),\n info: (msg, meta) => console.log(`${gray(stamp())} ${msg}`, meta ?? \"\"),\n warn: (msg, meta) => console.warn(`${gray(stamp())} ${yellow(\"WARN\")} ${msg}`, meta ?? \"\"),\n error: (msg, meta) => console.error(`${gray(stamp())} ${red(\"ERROR\")} ${msg}`, meta ?? \"\"),\n}\n"],"mappings":"wDAIA,MAAMA,uBAAsB,IAAI,KAAK,EAAA,CAAE,YAAY,EAoBtCC,EAA4B,CACvC,OAAQ,EAAK,IAAS,QAAQ,MAAM,GAAGC,EAAKF,EAAM,CAAC,EAAE,GAAGE,EAAK,OAAO,EAAE,GAAGC,IAAOC,GAAQ,EAAE,EAC1F,MAAO,EAAK,IAAS,QAAQ,IAAI,GAAGF,EAAKF,EAAM,CAAC,EAAE,GAAGG,IAAOC,GAAQ,EAAE,EACtE,MAAO,EAAK,IAAS,QAAQ,KAAK,GAAGF,EAAKF,EAAM,CAAC,EAAE,GAAGK,EAAO,MAAM,EAAE,GAAGF,IAAOC,GAAQ,EAAE,EACzF,OAAQ,EAAK,IAAS,QAAQ,MAAM,GAAGF,EAAKF,EAAM,CAAC,EAAE,GAAGM,EAAI,OAAO,EAAE,GAAGH,IAAOC,GAAQ,EAAE,CAC3F"}
@@ -1,9 +1,9 @@
1
- import { t as ConfigResolver } from "../ConfigResolver-p4Th3EPd.js";
2
- import { t as ConfigSource } from "../ConfigSource-D8Fi6vaG.js";
3
- import { t as Layered } from "../Layered-plQosjhw.js";
4
- import { t as ProcessEnvSource } from "../ProcessEnvSource-2Kv8VieC.js";
5
- import { t as StaticSource } from "../StaticSource-BgPzc1hx.js";
6
- import { n as MissingKey, r as bootDiagnostics, t as BootDiagnosticsOptions } from "../bootDiagnostics-CbmGG6s_.js";
7
- import { t as consoleBootLogger } from "../consoleBootLogger-Mp3WmMYH.js";
8
- import { t as maskValue } from "../mask-O-SEN-kZ.js";
1
+ import { t as ConfigResolver } from "../ConfigResolver-DpDKZFFL.js";
2
+ import { t as ConfigSource } from "../ConfigSource-BiNVyOgc.js";
3
+ import { t as Layered } from "../Layered-Bep7VzdC.js";
4
+ import { t as ProcessEnvSource } from "../ProcessEnvSource-X4vDsn43.js";
5
+ import { t as StaticSource } from "../StaticSource-Bg-cIAL0.js";
6
+ import { n as MissingKey, r as bootDiagnostics, t as BootDiagnosticsOptions } from "../bootDiagnostics-COdBMdp4.js";
7
+ import { t as consoleBootLogger } from "../consoleBootLogger-DsdYgCch.js";
8
+ import { t as maskValue } from "../mask-BLjNp9FP.js";
9
9
  export { type BootDiagnosticsOptions, ConfigResolver, type ConfigSource, Layered, type MissingKey, ProcessEnvSource, StaticSource, bootDiagnostics, consoleBootLogger, maskValue };
@@ -1,2 +1,2 @@
1
- import { t as maskValue } from "../mask-O-SEN-kZ.js";
1
+ import { t as maskValue } from "../mask-BLjNp9FP.js";
2
2
  export { maskValue };
@@ -1 +1 @@
1
- {"version":3,"file":"mask.js","names":["maskValue","value"],"sources":["../../src/config/mask.ts"],"sourcesContent":["/**\n * Mask a sensitive value for display in boot diagnostics or logs.\n *\n * - Values ≤ 8 characters become `****` (no leakage of length or characters).\n * - Longer values become `ab****yz` — first two and last two characters\n * preserved so an operator can confirm which secret loaded without\n * exposing the bulk of it.\n *\n * Exported from `functype-os/config` for ad-hoc masking outside\n * `bootDiagnostics`.\n *\n * @example\n * ```ts\n * maskValue(\"short\") // \"****\"\n * maskValue(\"supersecretvalue\") // \"su****ue\"\n * ```\n */\nexport const maskValue = (value: string): string => {\n if (value.length <= 8) return \"****\"\n return `${value.slice(0, 2)}****${value.slice(-2)}`\n}\n"],"mappings":"AAiBA,MAAaA,EAAa,GACpBC,EAAM,QAAU,EAAU,OACvB,GAAGA,EAAM,MAAM,EAAG,CAAC,EAAE,MAAMA,EAAM,MAAM,EAAE,I"}
1
+ {"version":3,"file":"mask.js","names":["maskValue","value"],"sources":["../../src/config/mask.ts"],"sourcesContent":["/**\n * Mask a sensitive value for display in boot diagnostics or logs.\n *\n * - Values ≤ 8 characters become `****` (no leakage of length or characters).\n * - Longer values become `ab****yz` — first two and last two characters\n * preserved so an operator can confirm which secret loaded without\n * exposing the bulk of it.\n *\n * Exported from `functype-os/config` for ad-hoc masking outside\n * `bootDiagnostics`.\n *\n * @example\n * ```ts\n * maskValue(\"short\") // \"****\"\n * maskValue(\"supersecretvalue\") // \"su****ue\"\n * ```\n */\nexport const maskValue = (value: string): string => {\n if (value.length <= 8) return \"****\"\n return `${value.slice(0, 2)}****${value.slice(-2)}`\n}\n"],"mappings":"AAiBA,MAAaA,EAAa,GACpBC,EAAM,QAAU,EAAU,OACvB,GAAGA,EAAM,MAAM,EAAG,CAAC,EAAE,MAAMA,EAAM,MAAM,EAAE"}
@@ -1,4 +1,5 @@
1
1
  import { Logger } from "functype";
2
+ //#region src/config/consoleBootLogger.d.ts
2
3
  /**
3
4
  * Default `Logger` impl for boot diagnostics — zero-dep, raw ANSI colors,
4
5
  * NO_COLOR / FORCE_COLOR / isTTY-respecting.
@@ -18,5 +19,6 @@ import { Logger } from "functype";
18
19
  * ```
19
20
  */
20
21
  declare const consoleBootLogger: Logger;
22
+ //#endregion
21
23
  export { consoleBootLogger as t };
22
- //# sourceMappingURL=consoleBootLogger-Mp3WmMYH.d.ts.map
24
+ //# sourceMappingURL=consoleBootLogger-DsdYgCch.d.ts.map
package/dist/env/Env.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { t as Env } from "../Env-eeHQ5oLF.js";
1
+ import { t as Env } from "../Env-CYRuNIYH.js";
2
2
  export { Env };
@@ -1 +1 @@
1
- {"version":3,"file":"Env.js","names":["Env","Option","name","EnvError","defaultValue","pairs","entry","k","v","List","valueOpt","Left","value","Try","parser","error","p","Right"],"sources":["../../src/env/Env.ts"],"sourcesContent":["import type { Either } from \"functype\"\nimport { Left, List, Option, Right, Try } from \"functype\"\n\nimport { EnvError } from \"../errors/errors\"\n\nconst EnvConstructor = (name: string): Option<string> => Option(process.env[name])\n\nconst EnvCompanion = {\n get: (name: string): Option<string> => Option(process.env[name]),\n\n getRequired: (name: string): Either<EnvError, string> => Option(process.env[name]).toEither(EnvError(name)),\n\n getOrDefault: (name: string, defaultValue: string): string => process.env[name] ?? defaultValue,\n\n has: (name: string): boolean => process.env[name] !== undefined,\n\n entries: (): List<readonly [string, string]> => {\n const pairs: Readonly<Array<readonly [string, string]>> = Object.entries(process.env)\n .filter((entry): entry is [string, string] => entry[1] !== undefined)\n .map(([k, v]) => [k, v] as const)\n return List(pairs)\n },\n\n parse: <T>(name: string, parser: (value: string) => T): Either<EnvError, T> => {\n const valueOpt = Option(process.env[name])\n if (valueOpt.isEmpty) return Left(EnvError(name))\n const value = valueOpt.orThrow()\n const parsed = Try(() => parser(value)).toEither((error) =>\n EnvError(name, `Failed to parse '${name}': ${error instanceof Error ? error.message : String(error)}`),\n )\n return parsed.flatMap((p) =>\n typeof p === \"number\" && isNaN(p)\n ? Left(EnvError(name, `Cannot parse '${value}' as number for '${name}'`))\n : Right(p),\n )\n },\n}\n\nexport const Env: typeof EnvConstructor & typeof EnvCompanion = Object.assign(EnvConstructor, EnvCompanion)\n"],"mappings":"A,yHAsCA,MAAaA,EAAmD,OAAO,OAjC/C,GAAiCC,EAAO,QAAQ,IAAIC,EAAK,EAiCa,CA9B5F,IAAM,GAAiCD,EAAO,QAAQ,IAAIC,EAAK,EAE/D,YAAc,GAA2CD,EAAO,QAAQ,IAAIC,EAAK,CAAC,CAAC,SAASC,EAASD,CAAI,CAAC,EAE1G,cAAe,EAAc,IAAiC,QAAQ,IAAIA,IAASE,EAEnF,IAAM,GAA0B,QAAQ,IAAIF,KAAU,IAAA,GAEtD,YAAgD,CAC9C,IAAMG,EAAoD,OAAO,QAAQ,QAAQ,GAAG,CAAC,CAClF,OAAQ,GAAqCC,EAAM,KAAO,IAAA,EAAS,CAAC,CACpE,KAAK,CAACC,EAAGC,KAAO,CAACD,EAAGC,CAAC,CAAU,EAClC,OAAOC,EAAKJ,CAAK,CACnB,EAEA,OAAW,EAAc,IAAsD,CAC7E,IAAMK,EAAWT,EAAO,QAAQ,IAAIC,EAAK,EACzC,GAAIQ,EAAS,QAAS,OAAOC,EAAKR,EAASD,CAAI,CAAC,EAChD,IAAMU,EAAQF,EAAS,QAAQ,EAI/B,OAHeG,MAAUC,EAAOF,CAAK,CAAC,CAAC,CAAC,SAAU,GAChDT,EAASD,EAAM,oBAAoBA,EAAK,KAAKa,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,GAAG,CAE3F,CAAC,CAAC,QAAS,GACrB,OAAOC,GAAM,UAAY,MAAMA,CAAC,EAC5BL,EAAKR,EAASD,EAAM,iBAAiBU,EAAM,mBAAmBV,EAAK,EAAE,CAAC,EACtEe,EAAMD,CAAC,CACb,CACF,CAG4F,CAAY,E"}
1
+ {"version":3,"file":"Env.js","names":["Env","Option","name","EnvError","defaultValue","pairs","entry","k","v","List","valueOpt","Left","value","Try","parser","error","p","Right"],"sources":["../../src/env/Env.ts"],"sourcesContent":["import type { Either } from \"functype\"\nimport { Left, List, Option, Right, Try } from \"functype\"\n\nimport { EnvError } from \"../errors/errors\"\n\nconst EnvConstructor = (name: string): Option<string> => Option(process.env[name])\n\nconst EnvCompanion = {\n get: (name: string): Option<string> => Option(process.env[name]),\n\n getRequired: (name: string): Either<EnvError, string> => Option(process.env[name]).toEither(EnvError(name)),\n\n getOrDefault: (name: string, defaultValue: string): string => process.env[name] ?? defaultValue,\n\n has: (name: string): boolean => process.env[name] !== undefined,\n\n entries: (): List<readonly [string, string]> => {\n const pairs: Readonly<Array<readonly [string, string]>> = Object.entries(process.env)\n .filter((entry): entry is [string, string] => entry[1] !== undefined)\n .map(([k, v]) => [k, v] as const)\n return List(pairs)\n },\n\n parse: <T>(name: string, parser: (value: string) => T): Either<EnvError, T> => {\n const valueOpt = Option(process.env[name])\n if (valueOpt.isEmpty) return Left(EnvError(name))\n const value = valueOpt.orThrow()\n const parsed = Try(() => parser(value)).toEither((error) =>\n EnvError(name, `Failed to parse '${name}': ${error instanceof Error ? error.message : String(error)}`),\n )\n return parsed.flatMap((p) =>\n typeof p === \"number\" && isNaN(p)\n ? Left(EnvError(name, `Cannot parse '${value}' as number for '${name}'`))\n : Right(p),\n )\n },\n}\n\nexport const Env: typeof EnvConstructor & typeof EnvCompanion = Object.assign(EnvConstructor, EnvCompanion)\n"],"mappings":"yHAsCA,MAAaA,EAAmD,OAAO,OAjC/C,GAAiCC,EAAO,QAAQ,IAAIC,EAAK,EAiCa,CA9B5F,IAAM,GAAiCD,EAAO,QAAQ,IAAIC,EAAK,EAE/D,YAAc,GAA2CD,EAAO,QAAQ,IAAIC,EAAK,CAAC,CAAC,SAASC,EAASD,CAAI,CAAC,EAE1G,cAAe,EAAc,IAAiC,QAAQ,IAAIA,IAASE,EAEnF,IAAM,GAA0B,QAAQ,IAAIF,KAAU,IAAA,GAEtD,YAAgD,CAC9C,IAAMG,EAAoD,OAAO,QAAQ,QAAQ,GAAG,CAAC,CAClF,OAAQ,GAAqCC,EAAM,KAAO,IAAA,EAAS,CAAC,CACpE,KAAK,CAACC,EAAGC,KAAO,CAACD,EAAGC,CAAC,CAAU,EAClC,OAAOC,EAAKJ,CAAK,CACnB,EAEA,OAAW,EAAc,IAAsD,CAC7E,IAAMK,EAAWT,EAAO,QAAQ,IAAIC,EAAK,EACzC,GAAIQ,EAAS,QAAS,OAAOC,EAAKR,EAASD,CAAI,CAAC,EAChD,IAAMU,EAAQF,EAAS,QAAQ,EAI/B,OAHeG,MAAUC,EAAOF,CAAK,CAAC,CAAC,CAAC,SAAU,GAChDT,EAASD,EAAM,oBAAoBA,EAAK,KAAKa,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,GAAG,CAE3F,CAAC,CAAC,QAAS,GACrB,OAAOC,GAAM,UAAY,MAAMA,CAAC,EAC5BL,EAAKR,EAASD,EAAM,iBAAiBU,EAAM,mBAAmBV,EAAK,EAAE,CAAC,EACtEe,EAAMD,CAAC,CACb,CACF,CAG4F,CAAY"}
@@ -1,2 +1,2 @@
1
- import { t as Env } from "../Env-eeHQ5oLF.js";
1
+ import { t as Env } from "../Env-CYRuNIYH.js";
2
2
  export { Env };
package/dist/env/index.js CHANGED
@@ -1 +1 @@
1
- export{Env}from"./Env.js";
1
+ import{Env as e}from"./Env.js";export{e as Env};
@@ -1,2 +1,2 @@
1
- import { a as PathError, i as OsError, n as EnvError, o as ProcessError, r as FsError, t as ConfigError } from "../errors-BIVj3Unk.js";
1
+ import { a as PathError, i as OsError, n as EnvError, o as ProcessError, r as FsError, t as ConfigError } from "../errors-uqbMcCFM.js";
2
2
  export { ConfigError, EnvError, FsError, OsError, PathError, ProcessError };
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":["EnvError","message","variable","PathError","reason","path","FsError","operation","cause","ConfigError","candidates","ProcessError","command","exitCode","stderr"],"sources":["../../src/errors/errors.ts"],"sourcesContent":["import type { Option } from \"functype\"\n\nexport type EnvError = {\n readonly _tag: \"EnvError\"\n readonly variable: string\n readonly message: string\n}\n\nexport type PathError = {\n readonly _tag: \"PathError\"\n readonly path: string\n readonly reason: \"unresolved_variable\" | \"invalid_path\"\n readonly message: string\n}\n\nexport type FsError = {\n readonly _tag: \"FsError\"\n readonly path: string\n readonly operation: string\n readonly cause: Error\n readonly message: string\n}\n\nexport type ConfigError = {\n readonly _tag: \"ConfigError\"\n readonly candidates: readonly string[]\n readonly message: string\n}\n\nexport type ProcessError = {\n readonly _tag: \"ProcessError\"\n readonly command: string\n readonly exitCode: Option<number>\n readonly stderr: string\n readonly message: string\n}\n\nexport type OsError = EnvError | PathError | FsError | ConfigError | ProcessError\n\nexport const EnvError = (variable: string, message?: string): EnvError => ({\n _tag: \"EnvError\",\n variable,\n message: message ?? `Environment variable '${variable}' is not set`,\n})\n\nexport const PathError = (path: string, reason: PathError[\"reason\"], message?: string): PathError => ({\n _tag: \"PathError\",\n path,\n reason,\n message:\n message ?? (reason === \"unresolved_variable\" ? `Unresolved variable in path: ${path}` : `Invalid path: ${path}`),\n})\n\nexport const FsError = (path: string, operation: string, cause: Error): FsError => ({\n _tag: \"FsError\",\n path,\n operation,\n cause,\n message: `${operation} failed for '${path}': ${cause.message}`,\n})\n\nexport const ConfigError = (candidates: readonly string[], message?: string): ConfigError => ({\n _tag: \"ConfigError\",\n candidates,\n message: message ?? `No config file found among candidates: ${candidates.join(\", \")}`,\n})\n\nexport const ProcessError = (\n command: string,\n exitCode: Option<number>,\n stderr: string,\n message?: string,\n): ProcessError => ({\n _tag: \"ProcessError\",\n command,\n exitCode,\n stderr,\n message: message ?? `Command '${command}' failed (exit ${exitCode.fold(() => \"?\", String)}): ${stderr}`,\n})\n"],"mappings":"AAuCA,MAAaA,GAAY,EAAkB,KAAgC,CACzE,KAAM,WACN,WACA,QAASC,GAAW,yBAAyBC,EAAS,aACxD,GAEaC,GAAa,EAAc,EAA6B,KAAiC,CACpG,KAAM,YACN,OACA,SACA,QACEF,IAAYG,IAAW,sBAAwB,gCAAgCC,IAAS,iBAAiBA,IAC7G,GAEaC,GAAW,EAAc,EAAmB,KAA2B,CAClF,KAAM,UACN,OACA,YACA,QACA,QAAS,GAAGC,EAAU,eAAeF,EAAK,KAAKG,EAAM,SACvD,GAEaC,GAAe,EAA+B,KAAmC,CAC5F,KAAM,cACN,aACA,QAASR,GAAW,0CAA0CS,EAAW,KAAK,IAAI,GACpF,GAEaC,GACX,EACA,EACA,EACA,KACkB,CAClB,KAAM,eACN,UACA,WACA,SACA,QAASV,GAAW,YAAYW,EAAQ,iBAAiBC,EAAS,SAAW,IAAK,MAAM,EAAE,KAAKC,GACjG,G"}
1
+ {"version":3,"file":"errors.js","names":["EnvError","message","variable","PathError","reason","path","FsError","operation","cause","ConfigError","candidates","ProcessError","command","exitCode","stderr"],"sources":["../../src/errors/errors.ts"],"sourcesContent":["import type { Option } from \"functype\"\n\nexport type EnvError = {\n readonly _tag: \"EnvError\"\n readonly variable: string\n readonly message: string\n}\n\nexport type PathError = {\n readonly _tag: \"PathError\"\n readonly path: string\n readonly reason: \"unresolved_variable\" | \"invalid_path\"\n readonly message: string\n}\n\nexport type FsError = {\n readonly _tag: \"FsError\"\n readonly path: string\n readonly operation: string\n readonly cause: Error\n readonly message: string\n}\n\nexport type ConfigError = {\n readonly _tag: \"ConfigError\"\n readonly candidates: readonly string[]\n readonly message: string\n}\n\nexport type ProcessError = {\n readonly _tag: \"ProcessError\"\n readonly command: string\n readonly exitCode: Option<number>\n readonly stderr: string\n readonly message: string\n}\n\nexport type OsError = EnvError | PathError | FsError | ConfigError | ProcessError\n\nexport const EnvError = (variable: string, message?: string): EnvError => ({\n _tag: \"EnvError\",\n variable,\n message: message ?? `Environment variable '${variable}' is not set`,\n})\n\nexport const PathError = (path: string, reason: PathError[\"reason\"], message?: string): PathError => ({\n _tag: \"PathError\",\n path,\n reason,\n message:\n message ?? (reason === \"unresolved_variable\" ? `Unresolved variable in path: ${path}` : `Invalid path: ${path}`),\n})\n\nexport const FsError = (path: string, operation: string, cause: Error): FsError => ({\n _tag: \"FsError\",\n path,\n operation,\n cause,\n message: `${operation} failed for '${path}': ${cause.message}`,\n})\n\nexport const ConfigError = (candidates: readonly string[], message?: string): ConfigError => ({\n _tag: \"ConfigError\",\n candidates,\n message: message ?? `No config file found among candidates: ${candidates.join(\", \")}`,\n})\n\nexport const ProcessError = (\n command: string,\n exitCode: Option<number>,\n stderr: string,\n message?: string,\n): ProcessError => ({\n _tag: \"ProcessError\",\n command,\n exitCode,\n stderr,\n message: message ?? `Command '${command}' failed (exit ${exitCode.fold(() => \"?\", String)}): ${stderr}`,\n})\n"],"mappings":"AAuCA,MAAaA,GAAY,EAAkB,KAAgC,CACzE,KAAM,WACN,WACA,QAASC,GAAW,yBAAyBC,EAAS,aACxD,GAEaC,GAAa,EAAc,EAA6B,KAAiC,CACpG,KAAM,YACN,OACA,SACA,QACEF,IAAYG,IAAW,sBAAwB,gCAAgCC,IAAS,iBAAiBA,IAC7G,GAEaC,GAAW,EAAc,EAAmB,KAA2B,CAClF,KAAM,UACN,OACA,YACA,QACA,QAAS,GAAGC,EAAU,eAAeF,EAAK,KAAKG,EAAM,SACvD,GAEaC,GAAe,EAA+B,KAAmC,CAC5F,KAAM,cACN,aACA,QAASR,GAAW,0CAA0CS,EAAW,KAAK,IAAI,GACpF,GAEaC,GACX,EACA,EACA,EACA,KACkB,CAClB,KAAM,eACN,UACA,WACA,SACA,QAASV,GAAW,YAAYW,EAAQ,iBAAiBC,EAAS,SAAW,IAAK,MAAM,EAAE,KAAKC,GACjG"}
@@ -1,2 +1,2 @@
1
- import { a as PathError, i as OsError, n as EnvError, o as ProcessError, r as FsError, t as ConfigError } from "../errors-BIVj3Unk.js";
1
+ import { a as PathError, i as OsError, n as EnvError, o as ProcessError, r as FsError, t as ConfigError } from "../errors-uqbMcCFM.js";
2
2
  export { ConfigError, EnvError, FsError, type OsError, PathError, ProcessError };
@@ -1 +1 @@
1
- export{ConfigError,EnvError,FsError,PathError,ProcessError}from"./errors.js";
1
+ import{ConfigError as e,EnvError as t,FsError as n,PathError as r,ProcessError as i}from"./errors.js";export{e as ConfigError,t as EnvError,n as FsError,r as PathError,i as ProcessError};
@@ -1,4 +1,5 @@
1
1
  import { Option } from "functype";
2
+ //#region src/errors/errors.d.ts
2
3
  type EnvError = {
3
4
  readonly _tag: "EnvError";
4
5
  readonly variable: string;
@@ -35,5 +36,6 @@ declare const PathError: (path: string, reason: PathError["reason"], message?: s
35
36
  declare const FsError: (path: string, operation: string, cause: Error) => FsError;
36
37
  declare const ConfigError: (candidates: readonly string[], message?: string) => ConfigError;
37
38
  declare const ProcessError: (command: string, exitCode: Option<number>, stderr: string, message?: string) => ProcessError;
39
+ //#endregion
38
40
  export { PathError as a, OsError as i, EnvError as n, ProcessError as o, FsError as r, ConfigError as t };
39
- //# sourceMappingURL=errors-BIVj3Unk.d.ts.map
41
+ //# sourceMappingURL=errors-uqbMcCFM.d.ts.map
package/dist/fs/Fs.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { n as Fs, t as FileInfo } from "../Fs-BkxuVfog.js";
1
+ import { n as Fs, t as FileInfo } from "../Fs-CPL0SxYV.js";
2
2
  export { FileInfo, Fs };
package/dist/fs/Fs.js CHANGED
@@ -1,2 +1,2 @@
1
- import{FsError as e}from"../errors/errors.js";import{IO as t,Left as n,List as r,Option as i,Right as a,Try as o}from"functype";import*as s from"node:fs";import*as c from"node:fs/promises";const l=e=>({size:e.size,isFile:e.isFile(),isDirectory:e.isDirectory(),isSymbolicLink:e.isSymbolicLink(),createdAt:e.birthtime,modifiedAt:e.mtime,accessedAt:e.atime,permissions:e.mode}),u=(t,n,r)=>e(t,n,r instanceof Error?r:Error(String(r))),d=[`/proc/`,`/sys/`,`/dev/`],f=e=>d.some(t=>e.startsWith(t)),p=(e,t)=>{let n=t.replace(/[\\^$+?.()|[\]{}]/g,`\\$&`).replace(/\*\*\//g,`{{GLOBSTAR}}`).replace(/\*\*/g,`{{GLOBSTAR}}`).replace(/\*/g,`[^/]*`).replace(/\{\{GLOBSTAR\}\}/g,`(?:.*/)?`);return RegExp(`^${n}$`).test(e)},m=(e,n,r)=>t.tryPromise({try:r,catch:t=>u(e,n,t)}),h=e=>e instanceof Error&&`code`in e&&e.code===`ENOENT`,g=(e,t,n)=>o(n).toEither(n=>u(e,t,n)),_={exists:e=>t.async(()=>c.access(e)).fold(()=>!1,()=>!0),readFile:(e,t=`utf8`)=>m(e,`readFile`,()=>c.readFile(e,{encoding:t})),readFileOpt:(e,r=`utf8`)=>t.async(()=>c.readFile(e,{encoding:r})).fold(t=>h(t)?a(i(void 0)):n(u(e,`readFile`,t)),e=>a(i(e))).flatMap(e=>t.fromEither(e)),stat:e=>m(e,`stat`,()=>c.stat(e).then(l)),copyFile:(e,t)=>m(e,`copyFile`,()=>c.copyFile(e,t)),rename:(e,t)=>m(e,`rename`,()=>c.rename(e,t)),readdir:e=>m(e,`readdir`,()=>c.readdir(e).then(e=>r(e))),glob:(e,t)=>m(e,`glob`,()=>c.readdir(e,{recursive:!0,encoding:`utf8`})).map(e=>r(e.filter(e=>p(e,t)))),writeFile:(e,t,n=`utf8`)=>m(e,`writeFile`,()=>c.writeFile(e,t,{encoding:n})),appendFile:(e,t,n=`utf8`)=>m(e,`appendFile`,()=>c.appendFile(e,t,{encoding:n})),mkdir:(e,n)=>n?.recursive&&f(e)?t.fail(u(e,`mkdir`,/* @__PURE__ */ Error(`recursive mkdir refused under magic filesystem root (/proc, /sys, /dev)`))):m(e,`mkdir`,()=>c.mkdir(e,n).then(()=>void 0)),unlink:e=>m(e,`unlink`,()=>c.unlink(e)),existsSync:e=>o(()=>s.accessSync(e)).isSuccess(),readFileSync:(e,t=`utf8`)=>g(e,`readFileSync`,()=>s.readFileSync(e,{encoding:t})),readFileOptSync:(e,t=`utf8`)=>o(()=>s.readFileSync(e,{encoding:t})).fold(t=>h(t)?a(i(void 0)):n(u(e,`readFileOptSync`,t)),e=>a(i(e))),statSync:e=>g(e,`statSync`,()=>l(s.statSync(e))),copyFileSync:(e,t)=>g(e,`copyFileSync`,()=>s.copyFileSync(e,t)),renameSync:(e,t)=>g(e,`renameSync`,()=>s.renameSync(e,t)),readdirSync:e=>g(e,`readdirSync`,()=>r(s.readdirSync(e))),writeFileSync:(e,t,n=`utf8`)=>g(e,`writeFileSync`,()=>s.writeFileSync(e,t,{encoding:n})),appendFileSync:(e,t,n=`utf8`)=>g(e,`appendFileSync`,()=>s.appendFileSync(e,t,{encoding:n})),mkdirSync:(e,t)=>t?.recursive&&f(e)?n(u(e,`mkdirSync`,/* @__PURE__ */ Error(`recursive mkdir refused under magic filesystem root (/proc, /sys, /dev)`))):g(e,`mkdirSync`,()=>{s.mkdirSync(e,t)}),unlinkSync:e=>g(e,`unlinkSync`,()=>s.unlinkSync(e))};export{_ as Fs};
1
+ import{FsError as e}from"../errors/errors.js";import{Err as t,Left as n,List as r,Ok as i,Option as a,Right as o,Try as s}from"functype";import*as c from"node:fs";import*as l from"node:fs/promises";const u=e=>({size:e.size,isFile:e.isFile(),isDirectory:e.isDirectory(),isSymbolicLink:e.isSymbolicLink(),createdAt:e.birthtime,modifiedAt:e.mtime,accessedAt:e.atime,permissions:e.mode}),d=(t,n,r)=>e(t,n,r instanceof Error?r:Error(String(r))),f=[`/proc/`,`/sys/`,`/dev/`],p=e=>f.some(t=>e.startsWith(t)),m=(e,t)=>{let n=t.replace(/[\\^$+?.()|[\]{}]/g,`\\$&`).replace(/\*\*\//g,`{{GLOBSTAR}}`).replace(/\*\*/g,`{{GLOBSTAR}}`).replace(/\*/g,`[^/]*`).replace(/\{\{GLOBSTAR\}\}/g,`(?:.*/)?`);return RegExp(`^${n}$`).test(e)},h=async(e,n,r)=>(await s.async(r)).fold(r=>Promise.resolve(t(d(e,n,r))),e=>Promise.resolve(i(e))),g=(e,t,n)=>s(n).toEither(n=>d(e,t,n)),_={exists:async e=>{let t=await s.async(()=>l.access(e));return i(t.isSuccess())},readFile:(e,t=`utf8`)=>h(e,`readFile`,()=>l.readFile(e,{encoding:t})),readFileOpt:async(e,n=`utf8`)=>(await s.async(()=>l.readFile(e,{encoding:n}))).fold(n=>n instanceof Error&&`code`in n&&n.code===`ENOENT`?Promise.resolve(i(a(void 0))):Promise.resolve(t(d(e,`readFile`,n))),e=>Promise.resolve(i(a(e)))),stat:e=>h(e,`stat`,()=>l.stat(e).then(u)),copyFile:(e,t)=>h(e,`copyFile`,()=>l.copyFile(e,t)),rename:(e,t)=>h(e,`rename`,()=>l.rename(e,t)),readdir:e=>h(e,`readdir`,()=>l.readdir(e).then(e=>r(e))),glob:async(e,n)=>(await s.async(()=>l.readdir(e,{recursive:!0,encoding:`utf8`}))).fold(n=>Promise.resolve(t(d(e,`glob`,n))),e=>{let t=e.filter(e=>m(e,n));return Promise.resolve(i(r(t)))}),writeFile:(e,t,n=`utf8`)=>h(e,`writeFile`,()=>l.writeFile(e,t,{encoding:n})),appendFile:(e,t,n=`utf8`)=>h(e,`appendFile`,()=>l.appendFile(e,t,{encoding:n})),mkdir:(e,n)=>n?.recursive&&p(e)?Promise.resolve(t(d(e,`mkdir`,/* @__PURE__ */ Error(`recursive mkdir refused under magic filesystem root (/proc, /sys, /dev)`)))):h(e,`mkdir`,()=>l.mkdir(e,n).then(()=>void 0)),unlink:e=>h(e,`unlink`,()=>l.unlink(e)),existsSync:e=>s(()=>c.accessSync(e)).isSuccess(),readFileSync:(e,t=`utf8`)=>g(e,`readFileSync`,()=>c.readFileSync(e,{encoding:t})),readFileOptSync:(e,t=`utf8`)=>s(()=>c.readFileSync(e,{encoding:t})).fold(t=>t instanceof Error&&`code`in t&&t.code===`ENOENT`?o(a(void 0)):n(d(e,`readFileOptSync`,t)),e=>o(a(e))),statSync:e=>g(e,`statSync`,()=>u(c.statSync(e))),copyFileSync:(e,t)=>g(e,`copyFileSync`,()=>c.copyFileSync(e,t)),renameSync:(e,t)=>g(e,`renameSync`,()=>c.renameSync(e,t)),readdirSync:e=>g(e,`readdirSync`,()=>r(c.readdirSync(e))),writeFileSync:(e,t,n=`utf8`)=>g(e,`writeFileSync`,()=>c.writeFileSync(e,t,{encoding:n})),appendFileSync:(e,t,n=`utf8`)=>g(e,`appendFileSync`,()=>c.appendFileSync(e,t,{encoding:n})),mkdirSync:(e,t)=>t?.recursive&&p(e)?n(d(e,`mkdirSync`,/* @__PURE__ */ Error(`recursive mkdir refused under magic filesystem root (/proc, /sys, /dev)`))):g(e,`mkdirSync`,()=>{c.mkdirSync(e,t)}),unlinkSync:e=>g(e,`unlinkSync`,()=>c.unlinkSync(e))};export{_ as Fs};
2
2
  //# sourceMappingURL=Fs.js.map
package/dist/fs/Fs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Fs.js","names":["fsSync","fs","toFileInfo","stats","toFsError","FsError","p","op","error","MAGIC_FS_PREFIXES","isMagicFsPath","prefix","matchGlob","regex","pattern","filePath","liftAsync","IO","thunk","err","isNotFound","liftSync","Try","Fs","Right","Option","Left","data","result","src","dest","oldPath","newPath","List","entries","dir","entry","options"],"sources":["../../src/fs/Fs.ts"],"sourcesContent":["import * as fsSync from \"node:fs\"\nimport * as fs from \"node:fs/promises\"\n\nimport type { Either } from \"functype\"\nimport { IO, Left, List, Option, Right, Try } from \"functype\"\n\nimport { FsError } from \"../errors/errors\"\n\nexport type FileInfo = {\n readonly size: number\n readonly isFile: boolean\n readonly isDirectory: boolean\n readonly isSymbolicLink: boolean\n readonly createdAt: Date\n readonly modifiedAt: Date\n readonly accessedAt: Date\n readonly permissions: number\n}\n\nconst toFileInfo = (stats: fsSync.Stats): FileInfo => ({\n size: stats.size,\n isFile: stats.isFile(),\n isDirectory: stats.isDirectory(),\n isSymbolicLink: stats.isSymbolicLink(),\n createdAt: stats.birthtime,\n modifiedAt: stats.mtime,\n accessedAt: stats.atime,\n permissions: stats.mode,\n})\n\nconst toFsError = (p: string, op: string, error: unknown): FsError =>\n FsError(p, op, error instanceof Error ? error : new Error(String(error)))\n\n/**\n * Linux magic filesystems where recursive mkdir can hang indefinitely against\n * unwritable subpaths (libuv quirk; macOS errors immediately instead).\n * Refusing recursive mkdir under these prefixes keeps `mkdir({ recursive: true })`\n * fast-failing and predictable across platforms. See issue #135.\n */\nconst MAGIC_FS_PREFIXES: ReadonlyArray<string> = [\"/proc/\", \"/sys/\", \"/dev/\"]\n\nconst isMagicFsPath = (p: string): boolean => MAGIC_FS_PREFIXES.some((prefix) => p.startsWith(prefix))\n\nconst matchGlob = (filePath: string, pattern: string): boolean => {\n // Escape every regex metachar EXCEPT '*' first, so the subsequent\n // '*' transformations are the only special characters in the output.\n // Order matters: backslashes must be escaped before any '\\\\' insertion below.\n const escaped = pattern.replace(/[\\\\^$+?.()|[\\]{}]/g, \"\\\\$&\")\n const regex = escaped\n .replace(/\\*\\*\\//g, \"{{GLOBSTAR}}\")\n .replace(/\\*\\*/g, \"{{GLOBSTAR}}\")\n .replace(/\\*/g, \"[^/]*\")\n .replace(/\\{\\{GLOBSTAR\\}\\}/g, \"(?:.*/)?\")\n return new RegExp(`^${regex}$`).test(filePath)\n}\n\n// Async helper: lift a Promise-returning thunk into a lazy IO, mapping rejections to\n// FsError. Nothing touches the filesystem until the IO runs. The interpreter awaits the\n// thunk inside its own try, so a synchronous throw from inside it (e.g. a bad encoding\n// argument) fails the same way a rejection does — same FsError, no unhandled rejection.\nconst liftAsync = <T>(p: string, op: string, thunk: () => Promise<T>): IO<never, FsError, T> =>\n IO.tryPromise({ try: thunk, catch: (err) => toFsError(p, op, err) })\n\nconst isNotFound = (err: unknown): boolean => err instanceof Error && \"code\" in err && err.code === \"ENOENT\"\n\n// Sync helper: run a thunk via Try and convert to Either<FsError, T>.\nconst liftSync = <T>(p: string, op: string, thunk: () => T): Either<FsError, T> =>\n Try(thunk).toEither((err) => toFsError(p, op, err))\n\nexport const Fs = {\n // Async methods — return a lazy IO<never, FsError, T>; nothing runs until `.run()`\n\n exists: (p: string): IO<never, never, boolean> =>\n IO.async(() => fs.access(p)).fold(\n () => false,\n () => true,\n ),\n\n readFile: (p: string, encoding: BufferEncoding = \"utf8\"): IO<never, FsError, string> =>\n liftAsync(p, \"readFile\", () => fs.readFile(p, { encoding })),\n\n readFileOpt: (p: string, encoding: BufferEncoding = \"utf8\"): IO<never, FsError, Option<string>> =>\n IO.async(() => fs.readFile(p, { encoding }))\n .fold(\n (err): Either<FsError, Option<string>> =>\n isNotFound(err) ? Right(Option<string>(undefined)) : Left(toFsError(p, \"readFile\", err)),\n (data): Either<FsError, Option<string>> => Right(Option(data)),\n )\n .flatMap((result) => IO.fromEither(result)),\n\n stat: (p: string): IO<never, FsError, FileInfo> => liftAsync(p, \"stat\", () => fs.stat(p).then(toFileInfo)),\n\n copyFile: (src: string, dest: string): IO<never, FsError, void> =>\n liftAsync(src, \"copyFile\", () => fs.copyFile(src, dest)),\n\n rename: (oldPath: string, newPath: string): IO<never, FsError, void> =>\n liftAsync(oldPath, \"rename\", () => fs.rename(oldPath, newPath)),\n\n readdir: (p: string): IO<never, FsError, List<string>> =>\n liftAsync(p, \"readdir\", () => fs.readdir(p).then((entries) => List<string>(entries))),\n\n glob: (dir: string, pattern: string): IO<never, FsError, List<string>> =>\n liftAsync(dir, \"glob\", () => fs.readdir(dir, { recursive: true, encoding: \"utf8\" })).map((entries) =>\n List<string>(entries.filter((entry) => matchGlob(entry, pattern))),\n ),\n\n writeFile: (p: string, data: string, encoding: BufferEncoding = \"utf8\"): IO<never, FsError, void> =>\n liftAsync(p, \"writeFile\", () => fs.writeFile(p, data, { encoding })),\n\n appendFile: (p: string, data: string, encoding: BufferEncoding = \"utf8\"): IO<never, FsError, void> =>\n liftAsync(p, \"appendFile\", () => fs.appendFile(p, data, { encoding })),\n\n mkdir: (p: string, options?: { recursive?: boolean }): IO<never, FsError, void> =>\n options?.recursive && isMagicFsPath(p)\n ? IO.fail(\n toFsError(p, \"mkdir\", new Error(\"recursive mkdir refused under magic filesystem root (/proc, /sys, /dev)\")),\n )\n : liftAsync(p, \"mkdir\", () => fs.mkdir(p, options).then(() => undefined)),\n\n unlink: (p: string): IO<never, FsError, void> => liftAsync(p, \"unlink\", () => fs.unlink(p)),\n\n // Sync methods — return Either<FsError, T>\n\n existsSync: (p: string): boolean => Try(() => fsSync.accessSync(p)).isSuccess(),\n\n readFileSync: (p: string, encoding: BufferEncoding = \"utf8\"): Either<FsError, string> =>\n liftSync(p, \"readFileSync\", () => fsSync.readFileSync(p, { encoding })),\n\n readFileOptSync: (p: string, encoding: BufferEncoding = \"utf8\"): Either<FsError, Option<string>> => {\n const tryResult = Try(() => fsSync.readFileSync(p, { encoding }))\n return tryResult.fold<Either<FsError, Option<string>>>(\n (err) => (isNotFound(err) ? Right(Option<string>(undefined)) : Left(toFsError(p, \"readFileOptSync\", err))),\n (data) => Right(Option(data)),\n )\n },\n\n statSync: (p: string): Either<FsError, FileInfo> => liftSync(p, \"statSync\", () => toFileInfo(fsSync.statSync(p))),\n\n copyFileSync: (src: string, dest: string): Either<FsError, void> =>\n liftSync(src, \"copyFileSync\", () => fsSync.copyFileSync(src, dest)),\n\n renameSync: (oldPath: string, newPath: string): Either<FsError, void> =>\n liftSync(oldPath, \"renameSync\", () => fsSync.renameSync(oldPath, newPath)),\n\n readdirSync: (p: string): Either<FsError, List<string>> =>\n liftSync(p, \"readdirSync\", () => List(fsSync.readdirSync(p))),\n\n writeFileSync: (p: string, data: string, encoding: BufferEncoding = \"utf8\"): Either<FsError, void> =>\n liftSync(p, \"writeFileSync\", () => fsSync.writeFileSync(p, data, { encoding })),\n\n appendFileSync: (p: string, data: string, encoding: BufferEncoding = \"utf8\"): Either<FsError, void> =>\n liftSync(p, \"appendFileSync\", () => fsSync.appendFileSync(p, data, { encoding })),\n\n mkdirSync: (p: string, options?: { recursive?: boolean }): Either<FsError, void> => {\n if (options?.recursive && isMagicFsPath(p)) {\n return Left(\n toFsError(p, \"mkdirSync\", new Error(\"recursive mkdir refused under magic filesystem root (/proc, /sys, /dev)\")),\n )\n }\n return liftSync(p, \"mkdirSync\", () => {\n fsSync.mkdirSync(p, options)\n })\n },\n\n unlinkSync: (p: string): Either<FsError, void> => liftSync(p, \"unlinkSync\", () => fsSync.unlinkSync(p)),\n}\n"],"mappings":"A,6LAmBA,MAAME,EAAc,IAAmC,CACrD,KAAMC,EAAM,KACZ,OAAQA,EAAM,OAAO,EACrB,YAAaA,EAAM,YAAY,EAC/B,eAAgBA,EAAM,eAAe,EACrC,UAAWA,EAAM,UACjB,WAAYA,EAAM,MAClB,WAAYA,EAAM,MAClB,YAAaA,EAAM,IACrB,GAEMC,GAAa,EAAW,EAAY,IACxCC,EAAQC,EAAGC,EAAIC,aAAiB,MAAQA,EAAY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AG,CAAE,UAAS,CAAC,CAAC,EAExE,iBAAkB,EAAW,EAA2B,SACpCgB,MAAUtB,EAAO,aAAaM,EAAG,CAAE,UAAS,CAAC,CAChD,CAAC,CAAC,KACd,GAASc,EAAWD,CAAG,EAAIK,EAAMC,EAAe,IAAA,EAAS,CAAC,EAAIC,EAAKtB,EAAUE,EAAG,kBAAmBa,CAAG,CAAC,EACvG,GAASK,EAAMC,EAAOE,CAAI,CAAC,CAC9B,EAGF,SAAW,GAAyCN,EAASf,EAAG,eAAkBJ,EAAWF,EAAO,SAASM,CAAC,CAAC,CAAC,EAEhH,cAAe,EAAa,IAC1Be,EAASQ,EAAK,mBAAsB7B,EAAO,aAAa6B,EAAKC,CAAI,CAAC,EAEpE,YAAa,EAAiB,IAC5BT,EAASU,EAAS,iBAAoB/B,EAAO,WAAW+B,EAASC,CAAO,CAAC,EAE3E,YAAc,GACZX,EAASf,EAAG,kBAAqB2B,EAAKjC,EAAO,YAAYM,CAAC,CAAC,CAAC,EAE9D,eAAgB,EAAW,EAAc,EAA2B,SAClEe,EAASf,EAAG,oBAAuBN,EAAO,cAAcM,EAAGqB,EAAM,CAAE,UAAS,CAAC,CAAC,EAEhF,gBAAiB,EAAW,EAAc,EAA2B,SACnEN,EAASf,EAAG,qBAAwBN,EAAO,eAAeM,EAAGqB,EAAM,CAAE,UAAS,CAAC,CAAC,EAElF,WAAY,EAAW,IACjBU,GAAS,WAAa3B,EAAcJ,CAAC,EAChCoB,EACLtB,EAAUE,EAAG,YAAa,gBAAI,MAAM,yEAAyE,CAAC,CAChH,EAEKe,EAASf,EAAG,gBAAmB,CACpCN,EAAO,UAAUM,EAAG+B,CAAO,CAC7B,CAAC,EAGH,WAAa,GAAqChB,EAASf,EAAG,iBAAoBN,EAAO,WAAWM,CAAC,CAAC,CACxG,E"}
1
+ {"version":3,"file":"Fs.js","names":["fsSync","fs","toFileInfo","stats","toFsError","FsError","p","op","error","MAGIC_FS_PREFIXES","isMagicFsPath","prefix","matchGlob","regex","pattern","filePath","liftAsync","Try","thunk","Err","err","Ok","value","liftSync","Fs","result","Option","data","src","dest","oldPath","newPath","List","entries","dir","matched","entry","options","Right","Left"],"sources":["../../src/fs/Fs.ts"],"sourcesContent":["import * as fsSync from \"node:fs\"\nimport * as fs from \"node:fs/promises\"\n\nimport type { Either, TaskResult } from \"functype\"\nimport { Err, Left, List, Ok, Option, Right, Try } from \"functype\"\n\nimport { FsError } from \"../errors/errors\"\n\nexport type FileInfo = {\n readonly size: number\n readonly isFile: boolean\n readonly isDirectory: boolean\n readonly isSymbolicLink: boolean\n readonly createdAt: Date\n readonly modifiedAt: Date\n readonly accessedAt: Date\n readonly permissions: number\n}\n\nconst toFileInfo = (stats: fsSync.Stats): FileInfo => ({\n size: stats.size,\n isFile: stats.isFile(),\n isDirectory: stats.isDirectory(),\n isSymbolicLink: stats.isSymbolicLink(),\n createdAt: stats.birthtime,\n modifiedAt: stats.mtime,\n accessedAt: stats.atime,\n permissions: stats.mode,\n})\n\nconst toFsError = (p: string, op: string, error: unknown): FsError =>\n FsError(p, op, error instanceof Error ? error : new Error(String(error)))\n\n/**\n * Linux magic filesystems where recursive mkdir can hang indefinitely against\n * unwritable subpaths (libuv quirk; macOS errors immediately instead).\n * Refusing recursive mkdir under these prefixes keeps `mkdir({ recursive: true })`\n * fast-failing and predictable across platforms. See issue #135.\n */\nconst MAGIC_FS_PREFIXES: ReadonlyArray<string> = [\"/proc/\", \"/sys/\", \"/dev/\"]\n\nconst isMagicFsPath = (p: string): boolean => MAGIC_FS_PREFIXES.some((prefix) => p.startsWith(prefix))\n\nconst matchGlob = (filePath: string, pattern: string): boolean => {\n // Escape every regex metachar EXCEPT '*' first, so the subsequent\n // '*' transformations are the only special characters in the output.\n // Order matters: backslashes must be escaped before any '\\\\' insertion below.\n const escaped = pattern.replace(/[\\\\^$+?.()|[\\]{}]/g, \"\\\\$&\")\n const regex = escaped\n .replace(/\\*\\*\\//g, \"{{GLOBSTAR}}\")\n .replace(/\\*\\*/g, \"{{GLOBSTAR}}\")\n .replace(/\\*/g, \"[^/]*\")\n .replace(/\\{\\{GLOBSTAR\\}\\}/g, \"(?:.*/)?\")\n return new RegExp(`^${regex}$`).test(filePath)\n}\n\n// Async helper: lift a Promise-returning thunk into TaskResult, mapping\n// rejections to FsError. Uses `Try.async(thunk)` rather than\n// `Try.fromPromise(thunk())` so synchronous throws from inside the thunk\n// (e.g. a bad encoding argument) are caught the same way async rejections\n// are — same Failure path, no unhandled-rejection escape hatch.\nconst liftAsync = async <T>(p: string, op: string, thunk: () => Promise<T>): TaskResult<T> => {\n const result = await Try.async(thunk)\n return result.fold<TaskResult<T>>(\n (err) => Promise.resolve(Err(toFsError(p, op, err))),\n (value) => Promise.resolve(Ok(value)),\n )\n}\n\n// Sync helper: run a thunk via Try and convert to Either<FsError, T>.\nconst liftSync = <T>(p: string, op: string, thunk: () => T): Either<FsError, T> =>\n Try(thunk).toEither((err) => toFsError(p, op, err))\n\nexport const Fs = {\n // Async methods — return TaskResult<T>\n\n exists: async (p: string): TaskResult<boolean> => {\n const result = await Try.async(() => fs.access(p))\n return Ok(result.isSuccess())\n },\n\n readFile: (p: string, encoding: BufferEncoding = \"utf8\"): TaskResult<string> =>\n liftAsync(p, \"readFile\", () => fs.readFile(p, { encoding })),\n\n readFileOpt: async (p: string, encoding: BufferEncoding = \"utf8\"): TaskResult<Option<string>> => {\n const result = await Try.async(() => fs.readFile(p, { encoding }))\n return result.fold<TaskResult<Option<string>>>(\n (err) => {\n if (err instanceof Error && \"code\" in err && err.code === \"ENOENT\") {\n return Promise.resolve(Ok(Option<string>(undefined)))\n }\n return Promise.resolve(Err(toFsError(p, \"readFile\", err)))\n },\n (data) => Promise.resolve(Ok(Option(data))),\n )\n },\n\n stat: (p: string): TaskResult<FileInfo> => liftAsync(p, \"stat\", () => fs.stat(p).then(toFileInfo)),\n\n copyFile: (src: string, dest: string): TaskResult<void> => liftAsync(src, \"copyFile\", () => fs.copyFile(src, dest)),\n\n rename: (oldPath: string, newPath: string): TaskResult<void> =>\n liftAsync(oldPath, \"rename\", () => fs.rename(oldPath, newPath)),\n\n readdir: (p: string): TaskResult<List<string>> =>\n liftAsync(p, \"readdir\", () => fs.readdir(p).then((entries) => List<string>(entries))),\n\n glob: async (dir: string, pattern: string): TaskResult<List<string>> => {\n const result = await Try.async(() => fs.readdir(dir, { recursive: true, encoding: \"utf8\" }))\n return result.fold<TaskResult<List<string>>>(\n (err) => Promise.resolve(Err(toFsError(dir, \"glob\", err))),\n (entries) => {\n const matched = (entries as string[]).filter((entry) => matchGlob(entry, pattern))\n return Promise.resolve(Ok(List<string>(matched)))\n },\n )\n },\n\n writeFile: (p: string, data: string, encoding: BufferEncoding = \"utf8\"): TaskResult<void> =>\n liftAsync(p, \"writeFile\", () => fs.writeFile(p, data, { encoding })),\n\n appendFile: (p: string, data: string, encoding: BufferEncoding = \"utf8\"): TaskResult<void> =>\n liftAsync(p, \"appendFile\", () => fs.appendFile(p, data, { encoding })),\n\n mkdir: (p: string, options?: { recursive?: boolean }): TaskResult<void> => {\n if (options?.recursive && isMagicFsPath(p)) {\n return Promise.resolve(\n Err(\n toFsError(p, \"mkdir\", new Error(\"recursive mkdir refused under magic filesystem root (/proc, /sys, /dev)\")),\n ),\n )\n }\n return liftAsync(p, \"mkdir\", () => fs.mkdir(p, options).then(() => undefined))\n },\n\n unlink: (p: string): TaskResult<void> => liftAsync(p, \"unlink\", () => fs.unlink(p)),\n\n // Sync methods — return Either<FsError, T>\n\n existsSync: (p: string): boolean => Try(() => fsSync.accessSync(p)).isSuccess(),\n\n readFileSync: (p: string, encoding: BufferEncoding = \"utf8\"): Either<FsError, string> =>\n liftSync(p, \"readFileSync\", () => fsSync.readFileSync(p, { encoding })),\n\n readFileOptSync: (p: string, encoding: BufferEncoding = \"utf8\"): Either<FsError, Option<string>> => {\n const tryResult = Try(() => fsSync.readFileSync(p, { encoding }))\n return tryResult.fold<Either<FsError, Option<string>>>(\n (err) => {\n if (err instanceof Error && \"code\" in err && err.code === \"ENOENT\") {\n return Right(Option<string>(undefined))\n }\n return Left(toFsError(p, \"readFileOptSync\", err))\n },\n (data) => Right(Option(data)),\n )\n },\n\n statSync: (p: string): Either<FsError, FileInfo> => liftSync(p, \"statSync\", () => toFileInfo(fsSync.statSync(p))),\n\n copyFileSync: (src: string, dest: string): Either<FsError, void> =>\n liftSync(src, \"copyFileSync\", () => fsSync.copyFileSync(src, dest)),\n\n renameSync: (oldPath: string, newPath: string): Either<FsError, void> =>\n liftSync(oldPath, \"renameSync\", () => fsSync.renameSync(oldPath, newPath)),\n\n readdirSync: (p: string): Either<FsError, List<string>> =>\n liftSync(p, \"readdirSync\", () => List(fsSync.readdirSync(p))),\n\n writeFileSync: (p: string, data: string, encoding: BufferEncoding = \"utf8\"): Either<FsError, void> =>\n liftSync(p, \"writeFileSync\", () => fsSync.writeFileSync(p, data, { encoding })),\n\n appendFileSync: (p: string, data: string, encoding: BufferEncoding = \"utf8\"): Either<FsError, void> =>\n liftSync(p, \"appendFileSync\", () => fsSync.appendFileSync(p, data, { encoding })),\n\n mkdirSync: (p: string, options?: { recursive?: boolean }): Either<FsError, void> => {\n if (options?.recursive && isMagicFsPath(p)) {\n return Left(\n toFsError(p, \"mkdirSync\", new Error(\"recursive mkdir refused under magic filesystem root (/proc, /sys, /dev)\")),\n )\n }\n return liftSync(p, \"mkdirSync\", () => {\n fsSync.mkdirSync(p, options)\n })\n },\n\n unlinkSync: (p: string): Either<FsError, void> => liftSync(p, \"unlinkSync\", () => fsSync.unlinkSync(p)),\n}\n"],"mappings":"sMAmBA,MAAME,EAAc,IAAmC,CACrD,KAAMC,EAAM,KACZ,OAAQA,EAAM,OAAO,EACrB,YAAaA,EAAM,YAAY,EAC/B,eAAgBA,EAAM,eAAe,EACrC,UAAWA,EAAM,UACjB,WAAYA,EAAM,MAClB,WAAYA,EAAM,MAClB,YAAaA,EAAM,IACrB,GAEMC,GAAa,EAAW,EAAY,IACxCC,EAAQC,EAAGC,EAAIC,aA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CiC,EACLnC,EAAUE,EAAG,YAAa,gBAAI,MAAM,yEAAyE,CAAC,CAChH,EAEKiB,EAASjB,EAAG,gBAAmB,CACpCN,EAAO,UAAUM,EAAG+B,CAAO,CAC7B,CAAC,EAGH,WAAa,GAAqCd,EAASjB,EAAG,iBAAoBN,EAAO,WAAWM,CAAC,CAAC,CACxG"}
@@ -1,2 +1,2 @@
1
- import { n as Fs, t as FileInfo } from "../Fs-BkxuVfog.js";
1
+ import { n as Fs, t as FileInfo } from "../Fs-CPL0SxYV.js";
2
2
  export { type FileInfo, Fs };
package/dist/fs/index.js CHANGED
@@ -1 +1 @@
1
- export{Fs}from"./Fs.js";
1
+ import{Fs as e}from"./Fs.js";export{e as Fs};
package/dist/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- import { a as PathError, i as OsError, n as EnvError, o as ProcessError, r as FsError, t as ConfigError } from "./errors-BIVj3Unk.js";
2
- import { t as ConfigResolver } from "./ConfigResolver-p4Th3EPd.js";
1
+ import { a as PathError, i as OsError, n as EnvError, o as ProcessError, r as FsError, t as ConfigError } from "./errors-uqbMcCFM.js";
2
+ import { t as ConfigResolver } from "./ConfigResolver-DpDKZFFL.js";
3
3
  import "./config/index.js";
4
- import { t as Env } from "./Env-eeHQ5oLF.js";
4
+ import { t as Env } from "./Env-CYRuNIYH.js";
5
5
  import "./env/index.js";
6
6
  import "./errors/index.js";
7
- import { n as Fs, t as FileInfo } from "./Fs-BkxuVfog.js";
7
+ import { n as Fs, t as FileInfo } from "./Fs-CPL0SxYV.js";
8
8
  import "./fs/index.js";
9
- import { i as expandVars, n as expandPath, r as expandTilde, t as Path } from "./PathExpander-Czw7TQBj.js";
9
+ import { i as expandVars, n as expandPath, r as expandTilde, t as Path } from "./PathExpander-DeA4vwTt.js";
10
10
  import "./path/index.js";
11
- import { i as UserInfo, n as CloudStorageDir, r as Platform, t as CloudProvider } from "./Platform-CxcnVBOy.js";
11
+ import { i as UserInfo, n as CloudStorageDir, r as Platform, t as CloudProvider } from "./Platform-ceKNPX6R.js";
12
12
  import "./platform/index.js";
13
- import { n as Process, t as ExecResult } from "./Process-BqMq_szA.js";
13
+ import { n as Process, t as ExecResult } from "./Process-DsE1sS2Y.js";
14
14
  import "./process/index.js";
15
15
  export { type CloudProvider, type CloudStorageDir, ConfigError, ConfigResolver, Env, EnvError, type ExecResult, type FileInfo, Fs, FsError, type OsError, Path, PathError, Platform, Process, ProcessError, type UserInfo, expandPath, expandTilde, expandVars };
@@ -1,3 +1,4 @@
1
+ //#region src/config/mask.d.ts
1
2
  /**
2
3
  * Mask a sensitive value for display in boot diagnostics or logs.
3
4
  *
@@ -16,5 +17,6 @@
16
17
  * ```
17
18
  */
18
19
  declare const maskValue: (value: string) => string;
20
+ //#endregion
19
21
  export { maskValue as t };
20
- //# sourceMappingURL=mask-O-SEN-kZ.d.ts.map
22
+ //# sourceMappingURL=mask-BLjNp9FP.d.ts.map
@@ -1,2 +1,2 @@
1
- import { i as expandVars, n as expandPath, r as expandTilde, t as Path } from "../PathExpander-Czw7TQBj.js";
1
+ import { i as expandVars, n as expandPath, r as expandTilde, t as Path } from "../PathExpander-DeA4vwTt.js";
2
2
  export { Path, expandPath, expandTilde, expandVars };
@@ -1 +1 @@
1
- {"version":3,"file":"PathExpander.js","names":["os","nodePath","expandTilde","p","expandVars","unresolvedVars","result","captures","varName","Option","value","_match","Left","PathError","Right","expandPath","tildeExpanded","varsResult","Path","segments","suffix"],"sources":["../../src/path/PathExpander.ts"],"sourcesContent":["import * as os from \"node:os\"\nimport * as nodePath from \"node:path\"\n\nimport type { Either } from \"functype\"\nimport { Left, Option, Right } from \"functype\"\n\nimport { PathError } from \"../errors/errors\"\n\nexport const expandTilde = (p: string): string => {\n if (p === \"~\") return os.homedir()\n if (p.startsWith(\"~/\") || p.startsWith(\"~\\\\\")) return nodePath.join(os.homedir(), p.slice(2))\n return p\n}\n\nexport const expandVars = (p: string): Either<PathError, string> => {\n const unresolvedVars: string[] = []\n // Factor out the leading `$` and forbid `$` inside `${...}` so the engine\n // can't backtrack catastrophically on inputs like `${{${{${{...` (CodeQL\n // js/polynomial-redos).\n const result = p.replace(/\\$(?:\\{([^}$]+)\\}|([A-Za-z_][A-Za-z0-9_]*))/g, (_match: string, ...captures: unknown[]) => {\n const varName = Option(captures[0] as string | undefined)\n .or(Option(captures[1] as string | undefined))\n .orElse(\"\")\n const value = process.env[varName]\n if (value === undefined) {\n unresolvedVars.push(varName)\n return _match\n }\n return value\n })\n\n if (unresolvedVars.length > 0) {\n return Left(PathError(p, \"unresolved_variable\", `Unresolved variables: ${unresolvedVars.join(\", \")}`))\n }\n\n return Right(result)\n}\n\nexport const expandPath = (p: string): Either<PathError, string> => {\n const tildeExpanded = expandTilde(p)\n const varsResult = expandVars(tildeExpanded)\n if (varsResult.isLeft()) return varsResult\n return Right(nodePath.resolve(varsResult.orThrow()))\n}\n\nexport const Path = {\n expand: expandPath,\n expandTilde,\n expandVars,\n join: (...segments: string[]): string => nodePath.join(...segments),\n resolve: (...segments: string[]): string => nodePath.resolve(...segments),\n dirname: (p: string): string => nodePath.dirname(p),\n basename: (p: string, suffix?: string): string => nodePath.basename(p, suffix),\n extname: (p: string): string => nodePath.extname(p),\n isAbsolute: (p: string): boolean => nodePath.isAbsolute(p),\n}\n"],"mappings":"A,6JAQA,MAAaE,EAAe,GACtBC,IAAM,IAAYH,EAAG,QAAQ,EAC7BG,EAAE,WAAW,IAAI,GAAKA,EAAE,WAAW,KAAK,EAAUF,EAAS,KAAKD,EAAG,QAAQ,EAAGG,EAAE,MAAM,CAAC,CAAC,EACrFA,EAGIC,EAAc,GAAyC,CAClE,IAAMC,EAA2B,CAAC,EAI5BC,EAASH,EAAE,QAAQ,gDAAiD,EAAgB,GAAGI,IAAwB,CACnH,IAAMC,EAAUC,EAAOF,EAAS,EAAwB,CAAC,CACtD,GAAGE,EAAOF,EAAS,EAAwB,CAAC,CAAC,CAC7C,OAAO,EAAE,EACNG,EAAQ,QAAQ,IAAIF,GAK1B,OAJIE,IAAU,IAAA,IACZL,EAAe,KAAKG,CAAO,EACpBG,GAEFD,CACT,CAAC,EAMD,OAJIL,EAAe,OAAS,EACnBO,EAAKC,EAAUV,EAAG,sBAAuB,yBAAyBE,EAAe,KAAK,IAAI,GAAG,CAAC,EAGhGS,EAAMR,CAAM,CACrB,EAEaS,EAAc,GAAyC,CAClE,IAAMC,EAAgBd,EAAYC,CAAC,EAC7Bc,EAAab,EAAWY,CAAa,EAE3C,OADIC,EAAW,OAAO,EAAUA,EACzBH,EAAMb,EAAS,QAAQgB,EAAW,QAAQ,CAAC,CAAC,CACrD,EAEaC,EAAO,CAClB,OAAQH,EACR,cACA,aACA,MAAO,GAAGI,IAA+BlB,EAAS,KAAK,GAAGkB,CAAQ,EAClE,SAAU,GAAGA,IAA+BlB,EAAS,QAAQ,GAAGkB,CAAQ,EACxE,QAAU,GAAsBlB,EAAS,QAAQE,CAAC,EAClD,UAAW,EAAW,IAA4BF,EAAS,SAASE,EAAGiB,CAAM,EAC7E,QAAU,GAAsBnB,EAAS,QAAQE,CAAC,EAClD,WAAa,GAAuBF,EAAS,WAAWE,CAAC,CAC3D,E"}
1
+ {"version":3,"file":"PathExpander.js","names":["os","nodePath","expandTilde","p","expandVars","unresolvedVars","result","captures","varName","Option","value","_match","Left","PathError","Right","expandPath","tildeExpanded","varsResult","Path","segments","suffix"],"sources":["../../src/path/PathExpander.ts"],"sourcesContent":["import * as os from \"node:os\"\nimport * as nodePath from \"node:path\"\n\nimport type { Either } from \"functype\"\nimport { Left, Option, Right } from \"functype\"\n\nimport { PathError } from \"../errors/errors\"\n\nexport const expandTilde = (p: string): string => {\n if (p === \"~\") return os.homedir()\n if (p.startsWith(\"~/\") || p.startsWith(\"~\\\\\")) return nodePath.join(os.homedir(), p.slice(2))\n return p\n}\n\nexport const expandVars = (p: string): Either<PathError, string> => {\n const unresolvedVars: string[] = []\n // Factor out the leading `$` and forbid `$` inside `${...}` so the engine\n // can't backtrack catastrophically on inputs like `${{${{${{...` (CodeQL\n // js/polynomial-redos).\n const result = p.replace(/\\$(?:\\{([^}$]+)\\}|([A-Za-z_][A-Za-z0-9_]*))/g, (_match: string, ...captures: unknown[]) => {\n const varName = Option(captures[0] as string | undefined)\n .or(Option(captures[1] as string | undefined))\n .orElse(\"\")\n const value = process.env[varName]\n if (value === undefined) {\n unresolvedVars.push(varName)\n return _match\n }\n return value\n })\n\n if (unresolvedVars.length > 0) {\n return Left(PathError(p, \"unresolved_variable\", `Unresolved variables: ${unresolvedVars.join(\", \")}`))\n }\n\n return Right(result)\n}\n\nexport const expandPath = (p: string): Either<PathError, string> => {\n const tildeExpanded = expandTilde(p)\n const varsResult = expandVars(tildeExpanded)\n if (varsResult.isLeft()) return varsResult\n return Right(nodePath.resolve(varsResult.orThrow()))\n}\n\nexport const Path = {\n expand: expandPath,\n expandTilde,\n expandVars,\n join: (...segments: string[]): string => nodePath.join(...segments),\n resolve: (...segments: string[]): string => nodePath.resolve(...segments),\n dirname: (p: string): string => nodePath.dirname(p),\n basename: (p: string, suffix?: string): string => nodePath.basename(p, suffix),\n extname: (p: string): string => nodePath.extname(p),\n isAbsolute: (p: string): boolean => nodePath.isAbsolute(p),\n}\n"],"mappings":"6JAQA,MAAaE,EAAe,GACtBC,IAAM,IAAYH,EAAG,QAAQ,EAC7BG,EAAE,WAAW,IAAI,GAAKA,EAAE,WAAW,KAAK,EAAUF,EAAS,KAAKD,EAAG,QAAQ,EAAGG,EAAE,MAAM,CAAC,CAAC,EACrFA,EAGIC,EAAc,GAAyC,CAClE,IAAMC,EAA2B,CAAC,EAI5BC,EAASH,EAAE,QAAQ,gDAAiD,EAAgB,GAAGI,IAAwB,CACnH,IAAMC,EAAUC,EAAOF,EAAS,EAAwB,CAAC,CACtD,GAAGE,EAAOF,EAAS,EAAwB,CAAC,CAAC,CAC7C,OAAO,EAAE,EACNG,EAAQ,QAAQ,IAAIF,GAK1B,OAJIE,IAAU,IAAA,IACZL,EAAe,KAAKG,CAAO,EACpBG,GAEFD,CACT,CAAC,EAMD,OAJIL,EAAe,OAAS,EACnBO,EAAKC,EAAUV,EAAG,sBAAuB,yBAAyBE,EAAe,KAAK,IAAI,GAAG,CAAC,EAGhGS,EAAMR,CAAM,CACrB,EAEaS,EAAc,GAAyC,CAClE,IAAMC,EAAgBd,EAAYC,CAAC,EAC7Bc,EAAab,EAAWY,CAAa,EAE3C,OADIC,EAAW,OAAO,EAAUA,EACzBH,EAAMb,EAAS,QAAQgB,EAAW,QAAQ,CAAC,CAAC,CACrD,EAEaC,EAAO,CAClB,OAAQH,EACR,cACA,aACA,MAAO,GAAGI,IAA+BlB,EAAS,KAAK,GAAGkB,CAAQ,EAClE,SAAU,GAAGA,IAA+BlB,EAAS,QAAQ,GAAGkB,CAAQ,EACxE,QAAU,GAAsBlB,EAAS,QAAQE,CAAC,EAClD,UAAW,EAAW,IAA4BF,EAAS,SAASE,EAAGiB,CAAM,EAC7E,QAAU,GAAsBnB,EAAS,QAAQE,CAAC,EAClD,WAAa,GAAuBF,EAAS,WAAWE,CAAC,CAC3D"}
@@ -1,2 +1,2 @@
1
- import { i as expandVars, n as expandPath, r as expandTilde, t as Path } from "../PathExpander-Czw7TQBj.js";
1
+ import { i as expandVars, n as expandPath, r as expandTilde, t as Path } from "../PathExpander-DeA4vwTt.js";
2
2
  export { Path, expandPath, expandTilde, expandVars };
@@ -1 +1 @@
1
- export{Path,expandPath,expandTilde,expandVars}from"./PathExpander.js";
1
+ import{Path as e,expandPath as t,expandTilde as n,expandVars as r}from"./PathExpander.js";export{e as Path,t as expandPath,n as expandTilde,r as expandVars};
@@ -1,2 +1,2 @@
1
- import { i as UserInfo, n as CloudStorageDir, r as Platform, t as CloudProvider } from "../Platform-CxcnVBOy.js";
1
+ import { i as UserInfo, n as CloudStorageDir, r as Platform, t as CloudProvider } from "../Platform-ceKNPX6R.js";
2
2
  export { CloudProvider, CloudStorageDir, Platform, UserInfo };
@@ -1 +1 @@
1
- {"version":3,"file":"Platform.js","names":["fs","os","path","hasDockerEnv","Try","hasDockerCGroup","contents","matched","memo","cache","fn","cachedIsDocker","cachedIsKube","cachedIsWSL","version","cachedIsCI","\"CI\"","\"GITHUB_ACTIONS\"","\"GITLAB_CI\"","\"CIRCLECI\"","\"JENKINS_URL\"","\"TRAVIS\"","\"BUILDKITE\"","SYSTEM_ACCOUNTS","Set","isSystemAccount","lower","name","isDirectory","p","isDir","readRealUsers","usersDir","entries","resolveViaCmdExe","parsed","execSync","match","raw","Option","wslPath","fallback","cachedWindowsHome","realUsers","detectCloudProvider","scanDirectChildren","home","fullPath","detection","results","scanMacCloudStorage","cloudStoragePath","scanMacICloud","icloudPath","scanCloudStorageDirs","Platform","info","primary","windowsHome","h","List","deduped","acc","dir"],"sources":["../../src/platform/Platform.ts"],"sourcesContent":["import { execSync } from \"node:child_process\"\nimport * as fs from \"node:fs\"\nimport * as os from \"node:os\"\nimport * as path from \"node:path\"\n\nimport { List, Option, Set, Try } from \"functype\"\n\nexport type UserInfo = {\n readonly username: string\n readonly uid: number\n readonly gid: number\n readonly shell: Option<string>\n readonly homedir: string\n}\n\nexport type CloudProvider = \"onedrive\" | \"gdrive\" | \"dropbox\" | \"icloud\"\n\nexport type CloudStorageDir = {\n readonly provider: CloudProvider\n readonly path: string\n readonly label: string\n}\n\nconst hasDockerEnv = (): boolean => Try(() => fs.statSync(\"/.dockerenv\")).isSuccess()\n\nconst hasDockerCGroup = (): boolean =>\n Try(() => fs.readFileSync(\"/proc/self/cgroup\", \"utf8\"))\n .map((contents) => contents.includes(\"docker\"))\n .toEither((): boolean => false)\n .fold(\n () => false,\n (matched) => matched,\n )\n\nconst memo = <T>(fn: () => T): (() => T) => {\n const cache: { value?: T } = {}\n return () => {\n if (!(\"value\" in cache)) {\n cache.value = fn()\n }\n return cache.value as T\n }\n}\n\nconst cachedIsDocker = memo(() => hasDockerEnv() || hasDockerCGroup())\nconst cachedIsKube = memo(() =>\n Try(() => fs.readFileSync(\"/proc/self/cgroup\", \"utf8\"))\n .map((contents) => contents.includes(\"kube\"))\n .fold(\n () => false,\n (matched) => matched,\n ),\n)\nconst cachedIsWSL = memo(() =>\n Try(() => fs.readFileSync(\"/proc/version\", \"utf8\"))\n .map((version) => version.includes(\"Microsoft\") || version.includes(\"WSL\"))\n .fold(\n () => false,\n (matched) => matched,\n ),\n)\nconst cachedIsCI = memo(\n () =>\n process.env[\"CI\"] !== undefined ||\n process.env[\"GITHUB_ACTIONS\"] !== undefined ||\n process.env[\"GITLAB_CI\"] !== undefined ||\n process.env[\"CIRCLECI\"] !== undefined ||\n process.env[\"JENKINS_URL\"] !== undefined ||\n process.env[\"TRAVIS\"] !== undefined ||\n process.env[\"BUILDKITE\"] !== undefined,\n)\n\nconst SYSTEM_ACCOUNTS = Set.of(\"all users\", \"default\", \"default user\", \"public\")\n\nconst isSystemAccount = (name: string): boolean => {\n const lower = name.toLowerCase()\n if (SYSTEM_ACCOUNTS.contains(lower)) return true\n if (lower.startsWith(\"defaultuser\") || lower.startsWith(\"desktop.\") || lower.startsWith(\"wsiaccount\")) return true\n return false\n}\n\nconst isDirectory = (p: string): boolean =>\n Try(() => fs.statSync(p).isDirectory()).fold(\n () => false,\n (isDir) => isDir,\n )\n\nconst readRealUsers = (usersDir: string): Option<readonly string[]> => {\n const filterRealUsers = (entries: readonly string[]): readonly string[] =>\n entries.filter((name) => !isSystemAccount(name) && isDirectory(path.join(usersDir, name)))\n return Try(() => fs.readdirSync(usersDir))\n .map(filterRealUsers)\n .toOption()\n}\n\nconst resolveViaCmdExe = (usersDir: string, fallback: string): Option<string> => {\n // Convert Windows path C:\\Users\\foo → /mnt/c/Users/foo if it's a directory;\n // returns None for unparseable output or non-existent directories.\n const parseCmdOutput = (raw: string): Option<string> => {\n const match = raw.match(/^([A-Za-z]):\\\\(.*)$/)\n if (!match) return Option<string>(undefined)\n const drive = (match[1] as string).toLowerCase()\n const rest = (match[2] as string).replace(/\\\\/g, \"/\")\n const wslPath = `/mnt/${drive}/${rest}`\n return isDirectory(wslPath) ? Option(wslPath) : Option<string>(undefined)\n }\n const parsed = Try(() => execSync(\"cmd.exe /c echo %USERPROFILE%\", { timeout: 3000, encoding: \"utf8\" }).trim())\n .toOption()\n .flatMap(parseCmdOutput)\n .orElse(fallback)\n return Option(parsed)\n}\n\nconst resolveWindowsHome = (): Option<string> => {\n if (!cachedIsWSL()) return Option<string>(undefined)\n\n const usersDir = \"/mnt/c/Users\"\n return readRealUsers(usersDir).fold<Option<string>>(\n () => Option<string>(undefined),\n (realUsers) => {\n if (realUsers.length === 1) return Option(path.join(usersDir, realUsers[0] as string))\n if (realUsers.length > 1) return resolveViaCmdExe(usersDir, path.join(usersDir, realUsers[0] as string))\n return Option<string>(undefined)\n },\n )\n}\n\nconst cachedWindowsHome = memo(resolveWindowsHome)\n\ntype CloudDetection = { readonly provider: CloudProvider; readonly label: string }\n\nconst detectCloudProvider = (name: string): Option<CloudDetection> => {\n if (name === \"OneDrive\" || name.startsWith(\"OneDrive \") || name.startsWith(\"OneDrive-\")) {\n return Option({ provider: \"onedrive\" as const, label: name })\n }\n if (name === \"Google Drive\") return Option({ provider: \"gdrive\" as const, label: name })\n if (name === \"Dropbox\") return Option({ provider: \"dropbox\" as const, label: name })\n return Option<CloudDetection>(undefined)\n}\n\nconst scanDirectChildren = (home: string): readonly CloudStorageDir[] =>\n Try(() => fs.readdirSync(home))\n .map((entries) =>\n entries.flatMap((name): CloudStorageDir[] => {\n const fullPath = path.join(home, name)\n return detectCloudProvider(name).fold<CloudStorageDir[]>(\n () => [],\n (detection) =>\n isDirectory(fullPath) ? [{ provider: detection.provider, path: fullPath, label: detection.label }] : [],\n )\n }),\n )\n .fold<readonly CloudStorageDir[]>(\n () => [],\n (results) => results,\n )\n\nconst scanMacCloudStorage = (home: string): readonly CloudStorageDir[] => {\n const cloudStoragePath = path.join(home, \"Library\", \"CloudStorage\")\n return Try(() => fs.readdirSync(cloudStoragePath))\n .map((entries) =>\n entries.flatMap((name): CloudStorageDir[] => {\n const fullPath = path.join(cloudStoragePath, name)\n if (!isDirectory(fullPath)) return []\n if (name.startsWith(\"OneDrive\")) return [{ provider: \"onedrive\", path: fullPath, label: name }]\n if (name.startsWith(\"GoogleDrive\")) return [{ provider: \"gdrive\", path: fullPath, label: name }]\n return []\n }),\n )\n .fold<readonly CloudStorageDir[]>(\n () => [],\n (results) => results,\n )\n}\n\nconst scanMacICloud = (home: string): readonly CloudStorageDir[] => {\n const icloudPath = path.join(home, \"Library\", \"Mobile Documents\", \"com~apple~CloudDocs\")\n return isDirectory(icloudPath) ? [{ provider: \"icloud\", path: icloudPath, label: \"iCloud Drive\" }] : []\n}\n\nconst scanCloudStorageDirs = (home: string): readonly CloudStorageDir[] => [\n ...scanDirectChildren(home),\n ...scanMacCloudStorage(home),\n ...scanMacICloud(home),\n]\n\nexport const Platform = {\n os: (): \"darwin\" | \"linux\" | \"win32\" | string => process.platform,\n arch: (): string => process.arch,\n homeDir: (): string => os.homedir(),\n tmpDir: (): string => os.tmpdir(),\n hostname: (): string => os.hostname(),\n eol: (): string => os.EOL,\n pathSep: (): string => path.sep,\n\n isWindows: (): boolean => process.platform === \"win32\",\n isMac: (): boolean => process.platform === \"darwin\",\n isLinux: (): boolean => process.platform === \"linux\",\n\n userInfo: (): Option<UserInfo> => {\n const toUserInfo = (info: os.UserInfo<string>): UserInfo => ({\n username: info.username,\n uid: info.uid,\n gid: info.gid,\n shell: Option(info.shell),\n homedir: info.homedir,\n })\n return Try(() => os.userInfo())\n .map(toUserInfo)\n .toOption()\n },\n\n isDocker: (): boolean => cachedIsDocker(),\n isKubernetes: (): boolean => cachedIsKube(),\n isWSL: (): boolean => cachedIsWSL(),\n isCI: (): boolean => cachedIsCI(),\n\n isContainer: (): boolean => Platform.isDocker() || Platform.isKubernetes(),\n\n windowsHomeDir: (): Option<string> => cachedWindowsHome(),\n\n homeDirs: (): List<string> => {\n const primary = os.homedir()\n const windowsHome = Platform.windowsHomeDir().fold<readonly string[]>(\n () => [],\n (h) => (h !== primary ? [h] : []),\n )\n return List<string>([primary, ...windowsHome])\n },\n\n cloudStorageDirs: (home?: string): List<CloudStorageDir> => {\n if (home !== undefined) return List(scanCloudStorageDirs(home))\n const allDirs = Platform.homeDirs()\n .toArray()\n .flatMap((h) => [...scanCloudStorageDirs(h)])\n // Deduplicate by path, first-wins\n const deduped = allDirs.reduce<{\n readonly seen: ReadonlyArray<string>\n readonly results: ReadonlyArray<CloudStorageDir>\n }>(\n (acc, dir) =>\n acc.seen.includes(dir.path) ? acc : { seen: [...acc.seen, dir.path], results: [...acc.results, dir] },\n { seen: [], results: [] },\n )\n return List(deduped.results)\n },\n}\n"],"mappings":"A,4LAuBA,MAAMG,MAA8BC,MAAUJ,EAAG,SAAS,aAAa,CAAC,CAAC,CAAC,UAAU,EAE9EK,MACJD,MAAUJ,EAAG,aAAa,oBAAqB,MAAM,CAAC,CAAC,CACpD,IAAK,GAAaM,EAAS,SAAS,QAAQ,CAAC,CAAC,CAC9C,aAAwB,EAAK,CAAC,CAC9B,SACO,GACL,GAAYC,CACf,EAEEC,EAAW,GAA2B,CAC1C,IAAMC,EAAuB,CAAC,EAC9B,WACQ,UAAWA,IACf,EAAM,MAAQC,EAAG,GAEZD,EAAM,MAEjB,EAEME,EAAiBH,MAAWL,EAAa,GAAKE,EAAgB,CAAC,EAC/DO,EAAeJ,MACnBJ,MAAUJ,EAAG,aAAa,oBAAqB,MAAM,CAAC,CAAC,CACpD,IAAK,GAAaM,EAAS,SAAS,MAAM,CAAC,CAAC,CAC5C,SACO,GACL,GAAYC,CACf,CACJ,EACMM,EAAcL,MAClBJ,MAAUJ,EAAG,aAAa,gBAAiB,MAAM,CAAC,CAAC,CAChD,IAAK,GAAYc,EAAQ,SAAS,WAAW,GAAKA,EAAQ,SAAS,KAAK,CAAC,CAAC,CAC1E,SACO,GACL,GAAYP,CACf,CACJ,EACMQ,EAAaP,MAEf,QAAQ,IAAIQ,KAAU,IAAA,IACtB,QAAQ,IAAIC,iBAAsB,IAAA,IAClC,QAAQ,IAAI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EAEzE,mBAAsCb,EAAkB,EAExD,aAA8B,CAC5B,IAAMe,EAAUxD,EAAG,QAAQ,EACrByD,EAAcH,EAAS,eAAe,CAAC,CAAC,SACtC,CAAC,EACN,GAAOI,IAAMF,EAAgB,CAAC,EAAP,CAACE,CAAC,CAC5B,EACA,OAAOC,EAAa,CAACH,EAAS,GAAGC,CAAW,CAAC,CAC/C,EAEA,iBAAmB,GAAyC,CAC1D,GAAIZ,IAAS,IAAA,GAAW,OAAOc,EAAKN,EAAqBR,CAAI,CAAC,EAK9D,IAAMe,EAJUN,EAAS,SAAS,CAAC,CAChC,QAAQ,CAAC,CACT,QAAS,GAAM,CAAC,GAAGD,EAAqBK,CAAC,CAAC,CAEvB,CAAC,CAAC,QAIrB,EAAK,IACJG,EAAI,KAAK,SAASC,EAAI,IAAI,EAAID,EAAM,CAAE,KAAM,CAAC,GAAGA,EAAI,KAAMC,EAAI,IAAI,EAAG,QAAS,CAAC,GAAGD,EAAI,QAASC,CAAG,CAAE,EACtG,CAAE,KAAM,CAAC,EAAG,QAAS,CAAC,CAAE,CAC1B,EACA,OAAOH,EAAKC,EAAQ,OAAO,CAC7B,CACF,E"}
1
+ {"version":3,"file":"Platform.js","names":["fs","os","path","hasDockerEnv","Try","hasDockerCGroup","contents","matched","memo","cache","fn","cachedIsDocker","cachedIsKube","cachedIsWSL","version","cachedIsCI","\"CI\"","\"GITHUB_ACTIONS\"","\"GITLAB_CI\"","\"CIRCLECI\"","\"JENKINS_URL\"","\"TRAVIS\"","\"BUILDKITE\"","SYSTEM_ACCOUNTS","Set","isSystemAccount","lower","name","isDirectory","p","isDir","readRealUsers","usersDir","entries","resolveViaCmdExe","parsed","execSync","match","raw","Option","wslPath","fallback","cachedWindowsHome","realUsers","detectCloudProvider","scanDirectChildren","home","fullPath","detection","results","scanMacCloudStorage","cloudStoragePath","scanMacICloud","icloudPath","scanCloudStorageDirs","Platform","info","primary","windowsHome","h","List","deduped","acc","dir"],"sources":["../../src/platform/Platform.ts"],"sourcesContent":["import { execSync } from \"node:child_process\"\nimport * as fs from \"node:fs\"\nimport * as os from \"node:os\"\nimport * as path from \"node:path\"\n\nimport { List, Option, Set, Try } from \"functype\"\n\nexport type UserInfo = {\n readonly username: string\n readonly uid: number\n readonly gid: number\n readonly shell: Option<string>\n readonly homedir: string\n}\n\nexport type CloudProvider = \"onedrive\" | \"gdrive\" | \"dropbox\" | \"icloud\"\n\nexport type CloudStorageDir = {\n readonly provider: CloudProvider\n readonly path: string\n readonly label: string\n}\n\nconst hasDockerEnv = (): boolean => Try(() => fs.statSync(\"/.dockerenv\")).isSuccess()\n\nconst hasDockerCGroup = (): boolean =>\n Try(() => fs.readFileSync(\"/proc/self/cgroup\", \"utf8\"))\n .map((contents) => contents.includes(\"docker\"))\n .toEither((): boolean => false)\n .fold(\n () => false,\n (matched) => matched,\n )\n\nconst memo = <T>(fn: () => T): (() => T) => {\n const cache: { value?: T } = {}\n return () => {\n if (!(\"value\" in cache)) {\n cache.value = fn()\n }\n return cache.value as T\n }\n}\n\nconst cachedIsDocker = memo(() => hasDockerEnv() || hasDockerCGroup())\nconst cachedIsKube = memo(() =>\n Try(() => fs.readFileSync(\"/proc/self/cgroup\", \"utf8\"))\n .map((contents) => contents.includes(\"kube\"))\n .fold(\n () => false,\n (matched) => matched,\n ),\n)\nconst cachedIsWSL = memo(() =>\n Try(() => fs.readFileSync(\"/proc/version\", \"utf8\"))\n .map((version) => version.includes(\"Microsoft\") || version.includes(\"WSL\"))\n .fold(\n () => false,\n (matched) => matched,\n ),\n)\nconst cachedIsCI = memo(\n () =>\n process.env[\"CI\"] !== undefined ||\n process.env[\"GITHUB_ACTIONS\"] !== undefined ||\n process.env[\"GITLAB_CI\"] !== undefined ||\n process.env[\"CIRCLECI\"] !== undefined ||\n process.env[\"JENKINS_URL\"] !== undefined ||\n process.env[\"TRAVIS\"] !== undefined ||\n process.env[\"BUILDKITE\"] !== undefined,\n)\n\nconst SYSTEM_ACCOUNTS = Set.of(\"all users\", \"default\", \"default user\", \"public\")\n\nconst isSystemAccount = (name: string): boolean => {\n const lower = name.toLowerCase()\n if (SYSTEM_ACCOUNTS.contains(lower)) return true\n if (lower.startsWith(\"defaultuser\") || lower.startsWith(\"desktop.\") || lower.startsWith(\"wsiaccount\")) return true\n return false\n}\n\nconst isDirectory = (p: string): boolean =>\n Try(() => fs.statSync(p).isDirectory()).fold(\n () => false,\n (isDir) => isDir,\n )\n\nconst readRealUsers = (usersDir: string): Option<readonly string[]> => {\n const filterRealUsers = (entries: readonly string[]): readonly string[] =>\n entries.filter((name) => !isSystemAccount(name) && isDirectory(path.join(usersDir, name)))\n return Try(() => fs.readdirSync(usersDir))\n .map(filterRealUsers)\n .toOption()\n}\n\nconst resolveViaCmdExe = (usersDir: string, fallback: string): Option<string> => {\n // Convert Windows path C:\\Users\\foo → /mnt/c/Users/foo if it's a directory;\n // returns None for unparseable output or non-existent directories.\n const parseCmdOutput = (raw: string): Option<string> => {\n const match = raw.match(/^([A-Za-z]):\\\\(.*)$/)\n if (!match) return Option<string>(undefined)\n const drive = (match[1] as string).toLowerCase()\n const rest = (match[2] as string).replace(/\\\\/g, \"/\")\n const wslPath = `/mnt/${drive}/${rest}`\n return isDirectory(wslPath) ? Option(wslPath) : Option<string>(undefined)\n }\n const parsed = Try(() => execSync(\"cmd.exe /c echo %USERPROFILE%\", { timeout: 3000, encoding: \"utf8\" }).trim())\n .toOption()\n .flatMap(parseCmdOutput)\n .orElse(fallback)\n return Option(parsed)\n}\n\nconst resolveWindowsHome = (): Option<string> => {\n if (!cachedIsWSL()) return Option<string>(undefined)\n\n const usersDir = \"/mnt/c/Users\"\n return readRealUsers(usersDir).fold<Option<string>>(\n () => Option<string>(undefined),\n (realUsers) => {\n if (realUsers.length === 1) return Option(path.join(usersDir, realUsers[0] as string))\n if (realUsers.length > 1) return resolveViaCmdExe(usersDir, path.join(usersDir, realUsers[0] as string))\n return Option<string>(undefined)\n },\n )\n}\n\nconst cachedWindowsHome = memo(resolveWindowsHome)\n\ntype CloudDetection = { readonly provider: CloudProvider; readonly label: string }\n\nconst detectCloudProvider = (name: string): Option<CloudDetection> => {\n if (name === \"OneDrive\" || name.startsWith(\"OneDrive \") || name.startsWith(\"OneDrive-\")) {\n return Option({ provider: \"onedrive\" as const, label: name })\n }\n if (name === \"Google Drive\") return Option({ provider: \"gdrive\" as const, label: name })\n if (name === \"Dropbox\") return Option({ provider: \"dropbox\" as const, label: name })\n return Option<CloudDetection>(undefined)\n}\n\nconst scanDirectChildren = (home: string): readonly CloudStorageDir[] =>\n Try(() => fs.readdirSync(home))\n .map((entries) =>\n entries.flatMap((name): CloudStorageDir[] => {\n const fullPath = path.join(home, name)\n return detectCloudProvider(name).fold<CloudStorageDir[]>(\n () => [],\n (detection) =>\n isDirectory(fullPath) ? [{ provider: detection.provider, path: fullPath, label: detection.label }] : [],\n )\n }),\n )\n .fold<readonly CloudStorageDir[]>(\n () => [],\n (results) => results,\n )\n\nconst scanMacCloudStorage = (home: string): readonly CloudStorageDir[] => {\n const cloudStoragePath = path.join(home, \"Library\", \"CloudStorage\")\n return Try(() => fs.readdirSync(cloudStoragePath))\n .map((entries) =>\n entries.flatMap((name): CloudStorageDir[] => {\n const fullPath = path.join(cloudStoragePath, name)\n if (!isDirectory(fullPath)) return []\n if (name.startsWith(\"OneDrive\")) return [{ provider: \"onedrive\", path: fullPath, label: name }]\n if (name.startsWith(\"GoogleDrive\")) return [{ provider: \"gdrive\", path: fullPath, label: name }]\n return []\n }),\n )\n .fold<readonly CloudStorageDir[]>(\n () => [],\n (results) => results,\n )\n}\n\nconst scanMacICloud = (home: string): readonly CloudStorageDir[] => {\n const icloudPath = path.join(home, \"Library\", \"Mobile Documents\", \"com~apple~CloudDocs\")\n return isDirectory(icloudPath) ? [{ provider: \"icloud\", path: icloudPath, label: \"iCloud Drive\" }] : []\n}\n\nconst scanCloudStorageDirs = (home: string): readonly CloudStorageDir[] => [\n ...scanDirectChildren(home),\n ...scanMacCloudStorage(home),\n ...scanMacICloud(home),\n]\n\nexport const Platform = {\n os: (): \"darwin\" | \"linux\" | \"win32\" | string => process.platform,\n arch: (): string => process.arch,\n homeDir: (): string => os.homedir(),\n tmpDir: (): string => os.tmpdir(),\n hostname: (): string => os.hostname(),\n eol: (): string => os.EOL,\n pathSep: (): string => path.sep,\n\n isWindows: (): boolean => process.platform === \"win32\",\n isMac: (): boolean => process.platform === \"darwin\",\n isLinux: (): boolean => process.platform === \"linux\",\n\n userInfo: (): Option<UserInfo> => {\n const toUserInfo = (info: os.UserInfo<string>): UserInfo => ({\n username: info.username,\n uid: info.uid,\n gid: info.gid,\n shell: Option(info.shell),\n homedir: info.homedir,\n })\n return Try(() => os.userInfo())\n .map(toUserInfo)\n .toOption()\n },\n\n isDocker: (): boolean => cachedIsDocker(),\n isKubernetes: (): boolean => cachedIsKube(),\n isWSL: (): boolean => cachedIsWSL(),\n isCI: (): boolean => cachedIsCI(),\n\n isContainer: (): boolean => Platform.isDocker() || Platform.isKubernetes(),\n\n windowsHomeDir: (): Option<string> => cachedWindowsHome(),\n\n homeDirs: (): List<string> => {\n const primary = os.homedir()\n const windowsHome = Platform.windowsHomeDir().fold<readonly string[]>(\n () => [],\n (h) => (h !== primary ? [h] : []),\n )\n return List<string>([primary, ...windowsHome])\n },\n\n cloudStorageDirs: (home?: string): List<CloudStorageDir> => {\n if (home !== undefined) return List(scanCloudStorageDirs(home))\n const allDirs = Platform.homeDirs()\n .toArray()\n .flatMap((h) => [...scanCloudStorageDirs(h)])\n // Deduplicate by path, first-wins\n const deduped = allDirs.reduce<{\n readonly seen: ReadonlyArray<string>\n readonly results: ReadonlyArray<CloudStorageDir>\n }>(\n (acc, dir) =>\n acc.seen.includes(dir.path) ? acc : { seen: [...acc.seen, dir.path], results: [...acc.results, dir] },\n { seen: [], results: [] },\n )\n return List(deduped.results)\n },\n}\n"],"mappings":"4LAuBA,MAAMG,MAA8BC,MAAUJ,EAAG,SAAS,aAAa,CAAC,CAAC,CAAC,UAAU,EAE9EK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JG,EAAI,KAAK,SAASC,EAAI,IAAI,EAAID,EAAM,CAAE,KAAM,CAAC,GAAGA,EAAI,KAAMC,EAAI,IAAI,EAAG,QAAS,CAAC,GAAGD,EAAI,QAASC,CAAG,CAAE,EACtG,CAAE,KAAM,CAAC,EAAG,QAAS,CAAC,CAAE,CAC1B,EACA,OAAOH,EAAKC,EAAQ,OAAO,CAC7B,CACF"}
@@ -1,2 +1,2 @@
1
- import { i as UserInfo, n as CloudStorageDir, r as Platform, t as CloudProvider } from "../Platform-CxcnVBOy.js";
1
+ import { i as UserInfo, n as CloudStorageDir, r as Platform, t as CloudProvider } from "../Platform-ceKNPX6R.js";
2
2
  export { type CloudProvider, type CloudStorageDir, Platform, type UserInfo };
@@ -1 +1 @@
1
- export{Platform}from"./Platform.js";
1
+ import{Platform as e}from"./Platform.js";export{e as Platform};
@@ -1,2 +1,2 @@
1
- import { n as Process, t as ExecResult } from "../Process-BqMq_szA.js";
1
+ import { n as Process, t as ExecResult } from "../Process-DsE1sS2Y.js";
2
2
  export { ExecResult, Process };
@@ -1,2 +1,2 @@
1
- import{ProcessError as e}from"../errors/errors.js";import{IO as t,Left as n,Option as r,Right as i,Try as a}from"functype";import{exec as o,execSync as s}from"node:child_process";const c={exec:(a,s)=>t.fromPromiseEither(()=>new Promise(t=>{o(a,{timeout:s?.timeout,cwd:s?.cwd},(o,s,c)=>{if(o){let i=r(typeof o.code==`number`?o.code:void 0);t(n(e(a,i,String(c))))}else t(i({stdout:String(s),stderr:String(c),exitCode:0}))})})),execSync:(t,n)=>a(()=>s(t,{timeout:n?.timeout,cwd:n?.cwd,encoding:`utf8`,stdio:[`pipe`,`pipe`,`pipe`]})).toEither(n=>{if(n instanceof Error&&`status`in n&&`stderr`in n){let i=n;return e(t,r(i.status),String(i.stderr))}return e(t,r(void 0),``,n instanceof Error?n.message:String(n))}).map(e=>({stdout:String(e),stderr:``,exitCode:0}))};export{c as Process};
1
+ import{ProcessError as e}from"../errors/errors.js";import{Err as t,Ok as n,Option as r,Try as i}from"functype";import{exec as a,execSync as o}from"node:child_process";const s={exec:(i,o)=>new Promise(s=>{a(i,{timeout:o?.timeout,cwd:o?.cwd},(a,o,c)=>{if(a){let n=r(typeof a.code==`number`?a.code:void 0);s(t(e(i,n,String(c))))}else s(n({stdout:String(o),stderr:String(c),exitCode:0}))})}),execSync:(t,n)=>i(()=>o(t,{timeout:n?.timeout,cwd:n?.cwd,encoding:`utf8`,stdio:[`pipe`,`pipe`,`pipe`]})).toEither(n=>{if(n instanceof Error&&`status`in n&&`stderr`in n){let i=n;return e(t,r(i.status),String(i.stderr))}return e(t,r(void 0),``,n instanceof Error?n.message:String(n))}).map(e=>({stdout:String(e),stderr:``,exitCode:0}))};export{s as Process};
2
2
  //# sourceMappingURL=Process.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Process.js","names":["nodeExecSync","Process","IO","exec","command","options","error","exitCode","Option","resolve","Left","ProcessError","stderr","Right","stdout","Try","execSync","execError"],"sources":["../../src/process/Process.ts"],"sourcesContent":["import { exec as execCb, execSync as nodeExecSync } from \"node:child_process\"\n\nimport type { Either } from \"functype\"\nimport { IO, Left, Option, Right, Try } from \"functype\"\n\nimport { ProcessError } from \"../errors/errors\"\n\nexport type ExecResult = {\n readonly stdout: string\n readonly stderr: string\n readonly exitCode: number\n}\n\nexport const Process = {\n // Lazy: the command doesn't start until the IO runs.\n exec: (command: string, options?: { timeout?: number; cwd?: string }): IO<never, ProcessError, ExecResult> =>\n IO.fromPromiseEither(\n () =>\n new Promise<Either<ProcessError, ExecResult>>((resolve) => {\n execCb(command, { timeout: options?.timeout, cwd: options?.cwd }, (error, stdout, stderr) => {\n if (error) {\n // exec callback error has `code` as exit code (number) — distinct from Node errno `code` (string)\n const exitCode = Option(typeof error.code === \"number\" ? error.code : undefined)\n resolve(Left(ProcessError(command, exitCode, String(stderr))))\n } else {\n resolve(Right({ stdout: String(stdout), stderr: String(stderr), exitCode: 0 }))\n }\n })\n }),\n ),\n\n execSync: (command: string, options?: { timeout?: number; cwd?: string }): Either<ProcessError, ExecResult> => {\n const buildProcessError = (error: unknown): ProcessError => {\n if (error instanceof Error && \"status\" in error && \"stderr\" in error) {\n const execError = error as Error & { status: number; stderr: string }\n return ProcessError(command, Option(execError.status), String(execError.stderr))\n }\n return ProcessError(\n command,\n Option<number>(undefined),\n \"\",\n error instanceof Error ? error.message : String(error),\n )\n }\n return Try(() =>\n nodeExecSync(command, {\n timeout: options?.timeout,\n cwd: options?.cwd,\n encoding: \"utf8\",\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n }),\n )\n .toEither(buildProcessError)\n .map((stdout): ExecResult => ({ stdout: String(stdout), stderr: \"\", exitCode: 0 }))\n },\n}\n"],"mappings":"A,mLAaA,MAAaC,EAAU,CAErB,MAAO,EAAiB,IACtBC,EAAG,sBAEC,IAAI,QAA2C,GAAY,CACzDC,EAAOC,EAAS,CAAE,QAASC,GAAS,QAAS,IAAKA,GAAS,GAAI,GAAI,EAAO,EAAQ,IAAW,CAC3F,GAAIC,EAAO,CAET,IAAMC,EAAWC,EAAO,OAAOF,EAAM,MAAS,SAAWA,EAAM,KAAO,IAAA,EAAS,EAC/EG,EAAQC,EAAKC,EAAaP,EAASG,EAAU,OAAOK,CAAM,CAAC,CAAC,CAAC,CAC/D,MACEH,EAAQI,EAAM,CAAE,OAAQ,OAAOC,CAAM,EAAG,OAAQ,OAAOF,CAAM,EAAG,SAAU,CAAE,CAAC,CAAC,CAElF,CAAC,CACH,CAAC,CACL,EAEF,UAAW,EAAiB,IAanBG,MACLf,EAAaI,EAAS,CACpB,QAASC,GAAS,QAClB,IAAKA,GAAS,IACd,SAAU,OACV,MAAO,CAAC,OAAQ,OAAQ,MAAM,CAChC,CAAC,CACH,CAAC,CACE,SApBwB,GAAiC,CAC1D,GAAIC,aAAiB,OAAS,WAAYA,GAAS,WAAYA,EAAO,CACpE,IAAMW,EAAYX,EAClB,OAAOK,EAAaP,EAASI,EAAOS,EAAU,MAAM,EAAG,OAAOA,EAAU,MAAM,CAAC,CACjF,CACA,OAAON,EACLP,EACAI,EAAe,IAAA,EAAS,EACxB,GACAF,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CACvD,CACF,CAS6B,CAAC,CAC3B,IAAK,IAAwB,CAAE,OAAQ,OAAOQ,CAAM,EAAG,OAAQ,GAAI,SAAU,CAAE,EAAE,CAExF,E"}
1
+ {"version":3,"file":"Process.js","names":["nodeExecSync","Process","exec","command","options","error","exitCode","Option","resolve","Err","ProcessError","stderr","Ok","stdout","Try","execSync","execError"],"sources":["../../src/process/Process.ts"],"sourcesContent":["import { exec as execCb, execSync as nodeExecSync } from \"node:child_process\"\n\nimport type { Either, TaskResult } from \"functype\"\nimport { Err, Ok, Option, Try } from \"functype\"\n\nimport { ProcessError } from \"../errors/errors\"\n\nexport type ExecResult = {\n readonly stdout: string\n readonly stderr: string\n readonly exitCode: number\n}\n\nexport const Process = {\n exec: (command: string, options?: { timeout?: number; cwd?: string }): TaskResult<ExecResult> => {\n return new Promise((resolve) => {\n execCb(command, { timeout: options?.timeout, cwd: options?.cwd }, (error, stdout, stderr) => {\n if (error) {\n // exec callback error has `code` as exit code (number) — distinct from Node errno `code` (string)\n const exitCode = Option(typeof error.code === \"number\" ? error.code : undefined)\n resolve(Err(ProcessError(command, exitCode, String(stderr))))\n } else {\n resolve(Ok({ stdout: String(stdout), stderr: String(stderr), exitCode: 0 }))\n }\n })\n })\n },\n\n execSync: (command: string, options?: { timeout?: number; cwd?: string }): Either<ProcessError, ExecResult> => {\n const buildProcessError = (error: unknown): ProcessError => {\n if (error instanceof Error && \"status\" in error && \"stderr\" in error) {\n const execError = error as Error & { status: number; stderr: string }\n return ProcessError(command, Option(execError.status), String(execError.stderr))\n }\n return ProcessError(\n command,\n Option<number>(undefined),\n \"\",\n error instanceof Error ? error.message : String(error),\n )\n }\n return Try(() =>\n nodeExecSync(command, {\n timeout: options?.timeout,\n cwd: options?.cwd,\n encoding: \"utf8\",\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n }),\n )\n .toEither(buildProcessError)\n .map((stdout): ExecResult => ({ stdout: String(stdout), stderr: \"\", exitCode: 0 }))\n },\n}\n"],"mappings":"uKAaA,MAAaC,EAAU,CACrB,MAAO,EAAiB,IACf,IAAI,QAAS,GAAY,CAC9BC,EAAOC,EAAS,CAAE,QAASC,GAAS,QAAS,IAAKA,GAAS,GAAI,GAAI,EAAO,EAAQ,IAAW,CAC3F,GAAIC,EAAO,CAET,IAAMC,EAAWC,EAAO,OAAOF,EAAM,MAAS,SAAWA,EAAM,KAAO,IAAA,EAAS,EAC/EG,EAAQC,EAAIC,EAAaP,EAASG,EAAU,OAAOK,CAAM,CAAC,CAAC,CAAC,CAC9D,MACEH,EAAQI,EAAG,CAAE,OAAQ,OAAOC,CAAM,EAAG,OAAQ,OAAOF,CAAM,EAAG,SAAU,CAAE,CAAC,CAAC,CAE/E,CAAC,CACH,CAAC,EAGH,UAAW,EAAiB,IAanBG,MACLd,EAAaG,EAAS,CACpB,QAASC,GAAS,QAClB,IAAKA,GAAS,IACd,SAAU,OACV,MAAO,CAAC,OAAQ,OAAQ,MAAM,CAChC,CAAC,CACH,CAAC,CACE,SApBwB,GAAiC,CAC1D,GAAIC,aAAiB,OAAS,WAAYA,GAAS,WAAYA,EAAO,CACpE,IAAMW,EAAYX,EAClB,OAAOK,EAAaP,EAASI,EAAOS,EAAU,MAAM,EAAG,OAAOA,EAAU,MAAM,CAAC,CACjF,CACA,OAAON,EACLP,EACAI,EAAe,IAAA,EAAS,EACxB,GACAF,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CACvD,CACF,CAS6B,CAAC,CAC3B,IAAK,IAAwB,CAAE,OAAQ,OAAOQ,CAAM,EAAG,OAAQ,GAAI,SAAU,CAAE,EAAE,CAExF"}
@@ -1,2 +1,2 @@
1
- import { n as Process, t as ExecResult } from "../Process-BqMq_szA.js";
1
+ import { n as Process, t as ExecResult } from "../Process-DsE1sS2Y.js";
2
2
  export { type ExecResult, Process };
@@ -1 +1 @@
1
- export{Process}from"./Process.js";
1
+ import{Process as e}from"./Process.js";export{e as Process};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functype-os",
3
- "version": "1.21.0",
3
+ "version": "1.21.1",
4
4
  "description": "Functional OS utilities using functype data structures — env vars, path expansion, file ops, platform detection",
5
5
  "keywords": [
6
6
  "functype",
@@ -23,15 +23,15 @@
23
23
  "directory": "packages/functype-os"
24
24
  },
25
25
  "peerDependencies": {
26
- "functype": ">=1.13.0"
26
+ "functype": ">=0.60.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/node": "^24.19.2",
29
+ "@types/node": "^24.19.1",
30
30
  "eslint-config-prettier": "^10.1.8",
31
- "functype": "^1.21.0",
32
- "ts-builds": "^4.0.0",
33
- "tsdown": "^0.23.2",
34
- "vitest": "^5.0.5"
31
+ "functype": "^1.21.1",
32
+ "ts-builds": "^3.4.3",
33
+ "tsdown": "^0.23.0",
34
+ "vitest": "^5.0.3"
35
35
  },
36
36
  "type": "module",
37
37
  "main": "./dist/index.js",