@gonvex/client 0.1.31 → 0.3.0

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.
Files changed (59) hide show
  1. package/README.md +119 -95
  2. package/dist/control.d.ts +416 -0
  3. package/dist/control.js +210 -0
  4. package/dist/control.js.map +1 -0
  5. package/dist/error-reporter.d.ts +20 -6
  6. package/dist/error-reporter.js +55 -27
  7. package/dist/error-reporter.js.map +1 -1
  8. package/dist/index.d.ts +170 -132
  9. package/dist/index.js +1123 -1138
  10. package/dist/index.js.map +1 -1
  11. package/dist/indexeddb-replica.d.ts +20 -0
  12. package/dist/indexeddb-replica.js +193 -0
  13. package/dist/indexeddb-replica.js.map +1 -0
  14. package/dist/kv-stores.d.ts +15 -0
  15. package/dist/kv-stores.js +60 -0
  16. package/dist/kv-stores.js.map +1 -0
  17. package/dist/local-replica.d.ts +240 -0
  18. package/dist/local-replica.js +590 -0
  19. package/dist/local-replica.js.map +1 -0
  20. package/dist/optimistic.d.ts +34 -55
  21. package/dist/optimistic.js +70 -269
  22. package/dist/optimistic.js.map +1 -1
  23. package/dist/outbox.d.ts +74 -16
  24. package/dist/outbox.js +194 -14
  25. package/dist/outbox.js.map +1 -1
  26. package/dist/query-expression.d.ts +58 -0
  27. package/dist/query-expression.js +164 -0
  28. package/dist/query-expression.js.map +1 -0
  29. package/dist/replica-integrity.d.ts +5 -0
  30. package/dist/replica-integrity.js +58 -0
  31. package/dist/replica-integrity.js.map +1 -0
  32. package/package.json +4 -4
  33. package/dist/browser-cache-client.d.ts +0 -77
  34. package/dist/browser-cache-client.js +0 -156
  35. package/dist/browser-cache-client.js.map +0 -1
  36. package/dist/browser-cache-shared-worker.d.ts +0 -35
  37. package/dist/browser-cache-shared-worker.js +0 -118
  38. package/dist/browser-cache-shared-worker.js.map +0 -1
  39. package/dist/browser-cache.d.ts +0 -43
  40. package/dist/browser-cache.js +0 -67
  41. package/dist/browser-cache.js.map +0 -1
  42. package/dist/browser-capabilities.d.ts +0 -21
  43. package/dist/browser-capabilities.js +0 -31
  44. package/dist/browser-capabilities.js.map +0 -1
  45. package/dist/cache-coordinator.d.ts +0 -37
  46. package/dist/cache-coordinator.js +0 -109
  47. package/dist/cache-coordinator.js.map +0 -1
  48. package/dist/cache.d.ts +0 -74
  49. package/dist/cache.js +0 -120
  50. package/dist/cache.js.map +0 -1
  51. package/dist/persistent-cache.d.ts +0 -41
  52. package/dist/persistent-cache.js +0 -103
  53. package/dist/persistent-cache.js.map +0 -1
  54. package/dist/query-cache.d.ts +0 -88
  55. package/dist/query-cache.js +0 -346
  56. package/dist/query-cache.js.map +0 -1
  57. package/dist/sync-store.d.ts +0 -96
  58. package/dist/sync-store.js +0 -500
  59. package/dist/sync-store.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,42 +1,61 @@
1
- import type { BrowserTelemetryInfo, JsonValue, MessageTrace, ServerCapabilities, ServerMessage } from "@gonvex/protocol";
2
- import { type QueryCacheOptions, type QueryCacheStatus } from "./query-cache.js";
3
- import { type SyncStoreOptions } from "./sync-store.js";
1
+ import type { BrowserTelemetryInfo, ExecutionScope, JsonValue, MessageTrace, ServerCapabilities, ServerMessage } from "@gonvex/protocol";
4
2
  import { type ErrorReporterOptions } from "./error-reporter.js";
5
- import { OptimisticOverlay, type OptimisticMutationDefinition, type OptimisticPatch, type OptimisticProjection } from "./optimistic.js";
6
- export * from "./cache.js";
7
- export * from "./cache-coordinator.js";
8
- export * from "./browser-cache.js";
9
- export * from "./browser-cache-client.js";
10
- export * from "./browser-cache-shared-worker.js";
11
- export * from "./browser-capabilities.js";
12
- export * from "./persistent-cache.js";
13
- export * from "./query-cache.js";
14
- export * from "./sync-store.js";
3
+ export { GonvexErrorReporter } from "./error-reporter.js";
4
+ export type { ErrorReporterOptions, ErrorEventPayload, ErrorContext, ErrorAccount } from "./error-reporter.js";
5
+ import { type OptimisticPatch, type OptimisticTransactionDefinition } from "./optimistic.js";
6
+ import { type OutboxStore } from "./outbox.js";
7
+ import { type LocalReplicaStorage, type LocalReplicaView, type ReplicaRow, type LiveQueryResult, type ReplicaCollectionState } from "./local-replica.js";
8
+ import { type LiveQueryPlan, type OfflineLiveQueryResult } from "./query-expression.js";
15
9
  export * from "./error-reporter.js";
16
10
  export * from "./optimistic.js";
17
11
  export * from "./outbox.js";
12
+ export * from "./kv-stores.js";
18
13
  export * from "./signals.js";
19
- export type { QueryCacheDirective } from "@gonvex/protocol";
14
+ export { MemoryLocalReplicaStorage, type LocalReplicaStorage, type LocalReplicaView, type ReplicaChange, type ReplicaFreshness, type ReplicaRow, type ReplicaScope, type ReplicaSnapshot, type ReplicaTransaction, type ReplicaWindow, type LiveQueryResult, type ReplicaCollectionState, } from "./local-replica.js";
15
+ export * from "./query-expression.js";
16
+ export * from "./indexeddb-replica.js";
17
+ export * from "./control.js";
20
18
  type SubscriptionHandler = (message: ServerMessage) => void;
21
- export type SyncReadyMessage = Extract<ServerMessage, {
22
- type: "sync.ready";
19
+ export type ReplicaReadyMessage = Extract<ServerMessage, {
20
+ type: "replica.ready";
23
21
  }> & {
24
22
  /** True when the server cut this collection at its row or byte budget. */
25
23
  truncated?: boolean;
26
24
  };
27
- export type SyncMessage = Extract<ServerMessage, {
28
- type: "sync.snapshot" | "sync.delta" | "sync.needHashes" | "sync.syncing" | "sync.reset" | "sync.error";
29
- }> | SyncReadyMessage;
30
- export type SyncSubscriptionHandler = (message: SyncMessage) => void;
25
+ export type ReplicaMessage = Extract<ServerMessage, {
26
+ type: "replica.snapshot" | "replica.delta" | "replica.needHashes" | "replica.syncing" | "replica.reset" | "replica.error";
27
+ }> | ReplicaReadyMessage;
28
+ export type ReplicaSubscriptionHandler = (message: ReplicaMessage) => void;
31
29
  type WatchUpdateHandler = () => void;
32
30
  type TelemetryHandler = (event: GonvexTelemetryEvent) => void;
33
31
  type ConnectionStateHandler = (state: ConnectionState) => void;
34
- export type FunctionReference = {
32
+ export type SupportCommand = {
33
+ id: string;
34
+ kind: string;
35
+ payload: JsonValue;
36
+ };
37
+ export type FunctionReference<Args extends JsonValue = JsonValue, Result extends JsonValue = JsonValue> = {
35
38
  kind: string;
36
39
  path: string;
40
+ /** Core Control Plane functions share the same persistent connection. */
41
+ scope?: ExecutionScope;
42
+ authorization?: "public" | "account" | "tenantAdmin" | "developer" | "projectAdmin" | "internal";
43
+ argsSchema?: JsonValue;
44
+ resultSchema?: JsonValue;
45
+ delivery?: "oneShot" | "live" | "replica";
46
+ offline?: {
47
+ mode: "forbidden" | "allowed" | "onlineOnly";
48
+ conflict?: "reject" | "expectedVersion" | "merge";
49
+ reason?: string;
50
+ };
51
+ live?: {
52
+ entity: string;
53
+ key: string;
54
+ resultPath?: readonly string[];
55
+ plan: LiveQueryPlan;
56
+ };
37
57
  optimistic?: {
38
- projection?: OptimisticProjection;
39
- mutation?: OptimisticMutationDefinition;
58
+ transaction?: OptimisticTransactionDefinition;
40
59
  };
41
60
  };
42
61
  export type GonvexClientErrorCode = "server" | "timeout" | "disconnected" | "closed" | "auth";
@@ -47,20 +66,20 @@ export type GonvexClientErrorCode = "server" | "timeout" | "disconnected" | "clo
47
66
  *
48
67
  * - `server`: the runtime executed the function and returned an error.
49
68
  * - `timeout`: no response arrived within the operation timeout. For
50
- * mutations/actions the write may or may not have been applied.
69
+ * reducers/actions the write may or may not have been applied.
51
70
  * - `disconnected`: the socket dropped while the operation was pending.
52
- * Mutations/actions fail closed unless a mutation opted into the outbox.
71
+ * Reducers/actions fail closed unless a reducer opted into the outbox.
53
72
  * - `closed`: the client was explicitly closed.
54
73
  * - `auth`: authentication was rejected.
55
74
  */
56
75
  export declare class GonvexClientError extends Error {
57
76
  readonly code: GonvexClientErrorCode;
58
77
  readonly path?: string;
59
- readonly operation?: "query" | "mutation" | "action";
78
+ readonly operation?: "query" | "reducer" | "action";
60
79
  constructor(message: string, options: {
61
80
  code: GonvexClientErrorCode;
62
81
  path?: string;
63
- operation?: "query" | "mutation" | "action";
82
+ operation?: "query" | "reducer" | "action";
64
83
  });
65
84
  }
66
85
  export type ConnectionState = {
@@ -69,33 +88,33 @@ export type ConnectionState = {
69
88
  connectionCount: number;
70
89
  connectionRetries: number;
71
90
  hasInflightRequests: boolean;
72
- inflightMutations: number;
91
+ inflightReducers: number;
73
92
  inflightActions: number;
74
93
  inflightOneShotQueries: number;
75
94
  };
76
95
  export type GonvexTimeoutOptions = {
77
96
  /** One-shot `client.query()` timeout. Default 20s. `0` disables. */
78
97
  queryTimeoutMs?: number;
79
- /** `client.mutation()` timeout. Default 20s. `0` disables. */
80
- mutationTimeoutMs?: number;
98
+ /** `client.reducer()` timeout. Default 20s. `0` disables. */
99
+ reducerTimeoutMs?: number;
81
100
  /** `client.action()` timeout. Default 60s. `0` disables. */
82
101
  actionTimeoutMs?: number;
83
102
  };
84
103
  export declare const DEFAULT_QUERY_TIMEOUT_MS = 20000;
85
- export declare const DEFAULT_MUTATION_TIMEOUT_MS = 20000;
104
+ export declare const DEFAULT_REDUCER_TIMEOUT_MS = 20000;
86
105
  export declare const DEFAULT_ACTION_TIMEOUT_MS = 60000;
87
106
  export type CallOptions = {
88
107
  /** Per-call override of the operation timeout. `0` disables. */
89
108
  timeoutMs?: number;
90
- /** Ordered row changes to expose until the mutation settles. */
109
+ /** Ordered row changes to expose until the reducer settles. */
91
110
  optimistic?: OptimisticPatch[];
92
111
  /** Queue transport failures durably instead of rejecting. Default `reject`. */
93
112
  offline?: "queue" | "reject";
94
113
  };
95
- /** Returned when an offline mutation has been accepted by the local outbox. */
96
- export type QueuedMutationOutcome = {
114
+ /** Returned when an offline reducer has been accepted by the local outbox. */
115
+ export type QueuedReducerOutcome = {
97
116
  status: "queued";
98
- mutationId: string;
117
+ reducerId: string;
99
118
  };
100
119
  export type GonvexAuthTokenFetcher = (args: {
101
120
  /** True when the server just rejected the current token — bypass any cache. */
@@ -107,33 +126,24 @@ export type GonvexClientAuth = {
107
126
  tenant?: string;
108
127
  telemetry?: boolean;
109
128
  /**
110
- * Async source of the auth token, mirroring Convex's `fetchToken` contract.
129
+ * Async source of the auth token.
111
130
  * When installed, the client re-fetches before every auth send — on first
112
131
  * connect, on every reconnect, and once more with `forceRefreshToken: true`
113
132
  * when the server rejects the current token — so a socket that outlives a
114
- * short-lived JWT (e.g. an ~1h Firebase ID token) reauthenticates with a
133
+ * short-lived Gonvex app session reauthenticates with a
115
134
  * live credential instead of replaying the expired one. A `token` passed in
116
135
  * the same `setAuth` call is trusted and sent as-is; resolving `null` signs
117
136
  * the session out; a rejected fetch keeps the currently installed token so
118
137
  * an offline start is not signed out.
119
138
  */
120
139
  fetchToken?: GonvexAuthTokenFetcher;
121
- /**
122
- * Non-secret identity hint ({@link https://datatracker.ietf.org/doc/html/rfc7519 JWT}
123
- * `sub` and `iss` claims) that stands in for a token when deriving the local
124
- * cache identity. Lets a cold start with no usable token — e.g. an offline
125
- * tab whose identity provider cannot refresh — recover the warm query-cache
126
- * directive and serve cached reads. Never sent to the server; a parseable
127
- * token always takes precedence, and both must derive the same key for the
128
- * same user (persist the claims of the last token you installed).
129
- */
140
+ /** Non-secret identity hint used to isolate local-replica persistence. */
130
141
  identity?: {
131
142
  sub: string;
132
143
  iss?: string;
133
144
  };
134
145
  };
135
146
  export type GonvexClientOptions = GonvexClientAuth & {
136
- queryCache?: false | QueryCacheOptions;
137
147
  /**
138
148
  * Keep listenerless live queries subscribed for this long so route
139
149
  * backtracking can reuse their current result without WebSocket churn.
@@ -141,27 +151,33 @@ export type GonvexClientOptions = GonvexClientAuth & {
141
151
  */
142
152
  querySubscriptionRetentionMs?: number;
143
153
  /**
144
- * Keep listenerless durable syncs open briefly across React remounts.
154
+ * Keep listenerless Replica Collections open briefly across React remounts.
145
155
  * Defaults to 250ms, preventing close/open/snapshot churn in StrictMode.
146
156
  */
147
- syncSubscriptionRetentionMs?: number;
148
- sync?: false | SyncStoreOptions;
157
+ replicaSubscriptionRetentionMs?: number;
149
158
  /**
150
- * Durable mutation queue settings. Every replay keeps its original
159
+ * Durable reducer queue settings. Every replay keeps its original
151
160
  * idempotency key, making an accidental cross-tab double-send server-safe.
161
+ * Runtimes without IndexedDB inject `store` to keep queued reducers
162
+ * durable; queue semantics always stay in the SDK.
152
163
  */
153
164
  outbox?: {
154
165
  databaseName?: string;
155
166
  enabled?: boolean;
167
+ store?: OutboxStore;
168
+ };
169
+ /** Transactional normalized store used by Replica Collections and Live Queries. */
170
+ localReplica?: {
171
+ storage?: LocalReplicaStorage;
156
172
  };
157
- errorReporting?: false | Omit<ErrorReporterOptions, "endpoint" | "project" | "tenant">;
173
+ errorReporting?: false | Omit<ErrorReporterOptions, "transport" | "project" | "tenant">;
158
174
  timeouts?: GonvexTimeoutOptions;
159
175
  };
160
176
  export type GonvexTelemetryEvent = {
161
- type: "mutation" | "action" | "query";
177
+ type: "reducer" | "action" | "query";
162
178
  id: string;
163
179
  path: string;
164
- reason?: "initial" | "invalidate" | "recover";
180
+ reason?: "initial" | "change" | "recover";
165
181
  outcome: "ok" | "error";
166
182
  error?: string;
167
183
  clientSentAtMs?: number;
@@ -175,14 +191,13 @@ export declare class GonvexClient {
175
191
  private socket;
176
192
  private readonly handlers;
177
193
  private readonly querySubscriptions;
178
- private readonly syncSubscriptions;
194
+ private readonly replicaSubscriptions;
179
195
  private readonly oneShotQueries;
180
196
  private readonly telemetryHandlers;
181
197
  private readonly pendingMessages;
182
- private readonly pendingSyncOpens;
198
+ private readonly pendingReplicaOpens;
183
199
  private readonly pendingQuerySubscribes;
184
- private readonly syncPersistence;
185
- private syncOpenFlushTimer;
200
+ private replicaOpenFlushTimer;
186
201
  private querySubscribeFlushTimer;
187
202
  private serverCapabilities;
188
203
  private auth;
@@ -192,29 +207,23 @@ export declare class GonvexClient {
192
207
  private authRetriedAfterError;
193
208
  private readonly authErrorHandlers;
194
209
  private telemetryEnabled;
195
- private readonly queryCache;
196
- private readonly queryCacheWaitForScope;
197
- private readonly queryCacheReadTimeoutMs;
198
210
  private readonly querySubscriptionRetentionMs;
199
- private readonly syncSubscriptionRetentionMs;
200
- private readonly syncStore;
201
- private readonly mutationOutbox;
202
- private readonly overlay;
203
- private readonly optimisticMutationIds;
211
+ private readonly replicaSubscriptionRetentionMs;
212
+ private readonly reducerOutbox;
213
+ private readonly replica;
214
+ private readonly replicaView;
215
+ private readonly optimisticReducerIds;
204
216
  private readonly optimisticOutboxEntryIds;
205
217
  private outboxReady;
206
218
  private outboxScope;
207
219
  private outboxScopeGeneration;
208
220
  private readonly outboxEphemeralScope;
221
+ private replicaScope;
222
+ private hasAuthoritativeReplicaScope;
223
+ private replicaReady;
209
224
  private readonly unsubscribeOutbox;
210
- private readonly unsubscribeOverlay;
211
225
  private drainingOutbox;
212
226
  private outboxDrainTimer;
213
- private queryCacheDirective;
214
- private queryCacheGeneration;
215
- private syncScopeGeneration;
216
- private queryCacheNegotiatedSocketGeneration;
217
- private syncIdentityGeneration;
218
227
  private readonly sessionScopeHandlers;
219
228
  private readonly errorReporter;
220
229
  private reconnectTimer;
@@ -223,14 +232,24 @@ export declare class GonvexClient {
223
232
  private manuallyClosed;
224
233
  private readonly pendingCalls;
225
234
  private readonly connectionStateHandlers;
235
+ private readonly supportCommandHandlers;
226
236
  private isWebSocketConnected;
227
237
  private hasEverConnected;
228
238
  private connectionCount;
229
239
  private readonly timeouts;
230
240
  constructor(url: string, options?: GonvexClientOptions);
231
- /** The client's materialized optimistic state for pending-row indicators. */
232
- get optimisticOverlay(): OptimisticOverlay;
233
- /** Number of mutations waiting for a definitive server result. */
241
+ /** The single normalized authoritative + optimistic application data store. */
242
+ get localReplica(): LocalReplicaView;
243
+ replicaSignature(ref: FunctionReference, args?: JsonValue): string;
244
+ /** Read one persisted Live Query membership without starting another transport subscription. */
245
+ retainedLiveQuery<T extends ReplicaRow = ReplicaRow>(signature: string): LiveQueryResult<T>;
246
+ /** Resolve an ordered ID batch from one normalized entity store. */
247
+ replicaEntities<T extends ReplicaRow = ReplicaRow>(entity: string, ids: readonly string[]): Array<T | undefined>;
248
+ /** Read rows and server-owned completeness for a persisted Replica Collection. */
249
+ replicaCollectionState<T extends ReplicaRow = ReplicaRow>(ref: FunctionReference, args?: JsonValue): ReplicaCollectionState<T>;
250
+ /** Run the generated Live Query plan over the bounded normalized cache. */
251
+ offlineLiveQuery<T extends ReplicaRow = ReplicaRow>(ref: FunctionReference, args?: JsonValue): OfflineLiveQueryResult<T>;
252
+ /** Number of reducers waiting for a definitive server result. */
234
253
  outboxCount(): Promise<number>;
235
254
  connectionState(): ConnectionState;
236
255
  /** Metadata advertised by the runtime in its latest session.ready frame. */
@@ -251,79 +270,96 @@ export declare class GonvexClient {
251
270
  private rejectPendingCalls;
252
271
  onTelemetry(handler: TelemetryHandler): () => boolean;
253
272
  onSessionScopeChange(handler: () => void): () => boolean;
254
- clearQueryCache(options?: {
255
- allScopes?: boolean;
256
- }): Promise<void>;
257
- getQueryCacheStatus(): QueryCacheStatus;
258
- subscribeQuery(ref: FunctionReference, args: JsonValue | undefined, onMessage: SubscriptionHandler): () => void;
273
+ onSupportCommand(handler: (command: SupportCommand) => void): () => boolean;
274
+ subscribeLiveQuery<Args extends JsonValue = JsonValue, Result extends JsonValue = JsonValue>(ref: FunctionReference<Args, Result>, args: Args | undefined, onMessage: SubscriptionHandler): () => void;
275
+ /** Watch an authorized host-owned Control Plane Query on the persistent connection. */
276
+ watchControlQuery<T extends JsonValue = JsonValue, Args extends JsonValue = JsonValue>(ref: FunctionReference<Args, T>, args?: Args): {
277
+ getSnapshot(): Readonly<{
278
+ result: T | undefined;
279
+ version: number;
280
+ }>;
281
+ onUpdate(listener: WatchUpdateHandler): () => void;
282
+ };
283
+ private handleQueryMessage;
284
+ private materializeLiveQuery;
259
285
  private normalizeSubscriptionMessage;
260
286
  private acceptRevision;
261
- watchQuery<T = JsonValue>(ref: FunctionReference, args?: JsonValue): {
262
- localQueryResult(): T | undefined;
263
- onUpdate(handler: WatchUpdateHandler): () => void;
264
- };
265
- subscribeSync(ref: FunctionReference, args: JsonValue | undefined, onMessage: SyncSubscriptionHandler): () => void;
266
- watchSync<T extends JsonValue = JsonValue>(ref: FunctionReference, args?: JsonValue): {
267
- localSyncResult(): T[] | undefined;
268
- status(): {
287
+ private subscribeReplicaTransport;
288
+ /** Subscribe to a bounded Replica Collection. */
289
+ subscribeReplica<Args extends JsonValue = JsonValue, Result extends JsonValue = JsonValue>(ref: FunctionReference<Args, Result>, args: Args | undefined, onMessage: ReplicaSubscriptionHandler): () => void;
290
+ /** Watch a bounded Replica Collection through the normalized Local Replica. */
291
+ watchReplica<T extends JsonValue = JsonValue, Args extends JsonValue = JsonValue>(ref: FunctionReference<Args, T>, args?: Args): {
292
+ localReplicaResult: () => T[] | undefined;
293
+ localReplicaState: () => ReplicaCollectionState | undefined;
294
+ status: () => {
269
295
  isLoading: boolean;
270
296
  isUpToDate: boolean;
271
297
  };
272
298
  onUpdate(handler: WatchUpdateHandler): () => void;
273
299
  };
274
- private handleSyncMessage;
275
- private acceptSyncReady;
276
- private handleSyncWatermark;
277
- private scheduleSyncWatermarkPersistence;
278
- private emitSyncMessage;
279
- private materializeSyncMessage;
300
+ /**
301
+ * Watch a structured Live Query through normalized LocalReplica rows. The
302
+ * latest query result is retained only as the transport-shaped skeleton;
303
+ * its row window is always rebuilt from LocalReplica membership/entities.
304
+ */
305
+ watchLiveQuery<T extends JsonValue = JsonValue, Args extends JsonValue = JsonValue>(ref: FunctionReference<Args, T>, args?: Args): {
306
+ localLiveQueryResult: () => T | undefined;
307
+ onUpdate(handler: WatchUpdateHandler): () => void;
308
+ };
309
+ private handleReplicaMessage;
310
+ private acceptReplicaReady;
311
+ private handleReplicaWatermark;
312
+ private emitReplicaMessage;
313
+ private materializeReplicaMessage;
280
314
  private materializeQueryMessage;
281
315
  private emitOptimisticEntity;
282
316
  private acknowledgeOptimisticSource;
283
317
  private acknowledgeOptimisticQuerySnapshot;
284
- private markSyncSubscriptionsOutOfDate;
285
- private startSync;
286
- private sendSyncOpen;
287
- private syncOpenRequest;
288
- private flushSyncOpens;
289
- private unsubscribeSyncListener;
290
- private persistSyncSnapshot;
291
- private persistSyncDelta;
318
+ private markReplicaSubscriptionsOutOfDate;
319
+ private startReplica;
320
+ private sendReplicaOpen;
321
+ private replicaOpenRequest;
322
+ private flushReplicaOpens;
323
+ private unsubscribeReplicaListener;
292
324
  private activateOutboxScope;
325
+ private activateReplicaDirective;
326
+ private quarantineReplicaScope;
327
+ private rejectMissingReplicaDirective;
328
+ private rejectReplicaDirective;
293
329
  private restoreOutbox;
294
- private addOptimisticMutation;
295
- private settleOptimisticMutation;
296
- private rejectOptimisticMutation;
297
- private ackOptimisticMutation;
330
+ private addOptimisticReducer;
331
+ private settleOptimisticReducer;
332
+ private rejectOptimisticReducer;
333
+ private ackOptimisticReducer;
298
334
  private drainOutbox;
299
335
  private scheduleOutboxDrain;
300
- mutation<T = JsonValue>(ref: FunctionReference, args: JsonValue, options: CallOptions & {
336
+ reducer<T extends JsonValue = JsonValue, Args extends JsonValue = JsonValue>(ref: FunctionReference<Args, T>, args: Args, options: CallOptions & {
301
337
  offline: "queue";
302
- }): Promise<T | QueuedMutationOutcome>;
303
- mutation<T = JsonValue>(ref: FunctionReference, args?: JsonValue, options?: CallOptions): Promise<T>;
304
- private runOptimisticMutation;
305
- action<T = JsonValue>(ref: FunctionReference, args?: JsonValue, options?: CallOptions): Promise<T>;
306
- query<T = JsonValue>(ref: FunctionReference, args?: JsonValue, options?: CallOptions): Promise<T>;
338
+ }): Promise<T | QueuedReducerOutcome>;
339
+ reducer<T extends JsonValue = JsonValue, Args extends JsonValue = JsonValue>(ref: FunctionReference<Args, T>, args?: Args, options?: CallOptions): Promise<T>;
340
+ private runOptimisticReducer;
341
+ action<T extends JsonValue = JsonValue, Args extends JsonValue = JsonValue>(ref: FunctionReference<Args, T>, args?: Args, options?: CallOptions): Promise<T>;
342
+ query<T extends JsonValue = JsonValue, Args extends JsonValue = JsonValue>(ref: FunctionReference<Args, T>, args?: Args, options?: CallOptions): Promise<T>;
307
343
  /**
308
344
  * Force a live query subscription to re-request its result from the server,
309
345
  * e.g. after a `query.error` or when a subscriber gave up waiting. No-op if
310
346
  * nothing is subscribed to this query.
311
347
  */
312
- retryQuery(ref: FunctionReference, args?: JsonValue): void;
348
+ retryLiveQuery(ref: FunctionReference, args?: JsonValue): void;
313
349
  /**
314
- * Flush a queue of mutations in one `mutation.callMany` frame (queue order,
350
+ * Flush a queue of reducers in one `reducer.callMany` frame (queue order,
315
351
  * one websocket round trip). Each entry settles independently — a failed
316
352
  * call does not reject the batch — so offline queues can apply per-row
317
- * outcomes. Falls back to the standard per-mutation path when the runtime
353
+ * outcomes. Falls back to the standard per-reducer path when the runtime
318
354
  * lacks batching or when a call needs generated/explicit optimism or durable
319
- * offline queuing, so there is never a second mutation-state implementation.
355
+ * offline queuing, so there is never a second reducer-state implementation.
320
356
  */
321
- mutationMany<T = JsonValue>(calls: Array<{
357
+ reducerMany<T extends JsonValue = JsonValue>(calls: Array<{
322
358
  ref: FunctionReference;
323
359
  args?: JsonValue;
324
360
  }>, options?: CallOptions): Promise<Array<{
325
361
  status: "ok";
326
- result: T;
362
+ result: T | QueuedReducerOutcome;
327
363
  } | {
328
364
  status: "error";
329
365
  error: GonvexClientError;
@@ -334,25 +370,30 @@ export declare class GonvexClient {
334
370
  private sendSubscription;
335
371
  private flushQuerySubscribes;
336
372
  private resumeQuerySubscriptions;
337
- private enqueueSyncPersistence;
338
- private scheduleSyncRetry;
339
- private clearSyncRetry;
373
+ private resumeReplicaSubscriptions;
374
+ private scheduleReplicaRetry;
375
+ private clearReplicaRetry;
340
376
  private requestSubscriptionSnapshot;
341
377
  private sendOneShotQuery;
342
378
  private resubscribeQueries;
379
+ private sendPendingControlCall;
380
+ private sendInvocation;
381
+ private hasControlPlaneWork;
343
382
  private scheduleReconnect;
344
- private installQueryCacheDirective;
345
- private recoverWarmSyncDirective;
346
- private resetQueryCacheScope;
347
- private resetQueryResultCacheState;
348
- private resetSyncCacheState;
349
- private startQueryCacheRead;
350
- private persistQueryResult;
351
- private deleteCachedQuery;
383
+ private resetReplicaScopeState;
384
+ /**
385
+ * A subscription id is also the server's response routing key. Rotate it on
386
+ * auth scope changes so a delayed frame from the previous tenant cannot be
387
+ * delivered to a handler that now materializes into the new scope.
388
+ */
389
+ private rotateSubscriptionScopes;
352
390
  private emitTelemetryFromCall;
353
391
  private recordTelemetry;
354
392
  private emitTelemetry;
355
393
  private reportTelemetry;
394
+ /** Send a bounded native error-telemetry frame using authenticated connection attribution. */
395
+ reportError(type: "register" | "envelope" | "heartbeat", payload: unknown): Promise<void>;
396
+ private sendNativeError;
356
397
  private sendAuth;
357
398
  private sendAuthFrame;
358
399
  private fetchAndSendAuth;
@@ -363,6 +404,3 @@ export declare class GonvexClient {
363
404
  private sendNow;
364
405
  private flushPendingMessages;
365
406
  }
366
- export declare class ConvexReactClient extends GonvexClient {
367
- constructor(url: string, options?: GonvexClientOptions);
368
- }