import { BasicExpression } from '../ir.js'; import { RefLeaf } from './types.js'; import { VirtualRowProps } from '../../virtual-props.js'; export interface RefProxy { /** @internal */ readonly __refProxy: true; /** @internal */ readonly __path: Array; /** @internal */ readonly __type: T; } /** * Virtual properties available on all row ref proxies. * These allow querying on sync status, origin, key, and collection ID. */ export type VirtualPropsRefProxy = { readonly [K in keyof VirtualRowProps]: RefLeaf[K]>; }; /** * Type for creating a RefProxy for a single row/type without namespacing * Used in collection indexes and where clauses * * Includes virtual properties ($synced, $origin, $key, $collectionId) for * querying on sync status and row metadata. */ export type SingleRowRefProxy = T extends Record ? { [K in keyof T]: T[K] extends Record ? SingleRowRefProxy & RefProxy : RefLeaf; } & RefProxy & VirtualPropsRefProxy : RefProxy & VirtualPropsRefProxy; /** * Creates a proxy object that records property access paths for a single row * Used in collection indexes and where clauses */ export declare function createSingleRowRefProxy>(): SingleRowRefProxy; /** * Creates a proxy object that records property access paths * Used in callbacks like where, select, etc. to create type-safe references */ export declare function createRefProxy>(aliases: Array): RefProxy & T; /** * Creates a ref proxy with $selected namespace for SELECT fields * * Adds a $selected property that allows accessing SELECT fields via $selected.fieldName syntax. * The $selected proxy creates paths like ['$selected', 'fieldName'] which directly reference * the $selected property on the namespaced row. * * @param aliases - Array of table aliases to create proxies for * @returns A ref proxy with table aliases and $selected namespace */ export declare function createRefProxyWithSelected>(aliases: Array): RefProxy & T & { $selected: SingleRowRefProxy; }; /** * Converts a value to an Expression. * If it's a RefProxy, creates a PropRef. Throws if the value is a * ToArrayWrapper, ConcatToArrayWrapper, or CaseWhenWrapper (these must be used * as direct select fields). Otherwise wraps it as a Value. */ export declare function toExpression(value: T): BasicExpression; export declare function toExpression(value: RefProxy): BasicExpression; /** * Type guard to check if a value is a RefProxy */ export declare function isRefProxy(value: any): value is RefProxy; /** * Helper to create a Value expression from a literal */ export declare function val(value: T): BasicExpression;