typed-settings 0.1.0 → 0.1.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/adapters/joi.d.cts +13 -0
- package/dist/adapters/joi.d.ts +13 -0
- package/dist/adapters/zod.d.cts +14 -0
- package/dist/adapters/zod.d.ts +14 -0
- package/dist/cli/main.d.cts +4 -0
- package/dist/cli/main.d.ts +4 -0
- package/dist/{errors-IU9n4f3t.d.cts → errors-itGaU4Q8.d.cts} +5 -0
- package/dist/{errors-IU9n4f3t.d.ts → errors-itGaU4Q8.d.ts} +5 -0
- package/dist/formats/env.d.cts +5 -0
- package/dist/formats/env.d.ts +5 -0
- package/dist/formats/json.d.cts +4 -0
- package/dist/formats/json.d.ts +4 -0
- package/dist/formats/toml.d.cts +4 -0
- package/dist/formats/toml.d.ts +4 -0
- package/dist/formats/yaml.d.cts +5 -0
- package/dist/formats/yaml.d.ts +5 -0
- package/dist/framework/next.d.cts +14 -3
- package/dist/framework/next.d.ts +14 -3
- package/dist/framework/vite.d.cts +14 -3
- package/dist/framework/vite.d.ts +14 -3
- package/dist/index.d.cts +37 -3
- package/dist/index.d.ts +37 -3
- package/dist/node.d.cts +29 -2
- package/dist/node.d.ts +29 -2
- package/dist/{shared-DBcV6jIy.d.cts → shared-CucO_XsG.d.cts} +1 -0
- package/dist/{shared-DBcV6jIy.d.ts → shared-CucO_XsG.d.ts} +1 -0
- package/dist/types-CClP1lxq.d.cts +67 -0
- package/dist/types-CClP1lxq.d.ts +67 -0
- package/dist/vault/aws.d.cts +24 -1
- package/dist/vault/aws.d.ts +24 -1
- package/dist/vault/hashicorp.d.cts +21 -2
- package/dist/vault/hashicorp.d.ts +21 -2
- package/dist/vault/http.d.cts +18 -2
- package/dist/vault/http.d.ts +18 -2
- package/package.json +1 -1
- package/dist/types-BswIPp7U.d.cts +0 -41
- package/dist/types-BswIPp7U.d.ts +0 -41
package/dist/adapters/joi.d.cts
CHANGED
|
@@ -4,7 +4,16 @@ type AnySchema = {
|
|
|
4
4
|
validateSync?: (v: unknown, o?: unknown) => unknown;
|
|
5
5
|
validate?: (...a: never[]) => unknown;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Adapts a Yup schema via `validateSync` (`stripUnknown`, all errors).
|
|
9
|
+
* `inner[]` failures map to issues; anything else becomes a root issue.
|
|
10
|
+
*/
|
|
7
11
|
declare function yupAdapter(schema: any): StandardSchemaV1;
|
|
12
|
+
/**
|
|
13
|
+
* Adapts a Joi schema (`validate` with convert + stripUnknown). `details[]`
|
|
14
|
+
* map to issues; a throwing `validate()` or empty details still yields a
|
|
15
|
+
* non-empty issues array, as Standard Schema requires.
|
|
16
|
+
*/
|
|
8
17
|
declare function joiAdapter(schema: AnySchema & {
|
|
9
18
|
validate?: (v: unknown, o?: unknown) => {
|
|
10
19
|
error?: {
|
|
@@ -17,6 +26,10 @@ declare function joiAdapter(schema: AnySchema & {
|
|
|
17
26
|
value: unknown;
|
|
18
27
|
};
|
|
19
28
|
}): StandardSchemaV1;
|
|
29
|
+
/**
|
|
30
|
+
* Adapts a Superstruct struct via `create()`. `failures()` map to issues;
|
|
31
|
+
* anything else falls back to the thrown message.
|
|
32
|
+
*/
|
|
20
33
|
declare function superstructAdapter(schema: AnySchema & {
|
|
21
34
|
create?: (v: unknown) => unknown;
|
|
22
35
|
}): StandardSchemaV1;
|
package/dist/adapters/joi.d.ts
CHANGED
|
@@ -4,7 +4,16 @@ type AnySchema = {
|
|
|
4
4
|
validateSync?: (v: unknown, o?: unknown) => unknown;
|
|
5
5
|
validate?: (...a: never[]) => unknown;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Adapts a Yup schema via `validateSync` (`stripUnknown`, all errors).
|
|
9
|
+
* `inner[]` failures map to issues; anything else becomes a root issue.
|
|
10
|
+
*/
|
|
7
11
|
declare function yupAdapter(schema: any): StandardSchemaV1;
|
|
12
|
+
/**
|
|
13
|
+
* Adapts a Joi schema (`validate` with convert + stripUnknown). `details[]`
|
|
14
|
+
* map to issues; a throwing `validate()` or empty details still yields a
|
|
15
|
+
* non-empty issues array, as Standard Schema requires.
|
|
16
|
+
*/
|
|
8
17
|
declare function joiAdapter(schema: AnySchema & {
|
|
9
18
|
validate?: (v: unknown, o?: unknown) => {
|
|
10
19
|
error?: {
|
|
@@ -17,6 +26,10 @@ declare function joiAdapter(schema: AnySchema & {
|
|
|
17
26
|
value: unknown;
|
|
18
27
|
};
|
|
19
28
|
}): StandardSchemaV1;
|
|
29
|
+
/**
|
|
30
|
+
* Adapts a Superstruct struct via `create()`. `failures()` map to issues;
|
|
31
|
+
* anything else falls back to the thrown message.
|
|
32
|
+
*/
|
|
20
33
|
declare function superstructAdapter(schema: AnySchema & {
|
|
21
34
|
create?: (v: unknown) => unknown;
|
|
22
35
|
}): StandardSchemaV1;
|
package/dist/adapters/zod.d.cts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Zod helpers: `withPrefix` scopes any Standard Schema under an env prefix,
|
|
5
|
+
* `coerceEnv` is the identity hook for composed pipelines.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Scopes a schema under `prefix`: matching keys strip case-insensitively before
|
|
10
|
+
* validation, prefixed keys win collisions, non-objects pass through untouched.
|
|
11
|
+
* An empty prefix returns the schema unchanged.
|
|
12
|
+
*/
|
|
3
13
|
declare function withPrefix<S extends StandardSchemaV1>(schema: S, prefix: string): S;
|
|
14
|
+
/**
|
|
15
|
+
* Identity hook for composed pipelines. Documents "this value already went
|
|
16
|
+
* through env coercion"; the real logic lives in `coerce.ts`.
|
|
17
|
+
*/
|
|
4
18
|
declare function coerceEnv(value: unknown): unknown;
|
|
5
19
|
|
|
6
20
|
export { coerceEnv, withPrefix };
|
package/dist/adapters/zod.d.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Zod helpers: `withPrefix` scopes any Standard Schema under an env prefix,
|
|
5
|
+
* `coerceEnv` is the identity hook for composed pipelines.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Scopes a schema under `prefix`: matching keys strip case-insensitively before
|
|
10
|
+
* validation, prefixed keys win collisions, non-objects pass through untouched.
|
|
11
|
+
* An empty prefix returns the schema unchanged.
|
|
12
|
+
*/
|
|
3
13
|
declare function withPrefix<S extends StandardSchemaV1>(schema: S, prefix: string): S;
|
|
14
|
+
/**
|
|
15
|
+
* Identity hook for composed pipelines. Documents "this value already went
|
|
16
|
+
* through env coercion"; the real logic lives in `coerce.ts`.
|
|
17
|
+
*/
|
|
4
18
|
declare function coerceEnv(value: unknown): unknown;
|
|
5
19
|
|
|
6
20
|
export { coerceEnv, withPrefix };
|
package/dist/cli/main.d.cts
CHANGED
package/dist/cli/main.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
/** One validation failure: the key path, the winning source, and what went wrong. */
|
|
1
2
|
interface ConfigIssue {
|
|
2
3
|
path: string;
|
|
3
4
|
from: string;
|
|
4
5
|
message: string;
|
|
5
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Every settings failure. Carries machine-readable `issues` plus a `code`
|
|
9
|
+
* (`E_INVALID_CONFIG` by default, e.g. `E_UNKNOWN_KEY`, `E_TIMEOUT`).
|
|
10
|
+
*/
|
|
6
11
|
declare class ConfigError extends Error {
|
|
7
12
|
code: string;
|
|
8
13
|
issues: ConfigIssue[];
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
/** One validation failure: the key path, the winning source, and what went wrong. */
|
|
1
2
|
interface ConfigIssue {
|
|
2
3
|
path: string;
|
|
3
4
|
from: string;
|
|
4
5
|
message: string;
|
|
5
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Every settings failure. Carries machine-readable `issues` plus a `code`
|
|
9
|
+
* (`E_INVALID_CONFIG` by default, e.g. `E_UNKNOWN_KEY`, `E_TIMEOUT`).
|
|
10
|
+
*/
|
|
6
11
|
declare class ConfigError extends Error {
|
|
7
12
|
code: string;
|
|
8
13
|
issues: ConfigIssue[];
|
package/dist/formats/env.d.cts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses dotenv text into a flat map. Strips one BOM, joins multiline
|
|
3
|
+
* double-quoted values, lets the last duplicate win. Throws `ParseError` on
|
|
4
|
+
* backticks, unterminated quotes, bare keys, and empty keys.
|
|
5
|
+
*/
|
|
1
6
|
declare function parseEnvText(text: string): Record<string, string>;
|
|
2
7
|
|
|
3
8
|
export { parseEnvText };
|
package/dist/formats/env.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses dotenv text into a flat map. Strips one BOM, joins multiline
|
|
3
|
+
* double-quoted values, lets the last duplicate win. Throws `ParseError` on
|
|
4
|
+
* backticks, unterminated quotes, bare keys, and empty keys.
|
|
5
|
+
*/
|
|
1
6
|
declare function parseEnvText(text: string): Record<string, string>;
|
|
2
7
|
|
|
3
8
|
export { parseEnvText };
|
package/dist/formats/json.d.cts
CHANGED
package/dist/formats/json.d.ts
CHANGED
package/dist/formats/toml.d.cts
CHANGED
package/dist/formats/toml.d.ts
CHANGED
package/dist/formats/yaml.d.cts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-doc YAML parse (1.2, duplicate keys rejected). A trailing lone `---`
|
|
3
|
+
* still parses; multi-doc payloads, bad indentation, and unresolvable aliases
|
|
4
|
+
* throw `ParseError` naming the source. Explicit `null` reads as `{}`.
|
|
5
|
+
*/
|
|
1
6
|
declare function parseYamlText(text: string, from?: string): unknown;
|
|
2
7
|
|
|
3
8
|
export { parseYamlText };
|
package/dist/formats/yaml.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-doc YAML parse (1.2, duplicate keys rejected). A trailing lone `---`
|
|
3
|
+
* still parses; multi-doc payloads, bad indentation, and unresolvable aliases
|
|
4
|
+
* throw `ParseError` naming the source. Explicit `null` reads as `{}`.
|
|
5
|
+
*/
|
|
1
6
|
declare function parseYamlText(text: string, from?: string): unknown;
|
|
2
7
|
|
|
3
8
|
export { parseYamlText };
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
export { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
export { pickPublic, settings, settingsAsync } from '../index.cjs';
|
|
3
|
-
export { S as SettingsOptions } from '../types-
|
|
4
|
-
export { C as ConfigError } from '../errors-
|
|
3
|
+
export { S as SettingsOptions } from '../types-CClP1lxq.cjs';
|
|
4
|
+
export { C as ConfigError } from '../errors-itGaU4Q8.cjs';
|
|
5
5
|
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Next.js App Router binding (Edge-safe: no `fs`, no static `server-only` import).
|
|
8
|
+
* Load the full config on the server, hand the client only an explicit subset.
|
|
9
|
+
*
|
|
10
|
+
* IMPORTANT: add `import 'server-only'` at the top of YOUR server settings file
|
|
11
|
+
* (not inside this library — the `server-only` package throws when evaluated
|
|
12
|
+
* outside a React Server Component, which would break plain Node/vitest usage).
|
|
13
|
+
* // settings.ts (server)
|
|
14
|
+
* import 'server-only';
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** Explicit public subset - no spread, keys enumerated so secrets can't leak via `...cfg`. */
|
|
7
18
|
declare function publicSettings<T extends object, K extends keyof T>(cfg: T, keys: readonly K[]): Pick<T, K>;
|
|
8
19
|
|
|
9
20
|
export { publicSettings };
|
package/dist/framework/next.d.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
export { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
export { pickPublic, settings, settingsAsync } from '../index.js';
|
|
3
|
-
export { S as SettingsOptions } from '../types-
|
|
4
|
-
export { C as ConfigError } from '../errors-
|
|
3
|
+
export { S as SettingsOptions } from '../types-CClP1lxq.js';
|
|
4
|
+
export { C as ConfigError } from '../errors-itGaU4Q8.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Next.js App Router binding (Edge-safe: no `fs`, no static `server-only` import).
|
|
8
|
+
* Load the full config on the server, hand the client only an explicit subset.
|
|
9
|
+
*
|
|
10
|
+
* IMPORTANT: add `import 'server-only'` at the top of YOUR server settings file
|
|
11
|
+
* (not inside this library — the `server-only` package throws when evaluated
|
|
12
|
+
* outside a React Server Component, which would break plain Node/vitest usage).
|
|
13
|
+
* // settings.ts (server)
|
|
14
|
+
* import 'server-only';
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** Explicit public subset - no spread, keys enumerated so secrets can't leak via `...cfg`. */
|
|
7
18
|
declare function publicSettings<T extends object, K extends keyof T>(cfg: T, keys: readonly K[]): Pick<T, K>;
|
|
8
19
|
|
|
9
20
|
export { publicSettings };
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
export { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
3
|
export { pickPublic, settings, settingsAsync } from '../index.cjs';
|
|
4
|
-
import { S as SettingsOptions, F as Flat } from '../types-
|
|
5
|
-
export { C as ConfigError } from '../errors-
|
|
4
|
+
import { S as SettingsOptions, F as Flat } from '../types-CClP1lxq.cjs';
|
|
5
|
+
export { C as ConfigError } from '../errors-itGaU4Q8.cjs';
|
|
6
6
|
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Vite binding (Edge-safe, no `fs`). Validates `import.meta.env` against a schema.
|
|
9
|
+
*
|
|
10
|
+
* Rules: never spread `import.meta.env` (it drags server secrets into the
|
|
11
|
+
* client bundle). Pass it as a map; file preloading belongs in `vite.config.ts`
|
|
12
|
+
* via `loadEnvFiles()` passed as `{ text }`.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Validates `import.meta.env` (passed explicitly by the caller) against a schema.
|
|
17
|
+
* Sources and ambient env are fixed: the map is the only input.
|
|
18
|
+
*/
|
|
8
19
|
declare function viteSettings<S extends StandardSchemaV1>(opts: Omit<SettingsOptions<S>, 'sources' | 'env'>, metaEnv: Flat): StandardSchemaV1.InferOutput<S>;
|
|
9
20
|
|
|
10
21
|
export { Flat, SettingsOptions, viteSettings };
|
package/dist/framework/vite.d.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
export { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
3
|
export { pickPublic, settings, settingsAsync } from '../index.js';
|
|
4
|
-
import { S as SettingsOptions, F as Flat } from '../types-
|
|
5
|
-
export { C as ConfigError } from '../errors-
|
|
4
|
+
import { S as SettingsOptions, F as Flat } from '../types-CClP1lxq.js';
|
|
5
|
+
export { C as ConfigError } from '../errors-itGaU4Q8.js';
|
|
6
6
|
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Vite binding (Edge-safe, no `fs`). Validates `import.meta.env` against a schema.
|
|
9
|
+
*
|
|
10
|
+
* Rules: never spread `import.meta.env` (it drags server secrets into the
|
|
11
|
+
* client bundle). Pass it as a map; file preloading belongs in `vite.config.ts`
|
|
12
|
+
* via `loadEnvFiles()` passed as `{ text }`.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Validates `import.meta.env` (passed explicitly by the caller) against a schema.
|
|
17
|
+
* Sources and ambient env are fixed: the map is the only input.
|
|
18
|
+
*/
|
|
8
19
|
declare function viteSettings<S extends StandardSchemaV1>(opts: Omit<SettingsOptions<S>, 'sources' | 'env'>, metaEnv: Flat): StandardSchemaV1.InferOutput<S>;
|
|
9
20
|
|
|
10
21
|
export { Flat, SettingsOptions, viteSettings };
|
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,46 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import { S as SettingsOptions, F as Flat } from './types-
|
|
3
|
-
export { A as ArrayStrategy, a as SecretProvider, b as SourceInput, U as UnknownKeys } from './types-
|
|
4
|
-
export { C as ConfigError } from './errors-
|
|
2
|
+
import { S as SettingsOptions, F as Flat } from './types-CClP1lxq.cjs';
|
|
3
|
+
export { A as ArrayStrategy, a as SecretProvider, b as SourceInput, U as UnknownKeys } from './types-CClP1lxq.cjs';
|
|
4
|
+
export { C as ConfigError } from './errors-itGaU4Q8.cjs';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Typed config in one call.
|
|
8
|
+
*
|
|
9
|
+
* `settings()` / `settingsAsync()` load env, `.env` files, YAML/TOML/JSON,
|
|
10
|
+
* secrets-dir maps, and vault secrets, then merge, expand `$VAR` references,
|
|
11
|
+
* coerce, validate against a Standard Schema, and return the result frozen.
|
|
12
|
+
* Anything invalid throws `ConfigError` at boot with the key and source attached.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Runs `fn` with `process.env` patched by `map` (`undefined` deletes a key),
|
|
17
|
+
* then restores the exact previous environment — synchronously for sync `fn`,
|
|
18
|
+
* held until settle for async `fn`. Restores on throw too.
|
|
19
|
+
*/
|
|
6
20
|
declare function withOverrides<T>(map: Flat, fn: () => T): T;
|
|
21
|
+
/**
|
|
22
|
+
* Copies only the listed, actually-present keys. A missing key yields no entry
|
|
23
|
+
* (not `{ k: undefined }`), and nothing is spread, so secrets can't leak through.
|
|
24
|
+
*/
|
|
7
25
|
declare function pickPublic<T extends object>(cfg: T, keys: (keyof T)[]): Partial<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Map-only settings for Vite-style `import.meta.env` objects: validates the
|
|
28
|
+
* map with no filesystem and no ambient env. (The framework entry's overload
|
|
29
|
+
* drops `sources`/`env` from the options.)
|
|
30
|
+
*/
|
|
8
31
|
declare function viteSettings<S extends StandardSchemaV1>(opts: SettingsOptions<S>, metaEnv: Flat): StandardSchemaV1.InferOutput<S>;
|
|
32
|
+
/**
|
|
33
|
+
* Loads, merges, expands, coerces, and validates config synchronously, returning
|
|
34
|
+
* the inferred output type, frozen. Throws `ConfigError` on invalid input (issues
|
|
35
|
+
* carry `path` + winning-source `from`, secrets redacted) and `USE_ASYNC` when a
|
|
36
|
+
* provider or the schema itself is async — then use `settingsAsync()`.
|
|
37
|
+
*/
|
|
9
38
|
declare function settings<S extends StandardSchemaV1>(opts: SettingsOptions<S>): StandardSchemaV1.InferOutput<S>;
|
|
39
|
+
/**
|
|
40
|
+
* Async twin of `settings()`: awaits async providers (whole collection races
|
|
41
|
+
* `timeoutMs`) and async schemas, with the same merge/expand/coerce/validate/
|
|
42
|
+
* freeze pipeline and the same `ConfigError` contract.
|
|
43
|
+
*/
|
|
10
44
|
declare function settingsAsync<S extends StandardSchemaV1>(opts: SettingsOptions<S>): Promise<StandardSchemaV1.InferOutput<S>>;
|
|
11
45
|
|
|
12
46
|
export { Flat, SettingsOptions, pickPublic, settings, settingsAsync, viteSettings, withOverrides };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,46 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import { S as SettingsOptions, F as Flat } from './types-
|
|
3
|
-
export { A as ArrayStrategy, a as SecretProvider, b as SourceInput, U as UnknownKeys } from './types-
|
|
4
|
-
export { C as ConfigError } from './errors-
|
|
2
|
+
import { S as SettingsOptions, F as Flat } from './types-CClP1lxq.js';
|
|
3
|
+
export { A as ArrayStrategy, a as SecretProvider, b as SourceInput, U as UnknownKeys } from './types-CClP1lxq.js';
|
|
4
|
+
export { C as ConfigError } from './errors-itGaU4Q8.js';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Typed config in one call.
|
|
8
|
+
*
|
|
9
|
+
* `settings()` / `settingsAsync()` load env, `.env` files, YAML/TOML/JSON,
|
|
10
|
+
* secrets-dir maps, and vault secrets, then merge, expand `$VAR` references,
|
|
11
|
+
* coerce, validate against a Standard Schema, and return the result frozen.
|
|
12
|
+
* Anything invalid throws `ConfigError` at boot with the key and source attached.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Runs `fn` with `process.env` patched by `map` (`undefined` deletes a key),
|
|
17
|
+
* then restores the exact previous environment — synchronously for sync `fn`,
|
|
18
|
+
* held until settle for async `fn`. Restores on throw too.
|
|
19
|
+
*/
|
|
6
20
|
declare function withOverrides<T>(map: Flat, fn: () => T): T;
|
|
21
|
+
/**
|
|
22
|
+
* Copies only the listed, actually-present keys. A missing key yields no entry
|
|
23
|
+
* (not `{ k: undefined }`), and nothing is spread, so secrets can't leak through.
|
|
24
|
+
*/
|
|
7
25
|
declare function pickPublic<T extends object>(cfg: T, keys: (keyof T)[]): Partial<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Map-only settings for Vite-style `import.meta.env` objects: validates the
|
|
28
|
+
* map with no filesystem and no ambient env. (The framework entry's overload
|
|
29
|
+
* drops `sources`/`env` from the options.)
|
|
30
|
+
*/
|
|
8
31
|
declare function viteSettings<S extends StandardSchemaV1>(opts: SettingsOptions<S>, metaEnv: Flat): StandardSchemaV1.InferOutput<S>;
|
|
32
|
+
/**
|
|
33
|
+
* Loads, merges, expands, coerces, and validates config synchronously, returning
|
|
34
|
+
* the inferred output type, frozen. Throws `ConfigError` on invalid input (issues
|
|
35
|
+
* carry `path` + winning-source `from`, secrets redacted) and `USE_ASYNC` when a
|
|
36
|
+
* provider or the schema itself is async — then use `settingsAsync()`.
|
|
37
|
+
*/
|
|
9
38
|
declare function settings<S extends StandardSchemaV1>(opts: SettingsOptions<S>): StandardSchemaV1.InferOutput<S>;
|
|
39
|
+
/**
|
|
40
|
+
* Async twin of `settings()`: awaits async providers (whole collection races
|
|
41
|
+
* `timeoutMs`) and async schemas, with the same merge/expand/coerce/validate/
|
|
42
|
+
* freeze pipeline and the same `ConfigError` contract.
|
|
43
|
+
*/
|
|
10
44
|
declare function settingsAsync<S extends StandardSchemaV1>(opts: SettingsOptions<S>): Promise<StandardSchemaV1.InferOutput<S>>;
|
|
11
45
|
|
|
12
46
|
export { Flat, SettingsOptions, pickPublic, settings, settingsAsync, viteSettings, withOverrides };
|
package/dist/node.d.cts
CHANGED
|
@@ -1,27 +1,54 @@
|
|
|
1
|
-
import { F as Flat, S as SettingsOptions } from './types-
|
|
1
|
+
import { F as Flat, S as SettingsOptions } from './types-CClP1lxq.cjs';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
|
-
import { C as ConfigError } from './errors-
|
|
3
|
+
import { C as ConfigError } from './errors-itGaU4Q8.cjs';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Reads dotenv files and joins them with newlines for `{ text }` sources.
|
|
7
|
+
* Missing files are skipped; anything else (e.g. `EACCES`) rethrows.
|
|
8
|
+
*/
|
|
5
9
|
declare function loadEnvFiles(paths: string[]): {
|
|
6
10
|
text: string;
|
|
7
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Reads a secrets dir (Docker/K8s `/run/secrets`) into a flat map keyed by
|
|
14
|
+
* uppercased filenames. Skips subdirectories, `..*` entries, and empties; strips
|
|
15
|
+
* one trailing newline but otherwise preserves whitespace verbatim. Missing dir
|
|
16
|
+
* reads as `{}`; unreadable files throw (`EACCES` fails closed).
|
|
17
|
+
*/
|
|
8
18
|
declare function loadSecretsDir(dir: string): Flat;
|
|
19
|
+
/**
|
|
20
|
+
* Parses one dotenv file into a flat map. Missing file reads as `{}`;
|
|
21
|
+
* anything else (including `EACCES` and syntax errors) rethrows.
|
|
22
|
+
*/
|
|
9
23
|
declare function parseEnvFile(path: string): Flat;
|
|
24
|
+
/** Watch tuning: debounce, provider/dir refresh, stat-poll fallback, and callbacks. */
|
|
10
25
|
interface WatchCallbacks {
|
|
26
|
+
/** Coalesce rapid saves. Default 100. */
|
|
11
27
|
debounceMs?: number;
|
|
28
|
+
/** Re-poll providers/secrets-dirs. Default 0=off (60000 when providers present). */
|
|
12
29
|
refreshMs?: number;
|
|
30
|
+
/** Stat-poll fallback for NFS/Docker where fs events are unreliable. Default 0=off. */
|
|
13
31
|
pollMs?: number;
|
|
32
|
+
/** Fires on each successful reload with the new config and changed leaf paths. */
|
|
14
33
|
onUpdate?: (cfg: unknown, changed: string[]) => void;
|
|
34
|
+
/** Fires when a reload fails; the old config stays live. Never throws outward. */
|
|
15
35
|
onError?: (e: ConfigError | Error, info?: {
|
|
16
36
|
version: number;
|
|
17
37
|
}) => void;
|
|
18
38
|
}
|
|
39
|
+
/** Live config subscription. `reload()` re-reads now; `dispose()` is idempotent. */
|
|
19
40
|
interface WatchHandle<T = unknown> {
|
|
20
41
|
get(): T;
|
|
21
42
|
reload(): Promise<void>;
|
|
22
43
|
dispose(): Promise<void>;
|
|
23
44
|
readonly version: number;
|
|
24
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Subscribes to config files with parent-dir watching (survives atomic renames),
|
|
48
|
+
* debounced reloads, and stable-size settling. Each reload validates off-side and
|
|
49
|
+
* swaps only on success, reporting changed leaf paths; failures keep the old
|
|
50
|
+
* config and notify `onError`. Overlapping reloads drop the stale one.
|
|
51
|
+
*/
|
|
25
52
|
declare function watchSettings<S extends StandardSchemaV1>(opts: SettingsOptions<S>, cb?: WatchCallbacks): WatchHandle<StandardSchemaV1.InferOutput<S>>;
|
|
26
53
|
|
|
27
54
|
export { type WatchCallbacks, type WatchHandle, loadEnvFiles, loadSecretsDir, parseEnvFile, watchSettings };
|
package/dist/node.d.ts
CHANGED
|
@@ -1,27 +1,54 @@
|
|
|
1
|
-
import { F as Flat, S as SettingsOptions } from './types-
|
|
1
|
+
import { F as Flat, S as SettingsOptions } from './types-CClP1lxq.js';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
|
-
import { C as ConfigError } from './errors-
|
|
3
|
+
import { C as ConfigError } from './errors-itGaU4Q8.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Reads dotenv files and joins them with newlines for `{ text }` sources.
|
|
7
|
+
* Missing files are skipped; anything else (e.g. `EACCES`) rethrows.
|
|
8
|
+
*/
|
|
5
9
|
declare function loadEnvFiles(paths: string[]): {
|
|
6
10
|
text: string;
|
|
7
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Reads a secrets dir (Docker/K8s `/run/secrets`) into a flat map keyed by
|
|
14
|
+
* uppercased filenames. Skips subdirectories, `..*` entries, and empties; strips
|
|
15
|
+
* one trailing newline but otherwise preserves whitespace verbatim. Missing dir
|
|
16
|
+
* reads as `{}`; unreadable files throw (`EACCES` fails closed).
|
|
17
|
+
*/
|
|
8
18
|
declare function loadSecretsDir(dir: string): Flat;
|
|
19
|
+
/**
|
|
20
|
+
* Parses one dotenv file into a flat map. Missing file reads as `{}`;
|
|
21
|
+
* anything else (including `EACCES` and syntax errors) rethrows.
|
|
22
|
+
*/
|
|
9
23
|
declare function parseEnvFile(path: string): Flat;
|
|
24
|
+
/** Watch tuning: debounce, provider/dir refresh, stat-poll fallback, and callbacks. */
|
|
10
25
|
interface WatchCallbacks {
|
|
26
|
+
/** Coalesce rapid saves. Default 100. */
|
|
11
27
|
debounceMs?: number;
|
|
28
|
+
/** Re-poll providers/secrets-dirs. Default 0=off (60000 when providers present). */
|
|
12
29
|
refreshMs?: number;
|
|
30
|
+
/** Stat-poll fallback for NFS/Docker where fs events are unreliable. Default 0=off. */
|
|
13
31
|
pollMs?: number;
|
|
32
|
+
/** Fires on each successful reload with the new config and changed leaf paths. */
|
|
14
33
|
onUpdate?: (cfg: unknown, changed: string[]) => void;
|
|
34
|
+
/** Fires when a reload fails; the old config stays live. Never throws outward. */
|
|
15
35
|
onError?: (e: ConfigError | Error, info?: {
|
|
16
36
|
version: number;
|
|
17
37
|
}) => void;
|
|
18
38
|
}
|
|
39
|
+
/** Live config subscription. `reload()` re-reads now; `dispose()` is idempotent. */
|
|
19
40
|
interface WatchHandle<T = unknown> {
|
|
20
41
|
get(): T;
|
|
21
42
|
reload(): Promise<void>;
|
|
22
43
|
dispose(): Promise<void>;
|
|
23
44
|
readonly version: number;
|
|
24
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Subscribes to config files with parent-dir watching (survives atomic renames),
|
|
48
|
+
* debounced reloads, and stable-size settling. Each reload validates off-side and
|
|
49
|
+
* swaps only on success, reporting changed leaf paths; failures keep the old
|
|
50
|
+
* config and notify `onError`. Overlapping reloads drop the stale one.
|
|
51
|
+
*/
|
|
25
52
|
declare function watchSettings<S extends StandardSchemaV1>(opts: SettingsOptions<S>, cb?: WatchCallbacks): WatchHandle<StandardSchemaV1.InferOutput<S>>;
|
|
26
53
|
|
|
27
54
|
export { type WatchCallbacks, type WatchHandle, loadEnvFiles, loadSecretsDir, parseEnvFile, watchSettings };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
|
|
3
|
+
/** Flat string map: the currency every source compiles to (`process.env` shape). */
|
|
4
|
+
type Flat = Record<string, string | undefined>;
|
|
5
|
+
/** A secret backend. `load()` may be sync or async; async forces `settingsAsync()`. */
|
|
6
|
+
interface SecretProvider {
|
|
7
|
+
/** Label used in error attribution (`from`) and timeouts. */
|
|
8
|
+
name: string;
|
|
9
|
+
load(): Promise<Flat> | Flat;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* One config source. Strings `'env' | '.env' | '.env.local'` are built-ins,
|
|
13
|
+
* any other string is a file path; objects cover inline text, files,
|
|
14
|
+
* secrets dirs (resolved by the caller), maps, and providers.
|
|
15
|
+
*/
|
|
16
|
+
type SourceInput = 'env' | '.env' | '.env.local' | {
|
|
17
|
+
text: string;
|
|
18
|
+
} | {
|
|
19
|
+
file: string;
|
|
20
|
+
} | {
|
|
21
|
+
dir: string;
|
|
22
|
+
} | {
|
|
23
|
+
map: Flat;
|
|
24
|
+
prefix?: string;
|
|
25
|
+
} | {
|
|
26
|
+
provider: SecretProvider;
|
|
27
|
+
prefix?: string;
|
|
28
|
+
} | SecretProvider | Flat | string;
|
|
29
|
+
/** How arrays merge across layers: wholesale win, append, or per-index union. */
|
|
30
|
+
type ArrayStrategy = 'replace' | 'concat' | 'mergeIndex';
|
|
31
|
+
/** What to do with input keys the schema doesn't declare. */
|
|
32
|
+
type UnknownKeys = 'strip' | 'preserve' | 'reject';
|
|
33
|
+
/** Options for `settings()` / `settingsAsync()`. Full semantics in docs/configuration.md. */
|
|
34
|
+
interface SettingsOptions<S extends StandardSchemaV1 = StandardSchemaV1> {
|
|
35
|
+
/** Validating schema (zod/valibot/arktype natively, yup/joi/superstruct via bridges). */
|
|
36
|
+
schema: S;
|
|
37
|
+
/** Ordered layers, later wins. Default `['.env', 'env']`. */
|
|
38
|
+
sources?: SourceInput[];
|
|
39
|
+
/** Global prefix strip (case-insensitive, once). */
|
|
40
|
+
prefix?: string;
|
|
41
|
+
/** Fixed to `'__'`; only double underscores split keys. */
|
|
42
|
+
separator?: '__';
|
|
43
|
+
/** Best-effort leaf coercion before validation. Default true. */
|
|
44
|
+
coerce?: boolean;
|
|
45
|
+
/** `$VAR` expansion after merging. Default true. */
|
|
46
|
+
expand?: boolean;
|
|
47
|
+
/** Also expand `$VAR` inside vault-provided values. Default false. */
|
|
48
|
+
expandSecrets?: boolean;
|
|
49
|
+
/** Cross-layer array merge. Default 'replace'. */
|
|
50
|
+
arrayStrategy?: ArrayStrategy;
|
|
51
|
+
/** Undeclared keys: drop, keep, or throw. Default 'strip'. */
|
|
52
|
+
unknownKeys?: UnknownKeys;
|
|
53
|
+
/** Deep-freeze the result. Default true. */
|
|
54
|
+
freeze?: boolean;
|
|
55
|
+
/** Async provider + validation timeout in ms. Default 5000, async only. */
|
|
56
|
+
timeoutMs?: number;
|
|
57
|
+
/** Per-file read cap in UTF-8 bytes. Default 2 MiB. */
|
|
58
|
+
maxBytes?: number;
|
|
59
|
+
/** Keys used literally: no prefix strip, no `__` split. */
|
|
60
|
+
envMap?: Record<string, string>;
|
|
61
|
+
/** Keep `${MISSING}` literally instead of throwing. Default false. */
|
|
62
|
+
allowUnresolved?: boolean;
|
|
63
|
+
/** Injectable env snapshot (tests, Edge). Defaults to process.env when available. */
|
|
64
|
+
env?: Flat;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type { ArrayStrategy as A, Flat as F, SettingsOptions as S, UnknownKeys as U, SecretProvider as a, SourceInput as b };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
|
|
3
|
+
/** Flat string map: the currency every source compiles to (`process.env` shape). */
|
|
4
|
+
type Flat = Record<string, string | undefined>;
|
|
5
|
+
/** A secret backend. `load()` may be sync or async; async forces `settingsAsync()`. */
|
|
6
|
+
interface SecretProvider {
|
|
7
|
+
/** Label used in error attribution (`from`) and timeouts. */
|
|
8
|
+
name: string;
|
|
9
|
+
load(): Promise<Flat> | Flat;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* One config source. Strings `'env' | '.env' | '.env.local'` are built-ins,
|
|
13
|
+
* any other string is a file path; objects cover inline text, files,
|
|
14
|
+
* secrets dirs (resolved by the caller), maps, and providers.
|
|
15
|
+
*/
|
|
16
|
+
type SourceInput = 'env' | '.env' | '.env.local' | {
|
|
17
|
+
text: string;
|
|
18
|
+
} | {
|
|
19
|
+
file: string;
|
|
20
|
+
} | {
|
|
21
|
+
dir: string;
|
|
22
|
+
} | {
|
|
23
|
+
map: Flat;
|
|
24
|
+
prefix?: string;
|
|
25
|
+
} | {
|
|
26
|
+
provider: SecretProvider;
|
|
27
|
+
prefix?: string;
|
|
28
|
+
} | SecretProvider | Flat | string;
|
|
29
|
+
/** How arrays merge across layers: wholesale win, append, or per-index union. */
|
|
30
|
+
type ArrayStrategy = 'replace' | 'concat' | 'mergeIndex';
|
|
31
|
+
/** What to do with input keys the schema doesn't declare. */
|
|
32
|
+
type UnknownKeys = 'strip' | 'preserve' | 'reject';
|
|
33
|
+
/** Options for `settings()` / `settingsAsync()`. Full semantics in docs/configuration.md. */
|
|
34
|
+
interface SettingsOptions<S extends StandardSchemaV1 = StandardSchemaV1> {
|
|
35
|
+
/** Validating schema (zod/valibot/arktype natively, yup/joi/superstruct via bridges). */
|
|
36
|
+
schema: S;
|
|
37
|
+
/** Ordered layers, later wins. Default `['.env', 'env']`. */
|
|
38
|
+
sources?: SourceInput[];
|
|
39
|
+
/** Global prefix strip (case-insensitive, once). */
|
|
40
|
+
prefix?: string;
|
|
41
|
+
/** Fixed to `'__'`; only double underscores split keys. */
|
|
42
|
+
separator?: '__';
|
|
43
|
+
/** Best-effort leaf coercion before validation. Default true. */
|
|
44
|
+
coerce?: boolean;
|
|
45
|
+
/** `$VAR` expansion after merging. Default true. */
|
|
46
|
+
expand?: boolean;
|
|
47
|
+
/** Also expand `$VAR` inside vault-provided values. Default false. */
|
|
48
|
+
expandSecrets?: boolean;
|
|
49
|
+
/** Cross-layer array merge. Default 'replace'. */
|
|
50
|
+
arrayStrategy?: ArrayStrategy;
|
|
51
|
+
/** Undeclared keys: drop, keep, or throw. Default 'strip'. */
|
|
52
|
+
unknownKeys?: UnknownKeys;
|
|
53
|
+
/** Deep-freeze the result. Default true. */
|
|
54
|
+
freeze?: boolean;
|
|
55
|
+
/** Async provider + validation timeout in ms. Default 5000, async only. */
|
|
56
|
+
timeoutMs?: number;
|
|
57
|
+
/** Per-file read cap in UTF-8 bytes. Default 2 MiB. */
|
|
58
|
+
maxBytes?: number;
|
|
59
|
+
/** Keys used literally: no prefix strip, no `__` split. */
|
|
60
|
+
envMap?: Record<string, string>;
|
|
61
|
+
/** Keep `${MISSING}` literally instead of throwing. Default false. */
|
|
62
|
+
allowUnresolved?: boolean;
|
|
63
|
+
/** Injectable env snapshot (tests, Edge). Defaults to process.env when available. */
|
|
64
|
+
env?: Flat;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type { ArrayStrategy as A, Flat as F, SettingsOptions as S, UnknownKeys as U, SecretProvider as a, SourceInput as b };
|
package/dist/vault/aws.d.cts
CHANGED
|
@@ -1,26 +1,49 @@
|
|
|
1
|
-
import { a as SecretProvider } from '../types-
|
|
1
|
+
import { a as SecretProvider } from '../types-CClP1lxq.cjs';
|
|
2
2
|
import '@standard-schema/spec';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* AWS provider: Secrets Manager ids plus SSM parameters (with decryption)
|
|
6
|
+
* merged into one flat map. SDK clients are injected, never imported blindly,
|
|
7
|
+
* so tests can pass fakes and Edge bundles stay lean.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** Minimal Secrets Manager surface this provider needs (real SDK client or a fake). */
|
|
4
11
|
interface AwsSecretsClient {
|
|
5
12
|
getSecretValue(secretId: string): Promise<{
|
|
6
13
|
SecretString?: string;
|
|
7
14
|
SecretBinary?: Uint8Array | string;
|
|
8
15
|
} | string>;
|
|
9
16
|
}
|
|
17
|
+
/** Minimal SSM surface this provider needs (real SDK client or a fake). */
|
|
10
18
|
interface AwsSsmClient {
|
|
11
19
|
getParameters(names: string[], withDecryption?: boolean): Promise<Record<string, string>>;
|
|
12
20
|
}
|
|
21
|
+
/** Options for {@link awsProvider}. */
|
|
13
22
|
interface AwsProviderOptions {
|
|
23
|
+
/** Secrets Manager ids. */
|
|
14
24
|
secrets?: string[];
|
|
25
|
+
/** SSM names or path prefixes (trailing `/` optional). */
|
|
15
26
|
params?: string[];
|
|
27
|
+
/** Reserved: region override (currently from env `AWS_REGION`). */
|
|
16
28
|
region?: string;
|
|
29
|
+
/** Reserved: VersionId / stage pin. */
|
|
17
30
|
versionId?: string;
|
|
31
|
+
/** Applies to the whole `load()`. Default 5000. */
|
|
18
32
|
timeoutMs?: number;
|
|
33
|
+
/** Injected Secrets Manager client (or test fake); missing throws `E_NO_SDK`. */
|
|
19
34
|
secretsClient?: AwsSecretsClient;
|
|
35
|
+
/** Injected SSM client (or test fake); missing throws `E_NO_SDK`. */
|
|
20
36
|
ssmClient?: AwsSsmClient;
|
|
37
|
+
/** Secrets Manager value cap in bytes. Default 64 KiB. */
|
|
21
38
|
maxBytesSecret?: number;
|
|
39
|
+
/** SSM value cap in bytes. Default 8 KiB. */
|
|
22
40
|
maxBytesParam?: number;
|
|
23
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Merges Secrets Manager values (JSON objects merge, scalars key on the last id
|
|
44
|
+
* segment) with SSM parameters (longest-prefix strip, `/` to `__`, uppercased).
|
|
45
|
+
* Concurrent `load()` calls share one in-flight request.
|
|
46
|
+
*/
|
|
24
47
|
declare function awsProvider(opts: AwsProviderOptions): SecretProvider;
|
|
25
48
|
|
|
26
49
|
export { type AwsProviderOptions, type AwsSecretsClient, type AwsSsmClient, awsProvider };
|
package/dist/vault/aws.d.ts
CHANGED
|
@@ -1,26 +1,49 @@
|
|
|
1
|
-
import { a as SecretProvider } from '../types-
|
|
1
|
+
import { a as SecretProvider } from '../types-CClP1lxq.js';
|
|
2
2
|
import '@standard-schema/spec';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* AWS provider: Secrets Manager ids plus SSM parameters (with decryption)
|
|
6
|
+
* merged into one flat map. SDK clients are injected, never imported blindly,
|
|
7
|
+
* so tests can pass fakes and Edge bundles stay lean.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** Minimal Secrets Manager surface this provider needs (real SDK client or a fake). */
|
|
4
11
|
interface AwsSecretsClient {
|
|
5
12
|
getSecretValue(secretId: string): Promise<{
|
|
6
13
|
SecretString?: string;
|
|
7
14
|
SecretBinary?: Uint8Array | string;
|
|
8
15
|
} | string>;
|
|
9
16
|
}
|
|
17
|
+
/** Minimal SSM surface this provider needs (real SDK client or a fake). */
|
|
10
18
|
interface AwsSsmClient {
|
|
11
19
|
getParameters(names: string[], withDecryption?: boolean): Promise<Record<string, string>>;
|
|
12
20
|
}
|
|
21
|
+
/** Options for {@link awsProvider}. */
|
|
13
22
|
interface AwsProviderOptions {
|
|
23
|
+
/** Secrets Manager ids. */
|
|
14
24
|
secrets?: string[];
|
|
25
|
+
/** SSM names or path prefixes (trailing `/` optional). */
|
|
15
26
|
params?: string[];
|
|
27
|
+
/** Reserved: region override (currently from env `AWS_REGION`). */
|
|
16
28
|
region?: string;
|
|
29
|
+
/** Reserved: VersionId / stage pin. */
|
|
17
30
|
versionId?: string;
|
|
31
|
+
/** Applies to the whole `load()`. Default 5000. */
|
|
18
32
|
timeoutMs?: number;
|
|
33
|
+
/** Injected Secrets Manager client (or test fake); missing throws `E_NO_SDK`. */
|
|
19
34
|
secretsClient?: AwsSecretsClient;
|
|
35
|
+
/** Injected SSM client (or test fake); missing throws `E_NO_SDK`. */
|
|
20
36
|
ssmClient?: AwsSsmClient;
|
|
37
|
+
/** Secrets Manager value cap in bytes. Default 64 KiB. */
|
|
21
38
|
maxBytesSecret?: number;
|
|
39
|
+
/** SSM value cap in bytes. Default 8 KiB. */
|
|
22
40
|
maxBytesParam?: number;
|
|
23
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Merges Secrets Manager values (JSON objects merge, scalars key on the last id
|
|
44
|
+
* segment) with SSM parameters (longest-prefix strip, `/` to `__`, uppercased).
|
|
45
|
+
* Concurrent `load()` calls share one in-flight request.
|
|
46
|
+
*/
|
|
24
47
|
declare function awsProvider(opts: AwsProviderOptions): SecretProvider;
|
|
25
48
|
|
|
26
49
|
export { type AwsProviderOptions, type AwsSecretsClient, type AwsSsmClient, awsProvider };
|
|
@@ -1,19 +1,38 @@
|
|
|
1
|
-
import { a as SecretProvider } from '../types-
|
|
2
|
-
import { F as FetchFn } from '../shared-
|
|
1
|
+
import { a as SecretProvider } from '../types-CClP1lxq.cjs';
|
|
2
|
+
import { F as FetchFn } from '../shared-CucO_XsG.cjs';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* HashiCorp Vault provider (KVv1 + KVv2): reads one secret path into a flat map.
|
|
7
|
+
* Token comes from `auth.token` or `VAULT_TOKEN`; KVv2 envelopes unwrap only
|
|
8
|
+
* when a `metadata` sibling is present. Fail-closed on 403.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Options for {@link hashicorpProvider}. */
|
|
5
12
|
interface HashicorpOptions {
|
|
13
|
+
/** Vault base URL, e.g. `https://vault:8200`. */
|
|
6
14
|
url: string;
|
|
15
|
+
/** KV mount. Default `'secret'`. */
|
|
7
16
|
mount?: string;
|
|
17
|
+
/** Secret path: `data/app/prod` (KVv2) or `app/prod` (KVv1). */
|
|
8
18
|
path: string;
|
|
19
|
+
/** Explicit token. `''` means none (no `VAULT_TOKEN` fallback); unset reads `VAULT_TOKEN`. */
|
|
9
20
|
auth?: {
|
|
10
21
|
token?: string;
|
|
11
22
|
};
|
|
23
|
+
/** Pinned KVv2 version (`?version=`). */
|
|
12
24
|
version?: number | string;
|
|
25
|
+
/** Request timeout in ms. Default 5000. */
|
|
13
26
|
timeoutMs?: number;
|
|
27
|
+
/** Injectable fetch for tests. */
|
|
14
28
|
fetchFn?: FetchFn;
|
|
29
|
+
/** Response body cap in bytes. Default 1 MiB. */
|
|
15
30
|
maxBytes?: number;
|
|
16
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Reads one Vault path into a flat map. Concurrent `load()` calls share a
|
|
34
|
+
* single in-flight request; failures reset so the next call retries.
|
|
35
|
+
*/
|
|
17
36
|
declare function hashicorpProvider(opts: HashicorpOptions): SecretProvider;
|
|
18
37
|
|
|
19
38
|
export { type HashicorpOptions, hashicorpProvider };
|
|
@@ -1,19 +1,38 @@
|
|
|
1
|
-
import { a as SecretProvider } from '../types-
|
|
2
|
-
import { F as FetchFn } from '../shared-
|
|
1
|
+
import { a as SecretProvider } from '../types-CClP1lxq.js';
|
|
2
|
+
import { F as FetchFn } from '../shared-CucO_XsG.js';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* HashiCorp Vault provider (KVv1 + KVv2): reads one secret path into a flat map.
|
|
7
|
+
* Token comes from `auth.token` or `VAULT_TOKEN`; KVv2 envelopes unwrap only
|
|
8
|
+
* when a `metadata` sibling is present. Fail-closed on 403.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Options for {@link hashicorpProvider}. */
|
|
5
12
|
interface HashicorpOptions {
|
|
13
|
+
/** Vault base URL, e.g. `https://vault:8200`. */
|
|
6
14
|
url: string;
|
|
15
|
+
/** KV mount. Default `'secret'`. */
|
|
7
16
|
mount?: string;
|
|
17
|
+
/** Secret path: `data/app/prod` (KVv2) or `app/prod` (KVv1). */
|
|
8
18
|
path: string;
|
|
19
|
+
/** Explicit token. `''` means none (no `VAULT_TOKEN` fallback); unset reads `VAULT_TOKEN`. */
|
|
9
20
|
auth?: {
|
|
10
21
|
token?: string;
|
|
11
22
|
};
|
|
23
|
+
/** Pinned KVv2 version (`?version=`). */
|
|
12
24
|
version?: number | string;
|
|
25
|
+
/** Request timeout in ms. Default 5000. */
|
|
13
26
|
timeoutMs?: number;
|
|
27
|
+
/** Injectable fetch for tests. */
|
|
14
28
|
fetchFn?: FetchFn;
|
|
29
|
+
/** Response body cap in bytes. Default 1 MiB. */
|
|
15
30
|
maxBytes?: number;
|
|
16
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Reads one Vault path into a flat map. Concurrent `load()` calls share a
|
|
34
|
+
* single in-flight request; failures reset so the next call retries.
|
|
35
|
+
*/
|
|
17
36
|
declare function hashicorpProvider(opts: HashicorpOptions): SecretProvider;
|
|
18
37
|
|
|
19
38
|
export { type HashicorpOptions, hashicorpProvider };
|
package/dist/vault/http.d.cts
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
|
-
import { F as Flat, a as SecretProvider } from '../types-
|
|
2
|
-
import { F as FetchFn } from '../shared-
|
|
1
|
+
import { F as Flat, a as SecretProvider } from '../types-CClP1lxq.cjs';
|
|
2
|
+
import { F as FetchFn } from '../shared-CucO_XsG.cjs';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Generic HTTP secret provider: GETs a JSON endpoint and reads a dot-path
|
|
7
|
+
* (`jsonPath`, default `'data'`) into a flat map. Auth rides in `headers`.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** Options for {@link httpProvider}. */
|
|
5
11
|
interface HttpProviderOptions {
|
|
12
|
+
/** Endpoint URL. */
|
|
6
13
|
url: string;
|
|
14
|
+
/** Extra headers. Feed auth from env-injected values, never CLI args. */
|
|
7
15
|
headers?: Flat;
|
|
16
|
+
/** Dot path into the JSON body. Default `'data'`; `''` reads the whole body. */
|
|
8
17
|
jsonPath?: string;
|
|
18
|
+
/** Request timeout in ms. Default 5000. */
|
|
9
19
|
timeoutMs?: number;
|
|
20
|
+
/** Injectable fetch for tests. */
|
|
10
21
|
fetchFn?: FetchFn;
|
|
22
|
+
/** Response body cap in bytes. Default 1 MiB. */
|
|
11
23
|
maxBytes?: number;
|
|
12
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* GETs a JSON endpoint and reads `jsonPath` into a flat map. Concurrent loads
|
|
27
|
+
* share one in-flight request; failures reset so the next call retries.
|
|
28
|
+
*/
|
|
13
29
|
declare function httpProvider(opts: HttpProviderOptions): SecretProvider;
|
|
14
30
|
|
|
15
31
|
export { type HttpProviderOptions, httpProvider };
|
package/dist/vault/http.d.ts
CHANGED
|
@@ -1,15 +1,31 @@
|
|
|
1
|
-
import { F as Flat, a as SecretProvider } from '../types-
|
|
2
|
-
import { F as FetchFn } from '../shared-
|
|
1
|
+
import { F as Flat, a as SecretProvider } from '../types-CClP1lxq.js';
|
|
2
|
+
import { F as FetchFn } from '../shared-CucO_XsG.js';
|
|
3
3
|
import '@standard-schema/spec';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Generic HTTP secret provider: GETs a JSON endpoint and reads a dot-path
|
|
7
|
+
* (`jsonPath`, default `'data'`) into a flat map. Auth rides in `headers`.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** Options for {@link httpProvider}. */
|
|
5
11
|
interface HttpProviderOptions {
|
|
12
|
+
/** Endpoint URL. */
|
|
6
13
|
url: string;
|
|
14
|
+
/** Extra headers. Feed auth from env-injected values, never CLI args. */
|
|
7
15
|
headers?: Flat;
|
|
16
|
+
/** Dot path into the JSON body. Default `'data'`; `''` reads the whole body. */
|
|
8
17
|
jsonPath?: string;
|
|
18
|
+
/** Request timeout in ms. Default 5000. */
|
|
9
19
|
timeoutMs?: number;
|
|
20
|
+
/** Injectable fetch for tests. */
|
|
10
21
|
fetchFn?: FetchFn;
|
|
22
|
+
/** Response body cap in bytes. Default 1 MiB. */
|
|
11
23
|
maxBytes?: number;
|
|
12
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* GETs a JSON endpoint and reads `jsonPath` into a flat map. Concurrent loads
|
|
27
|
+
* share one in-flight request; failures reset so the next call retries.
|
|
28
|
+
*/
|
|
13
29
|
declare function httpProvider(opts: HttpProviderOptions): SecretProvider;
|
|
14
30
|
|
|
15
31
|
export { type HttpProviderOptions, httpProvider };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typed-settings",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "One-call typed config for TS: env + .env + yaml/toml/json + secrets-dir + vault -> frozen object. Standard Schema + legacy bridges.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
|
|
3
|
-
type Flat = Record<string, string | undefined>;
|
|
4
|
-
interface SecretProvider {
|
|
5
|
-
name: string;
|
|
6
|
-
load(): Promise<Flat> | Flat;
|
|
7
|
-
}
|
|
8
|
-
type SourceInput = 'env' | '.env' | '.env.local' | {
|
|
9
|
-
text: string;
|
|
10
|
-
} | {
|
|
11
|
-
file: string;
|
|
12
|
-
} | {
|
|
13
|
-
dir: string;
|
|
14
|
-
} | {
|
|
15
|
-
map: Flat;
|
|
16
|
-
prefix?: string;
|
|
17
|
-
} | {
|
|
18
|
-
provider: SecretProvider;
|
|
19
|
-
prefix?: string;
|
|
20
|
-
} | SecretProvider | Flat | string;
|
|
21
|
-
type ArrayStrategy = 'replace' | 'concat' | 'mergeIndex';
|
|
22
|
-
type UnknownKeys = 'strip' | 'preserve' | 'reject';
|
|
23
|
-
interface SettingsOptions<S extends StandardSchemaV1 = StandardSchemaV1> {
|
|
24
|
-
schema: S;
|
|
25
|
-
sources?: SourceInput[];
|
|
26
|
-
prefix?: string;
|
|
27
|
-
separator?: '__';
|
|
28
|
-
coerce?: boolean;
|
|
29
|
-
expand?: boolean;
|
|
30
|
-
expandSecrets?: boolean;
|
|
31
|
-
arrayStrategy?: ArrayStrategy;
|
|
32
|
-
unknownKeys?: UnknownKeys;
|
|
33
|
-
freeze?: boolean;
|
|
34
|
-
timeoutMs?: number;
|
|
35
|
-
maxBytes?: number;
|
|
36
|
-
envMap?: Record<string, string>;
|
|
37
|
-
allowUnresolved?: boolean;
|
|
38
|
-
env?: Flat;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export type { ArrayStrategy as A, Flat as F, SettingsOptions as S, UnknownKeys as U, SecretProvider as a, SourceInput as b };
|
package/dist/types-BswIPp7U.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
|
|
3
|
-
type Flat = Record<string, string | undefined>;
|
|
4
|
-
interface SecretProvider {
|
|
5
|
-
name: string;
|
|
6
|
-
load(): Promise<Flat> | Flat;
|
|
7
|
-
}
|
|
8
|
-
type SourceInput = 'env' | '.env' | '.env.local' | {
|
|
9
|
-
text: string;
|
|
10
|
-
} | {
|
|
11
|
-
file: string;
|
|
12
|
-
} | {
|
|
13
|
-
dir: string;
|
|
14
|
-
} | {
|
|
15
|
-
map: Flat;
|
|
16
|
-
prefix?: string;
|
|
17
|
-
} | {
|
|
18
|
-
provider: SecretProvider;
|
|
19
|
-
prefix?: string;
|
|
20
|
-
} | SecretProvider | Flat | string;
|
|
21
|
-
type ArrayStrategy = 'replace' | 'concat' | 'mergeIndex';
|
|
22
|
-
type UnknownKeys = 'strip' | 'preserve' | 'reject';
|
|
23
|
-
interface SettingsOptions<S extends StandardSchemaV1 = StandardSchemaV1> {
|
|
24
|
-
schema: S;
|
|
25
|
-
sources?: SourceInput[];
|
|
26
|
-
prefix?: string;
|
|
27
|
-
separator?: '__';
|
|
28
|
-
coerce?: boolean;
|
|
29
|
-
expand?: boolean;
|
|
30
|
-
expandSecrets?: boolean;
|
|
31
|
-
arrayStrategy?: ArrayStrategy;
|
|
32
|
-
unknownKeys?: UnknownKeys;
|
|
33
|
-
freeze?: boolean;
|
|
34
|
-
timeoutMs?: number;
|
|
35
|
-
maxBytes?: number;
|
|
36
|
-
envMap?: Record<string, string>;
|
|
37
|
-
allowUnresolved?: boolean;
|
|
38
|
-
env?: Flat;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export type { ArrayStrategy as A, Flat as F, SettingsOptions as S, UnknownKeys as U, SecretProvider as a, SourceInput as b };
|