@o3co/ts.hocon 0.1.0 → 0.1.2

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 (106) hide show
  1. package/README.ja.md +49 -0
  2. package/README.md +49 -0
  3. package/dist/config-D4EyvNd8.d.cts +31 -0
  4. package/dist/config-D4EyvNd8.d.ts +31 -0
  5. package/dist/index.cjs +891 -0
  6. package/dist/index.d.cts +39 -0
  7. package/dist/index.d.ts +39 -0
  8. package/dist/index.js +847 -0
  9. package/dist/zod.cjs +39 -0
  10. package/dist/zod.d.cts +7 -0
  11. package/dist/zod.d.ts +7 -0
  12. package/dist/zod.js +13 -0
  13. package/package.json +13 -10
  14. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -29
  15. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -23
  16. package/.github/pull_request_template.md +0 -17
  17. package/.github/workflows/lint.yml +0 -33
  18. package/.github/workflows/release.yml +0 -41
  19. package/.github/workflows/test.yml +0 -53
  20. package/CHANGELOG.md +0 -22
  21. package/CONTRIBUTING.md +0 -62
  22. package/SECURITY.md +0 -20
  23. package/docs/superpowers/plans/2026-03-20-ts-hocon.md +0 -2412
  24. package/docs/superpowers/specs/2026-03-20-ts-hocon-design.md +0 -368
  25. package/src/config.ts +0 -108
  26. package/src/errors.ts +0 -34
  27. package/src/index.ts +0 -5
  28. package/src/internal/lexer/lexer.ts +0 -168
  29. package/src/internal/lexer/token.ts +0 -20
  30. package/src/internal/parser/ast.ts +0 -17
  31. package/src/internal/parser/parser.ts +0 -229
  32. package/src/internal/resolver/resolver.ts +0 -428
  33. package/src/parse.ts +0 -79
  34. package/src/value.ts +0 -5
  35. package/src/zod.ts +0 -12
  36. package/tests/config.test.ts +0 -100
  37. package/tests/errors.test.ts +0 -43
  38. package/tests/lexer.test.ts +0 -141
  39. package/tests/lightbend/lightbend.test.ts +0 -39
  40. package/tests/lightbend/testdata/a_1.conf +0 -1
  41. package/tests/lightbend/testdata/b_2.conf +0 -1
  42. package/tests/lightbend/testdata/beanconfig/beanconfig01.conf +0 -131
  43. package/tests/lightbend/testdata/bom.conf +0 -2
  44. package/tests/lightbend/testdata/cycle.conf +0 -1
  45. package/tests/lightbend/testdata/env-variables.conf +0 -16
  46. package/tests/lightbend/testdata/equiv01/comments.conf +0 -45
  47. package/tests/lightbend/testdata/equiv01/equals.conf +0 -41
  48. package/tests/lightbend/testdata/equiv01/no-commas.conf +0 -55
  49. package/tests/lightbend/testdata/equiv01/no-root-braces.conf +0 -40
  50. package/tests/lightbend/testdata/equiv01/no-whitespace.json +0 -1
  51. package/tests/lightbend/testdata/equiv01/omit-colons.conf +0 -44
  52. package/tests/lightbend/testdata/equiv01/original.json +0 -41
  53. package/tests/lightbend/testdata/equiv01/path-keys.conf +0 -29
  54. package/tests/lightbend/testdata/equiv01/properties-style.conf +0 -37
  55. package/tests/lightbend/testdata/equiv01/substitutions.conf +0 -41
  56. package/tests/lightbend/testdata/equiv01/unquoted.conf +0 -41
  57. package/tests/lightbend/testdata/equiv02/original.json +0 -17
  58. package/tests/lightbend/testdata/equiv02/path-keys-weird-whitespace.conf +0 -32
  59. package/tests/lightbend/testdata/equiv02/path-keys.conf +0 -9
  60. package/tests/lightbend/testdata/equiv03/includes.conf +0 -7
  61. package/tests/lightbend/testdata/equiv03/letters/a.conf +0 -6
  62. package/tests/lightbend/testdata/equiv03/letters/b.json +0 -3
  63. package/tests/lightbend/testdata/equiv03/letters/c.conf +0 -2
  64. package/tests/lightbend/testdata/equiv03/letters/c.properties +0 -1
  65. package/tests/lightbend/testdata/equiv03/letters/numbers/1.conf +0 -1
  66. package/tests/lightbend/testdata/equiv03/letters/numbers/2.properties +0 -1
  67. package/tests/lightbend/testdata/equiv03/original.json +0 -15
  68. package/tests/lightbend/testdata/equiv03/root/foo.conf +0 -1
  69. package/tests/lightbend/testdata/equiv04/missing-substitutions.conf +0 -4
  70. package/tests/lightbend/testdata/equiv04/original.json +0 -3
  71. package/tests/lightbend/testdata/equiv05/original.json +0 -16
  72. package/tests/lightbend/testdata/equiv05/triple-quotes.conf +0 -20
  73. package/tests/lightbend/testdata/file-include.conf +0 -5
  74. package/tests/lightbend/testdata/include-from-list.conf +0 -5
  75. package/tests/lightbend/testdata/onclasspath.conf +0 -2
  76. package/tests/lightbend/testdata/subdir/bar-file.conf +0 -1
  77. package/tests/lightbend/testdata/subdir/bar.conf +0 -1
  78. package/tests/lightbend/testdata/subdir/baz.conf +0 -1
  79. package/tests/lightbend/testdata/subdir/foo.conf +0 -5
  80. package/tests/lightbend/testdata/test01.conf +0 -96
  81. package/tests/lightbend/testdata/test01.json +0 -4
  82. package/tests/lightbend/testdata/test01.properties +0 -5
  83. package/tests/lightbend/testdata/test02.conf +0 -13
  84. package/tests/lightbend/testdata/test03-included.conf +0 -9
  85. package/tests/lightbend/testdata/test03.conf +0 -36
  86. package/tests/lightbend/testdata/test04.conf +0 -305
  87. package/tests/lightbend/testdata/test05.conf +0 -154
  88. package/tests/lightbend/testdata/test06.conf +0 -14
  89. package/tests/lightbend/testdata/test07.conf +0 -4
  90. package/tests/lightbend/testdata/test08.conf +0 -6
  91. package/tests/lightbend/testdata/test09.conf +0 -17
  92. package/tests/lightbend/testdata/test10.conf +0 -11
  93. package/tests/lightbend/testdata/test11.conf +0 -7
  94. package/tests/lightbend/testdata/test12.conf +0 -43
  95. package/tests/lightbend/testdata/test13-application-override-substitutions.conf +0 -1
  96. package/tests/lightbend/testdata/test13-reference-bad-substitutions.conf +0 -1
  97. package/tests/lightbend/testdata/test13-reference-with-substitutions.conf +0 -2
  98. package/tests/lightbend/testdata/validate-invalid.conf +0 -30
  99. package/tests/lightbend/testdata/validate-reference.conf +0 -32
  100. package/tests/parse.test.ts +0 -44
  101. package/tests/parser.test.ts +0 -154
  102. package/tests/resolver.test.ts +0 -159
  103. package/tests/zod.test.ts +0 -57
  104. package/tsconfig.json +0 -16
  105. package/tsup.config.ts +0 -12
  106. package/vitest.config.ts +0 -7
package/dist/zod.cjs ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/zod.ts
21
+ var zod_exports = {};
22
+ __export(zod_exports, {
23
+ getValidated: () => getValidated,
24
+ validate: () => validate
25
+ });
26
+ module.exports = __toCommonJS(zod_exports);
27
+ function validate(config, schema) {
28
+ const plain = config.toObject();
29
+ return schema.parse(plain);
30
+ }
31
+ function getValidated(config, path, schema) {
32
+ const val = config.get(path);
33
+ return schema.parse(val);
34
+ }
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ getValidated,
38
+ validate
39
+ });
package/dist/zod.d.cts ADDED
@@ -0,0 +1,7 @@
1
+ import { ZodType } from 'zod';
2
+ import { C as Config } from './config-D4EyvNd8.cjs';
3
+
4
+ declare function validate<T>(config: Config, schema: ZodType<T>): T;
5
+ declare function getValidated<T>(config: Config, path: string, schema: ZodType<T>): T;
6
+
7
+ export { getValidated, validate };
package/dist/zod.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { ZodType } from 'zod';
2
+ import { C as Config } from './config-D4EyvNd8.js';
3
+
4
+ declare function validate<T>(config: Config, schema: ZodType<T>): T;
5
+ declare function getValidated<T>(config: Config, path: string, schema: ZodType<T>): T;
6
+
7
+ export { getValidated, validate };
package/dist/zod.js ADDED
@@ -0,0 +1,13 @@
1
+ // src/zod.ts
2
+ function validate(config, schema) {
3
+ const plain = config.toObject();
4
+ return schema.parse(plain);
5
+ }
6
+ function getValidated(config, path, schema) {
7
+ const val = config.get(path);
8
+ return schema.parse(val);
9
+ }
10
+ export {
11
+ getValidated,
12
+ validate
13
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3co/ts.hocon",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -17,13 +17,9 @@
17
17
  "main": "./dist/index.cjs",
18
18
  "module": "./dist/index.js",
19
19
  "types": "./dist/index.d.ts",
20
- "scripts": {
21
- "build": "tsup",
22
- "test": "vitest run",
23
- "test:watch": "vitest",
24
- "typecheck": "tsc --noEmit",
25
- "coverage": "vitest run --coverage"
26
- },
20
+ "files": [
21
+ "dist"
22
+ ],
27
23
  "peerDependencies": {
28
24
  "zod": ">=3.0.0"
29
25
  },
@@ -40,5 +36,12 @@
40
36
  "vitest": "^3.2.4",
41
37
  "zod": "^4.3.6"
42
38
  },
43
- "packageManager": "pnpm@10.30.2"
44
- }
39
+ "scripts": {
40
+ "build": "tsup",
41
+ "test": "vitest run",
42
+ "test:watch": "vitest",
43
+ "typecheck": "tsc --noEmit",
44
+ "coverage": "vitest run --coverage",
45
+ "bench": "vitest bench"
46
+ }
47
+ }
@@ -1,29 +0,0 @@
1
- ---
2
- name: Bug report
3
- about: Report a bug in ts.hocon
4
- labels: bug
5
- ---
6
-
7
- ## Describe the bug
8
-
9
- <!-- A clear and concise description of the bug. -->
10
-
11
- ## HOCON input
12
-
13
- ```hocon
14
- # Minimal example that reproduces the issue
15
- ```
16
-
17
- ## Expected behavior
18
-
19
- <!-- What you expected to happen. -->
20
-
21
- ## Actual behavior
22
-
23
- <!-- What actually happened. Include error messages or incorrect output. -->
24
-
25
- ## Environment
26
-
27
- - @o3co/ts.hocon version:
28
- - Node.js version (`node --version`):
29
- - OS:
@@ -1,23 +0,0 @@
1
- ---
2
- name: Feature request
3
- about: Suggest a new feature or improvement
4
- labels: enhancement
5
- ---
6
-
7
- ## Summary
8
-
9
- <!-- One sentence describing what you want. -->
10
-
11
- ## Motivation
12
-
13
- <!-- Why is this needed? What problem does it solve? -->
14
-
15
- ## Proposed API / behavior
16
-
17
- ```ts
18
- // Example usage
19
- ```
20
-
21
- ## Alternatives considered
22
-
23
- <!-- Any other approaches you considered. -->
@@ -1,17 +0,0 @@
1
- ## Summary
2
-
3
- <!-- What does this PR do? -->
4
-
5
- ## Related issue
6
-
7
- <!-- Closes #123 -->
8
-
9
- ## Changes
10
-
11
- <!-- Bullet list of what changed. -->
12
-
13
- ## Test plan
14
-
15
- - [ ] `npm test` passes
16
- - [ ] `npm run typecheck` passes
17
- - [ ] New tests added for new behavior
@@ -1,33 +0,0 @@
1
- name: Lint
2
-
3
- on:
4
- pull_request:
5
- branches: [develop, main]
6
- push:
7
- branches: [develop, main]
8
-
9
- jobs:
10
- typecheck:
11
- name: TypeScript type check
12
- runs-on: ubuntu-latest
13
-
14
- steps:
15
- - uses: actions/checkout@v4
16
-
17
- - name: Set up pnpm
18
- uses: pnpm/action-setup@v4
19
-
20
- - name: Set up Node.js
21
- uses: actions/setup-node@v4
22
- with:
23
- node-version: "22"
24
- cache: pnpm
25
-
26
- - name: Install dependencies
27
- run: pnpm install --frozen-lockfile
28
-
29
- - name: Type check
30
- run: pnpm typecheck
31
-
32
- - name: Build
33
- run: pnpm build
@@ -1,41 +0,0 @@
1
- name: Release
2
-
3
- on:
4
- push:
5
- tags:
6
- - "v*"
7
-
8
- jobs:
9
- publish:
10
- name: Publish to npm
11
- runs-on: ubuntu-latest
12
-
13
- steps:
14
- - uses: actions/checkout@v4
15
-
16
- - name: Set up pnpm
17
- uses: pnpm/action-setup@v4
18
-
19
- - name: Set up Node.js
20
- uses: actions/setup-node@v4
21
- with:
22
- node-version: "22"
23
- cache: pnpm
24
- registry-url: "https://registry.npmjs.org"
25
-
26
- - name: Install dependencies
27
- run: pnpm install --frozen-lockfile
28
-
29
- - name: Type check
30
- run: pnpm typecheck
31
-
32
- - name: Test
33
- run: pnpm test
34
-
35
- - name: Build
36
- run: pnpm build
37
-
38
- - name: Publish
39
- run: pnpm publish --access public --no-git-checks
40
- env:
41
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -1,53 +0,0 @@
1
- name: Test
2
-
3
- on:
4
- pull_request:
5
- branches: [develop, main]
6
- push:
7
- branches: [develop, main]
8
-
9
- jobs:
10
- test:
11
- name: node${{ matrix.node }} / ${{ matrix.os }}
12
- runs-on: ${{ matrix.os }}
13
- strategy:
14
- fail-fast: false
15
- matrix:
16
- node: ["18", "20", "22"]
17
- os: [ubuntu-latest]
18
- include:
19
- - node: "22"
20
- os: macos-latest
21
-
22
- steps:
23
- - uses: actions/checkout@v4
24
-
25
- - name: Set up pnpm
26
- uses: pnpm/action-setup@v4
27
-
28
- - name: Set up Node.js
29
- uses: actions/setup-node@v4
30
- with:
31
- node-version: ${{ matrix.node }}
32
- cache: pnpm
33
-
34
- - name: Install dependencies
35
- run: pnpm install --frozen-lockfile
36
-
37
- - name: Type check
38
- run: pnpm typecheck
39
-
40
- - name: Test
41
- run: pnpm test
42
-
43
- - name: Test with coverage
44
- if: matrix.node == '22' && matrix.os == 'ubuntu-latest'
45
- run: pnpm coverage
46
-
47
- - name: Upload coverage to Codecov
48
- if: matrix.node == '22' && matrix.os == 'ubuntu-latest'
49
- uses: codecov/codecov-action@v5
50
- with:
51
- token: ${{ secrets.CODECOV_TOKEN }}
52
- slug: o3co/ts.hocon
53
- fail_ci_if_error: false
package/CHANGELOG.md DELETED
@@ -1,22 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [0.1.0] — 2026-03-20
9
-
10
- ### Added
11
-
12
- - Full HOCON parser: Lexer → Parser → Resolver → Config pipeline
13
- - Two-pass resolver with substitution (`${path}`, `${?path}`), concat, env fallback, self-referential substitution, cycle detection
14
- - `include "file"` and `include file("file")` directives with circular include detection
15
- - `parse()`, `parseAsync()`, `parseFile()`, `parseFileAsync()` public API
16
- - `Config` class: `get`, `getString`, `getNumber`, `getBoolean`, `getConfig`, `getList`, `has`, `keys`, `withFallback`, `toObject`
17
- - Zod integration: `validate(config, schema)` and `getValidated(config, path, schema)` via `@o3co/ts.hocon/zod`
18
- - ESM + CJS dual package via tsup
19
- - Browser compatible (`parse`/`parseAsync`)
20
- - TypeScript strict mode throughout
21
- - Lightbend official test suite: 13/13 test groups passing
22
- - 109 tests total
package/CONTRIBUTING.md DELETED
@@ -1,62 +0,0 @@
1
- # Contributing to ts.hocon
2
-
3
- Thank you for your interest in contributing!
4
-
5
- ## Reporting Bugs
6
-
7
- Please open a [GitHub Issue](https://github.com/o3co/ts.hocon/issues) and include:
8
-
9
- - Node.js version (`node --version`)
10
- - @o3co/ts.hocon version
11
- - A minimal reproducing HOCON snippet
12
- - Expected vs. actual behavior
13
-
14
- ## Proposing Features
15
-
16
- Open an issue first to discuss the proposal before sending a PR. This avoids wasted effort if the direction doesn't fit the project scope.
17
-
18
- ## Development Setup
19
-
20
- ```bash
21
- git clone https://github.com/o3co/ts.hocon.git
22
- cd ts.hocon
23
- pnpm install
24
- pnpm test
25
- ```
26
-
27
- ## Running Tests
28
-
29
- ```bash
30
- # All tests
31
- pnpm test
32
-
33
- # Watch mode
34
- pnpm test:watch
35
-
36
- # With coverage
37
- pnpm coverage
38
-
39
- # Type check only
40
- pnpm typecheck
41
-
42
- # Lightbend spec compliance suite
43
- pnpm vitest run tests/lightbend/
44
- ```
45
-
46
- ## Code Style
47
-
48
- - TypeScript strict mode throughout — no `any` unless unavoidable
49
- - Keep public API consistent with the existing throwing / `undefined`-return dual pattern
50
- - New features must include tests
51
- - Internal modules (`src/internal/`) are not part of the public API
52
-
53
- ## Submitting a Pull Request
54
-
55
- 1. Fork the repository and create a branch from `develop`
56
- 2. Write tests for your change
57
- 3. Ensure `pnpm test` and `pnpm typecheck` pass
58
- 4. Open a PR against `develop` with a clear description of what and why
59
-
60
- ## License
61
-
62
- By contributing, you agree that your contributions will be licensed under the [Apache License 2.0](LICENSE).
package/SECURITY.md DELETED
@@ -1,20 +0,0 @@
1
- # Security Policy
2
-
3
- ## Supported versions
4
-
5
- | Version | Supported |
6
- |---------|-----------|
7
- | latest | ✅ |
8
-
9
- ## Reporting a vulnerability
10
-
11
- Please **do not** open a public GitHub issue for security vulnerabilities.
12
-
13
- Report vulnerabilities privately via [GitHub Security Advisories](https://github.com/o3co/ts.hocon/security/advisories/new).
14
-
15
- Include:
16
- - Description of the vulnerability
17
- - Steps to reproduce
18
- - Potential impact
19
-
20
- You will receive a response within 7 days.