deepsource-mcp-server
Version:
Model Context Protocol server for DeepSource
50 lines (49 loc) • 2.2 kB
TypeScript
/**
* @fileoverview Pagination helpers for the DeepSource MCP Server
* This module provides utilities for working with pagination.
*/
import { PageInfo, PaginationParams, PaginatedResponse } from './types.js';
/**
* Creates an empty paginated response with no items
* @template T The type of items in the response
* @returns {PaginatedResponse<T>} Empty paginated response with consistent structure
* @public
*/
export declare function createEmptyPaginatedResponse<T>(): PaginatedResponse<T>;
/**
* Normalizes pagination parameters for GraphQL queries
* Ensures consistency in pagination parameters following Relay pagination best practices
*
* Normalization rules:
* 1. If 'before' is provided (backward pagination):
* - Use 'last' as the count parameter (default: 10)
* - Remove any 'first' parameter to avoid ambiguity
* 2. If 'last' is provided without 'before' (non-standard but supported):
* - Keep 'last' as is
* - Remove any 'first' parameter to avoid ambiguity
* - Log a warning about non-standard usage
* 3. Otherwise (forward pagination or defaults):
* - Use 'first' as the count parameter (default: 10)
* - Remove any 'last' parameter to avoid ambiguity
*
* @template T Type that extends PaginationParams
* @param {T} params - Original pagination parameters
* @returns {T} Normalized pagination parameters with consistent values
* @public
*/
export declare function normalizePaginationParams<T extends PaginationParams>(params: T): T;
/**
* Creates a formatted pagination help object for API responses
* @param pageInfo The page information to create help documentation for
* @returns Pagination help documentation object
* @public
*/
export declare function createPaginationHelp(pageInfo: PageInfo): Record<string, unknown>;
/**
* Creates a detailed pagination help object for API responses with more examples
* @param pageInfo The page information to create help documentation for
* @param itemCount The number of items in the current page
* @returns Enhanced pagination help documentation object
* @public
*/
export declare function createEnhancedPaginationHelp(pageInfo: PageInfo, itemCount: number): Record<string, unknown>;