mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-25 03:41:19 +00:00
* ru threshold beta * use new ru threshold package * fix typo * fix merge issue * fix package-lock.json * fix test * fixed settings pane test * fixed merge issue * sync with main * fixed settings pane check * fix checks * fixed aria-label error * fixed aria-label error * fixed aria-label error * fixed aria-label error * remove learn more --------- Co-authored-by: Asier Isayas <aisayas@microsoft.com>
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import { QueryOperationOptions } from "@azure/cosmos";
|
|
import { QueryResults } from "../Contracts/ViewModels";
|
|
|
|
interface QueryResponse {
|
|
// [Todo] remove any
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
resources: any[];
|
|
hasMoreResults: boolean;
|
|
activityId: string;
|
|
requestCharge: number;
|
|
}
|
|
|
|
export interface MinimalQueryIterator {
|
|
fetchNext: (queryOperationOptions?: QueryOperationOptions) => Promise<QueryResponse>;
|
|
}
|
|
|
|
// Pick<QueryIterator<any>, "fetchNext">;
|
|
|
|
export function nextPage(
|
|
documentsIterator: MinimalQueryIterator,
|
|
firstItemIndex: number,
|
|
queryOperationOptions?: QueryOperationOptions,
|
|
): Promise<QueryResults> {
|
|
return documentsIterator.fetchNext(queryOperationOptions).then((response) => {
|
|
const documents = response.resources;
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
const headers = (response as any).headers || {}; // TODO this is a private key. Remove any
|
|
const itemCount = (documents && documents.length) || 0;
|
|
return {
|
|
documents,
|
|
hasMoreResults: response.hasMoreResults,
|
|
itemCount,
|
|
firstItemIndex: Number(firstItemIndex) + 1,
|
|
lastItemIndex: Number(firstItemIndex) + Number(itemCount),
|
|
headers,
|
|
activityId: response.activityId,
|
|
requestCharge: response.requestCharge,
|
|
};
|
|
});
|
|
}
|