/** * Runtime configuration loading for Rayfin SPAs. * * Instead of baking environment-specific values into the bundle at build time * (via `import.meta.env.VITE_*`), the SPA fetches a `rayfin.config.json` file * at startup. This allows the same compiled bundle to work across all * environments — only the config file changes per stage. * * The file is a deploy-time artifact: `rayfin up` emits it into the static * build so it is bundled and served alongside the app, then removes it from the * working tree afterward. In local development the file is intentionally absent * — `rayfin dev` relies on build-time `VITE_*` values instead — so * `loadRayfinConfig` returns `null` and the SPA falls back to those values. */ /** * Error thrown when runtime configuration loading fails. */ export declare class RayfinConfigError extends Error { readonly code: string; constructor(message: string, code: string); } /** * Runtime configuration shape for a Rayfin SPA. * Loaded from `rayfin.config.json` at startup — contains only * deployment-specific values that change per environment. * Service mode (mock / rayfin / fabric) is controlled separately * via `VITE_SERVICE_MODE` and is not part of this config. */ export interface RayfinConfig { /** Base URL of the Rayfin backend API. */ apiUrl: string; /** Publishable key for service-level authentication. */ publishableKey?: string; /** Fabric workspace ID (present in Fabric deployments). */ workspaceId?: string; /** Fabric item ID (present in Fabric deployments). */ itemId?: string; /** Fabric portal URL (present in Fabric deployments). */ portalUrl?: string; /** Fabric tenant ID (present in Fabric deployments). */ tenantId?: string; } /** * Loads the Rayfin runtime configuration from the well-known config file. * * @param path - Override the config file URL (defaults to `/rayfin.config.json`). * @returns The validated runtime configuration, or `null` if the config is * genuinely absent (HTTP 404, an HTML SPA fallback body, or — in a * non-browser runtime with no explicit `configUrl` — a relative path with * no origin to resolve against). Throws {@link RayfinConfigError} if the * file could not be loaded for any other reason (`CONFIG_LOAD_FAILED`, * e.g. a 5xx or 401/403 response, or a fetch-level failure such as a * network error — these are real failures, not absence, and are not * silently swallowed), or if the file is present but malformed or * incomplete (`CONFIG_PARSE_FAILED`, `CONFIG_INVALID`, `CONFIG_INCOMPLETE`). * * Not part of the public API — {@link resolveRayfinConfig} calls this * internally. Prefer that over calling this directly. */ export declare function loadRayfinConfig(path?: string): Promise; /** * Options controlling how {@link resolveRayfinConfig} fetches remote runtime * configuration. To skip remote loading entirely, don't call it — construct * the client directly from your own values instead. */ export interface ResolveRayfinConfigOptions { /** * Absolute URL to fetch the runtime config from, overriding the default * relative `/rayfin.config.json`. * * The default relative path only resolves in a browser, where `fetch` * implicitly uses the page's document origin. Non-browser runtimes (e.g. * `RayfinServerClient` in Node.js) have no such origin, so omitting * `configUrl` there skips the fetch entirely and falls back to * caller-supplied values, rather than attempting a relative fetch that * would always reject. Pass an absolute `configUrl` (e.g. * `${process.env.RAYFIN_API_URL}/rayfin.config.json`) to enable remote * config loading outside the browser — once set (or in the browser, where * a fetch is always attempted), a fetch failure (unreachable host, * DNS/TLS error, offline, etc.) throws {@link RayfinConfigError} * (`CONFIG_LOAD_FAILED`) rather than silently falling back, since it's a * real failure, not evidence of absence. */ configUrl?: string; } /** * All `rayfin.config.json` values as a single optional-field bag — every * field is optional because neither the remote config nor a caller-supplied * set of defaults is guaranteed to provide it. Used both as the defaults * shape (typically build-time `VITE_*` values) and as the resolved shape * returned by {@link resolveRayfinConfig}. */ export interface RayfinRuntimeConfig { /** Base URL of the Rayfin backend API. */ apiUrl?: string; /** Publishable key for service-level authentication. */ publishableKey?: string; /** Fabric workspace ID (present in Fabric deployments). */ workspaceId?: string; /** Fabric item ID (present in Fabric deployments). */ itemId?: string; /** Fabric portal URL (present in Fabric deployments). */ portalUrl?: string; /** Fabric tenant ID (present in Fabric deployments). */ tenantId?: string; } /** * Resolves the config a `RayfinClient` / `RayfinServerClient` should be * constructed with: loads the remote `rayfin.config.json` (unless the caller * skips calling this function entirely), overlays it over the supplied * `defaults` per-field, and returns the merged `baseUrl` / `publishableKey` / * `runtimeConfig`. Construction itself is a plain, synchronous * `new RayfinClient(...)` call — this function only resolves values. * * @example * ```typescript * import { RayfinClient, resolveRayfinConfig } from '@microsoft/rayfin-client'; * * const resolved = await resolveRayfinConfig({ baseUrl, publishableKey }); * const client = new RayfinClient({ ...resolved, authStorage: true }); * ``` */ export declare function resolveRayfinConfig(defaults: Pick & Partial, options?: ResolveRayfinConfigOptions): Promise<{ baseUrl?: string; publishableKey?: string; runtimeConfig: RayfinRuntimeConfig; }>; //# sourceMappingURL=config.d.ts.map