@aws-amplify/api-graphql 2.2.19-custom-pk.94 → 2.2.19-custom-pk.98

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.
@@ -11214,131 +11214,6 @@ function (_super) {
11214
11214
 
11215
11215
 
11216
11216
 
11217
- /***/ }),
11218
-
11219
- /***/ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/constants.js":
11220
- /*!***************************************************************************!*\
11221
- !*** ../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/constants.js ***!
11222
- \***************************************************************************/
11223
- /*! exports provided: MAX_DELAY_MS, NON_RETRYABLE_CODES, MESSAGE_TYPES, SUBSCRIPTION_STATUS, SOCKET_STATUS, AMPLIFY_SYMBOL, AWS_APPSYNC_REALTIME_HEADERS, CONNECTION_INIT_TIMEOUT, START_ACK_TIMEOUT, DEFAULT_KEEP_ALIVE_TIMEOUT */
11224
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
11225
-
11226
- "use strict";
11227
- __webpack_require__.r(__webpack_exports__);
11228
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MAX_DELAY_MS", function() { return MAX_DELAY_MS; });
11229
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NON_RETRYABLE_CODES", function() { return NON_RETRYABLE_CODES; });
11230
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MESSAGE_TYPES", function() { return MESSAGE_TYPES; });
11231
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SUBSCRIPTION_STATUS", function() { return SUBSCRIPTION_STATUS; });
11232
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SOCKET_STATUS", function() { return SOCKET_STATUS; });
11233
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AMPLIFY_SYMBOL", function() { return AMPLIFY_SYMBOL; });
11234
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AWS_APPSYNC_REALTIME_HEADERS", function() { return AWS_APPSYNC_REALTIME_HEADERS; });
11235
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_INIT_TIMEOUT", function() { return CONNECTION_INIT_TIMEOUT; });
11236
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "START_ACK_TIMEOUT", function() { return START_ACK_TIMEOUT; });
11237
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_KEEP_ALIVE_TIMEOUT", function() { return DEFAULT_KEEP_ALIVE_TIMEOUT; });
11238
- var MAX_DELAY_MS = 5000;
11239
- var NON_RETRYABLE_CODES = [400, 401, 403];
11240
- var MESSAGE_TYPES;
11241
-
11242
- (function (MESSAGE_TYPES) {
11243
- /**
11244
- * Client -> Server message.
11245
- * This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
11246
- */
11247
- MESSAGE_TYPES["GQL_CONNECTION_INIT"] = "connection_init";
11248
- /**
11249
- * Server -> Client message
11250
- * This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
11251
- */
11252
-
11253
- MESSAGE_TYPES["GQL_CONNECTION_ERROR"] = "connection_error";
11254
- /**
11255
- * Server -> Client message.
11256
- * This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
11257
- */
11258
-
11259
- MESSAGE_TYPES["GQL_CONNECTION_ACK"] = "connection_ack";
11260
- /**
11261
- * Client -> Server message.
11262
- * This message type is for register subscriptions with AWS AppSync RealTime
11263
- */
11264
-
11265
- MESSAGE_TYPES["GQL_START"] = "start";
11266
- /**
11267
- * Server -> Client message.
11268
- * This message type is for the ack response from AWS AppSync RealTime for GQL_START message
11269
- */
11270
-
11271
- MESSAGE_TYPES["GQL_START_ACK"] = "start_ack";
11272
- /**
11273
- * Server -> Client message.
11274
- * This message type is for subscription message from AWS AppSync RealTime
11275
- */
11276
-
11277
- MESSAGE_TYPES["GQL_DATA"] = "data";
11278
- /**
11279
- * Server -> Client message.
11280
- * This message type helps the client to know is still receiving messages from AWS AppSync RealTime
11281
- */
11282
-
11283
- MESSAGE_TYPES["GQL_CONNECTION_KEEP_ALIVE"] = "ka";
11284
- /**
11285
- * Client -> Server message.
11286
- * This message type is for unregister subscriptions with AWS AppSync RealTime
11287
- */
11288
-
11289
- MESSAGE_TYPES["GQL_STOP"] = "stop";
11290
- /**
11291
- * Server -> Client message.
11292
- * This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
11293
- */
11294
-
11295
- MESSAGE_TYPES["GQL_COMPLETE"] = "complete";
11296
- /**
11297
- * Server -> Client message.
11298
- * This message type is for sending error messages from AWS AppSync RealTime to the client
11299
- */
11300
-
11301
- MESSAGE_TYPES["GQL_ERROR"] = "error";
11302
- })(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
11303
-
11304
- var SUBSCRIPTION_STATUS;
11305
-
11306
- (function (SUBSCRIPTION_STATUS) {
11307
- SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
11308
- SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
11309
- SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
11310
- })(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));
11311
-
11312
- var SOCKET_STATUS;
11313
-
11314
- (function (SOCKET_STATUS) {
11315
- SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
11316
- SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
11317
- SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
11318
- })(SOCKET_STATUS || (SOCKET_STATUS = {}));
11319
-
11320
- var AMPLIFY_SYMBOL = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function' ? Symbol["for"]('amplify_default') : '@@amplify_default';
11321
- var AWS_APPSYNC_REALTIME_HEADERS = {
11322
- accept: 'application/json, text/javascript',
11323
- 'content-encoding': 'amz-1.0',
11324
- 'content-type': 'application/json; charset=UTF-8'
11325
- };
11326
- /**
11327
- * Time in milleseconds to wait for GQL_CONNECTION_INIT message
11328
- */
11329
-
11330
- var CONNECTION_INIT_TIMEOUT = 15000;
11331
- /**
11332
- * Time in milleseconds to wait for GQL_START_ACK message
11333
- */
11334
-
11335
- var START_ACK_TIMEOUT = 15000;
11336
- /**
11337
- * Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
11338
- */
11339
-
11340
- var DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
11341
-
11342
11217
  /***/ }),
11343
11218
 
11344
11219
  /***/ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/index.js":
@@ -11368,7 +11243,8 @@ __webpack_require__.r(__webpack_exports__);
11368
11243
  /* harmony import */ var _aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_auth__WEBPACK_IMPORTED_MODULE_7__);
11369
11244
  /* harmony import */ var _PubSubProvider__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PubSubProvider */ "../pubsub/lib-esm/Providers/PubSubProvider.js");
11370
11245
  /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../index */ "../pubsub/lib-esm/index.js");
11371
- /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./constants */ "../pubsub/lib-esm/Providers/AWSAppSyncRealTimeProvider/constants.js");
11246
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../constants */ "../pubsub/lib-esm/Providers/constants.js");
11247
+ /* harmony import */ var _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../utils/ConnectionStateMonitor */ "../pubsub/lib-esm/utils/ConnectionStateMonitor.js");
11372
11248
  var __extends = undefined && undefined.__extends || function () {
11373
11249
  var _extendStatics = function extendStatics(d, b) {
11374
11250
  _extendStatics = Object.setPrototypeOf || {
@@ -11605,6 +11481,7 @@ var __read = undefined && undefined.__read || function (o, n) {
11605
11481
 
11606
11482
 
11607
11483
 
11484
+
11608
11485
  var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_5__["Logger"]('AWSAppSyncRealTimeProvider');
11609
11486
 
11610
11487
  var dispatchApiEvent = function dispatchApiEvent(event, data, message) {
@@ -11623,13 +11500,26 @@ var AWSAppSyncRealTimeProvider =
11623
11500
  function (_super) {
11624
11501
  __extends(AWSAppSyncRealTimeProvider, _super);
11625
11502
 
11626
- function AWSAppSyncRealTimeProvider() {
11627
- var _this = _super !== null && _super.apply(this, arguments) || this;
11503
+ function AWSAppSyncRealTimeProvider(options) {
11504
+ if (options === void 0) {
11505
+ options = {};
11506
+ }
11507
+
11508
+ var _this = _super.call(this, options) || this;
11628
11509
 
11629
11510
  _this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
11630
11511
  _this.keepAliveTimeout = _constants__WEBPACK_IMPORTED_MODULE_10__["DEFAULT_KEEP_ALIVE_TIMEOUT"];
11631
11512
  _this.subscriptionObserverMap = new Map();
11632
11513
  _this.promiseArray = [];
11514
+ _this.connectionStateMonitor = new _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["ConnectionStateMonitor"](); // Monitor the connection state and pass changes along to Hub
11515
+
11516
+ _this.connectionStateMonitor.connectionStateObservable.subscribe(function (ConnectionState) {
11517
+ dispatchApiEvent(_index__WEBPACK_IMPORTED_MODULE_9__["CONNECTION_STATE_CHANGE"], {
11518
+ provider: _this,
11519
+ connectionState: ConnectionState
11520
+ }, "Connection state is " + ConnectionState);
11521
+ });
11522
+
11633
11523
  return _this;
11634
11524
  }
11635
11525
 
@@ -11679,6 +11569,9 @@ function (_super) {
11679
11569
  observer.error({
11680
11570
  errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].REALTIME_SUBSCRIPTION_INIT_ERROR + ": " + err))]
11681
11571
  });
11572
+
11573
+ _this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
11574
+
11682
11575
  observer.complete();
11683
11576
  });
11684
11577
 
@@ -11823,6 +11716,7 @@ function (_super) {
11823
11716
  case 3:
11824
11717
  _k.trys.push([3, 5,, 6]);
11825
11718
 
11719
+ this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].OPENING_CONNECTION);
11826
11720
  return [4
11827
11721
  /*yield*/
11828
11722
  , this._initializeWebSocketConnection({
@@ -11846,6 +11740,7 @@ function (_super) {
11846
11740
  err: err_2
11847
11741
  });
11848
11742
  message = (_b = err_2['message']) !== null && _b !== void 0 ? _b : '';
11743
+ this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
11849
11744
  observer.error({
11850
11745
  errors: [__assign({}, new graphql__WEBPACK_IMPORTED_MODULE_1__["GraphQLError"](_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].CONNECTION_FAILED + ": " + message))]
11851
11746
  });
@@ -11964,12 +11859,22 @@ function (_super) {
11964
11859
  return;
11965
11860
  }
11966
11861
 
11862
+ this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSING_CONNECTION);
11863
+
11967
11864
  if (this.awsRealTimeSocket.bufferedAmount > 0) {
11968
11865
  // Still data on the WebSocket
11969
11866
  setTimeout(this._closeSocketIfRequired.bind(this), 1000);
11970
11867
  } else {
11971
11868
  logger.debug('closing WebSocket...');
11972
- if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
11869
+
11870
+ if (this.keepAliveTimeoutId) {
11871
+ clearTimeout(this.keepAliveTimeoutId);
11872
+ }
11873
+
11874
+ if (this.keepAliveAlertTimeoutId) {
11875
+ clearTimeout(this.keepAliveAlertTimeoutId);
11876
+ }
11877
+
11973
11878
  var tempSocket = this.awsRealTimeSocket; // Cleaning callbacks to avoid race condition, socket still exists
11974
11879
 
11975
11880
  tempSocket.onclose = null;
@@ -11977,10 +11882,13 @@ function (_super) {
11977
11882
  tempSocket.close(1000);
11978
11883
  this.awsRealTimeSocket = undefined;
11979
11884
  this.socketStatus = _constants__WEBPACK_IMPORTED_MODULE_10__["SOCKET_STATUS"].CLOSED;
11885
+ this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
11980
11886
  }
11981
11887
  };
11982
11888
 
11983
11889
  AWSAppSyncRealTimeProvider.prototype._handleIncomingSubscriptionMessage = function (message) {
11890
+ var _this = this;
11891
+
11984
11892
  logger.debug("subscription message from AWS AppSync RealTime: " + message.data);
11985
11893
 
11986
11894
  var _a = JSON.parse(message.data),
@@ -12044,15 +11952,22 @@ function (_super) {
12044
11952
  subscriptionReadyCallback: subscriptionReadyCallback,
12045
11953
  subscriptionFailedCallback: subscriptionFailedCallback
12046
11954
  });
12047
- } // TODO: emit event on hub but it requires to store the id first
12048
-
11955
+ }
12049
11956
 
11957
+ this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CONNECTION_ESTABLISHED);
12050
11958
  return;
12051
11959
  }
12052
11960
 
12053
11961
  if (type === _constants__WEBPACK_IMPORTED_MODULE_10__["MESSAGE_TYPES"].GQL_CONNECTION_KEEP_ALIVE) {
12054
11962
  if (this.keepAliveTimeoutId) clearTimeout(this.keepAliveTimeoutId);
12055
- this.keepAliveTimeoutId = setTimeout(this._errorDisconnect.bind(this, _index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].TIMEOUT_DISCONNECT), this.keepAliveTimeout);
11963
+ if (this.keepAliveAlertTimeoutId) clearTimeout(this.keepAliveAlertTimeoutId);
11964
+ this.keepAliveTimeoutId = setTimeout(function () {
11965
+ return _this._errorDisconnect(_index__WEBPACK_IMPORTED_MODULE_9__["CONTROL_MSG"].TIMEOUT_DISCONNECT);
11966
+ }, this.keepAliveTimeout);
11967
+ this.keepAliveAlertTimeoutId = setTimeout(function () {
11968
+ _this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].KEEP_ALIVE_MISSED);
11969
+ }, _constants__WEBPACK_IMPORTED_MODULE_10__["DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT"]);
11970
+ this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].KEEP_ALIVE);
12056
11971
  return;
12057
11972
  }
12058
11973
 
@@ -12096,6 +12011,7 @@ function (_super) {
12096
12011
  this.subscriptionObserverMap.clear();
12097
12012
 
12098
12013
  if (this.awsRealTimeSocket) {
12014
+ this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CLOSED);
12099
12015
  this.awsRealTimeSocket.close();
12100
12016
  }
12101
12017
 
@@ -12294,6 +12210,8 @@ function (_super) {
12294
12210
  };
12295
12211
 
12296
12212
  newSocket.onclose = function () {
12213
+ _this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CONNECTION_FAILED);
12214
+
12297
12215
  rej(new Error('Connection handshake error'));
12298
12216
  };
12299
12217
 
@@ -12380,13 +12298,17 @@ function (_super) {
12380
12298
 
12381
12299
  _this.awsRealTimeSocket.send(JSON.stringify(gqlInit));
12382
12300
 
12383
- setTimeout(checkAckOk.bind(_this, ackOk_1), _constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_INIT_TIMEOUT"]);
12384
- }
12301
+ var checkAckOk_1 = function checkAckOk_1(ackOk) {
12302
+ if (!ackOk) {
12303
+ _this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_11__["CONNECTION_CHANGE"].CONNECTION_FAILED);
12385
12304
 
12386
- function checkAckOk(ackOk) {
12387
- if (!ackOk) {
12388
- rej(new Error("Connection timeout: ack from AWSRealTime was not received on " + _constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_INIT_TIMEOUT"] + " ms"));
12389
- }
12305
+ rej(new Error("Connection timeout: ack from AWSAppSyncRealTime was not received after " + _constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_INIT_TIMEOUT"] + " ms"));
12306
+ }
12307
+ };
12308
+
12309
+ setTimeout(function () {
12310
+ return checkAckOk_1(ackOk_1);
12311
+ }, _constants__WEBPACK_IMPORTED_MODULE_10__["CONNECTION_INIT_TIMEOUT"]);
12390
12312
  }
12391
12313
  });
12392
12314
  }()];
@@ -12953,6 +12875,9 @@ __webpack_require__.r(__webpack_exports__);
12953
12875
  /* harmony import */ var _PubSubProvider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./PubSubProvider */ "../pubsub/lib-esm/Providers/PubSubProvider.js");
12954
12876
  /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
12955
12877
  /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_4__);
12878
+ /* harmony import */ var _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/ConnectionStateMonitor */ "../pubsub/lib-esm/utils/ConnectionStateMonitor.js");
12879
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./constants */ "../pubsub/lib-esm/Providers/constants.js");
12880
+ /* harmony import */ var ___WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! .. */ "../pubsub/lib-esm/index.js");
12956
12881
  function _typeof(obj) {
12957
12882
  "@babel/helpers - typeof";
12958
12883
 
@@ -13179,6 +13104,9 @@ var __rest = undefined && undefined.__rest || function (s, e) {
13179
13104
 
13180
13105
 
13181
13106
 
13107
+
13108
+
13109
+
13182
13110
  var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_4__["ConsoleLogger"]('MqttOverWSProvider');
13183
13111
  function mqttTopicMatch(filter, topic) {
13184
13112
  var filterArray = filter.split('/');
@@ -13244,6 +13172,14 @@ function () {
13244
13172
  return ClientsQueue;
13245
13173
  }();
13246
13174
 
13175
+ var dispatchPubSubEvent = function dispatchPubSubEvent(event, data, message) {
13176
+ _aws_amplify_core__WEBPACK_IMPORTED_MODULE_4__["Hub"].dispatch('pubsub', {
13177
+ event: event,
13178
+ data: data,
13179
+ message: message
13180
+ }, 'PubSub', _constants__WEBPACK_IMPORTED_MODULE_6__["AMPLIFY_SYMBOL"]);
13181
+ };
13182
+
13247
13183
  var topicSymbol = typeof Symbol !== 'undefined' ? Symbol('topic') : '@@topic';
13248
13184
 
13249
13185
  var MqttOverWSProvider =
@@ -13261,8 +13197,17 @@ function (_super) {
13261
13197
  })) || this;
13262
13198
 
13263
13199
  _this._clientsQueue = new ClientsQueue();
13200
+ _this.connectionStateMonitor = new _utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["ConnectionStateMonitor"]();
13264
13201
  _this._topicObservers = new Map();
13265
- _this._clientIdObservers = new Map();
13202
+ _this._clientIdObservers = new Map(); // Monitor the connection health state and pass changes along to Hub
13203
+
13204
+ _this.connectionStateMonitor.connectionStateObservable.subscribe(function (connectionStateChange) {
13205
+ dispatchPubSubEvent(___WEBPACK_IMPORTED_MODULE_7__["CONNECTION_STATE_CHANGE"], {
13206
+ provider: _this,
13207
+ connectionState: connectionStateChange
13208
+ }, "Connection state is " + connectionStateChange);
13209
+ });
13210
+
13266
13211
  return _this;
13267
13212
  }
13268
13213
 
@@ -13359,6 +13304,7 @@ function (_super) {
13359
13304
  switch (_b.label) {
13360
13305
  case 0:
13361
13306
  logger.debug('Creating new MQTT client', clientId);
13307
+ this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].OPENING_CONNECTION);
13362
13308
  client = new paho_mqtt__WEBPACK_IMPORTED_MODULE_0__["Client"](url, clientId); // client.trace = (args) => logger.debug(clientId, JSON.stringify(args, null, 2));
13363
13309
 
13364
13310
  client.onMessageArrived = function (_a) {
@@ -13376,6 +13322,8 @@ function (_super) {
13376
13322
  clientId: clientId,
13377
13323
  errorCode: errorCode
13378
13324
  }, args));
13325
+
13326
+ _this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].CLOSED);
13379
13327
  };
13380
13328
 
13381
13329
  return [4
@@ -13387,13 +13335,18 @@ function (_super) {
13387
13335
  onSuccess: function onSuccess() {
13388
13336
  return resolve(client);
13389
13337
  },
13390
- onFailure: reject
13338
+ onFailure: function onFailure() {
13339
+ reject();
13340
+
13341
+ _this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].CONNECTION_FAILED);
13342
+ }
13391
13343
  });
13392
13344
  })];
13393
13345
 
13394
13346
  case 1:
13395
13347
  _b.sent();
13396
13348
 
13349
+ this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].CONNECTION_ESTABLISHED);
13397
13350
  return [2
13398
13351
  /*return*/
13399
13352
  , client];
@@ -13445,6 +13398,7 @@ function (_super) {
13445
13398
 
13446
13399
  if (client && client.isConnected()) {
13447
13400
  client.disconnect();
13401
+ this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].CLOSED);
13448
13402
  }
13449
13403
 
13450
13404
  this.clientsQueue.remove(clientId);
@@ -13625,6 +13579,8 @@ function (_super) {
13625
13579
  (_a = _this._clientIdObservers.get(clientId)) === null || _a === void 0 ? void 0 : _a["delete"](observer); // No more observers per client => client not needed anymore
13626
13580
 
13627
13581
  if (((_b = _this._clientIdObservers.get(clientId)) === null || _b === void 0 ? void 0 : _b.size) === 0) {
13582
+ _this.connectionStateMonitor.record(_utils_ConnectionStateMonitor__WEBPACK_IMPORTED_MODULE_5__["CONNECTION_CHANGE"].CLOSING_CONNECTION);
13583
+
13628
13584
  _this.disconnect(clientId);
13629
13585
 
13630
13586
  _this._clientIdObservers["delete"](clientId);
@@ -13724,6 +13680,137 @@ function () {
13724
13680
 
13725
13681
 
13726
13682
 
13683
+ /***/ }),
13684
+
13685
+ /***/ "../pubsub/lib-esm/Providers/constants.js":
13686
+ /*!************************************************!*\
13687
+ !*** ../pubsub/lib-esm/Providers/constants.js ***!
13688
+ \************************************************/
13689
+ /*! exports provided: MAX_DELAY_MS, NON_RETRYABLE_CODES, MESSAGE_TYPES, SUBSCRIPTION_STATUS, SOCKET_STATUS, AMPLIFY_SYMBOL, AWS_APPSYNC_REALTIME_HEADERS, CONNECTION_INIT_TIMEOUT, START_ACK_TIMEOUT, DEFAULT_KEEP_ALIVE_TIMEOUT, DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT */
13690
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
13691
+
13692
+ "use strict";
13693
+ __webpack_require__.r(__webpack_exports__);
13694
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MAX_DELAY_MS", function() { return MAX_DELAY_MS; });
13695
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NON_RETRYABLE_CODES", function() { return NON_RETRYABLE_CODES; });
13696
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MESSAGE_TYPES", function() { return MESSAGE_TYPES; });
13697
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SUBSCRIPTION_STATUS", function() { return SUBSCRIPTION_STATUS; });
13698
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SOCKET_STATUS", function() { return SOCKET_STATUS; });
13699
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AMPLIFY_SYMBOL", function() { return AMPLIFY_SYMBOL; });
13700
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AWS_APPSYNC_REALTIME_HEADERS", function() { return AWS_APPSYNC_REALTIME_HEADERS; });
13701
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_INIT_TIMEOUT", function() { return CONNECTION_INIT_TIMEOUT; });
13702
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "START_ACK_TIMEOUT", function() { return START_ACK_TIMEOUT; });
13703
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_KEEP_ALIVE_TIMEOUT", function() { return DEFAULT_KEEP_ALIVE_TIMEOUT; });
13704
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT", function() { return DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT; });
13705
+ var MAX_DELAY_MS = 5000;
13706
+ var NON_RETRYABLE_CODES = [400, 401, 403];
13707
+ var MESSAGE_TYPES;
13708
+
13709
+ (function (MESSAGE_TYPES) {
13710
+ /**
13711
+ * Client -> Server message.
13712
+ * This message type is the first message after handshake and this will initialize AWS AppSync RealTime communication
13713
+ */
13714
+ MESSAGE_TYPES["GQL_CONNECTION_INIT"] = "connection_init";
13715
+ /**
13716
+ * Server -> Client message
13717
+ * This message type is in case there is an issue with AWS AppSync RealTime when establishing connection
13718
+ */
13719
+
13720
+ MESSAGE_TYPES["GQL_CONNECTION_ERROR"] = "connection_error";
13721
+ /**
13722
+ * Server -> Client message.
13723
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_CONNECTION_INIT message
13724
+ */
13725
+
13726
+ MESSAGE_TYPES["GQL_CONNECTION_ACK"] = "connection_ack";
13727
+ /**
13728
+ * Client -> Server message.
13729
+ * This message type is for register subscriptions with AWS AppSync RealTime
13730
+ */
13731
+
13732
+ MESSAGE_TYPES["GQL_START"] = "start";
13733
+ /**
13734
+ * Server -> Client message.
13735
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_START message
13736
+ */
13737
+
13738
+ MESSAGE_TYPES["GQL_START_ACK"] = "start_ack";
13739
+ /**
13740
+ * Server -> Client message.
13741
+ * This message type is for subscription message from AWS AppSync RealTime
13742
+ */
13743
+
13744
+ MESSAGE_TYPES["GQL_DATA"] = "data";
13745
+ /**
13746
+ * Server -> Client message.
13747
+ * This message type helps the client to know is still receiving messages from AWS AppSync RealTime
13748
+ */
13749
+
13750
+ MESSAGE_TYPES["GQL_CONNECTION_KEEP_ALIVE"] = "ka";
13751
+ /**
13752
+ * Client -> Server message.
13753
+ * This message type is for unregister subscriptions with AWS AppSync RealTime
13754
+ */
13755
+
13756
+ MESSAGE_TYPES["GQL_STOP"] = "stop";
13757
+ /**
13758
+ * Server -> Client message.
13759
+ * This message type is for the ack response from AWS AppSync RealTime for GQL_STOP message
13760
+ */
13761
+
13762
+ MESSAGE_TYPES["GQL_COMPLETE"] = "complete";
13763
+ /**
13764
+ * Server -> Client message.
13765
+ * This message type is for sending error messages from AWS AppSync RealTime to the client
13766
+ */
13767
+
13768
+ MESSAGE_TYPES["GQL_ERROR"] = "error";
13769
+ })(MESSAGE_TYPES || (MESSAGE_TYPES = {}));
13770
+
13771
+ var SUBSCRIPTION_STATUS;
13772
+
13773
+ (function (SUBSCRIPTION_STATUS) {
13774
+ SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["PENDING"] = 0] = "PENDING";
13775
+ SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["CONNECTED"] = 1] = "CONNECTED";
13776
+ SUBSCRIPTION_STATUS[SUBSCRIPTION_STATUS["FAILED"] = 2] = "FAILED";
13777
+ })(SUBSCRIPTION_STATUS || (SUBSCRIPTION_STATUS = {}));
13778
+
13779
+ var SOCKET_STATUS;
13780
+
13781
+ (function (SOCKET_STATUS) {
13782
+ SOCKET_STATUS[SOCKET_STATUS["CLOSED"] = 0] = "CLOSED";
13783
+ SOCKET_STATUS[SOCKET_STATUS["READY"] = 1] = "READY";
13784
+ SOCKET_STATUS[SOCKET_STATUS["CONNECTING"] = 2] = "CONNECTING";
13785
+ })(SOCKET_STATUS || (SOCKET_STATUS = {}));
13786
+
13787
+ var AMPLIFY_SYMBOL = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function' ? Symbol["for"]('amplify_default') : '@@amplify_default';
13788
+ var AWS_APPSYNC_REALTIME_HEADERS = {
13789
+ accept: 'application/json, text/javascript',
13790
+ 'content-encoding': 'amz-1.0',
13791
+ 'content-type': 'application/json; charset=UTF-8'
13792
+ };
13793
+ /**
13794
+ * Time in milleseconds to wait for GQL_CONNECTION_INIT message
13795
+ */
13796
+
13797
+ var CONNECTION_INIT_TIMEOUT = 15000;
13798
+ /**
13799
+ * Time in milleseconds to wait for GQL_START_ACK message
13800
+ */
13801
+
13802
+ var START_ACK_TIMEOUT = 15000;
13803
+ /**
13804
+ * Default Time in milleseconds to wait for GQL_CONNECTION_KEEP_ALIVE message
13805
+ */
13806
+
13807
+ var DEFAULT_KEEP_ALIVE_TIMEOUT = 5 * 60 * 1000;
13808
+ /**
13809
+ * Default Time in milleseconds to alert for missed GQL_CONNECTION_KEEP_ALIVE message
13810
+ */
13811
+
13812
+ var DEFAULT_KEEP_ALIVE_ALERT_TIMEOUT = 65 * 1000;
13813
+
13727
13814
  /***/ }),
13728
13815
 
13729
13816
  /***/ "../pubsub/lib-esm/Providers/index.js":
@@ -14157,11 +14244,12 @@ _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Amplify"].register(PubSub);
14157
14244
  /*!**********************************!*\
14158
14245
  !*** ../pubsub/lib-esm/index.js ***!
14159
14246
  \**********************************/
14160
- /*! exports provided: AbstractPubSubProvider, AWSAppSyncProvider, AWSAppSyncRealTimeProvider, AWSIoTProvider, mqttTopicMatch, MqttOverWSProvider, PubSub, CONTROL_MSG, default */
14247
+ /*! exports provided: AbstractPubSubProvider, AWSAppSyncProvider, AWSAppSyncRealTimeProvider, AWSIoTProvider, mqttTopicMatch, MqttOverWSProvider, CONNECTION_STATE_CHANGE, ConnectionState, PubSub, CONTROL_MSG, default */
14161
14248
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
14162
14249
 
14163
14250
  "use strict";
14164
14251
  __webpack_require__.r(__webpack_exports__);
14252
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_STATE_CHANGE", function() { return CONNECTION_STATE_CHANGE; });
14165
14253
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONTROL_MSG", function() { return CONTROL_MSG; });
14166
14254
  /* harmony import */ var _PubSub__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PubSub */ "../pubsub/lib-esm/PubSub.js");
14167
14255
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PubSub", function() { return _PubSub__WEBPACK_IMPORTED_MODULE_0__["PubSub"]; });
@@ -14179,6 +14267,9 @@ __webpack_require__.r(__webpack_exports__);
14179
14267
 
14180
14268
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MqttOverWSProvider", function() { return _Providers__WEBPACK_IMPORTED_MODULE_1__["MqttOverWSProvider"]; });
14181
14269
 
14270
+ /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types */ "../pubsub/lib-esm/types/index.js");
14271
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConnectionState", function() { return _types__WEBPACK_IMPORTED_MODULE_2__["ConnectionState"]; });
14272
+
14182
14273
  /*
14183
14274
  * Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
14184
14275
  *
@@ -14203,6 +14294,8 @@ var CONTROL_MSG;
14203
14294
  CONTROL_MSG["TIMEOUT_DISCONNECT"] = "Timeout disconnect";
14204
14295
  })(CONTROL_MSG || (CONTROL_MSG = {}));
14205
14296
 
14297
+ var CONNECTION_STATE_CHANGE = 'ConnectionStateChange';
14298
+
14206
14299
 
14207
14300
  /**
14208
14301
  * @deprecated use named import
@@ -14212,6 +14305,278 @@ var CONTROL_MSG;
14212
14305
 
14213
14306
  /***/ }),
14214
14307
 
14308
+ /***/ "../pubsub/lib-esm/types/index.js":
14309
+ /*!****************************************!*\
14310
+ !*** ../pubsub/lib-esm/types/index.js ***!
14311
+ \****************************************/
14312
+ /*! exports provided: ConnectionState */
14313
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
14314
+
14315
+ "use strict";
14316
+ __webpack_require__.r(__webpack_exports__);
14317
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConnectionState", function() { return ConnectionState; });
14318
+ /** @enum {string} */
14319
+ var ConnectionState;
14320
+
14321
+ (function (ConnectionState) {
14322
+ /*
14323
+ * The connection is alive and healthy
14324
+ */
14325
+ ConnectionState["Connected"] = "Connected";
14326
+ /*
14327
+ * The connection is alive, but the connection is offline
14328
+ */
14329
+
14330
+ ConnectionState["ConnectedPendingNetwork"] = "ConnectedPendingNetwork";
14331
+ /*
14332
+ * The connection has been disconnected while in use
14333
+ */
14334
+
14335
+ ConnectionState["ConnectionDisrupted"] = "ConnectionDisrupted";
14336
+ /*
14337
+ * The connection has been disconnected and the network is offline
14338
+ */
14339
+
14340
+ ConnectionState["ConnectionDisruptedPendingNetwork"] = "ConnectionDisruptedPendingNetwork";
14341
+ /*
14342
+ * The connection is in the process of connecting
14343
+ */
14344
+
14345
+ ConnectionState["Connecting"] = "Connecting";
14346
+ /*
14347
+ * The connection is not in use and is being disconnected
14348
+ */
14349
+
14350
+ ConnectionState["ConnectedPendingDisconnect"] = "ConnectedPendingDisconnect";
14351
+ /*
14352
+ * The connection is not in use and has been disconnected
14353
+ */
14354
+
14355
+ ConnectionState["Disconnected"] = "Disconnected";
14356
+ /*
14357
+ * The connection is alive, but a keep alive message has been missed
14358
+ */
14359
+
14360
+ ConnectionState["ConnectedPendingKeepAlive"] = "ConnectedPendingKeepAlive";
14361
+ })(ConnectionState || (ConnectionState = {}));
14362
+
14363
+ /***/ }),
14364
+
14365
+ /***/ "../pubsub/lib-esm/utils/ConnectionStateMonitor.js":
14366
+ /*!*********************************************************!*\
14367
+ !*** ../pubsub/lib-esm/utils/ConnectionStateMonitor.js ***!
14368
+ \*********************************************************/
14369
+ /*! exports provided: CONNECTION_CHANGE, ConnectionStateMonitor */
14370
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
14371
+
14372
+ "use strict";
14373
+ __webpack_require__.r(__webpack_exports__);
14374
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONNECTION_CHANGE", function() { return CONNECTION_CHANGE; });
14375
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConnectionStateMonitor", function() { return ConnectionStateMonitor; });
14376
+ /* harmony import */ var zen_observable_ts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! zen-observable-ts */ "../../node_modules/zen-observable-ts/lib/bundle.esm.js");
14377
+ /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../index */ "../pubsub/lib-esm/index.js");
14378
+ /* harmony import */ var _ReachabilityMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ReachabilityMonitor */ "../pubsub/lib-esm/utils/ReachabilityMonitor/index.js");
14379
+ /*
14380
+ * Copyright 2017-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
14381
+ *
14382
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
14383
+ * the License. A copy of the License is located at
14384
+ *
14385
+ * http://aws.amazon.com/apache2.0/
14386
+ *
14387
+ * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14388
+ * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
14389
+ * and limitations under the License.
14390
+ */
14391
+ var __assign = undefined && undefined.__assign || function () {
14392
+ __assign = Object.assign || function (t) {
14393
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
14394
+ s = arguments[i];
14395
+
14396
+ for (var p in s) {
14397
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
14398
+ }
14399
+ }
14400
+
14401
+ return t;
14402
+ };
14403
+
14404
+ return __assign.apply(this, arguments);
14405
+ };
14406
+
14407
+
14408
+
14409
+
14410
+ var CONNECTION_CHANGE = {
14411
+ KEEP_ALIVE_MISSED: {
14412
+ keepAliveState: 'unhealthy'
14413
+ },
14414
+ KEEP_ALIVE: {
14415
+ keepAliveState: 'healthy'
14416
+ },
14417
+ CONNECTION_ESTABLISHED: {
14418
+ connectionState: 'connected'
14419
+ },
14420
+ CONNECTION_FAILED: {
14421
+ intendedConnectionState: 'disconnected',
14422
+ connectionState: 'disconnected'
14423
+ },
14424
+ CLOSING_CONNECTION: {
14425
+ intendedConnectionState: 'disconnected'
14426
+ },
14427
+ OPENING_CONNECTION: {
14428
+ intendedConnectionState: 'connected',
14429
+ connectionState: 'connecting'
14430
+ },
14431
+ CLOSED: {
14432
+ connectionState: 'disconnected'
14433
+ },
14434
+ ONLINE: {
14435
+ networkState: 'connected'
14436
+ },
14437
+ OFFLINE: {
14438
+ networkState: 'disconnected'
14439
+ }
14440
+ };
14441
+
14442
+ var ConnectionStateMonitor =
14443
+ /** @class */
14444
+ function () {
14445
+ function ConnectionStateMonitor() {
14446
+ var _this = this;
14447
+
14448
+ this._networkMonitoringSubscription = undefined;
14449
+ this._linkedConnectionState = {
14450
+ networkState: 'connected',
14451
+ connectionState: 'disconnected',
14452
+ intendedConnectionState: 'disconnected',
14453
+ keepAliveState: 'healthy'
14454
+ };
14455
+ this._linkedConnectionStateObservable = new zen_observable_ts__WEBPACK_IMPORTED_MODULE_0__["default"](function (connectionStateObserver) {
14456
+ connectionStateObserver.next(_this._linkedConnectionState);
14457
+ _this._linkedConnectionStateObserver = connectionStateObserver;
14458
+ });
14459
+ }
14460
+ /**
14461
+ * Turn network state monitoring on if it isn't on already
14462
+ */
14463
+
14464
+
14465
+ ConnectionStateMonitor.prototype.enableNetworkMonitoring = function () {
14466
+ var _this = this; // Maintain the network state based on the reachability monitor
14467
+
14468
+
14469
+ if (this._networkMonitoringSubscription === undefined) {
14470
+ this._networkMonitoringSubscription = Object(_ReachabilityMonitor__WEBPACK_IMPORTED_MODULE_2__["ReachabilityMonitor"])().subscribe(function (_a) {
14471
+ var online = _a.online;
14472
+
14473
+ _this.record(online ? CONNECTION_CHANGE.ONLINE : CONNECTION_CHANGE.OFFLINE);
14474
+ });
14475
+ }
14476
+ };
14477
+ /**
14478
+ * Turn network state monitoring off if it isn't off already
14479
+ */
14480
+
14481
+
14482
+ ConnectionStateMonitor.prototype.disableNetworkMonitoring = function () {
14483
+ var _a;
14484
+
14485
+ (_a = this._networkMonitoringSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
14486
+ this._networkMonitoringSubscription = undefined;
14487
+ };
14488
+
14489
+ Object.defineProperty(ConnectionStateMonitor.prototype, "connectionStateObservable", {
14490
+ /**
14491
+ * Get the observable that allows us to monitor the connection state
14492
+ *
14493
+ * @returns {Observable<ConnectionState>} - The observable that emits ConnectionState updates
14494
+ */
14495
+ get: function get() {
14496
+ var _this = this;
14497
+
14498
+ var previous; // The linked state aggregates state changes to any of the network, connection,
14499
+ // intendedConnection and keepAliveHealth. Some states will change these independent
14500
+ // states without changing the overall connection state.
14501
+ // After translating from linked states to ConnectionState, then remove any duplicates
14502
+
14503
+ return this._linkedConnectionStateObservable.map(function (value) {
14504
+ return _this.connectionStatesTranslator(value);
14505
+ }).filter(function (current) {
14506
+ var toInclude = current !== previous;
14507
+ previous = current;
14508
+ return toInclude;
14509
+ });
14510
+ },
14511
+ enumerable: true,
14512
+ configurable: true
14513
+ });
14514
+ /*
14515
+ * Updates local connection state and emits the full state to the observer.
14516
+ */
14517
+
14518
+ ConnectionStateMonitor.prototype.record = function (statusUpdates) {
14519
+ // Maintain the network monitor
14520
+ if (statusUpdates.intendedConnectionState === 'connected') {
14521
+ this.enableNetworkMonitoring();
14522
+ } else if (statusUpdates.intendedConnectionState === 'disconnected') {
14523
+ this.disableNetworkMonitoring();
14524
+ } // Maintain the socket state
14525
+
14526
+
14527
+ var newSocketStatus = __assign(__assign({}, this._linkedConnectionState), statusUpdates);
14528
+
14529
+ this._linkedConnectionState = __assign({}, newSocketStatus);
14530
+
14531
+ this._linkedConnectionStateObserver.next(this._linkedConnectionState);
14532
+ };
14533
+ /*
14534
+ * Translate the ConnectionState structure into a specific ConnectionState string literal union
14535
+ */
14536
+
14537
+
14538
+ ConnectionStateMonitor.prototype.connectionStatesTranslator = function (_a) {
14539
+ var connectionState = _a.connectionState,
14540
+ networkState = _a.networkState,
14541
+ intendedConnectionState = _a.intendedConnectionState,
14542
+ keepAliveState = _a.keepAliveState;
14543
+ if (connectionState === 'connected' && networkState === 'disconnected') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectedPendingNetwork;
14544
+ if (connectionState === 'connected' && intendedConnectionState === 'disconnected') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectedPendingDisconnect;
14545
+ if (connectionState === 'disconnected' && intendedConnectionState === 'connected' && networkState === 'disconnected') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectionDisruptedPendingNetwork;
14546
+ if (connectionState === 'disconnected' && intendedConnectionState === 'connected') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectionDisrupted;
14547
+ if (connectionState === 'connected' && keepAliveState === 'unhealthy') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].ConnectedPendingKeepAlive; // All remaining states directly correspond to the connection state
14548
+
14549
+ if (connectionState === 'connecting') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].Connecting;
14550
+ if (connectionState === 'disconnected') return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].Disconnected;
14551
+ return _index__WEBPACK_IMPORTED_MODULE_1__["ConnectionState"].Connected;
14552
+ };
14553
+
14554
+ return ConnectionStateMonitor;
14555
+ }();
14556
+
14557
+
14558
+
14559
+ /***/ }),
14560
+
14561
+ /***/ "../pubsub/lib-esm/utils/ReachabilityMonitor/index.js":
14562
+ /*!************************************************************!*\
14563
+ !*** ../pubsub/lib-esm/utils/ReachabilityMonitor/index.js ***!
14564
+ \************************************************************/
14565
+ /*! exports provided: ReachabilityMonitor */
14566
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
14567
+
14568
+ "use strict";
14569
+ __webpack_require__.r(__webpack_exports__);
14570
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReachabilityMonitor", function() { return ReachabilityMonitor; });
14571
+ /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/core */ "@aws-amplify/core");
14572
+ /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__);
14573
+
14574
+ var ReachabilityMonitor = function ReachabilityMonitor() {
14575
+ return new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Reachability"]().networkMonitor();
14576
+ };
14577
+
14578
+ /***/ }),
14579
+
14215
14580
  /***/ "./lib-esm/GraphQLAPI.js":
14216
14581
  /*!*******************************!*\
14217
14582
  !*** ./lib-esm/GraphQLAPI.js ***!