@aws-amplify/datastore 3.11.4-unstable.12 → 3.11.4-unstable.13

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.
@@ -83037,6 +83037,8 @@ function () {
83037
83037
 
83038
83038
  (function () {
83039
83039
  return __awaiter(_this, void 0, void 0, function () {
83040
+ var _this = this;
83041
+
83040
83042
  return __generator(this, function (_a) {
83041
83043
  switch (_a.label) {
83042
83044
  case 0:
@@ -83052,24 +83054,44 @@ function () {
83052
83054
  handle = this.storage.observe(modelConstructor, predicate).filter(function (_a) {
83053
83055
  var model = _a.model;
83054
83056
  return namespaceResolver(model) === _util__WEBPACK_IMPORTED_MODULE_9__["USER"];
83055
- }).map(function (event) {
83056
- // The `element` returned by storage only contains updated fields.
83057
- // Intercept the event to send the `savedElement` so that the first
83058
- // snapshot returned to the consumer contains all fields.
83059
- // In the event of a delete we return `element`, as `savedElement`
83060
- // here is undefined.
83061
- var opType = event.opType,
83062
- model = event.model,
83063
- condition = event.condition,
83064
- element = event.element,
83065
- savedElement = event.savedElement;
83066
- return {
83067
- opType: opType,
83068
- element: savedElement || element,
83069
- model: model,
83070
- condition: condition
83071
- };
83072
- }).subscribe(observer);
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
+ });
83073
83095
  return [2
83074
83096
  /*return*/
83075
83097
  ];