/** * The adapter compiler — a PURE function set, no React, no jq engine. * * A named template `update` jq declares an input object (its `params` / declared * input keys). A binding must map the run's OUTPUT (and the run's INPUT) into that * object; that mapping is the `adapter` — a single jq program over `{ output, input }` * that CONSTRUCTS the update jq's declared input (which the update jq then reads as * `.input` alongside the record). * * The editor authors the adapter as a ROW form: one row per declared input key, * each row picking one of three value sources — a picked field (from the run's * output / input schema), a hardcoded literal, or a raw jq expression. The whole * form compiles here into ONE adapter jq; each row's own jq fragment is shown on demand. * * Compilation never throws: an invalid literal or an empty field surfaces as a * loud, human error the editor renders in a `role="alert"`, never a silent empty * object. */ /** Which root of `{ output, input }` a picked field reads. */ export type FieldRoot = 'output' | 'input'; /** A picked field: a path into `output` or `input`. */ export interface FieldSource { readonly kind: 'field'; readonly root: FieldRoot; readonly path: readonly string[]; } /** A hardcoded literal, authored as JSON text (`"a"`, `42`, `true`, `{…}`). */ export interface LiteralSource { readonly kind: 'literal'; readonly json: string; } /** A raw jq expression over `{ output, input }`. */ export interface JqSource { readonly kind: 'jq'; readonly expr: string; } /** The three value sources one mapping row may carry — exactly one at a time. */ export type MappingSource = FieldSource | LiteralSource | JqSource; /** One mapping row: a target key of the update jq's declared input + its value source. */ export interface MappingRow { readonly target: string; readonly source: MappingSource; } /** A compile outcome: the jq program, or a human error to surface loudly. */ export type AdapterCompileResult = { readonly ok: true; readonly jq: string; } | { readonly ok: false; readonly error: string; }; /** An object key rendered for jq: a bare identifier, or a quoted string otherwise. */ export declare function jqKey(key: string): string; /** A picked field rendered as a jq path, e.g. `.output.user.name` / `.input["odd key"]`. */ export declare function fieldPathToJq(root: FieldRoot, path: readonly string[]): string; /** The jq fragment ONE row's value compiles to — the row's "show jq". */ export declare function rowValueJq(source: MappingSource): AdapterCompileResult; /** * Compile a mapping form into ONE adapter jq that constructs the update jq's * declared input over `{ output, input }`. An empty form compiles to the * empty object `{}`; a blank target, a duplicate target, or an invalid source is a * loud error. */ export declare function compileAdapter(rows: readonly MappingRow[]): AdapterCompileResult; /** One row per declared input key, each defaulting to a picked `output` field. */ export declare function defaultRowsForInput(params: readonly string[]): MappingRow[]; /** Recover a field source from a pure path expression, or `null` if it is not one. */ export declare function parseFieldPath(value: string): FieldSource | null; /** Recover the mapping rows from a stored adapter jq, or `null` if it is not the generated shape. */ export declare function parseAdapter(jq: string): MappingRow[] | null; /** * Encode a template-name slug for a jq identifier: each `-` becomes `_`. Under the slug * invariant (no consecutive or trailing hyphens) the result carries no `__` and no * trailing `_`, which is what makes the first `__` in a call name the template boundary. */ export declare function encodeTemplateSegment(template: string): string; /** * The single-expression form of a named template update built from a mapping form: * `tjq___({…})` for a qualified ref, `tjq_({…})` for a bare * one (see the module note on the `__` boundary invariant). */ export declare function generateTemplateCall(ref: string, rows: readonly MappingRow[]): string; /** * Recover `{ callName, adapter }` from a `tjq_()` call, or `null` * otherwise. `callName` is the RAW jq identifier — NEVER split here (a jq name may carry * its own `__` past the template boundary); resolve it to a catalog ref with * `resolveCallName`. */ export declare function parseTemplateCall(expr: string): { callName: string; adapter: string; } | null; //# sourceMappingURL=adapter.d.ts.map