@o3co/ts.hocon 1.12.0 → 1.14.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.ja.md +256 -32
- package/README.md +166 -32
- package/dist/adapters/env.cjs +26 -1678
- package/dist/adapters/env.d.cts +1 -1
- package/dist/adapters/env.d.ts +1 -1
- package/dist/adapters/env.js +11 -1625
- package/dist/adapters/json5.cjs +496 -0
- package/dist/adapters/json5.d.cts +47 -0
- package/dist/adapters/json5.d.ts +47 -0
- package/dist/adapters/json5.js +496 -0
- package/dist/adapters/jsonc.cjs +17 -1632
- package/dist/adapters/jsonc.d.cts +1 -1
- package/dist/adapters/jsonc.d.ts +1 -1
- package/dist/adapters/jsonc.js +9 -1586
- package/dist/adapters/properties.cjs +7 -1773
- package/dist/adapters/properties.d.cts +1 -1
- package/dist/adapters/properties.d.ts +1 -1
- package/dist/adapters/properties.js +6 -1735
- package/dist/adapters/toml.cjs +12 -1626
- package/dist/adapters/toml.d.cts +1 -1
- package/dist/adapters/toml.d.ts +1 -1
- package/dist/adapters/toml.js +10 -1589
- package/dist/adapters/yaml.cjs +20 -1635
- package/dist/adapters/yaml.d.cts +1 -1
- package/dist/adapters/yaml.d.ts +1 -1
- package/dist/adapters/yaml.js +10 -1589
- package/dist/chunk-GBNQADHT.cjs +83 -0
- package/dist/chunk-IMJ7QHIK.cjs +158 -0
- package/dist/chunk-QY7ECGS6.js +83 -0
- package/dist/chunk-RO4D6BH7.cjs +3792 -0
- package/dist/chunk-WTXULUZS.js +3792 -0
- package/dist/chunk-XWKO4JM3.js +158 -0
- package/dist/{config-Dlq6rF3w.d.cts → config-OccaKqXu.d.cts} +148 -4
- package/dist/{config-Dlq6rF3w.d.ts → config-OccaKqXu.d.ts} +148 -4
- package/dist/index.cjs +35 -3449
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +25 -3383
- package/dist/zod.cjs +107 -3291
- package/dist/zod.d.cts +83 -3
- package/dist/zod.d.ts +83 -3
- package/dist/zod.js +95 -3245
- package/package.json +12 -2
package/dist/zod.d.cts
CHANGED
|
@@ -1,9 +1,89 @@
|
|
|
1
|
-
import { ZodType } from 'zod';
|
|
2
|
-
import { C as Config, a as ParseOptions } from './config-
|
|
1
|
+
import { ZodType, ZodTransform } from 'zod';
|
|
2
|
+
import { C as Config, D as DurationUnit, B as ByteUnit, b as Period, a as ParseOptions } from './config-OccaKqXu.cjs';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The whole config, validated against `schema`. HOCON strings are coerced
|
|
6
|
+
* where the schema expects a number or a boolean (`"8080"` → 8080), through
|
|
7
|
+
* objects, arrays and optional / nullable / default / catch / readonly
|
|
8
|
+
* wrappers (not unions, records, tuples or pipes); unit values go through the
|
|
9
|
+
* {@link hocon} markers.
|
|
10
|
+
*
|
|
11
|
+
* An object key named `__proto__`, `constructor` or `prototype` anywhere in
|
|
12
|
+
* the value is refused with a `ZodError` issue at the object that holds it
|
|
13
|
+
* (#202); read such a key with the plain getters instead.
|
|
14
|
+
*
|
|
15
|
+
* @throws {@link NotResolvedError} when the config still holds an unresolved
|
|
16
|
+
* substitution (#210); call `resolve()` first.
|
|
17
|
+
* @throws `ZodError` when the value does not match the schema.
|
|
18
|
+
*/
|
|
4
19
|
declare function validate<T>(config: Config, schema: ZodType<T>): T;
|
|
20
|
+
/**
|
|
21
|
+
* The value at `path`, validated against `schema` as {@link validate} does;
|
|
22
|
+
* issue paths are relative to that value.
|
|
23
|
+
*
|
|
24
|
+
* An object key named `__proto__`, `constructor` or `prototype` anywhere in
|
|
25
|
+
* the value is refused with a `ZodError` issue at the object that holds it
|
|
26
|
+
* (#202); read such a key with the plain getters instead.
|
|
27
|
+
*
|
|
28
|
+
* @throws {@link NotResolvedError} when the value at `path` still holds an
|
|
29
|
+
* unresolved substitution (#210); a resolved subtree of an otherwise
|
|
30
|
+
* unresolved config validates.
|
|
31
|
+
* @throws `ZodError` when the value does not match the schema.
|
|
32
|
+
*/
|
|
5
33
|
declare function getValidated<T>(config: Config, path: string, schema: ZodType<T>): T;
|
|
34
|
+
/**
|
|
35
|
+
* Zod schema markers for HOCON unit values. Each reads the forms the matching
|
|
36
|
+
* Config getter reads and gives what the getter gives (a number in the
|
|
37
|
+
* requested unit, or a {@link Period}); pipe it into a schema for the
|
|
38
|
+
* constraints:
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* const Session = z.object({
|
|
42
|
+
* lifetime: hocon.duration('s').pipe(z.number().int().min(60)),
|
|
43
|
+
* maxBody: hocon.bytes().pipe(z.number().int().positive()),
|
|
44
|
+
* })
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
declare const hocon: {
|
|
48
|
+
/**
|
|
49
|
+
* A duration, read as {@link Config.getDuration} reads it (default unit `ms`),
|
|
50
|
+
* exponent forms included, except that a number literal with more
|
|
51
|
+
* significant digits than a double holds can read differently: the getter
|
|
52
|
+
* reads its text, the marker its JS value (`1.0000000000000001` in `us`:
|
|
53
|
+
* 1000.0000000000001 through the getter, 1000 here).
|
|
54
|
+
*/
|
|
55
|
+
duration(unit?: DurationUnit): ZodTransform<number, unknown>;
|
|
56
|
+
/**
|
|
57
|
+
* A byte size, read as {@link Config.getBytes} reads it (default unit `B`),
|
|
58
|
+
* exponent forms included, except that a number literal with more
|
|
59
|
+
* significant digits than a double holds can read differently: the getter
|
|
60
|
+
* reads its text, the marker its JS value (`1.99999999999999999`: 1 through
|
|
61
|
+
* the getter, 2 here).
|
|
62
|
+
*/
|
|
63
|
+
bytes(unit?: ByteUnit): ZodTransform<number, unknown>;
|
|
64
|
+
/**
|
|
65
|
+
* A calendar period, read as {@link Config.getPeriod} reads it (a bare
|
|
66
|
+
* integer is days), except that a number literal with a decimal point or in
|
|
67
|
+
* exponent form (`7.0`, `1e2`) can read differently: the getter refuses it,
|
|
68
|
+
* the marker reads the JS number.
|
|
69
|
+
*/
|
|
70
|
+
period(): ZodTransform<Period, unknown>;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Parse a HOCON string and {@link validate} it.
|
|
74
|
+
*
|
|
75
|
+
* @throws as `parse`; {@link NotResolvedError} when parsed with
|
|
76
|
+
* `resolveSubstitutions: false` and a substitution is left (#210); `ZodError`
|
|
77
|
+
* when the value does not match the schema.
|
|
78
|
+
*/
|
|
6
79
|
declare function parseWithSchema<T>(input: string, schema: ZodType<T>, opts?: ParseOptions): T;
|
|
80
|
+
/**
|
|
81
|
+
* Read and parse a HOCON file and {@link validate} it.
|
|
82
|
+
*
|
|
83
|
+
* @throws as `parseFile`; {@link NotResolvedError} when parsed with
|
|
84
|
+
* `resolveSubstitutions: false` and a substitution is left (#210); `ZodError`
|
|
85
|
+
* when the value does not match the schema.
|
|
86
|
+
*/
|
|
7
87
|
declare function parseFileWithSchema<T>(filePath: string, schema: ZodType<T>, opts?: ParseOptions): T;
|
|
8
88
|
|
|
9
|
-
export { getValidated, parseFileWithSchema, parseWithSchema, validate };
|
|
89
|
+
export { getValidated, hocon, parseFileWithSchema, parseWithSchema, validate };
|
package/dist/zod.d.ts
CHANGED
|
@@ -1,9 +1,89 @@
|
|
|
1
|
-
import { ZodType } from 'zod';
|
|
2
|
-
import { C as Config, a as ParseOptions } from './config-
|
|
1
|
+
import { ZodType, ZodTransform } from 'zod';
|
|
2
|
+
import { C as Config, D as DurationUnit, B as ByteUnit, b as Period, a as ParseOptions } from './config-OccaKqXu.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The whole config, validated against `schema`. HOCON strings are coerced
|
|
6
|
+
* where the schema expects a number or a boolean (`"8080"` → 8080), through
|
|
7
|
+
* objects, arrays and optional / nullable / default / catch / readonly
|
|
8
|
+
* wrappers (not unions, records, tuples or pipes); unit values go through the
|
|
9
|
+
* {@link hocon} markers.
|
|
10
|
+
*
|
|
11
|
+
* An object key named `__proto__`, `constructor` or `prototype` anywhere in
|
|
12
|
+
* the value is refused with a `ZodError` issue at the object that holds it
|
|
13
|
+
* (#202); read such a key with the plain getters instead.
|
|
14
|
+
*
|
|
15
|
+
* @throws {@link NotResolvedError} when the config still holds an unresolved
|
|
16
|
+
* substitution (#210); call `resolve()` first.
|
|
17
|
+
* @throws `ZodError` when the value does not match the schema.
|
|
18
|
+
*/
|
|
4
19
|
declare function validate<T>(config: Config, schema: ZodType<T>): T;
|
|
20
|
+
/**
|
|
21
|
+
* The value at `path`, validated against `schema` as {@link validate} does;
|
|
22
|
+
* issue paths are relative to that value.
|
|
23
|
+
*
|
|
24
|
+
* An object key named `__proto__`, `constructor` or `prototype` anywhere in
|
|
25
|
+
* the value is refused with a `ZodError` issue at the object that holds it
|
|
26
|
+
* (#202); read such a key with the plain getters instead.
|
|
27
|
+
*
|
|
28
|
+
* @throws {@link NotResolvedError} when the value at `path` still holds an
|
|
29
|
+
* unresolved substitution (#210); a resolved subtree of an otherwise
|
|
30
|
+
* unresolved config validates.
|
|
31
|
+
* @throws `ZodError` when the value does not match the schema.
|
|
32
|
+
*/
|
|
5
33
|
declare function getValidated<T>(config: Config, path: string, schema: ZodType<T>): T;
|
|
34
|
+
/**
|
|
35
|
+
* Zod schema markers for HOCON unit values. Each reads the forms the matching
|
|
36
|
+
* Config getter reads and gives what the getter gives (a number in the
|
|
37
|
+
* requested unit, or a {@link Period}); pipe it into a schema for the
|
|
38
|
+
* constraints:
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* const Session = z.object({
|
|
42
|
+
* lifetime: hocon.duration('s').pipe(z.number().int().min(60)),
|
|
43
|
+
* maxBody: hocon.bytes().pipe(z.number().int().positive()),
|
|
44
|
+
* })
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
declare const hocon: {
|
|
48
|
+
/**
|
|
49
|
+
* A duration, read as {@link Config.getDuration} reads it (default unit `ms`),
|
|
50
|
+
* exponent forms included, except that a number literal with more
|
|
51
|
+
* significant digits than a double holds can read differently: the getter
|
|
52
|
+
* reads its text, the marker its JS value (`1.0000000000000001` in `us`:
|
|
53
|
+
* 1000.0000000000001 through the getter, 1000 here).
|
|
54
|
+
*/
|
|
55
|
+
duration(unit?: DurationUnit): ZodTransform<number, unknown>;
|
|
56
|
+
/**
|
|
57
|
+
* A byte size, read as {@link Config.getBytes} reads it (default unit `B`),
|
|
58
|
+
* exponent forms included, except that a number literal with more
|
|
59
|
+
* significant digits than a double holds can read differently: the getter
|
|
60
|
+
* reads its text, the marker its JS value (`1.99999999999999999`: 1 through
|
|
61
|
+
* the getter, 2 here).
|
|
62
|
+
*/
|
|
63
|
+
bytes(unit?: ByteUnit): ZodTransform<number, unknown>;
|
|
64
|
+
/**
|
|
65
|
+
* A calendar period, read as {@link Config.getPeriod} reads it (a bare
|
|
66
|
+
* integer is days), except that a number literal with a decimal point or in
|
|
67
|
+
* exponent form (`7.0`, `1e2`) can read differently: the getter refuses it,
|
|
68
|
+
* the marker reads the JS number.
|
|
69
|
+
*/
|
|
70
|
+
period(): ZodTransform<Period, unknown>;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Parse a HOCON string and {@link validate} it.
|
|
74
|
+
*
|
|
75
|
+
* @throws as `parse`; {@link NotResolvedError} when parsed with
|
|
76
|
+
* `resolveSubstitutions: false` and a substitution is left (#210); `ZodError`
|
|
77
|
+
* when the value does not match the schema.
|
|
78
|
+
*/
|
|
6
79
|
declare function parseWithSchema<T>(input: string, schema: ZodType<T>, opts?: ParseOptions): T;
|
|
80
|
+
/**
|
|
81
|
+
* Read and parse a HOCON file and {@link validate} it.
|
|
82
|
+
*
|
|
83
|
+
* @throws as `parseFile`; {@link NotResolvedError} when parsed with
|
|
84
|
+
* `resolveSubstitutions: false` and a substitution is left (#210); `ZodError`
|
|
85
|
+
* when the value does not match the schema.
|
|
86
|
+
*/
|
|
7
87
|
declare function parseFileWithSchema<T>(filePath: string, schema: ZodType<T>, opts?: ParseOptions): T;
|
|
8
88
|
|
|
9
|
-
export { getValidated, parseFileWithSchema, parseWithSchema, validate };
|
|
89
|
+
export { getValidated, hocon, parseFileWithSchema, parseWithSchema, validate };
|