@microsoft/rayfin-lib
The shared ApiClient, error classes, and small utilities every other Rayfin SDK package builds on — an internal dependency most builders never import directly.
@microsoft/rayfin-lib is the shared HTTP client and utility layer underneath every other
@microsoft/rayfin-* SDK package —
rayfin-core,
rayfin-data,
rayfin-auth,
rayfin-auth-provider-fabric, and
rayfin-functions all depend on it. Most Rayfin
applications never import it directly — you get its exports re-exported through
@microsoft/rayfin-client (ApiClientConfig, the error classes) — but it's useful to know
what lives here when you're reading a stack trace or building against the SDK at a lower
level.
Installation
npm install @microsoft/rayfin-libApiClient
The isomorphic HTTP client every higher-level SDK class wraps. It works in both browsers
and Node.js using native fetch, with automatic 401 retry when a refresh callback is
configured.
class ApiClient {
constructor(config: ApiClientConfig);
setAccessTokenCallback(callback: () => string | null): void;
setRefreshCallback(callback: () => Promise<void>): void;
get<T>(path: string, options?: RequestOptions): Promise<T>;
post<T>(path: string, data?: any, options?: RequestOptions): Promise<T>;
put<T>(path: string, data?: any, options?: RequestOptions): Promise<T>;
delete<T>(path: string, options?: RequestOptions): Promise<T>;
requestRaw(path: string, options?: RequestRawOptions): Promise<Response>;
}
interface ApiClientConfig {
baseUrl: string;
publishableKey: string;
headers?: Record<string, string>;
timeout?: number;
getAccessToken?: () => string | null;
useProxy?: boolean;
onRefreshNeeded?: () => Promise<void>;
}See @microsoft/rayfin-client for
the option table — RayfinClientConfig and RayfinServerClientConfig both extend
ApiClientConfig. setAccessTokenCallback and setRefreshCallback are how Auth attaches
itself to an ApiClient after construction (Auth.attachToClient()), which is also how
@microsoft/rayfin-auth-provider-fabric gets its token-refresh behavior for free.
Errors
Every SDK package's thrown errors extend this hierarchy:
class SdkError extends Error {
name: string;
code?: string;
constructor(message: string, code?: string);
}
class AuthError extends SdkError {}
class NetworkError extends SdkError {
status?: number;
constructor(message: string, status?: number, code?: string);
}@microsoft/rayfin-client declares its own AuthError extends SdkError rather than
re-exporting this one — the two classes are structurally identical but distinct; an
instanceof check needs the AuthError from whichever package actually threw it. See
Errors on the client reference page.
Small utilities
Two narrowly-scoped helpers are exported from the package root, used internally by the data client and storage tooling:
function normalizeContainerName(input: string): string;
class EntityNameResolver {
static getPlural(entityName: string): string;
static getSingular(pluralName: string): string;
static isPlural(word: string): boolean;
static setCustomPlural(singular: string, plural: string): void;
static clearCustomPlurals(): void;
}normalizeContainerName lowercases and hyphenates a string to satisfy Azure Blob container
naming rules (letters, numbers, and hyphens only; 3–63 characters). EntityNameResolver
backs the automatic singular/plural table-name inference @microsoft/rayfin-core performs
for @entity() classes (a Todo class maps to a todos table), and lets you register
irregular plurals it wouldn't guess correctly on its own.
What's intentionally not documented here
ServicePlugin (an abstract base class for building custom service plugins) is exported
from the package but marked @alpha and @hidden in its own source comments — it is not
considered part of the public API yet, so this page does not document its shape.
@microsoft/rayfin-connector-kusto
Marker, runtime, config, raw response, and normalization APIs for Fabric KQL Database connectors.
Rules for coding agents
The condensed set of rules and anti-patterns for writing Rayfin code — read this before generating entities, queries, permissions, or deployment commands.