@aws-amplify/datastore 3.7.1-unstable.4 → 3.7.2
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 +20 -0
- package/dist/aws-amplify-datastore.js +45 -4
- package/dist/aws-amplify-datastore.js.map +1 -1
- package/dist/aws-amplify-datastore.min.js +2 -2
- 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,26 @@
|
|
|
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.2](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.7.1...@aws-amplify/datastore@3.7.2) (2021-12-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @aws-amplify/datastore
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [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)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **@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))
|
|
20
|
+
* **@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))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
6
26
|
# [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
27
|
|
|
8
28
|
|
|
@@ -70458,7 +70458,7 @@ var getAmplifyUserAgent = function getAmplifyUserAgent() {
|
|
|
70458
70458
|
__webpack_require__.r(__webpack_exports__);
|
|
70459
70459
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "version", function() { return version; });
|
|
70460
70460
|
// generated by genversion
|
|
70461
|
-
var version = '4.3.
|
|
70461
|
+
var version = '4.3.9';
|
|
70462
70462
|
|
|
70463
70463
|
/***/ }),
|
|
70464
70464
|
|
|
@@ -91349,7 +91349,7 @@ function () {
|
|
|
91349
91349
|
|
|
91350
91350
|
MutationEventOutbox.prototype.syncOutboxVersionsOnDequeue = function (storage, record, head, recordOp) {
|
|
91351
91351
|
return __awaiter(this, void 0, void 0, function () {
|
|
91352
|
-
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;
|
|
91353
91353
|
|
|
91354
91354
|
var _this = this;
|
|
91355
91355
|
|
|
@@ -91362,7 +91362,8 @@ function () {
|
|
|
91362
91362
|
];
|
|
91363
91363
|
}
|
|
91364
91364
|
|
|
91365
|
-
_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);
|
|
91366
91367
|
data = JSON.parse(head.data);
|
|
91367
91368
|
|
|
91368
91369
|
if (!data) {
|
|
@@ -91371,7 +91372,8 @@ function () {
|
|
|
91371
91372
|
];
|
|
91372
91373
|
}
|
|
91373
91374
|
|
|
91374
|
-
__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
|
|
91375
91377
|
// in the request, i.e., when there's a handled conflict
|
|
91376
91378
|
|
|
91377
91379
|
if (!Object(_util__WEBPACK_IMPORTED_MODULE_2__["valuesEqual"])(incomingData, outgoingData, true)) {
|
|
@@ -91472,6 +91474,45 @@ function () {
|
|
|
91472
91474
|
data: data
|
|
91473
91475
|
}));
|
|
91474
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
|
+
};
|
|
91475
91516
|
|
|
91476
91517
|
return MutationEventOutbox;
|
|
91477
91518
|
}();
|