/** * Endpoint URL Builders * Advanced utilities for building URLs and cache keys from endpoints */ import { endpoints } from './index'; export type EndpointName = keyof typeof endpoints; /** * Query parameters type - matches fetchff's flexible param handling * Supports objects, URLSearchParams, and arrays of name-value pairs */ export type QueryParams = Record | URLSearchParams | Array<[string, string]>; /** * Generate cache key from endpoint name * * @param endpoint - The endpoint name * @param params - Optional path and query parameters * @returns Cache key string * * @example * endpointCacheKey('getCampaign', { pathParams: { id: '123' } }) // '/campaigns/123' * endpointCacheKey('listCampaigns', { queryParams: { status: 'active' } }) // '/campaigns:{"status":"active"}' */ export declare function endpointCacheKey(endpoint: EndpointName, params?: { pathParams?: Record; queryParams?: QueryParams; }): string; /** * Generate pattern for cache invalidation * * @param endpoint - The endpoint name * @param wildcardParam - Optional specific parameter to wildcard * @returns Pattern string with wildcards * * @example * endpointCachePattern('getCampaign') // '/campaigns/*' * endpointCachePattern('getCampaignStats', 'id') // '/campaigns/*\/stats' */ export declare function endpointCachePattern(endpoint: EndpointName, wildcardParam?: string): string; /** * Find endpoints by URL pattern * * @param pattern - RegExp pattern to match against URLs * @returns Array of matching endpoints with their configs * * @example * findEndpointsByPattern(/^\/campaigns/) // All campaign endpoints */ export declare function findEndpointsByPattern(pattern: RegExp): Array<{ name: EndpointName; url: string; method?: string; }>; /** * Get all endpoints by HTTP method * * @param method - HTTP method (GET, POST, etc.) * @returns Array of endpoints using that method * * @example * getEndpointsByMethod('GET') // All GET endpoints * getEndpointsByMethod('POST') // All POST endpoints */ export declare function getEndpointsByMethod(method: string): Array<{ name: EndpointName; url: string; method?: string; }>; /** * Endpoint-based cache key patterns * Predefined patterns for common cache invalidation scenarios */ export declare const endpointCachePatterns: { allCampaigns: () => string; campaignById: (id: string) => string; campaignsByPattern: () => string; campaignStats: (id: string) => string; all: () => string; byEndpoint: (endpoint: EndpointName) => string; custom: (pattern: string) => string; }; /** * Build full request URL including base URL and query parameters * * @param endpoint - The endpoint name * @param baseURL - Base URL of the API * @param params - Path and query parameters * @returns Full URL string * * @example * buildFullUrl('getCampaign', 'https://api.example.com', { pathParams: { id: '123' } }) * // 'https://api.example.com/campaigns/123' */ export declare function buildFullUrl(endpoint: EndpointName, baseURL: string, params?: { pathParams?: Record; queryParams?: QueryParams; }): string; /** * Validate that all required path parameters are provided * * @param endpoint - The endpoint name * @param pathParams - Provided path parameters * @returns True if all required params are provided * * @example * validatePathParams('getCampaign', { id: '123' }) // true * validatePathParams('getCampaign', {}) // false */ export declare function validatePathParams(endpoint: EndpointName, pathParams?: Record): boolean; //# sourceMappingURL=builders.d.ts.map