@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.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.
|
|
11
|
+
const version = "0.0.2-dataconnect-preview.877f8b7d0";
|
|
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(
|
|
84
|
-
this.
|
|
85
|
-
this.
|
|
86
|
-
this.
|
|
87
|
-
this.
|
|
88
|
-
if (!this.
|
|
89
|
-
|
|
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.
|
|
139
|
+
if (!this._auth) {
|
|
94
140
|
return new Promise((resolve, reject) => {
|
|
95
141
|
setTimeout(() => {
|
|
96
|
-
if (this.
|
|
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.
|
|
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.
|
|
165
|
+
(_a = this._auth) === null || _a === void 0 ? void 0 : _a.addAuthTokenListener(listener);
|
|
120
166
|
}
|
|
121
167
|
removeTokenChangeListener(listener) {
|
|
122
|
-
this.
|
|
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
|
|
145
|
-
const
|
|
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:
|
|
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:
|
|
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:
|
|
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.
|
|
502
|
-
this.
|
|
503
|
-
this.
|
|
504
|
-
this.
|
|
505
|
-
this.
|
|
506
|
-
this.
|
|
507
|
-
this.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
544
|
+
this._port = transportOptions.port;
|
|
543
545
|
}
|
|
544
546
|
if (typeof transportOptions.sslEnabled !== 'undefined') {
|
|
545
|
-
this.
|
|
547
|
+
this._secure = transportOptions.sslEnabled;
|
|
546
548
|
}
|
|
547
|
-
this.
|
|
549
|
+
this._host = transportOptions.host;
|
|
548
550
|
}
|
|
549
551
|
const { location, projectId: project, connector, service } = options;
|
|
550
552
|
if (location) {
|
|
551
|
-
this.
|
|
553
|
+
this._location = location;
|
|
552
554
|
}
|
|
553
555
|
if (project) {
|
|
554
|
-
this.
|
|
556
|
+
this._project = project;
|
|
555
557
|
}
|
|
556
|
-
this.
|
|
558
|
+
this._serviceName = service;
|
|
557
559
|
if (!connector) {
|
|
558
560
|
throw new DataConnectError(Code.INVALID_ARGUMENT, 'Connector Name required!');
|
|
559
561
|
}
|
|
560
|
-
this.
|
|
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.
|
|
565
|
+
this._accessToken = token;
|
|
564
566
|
});
|
|
565
567
|
}
|
|
566
568
|
get endpointUrl() {
|
|
567
569
|
return urlBuilder({
|
|
568
|
-
connector: this.
|
|
569
|
-
location: this.
|
|
570
|
-
projectId: this.
|
|
571
|
-
service: this.
|
|
572
|
-
}, { host: this.
|
|
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.
|
|
577
|
+
this._host = host;
|
|
576
578
|
if (typeof port === 'number') {
|
|
577
|
-
this.
|
|
579
|
+
this._port = port;
|
|
578
580
|
}
|
|
579
581
|
if (typeof isSecure !== 'undefined') {
|
|
580
|
-
this.
|
|
582
|
+
this._secure = isSecure;
|
|
581
583
|
}
|
|
582
584
|
}
|
|
583
585
|
onTokenChanged(newToken) {
|
|
584
|
-
this.
|
|
586
|
+
this._accessToken = newToken;
|
|
585
587
|
}
|
|
586
588
|
getWithAuth() {
|
|
587
|
-
let starterPromise = new Promise(resolve => resolve(this.
|
|
588
|
-
if (!this.
|
|
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.
|
|
597
|
-
return this.
|
|
598
|
+
this._accessToken = data.accessToken;
|
|
599
|
+
return this._accessToken;
|
|
598
600
|
});
|
|
599
601
|
}
|
|
600
602
|
else {
|
|
@@ -626,18 +628,18 @@ function mutationRef(dcInstance, queryName, variables) {
|
|
|
626
628
|
const ref = {
|
|
627
629
|
dataConnect: dcInstance,
|
|
628
630
|
name: queryName,
|
|
629
|
-
refType:
|
|
631
|
+
refType: MUTATION_STR,
|
|
630
632
|
variables: variables
|
|
631
633
|
};
|
|
632
634
|
return ref;
|
|
633
635
|
}
|
|
634
636
|
class MutationManager {
|
|
635
|
-
constructor(
|
|
636
|
-
this.
|
|
637
|
+
constructor(_transport) {
|
|
638
|
+
this._transport = _transport;
|
|
637
639
|
this._inflight = [];
|
|
638
640
|
}
|
|
639
641
|
executeMutation(mutationRef) {
|
|
640
|
-
const result = this.
|
|
642
|
+
const result = this._transport.invokeMutation(mutationRef.name, mutationRef.variables);
|
|
641
643
|
const withRefPromise = result.then(res => {
|
|
642
644
|
const obj = Object.assign(Object.assign({}, res), { source: SOURCE_SERVER, ref: mutationRef, fetchTime: Date.now().toLocaleString() });
|
|
643
645
|
return obj;
|
|
@@ -683,10 +685,12 @@ function parseOptions(fullHost) {
|
|
|
683
685
|
return { host, port, sslEnabled: isSecure };
|
|
684
686
|
}
|
|
685
687
|
class DataConnect {
|
|
686
|
-
constructor(app,
|
|
688
|
+
constructor(app,
|
|
689
|
+
// TODO(mtewani): Replace with _dataConnectOptions in the future
|
|
690
|
+
dataConnectOptions, _authProvider) {
|
|
687
691
|
this.app = app;
|
|
688
692
|
this.dataConnectOptions = dataConnectOptions;
|
|
689
|
-
this.
|
|
693
|
+
this._authProvider = _authProvider;
|
|
690
694
|
this.isEmulator = false;
|
|
691
695
|
this.initialized = false;
|
|
692
696
|
if (typeof process !== 'undefined' && process.env) {
|
|
@@ -694,7 +698,7 @@ class DataConnect {
|
|
|
694
698
|
if (host) {
|
|
695
699
|
logDebug('Found custom host. Using emulator');
|
|
696
700
|
this.isEmulator = true;
|
|
697
|
-
this.
|
|
701
|
+
this._transportOptions = parseOptions(host);
|
|
698
702
|
}
|
|
699
703
|
}
|
|
700
704
|
}
|
|
@@ -711,27 +715,27 @@ class DataConnect {
|
|
|
711
715
|
if (this.initialized) {
|
|
712
716
|
return;
|
|
713
717
|
}
|
|
714
|
-
if (this.
|
|
718
|
+
if (this._transportClass === undefined) {
|
|
715
719
|
logDebug('transportClass not provided. Defaulting to RESTTransport.');
|
|
716
|
-
this.
|
|
720
|
+
this._transportClass = RESTTransport;
|
|
717
721
|
}
|
|
718
|
-
if (this.
|
|
719
|
-
this.
|
|
722
|
+
if (this._authProvider) {
|
|
723
|
+
this._authTokenProvider = new FirebaseAuthProvider(this.app.name, this.app.options, this._authProvider);
|
|
720
724
|
}
|
|
721
725
|
this.initialized = true;
|
|
722
|
-
this._transport = new this.
|
|
723
|
-
if (this.
|
|
724
|
-
this._transport.useEmulator(this.
|
|
726
|
+
this._transport = new this._transportClass(this.dataConnectOptions, this.app.options.apiKey, this._authTokenProvider);
|
|
727
|
+
if (this._transportOptions) {
|
|
728
|
+
this._transport.useEmulator(this._transportOptions.host, this._transportOptions.port, this._transportOptions.sslEnabled);
|
|
725
729
|
}
|
|
726
730
|
this._queryManager = new QueryManager(this._transport);
|
|
727
731
|
this._mutationManager = new MutationManager(this._transport);
|
|
728
732
|
}
|
|
729
733
|
enableEmulator(transportOptions) {
|
|
730
734
|
if (this.initialized) {
|
|
731
|
-
logError('enableEmulator called
|
|
735
|
+
logError('enableEmulator called after initialization');
|
|
732
736
|
throw new DataConnectError(Code.ALREADY_INITIALIZED, 'DataConnect instance already initialized!');
|
|
733
737
|
}
|
|
734
|
-
this.
|
|
738
|
+
this._transportOptions = transportOptions;
|
|
735
739
|
this.isEmulator = true;
|
|
736
740
|
}
|
|
737
741
|
}
|
|
@@ -774,7 +778,7 @@ function getDataConnect(appOrOptions, optionalOptions) {
|
|
|
774
778
|
});
|
|
775
779
|
}
|
|
776
780
|
function terminate(dataConnect) {
|
|
777
|
-
dataConnect._delete();
|
|
781
|
+
return dataConnect._delete();
|
|
778
782
|
// TODO(mtewani): Stop pending tasks
|
|
779
783
|
}
|
|
780
784
|
|
|
@@ -834,7 +838,7 @@ function queryRef(dcInstance, queryName, variables, initialCache) {
|
|
|
834
838
|
dcInstance._queryManager.track(queryName, variables, initialCache);
|
|
835
839
|
return {
|
|
836
840
|
dataConnect: dcInstance,
|
|
837
|
-
refType:
|
|
841
|
+
refType: QUERY_STR,
|
|
838
842
|
name: queryName,
|
|
839
843
|
variables: variables
|
|
840
844
|
};
|
|
@@ -864,7 +868,7 @@ function subscribe(queryRefOrSerializedResult, observerOrOnNext, onError, onComp
|
|
|
864
868
|
let ref;
|
|
865
869
|
let initialCache;
|
|
866
870
|
if ('refInfo' in queryRefOrSerializedResult) {
|
|
867
|
-
|
|
871
|
+
const serializedRef = queryRefOrSerializedResult;
|
|
868
872
|
const { data, source, fetchTime } = serializedRef;
|
|
869
873
|
initialCache = {
|
|
870
874
|
data,
|
|
@@ -896,34 +900,14 @@ function subscribe(queryRefOrSerializedResult, observerOrOnNext, onError, onComp
|
|
|
896
900
|
*
|
|
897
901
|
* @packageDocumentation
|
|
898
902
|
*/
|
|
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
|
-
// })
|
|
903
|
+
registerDataConnect();
|
|
920
904
|
|
|
921
905
|
exports.DataConnect = DataConnect;
|
|
922
906
|
exports.FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR;
|
|
923
907
|
exports.FirebaseAuthProvider = FirebaseAuthProvider;
|
|
908
|
+
exports.MUTATION_STR = MUTATION_STR;
|
|
924
909
|
exports.MutationManager = MutationManager;
|
|
925
|
-
exports.
|
|
926
|
-
exports.QueryStr = QueryStr;
|
|
910
|
+
exports.QUERY_STR = QUERY_STR;
|
|
927
911
|
exports.SOURCE_CACHE = SOURCE_CACHE;
|
|
928
912
|
exports.SOURCE_SERVER = SOURCE_SERVER;
|
|
929
913
|
exports.connectDataConnectEmulator = connectDataConnectEmulator;
|