functype-os 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{bootDiagnostics-Dnyfm5Uw.d.ts → bootDiagnostics-WXjyslc9.d.ts} +3 -2
- package/dist/config/bootDiagnostics.d.ts +1 -1
- package/dist/config/bootDiagnostics.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 +2 -2
- package/dist/{consoleBootLogger-DrLH3iyi.d.ts → consoleBootLogger-DY3lxFlo.d.ts} +2 -2
- package/package.json +3 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { t as ConfigSource } from "./ConfigSource-n4VKw8Vi.js";
|
|
2
|
-
import { Either, List
|
|
2
|
+
import { Either, List } from "functype";
|
|
3
|
+
import { Logger } from "functype/logger";
|
|
3
4
|
|
|
4
5
|
//#region src/config/bootDiagnostics.d.ts
|
|
5
6
|
interface MissingKey {
|
|
@@ -68,4 +69,4 @@ interface BootDiagnosticsOptions {
|
|
|
68
69
|
declare const bootDiagnostics: (opts: BootDiagnosticsOptions) => Either<List<MissingKey>, void>;
|
|
69
70
|
//#endregion
|
|
70
71
|
export { MissingKey as n, bootDiagnostics as r, BootDiagnosticsOptions as t };
|
|
71
|
-
//# sourceMappingURL=bootDiagnostics-
|
|
72
|
+
//# sourceMappingURL=bootDiagnostics-WXjyslc9.d.ts.map
|
|
@@ -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-WXjyslc9.js";
|
|
2
2
|
export { BootDiagnosticsOptions, MissingKey, bootDiagnostics };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootDiagnostics.js","names":[],"sources":["../../src/config/bootDiagnostics.ts"],"sourcesContent":["import type { Either, List as ListType
|
|
1
|
+
{"version":3,"file":"bootDiagnostics.js","names":[],"sources":["../../src/config/bootDiagnostics.ts"],"sourcesContent":["import type { Either, List as ListType } from \"functype\"\nimport { Left, List, Right } from \"functype\"\n// Logger is type-only and subpath-only in 1.3.x (rolldown chunk-splitter\n// workaround — see comment in packages/functype/src/index.ts). Restore to\n// `import type { ..., Logger } from \"functype\"` when rolldown is fixed.\nimport type { Logger } from \"functype/logger\"\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 for (const key of sensitive) {\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 for (const key of publicKeys) {\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 for (const key of missing) 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":"sOA6EA,MAAa,EAAmB,GAAqE,CACnG,IAAM,EAAS,EAAK,QAAU,EACxB,EAAW,EAAK,UAAY,CAAC,EAC7B,EAAY,EAAK,WAAa,CAAC,EAC/B,EAAa,EAAK,QAAU,CAAC,EAEnC,EAAO,KAAK,GAAG,EAAK,IAAI,EAAE,qBAAqB,EAAK,aAAe,WAAW,EAC9E,EAAO,KAAK,cAAc,EAAK,OAAO,MAAM,EAE5C,IAAM,EAAU,EAAS,OAAQ,GAAM,EAAK,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,EAEjE,GAAI,EAAU,OAAS,EAAG,CACxB,EAAO,KAAK,EAAO,eAAe,CAAC,EACnC,IAAK,IAAM,KAAO,EAAW,CAE3B,IAAM,EADQ,EAAK,OAAO,IAAI,CACV,CAAC,CAAC,SACd,EAAI,YAAY,EACrB,GAAM,EAAU,CAAC,CACpB,EACA,EAAO,KAAK,MAAM,EAAI,OAAO,EAAE,EAA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consoleBootLogger };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consoleBootLogger.js","names":[],"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,MAAM,MAAsB,IAAI,KAAK,CAAA,CAAE,YAAY,EAoBtC,EAA4B,CACvC,OAAQ,EAAK,IAAS,QAAQ,MAAM,GAAG,EAAK,EAAM,CAAC,EAAE,GAAG,EAAK,OAAO,EAAE,GAAG,IAAO,GAAQ,EAAE,EAC1F,MAAO,EAAK,IAAS,QAAQ,IAAI,GAAG,EAAK,EAAM,CAAC,EAAE,GAAG,IAAO,GAAQ,EAAE,EACtE,MAAO,EAAK,IAAS,QAAQ,KAAK,GAAG,EAAK,EAAM,CAAC,EAAE,GAAG,EAAO,MAAM,EAAE,GAAG,IAAO,GAAQ,EAAE,EACzF,OAAQ,EAAK,IAAS,QAAQ,MAAM,GAAG,EAAK,EAAM,CAAC,EAAE,GAAG,EAAI,OAAO,EAAE,GAAG,IAAO,GAAQ,EAAE,CAC3F"}
|
|
1
|
+
{"version":3,"file":"consoleBootLogger.js","names":[],"sources":["../../src/config/consoleBootLogger.ts"],"sourcesContent":["import type { Logger } from \"functype/logger\"\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,MAAM,MAAsB,IAAI,KAAK,CAAA,CAAE,YAAY,EAoBtC,EAA4B,CACvC,OAAQ,EAAK,IAAS,QAAQ,MAAM,GAAG,EAAK,EAAM,CAAC,EAAE,GAAG,EAAK,OAAO,EAAE,GAAG,IAAO,GAAQ,EAAE,EAC1F,MAAO,EAAK,IAAS,QAAQ,IAAI,GAAG,EAAK,EAAM,CAAC,EAAE,GAAG,IAAO,GAAQ,EAAE,EACtE,MAAO,EAAK,IAAS,QAAQ,KAAK,GAAG,EAAK,EAAM,CAAC,EAAE,GAAG,EAAO,MAAM,EAAE,GAAG,IAAO,GAAQ,EAAE,EACzF,OAAQ,EAAK,IAAS,QAAQ,MAAM,GAAG,EAAK,EAAM,CAAC,EAAE,GAAG,EAAI,OAAO,EAAE,GAAG,IAAO,GAAQ,EAAE,CAC3F"}
|
package/dist/config/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { t as ConfigSource } from "../ConfigSource-n4VKw8Vi.js";
|
|
|
3
3
|
import { t as Layered } from "../Layered-4k7fpktc.js";
|
|
4
4
|
import { t as ProcessEnvSource } from "../ProcessEnvSource-C9EzlVbN.js";
|
|
5
5
|
import { t as StaticSource } from "../StaticSource-BjmavHQr.js";
|
|
6
|
-
import { n as MissingKey, r as bootDiagnostics, t as BootDiagnosticsOptions } from "../bootDiagnostics-
|
|
7
|
-
import { t as consoleBootLogger } from "../consoleBootLogger-
|
|
6
|
+
import { n as MissingKey, r as bootDiagnostics, t as BootDiagnosticsOptions } from "../bootDiagnostics-WXjyslc9.js";
|
|
7
|
+
import { t as consoleBootLogger } from "../consoleBootLogger-DY3lxFlo.js";
|
|
8
8
|
import { t as maskValue } from "../mask-BLjNp9FP.js";
|
|
9
9
|
export { type BootDiagnosticsOptions, ConfigResolver, type ConfigSource, Layered, type MissingKey, ProcessEnvSource, StaticSource, bootDiagnostics, consoleBootLogger, maskValue };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Logger } from "functype";
|
|
1
|
+
import { Logger } from "functype/logger";
|
|
2
2
|
|
|
3
3
|
//#region src/config/consoleBootLogger.d.ts
|
|
4
4
|
/**
|
|
@@ -22,4 +22,4 @@ import { Logger } from "functype";
|
|
|
22
22
|
declare const consoleBootLogger: Logger;
|
|
23
23
|
//#endregion
|
|
24
24
|
export { consoleBootLogger as t };
|
|
25
|
-
//# sourceMappingURL=consoleBootLogger-
|
|
25
|
+
//# sourceMappingURL=consoleBootLogger-DY3lxFlo.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functype-os",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Functional OS utilities using functype data structures — env vars, path expansion, file ops, platform detection",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"functype",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^24.12.4",
|
|
30
30
|
"eslint-config-prettier": "^10.1.8",
|
|
31
|
-
"ts-builds": "^
|
|
31
|
+
"ts-builds": "^3.0.0",
|
|
32
32
|
"tsdown": "^0.22.1",
|
|
33
33
|
"vitest": "^4.1.8",
|
|
34
|
-
"functype": "^1.3.
|
|
34
|
+
"functype": "^1.3.1"
|
|
35
35
|
},
|
|
36
36
|
"type": "module",
|
|
37
37
|
"main": "./dist/index.js",
|