@firebase/data-connect 0.3.12 → 0.4.0-canary.78384d32c
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.cjs.js +1012 -210
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1011 -212
- package/dist/index.esm.js.map +1 -1
- package/dist/index.node.cjs.js +960 -158
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/internal.d.ts +311 -25
- package/dist/node-esm/index.node.esm.js +959 -160
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api/DataConnect.d.ts +44 -3
- package/dist/node-esm/src/api/Reference.d.ts +2 -0
- package/dist/node-esm/src/api/index.d.ts +2 -1
- package/dist/node-esm/src/api/query.d.ts +9 -26
- package/dist/node-esm/src/api.browser.d.ts +2 -18
- package/dist/node-esm/src/api.node.d.ts +2 -1
- package/dist/node-esm/src/cache/Cache.d.ts +53 -0
- package/dist/node-esm/src/cache/CacheProvider.d.ts +25 -0
- package/dist/node-esm/src/cache/EntityDataObject.d.ts +37 -0
- package/dist/node-esm/src/cache/EntityNode.d.ts +56 -0
- package/dist/node-esm/src/cache/ImpactedQueryRefsAccumulator.d.ts +23 -0
- package/dist/node-esm/src/cache/InMemoryCacheProvider.d.ts +30 -0
- package/dist/node-esm/src/cache/ResultTree.d.ts +42 -0
- package/dist/node-esm/src/cache/ResultTreeProcessor.d.ts +40 -0
- package/dist/node-esm/src/cache/cacheUtils.d.ts +20 -0
- package/dist/node-esm/src/core/FirebaseAuthProvider.d.ts +3 -1
- package/dist/node-esm/src/core/query/QueryManager.d.ts +47 -0
- package/dist/node-esm/src/core/query/queryOptions.d.ts +25 -0
- package/dist/node-esm/src/core/query/subscribe.d.ts +67 -0
- package/dist/node-esm/src/network/fetch.d.ts +2 -5
- package/dist/node-esm/src/network/index.d.ts +1 -1
- package/dist/node-esm/src/network/transport/index.d.ts +37 -8
- package/dist/node-esm/src/network/transport/rest.d.ts +5 -17
- package/dist/node-esm/src/util/encoder.d.ts +4 -1
- package/dist/node-esm/src/util/url.d.ts +1 -0
- package/dist/private.d.ts +278 -17
- package/dist/public.d.ts +77 -3
- package/dist/src/api/DataConnect.d.ts +44 -3
- package/dist/src/api/Reference.d.ts +2 -0
- package/dist/src/api/index.d.ts +2 -1
- package/dist/src/api/query.d.ts +9 -26
- package/dist/src/api.browser.d.ts +2 -18
- package/dist/src/api.node.d.ts +2 -1
- package/dist/src/cache/Cache.d.ts +53 -0
- package/dist/src/cache/CacheProvider.d.ts +25 -0
- package/dist/src/cache/EntityDataObject.d.ts +37 -0
- package/dist/src/cache/EntityNode.d.ts +56 -0
- package/dist/src/cache/ImpactedQueryRefsAccumulator.d.ts +23 -0
- package/dist/src/cache/InMemoryCacheProvider.d.ts +30 -0
- package/dist/src/cache/ResultTree.d.ts +42 -0
- package/dist/src/cache/ResultTreeProcessor.d.ts +40 -0
- package/dist/src/cache/cacheUtils.d.ts +20 -0
- package/dist/src/core/FirebaseAuthProvider.d.ts +3 -1
- package/dist/src/core/query/QueryManager.d.ts +47 -0
- package/dist/src/core/query/queryOptions.d.ts +25 -0
- package/dist/src/core/query/subscribe.d.ts +67 -0
- package/dist/src/network/fetch.d.ts +2 -5
- package/dist/src/network/index.d.ts +1 -1
- package/dist/src/network/transport/index.d.ts +37 -8
- package/dist/src/network/transport/rest.d.ts +5 -17
- package/dist/src/util/encoder.d.ts +4 -1
- package/dist/src/util/url.d.ts +1 -0
- package/package.json +7 -7
- package/dist/node-esm/src/core/QueryManager.d.ts +0 -45
- package/dist/src/core/QueryManager.d.ts +0 -45
package/dist/internal.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types
|
|
|
8
8
|
import { AppCheckTokenListener } from '@firebase/app-check-interop-types';
|
|
9
9
|
import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
|
|
10
10
|
import { FirebaseApp } from '@firebase/app';
|
|
11
|
+
import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
|
|
11
12
|
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
12
13
|
import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
|
|
13
14
|
import { FirebaseError } from '@firebase/util';
|
|
@@ -40,6 +41,20 @@ declare type AuthTokenListener = (token: string | null) => void;
|
|
|
40
41
|
declare interface AuthTokenProvider {
|
|
41
42
|
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
|
|
42
43
|
addTokenChangeListener(listener: AuthTokenListener): void;
|
|
44
|
+
getAuth(): FirebaseAuthInternal;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export declare interface CacheProvider<T extends StorageType> {
|
|
48
|
+
type: T;
|
|
49
|
+
/**
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
initialize(cacheId: string): InternalCacheProvider;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export declare interface CacheSettings {
|
|
56
|
+
cacheProvider: CacheProvider<StorageType>;
|
|
57
|
+
maxAgeSeconds?: number;
|
|
43
58
|
}
|
|
44
59
|
|
|
45
60
|
/**
|
|
@@ -106,15 +121,50 @@ export declare class DataConnect {
|
|
|
106
121
|
_isUsingGeneratedSdk: boolean;
|
|
107
122
|
_callerSdkType: CallerSdkType;
|
|
108
123
|
private _appCheckTokenProvider?;
|
|
124
|
+
private _cacheSettings?;
|
|
125
|
+
/**
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
private cache?;
|
|
109
129
|
constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
|
|
130
|
+
/**
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
133
|
+
getCache(): DataConnectCache | undefined;
|
|
110
134
|
_useGeneratedSdk(): void;
|
|
111
135
|
_setCallerSdkType(callerSdkType: CallerSdkType): void;
|
|
112
136
|
_delete(): Promise<void>;
|
|
113
137
|
getSettings(): ConnectorConfig;
|
|
138
|
+
/**
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
141
|
+
setCacheSettings(cacheSettings: CacheSettings): void;
|
|
114
142
|
setInitialized(): void;
|
|
115
143
|
enableEmulator(transportOptions: TransportOptions): void;
|
|
116
144
|
}
|
|
117
145
|
|
|
146
|
+
declare class DataConnectCache {
|
|
147
|
+
private authProvider;
|
|
148
|
+
private projectId;
|
|
149
|
+
private connectorConfig;
|
|
150
|
+
private host;
|
|
151
|
+
cacheSettings: CacheSettings;
|
|
152
|
+
private cacheProvider;
|
|
153
|
+
private uid;
|
|
154
|
+
constructor(authProvider: AuthTokenProvider, projectId: string, connectorConfig: ConnectorConfig, host: string, cacheSettings: CacheSettings);
|
|
155
|
+
initialize(): Promise<void>;
|
|
156
|
+
getIdentifier(uid: string | null): Promise<string>;
|
|
157
|
+
initializeNewProviders(identifier: string): InternalCacheProvider;
|
|
158
|
+
containsResultTree(queryId: string): Promise<boolean>;
|
|
159
|
+
getResultTree(queryId: string): Promise<ResultTree | undefined>;
|
|
160
|
+
getResultJSON(queryId: string): Promise<Record<string, unknown>>;
|
|
161
|
+
update(queryId: string, serverValues: ServerValues, entityIds: Record<string, unknown>): Promise<string[]>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export declare interface DataConnectEntityArray {
|
|
165
|
+
entityIds: string[];
|
|
166
|
+
}
|
|
167
|
+
|
|
118
168
|
/** An error returned by a DataConnect operation. */
|
|
119
169
|
export declare class DataConnectError extends FirebaseError {
|
|
120
170
|
/** @internal */
|
|
@@ -126,6 +176,20 @@ export declare class DataConnectError extends FirebaseError {
|
|
|
126
176
|
|
|
127
177
|
export declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error' | 'unauthorized';
|
|
128
178
|
|
|
179
|
+
export declare type DataConnectExtension = {
|
|
180
|
+
path: Array<string | number>;
|
|
181
|
+
} & (DataConnectEntityArray | DataConnectSingleEntity);
|
|
182
|
+
|
|
183
|
+
/** @internal */
|
|
184
|
+
declare type DataConnectExtensionWithMaxAge = {
|
|
185
|
+
path: Array<string | number>;
|
|
186
|
+
} & (DataConnectEntityArray | DataConnectSingleEntity | DataConnectMaxAge);
|
|
187
|
+
|
|
188
|
+
/** @internal */
|
|
189
|
+
declare interface DataConnectMaxAge {
|
|
190
|
+
maxAge: string;
|
|
191
|
+
}
|
|
192
|
+
|
|
129
193
|
/** An error returned by a DataConnect operation. */
|
|
130
194
|
export declare class DataConnectOperationError extends DataConnectError {
|
|
131
195
|
/** @internal */
|
|
@@ -153,17 +217,37 @@ export declare interface DataConnectOptions extends ConnectorConfig {
|
|
|
153
217
|
projectId: string;
|
|
154
218
|
}
|
|
155
219
|
|
|
220
|
+
declare interface DataConnectResponse<T> {
|
|
221
|
+
data: T;
|
|
222
|
+
errors: Error[];
|
|
223
|
+
extensions: Extensions;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** @internal */
|
|
227
|
+
declare interface DataConnectResponseWithMaxAge<T> {
|
|
228
|
+
data: T;
|
|
229
|
+
errors: Error[];
|
|
230
|
+
extensions: ExtensionsWithMaxAge;
|
|
231
|
+
}
|
|
232
|
+
|
|
156
233
|
export declare interface DataConnectResult<Data, Variables> extends OpResult<Data> {
|
|
157
234
|
ref: OperationRef<Data, Variables>;
|
|
158
235
|
}
|
|
159
236
|
|
|
237
|
+
export declare interface DataConnectSettings {
|
|
238
|
+
cacheSettings?: CacheSettings;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export declare interface DataConnectSingleEntity {
|
|
242
|
+
entityId: string;
|
|
243
|
+
}
|
|
244
|
+
|
|
160
245
|
/**
|
|
161
246
|
* Representation of user provided subscription options.
|
|
162
247
|
*/
|
|
163
|
-
declare interface DataConnectSubscription<Data, Variables> {
|
|
248
|
+
export declare interface DataConnectSubscription<Data, Variables> {
|
|
164
249
|
userCallback: OnResultSubscription<Data, Variables>;
|
|
165
250
|
errCallback?: (e?: DataConnectError) => void;
|
|
166
|
-
onCompleteCallback?: () => void;
|
|
167
251
|
unsubscribe: () => void;
|
|
168
252
|
}
|
|
169
253
|
|
|
@@ -171,14 +255,8 @@ declare interface DataConnectSubscription<Data, Variables> {
|
|
|
171
255
|
* @internal
|
|
172
256
|
*/
|
|
173
257
|
export declare interface DataConnectTransport {
|
|
174
|
-
invokeQuery<T, U>(queryName: string, body?: U): Promise<
|
|
175
|
-
|
|
176
|
-
errors: Error[];
|
|
177
|
-
}>;
|
|
178
|
-
invokeMutation<T, U>(queryName: string, body?: U): Promise<{
|
|
179
|
-
data: T;
|
|
180
|
-
errors: Error[];
|
|
181
|
-
}>;
|
|
258
|
+
invokeQuery<T, U>(queryName: string, body?: U): Promise<DataConnectResponseWithMaxAge<T>>;
|
|
259
|
+
invokeMutation<T, U>(queryName: string, body?: U): Promise<DataConnectResponse<T>>;
|
|
182
260
|
useEmulator(host: string, port?: number, sslEnabled?: boolean): void;
|
|
183
261
|
onTokenChanged: (token: string | null) => void;
|
|
184
262
|
_setCallerSdkType(callerSdkType: CallerSdkType): void;
|
|
@@ -186,6 +264,70 @@ export declare interface DataConnectTransport {
|
|
|
186
264
|
|
|
187
265
|
export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
|
|
188
266
|
|
|
267
|
+
declare interface DehydratedResultTreeJson {
|
|
268
|
+
rootStub: DehydratedStubDataObject;
|
|
269
|
+
maxAge: number;
|
|
270
|
+
cachedAt: Date;
|
|
271
|
+
lastAccessed: Date;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
declare interface DehydratedStubDataObject {
|
|
275
|
+
backingData?: EntityDataObjectJson;
|
|
276
|
+
globalID?: string;
|
|
277
|
+
scalars: {
|
|
278
|
+
[key: string]: FDCScalarValue;
|
|
279
|
+
};
|
|
280
|
+
references: {
|
|
281
|
+
[key: string]: DehydratedStubDataObject;
|
|
282
|
+
};
|
|
283
|
+
objectLists: {
|
|
284
|
+
[key: string]: DehydratedStubDataObject[];
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
declare enum EncodingMode {
|
|
289
|
+
hydrated = 0,
|
|
290
|
+
dehydrated = 1
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
declare class EntityDataObject {
|
|
294
|
+
readonly globalID: string;
|
|
295
|
+
getServerValue(key: string): unknown;
|
|
296
|
+
private serverValues;
|
|
297
|
+
private referencedFrom;
|
|
298
|
+
constructor(globalID: string);
|
|
299
|
+
getServerValues(): {
|
|
300
|
+
[key: string]: FDCScalarValue;
|
|
301
|
+
};
|
|
302
|
+
toJSON(): EntityDataObjectJson;
|
|
303
|
+
static fromJSON(json: EntityDataObjectJson): EntityDataObject;
|
|
304
|
+
updateServerValue(key: string, value: FDCScalarValue, requestedFrom: string): string[];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
declare interface EntityDataObjectJson {
|
|
308
|
+
map: {
|
|
309
|
+
[key: string]: FDCScalarValue;
|
|
310
|
+
};
|
|
311
|
+
referencedFrom: string[];
|
|
312
|
+
globalID: string;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
declare class EntityNode {
|
|
316
|
+
entityData?: EntityDataObject;
|
|
317
|
+
scalars: Record<string, FDCScalarValue>;
|
|
318
|
+
references: {
|
|
319
|
+
[key: string]: EntityNode;
|
|
320
|
+
};
|
|
321
|
+
objectLists: {
|
|
322
|
+
[key: string]: EntityNode[];
|
|
323
|
+
};
|
|
324
|
+
globalId?: string;
|
|
325
|
+
entityDataKeys: Set<string>;
|
|
326
|
+
loadData(queryId: string, values: FDCScalarValue, entityIds: Record<string, unknown> | undefined, acc: ImpactedQueryRefsAccumulator, cacheProvider: InternalCacheProvider): Promise<void>;
|
|
327
|
+
toJSON(mode: EncodingMode): Record<string, unknown>;
|
|
328
|
+
static fromJson(obj: DehydratedStubDataObject): EntityNode;
|
|
329
|
+
}
|
|
330
|
+
|
|
189
331
|
/**
|
|
190
332
|
* Execute Mutation
|
|
191
333
|
* @param mutationRef mutation to execute
|
|
@@ -198,20 +340,101 @@ export declare function executeMutation<Data, Variables>(mutationRef: MutationRe
|
|
|
198
340
|
* @param queryRef query to execute.
|
|
199
341
|
* @returns `QueryPromise`
|
|
200
342
|
*/
|
|
201
|
-
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables
|
|
343
|
+
export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>, options?: ExecuteQueryOptions): QueryPromise<Data, Variables>;
|
|
344
|
+
|
|
345
|
+
export declare interface ExecuteQueryOptions {
|
|
346
|
+
fetchPolicy: QueryFetchPolicy;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export declare interface Extensions {
|
|
350
|
+
dataConnect?: DataConnectExtension[];
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/** @internal */
|
|
354
|
+
declare interface ExtensionsWithMaxAge {
|
|
355
|
+
dataConnect?: DataConnectExtensionWithMaxAge[];
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* @license
|
|
360
|
+
* Copyright 2025 Google LLC
|
|
361
|
+
*
|
|
362
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
363
|
+
* you may not use this file except in compliance with the License.
|
|
364
|
+
* You may obtain a copy of the License at
|
|
365
|
+
*
|
|
366
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
367
|
+
*
|
|
368
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
369
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
370
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
371
|
+
* See the License for the specific language governing permissions and
|
|
372
|
+
* limitations under the License.
|
|
373
|
+
*/
|
|
374
|
+
declare type FDCScalarValue = string | number | boolean | undefined | null | Record<string, unknown> | FDCScalarValue[];
|
|
202
375
|
|
|
203
376
|
/**
|
|
204
377
|
* Initialize DataConnect instance
|
|
205
378
|
* @param options ConnectorConfig
|
|
206
379
|
*/
|
|
380
|
+
export declare function getDataConnect(options: ConnectorConfig, settings?: DataConnectSettings): DataConnect;
|
|
381
|
+
|
|
207
382
|
export declare function getDataConnect(options: ConnectorConfig): DataConnect;
|
|
208
383
|
|
|
209
384
|
/**
|
|
210
385
|
* Initialize DataConnect instance
|
|
211
386
|
* @param app FirebaseApp to initialize to.
|
|
212
|
-
* @param
|
|
387
|
+
* @param connectorConfig ConnectorConfig
|
|
388
|
+
*/
|
|
389
|
+
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig): DataConnect;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Initialize DataConnect instance
|
|
393
|
+
* @param app FirebaseApp to initialize to.
|
|
394
|
+
* @param connectorConfig ConnectorConfig
|
|
213
395
|
*/
|
|
214
|
-
export declare function getDataConnect(app: FirebaseApp,
|
|
396
|
+
export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig, settings: DataConnectSettings): DataConnect;
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* @license
|
|
400
|
+
* Copyright 2025 Google LLC
|
|
401
|
+
*
|
|
402
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
403
|
+
* you may not use this file except in compliance with the License.
|
|
404
|
+
* You may obtain a copy of the License at
|
|
405
|
+
*
|
|
406
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
407
|
+
*
|
|
408
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
409
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
410
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
411
|
+
* See the License for the specific language governing permissions and
|
|
412
|
+
* limitations under the License.
|
|
413
|
+
*/
|
|
414
|
+
declare class ImpactedQueryRefsAccumulator {
|
|
415
|
+
private queryId;
|
|
416
|
+
impacted: Set<string>;
|
|
417
|
+
constructor(queryId: string);
|
|
418
|
+
add(impacted: string[]): void;
|
|
419
|
+
consumeEvents(): string[];
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
declare interface InternalCacheProvider {
|
|
423
|
+
getEntityData(globalId: string): Promise<EntityDataObject>;
|
|
424
|
+
updateEntityData(entityData: EntityDataObject): Promise<void>;
|
|
425
|
+
getResultTree(queryId: string): Promise<ResultTree | undefined>;
|
|
426
|
+
setResultTree(queryId: string, resultTree: ResultTree): Promise<void>;
|
|
427
|
+
close(): void;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/** @internal */
|
|
431
|
+
export declare type InternalQueryResult<Data, Variables> = QueryResult<Data, Variables> & Omit<DataConnectResult<Data, Variables>, 'extensions'> & {
|
|
432
|
+
extensions?: {
|
|
433
|
+
dataConnect?: DataConnectExtensionWithMaxAge[];
|
|
434
|
+
};
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
export declare function makeMemoryCacheProvider(): CacheProvider<'MEMORY'>;
|
|
215
438
|
|
|
216
439
|
export declare const MUTATION_STR = "mutation";
|
|
217
440
|
|
|
@@ -283,6 +506,7 @@ export declare interface OpResult<Data> {
|
|
|
283
506
|
data: Data;
|
|
284
507
|
source: DataSource;
|
|
285
508
|
fetchTime: string;
|
|
509
|
+
extensions?: Extensions;
|
|
286
510
|
}
|
|
287
511
|
|
|
288
512
|
declare interface ParsedArgs<Variables> {
|
|
@@ -300,13 +524,50 @@ export declare function parseOptions(fullHost: string): TransportOptions;
|
|
|
300
524
|
|
|
301
525
|
export declare const QUERY_STR = "query";
|
|
302
526
|
|
|
527
|
+
/**
|
|
528
|
+
* @license
|
|
529
|
+
* Copyright 2025 Google LLC
|
|
530
|
+
*
|
|
531
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
532
|
+
* you may not use this file except in compliance with the License.
|
|
533
|
+
* You may obtain a copy of the License at
|
|
534
|
+
*
|
|
535
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
536
|
+
*
|
|
537
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
538
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
539
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
540
|
+
* See the License for the specific language governing permissions and
|
|
541
|
+
* limitations under the License.
|
|
542
|
+
*/
|
|
543
|
+
export declare const QueryFetchPolicy: {
|
|
544
|
+
readonly PREFER_CACHE: "PREFER_CACHE";
|
|
545
|
+
readonly CACHE_ONLY: "CACHE_ONLY";
|
|
546
|
+
readonly SERVER_ONLY: "SERVER_ONLY";
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
export declare type QueryFetchPolicy = (typeof QueryFetchPolicy)[keyof typeof QueryFetchPolicy];
|
|
550
|
+
|
|
303
551
|
declare class QueryManager {
|
|
304
552
|
private transport;
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
553
|
+
private dc;
|
|
554
|
+
private cache?;
|
|
555
|
+
preferCacheResults<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables>>;
|
|
556
|
+
private callbacks;
|
|
557
|
+
private subscriptionCache;
|
|
558
|
+
constructor(transport: DataConnectTransport, dc: DataConnect, cache?: DataConnectCache | undefined);
|
|
559
|
+
private queue;
|
|
560
|
+
waitForQueuedWrites(): Promise<void>;
|
|
561
|
+
updateSSR<Data, Variables>(updatedData: QueryResult<Data, Variables>): void;
|
|
562
|
+
updateCache<Data, Variables>(result: QueryResult<Data, Variables>, extensions?: DataConnectExtensionWithMaxAge[]): Promise<string[]>;
|
|
563
|
+
addSubscription<Data, Variables>(queryRef: QueryRef<Data, Variables>, onResultCallback: OnResultSubscription<Data, Variables>, onCompleteCallback?: OnCompleteSubscription, onErrorCallback?: OnErrorSubscription, initialCache?: QueryResult<Data, Variables>): () => void;
|
|
564
|
+
fetchServerResults<Data, Variables>(queryRef: QueryRef<Data, Variables>): Promise<QueryResult<Data, Variables>>;
|
|
565
|
+
fetchCacheResults<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables>>;
|
|
566
|
+
publishErrorToSubscribers(key: string, err: unknown): void;
|
|
567
|
+
getFromResultTreeCache<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables> | null>;
|
|
568
|
+
getFromSubscriberCache<Data, Variables>(queryRef: QueryRef<Data, Variables>): Promise<QueryResult<Data, Variables> | undefined>;
|
|
569
|
+
publishDataToSubscribers(key: string, queryResult: QueryResult<unknown, unknown>): void;
|
|
570
|
+
publishCacheResultsToSubscribers(impactedQueries: string[], fetchTime: string): Promise<void>;
|
|
310
571
|
enableEmulator(host: string, port: number): void;
|
|
311
572
|
}
|
|
312
573
|
|
|
@@ -364,6 +625,25 @@ export declare interface RefInfo<Variables> {
|
|
|
364
625
|
connectorConfig: DataConnectOptions;
|
|
365
626
|
}
|
|
366
627
|
|
|
628
|
+
declare class ResultTree {
|
|
629
|
+
private rootStub;
|
|
630
|
+
private maxAge;
|
|
631
|
+
readonly cachedAt: Date;
|
|
632
|
+
private _lastAccessed;
|
|
633
|
+
/**
|
|
634
|
+
* Create a {@link ResultTree} from a dehydrated JSON object.
|
|
635
|
+
* @param value The dehydrated JSON object.
|
|
636
|
+
* @returns The {@link ResultTree}.
|
|
637
|
+
*/
|
|
638
|
+
static fromJson(value: DehydratedResultTreeJson): ResultTree;
|
|
639
|
+
constructor(rootStub: EntityNode, maxAge: number, cachedAt: Date, _lastAccessed: Date);
|
|
640
|
+
isStale(): boolean;
|
|
641
|
+
updateMaxAge(maxAgeInSeconds: number): void;
|
|
642
|
+
updateAccessed(): void;
|
|
643
|
+
get lastAccessed(): Date;
|
|
644
|
+
getRootStub(): EntityNode;
|
|
645
|
+
}
|
|
646
|
+
|
|
367
647
|
/**
|
|
368
648
|
* Serialized Ref as a result of `QueryResult.toJSON()`
|
|
369
649
|
*/
|
|
@@ -371,12 +651,25 @@ export declare interface SerializedRef<Data, Variables> extends OpResult<Data> {
|
|
|
371
651
|
refInfo: RefInfo<Variables>;
|
|
372
652
|
}
|
|
373
653
|
|
|
654
|
+
/**
|
|
655
|
+
* ServerValues
|
|
656
|
+
*/
|
|
657
|
+
declare interface ServerValues extends Record<string, unknown> {
|
|
658
|
+
maxAge?: number;
|
|
659
|
+
}
|
|
660
|
+
|
|
374
661
|
export declare function setLogLevel(logLevel: LogLevelString): void;
|
|
375
662
|
|
|
376
663
|
export declare const SOURCE_CACHE = "CACHE";
|
|
377
664
|
|
|
378
665
|
export declare const SOURCE_SERVER = "SERVER";
|
|
379
666
|
|
|
667
|
+
export declare const StorageType: {
|
|
668
|
+
readonly MEMORY: "MEMORY";
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
export declare type StorageType = (typeof StorageType)[keyof typeof StorageType];
|
|
672
|
+
|
|
380
673
|
/**
|
|
381
674
|
* Subscribe to a `QueryRef`
|
|
382
675
|
* @param queryRefOrSerializedResult query ref or serialized result.
|
|
@@ -418,13 +711,6 @@ export declare function terminate(dataConnect: DataConnect): Promise<void>;
|
|
|
418
711
|
*/
|
|
419
712
|
export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;
|
|
420
713
|
|
|
421
|
-
declare interface TrackedQuery<Data, Variables> {
|
|
422
|
-
ref: Omit<OperationRef<Data, Variables>, 'dataConnect'>;
|
|
423
|
-
subscriptions: Array<DataConnectSubscription<Data, Variables>>;
|
|
424
|
-
currentCache: OpResult<Data> | null;
|
|
425
|
-
lastError: DataConnectError | null;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
714
|
/**
|
|
429
715
|
* @internal
|
|
430
716
|
*/
|