@firebase/data-connect 0.1.0 → 0.1.1

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.
@@ -2,7 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib = require('tslib');
6
5
  var util = require('@firebase/util');
7
6
  var logger$1 = require('@firebase/logger');
8
7
  var app = require('@firebase/app');
@@ -24,7 +23,7 @@ var component = require('@firebase/component');
24
23
  * See the License for the specific language governing permissions and
25
24
  * limitations under the License.
26
25
  */
27
- var Code = {
26
+ const Code = {
28
27
  OTHER: 'other',
29
28
  ALREADY_INITIALIZED: 'already-initialized',
30
29
  NOT_INITIALIZED: 'not-initialized',
@@ -34,10 +33,9 @@ var Code = {
34
33
  UNAUTHORIZED: 'unauthorized'
35
34
  };
36
35
  /** An error returned by a DataConnect operation. */
37
- var DataConnectError = /** @class */ (function (_super) {
38
- tslib.__extends(DataConnectError, _super);
36
+ class DataConnectError extends util.FirebaseError {
39
37
  /** @hideconstructor */
40
- function DataConnectError(
38
+ constructor(
41
39
  /**
42
40
  * The backend error code associated with this error.
43
41
  */
@@ -46,17 +44,15 @@ var DataConnectError = /** @class */ (function (_super) {
46
44
  * A custom error description.
47
45
  */
48
46
  message) {
49
- var _this = _super.call(this, code, message) || this;
50
- _this.code = code;
51
- _this.message = message;
47
+ super(code, message);
48
+ this.code = code;
49
+ this.message = message;
52
50
  // HACK: We write a toString property directly because Error is not a real
53
51
  // class and so inheritance does not work correctly. We could alternatively
54
52
  // do the same "back-door inheritance" trick that FirebaseError does.
55
- _this.toString = function () { return "".concat(_this.name, ": [code=").concat(_this.code, "]: ").concat(_this.message); };
56
- return _this;
53
+ this.toString = () => `${this.name}: [code=${this.code}]: ${this.message}`;
57
54
  }
58
- return DataConnectError;
59
- }(util.FirebaseError));
55
+ }
60
56
 
61
57
  /**
62
58
  * @license
@@ -75,7 +71,7 @@ var DataConnectError = /** @class */ (function (_super) {
75
71
  * limitations under the License.
76
72
  */
77
73
  /** The semver (www.semver.org) version of the SDK. */
78
- var SDK_VERSION = '';
74
+ let SDK_VERSION = '';
79
75
  /**
80
76
  * SDK_VERSION should be set before any database instance is created
81
77
  * @internal
@@ -100,15 +96,15 @@ function setSDKVersion(version) {
100
96
  * See the License for the specific language governing permissions and
101
97
  * limitations under the License.
102
98
  */
103
- var logger = new logger$1.Logger('@firebase/data-connect');
99
+ const logger = new logger$1.Logger('@firebase/data-connect');
104
100
  function setLogLevel(logLevel) {
105
101
  logger.setLogLevel(logLevel);
106
102
  }
107
103
  function logDebug(msg) {
108
- logger.debug("DataConnect (".concat(SDK_VERSION, "): ").concat(msg));
104
+ logger.debug(`DataConnect (${SDK_VERSION}): ${msg}`);
109
105
  }
110
106
  function logError(msg) {
111
- logger.error("DataConnect (".concat(SDK_VERSION, "): ").concat(msg));
107
+ logger.error(`DataConnect (${SDK_VERSION}): ${msg}`);
112
108
  }
113
109
 
114
110
  /**
@@ -127,24 +123,22 @@ function logError(msg) {
127
123
  * See the License for the specific language governing permissions and
128
124
  * limitations under the License.
129
125
  */
130
- var connectFetch = globalThis.fetch;
126
+ let connectFetch = globalThis.fetch;
131
127
  function initializeFetch(fetchImpl) {
132
128
  connectFetch = fetchImpl;
133
129
  }
134
130
  function getGoogApiClientValue(_isUsingGen) {
135
- var str = 'gl-js/ fire/' + SDK_VERSION;
131
+ let str = 'gl-js/ fire/' + SDK_VERSION;
136
132
  if (_isUsingGen) {
137
- str += ' web/gen';
133
+ str += ' js/gen';
138
134
  }
139
135
  return str;
140
136
  }
141
- function dcFetch(url, body, _a, appId, accessToken, appCheckToken, _isUsingGen) {
142
- var _this = this;
143
- var signal = _a.signal;
137
+ function dcFetch(url, body, { signal }, appId, accessToken, appCheckToken, _isUsingGen) {
144
138
  if (!connectFetch) {
145
139
  throw new DataConnectError(Code.OTHER, 'No Fetch Implementation detected!');
146
140
  }
147
- var headers = {
141
+ const headers = {
148
142
  'Content-Type': 'application/json',
149
143
  'X-Goog-Api-Client': getGoogApiClientValue(_isUsingGen)
150
144
  };
@@ -157,49 +151,38 @@ function dcFetch(url, body, _a, appId, accessToken, appCheckToken, _isUsingGen)
157
151
  if (appCheckToken) {
158
152
  headers['X-Firebase-AppCheck'] = appCheckToken;
159
153
  }
160
- var bodyStr = JSON.stringify(body);
161
- logDebug("Making request out to ".concat(url, " with body: ").concat(bodyStr));
154
+ const bodyStr = JSON.stringify(body);
155
+ logDebug(`Making request out to ${url} with body: ${bodyStr}`);
162
156
  return connectFetch(url, {
163
157
  body: bodyStr,
164
158
  method: 'POST',
165
- headers: headers,
166
- signal: signal
159
+ headers,
160
+ signal
167
161
  })
168
- .catch(function (err) {
162
+ .catch(err => {
169
163
  throw new DataConnectError(Code.OTHER, 'Failed to fetch: ' + JSON.stringify(err));
170
164
  })
171
- .then(function (response) { return tslib.__awaiter(_this, void 0, void 0, function () {
172
- var jsonResponse, e_1, message;
173
- return tslib.__generator(this, function (_a) {
174
- switch (_a.label) {
175
- case 0:
176
- jsonResponse = null;
177
- _a.label = 1;
178
- case 1:
179
- _a.trys.push([1, 3, , 4]);
180
- return [4 /*yield*/, response.json()];
181
- case 2:
182
- jsonResponse = _a.sent();
183
- return [3 /*break*/, 4];
184
- case 3:
185
- e_1 = _a.sent();
186
- throw new DataConnectError(Code.OTHER, JSON.stringify(e_1));
187
- case 4:
188
- message = getMessage(jsonResponse);
189
- if (response.status >= 400) {
190
- logError('Error while performing request: ' + JSON.stringify(jsonResponse));
191
- if (response.status === 401) {
192
- throw new DataConnectError(Code.UNAUTHORIZED, message);
193
- }
194
- throw new DataConnectError(Code.OTHER, message);
195
- }
196
- return [2 /*return*/, jsonResponse];
165
+ .then(async (response) => {
166
+ let jsonResponse = null;
167
+ try {
168
+ jsonResponse = await response.json();
169
+ }
170
+ catch (e) {
171
+ throw new DataConnectError(Code.OTHER, JSON.stringify(e));
172
+ }
173
+ const message = getMessage(jsonResponse);
174
+ if (response.status >= 400) {
175
+ logError('Error while performing request: ' + JSON.stringify(jsonResponse));
176
+ if (response.status === 401) {
177
+ throw new DataConnectError(Code.UNAUTHORIZED, message);
197
178
  }
198
- });
199
- }); })
200
- .then(function (res) {
179
+ throw new DataConnectError(Code.OTHER, message);
180
+ }
181
+ return jsonResponse;
182
+ })
183
+ .then(res => {
201
184
  if (res.errors && res.errors.length) {
202
- var stringified = JSON.stringify(res.errors);
185
+ const stringified = JSON.stringify(res.errors);
203
186
  logError('DataConnect error while performing request: ' + stringified);
204
187
  throw new DataConnectError(Code.OTHER, stringified);
205
188
  }
@@ -213,8 +196,8 @@ function getMessage(obj) {
213
196
  return JSON.stringify(obj);
214
197
  }
215
198
 
216
- var name = "@firebase/data-connect";
217
- var version = "0.1.0";
199
+ const name = "@firebase/data-connect";
200
+ const version = "0.1.1";
218
201
 
219
202
  /**
220
203
  * @license
@@ -236,27 +219,25 @@ var version = "0.1.0";
236
219
  * @internal
237
220
  * Abstraction around AppCheck's token fetching capabilities.
238
221
  */
239
- var AppCheckTokenProvider = /** @class */ (function () {
240
- function AppCheckTokenProvider(appName_, appCheckProvider) {
241
- var _this = this;
222
+ class AppCheckTokenProvider {
223
+ constructor(appName_, appCheckProvider) {
242
224
  this.appName_ = appName_;
243
225
  this.appCheckProvider = appCheckProvider;
244
226
  this.appCheck = appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.getImmediate({ optional: true });
245
227
  if (!this.appCheck) {
246
- void (appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(function (appCheck) { return (_this.appCheck = appCheck); }).catch());
228
+ void (appCheckProvider === null || appCheckProvider === void 0 ? void 0 : appCheckProvider.get().then(appCheck => (this.appCheck = appCheck)).catch());
247
229
  }
248
230
  }
249
- AppCheckTokenProvider.prototype.getToken = function (forceRefresh) {
250
- var _this = this;
231
+ getToken(forceRefresh) {
251
232
  if (!this.appCheck) {
252
- return new Promise(function (resolve, reject) {
233
+ return new Promise((resolve, reject) => {
253
234
  // Support delayed initialization of FirebaseAppCheck. This allows our
254
235
  // customers to initialize the RTDB SDK before initializing Firebase
255
236
  // AppCheck and ensures that all requests are authenticated if a token
256
237
  // becomes available before the timoeout below expires.
257
- setTimeout(function () {
258
- if (_this.appCheck) {
259
- _this.getToken(forceRefresh).then(resolve, reject);
238
+ setTimeout(() => {
239
+ if (this.appCheck) {
240
+ this.getToken(forceRefresh).then(resolve, reject);
260
241
  }
261
242
  else {
262
243
  resolve(null);
@@ -265,13 +246,12 @@ var AppCheckTokenProvider = /** @class */ (function () {
265
246
  });
266
247
  }
267
248
  return this.appCheck.getToken(forceRefresh);
268
- };
269
- AppCheckTokenProvider.prototype.addTokenChangeListener = function (listener) {
249
+ }
250
+ addTokenChangeListener(listener) {
270
251
  var _a;
271
- void ((_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(function (appCheck) { return appCheck.addTokenListener(listener); }));
272
- };
273
- return AppCheckTokenProvider;
274
- }());
252
+ void ((_a = this.appCheckProvider) === null || _a === void 0 ? void 0 : _a.get().then(appCheck => appCheck.addTokenListener(listener)));
253
+ }
254
+ }
275
255
 
276
256
  /**
277
257
  * @license
@@ -290,24 +270,22 @@ var AppCheckTokenProvider = /** @class */ (function () {
290
270
  * limitations under the License.
291
271
  */
292
272
  // @internal
293
- var FirebaseAuthProvider = /** @class */ (function () {
294
- function FirebaseAuthProvider(_appName, _options, _authProvider) {
295
- var _this = this;
273
+ class FirebaseAuthProvider {
274
+ constructor(_appName, _options, _authProvider) {
296
275
  this._appName = _appName;
297
276
  this._options = _options;
298
277
  this._authProvider = _authProvider;
299
278
  this._auth = _authProvider.getImmediate({ optional: true });
300
279
  if (!this._auth) {
301
- _authProvider.onInit(function (auth) { return (_this._auth = auth); });
280
+ _authProvider.onInit(auth => (this._auth = auth));
302
281
  }
303
282
  }
304
- FirebaseAuthProvider.prototype.getToken = function (forceRefresh) {
305
- var _this = this;
283
+ getToken(forceRefresh) {
306
284
  if (!this._auth) {
307
- return new Promise(function (resolve, reject) {
308
- setTimeout(function () {
309
- if (_this._auth) {
310
- _this.getToken(forceRefresh).then(resolve, reject);
285
+ return new Promise((resolve, reject) => {
286
+ setTimeout(() => {
287
+ if (this._auth) {
288
+ this.getToken(forceRefresh).then(resolve, reject);
311
289
  }
312
290
  else {
313
291
  resolve(null);
@@ -315,7 +293,7 @@ var FirebaseAuthProvider = /** @class */ (function () {
315
293
  }, 0);
316
294
  });
317
295
  }
318
- return this._auth.getToken(forceRefresh).catch(function (error) {
296
+ return this._auth.getToken(forceRefresh).catch(error => {
319
297
  if (error && error.code === 'auth/token-not-initialized') {
320
298
  logDebug('Got auth/token-not-initialized error. Treating as null token.');
321
299
  return null;
@@ -326,19 +304,18 @@ var FirebaseAuthProvider = /** @class */ (function () {
326
304
  return Promise.reject(error);
327
305
  }
328
306
  });
329
- };
330
- FirebaseAuthProvider.prototype.addTokenChangeListener = function (listener) {
307
+ }
308
+ addTokenChangeListener(listener) {
331
309
  var _a;
332
310
  (_a = this._auth) === null || _a === void 0 ? void 0 : _a.addAuthTokenListener(listener);
333
- };
334
- FirebaseAuthProvider.prototype.removeTokenChangeListener = function (listener) {
311
+ }
312
+ removeTokenChangeListener(listener) {
335
313
  this._authProvider
336
314
  .get()
337
- .then(function (auth) { return auth.removeAuthTokenListener(listener); })
338
- .catch(function (err) { return logError(err); });
339
- };
340
- return FirebaseAuthProvider;
341
- }());
315
+ .then(auth => auth.removeAuthTokenListener(listener))
316
+ .catch(err => logError(err));
317
+ }
318
+ }
342
319
 
343
320
  /**
344
321
  * @license
@@ -356,10 +333,10 @@ var FirebaseAuthProvider = /** @class */ (function () {
356
333
  * See the License for the specific language governing permissions and
357
334
  * limitations under the License.
358
335
  */
359
- var QUERY_STR = 'query';
360
- var MUTATION_STR = 'mutation';
361
- var SOURCE_SERVER = 'SERVER';
362
- var SOURCE_CACHE = 'CACHE';
336
+ const QUERY_STR = 'query';
337
+ const MUTATION_STR = 'mutation';
338
+ const SOURCE_SERVER = 'SERVER';
339
+ const SOURCE_CACHE = 'CACHE';
363
340
 
364
341
  /**
365
342
  * @license
@@ -377,11 +354,11 @@ var SOURCE_CACHE = 'CACHE';
377
354
  * See the License for the specific language governing permissions and
378
355
  * limitations under the License.
379
356
  */
380
- var encoderImpl;
357
+ let encoderImpl;
381
358
  function setEncoder(encoder) {
382
359
  encoderImpl = encoder;
383
360
  }
384
- setEncoder(function (o) { return JSON.stringify(o); });
361
+ setEncoder(o => JSON.stringify(o));
385
362
 
386
363
  /**
387
364
  * @license
@@ -424,31 +401,31 @@ function setIfNotExists(map, key, val) {
424
401
  function getRefSerializer(queryRef, data, source) {
425
402
  return function toJSON() {
426
403
  return {
427
- data: data,
404
+ data,
428
405
  refInfo: {
429
406
  name: queryRef.name,
430
407
  variables: queryRef.variables,
431
- connectorConfig: tslib.__assign({ projectId: queryRef.dataConnect.app.options.projectId }, queryRef.dataConnect.getSettings())
408
+ connectorConfig: Object.assign({ projectId: queryRef.dataConnect.app.options.projectId }, queryRef.dataConnect.getSettings())
432
409
  },
433
410
  fetchTime: Date.now().toLocaleString(),
434
- source: source
411
+ source
435
412
  };
436
413
  };
437
414
  }
438
- var QueryManager = /** @class */ (function () {
439
- function QueryManager(transport) {
415
+ class QueryManager {
416
+ constructor(transport) {
440
417
  this.transport = transport;
441
418
  this._queries = new Map();
442
419
  }
443
- QueryManager.prototype.track = function (queryName, variables, initialCache) {
444
- var ref = {
420
+ track(queryName, variables, initialCache) {
421
+ const ref = {
445
422
  name: queryName,
446
- variables: variables,
423
+ variables,
447
424
  refType: QUERY_STR
448
425
  };
449
- var key = encoderImpl(ref);
450
- var newTrackedQuery = {
451
- ref: ref,
426
+ const key = encoderImpl(ref);
427
+ const newTrackedQuery = {
428
+ ref,
452
429
  subscriptions: [],
453
430
  currentCache: initialCache || null,
454
431
  lastError: null
@@ -456,22 +433,21 @@ var QueryManager = /** @class */ (function () {
456
433
  // @ts-ignore
457
434
  setIfNotExists(this._queries, key, newTrackedQuery);
458
435
  return this._queries.get(key);
459
- };
460
- QueryManager.prototype.addSubscription = function (queryRef, onResultCallback, onErrorCallback, initialCache) {
461
- var _this = this;
462
- var key = encoderImpl({
436
+ }
437
+ addSubscription(queryRef, onResultCallback, onErrorCallback, initialCache) {
438
+ const key = encoderImpl({
463
439
  name: queryRef.name,
464
440
  variables: queryRef.variables,
465
441
  refType: QUERY_STR
466
442
  });
467
- var trackedQuery = this._queries.get(key);
468
- var subscription = {
443
+ const trackedQuery = this._queries.get(key);
444
+ const subscription = {
469
445
  userCallback: onResultCallback,
470
446
  errCallback: onErrorCallback
471
447
  };
472
- var unsubscribe = function () {
473
- var trackedQuery = _this._queries.get(key);
474
- trackedQuery.subscriptions = trackedQuery.subscriptions.filter(function (sub) { return sub !== subscription; });
448
+ const unsubscribe = () => {
449
+ const trackedQuery = this._queries.get(key);
450
+ trackedQuery.subscriptions = trackedQuery.subscriptions.filter(sub => sub !== subscription);
475
451
  };
476
452
  if (initialCache && trackedQuery.currentCache !== initialCache) {
477
453
  logDebug('Initial cache found. Comparing dates.');
@@ -482,7 +458,7 @@ var QueryManager = /** @class */ (function () {
482
458
  }
483
459
  }
484
460
  if (trackedQuery.currentCache !== null) {
485
- var cachedData = trackedQuery.currentCache.data;
461
+ const cachedData = trackedQuery.currentCache.data;
486
462
  onResultCallback({
487
463
  data: cachedData,
488
464
  source: SOURCE_CACHE,
@@ -497,39 +473,42 @@ var QueryManager = /** @class */ (function () {
497
473
  trackedQuery.subscriptions.push({
498
474
  userCallback: onResultCallback,
499
475
  errCallback: onErrorCallback,
500
- unsubscribe: unsubscribe
476
+ unsubscribe
501
477
  });
502
478
  if (!trackedQuery.currentCache) {
503
- logDebug("No cache available for query ".concat(queryRef.name, " with variables ").concat(JSON.stringify(queryRef.variables), ". Calling executeQuery."));
504
- var promise = this.executeQuery(queryRef);
479
+ logDebug(`No cache available for query ${queryRef.name} with variables ${JSON.stringify(queryRef.variables)}. Calling executeQuery.`);
480
+ const promise = this.executeQuery(queryRef);
505
481
  // We want to ignore the error and let subscriptions handle it
506
- promise.then(undefined, function (err) { });
482
+ promise.then(undefined, err => { });
507
483
  }
508
484
  return unsubscribe;
509
- };
510
- QueryManager.prototype.executeQuery = function (queryRef) {
511
- var key = encoderImpl({
485
+ }
486
+ executeQuery(queryRef) {
487
+ if (queryRef.refType !== QUERY_STR) {
488
+ throw new DataConnectError(Code.INVALID_ARGUMENT, `ExecuteQuery can only execute query operation`);
489
+ }
490
+ const key = encoderImpl({
512
491
  name: queryRef.name,
513
492
  variables: queryRef.variables,
514
493
  refType: QUERY_STR
515
494
  });
516
- var trackedQuery = this._queries.get(key);
517
- var result = this.transport.invokeQuery(queryRef.name, queryRef.variables);
518
- var newR = result.then(function (res) {
519
- var fetchTime = new Date().toString();
520
- var result = tslib.__assign(tslib.__assign({}, res), { source: SOURCE_SERVER, ref: queryRef, toJSON: getRefSerializer(queryRef, res.data, SOURCE_SERVER), fetchTime: fetchTime });
521
- trackedQuery.subscriptions.forEach(function (subscription) {
495
+ const trackedQuery = this._queries.get(key);
496
+ const result = this.transport.invokeQuery(queryRef.name, queryRef.variables);
497
+ const newR = result.then(res => {
498
+ const fetchTime = new Date().toString();
499
+ const result = Object.assign(Object.assign({}, res), { source: SOURCE_SERVER, ref: queryRef, toJSON: getRefSerializer(queryRef, res.data, SOURCE_SERVER), fetchTime });
500
+ trackedQuery.subscriptions.forEach(subscription => {
522
501
  subscription.userCallback(result);
523
502
  });
524
503
  trackedQuery.currentCache = {
525
504
  data: res.data,
526
505
  source: SOURCE_CACHE,
527
- fetchTime: fetchTime
506
+ fetchTime
528
507
  };
529
508
  return result;
530
- }, function (err) {
509
+ }, err => {
531
510
  trackedQuery.lastError = err;
532
- trackedQuery.subscriptions.forEach(function (subscription) {
511
+ trackedQuery.subscriptions.forEach(subscription => {
533
512
  if (subscription.errCallback) {
534
513
  subscription.errCallback(err);
535
514
  }
@@ -537,15 +516,14 @@ var QueryManager = /** @class */ (function () {
537
516
  throw err;
538
517
  });
539
518
  return newR;
540
- };
541
- QueryManager.prototype.enableEmulator = function (host, port) {
519
+ }
520
+ enableEmulator(host, port) {
542
521
  this.transport.useEmulator(host, port);
543
- };
544
- return QueryManager;
545
- }());
522
+ }
523
+ }
546
524
  function compareDates(str1, str2) {
547
- var date1 = new Date(str1);
548
- var date2 = new Date(str2);
525
+ const date1 = new Date(str1);
526
+ const date2 = new Date(str2);
549
527
  return date1.getTime() < date2.getTime();
550
528
  }
551
529
 
@@ -566,25 +544,25 @@ function compareDates(str1, str2) {
566
544
  * limitations under the License.
567
545
  */
568
546
  function urlBuilder(projectConfig, transportOptions) {
569
- var connector = projectConfig.connector, location = projectConfig.location, project = projectConfig.projectId, service = projectConfig.service;
570
- var host = transportOptions.host, sslEnabled = transportOptions.sslEnabled, port = transportOptions.port;
571
- var protocol = sslEnabled ? 'https' : 'http';
572
- var realHost = host || "firebasedataconnect.googleapis.com";
573
- var baseUrl = "".concat(protocol, "://").concat(realHost);
547
+ const { connector, location, projectId: project, service } = projectConfig;
548
+ const { host, sslEnabled, port } = transportOptions;
549
+ const protocol = sslEnabled ? 'https' : 'http';
550
+ const realHost = host || `firebasedataconnect.googleapis.com`;
551
+ let baseUrl = `${protocol}://${realHost}`;
574
552
  if (typeof port === 'number') {
575
- baseUrl += ":".concat(port);
553
+ baseUrl += `:${port}`;
576
554
  }
577
555
  else if (typeof port !== 'undefined') {
578
556
  logError('Port type is of an invalid type');
579
557
  throw new DataConnectError(Code.INVALID_ARGUMENT, 'Incorrect type for port passed in!');
580
558
  }
581
- return "".concat(baseUrl, "/v1beta/projects/").concat(project, "/locations/").concat(location, "/services/").concat(service, "/connectors/").concat(connector);
559
+ return `${baseUrl}/v1beta/projects/${project}/locations/${location}/services/${service}/connectors/${connector}`;
582
560
  }
583
561
  function addToken(url, apiKey) {
584
562
  if (!apiKey) {
585
563
  return url;
586
564
  }
587
- var newUrl = new URL(url);
565
+ const newUrl = new URL(url);
588
566
  newUrl.searchParams.append('key', apiKey);
589
567
  return newUrl.toString();
590
568
  }
@@ -605,10 +583,8 @@ function addToken(url, apiKey) {
605
583
  * See the License for the specific language governing permissions and
606
584
  * limitations under the License.
607
585
  */
608
- var RESTTransport = /** @class */ (function () {
609
- function RESTTransport(options, apiKey, appId, authProvider, appCheckProvider, transportOptions, _isUsingGen) {
610
- if (_isUsingGen === void 0) { _isUsingGen = false; }
611
- var _this = this;
586
+ class RESTTransport {
587
+ constructor(options, apiKey, appId, authProvider, appCheckProvider, transportOptions, _isUsingGen = false) {
612
588
  var _a, _b;
613
589
  this.apiKey = apiKey;
614
590
  this.appId = appId;
@@ -624,36 +600,34 @@ var RESTTransport = /** @class */ (function () {
624
600
  this._appCheckToken = null;
625
601
  this._lastToken = null;
626
602
  // TODO(mtewani): Update U to include shape of body defined in line 13.
627
- this.invokeQuery = function (queryName, body) {
628
- var abortController = new AbortController();
603
+ this.invokeQuery = (queryName, body) => {
604
+ const abortController = new AbortController();
629
605
  // TODO(mtewani): Update to proper value
630
- var withAuth = _this.withRetry(function () {
631
- return dcFetch(addToken("".concat(_this.endpointUrl, ":executeQuery"), _this.apiKey), {
632
- name: "projects/".concat(_this._project, "/locations/").concat(_this._location, "/services/").concat(_this._serviceName, "/connectors/").concat(_this._connectorName),
633
- operationName: queryName,
634
- variables: body
635
- }, // TODO(mtewani): This is a patch, fix this.
636
- abortController, _this.appId, _this._accessToken, _this._appCheckToken, _this._isUsingGen);
637
- });
606
+ const withAuth = this.withRetry(() => dcFetch(addToken(`${this.endpointUrl}:executeQuery`, this.apiKey), {
607
+ name: `projects/${this._project}/locations/${this._location}/services/${this._serviceName}/connectors/${this._connectorName}`,
608
+ operationName: queryName,
609
+ variables: body
610
+ }, // TODO(mtewani): This is a patch, fix this.
611
+ abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen));
638
612
  return {
639
613
  then: withAuth.then.bind(withAuth),
640
614
  catch: withAuth.catch.bind(withAuth)
641
615
  };
642
616
  };
643
- this.invokeMutation = function (mutationName, body) {
644
- var abortController = new AbortController();
645
- var taskResult = _this.withRetry(function () {
646
- return dcFetch(addToken("".concat(_this.endpointUrl, ":executeMutation"), _this.apiKey), {
647
- name: "projects/".concat(_this._project, "/locations/").concat(_this._location, "/services/").concat(_this._serviceName, "/connectors/").concat(_this._connectorName),
617
+ this.invokeMutation = (mutationName, body) => {
618
+ const abortController = new AbortController();
619
+ const taskResult = this.withRetry(() => {
620
+ return dcFetch(addToken(`${this.endpointUrl}:executeMutation`, this.apiKey), {
621
+ name: `projects/${this._project}/locations/${this._location}/services/${this._serviceName}/connectors/${this._connectorName}`,
648
622
  operationName: mutationName,
649
623
  variables: body
650
- }, abortController, _this.appId, _this._accessToken, _this._appCheckToken, _this._isUsingGen);
624
+ }, abortController, this.appId, this._accessToken, this._appCheckToken, this._isUsingGen);
651
625
  });
652
626
  return {
653
627
  then: taskResult.then.bind(taskResult),
654
628
  // catch: taskResult.catch.bind(taskResult),
655
629
  // finally: taskResult.finally.bind(taskResult),
656
- cancel: function () { return abortController.abort(); }
630
+ cancel: () => abortController.abort()
657
631
  };
658
632
  };
659
633
  if (transportOptions) {
@@ -665,7 +639,7 @@ var RESTTransport = /** @class */ (function () {
665
639
  }
666
640
  this._host = transportOptions.host;
667
641
  }
668
- var location = options.location, project = options.projectId, connector = options.connector, service = options.service;
642
+ const { location, projectId: project, connector, service } = options;
669
643
  if (location) {
670
644
  this._location = location;
671
645
  }
@@ -677,29 +651,25 @@ var RESTTransport = /** @class */ (function () {
677
651
  throw new DataConnectError(Code.INVALID_ARGUMENT, 'Connector Name required!');
678
652
  }
679
653
  this._connectorName = connector;
680
- (_a = this.authProvider) === null || _a === void 0 ? void 0 : _a.addTokenChangeListener(function (token) {
681
- logDebug("New Token Available: ".concat(token));
682
- _this._accessToken = token;
654
+ (_a = this.authProvider) === null || _a === void 0 ? void 0 : _a.addTokenChangeListener(token => {
655
+ logDebug(`New Token Available: ${token}`);
656
+ this._accessToken = token;
683
657
  });
684
- (_b = this.appCheckProvider) === null || _b === void 0 ? void 0 : _b.addTokenChangeListener(function (result) {
685
- var token = result.token;
686
- logDebug("New App Check Token Available: ".concat(token));
687
- _this._appCheckToken = token;
658
+ (_b = this.appCheckProvider) === null || _b === void 0 ? void 0 : _b.addTokenChangeListener(result => {
659
+ const { token } = result;
660
+ logDebug(`New App Check Token Available: ${token}`);
661
+ this._appCheckToken = token;
688
662
  });
689
663
  }
690
- Object.defineProperty(RESTTransport.prototype, "endpointUrl", {
691
- get: function () {
692
- return urlBuilder({
693
- connector: this._connectorName,
694
- location: this._location,
695
- projectId: this._project,
696
- service: this._serviceName
697
- }, { host: this._host, sslEnabled: this._secure, port: this._port });
698
- },
699
- enumerable: false,
700
- configurable: true
701
- });
702
- RESTTransport.prototype.useEmulator = function (host, port, isSecure) {
664
+ get endpointUrl() {
665
+ return urlBuilder({
666
+ connector: this._connectorName,
667
+ location: this._location,
668
+ projectId: this._project,
669
+ service: this._serviceName
670
+ }, { host: this._host, sslEnabled: this._secure, port: this._port });
671
+ }
672
+ useEmulator(host, port, isSecure) {
703
673
  this._host = host;
704
674
  if (typeof port === 'number') {
705
675
  this._port = port;
@@ -707,76 +677,57 @@ var RESTTransport = /** @class */ (function () {
707
677
  if (typeof isSecure !== 'undefined') {
708
678
  this._secure = isSecure;
709
679
  }
710
- };
711
- RESTTransport.prototype.onTokenChanged = function (newToken) {
680
+ }
681
+ onTokenChanged(newToken) {
712
682
  this._accessToken = newToken;
713
- };
714
- RESTTransport.prototype.getWithAuth = function (forceToken) {
683
+ }
684
+ async getWithAuth(forceToken = false) {
715
685
  var _a;
716
- if (forceToken === void 0) { forceToken = false; }
717
- return tslib.__awaiter(this, void 0, void 0, function () {
718
- var starterPromise, _b;
719
- var _this = this;
720
- return tslib.__generator(this, function (_c) {
721
- switch (_c.label) {
722
- case 0:
723
- starterPromise = new Promise(function (resolve) {
724
- return resolve(_this._accessToken);
725
- });
726
- if (!this.appCheckProvider) return [3 /*break*/, 2];
727
- _b = this;
728
- return [4 /*yield*/, this.appCheckProvider.getToken()];
729
- case 1:
730
- _b._appCheckToken = (_a = (_c.sent())) === null || _a === void 0 ? void 0 : _a.token;
731
- _c.label = 2;
732
- case 2:
733
- if (this.authProvider) {
734
- starterPromise = this.authProvider
735
- .getToken(/*forceToken=*/ forceToken)
736
- .then(function (data) {
737
- if (!data) {
738
- return null;
739
- }
740
- _this._accessToken = data.accessToken;
741
- return _this._accessToken;
742
- });
743
- }
744
- else {
745
- starterPromise = new Promise(function (resolve) { return resolve(''); });
746
- }
747
- return [2 /*return*/, starterPromise];
686
+ let starterPromise = new Promise(resolve => resolve(this._accessToken));
687
+ if (this.appCheckProvider) {
688
+ this._appCheckToken = (_a = (await this.appCheckProvider.getToken())) === null || _a === void 0 ? void 0 : _a.token;
689
+ }
690
+ if (this.authProvider) {
691
+ starterPromise = this.authProvider
692
+ .getToken(/*forceToken=*/ forceToken)
693
+ .then(data => {
694
+ if (!data) {
695
+ return null;
748
696
  }
697
+ this._accessToken = data.accessToken;
698
+ return this._accessToken;
749
699
  });
750
- });
751
- };
752
- RESTTransport.prototype._setLastToken = function (lastToken) {
700
+ }
701
+ else {
702
+ starterPromise = new Promise(resolve => resolve(''));
703
+ }
704
+ return starterPromise;
705
+ }
706
+ _setLastToken(lastToken) {
753
707
  this._lastToken = lastToken;
754
- };
755
- RESTTransport.prototype.withRetry = function (promiseFactory, retry) {
756
- var _this = this;
757
- if (retry === void 0) { retry = false; }
758
- var isNewToken = false;
708
+ }
709
+ withRetry(promiseFactory, retry = false) {
710
+ let isNewToken = false;
759
711
  return this.getWithAuth(retry)
760
- .then(function (res) {
761
- isNewToken = _this._lastToken !== res;
762
- _this._lastToken = res;
712
+ .then(res => {
713
+ isNewToken = this._lastToken !== res;
714
+ this._lastToken = res;
763
715
  return res;
764
716
  })
765
717
  .then(promiseFactory)
766
- .catch(function (err) {
718
+ .catch(err => {
767
719
  // Only retry if the result is unauthorized and the last token isn't the same as the new one.
768
720
  if ('code' in err &&
769
721
  err.code === Code.UNAUTHORIZED &&
770
722
  !retry &&
771
723
  isNewToken) {
772
724
  logDebug('Retrying due to unauthorized');
773
- return _this.withRetry(promiseFactory, true);
725
+ return this.withRetry(promiseFactory, true);
774
726
  }
775
727
  throw err;
776
728
  });
777
- };
778
- return RESTTransport;
779
- }());
729
+ }
730
+ }
780
731
 
781
732
  /**
782
733
  * @license
@@ -803,7 +754,7 @@ var RESTTransport = /** @class */ (function () {
803
754
  */
804
755
  function mutationRef(dcInstance, mutationName, variables) {
805
756
  dcInstance.setInitialized();
806
- var ref = {
757
+ const ref = {
807
758
  dataConnect: dcInstance,
808
759
  name: mutationName,
809
760
  refType: MUTATION_STR,
@@ -814,27 +765,23 @@ function mutationRef(dcInstance, mutationName, variables) {
814
765
  /**
815
766
  * @internal
816
767
  */
817
- var MutationManager = /** @class */ (function () {
818
- function MutationManager(_transport) {
768
+ class MutationManager {
769
+ constructor(_transport) {
819
770
  this._transport = _transport;
820
771
  this._inflight = [];
821
772
  }
822
- MutationManager.prototype.executeMutation = function (mutationRef) {
823
- var _this = this;
824
- var result = this._transport.invokeMutation(mutationRef.name, mutationRef.variables);
825
- var withRefPromise = result.then(function (res) {
826
- var obj = tslib.__assign(tslib.__assign({}, res), { source: SOURCE_SERVER, ref: mutationRef, fetchTime: Date.now().toLocaleString() });
773
+ executeMutation(mutationRef) {
774
+ const result = this._transport.invokeMutation(mutationRef.name, mutationRef.variables);
775
+ const withRefPromise = result.then(res => {
776
+ const obj = Object.assign(Object.assign({}, res), { source: SOURCE_SERVER, ref: mutationRef, fetchTime: Date.now().toLocaleString() });
827
777
  return obj;
828
778
  });
829
779
  this._inflight.push(result);
830
- var removePromise = function () {
831
- return (_this._inflight = _this._inflight.filter(function (promise) { return promise !== result; }));
832
- };
780
+ const removePromise = () => (this._inflight = this._inflight.filter(promise => promise !== result));
833
781
  result.then(removePromise, removePromise);
834
782
  return withRefPromise;
835
- };
836
- return MutationManager;
837
- }());
783
+ }
784
+ }
838
785
  /**
839
786
  * Execute Mutation
840
787
  * @param mutationRef mutation to execute
@@ -860,7 +807,7 @@ function executeMutation(mutationRef) {
860
807
  * See the License for the specific language governing permissions and
861
808
  * limitations under the License.
862
809
  */
863
- var FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = 'FIREBASE_DATA_CONNECT_EMULATOR_HOST';
810
+ const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = 'FIREBASE_DATA_CONNECT_EMULATOR_HOST';
864
811
  /**
865
812
  *
866
813
  * @param fullHost
@@ -868,18 +815,18 @@ var FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR = 'FIREBASE_DATA_CONNECT_EMULATOR_HO
868
815
  * @internal
869
816
  */
870
817
  function parseOptions(fullHost) {
871
- var _a = fullHost.split('://'), protocol = _a[0], hostName = _a[1];
872
- var isSecure = protocol === 'https';
873
- var _b = hostName.split(':'), host = _b[0], portAsString = _b[1];
874
- var port = Number(portAsString);
875
- return { host: host, port: port, sslEnabled: isSecure };
818
+ const [protocol, hostName] = fullHost.split('://');
819
+ const isSecure = protocol === 'https';
820
+ const [host, portAsString] = hostName.split(':');
821
+ const port = Number(portAsString);
822
+ return { host, port, sslEnabled: isSecure };
876
823
  }
877
824
  /**
878
825
  * Class representing Firebase Data Connect
879
826
  */
880
- var DataConnect = /** @class */ (function () {
827
+ class DataConnect {
881
828
  // @internal
882
- function DataConnect(app,
829
+ constructor(app,
883
830
  // TODO(mtewani): Replace with _dataConnectOptions in the future
884
831
  dataConnectOptions, _authProvider, _appCheckProvider) {
885
832
  this.app = app;
@@ -890,7 +837,7 @@ var DataConnect = /** @class */ (function () {
890
837
  this._initialized = false;
891
838
  this._isUsingGeneratedSdk = false;
892
839
  if (typeof process !== 'undefined' && process.env) {
893
- var host = process.env[FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR];
840
+ const host = process.env[FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR];
894
841
  if (host) {
895
842
  logDebug('Found custom host. Using emulator');
896
843
  this.isEmulator = true;
@@ -899,23 +846,23 @@ var DataConnect = /** @class */ (function () {
899
846
  }
900
847
  }
901
848
  // @internal
902
- DataConnect.prototype._useGeneratedSdk = function () {
849
+ _useGeneratedSdk() {
903
850
  if (!this._isUsingGeneratedSdk) {
904
851
  this._isUsingGeneratedSdk = true;
905
852
  }
906
- };
907
- DataConnect.prototype._delete = function () {
853
+ }
854
+ _delete() {
908
855
  app._removeServiceInstance(this.app, 'data-connect', JSON.stringify(this.getSettings()));
909
856
  return Promise.resolve();
910
- };
857
+ }
911
858
  // @internal
912
- DataConnect.prototype.getSettings = function () {
913
- var copy = JSON.parse(JSON.stringify(this.dataConnectOptions));
859
+ getSettings() {
860
+ const copy = JSON.parse(JSON.stringify(this.dataConnectOptions));
914
861
  delete copy.projectId;
915
862
  return copy;
916
- };
863
+ }
917
864
  // @internal
918
- DataConnect.prototype.setInitialized = function () {
865
+ setInitialized() {
919
866
  if (this._initialized) {
920
867
  return;
921
868
  }
@@ -936,18 +883,17 @@ var DataConnect = /** @class */ (function () {
936
883
  }
937
884
  this._queryManager = new QueryManager(this._transport);
938
885
  this._mutationManager = new MutationManager(this._transport);
939
- };
886
+ }
940
887
  // @internal
941
- DataConnect.prototype.enableEmulator = function (transportOptions) {
888
+ enableEmulator(transportOptions) {
942
889
  if (this._initialized) {
943
890
  logError('enableEmulator called after initialization');
944
891
  throw new DataConnectError(Code.ALREADY_INITIALIZED, 'DataConnect instance already initialized!');
945
892
  }
946
893
  this._transportOptions = transportOptions;
947
894
  this.isEmulator = true;
948
- };
949
- return DataConnect;
950
- }());
895
+ }
896
+ }
951
897
  /**
952
898
  * Connect to the DataConnect Emulator
953
899
  * @param dc Data Connect instance
@@ -955,13 +901,12 @@ var DataConnect = /** @class */ (function () {
955
901
  * @param port port of emulator server
956
902
  * @param sslEnabled use https
957
903
  */
958
- function connectDataConnectEmulator(dc, host, port, sslEnabled) {
959
- if (sslEnabled === void 0) { sslEnabled = false; }
960
- dc.enableEmulator({ host: host, port: port, sslEnabled: sslEnabled });
904
+ function connectDataConnectEmulator(dc, host, port, sslEnabled = false) {
905
+ dc.enableEmulator({ host, port, sslEnabled });
961
906
  }
962
907
  function getDataConnect(appOrOptions, optionalOptions) {
963
- var app$1;
964
- var dcOptions;
908
+ let app$1;
909
+ let dcOptions;
965
910
  if ('location' in appOrOptions) {
966
911
  dcOptions = appOrOptions;
967
912
  app$1 = app.getApp();
@@ -973,12 +918,12 @@ function getDataConnect(appOrOptions, optionalOptions) {
973
918
  if (!app$1 || Object.keys(app$1).length === 0) {
974
919
  app$1 = app.getApp();
975
920
  }
976
- var provider = app._getProvider(app$1, 'data-connect');
977
- var identifier = JSON.stringify(dcOptions);
921
+ const provider = app._getProvider(app$1, 'data-connect');
922
+ const identifier = JSON.stringify(dcOptions);
978
923
  if (provider.isInitialized(identifier)) {
979
- var dcInstance = provider.getImmediate({ identifier: identifier });
980
- var options = provider.getOptions(identifier);
981
- var optionsValid = Object.keys(options).length > 0;
924
+ const dcInstance = provider.getImmediate({ identifier });
925
+ const options = provider.getOptions(identifier);
926
+ const optionsValid = Object.keys(options).length > 0;
982
927
  if (optionsValid) {
983
928
  logDebug('Re-using cached instance');
984
929
  return dcInstance;
@@ -999,13 +944,13 @@ function getDataConnect(appOrOptions, optionalOptions) {
999
944
  * @internal
1000
945
  */
1001
946
  function validateDCOptions(dcOptions) {
1002
- var fields = ['connector', 'location', 'service'];
947
+ const fields = ['connector', 'location', 'service'];
1003
948
  if (!dcOptions) {
1004
949
  throw new DataConnectError(Code.INVALID_ARGUMENT, 'DC Option Required');
1005
950
  }
1006
- fields.forEach(function (field) {
951
+ fields.forEach(field => {
1007
952
  if (dcOptions[field] === null || dcOptions[field] === undefined) {
1008
- throw new DataConnectError(Code.INVALID_ARGUMENT, "".concat(field, " Required"));
953
+ throw new DataConnectError(Code.INVALID_ARGUMENT, `${field} Required`);
1009
954
  }
1010
955
  });
1011
956
  return true;
@@ -1020,25 +965,40 @@ function terminate(dataConnect) {
1020
965
  // TODO(mtewani): Stop pending tasks
1021
966
  }
1022
967
 
968
+ /**
969
+ * @license
970
+ * Copyright 2024 Google LLC
971
+ *
972
+ * Licensed under the Apache License, Version 2.0 (the "License");
973
+ * you may not use this file except in compliance with the License.
974
+ * You may obtain a copy of the License at
975
+ *
976
+ * http://www.apache.org/licenses/LICENSE-2.0
977
+ *
978
+ * Unless required by applicable law or agreed to in writing, software
979
+ * distributed under the License is distributed on an "AS IS" BASIS,
980
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
981
+ * See the License for the specific language governing permissions and
982
+ * limitations under the License.
983
+ */
1023
984
  function registerDataConnect(variant) {
1024
985
  setSDKVersion(app.SDK_VERSION);
1025
- app._registerComponent(new component.Component('data-connect', function (container, _a) {
1026
- var settings = _a.instanceIdentifier, options = _a.options;
1027
- var app = container.getProvider('app').getImmediate();
1028
- var authProvider = container.getProvider('auth-internal');
1029
- var appCheckProvider = container.getProvider('app-check-internal');
1030
- var newOpts = options;
986
+ app._registerComponent(new component.Component('data-connect', (container, { instanceIdentifier: settings, options }) => {
987
+ const app = container.getProvider('app').getImmediate();
988
+ const authProvider = container.getProvider('auth-internal');
989
+ const appCheckProvider = container.getProvider('app-check-internal');
990
+ let newOpts = options;
1031
991
  if (settings) {
1032
992
  newOpts = JSON.parse(settings);
1033
993
  }
1034
994
  if (!app.options.projectId) {
1035
995
  throw new DataConnectError(Code.INVALID_ARGUMENT, 'Project ID must be provided. Did you pass in a proper projectId to initializeApp?');
1036
996
  }
1037
- return new DataConnect(app, tslib.__assign(tslib.__assign({}, newOpts), { projectId: app.options.projectId }), authProvider, appCheckProvider);
997
+ return new DataConnect(app, Object.assign(Object.assign({}, newOpts), { projectId: app.options.projectId }), authProvider, appCheckProvider);
1038
998
  }, "PUBLIC" /* ComponentType.PUBLIC */).setMultipleInstances(true));
1039
999
  app.registerVersion(name, version, variant);
1040
1000
  // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation
1041
- app.registerVersion(name, version, 'cjs5');
1001
+ app.registerVersion(name, version, 'cjs2017');
1042
1002
  }
1043
1003
 
1044
1004
  /**
@@ -1089,7 +1049,7 @@ function queryRef(dcInstance, queryName, variables, initialCache) {
1089
1049
  * @returns `QueryRef`
1090
1050
  */
1091
1051
  function toQueryRef(serializedRef) {
1092
- var _a = serializedRef.refInfo, name = _a.name, variables = _a.variables, connectorConfig = _a.connectorConfig;
1052
+ const { refInfo: { name, variables, connectorConfig } } = serializedRef;
1093
1053
  return queryRef(getDataConnect(connectorConfig), name, variables);
1094
1054
  }
1095
1055
 
@@ -1120,8 +1080,8 @@ function toQueryRef(serializedRef) {
1120
1080
  * @internal
1121
1081
  */
1122
1082
  function validateArgs(connectorConfig, dcOrVars, vars, validateVars) {
1123
- var dcInstance;
1124
- var realVars;
1083
+ let dcInstance;
1084
+ let realVars;
1125
1085
  if (dcOrVars && 'enableEmulator' in dcOrVars) {
1126
1086
  dcInstance = dcOrVars;
1127
1087
  realVars = vars;
@@ -1161,22 +1121,22 @@ function validateArgs(connectorConfig, dcOrVars, vars, validateVars) {
1161
1121
  * @returns `SubscriptionOptions`
1162
1122
  */
1163
1123
  function subscribe(queryRefOrSerializedResult, observerOrOnNext, onError, onComplete) {
1164
- var ref;
1165
- var initialCache;
1124
+ let ref;
1125
+ let initialCache;
1166
1126
  if ('refInfo' in queryRefOrSerializedResult) {
1167
- var serializedRef = queryRefOrSerializedResult;
1168
- var data = serializedRef.data, source = serializedRef.source, fetchTime = serializedRef.fetchTime;
1127
+ const serializedRef = queryRefOrSerializedResult;
1128
+ const { data, source, fetchTime } = serializedRef;
1169
1129
  initialCache = {
1170
- data: data,
1171
- source: source,
1172
- fetchTime: fetchTime
1130
+ data,
1131
+ source,
1132
+ fetchTime
1173
1133
  };
1174
1134
  ref = toQueryRef(serializedRef);
1175
1135
  }
1176
1136
  else {
1177
1137
  ref = queryRefOrSerializedResult;
1178
1138
  }
1179
- var onResult = undefined;
1139
+ let onResult = undefined;
1180
1140
  if (typeof observerOrOnNext === 'function') {
1181
1141
  onResult = observerOrOnNext;
1182
1142
  }