@aws-amplify/datastore 3.11.4-unstable.2 → 3.12.1-unstable.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
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.12.0](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.11.3...@aws-amplify/datastore@3.12.0) (2022-06-15)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **@aws-amplify/datastore:** adds missing fields to items sent through observe/observeQuery ([#9973](https://github.com/aws-amplify/amplify-js/issues/9973)) ([ca2a11b](https://github.com/aws-amplify/amplify-js/commit/ca2a11b5bc987e71ce3344058a4886bf067cb17b))
12
+ * merge patches for consecutive copyOf ([#9936](https://github.com/aws-amplify/amplify-js/issues/9936)) ([d5dd9cb](https://github.com/aws-amplify/amplify-js/commit/d5dd9cb5bf46131fb046cfe55e4899444f9d789e))
13
+ * **@aws-amplify/datastore:** fixes observeQuery not removing newly-filtered items from snapshot ([#9879](https://github.com/aws-amplify/amplify-js/issues/9879)) ([d1356b1](https://github.com/aws-amplify/amplify-js/commit/d1356b1e498eb71a4902892afbb41f6ff88abb6f))
14
+
15
+
16
+ ### Features
17
+
18
+ * **datastore:** add error maps for error handler ([#9918](https://github.com/aws-amplify/amplify-js/issues/9918)) ([3a27096](https://github.com/aws-amplify/amplify-js/commit/3a270969b6e097eeed73368091ace191cbc05511))
19
+
20
+
21
+
22
+
23
+
6
24
  ## [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
25
 
8
26
  **Note:** Version bump only for package @aws-amplify/datastore
@@ -71160,7 +71160,7 @@ var getAmplifyUserAgent = function getAmplifyUserAgent() {
71160
71160
  __webpack_require__.r(__webpack_exports__);
71161
71161
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "version", function() { return version; });
71162
71162
  // generated by genversion
71163
- var version = '4.5.6';
71163
+ var version = '4.5.7';
71164
71164
 
71165
71165
  /***/ }),
71166
71166
 
@@ -82313,10 +82313,21 @@ var createModelClass = function createModelClass(modelDefinition) {
82313
82313
  }, function (p) {
82314
82314
  return patches = p;
82315
82315
  });
82316
+ var hasExistingPatches = modelPatchesMap.has(source);
82316
82317
 
82317
- if (patches.length) {
82318
- modelPatchesMap.set(model, [patches, source]);
82319
- 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
+ }
82320
82331
  }
82321
82332
 
82322
82333
  return model;
@@ -83026,6 +83037,8 @@ function () {
83026
83037
 
83027
83038
  (function () {
83028
83039
  return __awaiter(_this, void 0, void 0, function () {
83040
+ var _this = this;
83041
+
83029
83042
  return __generator(this, function (_a) {
83030
83043
  switch (_a.label) {
83031
83044
  case 0:
@@ -83041,24 +83054,44 @@ function () {
83041
83054
  handle = this.storage.observe(modelConstructor, predicate).filter(function (_a) {
83042
83055
  var model = _a.model;
83043
83056
  return namespaceResolver(model) === _util__WEBPACK_IMPORTED_MODULE_9__["USER"];
83044
- }).map(function (event) {
83045
- // The `element` returned by storage only contains updated fields.
83046
- // Intercept the event to send the `savedElement` so that the first
83047
- // snapshot returned to the consumer contains all fields.
83048
- // In the event of a delete we return `element`, as `savedElement`
83049
- // here is undefined.
83050
- var opType = event.opType,
83051
- model = event.model,
83052
- condition = event.condition,
83053
- element = event.element,
83054
- savedElement = event.savedElement;
83055
- return {
83056
- opType: opType,
83057
- element: savedElement || element,
83058
- model: model,
83059
- condition: condition
83060
- };
83061
- }).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
+ });
83062
83095
  return [2
83063
83096
  /*return*/
83064
83097
  ];
@@ -83081,6 +83114,17 @@ function () {
83081
83114
  var itemsChanged = new Map();
83082
83115
  var deletedItemIds = [];
83083
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
+ */
83084
83128
 
83085
83129
  var generateAndEmitSnapshot = function generateAndEmitSnapshot() {
83086
83130
  var snapshot = generateSnapshot();
@@ -83098,6 +83142,24 @@ function () {
83098
83142
  var sortOptions = sort ? {
83099
83143
  sort: sort
83100
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;
83101
83163
 
83102
83164
  (function () {
83103
83165
  return __awaiter(_this, void 0, void 0, function () {
@@ -83118,16 +83180,31 @@ function () {
83118
83180
  // first, query and return any locally-available records
83119
83181
  _a.sent().forEach(function (item) {
83120
83182
  return items.set(item.id, item);
83121
- }); // 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.
83122
83187
 
83123
83188
 
83124
- handle = this.observe(model, // @ts-ignore TODO: fix this TSlint error
83125
- criteria).subscribe(function (_a) {
83189
+ handle = this.observe(model).subscribe(function (_a) {
83126
83190
  var element = _a.element,
83127
83191
  model = _a.model,
83128
83192
  opType = _a.opType;
83129
83193
 
83130
- 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
83131
83208
  // NOTE: Merging of separate operations to the same model instance is handled upstream
83132
83209
  // in the `mergePage` method within src/sync/merger.ts. The final state of a model instance
83133
83210
  // depends on the LATEST record (for a given id).
@@ -83169,7 +83246,13 @@ function () {
83169
83246
  }
83170
83247
  });
83171
83248
  });
83172
- })(); // 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
+ */
83173
83256
 
83174
83257
 
83175
83258
  var generateSnapshot = function generateSnapshot() {
@@ -83196,6 +83279,15 @@ function () {
83196
83279
  isSynced: isSynced
83197
83280
  };
83198
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
+
83199
83291
 
83200
83292
  var emitSnapshot = function emitSnapshot(snapshot) {
83201
83293
  // send the generated snapshot to the primary subscription
@@ -83204,6 +83296,13 @@ function () {
83204
83296
  itemsChanged.clear();
83205
83297
  deletedItemIds = [];
83206
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
+
83207
83306
 
83208
83307
  var sortItems = function sortItems(itemsToSort) {
83209
83308
  var modelDefinition = getModelDefinition(model);
@@ -83216,7 +83315,15 @@ function () {
83216
83315
  var compareFn = Object(_util__WEBPACK_IMPORTED_MODULE_9__["sortCompareFunction"])(sortPredicates);
83217
83316
  itemsToSort.sort(compareFn);
83218
83317
  }
83219
- }; // 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
+ */
83220
83327
 
83221
83328
 
83222
83329
  var hubCallback = function hubCallback(_a) {
@@ -92381,57 +92488,85 @@ var __values = undefined && undefined.__values || function (o) {
92381
92488
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
92382
92489
  };
92383
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
+
92384
92499
  var mutationErrorMap = {
92500
+ BadModel: function BadModel() {
92501
+ return false;
92502
+ },
92385
92503
  BadRecord: function BadRecord(error) {
92386
- 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
92387
92506
  },
92388
92507
  ConfigError: function ConfigError() {
92389
92508
  return false;
92390
92509
  },
92391
- Transient: function Transient() {
92392
- return false;
92510
+ Transient: function Transient(error) {
92511
+ return connectionTimeout(error) || serverError(error);
92393
92512
  },
92394
- Unauthorized: function Unauthorized() {
92395
- return false;
92513
+ Unauthorized: function Unauthorized(error) {
92514
+ return /^Request failed with status code 401/.test(error.message);
92396
92515
  }
92397
92516
  };
92398
92517
  var subscriptionErrorMap = {
92518
+ BadModel: function BadModel() {
92519
+ return false;
92520
+ },
92399
92521
  BadRecord: function BadRecord() {
92400
92522
  return false;
92401
92523
  },
92402
92524
  ConfigError: function ConfigError() {
92403
92525
  return false;
92404
92526
  },
92405
- Transient: function Transient() {
92406
- return false;
92527
+ Transient: function Transient(observableError) {
92528
+ var error = unwrapObservableError(observableError);
92529
+ return connectionTimeout(error) || serverError(error);
92407
92530
  },
92408
- Unauthorized: function Unauthorized(givenError) {
92409
- var _a = givenError.error,
92410
- _b = __read((_a === void 0 ? {
92411
- errors: []
92412
- } : _a).errors, 1),
92413
- _c = _b[0],
92414
- _d = (_c === void 0 ? {} : _c).message,
92415
- message = _d === void 0 ? '' : _d;
92416
-
92417
- var regex = /Connection failed.+Unauthorized/;
92418
- return regex.test(message);
92531
+ Unauthorized: function Unauthorized(observableError) {
92532
+ var error = unwrapObservableError(observableError);
92533
+ return /Connection failed.+Unauthorized/.test(error.message);
92419
92534
  }
92420
92535
  };
92421
92536
  var syncErrorMap = {
92537
+ BadModel: function BadModel() {
92538
+ return false;
92539
+ },
92422
92540
  BadRecord: function BadRecord(error) {
92423
92541
  return /^Cannot return \w+ for [\w-_]+ type/.test(error.message);
92424
92542
  },
92425
92543
  ConfigError: function ConfigError() {
92426
92544
  return false;
92427
92545
  },
92428
- Transient: function Transient() {
92429
- return false;
92546
+ Transient: function Transient(error) {
92547
+ return connectionTimeout(error) || serverError(error);
92430
92548
  },
92431
92549
  Unauthorized: function Unauthorized() {
92432
92550
  return false;
92433
92551
  }
92434
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
+
92435
92570
  function getMutationErrorType(error) {
92436
92571
  return mapErrorToType(mutationErrorMap, error);
92437
92572
  }
@@ -96169,7 +96304,7 @@ var LimitTimerRaceResolvedValues;
96169
96304
  /*!*************************!*\
96170
96305
  !*** ./lib-esm/util.js ***!
96171
96306
  \*************************/
96172
- /*! 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 */
96173
96308
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
96174
96309
 
96175
96310
  "use strict";
@@ -96207,13 +96342,15 @@ __webpack_require__.r(__webpack_exports__);
96207
96342
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isAWSIPAddress", function() { return isAWSIPAddress; });
96208
96343
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeferredPromise", function() { return DeferredPromise; });
96209
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; });
96210
96346
  /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js");
96211
96347
  /* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(buffer__WEBPACK_IMPORTED_MODULE_0__);
96212
96348
  /* harmony import */ var ulid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ulid */ "../../node_modules/ulid/dist/index.esm.js");
96213
96349
  /* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uuid */ "./node_modules/uuid/index.js");
96214
96350
  /* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(uuid__WEBPACK_IMPORTED_MODULE_2__);
96215
- /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./types */ "./lib-esm/types.js");
96216
- /* 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");
96217
96354
  function _typeof(obj) {
96218
96355
  "@babel/helpers - typeof";
96219
96356
 
@@ -96424,6 +96561,7 @@ var __values = undefined && undefined.__values || function (o) {
96424
96561
 
96425
96562
 
96426
96563
 
96564
+
96427
96565
  var exhaustiveCheck = function exhaustiveCheck(obj, throwOnError) {
96428
96566
  if (throwOnError === void 0) {
96429
96567
  throwOnError = true;
@@ -96463,7 +96601,7 @@ var validatePredicate = function validatePredicate(model, groupType, predicatesO
96463
96601
  }
96464
96602
 
96465
96603
  var result = predicatesOrGroups[filterType](function (predicateOrGroup) {
96466
- if (Object(_types__WEBPACK_IMPORTED_MODULE_3__["isPredicateObj"])(predicateOrGroup)) {
96604
+ if (Object(_types__WEBPACK_IMPORTED_MODULE_4__["isPredicateObj"])(predicateOrGroup)) {
96467
96605
  var field = predicateOrGroup.field,
96468
96606
  operator = predicateOrGroup.operator,
96469
96607
  operand = predicateOrGroup.operand;
@@ -96471,7 +96609,7 @@ var validatePredicate = function validatePredicate(model, groupType, predicatesO
96471
96609
  return validatePredicateField(value, operator, operand);
96472
96610
  }
96473
96611
 
96474
- if (Object(_types__WEBPACK_IMPORTED_MODULE_3__["isPredicateGroup"])(predicateOrGroup)) {
96612
+ if (Object(_types__WEBPACK_IMPORTED_MODULE_4__["isPredicateGroup"])(predicateOrGroup)) {
96475
96613
  var type = predicateOrGroup.type,
96476
96614
  predicates = predicateOrGroup.predicates;
96477
96615
  return validatePredicate(model, type, predicates);
@@ -96574,7 +96712,7 @@ var processCompositeKeys = function processCompositeKeys(attributes) {
96574
96712
  return sortKeyFields;
96575
96713
  };
96576
96714
 
96577
- 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);
96578
96716
  /*
96579
96717
  if 2 sets of fields have any intersecting fields => combine them into 1 union set
96580
96718
  e.g., ['a', 'b', 'c'] and ['a', 'b', 'd'] => ['a', 'b', 'c', 'd']
@@ -96653,11 +96791,11 @@ var establishRelationAndKeys = function establishRelationAndKeys(namespace) {
96653
96791
  for (var _e = __values(model.attributes), _f = _e.next(); !_f.done; _f = _e.next()) {
96654
96792
  var attribute = _f.value;
96655
96793
 
96656
- if (!Object(_types__WEBPACK_IMPORTED_MODULE_3__["isModelAttributeKey"])(attribute)) {
96794
+ if (!Object(_types__WEBPACK_IMPORTED_MODULE_4__["isModelAttributeKey"])(attribute)) {
96657
96795
  continue;
96658
96796
  }
96659
96797
 
96660
- if (Object(_types__WEBPACK_IMPORTED_MODULE_3__["isModelAttributePrimaryKey"])(attribute)) {
96798
+ if (Object(_types__WEBPACK_IMPORTED_MODULE_4__["isModelAttributePrimaryKey"])(attribute)) {
96661
96799
  keys[mKey].primaryKey = attribute.properties.fields;
96662
96800
  }
96663
96801
 
@@ -96884,7 +97022,7 @@ var isPrivateMode = function isPrivateMode() {
96884
97022
  };
96885
97023
 
96886
97024
  var randomBytes = function randomBytes(nBytes) {
96887
- 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');
96888
97026
  };
96889
97027
 
96890
97028
  var prng = function prng() {
@@ -96929,7 +97067,7 @@ function sortCompareFunction(sortPredicates) {
96929
97067
  var field = predicate.field,
96930
97068
  sortDirection = predicate.sortDirection; // reverse result when direction is descending
96931
97069
 
96932
- 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;
96933
97071
 
96934
97072
  if (a[field] < b[field]) {
96935
97073
  return -1 * sortMultiplier;
@@ -97118,7 +97256,7 @@ function () {
97118
97256
 
97119
97257
  this.timerPromise = new Promise(function (resolve, reject) {
97120
97258
  _this.timer = setTimeout(function () {
97121
- resolve(_types__WEBPACK_IMPORTED_MODULE_3__["LimitTimerRaceResolvedValues"].TIMER);
97259
+ resolve(_types__WEBPACK_IMPORTED_MODULE_4__["LimitTimerRaceResolvedValues"].TIMER);
97122
97260
  }, _this.maxInterval);
97123
97261
  });
97124
97262
  };
@@ -97178,13 +97316,41 @@ function () {
97178
97316
  };
97179
97317
 
97180
97318
  DeferredCallbackResolver.prototype.resolve = function () {
97181
- this.limitPromise.resolve(_types__WEBPACK_IMPORTED_MODULE_3__["LimitTimerRaceResolvedValues"].LIMIT);
97319
+ this.limitPromise.resolve(_types__WEBPACK_IMPORTED_MODULE_4__["LimitTimerRaceResolvedValues"].LIMIT);
97182
97320
  };
97183
97321
 
97184
97322
  return DeferredCallbackResolver;
97185
97323
  }();
97186
97324
 
97187
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
+ }
97188
97354
 
97189
97355
  /***/ }),
97190
97356