@aws-amplify/datastore 3.7.4-custom-pk.94 → 3.7.4-custom-pk.98

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.
@@ -60712,6 +60712,7 @@ var dispatchAuthEvent = function dispatchAuthEvent(event, data, message) {
60712
60712
 
60713
60713
 
60714
60714
  var MAX_DEVICES = 60;
60715
+ var MAX_AUTOSIGNIN_POLLING_MS = 3 * 60 * 1000;
60715
60716
  /**
60716
60717
  * Provide authentication steps
60717
60718
  */
@@ -60729,6 +60730,7 @@ function () {
60729
60730
  this.userPool = null;
60730
60731
  this.user = null;
60731
60732
  this.oAuthFlowInProgress = false;
60733
+ this.autoSignInInitiated = false;
60732
60734
  this.Credentials = _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Credentials"];
60733
60735
 
60734
60736
  this.wrapRefreshSessionCallback = function (callback) {
@@ -60874,6 +60876,19 @@ function () {
60874
60876
  }
60875
60877
 
60876
60878
  dispatchAuthEvent('configured', null, "The Auth category has been configured successfully");
60879
+
60880
+ if (!this.autoSignInInitiated && typeof this._storage['getItem'] === 'function') {
60881
+ var pollingInitiated = this.isTrueStorageValue('amplify-polling-started');
60882
+
60883
+ if (pollingInitiated) {
60884
+ dispatchAuthEvent('autoSignIn_failure', null, _types_Auth__WEBPACK_IMPORTED_MODULE_7__["AuthErrorTypes"].AutoSignInError);
60885
+
60886
+ this._storage.removeItem('amplify-auto-sign-in');
60887
+ }
60888
+
60889
+ this._storage.removeItem('amplify-polling-started');
60890
+ }
60891
+
60877
60892
  return this._config;
60878
60893
  };
60879
60894
  /**
@@ -60893,6 +60908,8 @@ function () {
60893
60908
  restOfAttrs[_i - 1] = arguments[_i];
60894
60909
  }
60895
60910
 
60911
+ var _a, _b, _c;
60912
+
60896
60913
  if (!this.userPool) {
60897
60914
  return this.rejectNoUserPool();
60898
60915
  }
@@ -60902,6 +60919,11 @@ function () {
60902
60919
  var attributes = [];
60903
60920
  var validationData = null;
60904
60921
  var clientMetadata;
60922
+ var autoSignIn = {
60923
+ enabled: false
60924
+ };
60925
+ var autoSignInValidationData = {};
60926
+ var autoSignInClientMetaData = {};
60905
60927
 
60906
60928
  if (params && typeof params === 'string') {
60907
60929
  username = params;
@@ -60948,6 +60970,17 @@ function () {
60948
60970
  }));
60949
60971
  });
60950
60972
  }
60973
+
60974
+ autoSignIn = (_a = params.autoSignIn) !== null && _a !== void 0 ? _a : {
60975
+ enabled: false
60976
+ };
60977
+
60978
+ if (autoSignIn.enabled) {
60979
+ this._storage.setItem('amplify-auto-sign-in', 'true');
60980
+
60981
+ autoSignInValidationData = (_b = autoSignIn.validationData) !== null && _b !== void 0 ? _b : {};
60982
+ autoSignInClientMetaData = (_c = autoSignIn.clientMetaData) !== null && _c !== void 0 ? _c : {};
60983
+ }
60951
60984
  } else {
60952
60985
  return this.rejectAuthError(_types_Auth__WEBPACK_IMPORTED_MODULE_7__["AuthErrorTypes"].SignUpError);
60953
60986
  }
@@ -60969,11 +61002,126 @@ function () {
60969
61002
  reject(err);
60970
61003
  } else {
60971
61004
  dispatchAuthEvent('signUp', data, username + " has signed up successfully");
61005
+
61006
+ if (autoSignIn.enabled) {
61007
+ _this.handleAutoSignIn(username, password, autoSignInValidationData, autoSignInClientMetaData, data);
61008
+ }
61009
+
60972
61010
  resolve(data);
60973
61011
  }
60974
61012
  }, clientMetadata);
60975
61013
  });
60976
61014
  };
61015
+
61016
+ AuthClass.prototype.handleAutoSignIn = function (username, password, validationData, clientMetadata, data) {
61017
+ this.autoSignInInitiated = true;
61018
+ var authDetails = new amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_2__["AuthenticationDetails"]({
61019
+ Username: username,
61020
+ Password: password,
61021
+ ValidationData: validationData,
61022
+ ClientMetadata: clientMetadata
61023
+ });
61024
+
61025
+ if (data.userConfirmed) {
61026
+ this.signInAfterUserConfirmed(authDetails);
61027
+ } else if (this._config.signUpVerificationMethod === 'link') {
61028
+ this.handleLinkAutoSignIn(authDetails);
61029
+ } else {
61030
+ this.handleCodeAutoSignIn(authDetails);
61031
+ }
61032
+ };
61033
+
61034
+ AuthClass.prototype.handleCodeAutoSignIn = function (authDetails) {
61035
+ var _this = this;
61036
+
61037
+ var listenEvent = function listenEvent(_a) {
61038
+ var payload = _a.payload;
61039
+
61040
+ if (payload.event === 'confirmSignUp') {
61041
+ _this.signInAfterUserConfirmed(authDetails, listenEvent);
61042
+ }
61043
+ };
61044
+
61045
+ _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Hub"].listen('auth', listenEvent);
61046
+ };
61047
+
61048
+ AuthClass.prototype.handleLinkAutoSignIn = function (authDetails) {
61049
+ var _this = this;
61050
+
61051
+ this._storage.setItem('amplify-polling-started', 'true');
61052
+
61053
+ var start = Date.now();
61054
+ var autoSignInPollingIntervalId = setInterval(function () {
61055
+ if (Date.now() - start > MAX_AUTOSIGNIN_POLLING_MS) {
61056
+ clearInterval(autoSignInPollingIntervalId);
61057
+ dispatchAuthEvent('autoSignIn_failure', null, 'Please confirm your account and use your credentials to sign in.');
61058
+
61059
+ _this._storage.removeItem('amplify-auto-sign-in');
61060
+ } else {
61061
+ _this.signInAfterUserConfirmed(authDetails, null, autoSignInPollingIntervalId);
61062
+ }
61063
+ }, 5000);
61064
+ };
61065
+
61066
+ AuthClass.prototype.signInAfterUserConfirmed = function (authDetails, listenEvent, autoSignInPollingIntervalId) {
61067
+ return __awaiter(this, void 0, void 0, function () {
61068
+ var user, error_1;
61069
+
61070
+ var _this = this;
61071
+
61072
+ return __generator(this, function (_a) {
61073
+ switch (_a.label) {
61074
+ case 0:
61075
+ user = this.createCognitoUser(authDetails.getUsername());
61076
+ _a.label = 1;
61077
+
61078
+ case 1:
61079
+ _a.trys.push([1, 3,, 4]);
61080
+
61081
+ return [4
61082
+ /*yield*/
61083
+ , user.authenticateUser(authDetails, this.authCallbacks(user, function (value) {
61084
+ dispatchAuthEvent('autoSignIn', value, authDetails.getUsername() + " has signed in successfully");
61085
+
61086
+ if (listenEvent) {
61087
+ _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["Hub"].remove('auth', listenEvent);
61088
+ }
61089
+
61090
+ if (autoSignInPollingIntervalId) {
61091
+ clearInterval(autoSignInPollingIntervalId);
61092
+
61093
+ _this._storage.removeItem('amplify-polling-started');
61094
+ }
61095
+
61096
+ _this._storage.removeItem('amplify-auto-sign-in');
61097
+ }, function (error) {
61098
+ logger.error(error);
61099
+
61100
+ _this._storage.removeItem('amplify-auto-sign-in');
61101
+ }))];
61102
+
61103
+ case 2:
61104
+ _a.sent();
61105
+
61106
+ return [3
61107
+ /*break*/
61108
+ , 4];
61109
+
61110
+ case 3:
61111
+ error_1 = _a.sent();
61112
+ logger.error(error_1);
61113
+ return [3
61114
+ /*break*/
61115
+ , 4];
61116
+
61117
+ case 4:
61118
+ return [2
61119
+ /*return*/
61120
+ ];
61121
+ }
61122
+ });
61123
+ });
61124
+ };
60977
61125
  /**
60978
61126
  * Send the verification code to confirm sign up
60979
61127
  * @param {String} username - The username to be confirmed
@@ -60984,6 +61132,8 @@ function () {
60984
61132
 
60985
61133
 
60986
61134
  AuthClass.prototype.confirmSignUp = function (username, code, options) {
61135
+ var _this = this;
61136
+
60987
61137
  if (!this.userPool) {
60988
61138
  return this.rejectNoUserPool();
60989
61139
  }
@@ -61011,11 +61161,27 @@ function () {
61011
61161
  if (err) {
61012
61162
  reject(err);
61013
61163
  } else {
61164
+ dispatchAuthEvent('confirmSignUp', data, username + " has been confirmed successfully");
61165
+
61166
+ var autoSignIn = _this.isTrueStorageValue('amplify-auto-sign-in');
61167
+
61168
+ if (autoSignIn && !_this.autoSignInInitiated) {
61169
+ dispatchAuthEvent('autoSignIn_failure', null, _types_Auth__WEBPACK_IMPORTED_MODULE_7__["AuthErrorTypes"].AutoSignInError);
61170
+
61171
+ _this._storage.removeItem('amplify-auto-sign-in');
61172
+ }
61173
+
61014
61174
  resolve(data);
61015
61175
  }
61016
61176
  }, clientMetadata);
61017
61177
  });
61018
61178
  };
61179
+
61180
+ AuthClass.prototype.isTrueStorageValue = function (value) {
61181
+ var item = this._storage.getItem(value);
61182
+
61183
+ return item ? item === 'true' : false;
61184
+ };
61019
61185
  /**
61020
61186
  * Resend the verification code
61021
61187
  * @param {String} username - The username to be confirmed
@@ -62691,7 +62857,7 @@ function () {
62691
62857
  logger.debug('Getting current session'); // Purposely not calling the reject method here because we don't need a console error
62692
62858
 
62693
62859
  if (!this.userPool) {
62694
- return this.rejectNoUserPool();
62860
+ return Promise.reject(new Error('No User Pool in the configuration.'));
62695
62861
  }
62696
62862
 
62697
62863
  return new Promise(function (res, rej) {
@@ -63713,7 +63879,7 @@ function () {
63713
63879
 
63714
63880
  AuthClass.prototype.rememberDevice = function () {
63715
63881
  return __awaiter(this, void 0, void 0, function () {
63716
- var currUser, error_1;
63882
+ var currUser, error_2;
63717
63883
  return __generator(this, function (_a) {
63718
63884
  switch (_a.label) {
63719
63885
  case 0:
@@ -63730,8 +63896,8 @@ function () {
63730
63896
  , 3];
63731
63897
 
63732
63898
  case 2:
63733
- error_1 = _a.sent();
63734
- logger.debug('The user is not authenticated by the error', error_1);
63899
+ error_2 = _a.sent();
63900
+ logger.debug('The user is not authenticated by the error', error_2);
63735
63901
  return [2
63736
63902
  /*return*/
63737
63903
  , Promise.reject('The user is not authenticated')];
@@ -63763,7 +63929,7 @@ function () {
63763
63929
 
63764
63930
  AuthClass.prototype.forgetDevice = function () {
63765
63931
  return __awaiter(this, void 0, void 0, function () {
63766
- var currUser, error_2;
63932
+ var currUser, error_3;
63767
63933
  return __generator(this, function (_a) {
63768
63934
  switch (_a.label) {
63769
63935
  case 0:
@@ -63780,8 +63946,8 @@ function () {
63780
63946
  , 3];
63781
63947
 
63782
63948
  case 2:
63783
- error_2 = _a.sent();
63784
- logger.debug('The user is not authenticated by the error', error_2);
63949
+ error_3 = _a.sent();
63950
+ logger.debug('The user is not authenticated by the error', error_3);
63785
63951
  return [2
63786
63952
  /*return*/
63787
63953
  , Promise.reject('The user is not authenticated')];
@@ -63813,7 +63979,7 @@ function () {
63813
63979
 
63814
63980
  AuthClass.prototype.fetchDevices = function () {
63815
63981
  return __awaiter(this, void 0, void 0, function () {
63816
- var currUser, error_3;
63982
+ var currUser, error_4;
63817
63983
  return __generator(this, function (_a) {
63818
63984
  switch (_a.label) {
63819
63985
  case 0:
@@ -63830,8 +63996,8 @@ function () {
63830
63996
  , 3];
63831
63997
 
63832
63998
  case 2:
63833
- error_3 = _a.sent();
63834
- logger.debug('The user is not authenticated by the error', error_3);
63999
+ error_4 = _a.sent();
64000
+ logger.debug('The user is not authenticated by the error', error_4);
63835
64001
  throw new Error('The user is not authenticated');
63836
64002
 
63837
64003
  case 3:
@@ -64027,6 +64193,9 @@ var authErrorMessages = {
64027
64193
  networkError: {
64028
64194
  message: _common_AuthErrorStrings__WEBPACK_IMPORTED_MODULE_1__["AuthErrorStrings"].NETWORK_ERROR
64029
64195
  },
64196
+ autoSignInError: {
64197
+ message: _common_AuthErrorStrings__WEBPACK_IMPORTED_MODULE_1__["AuthErrorStrings"].AUTOSIGNIN_ERROR
64198
+ },
64030
64199
  "default": {
64031
64200
  message: _common_AuthErrorStrings__WEBPACK_IMPORTED_MODULE_1__["AuthErrorStrings"].DEFAULT_MSG
64032
64201
  }
@@ -64753,6 +64922,7 @@ var AuthErrorStrings;
64753
64922
  AuthErrorStrings["NO_USER_SESSION"] = "Failed to get the session because the user is empty";
64754
64923
  AuthErrorStrings["NETWORK_ERROR"] = "Network Error";
64755
64924
  AuthErrorStrings["DEVICE_CONFIG"] = "Device tracking has not been configured in this User Pool";
64925
+ AuthErrorStrings["AUTOSIGNIN_ERROR"] = "Please use your credentials to sign in";
64756
64926
  })(AuthErrorStrings || (AuthErrorStrings = {}));
64757
64927
 
64758
64928
  /***/ }),
@@ -64886,6 +65056,7 @@ var AuthErrorTypes;
64886
65056
  AuthErrorTypes["Default"] = "default";
64887
65057
  AuthErrorTypes["DeviceConfig"] = "deviceConfig";
64888
65058
  AuthErrorTypes["NetworkError"] = "networkError";
65059
+ AuthErrorTypes["AutoSignInError"] = "autoSignInError";
64889
65060
  })(AuthErrorTypes || (AuthErrorTypes = {}));
64890
65061
 
64891
65062
  function isUsernamePasswordOpts(obj) {
@@ -71111,7 +71282,8 @@ var parseMobileHubConfig = function parseMobileHubConfig(config) {
71111
71282
  region: config['aws_cognito_region'],
71112
71283
  identityPoolId: config['aws_cognito_identity_pool_id'],
71113
71284
  identityPoolRegion: config['aws_cognito_region'],
71114
- mandatorySignIn: config['aws_mandatory_sign_in'] === 'enable'
71285
+ mandatorySignIn: config['aws_mandatory_sign_in'] === 'enable',
71286
+ signUpVerificationMethod: config['aws_cognito_sign_up_verification_method'] || 'code'
71115
71287
  };
71116
71288
  } // Storage
71117
71289
 
@@ -71249,7 +71421,7 @@ var getAmplifyUserAgent = function getAmplifyUserAgent(content) {
71249
71421
  __webpack_require__.r(__webpack_exports__);
71250
71422
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "version", function() { return version; });
71251
71423
  // generated by genversion
71252
- var version = '4.5.10';
71424
+ var version = '4.7.2';
71253
71425
 
71254
71426
  /***/ }),
71255
71427
 
@@ -72915,7 +73087,12 @@ function () {
72915
73087
  service_info = null;
72916
73088
  }
72917
73089
 
72918
- request.headers = request.headers || {}; // datetime string and date string
73090
+ request.headers = request.headers || {};
73091
+
73092
+ if (request.body && !request.data) {
73093
+ throw new Error('The attribute "body" was found on the request object. Please use the attribute "data" instead.');
73094
+ } // datetime string and date string
73095
+
72919
73096
 
72920
73097
  var dt = _Util__WEBPACK_IMPORTED_MODULE_4__["DateUtils"].getDateWithClockOffset(),
72921
73098
  dt_str = dt.toISOString().replace(/[:\-]|\.\d{3}/g, ''),
@@ -83037,17 +83214,17 @@ function () {
83037
83214
 
83038
83215
  this["delete"] = function (modelOrConstructor, identifierOrCriteria) {
83039
83216
  return __awaiter(_this, void 0, void 0, function () {
83040
- var condition, msg, modelConstructor, msg, modelDefinition, _a, keyField, msg, _b, deleted, model, modelConstructor, msg, modelDefinition, pkPredicate, msg, _c, _d, deleted;
83217
+ var condition, msg, modelConstructor, msg, modelDefinition, keyFields, msg, msg, _a, deleted, model, modelConstructor, msg, modelDefinition, pkPredicate, msg, _b, _c, deleted;
83041
83218
 
83042
- return __generator(this, function (_e) {
83043
- switch (_e.label) {
83219
+ return __generator(this, function (_d) {
83220
+ switch (_d.label) {
83044
83221
  case 0:
83045
83222
  return [4
83046
83223
  /*yield*/
83047
83224
  , this.start()];
83048
83225
 
83049
83226
  case 1:
83050
- _e.sent();
83227
+ _d.sent();
83051
83228
 
83052
83229
  if (!modelOrConstructor) {
83053
83230
  msg = 'Model or Model Constructor required';
@@ -83073,8 +83250,17 @@ function () {
83073
83250
  modelDefinition = getModelDefinition(modelConstructor);
83074
83251
 
83075
83252
  if (typeof identifierOrCriteria === 'string') {
83076
- _a = __read(Object(_util__WEBPACK_IMPORTED_MODULE_12__["extractPrimaryKeyFieldNames"])(modelDefinition), 1), keyField = _a[0];
83077
- condition = _predicates__WEBPACK_IMPORTED_MODULE_8__["ModelPredicateCreator"].createForSingleField(getModelDefinition(modelConstructor), keyField, identifierOrCriteria);
83253
+ keyFields = Object(_util__WEBPACK_IMPORTED_MODULE_12__["extractPrimaryKeyFieldNames"])(modelDefinition);
83254
+
83255
+ if (keyFields.length > 1) {
83256
+ msg = _util__WEBPACK_IMPORTED_MODULE_12__["errorMessages"].deleteByPkWithCompositeKeyPresent;
83257
+ logger.error(msg, {
83258
+ keyFields: keyFields
83259
+ });
83260
+ throw new Error(msg);
83261
+ }
83262
+
83263
+ condition = _predicates__WEBPACK_IMPORTED_MODULE_8__["ModelPredicateCreator"].createForSingleField(getModelDefinition(modelConstructor), keyFields[0], identifierOrCriteria);
83078
83264
  } else {
83079
83265
  if (Object(_types__WEBPACK_IMPORTED_MODULE_11__["isIdentifierObject"])(identifierOrCriteria, modelDefinition)) {
83080
83266
  condition = _predicates__WEBPACK_IMPORTED_MODULE_8__["ModelPredicateCreator"].createForPk(modelDefinition, identifierOrCriteria);
@@ -83101,7 +83287,7 @@ function () {
83101
83287
  , this.storage["delete"](modelConstructor, condition)];
83102
83288
 
83103
83289
  case 2:
83104
- _b = __read.apply(void 0, [_e.sent(), 1]), deleted = _b[0];
83290
+ _a = __read.apply(void 0, [_d.sent(), 1]), deleted = _a[0];
83105
83291
  return [2
83106
83292
  /*return*/
83107
83293
  , deleted];
@@ -83140,7 +83326,7 @@ function () {
83140
83326
  , this.storage["delete"](model, condition)];
83141
83327
 
83142
83328
  case 4:
83143
- _c = __read.apply(void 0, [_e.sent(), 1]), _d = __read(_c[0], 1), deleted = _d[0];
83329
+ _b = __read.apply(void 0, [_d.sent(), 1]), _c = __read(_b[0], 1), deleted = _c[0];
83144
83330
  return [2
83145
83331
  /*return*/
83146
83332
  , deleted];
@@ -89264,7 +89450,7 @@ function () {
89264
89450
  var e_9, _a, e_10, _b, e_11, _c;
89265
89451
 
89266
89452
  return __awaiter(this, void 0, void 0, function () {
89267
- var rel, relationType, fieldName, modelName, targetName, targetNames, storeName, index, _d, model, hasOneIndex, hasConnectedModelFields, keyValues, values, recordToDelete, hasOneIndex_1, hasOneCustomField, keyValues, value, recordToDelete, e_10_1, model, keyValues, childrenArray, e_11_1, e_9_1;
89453
+ var rel, relationType, modelName, targetName, targetNames, associatedWith, storeName, _d, model, hasOneIndex, values, recordToDelete, index, values, value, recordToDelete, e_10_1, model, index, keyValues, childrenArray, e_11_1, e_9_1;
89268
89454
 
89269
89455
  var _this = this;
89270
89456
 
@@ -89286,12 +89472,8 @@ function () {
89286
89472
  /*break*/
89287
89473
  , 37];
89288
89474
  rel = relations_2_1.value;
89289
- relationType = rel.relationType, fieldName = rel.fieldName, modelName = rel.modelName, targetName = rel.targetName, targetNames = rel.targetNames;
89475
+ relationType = rel.relationType, modelName = rel.modelName, targetName = rel.targetName, targetNames = rel.targetNames, associatedWith = rel.associatedWith;
89290
89476
  storeName = this.getStorename(nameSpace, modelName);
89291
- index = Object(_util__WEBPACK_IMPORTED_MODULE_4__["getIndex"])(this.schema.namespaces[nameSpace].relationships[modelName].relationTypes, srcModel) || // if we were unable to find an index via relationTypes
89292
- // i.e. for keyName connections, attempt to find one by the
89293
- // associatedWith property
89294
- Object(_util__WEBPACK_IMPORTED_MODULE_4__["getIndexFromAssociation"])(this.schema.namespaces[nameSpace].relationships[modelName].indexes, rel.associatedWith);
89295
89477
  _d = relationType;
89296
89478
 
89297
89479
  switch (_d) {
@@ -89331,26 +89513,13 @@ function () {
89331
89513
  /*break*/
89332
89514
  , 12];
89333
89515
  model = models_1_1.value;
89334
- hasOneIndex = index || 'byPk';
89335
- if (!(targetNames && targetNames.length > 0)) return [3
89516
+ hasOneIndex = 'byPk';
89517
+ if (!(targetNames === null || targetNames === void 0 ? void 0 : targetNames.length)) return [3
89336
89518
  /*break*/
89337
89519
  , 8];
89338
- hasConnectedModelFields = targetNames.every(function (targetName) {
89339
- return model.hasOwnProperty(targetName);
89520
+ values = targetNames.map(function (targetName) {
89521
+ return model[targetName];
89340
89522
  });
89341
- keyValues = this.getIndexKeyValues(model);
89342
- values = [];
89343
-
89344
- if (hasConnectedModelFields) {
89345
- // Values will be that of the child model
89346
- values = targetNames.map(function (targetName) {
89347
- return model[targetName];
89348
- });
89349
- } else {
89350
- // values will be that of the parent model
89351
- values = keyValues;
89352
- }
89353
-
89354
89523
  if (values.length === 0) return [3
89355
89524
  /*break*/
89356
89525
  , 12];
@@ -89372,16 +89541,28 @@ function () {
89372
89541
  , 12];
89373
89542
 
89374
89543
  case 8:
89375
- hasOneIndex_1 = index || 'byPk';
89376
- hasOneCustomField = targetName in model;
89377
- keyValues = this.getIndexKeyValues(model);
89378
- value = hasOneCustomField ? [model[targetName]] : keyValues;
89379
- if (!value) return [3
89544
+ index = void 0;
89545
+ values = void 0;
89546
+
89547
+ if (targetName && targetName in model) {
89548
+ index = hasOneIndex;
89549
+ value = model[targetName];
89550
+ values = [value];
89551
+ } else {
89552
+ // backwards compatability for older versions of codegen that did not emit targetName for HAS_ONE relations
89553
+ // TODO: can we deprecate this? it's been ~2 years since codegen started including targetName for HAS_ONE
89554
+ // If we deprecate, we'll need to re-gen the MIPR in __tests__/schema.ts > newSchema
89555
+ // otherwise some unit tests will fail
89556
+ index = Object(_util__WEBPACK_IMPORTED_MODULE_4__["getIndex"])(this.schema.namespaces[nameSpace].relationships[modelName].relationTypes, srcModel);
89557
+ values = this.getIndexKeyValues(model);
89558
+ }
89559
+
89560
+ if (!values || !index) return [3
89380
89561
  /*break*/
89381
89562
  , 12];
89382
89563
  return [4
89383
89564
  /*yield*/
89384
- , this.db.transaction(storeName, 'readwrite').objectStore(storeName).index(hasOneIndex_1).get(value)];
89565
+ , this.db.transaction(storeName, 'readwrite').objectStore(storeName).index(index).get(values)];
89385
89566
 
89386
89567
  case 9:
89387
89568
  recordToDelete = _e.sent();
@@ -89465,6 +89646,9 @@ function () {
89465
89646
  /*break*/
89466
89647
  , 26];
89467
89648
  model = models_2_1.value;
89649
+ index = // explicit bi-directional @hasMany and @manyToMany
89650
+ Object(_util__WEBPACK_IMPORTED_MODULE_4__["getIndex"])(this.schema.namespaces[nameSpace].relationships[modelName].relationTypes, srcModel) || // uni and/or implicit @hasMany
89651
+ Object(_util__WEBPACK_IMPORTED_MODULE_4__["getIndexFromAssociation"])(this.schema.namespaces[nameSpace].relationships[modelName].indexes, associatedWith);
89468
89652
  keyValues = this.getIndexKeyValues(model);
89469
89653
  return [4
89470
89654
  /*yield*/
@@ -97512,7 +97696,8 @@ var __values = undefined && undefined.__values || function (o) {
97512
97696
  var ID = 'id';
97513
97697
  var errorMessages = {
97514
97698
  idEmptyString: 'An index field cannot contain an empty string value',
97515
- queryByPkWithCompositeKeyPresent: 'Models with composite primary keys cannot by queried by a single key value. Use object literal syntax for composite keys instead: https://docs.amplify.aws/lib/datastore/advanced-workflows/q/platform/js/#querying-records-with-custom-primary-keys',
97699
+ queryByPkWithCompositeKeyPresent: 'Models with composite primary keys cannot be queried by a single key value. Use object literal syntax for composite keys instead: https://docs.amplify.aws/lib/datastore/advanced-workflows/q/platform/js/#querying-records-with-custom-primary-keys',
97700
+ deleteByPkWithCompositeKeyPresent: 'Models with composite primary keys cannot be deleted by a single key value, unless using a predicate. Use object literal syntax for composite keys instead: https://docs.amplify.aws/lib/datastore/advanced-workflows/q/platform/js/#querying-records-with-custom-primary-keys',
97516
97701
  observeWithObjectLiteral: 'Object literal syntax cannot be used with observe. Use a predicate instead: https://docs.amplify.aws/lib/datastore/data-access/q/platform/js/#predicates'
97517
97702
  };
97518
97703
  function extractKeyIfExists(modelDefinition) {