TypeScript config.json parser with lenient JSON support
- Dominant language
- TypeScript
- Stars
- 481
- Forks
- 108
- Avg merge
- 6d 8h
- Merged PRs (30d)
- 5
Description
## Parent PRD
#1670
## What to build
Create a TypeScript module that reads and parses the existing `config.json` file, replacing the `grep`/`cut` parsing in `process-environment.sh`.
The parser must handle lenient JSON (single-line `//` comments and trailing commas) because the documentation examples show these and users may have config files with them. Strip comments and trailing commas with a regex pre-processor before `JSON.parse()` — no new dependency needed.
Define a Zod schema for `config.json` that extracts ALL documented fields, including `GRAPH_EXP_FETCH_REQUEST_TIMEOUT` and `GRAPH_EXP_NODE_EXPANSION_LIMIT` which the shell script currently silently drops. This fixes an existing bug.
The module should:
- Accept a file path (from `CONFIGURATION_FOLDER_PATH`)
- Return `undefined` if the file does not exist (not an error)
- Throw a clear error if the file exists but is malformed
- Return a typed object with all extracted fields
Refer to the "config.json Parsing" section of #1670 for details.
## Acceptance criteria
- [ ] Parses valid JSON config files
- [ ] Parses JSON with `//` comments and trailing commas
- [ ] Extracts all 10 fields the shell script extracts: `PUBLIC_OR_PROXY_ENDPOINT`, `GRAPH_TYPE`, `SERVICE_TYPE`, `USING_PROXY_SERVER`, `IAM`, `GRAPH_CONNECTION_URL`, `AWS_REGION`, `PROXY_SERVER_HTTPS_CONNECTION`, `GRAPH_EXP_HTTPS_CONNECTION`, `NEPTUNE_NOTEBOOK`
- [ ] Also extracts `GRAPH_EXP_FETCH_REQUEST_TIMEOUT` and `GRAPH_EXP_NODE_EXPANSION_LIMIT` (bug fix)
- [ ] Returns `undefined` when config file does not exist
- [ ] Throws a clear error for malformed JSON
- [ ] Validated with a Zod schema
- [ ] Unit tests cover: valid JSON, JSON with comments, JSON with trailing commas, malformed JSON, missing file, all documented fields
## Blocked by
None — can start immediately
## User stories addressed
- User story 2
- User story 3
- User story 7
- User story 8
Contributor guide
Assessment
This issue has not been assessed yet.