/** * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com) * http://github.com/fonoster/fonoster * * This file is part of Fonoster * * Licensed under the MIT License (the "License"); * you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * https://opensource.org/licenses/MIT * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ type ListResponse = { items: T[]; nextPageToken?: string; }; type PaginatedListOptions = { pageSize: number; pageToken?: string; fetchPage: (pageToken: string | undefined, pageSize: number) => Promise>; filterItems: (items: TInput[]) => TOutput[]; maxIterations?: number; }; /** * Normalizes empty string pageToken to undefined. * Empty strings are falsy in JS, but gRPC/protobuf may send them as empty strings. */ export declare function normalizePageToken(pageToken?: string): string | undefined; /** * Normalizes nextPageToken from response; returns empty string when there are no more pages. */ export declare function normalizeNextPageToken(nextPageToken?: string): string; /** * Filters items by accessKeyId from extended field. */ export declare function filterByAccessKeyId(items: T[], accessKeyId: string): T[]; /** * Pages through Routr's items keeping only the caller's, so that following `nextPageToken` returns * every kept item exactly once (management-api, "Lists page through every item once"). * * Routr's page token is a cursor on the last ref it returned, so a page can end on any item: when * the page fills in the middle of a backend batch, the token is the ref of the last item kept and * the next call resumes right after it. Batches with none of the caller's items are skipped, up to * `maxIterations` of them; the token then points past the last batch read. * * @template TInput - The type of items returned from the API * @template TOutput - The type of items after filtering/transformation (defaults to TInput) */ export declare function paginateWithFiltering(options: PaginatedListOptions): Promise>; export {};