typed-settings 0.1.1 → 0.2.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/README.md +18 -9
- package/bin/typed-settings.mjs +5 -0
- package/dist/adapters/joi.cjs +1 -26
- package/dist/adapters/joi.d.cts +2 -1
- package/dist/adapters/joi.d.ts +2 -1
- package/dist/adapters/joi.js +1 -1
- package/dist/adapters/superstruct.cjs +1 -26
- package/dist/adapters/superstruct.js +1 -1
- package/dist/adapters/yup.cjs +1 -25
- package/dist/adapters/yup.js +1 -1
- package/dist/adapters/zod.cjs +3 -36
- package/dist/adapters/zod.d.cts +2 -0
- package/dist/adapters/zod.d.ts +2 -0
- package/dist/adapters/zod.js +1 -33
- package/dist/check-XVFZEVNV.js +1 -0
- package/dist/chunk-4EAMKDNK.js +3 -0
- package/dist/chunk-5D2AQWDG.js +1 -0
- package/dist/chunk-C6CG2D4B.js +2 -0
- package/dist/chunk-FQYD5ZKE.js +1 -0
- package/dist/chunk-NQDE3WLR.js +3 -0
- package/dist/chunk-RURPDXIJ.js +1 -0
- package/dist/cli/main.cjs +36 -2220
- package/dist/cli/main.js +32 -806
- package/dist/errors-JkkOM0u-.d.cts +25 -0
- package/dist/errors-JkkOM0u-.d.ts +25 -0
- package/dist/framework/next.cjs +5 -1153
- package/dist/framework/next.d.cts +5 -3
- package/dist/framework/next.d.ts +5 -3
- package/dist/framework/next.js +1 -15
- package/dist/framework/vite.cjs +5 -1151
- package/dist/framework/vite.d.cts +10 -3
- package/dist/framework/vite.d.ts +10 -3
- package/dist/framework/vite.js +1 -14
- package/dist/index.cjs +5 -1176
- package/dist/index.d.cts +46 -10
- package/dist/index.d.ts +46 -10
- package/dist/index.js +1 -6
- package/dist/node.cjs +6 -1236
- package/dist/node.d.cts +23 -9
- package/dist/node.d.ts +23 -9
- package/dist/node.js +1 -7
- package/dist/{types-CClP1lxq.d.ts → types-CcsYDAdO.d.cts} +27 -3
- package/dist/{types-CClP1lxq.d.cts → types-CcsYDAdO.d.ts} +27 -3
- package/dist/vault/aws.cjs +4 -217
- package/dist/vault/aws.d.cts +3 -1
- package/dist/vault/aws.d.ts +3 -1
- package/dist/vault/aws.js +2 -167
- package/dist/vault/hashicorp.cjs +4 -183
- package/dist/vault/hashicorp.d.cts +3 -1
- package/dist/vault/hashicorp.d.ts +3 -1
- package/dist/vault/hashicorp.js +2 -77
- package/dist/vault/http.cjs +4 -185
- package/dist/vault/http.d.cts +3 -1
- package/dist/vault/http.d.ts +3 -1
- package/dist/vault/http.js +2 -79
- package/package.json +10 -3
- package/dist/chunk-33M5GIKQ.js +0 -13
- package/dist/chunk-A5TCQJ7L.js +0 -65
- package/dist/chunk-EE6LXNJV.js +0 -34
- package/dist/chunk-F6DX3HXZ.js +0 -101
- package/dist/chunk-OVFMKC2O.js +0 -15
- package/dist/chunk-RCO6K3WQ.js +0 -984
- package/dist/chunk-RQC6OMVV.js +0 -86
- package/dist/chunk-UFUHHR2J.js +0 -38
- package/dist/chunk-VTIYOSG2.js +0 -233
- package/dist/errors-itGaU4Q8.d.cts +0 -17
- package/dist/errors-itGaU4Q8.d.ts +0 -17
- package/dist/formats/env.cjs +0 -103
- package/dist/formats/env.d.cts +0 -8
- package/dist/formats/env.d.ts +0 -8
- package/dist/formats/env.js +0 -1
- package/dist/formats/json.cjs +0 -15
- package/dist/formats/json.d.cts +0 -7
- package/dist/formats/json.d.ts +0 -7
- package/dist/formats/json.js +0 -1
- package/dist/formats/toml.cjs +0 -17
- package/dist/formats/toml.d.cts +0 -7
- package/dist/formats/toml.d.ts +0 -7
- package/dist/formats/toml.js +0 -1
- package/dist/formats/yaml.cjs +0 -40
- package/dist/formats/yaml.d.cts +0 -8
- package/dist/formats/yaml.d.ts +0 -8
- package/dist/formats/yaml.js +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,34 @@
|
|
|
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-CcsYDAdO.cjs';
|
|
3
|
+
export { A as ArrayStrategy, a as SecretProvider, b as SourceInput, U as UnknownKeys } from './types-CcsYDAdO.cjs';
|
|
4
|
+
export { C as ConfigError, i as isSecretKey } from './errors-JkkOM0u-.cjs';
|
|
5
|
+
|
|
6
|
+
/** Validation outcome with root-attributed, path-normalized issues. */
|
|
7
|
+
interface NormalizedResult {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
value?: unknown;
|
|
10
|
+
issues?: {
|
|
11
|
+
path: string;
|
|
12
|
+
message: string;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Runs a Standard Schema `validate()` and normalizes the outcome. Sync results
|
|
17
|
+
* return `{ value }` or `{ issues, async: false }`; a thenable (checked by shape,
|
|
18
|
+
* not `instanceof`) returns `{ promise }` for the async path. Throwing validators
|
|
19
|
+
* become root issues instead of leaking.
|
|
20
|
+
*/
|
|
21
|
+
declare function validateStandard<S extends StandardSchemaV1>(schema: S, input: unknown): {
|
|
22
|
+
value: unknown;
|
|
23
|
+
} | {
|
|
24
|
+
issues: {
|
|
25
|
+
path: string;
|
|
26
|
+
message: string;
|
|
27
|
+
}[];
|
|
28
|
+
async: false;
|
|
29
|
+
} | {
|
|
30
|
+
promise: Promise<NormalizedResult>;
|
|
31
|
+
};
|
|
5
32
|
|
|
6
33
|
/**
|
|
7
34
|
* Typed config in one call.
|
|
@@ -10,12 +37,17 @@ export { C as ConfigError } from './errors-itGaU4Q8.cjs';
|
|
|
10
37
|
* secrets-dir maps, and vault secrets, then merge, expand `$VAR` references,
|
|
11
38
|
* coerce, validate against a Standard Schema, and return the result frozen.
|
|
12
39
|
* Anything invalid throws `ConfigError` at boot with the key and source attached.
|
|
40
|
+
*
|
|
41
|
+
* @module
|
|
13
42
|
*/
|
|
14
43
|
|
|
15
44
|
/**
|
|
16
45
|
* Runs `fn` with `process.env` patched by `map` (`undefined` deletes a key),
|
|
17
46
|
* then restores the exact previous environment — synchronously for sync `fn`,
|
|
18
47
|
* held until settle for async `fn`. Restores on throw too.
|
|
48
|
+
*
|
|
49
|
+
* NOTE: not safe for overlapping concurrent use — two in-flight `withOverrides`
|
|
50
|
+
* calls interleave on the shared global. Serialize them, or pass `env:` instead.
|
|
19
51
|
*/
|
|
20
52
|
declare function withOverrides<T>(map: Flat, fn: () => T): T;
|
|
21
53
|
/**
|
|
@@ -31,16 +63,20 @@ declare function pickPublic<T extends object>(cfg: T, keys: (keyof T)[]): Partia
|
|
|
31
63
|
declare function viteSettings<S extends StandardSchemaV1>(opts: SettingsOptions<S>, metaEnv: Flat): StandardSchemaV1.InferOutput<S>;
|
|
32
64
|
/**
|
|
33
65
|
* Loads, merges, expands, coerces, and validates config synchronously, returning
|
|
34
|
-
* the inferred output type, frozen.
|
|
35
|
-
*
|
|
36
|
-
*
|
|
66
|
+
* the inferred output type, frozen. Each issue names the failing `path` and the
|
|
67
|
+
* source that won it, with secrets redacted.
|
|
68
|
+
*
|
|
69
|
+
* @throws ConfigError on merge, parse, expansion, or validation failure.
|
|
70
|
+
* @throws ConfigError with `code: 'USE_ASYNC'` if a provider or the schema is
|
|
71
|
+
* async — switch to `settingsAsync()`.
|
|
37
72
|
*/
|
|
38
73
|
declare function settings<S extends StandardSchemaV1>(opts: SettingsOptions<S>): StandardSchemaV1.InferOutput<S>;
|
|
39
74
|
/**
|
|
40
|
-
* Async twin of `settings()`: awaits async providers (whole collection
|
|
41
|
-
* `timeoutMs`) and async schemas
|
|
42
|
-
*
|
|
75
|
+
* Async twin of `settings()`: awaits async providers (the whole collection
|
|
76
|
+
* shares one `timeoutMs` deadline) and async schemas (which race a separate
|
|
77
|
+
* `timeoutMs` budget), with the same merge/expand/coerce/validate/freeze
|
|
78
|
+
* pipeline and the same `ConfigError` contract.
|
|
43
79
|
*/
|
|
44
80
|
declare function settingsAsync<S extends StandardSchemaV1>(opts: SettingsOptions<S>): Promise<StandardSchemaV1.InferOutput<S>>;
|
|
45
81
|
|
|
46
|
-
export { Flat, SettingsOptions, pickPublic, settings, settingsAsync, viteSettings, withOverrides };
|
|
82
|
+
export { Flat, SettingsOptions, pickPublic, settings, settingsAsync, validateStandard, viteSettings, withOverrides };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,34 @@
|
|
|
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-CcsYDAdO.js';
|
|
3
|
+
export { A as ArrayStrategy, a as SecretProvider, b as SourceInput, U as UnknownKeys } from './types-CcsYDAdO.js';
|
|
4
|
+
export { C as ConfigError, i as isSecretKey } from './errors-JkkOM0u-.js';
|
|
5
|
+
|
|
6
|
+
/** Validation outcome with root-attributed, path-normalized issues. */
|
|
7
|
+
interface NormalizedResult {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
value?: unknown;
|
|
10
|
+
issues?: {
|
|
11
|
+
path: string;
|
|
12
|
+
message: string;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Runs a Standard Schema `validate()` and normalizes the outcome. Sync results
|
|
17
|
+
* return `{ value }` or `{ issues, async: false }`; a thenable (checked by shape,
|
|
18
|
+
* not `instanceof`) returns `{ promise }` for the async path. Throwing validators
|
|
19
|
+
* become root issues instead of leaking.
|
|
20
|
+
*/
|
|
21
|
+
declare function validateStandard<S extends StandardSchemaV1>(schema: S, input: unknown): {
|
|
22
|
+
value: unknown;
|
|
23
|
+
} | {
|
|
24
|
+
issues: {
|
|
25
|
+
path: string;
|
|
26
|
+
message: string;
|
|
27
|
+
}[];
|
|
28
|
+
async: false;
|
|
29
|
+
} | {
|
|
30
|
+
promise: Promise<NormalizedResult>;
|
|
31
|
+
};
|
|
5
32
|
|
|
6
33
|
/**
|
|
7
34
|
* Typed config in one call.
|
|
@@ -10,12 +37,17 @@ export { C as ConfigError } from './errors-itGaU4Q8.js';
|
|
|
10
37
|
* secrets-dir maps, and vault secrets, then merge, expand `$VAR` references,
|
|
11
38
|
* coerce, validate against a Standard Schema, and return the result frozen.
|
|
12
39
|
* Anything invalid throws `ConfigError` at boot with the key and source attached.
|
|
40
|
+
*
|
|
41
|
+
* @module
|
|
13
42
|
*/
|
|
14
43
|
|
|
15
44
|
/**
|
|
16
45
|
* Runs `fn` with `process.env` patched by `map` (`undefined` deletes a key),
|
|
17
46
|
* then restores the exact previous environment — synchronously for sync `fn`,
|
|
18
47
|
* held until settle for async `fn`. Restores on throw too.
|
|
48
|
+
*
|
|
49
|
+
* NOTE: not safe for overlapping concurrent use — two in-flight `withOverrides`
|
|
50
|
+
* calls interleave on the shared global. Serialize them, or pass `env:` instead.
|
|
19
51
|
*/
|
|
20
52
|
declare function withOverrides<T>(map: Flat, fn: () => T): T;
|
|
21
53
|
/**
|
|
@@ -31,16 +63,20 @@ declare function pickPublic<T extends object>(cfg: T, keys: (keyof T)[]): Partia
|
|
|
31
63
|
declare function viteSettings<S extends StandardSchemaV1>(opts: SettingsOptions<S>, metaEnv: Flat): StandardSchemaV1.InferOutput<S>;
|
|
32
64
|
/**
|
|
33
65
|
* Loads, merges, expands, coerces, and validates config synchronously, returning
|
|
34
|
-
* the inferred output type, frozen.
|
|
35
|
-
*
|
|
36
|
-
*
|
|
66
|
+
* the inferred output type, frozen. Each issue names the failing `path` and the
|
|
67
|
+
* source that won it, with secrets redacted.
|
|
68
|
+
*
|
|
69
|
+
* @throws ConfigError on merge, parse, expansion, or validation failure.
|
|
70
|
+
* @throws ConfigError with `code: 'USE_ASYNC'` if a provider or the schema is
|
|
71
|
+
* async — switch to `settingsAsync()`.
|
|
37
72
|
*/
|
|
38
73
|
declare function settings<S extends StandardSchemaV1>(opts: SettingsOptions<S>): StandardSchemaV1.InferOutput<S>;
|
|
39
74
|
/**
|
|
40
|
-
* Async twin of `settings()`: awaits async providers (whole collection
|
|
41
|
-
* `timeoutMs`) and async schemas
|
|
42
|
-
*
|
|
75
|
+
* Async twin of `settings()`: awaits async providers (the whole collection
|
|
76
|
+
* shares one `timeoutMs` deadline) and async schemas (which race a separate
|
|
77
|
+
* `timeoutMs` budget), with the same merge/expand/coerce/validate/freeze
|
|
78
|
+
* pipeline and the same `ConfigError` contract.
|
|
43
79
|
*/
|
|
44
80
|
declare function settingsAsync<S extends StandardSchemaV1>(opts: SettingsOptions<S>): Promise<StandardSchemaV1.InferOutput<S>>;
|
|
45
81
|
|
|
46
|
-
export { Flat, SettingsOptions, pickPublic, settings, settingsAsync, viteSettings, withOverrides };
|
|
82
|
+
export { Flat, SettingsOptions, pickPublic, settings, settingsAsync, validateStandard, viteSettings, withOverrides };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
import './chunk-33M5GIKQ.js';
|
|
3
|
-
import './chunk-OVFMKC2O.js';
|
|
4
|
-
import './chunk-UFUHHR2J.js';
|
|
5
|
-
export { ConfigError } from './chunk-EE6LXNJV.js';
|
|
6
|
-
import './chunk-F6DX3HXZ.js';
|
|
1
|
+
export{d as pickPublic,f as settings,g as settingsAsync,b as validateStandard,e as viteSettings,c as withOverrides}from'./chunk-4EAMKDNK.js';export{d as ConfigError,a as isSecretKey}from'./chunk-NQDE3WLR.js';
|