@firebase/data-connect 0.0.1-dataconnect-preview.81ee5169c → 0.0.2-dataconnect-preview.388b61c7e

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 (38) hide show
  1. package/dist/index.cjs.js +181 -141
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.esm2017.js +180 -140
  4. package/dist/index.esm2017.js.map +1 -1
  5. package/dist/index.esm5.js +183 -143
  6. package/dist/index.esm5.js.map +1 -1
  7. package/dist/index.node.cjs.js +132 -72
  8. package/dist/index.node.cjs.js.map +1 -1
  9. package/dist/internal.d.ts +156 -44
  10. package/dist/node-esm/index.node.esm.js +132 -72
  11. package/dist/node-esm/index.node.esm.js.map +1 -1
  12. package/dist/node-esm/src/api/DataConnect.d.ts +39 -12
  13. package/dist/node-esm/src/api/Mutation.d.ts +33 -8
  14. package/dist/node-esm/src/api/Reference.d.ts +9 -3
  15. package/dist/node-esm/src/api/query.d.ts +52 -2
  16. package/dist/node-esm/src/api.browser.d.ts +12 -7
  17. package/dist/node-esm/src/core/FirebaseAuthProvider.d.ts +5 -5
  18. package/dist/node-esm/src/core/QueryManager.d.ts +7 -7
  19. package/dist/node-esm/src/network/transport/rest.d.ts +13 -25
  20. package/dist/node-esm/src/util/url.d.ts +2 -2
  21. package/dist/private.d.ts +151 -47
  22. package/dist/public.d.ts +135 -37
  23. package/dist/src/api/DataConnect.d.ts +39 -12
  24. package/dist/src/api/Mutation.d.ts +33 -8
  25. package/dist/src/api/Reference.d.ts +9 -3
  26. package/dist/src/api/query.d.ts +52 -2
  27. package/dist/src/api.browser.d.ts +12 -7
  28. package/dist/src/core/FirebaseAuthProvider.d.ts +5 -5
  29. package/dist/src/core/QueryManager.d.ts +7 -7
  30. package/dist/src/network/transport/rest.d.ts +13 -25
  31. package/dist/src/util/url.d.ts +2 -2
  32. package/package.json +7 -7
  33. package/dist/node-esm/test/emulatorSeeder.d.ts +0 -22
  34. package/dist/node-esm/test/queries.test.d.ts +0 -17
  35. package/dist/node-esm/test/util.d.ts +0 -26
  36. package/dist/test/emulatorSeeder.d.ts +0 -22
  37. package/dist/test/queries.test.d.ts +0 -17
  38. package/dist/test/util.d.ts +0 -26
@@ -1,10 +1,10 @@
1
1
  import { _removeServiceInstance, getApp, _getProvider, _registerComponent, registerVersion, SDK_VERSION as SDK_VERSION$1 } from '@firebase/app';
2
2
  import { Component } from '@firebase/component';
3
- import { Logger } from '@firebase/logger';
4
3
  import { FirebaseError } from '@firebase/util';
4
+ import { Logger } from '@firebase/logger';
5
5
 
6
6
  const name = "@firebase/data-connect";
7
- const version = "0.0.1-dataconnect-preview.81ee5169c";
7
+ const version = "0.0.2-dataconnect-preview.388b61c7e";
8
8
 
9
9
  /**
10
10
  * @license
@@ -32,6 +32,52 @@ function setSDKVersion(version) {
32
32
  SDK_VERSION = version;
33
33
  }
34
34
 
35
+ /**
36
+ * @license
37
+ * Copyright 2024 Google LLC
38
+ *
39
+ * Licensed under the Apache License, Version 2.0 (the "License");
40
+ * you may not use this file except in compliance with the License.
41
+ * You may obtain a copy of the License at
42
+ *
43
+ * http://www.apache.org/licenses/LICENSE-2.0
44
+ *
45
+ * Unless required by applicable law or agreed to in writing, software
46
+ * distributed under the License is distributed on an "AS IS" BASIS,
47
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48
+ * See the License for the specific language governing permissions and
49
+ * limitations under the License.
50
+ */
51
+ const Code = {
52
+ OTHER: 'other',
53
+ ALREADY_INITIALIZED: 'already-initialized',
54
+ NOT_INITIALIZED: 'not-initialized',
55
+ NOT_SUPPORTED: 'not-supported',
56
+ INVALID_ARGUMENT: 'invalid-argument',
57
+ PARTIAL_ERROR: 'partial-error'
58
+ };
59
+ /** An error returned by a DataConnect operation. */
60
+ class DataConnectError extends FirebaseError {
61
+ /** @hideconstructor */
62
+ constructor(
63
+ /**
64
+ * The backend error code associated with this error.
65
+ */
66
+ code,
67
+ /**
68
+ * A custom error description.
69
+ */
70
+ message) {
71
+ super(code, message);
72
+ this.code = code;
73
+ this.message = message;
74
+ // HACK: We write a toString property directly because Error is not a real
75
+ // class and so inheritance does not work correctly. We could alternatively
76
+ // do the same "back-door inheritance" trick that FirebaseError does.
77
+ this.toString = () => `${this.name}: [code=${this.code}]: ${this.message}`;
78
+ }
79
+ }
80
+
35
81
  /**
36
82
  * @license
37
83
  * Copyright 2024 Google LLC
@@ -76,20 +122,20 @@ function logError(msg) {
76
122
  * limitations under the License.
77
123
  */
78
124
  class FirebaseAuthProvider {
79
- constructor(appName, options, authProvider_) {
80
- this.appName = appName;
81
- this.options = options;
82
- this.authProvider_ = authProvider_;
83
- this.auth_ = authProvider_.getImmediate({ optional: true });
84
- if (!this.auth_) {
85
- authProvider_.onInit(auth => (this.auth_ = auth));
125
+ constructor(_appName, _options, _authProvider) {
126
+ this._appName = _appName;
127
+ this._options = _options;
128
+ this._authProvider = _authProvider;
129
+ this._auth = _authProvider.getImmediate({ optional: true });
130
+ if (!this._auth) {
131
+ _authProvider.onInit(auth => (this._auth = auth));
86
132
  }
87
133
  }
88
134
  getToken(forceRefresh) {
89
- if (!this.auth_) {
135
+ if (!this._auth) {
90
136
  return new Promise((resolve, reject) => {
91
137
  setTimeout(() => {
92
- if (this.auth_) {
138
+ if (this._auth) {
93
139
  this.getToken(forceRefresh).then(resolve, reject);
94
140
  }
95
141
  else {
@@ -98,7 +144,7 @@ class FirebaseAuthProvider {
98
144
  }, 0);
99
145
  });
100
146
  }
101
- return this.auth_.getToken(forceRefresh).catch(error => {
147
+ return this._auth.getToken(forceRefresh).catch(error => {
102
148
  if (error && error.code === 'auth/token-not-initialized') {
103
149
  logDebug('Got auth/token-not-initialized error. Treating as null token.');
104
150
  return null;
@@ -112,10 +158,10 @@ class FirebaseAuthProvider {
112
158
  }
113
159
  addTokenChangeListener(listener) {
114
160
  var _a;
115
- (_a = this.auth_) === null || _a === void 0 ? void 0 : _a.addAuthTokenListener(listener);
161
+ (_a = this._auth) === null || _a === void 0 ? void 0 : _a.addAuthTokenListener(listener);
116
162
  }
117
163
  removeTokenChangeListener(listener) {
118
- this.authProvider_
164
+ this._authProvider
119
165
  .get()
120
166
  .then(auth => auth.removeAuthTokenListener(listener));
121
167
  }
@@ -137,8 +183,8 @@ class FirebaseAuthProvider {
137
183
  * See the License for the specific language governing permissions and
138
184
  * limitations under the License.
139
185
  */
140
- const QueryStr = 'query';
141
- const MutationStr = 'mutation';
186
+ const QUERY_STR = 'query';
187
+ const MUTATION_STR = 'mutation';
142
188
  const SOURCE_SERVER = 'SERVER';
143
189
  const SOURCE_CACHE = 'CACHE';
144
190
 
@@ -225,7 +271,7 @@ class QueryManager {
225
271
  const ref = {
226
272
  name: queryName,
227
273
  variables,
228
- refType: QueryStr
274
+ refType: QUERY_STR
229
275
  };
230
276
  const key = encoderImpl(ref);
231
277
  const newTrackedQuery = {
@@ -242,7 +288,7 @@ class QueryManager {
242
288
  const key = encoderImpl({
243
289
  name: queryRef.name,
244
290
  variables: queryRef.variables,
245
- refType: QueryStr
291
+ refType: QUERY_STR
246
292
  });
247
293
  const trackedQuery = this._queries.get(key);
248
294
  const subscription = {
@@ -291,7 +337,7 @@ class QueryManager {
291
337
  const key = encoderImpl({
292
338
  name: queryRef.name,
293
339
  variables: queryRef.variables,
294
- refType: QueryStr
340
+ refType: QUERY_STR
295
341
  });
296
342
  const trackedQuery = this._queries.get(key);
297
343
  const result = this.transport.invokeQuery(queryRef.name, queryRef.variables);
@@ -328,52 +374,6 @@ function compareDates(str1, str2) {
328
374
  return date1.getTime() < date2.getTime();
329
375
  }
330
376
 
331
- /**
332
- * @license
333
- * Copyright 2024 Google LLC
334
- *
335
- * Licensed under the Apache License, Version 2.0 (the "License");
336
- * you may not use this file except in compliance with the License.
337
- * You may obtain a copy of the License at
338
- *
339
- * http://www.apache.org/licenses/LICENSE-2.0
340
- *
341
- * Unless required by applicable law or agreed to in writing, software
342
- * distributed under the License is distributed on an "AS IS" BASIS,
343
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
344
- * See the License for the specific language governing permissions and
345
- * limitations under the License.
346
- */
347
- const Code = {
348
- OTHER: 'other',
349
- ALREADY_INITIALIZED: 'already-initialized',
350
- NOT_INITIALIZED: 'not-initialized',
351
- NOT_SUPPORTED: 'not-supported',
352
- INVALID_ARGUMENT: 'invalid-argument',
353
- PARTIAL_ERROR: 'partial-error'
354
- };
355
- /** An error returned by a DataConnect operation. */
356
- class DataConnectError extends FirebaseError {
357
- /** @hideconstructor */
358
- constructor(
359
- /**
360
- * The backend error code associated with this error.
361
- */
362
- code,
363
- /**
364
- * A custom error description.
365
- */
366
- message) {
367
- super(code, message);
368
- this.code = code;
369
- this.message = message;
370
- // HACK: We write a toString property directly because Error is not a real
371
- // class and so inheritance does not work correctly. We could alternatively
372
- // do the same "back-door inheritance" trick that FirebaseError does.
373
- this.toString = () => `${this.name}: [code=${this.code}]: ${this.message}`;
374
- }
375
- }
376
-
377
377
  /**
378
378
  * @license
379
379
  * Copyright 2024 Google LLC
@@ -448,6 +448,8 @@ function dcFetch(url, body, { signal }, accessToken) {
448
448
  method: 'POST',
449
449
  headers,
450
450
  signal
451
+ }).catch(err => {
452
+ throw new DataConnectError(Code.OTHER, "Failed to fetch: " + JSON.stringify(err));
451
453
  })
452
454
  .then(async (response) => {
453
455
  let jsonResponse = null;
@@ -494,24 +496,24 @@ class RESTTransport {
494
496
  var _a;
495
497
  this.apiKey = apiKey;
496
498
  this.authProvider = authProvider;
497
- this.host = '';
498
- this.location = 'l';
499
- this.connectorName = '';
500
- this.secure = true;
501
- this.project = 'p';
502
- this.accessToken = null;
503
- this.authInitialized_ = false;
499
+ this._host = '';
500
+ this._location = 'l';
501
+ this._connectorName = '';
502
+ this._secure = true;
503
+ this._project = 'p';
504
+ this._accessToken = null;
505
+ this._authInitialized = false;
504
506
  // TODO(mtewani): Update U to include shape of body defined in line 13.
505
507
  this.invokeQuery = (queryName, body) => {
506
508
  const abortController = new AbortController();
507
509
  // TODO(mtewani): Update to proper value
508
510
  const withAuth = this.getWithAuth().then(() => {
509
511
  return dcFetch(addToken(`${this.endpointUrl}:executeQuery`, this.apiKey), {
510
- name: `projects/${this.project}/locations/${this.location}/services/${this.serviceName}/connectors/${this.connectorName}`,
512
+ name: `projects/${this._project}/locations/${this._location}/services/${this._serviceName}/connectors/${this._connectorName}`,
511
513
  operationName: queryName,
512
514
  variables: body
513
515
  }, // TODO(mtewani): This is a patch, fix this.
514
- abortController, this.accessToken);
516
+ abortController, this._accessToken);
515
517
  });
516
518
  return {
517
519
  then: withAuth.then.bind(withAuth)
@@ -521,10 +523,10 @@ class RESTTransport {
521
523
  const abortController = new AbortController();
522
524
  const taskResult = this.getWithAuth().then(() => {
523
525
  return dcFetch(addToken(`${this.endpointUrl}:executeMutation`, this.apiKey), {
524
- name: `projects/${this.project}/locations/${this.location}/services/${this.serviceName}/connectors/${this.connectorName}`,
526
+ name: `projects/${this._project}/locations/${this._location}/services/${this._serviceName}/connectors/${this._connectorName}`,
525
527
  operationName: mutationName,
526
528
  variables: body
527
- }, abortController, this.accessToken);
529
+ }, abortController, this._accessToken);
528
530
  });
529
531
  return {
530
532
  then: taskResult.then.bind(taskResult),
@@ -535,53 +537,53 @@ class RESTTransport {
535
537
  };
536
538
  if (transportOptions) {
537
539
  if (typeof transportOptions.port === 'number') {
538
- this.port = transportOptions.port;
540
+ this._port = transportOptions.port;
539
541
  }
540
542
  if (typeof transportOptions.sslEnabled !== 'undefined') {
541
- this.secure = transportOptions.sslEnabled;
543
+ this._secure = transportOptions.sslEnabled;
542
544
  }
543
- this.host = transportOptions.host;
545
+ this._host = transportOptions.host;
544
546
  }
545
547
  const { location, projectId: project, connector, service } = options;
546
548
  if (location) {
547
- this.location = location;
549
+ this._location = location;
548
550
  }
549
551
  if (project) {
550
- this.project = project;
552
+ this._project = project;
551
553
  }
552
- this.serviceName = service;
554
+ this._serviceName = service;
553
555
  if (!connector) {
554
556
  throw new DataConnectError(Code.INVALID_ARGUMENT, 'Connector Name required!');
555
557
  }
556
- this.connectorName = connector;
558
+ this._connectorName = connector;
557
559
  (_a = this.authProvider) === null || _a === void 0 ? void 0 : _a.addTokenChangeListener(token => {
558
560
  logDebug(`New Token Available: ${token}`);
559
- this.accessToken = token;
561
+ this._accessToken = token;
560
562
  });
561
563
  }
562
564
  get endpointUrl() {
563
565
  return urlBuilder({
564
- connector: this.connectorName,
565
- location: this.location,
566
- projectId: this.project,
567
- service: this.serviceName
568
- }, { host: this.host, sslEnabled: this.secure, port: this.port });
566
+ connector: this._connectorName,
567
+ location: this._location,
568
+ projectId: this._project,
569
+ service: this._serviceName
570
+ }, { host: this._host, sslEnabled: this._secure, port: this._port });
569
571
  }
570
572
  useEmulator(host, port, isSecure) {
571
- this.host = host;
573
+ this._host = host;
572
574
  if (typeof port === 'number') {
573
- this.port = port;
575
+ this._port = port;
574
576
  }
575
577
  if (typeof isSecure !== 'undefined') {
576
- this.secure = isSecure;
578
+ this._secure = isSecure;
577
579
  }
578
580
  }
579
581
  onTokenChanged(newToken) {
580
- this.accessToken = newToken;
582
+ this._accessToken = newToken;
581
583
  }
582
584
  getWithAuth() {
583
- let starterPromise = new Promise(resolve => resolve(this.accessToken));
584
- if (!this.authInitialized_) {
585
+ let starterPromise = new Promise(resolve => resolve(this._accessToken));
586
+ if (!this._authInitialized) {
585
587
  if (this.authProvider) {
586
588
  starterPromise = this.authProvider
587
589
  .getToken(/*forceToken=*/ false)
@@ -589,8 +591,8 @@ class RESTTransport {
589
591
  if (!data) {
590
592
  return null;
591
593
  }
592
- this.accessToken = data.accessToken;
593
- return this.accessToken;
594
+ this._accessToken = data.accessToken;
595
+ return this._accessToken;
594
596
  });
595
597
  }
596
598
  else {
@@ -617,23 +619,33 @@ class RESTTransport {
617
619
  * See the License for the specific language governing permissions and
618
620
  * limitations under the License.
619
621
  */
620
- function mutationRef(dcInstance, queryName, variables) {
622
+ /**
623
+ *
624
+ * @param dcInstance Data Connect instance
625
+ * @param mutationName name of mutation
626
+ * @param variables variables to send with mutation
627
+ * @returns `MutationRef`
628
+ */
629
+ function mutationRef(dcInstance, mutationName, variables) {
621
630
  dcInstance.setInitialized();
622
631
  const ref = {
623
632
  dataConnect: dcInstance,
624
- name: queryName,
625
- refType: MutationStr,
633
+ name: mutationName,
634
+ refType: MUTATION_STR,
626
635
  variables: variables
627
636
  };
628
637
  return ref;
629
638
  }
639
+ /**
640
+ * @internal
641
+ */
630
642
  class MutationManager {
631
- constructor(transport) {
632
- this.transport = transport;
643
+ constructor(_transport) {
644
+ this._transport = _transport;
633
645
  this._inflight = [];
634
646
  }
635
647
  executeMutation(mutationRef) {
636
- const result = this.transport.invokeMutation(mutationRef.name, mutationRef.variables);
648
+ const result = this._transport.invokeMutation(mutationRef.name, mutationRef.variables);
637
649
  const withRefPromise = result.then(res => {
638
650
  const obj = Object.assign(Object.assign({}, res), { source: SOURCE_SERVER, ref: mutationRef, fetchTime: Date.now().toLocaleString() });
639
651
  return obj;
@@ -644,6 +656,11 @@ class MutationManager {
644
656
  return withRefPromise;
645
657
  }
646
658
  }
659
+ /**
660
+ * Execute Mutation
661
+ * @param mutationRef mutation to execute
662
+ * @returns `MutationRef`
663
+ */
647
664
  function executeMutation(mutationRef) {
648
665
  return mutationRef.dataConnect._mutationManager.executeMutation(mutationRef);
649
666
  }
@@ -678,11 +695,16 @@ function parseOptions(fullHost) {
678
695
  const port = Number(portAsString);
679
696
  return { host, port, sslEnabled: isSecure };
680
697
  }
698
+ /**
699
+ * Class representing Firebase Data Connect
700
+ */
681
701
  class DataConnect {
682
- constructor(app, dataConnectOptions, authProvider) {
702
+ constructor(app,
703
+ // TODO(mtewani): Replace with _dataConnectOptions in the future
704
+ dataConnectOptions, _authProvider) {
683
705
  this.app = app;
684
706
  this.dataConnectOptions = dataConnectOptions;
685
- this.authProvider = authProvider;
707
+ this._authProvider = _authProvider;
686
708
  this.isEmulator = false;
687
709
  this.initialized = false;
688
710
  if (typeof process !== 'undefined' && process.env) {
@@ -690,7 +712,7 @@ class DataConnect {
690
712
  if (host) {
691
713
  logDebug('Found custom host. Using emulator');
692
714
  this.isEmulator = true;
693
- this.transportOptions = parseOptions(host);
715
+ this._transportOptions = parseOptions(host);
694
716
  }
695
717
  }
696
718
  }
@@ -707,30 +729,37 @@ class DataConnect {
707
729
  if (this.initialized) {
708
730
  return;
709
731
  }
710
- if (this.transportClass === undefined) {
732
+ if (this._transportClass === undefined) {
711
733
  logDebug('transportClass not provided. Defaulting to RESTTransport.');
712
- this.transportClass = RESTTransport;
734
+ this._transportClass = RESTTransport;
713
735
  }
714
- if (this.authProvider) {
715
- this.authTokenProvider = new FirebaseAuthProvider(this.app.name, this.app.options, this.authProvider);
736
+ if (this._authProvider) {
737
+ this._authTokenProvider = new FirebaseAuthProvider(this.app.name, this.app.options, this._authProvider);
716
738
  }
717
739
  this.initialized = true;
718
- this._transport = new this.transportClass(this.dataConnectOptions, this.app.options.apiKey, this.authTokenProvider);
719
- if (this.transportOptions) {
720
- this._transport.useEmulator(this.transportOptions.host, this.transportOptions.port, this.transportOptions.sslEnabled);
740
+ this._transport = new this._transportClass(this.dataConnectOptions, this.app.options.apiKey, this._authTokenProvider);
741
+ if (this._transportOptions) {
742
+ this._transport.useEmulator(this._transportOptions.host, this._transportOptions.port, this._transportOptions.sslEnabled);
721
743
  }
722
744
  this._queryManager = new QueryManager(this._transport);
723
745
  this._mutationManager = new MutationManager(this._transport);
724
746
  }
725
747
  enableEmulator(transportOptions) {
726
748
  if (this.initialized) {
727
- logError('enableEmulator called without initializing');
749
+ logError('enableEmulator called after initialization');
728
750
  throw new DataConnectError(Code.ALREADY_INITIALIZED, 'DataConnect instance already initialized!');
729
751
  }
730
- this.transportOptions = transportOptions;
752
+ this._transportOptions = transportOptions;
731
753
  this.isEmulator = true;
732
754
  }
733
755
  }
756
+ /**
757
+ * Connect to the DataConnect Emulator
758
+ * @param dc Data Connect instance
759
+ * @param host host of emulator server
760
+ * @param port port of emulator server
761
+ * @param sslEnabled use https
762
+ */
734
763
  function connectDataConnectEmulator(dc, host, port, sslEnabled = false) {
735
764
  dc.enableEmulator({ host, port, sslEnabled });
736
765
  }
@@ -769,8 +798,13 @@ function getDataConnect(appOrOptions, optionalOptions) {
769
798
  options: dcOptions
770
799
  });
771
800
  }
801
+ /**
802
+ * Delete DataConnect instance
803
+ * @param dataConnect DataConnect instance
804
+ * @returns
805
+ */
772
806
  function terminate(dataConnect) {
773
- dataConnect._delete();
807
+ return dataConnect._delete();
774
808
  // TODO(mtewani): Stop pending tasks
775
809
  }
776
810
 
@@ -822,19 +856,37 @@ function registerDataConnect(variant) {
822
856
  * See the License for the specific language governing permissions and
823
857
  * limitations under the License.
824
858
  */
859
+ /**
860
+ * Execute Query
861
+ * @param queryRef query to execute.
862
+ * @returns `QueryPromise`
863
+ */
825
864
  function executeQuery(queryRef) {
826
865
  return queryRef.dataConnect._queryManager.executeQuery(queryRef);
827
866
  }
867
+ /**
868
+ * Execute Query
869
+ * @param dcInstance Data Connect instance to use.
870
+ * @param queryName Query to execute
871
+ * @param variables Variables to execute with
872
+ * @param initialCache initial cache to use for client hydration
873
+ * @returns `QueryRef`
874
+ */
828
875
  function queryRef(dcInstance, queryName, variables, initialCache) {
829
876
  dcInstance.setInitialized();
830
877
  dcInstance._queryManager.track(queryName, variables, initialCache);
831
878
  return {
832
879
  dataConnect: dcInstance,
833
- refType: QueryStr,
880
+ refType: QUERY_STR,
834
881
  name: queryName,
835
882
  variables: variables
836
883
  };
837
884
  }
885
+ /**
886
+ * Converts serialized ref to query ref
887
+ * @param serializedRef ref to convert to `QueryRef`
888
+ * @returns `QueryRef`
889
+ */
838
890
  function toQueryRef(serializedRef) {
839
891
  const { refInfo: { name, variables, connectorConfig } } = serializedRef;
840
892
  return queryRef(getDataConnect(connectorConfig), name, variables);
@@ -856,11 +908,19 @@ function toQueryRef(serializedRef) {
856
908
  * See the License for the specific language governing permissions and
857
909
  * limitations under the License.
858
910
  */
911
+ /**
912
+ * Subscribe to a `QueryRef`
913
+ * @param queryRefOrSerializedResult query ref or serialized result.
914
+ * @param observerOrOnNext observer object or next function.
915
+ * @param onError Callback to call when error gets thrown.
916
+ * @param onComplete Called when subscription completes.
917
+ * @returns `SubscriptionOptions`
918
+ */
859
919
  function subscribe(queryRefOrSerializedResult, observerOrOnNext, onError, onComplete) {
860
920
  let ref;
861
921
  let initialCache;
862
922
  if ('refInfo' in queryRefOrSerializedResult) {
863
- let serializedRef = queryRefOrSerializedResult;
923
+ const serializedRef = queryRefOrSerializedResult;
864
924
  const { data, source, fetchTime } = serializedRef;
865
925
  initialCache = {
866
926
  data,
@@ -892,27 +952,7 @@ function subscribe(queryRefOrSerializedResult, observerOrOnNext, onError, onComp
892
952
  *
893
953
  * @packageDocumentation
894
954
  */
895
- registerDataConnect();
896
- // import { getDataConnect, queryRef } from './api';
897
- // import { getApp } from '@firebase/app';
898
- // const app = getApp();
899
- // const dc = getDataConnect({ location: '', connector: '', serviceId: '', projectId: '' });
900
- // interface Response {
901
- // name: string;
902
- // }
903
- // const converter: Converter<Response> = {
904
- // fromDataConnect(input: string) {
905
- // return { name: input };
906
- // },
907
- // fromType(input) {
908
- // return input;
909
- // }
910
- // };
911
- // const myRef = queryRef(dc, '', converter);
912
- // // Ref's shouldn't have access to their own cache, right?
913
- // const a = execute(myRef);
914
- // subscribe(myRef, (res) => {
915
- // })
955
+ registerDataConnect();
916
956
 
917
- export { DataConnect, FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR, FirebaseAuthProvider, MutationManager, MutationStr, QueryStr, SOURCE_CACHE, SOURCE_SERVER, connectDataConnectEmulator, executeMutation, executeQuery, getDataConnect, mutationRef, parseOptions, queryRef, setLogLevel, subscribe, terminate, toQueryRef };
957
+ export { DataConnect, FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR, FirebaseAuthProvider, MUTATION_STR, MutationManager, QUERY_STR, SOURCE_CACHE, SOURCE_SERVER, connectDataConnectEmulator, executeMutation, executeQuery, getDataConnect, mutationRef, parseOptions, queryRef, setLogLevel, subscribe, terminate, toQueryRef };
918
958
  //# sourceMappingURL=index.esm2017.js.map