@aws-amplify/datastore 3.7.1-unstable.3 → 3.7.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 +12 -0
- package/dist/aws-amplify-datastore.js +48 -10
- package/dist/aws-amplify-datastore.js.map +1 -1
- package/dist/aws-amplify-datastore.min.js +1 -1
- package/dist/aws-amplify-datastore.min.js.map +1 -1
- package/lib/storage/adapter/InMemoryStore.native.d.ts +1 -2
- package/lib/sync/outbox.d.ts +1 -0
- package/lib/sync/outbox.js +39 -5
- package/lib/sync/outbox.js.map +1 -1
- package/lib-esm/storage/adapter/InMemoryStore.native.d.ts +1 -2
- package/lib-esm/sync/outbox.d.ts +1 -0
- package/lib-esm/sync/outbox.js +40 -6
- package/lib-esm/sync/outbox.js.map +1 -1
- package/package.json +7 -7
- package/src/sync/outbox.ts +57 -18
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.7.1](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.7.0...@aws-amplify/datastore@3.7.1) (2021-12-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **@aws-amplify/datastore:** belongsTo bug ([#9268](https://github.com/aws-amplify/amplify-js/issues/9268)) ([5106639](https://github.com/aws-amplify/amplify-js/commit/510663981a32443b79dd065ca075b664ca8bdff6))
|
|
12
|
+
* **@aws-amplify/datastore:** consecutive saves with timestamps ([#9298](https://github.com/aws-amplify/amplify-js/issues/9298)) ([807dea0](https://github.com/aws-amplify/amplify-js/commit/807dea0acae8389854560ca73b035ecbf220d040))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
# [3.7.0](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.6.1...@aws-amplify/datastore@3.7.0) (2021-11-18)
|
|
7
19
|
|
|
8
20
|
|
|
@@ -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 (
|
|
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*/
|
|
@@ -91352,7 +91349,7 @@ function () {
|
|
|
91352
91349
|
|
|
91353
91350
|
MutationEventOutbox.prototype.syncOutboxVersionsOnDequeue = function (storage, record, head, recordOp) {
|
|
91354
91351
|
return __awaiter(this, void 0, void 0, function () {
|
|
91355
|
-
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;
|
|
91356
91353
|
|
|
91357
91354
|
var _this = this;
|
|
91358
91355
|
|
|
@@ -91365,7 +91362,8 @@ function () {
|
|
|
91365
91362
|
];
|
|
91366
91363
|
}
|
|
91367
91364
|
|
|
91368
|
-
_version = record._version, _lastChangedAt = record._lastChangedAt, _deleted = record._deleted,
|
|
91365
|
+
_version = record._version, _lastChangedAt = record._lastChangedAt, _deleted = record._deleted, _incomingData = __rest(record, ["_version", "_lastChangedAt", "_deleted"]);
|
|
91366
|
+
incomingData = this.removeTimestampFields(head.model, _incomingData);
|
|
91369
91367
|
data = JSON.parse(head.data);
|
|
91370
91368
|
|
|
91371
91369
|
if (!data) {
|
|
@@ -91374,7 +91372,8 @@ function () {
|
|
|
91374
91372
|
];
|
|
91375
91373
|
}
|
|
91376
91374
|
|
|
91377
|
-
__version = data._version, __lastChangedAt = data._lastChangedAt, __deleted = data._deleted,
|
|
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
|
|
91378
91377
|
// in the request, i.e., when there's a handled conflict
|
|
91379
91378
|
|
|
91380
91379
|
if (!Object(_util__WEBPACK_IMPORTED_MODULE_2__["valuesEqual"])(incomingData, outgoingData, true)) {
|
|
@@ -91475,6 +91474,45 @@ function () {
|
|
|
91475
91474
|
data: data
|
|
91476
91475
|
}));
|
|
91477
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
|
+
};
|
|
91478
91516
|
|
|
91479
91517
|
return MutationEventOutbox;
|
|
91480
91518
|
}();
|