UNPKG

mastra

Version:
37 lines 1.75 kB
import type { paths } from '../platform-api.js'; export declare const MASTRA_PLATFORM_API_URL: string; export declare const MASTRA_GATEWAY_URL: string; export declare const MASTRA_STUDIO_URL: string; export declare const SESSION_EXPIRED_MESSAGE = "Session expired. Run: mastra auth login"; /** * Throw a standardized error for API failures. * - 401: "Session expired" (authentication failed) * - Other: Show the server's error detail or fall back to status code */ export declare function throwApiError(message: string, status: number, detail?: string): never; /** Best-effort message from platform JSON error bodies (RFC 7807 `detail`, etc.). */ export declare function extractApiErrorDetail(error: unknown): string | undefined; /** * Set the current token/orgId used by authenticated fetch. * Call this after login or getToken(). */ export declare function setCurrentAuth(token: string, orgId?: string): void; /** * Get the current token, if one has been set. */ export declare function getCurrentToken(): string | null; /** * Create a typed API client with Bearer token + org ID headers. * Uses authenticatedFetch for automatic 401 retry. */ export declare function createApiClient(token: string, orgId?: string): import("openapi-fetch").Client<paths, `${string}/${string}`>; /** * Build auth headers for raw fetch calls (zip upload, SSE streaming, tokens). */ export declare function authHeaders(token: string, orgId?: string): Record<string, string>; /** * Make an authenticated fetch call that auto-refreshes on 401. * Use this instead of raw fetch() for platform API calls. */ export declare function platformFetch(input: string | URL | Request, init?: RequestInit): Promise<Response>; //# sourceMappingURL=client.d.ts.map