/**
 * Generic utility functions for creating paginated SDK functions
 */
import type { z } from "zod";
import type { PaginatedSdkResult } from "../types/functions";
/**
 * Callbacks for telemetry events during function execution
 */
export interface TelemetryCallbacks {
    onMethodCalled?: (data: {
        methodName: string;
        durationMs: number;
        success: boolean;
        error?: Error;
        argumentCount: number;
        isPaginated: boolean;
    }) => void;
}
/**
 * Helper function to extract cursor from pagination data
 * Supports JSON:API style `links.next` URLs by extracting the `offset` parameter.
 */
export declare function extractCursor(data: {
    next?: string | null;
} | null | undefined): string | undefined;
/**
 * Higher-order function that creates a function from a core function
 *
 * @param coreFn - Function that returns T directly or throws errors
 * @param schema - Optional Zod schema for validation
 * @param telemetry - Optional telemetry callbacks
 * @returns A function that normalizes and rethrows errors
 */
export declare function createFunction<TOptions, TResult, TSchemaOptions extends TOptions = TOptions>(coreFn: (options: TOptions) => Promise<TResult>, schema?: z.ZodSchema<TSchemaOptions>, telemetry?: TelemetryCallbacks): (options?: TOptions) => Promise<TResult>;
/**
 * Higher-order function that creates a paginated function that wraps results in {data}
 *
 * @param coreFn - Function that returns T directly or throws errors
 * @returns A function that normalizes errors and wraps results in {data}
 */
/**
 * Extract the item type from a page handler's return shape. The handler
 * may return a flat `{ data: TItem[] }` (or single `data: TItem`), a bare
 * array, or a JSON:API envelope; in all cases the wrapper normalizes to
 * `SdkPage<TItem>` and this resolves the right `TItem`.
 */
type ItemType<TResult> = TResult extends {
    data: infer TData;
} ? TData extends readonly (infer TItem)[] ? TItem : TData : TResult extends readonly (infer TItem)[] ? TItem : TResult;
export declare function createPaginatedFunction<TUserOptions, TResult>(coreFn: (options: TUserOptions & {
    cursor?: string;
    pageSize?: number;
}) => Promise<TResult>, schema?: z.ZodSchema<TUserOptions>, telemetry?: TelemetryCallbacks, explicitFunctionName?: string, defaultPageSize?: number): (options?: TUserOptions & {
    cursor?: string;
    pageSize?: number;
    maxItems?: number;
}) => PaginatedSdkResult<ItemType<TResult>>;
export {};
//# sourceMappingURL=function-utils.d.ts.map