@aws-amplify/datastore 3.4.9-in-app-messaging.49 → 3.4.9-in-app-messaging.53

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,10 @@
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.6.1](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.6.0...@aws-amplify/datastore@3.6.1) (2021-11-16)
7
+
8
+ **Note:** Version bump only for package @aws-amplify/datastore
9
+
6
10
  # [3.6.0](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.5.2...@aws-amplify/datastore@3.6.0) (2021-11-12)
7
11
 
8
12
  ### Features
@@ -70459,7 +70459,7 @@ var getAmplifyUserAgent = function getAmplifyUserAgent() {
70459
70459
  __webpack_require__.r(__webpack_exports__);
70460
70460
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "version", function() { return version; });
70461
70461
  // generated by genversion
70462
- var version = '4.3.6';
70462
+ var version = '4.3.7';
70463
70463
 
70464
70464
  /***/ }),
70465
70465
 
@@ -83623,7 +83623,7 @@ function () {
83623
83623
  var e_2, _a, e_3, _b, e_4, _c;
83624
83624
 
83625
83625
  return __awaiter(this, void 0, void 0, function () {
83626
- var namespace, relations, connectionStoreNames, modelConstructor, relations_1, relations_1_1, relation, fieldName, modelName, targetName, relationType, storeName, modelConstructor_1, _d, recordItem, connectionRecord, e_3_1, recordItem, connectionRecord, e_4_1, e_2_1;
83626
+ var namespace, relations, connectionStoreNames, modelConstructor, relations_1, relations_1_1, relation, fieldName, modelName, targetName, relationType, storeName, modelConstructor_1, _d, recordItem, getByfield, connectionRecord, e_3_1, recordItem, connectionRecord, e_4_1, e_2_1;
83627
83627
 
83628
83628
  var _this = this;
83629
83629
 
@@ -83706,12 +83706,13 @@ function () {
83706
83706
  /*break*/
83707
83707
  , 9];
83708
83708
  recordItem = records_1_1.value;
83709
- if (!recordItem[fieldName]) return [3
83709
+ getByfield = recordItem[targetName] ? targetName : fieldName;
83710
+ if (!recordItem[getByfield]) return [3
83710
83711
  /*break*/
83711
- , 8];
83712
+ , 9];
83712
83713
  return [4
83713
83714
  /*yield*/
83714
- , this.db.get(recordItem[fieldName], storeName)];
83715
+ , this.db.get(recordItem[getByfield], storeName)];
83715
83716
 
83716
83717
  case 7:
83717
83718
  connectionRecord = _e.sent();
@@ -84548,6 +84549,9 @@ function () {
84548
84549
  hasOneIndex = index || 'byId';
84549
84550
  hasOneCustomField = targetName in model;
84550
84551
  value = hasOneCustomField ? model[targetName] : model.id;
84552
+ if (!value) return [3
84553
+ /*break*/
84554
+ , 9];
84551
84555
  return [4
84552
84556
  /*yield*/
84553
84557
  , this.db.getAll(storeName)];
@@ -86741,7 +86745,7 @@ function () {
86741
86745
  var e_3, _a, e_4, _b, e_5, _c;
86742
86746
 
86743
86747
  return __awaiter(this, void 0, void 0, function () {
86744
- var namespace, relations, connectionStoreNames, modelConstructor, tx, relations_1, relations_1_1, relation, fieldName, modelName, targetName, storeName, store, modelConstructor_1, _d, recordItem, connectionRecord, e_4_1, recordItem, connectionRecord, e_5_1, e_3_1;
86748
+ var namespace, relations, connectionStoreNames, modelConstructor, tx, relations_1, relations_1_1, relation, fieldName, modelName, targetName, storeName, store, modelConstructor_1, _d, recordItem, getByfield, connectionRecord, e_4_1, recordItem, connectionRecord, e_5_1, e_3_1;
86745
86749
 
86746
86750
  var _this = this;
86747
86751
 
@@ -86826,12 +86830,13 @@ function () {
86826
86830
  /*break*/
86827
86831
  , 9];
86828
86832
  recordItem = records_1_1.value;
86829
- if (!recordItem[fieldName]) return [3
86833
+ getByfield = recordItem[targetName] ? targetName : fieldName;
86834
+ if (!recordItem[getByfield]) return [3
86830
86835
  /*break*/
86831
- , 8];
86836
+ , 9];
86832
86837
  return [4
86833
86838
  /*yield*/
86834
- , this._get(store, recordItem[fieldName])];
86839
+ , this._get(store, recordItem[getByfield])];
86835
86840
 
86836
86841
  case 7:
86837
86842
  connectionRecord = _e.sent();
@@ -87812,6 +87817,9 @@ function () {
87812
87817
  hasOneIndex = index || 'byId';
87813
87818
  hasOneCustomField = targetName in model;
87814
87819
  value = hasOneCustomField ? model[targetName] : model.id;
87820
+ if (!value) return [3
87821
+ /*break*/
87822
+ , 9];
87815
87823
  return [4
87816
87824
  /*yield*/
87817
87825
  , this.db.transaction(storeName, 'readwrite').objectStore(storeName).index(hasOneIndex).get(value)];
@@ -95566,15 +95574,26 @@ var traverseModel = function traverseModel(srcModelName, instance, namespace, mo
95566
95574
 
95567
95575
  try {
95568
95576
  modelInstance = modelInstanceCreator(modelConstructor, instance[rItem.fieldName]);
95569
- } catch (error) {// Do nothing
95577
+ } catch (error) {
95578
+ // Do nothing
95579
+ console.log(error);
95570
95580
  }
95571
95581
 
95572
95582
  result.push({
95573
95583
  modelName: rItem.modelName,
95574
95584
  item: instance[rItem.fieldName],
95575
95585
  instance: modelInstance
95576
- });
95577
- draftInstance[rItem.fieldName] = draftInstance[rItem.fieldName].id;
95586
+ }); // targetName will be defined for Has One if feature flag
95587
+ // https://docs.amplify.aws/cli/reference/feature-flags/#useAppsyncModelgenPlugin
95588
+ // is true (default as of 5/7/21)
95589
+ // Making this conditional for backward-compatibility
95590
+
95591
+ if (rItem.targetName) {
95592
+ draftInstance[rItem.targetName] = draftInstance[rItem.fieldName].id;
95593
+ delete draftInstance[rItem.fieldName];
95594
+ } else {
95595
+ draftInstance[rItem.fieldName] = draftInstance[rItem.fieldName].id;
95596
+ }
95578
95597
  }
95579
95598
 
95580
95599
  break;