redactWell
redactWell(
well,visibility):Well
Returns a copy of well with hidden sections and fields cleared: array
fields become [] and optional fields become undefined, so the result
stays a schema-valid Well. Never mutates well.
A field is hidden when its key or its section's key is false in
visibility (see VISIBILITY_TREE); missing keys are visible.
well_depth is dropped only when the whole constructive section is
hidden. Hiding a record type does not rewrite references to it held by
visible records (e.g. a production entry's meter_id).
Root members the spec does not define (x- fields and blocks) can hold
anything, so they are kept only when nothing is hidden. Unknown members
nested in a record follow that record.
Parameters
well
The well profile to redact.
visibility
Partial<Record<VisibilityKey, boolean>> | SectionVisibility
Section and/or field visibility. A SectionVisibility works as-is.
Returns
A new Well with hidden parts emptied.
Example
redactWell(well, { operation: false }); // whole section
redactWell(well, { meters: false, permits: false }); // single fields