functype-os 1.27.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +21 -13
  2. package/dist/{ConfigResolver-DpDKZFFL.d.ts → ConfigResolver-DNUfcdRT.d.ts} +6 -9
  3. package/dist/{ConfigSource-BiNVyOgc.d.ts → ConfigSource-DYg8zRVS.d.ts} +1 -4
  4. package/dist/{Env-CYRuNIYH.d.ts → Env-DSWZuC61.d.ts} +2 -5
  5. package/dist/{Fs-CPL0SxYV.d.ts → Fs-ZlDyYVKg.d.ts} +15 -18
  6. package/dist/{Layered-Bep7VzdC.d.ts → Layered-BJ8y5af3.d.ts} +2 -5
  7. package/dist/{PathExpander-DeA4vwTt.d.ts → PathExpander-C3o94nlr.d.ts} +2 -5
  8. package/dist/{Platform-ceKNPX6R.d.ts → Platform-Drtg2_HB.d.ts} +1 -4
  9. package/dist/{Process-DsE1sS2Y.d.ts → Process-CkyuPYhy.d.ts} +4 -7
  10. package/dist/{ProcessEnvSource-X4vDsn43.d.ts → ProcessEnvSource-CVw35NQr.d.ts} +2 -5
  11. package/dist/{StaticSource-Bg-cIAL0.d.ts → StaticSource-Xm7KjkoX.d.ts} +2 -5
  12. package/dist/{bootDiagnostics-COdBMdp4.d.ts → bootDiagnostics-DJhhGVlw.d.ts} +2 -5
  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 +1 -1
  25. package/dist/config/bootDiagnostics.js.map +1 -1
  26. package/dist/config/colors.d.ts +1 -4
  27. package/dist/config/colors.js.map +1 -1
  28. package/dist/config/consoleBootLogger.d.ts +1 -1
  29. package/dist/config/consoleBootLogger.js.map +1 -1
  30. package/dist/config/index.d.ts +8 -8
  31. package/dist/config/index.js +1 -1
  32. package/dist/config/mask.d.ts +1 -1
  33. package/dist/config/mask.js.map +1 -1
  34. package/dist/{consoleBootLogger-DsdYgCch.d.ts → consoleBootLogger-EaUJmtmz.d.ts} +1 -4
  35. package/dist/env/Env.d.ts +1 -1
  36. package/dist/env/Env.js +1 -1
  37. package/dist/env/Env.js.map +1 -1
  38. package/dist/env/index.d.ts +1 -1
  39. package/dist/env/index.js +1 -1
  40. package/dist/errors/errors.d.ts +1 -1
  41. package/dist/errors/errors.js.map +1 -1
  42. package/dist/errors/index.d.ts +1 -1
  43. package/dist/errors/index.js +1 -1
  44. package/dist/{errors-uqbMcCFM.d.ts → errors-CZA32bA8.d.ts} +1 -4
  45. package/dist/fs/Fs.d.ts +1 -1
  46. package/dist/fs/Fs.js +1 -1
  47. package/dist/fs/Fs.js.map +1 -1
  48. package/dist/fs/index.d.ts +1 -1
  49. package/dist/fs/index.js +1 -1
  50. package/dist/index.d.ts +7 -7
  51. package/dist/index.js +1 -1
  52. package/dist/{mask-BLjNp9FP.d.ts → mask-D42mrBYN.d.ts} +1 -4
  53. package/dist/path/PathExpander.d.ts +1 -1
  54. package/dist/path/PathExpander.js +1 -1
  55. package/dist/path/PathExpander.js.map +1 -1
  56. package/dist/path/index.d.ts +1 -1
  57. package/dist/path/index.js +1 -1
  58. package/dist/platform/Platform.d.ts +1 -1
  59. package/dist/platform/Platform.js +1 -1
  60. package/dist/platform/Platform.js.map +1 -1
  61. package/dist/platform/index.d.ts +1 -1
  62. package/dist/platform/index.js +1 -1
  63. package/dist/process/Process.d.ts +1 -1
  64. package/dist/process/Process.js +1 -1
  65. package/dist/process/Process.js.map +1 -1
  66. package/dist/process/index.d.ts +1 -1
  67. package/dist/process/index.js +1 -1
  68. 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`, `Task`, 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`, `IO`, and `List`.
4
4
 
5
5
  ## Install
6
6
 
@@ -46,17 +46,25 @@ Path.isAbsolute("/abs") // true
46
46
 
47
47
  ### Fs
48
48
 
49
- Async filesystem operations returning `TaskResult`.
49
+ Async filesystem operations return a lazy `IO`: nothing touches the disk until you call `.run()`. Each `*Sync` method returns `Either` and runs immediately.
50
50
 
51
51
  ```typescript
52
52
  import { Fs } from "functype-os"
53
53
 
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>>
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()
58
64
  ```
59
65
 
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
+
60
68
  ### Platform
61
69
 
62
70
  OS and container/runtime detection with lazy-cached sync checks.
@@ -89,18 +97,18 @@ import { ConfigResolver } from "functype-os"
89
97
 
90
98
  const config = await ConfigResolver.resolve({
91
99
  candidates: ["./app.toml", "~/.config/app/config.toml", "$APPDATA/app/config.toml"],
92
- })
93
- // TaskResult<Option<string>> — Ok(Some("/home/user/.config/app/config.toml"))
100
+ }).run()
101
+ // Either<never, Option<string>> — Right(Some("/home/user/.config/app/config.toml"))
94
102
 
95
103
  const required = await ConfigResolver.resolveRequired({
96
104
  candidates: ["./app.toml", "~/.config/app/config.toml"],
97
- })
98
- // TaskResult<string> — Err(ConfigError) if none found
105
+ }).run()
106
+ // Either<ConfigError, string> — Left(ConfigError) if none found
99
107
 
100
108
  const all = await ConfigResolver.resolveAll({
101
109
  candidates: ["./a.toml", "./b.toml", "./c.toml"],
102
- })
103
- // TaskResult<List<string>> — all existing paths
110
+ }).run()
111
+ // Either<never, List<string>> — all existing paths
104
112
  ```
105
113
 
106
114
  ### Errors
@@ -128,7 +136,7 @@ const handleError = (error: OsError) => {
128
136
  ## Requirements
129
137
 
130
138
  - Node.js >= 18
131
- - `functype` >= 0.49.0 (peer dependency)
139
+ - `functype` >= 2.0.0 (peer dependency)
132
140
 
133
141
  ## Development
134
142
 
@@ -1,16 +1,15 @@
1
- import { t as ConfigError } from "./errors-uqbMcCFM.js";
2
- import { Either, List, Option, TaskResult } from "functype";
3
- //#region src/config/ConfigResolver.d.ts
1
+ import { Either, IO, List, Option } from "functype";
2
+ import { t as ConfigError } from "./errors-CZA32bA8.js";
4
3
  declare const ConfigResolver: {
5
4
  resolve: (options: {
6
5
  readonly candidates: readonly string[];
7
- }) => TaskResult<Option<string>>;
6
+ }) => IO<never, never, Option<string>>;
8
7
  resolveRequired: (options: {
9
8
  readonly candidates: readonly string[];
10
- }) => TaskResult<string>;
9
+ }) => IO<never, ConfigError, string>;
11
10
  resolveAll: (options: {
12
11
  readonly candidates: readonly string[];
13
- }) => TaskResult<List<string>>;
12
+ }) => IO<never, never, List<string>>;
14
13
  resolveSync: (options: {
15
14
  readonly candidates: readonly string[];
16
15
  }) => Option<string>;
@@ -21,6 +20,4 @@ declare const ConfigResolver: {
21
20
  readonly candidates: readonly string[];
22
21
  }) => List<string>;
23
22
  };
24
- //#endregion
25
- export { ConfigResolver as t };
26
- //# sourceMappingURL=ConfigResolver-DpDKZFFL.d.ts.map
23
+ export { ConfigResolver as t };
@@ -1,5 +1,4 @@
1
1
  import { Option } from "functype";
2
- //#region src/config/ConfigSource.d.ts
3
2
  /**
4
3
  * Uniform contract for config lookup.
5
4
  *
@@ -29,6 +28,4 @@ interface ConfigSource {
29
28
  readonly name: string;
30
29
  get(key: string): Option<string>;
31
30
  }
32
- //#endregion
33
- export { ConfigSource as t };
34
- //# sourceMappingURL=ConfigSource-BiNVyOgc.d.ts.map
31
+ export { ConfigSource as t };
@@ -1,6 +1,5 @@
1
- import { n as EnvError } from "./errors-uqbMcCFM.js";
2
1
  import { Either, List, Option } from "functype";
3
- //#region src/env/Env.d.ts
2
+ import { n as EnvError } from "./errors-CZA32bA8.js";
4
3
  declare const EnvConstructor: (name: string) => Option<string>;
5
4
  declare const EnvCompanion: {
6
5
  get: (name: string) => Option<string>;
@@ -11,6 +10,4 @@ declare const EnvCompanion: {
11
10
  parse: <T>(name: string, parser: (value: string) => T) => Either<EnvError, T>;
12
11
  };
13
12
  declare const Env: typeof EnvConstructor & typeof EnvCompanion;
14
- //#endregion
15
- export { Env as t };
16
- //# sourceMappingURL=Env-CYRuNIYH.d.ts.map
13
+ export { Env as t };
@@ -1,6 +1,5 @@
1
- import { r as FsError } from "./errors-uqbMcCFM.js";
2
- import { Either, List, Option, TaskResult } from "functype";
3
- //#region src/fs/Fs.d.ts
1
+ import { Either, IO, List, Option } from "functype";
2
+ import { r as FsError } from "./errors-CZA32bA8.js";
4
3
  type FileInfo = {
5
4
  readonly size: number;
6
5
  readonly isFile: boolean;
@@ -12,20 +11,20 @@ type FileInfo = {
12
11
  readonly permissions: number;
13
12
  };
14
13
  declare const Fs: {
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>;
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>;
25
24
  mkdir: (p: string, options?: {
26
25
  recursive?: boolean;
27
- }) => TaskResult<void>;
28
- unlink: (p: string) => TaskResult<void>;
26
+ }) => IO<never, FsError, void>;
27
+ unlink: (p: string) => IO<never, FsError, void>;
29
28
  existsSync: (p: string) => boolean;
30
29
  readFileSync: (p: string, encoding?: BufferEncoding) => Either<FsError, string>;
31
30
  readFileOptSync: (p: string, encoding?: BufferEncoding) => Either<FsError, Option<string>>;
@@ -40,6 +39,4 @@ declare const Fs: {
40
39
  }) => Either<FsError, void>;
41
40
  unlinkSync: (p: string) => Either<FsError, void>;
42
41
  };
43
- //#endregion
44
- export { Fs as n, FileInfo as t };
45
- //# sourceMappingURL=Fs-CPL0SxYV.d.ts.map
42
+ export { Fs as n, FileInfo as t };
@@ -1,5 +1,4 @@
1
- import { t as ConfigSource } from "./ConfigSource-BiNVyOgc.js";
2
- //#region src/config/Layered.d.ts
1
+ import { t as ConfigSource } from "./ConfigSource-DYg8zRVS.js";
3
2
  /**
4
3
  * First-wins composition over N `ConfigSource`s.
5
4
  *
@@ -24,6 +23,4 @@ import { t as ConfigSource } from "./ConfigSource-BiNVyOgc.js";
24
23
  * ```
25
24
  */
26
25
  declare const Layered: (sources: readonly ConfigSource[]) => ConfigSource;
27
- //#endregion
28
- export { Layered as t };
29
- //# sourceMappingURL=Layered-Bep7VzdC.d.ts.map
26
+ export { Layered as t };
@@ -1,6 +1,5 @@
1
- import { a as PathError } from "./errors-uqbMcCFM.js";
2
1
  import { Either } from "functype";
3
- //#region src/path/PathExpander.d.ts
2
+ import { a as PathError } from "./errors-CZA32bA8.js";
4
3
  declare const expandTilde: (p: string) => string;
5
4
  declare const expandVars: (p: string) => Either<PathError, string>;
6
5
  declare const expandPath: (p: string) => Either<PathError, string>;
@@ -15,6 +14,4 @@ declare const Path: {
15
14
  extname: (p: string) => string;
16
15
  isAbsolute: (p: string) => boolean;
17
16
  };
18
- //#endregion
19
- export { expandVars as i, expandPath as n, expandTilde as r, Path as t };
20
- //# sourceMappingURL=PathExpander-DeA4vwTt.d.ts.map
17
+ export { expandVars as i, expandPath as n, expandTilde as r, Path as t };
@@ -1,5 +1,4 @@
1
1
  import { List, Option } from "functype";
2
- //#region src/platform/Platform.d.ts
3
2
  type UserInfo = {
4
3
  readonly username: string;
5
4
  readonly uid: number;
@@ -34,6 +33,4 @@ declare const Platform: {
34
33
  homeDirs: () => List<string>;
35
34
  cloudStorageDirs: (home?: string) => List<CloudStorageDir>;
36
35
  };
37
- //#endregion
38
- export { UserInfo as i, CloudStorageDir as n, Platform as r, CloudProvider as t };
39
- //# sourceMappingURL=Platform-ceKNPX6R.d.ts.map
36
+ export { UserInfo as i, CloudStorageDir as n, Platform as r, CloudProvider as t };
@@ -1,6 +1,5 @@
1
- import { o as ProcessError } from "./errors-uqbMcCFM.js";
2
- import { Either, TaskResult } from "functype";
3
- //#region src/process/Process.d.ts
1
+ import { Either, IO } from "functype";
2
+ import { o as ProcessError } from "./errors-CZA32bA8.js";
4
3
  type ExecResult = {
5
4
  readonly stdout: string;
6
5
  readonly stderr: string;
@@ -10,12 +9,10 @@ declare const Process: {
10
9
  exec: (command: string, options?: {
11
10
  timeout?: number;
12
11
  cwd?: string;
13
- }) => TaskResult<ExecResult>;
12
+ }) => IO<never, ProcessError, ExecResult>;
14
13
  execSync: (command: string, options?: {
15
14
  timeout?: number;
16
15
  cwd?: string;
17
16
  }) => Either<ProcessError, ExecResult>;
18
17
  };
19
- //#endregion
20
- export { Process as n, ExecResult as t };
21
- //# sourceMappingURL=Process-DsE1sS2Y.d.ts.map
18
+ export { Process as n, ExecResult as t };
@@ -1,5 +1,4 @@
1
- import { t as ConfigSource } from "./ConfigSource-BiNVyOgc.js";
2
- //#region src/config/ProcessEnvSource.d.ts
1
+ import { t as ConfigSource } from "./ConfigSource-DYg8zRVS.js";
3
2
  /**
4
3
  * Built-in `ConfigSource` backed by `process.env` via the existing `Env` wrapper.
5
4
  *
@@ -11,6 +10,4 @@ import { t as ConfigSource } from "./ConfigSource-BiNVyOgc.js";
11
10
  * ```
12
11
  */
13
12
  declare const ProcessEnvSource: () => ConfigSource;
14
- //#endregion
15
- export { ProcessEnvSource as t };
16
- //# sourceMappingURL=ProcessEnvSource-X4vDsn43.d.ts.map
13
+ export { ProcessEnvSource as t };
@@ -1,5 +1,4 @@
1
- import { t as ConfigSource } from "./ConfigSource-BiNVyOgc.js";
2
- //#region src/config/StaticSource.d.ts
1
+ import { t as ConfigSource } from "./ConfigSource-DYg8zRVS.js";
3
2
  /**
4
3
  * Built-in `ConfigSource` backed by an in-memory map.
5
4
  *
@@ -15,6 +14,4 @@ import { t as ConfigSource } from "./ConfigSource-BiNVyOgc.js";
15
14
  * ```
16
15
  */
17
16
  declare const StaticSource: (entries: Readonly<Record<string, string>>, name?: string) => ConfigSource;
18
- //#endregion
19
- export { StaticSource as t };
20
- //# sourceMappingURL=StaticSource-Bg-cIAL0.d.ts.map
17
+ export { StaticSource as t };
@@ -1,6 +1,5 @@
1
- import { t as ConfigSource } from "./ConfigSource-BiNVyOgc.js";
2
1
  import { Either, List, Logger } from "functype";
3
- //#region src/config/bootDiagnostics.d.ts
2
+ import { t as ConfigSource } from "./ConfigSource-DYg8zRVS.js";
4
3
  interface MissingKey {
5
4
  readonly key: string;
6
5
  readonly required: boolean;
@@ -65,6 +64,4 @@ interface BootDiagnosticsOptions {
65
64
  * ```
66
65
  */
67
66
  declare const bootDiagnostics: (opts: BootDiagnosticsOptions) => Either<List<MissingKey>, void>;
68
- //#endregion
69
- export { MissingKey as n, bootDiagnostics as r, BootDiagnosticsOptions as t };
70
- //# sourceMappingURL=bootDiagnostics-COdBMdp4.d.ts.map
67
+ export { MissingKey as n, bootDiagnostics as r, BootDiagnosticsOptions as t };
@@ -1,2 +1,2 @@
1
- import { t as ConfigResolver } from "../ConfigResolver-DpDKZFFL.js";
1
+ import { t as ConfigResolver } from "../ConfigResolver-DNUfcdRT.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{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};
1
+ import{IO as e,Left as t,List as n,Option as r,Right as i}from"functype";import{ConfigError as a}from"../errors/errors.js";import{Fs as o}from"../fs/Fs.js";import{expandPath as s}from"../path/PathExpander.js";const c=e=>s(e).fold(()=>r(void 0),e=>r(e)),l=t=>t.headOption().fold(()=>e.succeed(r(void 0)),n=>o.exists(n).flatMap(i=>i?e.succeed(r(n)):l(t.tail()))),u=e=>n(e.flatMap(e=>c(e).toArray())),d={resolve:e=>l(u(e.candidates)),resolveRequired:t=>d.resolve(t).flatMap(n=>n.fold(()=>e.fail(a(t.candidates)),t=>e.succeed(t))),resolveAll:t=>e.forEach(u(t.candidates).toArray(),e=>o.exists(e).map(t=>t?[e]:[])).map(e=>n(e.flat())),resolveSync:e=>u(e.candidates).find(o.existsSync),resolveRequiredSync:e=>d.resolveSync(e).fold(()=>t(a(e.candidates)),e=>i(e)),resolveAllSync:e=>u(e.candidates).filter(o.existsSync)};export{d as ConfigResolver};
2
2
  //# sourceMappingURL=ConfigResolver.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigResolver.js","names":["ConfigErrorConstructor","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
+ {"version":3,"file":"ConfigResolver.js","names":["ConfigErrorConstructor","IO","Left","List","Option","Right","ConfigError","Fs","expandPath","tryExpandPath","candidate","v","findFirstExisting","candidates","head","found","presentPaths","c","ConfigResolver","options","path","perPath"],"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()))\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),\n}\n"],"mappings":"A,iNAQA,MAAMS,EAAiBC,GACNF,EAAWE,CACd,CAAC,CAAC,SACNN,EAAe,IAAA,EAAS,EAC7BO,GAAMP,EAAOO,CAAC,CACjB,EAIIC,EAAqBC,GACzBA,EAAW,WAAW,CAAC,CAAC,SAChBZ,EAAG,QAAQG,EAAe,IAAA,EAAS,CAAC,EACzCU,GACCP,EAAG,OAAOO,CAAI,CAAC,CAAC,QAASC,GAAWA,EAAQd,EAAG,QAAQG,EAAOU,CAAI,CAAC,EAAIF,EAAkBC,EAAW,KAAK,CAAC,CAAE,CAChH,EAGIG,EAAgBH,GACpBV,EAAaU,EAAW,QAASI,GAAMR,EAAcQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAEvDC,EAAiB,CAG5B,QAAUC,GACRP,EAAkBI,EAAaG,EAAQ,UAAU,CAAC,EAEpD,gBAAkBA,GAChBD,EAAe,QAAQC,CAAO,CAAC,CAAC,QAASJ,GACvCA,EAAM,SACEd,EAAG,KAAKD,EAAuBmB,EAAQ,UAAU,CAAC,EACvDC,GAASnB,EAAG,QAAQmB,CAAI,CAC3B,CACF,EAIF,WAAaD,GACXlB,EAAG,QAAQe,EAAaG,EAAQ,UAAU,CAAC,CAAC,QAAQ,EAAIC,GACtDb,EAAG,OAAOa,CAAI,CAAC,CAAC,IAAKL,GAAWA,EAAQ,CAACK,CAAI,EAAI,CAAC,CAAE,CACtD,CAAC,CAAC,IAAKC,GAAYlB,EAAakB,EAAQ,KAAK,CAAC,CAAC,EAIjD,YAAcF,GACZH,EAAaG,EAAQ,UAAU,CAAC,CAAC,KAAKZ,EAAG,UAAU,EAErD,oBAAsBY,GACLD,EAAe,YAAYC,CAC9B,CAAC,CAAC,SACNjB,EAAKF,EAAuBmB,EAAQ,UAAU,CAAC,EACpDR,GAAMN,EAAMM,CAAC,CAChB,EAGF,eAAiBQ,GACfH,EAAaG,EAAQ,UAAU,CAAC,CAAC,OAAOZ,EAAG,UAAU,CACzD,E"}
@@ -1,2 +1,2 @@
1
- import { t as ConfigSource } from "../ConfigSource-BiNVyOgc.js";
1
+ import { t as ConfigSource } from "../ConfigSource-DYg8zRVS.js";
2
2
  export { ConfigSource };
@@ -1,2 +1,2 @@
1
- import { t as Layered } from "../Layered-Bep7VzdC.js";
1
+ import { t as Layered } from "../Layered-BJ8y5af3.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":"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
+ {"version":3,"file":"Layered.js","names":["OptionCtor","Option","Layered","sources","s","key","acc","source"],"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,MAAaE,EAAWC,IAAoD,CAC1E,KAAMA,EAAQ,IAAKC,GAAMA,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,EAC3C,IAAMC,GACJF,EAAQ,QACLG,EAAKC,IACJD,EAAI,SACIC,EAAO,IAAIF,CAAG,MACdC,CACR,EACFN,EAAmB,IAAA,EAAS,CAC9B,CACJ,G"}
@@ -1,2 +1,2 @@
1
- import { t as ProcessEnvSource } from "../ProcessEnvSource-X4vDsn43.js";
1
+ import { t as ProcessEnvSource } from "../ProcessEnvSource-CVw35NQr.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":"oCAaA,MAAaA,OAAwC,CACnD,KAAM,cACN,IAAM,GAAQC,EAAIC,CAAG,CACvB"}
1
+ {"version":3,"file":"ProcessEnvSource.js","names":["Env","ProcessEnvSource","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,MAAaC,OAAwC,CACnD,KAAM,cACN,IAAMC,GAAQF,EAAIE,CAAG,CACvB,G"}
@@ -1,2 +1,2 @@
1
- import { t as StaticSource } from "../StaticSource-Bg-cIAL0.js";
1
+ import { t as StaticSource } from "../StaticSource-Xm7KjkoX.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":"kCAkBA,MAAaA,GAAgB,EAA2C,EAAO,YAA4B,CACzG,OACA,IAAM,GAAQC,EAAOC,EAAQC,EAAI,CACnC"}
1
+ {"version":3,"file":"StaticSource.js","names":["Option","StaticSource","entries","name","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,MAAaC,GAAgBC,EAA2CC,EAAO,YAA4B,CACzGA,OACA,IAAMC,GAAQJ,EAAOE,EAAQE,EAAI,CACnC,G"}
@@ -1,2 +1,2 @@
1
- import { n as MissingKey, r as bootDiagnostics, t as BootDiagnosticsOptions } from "../bootDiagnostics-COdBMdp4.js";
1
+ import { n as MissingKey, r as bootDiagnostics, t as BootDiagnosticsOptions } from "../bootDiagnostics-DJhhGVlw.js";
2
2
  export { BootDiagnosticsOptions, MissingKey, bootDiagnostics };
@@ -1,2 +1,2 @@
1
- import{blue as e,green as t,magenta as n,red as r,yellow as i}from"./colors.js";import{consoleBootLogger as a}from"./consoleBootLogger.js";import{maskValue as o}from"./mask.js";import{Left as s,List as c,Right as l}from"functype";const u=u=>{let d=u.logger??a,f=u.required??[],p=u.sensitive??[],m=u.public??[];d.info(`${e(`📦`)} Boot diagnostics: ${u.serviceName??`service`}`),d.info(` source: ${u.source.name}`);let h=f.filter(e=>u.source.get(e).isEmpty);if(p.length>0&&(d.info(i(`🔐 Sensitive:`)),p.forEach(e=>{let t=u.source.get(e).fold(()=>r(`NOT_LOADED`),e=>o(e));d.info(` ${e.padEnd(28)} ${t}`)})),m.length>0&&(d.info(t(`⚙️ Public:`)),m.forEach(e=>{let t=u.source.get(e).fold(()=>r(`NOT_LOADED`),e=>e);d.info(` ${e.padEnd(28)} ${t}`)})),u.hostEnv!==void 0&&u.vaultEnvKey!==void 0){let e=u.source.get(u.vaultEnvKey),{hostEnv:r}=u,{vaultEnvKey:i}=u;e.fold(()=>{d.warn(`Vault env key '${i}' not present — skipping mismatch check`)},e=>{e===r?d.info(`${n(`🌍`)} Environment: ${r} (host) ↔ ${e} (vault) ${t(`✓`)}`):d.error(`${n(`🌍`)} Environment MISMATCH: host=${r} vault=${e}`,{hostEnv:r,vaultEnv:e})})}if(h.length===0)return d.info(t(`✅ All required keys present`)),l(void 0);d.error(r(`❌ Missing required keys (${h.length}):`)),h.forEach(e=>d.error(` ${e}`));let g=c(h.map(e=>({key:e,required:!0})));return u.failOn===`missing`&&process.exit(1),s(g)};export{u as bootDiagnostics};
1
+ import{Left as e,List as t,Right as n}from"functype";import{blue as r,green as i,magenta as a,red as o,yellow as s}from"./colors.js";import{consoleBootLogger as c}from"./consoleBootLogger.js";import{maskValue as l}from"./mask.js";const u=u=>{let d=u.logger??c,f=u.required??[],p=u.sensitive??[],m=u.public??[];d.info(`${r(`📦`)} Boot diagnostics: ${u.serviceName??`service`}`),d.info(` source: ${u.source.name}`);let h=f.filter(e=>u.source.get(e).isEmpty);if(p.length>0&&(d.info(s(`🔐 Sensitive:`)),p.forEach(e=>{let t=u.source.get(e).fold(()=>o(`NOT_LOADED`),e=>l(e));d.info(` ${e.padEnd(28)} ${t}`)})),m.length>0&&(d.info(i(`⚙️ Public:`)),m.forEach(e=>{let t=u.source.get(e).fold(()=>o(`NOT_LOADED`),e=>e);d.info(` ${e.padEnd(28)} ${t}`)})),u.hostEnv!==void 0&&u.vaultEnvKey!==void 0){let e=u.source.get(u.vaultEnvKey),{hostEnv:t}=u,{vaultEnvKey:n}=u;e.fold(()=>{d.warn(`Vault env key '${n}' not present — skipping mismatch check`)},e=>{e===t?d.info(`${a(`🌍`)} Environment: ${t} (host) ↔ ${e} (vault) ${i(`✓`)}`):d.error(`${a(`🌍`)} Environment MISMATCH: host=${t} vault=${e}`,{hostEnv:t,vaultEnv:e})})}if(h.length===0)return d.info(i(`✅ All required keys present`)),n(void 0);d.error(o(`❌ Missing required keys (${h.length}):`)),h.forEach(e=>d.error(` ${e}`));let g=t(h.map(e=>({key:e,required:!0})));return u.failOn===`missing`&&process.exit(1),e(g)};export{u as bootDiagnostics};
2
2
  //# sourceMappingURL=bootDiagnostics.js.map
@@ -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":"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"}
1
+ {"version":3,"file":"bootDiagnostics.js","names":["Left","List","Right","blue","green","magenta","red","yellow","consoleBootLogger","maskValue","bootDiagnostics","opts","logger","required","sensitive","publicKeys","missing","k","key","display","v","vaultEnv","hostEnv","vaultEnvKey","missingList"],"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,MAAaU,EAAmBC,GAAqE,CACnG,IAAMC,EAASD,EAAK,QAAUH,EACxBK,EAAWF,EAAK,UAAY,CAAC,EAC7BG,EAAYH,EAAK,WAAa,CAAC,EAC/BI,EAAaJ,EAAK,QAAU,CAAC,EAEnCC,EAAO,KAAK,GAAGT,EAAK,IAAI,EAAE,qBAAqBQ,EAAK,aAAe,WAAW,EAC9EC,EAAO,KAAK,cAAcD,EAAK,OAAO,MAAM,EAE5C,IAAMK,EAAUH,EAAS,OAAQI,GAAMN,EAAK,OAAO,IAAIM,CAAC,CAAC,CAAC,OAAO,EA0BjE,GAxBIH,EAAU,OAAS,IACrBF,EAAO,KAAKL,EAAO,eAAe,CAAC,EACnCO,EAAU,QAASI,GAAQ,CAEzB,IAAMC,EADQR,EAAK,OAAO,IAAIO,CACV,CAAC,CAAC,SACdZ,EAAI,YAAY,EACrBc,GAAMX,EAAUW,CAAC,CACpB,EACAR,EAAO,KAAK,MAAMM,EAAI,OAAO,EAAE,EAAE,GAAGC,GAAS,CAC/C,CAAC,GAGCJ,EAAW,OAAS,IACtBH,EAAO,KAAKR,EAAM,aAAa,CAAC,EAChCW,EAAW,QAASG,GAAQ,CAE1B,IAAMC,EADQR,EAAK,OAAO,IAAIO,CACV,CAAC,CAAC,SACdZ,EAAI,YAAY,EACrBc,GAAMA,CACT,EACAR,EAAO,KAAK,MAAMM,EAAI,OAAO,EAAE,EAAE,GAAGC,GAAS,CAC/C,CAAC,GAGCR,EAAK,UAAY,IAAA,IAAaA,EAAK,cAAgB,IAAA,GAAW,CAChE,IAAMU,EAAWV,EAAK,OAAO,IAAIA,EAAK,WAAW,EAC3C,CAAEW,WAAYX,EACd,CAAEY,eAAgBZ,EACxBU,EAAS,SACD,CACJT,EAAO,KAAK,kBAAkBW,EAAY,wCAAwC,CAEpF,EACCH,GAAM,CACDA,IAAME,EACRV,EAAO,KAAK,GAAGP,EAAQ,IAAI,EAAE,gBAAgBiB,EAAQ,YAAYF,EAAE,WAAWhB,EAAM,GAAG,GAAG,EAE1FQ,EAAO,MAAM,GAAGP,EAAQ,IAAI,EAAE,8BAA8BiB,EAAQ,SAASF,IAAK,CAChFE,UACA,SAAUF,CACZ,CAAC,CAGL,CACF,CACF,CAEA,GAAIJ,EAAQ,SAAW,EAErB,OADAJ,EAAO,KAAKR,EAAM,6BAA6B,CAAC,EACzCF,EAAkC,IAAA,EAAS,EAGpDU,EAAO,MAAMN,EAAI,4BAA4BU,EAAQ,OAAO,GAAG,CAAC,EAChEA,EAAQ,QAASE,GAAQN,EAAO,MAAM,MAAMM,GAAK,CAAC,EAElD,IAAMM,EAAcvB,EAAKe,EAAQ,IAAKE,IAAqB,CAAEA,MAAK,SAAU,EAAK,EAAE,CAAC,EAKpF,OAHIP,EAAK,SAAW,WAClB,QAAQ,KAAK,CAAC,EAETX,EAAiCwB,CAAW,CACrD,E"}
@@ -1,4 +1,3 @@
1
- //#region src/config/colors.d.ts
2
1
  /**
3
2
  * Internal raw-ANSI color helpers for boot diagnostics output.
4
3
  *
@@ -19,6 +18,4 @@ export declare const yellow: (s: string) => string;
19
18
  export declare const blue: (s: string) => string;
20
19
  export declare const magenta: (s: string) => string;
21
20
  export declare const cyan: (s: string) => string;
22
- export declare const gray: (s: string) => string;
23
- //#endregion
24
- //# sourceMappingURL=colors.d.ts.map
21
+ export declare const gray: (s: string) => string;
@@ -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"}
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,EACHC,GACAC,GACCH,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,2 +1,2 @@
1
- import { t as consoleBootLogger } from "../consoleBootLogger-DsdYgCch.js";
1
+ import { t as consoleBootLogger } from "../consoleBootLogger-EaUJmtmz.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":"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
+ {"version":3,"file":"consoleBootLogger.js","names":["gray","red","yellow","stamp","consoleBootLogger","msg","meta"],"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,MAAMG,uBAAsB,IAAI,KAAK,EAAA,CAAE,YAAY,EAoBtCC,EAA4B,CACvC,OAAQC,EAAKC,IAAS,QAAQ,MAAM,GAAGN,EAAKG,EAAM,CAAC,EAAE,GAAGH,EAAK,OAAO,EAAE,GAAGK,IAAOC,GAAQ,EAAE,EAC1F,MAAOD,EAAKC,IAAS,QAAQ,IAAI,GAAGN,EAAKG,EAAM,CAAC,EAAE,GAAGE,IAAOC,GAAQ,EAAE,EACtE,MAAOD,EAAKC,IAAS,QAAQ,KAAK,GAAGN,EAAKG,EAAM,CAAC,EAAE,GAAGD,EAAO,MAAM,EAAE,GAAGG,IAAOC,GAAQ,EAAE,EACzF,OAAQD,EAAKC,IAAS,QAAQ,MAAM,GAAGN,EAAKG,EAAM,CAAC,EAAE,GAAGF,EAAI,OAAO,EAAE,GAAGI,IAAOC,GAAQ,EAAE,CAC3F,E"}
@@ -1,9 +1,9 @@
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";
1
+ import { n as MissingKey, r as bootDiagnostics, t as BootDiagnosticsOptions } from "../bootDiagnostics-DJhhGVlw.js";
2
+ import { t as ConfigResolver } from "../ConfigResolver-DNUfcdRT.js";
3
+ import { t as ConfigSource } from "../ConfigSource-DYg8zRVS.js";
4
+ import { t as consoleBootLogger } from "../consoleBootLogger-EaUJmtmz.js";
5
+ import { t as Layered } from "../Layered-BJ8y5af3.js";
6
+ import { t as maskValue } from "../mask-D42mrBYN.js";
7
+ import { t as ProcessEnvSource } from "../ProcessEnvSource-CVw35NQr.js";
8
+ import { t as StaticSource } from "../StaticSource-Xm7KjkoX.js";
9
9
  export { type BootDiagnosticsOptions, ConfigResolver, type ConfigSource, Layered, type MissingKey, ProcessEnvSource, StaticSource, bootDiagnostics, consoleBootLogger, maskValue };
@@ -1 +1 @@
1
- import{consoleBootLogger as e}from"./consoleBootLogger.js";import{maskValue as t}from"./mask.js";import{bootDiagnostics as n}from"./bootDiagnostics.js";import{ConfigResolver as r}from"./ConfigResolver.js";import{Layered as i}from"./Layered.js";import{ProcessEnvSource as a}from"./ProcessEnvSource.js";import{StaticSource as o}from"./StaticSource.js";export{r as ConfigResolver,i as Layered,a as ProcessEnvSource,o as StaticSource,n as bootDiagnostics,e as consoleBootLogger,t as maskValue};
1
+ import{bootDiagnostics as e}from"./bootDiagnostics.js";import{ConfigResolver as t}from"./ConfigResolver.js";import{consoleBootLogger as n}from"./consoleBootLogger.js";import{Layered as r}from"./Layered.js";import{maskValue as i}from"./mask.js";import{ProcessEnvSource as a}from"./ProcessEnvSource.js";import{StaticSource as o}from"./StaticSource.js";export{t as ConfigResolver,r as Layered,a as ProcessEnvSource,o as StaticSource,e as bootDiagnostics,n as consoleBootLogger,i as maskValue};
@@ -1,2 +1,2 @@
1
- import { t as maskValue } from "../mask-BLjNp9FP.js";
1
+ import { t as maskValue } from "../mask-D42mrBYN.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"}
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,EAAaC,GACpBA,EAAM,QAAU,EAAU,OACvB,GAAGA,EAAM,MAAM,EAAG,CAAC,EAAE,MAAMA,EAAM,MAAM,EAAE,I"}
@@ -1,5 +1,4 @@
1
1
  import { Logger } from "functype";
2
- //#region src/config/consoleBootLogger.d.ts
3
2
  /**
4
3
  * Default `Logger` impl for boot diagnostics — zero-dep, raw ANSI colors,
5
4
  * NO_COLOR / FORCE_COLOR / isTTY-respecting.
@@ -19,6 +18,4 @@ import { Logger } from "functype";
19
18
  * ```
20
19
  */
21
20
  declare const consoleBootLogger: Logger;
22
- //#endregion
23
- export { consoleBootLogger as t };
24
- //# sourceMappingURL=consoleBootLogger-DsdYgCch.d.ts.map
21
+ export { consoleBootLogger as t };
package/dist/env/Env.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { t as Env } from "../Env-CYRuNIYH.js";
1
+ import { t as Env } from "../Env-DSWZuC61.js";
2
2
  export { Env };
package/dist/env/Env.js CHANGED
@@ -1,2 +1,2 @@
1
- import{EnvError as e}from"../errors/errors.js";import{Left as t,List as n,Option as r,Right as i,Try as a}from"functype";const o=Object.assign(e=>r(process.env[e]),{get:e=>r(process.env[e]),getRequired:t=>r(process.env[t]).toEither(e(t)),getOrDefault:(e,t)=>process.env[e]??t,has:e=>process.env[e]!==void 0,entries:()=>{let e=Object.entries(process.env).filter(e=>e[1]!==void 0).map(([e,t])=>[e,t]);return n(e)},parse:(n,o)=>{let s=r(process.env[n]);if(s.isEmpty)return t(e(n));let c=s.orThrow();return a(()=>o(c)).toEither(t=>e(n,`Failed to parse '${n}': ${t instanceof Error?t.message:String(t)}`)).flatMap(r=>typeof r==`number`&&isNaN(r)?t(e(n,`Cannot parse '${c}' as number for '${n}'`)):i(r))}});export{o as Env};
1
+ import{Left as e,List as t,Option as n,Right as r,Try as i}from"functype";import{EnvError as a}from"../errors/errors.js";const o=Object.assign(e=>n(process.env[e]),{get:e=>n(process.env[e]),getRequired:e=>n(process.env[e]).toEither(a(e)),getOrDefault:(e,t)=>process.env[e]??t,has:e=>process.env[e]!==void 0,entries:()=>{let e=Object.entries(process.env).filter(e=>e[1]!==void 0).map(([e,t])=>[e,t]);return t(e)},parse:(t,o)=>n(process.env[t]).fold(()=>e(a(t)),n=>i(()=>o(n)).toEither(e=>a(t,`Failed to parse '${t}': ${e instanceof Error?e.message:String(e)}`)).flatMap(i=>typeof i==`number`&&isNaN(i)?e(a(t,`Cannot parse '${n}' as number for '${t}'`)):r(i)))});export{o as Env};
2
2
  //# sourceMappingURL=Env.js.map