@rebasepro/client 0.24.0 → 0.24.1-canary.gcb918fc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -34,22 +34,37 @@ of it resolves too: Node has supported `require(esm)` since 22.12.
34
34
  |---|---|
35
35
  | `createRebaseClient<DB>(options)` | Create a client instance. Generic `DB` parameter enables type-safe `client.data.*` access. |
36
36
  | `CreateRebaseClientResult<DB>` | The client type it returns (`RebaseClient<DB>` from `@rebasepro/types`, narrowed) — includes `auth`, `admin`, `cron`, `functions`, `storage`, `ws`, `data`, `call`, and token management methods. |
37
- | `CreateRebaseClientOptions` | Extends `RebaseClientConfig` with `auth`, `admin`, and `cron` sub-configs. |
37
+ | `CreateRebaseClientOptions` | Extends `RebaseClientConfig` with the `auth`, `admin`, `cron`, `apiKeys` and `personalKeys` sub-configs, plus `storageSources`, `collections` and `offline`. |
38
38
 
39
39
  ### Config
40
40
 
41
41
  | Option | Type | Default | Description |
42
42
  |---|---|---|---|
43
43
  | `baseUrl` | `string` | `""` | Backend URL (e.g. `http://localhost:3001`) |
44
- | `token` | `string` | — | Static auth token |
44
+ | `token` | `string` | — | Auth token, read each time one is needed (so it may be declared as a getter) until `setToken()` or a sign-in replaces it |
45
45
  | `apiPath` | `string` | `"/api"` | API path prefix |
46
46
  | `fetch` | `typeof fetch` | `globalThis.fetch` | Custom fetch implementation |
47
- | `onUnauthorized` | `() => Promise<boolean>` | auto-refresh | Handler for 401 responses |
47
+ | `onUnauthorized` | `() => Promise<boolean>` | auto-refresh | Handler for a refused token, over HTTP (401) and on the realtime socket |
48
48
  | `websocketUrl` | `string` | derived from `baseUrl` | WebSocket URL for realtime |
49
49
  | `realtime` | `boolean` | `true` | Open the WebSocket — `false` lets a one-shot script exit |
50
50
  | `collections` | `Record<string, string>` | — | Maps accessor names to collection slugs |
51
51
  | `offline` | `boolean \| OfflineConfig` | `false` | Local-first sync — see [the docs](https://rebase.pro/docs/sdk/offline) |
52
52
 
53
+ ### Tokens
54
+
55
+ | Method | Description |
56
+ |---|---|
57
+ | `setAuthTokenGetter(getter)` | Ask `getter` for the token each time one is needed: every HTTP request and every time the realtime socket authenticates. This is how a host signing users in with its own provider (Clerk, Firebase Auth, its own session) authenticates the client. It comes before the client's own session and the `token` option |
58
+ | `setToken(token)` | Send this token from now on, over HTTP and on the socket |
59
+ | `setOnUnauthorized(handler)` | Answer a refused token, on HTTP and the socket; resolve `true` to retry |
60
+ | `resolveToken()` | The token the next request would carry |
61
+
62
+ Installing a getter or calling `setToken()` rebuilds an open socket so it authenticates as the new credential. `client.ws.setAuthTokenGetter()` is deprecated: it still works, warns once, and reaches only the socket.
63
+
64
+ ```ts
65
+ client.setAuthTokenGetter(() => clerk.session?.getToken() ?? Promise.resolve(null));
66
+ ```
67
+
53
68
  ### Collection Client
54
69
 
55
70
  `client.data.collection("slug")` or `client.data.myCollection` returns a `CollectionClient<M>`:
@@ -62,11 +77,11 @@ of it resolves too: Node has supported `require(esm)` since 22.12.
62
77
  | `update(id, data)` | Update a row. Returns `M` |
63
78
  | `delete(id)` | Delete a row |
64
79
  | `count(params?)` | Count matching rows |
65
- | `where(col, op, val)` | Start a fluent query — returns `QueryBuilder` |
66
- | `orderBy(col, dir?)` | Order results — returns `QueryBuilder` |
67
- | `limit(n)` / `offset(n)` | Pagination — returns `QueryBuilder` |
68
- | `search(str)` | Full-text search — returns `QueryBuilder` |
69
- | `include(...rels)` | Include related rows — returns `QueryBuilder` |
80
+ | `where(col, op, val)` | Start a fluent query — returns a query builder |
81
+ | `orderBy(col, dir?)` | Order results — returns a query builder |
82
+ | `limit(n)` / `offset(n)` | Pagination — returns a query builder |
83
+ | `search(str)` | Text search: a case-insensitive substring match by default, ranked full-text where the collection opts in — returns a query builder |
84
+ | `include(...rels)` | Include related rows — returns a query builder |
70
85
  | `listen(params, onUpdate, onError?)` | Realtime subscription (requires WebSocket) |
71
86
  | `listenById(id, onUpdate, onError?)` | Realtime single-row subscription |
72
87
  | `observe(params, onResult, onError?, options?)` | Live query — local-first when `offline` is on, otherwise fetch + `listen` |
@@ -107,7 +122,7 @@ of it resolves too: Node has supported `require(esm)` since 22.12.
107
122
 
108
123
  | Method | Description |
109
124
  |---|---|
110
- | `listUsers()` / `listUsersPaginated(options?)` | List all users |
125
+ | `listUsers(options?)` / `listUsersPaginated(options?)` | One page of users (25 by default; `limit`, `offset`, `search`, `orderBy`, `orderDir`) with `total` |
111
126
  | `getUser(userId)` | Get a single user |
112
127
  | `createUser(data)` | Create a user |
113
128
  | `updateUser(userId, data)` | Update a user |
@@ -130,7 +145,7 @@ of it resolves too: Node has supported `require(esm)` since 22.12.
130
145
  | `MemoryOfflineStore` | Reference `OfflineStore`; the IndexedDB one is wired automatically |
131
146
  | `createCookieStorage(options?)` | Cookie-based auth storage adapter |
132
147
  | `createMemoryStorage()` | In-memory auth storage adapter |
133
- | `QueryBuilder` | Fluent query builder (also re-exported from `@rebasepro/common`) |
148
+ | `or`, `and`, `not`, `cond` | Logical-condition helpers for `.where(…)` |
134
149
  | `FindResult`, `FindParams`, `User`, … | Re-exported from `@rebasepro/types` |
135
150
 
136
151
  ## Quick Start
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Compile-time assertions about the admin client's answers.
3
+ *
4
+ * A plain module under `src`, imported by nothing, for the reason
5
+ * `query-contract.types.ts` gives: a type assertion in a jest test is checked
6
+ * by nothing here, and `pnpm typecheck` reads `src`.
7
+ */
8
+ import type { createAdmin } from "./admin.js";
9
+ type Admin = ReturnType<typeof createAdmin>;
10
+ /**
11
+ * `POST /admin/users` answers `{ user, invitationSent, temporaryPassword?,
12
+ * emailDeliveryFailed? }`, and the temporary password is returned exactly
13
+ * once. Typed `{ user }`, it was a compile error to read — while the sibling
14
+ * `resetPassword` typed the same three fields.
15
+ */
16
+ export declare const createUserDelivery: (admin: Admin) => Promise<{
17
+ temporaryPassword: string | undefined;
18
+ invitationSent: boolean | undefined;
19
+ emailDeliveryFailed: boolean | undefined;
20
+ }>;
21
+ export {};
package/dist/admin.d.ts CHANGED
@@ -33,8 +33,12 @@ export declare function createAdmin(transport: Transport, options?: CreateAdminO
33
33
  displayName?: string;
34
34
  password?: string;
35
35
  roles?: string[];
36
+ skipPasswordPolicy?: boolean;
36
37
  }) => Promise<{
37
38
  user: AdminUser;
39
+ temporaryPassword?: string;
40
+ invitationSent?: boolean;
41
+ emailDeliveryFailed?: boolean;
38
42
  }>;
39
43
  updateUser: (userId: string, data: {
40
44
  email?: string;
package/dist/auth.d.ts CHANGED
@@ -197,10 +197,6 @@ export declare function createAuth(transport: Transport, options?: CreateAuthOpt
197
197
  verified: boolean;
198
198
  createdAt: string;
199
199
  }[]>;
200
- /**
201
- * Remove a factor. Requires an `aal2` session — one that has already
202
- * answered a challenge — so a stolen `aal1` token cannot turn MFA off.
203
- */
204
200
  /**
205
201
  * Replace the account's recovery codes with ten new ones, shown once.
206
202
  * Needs an `aal2` session. Adding a second factor keeps the codes the
@@ -209,6 +205,12 @@ export declare function createAuth(transport: Transport, options?: CreateAuthOpt
209
205
  regenerateRecoveryCodes(): Promise<{
210
206
  recoveryCodes: string[];
211
207
  }>;
208
+ /**
209
+ * Remove a factor. Once the account has a verified factor this
210
+ * requires an `aal2` session — one that has already answered a
211
+ * challenge — so a stolen `aal1` token cannot turn MFA off. An
212
+ * unfinished first enrolment can be removed from any session.
213
+ */
212
214
  unenroll(factorId: string): Promise<{
213
215
  success: boolean;
214
216
  message: string;
@@ -325,7 +327,27 @@ export declare function createAuth(transport: Transport, options?: CreateAuthOpt
325
327
  onAuthStateChange: (callback: (event: AuthChangeEvent, session: RebaseSession | null) => void) => () => boolean;
326
328
  canRestoreSession: () => boolean;
327
329
  isInitialized: () => Promise<void>;
330
+ /**
331
+ * How restoring the session on load ended — see
332
+ * {@link SessionRestoreOutcome}. `"unreachable"` with no session is
333
+ * the one case where "signed out" is not known to be true: the
334
+ * device could not ask.
335
+ */
336
+ restoreOutcome: () => SessionRestoreOutcome;
328
337
  };
338
+ /**
339
+ * How restoring the session on load ended — `auth.restoreOutcome()`.
340
+ *
341
+ * - `"pending"`: still restoring (`isInitialized()` has not settled).
342
+ * - `"restored"`: a session was restored, from storage or from the server.
343
+ * - `"none"`: there was nothing to restore.
344
+ * - `"refused"`: there was a session to restore, and the server refused it.
345
+ * - `"unreachable"`: the server could not be reached (or answered 5xx), so the
346
+ * session was neither confirmed nor refused. With a stored session the
347
+ * client keeps it and retries; in cookie mode, where nothing is stored on the
348
+ * device, it has no session until a later refresh or sign-in succeeds.
349
+ */
350
+ export type SessionRestoreOutcome = "pending" | "restored" | "none" | "refused" | "unreachable";
329
351
  export interface CookieStorageOptions {
330
352
  path?: string;
331
353
  domain?: string;
package/dist/backups.d.ts CHANGED
@@ -1,9 +1,20 @@
1
1
  import { Transport } from "./transport.js";
2
- import { type BackupListing } from "@rebasepro/types";
2
+ import { type BackupDownloadLink, type BackupListing } from "@rebasepro/types";
3
3
  export interface CreateBackupsOptions {
4
4
  backupsPath?: string;
5
5
  }
6
+ /** One backup's bytes, as {@link createBackups}' `stream()` answers them. */
7
+ export interface BackupStream {
8
+ /** The dump, read from the server as it is consumed. */
9
+ stream: ReadableStream<Uint8Array>;
10
+ /** Its size in bytes, when the server said. */
11
+ size?: number;
12
+ /** Its file name: the key's last segment, as the server names the download. */
13
+ name: string;
14
+ }
6
15
  export declare function createBackups(transport: Transport, options?: CreateBackupsOptions): {
7
16
  list: () => Promise<BackupListing>;
8
- download: (key: string) => Promise<Blob>;
17
+ download: (key: string) => Promise<void>;
18
+ downloadUrl: (key: string) => Promise<BackupDownloadLink>;
19
+ stream: (key: string) => Promise<BackupStream>;
9
20
  };
@@ -1,22 +1,14 @@
1
1
  import { FindParams, Transport } from "./transport.js";
2
2
  import { RebaseWebSocketClient } from "./websocket.js";
3
- import { FindResult, SDKCollectionClient, type IncludeSpec } from "@rebasepro/types";
3
+ import { FindResult, SDKCollectionClient, type ByIdReadOptions, type IncludeSpec, type RestoreOptions, type TrashClient, RebaseClientError } from "@rebasepro/types";
4
+ import { etagOf } from "@rebasepro/common";
4
5
  /**
5
- * The version of a row, when it came straight from a read that reported one.
6
- *
7
- * ```ts
8
- * const post = await client.data.posts.get(1);
9
- * await client.data.posts.update(1, { title: "New" }, { ifMatch: etagOf(post) });
10
- * ```
11
- *
12
- * `undefined` for a row from `find()` (a list response carries one ETag at
13
- * most, and it would not be this row's), from the offline cache, or from a
14
- * server that does not send them. Passing `undefined` as `ifMatch` sends no
15
- * precondition, so the call above degrades to an ordinary update rather than
16
- * failing — which is the right default, and the reason to read this at the call
17
- * site where the choice is visible.
6
+ * A bulk call given something other than an array. A `RebaseClientError` with
7
+ * the code the server uses for the same mistake in a request body, so one
8
+ * `case "INVALID_BULK_BODY"` covers both.
18
9
  */
19
- export declare function etagOf(row: unknown): string | undefined;
10
+ export declare function invalidBulkBody(message: string): RebaseClientError;
11
+ export { etagOf };
20
12
  /**
21
13
  * A live query result: a normal {@link FindResult} plus what an interface
22
14
  * needs to decide whether to show a "saving…" or "offline" affordance over it.
@@ -51,6 +43,25 @@ export interface ObserveOptions {
51
43
  */
52
44
  realtime?: boolean;
53
45
  }
46
+ /**
47
+ * Options for `observeById`: {@link ObserveOptions}, plus the relations to load
48
+ * into the row. `include` reaches both of its reads — the one-shot
49
+ * `findById` and the `listenById` subscription — so every emission carries
50
+ * the same relations.
51
+ */
52
+ export interface ObserveByIdOptions<Inc = IncludeSpec> extends ObserveOptions, ByIdReadOptions<Inc> {
53
+ }
54
+ /**
55
+ * {@link TrashClient} and {@link RestoreOptions} are the transport-agnostic
56
+ * contract in `@rebasepro/types`. On this client every call goes to the
57
+ * server. With `offline` enabled the trash is not cached and nothing in it is
58
+ * queued: the local database never holds a trashed row, so it cannot answer
59
+ * for one, and a restore or a purge made offline would act on a row this
60
+ * device cannot see. They reject with `OFFLINE` instead (see
61
+ * `isOfflineError`). A restored row joins the local database; a purged one
62
+ * leaves it.
63
+ */
64
+ export type { RestoreOptions, TrashClient };
54
65
  /**
55
66
  * The concrete, HTTP-backed implementation of the public
56
67
  * {@link SDKCollectionClient} contract — flat rows (no Entity wrapper), plus
@@ -63,6 +74,11 @@ export interface ObserveOptions {
63
74
  */
64
75
  export interface CollectionClient<M extends Record<string, unknown> = Record<string, unknown>, I = Partial<M>, U = Partial<M>, Inc = IncludeSpec> extends SDKCollectionClient<M, I, U, Inc> {
65
76
  count(params?: FindParams<M, Inc>): Promise<number>;
77
+ /**
78
+ * The collection's trash: list, count, restore and purge the rows a soft
79
+ * delete stamped. See {@link TrashClient}.
80
+ */
81
+ trash: TrashClient<M, Inc>;
66
82
  /**
67
83
  * Subscribe to a query's results.
68
84
  *
@@ -80,6 +96,11 @@ export interface CollectionClient<M extends Record<string, unknown> = Record<str
80
96
  */
81
97
  observe(params: FindParams<M, Inc> | undefined, onResult: (result: LiveResult<M>) => void, onError?: (error: Error) => void, options?: ObserveOptions): () => void;
82
98
  /** {@link CollectionClient.observe} for a single row. */
83
- observeById(id: string | number, onResult: (row: M | undefined, meta: RowSnapshotMeta) => void, onError?: (error: Error) => void, options?: ObserveOptions): () => void;
99
+ observeById(id: string | number, onResult: (row: M | undefined, meta: RowSnapshotMeta) => void, onError?: (error: Error) => void, options?: ObserveByIdOptions<Inc>): () => void;
84
100
  }
101
+ /**
102
+ * The part of {@link ObserveByIdOptions} that is a read option: `include`, and
103
+ * nothing else, so `realtime` never travels as a query parameter.
104
+ */
105
+ export declare function byIdRead<Inc>(options: ObserveByIdOptions<Inc> | undefined): ByIdReadOptions<Inc> | undefined;
85
106
  export declare function createCollectionClient<M extends Record<string, unknown> = Record<string, unknown>>(transport: Transport, slug: string, ws?: RebaseWebSocketClient): CollectionClient<M>;
package/dist/cron.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Transport } from "./transport.js";
2
- import type { CronJobStatus, CronJobLogEntry, CronJobListing } from "@rebasepro/types";
2
+ import type { CronJobStatus, CronJobLogEntry, CronJobListing, CronJobStarted } from "@rebasepro/types";
3
3
  export interface CreateCronOptions {
4
4
  cronPath?: string;
5
5
  }
@@ -8,10 +8,17 @@ export declare function createCron(transport: Transport, options?: CreateCronOpt
8
8
  getJob: (jobId: string) => Promise<{
9
9
  job: CronJobStatus;
10
10
  }>;
11
- triggerJob: (jobId: string) => Promise<{
12
- log: CronJobLogEntry;
13
- job: CronJobStatus;
14
- }>;
11
+ triggerJob: {
12
+ (jobId: string, options?: {
13
+ async?: false;
14
+ }): Promise<{
15
+ log: CronJobLogEntry;
16
+ job: CronJobStatus;
17
+ }>;
18
+ (jobId: string, options: {
19
+ async: true;
20
+ }): Promise<CronJobStarted>;
21
+ };
15
22
  getJobLogs: (jobId: string, options?: {
16
23
  limit?: number;
17
24
  }) => Promise<{
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Compile-time assertion that a consumer can name, from `@rebasepro/client`
3
+ * alone, the types its own calls are written in.
4
+ *
5
+ * A plain module under `src`, imported by nothing, for the reason
6
+ * `query-contract.types.ts` gives: `pnpm typecheck` reads `src`, and a type
7
+ * assertion in a jest test is checked by nothing. A browser app installs this
8
+ * package only, so an argument type missing from the barrel is one it has to
9
+ * spell out by hand or reach into a package it never installed.
10
+ */
11
+ import type { AggregateMeta, AggregateParams, AggregateResult, AggregateRow, AggregateSelect, FieldPath, FilterCondition, FilterConditionFor, FilterValues, IncludeOptions, IncludeSpec, InsertOf, LogicalCondition, LogicalConditionFor, OrderBySpec, QueryComputedFields, RestoreOptions, RowOf, StorageSource, TrashClient, UpdateOf, WhereConditionFor, WhereFilterOp, WhereFor, WhereValueFor, WriteOptions } from "./index.js";
12
+ export type ConsumerCanName = [
13
+ AggregateMeta,
14
+ AggregateParams,
15
+ AggregateResult,
16
+ AggregateRow,
17
+ AggregateSelect,
18
+ FieldPath,
19
+ FilterCondition,
20
+ FilterValues<string>,
21
+ IncludeOptions,
22
+ IncludeSpec,
23
+ InsertOf<Record<string, unknown>>,
24
+ LogicalCondition,
25
+ OrderBySpec,
26
+ FilterConditionFor<Record<string, unknown>>,
27
+ LogicalConditionFor<Record<string, unknown>>,
28
+ QueryComputedFields,
29
+ RowOf<Record<string, unknown>>,
30
+ StorageSource,
31
+ UpdateOf<Record<string, unknown>>,
32
+ WhereConditionFor<string>,
33
+ WhereFilterOp,
34
+ WhereFor<Record<string, unknown>>,
35
+ WhereValueFor<"==", string>,
36
+ WriteOptions,
37
+ RestoreOptions,
38
+ TrashClient
39
+ ];
@@ -28,21 +28,11 @@ export interface FunctionsClient {
28
28
  * One path segment: a sub-path goes in `options.path`.
29
29
  * @param payload - Optional JSON-serialisable body. Dropped for `GET`.
30
30
  * @param options - Optional overrides (HTTP method, sub-path, extra headers).
31
- * @returns The parsed JSON response from the function.
31
+ * @returns The parsed JSON response from the function, or — with
32
+ * `options.responseType` — its text, a `Blob`, or the raw `Response`.
32
33
  */
33
34
  invoke<T = unknown>(name: string, payload?: unknown, options?: FunctionInvokeOptions): Promise<T>;
34
35
  }
35
36
  export type { FunctionInvokeOptions } from "@rebasepro/types";
36
37
  import type { FunctionInvokeOptions } from "@rebasepro/types";
37
- /**
38
- * Create a `FunctionsClient` backed by the given transport.
39
- *
40
- * The transport already handles:
41
- * - Base URL resolution
42
- * - JWT injection via `Authorization: Bearer`
43
- * - 401 retry / `onUnauthorized` flow
44
- * - Consistent error throwing via `RebaseApiError`
45
- *
46
- * @internal
47
- */
48
38
  export declare function createFunctionsClient(transport: Transport): FunctionsClient;
package/dist/index.d.ts CHANGED
@@ -8,38 +8,38 @@ import { CollectionClient } from "./collection.js";
8
8
  import { createFunctionsClient } from "./functions.js";
9
9
  import { RebaseWebSocketClient } from "./websocket.js";
10
10
  import { RebaseRealtimeChannel, type ChannelOptions } from "./realtime-channel.js";
11
- import { type OfflineApi, type OfflineConfig } from "./offline.js";
11
+ import type { OfflineApi, OfflineConfig } from "./offline.js";
12
12
  import { type BatchOperation, type BatchResult, type IncludeOf, InsertOf, RebaseClient, RebaseSdkData, RowOf, StorageSource, StorageSourceDefinition, StorageSourceRegistry, UpdateOf, type WriteOptions } from "@rebasepro/types";
13
13
  export { RebaseApiError } from "./transport.js";
14
14
  export { RebaseClientError } from "./errors.js";
15
15
  export type { RebaseErrorCode } from "@rebasepro/types";
16
16
  export type { RebaseClientConfig, FindParams, FindResponse } from "./transport.js";
17
- export type { CollectionClient } from "./collection.js";
17
+ export type { CollectionClient, RestoreOptions, TrashClient } from "./collection.js";
18
18
  export type { FindResult, SDKCollectionClient, SDKQueryBuilderInterface, PaginationMeta } from "@rebasepro/types";
19
19
  export type { IterateParams, FindAllParams, PageWalkOptions, CursorSpec } from "@rebasepro/types";
20
20
  export { RebasePaginationError } from "@rebasepro/common";
21
21
  export type { PaginationErrorCode } from "@rebasepro/common";
22
- export { QueryBuilder, or, and, not, cond } from "@rebasepro/common";
23
- export { resolveStorageReferences, storageReference, parseStorageReference, isStorageReference, STORAGE_REFERENCE_SCHEME } from "@rebasepro/types";
22
+ export { or, and, not, cond } from "@rebasepro/common";
23
+ export { resolveStorageReferences, storageReference, parseStorageReference, isStorageReference, STORAGE_REFERENCE_SCHEME, storageTargetOfDownloadUrl, storageReferencesForDownloadUrls, storageTargetsInText } from "@rebasepro/types";
24
24
  export type { StorageReferenceTarget, StorageReferenceResolver } from "@rebasepro/types";
25
25
  export { createCookieStorage, createMemoryStorage } from "./auth.js";
26
- export type { AuthConfig, AuthStorage, CookieStorageOptions, CreateAuthOptions } from "./auth.js";
26
+ export type { AuthConfig, AuthStorage, CookieStorageOptions, CreateAuthOptions, SessionRestoreOutcome } from "./auth.js";
27
27
  export type { User, RebaseSession, AuthTokens, AuthChangeEvent, DeviceSession } from "@rebasepro/types";
28
28
  export type { CreateAdminOptions, ListUsersOptions } from "./admin.js";
29
29
  export type { AdminUser } from "./admin.js";
30
30
  export type { CreateCronOptions } from "./cron.js";
31
- export { createBackups } from "./backups.js";
32
- export type { CreateBackupsOptions } from "./backups.js";
31
+ export type { BackupStream } from "./backups.js";
33
32
  export type { ApiKeyKind, ApiKeyMasked, ApiKeyWithSecret, CreateApiKeyRequest, CreateApiKeysOptions, CreatePersonalKeyRequest, CreatePersonalKeysOptions, UpdateApiKeyRequest } from "./api-keys.js";
34
33
  export type { FunctionInvokeOptions, FunctionsClient } from "./functions.js";
35
34
  export { RebaseWebSocketClient } from "./websocket.js";
36
35
  export { RebaseRealtimeChannel } from "./realtime-channel.js";
37
36
  export type { PresenceState, PresenceDiff, BroadcastEvent, ChannelTransport, ChannelOptions, ChannelHistoryEntry, ChannelHistoryResult } from "./realtime-channel.js";
38
- export type { OfflineApi, OfflineConfig, OfflineQueueOptions, OfflineStatus } from "./offline.js";
39
- export { isOfflineError } from "./offline.js";
40
- export type { LiveResult, ObserveOptions, RowSnapshotMeta } from "./collection.js";
37
+ export type { ConflictResolution, OfflineApi, OfflineConfig, OfflineQueueOptions, OfflineStatus } from "./offline.js";
38
+ export { isOfflineError } from "./offline-errors.js";
39
+ export type { LiveResult, ObserveByIdOptions, ObserveOptions, RowSnapshotMeta } from "./collection.js";
41
40
  export { etagOf } from "./collection.js";
42
41
  export type { BatchOperation, BatchRef, BatchResult, FieldOperation, UpdateValues, UpsertOptions } from "@rebasepro/types";
42
+ export type { WriteOptions, WhereFilterOp, WhereFor, WhereConditionFor, WhereValueFor, FilterValues, FieldPath, OrderBySpec, LogicalCondition, LogicalConditionFor, FilterCondition, FilterConditionFor, AggregateParams, AggregateSelect, AggregateRow, AggregateResult, AggregateMeta, IncludeSpec, IncludeOptions, QueryComputedFields, RowOf, InsertOf, UpdateOf, StorageSource } from "@rebasepro/types";
43
43
  export type { OfflineStore, OfflineCacheEntry, OfflineCacheRecord, PendingMutation, MutationRollback } from "./offline-store.js";
44
44
  export { MemoryOfflineStore } from "./offline-store.js";
45
45
  export interface CreateRebaseClientOptions extends RebaseClientConfig {
@@ -102,9 +102,35 @@ type TypedDataLayer<DB> = {
102
102
  * typed collection accessors when a `DB` schema generic is supplied.
103
103
  */
104
104
  export type CreateRebaseClientResult<DB = Record<string, unknown>> = Omit<RebaseClient<DB>, "data" | "email"> & {
105
+ /**
106
+ * Send this token from now on, over HTTP and on the realtime socket. An
107
+ * open socket is rebuilt to authenticate with it. A token getter, when one
108
+ * is installed, still comes first.
109
+ */
105
110
  setToken: (token: string | null) => void;
111
+ /**
112
+ * Ask `getter` for the token each time one is needed — every HTTP request
113
+ * and every time the realtime socket authenticates. This is how a host
114
+ * that signs users in with its own provider (Clerk, Firebase Auth, a
115
+ * session of its own) authenticates the client:
116
+ *
117
+ * ```ts
118
+ * client.setAuthTokenGetter(() => clerk.session?.getToken() ?? Promise.resolve(null));
119
+ * ```
120
+ *
121
+ * It comes before the client's own session and the `token` option, which
122
+ * are used when it answers `null` or throws. An open socket is rebuilt to
123
+ * authenticate through it.
124
+ */
106
125
  setAuthTokenGetter: (getter: () => Promise<string | null>) => void;
126
+ /**
127
+ * Answer a refused credential — a 401 over HTTP, an auth error on the
128
+ * socket — with `handler`; resolve `true` to have the request or
129
+ * subscription retried with the token resolved again. Replaces the
130
+ * client's own session refresh.
131
+ */
107
132
  setOnUnauthorized: (handler: () => Promise<boolean>) => void;
133
+ /** The token the next request would carry, resolved as it would be. */
108
134
  resolveToken: () => Promise<string | null>;
109
135
  auth: ReturnType<typeof createAuth>;
110
136
  admin: ReturnType<typeof createAdmin>;