@o3co/ts.hocon 1.9.0 → 1.10.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.md CHANGED
@@ -391,13 +391,45 @@ const config = parseWithSchema(hoconInput, schema) // fails fast on startup
391
391
 
392
392
  The four parser implementations ([ts.hocon](https://github.com/o3co/ts.hocon), [rs.hocon](https://github.com/o3co/rs.hocon), [go.hocon](https://github.com/o3co/go.hocon), [py.hocon](https://github.com/o3co/py.hocon)) are all tracked against the same Lightbend HOCON spec — see the [cross-impl roll-up](https://github.com/o3co/xx.hocon/blob/main/docs/compliance-matrix.md) for per-impl conformance rates.
393
393
 
394
+ ## Format adapters
395
+
396
+ Config files that belong to *other* programs can be mounted as HOCON, so a
397
+ `${...}` in your document can reach into them:
398
+
399
+ ```ts
400
+ import { parseStringWithOptions } from '@o3co/ts.hocon'
401
+ import { loadEnv } from '@o3co/ts.hocon/adapters/env'
402
+
403
+ const base = loadEnv({ prefix: 'APP_' }) // APP_DB__HOST -> db.host
404
+ const cfg = parseStringWithOptions(src, { resolveSubstitutions: false })
405
+ const merged = cfg.withFallback(base).resolve()
406
+ ```
407
+
408
+ Deferring resolution matters: the plain `parse` resolves as it goes, so a
409
+ `${...}` aimed at the fallback would fail before the fallback is attached.
410
+
411
+ | Subpath | Needs | Notes |
412
+ | --- | --- | --- |
413
+ | `@o3co/ts.hocon/adapters/properties` | — | `java.util.Properties`, sharing the `include` syntax layer |
414
+ | `@o3co/ts.hocon/adapters/env` | — | Bulk-mounts a prefixed namespace; also reads `.env` |
415
+ | `@o3co/ts.hocon/adapters/jsonc` | — | JSON with comments and trailing commas |
416
+ | `@o3co/ts.hocon/adapters/toml` | `smol-toml` | Optional peer dependency |
417
+ | `@o3co/ts.hocon/adapters/yaml` | `yaml` | Optional peer dependency; YAML 1.2 core schema |
418
+
419
+ The TOML and YAML libraries are **optional peer dependencies**, so installing
420
+ this package still pulls in nothing — you add the one you actually use. Plain
421
+ JSON needs no adapter at all, HOCON being a JSON superset.
422
+
423
+ Foreign data stays data: a `${a.b}` in a mounted value is literal text, never a
424
+ reference, because the file belongs to a program that never agreed to HOCON's
425
+ syntax.
426
+
394
427
  ## Known Limitations
395
428
 
396
429
  - **`include url(...)`** is not supported. Fetching remote configuration is outside the scope of this parser. Use your application's HTTP client to fetch the content, then pass it to `parse()`.
397
430
  - **`include classpath(...)`** is not supported. This is a JVM-specific include form with no equivalent outside Java runtimes.
398
431
  - **No watch/reload** — the library parses config at load time. For live-reloading, re-call `parse()` or `parseFile()` on change.
399
432
  - **No streaming parser** — the entire input is loaded into memory. For very large configs, validate input size before parsing (see Security Considerations).
400
- - **`.properties` include** — supports basic `key=value` / `key:value` syntax. Does not support multiline values (backslash continuation), Unicode escapes, or key escaping from the full Java .properties specification.
401
433
 
402
434
  ## Security Considerations
403
435