@aws-amplify/datastore 3.7.1-unstable.5 → 3.7.3-unstable.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 +20 -0
- package/dist/aws-amplify-datastore.js +53 -8
- 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/datastore/datastore.js +4 -2
- package/lib/datastore/datastore.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/datastore/datastore.js +4 -2
- package/lib-esm/datastore/datastore.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/datastore/datastore.ts +87 -98
- 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.10';
|
|
70462
70462
|
|
|
70463
70463
|
/***/ }),
|
|
70464
70464
|
|
|
@@ -82381,19 +82381,21 @@ function () {
|
|
|
82381
82381
|
criteria).subscribe(function (_a) {
|
|
82382
82382
|
var element = _a.element,
|
|
82383
82383
|
model = _a.model,
|
|
82384
|
-
opType = _a.opType;
|
|
82384
|
+
opType = _a.opType;
|
|
82385
|
+
|
|
82386
|
+
var _b, _c; // Flag items which have been recently deleted
|
|
82385
82387
|
// NOTE: Merging of separate operations to the same model instance is handled upstream
|
|
82386
82388
|
// in the `mergePage` method within src/sync/merger.ts. The final state of a model instance
|
|
82387
82389
|
// depends on the LATEST record (for a given id).
|
|
82388
82390
|
|
|
82391
|
+
|
|
82389
82392
|
if (opType === 'DELETE') {
|
|
82390
82393
|
deletedItemIds.push(element.id);
|
|
82391
82394
|
} else {
|
|
82392
82395
|
itemsChanged.set(element.id, element);
|
|
82393
82396
|
}
|
|
82394
82397
|
|
|
82395
|
-
var isSynced = _this.sync.getModelSyncedStatus(model);
|
|
82396
|
-
|
|
82398
|
+
var isSynced = (_c = (_b = _this.sync) === null || _b === void 0 ? void 0 : _b.getModelSyncedStatus(model)) !== null && _c !== void 0 ? _c : false;
|
|
82397
82399
|
var limit = itemsChanged.size - deletedItemIds.length >= _this.syncPageSize;
|
|
82398
82400
|
|
|
82399
82401
|
if (limit || isSynced) {
|
|
@@ -82427,7 +82429,9 @@ function () {
|
|
|
82427
82429
|
|
|
82428
82430
|
|
|
82429
82431
|
var generateSnapshot = function generateSnapshot() {
|
|
82430
|
-
var
|
|
82432
|
+
var _a, _b;
|
|
82433
|
+
|
|
82434
|
+
var isSynced = (_b = (_a = _this.sync) === null || _a === void 0 ? void 0 : _a.getModelSyncedStatus(model)) !== null && _b !== void 0 ? _b : false;
|
|
82431
82435
|
|
|
82432
82436
|
var itemsArray = __spread(Array.from(items.values()), Array.from(itemsChanged.values()));
|
|
82433
82437
|
|
|
@@ -91349,7 +91353,7 @@ function () {
|
|
|
91349
91353
|
|
|
91350
91354
|
MutationEventOutbox.prototype.syncOutboxVersionsOnDequeue = function (storage, record, head, recordOp) {
|
|
91351
91355
|
return __awaiter(this, void 0, void 0, function () {
|
|
91352
|
-
var _version, _lastChangedAt, _deleted, incomingData, data, __version, __lastChangedAt, __deleted, outgoingData, mutationEventModelDefinition, predicate, outdatedMutations, reconciledMutations;
|
|
91356
|
+
var _version, _lastChangedAt, _deleted, _incomingData, incomingData, data, __version, __lastChangedAt, __deleted, _outgoingData, outgoingData, mutationEventModelDefinition, predicate, outdatedMutations, reconciledMutations;
|
|
91353
91357
|
|
|
91354
91358
|
var _this = this;
|
|
91355
91359
|
|
|
@@ -91362,7 +91366,8 @@ function () {
|
|
|
91362
91366
|
];
|
|
91363
91367
|
}
|
|
91364
91368
|
|
|
91365
|
-
_version = record._version, _lastChangedAt = record._lastChangedAt, _deleted = record._deleted,
|
|
91369
|
+
_version = record._version, _lastChangedAt = record._lastChangedAt, _deleted = record._deleted, _incomingData = __rest(record, ["_version", "_lastChangedAt", "_deleted"]);
|
|
91370
|
+
incomingData = this.removeTimestampFields(head.model, _incomingData);
|
|
91366
91371
|
data = JSON.parse(head.data);
|
|
91367
91372
|
|
|
91368
91373
|
if (!data) {
|
|
@@ -91371,7 +91376,8 @@ function () {
|
|
|
91371
91376
|
];
|
|
91372
91377
|
}
|
|
91373
91378
|
|
|
91374
|
-
__version = data._version, __lastChangedAt = data._lastChangedAt, __deleted = data._deleted,
|
|
91379
|
+
__version = data._version, __lastChangedAt = data._lastChangedAt, __deleted = data._deleted, _outgoingData = __rest(data, ["_version", "_lastChangedAt", "_deleted"]);
|
|
91380
|
+
outgoingData = this.removeTimestampFields(head.model, _outgoingData); // Don't sync the version when the data in the response does not match the data
|
|
91375
91381
|
// in the request, i.e., when there's a handled conflict
|
|
91376
91382
|
|
|
91377
91383
|
if (!Object(_util__WEBPACK_IMPORTED_MODULE_2__["valuesEqual"])(incomingData, outgoingData, true)) {
|
|
@@ -91472,6 +91478,45 @@ function () {
|
|
|
91472
91478
|
data: data
|
|
91473
91479
|
}));
|
|
91474
91480
|
};
|
|
91481
|
+
/*
|
|
91482
|
+
if a model is using custom timestamp fields
|
|
91483
|
+
the custom field names will be stored in the model attributes
|
|
91484
|
+
e.g.
|
|
91485
|
+
"attributes": [
|
|
91486
|
+
{
|
|
91487
|
+
"type": "model",
|
|
91488
|
+
"properties": {
|
|
91489
|
+
"timestamps": {
|
|
91490
|
+
"createdAt": "createdOn",
|
|
91491
|
+
"updatedAt": "updatedOn"
|
|
91492
|
+
}
|
|
91493
|
+
}
|
|
91494
|
+
}
|
|
91495
|
+
]
|
|
91496
|
+
*/
|
|
91497
|
+
|
|
91498
|
+
|
|
91499
|
+
MutationEventOutbox.prototype.removeTimestampFields = function (model, record) {
|
|
91500
|
+
var _a, _b;
|
|
91501
|
+
|
|
91502
|
+
var CREATED_AT_DEFAULT_KEY = 'createdAt';
|
|
91503
|
+
var UPDATED_AT_DEFAULT_KEY = 'updatedAt';
|
|
91504
|
+
var createdTimestampKey = CREATED_AT_DEFAULT_KEY;
|
|
91505
|
+
var updatedTimestampKey = UPDATED_AT_DEFAULT_KEY;
|
|
91506
|
+
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) {
|
|
91507
|
+
return attr.type === 'model';
|
|
91508
|
+
});
|
|
91509
|
+
var timestampFieldsMap = (_b = modelAttributes === null || modelAttributes === void 0 ? void 0 : modelAttributes.properties) === null || _b === void 0 ? void 0 : _b.timestamps;
|
|
91510
|
+
|
|
91511
|
+
if (timestampFieldsMap) {
|
|
91512
|
+
createdTimestampKey = timestampFieldsMap[CREATED_AT_DEFAULT_KEY];
|
|
91513
|
+
updatedTimestampKey = timestampFieldsMap[UPDATED_AT_DEFAULT_KEY];
|
|
91514
|
+
}
|
|
91515
|
+
|
|
91516
|
+
delete record[createdTimestampKey];
|
|
91517
|
+
delete record[updatedTimestampKey];
|
|
91518
|
+
return record;
|
|
91519
|
+
};
|
|
91475
91520
|
|
|
91476
91521
|
return MutationEventOutbox;
|
|
91477
91522
|
}();
|