@aws-amplify/datastore 3.7.7 → 3.7.8-cloud-logging.7

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.
@@ -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":
@@ -61911,7 +61929,7 @@ function () {
61911
61929
  * Delete the current authenticated user
61912
61930
  * @return {Promise}
61913
61931
  **/
61914
- //TODO: Check return type void
61932
+ // TODO: Check return type void
61915
61933
 
61916
61934
 
61917
61935
  AuthClass.prototype.deleteUser = function () {
@@ -69767,6 +69785,7 @@ var LOG_LEVELS = {
69767
69785
  WARN: 4,
69768
69786
  ERROR: 5
69769
69787
  };
69788
+ var COMPATIBLE_PLUGINS = [_Util_Constants__WEBPACK_IMPORTED_MODULE_0__["AWS_CLOUDWATCH_CATEGORY"]];
69770
69789
  var LOG_TYPE;
69771
69790
 
69772
69791
  (function (LOG_TYPE) {
@@ -69776,12 +69795,13 @@ var LOG_TYPE;
69776
69795
  LOG_TYPE["WARN"] = "WARN";
69777
69796
  LOG_TYPE["VERBOSE"] = "VERBOSE";
69778
69797
  })(LOG_TYPE || (LOG_TYPE = {}));
69798
+
69799
+ var cloudWatchExcludeList = ['AWSCloudWatch', 'Amplify', 'Credentials', 'AuthClass', 'CloudLogger'];
69779
69800
  /**
69780
69801
  * Write logs
69781
69802
  * @class Logger
69782
69803
  */
69783
69804
 
69784
-
69785
69805
  var ConsoleLogger =
69786
69806
  /** @class */
69787
69807
  function () {
@@ -69797,8 +69817,19 @@ function () {
69797
69817
  this.name = name;
69798
69818
  this.level = level;
69799
69819
  this._pluggables = [];
69820
+ this.addPluggable = this.addPluggable.bind(this);
69800
69821
  }
69801
69822
 
69823
+ ConsoleLogger.globalPluggables = function (pluggable) {
69824
+ if (pluggable && COMPATIBLE_PLUGINS.includes(pluggable.getCategoryName())) {
69825
+ ConsoleLogger._globalpluggables.push(pluggable);
69826
+ }
69827
+ };
69828
+
69829
+ ConsoleLogger.clearGlobalPluggables = function () {
69830
+ ConsoleLogger._globalpluggables = [];
69831
+ };
69832
+
69802
69833
  ConsoleLogger.prototype._padding = function (n) {
69803
69834
  return n < 10 ? '0' + n : '' + n;
69804
69835
  };
@@ -69813,6 +69844,20 @@ function () {
69813
69844
  this._config = config;
69814
69845
  return this._config;
69815
69846
  };
69847
+
69848
+ ConsoleLogger.prototype._checkPluggables = function () {
69849
+ if (this._pluggables.length !== ConsoleLogger._globalpluggables.length) {
69850
+ if (ConsoleLogger._globalpluggables.length > 0) {
69851
+ ConsoleLogger._globalpluggables.forEach(this.addPluggable);
69852
+
69853
+ return;
69854
+ }
69855
+
69856
+ if (ConsoleLogger._globalpluggables.length === 0) {
69857
+ this._pluggables = [];
69858
+ }
69859
+ }
69860
+ };
69816
69861
  /**
69817
69862
  * Write log
69818
69863
  * @method
@@ -69825,12 +69870,47 @@ function () {
69825
69870
  ConsoleLogger.prototype._log = function (type) {
69826
69871
  var e_1, _a;
69827
69872
 
69873
+ var _this = this;
69874
+
69828
69875
  var msg = [];
69829
69876
 
69830
69877
  for (var _i = 1; _i < arguments.length; _i++) {
69831
69878
  msg[_i - 1] = arguments[_i];
69832
69879
  }
69833
69880
 
69881
+ if (!cloudWatchExcludeList.includes(this.name)) {
69882
+ this._checkPluggables();
69883
+ }
69884
+
69885
+ var generateCloudMessage = function generateCloudMessage(msg) {
69886
+ var message = '';
69887
+ var data;
69888
+
69889
+ if (msg.length === 1 && typeof msg[0] === 'string') {
69890
+ message = msg[0];
69891
+ } else if (msg.length === 1) {
69892
+ data = msg[0];
69893
+ } else if (typeof msg[0] === 'string') {
69894
+ var obj = msg.slice(1);
69895
+
69896
+ if (obj.length === 1) {
69897
+ obj = obj[0];
69898
+ }
69899
+
69900
+ message = msg[0];
69901
+ data = obj;
69902
+ } else {
69903
+ data = msg;
69904
+ }
69905
+
69906
+ return JSON.stringify({
69907
+ level: type,
69908
+ "class": _this.name,
69909
+ message: message,
69910
+ data: data
69911
+ });
69912
+ };
69913
+
69834
69914
  var logger_level_name = this.level;
69835
69915
 
69836
69916
  if (ConsoleLogger.LOG_LEVEL) {
@@ -69844,62 +69924,72 @@ function () {
69844
69924
  var logger_level = LOG_LEVELS[logger_level_name];
69845
69925
  var type_level = LOG_LEVELS[type];
69846
69926
 
69847
- if (!(type_level >= logger_level)) {
69848
- // Do nothing if type is not greater than or equal to logger level (handle undefined)
69849
- return;
69850
- }
69927
+ if (type_level >= logger_level) {
69928
+ var log = console.log.bind(console);
69851
69929
 
69852
- var log = console.log.bind(console);
69930
+ if (type === LOG_TYPE.ERROR && console.error) {
69931
+ log = console.error.bind(console);
69932
+ }
69853
69933
 
69854
- if (type === LOG_TYPE.ERROR && console.error) {
69855
- log = console.error.bind(console);
69856
- }
69934
+ if (type === LOG_TYPE.WARN && console.warn) {
69935
+ log = console.warn.bind(console);
69936
+ }
69857
69937
 
69858
- if (type === LOG_TYPE.WARN && console.warn) {
69859
- log = console.warn.bind(console);
69860
- }
69938
+ var prefix = "[" + type + "] " + this._ts() + " " + this.name;
69939
+ var message = '';
69940
+ var data = void 0;
69861
69941
 
69862
- var prefix = "[" + type + "] " + this._ts() + " " + this.name;
69863
- var message = '';
69942
+ if (msg.length === 1 && typeof msg[0] === 'string') {
69943
+ message = msg[0];
69944
+ log(prefix + " - " + message);
69945
+ } else if (msg.length === 1) {
69946
+ data = msg[0];
69947
+ log(prefix, data);
69948
+ } else if (typeof msg[0] === 'string') {
69949
+ var obj = msg.slice(1);
69864
69950
 
69865
- if (msg.length === 1 && typeof msg[0] === 'string') {
69866
- message = prefix + " - " + msg[0];
69867
- log(message);
69868
- } else if (msg.length === 1) {
69869
- message = prefix + " " + msg[0];
69870
- log(prefix, msg[0]);
69871
- } else if (typeof msg[0] === 'string') {
69872
- var obj = msg.slice(1);
69951
+ if (obj.length === 1) {
69952
+ obj = obj[0];
69953
+ }
69873
69954
 
69874
- if (obj.length === 1) {
69875
- obj = obj[0];
69955
+ message = msg[0];
69956
+ data = obj;
69957
+ log(prefix + " - " + message, data);
69958
+ } else {
69959
+ data = msg;
69960
+ log(prefix, data);
69876
69961
  }
69877
-
69878
- message = prefix + " - " + msg[0] + " " + obj;
69879
- log(prefix + " - " + msg[0], obj);
69880
- } else {
69881
- message = prefix + " " + msg;
69882
- log(prefix, msg);
69883
69962
  }
69884
69963
 
69885
- try {
69886
- for (var _b = __values(this._pluggables), _c = _b.next(); !_c.done; _c = _b.next()) {
69887
- var plugin = _c.value;
69888
- var logEvent = {
69889
- message: message,
69890
- timestamp: Date.now()
69891
- };
69892
- plugin.pushLogs([logEvent]);
69893
- }
69894
- } catch (e_1_1) {
69895
- e_1 = {
69896
- error: e_1_1
69897
- };
69898
- } finally {
69964
+ if (ConsoleLogger.CLOUD_LOG_LEVEL != null && !cloudWatchExcludeList.includes(this.name)) {
69965
+ var cloudMessage = generateCloudMessage(msg);
69966
+
69899
69967
  try {
69900
- if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
69968
+ for (var _b = __values(this._pluggables), _c = _b.next(); !_c.done; _c = _b.next()) {
69969
+ var plugin = _c.value;
69970
+ var logger_level_1 = LOG_LEVELS[ConsoleLogger.CLOUD_LOG_LEVEL];
69971
+ var type_level_1 = LOG_LEVELS[type];
69972
+ var logEvent = {
69973
+ message: cloudMessage,
69974
+ timestamp: Date.now()
69975
+ };
69976
+
69977
+ if (type_level_1 >= logger_level_1) {
69978
+ plugin.pushLogs([logEvent]);
69979
+ } else {
69980
+ plugin.pushLogs([]);
69981
+ }
69982
+ }
69983
+ } catch (e_1_1) {
69984
+ e_1 = {
69985
+ error: e_1_1
69986
+ };
69901
69987
  } finally {
69902
- if (e_1) throw e_1.error;
69988
+ try {
69989
+ if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
69990
+ } finally {
69991
+ if (e_1) throw e_1.error;
69992
+ }
69903
69993
  }
69904
69994
  }
69905
69995
  };
@@ -70007,10 +70097,8 @@ function () {
70007
70097
  };
70008
70098
 
70009
70099
  ConsoleLogger.prototype.addPluggable = function (pluggable) {
70010
- if (pluggable && pluggable.getCategoryName() === _Util_Constants__WEBPACK_IMPORTED_MODULE_0__["AWS_CLOUDWATCH_CATEGORY"]) {
70100
+ if (pluggable && COMPATIBLE_PLUGINS.includes(pluggable.getCategoryName())) {
70011
70101
  this._pluggables.push(pluggable);
70012
-
70013
- pluggable.configure(this._config);
70014
70102
  }
70015
70103
  };
70016
70104
 
@@ -70018,7 +70106,9 @@ function () {
70018
70106
  return this._pluggables;
70019
70107
  };
70020
70108
 
70109
+ ConsoleLogger._globalpluggables = [];
70021
70110
  ConsoleLogger.LOG_LEVEL = null;
70111
+ ConsoleLogger.CLOUD_LOG_LEVEL = null;
70022
70112
  return ConsoleLogger;
70023
70113
  }();
70024
70114
 
@@ -70846,7 +70936,7 @@ var getAmplifyUserAgent = function getAmplifyUserAgent() {
70846
70936
  __webpack_require__.r(__webpack_exports__);
70847
70937
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "version", function() { return version; });
70848
70938
  // generated by genversion
70849
- var version = '4.3.14';
70939
+ var version = '4.4.0';
70850
70940
 
70851
70941
  /***/ }),
70852
70942
 
@@ -70866,6 +70956,15 @@ __webpack_require__.r(__webpack_exports__);
70866
70956
  /* harmony import */ var _Platform__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Platform */ "../core/lib-esm/Platform/index.js");
70867
70957
  /* harmony import */ var _Parser__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Parser */ "../core/lib-esm/Parser.js");
70868
70958
  /* harmony import */ var _Util_Constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Util/Constants */ "../core/lib-esm/Util/Constants.js");
70959
+ function _typeof(obj) {
70960
+ "@babel/helpers - typeof";
70961
+
70962
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
70963
+ return typeof obj;
70964
+ } : function (obj) {
70965
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
70966
+ }, _typeof(obj);
70967
+ }
70869
70968
  /*
70870
70969
  * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
70871
70970
  *
@@ -70878,6 +70977,8 @@ __webpack_require__.r(__webpack_exports__);
70878
70977
  * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
70879
70978
  * and limitations under the License.
70880
70979
  */
70980
+
70981
+
70881
70982
  var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
70882
70983
  function adopt(value) {
70883
70984
  return value instanceof P ? value : new P(function (resolve) {
@@ -71021,61 +71122,42 @@ var __generator = undefined && undefined.__generator || function (thisArg, body)
71021
71122
  }
71022
71123
  };
71023
71124
 
71024
- var __read = undefined && undefined.__read || function (o, n) {
71025
- var m = typeof Symbol === "function" && o[Symbol.iterator];
71026
- if (!m) return o;
71027
- var i = m.call(o),
71028
- r,
71029
- ar = [],
71030
- e;
71031
-
71032
- try {
71033
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
71034
- ar.push(r.value);
71035
- }
71036
- } catch (error) {
71037
- e = {
71038
- error: error
71039
- };
71040
- } finally {
71041
- try {
71042
- if (r && !r.done && (m = i["return"])) m.call(i);
71043
- } finally {
71044
- if (e) throw e.error;
71045
- }
71046
- }
71047
-
71048
- return ar;
71049
- };
71050
-
71051
- var __spread = undefined && undefined.__spread || function () {
71052
- for (var ar = [], i = 0; i < arguments.length; i++) {
71053
- ar = ar.concat(__read(arguments[i]));
71054
- }
71055
71125
 
71056
- return ar;
71057
- };
71058
71126
 
71059
71127
 
71060
71128
 
71061
71129
 
71062
71130
 
71063
71131
 
71132
+ if (typeof window === 'undefined' || (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && !window.TextEncoder) {
71133
+ __webpack_require__(/*! fast-text-encoding */ "../../node_modules/fast-text-encoding/text.min.js");
71134
+ }
71064
71135
 
71065
71136
  var logger = new _Logger__WEBPACK_IMPORTED_MODULE_2__["ConsoleLogger"]('AWSCloudWatch');
71137
+ var INTERVAL = 10000;
71066
71138
 
71067
71139
  var AWSCloudWatchProvider =
71068
71140
  /** @class */
71069
71141
  function () {
71070
71142
  function AWSCloudWatchProvider(config) {
71071
- this.configure(config);
71072
- this._dataTracker = {
71073
- eventUploadInProgress: false,
71074
- logEvents: []
71075
- };
71076
- this._currentLogBatch = [];
71143
+ this._initialized = false;
71144
+ console.log('cstr', config);
71077
71145
 
71078
- this._initiateLogPushInterval();
71146
+ if (!this._initialized) {
71147
+ this.configure(config);
71148
+ this._dataTracker = {
71149
+ eventUploadInProgress: false,
71150
+ logEvents: [],
71151
+ verifiedLogGroup: {
71152
+ logGroupName: this._config.logGroupName
71153
+ }
71154
+ };
71155
+ this._currentLogBatch = [];
71156
+
71157
+ this._initiateLogPushInterval();
71158
+
71159
+ this._initialized = true;
71160
+ }
71079
71161
  }
71080
71162
 
71081
71163
  AWSCloudWatchProvider.prototype.getProviderName = function () {
@@ -71090,6 +71172,12 @@ function () {
71090
71172
  return this._dataTracker.logEvents;
71091
71173
  };
71092
71174
 
71175
+ AWSCloudWatchProvider.prototype.setPreFlightCheck = function (cb) {
71176
+ if (typeof cb === 'function') {
71177
+ this._preFlightCheck = cb;
71178
+ }
71179
+ };
71180
+
71093
71181
  AWSCloudWatchProvider.prototype.configure = function (config) {
71094
71182
  if (!config) return this._config || {};
71095
71183
  var conf = Object.assign({}, this._config, Object(_Parser__WEBPACK_IMPORTED_MODULE_4__["parseMobileHubConfig"])(config).Logging, config);
@@ -71343,8 +71431,27 @@ function () {
71343
71431
  };
71344
71432
 
71345
71433
  AWSCloudWatchProvider.prototype.pushLogs = function (logs) {
71346
- logger.debug('pushing log events to Cloudwatch...');
71347
- this._dataTracker.logEvents = __spread(this._dataTracker.logEvents, logs);
71434
+ logger.debug('pushing log events to buffer');
71435
+ this._dataTracker.logEvents = this._dataTracker.logEvents.concat(logs);
71436
+ };
71437
+
71438
+ AWSCloudWatchProvider.prototype.pause = function () {
71439
+ this._processing = false;
71440
+
71441
+ if (this._timer) {
71442
+ clearInterval(this._timer);
71443
+ }
71444
+ };
71445
+
71446
+ AWSCloudWatchProvider.prototype.resume = function () {
71447
+ this._processing = true;
71448
+
71449
+ this._initiateLogPushInterval();
71450
+ };
71451
+
71452
+ AWSCloudWatchProvider.prototype.clear = function () {
71453
+ this._dataTracker.logEvents = [];
71454
+ this._currentLogBatch = [];
71348
71455
  };
71349
71456
 
71350
71457
  AWSCloudWatchProvider.prototype._validateLogGroupExistsAndCreate = function (logGroupName) {
@@ -71661,13 +71768,33 @@ function () {
71661
71768
  return __generator(this, function (_a) {
71662
71769
  switch (_a.label) {
71663
71770
  case 0:
71664
- _a.trys.push([0, 3,, 4]);
71771
+ _a.trys.push([0, 4,, 5]);
71665
71772
 
71666
71773
  return [4
71667
71774
  /*yield*/
71668
- , this._getNextSequenceToken()];
71775
+ , this._preFlightCheck()];
71669
71776
 
71670
71777
  case 1:
71778
+ /**
71779
+ * CloudWatch has restrictions on the size of the log events that get sent up.
71780
+ * We need to track both the size of each event and the total size of the batch
71781
+ * of logs.
71782
+ *
71783
+ * We also need to ensure that the logs in the batch are sorted in chronological order.
71784
+ * https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html
71785
+ */
71786
+ if (!_a.sent()) {
71787
+ this.clear();
71788
+ return [2
71789
+ /*return*/
71790
+ ];
71791
+ }
71792
+
71793
+ return [4
71794
+ /*yield*/
71795
+ , this._getNextSequenceToken()];
71796
+
71797
+ case 2:
71671
71798
  seqToken = _a.sent();
71672
71799
  logBatch = this._currentLogBatch.length === 0 ? this._getBufferedBatchOfLogs() : this._currentLogBatch;
71673
71800
  putLogsPayload = {
@@ -71681,7 +71808,7 @@ function () {
71681
71808
  /*yield*/
71682
71809
  , this._sendLogEvents(putLogsPayload)];
71683
71810
 
71684
- case 2:
71811
+ case 3:
71685
71812
  sendLogEventsResponse = _a.sent();
71686
71813
  this._nextSequenceToken = sendLogEventsResponse.nextSequenceToken;
71687
71814
  this._dataTracker.eventUploadInProgress = false;
@@ -71690,7 +71817,7 @@ function () {
71690
71817
  /*return*/
71691
71818
  , sendLogEventsResponse];
71692
71819
 
71693
- case 3:
71820
+ case 4:
71694
71821
  err_5 = _a.sent();
71695
71822
  logger.error("error during _safeUploadLogEvents: " + err_5);
71696
71823
 
@@ -71707,9 +71834,9 @@ function () {
71707
71834
 
71708
71835
  return [3
71709
71836
  /*break*/
71710
- , 4];
71837
+ , 5];
71711
71838
 
71712
- case 4:
71839
+ case 5:
71713
71840
  return [2
71714
71841
  /*return*/
71715
71842
  ];
@@ -71718,6 +71845,41 @@ function () {
71718
71845
  });
71719
71846
  };
71720
71847
 
71848
+ AWSCloudWatchProvider.prototype.truncateOversizedEvent = function (event) {
71849
+ var timestamp = event.timestamp,
71850
+ message = event.message;
71851
+ var messageJson;
71852
+
71853
+ try {
71854
+ messageJson = JSON.parse(message);
71855
+ var truncated = JSON.stringify({
71856
+ level: messageJson.level,
71857
+ "class": messageJson["class"],
71858
+ message: messageJson.message.substring(0, 500)
71859
+ });
71860
+
71861
+ if (messageJson.data != null) {
71862
+ truncated['data'] = "OBJECT SIZE EXCEEDS CLOUDWATCH EVENT LIMIT. Truncated: " + JSON.stringify(messageJson.data).substring(0, 500);
71863
+ }
71864
+
71865
+ return {
71866
+ timestamp: timestamp,
71867
+ message: truncated
71868
+ };
71869
+ } catch (error) {
71870
+ logger.warn('Could not minify oversized event', error);
71871
+ var truncated = JSON.stringify({
71872
+ level: 'UNKNOWN',
71873
+ "class": 'Unknown',
71874
+ message: 'OBJECT SIZE EXCEEDS CLOUDWATCH EVENT LIMIT. Could not parse event to truncate'
71875
+ });
71876
+ return {
71877
+ timestamp: timestamp,
71878
+ message: truncated
71879
+ };
71880
+ }
71881
+ };
71882
+
71721
71883
  AWSCloudWatchProvider.prototype._getBufferedBatchOfLogs = function () {
71722
71884
  /**
71723
71885
  * CloudWatch has restrictions on the size of the log events that get sent up.
@@ -71737,7 +71899,9 @@ function () {
71737
71899
  if (eventSize > _Util_Constants__WEBPACK_IMPORTED_MODULE_5__["AWS_CLOUDWATCH_MAX_EVENT_SIZE"]) {
71738
71900
  var errString = "Log entry exceeds maximum size for CloudWatch logs. Log size: " + eventSize + ". Truncating log message.";
71739
71901
  logger.warn(errString);
71740
- currentEvent.message = currentEvent.message.substring(0, eventSize);
71902
+ currentEvent = this.truncateOversizedEvent(currentEvent);
71903
+ this._dataTracker.logEvents[currentEventIdx] = currentEvent;
71904
+ eventSize = new TextEncoder().encode(currentEvent.message).length + _Util_Constants__WEBPACK_IMPORTED_MODULE_5__["AWS_CLOUDWATCH_BASE_BUFFER_SIZE"];
71741
71905
  }
71742
71906
 
71743
71907
  if (totalByteSize + eventSize > _Util_Constants__WEBPACK_IMPORTED_MODULE_5__["AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE"]) break;
@@ -71828,6 +71992,7 @@ function () {
71828
71992
  case 3:
71829
71993
  err_7 = _a.sent();
71830
71994
  logger.error("error when calling _safeUploadLogEvents in the timer interval - " + err_7);
71995
+ this.pause();
71831
71996
  return [3
71832
71997
  /*break*/
71833
71998
  , 4];
@@ -71839,7 +72004,7 @@ function () {
71839
72004
  }
71840
72005
  });
71841
72006
  });
71842
- }, 2000);
72007
+ }, INTERVAL);
71843
72008
  };
71844
72009
 
71845
72010
  AWSCloudWatchProvider.prototype._getDocUploadPermissibility = function () {
@@ -72871,7 +73036,7 @@ function () {
72871
73036
  /*!*****************************************!*\
72872
73037
  !*** ../core/lib-esm/Util/Constants.js ***!
72873
73038
  \*****************************************/
72874
- /*! 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 */
73039
+ /*! 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 */
72875
73040
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
72876
73041
 
72877
73042
  "use strict";
@@ -72883,6 +73048,8 @@ __webpack_require__.r(__webpack_exports__);
72883
73048
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AWS_CLOUDWATCH_PROVIDER_NAME", function() { return AWS_CLOUDWATCH_PROVIDER_NAME; });
72884
73049
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NO_CREDS_ERROR_STRING", function() { return NO_CREDS_ERROR_STRING; });
72885
73050
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RETRY_ERROR_CODES", function() { return RETRY_ERROR_CODES; });
73051
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AMAZON_KINESIS_LOGGING_PROVIDER_NAME", function() { return AMAZON_KINESIS_LOGGING_PROVIDER_NAME; });
73052
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AMAZON_KINESIS_LOGGING_CATEGORY", function() { return AMAZON_KINESIS_LOGGING_CATEGORY; });
72886
73053
  /*
72887
73054
  * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
72888
73055
  *
@@ -72896,11 +73063,14 @@ __webpack_require__.r(__webpack_exports__);
72896
73063
  * and limitations under the License.
72897
73064
  */
72898
73065
  // Logging constants
73066
+ // Cloudwatch
72899
73067
  var AWS_CLOUDWATCH_BASE_BUFFER_SIZE = 26;
72900
73068
  var AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE = 1048576;
72901
73069
  var AWS_CLOUDWATCH_MAX_EVENT_SIZE = 256000;
72902
73070
  var AWS_CLOUDWATCH_CATEGORY = 'Logging';
72903
73071
  var AWS_CLOUDWATCH_PROVIDER_NAME = 'AWSCloudWatch';
73072
+ var AMAZON_KINESIS_LOGGING_CATEGORY = 'KinesisLogging';
73073
+ var AMAZON_KINESIS_LOGGING_PROVIDER_NAME = 'AmazonKinesisLogging';
72904
73074
  var NO_CREDS_ERROR_STRING = 'No credentials';
72905
73075
  var RETRY_ERROR_CODES = ['ResourceNotFoundException', 'InvalidSequenceTokenException'];
72906
73076
 
@@ -73486,7 +73656,7 @@ function retry(functionToRetry, args, delayFn, attempt) {
73486
73656
  throw Error('functionToRetry must be a function');
73487
73657
  }
73488
73658
 
73489
- logger.debug(functionToRetry.name + " attempt #" + attempt + " with this vars: " + JSON.stringify(args));
73659
+ logger.debug(functionToRetry.name + " attempt #" + attempt + " with this vars:", args);
73490
73660
  _a.label = 1;
73491
73661
 
73492
73662
  case 1:
@@ -73603,7 +73773,7 @@ function urlSafeDecode(hex) {
73603
73773
  /*!*************************************!*\
73604
73774
  !*** ../core/lib-esm/Util/index.js ***!
73605
73775
  \*************************************/
73606
- /*! 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 */
73776
+ /*! 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 */
73607
73777
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
73608
73778
 
73609
73779
  "use strict";
@@ -73644,6 +73814,10 @@ __webpack_require__.r(__webpack_exports__);
73644
73814
 
73645
73815
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RETRY_ERROR_CODES", function() { return _Constants__WEBPACK_IMPORTED_MODULE_5__["RETRY_ERROR_CODES"]; });
73646
73816
 
73817
+ /* 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"]; });
73818
+
73819
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AMAZON_KINESIS_LOGGING_CATEGORY", function() { return _Constants__WEBPACK_IMPORTED_MODULE_5__["AMAZON_KINESIS_LOGGING_CATEGORY"]; });
73820
+
73647
73821
 
73648
73822
 
73649
73823
 
@@ -73693,7 +73867,7 @@ var USER_AGENT_HEADER = 'x-amz-user-agent';
73693
73867
  /*!********************************!*\
73694
73868
  !*** ../core/lib-esm/index.js ***!
73695
73869
  \********************************/
73696
- /*! 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 */
73870
+ /*! 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 */
73697
73871
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
73698
73872
 
73699
73873
  "use strict";
@@ -73832,6 +74006,10 @@ __webpack_require__.r(__webpack_exports__);
73832
74006
 
73833
74007
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RETRY_ERROR_CODES", function() { return _Util__WEBPACK_IMPORTED_MODULE_18__["RETRY_ERROR_CODES"]; });
73834
74008
 
74009
+ /* 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"]; });
74010
+
74011
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AMAZON_KINESIS_LOGGING_CATEGORY", function() { return _Util__WEBPACK_IMPORTED_MODULE_18__["AMAZON_KINESIS_LOGGING_CATEGORY"]; });
74012
+
73835
74013
  /*
73836
74014
  * Copyright 2017-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
73837
74015
  *
@@ -82066,7 +82244,7 @@ function defaultConflictHandler(conflictData) {
82066
82244
  }
82067
82245
 
82068
82246
  function defaultErrorHandler(error) {
82069
- logger.warn(error);
82247
+ logger.warn('DataStore Mutation Error', error);
82070
82248
  }
82071
82249
 
82072
82250
  function getModelConstructorByModelName(namespaceName, modelName) {
@@ -82279,24 +82457,32 @@ function () {
82279
82457
  case 4:
82280
82458
  _b.sent();
82281
82459
 
82460
+ logger.debug('Debug info before sync');
82282
82461
  return [4
82283
82462
  /*yield*/
82284
- , checkSchemaVersion(this.storage, schema.version)];
82463
+ , this.storage.logDebugInfo()];
82285
82464
 
82286
82465
  case 5:
82287
82466
  _b.sent();
82288
82467
 
82468
+ return [4
82469
+ /*yield*/
82470
+ , checkSchemaVersion(this.storage, schema.version)];
82471
+
82472
+ case 6:
82473
+ _b.sent();
82474
+
82289
82475
  aws_appsync_graphqlEndpoint = this.amplifyConfig.aws_appsync_graphqlEndpoint;
82290
82476
  if (!aws_appsync_graphqlEndpoint) return [3
82291
82477
  /*break*/
82292
- , 7];
82478
+ , 8];
82293
82479
  logger.debug('GraphQL endpoint available', aws_appsync_graphqlEndpoint);
82294
82480
  _a = this;
82295
82481
  return [4
82296
82482
  /*yield*/
82297
82483
  , this.processSyncExpressions()];
82298
82484
 
82299
- case 6:
82485
+ case 7:
82300
82486
  _a.syncPredicates = _b.sent();
82301
82487
  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);
82302
82488
  fullSyncIntervalInMilliseconds = this.fullSyncInterval * 1000 * 60;
@@ -82314,6 +82500,16 @@ function () {
82314
82500
  _this.initResolve();
82315
82501
  }
82316
82502
 
82503
+ if (type === _sync__WEBPACK_IMPORTED_MODULE_7__["ControlMessage"].SYNC_ENGINE_SYNC_QUERIES_READY) {
82504
+ logger.debug('Debug info after sync');
82505
+
82506
+ _this.storage.logDebugInfo();
82507
+ }
82508
+
82509
+ logger.debug({
82510
+ event: type,
82511
+ data: data
82512
+ });
82317
82513
  _aws_amplify_core__WEBPACK_IMPORTED_MODULE_0__["Hub"].dispatch('datastore', {
82318
82514
  event: type,
82319
82515
  data: data
@@ -82327,21 +82523,21 @@ function () {
82327
82523
  });
82328
82524
  return [3
82329
82525
  /*break*/
82330
- , 8];
82526
+ , 9];
82331
82527
 
82332
- case 7:
82528
+ case 8:
82333
82529
  logger.warn("Data won't be synchronized. No GraphQL endpoint configured. Did you forget `Amplify.configure(awsconfig)`?", {
82334
82530
  config: this.amplifyConfig
82335
82531
  });
82336
82532
  this.initResolve();
82337
- _b.label = 8;
82533
+ _b.label = 9;
82338
82534
 
82339
- case 8:
82535
+ case 9:
82340
82536
  return [4
82341
82537
  /*yield*/
82342
82538
  , this.initialized];
82343
82539
 
82344
- case 9:
82540
+ case 10:
82345
82541
  _b.sent();
82346
82542
 
82347
82543
  return [2
@@ -89337,6 +89533,33 @@ function () {
89337
89533
  });
89338
89534
  };
89339
89535
 
89536
+ StorageClass.prototype.logDebugInfo = function () {
89537
+ return __awaiter(this, void 0, void 0, function () {
89538
+ var results;
89539
+ return __generator(this, function (_a) {
89540
+ switch (_a.label) {
89541
+ case 0:
89542
+ if (!(typeof this.adapter.getDebugInfo === 'function')) return [3
89543
+ /*break*/
89544
+ , 2];
89545
+ return [4
89546
+ /*yield*/
89547
+ , this.adapter.getDebugInfo()];
89548
+
89549
+ case 1:
89550
+ results = _a.sent();
89551
+ logger.debug('DB Debug Info', results);
89552
+ _a.label = 2;
89553
+
89554
+ case 2:
89555
+ return [2
89556
+ /*return*/
89557
+ ];
89558
+ }
89559
+ });
89560
+ });
89561
+ };
89562
+
89340
89563
  return StorageClass;
89341
89564
  }();
89342
89565
 
@@ -89442,6 +89665,18 @@ function () {
89442
89665
  return this.storage.batchSave(modelConstructor, items);
89443
89666
  };
89444
89667
 
89668
+ ExclusiveStorage.prototype.logDebugInfo = function () {
89669
+ return __awaiter(this, void 0, void 0, function () {
89670
+ return __generator(this, function (_a) {
89671
+ return [2
89672
+ /*return*/
89673
+ , this.runExclusive(function (storage) {
89674
+ return storage.logDebugInfo();
89675
+ })];
89676
+ });
89677
+ });
89678
+ };
89679
+
89445
89680
  ExclusiveStorage.prototype.init = function () {
89446
89681
  return __awaiter(this, void 0, void 0, function () {
89447
89682
  return __generator(this, function (_a) {
@@ -90052,6 +90287,12 @@ function () {
90052
90287
  isEmpty: !hasMore
90053
90288
  }
90054
90289
  });
90290
+
90291
+ if (!hasMore) {
90292
+ logger.debug('Debug info after queue drained');
90293
+
90294
+ _this.storage.logDebugInfo();
90295
+ }
90055
90296
  })); //#endregion
90056
90297
  //#region Merge subscriptions buffer
90057
90298
  // TODO: extract to function
@@ -90075,26 +90316,34 @@ function () {
90075
90316
 
90076
90317
  return [3
90077
90318
  /*break*/
90078
- , 11];
90319
+ , 12];
90079
90320
 
90080
90321
  case 10:
90081
- if (!online) {
90082
- this.online = online;
90083
- observer.next({
90084
- type: ControlMessage.SYNC_ENGINE_NETWORK_STATUS,
90085
- data: {
90086
- active: this.online
90087
- }
90088
- });
90089
- subscriptions.forEach(function (sub) {
90090
- return sub.unsubscribe();
90091
- });
90092
- subscriptions = [];
90093
- }
90094
-
90095
- _c.label = 11;
90322
+ if (!!online) return [3
90323
+ /*break*/
90324
+ , 12];
90325
+ this.online = online;
90326
+ observer.next({
90327
+ type: ControlMessage.SYNC_ENGINE_NETWORK_STATUS,
90328
+ data: {
90329
+ active: this.online
90330
+ }
90331
+ });
90332
+ logger.debug('Debug info after offline');
90333
+ return [4
90334
+ /*yield*/
90335
+ , this.storage.logDebugInfo()];
90096
90336
 
90097
90337
  case 11:
90338
+ _c.sent();
90339
+
90340
+ subscriptions.forEach(function (sub) {
90341
+ return sub.unsubscribe();
90342
+ });
90343
+ subscriptions = [];
90344
+ _c.label = 12;
90345
+
90346
+ case 12:
90098
90347
  resolve();
90099
90348
  return [2
90100
90349
  /*return*/
@@ -92591,6 +92840,7 @@ function () {
92591
92840
  /*yield*/
92592
92841
  , this.errorHandler({
92593
92842
  localModel: this.modelInstanceCreator(modelConstructor, variables.input),
92843
+ modelName: model,
92594
92844
  message: error.message,
92595
92845
  operation: operation,
92596
92846
  errorType: error.errorType,