@aws-amplify/datastore 3.7.6-unstable.4 → 3.7.7-cloud-logging.9

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.
@@ -27891,7 +27891,6 @@ exports.serialize = serialize;
27891
27891
 
27892
27892
  var decode = decodeURIComponent;
27893
27893
  var encode = encodeURIComponent;
27894
- var pairSplitRegExp = /; */;
27895
27894
 
27896
27895
  /**
27897
27896
  * RegExp to match field-content in RFC 7230 sec 3.2
@@ -27922,28 +27921,29 @@ function parse(str, options) {
27922
27921
 
27923
27922
  var obj = {}
27924
27923
  var opt = options || {};
27925
- var pairs = str.split(pairSplitRegExp);
27924
+ var pairs = str.split(';')
27926
27925
  var dec = opt.decode || decode;
27927
27926
 
27928
27927
  for (var i = 0; i < pairs.length; i++) {
27929
27928
  var pair = pairs[i];
27930
- var eq_idx = pair.indexOf('=');
27929
+ var index = pair.indexOf('=')
27931
27930
 
27932
27931
  // skip things that don't look like key=value
27933
- if (eq_idx < 0) {
27932
+ if (index < 0) {
27934
27933
  continue;
27935
27934
  }
27936
27935
 
27937
- var key = pair.substr(0, eq_idx).trim()
27938
- var val = pair.substr(++eq_idx, pair.length).trim();
27939
-
27940
- // quoted values
27941
- if ('"' == val[0]) {
27942
- val = val.slice(1, -1);
27943
- }
27936
+ var key = pair.substring(0, index).trim()
27944
27937
 
27945
27938
  // only assign once
27946
27939
  if (undefined == obj[key]) {
27940
+ var val = pair.substring(index + 1, pair.length).trim()
27941
+
27942
+ // quoted values
27943
+ if (val[0] === '"') {
27944
+ val = val.slice(1, -1)
27945
+ }
27946
+
27947
27947
  obj[key] = tryDecode(val, dec);
27948
27948
  }
27949
27949
  }
@@ -28071,6 +28071,24 @@ function tryDecode(str, decode) {
28071
28071
  }
28072
28072
 
28073
28073
 
28074
+ /***/ }),
28075
+
28076
+ /***/ "../../node_modules/fast-text-encoding/text.min.js":
28077
+ /*!********************************************************************!*\
28078
+ !*** /root/amplify-js/node_modules/fast-text-encoding/text.min.js ***!
28079
+ \********************************************************************/
28080
+ /*! no static exports found */
28081
+ /***/ (function(module, exports, __webpack_require__) {
28082
+
28083
+ /* WEBPACK VAR INJECTION */(function(global, Buffer) {(function(l){function m(){}function k(a,c){a=void 0===a?"utf-8":a;c=void 0===c?{fatal:!1}:c;if(-1===r.indexOf(a.toLowerCase()))throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+a+"') is invalid.");if(c.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.");}function t(a){return Buffer.from(a.buffer,a.byteOffset,a.byteLength).toString("utf-8")}function u(a){var c=URL.createObjectURL(new Blob([a],{type:"text/plain;charset=UTF-8"}));
28084
+ try{var f=new XMLHttpRequest;f.open("GET",c,!1);f.send();return f.responseText}catch(e){return q(a)}finally{URL.revokeObjectURL(c)}}function q(a){for(var c=0,f=Math.min(65536,a.length+1),e=new Uint16Array(f),h=[],d=0;;){var b=c<a.length;if(!b||d>=f-1){h.push(String.fromCharCode.apply(null,e.subarray(0,d)));if(!b)return h.join("");a=a.subarray(c);d=c=0}b=a[c++];if(0===(b&128))e[d++]=b;else if(192===(b&224)){var g=a[c++]&63;e[d++]=(b&31)<<6|g}else if(224===(b&240)){g=a[c++]&63;var n=a[c++]&63;e[d++]=
28085
+ (b&31)<<12|g<<6|n}else if(240===(b&248)){g=a[c++]&63;n=a[c++]&63;var v=a[c++]&63;b=(b&7)<<18|g<<12|n<<6|v;65535<b&&(b-=65536,e[d++]=b>>>10&1023|55296,b=56320|b&1023);e[d++]=b}}}if(l.TextEncoder&&l.TextDecoder)return!1;var r=["utf-8","utf8","unicode-1-1-utf-8"];Object.defineProperty(m.prototype,"encoding",{value:"utf-8"});m.prototype.encode=function(a,c){c=void 0===c?{stream:!1}:c;if(c.stream)throw Error("Failed to encode: the 'stream' option is unsupported.");c=0;for(var f=a.length,e=0,h=Math.max(32,
28086
+ f+(f>>>1)+7),d=new Uint8Array(h>>>3<<3);c<f;){var b=a.charCodeAt(c++);if(55296<=b&&56319>=b){if(c<f){var g=a.charCodeAt(c);56320===(g&64512)&&(++c,b=((b&1023)<<10)+(g&1023)+65536)}if(55296<=b&&56319>=b)continue}e+4>d.length&&(h+=8,h*=1+c/a.length*2,h=h>>>3<<3,g=new Uint8Array(h),g.set(d),d=g);if(0===(b&4294967168))d[e++]=b;else{if(0===(b&4294965248))d[e++]=b>>>6&31|192;else if(0===(b&4294901760))d[e++]=b>>>12&15|224,d[e++]=b>>>6&63|128;else if(0===(b&4292870144))d[e++]=b>>>18&7|240,d[e++]=b>>>12&
28087
+ 63|128,d[e++]=b>>>6&63|128;else continue;d[e++]=b&63|128}}return d.slice?d.slice(0,e):d.subarray(0,e)};Object.defineProperty(k.prototype,"encoding",{value:"utf-8"});Object.defineProperty(k.prototype,"fatal",{value:!1});Object.defineProperty(k.prototype,"ignoreBOM",{value:!1});var p=q;"function"===typeof Buffer&&Buffer.from?p=t:"function"===typeof Blob&&"function"===typeof URL&&"function"===typeof URL.createObjectURL&&(p=u);k.prototype.decode=function(a,c){c=void 0===c?{stream:!1}:c;if(c.stream)throw Error("Failed to decode: the 'stream' option is unsupported.");
28088
+ a=a instanceof Uint8Array?a:a.buffer instanceof ArrayBuffer?new Uint8Array(a.buffer):new Uint8Array(a);return p(a)};l.TextEncoder=m;l.TextDecoder=k})("undefined"!==typeof window?window:"undefined"!==typeof global?global:this);
28089
+
28090
+ /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js"), __webpack_require__(/*! ./../buffer/index.js */ "../../node_modules/buffer/index.js").Buffer))
28091
+
28074
28092
  /***/ }),
28075
28093
 
28076
28094
  /***/ "../../node_modules/graphql/error/GraphQLError.mjs":
@@ -61917,7 +61935,7 @@ function () {
61917
61935
  * Delete the current authenticated user
61918
61936
  * @return {Promise}
61919
61937
  **/
61920
- //TODO: Check return type void
61938
+ // TODO: Check return type void
61921
61939
 
61922
61940
 
61923
61941
  AuthClass.prototype.deleteUser = function () {
@@ -68825,7 +68843,7 @@ function () {
68825
68843
  function HubClass(name) {
68826
68844
  this.listeners = [];
68827
68845
  this.patterns = [];
68828
- this.protectedChannels = ['core', 'auth', 'api', 'analytics', 'interactions', 'pubsub', 'storage', 'xr'];
68846
+ this.protectedChannels = ['core', 'auth', 'api', 'analytics', 'interactions', 'pubsub', 'storage', 'ui', 'xr'];
68829
68847
  this.name = name;
68830
68848
  } // Note - Need to pass channel as a reference for removal to work and not anonymous function
68831
68849
 
@@ -69773,6 +69791,7 @@ var LOG_LEVELS = {
69773
69791
  WARN: 4,
69774
69792
  ERROR: 5
69775
69793
  };
69794
+ var COMPATIBLE_PLUGINS = [_Util_Constants__WEBPACK_IMPORTED_MODULE_0__["AWS_CLOUDWATCH_CATEGORY"]];
69776
69795
  var LOG_TYPE;
69777
69796
 
69778
69797
  (function (LOG_TYPE) {
@@ -69782,12 +69801,13 @@ var LOG_TYPE;
69782
69801
  LOG_TYPE["WARN"] = "WARN";
69783
69802
  LOG_TYPE["VERBOSE"] = "VERBOSE";
69784
69803
  })(LOG_TYPE || (LOG_TYPE = {}));
69804
+
69805
+ var cloudWatchExcludeList = ['AWSCloudWatch', 'Amplify', 'Credentials', 'AuthClass', 'CloudLogger'];
69785
69806
  /**
69786
69807
  * Write logs
69787
69808
  * @class Logger
69788
69809
  */
69789
69810
 
69790
-
69791
69811
  var ConsoleLogger =
69792
69812
  /** @class */
69793
69813
  function () {
@@ -69803,8 +69823,19 @@ function () {
69803
69823
  this.name = name;
69804
69824
  this.level = level;
69805
69825
  this._pluggables = [];
69826
+ this.addPluggable = this.addPluggable.bind(this);
69806
69827
  }
69807
69828
 
69829
+ ConsoleLogger.globalPluggables = function (pluggable) {
69830
+ if (pluggable && COMPATIBLE_PLUGINS.includes(pluggable.getCategoryName())) {
69831
+ ConsoleLogger._globalpluggables.push(pluggable);
69832
+ }
69833
+ };
69834
+
69835
+ ConsoleLogger.clearGlobalPluggables = function () {
69836
+ ConsoleLogger._globalpluggables = [];
69837
+ };
69838
+
69808
69839
  ConsoleLogger.prototype._padding = function (n) {
69809
69840
  return n < 10 ? '0' + n : '' + n;
69810
69841
  };
@@ -69819,6 +69850,20 @@ function () {
69819
69850
  this._config = config;
69820
69851
  return this._config;
69821
69852
  };
69853
+
69854
+ ConsoleLogger.prototype._checkPluggables = function () {
69855
+ if (this._pluggables.length !== ConsoleLogger._globalpluggables.length) {
69856
+ if (ConsoleLogger._globalpluggables.length > 0) {
69857
+ ConsoleLogger._globalpluggables.forEach(this.addPluggable);
69858
+
69859
+ return;
69860
+ }
69861
+
69862
+ if (ConsoleLogger._globalpluggables.length === 0) {
69863
+ this._pluggables = [];
69864
+ }
69865
+ }
69866
+ };
69822
69867
  /**
69823
69868
  * Write log
69824
69869
  * @method
@@ -69831,12 +69876,49 @@ function () {
69831
69876
  ConsoleLogger.prototype._log = function (type) {
69832
69877
  var e_1, _a;
69833
69878
 
69879
+ var _this = this;
69880
+
69834
69881
  var msg = [];
69835
69882
 
69836
69883
  for (var _i = 1; _i < arguments.length; _i++) {
69837
69884
  msg[_i - 1] = arguments[_i];
69838
69885
  }
69839
69886
 
69887
+ if (!cloudWatchExcludeList.includes(this.name)) {
69888
+ this._checkPluggables();
69889
+ }
69890
+
69891
+ var generateMessage = function generateMessage(msg) {};
69892
+
69893
+ var generateCloudMessage = function generateCloudMessage(msg) {
69894
+ var message = '';
69895
+ var data;
69896
+
69897
+ if (msg.length === 1 && typeof msg[0] === 'string') {
69898
+ message = msg[0];
69899
+ } else if (msg.length === 1) {
69900
+ data = msg[0];
69901
+ } else if (typeof msg[0] === 'string') {
69902
+ var obj = msg.slice(1);
69903
+
69904
+ if (obj.length === 1) {
69905
+ obj = obj[0];
69906
+ }
69907
+
69908
+ message = msg[0];
69909
+ data = obj;
69910
+ } else {
69911
+ data = msg;
69912
+ }
69913
+
69914
+ return JSON.stringify({
69915
+ level: type,
69916
+ "class": _this.name,
69917
+ message: message,
69918
+ data: data
69919
+ });
69920
+ };
69921
+
69840
69922
  var logger_level_name = this.level;
69841
69923
 
69842
69924
  if (ConsoleLogger.LOG_LEVEL) {
@@ -69850,62 +69932,72 @@ function () {
69850
69932
  var logger_level = LOG_LEVELS[logger_level_name];
69851
69933
  var type_level = LOG_LEVELS[type];
69852
69934
 
69853
- if (!(type_level >= logger_level)) {
69854
- // Do nothing if type is not greater than or equal to logger level (handle undefined)
69855
- return;
69856
- }
69935
+ if (type_level >= logger_level) {
69936
+ var log = console.log.bind(console);
69857
69937
 
69858
- var log = console.log.bind(console);
69938
+ if (type === LOG_TYPE.ERROR && console.error) {
69939
+ log = console.error.bind(console);
69940
+ }
69859
69941
 
69860
- if (type === LOG_TYPE.ERROR && console.error) {
69861
- log = console.error.bind(console);
69862
- }
69942
+ if (type === LOG_TYPE.WARN && console.warn) {
69943
+ log = console.warn.bind(console);
69944
+ }
69863
69945
 
69864
- if (type === LOG_TYPE.WARN && console.warn) {
69865
- log = console.warn.bind(console);
69866
- }
69946
+ var prefix = "[" + type + "] " + this._ts() + " " + this.name;
69947
+ var message = '';
69948
+ var data = void 0;
69867
69949
 
69868
- var prefix = "[" + type + "] " + this._ts() + " " + this.name;
69869
- var message = '';
69950
+ if (msg.length === 1 && typeof msg[0] === 'string') {
69951
+ message = msg[0];
69952
+ log(prefix + " - " + message);
69953
+ } else if (msg.length === 1) {
69954
+ data = msg[0];
69955
+ log(prefix, data);
69956
+ } else if (typeof msg[0] === 'string') {
69957
+ var obj = msg.slice(1);
69870
69958
 
69871
- if (msg.length === 1 && typeof msg[0] === 'string') {
69872
- message = prefix + " - " + msg[0];
69873
- log(message);
69874
- } else if (msg.length === 1) {
69875
- message = prefix + " " + msg[0];
69876
- log(prefix, msg[0]);
69877
- } else if (typeof msg[0] === 'string') {
69878
- var obj = msg.slice(1);
69959
+ if (obj.length === 1) {
69960
+ obj = obj[0];
69961
+ }
69879
69962
 
69880
- if (obj.length === 1) {
69881
- obj = obj[0];
69963
+ message = msg[0];
69964
+ data = obj;
69965
+ log(prefix + " - " + message, data);
69966
+ } else {
69967
+ data = msg;
69968
+ log(prefix, data);
69882
69969
  }
69883
-
69884
- message = prefix + " - " + msg[0] + " " + obj;
69885
- log(prefix + " - " + msg[0], obj);
69886
- } else {
69887
- message = prefix + " " + msg;
69888
- log(prefix, msg);
69889
69970
  }
69890
69971
 
69891
- try {
69892
- for (var _b = __values(this._pluggables), _c = _b.next(); !_c.done; _c = _b.next()) {
69893
- var plugin = _c.value;
69894
- var logEvent = {
69895
- message: message,
69896
- timestamp: Date.now()
69897
- };
69898
- plugin.pushLogs([logEvent]);
69899
- }
69900
- } catch (e_1_1) {
69901
- e_1 = {
69902
- error: e_1_1
69903
- };
69904
- } finally {
69972
+ if (ConsoleLogger.CLOUD_LOG_LEVEL != null && !cloudWatchExcludeList.includes(this.name)) {
69973
+ var cloudMessage = generateCloudMessage(msg);
69974
+
69905
69975
  try {
69906
- if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
69976
+ for (var _b = __values(this._pluggables), _c = _b.next(); !_c.done; _c = _b.next()) {
69977
+ var plugin = _c.value;
69978
+ var logger_level_1 = LOG_LEVELS[ConsoleLogger.CLOUD_LOG_LEVEL];
69979
+ var type_level_1 = LOG_LEVELS[type];
69980
+ var logEvent = {
69981
+ message: cloudMessage,
69982
+ timestamp: Date.now()
69983
+ };
69984
+
69985
+ if (type_level_1 >= logger_level_1) {
69986
+ plugin.pushLogs([logEvent]);
69987
+ } else {
69988
+ plugin.pushLogs([]);
69989
+ }
69990
+ }
69991
+ } catch (e_1_1) {
69992
+ e_1 = {
69993
+ error: e_1_1
69994
+ };
69907
69995
  } finally {
69908
- if (e_1) throw e_1.error;
69996
+ try {
69997
+ if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
69998
+ } finally {
69999
+ if (e_1) throw e_1.error;
70000
+ }
69909
70001
  }
69910
70002
  }
69911
70003
  };
@@ -70013,10 +70105,8 @@ function () {
70013
70105
  };
70014
70106
 
70015
70107
  ConsoleLogger.prototype.addPluggable = function (pluggable) {
70016
- if (pluggable && pluggable.getCategoryName() === _Util_Constants__WEBPACK_IMPORTED_MODULE_0__["AWS_CLOUDWATCH_CATEGORY"]) {
70108
+ if (pluggable && COMPATIBLE_PLUGINS.includes(pluggable.getCategoryName())) {
70017
70109
  this._pluggables.push(pluggable);
70018
-
70019
- pluggable.configure(this._config);
70020
70110
  }
70021
70111
  };
70022
70112
 
@@ -70024,7 +70114,9 @@ function () {
70024
70114
  return this._pluggables;
70025
70115
  };
70026
70116
 
70117
+ ConsoleLogger._globalpluggables = [];
70027
70118
  ConsoleLogger.LOG_LEVEL = null;
70119
+ ConsoleLogger.CLOUD_LOG_LEVEL = null;
70028
70120
  return ConsoleLogger;
70029
70121
  }();
70030
70122
 
@@ -70852,7 +70944,7 @@ var getAmplifyUserAgent = function getAmplifyUserAgent() {
70852
70944
  __webpack_require__.r(__webpack_exports__);
70853
70945
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "version", function() { return version; });
70854
70946
  // generated by genversion
70855
- var version = '4.3.13';
70947
+ var version = '4.3.14';
70856
70948
 
70857
70949
  /***/ }),
70858
70950
 
@@ -70872,6 +70964,15 @@ __webpack_require__.r(__webpack_exports__);
70872
70964
  /* harmony import */ var _Platform__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Platform */ "../core/lib-esm/Platform/index.js");
70873
70965
  /* harmony import */ var _Parser__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Parser */ "../core/lib-esm/Parser.js");
70874
70966
  /* harmony import */ var _Util_Constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Util/Constants */ "../core/lib-esm/Util/Constants.js");
70967
+ function _typeof(obj) {
70968
+ "@babel/helpers - typeof";
70969
+
70970
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
70971
+ return typeof obj;
70972
+ } : function (obj) {
70973
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
70974
+ }, _typeof(obj);
70975
+ }
70875
70976
  /*
70876
70977
  * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
70877
70978
  *
@@ -70884,6 +70985,8 @@ __webpack_require__.r(__webpack_exports__);
70884
70985
  * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
70885
70986
  * and limitations under the License.
70886
70987
  */
70988
+
70989
+
70887
70990
  var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
70888
70991
  function adopt(value) {
70889
70992
  return value instanceof P ? value : new P(function (resolve) {
@@ -71027,62 +71130,44 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
71027
71130
  }
71028
71131
  };
71029
71132
 
71030
- var __read = undefined && undefined.__read || function (o, n) {
71031
- var m = typeof Symbol === "function" && o[Symbol.iterator];
71032
- if (!m) return o;
71033
- var i = m.call(o),
71034
- r,
71035
- ar = [],
71036
- e;
71037
71133
 
71038
- try {
71039
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
71040
- ar.push(r.value);
71041
- }
71042
- } catch (error) {
71043
- e = {
71044
- error: error
71045
- };
71046
- } finally {
71047
- try {
71048
- if (r && !r.done && (m = i["return"])) m.call(i);
71049
- } finally {
71050
- if (e) throw e.error;
71051
- }
71052
- }
71053
-
71054
- return ar;
71055
- };
71056
-
71057
- var __spread = undefined && undefined.__spread || function () {
71058
- for (var ar = [], i = 0; i < arguments.length; i++) {
71059
- ar = ar.concat(__read(arguments[i]));
71060
- }
71061
-
71062
- return ar;
71063
- };
71064
71134
 
71065
71135
 
71066
71136
 
71067
71137
 
71068
71138
 
71069
71139
 
71140
+ if (typeof window === 'undefined' || (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && !window.TextEncoder) {
71141
+ __webpack_require__(/*! fast-text-encoding */ "../../node_modules/fast-text-encoding/text.min.js");
71142
+ }
71070
71143
 
71071
71144
  var logger = new _Logger__WEBPACK_IMPORTED_MODULE_2__["ConsoleLogger"]('AWSCloudWatch');
71145
+ var INTERVAL = 30000;
71072
71146
 
71073
71147
  var AWSCloudWatchProvider =
71074
71148
  /** @class */
71075
71149
  function () {
71076
71150
  function AWSCloudWatchProvider(config) {
71077
- this.configure(config);
71078
- this._dataTracker = {
71079
- eventUploadInProgress: false,
71080
- logEvents: []
71081
- };
71082
- this._currentLogBatch = [];
71151
+ this._initialized = false;
71152
+ console.log('cstr', config);
71153
+
71154
+ if (!this._initialized) {
71155
+ this.configure(config);
71156
+ this._dataTracker = {
71157
+ eventUploadInProgress: false,
71158
+ logEvents: [],
71159
+ verifiedLogGroup: {
71160
+ logGroupName: this._config.logGroupName
71161
+ }
71162
+ };
71163
+ this._currentLogBatch = [];
71164
+
71165
+ this._initiateLogPushInterval();
71166
+
71167
+ this._initialized = true;
71168
+ }
71169
+ } // public static instance: AWSCloudWatchProvider;
71083
71170
 
71084
- this._initiateLogPushInterval();
71085
- }
71086
71171
 
71087
71172
  AWSCloudWatchProvider.prototype.getProviderName = function () {
71088
71173
  return AWSCloudWatchProvider.PROVIDER_NAME;
@@ -71096,6 +71181,12 @@ function () {
71096
71181
  return this._dataTracker.logEvents;
71097
71182
  };
71098
71183
 
71184
+ AWSCloudWatchProvider.prototype.setPreFlightCheck = function (cb) {
71185
+ if (typeof cb === 'function') {
71186
+ this._preFlightCheck = cb;
71187
+ }
71188
+ };
71189
+
71099
71190
  AWSCloudWatchProvider.prototype.configure = function (config) {
71100
71191
  if (!config) return this._config || {};
71101
71192
  var conf = Object.assign({}, this._config, Object(_Parser__WEBPACK_IMPORTED_MODULE_4__["parseMobileHubConfig"])(config).Logging, config);
@@ -71349,8 +71440,27 @@ function () {
71349
71440
  };
71350
71441
 
71351
71442
  AWSCloudWatchProvider.prototype.pushLogs = function (logs) {
71352
- logger.debug('pushing log events to Cloudwatch...');
71353
- this._dataTracker.logEvents = __spread(this._dataTracker.logEvents, logs);
71443
+ logger.debug('pushing log events to Cloudwatch buffer');
71444
+ this._dataTracker.logEvents = this._dataTracker.logEvents.concat(logs);
71445
+ };
71446
+
71447
+ AWSCloudWatchProvider.prototype.pause = function () {
71448
+ this._processing = false;
71449
+
71450
+ if (this._timer) {
71451
+ clearInterval(this._timer);
71452
+ }
71453
+ };
71454
+
71455
+ AWSCloudWatchProvider.prototype.resume = function () {
71456
+ this._processing = true;
71457
+
71458
+ this._initiateLogPushInterval();
71459
+ };
71460
+
71461
+ AWSCloudWatchProvider.prototype.clear = function () {
71462
+ this._dataTracker.logEvents = [];
71463
+ this._currentLogBatch = [];
71354
71464
  };
71355
71465
 
71356
71466
  AWSCloudWatchProvider.prototype._validateLogGroupExistsAndCreate = function (logGroupName) {
@@ -71667,13 +71777,33 @@ function () {
71667
71777
  return __generator(this, function (_a) {
71668
71778
  switch (_a.label) {
71669
71779
  case 0:
71670
- _a.trys.push([0, 3,, 4]);
71780
+ _a.trys.push([0, 4,, 5]);
71671
71781
 
71672
71782
  return [4
71673
71783
  /*yield*/
71674
- , this._getNextSequenceToken()];
71784
+ , this._preFlightCheck()];
71675
71785
 
71676
71786
  case 1:
71787
+ /**
71788
+ * CloudWatch has restrictions on the size of the log events that get sent up.
71789
+ * We need to track both the size of each event and the total size of the batch
71790
+ * of logs.
71791
+ *
71792
+ * We also need to ensure that the logs in the batch are sorted in chronological order.
71793
+ * https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html
71794
+ */
71795
+ if (!_a.sent()) {
71796
+ this.clear();
71797
+ return [2
71798
+ /*return*/
71799
+ ];
71800
+ }
71801
+
71802
+ return [4
71803
+ /*yield*/
71804
+ , this._getNextSequenceToken()];
71805
+
71806
+ case 2:
71677
71807
  seqToken = _a.sent();
71678
71808
  logBatch = this._currentLogBatch.length === 0 ? this._getBufferedBatchOfLogs() : this._currentLogBatch;
71679
71809
  putLogsPayload = {
@@ -71687,7 +71817,7 @@ function () {
71687
71817
  /*yield*/
71688
71818
  , this._sendLogEvents(putLogsPayload)];
71689
71819
 
71690
- case 2:
71820
+ case 3:
71691
71821
  sendLogEventsResponse = _a.sent();
71692
71822
  this._nextSequenceToken = sendLogEventsResponse.nextSequenceToken;
71693
71823
  this._dataTracker.eventUploadInProgress = false;
@@ -71696,7 +71826,7 @@ function () {
71696
71826
  /*return*/
71697
71827
  , sendLogEventsResponse];
71698
71828
 
71699
- case 3:
71829
+ case 4:
71700
71830
  err_5 = _a.sent();
71701
71831
  logger.error("error during _safeUploadLogEvents: " + err_5);
71702
71832
 
@@ -71713,9 +71843,9 @@ function () {
71713
71843
 
71714
71844
  return [3
71715
71845
  /*break*/
71716
- , 4];
71846
+ , 5];
71717
71847
 
71718
- case 4:
71848
+ case 5:
71719
71849
  return [2
71720
71850
  /*return*/
71721
71851
  ];
@@ -71834,6 +71964,7 @@ function () {
71834
71964
  case 3:
71835
71965
  err_7 = _a.sent();
71836
71966
  logger.error("error when calling _safeUploadLogEvents in the timer interval - " + err_7);
71967
+ this.pause();
71837
71968
  return [3
71838
71969
  /*break*/
71839
71970
  , 4];
@@ -71845,7 +71976,7 @@ function () {
71845
71976
  }
71846
71977
  });
71847
71978
  });
71848
- }, 2000);
71979
+ }, INTERVAL);
71849
71980
  };
71850
71981
 
71851
71982
  AWSCloudWatchProvider.prototype._getDocUploadPermissibility = function () {
@@ -72877,7 +73008,7 @@ function () {
72877
73008
  /*!*****************************************!*\
72878
73009
  !*** ../core/lib-esm/Util/Constants.js ***!
72879
73010
  \*****************************************/
72880
- /*! exports provided: AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES */
73011
+ /*! exports provided: AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES, AMAZON_KINESIS_LOGGING_PROVIDER_NAME, AMAZON_KINESIS_LOGGING_CATEGORY */
72881
73012
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
72882
73013
 
72883
73014
  "use strict";
@@ -72889,6 +73020,8 @@ __webpack_require__.r(__webpack_exports__);
72889
73020
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AWS_CLOUDWATCH_PROVIDER_NAME", function() { return AWS_CLOUDWATCH_PROVIDER_NAME; });
72890
73021
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NO_CREDS_ERROR_STRING", function() { return NO_CREDS_ERROR_STRING; });
72891
73022
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RETRY_ERROR_CODES", function() { return RETRY_ERROR_CODES; });
73023
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AMAZON_KINESIS_LOGGING_PROVIDER_NAME", function() { return AMAZON_KINESIS_LOGGING_PROVIDER_NAME; });
73024
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AMAZON_KINESIS_LOGGING_CATEGORY", function() { return AMAZON_KINESIS_LOGGING_CATEGORY; });
72892
73025
  /*
72893
73026
  * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
72894
73027
  *
@@ -72902,11 +73035,14 @@ __webpack_require__.r(__webpack_exports__);
72902
73035
  * and limitations under the License.
72903
73036
  */
72904
73037
  // Logging constants
73038
+ // Cloudwatch
72905
73039
  var AWS_CLOUDWATCH_BASE_BUFFER_SIZE = 26;
72906
73040
  var AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE = 1048576;
72907
73041
  var AWS_CLOUDWATCH_MAX_EVENT_SIZE = 256000;
72908
73042
  var AWS_CLOUDWATCH_CATEGORY = 'Logging';
72909
73043
  var AWS_CLOUDWATCH_PROVIDER_NAME = 'AWSCloudWatch';
73044
+ var AMAZON_KINESIS_LOGGING_CATEGORY = 'KinesisLogging';
73045
+ var AMAZON_KINESIS_LOGGING_PROVIDER_NAME = 'AmazonKinesisLogging';
72910
73046
  var NO_CREDS_ERROR_STRING = 'No credentials';
72911
73047
  var RETRY_ERROR_CODES = ['ResourceNotFoundException', 'InvalidSequenceTokenException'];
72912
73048
 
@@ -73609,7 +73745,7 @@ function urlSafeDecode(hex) {
73609
73745
  /*!*************************************!*\
73610
73746
  !*** ../core/lib-esm/Util/index.js ***!
73611
73747
  \*************************************/
73612
- /*! exports provided: NonRetryableError, retry, jitteredExponentialRetry, Mutex, Reachability, DateUtils, urlSafeEncode, urlSafeDecode, AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES */
73748
+ /*! exports provided: NonRetryableError, retry, jitteredExponentialRetry, Mutex, Reachability, DateUtils, urlSafeEncode, urlSafeDecode, AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES, AMAZON_KINESIS_LOGGING_PROVIDER_NAME, AMAZON_KINESIS_LOGGING_CATEGORY */
73613
73749
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
73614
73750
 
73615
73751
  "use strict";
@@ -73650,6 +73786,10 @@ __webpack_require__.r(__webpack_exports__);
73650
73786
 
73651
73787
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RETRY_ERROR_CODES", function() { return _Constants__WEBPACK_IMPORTED_MODULE_5__["RETRY_ERROR_CODES"]; });
73652
73788
 
73789
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AMAZON_KINESIS_LOGGING_PROVIDER_NAME", function() { return _Constants__WEBPACK_IMPORTED_MODULE_5__["AMAZON_KINESIS_LOGGING_PROVIDER_NAME"]; });
73790
+
73791
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AMAZON_KINESIS_LOGGING_CATEGORY", function() { return _Constants__WEBPACK_IMPORTED_MODULE_5__["AMAZON_KINESIS_LOGGING_CATEGORY"]; });
73792
+
73653
73793
 
73654
73794
 
73655
73795
 
@@ -73699,7 +73839,7 @@ var USER_AGENT_HEADER = 'x-amz-user-agent';
73699
73839
  /*!********************************!*\
73700
73840
  !*** ../core/lib-esm/index.js ***!
73701
73841
  \********************************/
73702
- /*! exports provided: AmplifyClass, ClientDevice, ConsoleLogger, Logger, missingConfig, invalidParameter, Hub, I18n, isEmpty, sortByField, objectLessAttributes, filenameToContentType, isTextFile, generateRandomString, makeQuerablePromise, isWebWorker, browserOrNode, transferKeyToLowerCase, transferKeyToUpperCase, isStrictObject, JS, Signer, parseMobileHubConfig, Parser, AWSCloudWatchProvider, FacebookOAuth, GoogleOAuth, Linking, AppState, AsyncStorage, Credentials, CredentialsClass, ServiceWorker, StorageHelper, MemoryStorage, UniversalStorage, Platform, getAmplifyUserAgent, INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER, INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, Constants, NonRetryableError, retry, jitteredExponentialRetry, Mutex, Reachability, DateUtils, urlSafeEncode, urlSafeDecode, AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES, Amplify, default */
73842
+ /*! exports provided: AmplifyClass, ClientDevice, ConsoleLogger, Logger, missingConfig, invalidParameter, Hub, I18n, isEmpty, sortByField, objectLessAttributes, filenameToContentType, isTextFile, generateRandomString, makeQuerablePromise, isWebWorker, browserOrNode, transferKeyToLowerCase, transferKeyToUpperCase, isStrictObject, JS, Signer, parseMobileHubConfig, Parser, AWSCloudWatchProvider, FacebookOAuth, GoogleOAuth, Linking, AppState, AsyncStorage, Credentials, CredentialsClass, ServiceWorker, StorageHelper, MemoryStorage, UniversalStorage, Platform, getAmplifyUserAgent, INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER, INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, Constants, NonRetryableError, retry, jitteredExponentialRetry, Mutex, Reachability, DateUtils, urlSafeEncode, urlSafeDecode, AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES, AMAZON_KINESIS_LOGGING_PROVIDER_NAME, AMAZON_KINESIS_LOGGING_CATEGORY, Amplify, default */
73703
73843
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
73704
73844
 
73705
73845
  "use strict";
@@ -73838,6 +73978,10 @@ __webpack_require__.r(__webpack_exports__);
73838
73978
 
73839
73979
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RETRY_ERROR_CODES", function() { return _Util__WEBPACK_IMPORTED_MODULE_18__["RETRY_ERROR_CODES"]; });
73840
73980
 
73981
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AMAZON_KINESIS_LOGGING_PROVIDER_NAME", function() { return _Util__WEBPACK_IMPORTED_MODULE_18__["AMAZON_KINESIS_LOGGING_PROVIDER_NAME"]; });
73982
+
73983
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AMAZON_KINESIS_LOGGING_CATEGORY", function() { return _Util__WEBPACK_IMPORTED_MODULE_18__["AMAZON_KINESIS_LOGGING_CATEGORY"]; });
73984
+
73841
73985
  /*
73842
73986
  * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
73843
73987
  *
@@ -82285,24 +82429,32 @@ function () {
82285
82429
  case 4:
82286
82430
  _b.sent();
82287
82431
 
82432
+ logger.debug('Debug info before sync');
82288
82433
  return [4
82289
82434
  /*yield*/
82290
- , checkSchemaVersion(this.storage, schema.version)];
82435
+ , this.storage.logDebugInfo()];
82291
82436
 
82292
82437
  case 5:
82293
82438
  _b.sent();
82294
82439
 
82440
+ return [4
82441
+ /*yield*/
82442
+ , checkSchemaVersion(this.storage, schema.version)];
82443
+
82444
+ case 6:
82445
+ _b.sent();
82446
+
82295
82447
  aws_appsync_graphqlEndpoint = this.amplifyConfig.aws_appsync_graphqlEndpoint;
82296
82448
  if (!aws_appsync_graphqlEndpoint) return [3
82297
82449
  /*break*/
82298
- , 7];
82450
+ , 8];
82299
82451
  logger.debug('GraphQL endpoint available', aws_appsync_graphqlEndpoint);
82300
82452
  _a = this;
82301
82453
  return [4
82302
82454
  /*yield*/
82303
82455
  , this.processSyncExpressions()];
82304
82456
 
82305
- case 6:
82457
+ case 7:
82306
82458
  _a.syncPredicates = _b.sent();
82307
82459
  this.sync = new _sync__WEBPACK_IMPORTED_MODULE_7__["SyncEngine"](schema, namespaceResolver, syncClasses, userClasses, this.storage, modelInstanceCreator, this.conflictHandler, this.errorHandler, this.syncPredicates, this.amplifyConfig, this.authModeStrategy);
82308
82460
  fullSyncIntervalInMilliseconds = this.fullSyncInterval * 1000 * 60;
@@ -82320,6 +82472,16 @@ function () {
82320
82472
  _this.initResolve();
82321
82473
  }
82322
82474
 
82475
+ if (type === _sync__WEBPACK_IMPORTED_MODULE_7__["ControlMessage"].SYNC_ENGINE_SYNC_QUERIES_READY) {
82476
+ logger.debug('Debug info after sync');
82477
+
82478
+ _this.storage.logDebugInfo();
82479
+ }
82480
+
82481
+ logger.debug({
82482
+ event: type,
82483
+ data: data
82484
+ });
82323
82485
  _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Hub"].dispatch('datastore', {
82324
82486
  event: type,
82325
82487
  data: data
@@ -82333,21 +82495,21 @@ function () {
82333
82495
  });
82334
82496
  return [3
82335
82497
  /*break*/
82336
- , 8];
82498
+ , 9];
82337
82499
 
82338
- case 7:
82500
+ case 8:
82339
82501
  logger.warn("Data won't be synchronized. No GraphQL endpoint configured. Did you forget `Amplify.configure(awsconfig)`?", {
82340
82502
  config: this.amplifyConfig
82341
82503
  });
82342
82504
  this.initResolve();
82343
- _b.label = 8;
82505
+ _b.label = 9;
82344
82506
 
82345
- case 8:
82507
+ case 9:
82346
82508
  return [4
82347
82509
  /*yield*/
82348
82510
  , this.initialized];
82349
82511
 
82350
- case 9:
82512
+ case 10:
82351
82513
  _b.sent();
82352
82514
 
82353
82515
  return [2
@@ -89343,6 +89505,33 @@ function () {
89343
89505
  });
89344
89506
  };
89345
89507
 
89508
+ StorageClass.prototype.logDebugInfo = function () {
89509
+ return __awaiter(this, void 0, void 0, function () {
89510
+ var results;
89511
+ return __generator(this, function (_a) {
89512
+ switch (_a.label) {
89513
+ case 0:
89514
+ if (!(typeof this.adapter.getDebugInfo === 'function')) return [3
89515
+ /*break*/
89516
+ , 2];
89517
+ return [4
89518
+ /*yield*/
89519
+ , this.adapter.getDebugInfo()];
89520
+
89521
+ case 1:
89522
+ results = _a.sent();
89523
+ logger.debug('DB Debug Info', results);
89524
+ _a.label = 2;
89525
+
89526
+ case 2:
89527
+ return [2
89528
+ /*return*/
89529
+ ];
89530
+ }
89531
+ });
89532
+ });
89533
+ };
89534
+
89346
89535
  return StorageClass;
89347
89536
  }();
89348
89537
 
@@ -89448,6 +89637,18 @@ function () {
89448
89637
  return this.storage.batchSave(modelConstructor, items);
89449
89638
  };
89450
89639
 
89640
+ ExclusiveStorage.prototype.logDebugInfo = function () {
89641
+ return __awaiter(this, void 0, void 0, function () {
89642
+ return __generator(this, function (_a) {
89643
+ return [2
89644
+ /*return*/
89645
+ , this.runExclusive(function (storage) {
89646
+ return storage.logDebugInfo();
89647
+ })];
89648
+ });
89649
+ });
89650
+ };
89651
+
89451
89652
  ExclusiveStorage.prototype.init = function () {
89452
89653
  return __awaiter(this, void 0, void 0, function () {
89453
89654
  return __generator(this, function (_a) {