@tanstack/db
Version:
A reactive client store for building super fast apps on sync
29 lines (28 loc) • 2.03 kB
text/typescript
import { CompileQueryFn } from './index.js';
import { OrderByOptimizationInfo } from './order-by.js';
import { BasicExpression, JoinClause, QueryIR } from '../ir.js';
import { Collection } from '../../collection/index.js';
import { KeyedStream, NamespacedAndKeyedStream } from '../../types.js';
import { QueryCache, QueryMapping, WindowOptions } from './types.js';
import { CollectionSubscription } from '../../collection/subscription.js';
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>, cache: QueryCache, queryMapping: QueryMapping, collections: Record<string, Collection>, subscriptions: Record<string, CollectionSubscription>, callbacks: Record<string, LazyCollectionCallbacks>, lazySources: Set<string>, optimizableOrderByCollections: Record<string, OrderByOptimizationInfo>, setWindowFn: (windowFn: (options: WindowOptions) => void) => void, rawQuery: QueryIR, onCompileSubquery: CompileQueryFn, aliasToCollectionId: Record<string, string>, aliasRemapping: Record<string, string>, sourceWhereClauses: Map<string, BasicExpression<boolean>>, mainSourceIsParentFiltered: boolean): NamespacedAndKeyedStream;