Documentation
¶
Overview ¶
Package jqtransform runs operator-supplied jq expressions against the JSON form of builder objects (execution payloads, bids, envelopes) so builders can apply arbitrary custom modifications the tool is not aware of. It wraps the pure-Go gojq interpreter (no I/O, context-cancellable) with a strict single-output contract and environment access disabled.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEmpty = errors.New("jq expression produced no output")
ErrEmpty is returned when an expression produces no output (e.g. `empty` or a filter that selects nothing) — a transform must yield exactly one object.
var ErrMultiple = errors.New("jq expression produced multiple outputs")
ErrMultiple is returned when an expression produces more than one output — a transform must yield exactly one object.
Functions ¶
func Apply ¶
Apply runs the expression against inputJSON (any JSON value) and returns the single transformed value marshaled back to JSON. An empty expression returns inputJSON unchanged. The context bounds execution time; a runaway expression (e.g. an unbounded generator) is cut off when ctx is cancelled.
func ApplyTyped ¶
func ApplyTyped[T JSONObject](ctx context.Context, expr string, src, dst T) error
ApplyTyped applies the expression to src's JSON form and decodes the result into dst. dst must be constructed with the correct Version already set (the union types select their JSON view from Version). An empty expression copies src into dst unchanged. On any error dst is left partially written and must be discarded by the caller.
Types ¶
type JSONObject ¶
type JSONObject interface {
json.Marshaler
json.Unmarshaler
}
JSONObject is a value that can round-trip through JSON in both directions. The builder's fork-agnostic union types (execution payload, bid message, envelope message) satisfy it; their UnmarshalJSON requires the target's Version to be preset, so callers construct dst with the right Version.