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