@infrab4a/connect 3.2.1 → 3.2.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.
@@ -2684,10 +2684,35 @@
2684
2684
  function OrderFirestoreRepository(firestore) {
2685
2685
  var _this = _super.call(this) || this;
2686
2686
  _this.firestore = firestore;
2687
+ _this.orderFromFirestore = function (order, id) {
2688
+ var _a;
2689
+ var modifiedOrder = _this.model.toInstance(Object.assign(Object.assign({}, order), { id: id }));
2690
+ if (!!((_a = modifiedOrder === null || modifiedOrder === void 0 ? void 0 : modifiedOrder.lineItems) === null || _a === void 0 ? void 0 : _a.length)) {
2691
+ modifiedOrder.lineItems = modifiedOrder.lineItems.map(function (lineItem) {
2692
+ if (!!lineItem.price[modifiedOrder.shop]) {
2693
+ var shopPrice = lineItem['price'][modifiedOrder.shop];
2694
+ lineItem['price'] = shopPrice;
2695
+ }
2696
+ return lineItem;
2697
+ });
2698
+ }
2699
+ return modifiedOrder;
2700
+ };
2687
2701
  _this.collectionName = 'orders';
2688
2702
  _this.model = Order;
2689
2703
  return _this;
2690
2704
  }
2705
+ OrderFirestoreRepository.prototype.buildModelInstance = function () {
2706
+ var _this = this;
2707
+ var _b = _super.prototype.buildModelInstance.call(this), fromFirestore = _b.fromFirestore, toFirestore = _b.toFirestore;
2708
+ return {
2709
+ toFirestore: function (data) { return toFirestore((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data); },
2710
+ fromFirestore: function (snap) {
2711
+ var instance = fromFirestore(snap);
2712
+ return _this.orderFromFirestore(instance, snap.id);
2713
+ },
2714
+ };
2715
+ };
2691
2716
  return OrderFirestoreRepository;
2692
2717
  }(withCrudFirestore(withHelpers(withFirestore(Base)))));
2693
2718