import type { ReplicacheImpl } from '../../../replicache/src/replicache-impl.ts'; import type { ClientID } from '../../../replicache/src/sync/ids.ts'; import { TDigest } from '../../../shared/src/tdigest.ts'; import { type AST } from '../../../zero-protocol/src/ast.ts'; import type { ChangeDesiredQueriesMessage } from '../../../zero-protocol/src/change-desired-queries.ts'; import type { ErroredQuery } from '../../../zero-protocol/src/custom-queries.ts'; import type { UpQueriesPatchOp } from '../../../zero-protocol/src/queries-patch.ts'; import type { TableSchema } from '../../../zero-schema/src/table-schema.ts'; import type { ClientMetricMap } from '../../../zql/src/query/metrics-delegate.ts'; import type { CustomQueryID } from '../../../zql/src/query/named.ts'; import type { GotCallback } from '../../../zql/src/query/query-delegate.ts'; import { type TTL } from '../../../zql/src/query/ttl.ts'; import type { InspectorDelegate } from './inspector/inspector.ts'; import type { MutationTracker } from './mutation-tracker.ts'; import type { ReadTransaction } from './replicache-types.ts'; import type { ZeroLogContext } from './zero-log-context.ts'; type ClientMetric = { [K in keyof ClientMetricMap]: TDigest; }; /** * Tracks what queries the client is currently subscribed to on the server. * Sends `changeDesiredQueries` message to server when this changes. * Deduplicates requests so that we only listen to a given unique query once. */ export declare class QueryManager implements InspectorDelegate { #private; constructor(lc: ZeroLogContext, mutationTracker: MutationTracker, clientID: ClientID, tables: Record, send: (change: ChangeDesiredQueriesMessage) => void, experimentalWatch: ReplicacheImpl['experimentalWatch'], recentQueriesMaxSize: number, queryChangeThrottleMs: number, _slowMaterializeThreshold: number); getAST(queryID: string): AST | undefined; /** * Get the queries that need to be registered with the server. * * An optional `lastPatch` can be provided. This is the last patch that was * sent to the server and may not yet have been acked. If `lastPatch` is provided, * this method will return a patch that does not include any events sent in `lastPatch`. * * This diffing of last patch and current patch is needed since we send * a set of queries to the server when we first connect inside of the `sec-protocol` as * the `initConnectionMessage`. * * While we're waiting for the `connected` response to come back from the server, * the client may have registered more queries. We need to diff the `initConnectionMessage` * queries with the current set of queries to understand what those were. */ getQueriesPatch(tx: ReadTransaction, lastPatch?: Map | undefined): Promise>; handleTransformErrors(errors: ErroredQuery[]): void; addCustom(ast: AST, { name, args }: CustomQueryID, ttl: TTL, gotCallback?: GotCallback | undefined): () => void; addLegacy(ast: AST, ttl: TTL, gotCallback?: GotCallback | undefined): () => void; updateCustom({ name, args }: CustomQueryID, ttl: TTL): void; updateLegacy(ast: AST, ttl: TTL): void; flushBatch(): void; /** * Gets the aggregated metrics for all queries managed by this QueryManager. */ get metrics(): ClientMetric; addMetric(metric: K, value: number, ...args: ClientMetricMap[K]): void; getQueryMetrics(queryID: string): ClientMetric | undefined; } export {}; //# sourceMappingURL=query-manager.d.ts.map