@o3co/ts.hocon 1.9.0 → 1.11.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 +129 -1
- package/README.md +122 -2
- package/dist/adapters/env.cjs +1738 -0
- package/dist/adapters/env.d.cts +56 -0
- package/dist/adapters/env.d.ts +56 -0
- package/dist/adapters/env.js +1700 -0
- package/dist/adapters/jsonc.cjs +1716 -0
- package/dist/adapters/jsonc.d.cts +45 -0
- package/dist/adapters/jsonc.d.ts +45 -0
- package/dist/adapters/jsonc.js +1678 -0
- package/dist/adapters/properties.cjs +1744 -0
- package/dist/adapters/properties.d.cts +32 -0
- package/dist/adapters/properties.d.ts +32 -0
- package/dist/adapters/properties.js +1707 -0
- package/dist/adapters/toml.cjs +1629 -0
- package/dist/adapters/toml.d.cts +18 -0
- package/dist/adapters/toml.d.ts +18 -0
- package/dist/adapters/toml.js +1594 -0
- package/dist/adapters/yaml.cjs +1686 -0
- package/dist/adapters/yaml.d.cts +51 -0
- package/dist/adapters/yaml.d.ts +51 -0
- package/dist/adapters/yaml.js +1650 -0
- package/dist/{config-D27s3_aG.d.cts → config-Dlq6rF3w.d.cts} +50 -4
- package/dist/{config-D27s3_aG.d.ts → config-Dlq6rF3w.d.ts} +50 -4
- package/dist/index.cjs +207 -35
- package/dist/index.d.cts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +214 -35
- package/dist/zod.cjs +203 -33
- package/dist/zod.d.cts +1 -1
- package/dist/zod.d.ts +1 -1
- package/dist/zod.js +210 -33
- package/package.json +89 -19
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { C as Config } from '../config-Dlq6rF3w.cjs';
|
|
2
|
+
|
|
3
|
+
type EnvOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Selects which variables to mount, and is stripped from the resulting path.
|
|
6
|
+
* Required by {@link loadEnv}: mounting the whole environment would pull in
|
|
7
|
+
* PATH, HOME and whatever secrets happen to be set (spec F1.1).
|
|
8
|
+
* {@link parseDotEnv} allows it to be empty, a `.env` file being a closed set
|
|
9
|
+
* the caller chose deliberately.
|
|
10
|
+
*/
|
|
11
|
+
prefix?: string;
|
|
12
|
+
/** Source name for error messages. */
|
|
13
|
+
originDescription?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Mount a prefixed slice of the environment as config.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* const base = loadEnv({ prefix: 'APP_' }) // APP_DB__HOST -> db.host
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Reading a single variable needs nothing from here — HOCON's own `${?VAR}`
|
|
23
|
+
* already does that. This is for mounting a whole namespace as a subtree.
|
|
24
|
+
*
|
|
25
|
+
* `__` is the only path separator: a single `_` stays part of its segment
|
|
26
|
+
* (`APP_DB__MAX_CONN` → `db.max_conn`), and a literal `.` in a variable name is
|
|
27
|
+
* key text rather than a boundary, so `APP_FOO.BAR` becomes the single
|
|
28
|
+
* top-level key `foo.bar` — addressable as the quoted path `"foo.bar"` — and
|
|
29
|
+
* coexists with `APP_FOO__BAR` instead of colliding with it (F1.2).
|
|
30
|
+
*
|
|
31
|
+
* Two names that do map to one path are an error, the environment having no
|
|
32
|
+
* order to break the tie with (F1.6). Keys named `__proto__`, `constructor` or
|
|
33
|
+
* `prototype` are kept like any other (F2.9).
|
|
34
|
+
*
|
|
35
|
+
* Values are always strings, and a `${...}` inside one stays literal (F0.2, F1.4).
|
|
36
|
+
*/
|
|
37
|
+
declare function loadEnv(opts?: EnvOptions & {
|
|
38
|
+
env?: Record<string, string | undefined>;
|
|
39
|
+
}): Config;
|
|
40
|
+
/**
|
|
41
|
+
* Read `.env` file content.
|
|
42
|
+
*
|
|
43
|
+
* The dialect is deliberately small (spec F1.7): `NAME=value`, an optional
|
|
44
|
+
* `export ` prefix, whole-line `#` comments, single quotes taken literally,
|
|
45
|
+
* double quotes with `\n \r \t \\ \"`. Multi-line values and trailing comments
|
|
46
|
+
* are not supported — an unquoted value containing ` #` is an error rather than
|
|
47
|
+
* a guess about whether a comment was meant. No `${...}` expansion.
|
|
48
|
+
*
|
|
49
|
+
* Names map to paths exactly as in {@link loadEnv}: `__` is the only separator,
|
|
50
|
+
* so a literal `.` stays key text (`FOO.BAR` → the single key `foo.bar`). A
|
|
51
|
+
* file has a definite line order, so a repeated name is last-wins (F0.7)
|
|
52
|
+
* rather than the collision error the process environment gets.
|
|
53
|
+
*/
|
|
54
|
+
declare function parseDotEnv(input: string, opts?: EnvOptions): Config;
|
|
55
|
+
|
|
56
|
+
export { type EnvOptions, loadEnv, parseDotEnv };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { C as Config } from '../config-Dlq6rF3w.js';
|
|
2
|
+
|
|
3
|
+
type EnvOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Selects which variables to mount, and is stripped from the resulting path.
|
|
6
|
+
* Required by {@link loadEnv}: mounting the whole environment would pull in
|
|
7
|
+
* PATH, HOME and whatever secrets happen to be set (spec F1.1).
|
|
8
|
+
* {@link parseDotEnv} allows it to be empty, a `.env` file being a closed set
|
|
9
|
+
* the caller chose deliberately.
|
|
10
|
+
*/
|
|
11
|
+
prefix?: string;
|
|
12
|
+
/** Source name for error messages. */
|
|
13
|
+
originDescription?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Mount a prefixed slice of the environment as config.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* const base = loadEnv({ prefix: 'APP_' }) // APP_DB__HOST -> db.host
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Reading a single variable needs nothing from here — HOCON's own `${?VAR}`
|
|
23
|
+
* already does that. This is for mounting a whole namespace as a subtree.
|
|
24
|
+
*
|
|
25
|
+
* `__` is the only path separator: a single `_` stays part of its segment
|
|
26
|
+
* (`APP_DB__MAX_CONN` → `db.max_conn`), and a literal `.` in a variable name is
|
|
27
|
+
* key text rather than a boundary, so `APP_FOO.BAR` becomes the single
|
|
28
|
+
* top-level key `foo.bar` — addressable as the quoted path `"foo.bar"` — and
|
|
29
|
+
* coexists with `APP_FOO__BAR` instead of colliding with it (F1.2).
|
|
30
|
+
*
|
|
31
|
+
* Two names that do map to one path are an error, the environment having no
|
|
32
|
+
* order to break the tie with (F1.6). Keys named `__proto__`, `constructor` or
|
|
33
|
+
* `prototype` are kept like any other (F2.9).
|
|
34
|
+
*
|
|
35
|
+
* Values are always strings, and a `${...}` inside one stays literal (F0.2, F1.4).
|
|
36
|
+
*/
|
|
37
|
+
declare function loadEnv(opts?: EnvOptions & {
|
|
38
|
+
env?: Record<string, string | undefined>;
|
|
39
|
+
}): Config;
|
|
40
|
+
/**
|
|
41
|
+
* Read `.env` file content.
|
|
42
|
+
*
|
|
43
|
+
* The dialect is deliberately small (spec F1.7): `NAME=value`, an optional
|
|
44
|
+
* `export ` prefix, whole-line `#` comments, single quotes taken literally,
|
|
45
|
+
* double quotes with `\n \r \t \\ \"`. Multi-line values and trailing comments
|
|
46
|
+
* are not supported — an unquoted value containing ` #` is an error rather than
|
|
47
|
+
* a guess about whether a comment was meant. No `${...}` expansion.
|
|
48
|
+
*
|
|
49
|
+
* Names map to paths exactly as in {@link loadEnv}: `__` is the only separator,
|
|
50
|
+
* so a literal `.` stays key text (`FOO.BAR` → the single key `foo.bar`). A
|
|
51
|
+
* file has a definite line order, so a repeated name is last-wins (F0.7)
|
|
52
|
+
* rather than the collision error the process environment gets.
|
|
53
|
+
*/
|
|
54
|
+
declare function parseDotEnv(input: string, opts?: EnvOptions): Config;
|
|
55
|
+
|
|
56
|
+
export { type EnvOptions, loadEnv, parseDotEnv };
|