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