Config parsing helpers: JSONC parsing with rich error reporting, plus validation of parsed data against both zod and Effect schemas.

Methods

(static) effectSchema(schema, data, source) → {*}

Validate and decode data against an Effect schema, preserving the user's original property order and rejecting unrecognized top-level keys.

Parameters:
NameTypeDescription
schemaObject

An Effect schema to decode against.

data*

The data to validate and decode.

sourcestring

Path/source label attached to validation errors.

Throws:

When unknown top-level keys are present or decoding fails.

Type
InvalidError
Returns:

The decoded value.

Type: 
*

(static) jsonc(text, filepath) → {*}

Parse JSONC (JSON with comments and trailing commas) text into a value. On parse failure, throws a JsonError whose message includes the input and a per-error report with line/column and a caret pointing at the problem.

Parameters:
NameTypeDescription
textstring

The JSONC source text.

filepathstring

Path used to label errors (the source of the text).

Throws:

When the text contains JSONC syntax errors.

Type
JsonError
Returns:

The parsed value.

Type: 
*

(static) schema(schema, data, source) → {*}

Validate and parse data against a zod schema.

Parameters:
NameTypeDescription
schemaObject

A zod schema exposing safeParse.

data*

The data to validate.

sourcestring

Path/source label attached to validation errors.

Throws:

When validation fails, carrying the zod issues.

Type
InvalidError
Returns:

The parsed (validated) data.

Type: 
*

(inner) topLevelExtraKeys(schema, data) → {Array.<string>}

List top-level keys present in data that are not declared by the schema. Returns an empty array unless data is a plain object and the schema is a closed object type (no index signatures), since only then are extra keys meaningful.

Parameters:
NameTypeDescription
schemaObject

An Effect schema whose AST is inspected.

data*

The data whose keys are checked.

Returns:

The unrecognized top-level key names.

Type: 
Array.<string>