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.
- package/README.md +21 -13
- package/dist/{ConfigResolver-DpDKZFFL.d.ts → ConfigResolver-DNUfcdRT.d.ts} +6 -9
- package/dist/{ConfigSource-BiNVyOgc.d.ts → ConfigSource-DYg8zRVS.d.ts} +1 -4
- package/dist/{Env-CYRuNIYH.d.ts → Env-DSWZuC61.d.ts} +2 -5
- package/dist/{Fs-CPL0SxYV.d.ts → Fs-ZlDyYVKg.d.ts} +15 -18
- package/dist/{Layered-Bep7VzdC.d.ts → Layered-BJ8y5af3.d.ts} +2 -5
- package/dist/{PathExpander-DeA4vwTt.d.ts → PathExpander-C3o94nlr.d.ts} +2 -5
- package/dist/{Platform-ceKNPX6R.d.ts → Platform-Drtg2_HB.d.ts} +1 -4
- package/dist/{Process-DsE1sS2Y.d.ts → Process-CkyuPYhy.d.ts} +4 -7
- package/dist/{ProcessEnvSource-X4vDsn43.d.ts → ProcessEnvSource-CVw35NQr.d.ts} +2 -5
- package/dist/{StaticSource-Bg-cIAL0.d.ts → StaticSource-Xm7KjkoX.d.ts} +2 -5
- package/dist/{bootDiagnostics-COdBMdp4.d.ts → bootDiagnostics-DJhhGVlw.d.ts} +2 -5
- package/dist/config/ConfigResolver.d.ts +1 -1
- package/dist/config/ConfigResolver.js +1 -1
- package/dist/config/ConfigResolver.js.map +1 -1
- package/dist/config/ConfigSource.d.ts +1 -1
- package/dist/config/Layered.d.ts +1 -1
- package/dist/config/Layered.js.map +1 -1
- package/dist/config/ProcessEnvSource.d.ts +1 -1
- package/dist/config/ProcessEnvSource.js.map +1 -1
- package/dist/config/StaticSource.d.ts +1 -1
- package/dist/config/StaticSource.js.map +1 -1
- package/dist/config/bootDiagnostics.d.ts +1 -1
- package/dist/config/bootDiagnostics.js +1 -1
- package/dist/config/bootDiagnostics.js.map +1 -1
- package/dist/config/colors.d.ts +1 -4
- package/dist/config/colors.js.map +1 -1
- package/dist/config/consoleBootLogger.d.ts +1 -1
- package/dist/config/consoleBootLogger.js.map +1 -1
- package/dist/config/index.d.ts +8 -8
- package/dist/config/index.js +1 -1
- package/dist/config/mask.d.ts +1 -1
- package/dist/config/mask.js.map +1 -1
- package/dist/{consoleBootLogger-DsdYgCch.d.ts → consoleBootLogger-EaUJmtmz.d.ts} +1 -4
- package/dist/env/Env.d.ts +1 -1
- package/dist/env/Env.js +1 -1
- package/dist/env/Env.js.map +1 -1
- package/dist/env/index.d.ts +1 -1
- package/dist/env/index.js +1 -1
- package/dist/errors/errors.d.ts +1 -1
- package/dist/errors/errors.js.map +1 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/{errors-uqbMcCFM.d.ts → errors-CZA32bA8.d.ts} +1 -4
- package/dist/fs/Fs.d.ts +1 -1
- package/dist/fs/Fs.js +1 -1
- package/dist/fs/Fs.js.map +1 -1
- package/dist/fs/index.d.ts +1 -1
- package/dist/fs/index.js +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +1 -1
- package/dist/{mask-BLjNp9FP.d.ts → mask-D42mrBYN.d.ts} +1 -4
- package/dist/path/PathExpander.d.ts +1 -1
- package/dist/path/PathExpander.js +1 -1
- package/dist/path/PathExpander.js.map +1 -1
- package/dist/path/index.d.ts +1 -1
- package/dist/path/index.js +1 -1
- package/dist/platform/Platform.d.ts +1 -1
- package/dist/platform/Platform.js +1 -1
- package/dist/platform/Platform.js.map +1 -1
- package/dist/platform/index.d.ts +1 -1
- package/dist/platform/index.js +1 -1
- package/dist/process/Process.d.ts +1 -1
- package/dist/process/Process.js +1 -1
- package/dist/process/Process.js.map +1 -1
- package/dist/process/index.d.ts +1 -1
- package/dist/process/index.js +1 -1
- 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`, `
|
|
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
|
|
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") //
|
|
55
|
-
await Fs.readFile("/path/to/file") //
|
|
56
|
-
await Fs.readFileOpt("/path/to/file") //
|
|
57
|
-
await Fs.readdir("/path/to/dir") //
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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.
|
|
139
|
+
- `functype` >= 2.0.0 (peer dependency)
|
|
132
140
|
|
|
133
141
|
## Development
|
|
134
142
|
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
-
}) =>
|
|
6
|
+
}) => IO<never, never, Option<string>>;
|
|
8
7
|
resolveRequired: (options: {
|
|
9
8
|
readonly candidates: readonly string[];
|
|
10
|
-
}) =>
|
|
9
|
+
}) => IO<never, ConfigError, string>;
|
|
11
10
|
resolveAll: (options: {
|
|
12
11
|
readonly candidates: readonly string[];
|
|
13
|
-
}) =>
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
15
|
-
export { Env as t };
|
|
16
|
-
//# sourceMappingURL=Env-CYRuNIYH.d.ts.map
|
|
13
|
+
export { Env as t };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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) =>
|
|
16
|
-
readFile: (p: string, encoding?: BufferEncoding) =>
|
|
17
|
-
readFileOpt: (p: string, encoding?: BufferEncoding) =>
|
|
18
|
-
stat: (p: string) =>
|
|
19
|
-
copyFile: (src: string, dest: string) =>
|
|
20
|
-
rename: (oldPath: string, newPath: string) =>
|
|
21
|
-
readdir: (p: string) =>
|
|
22
|
-
glob: (dir: string, pattern: string) =>
|
|
23
|
-
writeFile: (p: string, data: string, encoding?: BufferEncoding) =>
|
|
24
|
-
appendFile: (p: string, data: string, encoding?: BufferEncoding) =>
|
|
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
|
-
}) =>
|
|
28
|
-
unlink: (p: string) =>
|
|
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
|
-
|
|
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-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
2
|
-
import {
|
|
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
|
-
}) =>
|
|
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
|
-
|
|
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-
|
|
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
|
-
|
|
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-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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-
|
|
1
|
+
import { t as ConfigResolver } from "../ConfigResolver-DNUfcdRT.js";
|
|
2
2
|
export { ConfigResolver };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
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","
|
|
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-
|
|
1
|
+
import { t as ConfigSource } from "../ConfigSource-DYg8zRVS.js";
|
|
2
2
|
export { ConfigSource };
|
package/dist/config/Layered.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as Layered } from "../Layered-
|
|
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","
|
|
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-
|
|
1
|
+
import { t as ProcessEnvSource } from "../ProcessEnvSource-CVw35NQr.js";
|
|
2
2
|
export { ProcessEnvSource };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcessEnvSource.js","names":["
|
|
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-
|
|
1
|
+
import { t as StaticSource } from "../StaticSource-Xm7KjkoX.js";
|
|
2
2
|
export { StaticSource };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StaticSource.js","names":["
|
|
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-
|
|
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{
|
|
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":["
|
|
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"}
|
package/dist/config/colors.d.ts
CHANGED
|
@@ -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,
|
|
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-
|
|
1
|
+
import { t as consoleBootLogger } from "../consoleBootLogger-EaUJmtmz.js";
|
|
2
2
|
export { consoleBootLogger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consoleBootLogger.js","names":["
|
|
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"}
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
4
|
-
import { t as
|
|
5
|
-
import { t as
|
|
6
|
-
import {
|
|
7
|
-
import { t as
|
|
8
|
-
import { t as
|
|
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 };
|
package/dist/config/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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};
|
package/dist/config/mask.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as maskValue } from "../mask-
|
|
1
|
+
import { t as maskValue } from "../mask-D42mrBYN.js";
|
|
2
2
|
export { maskValue };
|
package/dist/config/mask.js.map
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
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-
|
|
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{
|
|
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
|