@o3co/ts.hocon 1.13.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.
Files changed (43) hide show
  1. package/README.ja.md +251 -29
  2. package/README.md +159 -29
  3. package/dist/adapters/env.cjs +26 -2018
  4. package/dist/adapters/env.d.cts +1 -1
  5. package/dist/adapters/env.d.ts +1 -1
  6. package/dist/adapters/env.js +11 -1965
  7. package/dist/adapters/json5.cjs +15 -1969
  8. package/dist/adapters/json5.d.cts +1 -1
  9. package/dist/adapters/json5.d.ts +1 -1
  10. package/dist/adapters/json5.js +12 -1929
  11. package/dist/adapters/jsonc.cjs +17 -1972
  12. package/dist/adapters/jsonc.d.cts +1 -1
  13. package/dist/adapters/jsonc.d.ts +1 -1
  14. package/dist/adapters/jsonc.js +9 -1926
  15. package/dist/adapters/properties.cjs +7 -2113
  16. package/dist/adapters/properties.d.cts +1 -1
  17. package/dist/adapters/properties.d.ts +1 -1
  18. package/dist/adapters/properties.js +6 -2075
  19. package/dist/adapters/toml.cjs +12 -1966
  20. package/dist/adapters/toml.d.cts +1 -1
  21. package/dist/adapters/toml.d.ts +1 -1
  22. package/dist/adapters/toml.js +10 -1929
  23. package/dist/adapters/yaml.cjs +20 -1975
  24. package/dist/adapters/yaml.d.cts +1 -1
  25. package/dist/adapters/yaml.d.ts +1 -1
  26. package/dist/adapters/yaml.js +10 -1929
  27. package/dist/chunk-GBNQADHT.cjs +83 -0
  28. package/dist/chunk-IMJ7QHIK.cjs +158 -0
  29. package/dist/chunk-QY7ECGS6.js +83 -0
  30. package/dist/chunk-RO4D6BH7.cjs +3792 -0
  31. package/dist/chunk-WTXULUZS.js +3792 -0
  32. package/dist/chunk-XWKO4JM3.js +158 -0
  33. package/dist/{config-6sApTEMM.d.cts → config-OccaKqXu.d.cts} +126 -4
  34. package/dist/{config-6sApTEMM.d.ts → config-OccaKqXu.d.ts} +126 -4
  35. package/dist/index.cjs +34 -3793
  36. package/dist/index.d.cts +2 -2
  37. package/dist/index.d.ts +2 -2
  38. package/dist/index.js +25 -3728
  39. package/dist/zod.cjs +107 -3636
  40. package/dist/zod.d.cts +83 -3
  41. package/dist/zod.d.ts +83 -3
  42. package/dist/zod.js +94 -3589
  43. package/package.json +1 -1
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-6sApTEMM.cjs';
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-6sApTEMM.js';
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 };