@o3co/ts.hocon 1.13.0 → 1.14.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.
Files changed (43) hide show
  1. package/README.ja.md +253 -29
  2. package/README.md +161 -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-GOXMKYWS.js +3801 -0
  28. package/dist/chunk-JVABBNF5.js +158 -0
  29. package/dist/chunk-L3D2RE2U.cjs +3801 -0
  30. package/dist/chunk-OUPKYWL3.cjs +158 -0
  31. package/dist/chunk-PCAMDXJ4.cjs +83 -0
  32. package/dist/chunk-YRNDXYGQ.js +83 -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 +195 -3636
  40. package/dist/zod.d.cts +86 -3
  41. package/dist/zod.d.ts +86 -3
  42. package/dist/zod.js +182 -3589
  43. package/package.json +5 -5
package/dist/zod.d.cts CHANGED
@@ -1,9 +1,92 @@
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, records, tuples, unions, pipes (by their input schema), lazy
8
+ * schemas and optional / nullable / default / prefault / nonoptional / catch /
9
+ * readonly wrappers; a union coerces by the option that takes the value (see
10
+ * the README). Unit values go through the {@link hocon} markers.
11
+ *
12
+ * An object key named `__proto__`, `constructor` or `prototype` anywhere in
13
+ * the value is refused with a `ZodError` issue at the object that holds it
14
+ * (#202), reported together with the schema's issues for the rest of the value
15
+ * (#227); read such a key with the plain getters instead.
16
+ *
17
+ * @throws {@link NotResolvedError} when the config still holds an unresolved
18
+ * substitution (#210); call `resolve()` first.
19
+ * @throws `ZodError` when the value does not match the schema.
20
+ */
4
21
  declare function validate<T>(config: Config, schema: ZodType<T>): T;
22
+ /**
23
+ * The value at `path`, validated against `schema` as {@link validate} does;
24
+ * issue paths are relative to that value.
25
+ *
26
+ * An object key named `__proto__`, `constructor` or `prototype` anywhere in
27
+ * the value is refused with a `ZodError` issue at the object that holds it
28
+ * (#202), reported together with the schema's issues for the rest of the value
29
+ * (#227); read such a key with the plain getters instead.
30
+ *
31
+ * @throws {@link NotResolvedError} when the value at `path` still holds an
32
+ * unresolved substitution (#210); a resolved subtree of an otherwise
33
+ * unresolved config validates.
34
+ * @throws `ZodError` when the value does not match the schema.
35
+ */
5
36
  declare function getValidated<T>(config: Config, path: string, schema: ZodType<T>): T;
37
+ /**
38
+ * Zod schema markers for HOCON unit values. Each reads the forms the matching
39
+ * Config getter reads and gives what the getter gives (a number in the
40
+ * requested unit, or a {@link Period}); pipe it into a schema for the
41
+ * constraints:
42
+ *
43
+ * ```ts
44
+ * const Session = z.object({
45
+ * lifetime: hocon.duration('s').pipe(z.number().int().min(60)),
46
+ * maxBody: hocon.bytes().pipe(z.number().int().positive()),
47
+ * })
48
+ * ```
49
+ */
50
+ declare const hocon: {
51
+ /**
52
+ * A duration, read as {@link Config.getDuration} reads it (default unit `ms`),
53
+ * exponent forms included, except that a number literal with more
54
+ * significant digits than a double holds can read differently: the getter
55
+ * reads its text, the marker its JS value (`1.0000000000000001` in `us`:
56
+ * 1000.0000000000001 through the getter, 1000 here).
57
+ */
58
+ duration(unit?: DurationUnit): ZodTransform<number, unknown>;
59
+ /**
60
+ * A byte size, read as {@link Config.getBytes} reads it (default unit `B`),
61
+ * exponent forms included, except that a number literal with more
62
+ * significant digits than a double holds can read differently: the getter
63
+ * reads its text, the marker its JS value (`1.99999999999999999`: 1 through
64
+ * the getter, 2 here).
65
+ */
66
+ bytes(unit?: ByteUnit): ZodTransform<number, unknown>;
67
+ /**
68
+ * A calendar period, read as {@link Config.getPeriod} reads it (a bare
69
+ * integer is days), except that a number literal with a decimal point or in
70
+ * exponent form (`7.0`, `1e2`) can read differently: the getter refuses it,
71
+ * the marker reads the JS number.
72
+ */
73
+ period(): ZodTransform<Period, unknown>;
74
+ };
75
+ /**
76
+ * Parse a HOCON string and {@link validate} it.
77
+ *
78
+ * @throws as `parse`; {@link NotResolvedError} when parsed with
79
+ * `resolveSubstitutions: false` and a substitution is left (#210); `ZodError`
80
+ * when the value does not match the schema.
81
+ */
6
82
  declare function parseWithSchema<T>(input: string, schema: ZodType<T>, opts?: ParseOptions): T;
83
+ /**
84
+ * Read and parse a HOCON file and {@link validate} it.
85
+ *
86
+ * @throws as `parseFile`; {@link NotResolvedError} when parsed with
87
+ * `resolveSubstitutions: false` and a substitution is left (#210); `ZodError`
88
+ * when the value does not match the schema.
89
+ */
7
90
  declare function parseFileWithSchema<T>(filePath: string, schema: ZodType<T>, opts?: ParseOptions): T;
8
91
 
9
- export { getValidated, parseFileWithSchema, parseWithSchema, validate };
92
+ export { getValidated, hocon, parseFileWithSchema, parseWithSchema, validate };
package/dist/zod.d.ts CHANGED
@@ -1,9 +1,92 @@
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, records, tuples, unions, pipes (by their input schema), lazy
8
+ * schemas and optional / nullable / default / prefault / nonoptional / catch /
9
+ * readonly wrappers; a union coerces by the option that takes the value (see
10
+ * the README). Unit values go through the {@link hocon} markers.
11
+ *
12
+ * An object key named `__proto__`, `constructor` or `prototype` anywhere in
13
+ * the value is refused with a `ZodError` issue at the object that holds it
14
+ * (#202), reported together with the schema's issues for the rest of the value
15
+ * (#227); read such a key with the plain getters instead.
16
+ *
17
+ * @throws {@link NotResolvedError} when the config still holds an unresolved
18
+ * substitution (#210); call `resolve()` first.
19
+ * @throws `ZodError` when the value does not match the schema.
20
+ */
4
21
  declare function validate<T>(config: Config, schema: ZodType<T>): T;
22
+ /**
23
+ * The value at `path`, validated against `schema` as {@link validate} does;
24
+ * issue paths are relative to that value.
25
+ *
26
+ * An object key named `__proto__`, `constructor` or `prototype` anywhere in
27
+ * the value is refused with a `ZodError` issue at the object that holds it
28
+ * (#202), reported together with the schema's issues for the rest of the value
29
+ * (#227); read such a key with the plain getters instead.
30
+ *
31
+ * @throws {@link NotResolvedError} when the value at `path` still holds an
32
+ * unresolved substitution (#210); a resolved subtree of an otherwise
33
+ * unresolved config validates.
34
+ * @throws `ZodError` when the value does not match the schema.
35
+ */
5
36
  declare function getValidated<T>(config: Config, path: string, schema: ZodType<T>): T;
37
+ /**
38
+ * Zod schema markers for HOCON unit values. Each reads the forms the matching
39
+ * Config getter reads and gives what the getter gives (a number in the
40
+ * requested unit, or a {@link Period}); pipe it into a schema for the
41
+ * constraints:
42
+ *
43
+ * ```ts
44
+ * const Session = z.object({
45
+ * lifetime: hocon.duration('s').pipe(z.number().int().min(60)),
46
+ * maxBody: hocon.bytes().pipe(z.number().int().positive()),
47
+ * })
48
+ * ```
49
+ */
50
+ declare const hocon: {
51
+ /**
52
+ * A duration, read as {@link Config.getDuration} reads it (default unit `ms`),
53
+ * exponent forms included, except that a number literal with more
54
+ * significant digits than a double holds can read differently: the getter
55
+ * reads its text, the marker its JS value (`1.0000000000000001` in `us`:
56
+ * 1000.0000000000001 through the getter, 1000 here).
57
+ */
58
+ duration(unit?: DurationUnit): ZodTransform<number, unknown>;
59
+ /**
60
+ * A byte size, read as {@link Config.getBytes} reads it (default unit `B`),
61
+ * exponent forms included, except that a number literal with more
62
+ * significant digits than a double holds can read differently: the getter
63
+ * reads its text, the marker its JS value (`1.99999999999999999`: 1 through
64
+ * the getter, 2 here).
65
+ */
66
+ bytes(unit?: ByteUnit): ZodTransform<number, unknown>;
67
+ /**
68
+ * A calendar period, read as {@link Config.getPeriod} reads it (a bare
69
+ * integer is days), except that a number literal with a decimal point or in
70
+ * exponent form (`7.0`, `1e2`) can read differently: the getter refuses it,
71
+ * the marker reads the JS number.
72
+ */
73
+ period(): ZodTransform<Period, unknown>;
74
+ };
75
+ /**
76
+ * Parse a HOCON string and {@link validate} it.
77
+ *
78
+ * @throws as `parse`; {@link NotResolvedError} when parsed with
79
+ * `resolveSubstitutions: false` and a substitution is left (#210); `ZodError`
80
+ * when the value does not match the schema.
81
+ */
6
82
  declare function parseWithSchema<T>(input: string, schema: ZodType<T>, opts?: ParseOptions): T;
83
+ /**
84
+ * Read and parse a HOCON file and {@link validate} it.
85
+ *
86
+ * @throws as `parseFile`; {@link NotResolvedError} when parsed with
87
+ * `resolveSubstitutions: false` and a substitution is left (#210); `ZodError`
88
+ * when the value does not match the schema.
89
+ */
7
90
  declare function parseFileWithSchema<T>(filePath: string, schema: ZodType<T>, opts?: ParseOptions): T;
8
91
 
9
- export { getValidated, parseFileWithSchema, parseWithSchema, validate };
92
+ export { getValidated, hocon, parseFileWithSchema, parseWithSchema, validate };