@rebasepro/client 0.23.0 → 0.24.1-canary.g56af4a4

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/dist/reviver.d.ts CHANGED
@@ -1 +1,19 @@
1
1
  export declare function rebaseReviver(_key: string, value: unknown): unknown;
2
+ /**
3
+ * `JSON.parse(text, rebaseReviver)`, without the reviver's cost where it has
4
+ * nothing to do.
5
+ *
6
+ * Handing `JSON.parse` a reviver takes V8 off its fast path and calls back for
7
+ * every key and every value, primitives included: about 7× a plain parse on a
8
+ * 1,000-row page, 10 ms of main thread per 600 KB. The reviver only ever
9
+ * changes objects carrying `__type`, and a REST page of flat rows has none. So
10
+ * this parses plainly and walks the result only when the text can hold one —
11
+ * and the walk visits objects, never primitives.
12
+ *
13
+ * Same result, instance for instance: the same values revived, bottom-up, as
14
+ * own data properties, and nothing deleted (the reviver never answers
15
+ * `undefined`).
16
+ *
17
+ * @throws SyntaxError exactly where `JSON.parse` does.
18
+ */
19
+ export declare function parseRebaseJson<T = unknown>(text: string): T;
@@ -1,4 +1,4 @@
1
- import { FindResult, LogicalCondition, PageWalkOptions, RelationAggregateSort, SDKCollectionClient, SDKQueryBuilderInterface, WhereFilterOp, WhereValueFor, type AggregateParams, type AggregateRow, type ComputedSortField, type FieldPath, type IncludeSpec, type NonColumnFieldPath, type NullsPlacement } from "@rebasepro/types";
1
+ import { FindResult, LogicalCondition, PageWalkOptions, RelationAggregateSort, SDKCollectionClient, SDKQueryBuilderInterface, WhereFilterOp, WhereValueFor, type AggregateParams, type AggregateResult, type ComputedSortField, type FieldPath, type IncludeSpec, type NonColumnFieldPath, type NullsPlacement } from "@rebasepro/types";
2
2
  /**
3
3
  * SDK Query Builder — returns flat rows (`FindResult<M>`) instead of
4
4
  * Entity-wrapped results (`FindResponse<M>`).
@@ -173,7 +173,7 @@ export declare class SDKQueryBuilder<M extends Record<string, unknown> = Record<
173
173
  * // [{ status: "paid", sum_total: 41822.5 }, …]
174
174
  * ```
175
175
  */
176
- aggregate(params: Omit<AggregateParams<M>, "where" | "logical" | "searchString">): Promise<AggregateRow[]>;
176
+ aggregate(params: Omit<AggregateParams<M>, "where" | "logical" | "searchString">): Promise<AggregateResult>;
177
177
  /**
178
178
  * Page through everything this query matches, one row at a time.
179
179
  *
@@ -0,0 +1,10 @@
1
+ import type { SqlScriptResult } from "@rebasepro/types";
2
+ /**
3
+ * Read an `EXECUTE_SQL_SUCCESS` payload for a script run as a
4
+ * {@link SqlScriptResult}, checking every field rather than trusting the frame.
5
+ *
6
+ * A server from before scripts existed answers `{ result }` alone, with parsed
7
+ * values. Its rows are kept, as text, and no column is said to come from
8
+ * anywhere — the console edits no cell of a result it cannot trace.
9
+ */
10
+ export declare function readSqlScriptResult(payload: unknown): SqlScriptResult;
@@ -0,0 +1,2 @@
1
+ import { uploadResumable } from "@rebasepro/common";
2
+ export { uploadResumable };
@@ -0,0 +1 @@
1
+ export { uploadResumable } from "@rebasepro/common";
@@ -1,4 +1,4 @@
1
- import { AggregateParams, FindParams as TypesFindParams, FindResponse as TypesFindResponse } from "@rebasepro/types";
1
+ import { AggregateParams, FindParams as TypesFindParams, FindResponse as TypesFindResponse, type IncludeSpec } from "@rebasepro/types";
2
2
  export { RebaseApiError } from "@rebasepro/types";
3
3
  export type { RebaseErrorInit } from "@rebasepro/types";
4
4
  export interface RebaseClientConfig {
@@ -95,6 +95,19 @@ export interface RebaseClientConfig {
95
95
  * is not settable here; it always comes from the token.
96
96
  */
97
97
  headers?: Record<string, string>;
98
+ /**
99
+ * Run every request as this user, named by uid: sent as
100
+ * `x-rebase-impersonate` on each HTTP request, and with the realtime
101
+ * socket's sign-in.
102
+ *
103
+ * For checking what one user can see and do against the real row-level
104
+ * security, as Studio's API explorer and JS editor do. Only an
105
+ * administrator's own session may — the server refuses it for anyone
106
+ * else, and always for an API key or the service key. The data API,
107
+ * custom functions and realtime run as the named user; every other route
108
+ * refuses the request rather than answer as the administrator.
109
+ */
110
+ impersonate?: string;
98
111
  }
99
112
  /**
100
113
  * Facts about the surrounding client that the transport cannot read off its own
@@ -124,7 +137,7 @@ export declare const ANONYMOUS_SERVER_CLIENT_WARNING: string;
124
137
  * `orderBy` went back to accepting any column name — the alias, not the
125
138
  * definition, was where the typing was lost.
126
139
  */
127
- export type FindParams<M extends Record<string, unknown> = Record<string, unknown>> = TypesFindParams<M>;
140
+ export type FindParams<M extends Record<string, unknown> = Record<string, unknown>, Inc = IncludeSpec> = TypesFindParams<M, Inc>;
128
141
  export type FindResponse<T> = TypesFindResponse<T extends Record<string, unknown> ? T : Record<string, unknown>>;
129
142
  /**
130
143
  * Refuse a filter whose *value* is missing.
@@ -143,7 +156,25 @@ export type FindResponse<T> = TypesFindResponse<T extends Record<string, unknown
143
156
  * serializes — `null` is a value, `undefined` is the absence of one).
144
157
  */
145
158
  export declare function assertNoUndefinedFilterValues(where: Record<string, unknown>): void;
146
- export declare function buildQueryString(params?: FindParams): string;
159
+ /**
160
+ * `?deleted=` — which soft-deleted rows a read covers: `"only"` the trashed
161
+ * ones, `"include"` live and trashed together. Absent, the server hides them.
162
+ *
163
+ * Not a {@link FindParams} field: `FindParams` is also what `listen()` and the
164
+ * offline cache take, and neither can answer for a trashed row — a
165
+ * subscription has no `withDeleted`, and the local database never holds one.
166
+ * Only the trash accessor (`client.data.<slug>.trash`) passes it.
167
+ */
168
+ export type SoftDeletedRows = "include" | "only";
169
+ export declare function buildQueryString(params?: FindParams, deleted?: SoftDeletedRows): string;
170
+ /**
171
+ * The body of `POST /data/<collection>/query`: the parameters
172
+ * {@link buildQueryString} puts in the URL, spelled as the URL spells them —
173
+ * each value a string, and a parameter the URL repeats (a filter with two
174
+ * conditions on one field) a list of them. The server reads it back into the
175
+ * same parameters and runs the same listing.
176
+ */
177
+ export declare function buildQueryBody(params?: FindParams, deleted?: SoftDeletedRows): Record<string, string | string[]>;
147
178
  /**
148
179
  * The query string for `GET /<collection>/aggregate`.
149
180
  *
@@ -153,11 +184,12 @@ export declare function buildQueryString(params?: FindParams): string;
153
184
  * by exactly the same code a `find()` uses, so "revenue by status, this month"
154
185
  * narrows the same rows whichever call is asking.
155
186
  *
156
- * `orderBy`, `include` and the page are deliberately not here: an aggregate has
157
- * no rows to sort, no relations to load and no page to continue. `limit` is,
158
- * and bounds the number of *groups*.
187
+ * `include` and a cursor are deliberately not here: an aggregate has no
188
+ * relations to load and no row to continue after. `limit`, `offset` and
189
+ * `orderBy` are, and page and sort the *groups* — `orderBy` by a group column or
190
+ * an aggregate's alias, in the spelling a `find()` sends.
159
191
  */
160
- export declare function buildAggregateQueryString(params: AggregateParams): string;
192
+ export declare function buildAggregateQueryString<M extends Record<string, unknown>>(params: AggregateParams<M>): string;
161
193
  /**
162
194
  * Response metadata a caller can ask for, filled in by `request`.
163
195
  *
@@ -178,12 +210,40 @@ export interface ResponseMeta {
178
210
  etag?: string;
179
211
  /** The HTTP status, for a caller that has to tell 200 from 204. */
180
212
  status?: number;
213
+ /**
214
+ * The response's headers, for a protocol that answers in them — a
215
+ * resumable upload's `Location` and `Upload-Offset`.
216
+ */
217
+ headers?: {
218
+ get(name: string): string | null;
219
+ };
181
220
  }
221
+ /** See {@link Transport.setTokenRefresher}. */
222
+ export type TokenRefresher = () => Promise<string | undefined> | undefined;
182
223
  export interface Transport {
183
224
  request: <T = unknown>(path: string, init?: RequestInit, meta?: ResponseMeta) => Promise<T>;
225
+ /**
226
+ * Like `request`, but the body of a success is left unread: the response
227
+ * comes back as it arrived, for a caller that wants text, a Blob or a
228
+ * stream. Auth, the refresh-and-resend and the error envelope are the same.
229
+ * Optional so a hand-written transport need not have it.
230
+ */
231
+ requestRaw?: (path: string, init?: RequestInit, meta?: ResponseMeta) => Promise<Response>;
184
232
  setToken: (newToken: string | null) => void;
185
233
  setAuthTokenGetter: (getter: () => Promise<string | null>) => void;
186
234
  setOnUnauthorized: (handler: () => Promise<boolean>) => void;
235
+ /**
236
+ * Install the hook asked, before each request that carries this
237
+ * transport's own token, whether that token is known to be spent. It
238
+ * answers `undefined` to send the token as held, or a promise for the one
239
+ * to send instead — the auth module's refresh, so a request made while a
240
+ * session is being restored, or after its token expired unnoticed, goes
241
+ * out once with a good token rather than with none or a dead one.
242
+ *
243
+ * Not consulted when an auth token getter is installed: the getter owns
244
+ * the token then. Optional so a hand-written transport need not have it.
245
+ */
246
+ setTokenRefresher?: (refresher: TokenRefresher | null) => void;
187
247
  readonly baseUrl: string;
188
248
  readonly apiPath: string;
189
249
  /** See {@link RebaseClientConfig.storageUrlOrigin}. Undefined = use `baseUrl`. */
@@ -192,4 +252,32 @@ export interface Transport {
192
252
  getHeaders: (init?: RequestInit) => Record<string, string>;
193
253
  resolveToken: () => Promise<string | null>;
194
254
  }
255
+ /**
256
+ * The base every request and every caller-built URL resolves against.
257
+ *
258
+ * `baseUrl` is optional because the common production shape is a Rebase
259
+ * backend serving its own SPA, where the API is simply the page's origin.
260
+ * Leaving it unset is therefore the *correct* configuration there — and the
261
+ * one that keeps working when a second hostname (a custom domain) points at
262
+ * the same app.
263
+ *
264
+ * When unset in a browser this resolves to the page origin rather than "".
265
+ * Requests behave identically either way, but the empty string is a trap for
266
+ * anything that builds a URL from `client.baseUrl`: `new URL("" + path)`
267
+ * throws, so apps "fixed" it by baking an absolute host into their bundle —
268
+ * which is exactly what breaks the day a custom domain is added, and which no
269
+ * amount of CORS configuration repairs, because a SameSite=Lax auth cookie is
270
+ * not sent cross-site either.
271
+ */
272
+ /**
273
+ * The code an error carries when the response did not name one: a proxy's 413,
274
+ * a load balancer's 502, a crash page's 500 — anything without the server's
275
+ * envelope. Without it `e.code` was `undefined` and the documented
276
+ * `switch (e.code)` fell through to `default` on exactly the failures that are
277
+ * not Rebase's own. Only codes the backend itself answers with, so a switch
278
+ * written against the error reference catches both.
279
+ *
280
+ * @internal
281
+ */
282
+ export declare function defaultCodeForStatus(status: number): string | undefined;
195
283
  export declare function createTransport(config: RebaseClientConfig, environment?: TransportEnvironment): Transport;
@@ -1,4 +1,5 @@
1
- import { DeleteProps, CollectionConfig, FetchCollectionProps, ListenCollectionProps, FetchOneProps, SaveProps, CollectionUpdateMeta, ChannelMessage, TableMetadata, BranchInfo } from "@rebasepro/types";
1
+ import { DeleteProps, CollectionConfig, FetchCollectionProps, ListenCollectionProps, FetchOneProps, ListenOneTarget, SaveProps, CollectionUpdateMeta, ChannelMessage, TableMetadata, BranchInfo, RebaseApiError, type RealtimeConnectionState } from "@rebasepro/types";
2
+ import type { SqlScriptResult } from "@rebasepro/types";
2
3
  export interface RebaseWebSocketConfig {
3
4
  websocketUrl: string;
4
5
  /** Optional auth token getter for WebSocket authentication */
@@ -7,6 +8,11 @@ export interface RebaseWebSocketConfig {
7
8
  WebSocket?: typeof WebSocket;
8
9
  /** Callback to handle unauthorized requests or token expiration (refreshes auth session) */
9
10
  onUnauthorized?: () => Promise<boolean>;
11
+ /**
12
+ * Sign in as this user rather than as the token's own — the socket half of
13
+ * `RebaseClientConfig.impersonate`. Sent with every `AUTHENTICATE`.
14
+ */
15
+ impersonate?: string;
10
16
  }
11
17
  export declare class RebaseWebSocketClient {
12
18
  private websocketUrl;
@@ -18,16 +24,41 @@ export declare class RebaseWebSocketClient {
18
24
  /** Set by `close()`. Blocks any later operation from silently redialling. */
19
25
  private closedByCaller;
20
26
  /**
21
- * Set when the backoff budget ran out, cleared by anything that earns a
22
- * fresh one.
27
+ * Set when the backoff budget ran out with nothing registered, cleared by
28
+ * anything that earns a fresh one.
23
29
  *
24
- * Unlike {@link closedByCaller} this is not final — nobody *asked* for the
25
- * socket to stay down. Five attempts with exponential backoff is about a
26
- * minute, which a laptop lid, a wifi handover or a backend rollout all
27
- * exceed routinely; treating that as permanent meant realtime silently
28
- * stopped for the rest of the page's life, with a reload the only cure.
30
+ * Only reachable with nothing registered: while a subscription or a joined
31
+ * channel exists the client never stops retrying (see `attemptReconnect`).
32
+ * And it is not final like {@link closedByCaller} — nobody *asked* for the
33
+ * socket to stay down, so the next subscribe dials again.
29
34
  */
30
35
  private gaveUp;
36
+ /** See {@link state}. */
37
+ private connectionState;
38
+ private stateListeners;
39
+ /**
40
+ * Whether the current outage has been reported to the registrations as
41
+ * `CONNECTION_LOST`. Once per outage: cleared when a socket opens.
42
+ */
43
+ private outageReported;
44
+ /**
45
+ * Where the connection is.
46
+ *
47
+ * - `idle` — no socket, and none wanted yet (the connection is lazy), or
48
+ * the last one was dropped by a sign-out.
49
+ * - `connecting` — dialling, with no outage in progress.
50
+ * - `connected` — the socket is open.
51
+ * - `reconnecting` — the socket dropped and the client is redialling. A
52
+ * blip, so far: nothing has been reported.
53
+ * - `disconnected` — the outage has outlasted the blip budget. Every
54
+ * subscription and joined channel has been told `CONNECTION_LOST` once;
55
+ * the client keeps redialling (every 30 s at most) while any exists.
56
+ * - `closed` — `client.close()`. Final.
57
+ */
58
+ get state(): RealtimeConnectionState;
59
+ /** Called on every change of {@link state}. Returns the unsubscribe. */
60
+ onStateChange(listener: (state: RealtimeConnectionState) => void): () => void;
61
+ private setState;
31
62
  /**
32
63
  * Whether a socket exists at all (open or still opening).
33
64
  *
@@ -37,10 +68,37 @@ export declare class RebaseWebSocketClient {
37
68
  get hasSocket(): boolean;
38
69
  /** So the "no WebSocket in this environment" warning is said once, not per call. */
39
70
  private warnedNoWebSocket;
71
+ /**
72
+ * What the server said in its `hello` it does for this socket: empty
73
+ * until then, after a close, and for a server that sends no `hello`.
74
+ */
75
+ private serverOptIns;
76
+ /** This socket's id on the server, from its `hello` (with `channel_seq`). */
77
+ private serverClientId;
78
+ /** When the current socket last delivered anything, heartbeats included. */
79
+ private lastFrameAt;
80
+ private livenessTimer;
81
+ /** Give up on the current socket as though it had closed. Set per socket. */
82
+ private dropSocket;
83
+ /** Whether the server agreed, in its `hello`, to `name` for this socket. */
84
+ hasServerOptIn(name: string): boolean;
85
+ /**
86
+ * This socket's id on the server, as its broadcasts' `senderId` in a
87
+ * channel's history. Known once a server that numbers retained channels
88
+ * for it (`channel_seq`) has said hello.
89
+ */
90
+ get socketClientId(): string | undefined;
40
91
  /** Subscribe to broadcast/presence frames for one channel. */
41
92
  onChannelMessage(channel: string, handler: (message: ChannelMessage) => void): () => void;
42
93
  /** Notified after the socket comes back, so channels can re-join. */
43
94
  onReconnect(handler: () => void): () => void;
95
+ /**
96
+ * Notified once per outage that outlasted a blip, with the
97
+ * `CONNECTION_LOST` error — so a joined channel can tell its `onError`
98
+ * handlers, as subscriptions are told through theirs.
99
+ */
100
+ onConnectionLost(handler: (error: RebaseApiError) => void): () => void;
101
+ private connectionLostHandlers;
44
102
  on(event: "connect" | "disconnect" | "reconnect" | "error", cb: (...args: unknown[]) => void): () => boolean;
45
103
  private emit;
46
104
  private collectionSubscriptions;
@@ -49,7 +107,18 @@ export declare class RebaseWebSocketClient {
49
107
  private backendToEntityKey;
50
108
  private pendingRequests;
51
109
  private reconnectAttempts;
110
+ /**
111
+ * With nothing registered, how many failed redials before the client stops
112
+ * trying until something asks for the connection. With a registration it
113
+ * never stops.
114
+ */
52
115
  private maxReconnectAttempts;
116
+ /**
117
+ * Reports the outage once the connection has been down for
118
+ * {@link OUTAGE_REPORT_AFTER_MS}. Armed by the first redial after a drop,
119
+ * cleared when a socket opens or the caller disconnects.
120
+ */
121
+ private outageTimer;
53
122
  /**
54
123
  * Whether a socket of this client has ever opened — what makes the next
55
124
  * open a *reconnect*, whose server has forgotten every subscription and
@@ -71,6 +140,7 @@ export declare class RebaseWebSocketClient {
71
140
  private WebSocketConstructor;
72
141
  onUnauthorized?: () => Promise<boolean>;
73
142
  private refreshInProgress;
143
+ private readonly impersonate?;
74
144
  constructor(config: RebaseWebSocketConfig);
75
145
  /**
76
146
  * Open the socket if it is not open (or opening) already.
@@ -81,12 +151,20 @@ export declare class RebaseWebSocketClient {
81
151
  */
82
152
  ensureConnected(): void;
83
153
  /**
84
- * The browser says the network is back — the usual reason the budget ran
85
- * out in the first place. Registered lazily so a Node client, or a page
86
- * that never subscribes, adds no listener.
154
+ * Dial now rather than at the next backoff step — the browser says the
155
+ * network is back, or the tab is in front of the user again. Both are the
156
+ * usual end of an outage; neither fires for a server restart, which the
157
+ * backoff covers.
87
158
  */
88
- private installOnlineListener;
159
+ private retryNow;
160
+ /**
161
+ * `online` and `visibilitychange`. Registered lazily so a Node client, or a
162
+ * page that never subscribes, adds no listener.
163
+ */
164
+ private installNetworkListeners;
165
+ private removeNetworkListeners;
89
166
  private onlineListener;
167
+ private visibilityListener;
90
168
  /**
91
169
  * Authenticate the WebSocket connection
92
170
  */
@@ -105,6 +183,15 @@ export declare class RebaseWebSocketClient {
105
183
  */
106
184
  disconnect(permanent?: boolean): void;
107
185
  private initWebSocket;
186
+ /** Read the server's `hello`: what it agreed to, and start watching for heartbeats. */
187
+ private receiveHello;
188
+ /**
189
+ * Redial when two heartbeats in a row have not arrived. Anything the
190
+ * server sends counts as a beat, so a busy socket is never judged on them.
191
+ */
192
+ private watchLiveness;
193
+ private stopLivenessWatch;
194
+ private forgetServerOptIns;
108
195
  private processMessageQueue;
109
196
  /**
110
197
  * Whether a frame that waited in the queue should go out on the socket
@@ -122,6 +209,28 @@ export declare class RebaseWebSocketClient {
122
209
  */
123
210
  private shouldSendQueued;
124
211
  private attemptReconnect;
212
+ /**
213
+ * Whether anything depends on the socket coming back: a subscription, a
214
+ * joined channel, or a request whose caller is still waiting for a socket.
215
+ */
216
+ private hasRegistrations;
217
+ /**
218
+ * Tell every subscription and joined channel, once per outage, that the
219
+ * connection is down and their data is not updating.
220
+ *
221
+ * Registrations are kept — that is the difference from a subscribe that
222
+ * failed. When the socket is back they are re-subscribed, and the fresh
223
+ * `onUpdate` is the recovery.
224
+ */
225
+ private clearOutageTimer;
226
+ private reportConnectionLost;
227
+ private notifyError;
228
+ /**
229
+ * A listener attaching while an outage is being reported is told at once:
230
+ * its subscribe waits for a socket that may be minutes away, and nothing
231
+ * else would say so.
232
+ */
233
+ private reportOutageTo;
125
234
  private isAuthError;
126
235
  private handleAuthFailure;
127
236
  /**
@@ -138,15 +247,49 @@ export declare class RebaseWebSocketClient {
138
247
  * Not part of the stable surface — prefer `client.realtime.channel(name)`.
139
248
  */
140
249
  sendMessage(message: Record<string, unknown>): Promise<unknown>;
250
+ /**
251
+ * Frames whose caller has already been answered — timed out, or rejected
252
+ * by a close. One can still be on its way to the socket (awaiting
253
+ * authentication), and must not be written after its caller was told it
254
+ * failed.
255
+ */
256
+ private abandonedFrames;
257
+ /** Whether the server answers this frame with a response envelope. */
258
+ private expectsResponse;
141
259
  private doSendMessage;
142
260
  fetchCollection<M extends Record<string, unknown>>(props: FetchCollectionProps<M>): Promise<Record<string, unknown>[]>;
143
261
  fetchOne<M extends Record<string, unknown>>(props: FetchOneProps<M>): Promise<Record<string, unknown> | undefined>;
144
262
  save<M extends Record<string, unknown>>(props: SaveProps<M>): Promise<Record<string, unknown>>;
145
263
  delete<M extends Record<string, unknown>>(props: DeleteProps<M>): Promise<void>;
264
+ /**
265
+ * @deprecated Will leave the public `client.ws` type in the next minor.
266
+ * Not part of the app-facing client: the admin UI's SQL console reaches it
267
+ * through `<Rebase>`, and it answers only a caller with `database:write`.
268
+ * App code has no supported SQL or branch path on the client; run SQL
269
+ * server-side (`isSQLAdmin(driver.admin)`), and use `client.admin` for
270
+ * users and roles.
271
+ */
146
272
  executeSql(sql: string, options?: {
147
273
  database?: string;
148
274
  role?: string;
149
275
  }): Promise<Record<string, unknown>[]>;
276
+ /**
277
+ * Run a script a person wrote — the Studio console — and get back what its
278
+ * last statement returned, every value as the database's text, with the
279
+ * table column each result column was read from. See
280
+ * `SQLAdmin.runSqlScript`.
281
+ */
282
+ runSqlScript(sql: string, options?: {
283
+ database?: string;
284
+ role?: string;
285
+ signal?: AbortSignal;
286
+ }): Promise<SqlScriptResult>;
287
+ /**
288
+ * Stop a console run its caller gave up on: never written if it has not
289
+ * been yet, and cancelled on a server whose `hello` listed `cancel_sql`. A server
290
+ * that does not is left to finish it, bounded by its `statement_timeout`.
291
+ */
292
+ private cancelSqlRun;
150
293
  fetchAvailableDatabases(): Promise<string[]>;
151
294
  fetchAvailableRoles(): Promise<string[]>;
152
295
  fetchApplicationRoles(): Promise<string[]>;
@@ -155,17 +298,41 @@ export declare class RebaseWebSocketClient {
155
298
  count<M extends Record<string, unknown>>(props: FetchCollectionProps<M>): Promise<number>;
156
299
  fetchUnmappedTables(mappedPaths?: string[]): Promise<string[]>;
157
300
  fetchTableMetadata(tableName: string): Promise<TableMetadata>;
301
+ /**
302
+ * @deprecated Will leave the public `client.ws` type in the next minor.
303
+ * Not part of the app-facing client: the admin UI's SQL console reaches it
304
+ * through `<Rebase>`, and it answers only a caller with `database:write`.
305
+ * App code has no supported SQL or branch path on the client; run SQL
306
+ * server-side (`isSQLAdmin(driver.admin)`), and use `client.admin` for
307
+ * users and roles.
308
+ */
158
309
  createBranch(name: string, options?: {
159
310
  source?: string;
160
311
  }): Promise<BranchInfo>;
312
+ /**
313
+ * @deprecated Will leave the public `client.ws` type in the next minor.
314
+ * Not part of the app-facing client: the admin UI's SQL console reaches it
315
+ * through `<Rebase>`, and it answers only a caller with `database:write`.
316
+ * App code has no supported SQL or branch path on the client; run SQL
317
+ * server-side (`isSQLAdmin(driver.admin)`), and use `client.admin` for
318
+ * users and roles.
319
+ */
161
320
  deleteBranch(name: string): Promise<void>;
162
321
  listBranches(): Promise<BranchInfo[]>;
163
322
  /**
164
- * Recursively compare two values for structural equality.
165
- * Handles primitives, null, undefined, Date, RegExp, arrays, and plain objects.
323
+ * Recursively compare two values a refetch can carry for structural
324
+ * equality: primitives, null, undefined, Date, RegExp, arrays and objects.
325
+ *
326
+ * A relation compares by the reference it holds, not by the row it happens
327
+ * to have loaded, so its `data` is left out on both sides. That used to be
328
+ * done by normalising each side into a copy first — two deep copies of
329
+ * every cached row on every frame, most of which then compared equal. It is
330
+ * done in place now, and an unchanged row costs no copy.
331
+ *
332
+ * `relationAware` is off for a relation's own fields: the copies never
333
+ * looked inside those either.
166
334
  */
167
335
  private deepEqual;
168
- private normalizeForComparison;
169
336
  /**
170
337
  * The address of a row, for matching it against another copy of itself.
171
338
  *
@@ -187,7 +354,7 @@ export declare class RebaseWebSocketClient {
187
354
  */
188
355
  private mergeRows;
189
356
  listenCollection<M extends Record<string, unknown>>(props: Omit<ListenCollectionProps<M>, "onUpdate" | "onError">, onUpdate: (rows: Record<string, unknown>[], meta?: CollectionUpdateMeta) => void, onError?: (error: Error) => void): () => void;
190
- listenOne<M extends Record<string, unknown>>(props: FetchOneProps<M>, onUpdate: (row: Record<string, unknown> | null) => void, onError?: (error: Error) => void): () => void;
357
+ listenOne<M extends Record<string, unknown>>(props: ListenOneTarget<M>, onUpdate: (row: Record<string, unknown> | null) => void, onError?: (error: Error) => void): () => void;
191
358
  /**
192
359
  * Send a `subscribe_collection` for an already-registered subscription and
193
360
  * arm its watchdog.
@@ -233,11 +400,6 @@ export declare class RebaseWebSocketClient {
233
400
  private armPendingSubscribeWatchdogs;
234
401
  private sendCollectionSubscribeWatchdog;
235
402
  private sendEntitySubscribeWatchdog;
236
- /**
237
- * Fail every subscription that never received data. Called when reconnection
238
- * is given up on, so views surface an error instead of spinning forever.
239
- */
240
- private failAllPendingSubscriptions;
241
403
  /**
242
404
  * Re-send all active subscriptions to the backend after a reconnect.
243
405
  * The server wipes subscription state when a client disconnects, so
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebasepro/client",
3
- "version": "0.23.0",
3
+ "version": "0.24.1-canary.g56af4a4",
4
4
  "description": "HTTP SDK client for the Rebase custom backend",
5
5
  "keywords": [
6
6
  "rebase",
@@ -41,9 +41,9 @@
41
41
  "./package.json": "./package.json"
42
42
  },
43
43
  "dependencies": {
44
- "@rebasepro/common": "0.23.0",
45
- "@rebasepro/utils": "0.23.0",
46
- "@rebasepro/types": "0.23.0"
44
+ "@rebasepro/common": "0.24.1-canary.g56af4a4",
45
+ "@rebasepro/types": "0.24.1-canary.g56af4a4",
46
+ "@rebasepro/utils": "0.24.1-canary.g56af4a4"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@jest/globals": "^30.4.1",
@@ -1 +0,0 @@
1
- export { QueryBuilder, or, and, cond } from "@rebasepro/common";