import type { ObjectOrInterfaceDefinition, ObjectSet, ObjectTypeDefinition, Osdk, PageResult, PropertyKeys } from "@osdk/api";
import type { Observable, Subscription } from "rxjs";
import type { InterfaceHolder } from "../../../object/convertWireToOsdkObjects/InterfaceHolder.js";
import type { ObjectHolder } from "../../../object/convertWireToOsdkObjects/ObjectHolder.js";
import type { ListPayload } from "../../ListPayload.js";
import type { Status } from "../../ObservableClient/common.js";
import { BaseListQuery } from "../base-list/BaseListQuery.js";
import type { BatchContext } from "../BatchContext.js";
import { type CacheKey } from "../CacheKey.js";
import type { Canonical } from "../Canonical.js";
import { type Changes } from "../Changes.js";
import type { Entry } from "../Layer.js";
import type { OptimisticId } from "../OptimisticId.js";
import type { PivotInfo } from "../PivotCanonicalizer.js";
import type { SimpleWhereClause } from "../SimpleWhereClause.js";
import type { Store } from "../Store.js";
import type { SubjectPayload } from "../SubjectPayload.js";
import { type ListCacheKey } from "./ListCacheKey.js";
export { API_NAME_IDX, INTERSECT_IDX, PIVOT_IDX, RDP_IDX } from "./ListCacheKey.js";
import type { ListQueryOptions } from "./ListQueryOptions.js";
type ExtractRelevantObjectsResult = Record<"added" | "modified", {
	all: (ObjectHolder | InterfaceHolder)[]
	strictMatches: Set<(ObjectHolder | InterfaceHolder)>
	sortaMatches: Set<(ObjectHolder | InterfaceHolder)>
}>;
/**
* Base class for filtered and sorted object collection queries.
* - Handles where clause filtering and orderBy sorting
* - Manages pagination through fetchMore
* - Auto-updates when matching objects change
* - Uses canonicalized cache keys for consistency
*/
export declare abstract class ListQuery extends BaseListQuery<ListCacheKey, ListPayload, ListQueryOptions> {
	#private;
	protected apiName: string;
	/**
	* Register changes to the cache specific to ListQuery
	*/
	protected registerCacheChanges(batch: BatchContext): void;
	constructor(store: Store, subject: Observable<SubjectPayload<ListCacheKey>>, apiName: string, cacheKey: ListCacheKey, opts: ListQueryOptions);
	get canonicalWhere(): Canonical<SimpleWhereClause>;
	get canonicalIntersectWith(): Canonical<Array<Canonical<SimpleWhereClause>>> | undefined;
	get canonicalPivotInfo(): Canonical<PivotInfo> | undefined;
	/**
	* Create the ObjectSet for this query.
	*/
	protected abstract createObjectSet(store: Store): ObjectSet<ObjectTypeDefinition>;
	/**
	* Implements fetchPageData from BaseCollectionQuery template method
	* Fetches a page of data
	*/
	protected fetchPageData(signal: AbortSignal | undefined): Promise<PageResult<Osdk.Instance<any>>>;
	/**
	* Handle fetch errors by setting appropriate error state and notifying subscribers
	*/
	protected handleFetchError(error: unknown, _status: Status, batch: BatchContext): Entry<ListCacheKey>;
	/**
	* Will revalidate the list if its query is affected by invalidating the
	* apiName of the object type passed in.
	*
	* @param apiName to invalidate
	* @returns
	*/
	abstract revalidateObjectType(apiName: string): Promise<void>;
	/**
	* Postprocess fetched data.
	*/
	protected abstract postProcessFetchedData(data: Osdk.Instance<any>[]): Promise<Osdk.Instance<any>[]>;
	invalidateObjectType: (objectType: string, changes: Changes | undefined) => Promise<void>;
	/**
	* Note: This method is not async because I want it to return right after it
	*       finishes the synchronous updates. The promise that is returned
	*       will resolve after the revalidation is complete.
	* @param changes
	* @param optimisticId
	* @returns If revalidation is needed, a promise that resolves after the
	*          revalidation is complete. Otherwise, undefined.
	*/
	maybeUpdateAndRevalidate: (changes: Changes, optimisticId: OptimisticId | undefined) => Promise<void> | undefined;
	protected _extractAndCategorizeRelevantObjects(changes: Changes): ExtractRelevantObjectsResult;
	/**
	* Extract relevant objects for this query type.
	*/
	protected abstract extractRelevantObjects(changes: Changes): ExtractRelevantObjectsResult;
	registerStreamUpdates(sub: Subscription): void;
	protected onOswChange({ object: objOrIface, state }: ObjectUpdate<ObjectTypeDefinition, string>): void;
	protected onOswRemoved(objOrIface: Osdk.Instance<ObjectTypeDefinition, never, string, {}>): void;
	/**
	* Get cache key for object.
	*/
	private getObjectCacheKey;
}
export declare function isListCacheKey(cacheKey: CacheKey): cacheKey is ListCacheKey;
/**
* Copied from @osdk/api
*/
type ObjectUpdate<
	O extends ObjectOrInterfaceDefinition,
	P extends PropertyKeys<O>
> = {
	object: Osdk.Instance<O, never, P>
	state: "ADDED_OR_UPDATED" | "REMOVED"
};
