@pisell/pisellos 0.10.15 → 0.10.17
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/dist/core/index.js +6 -9
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/example.js +3 -26
- package/dist/model/strategy/strategy-example.js +5 -19
- package/dist/modules/Cart/index.js +0 -3
- package/dist/modules/Cart/utils/cartProduct.js +0 -1
- package/dist/modules/Date/index.js +1 -5
- package/dist/modules/Discount/index.js +2 -4
- package/dist/modules/OpenData/index.d.ts +5 -2
- package/dist/modules/OpenData/index.js +27 -14
- package/dist/modules/OpenData/types.d.ts +42 -0
- package/dist/modules/OpenData/types.js +7 -1
- package/dist/modules/OpenData/utils.d.ts +15 -1
- package/dist/modules/OpenData/utils.js +85 -0
- package/dist/modules/Order/index.d.ts +4 -2
- package/dist/modules/Order/index.js +131 -123
- package/dist/modules/Order/types.d.ts +8 -1
- package/dist/modules/Order/types.js +1 -0
- package/dist/modules/Order/utils.js +7 -1
- package/dist/modules/Payment/index.js +97 -162
- package/dist/modules/Product/types.d.ts +2 -0
- package/dist/modules/ProductList/index.js +96 -74
- package/dist/modules/Rules/index.js +12 -12
- package/dist/modules/SalesSummary/index.js +6 -4
- package/dist/modules/Schedule/index.js +0 -1
- package/dist/modules/Schedule/utils.js +0 -1
- package/dist/modules/Step/index.js +0 -1
- package/dist/plugins/request.js +1 -4
- package/dist/plugins/window.js +2 -6
- package/dist/server/index.d.ts +11 -0
- package/dist/server/index.js +977 -641
- package/dist/server/modules/menu/index.js +32 -41
- package/dist/server/modules/order/index.d.ts +8 -0
- package/dist/server/modules/order/index.js +253 -219
- package/dist/server/modules/products/index.js +24 -42
- package/dist/server/modules/quotation/index.js +29 -38
- package/dist/server/modules/resource/index.js +3 -4
- package/dist/server/modules/schedule/index.js +27 -35
- package/dist/server/utils/product.js +0 -1
- package/dist/server/utils/small-ticket.d.ts +9 -1
- package/dist/server/utils/small-ticket.js +117 -43
- package/dist/solution/BaseSales/index.d.ts +7 -0
- package/dist/solution/BaseSales/index.js +350 -215
- package/dist/solution/BaseSales/types.d.ts +2 -0
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +15 -6
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +7 -1
- package/dist/solution/BaseSales/utils.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingByStep/index.js +7 -59
- package/dist/solution/BookingByStep/utils/capacity.js +1 -11
- package/dist/solution/BookingByStep/utils/resources.js +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
- package/dist/solution/BookingTicket/index.d.ts +14 -19
- package/dist/solution/BookingTicket/index.js +553 -433
- package/dist/solution/BookingTicket/utils/addProductDecision.js +3 -1
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +6 -7
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
- package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
- package/dist/solution/BuyTickets/index.js +9 -12
- package/dist/solution/Checkout/index.js +177 -252
- package/dist/solution/Checkout/utils/index.js +4 -16
- package/dist/solution/RegisterAndLogin/index.js +30 -76
- package/dist/solution/Sales/index.d.ts +20 -4
- package/dist/solution/Sales/index.js +348 -75
- package/dist/solution/Sales/types.d.ts +10 -0
- package/dist/solution/ScanOrder/index.js +50 -60
- package/dist/solution/ScanOrder/types.d.ts +2 -0
- package/dist/solution/ScanOrder/utils.js +6 -3
- package/dist/solution/ShopDiscount/index.js +2 -7
- package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/dist/solution/UnifiedBookingSales/index.js +495 -422
- package/dist/solution/UnifiedBookingSales/types.d.ts +7 -1
- package/dist/solution/VenueBooking/index.js +45 -55
- package/dist/utils/task.js +15 -18
- package/dist/utils/watch.js +0 -1
- package/lib/apis/picoding.js +2 -0
- package/lib/core/index.js +131 -131
- package/lib/effects/index.js +46 -57
- package/lib/index.js +82 -49
- package/lib/model/index.js +14 -21
- package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +209 -315
- package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
- package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
- package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
- package/lib/model/strategy/adapter/index.js +100 -64
- package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
- package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
- package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
- package/lib/model/strategy/adapter/itemRule/index.js +83 -57
- package/lib/model/strategy/adapter/itemRule/type.js +97 -36
- package/lib/model/strategy/adapter/promotion/adapter.js +91 -69
- package/lib/model/strategy/adapter/promotion/evaluator.js +444 -310
- package/lib/model/strategy/adapter/promotion/examples.js +222 -234
- package/lib/model/strategy/adapter/promotion/index.js +1 -51
- package/lib/model/strategy/adapter/promotion/type.js +243 -36
- package/lib/model/strategy/adapter/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -150
- package/lib/model/strategy/adapter/walletPass/example.js +217 -190
- package/lib/model/strategy/adapter/walletPass/index.js +75 -51
- package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
- package/lib/model/strategy/adapter/walletPass/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/utils.js +588 -378
- package/lib/model/strategy/engine.js +270 -168
- package/lib/model/strategy/index.js +49 -34
- package/lib/model/strategy/strategy-example.js +243 -239
- package/lib/model/strategy/type.js +100 -40
- package/lib/modules/Account/index.js +39 -53
- package/lib/modules/Account/types.js +20 -33
- package/lib/modules/AccountList/index.js +116 -154
- package/lib/modules/AccountList/types.js +30 -31
- package/lib/modules/AccountList/utils.js +18 -30
- package/lib/modules/BaseModule.js +23 -42
- package/lib/modules/BookingContext/index.js +158 -136
- package/lib/modules/BookingContext/types.js +46 -32
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +138 -146
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +78 -83
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +170 -150
- package/lib/modules/BookingContext/utils/flexible.js +38 -55
- package/lib/modules/BookingContext/utils/formatResourceList.js +19 -34
- package/lib/modules/BookingContext/utils/index.js +124 -41
- package/lib/modules/BookingContext/utils/noResource.js +58 -70
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +14 -41
- package/lib/modules/BookingContext/utils/productExtend.js +202 -155
- package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
- package/lib/modules/BookingContext/utils/resourceSelection.js +19 -41
- package/lib/modules/BookingContext/utils/resources.js +209 -167
- package/lib/modules/BookingContext/utils/serviceTimes.js +115 -116
- package/lib/modules/BookingContext/utils/timeSlices.js +76 -86
- package/lib/modules/Cart/index.js +170 -124
- package/lib/modules/Cart/types.js +46 -51
- package/lib/modules/Cart/utils/cartAccount.js +40 -39
- package/lib/modules/Cart/utils/cartDate.js +56 -61
- package/lib/modules/Cart/utils/cartDiscount.js +28 -33
- package/lib/modules/Cart/utils/cartNote.js +27 -32
- package/lib/modules/Cart/utils/cartProduct.js +321 -251
- package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
- package/lib/modules/Cart/utils/cartResource.js +70 -78
- package/lib/modules/Cart/utils/changePrice.js +22 -50
- package/lib/modules/Cart/utils/index.js +106 -48
- package/lib/modules/Customer/constants.js +13 -34
- package/lib/modules/Customer/index.js +235 -172
- package/lib/modules/Customer/types.js +38 -35
- package/lib/modules/Date/index.js +116 -115
- package/lib/modules/Date/types.js +16 -28
- package/lib/modules/Date/utils.js +174 -123
- package/lib/modules/Discount/index.js +133 -143
- package/lib/modules/Discount/types.js +9 -31
- package/lib/modules/Guests/index.js +30 -56
- package/lib/modules/Guests/types.js +23 -33
- package/lib/modules/Holder/index.js +209 -189
- package/lib/modules/Holder/types.js +4 -16
- package/lib/modules/Holder/utils.js +20 -49
- package/lib/modules/OpenData/index.d.ts +5 -2
- package/lib/modules/OpenData/index.js +119 -78
- package/lib/modules/OpenData/types.d.ts +42 -0
- package/lib/modules/OpenData/types.js +12 -16
- package/lib/modules/OpenData/utils.d.ts +15 -1
- package/lib/modules/OpenData/utils.js +129 -78
- package/lib/modules/Order/index.d.ts +4 -2
- package/lib/modules/Order/index.js +1843 -2251
- package/lib/modules/Order/payment-utils.js +77 -120
- package/lib/modules/Order/types.d.ts +8 -1
- package/lib/modules/Order/types.js +88 -35
- package/lib/modules/Order/utils/bundleDiscountHydration.js +41 -74
- package/lib/modules/Order/utils/discountProductLineIdentity.js +142 -100
- package/lib/modules/Order/utils/manualProductDiscount.js +124 -123
- package/lib/modules/Order/utils/orderCollectionIdentity.js +184 -244
- package/lib/modules/Order/utils/virtualSettlement.js +120 -171
- package/lib/modules/Order/utils.js +834 -668
- package/lib/modules/Payment/cash.js +20 -33
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
- package/lib/modules/Payment/eftpos.js +16 -30
- package/lib/modules/Payment/index.js +532 -399
- package/lib/modules/Payment/mx51.js +1 -0
- package/lib/modules/Payment/types.js +230 -108
- package/lib/modules/Payment/utils.js +52 -51
- package/lib/modules/Payment/walletpass.js +485 -660
- package/lib/modules/Product/index.js +51 -46
- package/lib/modules/Product/types.d.ts +2 -0
- package/lib/modules/Product/types.js +4 -16
- package/lib/modules/Product/utils.js +32 -33
- package/lib/modules/ProductList/index.js +141 -161
- package/lib/modules/ProductList/types.js +9 -31
- package/lib/modules/Quotation/index.js +66 -100
- package/lib/modules/Quotation/types.js +4 -16
- package/lib/modules/Resource/index.js +27 -59
- package/lib/modules/Resource/types.js +22 -32
- package/lib/modules/Resource/utils.js +30 -38
- package/lib/modules/ResourcePlanner/index.js +25 -23
- package/lib/modules/ResourcePlanner/localClock.js +54 -119
- package/lib/modules/ResourcePlanner/planner.js +591 -772
- package/lib/modules/ResourcePlanner/types.js +10 -29
- package/lib/modules/Rules/index.js +1224 -963
- package/lib/modules/Rules/types.js +17 -40
- package/lib/modules/SalesSummary/index.js +80 -89
- package/lib/modules/SalesSummary/types.js +4 -16
- package/lib/modules/SalesSummary/utils.js +359 -442
- package/lib/modules/ScanOrderLogger/index.js +59 -79
- package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
- package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
- package/lib/modules/ScanOrderLogger/types.js +4 -16
- package/lib/modules/Schedule/getDateIsInSchedule.js +334 -163
- package/lib/modules/Schedule/index.js +100 -114
- package/lib/modules/Schedule/type.js +4 -16
- package/lib/modules/Schedule/types.js +4 -16
- package/lib/modules/Schedule/utils.js +433 -291
- package/lib/modules/Step/index.js +40 -52
- package/lib/modules/Step/tyeps.js +4 -16
- package/lib/modules/Summary/index.js +66 -71
- package/lib/modules/Summary/types.js +4 -16
- package/lib/modules/Summary/utils.js +773 -418
- package/lib/modules/SurchargeList/index.js +46 -60
- package/lib/modules/SurchargeList/types.js +4 -16
- package/lib/modules/index.js +245 -63
- package/lib/plugins/app.js +4 -16
- package/lib/plugins/index.js +36 -25
- package/lib/plugins/request.js +137 -126
- package/lib/plugins/shopStore.js +4 -16
- package/lib/plugins/user.js +4 -16
- package/lib/plugins/window.js +171 -179
- package/lib/server/index.d.ts +11 -0
- package/lib/server/index.js +3432 -2757
- package/lib/server/modules/floor-plan/index.js +102 -123
- package/lib/server/modules/floor-plan/types.js +15 -30
- package/lib/server/modules/index.js +106 -68
- package/lib/server/modules/menu/index.js +146 -122
- package/lib/server/modules/menu/types.js +18 -31
- package/lib/server/modules/order/index.d.ts +8 -0
- package/lib/server/modules/order/index.js +781 -956
- package/lib/server/modules/order/types.js +122 -33
- package/lib/server/modules/order/utils/filterBookings.js +219 -194
- package/lib/server/modules/order/utils/filterOrders.js +118 -92
- package/lib/server/modules/payment/index.js +59 -83
- package/lib/server/modules/payment/types.js +4 -16
- package/lib/server/modules/products/index.js +575 -459
- package/lib/server/modules/products/types.js +44 -34
- package/lib/server/modules/quotation/index.js +137 -172
- package/lib/server/modules/quotation/types.js +21 -31
- package/lib/server/modules/resource/index.js +213 -184
- package/lib/server/modules/resource/types.js +42 -33
- package/lib/server/modules/schedule/index.js +135 -123
- package/lib/server/modules/schedule/types.js +14 -21
- package/lib/server/modules/schedule/utils.js +334 -163
- package/lib/server/types.js +4 -16
- package/lib/server/utils/index.js +25 -23
- package/lib/server/utils/product.js +196 -139
- package/lib/server/utils/schedule.js +34 -41
- package/lib/server/utils/small-ticket.d.ts +9 -1
- package/lib/server/utils/small-ticket.js +565 -470
- package/lib/server/utils/time.js +40 -49
- package/lib/solution/BaseSales/index.d.ts +7 -0
- package/lib/solution/BaseSales/index.js +1385 -1503
- package/lib/solution/BaseSales/types.d.ts +2 -0
- package/lib/solution/BaseSales/types.js +42 -38
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +5 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +652 -498
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +85 -105
- package/lib/solution/BaseSales/utils/quotationPrice.js +56 -114
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +138 -180
- package/lib/solution/BaseSales/utils.js +161 -143
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingByStep/index.js +1527 -1340
- package/lib/solution/BookingByStep/types.js +40 -99
- package/lib/solution/BookingByStep/utils/capacity.js +192 -160
- package/lib/solution/BookingByStep/utils/products.js +42 -52
- package/lib/solution/BookingByStep/utils/resources.js +527 -330
- package/lib/solution/BookingByStep/utils/stock.js +65 -44
- package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
- package/lib/solution/BookingTicket/index.d.ts +14 -19
- package/lib/solution/BookingTicket/index.js +663 -526
- package/lib/solution/BookingTicket/types.js +99 -77
- package/lib/solution/BookingTicket/utils/addProductDecision.js +229 -190
- package/lib/solution/BookingTicket/utils/addTimeAvailability.js +58 -89
- package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -78
- package/lib/solution/BookingTicket/utils/cartView.js +114 -99
- package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +18 -41
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +219 -86
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +168 -116
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +79 -91
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +54 -41
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -81
- package/lib/solution/BookingTicket/utils/scan/index.js +98 -104
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +52 -64
- package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +56 -58
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +34 -48
- package/lib/solution/BuyTickets/index.js +67 -70
- package/lib/solution/BuyTickets/types.js +22 -38
- package/lib/solution/Checkout/index.js +1451 -1158
- package/lib/solution/Checkout/types.js +91 -61
- package/lib/solution/Checkout/utils/index.js +228 -156
- package/lib/solution/PlaceOrder/index.js +55 -0
- package/lib/solution/RegisterAndLogin/config.js +493 -460
- package/lib/solution/RegisterAndLogin/index.js +633 -630
- package/lib/solution/RegisterAndLogin/types.js +189 -76
- package/lib/solution/RegisterAndLogin/utils.js +183 -125
- package/lib/solution/Sales/index.d.ts +20 -4
- package/lib/solution/Sales/index.js +502 -330
- package/lib/solution/Sales/types.d.ts +10 -0
- package/lib/solution/Sales/types.js +27 -33
- package/lib/solution/ScanOrder/index.js +822 -852
- package/lib/solution/ScanOrder/types.d.ts +2 -0
- package/lib/solution/ScanOrder/types.js +33 -34
- package/lib/solution/ScanOrder/utils.js +412 -374
- package/lib/solution/ShopDiscount/index.js +226 -232
- package/lib/solution/ShopDiscount/types.js +15 -37
- package/lib/solution/ShopDiscount/utils.js +300 -172
- package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/lib/solution/UnifiedBookingSales/index.js +1087 -1222
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +99 -159
- package/lib/solution/UnifiedBookingSales/types.d.ts +7 -1
- package/lib/solution/UnifiedBookingSales/types.js +10 -32
- package/lib/solution/VenueBooking/index.js +811 -879
- package/lib/solution/VenueBooking/types.js +19 -39
- package/lib/solution/VenueBooking/utils/dateSummary.js +27 -56
- package/lib/solution/VenueBooking/utils/resource.js +31 -54
- package/lib/solution/VenueBooking/utils/slotMerge.js +94 -107
- package/lib/solution/VenueBooking/utils/timeSlot.js +132 -132
- package/lib/solution/VenueBooking/utils.js +130 -67
- package/lib/solution/index.js +124 -41
- package/lib/store/createStore.js +32 -29
- package/lib/types/index.js +4 -16
- package/lib/utils/payment-number.js +26 -46
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +81 -47
- package/package.json +2 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
5
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
6
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
7
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
4
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
5
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
9
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
10
10
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
11
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
12
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
@@ -90,6 +90,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
90
90
|
_defineProperty(_assertThisInitialized(_this), "orderSQLiteSaveQueue", Promise.resolve());
|
|
91
91
|
/** 按 storageKey 记录最近一次 SQLite 写入来源与时间,用于去重 */
|
|
92
92
|
_defineProperty(_assertThisInitialized(_this), "recentSqliteWriteByStorageKey", new Map());
|
|
93
|
+
/** 最近一次清理过期 SQLite 去重记录的时间,避免每次写入都遍历 Map */
|
|
94
|
+
_defineProperty(_assertThisInitialized(_this), "lastRecentSqliteWriteCleanupAtMs", 0);
|
|
93
95
|
/** 最近一次 SSE 全量拉取完成时间 */
|
|
94
96
|
_defineProperty(_assertThisInitialized(_this), "lastServerFullFetchAtMs", 0);
|
|
95
97
|
return _this;
|
|
@@ -115,7 +117,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
115
117
|
case 0:
|
|
116
118
|
changedOrders = _args.length > 0 && _args[0] !== undefined ? _args[0] : [];
|
|
117
119
|
source = _args.length > 1 ? _args[1] : undefined;
|
|
118
|
-
console.log('触发emitOrdersChanged');
|
|
119
120
|
payload = {
|
|
120
121
|
list: this.store.list,
|
|
121
122
|
changedOrders: changedOrders.map(function (order) {
|
|
@@ -123,9 +124,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
123
124
|
}),
|
|
124
125
|
source: source
|
|
125
126
|
};
|
|
126
|
-
_context.next =
|
|
127
|
+
_context.next = 5;
|
|
127
128
|
return this.core.effects.emit(OrderHooks.onOrdersChanged, payload);
|
|
128
|
-
case
|
|
129
|
+
case 5:
|
|
129
130
|
case "end":
|
|
130
131
|
return _context.stop();
|
|
131
132
|
}
|
|
@@ -429,6 +430,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
429
430
|
return this.normalizeOrderCollectionsForIngress(applyOrderCollectionUidRemaps(reconciled, uidRemaps), 'overwriteExistingOrder.reconciled');
|
|
430
431
|
}
|
|
431
432
|
|
|
433
|
+
/**
|
|
434
|
+
* 惰性清理已经超过去重窗口的 SQLite 写入记录。
|
|
435
|
+
*
|
|
436
|
+
* 清理频率与去重窗口一致,既限制 Map 长期增长,也不会移除仍参与去重的记录。
|
|
437
|
+
*/
|
|
438
|
+
}, {
|
|
439
|
+
key: "cleanupExpiredRecentSqliteWrites",
|
|
440
|
+
value: function cleanupExpiredRecentSqliteWrites(now) {
|
|
441
|
+
var elapsedSinceCleanup = now - this.lastRecentSqliteWriteCleanupAtMs;
|
|
442
|
+
if (this.lastRecentSqliteWriteCleanupAtMs > 0 && elapsedSinceCleanup >= 0 && elapsedSinceCleanup < ORDER_SQLITE_DEDUPE_MS) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
var _iterator3 = _createForOfIteratorHelper(this.recentSqliteWriteByStorageKey),
|
|
446
|
+
_step3;
|
|
447
|
+
try {
|
|
448
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
449
|
+
var _step3$value = _slicedToArray(_step3.value, 2),
|
|
450
|
+
storageKey = _step3$value[0],
|
|
451
|
+
recentWrite = _step3$value[1];
|
|
452
|
+
if (now - recentWrite.ts >= ORDER_SQLITE_DEDUPE_MS) {
|
|
453
|
+
this.recentSqliteWriteByStorageKey.delete(storageKey);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
} catch (err) {
|
|
457
|
+
_iterator3.e(err);
|
|
458
|
+
} finally {
|
|
459
|
+
_iterator3.f();
|
|
460
|
+
}
|
|
461
|
+
this.lastRecentSqliteWriteCleanupAtMs = now;
|
|
462
|
+
}
|
|
463
|
+
|
|
432
464
|
/**
|
|
433
465
|
* 记录订单最近一次 SQLite 写入,供 pubsub 回声去重使用。
|
|
434
466
|
*
|
|
@@ -439,11 +471,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
439
471
|
key: "recordRecentSqliteWrite",
|
|
440
472
|
value: function recordRecentSqliteWrite(source, orders) {
|
|
441
473
|
var now = Date.now();
|
|
442
|
-
|
|
443
|
-
|
|
474
|
+
this.cleanupExpiredRecentSqliteWrites(now);
|
|
475
|
+
var _iterator4 = _createForOfIteratorHelper(orders),
|
|
476
|
+
_step4;
|
|
444
477
|
try {
|
|
445
|
-
for (
|
|
446
|
-
var order =
|
|
478
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
479
|
+
var order = _step4.value;
|
|
447
480
|
var storageKey = this.getOrderStorageKey(order);
|
|
448
481
|
if (!storageKey) continue;
|
|
449
482
|
this.recentSqliteWriteByStorageKey.set(storageKey, {
|
|
@@ -452,9 +485,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
452
485
|
});
|
|
453
486
|
}
|
|
454
487
|
} catch (err) {
|
|
455
|
-
|
|
488
|
+
_iterator4.e(err);
|
|
456
489
|
} finally {
|
|
457
|
-
|
|
490
|
+
_iterator4.f();
|
|
458
491
|
}
|
|
459
492
|
}
|
|
460
493
|
|
|
@@ -478,11 +511,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
478
511
|
var now = Date.now();
|
|
479
512
|
var toWrite = [];
|
|
480
513
|
var skipped = [];
|
|
481
|
-
var
|
|
482
|
-
|
|
514
|
+
var _iterator5 = _createForOfIteratorHelper(orders),
|
|
515
|
+
_step5;
|
|
483
516
|
try {
|
|
484
|
-
for (
|
|
485
|
-
var order =
|
|
517
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
518
|
+
var order = _step5.value;
|
|
486
519
|
var storageKey = this.getOrderStorageKey(order);
|
|
487
520
|
if (!storageKey) {
|
|
488
521
|
toWrite.push(order);
|
|
@@ -517,9 +550,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
517
550
|
toWrite.push(order);
|
|
518
551
|
}
|
|
519
552
|
} catch (err) {
|
|
520
|
-
|
|
553
|
+
_iterator5.e(err);
|
|
521
554
|
} finally {
|
|
522
|
-
|
|
555
|
+
_iterator5.f();
|
|
523
556
|
}
|
|
524
557
|
return {
|
|
525
558
|
toWrite: toWrite,
|
|
@@ -539,11 +572,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
539
572
|
var now = Date.now();
|
|
540
573
|
var toFetch = [];
|
|
541
574
|
var skipped = [];
|
|
542
|
-
var
|
|
543
|
-
|
|
575
|
+
var _iterator6 = _createForOfIteratorHelper(ids),
|
|
576
|
+
_step6;
|
|
544
577
|
try {
|
|
545
|
-
for (
|
|
546
|
-
var id =
|
|
578
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
579
|
+
var id = _step6.value;
|
|
547
580
|
var existing = this.getOrderByOrderId(id);
|
|
548
581
|
if (!existing) {
|
|
549
582
|
toFetch.push(id);
|
|
@@ -562,9 +595,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
562
595
|
toFetch.push(id);
|
|
563
596
|
}
|
|
564
597
|
} catch (err) {
|
|
565
|
-
|
|
598
|
+
_iterator6.e(err);
|
|
566
599
|
} finally {
|
|
567
|
-
|
|
600
|
+
_iterator6.f();
|
|
568
601
|
}
|
|
569
602
|
return {
|
|
570
603
|
toFetch: toFetch,
|
|
@@ -1440,8 +1473,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1440
1473
|
var options,
|
|
1441
1474
|
pendingMap,
|
|
1442
1475
|
memoryPendingMap,
|
|
1443
|
-
|
|
1444
|
-
|
|
1476
|
+
_iterator7,
|
|
1477
|
+
_step7,
|
|
1445
1478
|
order,
|
|
1446
1479
|
normalizedOrder,
|
|
1447
1480
|
pendingOrder,
|
|
@@ -1450,12 +1483,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1450
1483
|
updatedList,
|
|
1451
1484
|
identityKeyToIndex,
|
|
1452
1485
|
index,
|
|
1453
|
-
_iterator7,
|
|
1454
|
-
_step7,
|
|
1455
|
-
key,
|
|
1456
1486
|
_iterator8,
|
|
1457
1487
|
_step8,
|
|
1458
|
-
|
|
1488
|
+
key,
|
|
1489
|
+
_iterator9,
|
|
1490
|
+
_step9,
|
|
1491
|
+
_step9$value,
|
|
1459
1492
|
_storageKey,
|
|
1460
1493
|
_pendingOrder,
|
|
1461
1494
|
matchIndex,
|
|
@@ -1480,15 +1513,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1480
1513
|
case 4:
|
|
1481
1514
|
pendingMap = new Map();
|
|
1482
1515
|
memoryPendingMap = new Map();
|
|
1483
|
-
|
|
1516
|
+
_iterator7 = _createForOfIteratorHelper(pendingOrders);
|
|
1484
1517
|
_context13.prev = 7;
|
|
1485
|
-
|
|
1518
|
+
_iterator7.s();
|
|
1486
1519
|
case 9:
|
|
1487
|
-
if ((
|
|
1520
|
+
if ((_step7 = _iterator7.n()).done) {
|
|
1488
1521
|
_context13.next = 20;
|
|
1489
1522
|
break;
|
|
1490
1523
|
}
|
|
1491
|
-
order =
|
|
1524
|
+
order = _step7.value;
|
|
1492
1525
|
normalizedOrder = this.normalizeOrderCollectionsForIngress(order, 'upsertPendingSyncOrders.incoming');
|
|
1493
1526
|
pendingOrder = _objectSpread(_objectSpread({}, normalizedOrder), {}, {
|
|
1494
1527
|
need_sync: 1,
|
|
@@ -1512,10 +1545,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1512
1545
|
case 22:
|
|
1513
1546
|
_context13.prev = 22;
|
|
1514
1547
|
_context13.t0 = _context13["catch"](7);
|
|
1515
|
-
|
|
1548
|
+
_iterator7.e(_context13.t0);
|
|
1516
1549
|
case 25:
|
|
1517
1550
|
_context13.prev = 25;
|
|
1518
|
-
|
|
1551
|
+
_iterator7.f();
|
|
1519
1552
|
return _context13.finish(25);
|
|
1520
1553
|
case 28:
|
|
1521
1554
|
if (!(pendingMap.size === 0)) {
|
|
@@ -1537,28 +1570,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1537
1570
|
// 从 O(n) 线性扫描降为 O(1),整体复杂度由 O(n^2) 降为 O(n + m)。
|
|
1538
1571
|
identityKeyToIndex = new Map();
|
|
1539
1572
|
for (index = 0; index < updatedList.length; index += 1) {
|
|
1540
|
-
|
|
1573
|
+
_iterator8 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(updatedList[index]));
|
|
1541
1574
|
try {
|
|
1542
|
-
for (
|
|
1543
|
-
key =
|
|
1575
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1576
|
+
key = _step8.value;
|
|
1544
1577
|
// 同一 key 命中多张时保留最靠前的下标,与原 findIndex「取首个匹配」一致
|
|
1545
1578
|
if (!identityKeyToIndex.has(key)) identityKeyToIndex.set(key, index);
|
|
1546
1579
|
}
|
|
1547
1580
|
} catch (err) {
|
|
1548
|
-
|
|
1581
|
+
_iterator8.e(err);
|
|
1549
1582
|
} finally {
|
|
1550
|
-
|
|
1583
|
+
_iterator8.f();
|
|
1551
1584
|
}
|
|
1552
1585
|
}
|
|
1553
|
-
|
|
1586
|
+
_iterator9 = _createForOfIteratorHelper(memoryPendingMap.entries());
|
|
1554
1587
|
_context13.prev = 37;
|
|
1555
|
-
|
|
1588
|
+
_iterator9.s();
|
|
1556
1589
|
case 39:
|
|
1557
|
-
if ((
|
|
1590
|
+
if ((_step9 = _iterator9.n()).done) {
|
|
1558
1591
|
_context13.next = 58;
|
|
1559
1592
|
break;
|
|
1560
1593
|
}
|
|
1561
|
-
|
|
1594
|
+
_step9$value = _slicedToArray(_step9.value, 2), _storageKey = _step9$value[0], _pendingOrder = _step9$value[1];
|
|
1562
1595
|
matchIndex = this.lookupOrderIndexByIdentityKeys(identityKeyToIndex, this.getOrderIdentityMatchKeys(_pendingOrder));
|
|
1563
1596
|
if (!(matchIndex >= 0)) {
|
|
1564
1597
|
_context13.next = 52;
|
|
@@ -1593,10 +1626,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1593
1626
|
case 60:
|
|
1594
1627
|
_context13.prev = 60;
|
|
1595
1628
|
_context13.t1 = _context13["catch"](37);
|
|
1596
|
-
|
|
1629
|
+
_iterator9.e(_context13.t1);
|
|
1597
1630
|
case 63:
|
|
1598
1631
|
_context13.prev = 63;
|
|
1599
|
-
|
|
1632
|
+
_iterator9.f();
|
|
1600
1633
|
return _context13.finish(63);
|
|
1601
1634
|
case 66:
|
|
1602
1635
|
patchedOrders = _toConsumableArray(pendingMap.values()); // 增量索引已保证 store 去重不变量,无需再对全表做 O(n^2) 压缩;仅自检开关开启时兜底。
|
|
@@ -1643,7 +1676,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1643
1676
|
value: (function () {
|
|
1644
1677
|
var _upsertLocalDraftOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(draftOrders) {
|
|
1645
1678
|
var _this10 = this;
|
|
1646
|
-
var draftMap, memoryDraftMap,
|
|
1679
|
+
var draftMap, memoryDraftMap, _iterator10, _step10, order, draftOrder, storageKey, memoryDraftOrder, mergeActions, updatedList, identityKeyToIndex, index, _iterator11, _step11, key, _iterator12, _step12, _step12$value, _storageKey2, _draftOrder, matchIndex, existingOrder, reconciledDraftOrder, mergedOrder, nextOrder, insertIndex, patchedOrders, previousList, removedLegacyMemoryDraft;
|
|
1647
1680
|
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1648
1681
|
while (1) switch (_context14.prev = _context14.next) {
|
|
1649
1682
|
case 0:
|
|
@@ -1656,15 +1689,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1656
1689
|
case 3:
|
|
1657
1690
|
draftMap = new Map();
|
|
1658
1691
|
memoryDraftMap = new Map();
|
|
1659
|
-
|
|
1692
|
+
_iterator10 = _createForOfIteratorHelper(draftOrders);
|
|
1660
1693
|
_context14.prev = 6;
|
|
1661
|
-
|
|
1694
|
+
_iterator10.s();
|
|
1662
1695
|
case 8:
|
|
1663
|
-
if ((
|
|
1696
|
+
if ((_step10 = _iterator10.n()).done) {
|
|
1664
1697
|
_context14.next = 19;
|
|
1665
1698
|
break;
|
|
1666
1699
|
}
|
|
1667
|
-
order =
|
|
1700
|
+
order = _step10.value;
|
|
1668
1701
|
draftOrder = _objectSpread(_objectSpread({}, order), {}, {
|
|
1669
1702
|
need_sync: 0,
|
|
1670
1703
|
is_draft_order: 1
|
|
@@ -1690,10 +1723,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1690
1723
|
case 21:
|
|
1691
1724
|
_context14.prev = 21;
|
|
1692
1725
|
_context14.t0 = _context14["catch"](6);
|
|
1693
|
-
|
|
1726
|
+
_iterator10.e(_context14.t0);
|
|
1694
1727
|
case 24:
|
|
1695
1728
|
_context14.prev = 24;
|
|
1696
|
-
|
|
1729
|
+
_iterator10.f();
|
|
1697
1730
|
return _context14.finish(24);
|
|
1698
1731
|
case 27:
|
|
1699
1732
|
if (!(draftMap.size === 0)) {
|
|
@@ -1716,27 +1749,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1716
1749
|
});
|
|
1717
1750
|
identityKeyToIndex = new Map();
|
|
1718
1751
|
for (index = 0; index < updatedList.length; index += 1) {
|
|
1719
|
-
|
|
1752
|
+
_iterator11 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(updatedList[index]));
|
|
1720
1753
|
try {
|
|
1721
|
-
for (
|
|
1722
|
-
key =
|
|
1754
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
1755
|
+
key = _step11.value;
|
|
1723
1756
|
if (!identityKeyToIndex.has(key)) identityKeyToIndex.set(key, index);
|
|
1724
1757
|
}
|
|
1725
1758
|
} catch (err) {
|
|
1726
|
-
|
|
1759
|
+
_iterator11.e(err);
|
|
1727
1760
|
} finally {
|
|
1728
|
-
|
|
1761
|
+
_iterator11.f();
|
|
1729
1762
|
}
|
|
1730
1763
|
}
|
|
1731
|
-
|
|
1764
|
+
_iterator12 = _createForOfIteratorHelper(memoryDraftMap.entries());
|
|
1732
1765
|
_context14.prev = 36;
|
|
1733
|
-
|
|
1766
|
+
_iterator12.s();
|
|
1734
1767
|
case 38:
|
|
1735
|
-
if ((
|
|
1768
|
+
if ((_step12 = _iterator12.n()).done) {
|
|
1736
1769
|
_context14.next = 57;
|
|
1737
1770
|
break;
|
|
1738
1771
|
}
|
|
1739
|
-
|
|
1772
|
+
_step12$value = _slicedToArray(_step12.value, 2), _storageKey2 = _step12$value[0], _draftOrder = _step12$value[1];
|
|
1740
1773
|
matchIndex = this.lookupOrderIndexByIdentityKeys(identityKeyToIndex, this.getOrderIdentityMatchKeys(_draftOrder));
|
|
1741
1774
|
if (!(matchIndex >= 0)) {
|
|
1742
1775
|
_context14.next = 51;
|
|
@@ -1769,10 +1802,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1769
1802
|
case 59:
|
|
1770
1803
|
_context14.prev = 59;
|
|
1771
1804
|
_context14.t1 = _context14["catch"](36);
|
|
1772
|
-
|
|
1805
|
+
_iterator12.e(_context14.t1);
|
|
1773
1806
|
case 62:
|
|
1774
1807
|
_context14.prev = 62;
|
|
1775
|
-
|
|
1808
|
+
_iterator12.f();
|
|
1776
1809
|
return _context14.finish(62);
|
|
1777
1810
|
case 65:
|
|
1778
1811
|
patchedOrders = _toConsumableArray(draftMap.values());
|
|
@@ -1884,6 +1917,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1884
1917
|
}
|
|
1885
1918
|
this.isProcessingSyncBatch = false;
|
|
1886
1919
|
this.pendingSyncMessages = [];
|
|
1920
|
+
this.recentSqliteWriteByStorageKey.clear();
|
|
1921
|
+
this.lastRecentSqliteWriteCleanupAtMs = 0;
|
|
1887
1922
|
if ((_this$orderDataSource = this.orderDataSource) !== null && _this$orderDataSource !== void 0 && _this$orderDataSource.destroy) this.orderDataSource.destroy();
|
|
1888
1923
|
_get(_getPrototypeOf(OrderModule.prototype), "destroy", this).call(this);
|
|
1889
1924
|
}
|
|
@@ -1895,19 +1930,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1895
1930
|
return _this11.shouldKeepOrderInMemory(order);
|
|
1896
1931
|
});
|
|
1897
1932
|
this.store.map.clear();
|
|
1898
|
-
var
|
|
1899
|
-
|
|
1933
|
+
var _iterator13 = _createForOfIteratorHelper(this.store.list),
|
|
1934
|
+
_step13;
|
|
1900
1935
|
try {
|
|
1901
|
-
for (
|
|
1902
|
-
var order =
|
|
1936
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
1937
|
+
var order = _step13.value;
|
|
1903
1938
|
var primaryIdentity = this.getOrderMapKey(order);
|
|
1904
1939
|
if (!primaryIdentity) continue;
|
|
1905
1940
|
this.store.map.set(primaryIdentity, order);
|
|
1906
1941
|
}
|
|
1907
1942
|
} catch (err) {
|
|
1908
|
-
|
|
1943
|
+
_iterator13.e(err);
|
|
1909
1944
|
} finally {
|
|
1910
|
-
|
|
1945
|
+
_iterator13.f();
|
|
1911
1946
|
}
|
|
1912
1947
|
}
|
|
1913
1948
|
}, {
|
|
@@ -1988,17 +2023,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1988
2023
|
key: "getOrderIdentityKeys",
|
|
1989
2024
|
value: function getOrderIdentityKeys(order) {
|
|
1990
2025
|
var keys = [];
|
|
1991
|
-
var
|
|
1992
|
-
|
|
2026
|
+
var _iterator14 = _createForOfIteratorHelper(this.getOrderIdentityEntries(order)),
|
|
2027
|
+
_step14;
|
|
1993
2028
|
try {
|
|
1994
|
-
for (
|
|
1995
|
-
var entry =
|
|
2029
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
2030
|
+
var entry = _step14.value;
|
|
1996
2031
|
if (!keys.includes(entry.key)) keys.push(entry.key);
|
|
1997
2032
|
}
|
|
1998
2033
|
} catch (err) {
|
|
1999
|
-
|
|
2034
|
+
_iterator14.e(err);
|
|
2000
2035
|
} finally {
|
|
2001
|
-
|
|
2036
|
+
_iterator14.f();
|
|
2002
2037
|
}
|
|
2003
2038
|
return keys;
|
|
2004
2039
|
}
|
|
@@ -2041,7 +2076,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2041
2076
|
pubsub: {
|
|
2042
2077
|
callback: function callback(res) {
|
|
2043
2078
|
var _message$id, _message$order_id, _message$type;
|
|
2044
|
-
console.log('orderDataSource', res);
|
|
2045
2079
|
var pubsubReceivedAt = Date.now();
|
|
2046
2080
|
var message = _this13.normalizeOrderSyncMessage(res);
|
|
2047
2081
|
if (!message) return;
|
|
@@ -2327,7 +2361,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2327
2361
|
value: (function () {
|
|
2328
2362
|
var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(freshOrders, source) {
|
|
2329
2363
|
var _this16 = this;
|
|
2330
|
-
var storeOrderCountBefore, normalizedFreshOrders, incomingProductsHaveStableIdentity,
|
|
2364
|
+
var storeOrderCountBefore, normalizedFreshOrders, incomingProductsHaveStableIdentity, _iterator15, _step15, order, id, rawProducts, _incomingProductsHave, allProductsHaveStableIdentity, orderIdKey, uniqueFreshOrders, uniqueFreshCount, patchedOrders, remoteProductMembershipChanges, forceWriteStorageKeys, storageKeyMigrations, mergeActions, existingProductsHaveStableIdentity, updatedList, identityKeyToIndex, index, identityKeys, _iterator16, _step16, key, _iterator17, _step17, fresh, freshIdentityKeys, matchIndex, storageKey, mergeKey, existingOrder, previousStorageKey, _ref, _existingOrder$order_, _ref2, _external_sale_number2, _existingOrder$paymen, _fresh$payment_status, _existingOrder$need_s, _fresh$need_sync, _ref3, _existingOrder$order_2, _ref4, _external_sale_number3, _existingOrder$is_dra, _fresh$is_draft_order, mergedOrder, freshOrderId, incomingProductsAreStable, membershipChange, mergedProductsHaveStableIdentity, adjustedMatchIndex, duplicateIndexes, _iterator18, _step18, _key2, _duplicateIndex, _iterator19, _step19, duplicateIndex, _index, _iterator20, _step20, _key, nextStorageKey, _ref5, _ref6, _mergedOrder$order_id, mergedStorageKey, insertIndex, insertCount, updateCount;
|
|
2331
2365
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
2332
2366
|
while (1) switch (_context19.prev = _context19.next) {
|
|
2333
2367
|
case 0:
|
|
@@ -2340,15 +2374,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2340
2374
|
this.logDuplicateOrders("".concat(source, ".beforeMerge"), this.store.list);
|
|
2341
2375
|
normalizedFreshOrders = [];
|
|
2342
2376
|
incomingProductsHaveStableIdentity = new Map();
|
|
2343
|
-
|
|
2377
|
+
_iterator15 = _createForOfIteratorHelper(freshOrders);
|
|
2344
2378
|
_context19.prev = 6;
|
|
2345
|
-
|
|
2379
|
+
_iterator15.s();
|
|
2346
2380
|
case 8:
|
|
2347
|
-
if ((
|
|
2381
|
+
if ((_step15 = _iterator15.n()).done) {
|
|
2348
2382
|
_context19.next = 18;
|
|
2349
2383
|
break;
|
|
2350
2384
|
}
|
|
2351
|
-
order =
|
|
2385
|
+
order = _step15.value;
|
|
2352
2386
|
id = order === null || order === void 0 ? void 0 : order.order_id;
|
|
2353
2387
|
if (!(id === undefined || id === null)) {
|
|
2354
2388
|
_context19.next = 13;
|
|
@@ -2372,10 +2406,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2372
2406
|
case 20:
|
|
2373
2407
|
_context19.prev = 20;
|
|
2374
2408
|
_context19.t0 = _context19["catch"](6);
|
|
2375
|
-
|
|
2409
|
+
_iterator15.e(_context19.t0);
|
|
2376
2410
|
case 23:
|
|
2377
2411
|
_context19.prev = 23;
|
|
2378
|
-
|
|
2412
|
+
_iterator15.f();
|
|
2379
2413
|
return _context19.finish(23);
|
|
2380
2414
|
case 26:
|
|
2381
2415
|
// 先对本批新单做去重(批内规模 m 很小),保证每条 fresh 身份唯一
|
|
@@ -2397,28 +2431,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2397
2431
|
identityKeyToIndex = new Map();
|
|
2398
2432
|
for (index = 0; index < updatedList.length; index += 1) {
|
|
2399
2433
|
identityKeys = this.getOrderIdentityMatchKeys(updatedList[index]);
|
|
2400
|
-
|
|
2434
|
+
_iterator16 = _createForOfIteratorHelper(identityKeys);
|
|
2401
2435
|
try {
|
|
2402
|
-
for (
|
|
2403
|
-
key =
|
|
2436
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
2437
|
+
key = _step16.value;
|
|
2404
2438
|
// 同一 key 命中多张时保留最靠前的下标,与原 findIndex「取首个匹配」一致
|
|
2405
2439
|
if (!identityKeyToIndex.has(key)) identityKeyToIndex.set(key, index);
|
|
2406
2440
|
}
|
|
2407
2441
|
} catch (err) {
|
|
2408
|
-
|
|
2442
|
+
_iterator16.e(err);
|
|
2409
2443
|
} finally {
|
|
2410
|
-
|
|
2444
|
+
_iterator16.f();
|
|
2411
2445
|
}
|
|
2412
2446
|
}
|
|
2413
|
-
|
|
2447
|
+
_iterator17 = _createForOfIteratorHelper(uniqueFreshOrders);
|
|
2414
2448
|
_context19.prev = 38;
|
|
2415
|
-
|
|
2449
|
+
_iterator17.s();
|
|
2416
2450
|
case 40:
|
|
2417
|
-
if ((
|
|
2451
|
+
if ((_step17 = _iterator17.n()).done) {
|
|
2418
2452
|
_context19.next = 100;
|
|
2419
2453
|
break;
|
|
2420
2454
|
}
|
|
2421
|
-
fresh =
|
|
2455
|
+
fresh = _step17.value;
|
|
2422
2456
|
freshIdentityKeys = this.getOrderIdentityMatchKeys(fresh);
|
|
2423
2457
|
matchIndex = this.lookupOrderIndexByIdentityKeys(identityKeyToIndex, freshIdentityKeys);
|
|
2424
2458
|
storageKey = this.getOrderStorageKey(fresh);
|
|
@@ -2469,15 +2503,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2469
2503
|
mergedProductsHaveStableIdentity = existingProductsHaveStableIdentity[matchIndex] !== false && incomingProductsAreStable;
|
|
2470
2504
|
adjustedMatchIndex = matchIndex;
|
|
2471
2505
|
duplicateIndexes = new Set();
|
|
2472
|
-
|
|
2506
|
+
_iterator18 = _createForOfIteratorHelper(freshIdentityKeys);
|
|
2473
2507
|
_context19.prev = 64;
|
|
2474
|
-
|
|
2508
|
+
_iterator18.s();
|
|
2475
2509
|
case 66:
|
|
2476
|
-
if ((
|
|
2510
|
+
if ((_step18 = _iterator18.n()).done) {
|
|
2477
2511
|
_context19.next = 74;
|
|
2478
2512
|
break;
|
|
2479
2513
|
}
|
|
2480
|
-
_key2 =
|
|
2514
|
+
_key2 = _step18.value;
|
|
2481
2515
|
_duplicateIndex = identityKeyToIndex.get(_key2);
|
|
2482
2516
|
if (!(_duplicateIndex === undefined || _duplicateIndex === matchIndex)) {
|
|
2483
2517
|
_context19.next = 71;
|
|
@@ -2495,19 +2529,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2495
2529
|
case 76:
|
|
2496
2530
|
_context19.prev = 76;
|
|
2497
2531
|
_context19.t1 = _context19["catch"](64);
|
|
2498
|
-
|
|
2532
|
+
_iterator18.e(_context19.t1);
|
|
2499
2533
|
case 79:
|
|
2500
2534
|
_context19.prev = 79;
|
|
2501
|
-
|
|
2535
|
+
_iterator18.f();
|
|
2502
2536
|
return _context19.finish(79);
|
|
2503
2537
|
case 82:
|
|
2504
2538
|
if (duplicateIndexes.size > 0) {
|
|
2505
|
-
|
|
2539
|
+
_iterator19 = _createForOfIteratorHelper(_toConsumableArray(duplicateIndexes).sort(function (left, right) {
|
|
2506
2540
|
return right - left;
|
|
2507
2541
|
}));
|
|
2508
2542
|
try {
|
|
2509
|
-
for (
|
|
2510
|
-
duplicateIndex =
|
|
2543
|
+
for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
|
|
2544
|
+
duplicateIndex = _step19.value;
|
|
2511
2545
|
mergedOrder = this.mergeOrderRecords(mergedOrder, updatedList[duplicateIndex]);
|
|
2512
2546
|
mergedProductsHaveStableIdentity = mergedProductsHaveStableIdentity && existingProductsHaveStableIdentity[duplicateIndex] !== false;
|
|
2513
2547
|
updatedList.splice(duplicateIndex, 1);
|
|
@@ -2515,22 +2549,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2515
2549
|
if (duplicateIndex < adjustedMatchIndex) adjustedMatchIndex -= 1;
|
|
2516
2550
|
}
|
|
2517
2551
|
} catch (err) {
|
|
2518
|
-
|
|
2552
|
+
_iterator19.e(err);
|
|
2519
2553
|
} finally {
|
|
2520
|
-
|
|
2554
|
+
_iterator19.f();
|
|
2521
2555
|
}
|
|
2522
2556
|
identityKeyToIndex.clear();
|
|
2523
2557
|
for (_index = 0; _index < updatedList.length; _index += 1) {
|
|
2524
|
-
|
|
2558
|
+
_iterator20 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(updatedList[_index]));
|
|
2525
2559
|
try {
|
|
2526
|
-
for (
|
|
2527
|
-
_key =
|
|
2560
|
+
for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
|
|
2561
|
+
_key = _step20.value;
|
|
2528
2562
|
if (!identityKeyToIndex.has(_key)) identityKeyToIndex.set(_key, _index);
|
|
2529
2563
|
}
|
|
2530
2564
|
} catch (err) {
|
|
2531
|
-
|
|
2565
|
+
_iterator20.e(err);
|
|
2532
2566
|
} finally {
|
|
2533
|
-
|
|
2567
|
+
_iterator20.f();
|
|
2534
2568
|
}
|
|
2535
2569
|
}
|
|
2536
2570
|
}
|
|
@@ -2571,10 +2605,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2571
2605
|
case 102:
|
|
2572
2606
|
_context19.prev = 102;
|
|
2573
2607
|
_context19.t2 = _context19["catch"](38);
|
|
2574
|
-
|
|
2608
|
+
_iterator17.e(_context19.t2);
|
|
2575
2609
|
case 105:
|
|
2576
2610
|
_context19.prev = 105;
|
|
2577
|
-
|
|
2611
|
+
_iterator17.f();
|
|
2578
2612
|
return _context19.finish(105);
|
|
2579
2613
|
case 108:
|
|
2580
2614
|
insertCount = Object.values(mergeActions).filter(function (v) {
|
|
@@ -2631,19 +2665,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2631
2665
|
key: "lookupOrderIndexByIdentityKeys",
|
|
2632
2666
|
value: function lookupOrderIndexByIdentityKeys(identityKeyToIndex, identityKeys) {
|
|
2633
2667
|
var matchIndex = -1;
|
|
2634
|
-
var
|
|
2635
|
-
|
|
2668
|
+
var _iterator21 = _createForOfIteratorHelper(identityKeys),
|
|
2669
|
+
_step21;
|
|
2636
2670
|
try {
|
|
2637
|
-
for (
|
|
2638
|
-
var key =
|
|
2671
|
+
for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
|
|
2672
|
+
var key = _step21.value;
|
|
2639
2673
|
var index = identityKeyToIndex.get(key);
|
|
2640
2674
|
if (index === undefined) continue;
|
|
2641
2675
|
if (matchIndex < 0 || index < matchIndex) matchIndex = index;
|
|
2642
2676
|
}
|
|
2643
2677
|
} catch (err) {
|
|
2644
|
-
|
|
2678
|
+
_iterator21.e(err);
|
|
2645
2679
|
} finally {
|
|
2646
|
-
|
|
2680
|
+
_iterator21.f();
|
|
2647
2681
|
}
|
|
2648
2682
|
return matchIndex;
|
|
2649
2683
|
}
|
|
@@ -2703,11 +2737,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2703
2737
|
return index;
|
|
2704
2738
|
}));
|
|
2705
2739
|
var removedProductKeys = [];
|
|
2706
|
-
var
|
|
2707
|
-
|
|
2740
|
+
var _iterator22 = _createForOfIteratorHelper(previousProducts),
|
|
2741
|
+
_step22;
|
|
2708
2742
|
try {
|
|
2709
2743
|
var _loop2 = function _loop2() {
|
|
2710
|
-
var previousProduct =
|
|
2744
|
+
var previousProduct = _step22.value;
|
|
2711
2745
|
var matchedIndex = currentProducts.findIndex(function (currentProduct, index) {
|
|
2712
2746
|
return unmatchedCurrentIndexes.has(index) && _this17.isSameProductMembershipItem(previousProduct, currentProduct);
|
|
2713
2747
|
});
|
|
@@ -2718,13 +2752,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2718
2752
|
var productKey = _this17.getProductMembershipKey(previousProduct);
|
|
2719
2753
|
if (productKey) removedProductKeys.push(productKey);
|
|
2720
2754
|
};
|
|
2721
|
-
for (
|
|
2755
|
+
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
2722
2756
|
if (_loop2()) continue;
|
|
2723
2757
|
}
|
|
2724
2758
|
} catch (err) {
|
|
2725
|
-
|
|
2759
|
+
_iterator22.e(err);
|
|
2726
2760
|
} finally {
|
|
2727
|
-
|
|
2761
|
+
_iterator22.f();
|
|
2728
2762
|
}
|
|
2729
2763
|
var addedProductKeys = _toConsumableArray(unmatchedCurrentIndexes).map(function (index) {
|
|
2730
2764
|
return _this17.getProductMembershipKey(currentProducts[index]);
|
|
@@ -2755,17 +2789,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2755
2789
|
key: "registerOrderIdentityKeys",
|
|
2756
2790
|
value: function registerOrderIdentityKeys(identityKeyToIndex, order, index) {
|
|
2757
2791
|
var identityKeys = this.getOrderIdentityMatchKeys(order);
|
|
2758
|
-
var
|
|
2759
|
-
|
|
2792
|
+
var _iterator23 = _createForOfIteratorHelper(identityKeys),
|
|
2793
|
+
_step23;
|
|
2760
2794
|
try {
|
|
2761
|
-
for (
|
|
2762
|
-
var key =
|
|
2795
|
+
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
2796
|
+
var key = _step23.value;
|
|
2763
2797
|
identityKeyToIndex.set(key, index);
|
|
2764
2798
|
}
|
|
2765
2799
|
} catch (err) {
|
|
2766
|
-
|
|
2800
|
+
_iterator23.e(err);
|
|
2767
2801
|
} finally {
|
|
2768
|
-
|
|
2802
|
+
_iterator23.f();
|
|
2769
2803
|
}
|
|
2770
2804
|
}
|
|
2771
2805
|
|
|
@@ -2820,17 +2854,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2820
2854
|
key: "uniqueOrderIds",
|
|
2821
2855
|
value: function uniqueOrderIds(ids) {
|
|
2822
2856
|
var idMap = new Map();
|
|
2823
|
-
var
|
|
2824
|
-
|
|
2857
|
+
var _iterator24 = _createForOfIteratorHelper(ids),
|
|
2858
|
+
_step24;
|
|
2825
2859
|
try {
|
|
2826
|
-
for (
|
|
2827
|
-
var id =
|
|
2860
|
+
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
2861
|
+
var id = _step24.value;
|
|
2828
2862
|
idMap.set(this.getIdKey(id), id);
|
|
2829
2863
|
}
|
|
2830
2864
|
} catch (err) {
|
|
2831
|
-
|
|
2865
|
+
_iterator24.e(err);
|
|
2832
2866
|
} finally {
|
|
2833
|
-
|
|
2867
|
+
_iterator24.f();
|
|
2834
2868
|
}
|
|
2835
2869
|
return _toConsumableArray(idMap.values());
|
|
2836
2870
|
}
|
|
@@ -2951,58 +2985,58 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2951
2985
|
if (secondaryList.length === 0) return preferredList;
|
|
2952
2986
|
if (preferredList.length === 0) return secondaryList;
|
|
2953
2987
|
var seenKeys = new Set();
|
|
2954
|
-
var
|
|
2955
|
-
|
|
2988
|
+
var _iterator25 = _createForOfIteratorHelper(preferredList),
|
|
2989
|
+
_step25;
|
|
2956
2990
|
try {
|
|
2957
|
-
for (
|
|
2958
|
-
var item =
|
|
2991
|
+
for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
|
|
2992
|
+
var item = _step25.value;
|
|
2959
2993
|
var keys = this.getProductIdentityKeys(item);
|
|
2960
|
-
var
|
|
2961
|
-
|
|
2994
|
+
var _iterator27 = _createForOfIteratorHelper(keys),
|
|
2995
|
+
_step27;
|
|
2962
2996
|
try {
|
|
2963
|
-
for (
|
|
2964
|
-
var key =
|
|
2997
|
+
for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
|
|
2998
|
+
var key = _step27.value;
|
|
2965
2999
|
seenKeys.add(key);
|
|
2966
3000
|
}
|
|
2967
3001
|
} catch (err) {
|
|
2968
|
-
|
|
3002
|
+
_iterator27.e(err);
|
|
2969
3003
|
} finally {
|
|
2970
|
-
|
|
3004
|
+
_iterator27.f();
|
|
2971
3005
|
}
|
|
2972
3006
|
}
|
|
2973
3007
|
} catch (err) {
|
|
2974
|
-
|
|
3008
|
+
_iterator25.e(err);
|
|
2975
3009
|
} finally {
|
|
2976
|
-
|
|
3010
|
+
_iterator25.f();
|
|
2977
3011
|
}
|
|
2978
3012
|
var result = _toConsumableArray(preferredList);
|
|
2979
|
-
var
|
|
2980
|
-
|
|
3013
|
+
var _iterator26 = _createForOfIteratorHelper(secondaryList),
|
|
3014
|
+
_step26;
|
|
2981
3015
|
try {
|
|
2982
|
-
for (
|
|
2983
|
-
var _item =
|
|
3016
|
+
for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {
|
|
3017
|
+
var _item = _step26.value;
|
|
2984
3018
|
var _keys = this.getProductIdentityKeys(_item);
|
|
2985
3019
|
if (_keys.length === 0 || _keys.some(function (key) {
|
|
2986
3020
|
return seenKeys.has(key);
|
|
2987
3021
|
})) continue;
|
|
2988
|
-
var
|
|
2989
|
-
|
|
3022
|
+
var _iterator28 = _createForOfIteratorHelper(_keys),
|
|
3023
|
+
_step28;
|
|
2990
3024
|
try {
|
|
2991
|
-
for (
|
|
2992
|
-
var _key3 =
|
|
3025
|
+
for (_iterator28.s(); !(_step28 = _iterator28.n()).done;) {
|
|
3026
|
+
var _key3 = _step28.value;
|
|
2993
3027
|
seenKeys.add(_key3);
|
|
2994
3028
|
}
|
|
2995
3029
|
} catch (err) {
|
|
2996
|
-
|
|
3030
|
+
_iterator28.e(err);
|
|
2997
3031
|
} finally {
|
|
2998
|
-
|
|
3032
|
+
_iterator28.f();
|
|
2999
3033
|
}
|
|
3000
3034
|
result.push(cloneDeep(_item));
|
|
3001
3035
|
}
|
|
3002
3036
|
} catch (err) {
|
|
3003
|
-
|
|
3037
|
+
_iterator26.e(err);
|
|
3004
3038
|
} finally {
|
|
3005
|
-
|
|
3039
|
+
_iterator26.f();
|
|
3006
3040
|
}
|
|
3007
3041
|
return result;
|
|
3008
3042
|
}
|
|
@@ -3112,30 +3146,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3112
3146
|
key: "summarizeDuplicateOrders",
|
|
3113
3147
|
value: function summarizeDuplicateOrders(orders) {
|
|
3114
3148
|
var groups = new Map();
|
|
3115
|
-
var
|
|
3116
|
-
|
|
3149
|
+
var _iterator29 = _createForOfIteratorHelper(orders),
|
|
3150
|
+
_step29;
|
|
3117
3151
|
try {
|
|
3118
|
-
for (
|
|
3119
|
-
var order =
|
|
3120
|
-
var
|
|
3121
|
-
|
|
3152
|
+
for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
|
|
3153
|
+
var order = _step29.value;
|
|
3154
|
+
var _iterator30 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(order)),
|
|
3155
|
+
_step30;
|
|
3122
3156
|
try {
|
|
3123
|
-
for (
|
|
3124
|
-
var key =
|
|
3157
|
+
for (_iterator30.s(); !(_step30 = _iterator30.n()).done;) {
|
|
3158
|
+
var key = _step30.value;
|
|
3125
3159
|
var group = groups.get(key) || [];
|
|
3126
3160
|
group.push(order);
|
|
3127
3161
|
groups.set(key, group);
|
|
3128
3162
|
}
|
|
3129
3163
|
} catch (err) {
|
|
3130
|
-
|
|
3164
|
+
_iterator30.e(err);
|
|
3131
3165
|
} finally {
|
|
3132
|
-
|
|
3166
|
+
_iterator30.f();
|
|
3133
3167
|
}
|
|
3134
3168
|
}
|
|
3135
3169
|
} catch (err) {
|
|
3136
|
-
|
|
3170
|
+
_iterator29.e(err);
|
|
3137
3171
|
} finally {
|
|
3138
|
-
|
|
3172
|
+
_iterator29.f();
|
|
3139
3173
|
}
|
|
3140
3174
|
return _toConsumableArray(groups.entries()).filter(function (_ref9) {
|
|
3141
3175
|
var _ref10 = _slicedToArray(_ref9, 2),
|
|
@@ -3178,11 +3212,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3178
3212
|
value: function compactOrderListByIdentity(orders, source) {
|
|
3179
3213
|
var list = [];
|
|
3180
3214
|
var removedCount = 0;
|
|
3181
|
-
var
|
|
3182
|
-
|
|
3215
|
+
var _iterator31 = _createForOfIteratorHelper(orders),
|
|
3216
|
+
_step31;
|
|
3183
3217
|
try {
|
|
3184
|
-
for (
|
|
3185
|
-
var order =
|
|
3218
|
+
for (_iterator31.s(); !(_step31 = _iterator31.n()).done;) {
|
|
3219
|
+
var order = _step31.value;
|
|
3186
3220
|
var normalizedOrder = this.normalizeOrderCollectionsForIngress(order, "".concat(source, ".order"));
|
|
3187
3221
|
var matchIndex = this.findOrderIndexByIdentity(list, normalizedOrder);
|
|
3188
3222
|
if (matchIndex < 0) {
|
|
@@ -3193,9 +3227,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3193
3227
|
removedCount += 1;
|
|
3194
3228
|
}
|
|
3195
3229
|
} catch (err) {
|
|
3196
|
-
|
|
3230
|
+
_iterator31.e(err);
|
|
3197
3231
|
} finally {
|
|
3198
|
-
|
|
3232
|
+
_iterator31.f();
|
|
3199
3233
|
}
|
|
3200
3234
|
if (removedCount > 0) {
|
|
3201
3235
|
this.logWarning('订单列表重复项已压缩', {
|
|
@@ -3375,11 +3409,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3375
3409
|
var merged = remoteOrders.map(function (order) {
|
|
3376
3410
|
return _this21.normalizeRemoteSyncedOrder(order);
|
|
3377
3411
|
});
|
|
3378
|
-
var
|
|
3379
|
-
|
|
3412
|
+
var _iterator32 = _createForOfIteratorHelper(existingOrders),
|
|
3413
|
+
_step32;
|
|
3380
3414
|
try {
|
|
3381
|
-
for (
|
|
3382
|
-
var rawOrder =
|
|
3415
|
+
for (_iterator32.s(); !(_step32 = _iterator32.n()).done;) {
|
|
3416
|
+
var rawOrder = _step32.value;
|
|
3383
3417
|
var order = this.normalizeOrderCollectionsForIngress(rawOrder, 'mergeRemoteSnapshotWithPendingOrders.existingSQLite');
|
|
3384
3418
|
if (!this.shouldProtectLocalOrderFromRemoteSnapshot(order)) continue;
|
|
3385
3419
|
var matchIndex = this.findOrderIndexByIdentity(merged, order);
|
|
@@ -3395,9 +3429,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3395
3429
|
merged.push(order);
|
|
3396
3430
|
}
|
|
3397
3431
|
} catch (err) {
|
|
3398
|
-
|
|
3432
|
+
_iterator32.e(err);
|
|
3399
3433
|
} finally {
|
|
3400
|
-
|
|
3434
|
+
_iterator32.f();
|
|
3401
3435
|
}
|
|
3402
3436
|
return this.compactOrderListByIdentity(merged, 'mergeRemoteSnapshotWithPendingOrders').list;
|
|
3403
3437
|
}
|
|
@@ -3459,8 +3493,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3459
3493
|
compactedToWrite,
|
|
3460
3494
|
writtenStorageKeys,
|
|
3461
3495
|
storageKeyMigrations,
|
|
3462
|
-
|
|
3463
|
-
|
|
3496
|
+
_iterator33,
|
|
3497
|
+
_step33,
|
|
3464
3498
|
migration,
|
|
3465
3499
|
_args23 = arguments;
|
|
3466
3500
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
@@ -3523,15 +3557,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3523
3557
|
return _this22.getOrderStorageKey(order);
|
|
3524
3558
|
}).filter(Boolean));
|
|
3525
3559
|
storageKeyMigrations = new Map();
|
|
3526
|
-
|
|
3560
|
+
_iterator33 = _createForOfIteratorHelper(options.storageKeyMigrations || []);
|
|
3527
3561
|
_context23.prev = 22;
|
|
3528
|
-
|
|
3562
|
+
_iterator33.s();
|
|
3529
3563
|
case 24:
|
|
3530
|
-
if ((
|
|
3564
|
+
if ((_step33 = _iterator33.n()).done) {
|
|
3531
3565
|
_context23.next = 33;
|
|
3532
3566
|
break;
|
|
3533
3567
|
}
|
|
3534
|
-
migration =
|
|
3568
|
+
migration = _step33.value;
|
|
3535
3569
|
if (writtenStorageKeys.has(migration.to)) {
|
|
3536
3570
|
_context23.next = 28;
|
|
3537
3571
|
break;
|
|
@@ -3554,16 +3588,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3554
3588
|
case 35:
|
|
3555
3589
|
_context23.prev = 35;
|
|
3556
3590
|
_context23.t0 = _context23["catch"](22);
|
|
3557
|
-
|
|
3591
|
+
_iterator33.e(_context23.t0);
|
|
3558
3592
|
case 38:
|
|
3559
3593
|
_context23.prev = 38;
|
|
3560
|
-
|
|
3594
|
+
_iterator33.f();
|
|
3561
3595
|
return _context23.finish(38);
|
|
3562
3596
|
case 41:
|
|
3563
3597
|
_context23.prev = 41;
|
|
3564
3598
|
_context23.next = 44;
|
|
3565
3599
|
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
3566
|
-
var writeMethod,
|
|
3600
|
+
var writeMethod, _iterator34, _step34, order, _iterator35, _step35, migration, _iterator36, _step36, _orderRecord$ORDER_ST, _order, orderRecord;
|
|
3567
3601
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
3568
3602
|
while (1) switch (_context22.prev = _context22.next) {
|
|
3569
3603
|
case 0:
|
|
@@ -3600,15 +3634,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3600
3634
|
break;
|
|
3601
3635
|
}
|
|
3602
3636
|
writeMethod = 'update';
|
|
3603
|
-
|
|
3637
|
+
_iterator34 = _createForOfIteratorHelper(compactedToWrite);
|
|
3604
3638
|
_context22.prev = 17;
|
|
3605
|
-
|
|
3639
|
+
_iterator34.s();
|
|
3606
3640
|
case 19:
|
|
3607
|
-
if ((
|
|
3641
|
+
if ((_step34 = _iterator34.n()).done) {
|
|
3608
3642
|
_context22.next = 25;
|
|
3609
3643
|
break;
|
|
3610
3644
|
}
|
|
3611
|
-
order =
|
|
3645
|
+
order = _step34.value;
|
|
3612
3646
|
_context22.next = 23;
|
|
3613
3647
|
return _this22.dbManager.update(INDEXDB_STORE_NAME, order);
|
|
3614
3648
|
case 23:
|
|
@@ -3620,10 +3654,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3620
3654
|
case 27:
|
|
3621
3655
|
_context22.prev = 27;
|
|
3622
3656
|
_context22.t0 = _context22["catch"](17);
|
|
3623
|
-
|
|
3657
|
+
_iterator34.e(_context22.t0);
|
|
3624
3658
|
case 30:
|
|
3625
3659
|
_context22.prev = 30;
|
|
3626
|
-
|
|
3660
|
+
_iterator34.f();
|
|
3627
3661
|
return _context22.finish(30);
|
|
3628
3662
|
case 33:
|
|
3629
3663
|
_context22.next = 37;
|
|
@@ -3640,29 +3674,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3640
3674
|
_context22.next = 84;
|
|
3641
3675
|
break;
|
|
3642
3676
|
}
|
|
3643
|
-
|
|
3677
|
+
_iterator35 = _createForOfIteratorHelper(storageKeyMigrations.values());
|
|
3644
3678
|
_context22.prev = 40;
|
|
3645
|
-
|
|
3679
|
+
_iterator35.s();
|
|
3646
3680
|
case 42:
|
|
3647
|
-
if ((
|
|
3681
|
+
if ((_step35 = _iterator35.n()).done) {
|
|
3648
3682
|
_context22.next = 76;
|
|
3649
3683
|
break;
|
|
3650
3684
|
}
|
|
3651
|
-
migration =
|
|
3685
|
+
migration = _step35.value;
|
|
3652
3686
|
_context22.prev = 44;
|
|
3653
3687
|
_context22.next = 47;
|
|
3654
3688
|
return _this22.dbManager.delete(INDEXDB_STORE_NAME, migration.from);
|
|
3655
3689
|
case 47:
|
|
3656
3690
|
_this22.recentSqliteWriteByStorageKey.delete(migration.from);
|
|
3657
|
-
|
|
3691
|
+
_iterator36 = _createForOfIteratorHelper(orders);
|
|
3658
3692
|
_context22.prev = 49;
|
|
3659
|
-
|
|
3693
|
+
_iterator36.s();
|
|
3660
3694
|
case 51:
|
|
3661
|
-
if ((
|
|
3695
|
+
if ((_step36 = _iterator36.n()).done) {
|
|
3662
3696
|
_context22.next = 61;
|
|
3663
3697
|
break;
|
|
3664
3698
|
}
|
|
3665
|
-
_order =
|
|
3699
|
+
_order = _step36.value;
|
|
3666
3700
|
if (!(_this22.getOrderStorageKey(_order) !== migration.to)) {
|
|
3667
3701
|
_context22.next = 55;
|
|
3668
3702
|
break;
|
|
@@ -3686,10 +3720,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3686
3720
|
case 63:
|
|
3687
3721
|
_context22.prev = 63;
|
|
3688
3722
|
_context22.t1 = _context22["catch"](49);
|
|
3689
|
-
|
|
3723
|
+
_iterator36.e(_context22.t1);
|
|
3690
3724
|
case 66:
|
|
3691
3725
|
_context22.prev = 66;
|
|
3692
|
-
|
|
3726
|
+
_iterator36.f();
|
|
3693
3727
|
return _context22.finish(66);
|
|
3694
3728
|
case 69:
|
|
3695
3729
|
_context22.next = 74;
|
|
@@ -3713,10 +3747,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3713
3747
|
case 78:
|
|
3714
3748
|
_context22.prev = 78;
|
|
3715
3749
|
_context22.t3 = _context22["catch"](40);
|
|
3716
|
-
|
|
3750
|
+
_iterator35.e(_context22.t3);
|
|
3717
3751
|
case 81:
|
|
3718
3752
|
_context22.prev = 81;
|
|
3719
|
-
|
|
3753
|
+
_iterator35.f();
|
|
3720
3754
|
return _context22.finish(81);
|
|
3721
3755
|
case 84:
|
|
3722
3756
|
_this22.logInfo('patchOrdersInSQLite-完成', {
|
|
@@ -3931,7 +3965,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3931
3965
|
_context27.prev = 5;
|
|
3932
3966
|
_context27.next = 8;
|
|
3933
3967
|
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
3934
|
-
var existingOrders, protectedLocalOrders,
|
|
3968
|
+
var existingOrders, protectedLocalOrders, _iterator37, _step37, rawCurrentOrder, currentOrder, protectedIndex, currentNeedsProtection, orderListSnapshot;
|
|
3935
3969
|
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
3936
3970
|
while (1) switch (_context26.prev = _context26.next) {
|
|
3937
3971
|
case 0:
|
|
@@ -3954,15 +3988,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3954
3988
|
}).filter(function (order) {
|
|
3955
3989
|
return _this24.shouldProtectLocalOrderFromRemoteSnapshot(order);
|
|
3956
3990
|
});
|
|
3957
|
-
|
|
3991
|
+
_iterator37 = _createForOfIteratorHelper(existingOrders || []);
|
|
3958
3992
|
_context26.prev = 10;
|
|
3959
|
-
|
|
3993
|
+
_iterator37.s();
|
|
3960
3994
|
case 12:
|
|
3961
|
-
if ((
|
|
3995
|
+
if ((_step37 = _iterator37.n()).done) {
|
|
3962
3996
|
_context26.next = 23;
|
|
3963
3997
|
break;
|
|
3964
3998
|
}
|
|
3965
|
-
rawCurrentOrder =
|
|
3999
|
+
rawCurrentOrder = _step37.value;
|
|
3966
4000
|
currentOrder = _this24.normalizeOrderCollectionsForIngress(rawCurrentOrder, "".concat(source, ".currentSQLite"));
|
|
3967
4001
|
protectedIndex = _this24.findOrderIndexByIdentity(protectedLocalOrders, currentOrder);
|
|
3968
4002
|
currentNeedsProtection = _this24.shouldProtectLocalOrderFromRemoteSnapshot(currentOrder);
|
|
@@ -3987,10 +4021,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3987
4021
|
case 25:
|
|
3988
4022
|
_context26.prev = 25;
|
|
3989
4023
|
_context26.t1 = _context26["catch"](10);
|
|
3990
|
-
|
|
4024
|
+
_iterator37.e(_context26.t1);
|
|
3991
4025
|
case 28:
|
|
3992
4026
|
_context26.prev = 28;
|
|
3993
|
-
|
|
4027
|
+
_iterator37.f();
|
|
3994
4028
|
return _context26.finish(28);
|
|
3995
4029
|
case 31:
|
|
3996
4030
|
orderListSnapshot = _this24.mergeRemoteSnapshotWithPendingOrders(remoteSnapshot, protectedLocalOrders);
|