@depup/firebase__data-connect 0.4.0-depup.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 (86) hide show
  1. package/README.md +31 -0
  2. package/changes.json +10 -0
  3. package/dist/index.cjs.js +2069 -0
  4. package/dist/index.cjs.js.map +1 -0
  5. package/dist/index.esm.js +2039 -0
  6. package/dist/index.esm.js.map +1 -0
  7. package/dist/index.node.cjs.js +2084 -0
  8. package/dist/index.node.cjs.js.map +1 -0
  9. package/dist/internal.d.ts +748 -0
  10. package/dist/node-esm/index.node.esm.js +2054 -0
  11. package/dist/node-esm/index.node.esm.js.map +1 -0
  12. package/dist/node-esm/package.json +1 -0
  13. package/dist/node-esm/src/api/DataConnect.d.ts +159 -0
  14. package/dist/node-esm/src/api/Mutation.d.ts +61 -0
  15. package/dist/node-esm/src/api/Reference.d.ts +53 -0
  16. package/dist/node-esm/src/api/index.d.ts +25 -0
  17. package/dist/node-esm/src/api/query.d.ts +71 -0
  18. package/dist/node-esm/src/api.browser.d.ts +18 -0
  19. package/dist/node-esm/src/api.node.d.ts +18 -0
  20. package/dist/node-esm/src/cache/Cache.d.ts +53 -0
  21. package/dist/node-esm/src/cache/CacheProvider.d.ts +25 -0
  22. package/dist/node-esm/src/cache/EntityDataObject.d.ts +37 -0
  23. package/dist/node-esm/src/cache/EntityNode.d.ts +56 -0
  24. package/dist/node-esm/src/cache/ImpactedQueryRefsAccumulator.d.ts +23 -0
  25. package/dist/node-esm/src/cache/InMemoryCacheProvider.d.ts +30 -0
  26. package/dist/node-esm/src/cache/ResultTree.d.ts +42 -0
  27. package/dist/node-esm/src/cache/ResultTreeProcessor.d.ts +40 -0
  28. package/dist/node-esm/src/cache/cacheUtils.d.ts +20 -0
  29. package/dist/node-esm/src/core/AppCheckTokenProvider.d.ts +31 -0
  30. package/dist/node-esm/src/core/FirebaseAuthProvider.d.ts +36 -0
  31. package/dist/node-esm/src/core/error.d.ts +53 -0
  32. package/dist/node-esm/src/core/query/QueryManager.d.ts +47 -0
  33. package/dist/node-esm/src/core/query/queryOptions.d.ts +25 -0
  34. package/dist/node-esm/src/core/query/subscribe.d.ts +67 -0
  35. package/dist/node-esm/src/core/version.d.ts +23 -0
  36. package/dist/node-esm/src/index.d.ts +29 -0
  37. package/dist/node-esm/src/index.node.d.ts +18 -0
  38. package/dist/node-esm/src/logger.d.ts +20 -0
  39. package/dist/node-esm/src/network/fetch.d.ts +24 -0
  40. package/dist/node-esm/src/network/index.d.ts +17 -0
  41. package/dist/node-esm/src/network/transport/index.d.ts +81 -0
  42. package/dist/node-esm/src/network/transport/rest.d.ts +49 -0
  43. package/dist/node-esm/src/register.d.ts +1 -0
  44. package/dist/node-esm/src/util/encoder.d.ts +22 -0
  45. package/dist/node-esm/src/util/map.d.ts +17 -0
  46. package/dist/node-esm/src/util/url.d.ts +20 -0
  47. package/dist/node-esm/src/util/validateArgs.d.ts +33 -0
  48. package/dist/private.d.ts +655 -0
  49. package/dist/public.d.ts +350 -0
  50. package/dist/src/api/DataConnect.d.ts +159 -0
  51. package/dist/src/api/Mutation.d.ts +61 -0
  52. package/dist/src/api/Reference.d.ts +53 -0
  53. package/dist/src/api/index.d.ts +25 -0
  54. package/dist/src/api/query.d.ts +71 -0
  55. package/dist/src/api.browser.d.ts +18 -0
  56. package/dist/src/api.node.d.ts +18 -0
  57. package/dist/src/cache/Cache.d.ts +53 -0
  58. package/dist/src/cache/CacheProvider.d.ts +25 -0
  59. package/dist/src/cache/EntityDataObject.d.ts +37 -0
  60. package/dist/src/cache/EntityNode.d.ts +56 -0
  61. package/dist/src/cache/ImpactedQueryRefsAccumulator.d.ts +23 -0
  62. package/dist/src/cache/InMemoryCacheProvider.d.ts +30 -0
  63. package/dist/src/cache/ResultTree.d.ts +42 -0
  64. package/dist/src/cache/ResultTreeProcessor.d.ts +40 -0
  65. package/dist/src/cache/cacheUtils.d.ts +20 -0
  66. package/dist/src/core/AppCheckTokenProvider.d.ts +31 -0
  67. package/dist/src/core/FirebaseAuthProvider.d.ts +36 -0
  68. package/dist/src/core/error.d.ts +53 -0
  69. package/dist/src/core/query/QueryManager.d.ts +47 -0
  70. package/dist/src/core/query/queryOptions.d.ts +25 -0
  71. package/dist/src/core/query/subscribe.d.ts +67 -0
  72. package/dist/src/core/version.d.ts +23 -0
  73. package/dist/src/index.d.ts +29 -0
  74. package/dist/src/index.node.d.ts +18 -0
  75. package/dist/src/logger.d.ts +20 -0
  76. package/dist/src/network/fetch.d.ts +24 -0
  77. package/dist/src/network/index.d.ts +17 -0
  78. package/dist/src/network/transport/index.d.ts +81 -0
  79. package/dist/src/network/transport/rest.d.ts +49 -0
  80. package/dist/src/register.d.ts +1 -0
  81. package/dist/src/tsdoc-metadata.json +11 -0
  82. package/dist/src/util/encoder.d.ts +22 -0
  83. package/dist/src/util/map.d.ts +17 -0
  84. package/dist/src/util/url.d.ts +20 -0
  85. package/dist/src/util/validateArgs.d.ts +33 -0
  86. package/package.json +99 -0
@@ -0,0 +1,655 @@
1
+ /**
2
+ * Firebase Data Connect
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
7
+ import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
8
+ import { AppCheckTokenListener } from '@firebase/app-check-interop-types';
9
+ import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
10
+ import { FirebaseApp } from '@firebase/app';
11
+ import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
12
+ import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
13
+ import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
14
+ import { FirebaseError } from '@firebase/util';
15
+ import { LogLevelString } from '@firebase/logger';
16
+ import { Provider } from '@firebase/component';
17
+
18
+ /* Excluded from this release type: AppCheckTokenProvider */
19
+
20
+ /* Excluded from this release type: areTransportOptionsEqual */
21
+
22
+ declare type AuthTokenListener = (token: string | null) => void;
23
+
24
+ declare interface AuthTokenProvider {
25
+ getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
26
+ addTokenChangeListener(listener: AuthTokenListener): void;
27
+ getAuth(): FirebaseAuthInternal;
28
+ }
29
+
30
+ export declare interface CacheProvider<T extends StorageType> {
31
+ type: T;
32
+ /* Excluded from this release type: initialize */
33
+ }
34
+
35
+ export declare interface CacheSettings {
36
+ cacheProvider: CacheProvider<StorageType>;
37
+ maxAgeSeconds?: number;
38
+ }
39
+
40
+ /**
41
+ * enum representing different flavors of the SDK used by developers
42
+ * use the CallerSdkType for type-checking, and the CallerSdkTypeEnum for value-checking/assigning
43
+ */
44
+ export declare type CallerSdkType = 'Base' | 'Generated' | 'TanstackReactCore' | 'GeneratedReact' | 'TanstackAngularCore' | 'GeneratedAngular';
45
+
46
+ export declare const CallerSdkTypeEnum: {
47
+ readonly Base: "Base";
48
+ readonly Generated: "Generated";
49
+ readonly TanstackReactCore: "TanstackReactCore";
50
+ readonly GeneratedReact: "GeneratedReact";
51
+ readonly TanstackAngularCore: "TanstackAngularCore";
52
+ readonly GeneratedAngular: "GeneratedAngular";
53
+ };
54
+
55
+ export declare type Code = DataConnectErrorCode;
56
+
57
+ export declare const Code: {
58
+ OTHER: DataConnectErrorCode;
59
+ ALREADY_INITIALIZED: DataConnectErrorCode;
60
+ NOT_INITIALIZED: DataConnectErrorCode;
61
+ NOT_SUPPORTED: DataConnectErrorCode;
62
+ INVALID_ARGUMENT: DataConnectErrorCode;
63
+ PARTIAL_ERROR: DataConnectErrorCode;
64
+ UNAUTHORIZED: DataConnectErrorCode;
65
+ };
66
+
67
+ /**
68
+ * Connect to the DataConnect Emulator
69
+ * @param dc Data Connect instance
70
+ * @param host host of emulator server
71
+ * @param port port of emulator server
72
+ * @param sslEnabled use https
73
+ */
74
+ export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
75
+
76
+ /**
77
+ * Connector Config for calling Data Connect backend.
78
+ */
79
+ export declare interface ConnectorConfig {
80
+ location: string;
81
+ connector: string;
82
+ service: string;
83
+ }
84
+
85
+ /**
86
+ * Class representing Firebase Data Connect
87
+ */
88
+ export declare class DataConnect {
89
+ readonly app: FirebaseApp;
90
+ private readonly dataConnectOptions;
91
+ private readonly _authProvider;
92
+ private readonly _appCheckProvider;
93
+ _queryManager: QueryManager;
94
+ _mutationManager: MutationManager;
95
+ isEmulator: boolean;
96
+ _initialized: boolean;
97
+ private _transport;
98
+ private _transportClass;
99
+ private _transportOptions?;
100
+ private _authTokenProvider?;
101
+ _isUsingGeneratedSdk: boolean;
102
+ _callerSdkType: CallerSdkType;
103
+ private _appCheckTokenProvider?;
104
+ private _cacheSettings?;
105
+ /* Excluded from this release type: cache */
106
+ constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
107
+ /* Excluded from this release type: getCache */
108
+ _useGeneratedSdk(): void;
109
+ _setCallerSdkType(callerSdkType: CallerSdkType): void;
110
+ _delete(): Promise<void>;
111
+ getSettings(): ConnectorConfig;
112
+ /* Excluded from this release type: setCacheSettings */
113
+ setInitialized(): void;
114
+ enableEmulator(transportOptions: TransportOptions): void;
115
+ }
116
+
117
+ declare class DataConnectCache {
118
+ private authProvider;
119
+ private projectId;
120
+ private connectorConfig;
121
+ private host;
122
+ cacheSettings: CacheSettings;
123
+ private cacheProvider;
124
+ private uid;
125
+ constructor(authProvider: AuthTokenProvider, projectId: string, connectorConfig: ConnectorConfig, host: string, cacheSettings: CacheSettings);
126
+ initialize(): Promise<void>;
127
+ getIdentifier(uid: string | null): Promise<string>;
128
+ initializeNewProviders(identifier: string): InternalCacheProvider;
129
+ containsResultTree(queryId: string): Promise<boolean>;
130
+ getResultTree(queryId: string): Promise<ResultTree | undefined>;
131
+ getResultJSON(queryId: string): Promise<Record<string, unknown>>;
132
+ update(queryId: string, serverValues: ServerValues, entityIds: Record<string, unknown>): Promise<string[]>;
133
+ }
134
+
135
+ export declare interface DataConnectEntityArray {
136
+ entityIds: string[];
137
+ }
138
+
139
+ /** An error returned by a DataConnect operation. */
140
+ export declare class DataConnectError extends FirebaseError {
141
+ /* Excluded from this release type: name */
142
+ constructor(code: Code, message: string);
143
+ /* Excluded from this release type: toString */
144
+ }
145
+
146
+ export declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error' | 'unauthorized';
147
+
148
+ export declare type DataConnectExtension = {
149
+ path: Array<string | number>;
150
+ } & (DataConnectEntityArray | DataConnectSingleEntity);
151
+
152
+ /* Excluded from this release type: DataConnectExtensionWithMaxAge */
153
+
154
+ /* Excluded from this release type: DataConnectMaxAge */
155
+
156
+ /** An error returned by a DataConnect operation. */
157
+ export declare class DataConnectOperationError extends DataConnectError {
158
+ /* Excluded from this release type: name */
159
+ /** The response received from the backend. */
160
+ readonly response: DataConnectOperationFailureResponse;
161
+ /** @hideconstructor */
162
+ constructor(message: string, response: DataConnectOperationFailureResponse);
163
+ }
164
+
165
+ export declare interface DataConnectOperationFailureResponse {
166
+ readonly data?: Record<string, unknown> | null;
167
+ readonly errors: DataConnectOperationFailureResponseErrorInfo[];
168
+ }
169
+
170
+ export declare interface DataConnectOperationFailureResponseErrorInfo {
171
+ readonly message: string;
172
+ readonly path: Array<string | number>;
173
+ }
174
+
175
+ /**
176
+ * DataConnectOptions including project id
177
+ */
178
+ export declare interface DataConnectOptions extends ConnectorConfig {
179
+ projectId: string;
180
+ }
181
+
182
+ declare interface DataConnectResponse<T> {
183
+ data: T;
184
+ errors: Error[];
185
+ extensions: Extensions;
186
+ }
187
+
188
+ /* Excluded from this release type: DataConnectResponseWithMaxAge */
189
+
190
+ export declare interface DataConnectResult<Data, Variables> extends OpResult<Data> {
191
+ ref: OperationRef<Data, Variables>;
192
+ }
193
+
194
+ export declare interface DataConnectSettings {
195
+ cacheSettings?: CacheSettings;
196
+ }
197
+
198
+ export declare interface DataConnectSingleEntity {
199
+ entityId: string;
200
+ }
201
+
202
+ /**
203
+ * Representation of user provided subscription options.
204
+ */
205
+ export declare interface DataConnectSubscription<Data, Variables> {
206
+ userCallback: OnResultSubscription<Data, Variables>;
207
+ errCallback?: (e?: DataConnectError) => void;
208
+ unsubscribe: () => void;
209
+ }
210
+
211
+ /* Excluded from this release type: DataConnectTransport */
212
+
213
+ export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
214
+
215
+ declare interface DehydratedResultTreeJson {
216
+ rootStub: DehydratedStubDataObject;
217
+ maxAge: number;
218
+ cachedAt: Date;
219
+ lastAccessed: Date;
220
+ }
221
+
222
+ declare interface DehydratedStubDataObject {
223
+ backingData?: EntityDataObjectJson;
224
+ globalID?: string;
225
+ scalars: {
226
+ [key: string]: FDCScalarValue;
227
+ };
228
+ references: {
229
+ [key: string]: DehydratedStubDataObject;
230
+ };
231
+ objectLists: {
232
+ [key: string]: DehydratedStubDataObject[];
233
+ };
234
+ }
235
+
236
+ declare enum EncodingMode {
237
+ hydrated = 0,
238
+ dehydrated = 1
239
+ }
240
+
241
+ declare class EntityDataObject {
242
+ readonly globalID: string;
243
+ getServerValue(key: string): unknown;
244
+ private serverValues;
245
+ private referencedFrom;
246
+ constructor(globalID: string);
247
+ getServerValues(): {
248
+ [key: string]: FDCScalarValue;
249
+ };
250
+ toJSON(): EntityDataObjectJson;
251
+ static fromJSON(json: EntityDataObjectJson): EntityDataObject;
252
+ updateServerValue(key: string, value: FDCScalarValue, requestedFrom: string): string[];
253
+ }
254
+
255
+ declare interface EntityDataObjectJson {
256
+ map: {
257
+ [key: string]: FDCScalarValue;
258
+ };
259
+ referencedFrom: string[];
260
+ globalID: string;
261
+ }
262
+
263
+ declare class EntityNode {
264
+ entityData?: EntityDataObject;
265
+ scalars: Record<string, FDCScalarValue>;
266
+ references: {
267
+ [key: string]: EntityNode;
268
+ };
269
+ objectLists: {
270
+ [key: string]: EntityNode[];
271
+ };
272
+ globalId?: string;
273
+ entityDataKeys: Set<string>;
274
+ loadData(queryId: string, values: FDCScalarValue, entityIds: Record<string, unknown> | undefined, acc: ImpactedQueryRefsAccumulator, cacheProvider: InternalCacheProvider): Promise<void>;
275
+ toJSON(mode: EncodingMode): Record<string, unknown>;
276
+ static fromJson(obj: DehydratedStubDataObject): EntityNode;
277
+ }
278
+
279
+ /**
280
+ * Execute Mutation
281
+ * @param mutationRef mutation to execute
282
+ * @returns `MutationRef`
283
+ */
284
+ export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
285
+
286
+ /**
287
+ * Execute Query
288
+ * @param queryRef query to execute.
289
+ * @returns `QueryPromise`
290
+ */
291
+ export declare function executeQuery<Data, Variables>(queryRef: QueryRef<Data, Variables>, options?: ExecuteQueryOptions): QueryPromise<Data, Variables>;
292
+
293
+ export declare interface ExecuteQueryOptions {
294
+ fetchPolicy: QueryFetchPolicy;
295
+ }
296
+
297
+ export declare interface Extensions {
298
+ dataConnect?: DataConnectExtension[];
299
+ }
300
+
301
+ /* Excluded from this release type: ExtensionsWithMaxAge */
302
+
303
+ /**
304
+ * @license
305
+ * Copyright 2025 Google LLC
306
+ *
307
+ * Licensed under the Apache License, Version 2.0 (the "License");
308
+ * you may not use this file except in compliance with the License.
309
+ * You may obtain a copy of the License at
310
+ *
311
+ * http://www.apache.org/licenses/LICENSE-2.0
312
+ *
313
+ * Unless required by applicable law or agreed to in writing, software
314
+ * distributed under the License is distributed on an "AS IS" BASIS,
315
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
316
+ * See the License for the specific language governing permissions and
317
+ * limitations under the License.
318
+ */
319
+ declare type FDCScalarValue = string | number | boolean | undefined | null | Record<string, unknown> | FDCScalarValue[];
320
+
321
+ /**
322
+ * Initialize DataConnect instance
323
+ * @param options ConnectorConfig
324
+ */
325
+ export declare function getDataConnect(options: ConnectorConfig, settings?: DataConnectSettings): DataConnect;
326
+
327
+ export declare function getDataConnect(options: ConnectorConfig): DataConnect;
328
+
329
+ /**
330
+ * Initialize DataConnect instance
331
+ * @param app FirebaseApp to initialize to.
332
+ * @param connectorConfig ConnectorConfig
333
+ */
334
+ export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig): DataConnect;
335
+
336
+ /**
337
+ * Initialize DataConnect instance
338
+ * @param app FirebaseApp to initialize to.
339
+ * @param connectorConfig ConnectorConfig
340
+ */
341
+ export declare function getDataConnect(app: FirebaseApp, connectorConfig: ConnectorConfig, settings: DataConnectSettings): DataConnect;
342
+
343
+ /**
344
+ * @license
345
+ * Copyright 2025 Google LLC
346
+ *
347
+ * Licensed under the Apache License, Version 2.0 (the "License");
348
+ * you may not use this file except in compliance with the License.
349
+ * You may obtain a copy of the License at
350
+ *
351
+ * http://www.apache.org/licenses/LICENSE-2.0
352
+ *
353
+ * Unless required by applicable law or agreed to in writing, software
354
+ * distributed under the License is distributed on an "AS IS" BASIS,
355
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
356
+ * See the License for the specific language governing permissions and
357
+ * limitations under the License.
358
+ */
359
+ declare class ImpactedQueryRefsAccumulator {
360
+ private queryId;
361
+ impacted: Set<string>;
362
+ constructor(queryId: string);
363
+ add(impacted: string[]): void;
364
+ consumeEvents(): string[];
365
+ }
366
+
367
+ declare interface InternalCacheProvider {
368
+ getEntityData(globalId: string): Promise<EntityDataObject>;
369
+ updateEntityData(entityData: EntityDataObject): Promise<void>;
370
+ getResultTree(queryId: string): Promise<ResultTree | undefined>;
371
+ setResultTree(queryId: string, resultTree: ResultTree): Promise<void>;
372
+ close(): void;
373
+ }
374
+
375
+ /* Excluded from this release type: InternalQueryResult */
376
+
377
+ export declare function makeMemoryCacheProvider(): CacheProvider<'MEMORY'>;
378
+
379
+ export declare const MUTATION_STR = "mutation";
380
+
381
+ /* Excluded from this release type: MutationManager */
382
+
383
+ /**
384
+ * Mutation return value from `executeMutation`
385
+ */
386
+ export declare interface MutationPromise<Data, Variables> extends Promise<MutationResult<Data, Variables>> {
387
+ }
388
+
389
+ export declare interface MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
390
+ refType: typeof MUTATION_STR;
391
+ }
392
+
393
+ /**
394
+ * Creates a `MutationRef`
395
+ * @param dcInstance Data Connect instance
396
+ * @param mutationName name of mutation
397
+ */
398
+ export declare function mutationRef<Data>(dcInstance: DataConnect, mutationName: string): MutationRef<Data, undefined>;
399
+
400
+ /**
401
+ *
402
+ * @param dcInstance Data Connect instance
403
+ * @param mutationName name of mutation
404
+ * @param variables variables to send with mutation
405
+ */
406
+ export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
407
+
408
+ /**
409
+ * Mutation Result from `executeMutation`
410
+ */
411
+ export declare interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
412
+ ref: MutationRef<Data, Variables>;
413
+ }
414
+
415
+ /**
416
+ * `OnCompleteSubscription`
417
+ */
418
+ export declare type OnCompleteSubscription = () => void;
419
+
420
+ /**
421
+ * Signature for `OnErrorSubscription` for `subscribe`
422
+ */
423
+ export declare type OnErrorSubscription = (err?: DataConnectError) => void;
424
+
425
+ /**
426
+ * Signature for `OnResultSubscription` for `subscribe`
427
+ */
428
+ export declare type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
429
+
430
+ export declare interface OperationRef<_Data, Variables> {
431
+ name: string;
432
+ variables: Variables;
433
+ refType: ReferenceType;
434
+ dataConnect: DataConnect;
435
+ }
436
+
437
+ export declare interface OpResult<Data> {
438
+ data: Data;
439
+ source: DataSource;
440
+ fetchTime: string;
441
+ extensions?: Extensions;
442
+ }
443
+
444
+ declare interface ParsedArgs<Variables> {
445
+ dc: DataConnect;
446
+ vars: Variables;
447
+ }
448
+
449
+ /* Excluded from this release type: parseOptions */
450
+
451
+ export declare const QUERY_STR = "query";
452
+
453
+ /**
454
+ * @license
455
+ * Copyright 2025 Google LLC
456
+ *
457
+ * Licensed under the Apache License, Version 2.0 (the "License");
458
+ * you may not use this file except in compliance with the License.
459
+ * You may obtain a copy of the License at
460
+ *
461
+ * http://www.apache.org/licenses/LICENSE-2.0
462
+ *
463
+ * Unless required by applicable law or agreed to in writing, software
464
+ * distributed under the License is distributed on an "AS IS" BASIS,
465
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
466
+ * See the License for the specific language governing permissions and
467
+ * limitations under the License.
468
+ */
469
+ export declare const QueryFetchPolicy: {
470
+ readonly PREFER_CACHE: "PREFER_CACHE";
471
+ readonly CACHE_ONLY: "CACHE_ONLY";
472
+ readonly SERVER_ONLY: "SERVER_ONLY";
473
+ };
474
+
475
+ export declare type QueryFetchPolicy = (typeof QueryFetchPolicy)[keyof typeof QueryFetchPolicy];
476
+
477
+ declare class QueryManager {
478
+ private transport;
479
+ private dc;
480
+ private cache?;
481
+ preferCacheResults<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables>>;
482
+ private callbacks;
483
+ private subscriptionCache;
484
+ constructor(transport: DataConnectTransport, dc: DataConnect, cache?: DataConnectCache | undefined);
485
+ private queue;
486
+ waitForQueuedWrites(): Promise<void>;
487
+ updateSSR<Data, Variables>(updatedData: QueryResult<Data, Variables>): void;
488
+ updateCache<Data, Variables>(result: QueryResult<Data, Variables>, extensions?: DataConnectExtensionWithMaxAge[]): Promise<string[]>;
489
+ addSubscription<Data, Variables>(queryRef: QueryRef<Data, Variables>, onResultCallback: OnResultSubscription<Data, Variables>, onCompleteCallback?: OnCompleteSubscription, onErrorCallback?: OnErrorSubscription, initialCache?: QueryResult<Data, Variables>): () => void;
490
+ fetchServerResults<Data, Variables>(queryRef: QueryRef<Data, Variables>): Promise<QueryResult<Data, Variables>>;
491
+ fetchCacheResults<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables>>;
492
+ publishErrorToSubscribers(key: string, err: unknown): void;
493
+ getFromResultTreeCache<Data, Variables>(queryRef: QueryRef<Data, Variables>, allowStale?: boolean): Promise<QueryResult<Data, Variables> | null>;
494
+ getFromSubscriberCache<Data, Variables>(queryRef: QueryRef<Data, Variables>): Promise<QueryResult<Data, Variables> | undefined>;
495
+ publishDataToSubscribers(key: string, queryResult: QueryResult<unknown, unknown>): void;
496
+ publishCacheResultsToSubscribers(impactedQueries: string[], fetchTime: string): Promise<void>;
497
+ enableEmulator(host: string, port: number): void;
498
+ }
499
+
500
+ /**
501
+ * Promise returned from `executeQuery`
502
+ */
503
+ export declare interface QueryPromise<Data, Variables> extends Promise<QueryResult<Data, Variables>> {
504
+ }
505
+
506
+ /**
507
+ * QueryRef object
508
+ */
509
+ export declare interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
510
+ refType: typeof QUERY_STR;
511
+ }
512
+
513
+ /**
514
+ * Execute Query
515
+ * @param dcInstance Data Connect instance to use.
516
+ * @param queryName Query to execute
517
+ * @returns `QueryRef`
518
+ */
519
+ export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
520
+
521
+ /**
522
+ * Execute Query
523
+ * @param dcInstance Data Connect instance to use.
524
+ * @param queryName Query to execute
525
+ * @param variables Variables to execute with
526
+ * @returns `QueryRef`
527
+ */
528
+ export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
529
+
530
+ /**
531
+ * Result of `executeQuery`
532
+ */
533
+ export declare interface QueryResult<Data, Variables> extends DataConnectResult<Data, Variables> {
534
+ ref: QueryRef<Data, Variables>;
535
+ toJSON: () => SerializedRef<Data, Variables>;
536
+ }
537
+
538
+ /**
539
+ * Signature for unsubscribe from `subscribe`
540
+ */
541
+ export declare type QueryUnsubscribe = () => void;
542
+
543
+ export declare type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;
544
+
545
+ /**
546
+ * Serialized RefInfo as a result of `QueryResult.toJSON().refInfo`
547
+ */
548
+ export declare interface RefInfo<Variables> {
549
+ name: string;
550
+ variables: Variables;
551
+ connectorConfig: DataConnectOptions;
552
+ }
553
+
554
+ declare class ResultTree {
555
+ private rootStub;
556
+ private maxAge;
557
+ readonly cachedAt: Date;
558
+ private _lastAccessed;
559
+ /**
560
+ * Create a {@link ResultTree} from a dehydrated JSON object.
561
+ * @param value The dehydrated JSON object.
562
+ * @returns The {@link ResultTree}.
563
+ */
564
+ static fromJson(value: DehydratedResultTreeJson): ResultTree;
565
+ constructor(rootStub: EntityNode, maxAge: number, cachedAt: Date, _lastAccessed: Date);
566
+ isStale(): boolean;
567
+ updateMaxAge(maxAgeInSeconds: number): void;
568
+ updateAccessed(): void;
569
+ get lastAccessed(): Date;
570
+ getRootStub(): EntityNode;
571
+ }
572
+
573
+ /**
574
+ * Serialized Ref as a result of `QueryResult.toJSON()`
575
+ */
576
+ export declare interface SerializedRef<Data, Variables> extends OpResult<Data> {
577
+ refInfo: RefInfo<Variables>;
578
+ }
579
+
580
+ /**
581
+ * ServerValues
582
+ */
583
+ declare interface ServerValues extends Record<string, unknown> {
584
+ maxAge?: number;
585
+ }
586
+
587
+ export declare function setLogLevel(logLevel: LogLevelString): void;
588
+
589
+ export declare const SOURCE_CACHE = "CACHE";
590
+
591
+ export declare const SOURCE_SERVER = "SERVER";
592
+
593
+ export declare const StorageType: {
594
+ readonly MEMORY: "MEMORY";
595
+ };
596
+
597
+ export declare type StorageType = (typeof StorageType)[keyof typeof StorageType];
598
+
599
+ /**
600
+ * Subscribe to a `QueryRef`
601
+ * @param queryRefOrSerializedResult query ref or serialized result.
602
+ * @param observer observer object to use for subscribing.
603
+ * @returns `SubscriptionOptions`
604
+ */
605
+ export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, observer: SubscriptionOptions<Data, Variables>): QueryUnsubscribe;
606
+
607
+ /**
608
+ * Subscribe to a `QueryRef`
609
+ * @param queryRefOrSerializedResult query ref or serialized result.
610
+ * @param onNext Callback to call when result comes back.
611
+ * @param onError Callback to call when error gets thrown.
612
+ * @param onComplete Called when subscription completes.
613
+ * @returns `SubscriptionOptions`
614
+ */
615
+ export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, onNext: OnResultSubscription<Data, Variables>, onError?: OnErrorSubscription, onComplete?: OnCompleteSubscription): QueryUnsubscribe;
616
+
617
+ /**
618
+ * Representation of full observer options in `subscribe`
619
+ */
620
+ export declare interface SubscriptionOptions<Data, Variables> {
621
+ onNext?: OnResultSubscription<Data, Variables>;
622
+ onErr?: OnErrorSubscription;
623
+ onComplete?: OnCompleteSubscription;
624
+ }
625
+
626
+ /**
627
+ * Delete DataConnect instance
628
+ * @param dataConnect DataConnect instance
629
+ * @returns
630
+ */
631
+ export declare function terminate(dataConnect: DataConnect): Promise<void>;
632
+
633
+ /**
634
+ * Converts serialized ref to query ref
635
+ * @param serializedRef ref to convert to `QueryRef`
636
+ * @returns `QueryRef`
637
+ */
638
+ export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;
639
+
640
+ /* Excluded from this release type: TransportClass */
641
+
642
+ /**
643
+ * Options to connect to emulator
644
+ */
645
+ export declare interface TransportOptions {
646
+ host: string;
647
+ sslEnabled?: boolean;
648
+ port?: number;
649
+ }
650
+
651
+ /* Excluded from this release type: validateArgs */
652
+
653
+ /* Excluded from this release type: validateDCOptions */
654
+
655
+ export { }