@unchainedshop/core 3.0.0-alpha7 → 3.0.0-rc10
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 +173 -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 +309 -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
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { BaseDirector, IBaseDirector, PricingCalculation } from '@unchainedshop/utils';
|
|
2
|
+
import { BasePricingAdapterContext, BasePricingContext, IPricingAdapter } from './BasePricingAdapter.js';
|
|
3
|
+
import { IPricingSheet } from './BasePricingSheet.js';
|
|
4
|
+
import { OrderDiscountDirector } from './OrderDiscountDirector.js';
|
|
5
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
6
|
+
import { Modules } from '../modules.js';
|
|
7
|
+
|
|
8
|
+
const logger = createLogger('unchained:core');
|
|
9
|
+
|
|
10
|
+
export interface Discount<DiscountConfiguration> {
|
|
11
|
+
discountId: string;
|
|
12
|
+
configuration: DiscountConfiguration;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type IPricingDirector<
|
|
16
|
+
PricingContext extends BasePricingContext,
|
|
17
|
+
Calculation extends PricingCalculation,
|
|
18
|
+
PricingAdapterContext extends BasePricingAdapterContext,
|
|
19
|
+
PricingAdapterSheet extends IPricingSheet<Calculation>,
|
|
20
|
+
Adapter extends IPricingAdapter<PricingAdapterContext & Context, Calculation, PricingAdapterSheet>,
|
|
21
|
+
Context = { modules: Modules },
|
|
22
|
+
> = IBaseDirector<Adapter> & {
|
|
23
|
+
buildPricingContext: (
|
|
24
|
+
pricingContext: PricingContext,
|
|
25
|
+
unchainedAPI: Context,
|
|
26
|
+
) => Promise<PricingAdapterContext>;
|
|
27
|
+
|
|
28
|
+
rebuildCalculation: (
|
|
29
|
+
pricingContext: PricingContext,
|
|
30
|
+
unchainedAPI: Context,
|
|
31
|
+
) => Promise<Array<Calculation>>;
|
|
32
|
+
|
|
33
|
+
calculationSheet: (
|
|
34
|
+
pricingContext: PricingContext,
|
|
35
|
+
calculation: Array<Calculation>,
|
|
36
|
+
) => PricingAdapterSheet;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const BasePricingDirector = <
|
|
40
|
+
DirectorContext extends BasePricingContext,
|
|
41
|
+
AdapterContext extends BasePricingAdapterContext,
|
|
42
|
+
Calculation extends PricingCalculation,
|
|
43
|
+
PricingAdapter extends IPricingAdapter<AdapterContext, Calculation, IPricingSheet<Calculation>>,
|
|
44
|
+
>(
|
|
45
|
+
directorName: string,
|
|
46
|
+
): IPricingDirector<
|
|
47
|
+
DirectorContext,
|
|
48
|
+
Calculation,
|
|
49
|
+
AdapterContext,
|
|
50
|
+
IPricingSheet<Calculation>,
|
|
51
|
+
PricingAdapter,
|
|
52
|
+
any
|
|
53
|
+
> => {
|
|
54
|
+
const baseDirector = BaseDirector<PricingAdapter>(directorName, {
|
|
55
|
+
adapterSortKey: 'orderIndex',
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const director: IPricingDirector<
|
|
59
|
+
DirectorContext,
|
|
60
|
+
Calculation,
|
|
61
|
+
AdapterContext,
|
|
62
|
+
IPricingSheet<Calculation>,
|
|
63
|
+
PricingAdapter,
|
|
64
|
+
any
|
|
65
|
+
> = {
|
|
66
|
+
...baseDirector,
|
|
67
|
+
|
|
68
|
+
buildPricingContext: async () => {
|
|
69
|
+
throw new Error('Method not implemented');
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
calculationSheet() {
|
|
73
|
+
throw new Error('Method not implemented');
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
async rebuildCalculation(pricingContext, unchainedAPI) {
|
|
77
|
+
const context = await director.buildPricingContext(pricingContext, unchainedAPI);
|
|
78
|
+
|
|
79
|
+
let calculation: Array<Calculation> = [];
|
|
80
|
+
|
|
81
|
+
const Adapters = baseDirector.getAdapters({
|
|
82
|
+
adapterFilter: (Adapter) => {
|
|
83
|
+
return Adapter.isActivatedFor(context);
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
calculation = await Adapters.reduce(async (previousPromise, Adapter) => {
|
|
88
|
+
const resolvedCalculation = await previousPromise;
|
|
89
|
+
if (!resolvedCalculation) return null;
|
|
90
|
+
|
|
91
|
+
const discounts: Array<Discount<any>> = await Promise.all(
|
|
92
|
+
context.discounts.map(async (orderDiscount) => {
|
|
93
|
+
const order = await unchainedAPI.modules.orders.findOrder({
|
|
94
|
+
orderId: orderDiscount.orderId,
|
|
95
|
+
});
|
|
96
|
+
const DiscountAdapter = OrderDiscountDirector.getAdapter(orderDiscount.discountKey);
|
|
97
|
+
if (!DiscountAdapter) return null;
|
|
98
|
+
|
|
99
|
+
const adapter = await DiscountAdapter.actions({
|
|
100
|
+
context: { order, orderDiscount, code: orderDiscount.code, ...unchainedAPI },
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const configuration = adapter.discountForPricingAdapterKey({
|
|
104
|
+
pricingAdapterKey: Adapter.key,
|
|
105
|
+
calculationSheet: this.calculationSheet(pricingContext, calculation),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
discountId: orderDiscount._id,
|
|
110
|
+
configuration,
|
|
111
|
+
};
|
|
112
|
+
}),
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
const adapter = Adapter.actions({
|
|
117
|
+
context,
|
|
118
|
+
calculationSheet: this.calculationSheet(pricingContext, calculation),
|
|
119
|
+
discounts: discounts.filter((d) => d?.configuration !== null),
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const nextCalculationResult = await adapter.calculate();
|
|
123
|
+
if (!nextCalculationResult) return null;
|
|
124
|
+
calculation = resolvedCalculation.concat(nextCalculationResult);
|
|
125
|
+
return calculation;
|
|
126
|
+
} catch (error) {
|
|
127
|
+
logger.error(error);
|
|
128
|
+
}
|
|
129
|
+
return resolvedCalculation;
|
|
130
|
+
}, Promise.resolve([]));
|
|
131
|
+
|
|
132
|
+
return calculation;
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
return director;
|
|
137
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { resolveRatioAndTaxDivisorForPricingSheet } from './BasePricingSheet';
|
|
2
|
+
|
|
3
|
+
describe('resolveRatioAndTaxDivisorForPricingSheet', () => {
|
|
4
|
+
it('total is 0 and pricing is provided', () => {
|
|
5
|
+
const pricing: any = {
|
|
6
|
+
taxSum: () => 10,
|
|
7
|
+
gross: () => 20,
|
|
8
|
+
net: () => 10,
|
|
9
|
+
};
|
|
10
|
+
const result = resolveRatioAndTaxDivisorForPricingSheet(pricing, 0);
|
|
11
|
+
expect(result).toEqual({ ratio: 1, taxDivisor: 1 });
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('gross - tax is 0', () => {
|
|
15
|
+
const pricing: any = {
|
|
16
|
+
taxSum: () => 10,
|
|
17
|
+
gross: () => 10,
|
|
18
|
+
net: () => 0,
|
|
19
|
+
};
|
|
20
|
+
const result = resolveRatioAndTaxDivisorForPricingSheet(pricing, 20);
|
|
21
|
+
expect(result).toEqual({ ratio: 0, taxDivisor: 0 });
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('gross - tax is not 0', () => {
|
|
25
|
+
const pricing: any = {
|
|
26
|
+
taxSum: () => 10,
|
|
27
|
+
gross: () => 20,
|
|
28
|
+
net: () => 10,
|
|
29
|
+
};
|
|
30
|
+
const result = resolveRatioAndTaxDivisorForPricingSheet(pricing, 20);
|
|
31
|
+
expect(result).toEqual({ ratio: 1, taxDivisor: 2 });
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('taxSum is 0', () => {
|
|
35
|
+
const pricing: any = {
|
|
36
|
+
taxSum: () => 0,
|
|
37
|
+
gross: () => 20,
|
|
38
|
+
net: () => 20,
|
|
39
|
+
};
|
|
40
|
+
const result = resolveRatioAndTaxDivisorForPricingSheet(pricing, 20);
|
|
41
|
+
expect(result).toEqual({ ratio: 1, taxDivisor: 1 });
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { PricingCalculation } from '@unchainedshop/utils';
|
|
2
|
+
export interface PricingDiscount {
|
|
3
|
+
discountId: string;
|
|
4
|
+
amount: number;
|
|
5
|
+
currency: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface IPricingSheet<Calculation extends PricingCalculation>
|
|
9
|
+
extends IBasePricingSheet<Calculation> {
|
|
10
|
+
discountPrices: (discountId?: string) => Array<PricingDiscount>;
|
|
11
|
+
addDiscount: (params: { amount: number; discountId: string; meta?: any }) => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface IBasePricingSheet<Calculation extends PricingCalculation> {
|
|
15
|
+
calculation: Array<Calculation>;
|
|
16
|
+
currency?: string;
|
|
17
|
+
quantity?: number;
|
|
18
|
+
|
|
19
|
+
getRawPricingSheet: () => Array<Calculation>;
|
|
20
|
+
filterBy: (filter?: Partial<Calculation>) => Array<Calculation>;
|
|
21
|
+
isValid: () => boolean;
|
|
22
|
+
|
|
23
|
+
gross: () => number;
|
|
24
|
+
net: () => number;
|
|
25
|
+
sum: (filter?: Partial<Calculation>) => number;
|
|
26
|
+
total: (params?: { category?: string; discountId?: string; useNetPrice?: boolean }) => {
|
|
27
|
+
amount: number;
|
|
28
|
+
currency: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
taxSum: (filter?: Partial<Calculation>) => number;
|
|
32
|
+
|
|
33
|
+
resetCalculation: (sheetToInvert: IBasePricingSheet<Calculation>) => Array<Calculation>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface PricingSheetParams<Calculation extends PricingCalculation> {
|
|
37
|
+
calculation?: Array<Calculation>;
|
|
38
|
+
currency?: string;
|
|
39
|
+
quantity?: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const BasePricingSheet = <Calculation extends PricingCalculation>(
|
|
43
|
+
params: PricingSheetParams<Calculation>,
|
|
44
|
+
): IBasePricingSheet<Calculation> => {
|
|
45
|
+
const pricingSheet: IBasePricingSheet<Calculation> = {
|
|
46
|
+
calculation: params.calculation || [],
|
|
47
|
+
currency: params.currency,
|
|
48
|
+
quantity: params.quantity,
|
|
49
|
+
|
|
50
|
+
getRawPricingSheet() {
|
|
51
|
+
return this.calculation;
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
isValid() {
|
|
55
|
+
return this.calculation.length > 0;
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
sum(filter) {
|
|
59
|
+
return this.filterBy(filter)
|
|
60
|
+
.filter(Boolean)
|
|
61
|
+
.reduce((sum: number, calculationRow: Calculation) => sum + calculationRow.amount, 0);
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
taxSum() {
|
|
65
|
+
return 0;
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
gross() {
|
|
69
|
+
// Sum contains taxes, thus it's gross when just suming everything
|
|
70
|
+
return this.sum();
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
net() {
|
|
74
|
+
// Remove all taxes from gross to get net
|
|
75
|
+
return this.sum() - this.taxSum();
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
total({ category, useNetPrice, discountId } = { useNetPrice: false }) {
|
|
79
|
+
const amount = this.sum({ category, discountId });
|
|
80
|
+
const taxAmountForCategory = this.taxSum({ baseCategory: category, discountId });
|
|
81
|
+
|
|
82
|
+
// Sum does not contain taxes when filtering by category, it's net in that case and gross if there is no category
|
|
83
|
+
const netAmount = !category ? amount - taxAmountForCategory : amount;
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
amount: Math.round(useNetPrice ? netAmount : netAmount + taxAmountForCategory),
|
|
87
|
+
currency: this.currency,
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
filterBy(filter) {
|
|
92
|
+
const filteredCalculation = Object.keys(filter || {}).reduce(
|
|
93
|
+
(oldCalculation, filterKey) =>
|
|
94
|
+
oldCalculation.filter(
|
|
95
|
+
(row: Calculation) =>
|
|
96
|
+
!!row && (filter[filterKey] === undefined || row[filterKey] === filter[filterKey]),
|
|
97
|
+
),
|
|
98
|
+
this.calculation,
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
return filteredCalculation;
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
resetCalculation(calculationSheet) {
|
|
105
|
+
calculationSheet.filterBy().forEach(({ amount, ...row }: Calculation) => {
|
|
106
|
+
this.calculation.push({
|
|
107
|
+
...row,
|
|
108
|
+
amount: amount * -1,
|
|
109
|
+
} as Calculation);
|
|
110
|
+
});
|
|
111
|
+
return this.calculation;
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
return pricingSheet;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const resolveRatioAndTaxDivisorForPricingSheet = (
|
|
119
|
+
pricing: IBasePricingSheet<PricingCalculation>,
|
|
120
|
+
total: number,
|
|
121
|
+
) => {
|
|
122
|
+
if (total === 0 || !pricing) {
|
|
123
|
+
return {
|
|
124
|
+
ratio: 1,
|
|
125
|
+
taxDivisor: 1,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const tax = pricing.taxSum();
|
|
129
|
+
const gross = pricing.gross();
|
|
130
|
+
if (gross - tax === 0) {
|
|
131
|
+
return {
|
|
132
|
+
ratio: 0,
|
|
133
|
+
taxDivisor: 0,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
ratio: gross / total,
|
|
138
|
+
taxDivisor: gross / (gross - tax),
|
|
139
|
+
};
|
|
140
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { log, LogLevel } from '@unchainedshop/logger';
|
|
2
|
+
import { IBaseAdapter } from '@unchainedshop/utils';
|
|
3
|
+
import type { Order, OrderPosition, OrderDelivery } from '@unchainedshop/core-orders';
|
|
4
|
+
import type { Product } from '@unchainedshop/core-products';
|
|
5
|
+
import type { WarehousingProvider } from '@unchainedshop/core-warehousing';
|
|
6
|
+
import type { Work } from '@unchainedshop/core-worker';
|
|
7
|
+
import type { User } from '@unchainedshop/core-users';
|
|
8
|
+
import {
|
|
9
|
+
DeliveryConfiguration,
|
|
10
|
+
DeliveryLocation,
|
|
11
|
+
DeliveryProvider,
|
|
12
|
+
DeliveryProviderType,
|
|
13
|
+
} from '@unchainedshop/core-delivery';
|
|
14
|
+
import { Modules } from '../modules.js';
|
|
15
|
+
|
|
16
|
+
export enum DeliveryError {
|
|
17
|
+
ADAPTER_NOT_FOUND = 'ADAPTER_NOT_FOUND',
|
|
18
|
+
NOT_IMPLEMENTED = 'NOT_IMPLEMENTED',
|
|
19
|
+
INCOMPLETE_CONFIGURATION = 'INCOMPLETE_CONFIGURATION',
|
|
20
|
+
WRONG_CREDENTIALS = 'WRONG_CREDENTIALS',
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface DeliveryAdapterActions {
|
|
24
|
+
configurationError: (transactionContext?: any) => DeliveryError;
|
|
25
|
+
estimatedDeliveryThroughput: (warehousingThroughputTime: number) => Promise<number>;
|
|
26
|
+
isActive: () => boolean;
|
|
27
|
+
isAutoReleaseAllowed: () => boolean;
|
|
28
|
+
pickUpLocationById: (locationId: string) => Promise<DeliveryLocation>;
|
|
29
|
+
pickUpLocations: () => Promise<Array<DeliveryLocation>>;
|
|
30
|
+
send: () => Promise<boolean | Work>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface DeliveryContext {
|
|
34
|
+
country?: string;
|
|
35
|
+
deliveryProvider?: DeliveryProvider;
|
|
36
|
+
order?: Order;
|
|
37
|
+
orderDelivery?: OrderDelivery;
|
|
38
|
+
orderPosition?: OrderPosition;
|
|
39
|
+
product?: Product;
|
|
40
|
+
quantity?: number;
|
|
41
|
+
referenceDate?: Date;
|
|
42
|
+
transactionContext?: any;
|
|
43
|
+
user?: User;
|
|
44
|
+
warehousingProvider?: WarehousingProvider;
|
|
45
|
+
warehousingThroughputTime?: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type IDeliveryAdapter = IBaseAdapter & {
|
|
49
|
+
initialConfiguration: DeliveryConfiguration;
|
|
50
|
+
|
|
51
|
+
typeSupported: (type: DeliveryProviderType) => boolean;
|
|
52
|
+
|
|
53
|
+
actions: (
|
|
54
|
+
config: DeliveryConfiguration,
|
|
55
|
+
context: DeliveryContext & { modules: Modules },
|
|
56
|
+
) => DeliveryAdapterActions;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const DeliveryAdapter: Omit<IDeliveryAdapter, 'key' | 'label' | 'version'> = {
|
|
60
|
+
initialConfiguration: [],
|
|
61
|
+
|
|
62
|
+
typeSupported: () => {
|
|
63
|
+
return false;
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
actions: () => {
|
|
67
|
+
return {
|
|
68
|
+
configurationError: () => {
|
|
69
|
+
return DeliveryError.NOT_IMPLEMENTED;
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
estimatedDeliveryThroughput: async () => {
|
|
73
|
+
return 0;
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
isActive: () => {
|
|
77
|
+
return false;
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
isAutoReleaseAllowed: () => {
|
|
81
|
+
// if you return false here,
|
|
82
|
+
// the order will need manual confirmation before
|
|
83
|
+
// unchained will try to invoke send()
|
|
84
|
+
return true;
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
send: async () => {
|
|
88
|
+
// if you return true, the status will be changed to DELIVERED
|
|
89
|
+
|
|
90
|
+
// if you return false, the order delivery status stays the
|
|
91
|
+
// same but the order status might change
|
|
92
|
+
|
|
93
|
+
// if you throw an error, you cancel the whole checkout process
|
|
94
|
+
return false;
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
pickUpLocationById: async () => {
|
|
98
|
+
return null;
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
pickUpLocations: async () => {
|
|
102
|
+
return [];
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
log: (message: string, { level = LogLevel.Debug, ...options } = {}) => {
|
|
108
|
+
return log(message, { level, ...options });
|
|
109
|
+
},
|
|
110
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { BaseDirector, IBaseDirector } from '@unchainedshop/utils';
|
|
2
|
+
import {
|
|
3
|
+
DeliveryAdapterActions,
|
|
4
|
+
DeliveryContext,
|
|
5
|
+
IDeliveryAdapter,
|
|
6
|
+
DeliveryError,
|
|
7
|
+
} from './DeliveryAdapter.js';
|
|
8
|
+
import { DeliveryProvider } from '@unchainedshop/core-delivery';
|
|
9
|
+
import { OrderDelivery, OrderDeliveryStatus } from '@unchainedshop/core-orders';
|
|
10
|
+
import { Modules } from '../modules.js';
|
|
11
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
12
|
+
|
|
13
|
+
const logger = createLogger('unchained:core');
|
|
14
|
+
|
|
15
|
+
export type IDeliveryDirector = IBaseDirector<IDeliveryAdapter> & {
|
|
16
|
+
sendOrderDelivery: (
|
|
17
|
+
orderDelivery: OrderDelivery,
|
|
18
|
+
transactionContext: Record<string, any>,
|
|
19
|
+
unchainedAPI: { modules: Modules },
|
|
20
|
+
) => Promise<OrderDelivery>;
|
|
21
|
+
actions: (
|
|
22
|
+
deliveryProvider: DeliveryProvider,
|
|
23
|
+
deliveryContext: DeliveryContext,
|
|
24
|
+
unchainedAPI: { modules: Modules },
|
|
25
|
+
) => Promise<DeliveryAdapterActions>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const baseDirector = BaseDirector<IDeliveryAdapter>('DeliveryDirector');
|
|
29
|
+
|
|
30
|
+
export const DeliveryDirector: IDeliveryDirector = {
|
|
31
|
+
...baseDirector,
|
|
32
|
+
|
|
33
|
+
actions: async (deliveryProvider, deliveryContext, unchainedAPI) => {
|
|
34
|
+
const Adapter = baseDirector.getAdapter(deliveryProvider.adapterKey);
|
|
35
|
+
|
|
36
|
+
const context = { ...deliveryContext, ...unchainedAPI };
|
|
37
|
+
const adapter = Adapter?.actions(deliveryProvider.configuration, context);
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
configurationError: () => {
|
|
41
|
+
try {
|
|
42
|
+
return adapter.configurationError();
|
|
43
|
+
} catch {
|
|
44
|
+
return DeliveryError.ADAPTER_NOT_FOUND;
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
estimatedDeliveryThroughput: async (warehousingThroughputTime) => {
|
|
49
|
+
try {
|
|
50
|
+
const throughput = await adapter.estimatedDeliveryThroughput(warehousingThroughputTime);
|
|
51
|
+
return throughput;
|
|
52
|
+
} catch (error) {
|
|
53
|
+
logger.warn('Delivery Director -> Error while estimating delivery throughput', {
|
|
54
|
+
...error,
|
|
55
|
+
});
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
isActive: () => {
|
|
61
|
+
try {
|
|
62
|
+
return adapter.isActive();
|
|
63
|
+
} catch (error) {
|
|
64
|
+
logger.warn('Delivery Director -> Error while checking if is active', {
|
|
65
|
+
...error,
|
|
66
|
+
});
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
isAutoReleaseAllowed: () => {
|
|
72
|
+
try {
|
|
73
|
+
return adapter.isAutoReleaseAllowed();
|
|
74
|
+
} catch (error) {
|
|
75
|
+
logger.warn('Delivery Director -> Error while checking if auto release is allowed', {
|
|
76
|
+
...error,
|
|
77
|
+
});
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
send: async () => {
|
|
83
|
+
return adapter.send();
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
pickUpLocationById: async (locationId) => {
|
|
87
|
+
return adapter.pickUpLocationById(locationId);
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
pickUpLocations: async () => {
|
|
91
|
+
return adapter.pickUpLocations();
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
sendOrderDelivery: async (orderDelivery, transactionContext, unchainedAPI) => {
|
|
97
|
+
if (
|
|
98
|
+
unchainedAPI.modules.orders.deliveries.normalizedStatus(orderDelivery) !== OrderDeliveryStatus.OPEN
|
|
99
|
+
)
|
|
100
|
+
return orderDelivery;
|
|
101
|
+
|
|
102
|
+
const order = await unchainedAPI.modules.orders.findOrder({ orderId: orderDelivery.orderId });
|
|
103
|
+
const deliveryProvider = await unchainedAPI.modules.delivery.findProvider({
|
|
104
|
+
deliveryProviderId: orderDelivery.deliveryProviderId,
|
|
105
|
+
});
|
|
106
|
+
const deliveryProviderId = deliveryProvider._id;
|
|
107
|
+
const address = orderDelivery.context?.address || order || order.billingAddress;
|
|
108
|
+
const provider = await await unchainedAPI.modules.delivery.findProvider({ deliveryProviderId });
|
|
109
|
+
|
|
110
|
+
const adapter = await DeliveryDirector.actions(
|
|
111
|
+
provider,
|
|
112
|
+
{
|
|
113
|
+
order,
|
|
114
|
+
orderDelivery,
|
|
115
|
+
transactionContext: {
|
|
116
|
+
...(transactionContext || {}),
|
|
117
|
+
...(orderDelivery.context || {}),
|
|
118
|
+
...(address || {}),
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
unchainedAPI,
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const arbitraryResponseData = await adapter.send();
|
|
125
|
+
|
|
126
|
+
if (arbitraryResponseData) {
|
|
127
|
+
return await unchainedAPI.modules.orders.deliveries.updateStatus(orderDelivery._id, {
|
|
128
|
+
status: OrderDeliveryStatus.DELIVERED,
|
|
129
|
+
info: JSON.stringify(arbitraryResponseData),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return orderDelivery;
|
|
134
|
+
},
|
|
135
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { DeliveryPricingSheet } from './DeliveryPricingSheet.js';
|
|
2
|
+
import {
|
|
3
|
+
BasePricingAdapterContext,
|
|
4
|
+
IPricingAdapter,
|
|
5
|
+
IPricingSheet,
|
|
6
|
+
BasePricingAdapter,
|
|
7
|
+
} from '../directors/index.js';
|
|
8
|
+
import { DeliveryProvider } from '@unchainedshop/core-delivery';
|
|
9
|
+
import { PricingCalculation } from '@unchainedshop/utils';
|
|
10
|
+
import { OrderDelivery, OrderDiscount, Order } from '@unchainedshop/core-orders';
|
|
11
|
+
import { User } from '@unchainedshop/core-users';
|
|
12
|
+
import { Modules } from '../modules.js';
|
|
13
|
+
|
|
14
|
+
export interface DeliveryPricingCalculation extends PricingCalculation {
|
|
15
|
+
discountId?: string;
|
|
16
|
+
isNetPrice: boolean;
|
|
17
|
+
isTaxable: boolean;
|
|
18
|
+
rate?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type IDeliveryPricingSheet = IPricingSheet<DeliveryPricingCalculation> & {
|
|
22
|
+
addFee: (params: { amount: number; isTaxable: boolean; isNetPrice: boolean; meta?: any }) => void;
|
|
23
|
+
addTax: (params: {
|
|
24
|
+
amount: number;
|
|
25
|
+
rate: number;
|
|
26
|
+
baseCategory?: string;
|
|
27
|
+
discountId?: string;
|
|
28
|
+
meta?: any;
|
|
29
|
+
}) => void;
|
|
30
|
+
addDiscount: (params: {
|
|
31
|
+
amount: number;
|
|
32
|
+
isTaxable: boolean;
|
|
33
|
+
isNetPrice: boolean;
|
|
34
|
+
discountId: string;
|
|
35
|
+
meta?: any;
|
|
36
|
+
}) => void;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export interface DeliveryPricingAdapterContext extends BasePricingAdapterContext {
|
|
40
|
+
country?: string;
|
|
41
|
+
currency?: string;
|
|
42
|
+
provider: DeliveryProvider;
|
|
43
|
+
providerContext?: any;
|
|
44
|
+
order: Order;
|
|
45
|
+
orderDelivery: OrderDelivery;
|
|
46
|
+
user: User;
|
|
47
|
+
discounts: Array<OrderDiscount>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type IDeliveryPricingAdapter<DiscountConfiguration = unknown> = IPricingAdapter<
|
|
51
|
+
DeliveryPricingAdapterContext & { modules: Modules },
|
|
52
|
+
DeliveryPricingCalculation,
|
|
53
|
+
IDeliveryPricingSheet,
|
|
54
|
+
DiscountConfiguration
|
|
55
|
+
>;
|
|
56
|
+
|
|
57
|
+
const basePricingAdapter = BasePricingAdapter<
|
|
58
|
+
DeliveryPricingAdapterContext,
|
|
59
|
+
DeliveryPricingCalculation
|
|
60
|
+
>();
|
|
61
|
+
|
|
62
|
+
export const DeliveryPricingAdapter: IDeliveryPricingAdapter = {
|
|
63
|
+
...basePricingAdapter,
|
|
64
|
+
|
|
65
|
+
isActivatedFor: () => {
|
|
66
|
+
return false;
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
actions: (params) => {
|
|
70
|
+
const { context } = params;
|
|
71
|
+
const { currency } = context;
|
|
72
|
+
const baseActions = basePricingAdapter.actions(params);
|
|
73
|
+
const resultSheet = DeliveryPricingSheet({ currency });
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
...baseActions,
|
|
77
|
+
calculate: async () => {
|
|
78
|
+
const resultRaw = resultSheet.getRawPricingSheet();
|
|
79
|
+
resultRaw.forEach(({ amount, category }) =>
|
|
80
|
+
basePricingAdapter.log(`Delivery Calculation -> ${category} ${amount}`),
|
|
81
|
+
);
|
|
82
|
+
return resultRaw;
|
|
83
|
+
},
|
|
84
|
+
resultSheet: () => resultSheet,
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
};
|