UNPKG

@tanstack/db

Version:

A reactive client store for building super fast apps on sync

39 lines (38 loc) • 2.59 kB
import { ValueIdentity } from '../equality-value-identity.js'; import { CompilationResult, IncludesCompilationResult } from './index.js'; import { BasicExpression, CollectionSourceRef, From, JoinClause, QueryIR, QueryRef } from '../ir.js'; import { Collection } from '../../collection/index.js'; import { KeyedStream, NamespacedAndKeyedStream } from '../../types.js'; import { QueryMapping } from './types.js'; type CompileSubquery = (query: QueryIR, parentKeyStream?: KeyedStream) => CompilationResult; export type LazyDemandPlan = { id: string; path: Array<string>; collectionId: string; initialKeys: Set<unknown>; }; /** Callbacks for managing lazy-loaded collections in optimized joins */ export type LazyCollectionCallbacks = { plans?: Array<LazyDemandPlan>; setDemand?: (plan: LazyDemandPlan, keys: Set<unknown>) => void; }; export declare function registerLazyDemandPlan(callbacks: Record<string, LazyCollectionCallbacks>, target: { sourceId: string; path: Array<string>; collection: Collection; }, initialKeys?: Set<unknown>): LazyDemandPlan; /** * Processes all join clauses, applying lazy loading optimizations and maintaining * alias tracking for per-alias subscriptions (enables self-joins). */ export declare function processJoins(pipeline: NamespacedAndKeyedStream, joinClauses: Array<JoinClause>, sources: Record<string, KeyedStream>, mainCollectionId: string, mainSource: string, allInputs: Record<string, KeyedStream>, queryMapping: QueryMapping, collections: Record<string, Collection>, callbacks: Record<string, LazyCollectionCallbacks>, lazySources: Set<string>, rawQuery: QueryIR, localFrom: From, onCompileSubquery: CompileSubquery, aliasToCollectionId: Record<string, string>, aliasRemapping: Record<string, string>, sourceWhereClauses: Map<string, BasicExpression<boolean>>, mainSourceIsParentFiltered: boolean, valueIdentity: ValueIdentity, parentKeyStream?: KeyedStream): NamespacedAndKeyedStream; /** * Compiles a FROM or JOIN source and propagates its source metadata. */ export declare function processSource(from: CollectionSourceRef | QueryRef, allInputs: Record<string, KeyedStream>, queryMapping: QueryMapping, onCompileSubquery: CompileSubquery, aliasToCollectionId: Record<string, string>, aliasRemapping: Record<string, string>, sourceWhereClauses: Map<string, BasicExpression<boolean>>, valueIdentity: ValueIdentity, sourceKind: `from` | `join`, parentKeyStream?: KeyedStream): { alias: string; input: KeyedStream; collectionId: string; includes?: Array<IncludesCompilationResult>; }; export {};