@aws-amplify/datastore 3.11.4-unstable.9 → 3.12.0
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 +18 -0
- package/dist/aws-amplify-datastore.js +97 -33
- package/dist/aws-amplify-datastore.js.map +1 -1
- package/dist/aws-amplify-datastore.min.js +8 -8
- package/dist/aws-amplify-datastore.min.js.map +1 -1
- package/lib/datastore/datastore.js +35 -18
- package/lib/datastore/datastore.js.map +1 -1
- package/lib/storage/adapter/AsyncStorageAdapter.js.map +1 -1
- package/lib/util.d.ts +19 -0
- package/lib/util.js +29 -0
- package/lib/util.js.map +1 -1
- package/lib-esm/datastore/datastore.js +36 -19
- package/lib-esm/datastore/datastore.js.map +1 -1
- package/lib-esm/storage/adapter/AsyncStorageAdapter.js.map +1 -1
- package/lib-esm/util.d.ts +19 -0
- package/lib-esm/util.js +28 -0
- package/lib-esm/util.js.map +1 -1
- package/package.json +7 -7
- package/src/datastore/datastore.ts +42 -22
- package/src/storage/adapter/AsyncStorageAdapter.ts +1 -0
- package/src/util.ts +40 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
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.12.0](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.11.3...@aws-amplify/datastore@3.12.0) (2022-06-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **@aws-amplify/datastore:** adds missing fields to items sent through observe/observeQuery ([#9973](https://github.com/aws-amplify/amplify-js/issues/9973)) ([ca2a11b](https://github.com/aws-amplify/amplify-js/commit/ca2a11b5bc987e71ce3344058a4886bf067cb17b))
|
|
12
|
+
* merge patches for consecutive copyOf ([#9936](https://github.com/aws-amplify/amplify-js/issues/9936)) ([d5dd9cb](https://github.com/aws-amplify/amplify-js/commit/d5dd9cb5bf46131fb046cfe55e4899444f9d789e))
|
|
13
|
+
* **@aws-amplify/datastore:** fixes observeQuery not removing newly-filtered items from snapshot ([#9879](https://github.com/aws-amplify/amplify-js/issues/9879)) ([d1356b1](https://github.com/aws-amplify/amplify-js/commit/d1356b1e498eb71a4902892afbb41f6ff88abb6f))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **datastore:** add error maps for error handler ([#9918](https://github.com/aws-amplify/amplify-js/issues/9918)) ([3a27096](https://github.com/aws-amplify/amplify-js/commit/3a270969b6e097eeed73368091ace191cbc05511))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
## [3.11.3](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.11.2...@aws-amplify/datastore@3.11.3) (2022-05-24)
|
|
7
25
|
|
|
8
26
|
**Note:** Version bump only for package @aws-amplify/datastore
|
|
@@ -82313,10 +82313,21 @@ var createModelClass = function createModelClass(modelDefinition) {
|
|
|
82313
82313
|
}, function (p) {
|
|
82314
82314
|
return patches = p;
|
|
82315
82315
|
});
|
|
82316
|
+
var hasExistingPatches = modelPatchesMap.has(source);
|
|
82316
82317
|
|
|
82317
|
-
if (patches.length) {
|
|
82318
|
-
|
|
82319
|
-
|
|
82318
|
+
if (patches.length || hasExistingPatches) {
|
|
82319
|
+
if (hasExistingPatches) {
|
|
82320
|
+
var _a = __read(modelPatchesMap.get(source), 2),
|
|
82321
|
+
existingPatches = _a[0],
|
|
82322
|
+
existingSource = _a[1];
|
|
82323
|
+
|
|
82324
|
+
var mergedPatches = Object(_util__WEBPACK_IMPORTED_MODULE_9__["mergePatches"])(existingSource, existingPatches, patches);
|
|
82325
|
+
modelPatchesMap.set(model, [mergedPatches, existingSource]);
|
|
82326
|
+
checkReadOnlyPropertyOnUpdate(mergedPatches, modelDefinition);
|
|
82327
|
+
} else {
|
|
82328
|
+
modelPatchesMap.set(model, [patches, source]);
|
|
82329
|
+
checkReadOnlyPropertyOnUpdate(patches, modelDefinition);
|
|
82330
|
+
}
|
|
82320
82331
|
}
|
|
82321
82332
|
|
|
82322
82333
|
return model;
|
|
@@ -83026,6 +83037,8 @@ function () {
|
|
|
83026
83037
|
|
|
83027
83038
|
(function () {
|
|
83028
83039
|
return __awaiter(_this, void 0, void 0, function () {
|
|
83040
|
+
var _this = this;
|
|
83041
|
+
|
|
83029
83042
|
return __generator(this, function (_a) {
|
|
83030
83043
|
switch (_a.label) {
|
|
83031
83044
|
case 0:
|
|
@@ -83041,24 +83054,44 @@ function () {
|
|
|
83041
83054
|
handle = this.storage.observe(modelConstructor, predicate).filter(function (_a) {
|
|
83042
83055
|
var model = _a.model;
|
|
83043
83056
|
return namespaceResolver(model) === _util__WEBPACK_IMPORTED_MODULE_9__["USER"];
|
|
83044
|
-
}).
|
|
83045
|
-
|
|
83046
|
-
|
|
83047
|
-
|
|
83048
|
-
|
|
83049
|
-
|
|
83050
|
-
|
|
83051
|
-
|
|
83052
|
-
|
|
83053
|
-
|
|
83054
|
-
|
|
83055
|
-
|
|
83056
|
-
|
|
83057
|
-
|
|
83058
|
-
|
|
83059
|
-
|
|
83060
|
-
|
|
83061
|
-
|
|
83057
|
+
}).subscribe({
|
|
83058
|
+
next: function next(item) {
|
|
83059
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
83060
|
+
var message, freshElement;
|
|
83061
|
+
return __generator(this, function (_a) {
|
|
83062
|
+
switch (_a.label) {
|
|
83063
|
+
case 0:
|
|
83064
|
+
message = item;
|
|
83065
|
+
if (!(item.opType !== 'DELETE')) return [3
|
|
83066
|
+
/*break*/
|
|
83067
|
+
, 2];
|
|
83068
|
+
return [4
|
|
83069
|
+
/*yield*/
|
|
83070
|
+
, this.query(item.model, item.element.id)];
|
|
83071
|
+
|
|
83072
|
+
case 1:
|
|
83073
|
+
freshElement = _a.sent();
|
|
83074
|
+
message = __assign(__assign({}, message), {
|
|
83075
|
+
element: freshElement
|
|
83076
|
+
});
|
|
83077
|
+
_a.label = 2;
|
|
83078
|
+
|
|
83079
|
+
case 2:
|
|
83080
|
+
observer.next(message);
|
|
83081
|
+
return [2
|
|
83082
|
+
/*return*/
|
|
83083
|
+
];
|
|
83084
|
+
}
|
|
83085
|
+
});
|
|
83086
|
+
});
|
|
83087
|
+
},
|
|
83088
|
+
error: function error(err) {
|
|
83089
|
+
return observer.error(err);
|
|
83090
|
+
},
|
|
83091
|
+
complete: function complete() {
|
|
83092
|
+
return observer.complete();
|
|
83093
|
+
}
|
|
83094
|
+
});
|
|
83062
83095
|
return [2
|
|
83063
83096
|
/*return*/
|
|
83064
83097
|
];
|
|
@@ -96271,7 +96304,7 @@ var LimitTimerRaceResolvedValues;
|
|
|
96271
96304
|
/*!*************************!*\
|
|
96272
96305
|
!*** ./lib-esm/util.js ***!
|
|
96273
96306
|
\*************************/
|
|
96274
|
-
/*! exports provided: exhaustiveCheck, isNullOrUndefined, validatePredicate, validatePredicateField, isModelConstructor, registerNonModelClass, isNonModelConstructor, processCompositeKeys, establishRelationAndKeys, traverseModel, getIndex, getIndexFromAssociation, NAMESPACES, USER, SYNC, STORAGE, DATASTORE, isPrivateMode, monotonicUlidFactory, getNow, sortCompareFunction, valuesEqual, isAWSDate, isAWSTime, isAWSDateTime, isAWSTimestamp, isAWSEmail, isAWSJSON, isAWSURL, isAWSPhone, isAWSIPAddress, DeferredPromise, DeferredCallbackResolver */
|
|
96307
|
+
/*! exports provided: exhaustiveCheck, isNullOrUndefined, validatePredicate, validatePredicateField, isModelConstructor, registerNonModelClass, isNonModelConstructor, processCompositeKeys, establishRelationAndKeys, traverseModel, getIndex, getIndexFromAssociation, NAMESPACES, USER, SYNC, STORAGE, DATASTORE, isPrivateMode, monotonicUlidFactory, getNow, sortCompareFunction, valuesEqual, isAWSDate, isAWSTime, isAWSDateTime, isAWSTimestamp, isAWSEmail, isAWSJSON, isAWSURL, isAWSPhone, isAWSIPAddress, DeferredPromise, DeferredCallbackResolver, mergePatches */
|
|
96275
96308
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
96276
96309
|
|
|
96277
96310
|
"use strict";
|
|
@@ -96309,13 +96342,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
96309
96342
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isAWSIPAddress", function() { return isAWSIPAddress; });
|
|
96310
96343
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeferredPromise", function() { return DeferredPromise; });
|
|
96311
96344
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeferredCallbackResolver", function() { return DeferredCallbackResolver; });
|
|
96345
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mergePatches", function() { return mergePatches; });
|
|
96312
96346
|
/* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! buffer */ "../../node_modules/buffer/index.js");
|
|
96313
96347
|
/* harmony import */ var buffer__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(buffer__WEBPACK_IMPORTED_MODULE_0__);
|
|
96314
96348
|
/* harmony import */ var ulid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ulid */ "../../node_modules/ulid/dist/index.esm.js");
|
|
96315
96349
|
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uuid */ "./node_modules/uuid/index.js");
|
|
96316
96350
|
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(uuid__WEBPACK_IMPORTED_MODULE_2__);
|
|
96317
|
-
/* harmony import */ var
|
|
96318
|
-
/* harmony import */ var
|
|
96351
|
+
/* harmony import */ var immer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! immer */ "./node_modules/immer/dist/immer.esm.js");
|
|
96352
|
+
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./types */ "./lib-esm/types.js");
|
|
96353
|
+
/* harmony import */ var amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! amazon-cognito-identity-js */ "../amazon-cognito-identity-js/es/index.js");
|
|
96319
96354
|
function _typeof(obj) {
|
|
96320
96355
|
"@babel/helpers - typeof";
|
|
96321
96356
|
|
|
@@ -96526,6 +96561,7 @@ var __values = undefined && undefined.__values || function (o) {
|
|
|
96526
96561
|
|
|
96527
96562
|
|
|
96528
96563
|
|
|
96564
|
+
|
|
96529
96565
|
var exhaustiveCheck = function exhaustiveCheck(obj, throwOnError) {
|
|
96530
96566
|
if (throwOnError === void 0) {
|
|
96531
96567
|
throwOnError = true;
|
|
@@ -96565,7 +96601,7 @@ var validatePredicate = function validatePredicate(model, groupType, predicatesO
|
|
|
96565
96601
|
}
|
|
96566
96602
|
|
|
96567
96603
|
var result = predicatesOrGroups[filterType](function (predicateOrGroup) {
|
|
96568
|
-
if (Object(
|
|
96604
|
+
if (Object(_types__WEBPACK_IMPORTED_MODULE_4__["isPredicateObj"])(predicateOrGroup)) {
|
|
96569
96605
|
var field = predicateOrGroup.field,
|
|
96570
96606
|
operator = predicateOrGroup.operator,
|
|
96571
96607
|
operand = predicateOrGroup.operand;
|
|
@@ -96573,7 +96609,7 @@ var validatePredicate = function validatePredicate(model, groupType, predicatesO
|
|
|
96573
96609
|
return validatePredicateField(value, operator, operand);
|
|
96574
96610
|
}
|
|
96575
96611
|
|
|
96576
|
-
if (Object(
|
|
96612
|
+
if (Object(_types__WEBPACK_IMPORTED_MODULE_4__["isPredicateGroup"])(predicateOrGroup)) {
|
|
96577
96613
|
var type = predicateOrGroup.type,
|
|
96578
96614
|
predicates = predicateOrGroup.predicates;
|
|
96579
96615
|
return validatePredicate(model, type, predicates);
|
|
@@ -96676,7 +96712,7 @@ var processCompositeKeys = function processCompositeKeys(attributes) {
|
|
|
96676
96712
|
return sortKeyFields;
|
|
96677
96713
|
};
|
|
96678
96714
|
|
|
96679
|
-
var compositeKeyFields = attributes.filter(
|
|
96715
|
+
var compositeKeyFields = attributes.filter(_types__WEBPACK_IMPORTED_MODULE_4__["isModelAttributeCompositeKey"]).map(extractCompositeSortKey);
|
|
96680
96716
|
/*
|
|
96681
96717
|
if 2 sets of fields have any intersecting fields => combine them into 1 union set
|
|
96682
96718
|
e.g., ['a', 'b', 'c'] and ['a', 'b', 'd'] => ['a', 'b', 'c', 'd']
|
|
@@ -96755,11 +96791,11 @@ var establishRelationAndKeys = function establishRelationAndKeys(namespace) {
|
|
|
96755
96791
|
for (var _e = __values(model.attributes), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
96756
96792
|
var attribute = _f.value;
|
|
96757
96793
|
|
|
96758
|
-
if (!Object(
|
|
96794
|
+
if (!Object(_types__WEBPACK_IMPORTED_MODULE_4__["isModelAttributeKey"])(attribute)) {
|
|
96759
96795
|
continue;
|
|
96760
96796
|
}
|
|
96761
96797
|
|
|
96762
|
-
if (Object(
|
|
96798
|
+
if (Object(_types__WEBPACK_IMPORTED_MODULE_4__["isModelAttributePrimaryKey"])(attribute)) {
|
|
96763
96799
|
keys[mKey].primaryKey = attribute.properties.fields;
|
|
96764
96800
|
}
|
|
96765
96801
|
|
|
@@ -96986,7 +97022,7 @@ var isPrivateMode = function isPrivateMode() {
|
|
|
96986
97022
|
};
|
|
96987
97023
|
|
|
96988
97024
|
var randomBytes = function randomBytes(nBytes) {
|
|
96989
|
-
return buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].from(new
|
|
97025
|
+
return buffer__WEBPACK_IMPORTED_MODULE_0__["Buffer"].from(new amazon_cognito_identity_js__WEBPACK_IMPORTED_MODULE_5__["WordArray"]().random(nBytes).toString(), 'hex');
|
|
96990
97026
|
};
|
|
96991
97027
|
|
|
96992
97028
|
var prng = function prng() {
|
|
@@ -97031,7 +97067,7 @@ function sortCompareFunction(sortPredicates) {
|
|
|
97031
97067
|
var field = predicate.field,
|
|
97032
97068
|
sortDirection = predicate.sortDirection; // reverse result when direction is descending
|
|
97033
97069
|
|
|
97034
|
-
var sortMultiplier = sortDirection ===
|
|
97070
|
+
var sortMultiplier = sortDirection === _types__WEBPACK_IMPORTED_MODULE_4__["SortDirection"].ASCENDING ? 1 : -1;
|
|
97035
97071
|
|
|
97036
97072
|
if (a[field] < b[field]) {
|
|
97037
97073
|
return -1 * sortMultiplier;
|
|
@@ -97220,7 +97256,7 @@ function () {
|
|
|
97220
97256
|
|
|
97221
97257
|
this.timerPromise = new Promise(function (resolve, reject) {
|
|
97222
97258
|
_this.timer = setTimeout(function () {
|
|
97223
|
-
resolve(
|
|
97259
|
+
resolve(_types__WEBPACK_IMPORTED_MODULE_4__["LimitTimerRaceResolvedValues"].TIMER);
|
|
97224
97260
|
}, _this.maxInterval);
|
|
97225
97261
|
});
|
|
97226
97262
|
};
|
|
@@ -97280,13 +97316,41 @@ function () {
|
|
|
97280
97316
|
};
|
|
97281
97317
|
|
|
97282
97318
|
DeferredCallbackResolver.prototype.resolve = function () {
|
|
97283
|
-
this.limitPromise.resolve(
|
|
97319
|
+
this.limitPromise.resolve(_types__WEBPACK_IMPORTED_MODULE_4__["LimitTimerRaceResolvedValues"].LIMIT);
|
|
97284
97320
|
};
|
|
97285
97321
|
|
|
97286
97322
|
return DeferredCallbackResolver;
|
|
97287
97323
|
}();
|
|
97288
97324
|
|
|
97289
97325
|
|
|
97326
|
+
/**
|
|
97327
|
+
* merge two sets of patches created by immer produce.
|
|
97328
|
+
* newPatches take precedent over oldPatches for patches modifying the same path.
|
|
97329
|
+
* In the case many consecutive pathces are merged the original model should
|
|
97330
|
+
* always be the root model.
|
|
97331
|
+
*
|
|
97332
|
+
* Example:
|
|
97333
|
+
* A -> B, patches1
|
|
97334
|
+
* B -> C, patches2
|
|
97335
|
+
*
|
|
97336
|
+
* mergePatches(A, patches1, patches2) to get patches for A -> C
|
|
97337
|
+
*
|
|
97338
|
+
* @param originalSource the original Model the patches should be applied to
|
|
97339
|
+
* @param oldPatches immer produce patch list
|
|
97340
|
+
* @param newPatches immer produce patch list (will take precedence)
|
|
97341
|
+
* @return merged patches
|
|
97342
|
+
*/
|
|
97343
|
+
|
|
97344
|
+
function mergePatches(originalSource, oldPatches, newPatches) {
|
|
97345
|
+
var patchesToMerge = oldPatches.concat(newPatches);
|
|
97346
|
+
var patches;
|
|
97347
|
+
Object(immer__WEBPACK_IMPORTED_MODULE_3__["produce"])(originalSource, function (draft) {
|
|
97348
|
+
Object(immer__WEBPACK_IMPORTED_MODULE_3__["applyPatches"])(draft, patchesToMerge);
|
|
97349
|
+
}, function (p) {
|
|
97350
|
+
patches = p;
|
|
97351
|
+
});
|
|
97352
|
+
return patches;
|
|
97353
|
+
}
|
|
97290
97354
|
|
|
97291
97355
|
/***/ }),
|
|
97292
97356
|
|