@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,748 @@
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
+ /**
19
+ * @internal
20
+ * Abstraction around AppCheck's token fetching capabilities.
21
+ */
22
+ declare class AppCheckTokenProvider {
23
+ private appCheckProvider?;
24
+ private appCheck?;
25
+ private serverAppAppCheckToken?;
26
+ constructor(app: FirebaseApp, appCheckProvider?: Provider<AppCheckInternalComponentName> | undefined);
27
+ getToken(): Promise<AppCheckTokenResult | null>;
28
+ addTokenChangeListener(listener: AppCheckTokenListener): void;
29
+ }
30
+
31
+ /**
32
+ * @internal
33
+ * @param transportOptions1
34
+ * @param transportOptions2
35
+ * @returns
36
+ */
37
+ export declare function areTransportOptionsEqual(transportOptions1: TransportOptions, transportOptions2: TransportOptions): boolean;
38
+
39
+ declare type AuthTokenListener = (token: string | null) => void;
40
+
41
+ declare interface AuthTokenProvider {
42
+ getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData | null>;
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;
58
+ }
59
+
60
+ /**
61
+ * enum representing different flavors of the SDK used by developers
62
+ * use the CallerSdkType for type-checking, and the CallerSdkTypeEnum for value-checking/assigning
63
+ */
64
+ export declare type CallerSdkType = 'Base' | 'Generated' | 'TanstackReactCore' | 'GeneratedReact' | 'TanstackAngularCore' | 'GeneratedAngular';
65
+
66
+ export declare const CallerSdkTypeEnum: {
67
+ readonly Base: "Base";
68
+ readonly Generated: "Generated";
69
+ readonly TanstackReactCore: "TanstackReactCore";
70
+ readonly GeneratedReact: "GeneratedReact";
71
+ readonly TanstackAngularCore: "TanstackAngularCore";
72
+ readonly GeneratedAngular: "GeneratedAngular";
73
+ };
74
+
75
+ export declare type Code = DataConnectErrorCode;
76
+
77
+ export declare const Code: {
78
+ OTHER: DataConnectErrorCode;
79
+ ALREADY_INITIALIZED: DataConnectErrorCode;
80
+ NOT_INITIALIZED: DataConnectErrorCode;
81
+ NOT_SUPPORTED: DataConnectErrorCode;
82
+ INVALID_ARGUMENT: DataConnectErrorCode;
83
+ PARTIAL_ERROR: DataConnectErrorCode;
84
+ UNAUTHORIZED: DataConnectErrorCode;
85
+ };
86
+
87
+ /**
88
+ * Connect to the DataConnect Emulator
89
+ * @param dc Data Connect instance
90
+ * @param host host of emulator server
91
+ * @param port port of emulator server
92
+ * @param sslEnabled use https
93
+ */
94
+ export declare function connectDataConnectEmulator(dc: DataConnect, host: string, port?: number, sslEnabled?: boolean): void;
95
+
96
+ /**
97
+ * Connector Config for calling Data Connect backend.
98
+ */
99
+ export declare interface ConnectorConfig {
100
+ location: string;
101
+ connector: string;
102
+ service: string;
103
+ }
104
+
105
+ /**
106
+ * Class representing Firebase Data Connect
107
+ */
108
+ export declare class DataConnect {
109
+ readonly app: FirebaseApp;
110
+ private readonly dataConnectOptions;
111
+ private readonly _authProvider;
112
+ private readonly _appCheckProvider;
113
+ _queryManager: QueryManager;
114
+ _mutationManager: MutationManager;
115
+ isEmulator: boolean;
116
+ _initialized: boolean;
117
+ private _transport;
118
+ private _transportClass;
119
+ private _transportOptions?;
120
+ private _authTokenProvider?;
121
+ _isUsingGeneratedSdk: boolean;
122
+ _callerSdkType: CallerSdkType;
123
+ private _appCheckTokenProvider?;
124
+ private _cacheSettings?;
125
+ /**
126
+ * @internal
127
+ */
128
+ private cache?;
129
+ constructor(app: FirebaseApp, dataConnectOptions: DataConnectOptions, _authProvider: Provider<FirebaseAuthInternalName>, _appCheckProvider: Provider<AppCheckInternalComponentName>);
130
+ /**
131
+ * @internal
132
+ */
133
+ getCache(): DataConnectCache | undefined;
134
+ _useGeneratedSdk(): void;
135
+ _setCallerSdkType(callerSdkType: CallerSdkType): void;
136
+ _delete(): Promise<void>;
137
+ getSettings(): ConnectorConfig;
138
+ /**
139
+ * @internal
140
+ */
141
+ setCacheSettings(cacheSettings: CacheSettings): void;
142
+ setInitialized(): void;
143
+ enableEmulator(transportOptions: TransportOptions): void;
144
+ }
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
+
168
+ /** An error returned by a DataConnect operation. */
169
+ export declare class DataConnectError extends FirebaseError {
170
+ /** @internal */
171
+ readonly name: string;
172
+ constructor(code: Code, message: string);
173
+ /** @internal */
174
+ toString(): string;
175
+ }
176
+
177
+ export declare type DataConnectErrorCode = 'other' | 'already-initialized' | 'not-initialized' | 'not-supported' | 'invalid-argument' | 'partial-error' | 'unauthorized';
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
+
193
+ /** An error returned by a DataConnect operation. */
194
+ export declare class DataConnectOperationError extends DataConnectError {
195
+ /** @internal */
196
+ readonly name: string;
197
+ /** The response received from the backend. */
198
+ readonly response: DataConnectOperationFailureResponse;
199
+ /** @hideconstructor */
200
+ constructor(message: string, response: DataConnectOperationFailureResponse);
201
+ }
202
+
203
+ export declare interface DataConnectOperationFailureResponse {
204
+ readonly data?: Record<string, unknown> | null;
205
+ readonly errors: DataConnectOperationFailureResponseErrorInfo[];
206
+ }
207
+
208
+ export declare interface DataConnectOperationFailureResponseErrorInfo {
209
+ readonly message: string;
210
+ readonly path: Array<string | number>;
211
+ }
212
+
213
+ /**
214
+ * DataConnectOptions including project id
215
+ */
216
+ export declare interface DataConnectOptions extends ConnectorConfig {
217
+ projectId: string;
218
+ }
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
+
233
+ export declare interface DataConnectResult<Data, Variables> extends OpResult<Data> {
234
+ ref: OperationRef<Data, Variables>;
235
+ }
236
+
237
+ export declare interface DataConnectSettings {
238
+ cacheSettings?: CacheSettings;
239
+ }
240
+
241
+ export declare interface DataConnectSingleEntity {
242
+ entityId: string;
243
+ }
244
+
245
+ /**
246
+ * Representation of user provided subscription options.
247
+ */
248
+ export declare interface DataConnectSubscription<Data, Variables> {
249
+ userCallback: OnResultSubscription<Data, Variables>;
250
+ errCallback?: (e?: DataConnectError) => void;
251
+ unsubscribe: () => void;
252
+ }
253
+
254
+ /**
255
+ * @internal
256
+ */
257
+ export declare interface DataConnectTransport {
258
+ invokeQuery<T, U>(queryName: string, body?: U): Promise<DataConnectResponseWithMaxAge<T>>;
259
+ invokeMutation<T, U>(queryName: string, body?: U): Promise<DataConnectResponse<T>>;
260
+ useEmulator(host: string, port?: number, sslEnabled?: boolean): void;
261
+ onTokenChanged: (token: string | null) => void;
262
+ _setCallerSdkType(callerSdkType: CallerSdkType): void;
263
+ }
264
+
265
+ export declare type DataSource = typeof SOURCE_CACHE | typeof SOURCE_SERVER;
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
+
331
+ /**
332
+ * Execute Mutation
333
+ * @param mutationRef mutation to execute
334
+ * @returns `MutationRef`
335
+ */
336
+ export declare function executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
337
+
338
+ /**
339
+ * Execute Query
340
+ * @param queryRef query to execute.
341
+ * @returns `QueryPromise`
342
+ */
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[];
375
+
376
+ /**
377
+ * Initialize DataConnect instance
378
+ * @param options ConnectorConfig
379
+ */
380
+ export declare function getDataConnect(options: ConnectorConfig, settings?: DataConnectSettings): DataConnect;
381
+
382
+ export declare function getDataConnect(options: ConnectorConfig): DataConnect;
383
+
384
+ /**
385
+ * Initialize DataConnect instance
386
+ * @param app FirebaseApp to initialize to.
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
395
+ */
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'>;
438
+
439
+ export declare const MUTATION_STR = "mutation";
440
+
441
+ /**
442
+ * @internal
443
+ */
444
+ export declare class MutationManager {
445
+ private _transport;
446
+ private _inflight;
447
+ constructor(_transport: DataConnectTransport);
448
+ executeMutation<Data, Variables>(mutationRef: MutationRef<Data, Variables>): MutationPromise<Data, Variables>;
449
+ }
450
+
451
+ /**
452
+ * Mutation return value from `executeMutation`
453
+ */
454
+ export declare interface MutationPromise<Data, Variables> extends Promise<MutationResult<Data, Variables>> {
455
+ }
456
+
457
+ export declare interface MutationRef<Data, Variables> extends OperationRef<Data, Variables> {
458
+ refType: typeof MUTATION_STR;
459
+ }
460
+
461
+ /**
462
+ * Creates a `MutationRef`
463
+ * @param dcInstance Data Connect instance
464
+ * @param mutationName name of mutation
465
+ */
466
+ export declare function mutationRef<Data>(dcInstance: DataConnect, mutationName: string): MutationRef<Data, undefined>;
467
+
468
+ /**
469
+ *
470
+ * @param dcInstance Data Connect instance
471
+ * @param mutationName name of mutation
472
+ * @param variables variables to send with mutation
473
+ */
474
+ export declare function mutationRef<Data, Variables>(dcInstance: DataConnect, mutationName: string, variables: Variables): MutationRef<Data, Variables>;
475
+
476
+ /**
477
+ * Mutation Result from `executeMutation`
478
+ */
479
+ export declare interface MutationResult<Data, Variables> extends DataConnectResult<Data, Variables> {
480
+ ref: MutationRef<Data, Variables>;
481
+ }
482
+
483
+ /**
484
+ * `OnCompleteSubscription`
485
+ */
486
+ export declare type OnCompleteSubscription = () => void;
487
+
488
+ /**
489
+ * Signature for `OnErrorSubscription` for `subscribe`
490
+ */
491
+ export declare type OnErrorSubscription = (err?: DataConnectError) => void;
492
+
493
+ /**
494
+ * Signature for `OnResultSubscription` for `subscribe`
495
+ */
496
+ export declare type OnResultSubscription<Data, Variables> = (res: QueryResult<Data, Variables>) => void;
497
+
498
+ export declare interface OperationRef<_Data, Variables> {
499
+ name: string;
500
+ variables: Variables;
501
+ refType: ReferenceType;
502
+ dataConnect: DataConnect;
503
+ }
504
+
505
+ export declare interface OpResult<Data> {
506
+ data: Data;
507
+ source: DataSource;
508
+ fetchTime: string;
509
+ extensions?: Extensions;
510
+ }
511
+
512
+ declare interface ParsedArgs<Variables> {
513
+ dc: DataConnect;
514
+ vars: Variables;
515
+ }
516
+
517
+ /**
518
+ *
519
+ * @param fullHost
520
+ * @returns TransportOptions
521
+ * @internal
522
+ */
523
+ export declare function parseOptions(fullHost: string): TransportOptions;
524
+
525
+ export declare const QUERY_STR = "query";
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
+
551
+ declare class QueryManager {
552
+ private transport;
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>;
571
+ enableEmulator(host: string, port: number): void;
572
+ }
573
+
574
+ /**
575
+ * Promise returned from `executeQuery`
576
+ */
577
+ export declare interface QueryPromise<Data, Variables> extends Promise<QueryResult<Data, Variables>> {
578
+ }
579
+
580
+ /**
581
+ * QueryRef object
582
+ */
583
+ export declare interface QueryRef<Data, Variables> extends OperationRef<Data, Variables> {
584
+ refType: typeof QUERY_STR;
585
+ }
586
+
587
+ /**
588
+ * Execute Query
589
+ * @param dcInstance Data Connect instance to use.
590
+ * @param queryName Query to execute
591
+ * @returns `QueryRef`
592
+ */
593
+ export declare function queryRef<Data>(dcInstance: DataConnect, queryName: string): QueryRef<Data, undefined>;
594
+
595
+ /**
596
+ * Execute Query
597
+ * @param dcInstance Data Connect instance to use.
598
+ * @param queryName Query to execute
599
+ * @param variables Variables to execute with
600
+ * @returns `QueryRef`
601
+ */
602
+ export declare function queryRef<Data, Variables>(dcInstance: DataConnect, queryName: string, variables: Variables): QueryRef<Data, Variables>;
603
+
604
+ /**
605
+ * Result of `executeQuery`
606
+ */
607
+ export declare interface QueryResult<Data, Variables> extends DataConnectResult<Data, Variables> {
608
+ ref: QueryRef<Data, Variables>;
609
+ toJSON: () => SerializedRef<Data, Variables>;
610
+ }
611
+
612
+ /**
613
+ * Signature for unsubscribe from `subscribe`
614
+ */
615
+ export declare type QueryUnsubscribe = () => void;
616
+
617
+ export declare type ReferenceType = typeof QUERY_STR | typeof MUTATION_STR;
618
+
619
+ /**
620
+ * Serialized RefInfo as a result of `QueryResult.toJSON().refInfo`
621
+ */
622
+ export declare interface RefInfo<Variables> {
623
+ name: string;
624
+ variables: Variables;
625
+ connectorConfig: DataConnectOptions;
626
+ }
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
+
647
+ /**
648
+ * Serialized Ref as a result of `QueryResult.toJSON()`
649
+ */
650
+ export declare interface SerializedRef<Data, Variables> extends OpResult<Data> {
651
+ refInfo: RefInfo<Variables>;
652
+ }
653
+
654
+ /**
655
+ * ServerValues
656
+ */
657
+ declare interface ServerValues extends Record<string, unknown> {
658
+ maxAge?: number;
659
+ }
660
+
661
+ export declare function setLogLevel(logLevel: LogLevelString): void;
662
+
663
+ export declare const SOURCE_CACHE = "CACHE";
664
+
665
+ export declare const SOURCE_SERVER = "SERVER";
666
+
667
+ export declare const StorageType: {
668
+ readonly MEMORY: "MEMORY";
669
+ };
670
+
671
+ export declare type StorageType = (typeof StorageType)[keyof typeof StorageType];
672
+
673
+ /**
674
+ * Subscribe to a `QueryRef`
675
+ * @param queryRefOrSerializedResult query ref or serialized result.
676
+ * @param observer observer object to use for subscribing.
677
+ * @returns `SubscriptionOptions`
678
+ */
679
+ export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, observer: SubscriptionOptions<Data, Variables>): QueryUnsubscribe;
680
+
681
+ /**
682
+ * Subscribe to a `QueryRef`
683
+ * @param queryRefOrSerializedResult query ref or serialized result.
684
+ * @param onNext Callback to call when result comes back.
685
+ * @param onError Callback to call when error gets thrown.
686
+ * @param onComplete Called when subscription completes.
687
+ * @returns `SubscriptionOptions`
688
+ */
689
+ export declare function subscribe<Data, Variables>(queryRefOrSerializedResult: QueryRef<Data, Variables> | SerializedRef<Data, Variables>, onNext: OnResultSubscription<Data, Variables>, onError?: OnErrorSubscription, onComplete?: OnCompleteSubscription): QueryUnsubscribe;
690
+
691
+ /**
692
+ * Representation of full observer options in `subscribe`
693
+ */
694
+ export declare interface SubscriptionOptions<Data, Variables> {
695
+ onNext?: OnResultSubscription<Data, Variables>;
696
+ onErr?: OnErrorSubscription;
697
+ onComplete?: OnCompleteSubscription;
698
+ }
699
+
700
+ /**
701
+ * Delete DataConnect instance
702
+ * @param dataConnect DataConnect instance
703
+ * @returns
704
+ */
705
+ export declare function terminate(dataConnect: DataConnect): Promise<void>;
706
+
707
+ /**
708
+ * Converts serialized ref to query ref
709
+ * @param serializedRef ref to convert to `QueryRef`
710
+ * @returns `QueryRef`
711
+ */
712
+ export declare function toQueryRef<Data, Variables>(serializedRef: SerializedRef<Data, Variables>): QueryRef<Data, Variables>;
713
+
714
+ /**
715
+ * @internal
716
+ */
717
+ export declare type TransportClass = new (options: DataConnectOptions, apiKey?: string, appId?: string, authProvider?: AuthTokenProvider, appCheckProvider?: AppCheckTokenProvider, transportOptions?: TransportOptions, _isUsingGen?: boolean, _callerSdkType?: CallerSdkType) => DataConnectTransport;
718
+
719
+ /**
720
+ * Options to connect to emulator
721
+ */
722
+ export declare interface TransportOptions {
723
+ host: string;
724
+ sslEnabled?: boolean;
725
+ port?: number;
726
+ }
727
+
728
+ /**
729
+ * The generated SDK will allow the user to pass in either the variable or the data connect instance with the variable,
730
+ * and this function validates the variables and returns back the DataConnect instance and variables based on the arguments passed in.
731
+ * @param connectorConfig
732
+ * @param dcOrVars
733
+ * @param vars
734
+ * @param validateVars
735
+ * @returns {DataConnect} and {Variables} instance
736
+ * @internal
737
+ */
738
+ export declare function validateArgs<Variables extends object>(connectorConfig: ConnectorConfig, dcOrVars?: DataConnect | Variables, vars?: Variables, validateVars?: boolean): ParsedArgs<Variables>;
739
+
740
+ /**
741
+ *
742
+ * @param dcOptions
743
+ * @returns {void}
744
+ * @internal
745
+ */
746
+ export declare function validateDCOptions(dcOptions: ConnectorConfig): boolean;
747
+
748
+ export { }