@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.
- package/dist/index.cjs.js +181 -141
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +180 -140
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +183 -143
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +132 -72
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/internal.d.ts +156 -44
- package/dist/node-esm/index.node.esm.js +132 -72
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api/DataConnect.d.ts +39 -12
- package/dist/node-esm/src/api/Mutation.d.ts +33 -8
- package/dist/node-esm/src/api/Reference.d.ts +9 -3
- package/dist/node-esm/src/api/query.d.ts +52 -2
- package/dist/node-esm/src/api.browser.d.ts +12 -7
- package/dist/node-esm/src/core/FirebaseAuthProvider.d.ts +5 -5
- package/dist/node-esm/src/core/QueryManager.d.ts +7 -7
- package/dist/node-esm/src/network/transport/rest.d.ts +13 -25
- package/dist/node-esm/src/util/url.d.ts +2 -2
- package/dist/private.d.ts +151 -47
- package/dist/public.d.ts +135 -37
- package/dist/src/api/DataConnect.d.ts +39 -12
- package/dist/src/api/Mutation.d.ts +33 -8
- package/dist/src/api/Reference.d.ts +9 -3
- package/dist/src/api/query.d.ts +52 -2
- package/dist/src/api.browser.d.ts +12 -7
- package/dist/src/core/FirebaseAuthProvider.d.ts +5 -5
- package/dist/src/core/QueryManager.d.ts +7 -7
- package/dist/src/network/transport/rest.d.ts +13 -25
- package/dist/src/util/url.d.ts +2 -2
- package/package.json +7 -7
- package/dist/node-esm/test/emulatorSeeder.d.ts +0 -22
- package/dist/node-esm/test/queries.test.d.ts +0 -17
- package/dist/node-esm/test/util.d.ts +0 -26
- package/dist/test/emulatorSeeder.d.ts +0 -22
- package/dist/test/queries.test.d.ts +0 -17
- package/dist/test/util.d.ts +0 -26
package/dist/index.node.cjs.js
CHANGED
|
@@ -149,6 +149,8 @@ function dcFetch(url, body, _a, accessToken) {
|
|
|
149
149
|
method: 'POST',
|
|
150
150
|
headers: headers,
|
|
151
151
|
signal: signal
|
|
152
|
+
}).catch(function (err) {
|
|
153
|
+
throw new DataConnectError(Code.OTHER, "Failed to fetch: " + JSON.stringify(err));
|
|
152
154
|
})
|
|
153
155
|
.then(function (response) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
154
156
|
var jsonResponse, e_1;
|
|
@@ -186,7 +188,7 @@ function dcFetch(url, body, _a, accessToken) {
|
|
|
186
188
|
}
|
|
187
189
|
|
|
188
190
|
var name = "@firebase/data-connect";
|
|
189
|
-
var version = "0.0.
|
|
191
|
+
var version = "0.0.2-dataconnect-preview.388b61c7e";
|
|
190
192
|
|
|
191
193
|
/**
|
|
192
194
|
* @license
|
|
@@ -205,22 +207,22 @@ var version = "0.0.1-dataconnect-preview.81ee5169c";
|
|
|
205
207
|
* limitations under the License.
|
|
206
208
|
*/
|
|
207
209
|
var FirebaseAuthProvider = /** @class */ (function () {
|
|
208
|
-
function FirebaseAuthProvider(
|
|
210
|
+
function FirebaseAuthProvider(_appName, _options, _authProvider) {
|
|
209
211
|
var _this = this;
|
|
210
|
-
this.
|
|
211
|
-
this.
|
|
212
|
-
this.
|
|
213
|
-
this.
|
|
214
|
-
if (!this.
|
|
215
|
-
|
|
212
|
+
this._appName = _appName;
|
|
213
|
+
this._options = _options;
|
|
214
|
+
this._authProvider = _authProvider;
|
|
215
|
+
this._auth = _authProvider.getImmediate({ optional: true });
|
|
216
|
+
if (!this._auth) {
|
|
217
|
+
_authProvider.onInit(function (auth) { return (_this._auth = auth); });
|
|
216
218
|
}
|
|
217
219
|
}
|
|
218
220
|
FirebaseAuthProvider.prototype.getToken = function (forceRefresh) {
|
|
219
221
|
var _this = this;
|
|
220
|
-
if (!this.
|
|
222
|
+
if (!this._auth) {
|
|
221
223
|
return new Promise(function (resolve, reject) {
|
|
222
224
|
setTimeout(function () {
|
|
223
|
-
if (_this.
|
|
225
|
+
if (_this._auth) {
|
|
224
226
|
_this.getToken(forceRefresh).then(resolve, reject);
|
|
225
227
|
}
|
|
226
228
|
else {
|
|
@@ -229,7 +231,7 @@ var FirebaseAuthProvider = /** @class */ (function () {
|
|
|
229
231
|
}, 0);
|
|
230
232
|
});
|
|
231
233
|
}
|
|
232
|
-
return this.
|
|
234
|
+
return this._auth.getToken(forceRefresh).catch(function (error) {
|
|
233
235
|
if (error && error.code === 'auth/token-not-initialized') {
|
|
234
236
|
logDebug('Got auth/token-not-initialized error. Treating as null token.');
|
|
235
237
|
return null;
|
|
@@ -243,10 +245,10 @@ var FirebaseAuthProvider = /** @class */ (function () {
|
|
|
243
245
|
};
|
|
244
246
|
FirebaseAuthProvider.prototype.addTokenChangeListener = function (listener) {
|
|
245
247
|
var _a;
|
|
246
|
-
(_a = this.
|
|
248
|
+
(_a = this._auth) === null || _a === void 0 ? void 0 : _a.addAuthTokenListener(listener);
|
|
247
249
|
};
|
|
248
250
|
FirebaseAuthProvider.prototype.removeTokenChangeListener = function (listener) {
|
|
249
|
-
this.
|
|
251
|
+
this._authProvider
|
|
250
252
|
.get()
|
|
251
253
|
.then(function (auth) { return auth.removeAuthTokenListener(listener); });
|
|
252
254
|
};
|
|
@@ -269,8 +271,8 @@ var FirebaseAuthProvider = /** @class */ (function () {
|
|
|
269
271
|
* See the License for the specific language governing permissions and
|
|
270
272
|
* limitations under the License.
|
|
271
273
|
*/
|
|
272
|
-
var
|
|
273
|
-
var
|
|
274
|
+
var QUERY_STR = 'query';
|
|
275
|
+
var MUTATION_STR = 'mutation';
|
|
274
276
|
var SOURCE_SERVER = 'SERVER';
|
|
275
277
|
var SOURCE_CACHE = 'CACHE';
|
|
276
278
|
|
|
@@ -357,7 +359,7 @@ var QueryManager = /** @class */ (function () {
|
|
|
357
359
|
var ref = {
|
|
358
360
|
name: queryName,
|
|
359
361
|
variables: variables,
|
|
360
|
-
refType:
|
|
362
|
+
refType: QUERY_STR
|
|
361
363
|
};
|
|
362
364
|
var key = encoderImpl(ref);
|
|
363
365
|
var newTrackedQuery = {
|
|
@@ -375,7 +377,7 @@ var QueryManager = /** @class */ (function () {
|
|
|
375
377
|
var key = encoderImpl({
|
|
376
378
|
name: queryRef.name,
|
|
377
379
|
variables: queryRef.variables,
|
|
378
|
-
refType:
|
|
380
|
+
refType: QUERY_STR
|
|
379
381
|
});
|
|
380
382
|
var trackedQuery = this._queries.get(key);
|
|
381
383
|
var subscription = {
|
|
@@ -424,7 +426,7 @@ var QueryManager = /** @class */ (function () {
|
|
|
424
426
|
var key = encoderImpl({
|
|
425
427
|
name: queryRef.name,
|
|
426
428
|
variables: queryRef.variables,
|
|
427
|
-
refType:
|
|
429
|
+
refType: QUERY_STR
|
|
428
430
|
});
|
|
429
431
|
var trackedQuery = this._queries.get(key);
|
|
430
432
|
var result = this.transport.invokeQuery(queryRef.name, queryRef.variables);
|
|
@@ -524,24 +526,24 @@ var RESTTransport = /** @class */ (function () {
|
|
|
524
526
|
var _a;
|
|
525
527
|
this.apiKey = apiKey;
|
|
526
528
|
this.authProvider = authProvider;
|
|
527
|
-
this.
|
|
528
|
-
this.
|
|
529
|
-
this.
|
|
530
|
-
this.
|
|
531
|
-
this.
|
|
532
|
-
this.
|
|
533
|
-
this.
|
|
529
|
+
this._host = '';
|
|
530
|
+
this._location = 'l';
|
|
531
|
+
this._connectorName = '';
|
|
532
|
+
this._secure = true;
|
|
533
|
+
this._project = 'p';
|
|
534
|
+
this._accessToken = null;
|
|
535
|
+
this._authInitialized = false;
|
|
534
536
|
// TODO(mtewani): Update U to include shape of body defined in line 13.
|
|
535
537
|
this.invokeQuery = function (queryName, body) {
|
|
536
538
|
var abortController = new AbortController();
|
|
537
539
|
// TODO(mtewani): Update to proper value
|
|
538
540
|
var withAuth = _this.getWithAuth().then(function () {
|
|
539
541
|
return dcFetch(addToken("".concat(_this.endpointUrl, ":executeQuery"), _this.apiKey), {
|
|
540
|
-
name: "projects/".concat(_this.
|
|
542
|
+
name: "projects/".concat(_this._project, "/locations/").concat(_this._location, "/services/").concat(_this._serviceName, "/connectors/").concat(_this._connectorName),
|
|
541
543
|
operationName: queryName,
|
|
542
544
|
variables: body
|
|
543
545
|
}, // TODO(mtewani): This is a patch, fix this.
|
|
544
|
-
abortController, _this.
|
|
546
|
+
abortController, _this._accessToken);
|
|
545
547
|
});
|
|
546
548
|
return {
|
|
547
549
|
then: withAuth.then.bind(withAuth)
|
|
@@ -551,10 +553,10 @@ var RESTTransport = /** @class */ (function () {
|
|
|
551
553
|
var abortController = new AbortController();
|
|
552
554
|
var taskResult = _this.getWithAuth().then(function () {
|
|
553
555
|
return dcFetch(addToken("".concat(_this.endpointUrl, ":executeMutation"), _this.apiKey), {
|
|
554
|
-
name: "projects/".concat(_this.
|
|
556
|
+
name: "projects/".concat(_this._project, "/locations/").concat(_this._location, "/services/").concat(_this._serviceName, "/connectors/").concat(_this._connectorName),
|
|
555
557
|
operationName: mutationName,
|
|
556
558
|
variables: body
|
|
557
|
-
}, abortController, _this.
|
|
559
|
+
}, abortController, _this._accessToken);
|
|
558
560
|
});
|
|
559
561
|
return {
|
|
560
562
|
then: taskResult.then.bind(taskResult),
|
|
@@ -565,60 +567,60 @@ var RESTTransport = /** @class */ (function () {
|
|
|
565
567
|
};
|
|
566
568
|
if (transportOptions) {
|
|
567
569
|
if (typeof transportOptions.port === 'number') {
|
|
568
|
-
this.
|
|
570
|
+
this._port = transportOptions.port;
|
|
569
571
|
}
|
|
570
572
|
if (typeof transportOptions.sslEnabled !== 'undefined') {
|
|
571
|
-
this.
|
|
573
|
+
this._secure = transportOptions.sslEnabled;
|
|
572
574
|
}
|
|
573
|
-
this.
|
|
575
|
+
this._host = transportOptions.host;
|
|
574
576
|
}
|
|
575
577
|
var location = options.location, project = options.projectId, connector = options.connector, service = options.service;
|
|
576
578
|
if (location) {
|
|
577
|
-
this.
|
|
579
|
+
this._location = location;
|
|
578
580
|
}
|
|
579
581
|
if (project) {
|
|
580
|
-
this.
|
|
582
|
+
this._project = project;
|
|
581
583
|
}
|
|
582
|
-
this.
|
|
584
|
+
this._serviceName = service;
|
|
583
585
|
if (!connector) {
|
|
584
586
|
throw new DataConnectError(Code.INVALID_ARGUMENT, 'Connector Name required!');
|
|
585
587
|
}
|
|
586
|
-
this.
|
|
588
|
+
this._connectorName = connector;
|
|
587
589
|
(_a = this.authProvider) === null || _a === void 0 ? void 0 : _a.addTokenChangeListener(function (token) {
|
|
588
590
|
logDebug("New Token Available: ".concat(token));
|
|
589
|
-
_this.
|
|
591
|
+
_this._accessToken = token;
|
|
590
592
|
});
|
|
591
593
|
}
|
|
592
594
|
Object.defineProperty(RESTTransport.prototype, "endpointUrl", {
|
|
593
595
|
get: function () {
|
|
594
596
|
return urlBuilder({
|
|
595
|
-
connector: this.
|
|
596
|
-
location: this.
|
|
597
|
-
projectId: this.
|
|
598
|
-
service: this.
|
|
599
|
-
}, { host: this.
|
|
597
|
+
connector: this._connectorName,
|
|
598
|
+
location: this._location,
|
|
599
|
+
projectId: this._project,
|
|
600
|
+
service: this._serviceName
|
|
601
|
+
}, { host: this._host, sslEnabled: this._secure, port: this._port });
|
|
600
602
|
},
|
|
601
603
|
enumerable: false,
|
|
602
604
|
configurable: true
|
|
603
605
|
});
|
|
604
606
|
RESTTransport.prototype.useEmulator = function (host, port, isSecure) {
|
|
605
|
-
this.
|
|
607
|
+
this._host = host;
|
|
606
608
|
if (typeof port === 'number') {
|
|
607
|
-
this.
|
|
609
|
+
this._port = port;
|
|
608
610
|
}
|
|
609
611
|
if (typeof isSecure !== 'undefined') {
|
|
610
|
-
this.
|
|
612
|
+
this._secure = isSecure;
|
|
611
613
|
}
|
|
612
614
|
};
|
|
613
615
|
RESTTransport.prototype.onTokenChanged = function (newToken) {
|
|
614
|
-
this.
|
|
616
|
+
this._accessToken = newToken;
|
|
615
617
|
};
|
|
616
618
|
RESTTransport.prototype.getWithAuth = function () {
|
|
617
619
|
var _this = this;
|
|
618
620
|
var starterPromise = new Promise(function (resolve) {
|
|
619
|
-
return resolve(_this.
|
|
621
|
+
return resolve(_this._accessToken);
|
|
620
622
|
});
|
|
621
|
-
if (!this.
|
|
623
|
+
if (!this._authInitialized) {
|
|
622
624
|
if (this.authProvider) {
|
|
623
625
|
starterPromise = this.authProvider
|
|
624
626
|
.getToken(/*forceToken=*/ false)
|
|
@@ -626,8 +628,8 @@ var RESTTransport = /** @class */ (function () {
|
|
|
626
628
|
if (!data) {
|
|
627
629
|
return null;
|
|
628
630
|
}
|
|
629
|
-
_this.
|
|
630
|
-
return _this.
|
|
631
|
+
_this._accessToken = data.accessToken;
|
|
632
|
+
return _this._accessToken;
|
|
631
633
|
});
|
|
632
634
|
}
|
|
633
635
|
else {
|
|
@@ -655,24 +657,34 @@ var RESTTransport = /** @class */ (function () {
|
|
|
655
657
|
* See the License for the specific language governing permissions and
|
|
656
658
|
* limitations under the License.
|
|
657
659
|
*/
|
|
658
|
-
|
|
660
|
+
/**
|
|
661
|
+
*
|
|
662
|
+
* @param dcInstance Data Connect instance
|
|
663
|
+
* @param mutationName name of mutation
|
|
664
|
+
* @param variables variables to send with mutation
|
|
665
|
+
* @returns `MutationRef`
|
|
666
|
+
*/
|
|
667
|
+
function mutationRef(dcInstance, mutationName, variables) {
|
|
659
668
|
dcInstance.setInitialized();
|
|
660
669
|
var ref = {
|
|
661
670
|
dataConnect: dcInstance,
|
|
662
|
-
name:
|
|
663
|
-
refType:
|
|
671
|
+
name: mutationName,
|
|
672
|
+
refType: MUTATION_STR,
|
|
664
673
|
variables: variables
|
|
665
674
|
};
|
|
666
675
|
return ref;
|
|
667
676
|
}
|
|
677
|
+
/**
|
|
678
|
+
* @internal
|
|
679
|
+
*/
|
|
668
680
|
var MutationManager = /** @class */ (function () {
|
|
669
|
-
function MutationManager(
|
|
670
|
-
this.
|
|
681
|
+
function MutationManager(_transport) {
|
|
682
|
+
this._transport = _transport;
|
|
671
683
|
this._inflight = [];
|
|
672
684
|
}
|
|
673
685
|
MutationManager.prototype.executeMutation = function (mutationRef) {
|
|
674
686
|
var _this = this;
|
|
675
|
-
var result = this.
|
|
687
|
+
var result = this._transport.invokeMutation(mutationRef.name, mutationRef.variables);
|
|
676
688
|
var withRefPromise = result.then(function (res) {
|
|
677
689
|
var obj = tslib.__assign(tslib.__assign({}, res), { source: SOURCE_SERVER, ref: mutationRef, fetchTime: Date.now().toLocaleString() });
|
|
678
690
|
return obj;
|
|
@@ -686,6 +698,11 @@ var MutationManager = /** @class */ (function () {
|
|
|
686
698
|
};
|
|
687
699
|
return MutationManager;
|
|
688
700
|
}());
|
|
701
|
+
/**
|
|
702
|
+
* Execute Mutation
|
|
703
|
+
* @param mutationRef mutation to execute
|
|
704
|
+
* @returns `MutationRef`
|
|
705
|
+
*/
|
|
689
706
|
function executeMutation(mutationRef) {
|
|
690
707
|
return mutationRef.dataConnect._mutationManager.executeMutation(mutationRef);
|
|
691
708
|
}
|
|
@@ -720,11 +737,16 @@ function parseOptions(fullHost) {
|
|
|
720
737
|
var port = Number(portAsString);
|
|
721
738
|
return { host: host, port: port, sslEnabled: isSecure };
|
|
722
739
|
}
|
|
740
|
+
/**
|
|
741
|
+
* Class representing Firebase Data Connect
|
|
742
|
+
*/
|
|
723
743
|
var DataConnect = /** @class */ (function () {
|
|
724
|
-
function DataConnect(app,
|
|
744
|
+
function DataConnect(app,
|
|
745
|
+
// TODO(mtewani): Replace with _dataConnectOptions in the future
|
|
746
|
+
dataConnectOptions, _authProvider) {
|
|
725
747
|
this.app = app;
|
|
726
748
|
this.dataConnectOptions = dataConnectOptions;
|
|
727
|
-
this.
|
|
749
|
+
this._authProvider = _authProvider;
|
|
728
750
|
this.isEmulator = false;
|
|
729
751
|
this.initialized = false;
|
|
730
752
|
if (typeof process !== 'undefined' && process.env) {
|
|
@@ -732,7 +754,7 @@ var DataConnect = /** @class */ (function () {
|
|
|
732
754
|
if (host) {
|
|
733
755
|
logDebug('Found custom host. Using emulator');
|
|
734
756
|
this.isEmulator = true;
|
|
735
|
-
this.
|
|
757
|
+
this._transportOptions = parseOptions(host);
|
|
736
758
|
}
|
|
737
759
|
}
|
|
738
760
|
}
|
|
@@ -749,31 +771,38 @@ var DataConnect = /** @class */ (function () {
|
|
|
749
771
|
if (this.initialized) {
|
|
750
772
|
return;
|
|
751
773
|
}
|
|
752
|
-
if (this.
|
|
774
|
+
if (this._transportClass === undefined) {
|
|
753
775
|
logDebug('transportClass not provided. Defaulting to RESTTransport.');
|
|
754
|
-
this.
|
|
776
|
+
this._transportClass = RESTTransport;
|
|
755
777
|
}
|
|
756
|
-
if (this.
|
|
757
|
-
this.
|
|
778
|
+
if (this._authProvider) {
|
|
779
|
+
this._authTokenProvider = new FirebaseAuthProvider(this.app.name, this.app.options, this._authProvider);
|
|
758
780
|
}
|
|
759
781
|
this.initialized = true;
|
|
760
|
-
this._transport = new this.
|
|
761
|
-
if (this.
|
|
762
|
-
this._transport.useEmulator(this.
|
|
782
|
+
this._transport = new this._transportClass(this.dataConnectOptions, this.app.options.apiKey, this._authTokenProvider);
|
|
783
|
+
if (this._transportOptions) {
|
|
784
|
+
this._transport.useEmulator(this._transportOptions.host, this._transportOptions.port, this._transportOptions.sslEnabled);
|
|
763
785
|
}
|
|
764
786
|
this._queryManager = new QueryManager(this._transport);
|
|
765
787
|
this._mutationManager = new MutationManager(this._transport);
|
|
766
788
|
};
|
|
767
789
|
DataConnect.prototype.enableEmulator = function (transportOptions) {
|
|
768
790
|
if (this.initialized) {
|
|
769
|
-
logError('enableEmulator called
|
|
791
|
+
logError('enableEmulator called after initialization');
|
|
770
792
|
throw new DataConnectError(Code.ALREADY_INITIALIZED, 'DataConnect instance already initialized!');
|
|
771
793
|
}
|
|
772
|
-
this.
|
|
794
|
+
this._transportOptions = transportOptions;
|
|
773
795
|
this.isEmulator = true;
|
|
774
796
|
};
|
|
775
797
|
return DataConnect;
|
|
776
798
|
}());
|
|
799
|
+
/**
|
|
800
|
+
* Connect to the DataConnect Emulator
|
|
801
|
+
* @param dc Data Connect instance
|
|
802
|
+
* @param host host of emulator server
|
|
803
|
+
* @param port port of emulator server
|
|
804
|
+
* @param sslEnabled use https
|
|
805
|
+
*/
|
|
777
806
|
function connectDataConnectEmulator(dc, host, port, sslEnabled) {
|
|
778
807
|
if (sslEnabled === void 0) { sslEnabled = false; }
|
|
779
808
|
dc.enableEmulator({ host: host, port: port, sslEnabled: sslEnabled });
|
|
@@ -813,8 +842,13 @@ function getDataConnect(appOrOptions, optionalOptions) {
|
|
|
813
842
|
options: dcOptions
|
|
814
843
|
});
|
|
815
844
|
}
|
|
845
|
+
/**
|
|
846
|
+
* Delete DataConnect instance
|
|
847
|
+
* @param dataConnect DataConnect instance
|
|
848
|
+
* @returns
|
|
849
|
+
*/
|
|
816
850
|
function terminate(dataConnect) {
|
|
817
|
-
dataConnect._delete();
|
|
851
|
+
return dataConnect._delete();
|
|
818
852
|
// TODO(mtewani): Stop pending tasks
|
|
819
853
|
}
|
|
820
854
|
|
|
@@ -851,19 +885,37 @@ function registerDataConnect(variant) {
|
|
|
851
885
|
* See the License for the specific language governing permissions and
|
|
852
886
|
* limitations under the License.
|
|
853
887
|
*/
|
|
888
|
+
/**
|
|
889
|
+
* Execute Query
|
|
890
|
+
* @param queryRef query to execute.
|
|
891
|
+
* @returns `QueryPromise`
|
|
892
|
+
*/
|
|
854
893
|
function executeQuery(queryRef) {
|
|
855
894
|
return queryRef.dataConnect._queryManager.executeQuery(queryRef);
|
|
856
895
|
}
|
|
896
|
+
/**
|
|
897
|
+
* Execute Query
|
|
898
|
+
* @param dcInstance Data Connect instance to use.
|
|
899
|
+
* @param queryName Query to execute
|
|
900
|
+
* @param variables Variables to execute with
|
|
901
|
+
* @param initialCache initial cache to use for client hydration
|
|
902
|
+
* @returns `QueryRef`
|
|
903
|
+
*/
|
|
857
904
|
function queryRef(dcInstance, queryName, variables, initialCache) {
|
|
858
905
|
dcInstance.setInitialized();
|
|
859
906
|
dcInstance._queryManager.track(queryName, variables, initialCache);
|
|
860
907
|
return {
|
|
861
908
|
dataConnect: dcInstance,
|
|
862
|
-
refType:
|
|
909
|
+
refType: QUERY_STR,
|
|
863
910
|
name: queryName,
|
|
864
911
|
variables: variables
|
|
865
912
|
};
|
|
866
913
|
}
|
|
914
|
+
/**
|
|
915
|
+
* Converts serialized ref to query ref
|
|
916
|
+
* @param serializedRef ref to convert to `QueryRef`
|
|
917
|
+
* @returns `QueryRef`
|
|
918
|
+
*/
|
|
867
919
|
function toQueryRef(serializedRef) {
|
|
868
920
|
var _a = serializedRef.refInfo, name = _a.name, variables = _a.variables, connectorConfig = _a.connectorConfig;
|
|
869
921
|
return queryRef(getDataConnect(connectorConfig), name, variables);
|
|
@@ -885,6 +937,14 @@ function toQueryRef(serializedRef) {
|
|
|
885
937
|
* See the License for the specific language governing permissions and
|
|
886
938
|
* limitations under the License.
|
|
887
939
|
*/
|
|
940
|
+
/**
|
|
941
|
+
* Subscribe to a `QueryRef`
|
|
942
|
+
* @param queryRefOrSerializedResult query ref or serialized result.
|
|
943
|
+
* @param observerOrOnNext observer object or next function.
|
|
944
|
+
* @param onError Callback to call when error gets thrown.
|
|
945
|
+
* @param onComplete Called when subscription completes.
|
|
946
|
+
* @returns `SubscriptionOptions`
|
|
947
|
+
*/
|
|
888
948
|
function subscribe(queryRefOrSerializedResult, observerOrOnNext, onError, onComplete) {
|
|
889
949
|
var ref;
|
|
890
950
|
var initialCache;
|
|
@@ -938,9 +998,9 @@ registerDataConnect('node');
|
|
|
938
998
|
exports.DataConnect = DataConnect;
|
|
939
999
|
exports.FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR;
|
|
940
1000
|
exports.FirebaseAuthProvider = FirebaseAuthProvider;
|
|
1001
|
+
exports.MUTATION_STR = MUTATION_STR;
|
|
941
1002
|
exports.MutationManager = MutationManager;
|
|
942
|
-
exports.
|
|
943
|
-
exports.QueryStr = QueryStr;
|
|
1003
|
+
exports.QUERY_STR = QUERY_STR;
|
|
944
1004
|
exports.SOURCE_CACHE = SOURCE_CACHE;
|
|
945
1005
|
exports.SOURCE_SERVER = SOURCE_SERVER;
|
|
946
1006
|
exports.connectDataConnectEmulator = connectDataConnectEmulator;
|