/**
 * Raw queries against the `cell_field` table.
 *
 * Named-relation primitive: each row is `(source_id, name) → target_id`,
 * a JSON-object-shaped edge from one cell to another. `(source_id, name)`
 * is unique — one target per name per source. Multiplicity by composition
 * (target a collection cell whose `items[]` are the multi-valued tags),
 * not by allowing duplicate field rows.
 *
 * Reads filter both endpoints by `cell.deleted_at IS NULL` so relations
 * dangling off a soft-deleted cell don't surface to the live graph.
 *
 * `query_cell_field_set` upserts on the `(source_id, name)` PK so
 * re-pointing a name updates `target_id` in place — JSON-object semantics
 * (`obj.foo = bar` overwrites whatever was there).
 *
 * @module
 */
import type { QueryDeps } from './query_deps.js';
import type { Uuid } from '@fuzdev/fuz_util/id.js';
/** Row shape returned by `cell_field` SELECTs. */
export interface CellFieldRow {
    source_id: Uuid;
    name: string;
    target_id: Uuid;
    created_at: Date;
}
/** Input for `query_cell_field_set`. */
export interface CellFieldSetQueryInput {
    source_id: Uuid;
    name: string;
    target_id: Uuid;
}
/**
 * Insert or update a field row.
 *
 * UPSERT on `(source_id, name)` — re-setting the same name updates
 * `target_id` and bumps `created_at` (timestamp reflects last write).
 * Idempotent at the row level: caller can re-issue with the same input
 * without checking existence first.
 *
 * @param deps - query deps
 * @param input - source, name, target
 * @returns the inserted-or-updated row
 * @mutates `cell_field` - inserts or updates one row
 */
export declare const query_cell_field_set: (deps: QueryDeps, input: CellFieldSetQueryInput) => Promise<CellFieldRow>;
/**
 * Fetch one field row by primary key.
 *
 * Does NOT JOIN cell — the caller decides whether to filter by
 * `deleted_at`. Used by handlers that need the row's current target_id
 * for audit envelopes before issuing the delete.
 *
 * @param deps - query deps
 * @param source_id - source cell id
 * @param name - field name
 * @returns the row or `null` when not found
 */
export declare const query_cell_field_get: (deps: QueryDeps, source_id: Uuid, name: string) => Promise<CellFieldRow | null>;
/**
 * Delete a field row by primary key. Returns the deleted row so callers
 * can audit the prior target_id without a pre-fetch.
 *
 * @returns the deleted row, or `null` when no row matched (idempotent
 *   delete: a 200 response is correct even when nothing was deleted)
 * @mutates `cell_field` - deletes one row
 */
export declare const query_cell_field_delete: (deps: QueryDeps, source_id: Uuid, name: string) => Promise<CellFieldRow | null>;
/**
 * Forward fields list (`source.fields[]`).
 *
 * Filters target by `deleted_at IS NULL` so relations to tombstoned cells
 * don't surface; the source filter is the caller's responsibility (gated
 * upstream by `can_view_cell(source)`).
 *
 * @param deps - query deps
 * @param source_id - source cell id
 * @returns matching rows, oldest first by name (lex order)
 */
export declare const query_cell_field_list_for_source: (deps: QueryDeps, source_id: Uuid, options?: {
    limit?: number;
    name_after?: string;
}) => Promise<Array<CellFieldRow>>;
/**
 * Reverse fields list (`target.upfields[]`).
 *
 * Returns rows whose `target_id = $1`, joined to `cell` on `source_id` so
 * relations from tombstoned sources don't surface. The caller-side
 * authz filter (per-source `can_view_cell`) runs after the SQL fetch
 * — see the 2-layer authz contract on `cell_field_list({target_id})`.
 *
 * Bounded by `limit` (the wire `cell_field_list` cap) so a heavily
 * inbound-linked target can't force an unbounded fetch + per-source authz
 * pass on the public, IP-rate-limited reverse endpoint.
 *
 * @param deps - query deps
 * @param target_id - target cell id
 * @param options - `limit` caps the row count
 * @returns matching rows, oldest first by source created_at
 */
export declare const query_cell_field_list_for_target: (deps: QueryDeps, target_id: Uuid, options?: {
    limit?: number;
}) => Promise<Array<CellFieldRow>>;
//# sourceMappingURL=cell_field_queries.d.ts.map