@aws-amplify/datastore 3.11.2 → 3.11.4-geo.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.11.3](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.11.2...@aws-amplify/datastore@3.11.3) (2022-05-24)
7
+
8
+ **Note:** Version bump only for package @aws-amplify/datastore
9
+
10
+
11
+
12
+
13
+
6
14
  ## [3.11.2](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.11.1...@aws-amplify/datastore@3.11.2) (2022-05-23)
7
15
 
8
16
 
@@ -52736,7 +52736,7 @@ function _wrapNativeSuper(Class) {
52736
52736
 
52737
52737
  function _construct(Parent, args, Class) {
52738
52738
  if (_isNativeReflectConstruct()) {
52739
- _construct = Reflect.construct;
52739
+ _construct = Reflect.construct.bind();
52740
52740
  } else {
52741
52741
  _construct = function _construct(Parent, args, Class) {
52742
52742
  var a = [null];
@@ -52769,16 +52769,15 @@ function _isNativeFunction(fn) {
52769
52769
  }
52770
52770
 
52771
52771
  function _setPrototypeOf(o, p) {
52772
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
52772
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
52773
52773
  o.__proto__ = p;
52774
52774
  return o;
52775
52775
  };
52776
-
52777
52776
  return _setPrototypeOf(o, p);
52778
52777
  }
52779
52778
 
52780
52779
  function _getPrototypeOf(o) {
52781
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
52780
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
52782
52781
  return o.__proto__ || Object.getPrototypeOf(o);
52783
52782
  };
52784
52783
  return _getPrototypeOf(o);
@@ -53046,11 +53045,10 @@ function _inheritsLoose(subClass, superClass) {
53046
53045
  }
53047
53046
 
53048
53047
  function _setPrototypeOf(o, p) {
53049
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
53048
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
53050
53049
  o.__proto__ = p;
53051
53050
  return o;
53052
53051
  };
53053
-
53054
53052
  return _setPrototypeOf(o, p);
53055
53053
  }
53056
53054
  /*!
@@ -53103,11 +53101,10 @@ function _inheritsLoose(subClass, superClass) {
53103
53101
  }
53104
53102
 
53105
53103
  function _setPrototypeOf(o, p) {
53106
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
53104
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
53107
53105
  o.__proto__ = p;
53108
53106
  return o;
53109
53107
  };
53110
-
53111
53108
  return _setPrototypeOf(o, p);
53112
53109
  }
53113
53110
  /*!
@@ -71163,7 +71160,7 @@ var getAmplifyUserAgent = function getAmplifyUserAgent() {
71163
71160
  __webpack_require__.r(__webpack_exports__);
71164
71161
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "version", function() { return version; });
71165
71162
  // generated by genversion
71166
- var version = '4.5.4';
71163
+ var version = '4.5.6';
71167
71164
 
71168
71165
  /***/ }),
71169
71166
 
@@ -82316,10 +82313,21 @@ var createModelClass = function createModelClass(modelDefinition) {
82316
82313
  }, function (p) {
82317
82314
  return patches = p;
82318
82315
  });
82316
+ var hasExistingPatches = modelPatchesMap.has(source);
82319
82317
 
82320
- if (patches.length) {
82321
- modelPatchesMap.set(model, [patches, source]);
82322
- checkReadOnlyPropertyOnUpdate(patches, modelDefinition);
82318
+ if (patches.length || hasExistingPatches) {
82319
+ if (hasExistingPatches) {
82320
+ var _a = __read(modelPatchesMap.get(source), 2),
82321
+ existingPatches = _a[0],
82322
+ existingSource = _a[1];
82323
+
82324
+ var mergedPatches = Object(_util__WEBPACK_IMPORTED_MODULE_9__["mergePatches"])(existingSource, existingPatches, patches);
82325
+ modelPatchesMap.set(model, [mergedPatches, existingSource]);
82326
+ checkReadOnlyPropertyOnUpdate(mergedPatches, modelDefinition);
82327
+ } else {
82328
+ modelPatchesMap.set(model, [patches, source]);
82329
+ checkReadOnlyPropertyOnUpdate(patches, modelDefinition);
82330
+ }
82323
82331
  }
82324
82332
 
82325
82333
  return model;
@@ -83029,6 +83037,8 @@ function () {
83029
83037
 
83030
83038
  (function () {
83031
83039
  return __awaiter(_this, void 0, void 0, function () {
83040
+ var _this = this;
83041
+
83032
83042
  return __generator(this, function (_a) {
83033
83043
  switch (_a.label) {
83034
83044
  case 0:
@@ -83044,24 +83054,44 @@ function () {
83044
83054
  handle = this.storage.observe(modelConstructor, predicate).filter(function (_a) {
83045
83055
  var model = _a.model;
83046
83056
  return namespaceResolver(model) === _util__WEBPACK_IMPORTED_MODULE_9__["USER"];
83047
- }).map(function (event) {
83048
- // The `element` returned by storage only contains updated fields.
83049
- // Intercept the event to send the `savedElement` so that the first
83050
- // snapshot returned to the consumer contains all fields.
83051
- // In the event of a delete we return `element`, as `savedElement`
83052
- // here is undefined.
83053
- var opType = event.opType,
83054
- model = event.model,
83055
- condition = event.condition,
83056
- element = event.element,
83057
- savedElement = event.savedElement;
83058
- return {
83059
- opType: opType,
83060
- element: savedElement || element,
83061
- model: model,
83062
- condition: condition
83063
- };
83064
- }).subscribe(observer);
83057
+ }).subscribe({
83058
+ next: function next(item) {
83059
+ return __awaiter(_this, void 0, void 0, function () {
83060
+ var message, freshElement;
83061
+ return __generator(this, function (_a) {
83062
+ switch (_a.label) {
83063
+ case 0:
83064
+ message = item;
83065
+ if (!(item.opType !== 'DELETE')) return [3
83066
+ /*break*/
83067
+ , 2];
83068
+ return [4
83069
+ /*yield*/
83070
+ , this.query(item.model, item.element.id)];
83071
+
83072
+ case 1:
83073
+ freshElement = _a.sent();
83074
+ message = __assign(__assign({}, message), {
83075
+ element: freshElement
83076
+ });
83077
+ _a.label = 2;
83078
+
83079
+ case 2:
83080
+ observer.next(message);
83081
+ return [2
83082
+ /*return*/
83083
+ ];
83084
+ }
83085
+ });
83086
+ });
83087
+ },
83088
+ error: function error(err) {
83089
+ return observer.error(err);
83090
+ },
83091
+ complete: function complete() {
83092
+ return observer.complete();
83093
+ }
83094
+ });
83065
83095
  return [2
83066
83096
  /*return*/
83067
83097
  ];
@@ -83084,6 +83114,17 @@ function () {
83084
83114
  var itemsChanged = new Map();
83085
83115
  var deletedItemIds = [];
83086
83116
  var handle;
83117
+ var predicate;
83118
+ /**
83119
+ * As the name suggests, this geneates a snapshot in the form of
83120
+ * `{items: T[], isSynced: boolean}`
83121
+ * and sends it to the observer.
83122
+ *
83123
+ * SIDE EFFECT: The underlying generation and emission methods may touch:
83124
+ * `items`, `itemsChanged`, and `deletedItemIds`.
83125
+ *
83126
+ * Refer to `generateSnapshot` and `emitSnapshot` for more details.
83127
+ */
83087
83128
 
83088
83129
  var generateAndEmitSnapshot = function generateAndEmitSnapshot() {
83089
83130
  var snapshot = generateSnapshot();
@@ -83101,6 +83142,24 @@ function () {
83101
83142
  var sortOptions = sort ? {
83102
83143
  sort: sort
83103
83144
  } : undefined;
83145
+ var modelDefinition = getModelDefinition(model);
83146
+
83147
+ if (isQueryOne(criteria)) {
83148
+ predicate = _predicates__WEBPACK_IMPORTED_MODULE_5__["ModelPredicateCreator"].createForId(modelDefinition, criteria);
83149
+ } else {
83150
+ if (Object(_predicates__WEBPACK_IMPORTED_MODULE_5__["isPredicatesAll"])(criteria)) {
83151
+ // Predicates.ALL means "all records", so no predicate (undefined)
83152
+ predicate = undefined;
83153
+ } else {
83154
+ predicate = _predicates__WEBPACK_IMPORTED_MODULE_5__["ModelPredicateCreator"].createFromExisting(modelDefinition, criteria);
83155
+ }
83156
+ }
83157
+
83158
+ var _a = _predicates__WEBPACK_IMPORTED_MODULE_5__["ModelPredicateCreator"].getPredicates(predicate, false) || {},
83159
+ predicates = _a.predicates,
83160
+ predicateGroupType = _a.type;
83161
+
83162
+ var hasPredicate = !!predicates;
83104
83163
 
83105
83164
  (function () {
83106
83165
  return __awaiter(_this, void 0, void 0, function () {
@@ -83121,16 +83180,31 @@ function () {
83121
83180
  // first, query and return any locally-available records
83122
83181
  _a.sent().forEach(function (item) {
83123
83182
  return items.set(item.id, item);
83124
- }); // observe the model and send a stream of updates (debounced)
83183
+ }); // Observe the model and send a stream of updates (debounced).
83184
+ // We need to post-filter results instead of passing criteria through
83185
+ // to have visibility into items that move from in-set to out-of-set.
83186
+ // We need to explicitly remove those items from the existing snapshot.
83125
83187
 
83126
83188
 
83127
- handle = this.observe(model, // @ts-ignore TODO: fix this TSlint error
83128
- criteria).subscribe(function (_a) {
83189
+ handle = this.observe(model).subscribe(function (_a) {
83129
83190
  var element = _a.element,
83130
83191
  model = _a.model,
83131
83192
  opType = _a.opType;
83132
83193
 
83133
- var _b, _c; // Flag items which have been recently deleted
83194
+ var _b, _c;
83195
+
83196
+ if (hasPredicate && !Object(_util__WEBPACK_IMPORTED_MODULE_9__["validatePredicate"])(element, predicateGroupType, predicates)) {
83197
+ if (opType === 'UPDATE' && (items.has(element.id) || itemsChanged.has(element.id))) {
83198
+ // tracking as a "deleted item" will include the item in
83199
+ // page limit calculations and ensure it is removed from the
83200
+ // final items collection, regardless of which collection(s)
83201
+ // it is currently in. (I mean, it could be in both, right!?)
83202
+ deletedItemIds.push(element.id);
83203
+ } else {
83204
+ // ignore updates for irrelevant/filtered items.
83205
+ return;
83206
+ }
83207
+ } // Flag items which have been recently deleted
83134
83208
  // NOTE: Merging of separate operations to the same model instance is handled upstream
83135
83209
  // in the `mergePage` method within src/sync/merger.ts. The final state of a model instance
83136
83210
  // depends on the LATEST record (for a given id).
@@ -83172,7 +83246,13 @@ function () {
83172
83246
  }
83173
83247
  });
83174
83248
  });
83175
- })(); // TODO: abstract this function into a util file to be able to write better unit tests
83249
+ })();
83250
+ /**
83251
+ * Combines the `items`, `itemsChanged`, and `deletedItemIds` collections into
83252
+ * a snapshot in the form of `{ items: T[], isSynced: boolean}`.
83253
+ *
83254
+ * SIDE EFFECT: The shared `items` collection is recreated.
83255
+ */
83176
83256
 
83177
83257
 
83178
83258
  var generateSnapshot = function generateSnapshot() {
@@ -83199,6 +83279,15 @@ function () {
83199
83279
  isSynced: isSynced
83200
83280
  };
83201
83281
  };
83282
+ /**
83283
+ * Emits the list of items to the observer.
83284
+ *
83285
+ * SIDE EFFECT: `itemsChanged` and `deletedItemIds` are cleared to prepare
83286
+ * for the next snapshot.
83287
+ *
83288
+ * @param snapshot The generated items data to emit.
83289
+ */
83290
+
83202
83291
 
83203
83292
  var emitSnapshot = function emitSnapshot(snapshot) {
83204
83293
  // send the generated snapshot to the primary subscription
@@ -83207,6 +83296,13 @@ function () {
83207
83296
  itemsChanged.clear();
83208
83297
  deletedItemIds = [];
83209
83298
  };
83299
+ /**
83300
+ * Sorts an `Array` of `T` according to the sort instructions given in the
83301
+ * original `observeQuery()` call.
83302
+ *
83303
+ * @param itemsToSort A array of model type.
83304
+ */
83305
+
83210
83306
 
83211
83307
  var sortItems = function sortItems(itemsToSort) {
83212
83308
  var modelDefinition = getModelDefinition(model);
@@ -83219,7 +83315,15 @@ function () {
83219
83315
  var compareFn = Object(_util__WEBPACK_IMPORTED_MODULE_9__["sortCompareFunction"])(sortPredicates);
83220
83316
  itemsToSort.sort(compareFn);
83221
83317
  }
83222
- }; // send one last snapshot when the model is fully synced
83318
+ };
83319
+ /**
83320
+ * Force one last snapshot when the model is fully synced.
83321
+ *
83322
+ * This reduces latency for that last snapshot, which will otherwise
83323
+ * wait for the configured timeout.
83324
+ *
83325
+ * @param payload The payload from the Hub event.
83326
+ */
83223
83327
 
83224
83328
 
83225
83329
  var hubCallback = function hubCallback(_a) {
@@ -92384,57 +92488,85 @@ var __values = undefined && undefined.__values || function (o) {
92384
92488
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
92385
92489
  };
92386
92490
 
92491
+ var connectionTimeout = function connectionTimeout(error) {
92492
+ return /^Connection failed: Connection Timeout/.test(error.message);
92493
+ };
92494
+
92495
+ var serverError = function serverError(error) {
92496
+ return /^Error: Request failed with status code 5\d\d/.test(error.message);
92497
+ };
92498
+
92387
92499
  var mutationErrorMap = {
92500
+ BadModel: function BadModel() {
92501
+ return false;
92502
+ },
92388
92503
  BadRecord: function BadRecord(error) {
92389
- return /^Cannot return \w+ for [\w-_]+ type/.test(error.message);
92504
+ var message = error.message;
92505
+ return /^Cannot return \w+ for [\w-_]+ type/.test(message) || /^Variable '.+' has coerced Null value for NonNull type/.test(message); // newly required field, out of date client
92390
92506
  },
92391
92507
  ConfigError: function ConfigError() {
92392
92508
  return false;
92393
92509
  },
92394
- Transient: function Transient() {
92395
- return false;
92510
+ Transient: function Transient(error) {
92511
+ return connectionTimeout(error) || serverError(error);
92396
92512
  },
92397
- Unauthorized: function Unauthorized() {
92398
- return false;
92513
+ Unauthorized: function Unauthorized(error) {
92514
+ return /^Request failed with status code 401/.test(error.message);
92399
92515
  }
92400
92516
  };
92401
92517
  var subscriptionErrorMap = {
92518
+ BadModel: function BadModel() {
92519
+ return false;
92520
+ },
92402
92521
  BadRecord: function BadRecord() {
92403
92522
  return false;
92404
92523
  },
92405
92524
  ConfigError: function ConfigError() {
92406
92525
  return false;
92407
92526
  },
92408
- Transient: function Transient() {
92409
- return false;
92527
+ Transient: function Transient(observableError) {
92528
+ var error = unwrapObservableError(observableError);
92529
+ return connectionTimeout(error) || serverError(error);
92410
92530
  },
92411
- Unauthorized: function Unauthorized(givenError) {
92412
- var _a = givenError.error,
92413
- _b = __read((_a === void 0 ? {
92414
- errors: []
92415
- } : _a).errors, 1),
92416
- _c = _b[0],
92417
- _d = (_c === void 0 ? {} : _c).message,
92418
- message = _d === void 0 ? '' : _d;
92419
-
92420
- var regex = /Connection failed.+Unauthorized/;
92421
- return regex.test(message);
92531
+ Unauthorized: function Unauthorized(observableError) {
92532
+ var error = unwrapObservableError(observableError);
92533
+ return /Connection failed.+Unauthorized/.test(error.message);
92422
92534
  }
92423
92535
  };
92424
92536
  var syncErrorMap = {
92537
+ BadModel: function BadModel() {
92538
+ return false;
92539
+ },
92425
92540
  BadRecord: function BadRecord(error) {
92426
92541
  return /^Cannot return \w+ for [\w-_]+ type/.test(error.message);
92427
92542
  },
92428
92543
  ConfigError: function ConfigError() {
92429
92544
  return false;
92430
92545
  },
92431
- Transient: function Transient() {
92432
- return false;
92546
+ Transient: function Transient(error) {
92547
+ return connectionTimeout(error) || serverError(error);
92433
92548
  },
92434
92549
  Unauthorized: function Unauthorized() {
92435
92550
  return false;
92436
92551
  }
92437
92552
  };
92553
+ /**
92554
+ * Get the first error reason of an observable.
92555
+ * Allows for error maps to be easily applied to observable errors
92556
+ *
92557
+ * @param observableError an error from ZenObservable subscribe error callback
92558
+ */
92559
+
92560
+ function unwrapObservableError(observableError) {
92561
+ var _a = observableError.error,
92562
+ _b = __read((_a === void 0 ? {
92563
+ errors: []
92564
+ } : _a).errors, 1),
92565
+ error = _b[0];
92566
+
92567
+ return error;
92568
+ }
92569
+
92438
92570
  function getMutationErrorType(error) {
92439
92571
  return mapErrorToType(mutationErrorMap, error);
92440
92572
  }
@@ -96172,7 +96304,7 @@ var LimitTimerRaceResolvedValues;
96172
96304
  /*!*************************!*\
96173
96305
  !*** ./lib-esm/util.js ***!
96174
96306
  \*************************/
96175
- /*! exports provided: exhaustiveCheck, isNullOrUndefined, validatePredicate, validatePredicateField, isModelConstructor, registerNonModelClass, isNonModelConstructor, processCompositeKeys, establishRelationAndKeys, traverseModel, getIndex, getIndexFromAssociation, NAMESPACES, USER, SYNC, STORAGE, DATASTORE, isPrivateMode, monotonicUlidFactory, getNow, sortCompareFunction, valuesEqual, isAWSDate, isAWSTime, isAWSDateTime, isAWSTimestamp, isAWSEmail, isAWSJSON, isAWSURL, isAWSPhone, isAWSIPAddress, DeferredPromise, DeferredCallbackResolver */
96307
+ /*! exports provided: exhaustiveCheck, isNullOrUndefined, validatePredicate, validatePredicateField, isModelConstructor, registerNonModelClass, isNonModelConstructor, processCompositeKeys, establishRelationAndKeys, traverseModel, getIndex, getIndexFromAssociation, NAMESPACES, USER, SYNC, STORAGE, DATASTORE, isPrivateMode, monotonicUlidFactory, getNow, sortCompareFunction, valuesEqual, isAWSDate, isAWSTime, isAWSDateTime, isAWSTimestamp, isAWSEmail, isAWSJSON, isAWSURL, isAWSPhone, isAWSIPAddress, DeferredPromise, DeferredCallbackResolver, mergePatches */
96176
96308
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
96177
96309
 
96178
96310
  "use strict";
@@ -96210,13 +96342,15 @@ __webpack_require__.r(__webpack_exports__);
96210
96342
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isAWSIPAddress", function() { return isAWSIPAddress; });
96211
96343
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeferredPromise", function() { return DeferredPromise; });
96212
96344
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeferredCallbackResolver", function() { return DeferredCallbackResolver; });
96345
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mergePatches", function() { return mergePatches; });
96213
96346
  /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js");
96214
96347
  /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(buffer__WEBPACK_IMPORTED_MODULE_0__);
96215
96348
  /* harmony import */ var ulid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ulid */ "../../node_modules/ulid/dist/index.esm.js");
96216
96349
  /* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uuid */ "./node_modules/uuid/index.js");
96217
96350
  /* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(uuid__WEBPACK_IMPORTED_MODULE_2__);
96218
- /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./types */ "./lib-esm/types.js");
96219
- /* harmony import */ var amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! amazon-cognito-identity-js */ "../amazon-cognito-identity-js/es/index.js");
96351
+ /* harmony import */ var immer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! immer */ "./node_modules/immer/dist/immer.esm.js");
96352
+ /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./types */ "./lib-esm/types.js");
96353
+ /* harmony import */ var amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! amazon-cognito-identity-js */ "../amazon-cognito-identity-js/es/index.js");
96220
96354
  function _typeof(obj) {
96221
96355
  "@babel/helpers - typeof";
96222
96356
 
@@ -96427,6 +96561,7 @@ var __values = undefined && undefined.__values || function (o) {
96427
96561
 
96428
96562
 
96429
96563
 
96564
+
96430
96565
  var exhaustiveCheck = function exhaustiveCheck(obj, throwOnError) {
96431
96566
  if (throwOnError === void 0) {
96432
96567
  throwOnError = true;
@@ -96466,7 +96601,7 @@ var validatePredicate = function validatePredicate(model, groupType, predicatesO
96466
96601
  }
96467
96602
 
96468
96603
  var result = predicatesOrGroups[filterType](function (predicateOrGroup) {
96469
- if (Object(_types__WEBPACK_IMPORTED_MODULE_3__["isPredicateObj"])(predicateOrGroup)) {
96604
+ if (Object(_types__WEBPACK_IMPORTED_MODULE_4__["isPredicateObj"])(predicateOrGroup)) {
96470
96605
  var field = predicateOrGroup.field,
96471
96606
  operator = predicateOrGroup.operator,
96472
96607
  operand = predicateOrGroup.operand;
@@ -96474,7 +96609,7 @@ var validatePredicate = function validatePredicate(model, groupType, predicatesO
96474
96609
  return validatePredicateField(value, operator, operand);
96475
96610
  }
96476
96611
 
96477
- if (Object(_types__WEBPACK_IMPORTED_MODULE_3__["isPredicateGroup"])(predicateOrGroup)) {
96612
+ if (Object(_types__WEBPACK_IMPORTED_MODULE_4__["isPredicateGroup"])(predicateOrGroup)) {
96478
96613
  var type = predicateOrGroup.type,
96479
96614
  predicates = predicateOrGroup.predicates;
96480
96615
  return validatePredicate(model, type, predicates);
@@ -96577,7 +96712,7 @@ var processCompositeKeys = function processCompositeKeys(attributes) {
96577
96712
  return sortKeyFields;
96578
96713
  };
96579
96714
 
96580
- var compositeKeyFields = attributes.filter(_types__WEBPACK_IMPORTED_MODULE_3__["isModelAttributeCompositeKey"]).map(extractCompositeSortKey);
96715
+ var compositeKeyFields = attributes.filter(_types__WEBPACK_IMPORTED_MODULE_4__["isModelAttributeCompositeKey"]).map(extractCompositeSortKey);
96581
96716
  /*
96582
96717
  if 2 sets of fields have any intersecting fields => combine them into 1 union set
96583
96718
  e.g., ['a', 'b', 'c'] and ['a', 'b', 'd'] => ['a', 'b', 'c', 'd']
@@ -96656,11 +96791,11 @@ var establishRelationAndKeys = function establishRelationAndKeys(namespace) {
96656
96791
  for (var _e = __values(model.attributes), _f = _e.next(); !_f.done; _f = _e.next()) {
96657
96792
  var attribute = _f.value;
96658
96793
 
96659
- if (!Object(_types__WEBPACK_IMPORTED_MODULE_3__["isModelAttributeKey"])(attribute)) {
96794
+ if (!Object(_types__WEBPACK_IMPORTED_MODULE_4__["isModelAttributeKey"])(attribute)) {
96660
96795
  continue;
96661
96796
  }
96662
96797
 
96663
- if (Object(_types__WEBPACK_IMPORTED_MODULE_3__["isModelAttributePrimaryKey"])(attribute)) {
96798
+ if (Object(_types__WEBPACK_IMPORTED_MODULE_4__["isModelAttributePrimaryKey"])(attribute)) {
96664
96799
  keys[mKey].primaryKey = attribute.properties.fields;
96665
96800
  }
96666
96801
 
@@ -96887,7 +97022,7 @@ var isPrivateMode = function isPrivateMode() {
96887
97022
  };
96888
97023
 
96889
97024
  var randomBytes = function randomBytes(nBytes) {
96890
- return buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].from(new amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_4__["WordArray"]().random(nBytes).toString(), 'hex');
97025
+ return buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].from(new amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_5__["WordArray"]().random(nBytes).toString(), 'hex');
96891
97026
  };
96892
97027
 
96893
97028
  var prng = function prng() {
@@ -96932,7 +97067,7 @@ function sortCompareFunction(sortPredicates) {
96932
97067
  var field = predicate.field,
96933
97068
  sortDirection = predicate.sortDirection; // reverse result when direction is descending
96934
97069
 
96935
- var sortMultiplier = sortDirection === _types__WEBPACK_IMPORTED_MODULE_3__["SortDirection"].ASCENDING ? 1 : -1;
97070
+ var sortMultiplier = sortDirection === _types__WEBPACK_IMPORTED_MODULE_4__["SortDirection"].ASCENDING ? 1 : -1;
96936
97071
 
96937
97072
  if (a[field] < b[field]) {
96938
97073
  return -1 * sortMultiplier;
@@ -97121,7 +97256,7 @@ function () {
97121
97256
 
97122
97257
  this.timerPromise = new Promise(function (resolve, reject) {
97123
97258
  _this.timer = setTimeout(function () {
97124
- resolve(_types__WEBPACK_IMPORTED_MODULE_3__["LimitTimerRaceResolvedValues"].TIMER);
97259
+ resolve(_types__WEBPACK_IMPORTED_MODULE_4__["LimitTimerRaceResolvedValues"].TIMER);
97125
97260
  }, _this.maxInterval);
97126
97261
  });
97127
97262
  };
@@ -97181,13 +97316,41 @@ function () {
97181
97316
  };
97182
97317
 
97183
97318
  DeferredCallbackResolver.prototype.resolve = function () {
97184
- this.limitPromise.resolve(_types__WEBPACK_IMPORTED_MODULE_3__["LimitTimerRaceResolvedValues"].LIMIT);
97319
+ this.limitPromise.resolve(_types__WEBPACK_IMPORTED_MODULE_4__["LimitTimerRaceResolvedValues"].LIMIT);
97185
97320
  };
97186
97321
 
97187
97322
  return DeferredCallbackResolver;
97188
97323
  }();
97189
97324
 
97190
97325
 
97326
+ /**
97327
+ * merge two sets of patches created by immer produce.
97328
+ * newPatches take precedent over oldPatches for patches modifying the same path.
97329
+ * In the case many consecutive pathces are merged the original model should
97330
+ * always be the root model.
97331
+ *
97332
+ * Example:
97333
+ * A -> B, patches1
97334
+ * B -> C, patches2
97335
+ *
97336
+ * mergePatches(A, patches1, patches2) to get patches for A -> C
97337
+ *
97338
+ * @param originalSource the original Model the patches should be applied to
97339
+ * @param oldPatches immer produce patch list
97340
+ * @param newPatches immer produce patch list (will take precedence)
97341
+ * @return merged patches
97342
+ */
97343
+
97344
+ function mergePatches(originalSource, oldPatches, newPatches) {
97345
+ var patchesToMerge = oldPatches.concat(newPatches);
97346
+ var patches;
97347
+ Object(immer__WEBPACK_IMPORTED_MODULE_3__["produce"])(originalSource, function (draft) {
97348
+ Object(immer__WEBPACK_IMPORTED_MODULE_3__["applyPatches"])(draft, patchesToMerge);
97349
+ }, function (p) {
97350
+ patches = p;
97351
+ });
97352
+ return patches;
97353
+ }
97191
97354
 
97192
97355
  /***/ }),
97193
97356