@o3co/ts.hocon 0.1.2 → 0.1.5

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/LICENSE CHANGED
@@ -187,7 +187,7 @@
187
187
  same "printed page" as the copyright notice for easier
188
188
  identification within third-party archives.
189
189
 
190
- Copyright 2026 o3co Inc.
190
+ Copyright 2026 1o1 Co. Ltd.
191
191
 
192
192
  Licensed under the Apache License, Version 2.0 (the "License");
193
193
  you may not use this file except in compliance with the License.
package/README.ja.md CHANGED
@@ -1,4 +1,4 @@
1
- # ts.hocon
1
+ # ts.hocon — TypeScript 向け HOCON パーサー
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@o3co/ts.hocon.svg)](https://www.npmjs.com/package/@o3co/ts.hocon)
4
4
  [![CI](https://github.com/o3co/ts.hocon/actions/workflows/test.yml/badge.svg)](https://github.com/o3co/ts.hocon/actions/workflows/test.yml)
@@ -8,25 +8,15 @@
8
8
  [Lightbend HOCON](https://github.com/lightbend/config/blob/main/HOCON.md) 仕様に完全準拠した TypeScript ライブラリです。
9
9
 
10
10
  > **[Claude](https://claude.ai/)(Anthropic)による実装** — Claude Code を用いて設計・実装されました。
11
+ > [GitHub Copilot](https://github.com/features/copilot) および [OpenAI Codex](https://openai.com/index/openai-codex/) によるレビュー。
11
12
 
12
13
  [English](README.md)
13
14
 
14
15
  ---
15
16
 
16
- ## 特徴
17
-
18
- - 完全な HOCON パース:オブジェクト、配列、スカラー値、代入(`${path}`、`${?path}`)
19
- - 自己参照代入(`path = ${path}:/extra`)
20
- - 重複キーのディープマージ(後勝ち)
21
- - `+=` 追加演算子
22
- - `include "file.conf"` および `include file("file.conf")` ディレクティブ
23
- - トリプルクォート文字列(`"""..."""`)
24
- - 同期・非同期 API(`parse` / `parseAsync` / `parseFile` / `parseFileAsync`)
25
- - ESM + CJS デュアルパッケージ
26
- - [Zod](https://zod.dev/) スキーマバリデーション統合(オプション)
27
- - ブラウザ対応(`parse`/`parseAsync` — Node.js 不要)
17
+ ## クイックスタート
28
18
 
29
- ## インストール
19
+ ### 1. インストール
30
20
 
31
21
  ```bash
32
22
  npm install @o3co/ts.hocon
@@ -34,12 +24,11 @@ npm install @o3co/ts.hocon
34
24
 
35
25
  Node.js 18 以上が必要です。
36
26
 
37
- ## クイックスタート
27
+ ### 2. 使い方
38
28
 
39
29
  ```ts
40
- import { parse, parseFile } from '@o3co/ts.hocon'
30
+ import { parse } from '@o3co/ts.hocon'
41
31
 
42
- // 文字列からパース
43
32
  const cfg = parse(`
44
33
  server {
45
34
  host = "localhost"
@@ -47,17 +36,38 @@ const cfg = parse(`
47
36
  }
48
37
  `)
49
38
 
50
- // ファイルからパース
51
- const cfg = parseFile('application.conf')
39
+ cfg.getString('server.host') // "localhost"
40
+ cfg.getNumber('server.port') // 8080
41
+ cfg.has('server.host') // true
42
+ ```
43
+
44
+ ## なぜ HOCON?
52
45
 
53
- // スカラーゲッター(存在しない・型が違う場合は ConfigError をスロー)
54
- const host = cfg.getString('server.host') // "localhost"
55
- const port = cfg.getNumber('server.port') // 8080
46
+ | | `.env` | JSON | YAML | HOCON |
47
+ |---|---|---|---|---|
48
+ | Comments | No | No | Yes | Yes |
49
+ | Nesting | No | Yes | Yes | Yes |
50
+ | References / Substitution | No | No | No | Yes (`${var}`) |
51
+ | File inclusion | No | No | No | Yes (`include`) |
52
+ | Object merging | No | No | Anchors (fragile) | Yes (deep merge) |
53
+ | Optional values | No | No | No | Yes (`${?var}`) |
54
+ | Trailing commas | N/A | No | N/A | Yes |
55
+ | Unquoted strings | Yes | No | Yes | Yes |
56
56
 
57
- // 安全なアクセス
58
- const host = cfg.get('server.host') // unknown | undefined
59
- const exists = cfg.has('server.host') // true
60
- ```
57
+ HOCON は YAML の可読性と JSON の構造性を兼ね備え、どちらにもない機能 — 変数参照、インクルード、ディープマージ — を提供します。設定がフラットなキーバリューペア以上のものであれば、HOCON を検討する価値があります。
58
+
59
+ ## 特徴
60
+
61
+ - 完全な HOCON パース:オブジェクト、配列、スカラー値、代入(`${path}`、`${?path}`)
62
+ - 自己参照代入(`path = ${path}:/extra`)
63
+ - 重複キーのディープマージ(後勝ち)
64
+ - `+=` 追加演算子
65
+ - `include "file.conf"` および `include file("file.conf")` ディレクティブ
66
+ - トリプルクォート文字列(`"""..."""`)
67
+ - 同期・非同期 API(`parse` / `parseAsync` / `parseFile` / `parseFileAsync`)
68
+ - ESM + CJS デュアルパッケージ
69
+ - [Zod](https://zod.dev/) スキーマバリデーション統合(オプション)
70
+ - ブラウザ対応(`parse`/`parseAsync` — Node.js 不要)
61
71
 
62
72
  ## API
63
73
 
@@ -237,8 +247,57 @@ const cfg = await parseAsync(hoconString, {
237
247
  })
238
248
  ```
239
249
 
250
+ ## ベストプラクティス
251
+
252
+ ### 設定構成
253
+
254
+ - **ドメインごとに分割**: 設定を論理的な単位に分けましょう(`database.conf`、`server.conf`、`logging.conf`)
255
+ - **`include` で合成**: ドメイン別ファイルからフル設定を組み立てましょう
256
+ - **設定にロジックを入れない**: HOCON は宣言的なデータのためのもので、条件分岐や計算には向きません
257
+
258
+ ### 環境変数
259
+
260
+ - **`${ENV}` の使用を最小限に**: 設定ファイル自体にデフォルト値を定義し、`${?ENV}`(オプショナル)を使いましょう
261
+ - **ローカル開発で環境変数を必須にしない**: デフォルトだけで動くようにしましょう
262
+ - **必須の環境変数を文書化**: プロジェクトの README や `.env.example` にリストしましょう
263
+
264
+ ### 開発 / 本番の分離
265
+
266
+ ```text
267
+ config/
268
+ ├── application.conf # 共有デフォルト
269
+ ├── dev.conf # include "application.conf" + 開発用オーバーライド
270
+ └── prod.conf # include "application.conf" + 本番用オーバーライド
271
+ ```
272
+
273
+ ### バリデーション
274
+
275
+ - 設定のバリデーションは常にアプリケーション起動時に行い、使用時ではなく早期に検出しましょう
276
+ - スキーマバリデーション(TypeScript は Zod、Go は struct Unmarshal、Rust は Serde)を使って早期にエラーをキャッチしましょう
277
+
278
+ ```typescript
279
+ import { parseWithSchema } from '@o3co/ts.hocon/zod'
280
+ import { z } from 'zod'
281
+
282
+ const schema = z.object({
283
+ server: z.object({ host: z.string(), port: z.number() }),
284
+ debug: z.boolean(),
285
+ })
286
+ const config = parseWithSchema(hoconInput, schema) // 起動時に即座に失敗
287
+ ```
288
+
289
+ ## 関連プロジェクト
290
+
291
+ | プロジェクト | 言語 | レジストリ | 説明 |
292
+ |---------|----------|----------|-------------|
293
+ | [go.hocon](https://github.com/o3co/go.hocon) | Go | [pkg.go.dev](https://pkg.go.dev/github.com/o3co/go.hocon) | Go 向け HOCON パーサー |
294
+ | [rs.hocon](https://github.com/o3co/rs.hocon) | Rust | [crates.io](https://crates.io/crates/o3co-hocon) | Rust 向け HOCON パーサー |
295
+ | [hocon2](https://github.com/o3co/hocon2) | Go | [pkg.go.dev](https://pkg.go.dev/github.com/o3co/hocon2) | HOCON → JSON/YAML/TOML/Properties 変換 CLI |
296
+
297
+ すべての実装が Lightbend HOCON 仕様に完全準拠しています。
298
+
240
299
  ## ライセンス
241
300
 
242
301
  Apache License 2.0 — [LICENSE](LICENSE) を参照。
243
302
 
244
- Copyright 2026 o3co Inc.
303
+ Copyright 2026 1o1 Co. Ltd.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ts.hocon
1
+ # ts.hocon — HOCON Parser for TypeScript
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@o3co/ts.hocon.svg)](https://www.npmjs.com/package/@o3co/ts.hocon)
4
4
  [![CI](https://github.com/o3co/ts.hocon/actions/workflows/test.yml/badge.svg)](https://github.com/o3co/ts.hocon/actions/workflows/test.yml)
@@ -8,25 +8,15 @@
8
8
  A full [Lightbend HOCON](https://github.com/lightbend/config/blob/main/HOCON.md) spec-compliant TypeScript library.
9
9
 
10
10
  > **Implemented by [Claude](https://claude.ai/) (Anthropic)** — designed and built end-to-end with Claude Code.
11
+ > Reviewed by [GitHub Copilot](https://github.com/features/copilot) and [OpenAI Codex](https://openai.com/index/openai-codex/).
11
12
 
12
13
  [日本語](README.ja.md)
13
14
 
14
15
  ---
15
16
 
16
- ## Features
17
-
18
- - Full HOCON parsing: objects, arrays, scalars, substitutions (`${path}`, `${?path}`)
19
- - Self-referential substitutions (`path = ${path}:/extra`)
20
- - Deep-merge for duplicate keys (last definition wins)
21
- - `+=` append operator
22
- - `include "file.conf"` and `include file("file.conf")` directives
23
- - Triple-quoted strings (`"""..."""`)
24
- - Sync and async API (`parse` / `parseAsync` / `parseFile` / `parseFileAsync`)
25
- - ESM + CJS dual package
26
- - Optional [Zod](https://zod.dev/) integration for schema validation
27
- - Browser compatible (`parse`/`parseAsync` — no Node.js required)
17
+ ## Quick Start
28
18
 
29
- ## Installation
19
+ ### 1. Install
30
20
 
31
21
  ```bash
32
22
  npm install @o3co/ts.hocon
@@ -34,12 +24,11 @@ npm install @o3co/ts.hocon
34
24
 
35
25
  Requires Node.js 18+.
36
26
 
37
- ## Quick Start
27
+ ### 2. Use
38
28
 
39
29
  ```ts
40
- import { parse, parseFile } from '@o3co/ts.hocon'
30
+ import { parse } from '@o3co/ts.hocon'
41
31
 
42
- // Parse from string
43
32
  const cfg = parse(`
44
33
  server {
45
34
  host = "localhost"
@@ -47,17 +36,38 @@ const cfg = parse(`
47
36
  }
48
37
  `)
49
38
 
50
- // Parse from file
51
- const cfg = parseFile('application.conf')
39
+ cfg.getString('server.host') // "localhost"
40
+ cfg.getNumber('server.port') // 8080
41
+ cfg.has('server.host') // true
42
+ ```
43
+
44
+ ## Why HOCON?
52
45
 
53
- // Scalar getters (throw ConfigError on missing/wrong type)
54
- const host = cfg.getString('server.host') // "localhost"
55
- const port = cfg.getNumber('server.port') // 8080
46
+ | | `.env` | JSON | YAML | HOCON |
47
+ |---|---|---|---|---|
48
+ | Comments | No | No | Yes | Yes |
49
+ | Nesting | No | Yes | Yes | Yes |
50
+ | References / Substitution | No | No | No | Yes (`${var}`) |
51
+ | File inclusion | No | No | No | Yes (`include`) |
52
+ | Object merging | No | No | Anchors (fragile) | Yes (deep merge) |
53
+ | Optional values | No | No | No | Yes (`${?var}`) |
54
+ | Trailing commas | N/A | No | N/A | Yes |
55
+ | Unquoted strings | Yes | No | Yes | Yes |
56
56
 
57
- // Safe access
58
- const host = cfg.get('server.host') // unknown | undefined
59
- const exists = cfg.has('server.host') // true
60
- ```
57
+ HOCON gives you the readability of YAML, the structure of JSON, and features that neither has — substitutions, includes, and deep merge. If your config is more than a few flat key-value pairs, HOCON is worth considering.
58
+
59
+ ## Features
60
+
61
+ - Full HOCON parsing: objects, arrays, scalars, substitutions (`${path}`, `${?path}`)
62
+ - Self-referential substitutions (`path = ${path}:/extra`)
63
+ - Deep-merge for duplicate keys (last definition wins)
64
+ - `+=` append operator
65
+ - `include "file.conf"` and `include file("file.conf")` directives
66
+ - Triple-quoted strings (`"""..."""`)
67
+ - Sync and async API (`parse` / `parseAsync` / `parseFile` / `parseFileAsync`)
68
+ - ESM + CJS dual package
69
+ - Optional [Zod](https://zod.dev/) integration for schema validation
70
+ - Browser compatible (`parse`/`parseAsync` — no Node.js required)
61
71
 
62
72
  ## API
63
73
 
@@ -237,8 +247,57 @@ const cfg = await parseAsync(hoconString, {
237
247
  })
238
248
  ```
239
249
 
250
+ ## Best Practices
251
+
252
+ ### Config Structure
253
+
254
+ - **Split by domain**: Separate configuration into logical units (`database.conf`, `server.conf`, `logging.conf`)
255
+ - **Use `include` for composition**: Compose a full config from domain-specific files
256
+ - **Avoid logic in config**: HOCON is for declarative data, not conditionals or computation
257
+
258
+ ### Environment Variables
259
+
260
+ - **Minimize `${ENV}` usage**: Prefer `${?ENV}` (optional) with sensible defaults defined in the config itself
261
+ - **Never require env vars for local development**: Defaults should work out of the box
262
+ - **Document required env vars**: List them in your project's README or a `.env.example`
263
+
264
+ ### Dev / Prod Separation
265
+
266
+ ```text
267
+ config/
268
+ ├── application.conf # shared defaults
269
+ ├── dev.conf # include "application.conf" + dev overrides
270
+ └── prod.conf # include "application.conf" + prod overrides
271
+ ```
272
+
273
+ ### Validation
274
+
275
+ - Always validate config at application startup, not at point-of-use
276
+ - Use schema validation (Zod for TypeScript, struct unmarshaling for Go, Serde for Rust) to catch errors early
277
+
278
+ ```typescript
279
+ import { parseWithSchema } from '@o3co/ts.hocon/zod'
280
+ import { z } from 'zod'
281
+
282
+ const schema = z.object({
283
+ server: z.object({ host: z.string(), port: z.number() }),
284
+ debug: z.boolean(),
285
+ })
286
+ const config = parseWithSchema(hoconInput, schema) // fails fast on startup
287
+ ```
288
+
289
+ ## Related Projects
290
+
291
+ | Project | Language | Registry | Description |
292
+ |---------|----------|----------|-------------|
293
+ | [go.hocon](https://github.com/o3co/go.hocon) | Go | [pkg.go.dev](https://pkg.go.dev/github.com/o3co/go.hocon) | HOCON parser for Go |
294
+ | [rs.hocon](https://github.com/o3co/rs.hocon) | Rust | [crates.io](https://crates.io/crates/o3co-hocon) | HOCON parser for Rust |
295
+ | [hocon2](https://github.com/o3co/hocon2) | Go | [pkg.go.dev](https://pkg.go.dev/github.com/o3co/hocon2) | HOCON → JSON/YAML/TOML/Properties CLI |
296
+
297
+ All implementations are full Lightbend HOCON spec compliant.
298
+
240
299
  ## License
241
300
 
242
301
  Apache License 2.0 — see [LICENSE](LICENSE).
243
302
 
244
- Copyright 2026 o3co Inc.
303
+ Copyright 2026 1o1 Co. Ltd.
package/dist/index.cjs CHANGED
@@ -41,6 +41,20 @@ __export(src_exports, {
41
41
  });
42
42
  module.exports = __toCommonJS(src_exports);
43
43
 
44
+ // src/coerce.ts
45
+ var TRUTHY = /* @__PURE__ */ new Set(["true", "yes", "on"]);
46
+ var FALSY = /* @__PURE__ */ new Set(["false", "no", "off"]);
47
+ function coerceBoolean(value) {
48
+ const lower = value.toLowerCase();
49
+ if (TRUTHY.has(lower)) return true;
50
+ if (FALSY.has(lower)) return false;
51
+ return void 0;
52
+ }
53
+ function coerceNumber(value) {
54
+ if (!/^-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/.test(value)) return void 0;
55
+ return Number(value);
56
+ }
57
+
44
58
  // src/errors.ts
45
59
  var ParseError = class extends Error {
46
60
  constructor(message, line, col, file) {
@@ -88,8 +102,8 @@ var Config = class _Config {
88
102
  const v = this.requireScalar(path2);
89
103
  if (typeof v === "number") return v;
90
104
  if (typeof v === "string") {
91
- const n = Number(v);
92
- if (!Number.isNaN(n)) return n;
105
+ const coerced = coerceNumber(v);
106
+ if (coerced !== void 0) return coerced;
93
107
  }
94
108
  throw new ConfigError(`expected number at ${path2}, got ${typeof v}`, path2);
95
109
  }
@@ -97,8 +111,8 @@ var Config = class _Config {
97
111
  const v = this.requireScalar(path2);
98
112
  if (typeof v === "boolean") return v;
99
113
  if (typeof v === "string") {
100
- if (v === "true") return true;
101
- if (v === "false") return false;
114
+ const coerced = coerceBoolean(v);
115
+ if (coerced !== void 0) return coerced;
102
116
  }
103
117
  throw new ConfigError(`expected boolean at ${path2}, got ${typeof v}`, path2);
104
118
  }
package/dist/index.d.cts CHANGED
@@ -1,5 +1,4 @@
1
- import { C as Config } from './config-D4EyvNd8.cjs';
2
- export { H as HoconValue } from './config-D4EyvNd8.cjs';
1
+ export { C as Config, H as HoconValue, P as ParseOptions, p as parse, a as parseAsync, b as parseFile, c as parseFileAsync } from './parse-C1NDMzD5.cjs';
3
2
 
4
3
  declare class ParseError extends Error {
5
4
  readonly line: number;
@@ -19,21 +18,4 @@ declare class ConfigError extends Error {
19
18
  constructor(message: string, path: string);
20
19
  }
21
20
 
22
- type ParseOptions = {
23
- baseDir?: string;
24
- env?: Record<string, string>;
25
- readFile?: (filePath: string) => Promise<string>;
26
- readFileSync?: (filePath: string) => string;
27
- };
28
- declare function parse(input: string, opts?: ParseOptions): Config;
29
- /**
30
- * Async wrapper around `parse()`. Returns a resolved Promise — the parsing
31
- * itself is synchronous. Use `parseFileAsync()` for async file I/O.
32
- * Note: `include` directives in string input are resolved synchronously
33
- * via `readFileSync`; `readFile` is not used by this function.
34
- */
35
- declare function parseAsync(input: string, opts?: ParseOptions): Promise<Config>;
36
- declare function parseFile(filePath: string, opts?: ParseOptions): Config;
37
- declare function parseFileAsync(filePath: string, opts?: ParseOptions): Promise<Config>;
38
-
39
- export { Config, ConfigError, ParseError, type ParseOptions, ResolveError, parse, parseAsync, parseFile, parseFileAsync };
21
+ export { ConfigError, ParseError, ResolveError };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { C as Config } from './config-D4EyvNd8.js';
2
- export { H as HoconValue } from './config-D4EyvNd8.js';
1
+ export { C as Config, H as HoconValue, P as ParseOptions, p as parse, a as parseAsync, b as parseFile, c as parseFileAsync } from './parse-C1NDMzD5.js';
3
2
 
4
3
  declare class ParseError extends Error {
5
4
  readonly line: number;
@@ -19,21 +18,4 @@ declare class ConfigError extends Error {
19
18
  constructor(message: string, path: string);
20
19
  }
21
20
 
22
- type ParseOptions = {
23
- baseDir?: string;
24
- env?: Record<string, string>;
25
- readFile?: (filePath: string) => Promise<string>;
26
- readFileSync?: (filePath: string) => string;
27
- };
28
- declare function parse(input: string, opts?: ParseOptions): Config;
29
- /**
30
- * Async wrapper around `parse()`. Returns a resolved Promise — the parsing
31
- * itself is synchronous. Use `parseFileAsync()` for async file I/O.
32
- * Note: `include` directives in string input are resolved synchronously
33
- * via `readFileSync`; `readFile` is not used by this function.
34
- */
35
- declare function parseAsync(input: string, opts?: ParseOptions): Promise<Config>;
36
- declare function parseFile(filePath: string, opts?: ParseOptions): Config;
37
- declare function parseFileAsync(filePath: string, opts?: ParseOptions): Promise<Config>;
38
-
39
- export { Config, ConfigError, ParseError, type ParseOptions, ResolveError, parse, parseAsync, parseFile, parseFileAsync };
21
+ export { ConfigError, ParseError, ResolveError };
package/dist/index.js CHANGED
@@ -1,3 +1,17 @@
1
+ // src/coerce.ts
2
+ var TRUTHY = /* @__PURE__ */ new Set(["true", "yes", "on"]);
3
+ var FALSY = /* @__PURE__ */ new Set(["false", "no", "off"]);
4
+ function coerceBoolean(value) {
5
+ const lower = value.toLowerCase();
6
+ if (TRUTHY.has(lower)) return true;
7
+ if (FALSY.has(lower)) return false;
8
+ return void 0;
9
+ }
10
+ function coerceNumber(value) {
11
+ if (!/^-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/.test(value)) return void 0;
12
+ return Number(value);
13
+ }
14
+
1
15
  // src/errors.ts
2
16
  var ParseError = class extends Error {
3
17
  constructor(message, line, col, file) {
@@ -45,8 +59,8 @@ var Config = class _Config {
45
59
  const v = this.requireScalar(path2);
46
60
  if (typeof v === "number") return v;
47
61
  if (typeof v === "string") {
48
- const n = Number(v);
49
- if (!Number.isNaN(n)) return n;
62
+ const coerced = coerceNumber(v);
63
+ if (coerced !== void 0) return coerced;
50
64
  }
51
65
  throw new ConfigError(`expected number at ${path2}, got ${typeof v}`, path2);
52
66
  }
@@ -54,8 +68,8 @@ var Config = class _Config {
54
68
  const v = this.requireScalar(path2);
55
69
  if (typeof v === "boolean") return v;
56
70
  if (typeof v === "string") {
57
- if (v === "true") return true;
58
- if (v === "false") return false;
71
+ const coerced = coerceBoolean(v);
72
+ if (coerced !== void 0) return coerced;
59
73
  }
60
74
  throw new ConfigError(`expected boolean at ${path2}, got ${typeof v}`, path2);
61
75
  }
@@ -0,0 +1,48 @@
1
+ type HoconValue = {
2
+ kind: 'object';
3
+ fields: Map<string, HoconValue>;
4
+ } | {
5
+ kind: 'array';
6
+ items: HoconValue[];
7
+ } | {
8
+ kind: 'scalar';
9
+ value: string | number | boolean | null;
10
+ };
11
+
12
+ declare class Config {
13
+ private readonly root;
14
+ constructor(root: HoconValue & {
15
+ kind: 'object';
16
+ });
17
+ get(path: string): unknown;
18
+ getString(path: string): string;
19
+ getNumber(path: string): number;
20
+ getBoolean(path: string): boolean;
21
+ getConfig(path: string): Config;
22
+ getList(path: string): unknown[];
23
+ has(path: string): boolean;
24
+ keys(): string[];
25
+ withFallback(fallback: Config): Config;
26
+ toObject(): unknown;
27
+ private lookupNode;
28
+ private requireScalar;
29
+ }
30
+
31
+ type ParseOptions = {
32
+ baseDir?: string;
33
+ env?: Record<string, string>;
34
+ readFile?: (filePath: string) => Promise<string>;
35
+ readFileSync?: (filePath: string) => string;
36
+ };
37
+ declare function parse(input: string, opts?: ParseOptions): Config;
38
+ /**
39
+ * Async wrapper around `parse()`. Returns a resolved Promise — the parsing
40
+ * itself is synchronous. Use `parseFileAsync()` for async file I/O.
41
+ * Note: `include` directives in string input are resolved synchronously
42
+ * via `readFileSync`; `readFile` is not used by this function.
43
+ */
44
+ declare function parseAsync(input: string, opts?: ParseOptions): Promise<Config>;
45
+ declare function parseFile(filePath: string, opts?: ParseOptions): Config;
46
+ declare function parseFileAsync(filePath: string, opts?: ParseOptions): Promise<Config>;
47
+
48
+ export { Config as C, type HoconValue as H, type ParseOptions as P, parseAsync as a, parseFile as b, parseFileAsync as c, parse as p };
@@ -0,0 +1,48 @@
1
+ type HoconValue = {
2
+ kind: 'object';
3
+ fields: Map<string, HoconValue>;
4
+ } | {
5
+ kind: 'array';
6
+ items: HoconValue[];
7
+ } | {
8
+ kind: 'scalar';
9
+ value: string | number | boolean | null;
10
+ };
11
+
12
+ declare class Config {
13
+ private readonly root;
14
+ constructor(root: HoconValue & {
15
+ kind: 'object';
16
+ });
17
+ get(path: string): unknown;
18
+ getString(path: string): string;
19
+ getNumber(path: string): number;
20
+ getBoolean(path: string): boolean;
21
+ getConfig(path: string): Config;
22
+ getList(path: string): unknown[];
23
+ has(path: string): boolean;
24
+ keys(): string[];
25
+ withFallback(fallback: Config): Config;
26
+ toObject(): unknown;
27
+ private lookupNode;
28
+ private requireScalar;
29
+ }
30
+
31
+ type ParseOptions = {
32
+ baseDir?: string;
33
+ env?: Record<string, string>;
34
+ readFile?: (filePath: string) => Promise<string>;
35
+ readFileSync?: (filePath: string) => string;
36
+ };
37
+ declare function parse(input: string, opts?: ParseOptions): Config;
38
+ /**
39
+ * Async wrapper around `parse()`. Returns a resolved Promise — the parsing
40
+ * itself is synchronous. Use `parseFileAsync()` for async file I/O.
41
+ * Note: `include` directives in string input are resolved synchronously
42
+ * via `readFileSync`; `readFile` is not used by this function.
43
+ */
44
+ declare function parseAsync(input: string, opts?: ParseOptions): Promise<Config>;
45
+ declare function parseFile(filePath: string, opts?: ParseOptions): Config;
46
+ declare function parseFileAsync(filePath: string, opts?: ParseOptions): Promise<Config>;
47
+
48
+ export { Config as C, type HoconValue as H, type ParseOptions as P, parseAsync as a, parseFile as b, parseFileAsync as c, parse as p };