Skip to content

anonymizeIr

Import from @varavel/vdl-plugin-sdk/utils/ir.

Call Signature

function anonymizeIr<T>(input): T;

Returns a deep-cloned copy of an object with source metadata redacted.

Redaction rules: - every entryPoint string is replaced with "" - every position object is replaced with { file: "schema.vdl", line: 1, column: 1 }

The traversal is recursive, covers nested objects and arrays, and never mutates the input value. Non-object values are returned as-is.

This helper is useful before snapshotting, hashing, logging, or emitting IR outside trusted boundaries where absolute file paths should not leak.

Type Parameters

Type Parameter
T extends AnonymizableIr

Parameters

Parameter Type Description
input T Object to sanitize.

Returns

T

A new object with the same structure and redacted IR metadata.

Example

const safeIr = anonymizeIr(irSchema);
// safeIr.entryPoint === ""
// safeIr.types[0].position.file === "schema.vdl"

Call Signature

function anonymizeIr<T>(input): T;

Returns a deep-cloned copy of an object with source metadata redacted.

Redaction rules: - every entryPoint string is replaced with "" - every position object is replaced with { file: "schema.vdl", line: 1, column: 1 }

The traversal is recursive, covers nested objects and arrays, and never mutates the input value. Non-object values are returned as-is.

This helper is useful before snapshotting, hashing, logging, or emitting IR outside trusted boundaries where absolute file paths should not leak.

Type Parameters

Type Parameter
T extends object

Parameters

Parameter Type Description
input T Object to sanitize.

Returns

T

A new object with the same structure and redacted IR metadata.

Example

const safeIr = anonymizeIr(irSchema);
// safeIr.entryPoint === ""
// safeIr.types[0].position.file === "schema.vdl"