@gonvex/client 0.5.1 → 0.5.2-staging.1

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/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { GonvexErrorReporter } from "./error-reporter.js";
4
4
  export type { ErrorReporterOptions, ErrorEventPayload, ErrorContext, ErrorAccount } from "./error-reporter.js";
5
5
  import { type OptimisticPatch, type OptimisticTransactionDefinition } from "./optimistic.js";
6
6
  import { type OutboxStore } from "./outbox.js";
7
- import { type LocalReplicaStorage, type LocalReplicaView, type ReplicaRow, type LiveQueryResult, type ReplicaCollectionState } from "./local-replica.js";
7
+ import { type LocalReplicaStorage, type LocalReplicaView, type ReplicaRow, type LiveQueryResult, type ReplicaCollectionState, type ReplicaCollectionSubscriptionState, type ReplicaCollectionPlan } from "./local-replica.js";
8
8
  import { type LiveQueryPlan, type OfflineLiveQueryResult } from "./query-expression.js";
9
9
  export * from "./error-reporter.js";
10
10
  export * from "./optimistic.js";
@@ -12,7 +12,7 @@ export * from "./outbox.js";
12
12
  export * from "./kv-stores.js";
13
13
  export * from "./signals.js";
14
14
  export * from "./external-auth.js";
15
- 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 { MemoryLocalReplicaStorage, type LocalReplicaStorage, type LocalReplicaView, type ReplicaChange, type ReplicaFreshness, type ReplicaRow, type ReplicaScope, type ReplicaSnapshot, type ReplicaTransaction, type ReplicaWindow, type LiveQueryResult, type ReplicaCollectionState, type ReplicaCollectionSubscriptionState, type ReplicaCollectionPlan, } from "./local-replica.js";
16
16
  export * from "./query-expression.js";
17
17
  export * from "./indexeddb-replica.js";
18
18
  export * from "./control.js";
@@ -55,11 +55,17 @@ export type FunctionReference<Args extends JsonValue = JsonValue, Result extends
55
55
  resultPath?: readonly string[];
56
56
  plan: LiveQueryPlan;
57
57
  };
58
+ replica?: ReplicaCollectionPlan & {
59
+ columns?: readonly string[];
60
+ mode?: "eager" | "progressive";
61
+ maxRows?: number;
62
+ maxBytes?: number;
63
+ };
58
64
  optimistic?: {
59
65
  transaction?: OptimisticTransactionDefinition;
60
66
  };
61
67
  };
62
- export type GonvexClientErrorCode = "server" | "timeout" | "disconnected" | "closed" | "auth";
68
+ export type GonvexClientErrorCode = "server" | "timeout" | "disconnected" | "closed" | "auth" | "superseded";
63
69
  /**
64
70
  * Typed error for every rejected Gonvex operation. `code` distinguishes
65
71
  * server-side failures from transport-level ones so apps can decide whether
@@ -72,6 +78,8 @@ export type GonvexClientErrorCode = "server" | "timeout" | "disconnected" | "clo
72
78
  * Reducers/actions fail closed unless a reducer opted into the outbox.
73
79
  * - `closed`: the client was explicitly closed.
74
80
  * - `auth`: authentication was rejected.
81
+ * - `superseded`: the operation belonged to an authentication scope that the
82
+ * caller replaced before the operation completed.
75
83
  */
76
84
  export declare class GonvexClientError extends Error {
77
85
  readonly code: GonvexClientErrorCode;
@@ -204,6 +212,9 @@ export declare class GonvexClient {
204
212
  private activeArtifactHashValue;
205
213
  private auth;
206
214
  private authInFlight;
215
+ private latestAuthFrameId;
216
+ private activeAuthFrameId;
217
+ private authResendRequired;
207
218
  private authWatchdogTimer;
208
219
  private authFetchGeneration;
209
220
  private authRetriedAfterError;
@@ -216,6 +227,8 @@ export declare class GonvexClient {
216
227
  private readonly replica;
217
228
  private readonly replicaView;
218
229
  private readonly optimisticReducerIds;
230
+ /** Reducers currently owned by the foreground send path, never by recovery. */
231
+ private readonly directOutboxReducerIds;
219
232
  private readonly optimisticOutboxEntryIds;
220
233
  private outboxReady;
221
234
  private outboxScope;
@@ -224,7 +237,11 @@ export declare class GonvexClient {
224
237
  private replicaScope;
225
238
  private hasAuthoritativeReplicaScope;
226
239
  private replicaReady;
240
+ private replicaFrames;
241
+ private processedReplicaWatermarkRevision;
242
+ private readonly pendingReplicaTransactions;
227
243
  private readonly unsubscribeOutbox;
244
+ private readonly unsubscribeBrowserOnline;
228
245
  private drainingOutbox;
229
246
  private outboxDrainTimer;
230
247
  private readonly sessionScopeHandlers;
@@ -232,6 +249,7 @@ export declare class GonvexClient {
232
249
  private reconnectTimer;
233
250
  private reconnectAttempt;
234
251
  private socketGeneration;
252
+ private authenticatedSocketGeneration;
235
253
  private manuallyClosed;
236
254
  private readonly pendingCalls;
237
255
  private readonly connectionStateHandlers;
@@ -302,7 +320,7 @@ export declare class GonvexClient {
302
320
  /** Watch a bounded Replica Collection through the normalized Local Replica. */
303
321
  watchReplica<T extends JsonValue = JsonValue, Args extends JsonValue = JsonValue>(ref: FunctionReference<Args, T>, args?: Args): {
304
322
  localReplicaResult: () => T[] | undefined;
305
- localReplicaState: () => ReplicaCollectionState | undefined;
323
+ localReplicaState: () => ReplicaCollectionSubscriptionState | undefined;
306
324
  status: () => {
307
325
  isLoading: boolean;
308
326
  isUpToDate: boolean;
@@ -319,6 +337,9 @@ export declare class GonvexClient {
319
337
  onUpdate(handler: WatchUpdateHandler): () => void;
320
338
  };
321
339
  private handleReplicaMessage;
340
+ private enqueueReplicaFrame;
341
+ private enqueueReplicaTransaction;
342
+ private drainPendingReplicaTransactions;
322
343
  private acceptReplicaReady;
323
344
  private handleReplicaWatermark;
324
345
  private emitReplicaMessage;
@@ -350,6 +371,7 @@ export declare class GonvexClient {
350
371
  }): Promise<T | QueuedReducerOutcome>;
351
372
  reducer<T extends JsonValue = JsonValue, Args extends JsonValue = JsonValue>(ref: FunctionReference<Args, T>, args?: Args, options?: CallOptions): Promise<T>;
352
373
  private runOptimisticReducer;
374
+ private canSendReducerNow;
353
375
  action<T extends JsonValue = JsonValue, Args extends JsonValue = JsonValue>(ref: FunctionReference<Args, T>, args?: Args, options?: CallOptions): Promise<T>;
354
376
  query<T extends JsonValue = JsonValue, Args extends JsonValue = JsonValue>(ref: FunctionReference<Args, T>, args?: Args, options?: CallOptions): Promise<T>;
355
377
  /**