import { RebaseClientConfig } from "./transport"; import { createAuth, CreateAuthOptions } from "./auth"; import { createAdmin, CreateAdminOptions } from "./admin"; import { createCron, CreateCronOptions } from "./cron"; import { createBackups } from "./backups"; import { createApiKeys, CreateApiKeysOptions } from "./api-keys"; import { CollectionClient } from "./collection"; import { createFunctionsClient } from "./functions"; import { RebaseWebSocketClient } from "./websocket"; import { RebaseRealtimeChannel, type ChannelOptions } from "./realtime-channel"; import { type OfflineApi, type OfflineConfig } from "./offline"; import { InsertOf, RebaseClient, RebaseSdkData, RowOf, StorageSource, StorageSourceDefinition, StorageSourceRegistry, UpdateOf } from "@rebasepro/types"; export { RebaseApiError } from "./transport"; export { RebaseClientError } from "./errors"; export type { RebaseErrorCode } from "@rebasepro/types"; export type { RebaseClientConfig, FindParams, FindResponse } from "./transport"; export type { CollectionClient } from "./collection"; export type { FindResult, SDKCollectionClient, SDKQueryBuilderInterface, PaginationMeta } from "@rebasepro/types"; export type { IterateParams, FindAllParams, PageWalkOptions, CursorSpec } from "@rebasepro/types"; export { RebasePaginationError } from "@rebasepro/common"; export type { PaginationErrorCode } from "@rebasepro/common"; export { QueryBuilder, or, and, cond } from "@rebasepro/common"; export { createCookieStorage, createMemoryStorage } from "./auth"; export type { AuthConfig, AuthStorage, CookieStorageOptions, CreateAuthOptions } from "./auth"; export type { User, RebaseSession, AuthTokens, AuthChangeEvent, DeviceSession } from "@rebasepro/types"; export type { CreateAdminOptions } from "./admin"; export type { AdminUser } from "./admin"; export type { CreateCronOptions } from "./cron"; export { createBackups } from "./backups"; export type { CreateBackupsOptions } from "./backups"; export type { ApiKeyMasked, ApiKeyPermission, ApiKeyWithSecret, CreateApiKeyRequest, CreateApiKeysOptions, UpdateApiKeyRequest } from "./api-keys"; export type { FunctionInvokeOptions, FunctionsClient } from "./functions"; export { RebaseWebSocketClient } from "./websocket"; export { RebaseRealtimeChannel } from "./realtime-channel"; export type { PresenceState, PresenceDiff, BroadcastEvent, ChannelTransport, ChannelOptions, ChannelHistoryEntry, ChannelHistoryResult } from "./realtime-channel"; export type { OfflineApi, OfflineConfig, OfflineStatus } from "./offline"; export { isOfflineError } from "./offline"; export type { LiveResult, ObserveOptions, RowSnapshotMeta } from "./collection"; export type { OfflineStore, OfflineCacheEntry, OfflineCacheRecord, PendingMutation, MutationRollback } from "./offline-store"; export { MemoryOfflineStore } from "./offline-store"; export interface CreateRebaseClientOptions extends RebaseClientConfig { auth?: CreateAuthOptions; admin?: CreateAdminOptions; cron?: CreateCronOptions; apiKeys?: CreateApiKeysOptions; /** * Declared storage sources for multi-backend support. Server-transport * entries are auto-wired into `client.storageRegistry`; `direct` sources * are registered app-side (e.g. via a Firebase Storage hook). The default * source (`storage`) is always registered under * {@link DEFAULT_STORAGE_SOURCE_KEY}. */ storageSources?: StorageSourceDefinition[]; /** * Maps camelCase property names / safe identifiers to the actual * collection slugs on the server (e.g. `{ companyMembers: "company-members" }`). * If provided, the data layer proxy will resolve property accessors to their * correct slugs via this map before falling back to automatic snake_casing. */ collections?: Record; /** * Local-first sync for the data layer. * * `true` enables it with defaults: reads populate a local row database and * fall back to it (evaluating filters and sorts locally) when the network * is gone, writes made offline apply immediately and replay in order when * it returns, and `observe()` becomes a live query that emits from the * local database first. A rejected write is rolled back. Pass an * {@link OfflineConfig} to control the store, cache sizes, retry backoff, * or rejection handling. * * Local rows and queued writes are partitioned per signed-in user, and * shared across tabs. Off by default. */ offline?: boolean | OfflineConfig; } type KebabToCamelCase = S extends `${infer T}-${infer U}` ? `${T}${Capitalize>}` : S; type DBEntry = KebabToCamelCase extends keyof DB ? DB[KebabToCamelCase] : unknown; type TypedDataLayer = { collection(slug: S): CollectionClient>, InsertOf>, UpdateOf>>; } & { [K in keyof DB]: CollectionClient, InsertOf, UpdateOf>; } & RebaseSdkData; /** * The return type of `createRebaseClient()`. * * This is `RebaseClient` (from `@rebasepro/types`) with all optional * capabilities populated and the `data` layer narrowed to provide * typed collection accessors when a `DB` schema generic is supplied. */ export type CreateRebaseClientResult> = Omit, "data" | "email"> & { setToken: (token: string | null) => void; setAuthTokenGetter: (getter: () => Promise) => void; setOnUnauthorized: (handler: () => Promise) => void; resolveToken: () => Promise; auth: ReturnType; admin: ReturnType; cron: ReturnType; backups: ReturnType; apiKeys: ReturnType; functions: ReturnType; ws?: RebaseWebSocketClient; /** * Broadcast and presence channels. * * Was missing from this type while present on the returned object, which * made `client.realtime.channel(...)` a type error and forced every adopter * to cast around the feature before they could reach it. */ realtime: { /** * Join a broadcast/presence channel. Repeated calls with the same name * return the same channel object. Throws only when the client was * created with `realtime: false`. * * Pass `{ history: true }` to have the channel replay what it missed on * join and on every reconnect, for channels the server retains. */ channel: (name: string, options?: ChannelOptions) => RebaseRealtimeChannel; }; /** * Release everything this client holds that can keep a process alive: the * realtime socket and its reconnect timer, channel presence heartbeats, the * offline manager, and the scheduled token refresh. * * Each of those keeps the Node event loop alive on its own, so a script * that does not call this will not exit — and, until the refresh timer was * included, one that *did* call it still would not if it had signed in. * * Safe when realtime was never started (`realtime: false`), safe when * signed out, and safe to call twice. It does not sign the user out: a * persisted session survives for the next client to restore. */ close: () => void; storage: StorageSource; storageRegistry: StorageSourceRegistry; createStorageSource: (storageId: string) => StorageSource; fetchStorageSources: () => Promise; call: (endpoint: string, payload?: unknown) => Promise; collection: = Record>(slug: string) => CollectionClient; data: TypedDataLayer; /** Present only when the client was created with `offline` enabled. */ offline?: OfflineApi; }; export declare function createRebaseClient>(options: CreateRebaseClientOptions): CreateRebaseClientResult;