@aws-amplify/datastore 3.7.1-unstable.2 → 3.7.1-unstable.6

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.
@@ -71237,6 +71237,7 @@ function () {
71237
71237
  case 2:
71238
71238
  _a.sent();
71239
71239
 
71240
+ this._nextSequenceToken = undefined;
71240
71241
  return [4
71241
71242
  /*yield*/
71242
71243
  , this._validateLogStreamExists(this._config.logGroupName, this._config.logStreamName)];
@@ -71244,14 +71245,10 @@ function () {
71244
71245
  case 3:
71245
71246
  logStream = _a.sent();
71246
71247
 
71247
- if (!logStream) {
71248
- this._nextSequenceToken = '';
71249
- return [2
71250
- /*return*/
71251
- , ''];
71248
+ if (logStream) {
71249
+ this._nextSequenceToken = logStream.uploadSequenceToken;
71252
71250
  }
71253
71251
 
71254
- this._nextSequenceToken = logStream.uploadSequenceToken || '';
71255
71252
  return [2
71256
71253
  /*return*/
71257
71254
  , this._nextSequenceToken];
@@ -71372,7 +71369,7 @@ function () {
71372
71369
  case 0:
71373
71370
  _a.trys.push([0, 3,, 4]);
71374
71371
 
71375
- this._nextSequenceToken = '';
71372
+ this._nextSequenceToken = undefined;
71376
71373
  this._dataTracker.eventUploadInProgress = true;
71377
71374
  return [4
71378
71375
  /*yield*/
@@ -88894,7 +88891,9 @@ function () {
88894
88891
  updatedFields.forEach(function (field) {
88895
88892
  var e_2, _a, e_3, _b;
88896
88893
 
88897
- var targetName = Object(_types__WEBPACK_IMPORTED_MODULE_3__["isTargetNameAssociation"])(fields[field].association); // if field refers to a belongsTo relation, use the target field instead
88894
+ var _c;
88895
+
88896
+ var targetName = Object(_types__WEBPACK_IMPORTED_MODULE_3__["isTargetNameAssociation"])((_c = fields[field]) === null || _c === void 0 ? void 0 : _c.association); // if field refers to a belongsTo relation, use the target field instead
88898
88897
 
88899
88898
  var key = targetName || field; // check field values by value. Ignore unchanged fields
88900
88899
 
@@ -91350,7 +91349,7 @@ function () {
91350
91349
 
91351
91350
  MutationEventOutbox.prototype.syncOutboxVersionsOnDequeue = function (storage, record, head, recordOp) {
91352
91351
  return __awaiter(this, void 0, void 0, function () {
91353
- var _version, _lastChangedAt, _deleted, incomingData, data, __version, __lastChangedAt, __deleted, outgoingData, mutationEventModelDefinition, predicate, outdatedMutations, reconciledMutations;
91352
+ var _version, _lastChangedAt, _deleted, _incomingData, incomingData, data, __version, __lastChangedAt, __deleted, _outgoingData, outgoingData, mutationEventModelDefinition, predicate, outdatedMutations, reconciledMutations;
91354
91353
 
91355
91354
  var _this = this;
91356
91355
 
@@ -91363,7 +91362,8 @@ function () {
91363
91362
  ];
91364
91363
  }
91365
91364
 
91366
- _version = record._version, _lastChangedAt = record._lastChangedAt, _deleted = record._deleted, incomingData = __rest(record, ["_version", "_lastChangedAt", "_deleted"]);
91365
+ _version = record._version, _lastChangedAt = record._lastChangedAt, _deleted = record._deleted, _incomingData = __rest(record, ["_version", "_lastChangedAt", "_deleted"]);
91366
+ incomingData = this.removeTimestampFields(head.model, _incomingData);
91367
91367
  data = JSON.parse(head.data);
91368
91368
 
91369
91369
  if (!data) {
@@ -91372,7 +91372,8 @@ function () {
91372
91372
  ];
91373
91373
  }
91374
91374
 
91375
- __version = data._version, __lastChangedAt = data._lastChangedAt, __deleted = data._deleted, outgoingData = __rest(data, ["_version", "_lastChangedAt", "_deleted"]); // Don't sync the version when the data in the response does not match the data
91375
+ __version = data._version, __lastChangedAt = data._lastChangedAt, __deleted = data._deleted, _outgoingData = __rest(data, ["_version", "_lastChangedAt", "_deleted"]);
91376
+ outgoingData = this.removeTimestampFields(head.model, _outgoingData); // Don't sync the version when the data in the response does not match the data
91376
91377
  // in the request, i.e., when there's a handled conflict
91377
91378
 
91378
91379
  if (!Object(_util__WEBPACK_IMPORTED_MODULE_2__["valuesEqual"])(incomingData, outgoingData, true)) {
@@ -91473,6 +91474,45 @@ function () {
91473
91474
  data: data
91474
91475
  }));
91475
91476
  };
91477
+ /*
91478
+ if a model is using custom timestamp fields
91479
+ the custom field names will be stored in the model attributes
91480
+ e.g.
91481
+ "attributes": [
91482
+ {
91483
+ "type": "model",
91484
+ "properties": {
91485
+ "timestamps": {
91486
+ "createdAt": "createdOn",
91487
+ "updatedAt": "updatedOn"
91488
+ }
91489
+ }
91490
+ }
91491
+ ]
91492
+ */
91493
+
91494
+
91495
+ MutationEventOutbox.prototype.removeTimestampFields = function (model, record) {
91496
+ var _a, _b;
91497
+
91498
+ var CREATED_AT_DEFAULT_KEY = 'createdAt';
91499
+ var UPDATED_AT_DEFAULT_KEY = 'updatedAt';
91500
+ var createdTimestampKey = CREATED_AT_DEFAULT_KEY;
91501
+ var updatedTimestampKey = UPDATED_AT_DEFAULT_KEY;
91502
+ var modelAttributes = (_a = this.schema.namespaces[_util__WEBPACK_IMPORTED_MODULE_2__["USER"]].models[model].attributes) === null || _a === void 0 ? void 0 : _a.find(function (attr) {
91503
+ return attr.type === 'model';
91504
+ });
91505
+ var timestampFieldsMap = (_b = modelAttributes === null || modelAttributes === void 0 ? void 0 : modelAttributes.properties) === null || _b === void 0 ? void 0 : _b.timestamps;
91506
+
91507
+ if (timestampFieldsMap) {
91508
+ createdTimestampKey = timestampFieldsMap[CREATED_AT_DEFAULT_KEY];
91509
+ updatedTimestampKey = timestampFieldsMap[UPDATED_AT_DEFAULT_KEY];
91510
+ }
91511
+
91512
+ delete record[createdTimestampKey];
91513
+ delete record[updatedTimestampKey];
91514
+ return record;
91515
+ };
91476
91516
 
91477
91517
  return MutationEventOutbox;
91478
91518
  }();