github-pr-automation
Version:
MCP server and CLI for automated GitHub PR management, review resolution, and workflow optimization
54 lines • 2.23 kB
TypeScript
import type { PaginatedResult } from "../types/index.js";
/**
* MCP-compliant cursor-based pagination
* Reference: https://modelcontextprotocol.io/specification/2025-06-18/server/utilities/pagination
*
* Cursors are opaque base64-encoded strings containing offset and page size.
* Clients MUST NOT parse or modify cursors.
*/
interface CursorData {
offset: number;
pageSize: number;
}
/**
* Encode pagination cursor from offset and page size
* @param offset - Starting offset for pagination
* @param pageSize - Number of items per page
* @returns Base64-encoded cursor string
*/
export declare function encodeCursor(offset: number, pageSize: number): string;
/**
* Decode pagination cursor to offset and page size
* @param cursor - Base64-encoded cursor string
* @returns Decoded cursor data with offset and pageSize
* @throws Error if cursor format is invalid
*/
export declare function decodeCursor(cursor: string): CursorData;
/**
* Convert MCP cursor to GitHub API pagination parameters
* @param cursor - Optional MCP cursor string
* @param defaultPageSize - Default page size to use if no cursor provided
* @returns GitHub API pagination parameters (page, per_page)
*/
export declare function cursorToGitHubPagination(cursor: string | undefined, defaultPageSize: number): {
page: number;
per_page: number;
};
/**
* Create next cursor for pagination if more results exist
* @param currentCursor - Current cursor string
* @param pageSize - Size of the current page
* @param hasMore - Whether more results exist
* @returns Next cursor string or undefined if no more results
*/
export declare function createNextCursor(currentCursor: string | undefined, pageSize: number, hasMore: boolean): string | undefined;
/**
* Paginate an array of items using MCP cursor-based pagination
* @param items - Array of items to paginate
* @param cursor - Optional cursor string for pagination
* @param defaultPageSize - Number of items per page
* @returns Paginated result with items and optional next cursor
*/
export declare function paginateResults<T>(items: T[], cursor: string | undefined, defaultPageSize: number): PaginatedResult<T>;
export {};
//# sourceMappingURL=pagination.d.ts.map