@ahoo-wang/fetcher-wow
Version:
Support for Wow(https://github.com/Ahoo-Wang/Wow) in Fetcher
60 lines • 3.72 kB
TypeScript
import { ListQuery, PagedList, PagedQuery, SingleQuery } from './queryable';
import { JsonServerSentEvent } from '@ahoo-wang/fetcher-eventstream';
import { Condition } from './condition';
/**
* Interface for generic query API operations.
* Provides methods for querying resources in different ways including single item retrieval,
* list retrieval, streaming lists, paged retrieval, and counting.
*
* @see {@link EventStreamQueryApi}
* @see {@link SnapshotQueryApi}
* @template R - The type of resource being queried
*/
export interface QueryApi<R, FIELDS extends string = string> {
/**
* Retrieves a single resource based on the provided query parameters.
* @param singleQuery - The query parameters for retrieving a single resource
* @param attributes - Optional shared attributes that can be accessed by interceptors
* throughout the request lifecycle. These attributes allow passing
* custom data between different interceptors.
* @returns A promise that resolves to a partial resource
*/
single<T extends Partial<R> = R>(singleQuery: SingleQuery<FIELDS>, attributes?: Record<string, any>): Promise<T>;
/**
* Retrieves a list of resources based on the provided query parameters.
* @param listQuery - The query parameters for listing resources
* @param attributes - Optional shared attributes that can be accessed by interceptors
* throughout the request lifecycle. These attributes allow passing
* custom data between different interceptors.
* @returns A promise that resolves to an array of partial resources
*/
list<T extends Partial<R> = R>(listQuery: ListQuery<FIELDS>, attributes?: Record<string, any>): Promise<T[]>;
/**
* Retrieves a stream of resources based on the provided query parameters.
* @param listQuery - The query parameters for listing resources
* @param attributes - Optional shared attributes that can be accessed by interceptors
* throughout the request lifecycle. These attributes allow passing
* custom data between different interceptors.
* @returns A promise that resolves to a readable stream of JSON server-sent events containing partial resources
*/
listStream<T extends Partial<R> = R>(listQuery: ListQuery<FIELDS>, attributes?: Record<string, any>): Promise<ReadableStream<JsonServerSentEvent<T>>>;
/**
* Retrieves a paged list of resources based on the provided query parameters.
* @param pagedQuery - The query parameters for paging resources
* @param attributes - Optional shared attributes that can be accessed by interceptors
* throughout the request lifecycle. These attributes allow passing
* custom data between different interceptors.
* @returns A promise that resolves to a paged list of partial resources
*/
paged<T extends Partial<R> = R>(pagedQuery: PagedQuery<FIELDS>, attributes?: Record<string, any>): Promise<PagedList<T>>;
/**
* Counts the number of resources that match the given condition.
* @param condition - The condition to filter resources
* @param attributes - Optional shared attributes that can be accessed by interceptors
* throughout the request lifecycle. These attributes allow passing
* custom data between different interceptors.
* @returns A promise that resolves to the count of matching resources
*/
count(condition: Condition<FIELDS>, attributes?: Record<string, any>): Promise<number>;
}
//# sourceMappingURL=queryApi.d.ts.map