import { PolyesterEnvironment } from "./environment.js"; import { CatalogSnapshot, CatalogSnapshotCell, ClientCatalog } from "./catalogs/types.js"; import "./catalogs/index.js"; import { ApiKeyEd25519AuthProvider, AuthAndPublicApiTransports, JwtAuthProvider, Transports } from "./shared/transports.js"; import { SubaccountResolver } from "./services/subaccount-resolver.js"; import { PolyesterRealtime } from "./realtime/types.js"; import { RealtimeConfig } from "./realtime/client.js"; import "./realtime/index.js"; import { SubaccountsService } from "./services/subaccounts/subaccounts.js"; import "./shared/decimal-surface.js"; import { AuthService } from "./services/auth/auth.js"; import { Interceptor } from "@connectrpc/connect"; //#region src/core-client.d.ts type PolyesterRealtimeAuthConfig = Pick; interface PolyesterClientCommonConfig { environment: PolyesterEnvironment; interceptors?: Interceptor[]; auth?: JwtAuthProvider | ApiKeyEd25519AuthProvider; realtime?: PolyesterRealtimeAuthConfig; /** * Connect wire format. Defaults to binary for production performance. * Use `json` for human-readable debugging. */ wireFormat?: "binary" | "json"; /** * Custom fetch implementation for SDK HTTP requests. Defaults to the global * `fetch`, resolved on each request. Ignored when `transports` is * provided. */ fetch?: typeof fetch; /** * Advanced: inject pre-built Connect transports (in-memory mocks, custom * stacks). When provided, the SDK does not build its own transports and the * built-in auth/error-mapping interceptors are NOT applied — the injected * transports own their full interceptor chain. */ transports?: Transports; /** * Advanced: inject a realtime implementation (in-memory mocks, custom * stacks). When provided, the SDK skips constructing its Centrifuge-backed * realtime client and the `realtime` auth config is ignored. */ realtimeClient?: PolyesterRealtime; } type PolyesterCatalogConfig = { /** Client-owned catalog store. */ catalog: ClientCatalog; catalogSnapshot?: never; catalogCell?: never; } | { catalog?: never; /** * Explicit initial catalog snapshot, commonly hydrated from server-rendered data. * Combines with `catalogCell` as the cell's initial value without clobbering a * pre-populated cell. */ catalogSnapshot?: CatalogSnapshot; /** * External snapshot storage for the client-built catalog. A cell backed by a * reactive source makes every catalog read reactive. */ catalogCell?: CatalogSnapshotCell; }; /** Configuration shared by every Polyester client. */ type PolyesterClientBaseConfig = PolyesterClientCommonConfig & PolyesterCatalogConfig; /** Configuration for the base Polyester client. */ type PolyesterClientConfig = PolyesterClientBaseConfig; interface AuthServiceFactoryContext { transports: AuthAndPublicApiTransports; realtime: PolyesterRealtime; environment: PolyesterEnvironment; /** Loads this client's subaccounts service on demand, keeping it out of the core bundle. */ loadSubaccounts: () => Promise; } interface PolyesterClientRuntimeConfig { createAuth?: (context: AuthServiceFactoryContext) => AuthService; } /** * Tree-shakable SDK client core: wires transports, realtime, catalogs, and auth * for a Polyester environment. Other services are reached through their * `@polyester/sdk/services/*` accessors, e.g. `ordersService(core)`, so bundles * only include the services they use. `PolyesterClient` adds a getter for every service. * * Everything is constructed lazily on first access (and memoized) so that creating a * client — which happens for every SSR request in server hooks — stays cheap. */ declare class PolyesterCore { #private; protected readonly transports: Transports; constructor(config: PolyesterClientConfig, runtime?: PolyesterClientRuntimeConfig); get realtime(): PolyesterRealtime; get catalog(): ClientCatalog; get auth(): AuthService; /** * Override in subclasses to provide a subaccount resolver. * The resolver is called lazily when service methods are invoked. */ protected createSubaccountResolver(): SubaccountResolver | undefined; } //#endregion export { PolyesterClientBaseConfig, PolyesterClientConfig, PolyesterCore, PolyesterRealtimeAuthConfig }; //# sourceMappingURL=core-client.d.ts.map