@firebase/data-connect 0.0.1-dataconnect-preview.81ee5169c → 0.0.2-dataconnect-preview.877f8b7d0
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 +123 -139
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +122 -138
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +125 -141
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +74 -70
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/internal.d.ts +30 -37
- package/dist/node-esm/index.node.esm.js +74 -70
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api/DataConnect.d.ts +6 -12
- package/dist/node-esm/src/api/Mutation.d.ts +8 -8
- package/dist/node-esm/src/api/Reference.d.ts +3 -3
- package/dist/node-esm/src/api/query.d.ts +2 -2
- 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 +30 -37
- package/dist/public.d.ts +13 -28
- package/dist/src/api/DataConnect.d.ts +6 -12
- package/dist/src/api/Mutation.d.ts +8 -8
- package/dist/src/api/Reference.d.ts +3 -3
- package/dist/src/api/query.d.ts +2 -2
- 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.esm2017.js
CHANGED
|
@@ -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.
|
|
7
|
+
const version = "0.0.2-dataconnect-preview.877f8b7d0";
|
|
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(
|
|
80
|
-
this.
|
|
81
|
-
this.
|
|
82
|
-
this.
|
|
83
|
-
this.
|
|
84
|
-
if (!this.
|
|
85
|
-
|
|
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.
|
|
135
|
+
if (!this._auth) {
|
|
90
136
|
return new Promise((resolve, reject) => {
|
|
91
137
|
setTimeout(() => {
|
|
92
|
-
if (this.
|
|
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.
|
|
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.
|
|
161
|
+
(_a = this._auth) === null || _a === void 0 ? void 0 : _a.addAuthTokenListener(listener);
|
|
116
162
|
}
|
|
117
163
|
removeTokenChangeListener(listener) {
|
|
118
|
-
this.
|
|
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
|
|
141
|
-
const
|
|
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:
|
|
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:
|
|
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:
|
|
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.
|
|
498
|
-
this.
|
|
499
|
-
this.
|
|
500
|
-
this.
|
|
501
|
-
this.
|
|
502
|
-
this.
|
|
503
|
-
this.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
540
|
+
this._port = transportOptions.port;
|
|
539
541
|
}
|
|
540
542
|
if (typeof transportOptions.sslEnabled !== 'undefined') {
|
|
541
|
-
this.
|
|
543
|
+
this._secure = transportOptions.sslEnabled;
|
|
542
544
|
}
|
|
543
|
-
this.
|
|
545
|
+
this._host = transportOptions.host;
|
|
544
546
|
}
|
|
545
547
|
const { location, projectId: project, connector, service } = options;
|
|
546
548
|
if (location) {
|
|
547
|
-
this.
|
|
549
|
+
this._location = location;
|
|
548
550
|
}
|
|
549
551
|
if (project) {
|
|
550
|
-
this.
|
|
552
|
+
this._project = project;
|
|
551
553
|
}
|
|
552
|
-
this.
|
|
554
|
+
this._serviceName = service;
|
|
553
555
|
if (!connector) {
|
|
554
556
|
throw new DataConnectError(Code.INVALID_ARGUMENT, 'Connector Name required!');
|
|
555
557
|
}
|
|
556
|
-
this.
|
|
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.
|
|
561
|
+
this._accessToken = token;
|
|
560
562
|
});
|
|
561
563
|
}
|
|
562
564
|
get endpointUrl() {
|
|
563
565
|
return urlBuilder({
|
|
564
|
-
connector: this.
|
|
565
|
-
location: this.
|
|
566
|
-
projectId: this.
|
|
567
|
-
service: this.
|
|
568
|
-
}, { host: this.
|
|
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.
|
|
573
|
+
this._host = host;
|
|
572
574
|
if (typeof port === 'number') {
|
|
573
|
-
this.
|
|
575
|
+
this._port = port;
|
|
574
576
|
}
|
|
575
577
|
if (typeof isSecure !== 'undefined') {
|
|
576
|
-
this.
|
|
578
|
+
this._secure = isSecure;
|
|
577
579
|
}
|
|
578
580
|
}
|
|
579
581
|
onTokenChanged(newToken) {
|
|
580
|
-
this.
|
|
582
|
+
this._accessToken = newToken;
|
|
581
583
|
}
|
|
582
584
|
getWithAuth() {
|
|
583
|
-
let starterPromise = new Promise(resolve => resolve(this.
|
|
584
|
-
if (!this.
|
|
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.
|
|
593
|
-
return this.
|
|
594
|
+
this._accessToken = data.accessToken;
|
|
595
|
+
return this._accessToken;
|
|
594
596
|
});
|
|
595
597
|
}
|
|
596
598
|
else {
|
|
@@ -622,18 +624,18 @@ function mutationRef(dcInstance, queryName, variables) {
|
|
|
622
624
|
const ref = {
|
|
623
625
|
dataConnect: dcInstance,
|
|
624
626
|
name: queryName,
|
|
625
|
-
refType:
|
|
627
|
+
refType: MUTATION_STR,
|
|
626
628
|
variables: variables
|
|
627
629
|
};
|
|
628
630
|
return ref;
|
|
629
631
|
}
|
|
630
632
|
class MutationManager {
|
|
631
|
-
constructor(
|
|
632
|
-
this.
|
|
633
|
+
constructor(_transport) {
|
|
634
|
+
this._transport = _transport;
|
|
633
635
|
this._inflight = [];
|
|
634
636
|
}
|
|
635
637
|
executeMutation(mutationRef) {
|
|
636
|
-
const result = this.
|
|
638
|
+
const result = this._transport.invokeMutation(mutationRef.name, mutationRef.variables);
|
|
637
639
|
const withRefPromise = result.then(res => {
|
|
638
640
|
const obj = Object.assign(Object.assign({}, res), { source: SOURCE_SERVER, ref: mutationRef, fetchTime: Date.now().toLocaleString() });
|
|
639
641
|
return obj;
|
|
@@ -679,10 +681,12 @@ function parseOptions(fullHost) {
|
|
|
679
681
|
return { host, port, sslEnabled: isSecure };
|
|
680
682
|
}
|
|
681
683
|
class DataConnect {
|
|
682
|
-
constructor(app,
|
|
684
|
+
constructor(app,
|
|
685
|
+
// TODO(mtewani): Replace with _dataConnectOptions in the future
|
|
686
|
+
dataConnectOptions, _authProvider) {
|
|
683
687
|
this.app = app;
|
|
684
688
|
this.dataConnectOptions = dataConnectOptions;
|
|
685
|
-
this.
|
|
689
|
+
this._authProvider = _authProvider;
|
|
686
690
|
this.isEmulator = false;
|
|
687
691
|
this.initialized = false;
|
|
688
692
|
if (typeof process !== 'undefined' && process.env) {
|
|
@@ -690,7 +694,7 @@ class DataConnect {
|
|
|
690
694
|
if (host) {
|
|
691
695
|
logDebug('Found custom host. Using emulator');
|
|
692
696
|
this.isEmulator = true;
|
|
693
|
-
this.
|
|
697
|
+
this._transportOptions = parseOptions(host);
|
|
694
698
|
}
|
|
695
699
|
}
|
|
696
700
|
}
|
|
@@ -707,27 +711,27 @@ class DataConnect {
|
|
|
707
711
|
if (this.initialized) {
|
|
708
712
|
return;
|
|
709
713
|
}
|
|
710
|
-
if (this.
|
|
714
|
+
if (this._transportClass === undefined) {
|
|
711
715
|
logDebug('transportClass not provided. Defaulting to RESTTransport.');
|
|
712
|
-
this.
|
|
716
|
+
this._transportClass = RESTTransport;
|
|
713
717
|
}
|
|
714
|
-
if (this.
|
|
715
|
-
this.
|
|
718
|
+
if (this._authProvider) {
|
|
719
|
+
this._authTokenProvider = new FirebaseAuthProvider(this.app.name, this.app.options, this._authProvider);
|
|
716
720
|
}
|
|
717
721
|
this.initialized = true;
|
|
718
|
-
this._transport = new this.
|
|
719
|
-
if (this.
|
|
720
|
-
this._transport.useEmulator(this.
|
|
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);
|
|
721
725
|
}
|
|
722
726
|
this._queryManager = new QueryManager(this._transport);
|
|
723
727
|
this._mutationManager = new MutationManager(this._transport);
|
|
724
728
|
}
|
|
725
729
|
enableEmulator(transportOptions) {
|
|
726
730
|
if (this.initialized) {
|
|
727
|
-
logError('enableEmulator called
|
|
731
|
+
logError('enableEmulator called after initialization');
|
|
728
732
|
throw new DataConnectError(Code.ALREADY_INITIALIZED, 'DataConnect instance already initialized!');
|
|
729
733
|
}
|
|
730
|
-
this.
|
|
734
|
+
this._transportOptions = transportOptions;
|
|
731
735
|
this.isEmulator = true;
|
|
732
736
|
}
|
|
733
737
|
}
|
|
@@ -770,7 +774,7 @@ function getDataConnect(appOrOptions, optionalOptions) {
|
|
|
770
774
|
});
|
|
771
775
|
}
|
|
772
776
|
function terminate(dataConnect) {
|
|
773
|
-
dataConnect._delete();
|
|
777
|
+
return dataConnect._delete();
|
|
774
778
|
// TODO(mtewani): Stop pending tasks
|
|
775
779
|
}
|
|
776
780
|
|
|
@@ -830,7 +834,7 @@ function queryRef(dcInstance, queryName, variables, initialCache) {
|
|
|
830
834
|
dcInstance._queryManager.track(queryName, variables, initialCache);
|
|
831
835
|
return {
|
|
832
836
|
dataConnect: dcInstance,
|
|
833
|
-
refType:
|
|
837
|
+
refType: QUERY_STR,
|
|
834
838
|
name: queryName,
|
|
835
839
|
variables: variables
|
|
836
840
|
};
|
|
@@ -860,7 +864,7 @@ function subscribe(queryRefOrSerializedResult, observerOrOnNext, onError, onComp
|
|
|
860
864
|
let ref;
|
|
861
865
|
let initialCache;
|
|
862
866
|
if ('refInfo' in queryRefOrSerializedResult) {
|
|
863
|
-
|
|
867
|
+
const serializedRef = queryRefOrSerializedResult;
|
|
864
868
|
const { data, source, fetchTime } = serializedRef;
|
|
865
869
|
initialCache = {
|
|
866
870
|
data,
|
|
@@ -892,27 +896,7 @@ function subscribe(queryRefOrSerializedResult, observerOrOnNext, onError, onComp
|
|
|
892
896
|
*
|
|
893
897
|
* @packageDocumentation
|
|
894
898
|
*/
|
|
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
|
-
// })
|
|
899
|
+
registerDataConnect();
|
|
916
900
|
|
|
917
|
-
export { DataConnect, FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR, FirebaseAuthProvider,
|
|
901
|
+
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
902
|
//# sourceMappingURL=index.esm2017.js.map
|