import { RequestContext } from '@mastra/core/request-context'; /** * Normalizes a route path to ensure consistent formatting. * - Removes leading/trailing whitespace * - Validates no path traversal (..), query strings (?), or fragments (#) * - Collapses multiple consecutive slashes * - Removes trailing slashes * - Ensures leading slash (unless empty) * * @param path - The route path to normalize * @returns The normalized path (empty string for root paths) * @throws Error if path contains invalid characters */ export declare function normalizeRoutePath(path: string): string; /** * Converts a nested params object to flat URL query parameters. * * This mirrors the server's `wrapSchemaForQueryParams` behavior: * - Flattens specified nested keys to top-level params * - JSON-stringifies complex values (objects, arrays) * - Converts primitives to strings * - Handles Date objects by converting to ISO strings * * @param params - The params object to convert * @param flattenKeys - Keys whose values should be flattened to top-level params * * @example * ```ts * toQueryParams( * { * pagination: { page: 0, perPage: 10 }, * filters: { spanType: 'agent_run', startedAt: { start: new Date() } }, * orderBy: { field: 'startedAt', direction: 'DESC' } * }, * ['filters', 'pagination', 'orderBy'] * ) * // Returns: "page=0&perPage=10&spanType=agent_run&startedAt=%7B%22start%22%3A%222024-...%22%7D&field=startedAt&direction=DESC" * ``` */ export declare function toQueryParams>(params: T, flattenKeys?: (keyof T)[]): string; /** * Parses a JSON string that may have been serialized with superjson. * superjson wraps values as `{json: ..., meta: ...}` — this unwraps to the inner value. * Also handles plain JSON strings for forward compatibility. * @throws {SyntaxError} if `value` is not valid JSON */ export declare function parseSuperJsonString(value: string): unknown; export declare function parseClientRequestContext(requestContext?: RequestContext | Record): Record | undefined; export declare function base64RequestContext(requestContext?: Record): string | undefined; /** * Converts a request context to a query string * @param requestContext - The request context to convert * @param delimiter - The delimiter to use in the query string * @returns The query string */ export declare function requestContextQueryString(requestContext?: RequestContext | Record, delimiter?: string): string; /** * Build a `?organizationId=...&projectId=...` query string fragment from * optional tenancy scope fields. Returns an empty string when neither field * is supplied so callers can safely concatenate it to a URL. */ export declare function buildTenancyQuery(tenancy?: { organizationId?: string; projectId?: string; }): string; /** * Merges header records case-insensitively; later layers win and keep their casing. * Spreading would keep `Authorization` and `authorization` apart, and fetch joins them into "a, b". */ export declare function mergeHeaders(...layers: Array | undefined>): Record; /** * Merges multiple optional abort signals into one. Returns `undefined` when no * signals are provided, the single signal when only one is provided, and a * combined signal otherwise. Uses `AbortSignal.any` when available and falls * back to a manual listener merge for runtimes that lack it. */ export declare function mergeAbortSignals(...signals: Array): AbortSignal | undefined; /** * Whether an error carries an HTTP status that retrying cannot fix: any 4xx * client error (e.g. 401/403 auth failures) or 501 Not Implemented. */ export declare function isTerminalHttpError(error: unknown): boolean; /** * Whether an error is the server's trace query execution timeout (504 with code * `TRACE_QUERY_EXECUTION_TIMEOUT`). Re-sending the same query hits the same * timeout budget, so retrying only repeats an expensive database query. * Plain 504s from proxies or gateways do not carry this code and stay retryable. */ export declare function isTraceQueryTimeoutError(error: unknown): boolean; /** * Whether a failed resubscribe should end a long-lived subscription instead of * retrying. Like {@link isTerminalHttpError}, but 408 Request Timeout and * 429 Too Many Requests stay retryable because they mean "try again later". */ export declare function isTerminalReconnectError(error: unknown): boolean; //# sourceMappingURL=index.d.ts.map