@unchainedshop/core 3.0.0-alpha7 → 3.0.0-rc.11
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/lib/core-index.d.ts +8 -61
- package/lib/core-index.d.ts.map +1 -1
- package/lib/core-index.js +9 -140
- package/lib/core-index.js.map +1 -1
- package/lib/directors/BaseDiscountAdapter.d.ts +36 -0
- package/lib/directors/BaseDiscountAdapter.d.ts.map +1 -0
- package/lib/directors/BaseDiscountAdapter.js +48 -0
- package/lib/directors/BaseDiscountAdapter.js.map +1 -0
- package/lib/directors/BaseDiscountDirector.d.ts +15 -0
- package/lib/directors/BaseDiscountDirector.d.ts.map +1 -0
- package/lib/directors/BaseDiscountDirector.js +45 -0
- package/lib/directors/BaseDiscountDirector.js.map +1 -0
- package/lib/directors/BasePricingAdapter.d.ts +34 -0
- package/lib/directors/BasePricingAdapter.d.ts.map +1 -0
- package/lib/directors/BasePricingAdapter.js +25 -0
- package/lib/directors/BasePricingAdapter.js.map +1 -0
- package/lib/directors/BasePricingDirector.d.ts +17 -0
- package/lib/directors/BasePricingDirector.d.ts.map +1 -0
- package/lib/directors/BasePricingDirector.js +70 -0
- package/lib/directors/BasePricingDirector.js.map +1 -0
- package/lib/directors/BasePricingSheet.d.ts +46 -0
- package/lib/directors/BasePricingSheet.d.ts.map +1 -0
- package/lib/directors/BasePricingSheet.js +74 -0
- package/lib/directors/BasePricingSheet.js.map +1 -0
- package/lib/directors/DeliveryAdapter.d.ts +46 -0
- package/lib/directors/DeliveryAdapter.d.ts.map +1 -0
- package/lib/directors/DeliveryAdapter.js +50 -0
- package/lib/directors/DeliveryAdapter.js.map +1 -0
- package/lib/directors/DeliveryDirector.d.ts +15 -0
- package/lib/directors/DeliveryDirector.d.ts.map +1 -0
- package/lib/directors/DeliveryDirector.js +96 -0
- package/lib/directors/DeliveryDirector.js.map +1 -0
- package/lib/directors/DeliveryPricingAdapter.d.ts +49 -0
- package/lib/directors/DeliveryPricingAdapter.d.ts.map +1 -0
- package/lib/directors/DeliveryPricingAdapter.js +25 -0
- package/lib/directors/DeliveryPricingAdapter.js.map +1 -0
- package/lib/directors/DeliveryPricingDirector.d.ts +20 -0
- package/lib/directors/DeliveryPricingDirector.d.ts.map +1 -0
- package/lib/directors/DeliveryPricingDirector.js +50 -0
- package/lib/directors/DeliveryPricingDirector.js.map +1 -0
- package/lib/directors/DeliveryPricingSheet.d.ts +10 -0
- package/lib/directors/DeliveryPricingSheet.d.ts.map +1 -0
- package/lib/directors/DeliveryPricingSheet.js +75 -0
- package/lib/directors/DeliveryPricingSheet.js.map +1 -0
- package/lib/directors/EnrollmentAdapter.d.ts +27 -0
- package/lib/directors/EnrollmentAdapter.d.ts.map +1 -0
- package/lib/directors/EnrollmentAdapter.js +73 -0
- package/lib/directors/EnrollmentAdapter.js.map +1 -0
- package/lib/directors/EnrollmentDirector.d.ts +14 -0
- package/lib/directors/EnrollmentDirector.d.ts.map +1 -0
- package/lib/directors/EnrollmentDirector.js +44 -0
- package/lib/directors/EnrollmentDirector.js.map +1 -0
- package/lib/directors/FilterAdapter.d.ts +54 -0
- package/lib/directors/FilterAdapter.d.ts.map +1 -0
- package/lib/directors/FilterAdapter.js +38 -0
- package/lib/directors/FilterAdapter.js.map +1 -0
- package/lib/directors/FilterDirector.d.ts +40 -0
- package/lib/directors/FilterDirector.d.ts.map +1 -0
- package/lib/directors/FilterDirector.js +177 -0
- package/lib/directors/FilterDirector.js.map +1 -0
- package/lib/directors/MessagingDirector.d.ts +46 -0
- package/lib/directors/MessagingDirector.d.ts.map +1 -0
- package/lib/directors/MessagingDirector.js +10 -0
- package/lib/directors/MessagingDirector.js.map +1 -0
- package/lib/directors/OrderDiscountAdapter.d.ts +3 -0
- package/lib/directors/OrderDiscountAdapter.d.ts.map +1 -0
- package/lib/directors/OrderDiscountAdapter.js +3 -0
- package/lib/directors/OrderDiscountAdapter.js.map +1 -0
- package/lib/directors/OrderDiscountConfiguration.d.ts +6 -0
- package/lib/directors/OrderDiscountConfiguration.d.ts.map +1 -0
- package/lib/directors/OrderDiscountConfiguration.js +2 -0
- package/lib/directors/OrderDiscountConfiguration.js.map +1 -0
- package/lib/directors/OrderDiscountDirector.d.ts +3 -0
- package/lib/directors/OrderDiscountDirector.d.ts.map +1 -0
- package/lib/directors/OrderDiscountDirector.js +3 -0
- package/lib/directors/OrderDiscountDirector.js.map +1 -0
- package/lib/directors/OrderPricingAdapter.d.ts +18 -0
- package/lib/directors/OrderPricingAdapter.d.ts.map +1 -0
- package/lib/directors/OrderPricingAdapter.js +24 -0
- package/lib/directors/OrderPricingAdapter.js.map +1 -0
- package/lib/directors/OrderPricingDirector.d.ts +18 -0
- package/lib/directors/OrderPricingDirector.d.ts.map +1 -0
- package/lib/directors/OrderPricingDirector.js +31 -0
- package/lib/directors/OrderPricingDirector.js.map +1 -0
- package/lib/directors/OrderPricingSheet.d.ts +37 -0
- package/lib/directors/OrderPricingSheet.d.ts.map +1 -0
- package/lib/directors/OrderPricingSheet.js +108 -0
- package/lib/directors/OrderPricingSheet.js.map +1 -0
- package/lib/directors/PaymentAdapter.d.ts +50 -0
- package/lib/directors/PaymentAdapter.d.ts.map +1 -0
- package/lib/directors/PaymentAdapter.js +55 -0
- package/lib/directors/PaymentAdapter.js.map +1 -0
- package/lib/directors/PaymentDirector.d.ts +21 -0
- package/lib/directors/PaymentDirector.d.ts.map +1 -0
- package/lib/directors/PaymentDirector.js +172 -0
- package/lib/directors/PaymentDirector.js.map +1 -0
- package/lib/directors/PaymentPricingAdapter.d.ts +48 -0
- package/lib/directors/PaymentPricingAdapter.d.ts.map +1 -0
- package/lib/directors/PaymentPricingAdapter.js +25 -0
- package/lib/directors/PaymentPricingAdapter.js.map +1 -0
- package/lib/directors/PaymentPricingDirector.d.ts +18 -0
- package/lib/directors/PaymentPricingDirector.d.ts.map +1 -0
- package/lib/directors/PaymentPricingDirector.js +51 -0
- package/lib/directors/PaymentPricingDirector.js.map +1 -0
- package/lib/directors/PaymentPricingSheet.d.ts +9 -0
- package/lib/directors/PaymentPricingSheet.d.ts.map +1 -0
- package/lib/directors/PaymentPricingSheet.js +75 -0
- package/lib/directors/PaymentPricingSheet.js.map +1 -0
- package/lib/directors/ProductDiscountAdapter.d.ts +3 -0
- package/lib/directors/ProductDiscountAdapter.d.ts.map +1 -0
- package/lib/directors/ProductDiscountAdapter.js +3 -0
- package/lib/directors/ProductDiscountAdapter.js.map +1 -0
- package/lib/directors/ProductDiscountConfiguration.d.ts +13 -0
- package/lib/directors/ProductDiscountConfiguration.d.ts.map +1 -0
- package/lib/directors/ProductDiscountConfiguration.js +2 -0
- package/lib/directors/ProductDiscountConfiguration.js.map +1 -0
- package/lib/directors/ProductDiscountDirector.d.ts +3 -0
- package/lib/directors/ProductDiscountDirector.d.ts.map +1 -0
- package/lib/directors/ProductDiscountDirector.js +3 -0
- package/lib/directors/ProductDiscountDirector.js.map +1 -0
- package/lib/directors/ProductPricingAdapter.d.ts +19 -0
- package/lib/directors/ProductPricingAdapter.d.ts.map +1 -0
- package/lib/directors/ProductPricingAdapter.js +24 -0
- package/lib/directors/ProductPricingAdapter.js.map +1 -0
- package/lib/directors/ProductPricingDirector.d.ts +21 -0
- package/lib/directors/ProductPricingDirector.d.ts.map +1 -0
- package/lib/directors/ProductPricingDirector.js +52 -0
- package/lib/directors/ProductPricingDirector.js.map +1 -0
- package/lib/directors/ProductPricingSheet.d.ts +35 -0
- package/lib/directors/ProductPricingSheet.d.ts.map +1 -0
- package/lib/directors/ProductPricingSheet.js +83 -0
- package/lib/directors/ProductPricingSheet.js.map +1 -0
- package/lib/directors/QuotationAdapter.d.ts +28 -0
- package/lib/directors/QuotationAdapter.d.ts.map +1 -0
- package/lib/directors/QuotationAdapter.js +46 -0
- package/lib/directors/QuotationAdapter.js.map +1 -0
- package/lib/directors/QuotationDirector.d.ts +7 -0
- package/lib/directors/QuotationDirector.d.ts.map +1 -0
- package/lib/directors/QuotationDirector.js +84 -0
- package/lib/directors/QuotationDirector.js.map +1 -0
- package/lib/directors/WarehousingAdapter.d.ts +40 -0
- package/lib/directors/WarehousingAdapter.d.ts.map +1 -0
- package/lib/directors/WarehousingAdapter.js +32 -0
- package/lib/directors/WarehousingAdapter.js.map +1 -0
- package/lib/directors/WarehousingDirector.d.ts +41 -0
- package/lib/directors/WarehousingDirector.d.ts.map +1 -0
- package/lib/directors/WarehousingDirector.js +169 -0
- package/lib/directors/WarehousingDirector.js.map +1 -0
- package/lib/directors/WorkerAdapter.d.ts +17 -0
- package/lib/directors/WorkerAdapter.d.ts.map +1 -0
- package/lib/directors/WorkerAdapter.js +11 -0
- package/lib/directors/WorkerAdapter.js.map +1 -0
- package/lib/directors/WorkerDirector.d.ts +26 -0
- package/lib/directors/WorkerDirector.d.ts.map +1 -0
- package/lib/directors/WorkerDirector.js +102 -0
- package/lib/directors/WorkerDirector.js.map +1 -0
- package/lib/directors/index.d.ts +39 -0
- package/lib/directors/index.d.ts.map +1 -0
- package/lib/directors/index.js +39 -0
- package/lib/directors/index.js.map +1 -0
- package/lib/modules.d.ts +59 -0
- package/lib/modules.d.ts.map +1 -0
- package/lib/modules.js +126 -0
- package/lib/modules.js.map +1 -0
- package/lib/services/activateEnrollment.d.ts +4 -0
- package/lib/services/activateEnrollment.d.ts.map +1 -0
- package/lib/services/activateEnrollment.js +25 -0
- package/lib/services/activateEnrollment.js.map +1 -0
- package/lib/services/calculateDiscountTotal.d.ts +7 -0
- package/lib/services/calculateDiscountTotal.d.ts.map +1 -0
- package/lib/services/calculateDiscountTotal.js +49 -0
- package/lib/services/calculateDiscountTotal.js.map +1 -0
- package/lib/services/checkoutOrder.d.ts +9 -0
- package/lib/services/checkoutOrder.d.ts.map +1 -0
- package/lib/services/checkoutOrder.js +28 -0
- package/lib/services/checkoutOrder.js.map +1 -0
- package/lib/services/confirmOrder.d.ts +9 -0
- package/lib/services/confirmOrder.d.ts.map +1 -0
- package/lib/services/confirmOrder.js +17 -0
- package/lib/services/confirmOrder.js.map +1 -0
- package/lib/services/createDownloadStream.d.ts +5 -0
- package/lib/services/createDownloadStream.d.ts.map +1 -0
- package/lib/services/createDownloadStream.js +8 -0
- package/lib/services/createDownloadStream.js.map +1 -0
- package/lib/services/createEnrollmentFromCheckout.d.ts +15 -0
- package/lib/services/createEnrollmentFromCheckout.d.ts.map +1 -0
- package/lib/services/createEnrollmentFromCheckout.js +40 -0
- package/lib/services/createEnrollmentFromCheckout.js.map +1 -0
- package/lib/services/createManualOrderDiscount.d.ts +7 -0
- package/lib/services/createManualOrderDiscount.d.ts.map +1 -0
- package/lib/services/createManualOrderDiscount.js +47 -0
- package/lib/services/createManualOrderDiscount.js.map +1 -0
- package/lib/services/createSignedURL.d.ts +8 -0
- package/lib/services/createSignedURL.d.ts.map +1 -0
- package/lib/services/createSignedURL.js +15 -0
- package/lib/services/createSignedURL.js.map +1 -0
- package/lib/services/deleteUser.d.ts +5 -0
- package/lib/services/deleteUser.d.ts.map +1 -0
- package/lib/services/deleteUser.js +26 -0
- package/lib/services/deleteUser.js.map +1 -0
- package/lib/services/discountedEntities.d.ts +5 -0
- package/lib/services/discountedEntities.d.ts.map +1 -0
- package/lib/services/discountedEntities.js +61 -0
- package/lib/services/discountedEntities.js.map +1 -0
- package/lib/services/ercMetadata.d.ts +7 -0
- package/lib/services/ercMetadata.d.ts.map +1 -0
- package/lib/services/ercMetadata.js +22 -0
- package/lib/services/ercMetadata.js.map +1 -0
- package/lib/services/findOrInitCart.d.ts +9 -0
- package/lib/services/findOrInitCart.d.ts.map +1 -0
- package/lib/services/findOrInitCart.js +15 -0
- package/lib/services/findOrInitCart.js.map +1 -0
- package/lib/services/fullfillQuotation.d.ts +4 -0
- package/lib/services/fullfillQuotation.d.ts.map +1 -0
- package/lib/services/fullfillQuotation.js +12 -0
- package/lib/services/fullfillQuotation.js.map +1 -0
- package/lib/services/index.d.ts +118 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/index.js +132 -0
- package/lib/services/index.js.map +1 -0
- package/lib/services/initCartProviders.d.ts +4 -0
- package/lib/services/initCartProviders.d.ts.map +1 -0
- package/lib/services/initCartProviders.js +55 -0
- package/lib/services/initCartProviders.js.map +1 -0
- package/lib/services/initializeEnrollment.d.ts +7 -0
- package/lib/services/initializeEnrollment.d.ts.map +1 -0
- package/lib/services/initializeEnrollment.js +28 -0
- package/lib/services/initializeEnrollment.js.map +1 -0
- package/lib/services/invalidateFilterCache.d.ts +3 -0
- package/lib/services/invalidateFilterCache.d.ts.map +1 -0
- package/lib/services/invalidateFilterCache.js +12 -0
- package/lib/services/invalidateFilterCache.js.map +1 -0
- package/lib/services/linkFileService.d.ts +7 -0
- package/lib/services/linkFileService.d.ts.map +1 -0
- package/lib/services/linkFileService.js +18 -0
- package/lib/services/linkFileService.js.map +1 -0
- package/lib/services/loadFilterOptions.d.ts +14 -0
- package/lib/services/loadFilterOptions.d.ts.map +1 -0
- package/lib/services/loadFilterOptions.js +29 -0
- package/lib/services/loadFilterOptions.js.map +1 -0
- package/lib/services/loadFilters.d.ts +14 -0
- package/lib/services/loadFilters.d.ts.map +1 -0
- package/lib/services/loadFilters.js +36 -0
- package/lib/services/loadFilters.js.map +1 -0
- package/lib/services/migrateBookmarks.d.ts +8 -0
- package/lib/services/migrateBookmarks.d.ts.map +1 -0
- package/lib/services/migrateBookmarks.js +26 -0
- package/lib/services/migrateBookmarks.js.map +1 -0
- package/lib/services/migrateOrderCart.d.ts +8 -0
- package/lib/services/migrateOrderCart.d.ts.map +1 -0
- package/lib/services/migrateOrderCart.js +32 -0
- package/lib/services/migrateOrderCart.js.map +1 -0
- package/lib/services/migrateUserData.d.ts +2 -0
- package/lib/services/migrateUserData.d.ts.map +1 -0
- package/lib/services/migrateUserData.js +20 -0
- package/lib/services/migrateUserData.js.map +1 -0
- package/lib/services/nextUserCart.d.ts +9 -0
- package/lib/services/nextUserCart.d.ts.map +1 -0
- package/lib/services/nextUserCart.js +34 -0
- package/lib/services/nextUserCart.js.map +1 -0
- package/lib/services/processEnrollment.d.ts +4 -0
- package/lib/services/processEnrollment.d.ts.map +1 -0
- package/lib/services/processEnrollment.js +33 -0
- package/lib/services/processEnrollment.js.map +1 -0
- package/lib/services/processOrder.d.ts +9 -0
- package/lib/services/processOrder.d.ts.map +1 -0
- package/lib/services/processOrder.js +161 -0
- package/lib/services/processOrder.js.map +1 -0
- package/lib/services/processQuotation.d.ts +6 -0
- package/lib/services/processQuotation.d.ts.map +1 -0
- package/lib/services/processQuotation.js +60 -0
- package/lib/services/processQuotation.js.map +1 -0
- package/lib/services/proposeQuotation.d.ts +6 -0
- package/lib/services/proposeQuotation.d.ts.map +1 -0
- package/lib/services/proposeQuotation.js +12 -0
- package/lib/services/proposeQuotation.js.map +1 -0
- package/lib/services/registerPaymentCredentials.d.ts +5 -0
- package/lib/services/registerPaymentCredentials.d.ts.map +1 -0
- package/lib/services/registerPaymentCredentials.js +21 -0
- package/lib/services/registerPaymentCredentials.js.map +1 -0
- package/lib/services/rejectOrder.d.ts +9 -0
- package/lib/services/rejectOrder.d.ts.map +1 -0
- package/lib/services/rejectOrder.js +17 -0
- package/lib/services/rejectOrder.js.map +1 -0
- package/lib/services/rejectQuotation.d.ts +6 -0
- package/lib/services/rejectQuotation.d.ts.map +1 -0
- package/lib/services/rejectQuotation.js +12 -0
- package/lib/services/rejectQuotation.js.map +1 -0
- package/lib/services/removeFiles.d.ts +5 -0
- package/lib/services/removeFiles.d.ts.map +1 -0
- package/lib/services/removeFiles.js +19 -0
- package/lib/services/removeFiles.js.map +1 -0
- package/lib/services/removeProduct.d.ts +5 -0
- package/lib/services/removeProduct.d.ts.map +1 -0
- package/lib/services/removeProduct.js +26 -0
- package/lib/services/removeProduct.js.map +1 -0
- package/lib/services/searchAssortments.d.ts +19 -0
- package/lib/services/searchAssortments.d.ts.map +1 -0
- package/lib/services/searchAssortments.js +33 -0
- package/lib/services/searchAssortments.js.map +1 -0
- package/lib/services/searchProducts.d.ts +16 -0
- package/lib/services/searchProducts.d.ts.map +1 -0
- package/lib/services/searchProducts.js +41 -0
- package/lib/services/searchProducts.js.map +1 -0
- package/lib/services/simulateProductDispatching.d.ts +15 -0
- package/lib/services/simulateProductDispatching.d.ts.map +1 -0
- package/lib/services/simulateProductDispatching.js +30 -0
- package/lib/services/simulateProductDispatching.js.map +1 -0
- package/lib/services/simulateProductInventory.d.ts +15 -0
- package/lib/services/simulateProductInventory.d.ts.map +1 -0
- package/lib/services/simulateProductInventory.js +29 -0
- package/lib/services/simulateProductInventory.js.map +1 -0
- package/lib/services/simulateProductPricing.d.ts +12 -0
- package/lib/services/simulateProductPricing.d.ts.map +1 -0
- package/lib/services/simulateProductPricing.js +8 -0
- package/lib/services/simulateProductPricing.js.map +1 -0
- package/lib/services/supportedDeliveryProviders.d.ts +5 -0
- package/lib/services/supportedDeliveryProviders.d.ts.map +1 -0
- package/lib/services/supportedDeliveryProviders.js +14 -0
- package/lib/services/supportedDeliveryProviders.js.map +1 -0
- package/lib/services/supportedPaymentProviders.d.ts +5 -0
- package/lib/services/supportedPaymentProviders.d.ts.map +1 -0
- package/lib/services/supportedPaymentProviders.js +14 -0
- package/lib/services/supportedPaymentProviders.js.map +1 -0
- package/lib/services/supportedWarehousingProviders.d.ts +5 -0
- package/lib/services/supportedWarehousingProviders.d.ts.map +1 -0
- package/lib/services/supportedWarehousingProviders.js +10 -0
- package/lib/services/supportedWarehousingProviders.js.map +1 -0
- package/lib/services/terminateEnrollment.d.ts +3 -0
- package/lib/services/terminateEnrollment.d.ts.map +1 -0
- package/lib/services/terminateEnrollment.js +25 -0
- package/lib/services/terminateEnrollment.js.map +1 -0
- package/lib/services/updateCalculation.d.ts +3 -0
- package/lib/services/updateCalculation.d.ts.map +1 -0
- package/lib/services/updateCalculation.js +101 -0
- package/lib/services/updateCalculation.js.map +1 -0
- package/lib/services/updateScheduling.d.ts +8 -0
- package/lib/services/updateScheduling.d.ts.map +1 -0
- package/lib/services/updateScheduling.js +42 -0
- package/lib/services/updateScheduling.js.map +1 -0
- package/lib/services/updateUserAvatarAfterUpload.d.ts +6 -0
- package/lib/services/updateUserAvatarAfterUpload.d.ts.map +1 -0
- package/lib/services/updateUserAvatarAfterUpload.js +25 -0
- package/lib/services/updateUserAvatarAfterUpload.js.map +1 -0
- package/lib/services/uploadFileFromStream.d.ts +8 -0
- package/lib/services/uploadFileFromStream.d.ts.map +1 -0
- package/lib/services/uploadFileFromStream.js +11 -0
- package/lib/services/uploadFileFromStream.js.map +1 -0
- package/lib/services/uploadFileFromURL.d.ts +13 -0
- package/lib/services/uploadFileFromURL.d.ts.map +1 -0
- package/lib/services/uploadFileFromURL.js +11 -0
- package/lib/services/uploadFileFromURL.js.map +1 -0
- package/lib/services/validateOrder.d.ts +4 -0
- package/lib/services/validateOrder.d.ts.map +1 -0
- package/lib/services/validateOrder.js +45 -0
- package/lib/services/validateOrder.js.map +1 -0
- package/lib/services/verifyQuotation.d.ts +6 -0
- package/lib/services/verifyQuotation.d.ts.map +1 -0
- package/lib/services/verifyQuotation.js +12 -0
- package/lib/services/verifyQuotation.js.map +1 -0
- package/package.json +30 -29
- package/src/core-index.ts +14 -241
- package/src/directors/BaseDiscountAdapter.test.ts +49 -0
- package/src/directors/BaseDiscountAdapter.ts +90 -0
- package/src/directors/BaseDiscountDirector.ts +73 -0
- package/src/directors/BasePricingAdapter.ts +80 -0
- package/src/directors/BasePricingDirector.ts +137 -0
- package/src/directors/BasePricingSheet.test.ts +43 -0
- package/src/directors/BasePricingSheet.ts +140 -0
- package/src/directors/DeliveryAdapter.ts +110 -0
- package/src/directors/DeliveryDirector.ts +135 -0
- package/src/directors/DeliveryPricingAdapter.ts +87 -0
- package/src/directors/DeliveryPricingDirector.ts +92 -0
- package/src/directors/DeliveryPricingSheet.ts +86 -0
- package/src/directors/EnrollmentAdapter.ts +113 -0
- package/src/directors/EnrollmentDirector.ts +70 -0
- package/src/directors/FilterAdapter.ts +103 -0
- package/src/directors/FilterDirector.ts +313 -0
- package/src/directors/MessagingDirector.test.ts +5 -0
- package/src/directors/MessagingDirector.ts +59 -0
- package/src/directors/OrderDiscountAdapter.ts +10 -0
- package/src/directors/OrderDiscountConfiguration.ts +5 -0
- package/src/directors/OrderDiscountDirector.ts +5 -0
- package/src/directors/OrderPricingAdapter.ts +63 -0
- package/src/directors/OrderPricingDirector.ts +74 -0
- package/src/directors/OrderPricingSheet.ts +147 -0
- package/src/directors/PaymentAdapter.ts +118 -0
- package/src/directors/PaymentDirector.ts +275 -0
- package/src/directors/PaymentPricingAdapter.ts +86 -0
- package/src/directors/PaymentPricingDirector.ts +94 -0
- package/src/directors/PaymentPricingSheet.ts +91 -0
- package/src/directors/ProductDiscountAdapter.ts +10 -0
- package/src/directors/ProductDiscountConfiguration.ts +18 -0
- package/src/directors/ProductDiscountDirector.ts +4 -0
- package/src/directors/ProductPricingAdapter.ts +58 -0
- package/src/directors/ProductPricingDirector.ts +100 -0
- package/src/directors/ProductPricingSheet.test.ts +129 -0
- package/src/directors/ProductPricingSheet.ts +124 -0
- package/src/directors/QuotationAdapter.ts +86 -0
- package/src/directors/QuotationDirector.ts +105 -0
- package/src/directors/WarehousingAdapter.ts +83 -0
- package/src/directors/WarehousingDirector.ts +236 -0
- package/src/directors/WorkerAdapter.ts +30 -0
- package/src/directors/WorkerDirector.ts +154 -0
- package/src/directors/index.ts +49 -0
- package/src/directors/periodForReferenceDate.test.ts +23 -0
- package/src/modules.ts +208 -0
- package/src/services/activateEnrollment.ts +30 -0
- package/src/services/calculateDiscountTotal.ts +71 -0
- package/src/services/checkoutOrder.ts +43 -0
- package/src/services/confirmOrder.ts +26 -0
- package/src/services/createDownloadStream.ts +16 -0
- package/src/services/createEnrollmentFromCheckout.ts +66 -0
- package/src/services/createManualOrderDiscount.ts +56 -0
- package/src/services/createSignedURL.ts +20 -0
- package/src/services/deleteUser.ts +33 -0
- package/src/services/discountedEntities.ts +81 -0
- package/src/services/ercMetadata.ts +33 -0
- package/src/services/findOrInitCart.ts +29 -0
- package/src/services/fullfillQuotation.ts +14 -0
- package/src/services/index.ts +168 -0
- package/src/services/initCartProviders.ts +86 -0
- package/src/services/initializeEnrollment.ts +38 -0
- package/src/services/invalidateFilterCache.ts +16 -0
- package/src/services/linkFileService.ts +22 -0
- package/src/services/loadFilterOptions.ts +49 -0
- package/src/services/loadFilters.ts +52 -0
- package/src/services/migrateBookmarks.ts +39 -0
- package/src/services/migrateOrderCart.ts +52 -0
- package/src/services/migrateUserData.ts +22 -0
- package/src/services/nextUserCart.ts +52 -0
- package/src/services/processEnrollment.ts +37 -0
- package/src/services/processOrder.ts +241 -0
- package/src/services/processQuotation.ts +75 -0
- package/src/services/proposeQuotation.ts +18 -0
- package/src/services/registerPaymentCredentials.ts +30 -0
- package/src/services/rejectOrder.ts +26 -0
- package/src/services/rejectQuotation.ts +18 -0
- package/src/services/removeFiles.ts +25 -0
- package/src/services/removeProduct.ts +34 -0
- package/src/services/searchAssortments.ts +58 -0
- package/src/services/searchProducts.ts +73 -0
- package/src/services/simulateProductDispatching.ts +59 -0
- package/src/services/simulateProductInventory.ts +56 -0
- package/src/services/simulateProductPricing.ts +20 -0
- package/src/services/supportedDeliveryProviders.ts +24 -0
- package/src/services/supportedPaymentProviders.ts +25 -0
- package/src/services/supportedWarehousingProviders.ts +18 -0
- package/src/services/terminateEnrollment.ts +29 -0
- package/src/services/updateCalculation.ts +143 -0
- package/src/services/updateScheduling.ts +64 -0
- package/src/services/updateUserAvatarAfterUpload.ts +30 -0
- package/src/services/uploadFileFromStream.ts +15 -0
- package/src/services/uploadFileFromURL.ts +29 -0
- package/src/services/validateOrder.ts +53 -0
- package/src/services/verifyQuotation.ts +18 -0
- package/tsconfig.json +5 -7
- package/lib/types.d.ts +0 -4
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -5
- package/lib/types.js.map +0 -1
- package/src/types.ts +0 -7
package/lib/core-index.d.ts
CHANGED
|
@@ -1,36 +1,10 @@
|
|
|
1
|
-
import { BulkImporter } from './types.js';
|
|
2
|
-
import { AssortmentsModule, AssortmentsSettingsOptions } from '@unchainedshop/core-assortments';
|
|
3
|
-
import { BookmarkServices, BookmarksModule } from '@unchainedshop/core-bookmarks';
|
|
4
|
-
import { CountriesModule } from '@unchainedshop/core-countries';
|
|
5
|
-
import { CurrenciesModule } from '@unchainedshop/core-currencies';
|
|
6
|
-
import { DeliveryModule, DeliverySettingsOptions } from '@unchainedshop/core-delivery';
|
|
7
|
-
import { EnrollmentsModule, EnrollmentsSettingsOptions } from '@unchainedshop/core-enrollments';
|
|
8
|
-
import { EventsModule } from '@unchainedshop/core-events';
|
|
9
|
-
import { FileServices, FilesModule, FilesSettingsOptions } from '@unchainedshop/core-files';
|
|
10
|
-
import { FiltersModule, FiltersSettingsOptions } from '@unchainedshop/core-filters';
|
|
11
|
-
import { LanguagesModule } from '@unchainedshop/core-languages';
|
|
12
|
-
import { MessagingModule } from '@unchainedshop/core-messaging';
|
|
13
|
-
import { OrderServices, OrdersModule, OrdersSettingsOptions } from '@unchainedshop/core-orders';
|
|
14
|
-
import { PaymentModule, PaymentSettingsOptions } from '@unchainedshop/core-payment';
|
|
15
|
-
import { ProductServices, ProductsModule, ProductsSettingsOptions } from '@unchainedshop/core-products';
|
|
16
|
-
import { QuotationsModule, QuotationsSettingsOptions } from '@unchainedshop/core-quotations';
|
|
17
|
-
import { UserServices, UserSettingsOptions, UsersModule } from '@unchainedshop/core-users';
|
|
18
|
-
import { WarehousingModule } from '@unchainedshop/core-warehousing';
|
|
19
|
-
import { WorkerModule, WorkerSettingsOptions } from '@unchainedshop/core-worker';
|
|
20
1
|
import { mongodb, MigrationRepository, ModuleInput } from '@unchainedshop/mongodb';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
enrollments?: EnrollmentsSettingsOptions;
|
|
28
|
-
orders?: OrdersSettingsOptions;
|
|
29
|
-
quotations?: QuotationsSettingsOptions;
|
|
30
|
-
files?: FilesSettingsOptions;
|
|
31
|
-
payment?: PaymentSettingsOptions;
|
|
32
|
-
worker?: WorkerSettingsOptions;
|
|
33
|
-
users?: UserSettingsOptions;
|
|
2
|
+
import { Services } from './services/index.js';
|
|
3
|
+
import { Modules, ModuleOptions } from './modules.js';
|
|
4
|
+
export * from './services/index.js';
|
|
5
|
+
export * from './directors/index.js';
|
|
6
|
+
export interface BulkImporter {
|
|
7
|
+
createBulkImporter: (options: any) => any;
|
|
34
8
|
}
|
|
35
9
|
export interface UnchainedCoreOptions {
|
|
36
10
|
db: mongodb.Db;
|
|
@@ -39,41 +13,14 @@ export interface UnchainedCoreOptions {
|
|
|
39
13
|
modules?: Record<string, {
|
|
40
14
|
configure: (params: ModuleInput<any>) => any;
|
|
41
15
|
}>;
|
|
42
|
-
services?: Record<string, any>;
|
|
16
|
+
services?: Record<string, (this: Modules, ...args: any[]) => any>;
|
|
43
17
|
options?: ModuleOptions;
|
|
44
18
|
}
|
|
45
|
-
export interface Modules {
|
|
46
|
-
assortments: AssortmentsModule;
|
|
47
|
-
bookmarks: BookmarksModule;
|
|
48
|
-
countries: CountriesModule;
|
|
49
|
-
currencies: CurrenciesModule;
|
|
50
|
-
delivery: DeliveryModule;
|
|
51
|
-
enrollments: EnrollmentsModule;
|
|
52
|
-
events: EventsModule;
|
|
53
|
-
files: FilesModule;
|
|
54
|
-
filters: FiltersModule;
|
|
55
|
-
languages: LanguagesModule;
|
|
56
|
-
messaging: MessagingModule;
|
|
57
|
-
orders: OrdersModule;
|
|
58
|
-
payment: PaymentModule;
|
|
59
|
-
products: ProductsModule;
|
|
60
|
-
quotations: QuotationsModule;
|
|
61
|
-
users: UsersModule;
|
|
62
|
-
warehousing: WarehousingModule;
|
|
63
|
-
worker: WorkerModule;
|
|
64
|
-
}
|
|
65
|
-
export interface Services {
|
|
66
|
-
bookmarks: BookmarkServices;
|
|
67
|
-
files: FileServices;
|
|
68
|
-
orders: OrderServices;
|
|
69
|
-
products: ProductServices;
|
|
70
|
-
users: UserServices;
|
|
71
|
-
}
|
|
72
19
|
export interface UnchainedCore {
|
|
73
20
|
modules: Modules;
|
|
74
21
|
services: Services;
|
|
75
22
|
bulkImporter: BulkImporter;
|
|
76
23
|
options: ModuleOptions;
|
|
77
24
|
}
|
|
78
|
-
export declare const initCore: ({ db, migrationRepository, bulkImporter, modules, services, options, }: UnchainedCoreOptions) => Promise<UnchainedCore>;
|
|
25
|
+
export declare const initCore: ({ db, migrationRepository, bulkImporter, modules: customModules, services: customServices, options, }: UnchainedCoreOptions) => Promise<UnchainedCore>;
|
|
79
26
|
//# sourceMappingURL=core-index.d.ts.map
|
package/lib/core-index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-index.d.ts","sourceRoot":"","sources":["../src/core-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"core-index.d.ts","sourceRoot":"","sources":["../src/core-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAqB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAoB,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEnE,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAErC,MAAM,WAAW,YAAY;IAC3B,kBAAkB,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,GAAG,CAAC;CAC3C;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,OAAO,CAAC,EAAE,CAAC;IACf,mBAAmB,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAC;IACxD,YAAY,EAAE,GAAG,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CACd,MAAM,EACN;QACE,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC;KAC9C,CACF,CAAC;IACF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,OAAA,KAAK,GAAG,CAAC,CAAC;IAC3D,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,eAAO,MAAM,QAAQ,0GAOlB,oBAAoB,KAAG,OAAO,CAAC,aAAa,CAY9C,CAAC"}
|
package/lib/core-index.js
CHANGED
|
@@ -1,145 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { configureEnrollmentsModule, } from '@unchainedshop/core-enrollments';
|
|
7
|
-
import { configureEventsModule } from '@unchainedshop/core-events';
|
|
8
|
-
import { configureFilesModule, fileServices, } from '@unchainedshop/core-files';
|
|
9
|
-
import { configureFiltersModule, } from '@unchainedshop/core-filters';
|
|
10
|
-
import { configureLanguagesModule } from '@unchainedshop/core-languages';
|
|
11
|
-
import { configureMessagingModule } from '@unchainedshop/core-messaging';
|
|
12
|
-
import { configureOrdersModule, orderServices, } from '@unchainedshop/core-orders';
|
|
13
|
-
import { configurePaymentModule, } from '@unchainedshop/core-payment';
|
|
14
|
-
import { configureProductsModule, productServices, } from '@unchainedshop/core-products';
|
|
15
|
-
import { configureQuotationsModule, } from '@unchainedshop/core-quotations';
|
|
16
|
-
import { configureUsersModule, userServices, } from '@unchainedshop/core-users';
|
|
17
|
-
import { configureWarehousingModule } from '@unchainedshop/core-warehousing';
|
|
18
|
-
import { configureWorkerModule } from '@unchainedshop/core-worker';
|
|
19
|
-
export * from './types.js';
|
|
20
|
-
export const initCore = async ({ db, migrationRepository, bulkImporter, modules = {}, services = {}, options = {}, }) => {
|
|
21
|
-
const assortments = await configureAssortmentsModule({
|
|
22
|
-
db,
|
|
23
|
-
options: options.assortments,
|
|
24
|
-
migrationRepository,
|
|
25
|
-
});
|
|
26
|
-
const bookmarks = await configureBookmarksModule({
|
|
27
|
-
db,
|
|
28
|
-
migrationRepository,
|
|
29
|
-
});
|
|
30
|
-
const countries = await configureCountriesModule({
|
|
31
|
-
db,
|
|
32
|
-
migrationRepository,
|
|
33
|
-
});
|
|
34
|
-
const currencies = await configureCurrenciesModule({
|
|
35
|
-
db,
|
|
36
|
-
migrationRepository,
|
|
37
|
-
});
|
|
38
|
-
const delivery = await configureDeliveryModule({
|
|
39
|
-
db,
|
|
40
|
-
options: options.delivery,
|
|
41
|
-
migrationRepository,
|
|
42
|
-
});
|
|
43
|
-
const enrollments = await configureEnrollmentsModule({
|
|
44
|
-
db,
|
|
45
|
-
options: options.enrollments,
|
|
46
|
-
migrationRepository,
|
|
47
|
-
});
|
|
48
|
-
const events = await configureEventsModule({
|
|
49
|
-
db,
|
|
50
|
-
migrationRepository,
|
|
51
|
-
});
|
|
52
|
-
const files = await configureFilesModule({
|
|
53
|
-
db,
|
|
54
|
-
options: options.files,
|
|
55
|
-
migrationRepository,
|
|
56
|
-
});
|
|
57
|
-
const filters = await configureFiltersModule({
|
|
58
|
-
db,
|
|
59
|
-
options: options.filters,
|
|
60
|
-
migrationRepository,
|
|
61
|
-
});
|
|
62
|
-
const languages = await configureLanguagesModule({
|
|
63
|
-
db,
|
|
64
|
-
migrationRepository,
|
|
65
|
-
});
|
|
66
|
-
const messaging = await configureMessagingModule({
|
|
67
|
-
db,
|
|
68
|
-
migrationRepository,
|
|
69
|
-
});
|
|
70
|
-
const orders = await configureOrdersModule({
|
|
71
|
-
db,
|
|
72
|
-
options: options.orders,
|
|
73
|
-
migrationRepository,
|
|
74
|
-
});
|
|
75
|
-
const payment = await configurePaymentModule({
|
|
76
|
-
db,
|
|
77
|
-
options: options.payment,
|
|
78
|
-
migrationRepository,
|
|
79
|
-
});
|
|
80
|
-
const products = await configureProductsModule({
|
|
81
|
-
db,
|
|
82
|
-
migrationRepository,
|
|
83
|
-
});
|
|
84
|
-
const quotations = await configureQuotationsModule({
|
|
85
|
-
db,
|
|
86
|
-
options: options.quotations,
|
|
87
|
-
migrationRepository,
|
|
88
|
-
});
|
|
89
|
-
const users = await configureUsersModule({
|
|
90
|
-
db,
|
|
91
|
-
migrationRepository,
|
|
92
|
-
});
|
|
93
|
-
const warehousing = await configureWarehousingModule({
|
|
94
|
-
db,
|
|
95
|
-
migrationRepository,
|
|
96
|
-
});
|
|
97
|
-
const worker = await configureWorkerModule({
|
|
98
|
-
db,
|
|
99
|
-
options: options.worker,
|
|
100
|
-
migrationRepository,
|
|
101
|
-
});
|
|
1
|
+
import initServices from './services/index.js';
|
|
2
|
+
import initModules from './modules.js';
|
|
3
|
+
export * from './services/index.js';
|
|
4
|
+
export * from './directors/index.js';
|
|
5
|
+
export const initCore = async ({ db, migrationRepository, bulkImporter, modules: customModules = {}, services: customServices = {}, options = {}, }) => {
|
|
102
6
|
// Configure custom modules
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
...(await modulesPromise),
|
|
106
|
-
[key]: await customModule.configure({
|
|
107
|
-
db,
|
|
108
|
-
options: options?.[key],
|
|
109
|
-
migrationRepository,
|
|
110
|
-
}),
|
|
111
|
-
};
|
|
112
|
-
}, Promise.resolve({}));
|
|
7
|
+
const modules = await initModules({ db, migrationRepository, options }, customModules);
|
|
8
|
+
const services = initServices(modules, customServices);
|
|
113
9
|
return {
|
|
114
|
-
modules
|
|
115
|
-
|
|
116
|
-
bookmarks,
|
|
117
|
-
countries,
|
|
118
|
-
currencies,
|
|
119
|
-
delivery,
|
|
120
|
-
enrollments,
|
|
121
|
-
events,
|
|
122
|
-
files,
|
|
123
|
-
filters,
|
|
124
|
-
languages,
|
|
125
|
-
messaging,
|
|
126
|
-
orders,
|
|
127
|
-
payment,
|
|
128
|
-
products,
|
|
129
|
-
quotations,
|
|
130
|
-
users,
|
|
131
|
-
warehousing,
|
|
132
|
-
worker,
|
|
133
|
-
...customModules,
|
|
134
|
-
},
|
|
135
|
-
services: {
|
|
136
|
-
bookmarks: bookmarkServices,
|
|
137
|
-
files: fileServices,
|
|
138
|
-
orders: orderServices,
|
|
139
|
-
products: productServices,
|
|
140
|
-
users: userServices,
|
|
141
|
-
...services,
|
|
142
|
-
},
|
|
10
|
+
modules,
|
|
11
|
+
services,
|
|
143
12
|
bulkImporter,
|
|
144
13
|
options,
|
|
145
14
|
};
|
package/lib/core-index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-index.js","sourceRoot":"","sources":["../src/core-index.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"core-index.js","sourceRoot":"","sources":["../src/core-index.ts"],"names":[],"mappings":"AACA,OAAO,YAA0B,MAAM,qBAAqB,CAAC;AAC7D,OAAO,WAAuC,MAAM,cAAc,CAAC;AAEnE,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AA2BrC,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,EAC7B,EAAE,EACF,mBAAmB,EACnB,YAAY,EACZ,OAAO,EAAE,aAAa,GAAG,EAAE,EAC3B,QAAQ,EAAE,cAAc,GAAG,EAAE,EAC7B,OAAO,GAAG,EAAE,GACS,EAA0B,EAAE;IACjD,2BAA2B;IAE3B,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,EAAE,EAAE,EAAE,mBAAmB,EAAE,OAAO,EAAE,EAAE,aAAa,CAAC,CAAC;IACvF,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAEvD,OAAO;QACL,OAAO;QACP,QAAQ;QACR,YAAY;QACZ,OAAO;KACR,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IBaseAdapter } from '@unchainedshop/utils';
|
|
2
|
+
import { IPricingSheet } from './BasePricingSheet.js';
|
|
3
|
+
import { PricingCalculation } from '@unchainedshop/utils';
|
|
4
|
+
import { Order, OrderDiscount } from '@unchainedshop/core-orders';
|
|
5
|
+
import { Modules } from '../modules.js';
|
|
6
|
+
export interface DiscountContext {
|
|
7
|
+
code?: string;
|
|
8
|
+
orderDiscount?: OrderDiscount;
|
|
9
|
+
order?: Order;
|
|
10
|
+
}
|
|
11
|
+
export type IDiscountAdapter<DiscountConfiguration> = IBaseAdapter & {
|
|
12
|
+
orderIndex: number;
|
|
13
|
+
isManualAdditionAllowed: (code: string) => Promise<boolean>;
|
|
14
|
+
isManualRemovalAllowed: () => Promise<boolean>;
|
|
15
|
+
actions: (params: {
|
|
16
|
+
context: DiscountContext & {
|
|
17
|
+
modules: Modules;
|
|
18
|
+
};
|
|
19
|
+
}) => Promise<DiscountAdapterActions<DiscountConfiguration>>;
|
|
20
|
+
};
|
|
21
|
+
export interface DiscountAdapterActions<DiscountConfiguration> {
|
|
22
|
+
isValidForSystemTriggering: () => Promise<boolean>;
|
|
23
|
+
isValidForCodeTriggering: (params: {
|
|
24
|
+
code: string;
|
|
25
|
+
}) => Promise<boolean>;
|
|
26
|
+
discountForPricingAdapterKey: (params: {
|
|
27
|
+
pricingAdapterKey: string;
|
|
28
|
+
calculationSheet: IPricingSheet<PricingCalculation>;
|
|
29
|
+
}) => DiscountConfiguration;
|
|
30
|
+
reserve: (params: {
|
|
31
|
+
code: string;
|
|
32
|
+
}) => Promise<any>;
|
|
33
|
+
release: () => Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export declare const BaseDiscountAdapter: Omit<IDiscountAdapter<unknown>, 'key' | 'label' | 'version'>;
|
|
36
|
+
//# sourceMappingURL=BaseDiscountAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseDiscountAdapter.d.ts","sourceRoot":"","sources":["../../src/directors/BaseDiscountAdapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,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D,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,eAAO,MAAM,mBAAmB,EAAE,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,SAAS,CAqD5F,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { log, LogLevel } from '@unchainedshop/logger';
|
|
2
|
+
export const BaseDiscountAdapter = {
|
|
3
|
+
orderIndex: 0,
|
|
4
|
+
isManualAdditionAllowed: async () => {
|
|
5
|
+
return false;
|
|
6
|
+
},
|
|
7
|
+
// return true if a discount is allowed to get removed manually by a user
|
|
8
|
+
isManualRemovalAllowed: async () => {
|
|
9
|
+
return false;
|
|
10
|
+
},
|
|
11
|
+
actions: async () => ({
|
|
12
|
+
// return true if a discount is valid to be part of the order
|
|
13
|
+
// without input of a user. that could be a time based global discount
|
|
14
|
+
// like a 10% discount day
|
|
15
|
+
// if you return false, this discount will
|
|
16
|
+
// get removed from the order before any price calculation
|
|
17
|
+
// takes place.
|
|
18
|
+
// eslint-disable-next-line
|
|
19
|
+
isValidForSystemTriggering: async () => {
|
|
20
|
+
return false;
|
|
21
|
+
},
|
|
22
|
+
// return an arbitrary JSON serializable object with reservation data
|
|
23
|
+
// this method is called when a discount is added through a manual code and let's
|
|
24
|
+
// you manually deduct expendable discounts (coupon balances for ex.) before checkout
|
|
25
|
+
reserve: async () => {
|
|
26
|
+
return {};
|
|
27
|
+
},
|
|
28
|
+
// return void, allows you to free up any reservations in backend systems
|
|
29
|
+
release: async () => {
|
|
30
|
+
return null;
|
|
31
|
+
},
|
|
32
|
+
// return true if a discount is valid to be part of the order.
|
|
33
|
+
// if you return false, this discount will
|
|
34
|
+
// get removed from the order before any price calculation
|
|
35
|
+
// takes place.
|
|
36
|
+
isValidForCodeTriggering: async () => {
|
|
37
|
+
return false;
|
|
38
|
+
},
|
|
39
|
+
// returns the appropriate discount context for a calculation adapter
|
|
40
|
+
discountForPricingAdapterKey() {
|
|
41
|
+
return null;
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
log(message, { level = LogLevel.Debug, ...options } = {}) {
|
|
45
|
+
return log(message, { level, ...options });
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=BaseDiscountAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseDiscountAdapter.js","sourceRoot":"","sources":["../../src/directors/BaseDiscountAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAoCtD,MAAM,CAAC,MAAM,mBAAmB,GAAiE;IAC/F,UAAU,EAAE,CAAC;IAEb,uBAAuB,EAAE,KAAK,IAAI,EAAE;QAClC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,yEAAyE;IACzE,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACjC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QACpB,6DAA6D;QAC7D,sEAAsE;QACtE,0BAA0B;QAC1B,0CAA0C;QAC1C,0DAA0D;QAC1D,eAAe;QACf,2BAA2B;QAC3B,0BAA0B,EAAE,KAAK,IAAI,EAAE;YACrC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,qEAAqE;QACrE,iFAAiF;QACjF,qFAAqF;QACrF,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,yEAAyE;QACzE,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,8DAA8D;QAC9D,0CAA0C;QAC1C,0DAA0D;QAC1D,eAAe;QACf,wBAAwB,EAAE,KAAK,IAAI,EAAE;YACnC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,qEAAqE;QACrE,4BAA4B;YAC1B,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;IAEF,GAAG,CAAC,OAAe,EAAE,EAAE,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE;QAC9D,OAAO,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IBaseDirector } from '@unchainedshop/utils';
|
|
2
|
+
import { DiscountContext, IDiscountAdapter } from './BaseDiscountAdapter.js';
|
|
3
|
+
import { Modules } from '../modules.js';
|
|
4
|
+
export type IDiscountDirector<DiscountConfiguration> = IBaseDirector<IDiscountAdapter<DiscountConfiguration>> & {
|
|
5
|
+
actions: (discountContext: DiscountContext, unchainedAPI: {
|
|
6
|
+
modules: Modules;
|
|
7
|
+
}) => Promise<{
|
|
8
|
+
resolveDiscountAdapterFromStaticCode: (params: {
|
|
9
|
+
code: string;
|
|
10
|
+
}) => Promise<IDiscountAdapter<DiscountConfiguration>>;
|
|
11
|
+
findSystemDiscounts: () => Promise<Array<string>>;
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
export declare const BaseDiscountDirector: <DiscountConfigurationType>(directorName: string) => IDiscountDirector<DiscountConfigurationType>;
|
|
15
|
+
//# sourceMappingURL=BaseDiscountDirector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseDiscountDirector.d.ts","sourceRoot":"","sources":["../../src/directors/BaseDiscountDirector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,MAAM,iBAAiB,CAAC,qBAAqB,IAAI,aAAa,CAClE,gBAAgB,CAAC,qBAAqB,CAAC,CACxC,GAAG;IACF,OAAO,EAAE,CACP,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,KAC/B,OAAO,CAAC;QACX,oCAAoC,EAAE,CAAC,MAAM,EAAE;YAC7C,IAAI,EAAE,MAAM,CAAC;SACd,KAAK,OAAO,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,CAAC,CAAC;QACvD,mBAAmB,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;KACnD,CAAC,CAAC;CACJ,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,yBAAyB,gBAC9C,MAAM,KACnB,iBAAiB,CAAC,yBAAyB,CAoD7C,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BaseDirector } from '@unchainedshop/utils';
|
|
2
|
+
export const BaseDiscountDirector = (directorName) => {
|
|
3
|
+
const baseDirector = BaseDirector(directorName, {
|
|
4
|
+
adapterSortKey: 'orderIndex',
|
|
5
|
+
});
|
|
6
|
+
return {
|
|
7
|
+
...baseDirector,
|
|
8
|
+
actions: async (discountContext, unchainedAPI) => {
|
|
9
|
+
const context = { ...discountContext, ...unchainedAPI };
|
|
10
|
+
return {
|
|
11
|
+
resolveDiscountAdapterFromStaticCode: async (options) => {
|
|
12
|
+
if (!context.order)
|
|
13
|
+
return null;
|
|
14
|
+
const discounts = await Promise.all(baseDirector
|
|
15
|
+
.getAdapters()
|
|
16
|
+
.filter((Adapter) => Adapter.isManualAdditionAllowed(options?.code))
|
|
17
|
+
.map(async (Adapter) => {
|
|
18
|
+
const adapter = await Adapter.actions({ context });
|
|
19
|
+
return {
|
|
20
|
+
Adapter,
|
|
21
|
+
isValid: await adapter.isValidForCodeTriggering(options),
|
|
22
|
+
};
|
|
23
|
+
}));
|
|
24
|
+
return discounts.find(({ isValid }) => isValid === true)?.Adapter;
|
|
25
|
+
},
|
|
26
|
+
async findSystemDiscounts() {
|
|
27
|
+
if (!context.order)
|
|
28
|
+
return [];
|
|
29
|
+
const discounts = await Promise.all(baseDirector.getAdapters().map(async (Adapter) => {
|
|
30
|
+
const adapter = await Adapter.actions({ context });
|
|
31
|
+
return {
|
|
32
|
+
key: Adapter.key,
|
|
33
|
+
isValid: await adapter.isValidForSystemTriggering(),
|
|
34
|
+
};
|
|
35
|
+
}));
|
|
36
|
+
const validDiscounts = discounts
|
|
37
|
+
.filter(({ isValid }) => isValid === true)
|
|
38
|
+
.map(({ key }) => key);
|
|
39
|
+
return validDiscounts;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=BaseDiscountDirector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseDiscountDirector.js","sourceRoot":"","sources":["../../src/directors/BaseDiscountDirector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAiB,MAAM,sBAAsB,CAAC;AAkBnE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,YAAoB,EAC0B,EAAE;IAChD,MAAM,YAAY,GAAG,YAAY,CAA8C,YAAY,EAAE;QAC3F,cAAc,EAAE,YAAY;KAC7B,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,YAAY;QAEf,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,EAAE;YAC/C,MAAM,OAAO,GAAG,EAAE,GAAG,eAAe,EAAE,GAAG,YAAY,EAAE,CAAC;YAExD,OAAO;gBACL,oCAAoC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;oBACtD,IAAI,CAAC,OAAO,CAAC,KAAK;wBAAE,OAAO,IAAI,CAAC;oBAEhC,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CACjC,YAAY;yBACT,WAAW,EAAE;yBACb,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,uBAAuB,CAAC,OAAO,E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
|
2
|
+
import { IBaseAdapter, PricingCalculation } from '@unchainedshop/utils';
|
|
3
|
+
import { Discount } from './BasePricingDirector.js';
|
|
4
|
+
import { Order, OrderDiscount } from '@unchainedshop/core-orders';
|
|
5
|
+
interface IDiscountableItem {
|
|
6
|
+
_id?: string;
|
|
7
|
+
orderId?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface BasePricingAdapterContext {
|
|
10
|
+
order?: Order;
|
|
11
|
+
discounts: Array<OrderDiscount>;
|
|
12
|
+
}
|
|
13
|
+
export type BasePricingContext = {
|
|
14
|
+
order?: Order;
|
|
15
|
+
discounts?: Array<OrderDiscount>;
|
|
16
|
+
} | {
|
|
17
|
+
item: IDiscountableItem;
|
|
18
|
+
};
|
|
19
|
+
export interface IPricingAdapterActions<Calculation extends PricingCalculation, Sheet extends IPricingSheet<Calculation>> {
|
|
20
|
+
calculate: () => Promise<Array<Calculation>>;
|
|
21
|
+
resultSheet: () => Sheet;
|
|
22
|
+
}
|
|
23
|
+
export type IPricingAdapter<PricingAdapterContext extends BasePricingAdapterContext, Calculation extends PricingCalculation, Sheet extends IPricingSheet<Calculation>, DiscountConfiguration = unknown> = IBaseAdapter & {
|
|
24
|
+
orderIndex: number;
|
|
25
|
+
isActivatedFor: (context: PricingAdapterContext) => boolean;
|
|
26
|
+
actions: (params: {
|
|
27
|
+
context: PricingAdapterContext;
|
|
28
|
+
calculationSheet: Sheet;
|
|
29
|
+
discounts: Array<Discount<DiscountConfiguration>>;
|
|
30
|
+
}) => IPricingAdapterActions<Calculation, Sheet>;
|
|
31
|
+
};
|
|
32
|
+
export declare const BasePricingAdapter: <PricingAdapterContext extends BasePricingAdapterContext, Calculation extends PricingCalculation>() => IPricingAdapter<PricingAdapterContext, Calculation, IPricingSheet<Calculation>>;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=BasePricingAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePricingAdapter.d.ts","source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AK,CAAC;QACxB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC,CAAC;KACnD,KAAK,sBAAsB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;CAClD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,qBAAqB,SAAS,yBAAyB,EACvD,WAAW,SAAS,kBAAkB,OACnC,eAAe,CAAC,qBAAqB,EAAE,WAAW,EAAE,aAAa,CAAC,WAAW,CAAC,CAwBjF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
2
|
+
const logger = createLogger('unchained:core');
|
|
3
|
+
export const BasePricingAdapter = () => ({
|
|
4
|
+
key: '',
|
|
5
|
+
label: '',
|
|
6
|
+
version: '',
|
|
7
|
+
orderIndex: 0,
|
|
8
|
+
isActivatedFor: () => {
|
|
9
|
+
return false;
|
|
10
|
+
},
|
|
11
|
+
actions: () => {
|
|
12
|
+
return {
|
|
13
|
+
calculate: async () => {
|
|
14
|
+
throw new Error('Method not implemented.');
|
|
15
|
+
},
|
|
16
|
+
resultSheet: () => {
|
|
17
|
+
throw new Error('Method not implemented.');
|
|
18
|
+
}, // abstract
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
log(message, options) {
|
|
22
|
+
return logger.debug(message, options);
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=BasePricingAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePricingAdapter.js","sourceRoot":"","sources":["../../src/directors/BasePricingAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAMrD,MAAM,MAAM,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC;AA8C9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAGmD,EAAE,CAAC,CAAC;IACvF,GAAG,EAAE,EAAE;IACP,KAAK,EAAE,EAAE;IACT,OAAO,EAAE,EAAE;IACX,UAAU,EAAE,CAAC;IAEb,cAAc,EAAE,GAAG,EAAE;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,EAAE,GAAG,EAAE;QACZ,OAAO;YACL,SAAS,EAAE,KAAK,IAAI,EAAE;gBACpB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;YAC7C,CAAC;YACD,WAAW,EAAE,GAAG,EAAE;gBAChB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;YAC7C,CAAC,EAAE,WAAW;SACf,CAAC;IACJ,CAAC;IAED,GAAG,CAAC,OAAe,EAAE,OAAO;QAC1B,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IBaseDirector, PricingCalculation } from '@unchainedshop/utils';
|
|
2
|
+
import { BasePricingAdapterContext, BasePricingContext, IPricingAdapter } from './BasePricingAdapter.js';
|
|
3
|
+
import { IPricingSheet } from './BasePricingSheet.js';
|
|
4
|
+
import { Modules } from '../modules.js';
|
|
5
|
+
export interface Discount<DiscountConfiguration> {
|
|
6
|
+
discountId: string;
|
|
7
|
+
configuration: DiscountConfiguration;
|
|
8
|
+
}
|
|
9
|
+
export type IPricingDirector<PricingContext extends BasePricingContext, Calculation extends PricingCalculation, PricingAdapterContext extends BasePricingAdapterContext, PricingAdapterSheet extends IPricingSheet<Calculation>, Adapter extends IPricingAdapter<PricingAdapterContext & Context, Calculation, PricingAdapterSheet>, Context = {
|
|
10
|
+
modules: Modules;
|
|
11
|
+
}> = IBaseDirector<Adapter> & {
|
|
12
|
+
buildPricingContext: (pricingContext: PricingContext, unchainedAPI: Context) => Promise<PricingAdapterContext>;
|
|
13
|
+
rebuildCalculation: (pricingContext: PricingContext, unchainedAPI: Context) => Promise<Array<Calculation>>;
|
|
14
|
+
calculationSheet: (pricingContext: PricingContext, calculation: Array<Calculation>) => PricingAdapterSheet;
|
|
15
|
+
};
|
|
16
|
+
export declare const BasePricingDirector: <DirectorContext extends BasePricingContext, AdapterContext extends BasePricingAdapterContext, Calculation extends PricingCalculation, PricingAdapter extends IPricingAdapter<AdapterContext, Calculation, IPricingSheet<Calculation>>>(directorName: string) => IPricingDirector<DirectorContext, Calculation, AdapterContext, IPricingSheet<Calculation>, PricingAdapter, any>;
|
|
17
|
+
//# sourceMappingURL=BasePricingDirector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePricingDirector.d.ts","sourceRoot":"","sources":["../../src/directors/BasePricingDirector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,aAAa,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACzG,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAIxC,MAAM,WAAW,QAAQ,CAAC,qBAAqB;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,qBAAqB,CAAC;CACtC;AAED,MAAM,MAAM,gBAAgB,CAC1B,cAAc,SAAS,kBAAkB,EACzC,WAAW,SAAS,kBAAkB,EACtC,qBAAqB,SAAS,yBAAyB,EACvD,mBAAmB,SAAS,aAAa,CAAC,WAAW,CAAC,EACtD,OAAO,SAAS,eAAe,CAAC,qBAAqB,GAAG,OAAO,EAAE,WAAW,EAAE,mBAAmB,CAAC,EAClG,OAAO,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,IAC5B,aAAa,CAAC,OAAO,CAAC,GAAG;IAC3B,mBAAmB,EAAE,CACnB,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,OAAO,KAClB,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAEpC,kBAAkB,EAAE,CAClB,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,OAAO,KAClB,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IAEjC,gBAAgB,EAAE,CAChB,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,KAC5B,mBAAmB,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,eAAe,SAAS,kBAAkB,EAC1C,cAAc,SAAS,yBAAyB,EAChD,WAAW,SAAS,kBAAkB,EACtC,cAAc,SAAS,eAAe,CAAC,cAAc,EAAE,WAAW,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,gBAEjF,MAAM,KACnB,gBAAgB,CACjB,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,CAAC,WAAW,CAAC,EAC1B,cAAc,EACd,GAAG,CAqFJ,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { BaseDirector } from '@unchainedshop/utils';
|
|
2
|
+
import { OrderDiscountDirector } from './OrderDiscountDirector.js';
|
|
3
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
4
|
+
const logger = createLogger('unchained:core');
|
|
5
|
+
export const BasePricingDirector = (directorName) => {
|
|
6
|
+
const baseDirector = BaseDirector(directorName, {
|
|
7
|
+
adapterSortKey: 'orderIndex',
|
|
8
|
+
});
|
|
9
|
+
const director = {
|
|
10
|
+
...baseDirector,
|
|
11
|
+
buildPricingContext: async () => {
|
|
12
|
+
throw new Error('Method not implemented');
|
|
13
|
+
},
|
|
14
|
+
calculationSheet() {
|
|
15
|
+
throw new Error('Method not implemented');
|
|
16
|
+
},
|
|
17
|
+
async rebuildCalculation(pricingContext, unchainedAPI) {
|
|
18
|
+
const context = await this.buildPricingContext(pricingContext, unchainedAPI);
|
|
19
|
+
let calculation = [];
|
|
20
|
+
const Adapters = baseDirector.getAdapters({
|
|
21
|
+
adapterFilter: (Adapter) => {
|
|
22
|
+
return Adapter.isActivatedFor(context);
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
calculation = await Adapters.reduce(async (previousPromise, Adapter) => {
|
|
26
|
+
const resolvedCalculation = await previousPromise;
|
|
27
|
+
if (!resolvedCalculation)
|
|
28
|
+
return null;
|
|
29
|
+
const discounts = await Promise.all(context.discounts.map(async (orderDiscount) => {
|
|
30
|
+
const order = await unchainedAPI.modules.orders.findOrder({
|
|
31
|
+
orderId: orderDiscount.orderId,
|
|
32
|
+
});
|
|
33
|
+
const DiscountAdapter = OrderDiscountDirector.getAdapter(orderDiscount.discountKey);
|
|
34
|
+
if (!DiscountAdapter)
|
|
35
|
+
return null;
|
|
36
|
+
const adapter = await DiscountAdapter.actions({
|
|
37
|
+
context: { order, orderDiscount, code: orderDiscount.code, ...unchainedAPI },
|
|
38
|
+
});
|
|
39
|
+
const configuration = adapter.discountForPricingAdapterKey({
|
|
40
|
+
pricingAdapterKey: Adapter.key,
|
|
41
|
+
calculationSheet: this.calculationSheet(pricingContext, calculation),
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
discountId: orderDiscount._id,
|
|
45
|
+
configuration,
|
|
46
|
+
};
|
|
47
|
+
}));
|
|
48
|
+
try {
|
|
49
|
+
const adapter = Adapter.actions({
|
|
50
|
+
context,
|
|
51
|
+
calculationSheet: this.calculationSheet(pricingContext, calculation),
|
|
52
|
+
discounts: discounts.filter((d) => d?.configuration !== null),
|
|
53
|
+
});
|
|
54
|
+
const nextCalculationResult = await adapter.calculate();
|
|
55
|
+
if (!nextCalculationResult)
|
|
56
|
+
return null;
|
|
57
|
+
calculation = resolvedCalculation.concat(nextCalculationResult);
|
|
58
|
+
return calculation;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
logger.error(error);
|
|
62
|
+
}
|
|
63
|
+
return resolvedCalculation;
|
|
64
|
+
}, Promise.resolve([]));
|
|
65
|
+
return calculation;
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
return director;
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=BasePricingDirector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePricingDirector.js","sourceRoot":"","sources":["../../src/directors/BasePricingDirector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAqC,MAAM,sBAAsB,CAAC;AAGvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,MAAM,MAAM,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC;AA+B9C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAMjC,YAAoB,EAQpB,EAAE;IACF,MAAM,YAAY,GAAG,YAAY,CAAiB,YAAY,EAAE;QAC9D,cAAc,EAAE,YAAY;KAC7B,CAAC,CAAC;IAEH,MAAM,QAAQ,GAOV;QACF,GAAG,YAAY;QAEf,mBAAmB,EAAE,KAAK,IAAI,EAAE;YAC9B,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,gBAAgB;YACd,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,KAAK,CAAC,kBAAkB,CAAwB,cAAc,EAAE,YAAY;YAC1E,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;YAE7E,IAAI,WAAW,GAAuB,EAAE,CAAC;YAEzC,MAAM,QAAQ,GAAG,YAAY,CAAC,WAAW,CAAC;gBACxC,aAAa,EAAE,CAAC,OAAO,EAAE,EAAE;oBACzB,OAAO,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;gBACzC,CAAC;aACF,CAAC,CAAC;YAEH,WAAW,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,EA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