@unchainedshop/core 4.0.0-rc.16 → 4.0.0-rc.18
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/bulk-importer/createBulkImporter.d.ts +29 -6
- package/lib/bulk-importer/createBulkImporter.d.ts.map +1 -1
- package/lib/bulk-importer/createBulkImporter.js +26 -19
- package/lib/bulk-importer/createBulkImporter.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/create.d.ts +552 -2
- package/lib/bulk-importer/handlers/assortment/create.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/create.js +32 -5
- package/lib/bulk-importer/handlers/assortment/create.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/remove.d.ts +20 -2
- package/lib/bulk-importer/handlers/assortment/remove.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/remove.js +7 -2
- package/lib/bulk-importer/handlers/assortment/remove.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/update.d.ts +552 -2
- package/lib/bulk-importer/handlers/assortment/update.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/update.js +43 -7
- package/lib/bulk-importer/handlers/assortment/update.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts +23 -3
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js +14 -6
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts +23 -3
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js +15 -6
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts +23 -3
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js +17 -8
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts +67 -2
- package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js +18 -4
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/create.d.ts +125 -0
- package/lib/bulk-importer/handlers/filter/create.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/filter/create.js +22 -0
- package/lib/bulk-importer/handlers/filter/create.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/remove.d.ts +10 -2
- package/lib/bulk-importer/handlers/filter/remove.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/filter/remove.js +4 -0
- package/lib/bulk-importer/handlers/filter/remove.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/update.d.ts +125 -0
- package/lib/bulk-importer/handlers/filter/update.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/filter/update.js +22 -0
- package/lib/bulk-importer/handlers/filter/update.js.map +1 -1
- package/lib/bulk-importer/handlers/product/create.d.ts +1317 -2
- package/lib/bulk-importer/handlers/product/create.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/create.js +87 -8
- package/lib/bulk-importer/handlers/product/create.js.map +1 -1
- package/lib/bulk-importer/handlers/product/remove.d.ts +20 -2
- package/lib/bulk-importer/handlers/product/remove.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/remove.js +5 -0
- package/lib/bulk-importer/handlers/product/remove.js.map +1 -1
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts +278 -1
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js +64 -3
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js.map +1 -1
- package/lib/bulk-importer/handlers/product/update.d.ts +1317 -2
- package/lib/bulk-importer/handlers/product/update.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/update.js +89 -5
- package/lib/bulk-importer/handlers/product/update.js.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertMedia.d.ts +67 -2
- package/lib/bulk-importer/handlers/product/upsertMedia.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertMedia.js +16 -2
- package/lib/bulk-importer/handlers/product/upsertMedia.js.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertVariations.d.ts +73 -2
- package/lib/bulk-importer/handlers/product/upsertVariations.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertVariations.js +26 -2
- package/lib/bulk-importer/handlers/product/upsertVariations.js.map +1 -1
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts +1 -1
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js.map +1 -1
- package/lib/bulk-importer/handlers/utils/event-schema.d.ts +21 -0
- package/lib/bulk-importer/handlers/utils/event-schema.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/utils/event-schema.js +64 -0
- package/lib/bulk-importer/handlers/utils/event-schema.js.map +1 -0
- package/lib/bulk-importer/index.d.ts +4 -0
- package/lib/bulk-importer/index.d.ts.map +1 -0
- package/lib/bulk-importer/index.js +4 -0
- package/lib/bulk-importer/index.js.map +1 -0
- package/lib/bulk-importer/upsertAsset.d.ts +21 -5
- package/lib/bulk-importer/upsertAsset.d.ts.map +1 -1
- package/lib/bulk-importer/upsertAsset.js +8 -0
- package/lib/bulk-importer/upsertAsset.js.map +1 -1
- package/lib/core-index.d.ts +4 -3
- package/lib/core-index.d.ts.map +1 -1
- package/lib/core-index.js +2 -2
- package/lib/core-index.js.map +1 -1
- package/lib/directors/BaseDiscountAdapter.d.ts +4 -4
- package/lib/directors/BaseDiscountAdapter.d.ts.map +1 -1
- package/lib/directors/BaseDiscountAdapter.js +1 -1
- package/lib/directors/BaseDiscountAdapter.js.map +1 -1
- package/lib/directors/BaseDiscountDirector.d.ts +1 -1
- package/lib/directors/BaseDiscountDirector.d.ts.map +1 -1
- package/lib/directors/BaseDiscountDirector.js +1 -1
- package/lib/directors/BaseDiscountDirector.js.map +1 -1
- package/lib/directors/BasePricingAdapter.d.ts +2 -2
- package/lib/directors/BasePricingAdapter.d.ts.map +1 -1
- package/lib/directors/BasePricingDirector.d.ts.map +1 -1
- package/lib/directors/BasePricingDirector.js +3 -3
- package/lib/directors/BasePricingDirector.js.map +1 -1
- package/lib/directors/BasePricingSheet.js.map +1 -1
- package/lib/directors/BaseWorker.js +1 -1
- package/lib/directors/BaseWorker.js.map +1 -1
- package/lib/directors/DeliveryAdapter.d.ts +3 -3
- package/lib/directors/DeliveryAdapter.d.ts.map +1 -1
- package/lib/directors/DeliveryDirector.d.ts +3 -3
- package/lib/directors/DeliveryDirector.d.ts.map +1 -1
- package/lib/directors/DeliveryDirector.js +29 -16
- package/lib/directors/DeliveryDirector.js.map +1 -1
- package/lib/directors/DeliveryPricingAdapter.d.ts +1 -1
- package/lib/directors/DeliveryPricingAdapter.d.ts.map +1 -1
- package/lib/directors/DeliveryPricingDirector.d.ts.map +1 -1
- package/lib/directors/DeliveryPricingDirector.js +3 -4
- package/lib/directors/DeliveryPricingDirector.js.map +1 -1
- package/lib/directors/DeliveryPricingSheet.d.ts.map +1 -1
- package/lib/directors/DeliveryPricingSheet.js +2 -1
- package/lib/directors/DeliveryPricingSheet.js.map +1 -1
- package/lib/directors/EnrollmentAdapter.d.ts +7 -4
- package/lib/directors/EnrollmentAdapter.d.ts.map +1 -1
- package/lib/directors/EnrollmentAdapter.js +1 -4
- package/lib/directors/EnrollmentAdapter.js.map +1 -1
- package/lib/directors/EnrollmentDirector.d.ts +1 -1
- package/lib/directors/EnrollmentDirector.d.ts.map +1 -1
- package/lib/directors/EnrollmentDirector.js +1 -5
- package/lib/directors/EnrollmentDirector.js.map +1 -1
- package/lib/directors/FilterAdapter.d.ts +3 -3
- package/lib/directors/FilterAdapter.d.ts.map +1 -1
- package/lib/directors/FilterDirector.d.ts +1 -1
- package/lib/directors/FilterDirector.d.ts.map +1 -1
- package/lib/directors/FilterDirector.js +1 -1
- package/lib/directors/FilterDirector.js.map +1 -1
- package/lib/directors/MessagingDirector.d.ts +1 -1
- package/lib/directors/OrderDiscountAdapter.d.ts +1 -1
- package/lib/directors/OrderDiscountAdapter.d.ts.map +1 -1
- package/lib/directors/OrderDiscountAdapter.js.map +1 -1
- package/lib/directors/OrderPricingAdapter.d.ts +2 -2
- package/lib/directors/OrderPricingAdapter.d.ts.map +1 -1
- package/lib/directors/OrderPricingDirector.d.ts +2 -2
- package/lib/directors/OrderPricingDirector.d.ts.map +1 -1
- package/lib/directors/OrderPricingDirector.js +1 -1
- package/lib/directors/OrderPricingDirector.js.map +1 -1
- package/lib/directors/OrderPricingSheet.d.ts.map +1 -1
- package/lib/directors/OrderPricingSheet.js +2 -1
- package/lib/directors/OrderPricingSheet.js.map +1 -1
- package/lib/directors/PaymentAdapter.d.ts +2 -2
- package/lib/directors/PaymentAdapter.d.ts.map +1 -1
- package/lib/directors/PaymentDirector.d.ts +4 -4
- package/lib/directors/PaymentDirector.d.ts.map +1 -1
- package/lib/directors/PaymentDirector.js +22 -4
- package/lib/directors/PaymentDirector.js.map +1 -1
- package/lib/directors/PaymentPricingAdapter.d.ts +2 -2
- package/lib/directors/PaymentPricingAdapter.d.ts.map +1 -1
- package/lib/directors/PaymentPricingDirector.d.ts +1 -1
- package/lib/directors/PaymentPricingDirector.d.ts.map +1 -1
- package/lib/directors/PaymentPricingDirector.js +3 -5
- package/lib/directors/PaymentPricingDirector.js.map +1 -1
- package/lib/directors/PaymentPricingSheet.d.ts.map +1 -1
- package/lib/directors/PaymentPricingSheet.js +2 -1
- package/lib/directors/PaymentPricingSheet.js.map +1 -1
- package/lib/directors/ProductDiscountAdapter.d.ts +1 -1
- package/lib/directors/ProductDiscountAdapter.d.ts.map +1 -1
- package/lib/directors/ProductDiscountAdapter.js.map +1 -1
- package/lib/directors/ProductDiscountConfiguration.d.ts +1 -1
- package/lib/directors/ProductDiscountConfiguration.d.ts.map +1 -1
- package/lib/directors/ProductPricingAdapter.d.ts +1 -1
- package/lib/directors/ProductPricingAdapter.d.ts.map +1 -1
- package/lib/directors/ProductPricingDirector.d.ts +2 -2
- package/lib/directors/ProductPricingDirector.d.ts.map +1 -1
- package/lib/directors/ProductPricingDirector.js +3 -3
- package/lib/directors/ProductPricingDirector.js.map +1 -1
- package/lib/directors/ProductPricingSheet.d.ts +2 -2
- package/lib/directors/ProductPricingSheet.d.ts.map +1 -1
- package/lib/directors/ProductPricingSheet.js +2 -1
- package/lib/directors/ProductPricingSheet.js.map +1 -1
- package/lib/directors/QuotationAdapter.d.ts +2 -2
- package/lib/directors/QuotationAdapter.d.ts.map +1 -1
- package/lib/directors/QuotationDirector.js +2 -2
- package/lib/directors/WarehousingAdapter.d.ts +3 -4
- package/lib/directors/WarehousingAdapter.d.ts.map +1 -1
- package/lib/directors/WarehousingAdapter.js.map +1 -1
- package/lib/directors/WarehousingDirector.d.ts +5 -5
- package/lib/directors/WarehousingDirector.d.ts.map +1 -1
- package/lib/directors/WarehousingDirector.js +10 -13
- package/lib/directors/WarehousingDirector.js.map +1 -1
- package/lib/directors/WorkerAdapter.d.ts +1 -1
- package/lib/directors/WorkerAdapter.d.ts.map +1 -1
- package/lib/directors/WorkerAdapter.js +1 -1
- package/lib/directors/WorkerAdapter.js.map +1 -1
- package/lib/directors/WorkerDirector.d.ts +2 -2
- package/lib/directors/WorkerDirector.d.ts.map +1 -1
- package/lib/directors/WorkerDirector.js +2 -3
- package/lib/directors/WorkerDirector.js.map +1 -1
- package/lib/modules.d.ts +1 -1
- package/lib/modules.d.ts.map +1 -1
- package/lib/services/activateEnrollment.js +3 -3
- package/lib/services/activateEnrollment.js.map +1 -1
- package/lib/services/calculateDiscountTotal.js +2 -2
- package/lib/services/calculateDiscountTotal.js.map +1 -1
- package/lib/services/checkoutOrder.d.ts +1 -1
- package/lib/services/checkoutOrder.d.ts.map +1 -1
- package/lib/services/checkoutOrder.js +9 -3
- package/lib/services/checkoutOrder.js.map +1 -1
- package/lib/services/confirmOrder.d.ts +1 -1
- package/lib/services/confirmOrder.d.ts.map +1 -1
- package/lib/services/createDownloadStream.d.ts +1 -1
- package/lib/services/createDownloadStream.d.ts.map +1 -1
- package/lib/services/createDownloadStream.js +2 -0
- package/lib/services/createDownloadStream.js.map +1 -1
- package/lib/services/createEnrollmentFromCheckout.d.ts.map +1 -1
- package/lib/services/createEnrollmentFromCheckout.js +2 -2
- package/lib/services/createEnrollmentFromCheckout.js.map +1 -1
- package/lib/services/createManualOrderDiscount.d.ts +2 -2
- package/lib/services/createManualOrderDiscount.d.ts.map +1 -1
- package/lib/services/createSignedURL.d.ts.map +1 -1
- package/lib/services/createSignedURL.js +2 -0
- package/lib/services/createSignedURL.js.map +1 -1
- package/lib/services/deleteUser.d.ts +1 -1
- package/lib/services/deleteUser.d.ts.map +1 -1
- package/lib/services/deleteUser.js +4 -2
- package/lib/services/deleteUser.js.map +1 -1
- package/lib/services/discountedEntities.js.map +1 -1
- package/lib/services/findOrInitCart.d.ts +1 -2
- package/lib/services/findOrInitCart.d.ts.map +1 -1
- package/lib/services/findOrInitCart.js.map +1 -1
- package/lib/services/fullfillQuotation.d.ts +1 -1
- package/lib/services/fullfillQuotation.d.ts.map +1 -1
- package/lib/services/fullfillQuotation.js.map +1 -1
- package/lib/services/generateOrderFromEnrollment.d.ts +7 -0
- package/lib/services/generateOrderFromEnrollment.d.ts.map +1 -0
- package/lib/services/generateOrderFromEnrollment.js +34 -0
- package/lib/services/generateOrderFromEnrollment.js.map +1 -0
- package/lib/services/index.d.ts +2 -0
- package/lib/services/index.d.ts.map +1 -1
- package/lib/services/index.js +2 -0
- package/lib/services/index.js.map +1 -1
- package/lib/services/initCartProviders.js.map +1 -1
- package/lib/services/initializeEnrollment.d.ts +1 -1
- package/lib/services/initializeEnrollment.d.ts.map +1 -1
- package/lib/services/initializeEnrollment.js +6 -3
- package/lib/services/initializeEnrollment.js.map +1 -1
- package/lib/services/linkFileService.d.ts +1 -1
- package/lib/services/linkFileService.d.ts.map +1 -1
- package/lib/services/linkFileService.js +3 -1
- package/lib/services/linkFileService.js.map +1 -1
- package/lib/services/loadFilterOptions.d.ts +2 -2
- package/lib/services/loadFilterOptions.d.ts.map +1 -1
- package/lib/services/migrateOrderCart.d.ts +1 -1
- package/lib/services/migrateOrderCart.d.ts.map +1 -1
- package/lib/services/nextUserCart.d.ts +1 -1
- package/lib/services/nextUserCart.d.ts.map +1 -1
- package/lib/services/nextUserCart.js +1 -1
- package/lib/services/nextUserCart.js.map +1 -1
- package/lib/services/processEnrollment.d.ts.map +1 -1
- package/lib/services/processEnrollment.js +13 -5
- package/lib/services/processEnrollment.js.map +1 -1
- package/lib/services/processOrder.d.ts.map +1 -1
- package/lib/services/processOrder.js +26 -30
- package/lib/services/processOrder.js.map +1 -1
- package/lib/services/processQuotation.js +6 -6
- package/lib/services/processQuotation.js.map +1 -1
- package/lib/services/proposeQuotation.d.ts +1 -1
- package/lib/services/proposeQuotation.d.ts.map +1 -1
- package/lib/services/proposeQuotation.js +2 -2
- package/lib/services/proposeQuotation.js.map +1 -1
- package/lib/services/registerPaymentCredentials.d.ts +1 -2
- package/lib/services/registerPaymentCredentials.d.ts.map +1 -1
- package/lib/services/registerPaymentCredentials.js +4 -6
- package/lib/services/registerPaymentCredentials.js.map +1 -1
- package/lib/services/rejectOrder.d.ts +1 -1
- package/lib/services/rejectOrder.d.ts.map +1 -1
- package/lib/services/rejectQuotation.d.ts +1 -1
- package/lib/services/rejectQuotation.d.ts.map +1 -1
- package/lib/services/rejectQuotation.js +2 -2
- package/lib/services/rejectQuotation.js.map +1 -1
- package/lib/services/removeProduct.js +3 -3
- package/lib/services/removeProduct.js.map +1 -1
- package/lib/services/searchAssortments.js +1 -1
- package/lib/services/searchAssortments.js.map +1 -1
- package/lib/services/searchProducts.js +1 -1
- package/lib/services/searchProducts.js.map +1 -1
- package/lib/services/simulateProductDispatching.d.ts +1 -1
- package/lib/services/simulateProductDispatching.d.ts.map +1 -1
- package/lib/services/simulateProductInventory.d.ts +1 -1
- package/lib/services/simulateProductInventory.d.ts.map +1 -1
- package/lib/services/simulateProductInventory.js.map +1 -1
- package/lib/services/simulateProductPricing.d.ts +7 -4
- package/lib/services/simulateProductPricing.d.ts.map +1 -1
- package/lib/services/simulateProductPricing.js.map +1 -1
- package/lib/services/updateCalculation.d.ts +2 -1
- package/lib/services/updateCalculation.d.ts.map +1 -1
- package/lib/services/updateCalculation.js +16 -10
- package/lib/services/updateCalculation.js.map +1 -1
- package/lib/services/updateScheduling.d.ts +1 -1
- package/lib/services/updateScheduling.d.ts.map +1 -1
- package/lib/services/updateScheduling.js +7 -11
- package/lib/services/updateScheduling.js.map +1 -1
- package/lib/services/updateUserAvatarAfterUpload.d.ts +1 -1
- package/lib/services/updateUserAvatarAfterUpload.d.ts.map +1 -1
- package/lib/services/updateUserAvatarAfterUpload.js.map +1 -1
- package/lib/services/uploadFileFromStream.d.ts.map +1 -1
- package/lib/services/uploadFileFromStream.js +4 -1
- package/lib/services/uploadFileFromStream.js.map +1 -1
- package/lib/services/uploadFileFromURL.d.ts +1 -2
- package/lib/services/uploadFileFromURL.d.ts.map +1 -1
- package/lib/services/uploadFileFromURL.js.map +1 -1
- package/lib/services/validateOrder.d.ts +1 -1
- package/lib/services/validateOrder.d.ts.map +1 -1
- package/lib/services/validateOrder.js +17 -24
- package/lib/services/validateOrder.js.map +1 -1
- package/lib/services/verifyQuotation.d.ts +1 -1
- package/lib/services/verifyQuotation.d.ts.map +1 -1
- package/lib/services/verifyQuotation.js +2 -2
- package/lib/services/verifyQuotation.js.map +1 -1
- package/package.json +20 -20
- package/src/bulk-importer/createBulkImporter.ts +34 -22
- package/src/bulk-importer/handlers/assortment/create.ts +38 -7
- package/src/bulk-importer/handlers/assortment/remove.ts +14 -3
- package/src/bulk-importer/handlers/assortment/update.ts +53 -9
- package/src/bulk-importer/handlers/assortment/upsertAssortmentChildren.ts +44 -19
- package/src/bulk-importer/handlers/assortment/upsertAssortmentFilters.ts +37 -9
- package/src/bulk-importer/handlers/assortment/upsertAssortmentProducts.ts +35 -9
- package/src/bulk-importer/handlers/assortment/upsertMedia.ts +23 -5
- package/src/bulk-importer/handlers/filter/create.ts +28 -0
- package/src/bulk-importer/handlers/filter/remove.ts +6 -1
- package/src/bulk-importer/handlers/filter/update.ts +28 -1
- package/src/bulk-importer/handlers/product/create.ts +109 -9
- package/src/bulk-importer/handlers/product/remove.ts +7 -1
- package/src/bulk-importer/handlers/product/update.ts +117 -8
- package/src/bulk-importer/handlers/product/upsertMedia.ts +20 -3
- package/src/bulk-importer/handlers/product/upsertVariations.ts +43 -4
- package/src/bulk-importer/handlers/utils/convertTagsToLowerCase.ts +1 -1
- package/src/bulk-importer/index.ts +3 -0
- package/src/bulk-importer/upsertAsset.ts +10 -2
- package/src/core-index.ts +4 -6
- package/src/directors/BaseDiscountAdapter.test.ts +1 -1
- package/src/directors/BaseDiscountAdapter.ts +5 -5
- package/src/directors/BaseDiscountDirector.ts +2 -2
- package/src/directors/BasePricingAdapter.ts +2 -2
- package/src/directors/BasePricingDirector.ts +47 -44
- package/src/directors/BasePricingSheet.ts +1 -1
- package/src/directors/BaseWorker.ts +1 -1
- package/src/directors/DeliveryAdapter.ts +3 -3
- package/src/directors/DeliveryDirector.ts +33 -23
- package/src/directors/DeliveryPricingAdapter.ts +1 -1
- package/src/directors/DeliveryPricingDirector.ts +5 -6
- package/src/directors/DeliveryPricingSheet.ts +3 -2
- package/src/directors/EnrollmentAdapter.ts +9 -6
- package/src/directors/EnrollmentDirector.ts +9 -8
- package/src/directors/FilterAdapter.ts +3 -3
- package/src/directors/FilterDirector.ts +5 -5
- package/src/directors/OrderDiscountAdapter.ts +2 -2
- package/src/directors/OrderPricingAdapter.ts +2 -2
- package/src/directors/OrderPricingDirector.ts +3 -3
- package/src/directors/OrderPricingSheet.ts +3 -2
- package/src/directors/PaymentAdapter.ts +2 -2
- package/src/directors/PaymentDirector.ts +32 -8
- package/src/directors/PaymentPricingAdapter.ts +2 -2
- package/src/directors/PaymentPricingDirector.ts +6 -8
- package/src/directors/PaymentPricingSheet.ts +3 -2
- package/src/directors/ProductDiscountAdapter.ts +2 -2
- package/src/directors/ProductDiscountConfiguration.ts +1 -1
- package/src/directors/ProductPricingAdapter.ts +1 -1
- package/src/directors/ProductPricingDirector.ts +7 -7
- package/src/directors/ProductPricingSheet.ts +4 -3
- package/src/directors/QuotationAdapter.ts +2 -2
- package/src/directors/QuotationDirector.ts +2 -2
- package/src/directors/WarehousingAdapter.ts +3 -4
- package/src/directors/WarehousingDirector.ts +20 -23
- package/src/directors/WorkerAdapter.ts +2 -2
- package/src/directors/WorkerDirector.ts +5 -6
- package/src/modules.ts +1 -1
- package/src/services/activateEnrollment.ts +5 -5
- package/src/services/calculateDiscountTotal.ts +4 -4
- package/src/services/checkoutOrder.ts +9 -4
- package/src/services/createDownloadStream.ts +1 -0
- package/src/services/createEnrollmentFromCheckout.ts +22 -20
- package/src/services/createManualOrderDiscount.ts +2 -2
- package/src/services/createSignedURL.ts +1 -0
- package/src/services/deleteUser.ts +7 -2
- package/src/services/discountedEntities.ts +6 -6
- package/src/services/findOrInitCart.ts +1 -2
- package/src/services/fullfillQuotation.ts +1 -1
- package/src/services/generateOrderFromEnrollment.ts +54 -0
- package/src/services/index.ts +4 -0
- package/src/services/initCartProviders.ts +2 -2
- package/src/services/initializeEnrollment.ts +11 -4
- package/src/services/linkFileService.ts +3 -1
- package/src/services/nextUserCart.ts +1 -1
- package/src/services/processEnrollment.ts +18 -6
- package/src/services/processOrder.ts +33 -36
- package/src/services/processQuotation.ts +6 -6
- package/src/services/proposeQuotation.ts +2 -2
- package/src/services/registerPaymentCredentials.ts +6 -8
- package/src/services/rejectQuotation.ts +2 -2
- package/src/services/removeProduct.ts +3 -3
- package/src/services/searchAssortments.ts +1 -1
- package/src/services/searchProducts.ts +1 -1
- package/src/services/simulateProductDispatching.ts +1 -1
- package/src/services/simulateProductInventory.ts +7 -3
- package/src/services/simulateProductPricing.ts +6 -3
- package/src/services/updateCalculation.ts +33 -18
- package/src/services/updateScheduling.ts +19 -20
- package/src/services/updateUserAvatarAfterUpload.ts +4 -1
- package/src/services/uploadFileFromStream.ts +3 -1
- package/src/services/uploadFileFromURL.ts +2 -2
- package/src/services/validateOrder.ts +34 -38
- package/src/services/verifyQuotation.ts +2 -2
- package/lib/factory/registerProductDiscoverabilityFilter copy.d.ts +0 -5
- package/lib/factory/registerProductDiscoverabilityFilter copy.d.ts.map +0 -1
- package/lib/factory/registerProductDiscoverabilityFilter copy.js +0 -28
- package/lib/factory/registerProductDiscoverabilityFilter copy.js.map +0 -1
- package/src/bulk-importer/handlers/product/transformSpecificationToProductStructure.ts +0 -22
|
@@ -1,12 +1,115 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { Modules } from '../../../modules.js';
|
|
2
3
|
import { Services } from '../../../services/index.js';
|
|
3
|
-
import upsertVariations from './upsertVariations.js';
|
|
4
|
-
import upsertMedia from './upsertMedia.js';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
4
|
+
import upsertVariations, { ProductVariationSchema } from './upsertVariations.js';
|
|
5
|
+
import upsertMedia, { MediaSchema } from './upsertMedia.js';
|
|
6
|
+
import createProduct, { ProductCreatePayloadSchema } from './create.js';
|
|
7
|
+
import convertTagsToLowerCase from '../utils/convertTagsToLowerCase.js';
|
|
8
|
+
|
|
9
|
+
export const ProductUpdateSpecificationSchema = z.object({
|
|
10
|
+
type: z.string().optional(),
|
|
11
|
+
sequence: z.number().optional(),
|
|
12
|
+
status: z.string().optional().nullable(), // or null!
|
|
13
|
+
published: z.string().datetime().optional().nullable(), // or null!
|
|
14
|
+
tags: z.array(z.string()).optional(),
|
|
15
|
+
commerce: z
|
|
16
|
+
.object({
|
|
17
|
+
pricing: z.array(
|
|
18
|
+
z.object({
|
|
19
|
+
amount: z.number(),
|
|
20
|
+
maxQuantity: z.number().optional(),
|
|
21
|
+
isTaxable: z.boolean().optional(),
|
|
22
|
+
isNetPrice: z.boolean().optional(),
|
|
23
|
+
currencyCode: z.string(),
|
|
24
|
+
countryCode: z.string(),
|
|
25
|
+
}),
|
|
26
|
+
),
|
|
27
|
+
})
|
|
28
|
+
.optional(),
|
|
29
|
+
warehousing: z
|
|
30
|
+
.object({
|
|
31
|
+
sku: z.string().optional(),
|
|
32
|
+
baseUnit: z.string().optional(),
|
|
33
|
+
})
|
|
34
|
+
.optional(),
|
|
35
|
+
supply: z
|
|
36
|
+
.object({
|
|
37
|
+
weightInGram: z.number().optional(),
|
|
38
|
+
heightInMillimeters: z.number().optional(),
|
|
39
|
+
lengthInMillimeters: z.number().optional(),
|
|
40
|
+
widthInMillimeters: z.number().optional(),
|
|
41
|
+
})
|
|
42
|
+
.optional(),
|
|
43
|
+
bundleItems: z
|
|
44
|
+
.array(
|
|
45
|
+
z.object({
|
|
46
|
+
productId: z.string(),
|
|
47
|
+
quantity: z.number(),
|
|
48
|
+
configuration: z.array(
|
|
49
|
+
z.object({
|
|
50
|
+
key: z.string(),
|
|
51
|
+
value: z.string(),
|
|
52
|
+
}),
|
|
53
|
+
),
|
|
54
|
+
}),
|
|
55
|
+
)
|
|
56
|
+
.optional(),
|
|
57
|
+
meta: z.record(z.unknown()).optional(),
|
|
58
|
+
content: z
|
|
59
|
+
.record(
|
|
60
|
+
z.string(), // locale
|
|
61
|
+
z.object({
|
|
62
|
+
title: z.string().optional(),
|
|
63
|
+
subtitle: z.string().optional(),
|
|
64
|
+
slug: z.string().optional(),
|
|
65
|
+
description: z.string().optional(),
|
|
66
|
+
brand: z.string().optional(),
|
|
67
|
+
vendor: z.string().optional(),
|
|
68
|
+
labels: z.array(z.string()).optional(),
|
|
69
|
+
}),
|
|
70
|
+
)
|
|
71
|
+
.optional(),
|
|
72
|
+
variationResolvers: z
|
|
73
|
+
.array(
|
|
74
|
+
z.object({
|
|
75
|
+
vector: z.record(z.string()),
|
|
76
|
+
productId: z.string(),
|
|
77
|
+
}),
|
|
78
|
+
)
|
|
79
|
+
.optional(),
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export const ProductUpdatePayloadSchema = z.object({
|
|
83
|
+
_id: z.string(),
|
|
84
|
+
specification: ProductUpdateSpecificationSchema.optional(),
|
|
85
|
+
media: z.array(MediaSchema).optional(),
|
|
86
|
+
variations: z.array(ProductVariationSchema).optional(),
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const transformSpecification = (specification: z.infer<typeof ProductUpdateSpecificationSchema>) => {
|
|
90
|
+
const {
|
|
91
|
+
variationResolvers: assignments,
|
|
92
|
+
content, // eslint-disable-line
|
|
93
|
+
supply,
|
|
94
|
+
warehousing,
|
|
95
|
+
...productData
|
|
96
|
+
} = specification;
|
|
97
|
+
|
|
98
|
+
const tags = productData?.tags ? convertTagsToLowerCase(productData.tags!)! : [];
|
|
99
|
+
const proxy = assignments ? { assignments } : undefined;
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
...productData,
|
|
103
|
+
published: productData.published ? new Date(productData.published) : undefined,
|
|
104
|
+
tags,
|
|
105
|
+
warehousing,
|
|
106
|
+
supply,
|
|
107
|
+
proxy,
|
|
108
|
+
};
|
|
109
|
+
};
|
|
7
110
|
|
|
8
111
|
export default async function updateProduct(
|
|
9
|
-
payload:
|
|
112
|
+
payload: z.infer<typeof ProductUpdatePayloadSchema>,
|
|
10
113
|
{ logger, updateShouldUpsertIfIDNotExists },
|
|
11
114
|
unchainedAPI: { modules: Modules; services: Services },
|
|
12
115
|
) {
|
|
@@ -14,14 +117,18 @@ export default async function updateProduct(
|
|
|
14
117
|
const { specification, media, variations, _id } = payload;
|
|
15
118
|
|
|
16
119
|
if (!(await modules.products.productExists({ productId: _id }))) {
|
|
17
|
-
if (updateShouldUpsertIfIDNotExists) {
|
|
18
|
-
return createProduct(
|
|
120
|
+
if (updateShouldUpsertIfIDNotExists && payload.specification) {
|
|
121
|
+
return createProduct(
|
|
122
|
+
payload as z.infer<typeof ProductCreatePayloadSchema>,
|
|
123
|
+
{ logger, createShouldUpsertIfIDExists: false },
|
|
124
|
+
unchainedAPI,
|
|
125
|
+
);
|
|
19
126
|
}
|
|
20
127
|
throw new Error(`Can't update non-existing product ${_id}`);
|
|
21
128
|
}
|
|
22
129
|
|
|
23
130
|
if (specification) {
|
|
24
|
-
const productData =
|
|
131
|
+
const productData = transformSpecification(specification);
|
|
25
132
|
logger.debug('update product object', productData);
|
|
26
133
|
await modules.products.update(_id, {
|
|
27
134
|
...productData,
|
|
@@ -64,3 +171,5 @@ export default async function updateProduct(
|
|
|
64
171
|
success: true,
|
|
65
172
|
};
|
|
66
173
|
}
|
|
174
|
+
|
|
175
|
+
updateProduct.payloadSchema = ProductUpdatePayloadSchema;
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { ProductMedia } from '@unchainedshop/core-products';
|
|
2
3
|
import { Modules } from '../../../modules.js';
|
|
3
4
|
import { Services } from '../../../services/index.js';
|
|
4
5
|
import convertTagsToLowerCase from '../utils/convertTagsToLowerCase.js';
|
|
5
|
-
import upsertAsset from '../../upsertAsset.js';
|
|
6
|
+
import upsertAsset, { AssetSchema } from '../../upsertAsset.js';
|
|
7
|
+
|
|
8
|
+
export const MediaSchema = z.object({
|
|
9
|
+
_id: z.string().optional(),
|
|
10
|
+
asset: AssetSchema,
|
|
11
|
+
content: z
|
|
12
|
+
.record(
|
|
13
|
+
z.string(), // locale
|
|
14
|
+
z.object({
|
|
15
|
+
title: z.string().optional(),
|
|
16
|
+
subtitle: z.string().optional(),
|
|
17
|
+
}),
|
|
18
|
+
)
|
|
19
|
+
.optional(),
|
|
20
|
+
tags: z.array(z.string()).optional(),
|
|
21
|
+
sortKey: z.number().optional(),
|
|
22
|
+
});
|
|
6
23
|
|
|
7
24
|
const upsertProductMedia = async (productMedia: ProductMedia, { modules }: { modules: Modules }) => {
|
|
8
25
|
try {
|
|
@@ -16,14 +33,14 @@ const upsertProductMedia = async (productMedia: ProductMedia, { modules }: { mod
|
|
|
16
33
|
};
|
|
17
34
|
|
|
18
35
|
export default async function upsertMedia(
|
|
19
|
-
{ media, productId },
|
|
36
|
+
{ media, productId }: { media: z.infer<typeof MediaSchema>[]; productId: string },
|
|
20
37
|
unchainedAPI: { modules: Modules; services: Services },
|
|
21
38
|
) {
|
|
22
39
|
const { modules } = unchainedAPI;
|
|
23
40
|
|
|
24
41
|
const productMediaObjects = await Promise.all(
|
|
25
42
|
media.map(async ({ asset, content, ...mediaData }) => {
|
|
26
|
-
const tags = convertTagsToLowerCase(mediaData?.tags);
|
|
43
|
+
const tags = mediaData?.tags ? convertTagsToLowerCase(mediaData?.tags)! : [];
|
|
27
44
|
const file = await upsertAsset(
|
|
28
45
|
'product-media',
|
|
29
46
|
{ meta: { ...(asset.meta || {}), productId }, ...asset },
|
|
@@ -1,18 +1,57 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { ProductVariation } from '@unchainedshop/core-products';
|
|
2
3
|
import { Modules } from '../../../modules.js';
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
+
const ProductVariationOptionSchema = z.object({
|
|
6
|
+
value: z.string(),
|
|
7
|
+
content: z
|
|
8
|
+
.record(
|
|
9
|
+
z.string(), // locale
|
|
10
|
+
z.object({
|
|
11
|
+
title: z.string().optional(),
|
|
12
|
+
subtitle: z.string().optional(),
|
|
13
|
+
}),
|
|
14
|
+
)
|
|
15
|
+
.optional(),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const ProductVariationSchema = z.object({
|
|
19
|
+
_id: z.string().optional(),
|
|
20
|
+
key: z.string(),
|
|
21
|
+
type: z.string(),
|
|
22
|
+
options: z.array(ProductVariationOptionSchema),
|
|
23
|
+
content: z
|
|
24
|
+
.record(
|
|
25
|
+
z.string(), // locale
|
|
26
|
+
z.object({
|
|
27
|
+
title: z.string().optional(),
|
|
28
|
+
subtitle: z.string().optional(),
|
|
29
|
+
}),
|
|
30
|
+
)
|
|
31
|
+
.optional(),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const upsert = async (
|
|
35
|
+
productVariation: Omit<ProductVariation, '_id' | 'created'> &
|
|
36
|
+
Pick<Partial<ProductVariation>, '_id' | 'created'>,
|
|
37
|
+
unchainedAPI: { modules: Modules },
|
|
38
|
+
) => {
|
|
5
39
|
const { modules } = unchainedAPI;
|
|
6
40
|
try {
|
|
7
|
-
const newVariation = await modules.products.variations.create(
|
|
41
|
+
const newVariation = (await modules.products.variations.create(
|
|
42
|
+
productVariation,
|
|
43
|
+
)) as ProductVariation;
|
|
8
44
|
return newVariation;
|
|
9
45
|
} catch {
|
|
10
|
-
return modules.products.variations.update(
|
|
46
|
+
return (await modules.products.variations.update(
|
|
47
|
+
productVariation._id!,
|
|
48
|
+
productVariation,
|
|
49
|
+
)) as ProductVariation;
|
|
11
50
|
}
|
|
12
51
|
};
|
|
13
52
|
|
|
14
53
|
export default async function upsertVariations(
|
|
15
|
-
{ variations, productId },
|
|
54
|
+
{ variations, productId }: { variations: z.infer<typeof ProductVariationSchema>[]; productId: string },
|
|
16
55
|
unchainedAPI: { modules: Modules },
|
|
17
56
|
) {
|
|
18
57
|
const { modules } = unchainedAPI;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import type { File } from '@unchainedshop/core-files';
|
|
2
1
|
import { Modules } from '../modules.js';
|
|
3
2
|
import { Services } from '../services/index.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
export const AssetSchema = z.object({
|
|
6
|
+
_id: z.string().optional(),
|
|
7
|
+
url: z.string(),
|
|
8
|
+
meta: z.record(z.unknown()).optional(),
|
|
9
|
+
fileName: z.string(),
|
|
10
|
+
headers: z.record(z.string()).optional(),
|
|
11
|
+
});
|
|
4
12
|
|
|
5
13
|
const upsertAsset = async (
|
|
6
14
|
directoryName: string,
|
|
7
|
-
asset:
|
|
15
|
+
asset: z.infer<typeof AssetSchema>,
|
|
8
16
|
unchainedAPI: { modules: Modules; services: Services },
|
|
9
17
|
) => {
|
|
10
18
|
const { modules, services } = unchainedAPI;
|
package/src/core-index.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { mongodb, MigrationRepository, ModuleInput } from '@unchainedshop/mongodb';
|
|
2
2
|
import initServices, { CustomServices, Services } from './services/index.js';
|
|
3
3
|
import initModules, { Modules, ModuleOptions } from './modules.js';
|
|
4
|
-
import createBulkImporterFactory, {
|
|
5
|
-
BulkImporter,
|
|
6
|
-
BulkImportHandler,
|
|
7
|
-
} from './bulk-importer/createBulkImporter.js';
|
|
4
|
+
import createBulkImporterFactory, { BulkImporter, BulkImportHandler } from './bulk-importer/index.js';
|
|
8
5
|
|
|
9
6
|
import {
|
|
10
7
|
WorkerDirector,
|
|
@@ -21,8 +18,9 @@ import {
|
|
|
21
18
|
QuotationDirector,
|
|
22
19
|
WarehousingDirector,
|
|
23
20
|
} from './directors/index.js';
|
|
21
|
+
import { IBaseAdapter } from '@unchainedshop/utils';
|
|
24
22
|
|
|
25
|
-
export * from './bulk-importer/
|
|
23
|
+
export * from './bulk-importer/index.js';
|
|
26
24
|
export * from './services/index.js';
|
|
27
25
|
export * from './directors/index.js';
|
|
28
26
|
export * from './factory/index.js';
|
|
@@ -87,7 +85,7 @@ export const getAllAdapters = () => {
|
|
|
87
85
|
const quotation = QuotationDirector.getAdapters();
|
|
88
86
|
const warehousing = WarehousingDirector.getAdapters();
|
|
89
87
|
|
|
90
|
-
return [].concat(
|
|
88
|
+
return ([] as IBaseAdapter[]).concat(
|
|
91
89
|
worker,
|
|
92
90
|
delivery,
|
|
93
91
|
deliveryPricing,
|
|
@@ -32,7 +32,7 @@ describe('BaseDiscountAdapter instantiation', () => {
|
|
|
32
32
|
|
|
33
33
|
it('release', async () => {
|
|
34
34
|
const result = await adapter.actions(context);
|
|
35
|
-
assert.equal(await result.release(),
|
|
35
|
+
assert.equal(await result.release(), undefined);
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
it('isValidForCodeTriggering', async () => {
|
|
@@ -6,13 +6,13 @@ import { Modules } from '../modules.js';
|
|
|
6
6
|
export interface DiscountContext {
|
|
7
7
|
code?: string;
|
|
8
8
|
orderDiscount?: OrderDiscount;
|
|
9
|
-
order
|
|
9
|
+
order: Order;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export type IDiscountAdapter<DiscountConfiguration> = IBaseAdapter & {
|
|
13
13
|
orderIndex: number;
|
|
14
14
|
|
|
15
|
-
isManualAdditionAllowed: (code
|
|
15
|
+
isManualAdditionAllowed: (code?: string) => Promise<boolean>;
|
|
16
16
|
isManualRemovalAllowed: () => Promise<boolean>;
|
|
17
17
|
|
|
18
18
|
actions: (params: {
|
|
@@ -27,9 +27,9 @@ export interface DiscountAdapterActions<DiscountConfiguration> {
|
|
|
27
27
|
discountForPricingAdapterKey: (params: {
|
|
28
28
|
pricingAdapterKey: string;
|
|
29
29
|
calculationSheet: IPricingSheet<PricingCalculation>;
|
|
30
|
-
}) => DiscountConfiguration;
|
|
30
|
+
}) => DiscountConfiguration | null;
|
|
31
31
|
|
|
32
|
-
reserve: (params: { code
|
|
32
|
+
reserve: (params: { code?: string }) => Promise<any>;
|
|
33
33
|
release: () => Promise<void>;
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -67,7 +67,7 @@ export const BaseDiscountAdapter: Omit<IDiscountAdapter<unknown>, 'key' | 'label
|
|
|
67
67
|
|
|
68
68
|
// return void, allows you to free up any reservations in backend systems
|
|
69
69
|
release: async () => {
|
|
70
|
-
return
|
|
70
|
+
return;
|
|
71
71
|
},
|
|
72
72
|
|
|
73
73
|
// return true if a discount is valid to be part of the order.
|
|
@@ -11,7 +11,7 @@ export type IDiscountDirector<DiscountConfiguration> = IBaseDirector<
|
|
|
11
11
|
) => Promise<{
|
|
12
12
|
resolveDiscountAdapterFromStaticCode: (params: {
|
|
13
13
|
code: string;
|
|
14
|
-
}) => Promise<IDiscountAdapter<DiscountConfiguration
|
|
14
|
+
}) => Promise<IDiscountAdapter<DiscountConfiguration> | null>;
|
|
15
15
|
findSystemDiscounts: () => Promise<string[]>;
|
|
16
16
|
}>;
|
|
17
17
|
};
|
|
@@ -46,7 +46,7 @@ export const BaseDiscountDirector = <DiscountConfigurationType>(
|
|
|
46
46
|
}),
|
|
47
47
|
);
|
|
48
48
|
|
|
49
|
-
return discounts.find(({ isValid }) => isValid === true)?.Adapter;
|
|
49
|
+
return discounts.find(({ isValid }) => isValid === true)?.Adapter || null;
|
|
50
50
|
},
|
|
51
51
|
|
|
52
52
|
async findSystemDiscounts() {
|
|
@@ -4,7 +4,7 @@ import { Discount } from './BasePricingDirector.js';
|
|
|
4
4
|
import { Order, OrderDiscount } from '@unchainedshop/core-orders';
|
|
5
5
|
|
|
6
6
|
interface IDiscountableItem {
|
|
7
|
-
_id
|
|
7
|
+
_id: string;
|
|
8
8
|
orderId?: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -26,7 +26,7 @@ export interface IPricingAdapterActions<
|
|
|
26
26
|
Calculation extends PricingCalculation,
|
|
27
27
|
Sheet extends IPricingSheet<Calculation>,
|
|
28
28
|
> {
|
|
29
|
-
calculate: () => Promise<Calculation[]>;
|
|
29
|
+
calculate: () => Promise<Calculation[] | null>;
|
|
30
30
|
resultSheet: () => Sheet;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -70,7 +70,7 @@ export const BasePricingDirector = <
|
|
|
70
70
|
async rebuildCalculation(this: typeof director, pricingContext, unchainedAPI) {
|
|
71
71
|
const context = await this.buildPricingContext(pricingContext, unchainedAPI);
|
|
72
72
|
|
|
73
|
-
let calculation: Calculation[] = [];
|
|
73
|
+
let calculation: Calculation[] | null = [];
|
|
74
74
|
|
|
75
75
|
const Adapters = baseDirector.getAdapters({
|
|
76
76
|
adapterFilter: (Adapter) => {
|
|
@@ -78,52 +78,55 @@ export const BasePricingDirector = <
|
|
|
78
78
|
},
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
calculation = await Adapters.reduce(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
81
|
+
calculation = await Adapters.reduce(
|
|
82
|
+
async (previousPromise, Adapter) => {
|
|
83
|
+
const resolvedCalculation = await previousPromise;
|
|
84
|
+
if (!resolvedCalculation) return null;
|
|
85
|
+
|
|
86
|
+
const discounts: (Discount<any> | null)[] = await Promise.all(
|
|
87
|
+
context.discounts.map(async (orderDiscount) => {
|
|
88
|
+
const order = await unchainedAPI.modules.orders.findOrder({
|
|
89
|
+
orderId: orderDiscount.orderId,
|
|
90
|
+
});
|
|
91
|
+
const DiscountAdapter = OrderDiscountDirector.getAdapter(orderDiscount.discountKey);
|
|
92
|
+
if (!DiscountAdapter) return null;
|
|
93
|
+
|
|
94
|
+
const adapter = await DiscountAdapter.actions({
|
|
95
|
+
context: { order, orderDiscount, code: orderDiscount.code, ...unchainedAPI },
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const configuration = adapter.discountForPricingAdapterKey({
|
|
99
|
+
pricingAdapterKey: Adapter.key,
|
|
100
|
+
calculationSheet: this.calculationSheet(pricingContext, resolvedCalculation),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
discountId: orderDiscount._id,
|
|
105
|
+
configuration,
|
|
106
|
+
};
|
|
107
|
+
}),
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
const adapter = Adapter.actions({
|
|
112
|
+
context,
|
|
113
|
+
calculationSheet: this.calculationSheet(pricingContext, resolvedCalculation),
|
|
114
|
+
discounts: discounts.filter((d) => d?.configuration !== null) as Discount<any>[],
|
|
95
115
|
});
|
|
96
116
|
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
117
|
+
const nextCalculationResult = await adapter.calculate();
|
|
118
|
+
if (!nextCalculationResult) return null;
|
|
119
|
+
calculation = resolvedCalculation.concat(nextCalculationResult);
|
|
120
|
+
return calculation;
|
|
121
|
+
} catch (error) {
|
|
122
|
+
logger.error(error);
|
|
123
|
+
}
|
|
124
|
+
return resolvedCalculation;
|
|
125
|
+
},
|
|
126
|
+
Promise.resolve([] as Calculation[]),
|
|
127
|
+
);
|
|
101
128
|
|
|
102
|
-
|
|
103
|
-
discountId: orderDiscount._id,
|
|
104
|
-
configuration,
|
|
105
|
-
};
|
|
106
|
-
}),
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
try {
|
|
110
|
-
const adapter = Adapter.actions({
|
|
111
|
-
context,
|
|
112
|
-
calculationSheet: this.calculationSheet(pricingContext, calculation),
|
|
113
|
-
discounts: discounts.filter((d) => d?.configuration !== null),
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
const nextCalculationResult = await adapter.calculate();
|
|
117
|
-
if (!nextCalculationResult) return null;
|
|
118
|
-
calculation = resolvedCalculation.concat(nextCalculationResult);
|
|
119
|
-
return calculation;
|
|
120
|
-
} catch (error) {
|
|
121
|
-
logger.error(error);
|
|
122
|
-
}
|
|
123
|
-
return resolvedCalculation;
|
|
124
|
-
}, Promise.resolve([]));
|
|
125
|
-
|
|
126
|
-
return calculation;
|
|
129
|
+
return calculation || ([] as Calculation[]);
|
|
127
130
|
},
|
|
128
131
|
};
|
|
129
132
|
|
|
@@ -93,7 +93,7 @@ export const BasePricingSheet = <Calculation extends PricingCalculation>(
|
|
|
93
93
|
(oldCalculation, filterKey) =>
|
|
94
94
|
oldCalculation.filter(
|
|
95
95
|
(row: Calculation) =>
|
|
96
|
-
!!row && (filter[filterKey] === undefined || row[filterKey] === filter[filterKey]),
|
|
96
|
+
!!row && (filter![filterKey] === undefined || row[filterKey] === filter![filterKey]),
|
|
97
97
|
),
|
|
98
98
|
this.calculation,
|
|
99
99
|
);
|
|
@@ -83,7 +83,7 @@ export const BaseWorker: IWorker<WorkerParams> = {
|
|
|
83
83
|
retries: workConfig.retries || 0,
|
|
84
84
|
};
|
|
85
85
|
if (workConfig.input) {
|
|
86
|
-
workData.input = await workConfig.input(workData);
|
|
86
|
+
workData.input = (await workConfig.input(workData)) || {};
|
|
87
87
|
// A work input fn can skip auto scheduling a new record
|
|
88
88
|
// when it explicitly returns a falsish input instead of a dictionary
|
|
89
89
|
if (!workData.input) return null;
|
|
@@ -19,11 +19,11 @@ export enum DeliveryError {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export interface DeliveryAdapterActions {
|
|
22
|
-
configurationError: (transactionContext?: any) => DeliveryError;
|
|
23
|
-
estimatedDeliveryThroughput: (warehousingThroughputTime: number) => Promise<number>;
|
|
22
|
+
configurationError: (transactionContext?: any) => DeliveryError | null;
|
|
23
|
+
estimatedDeliveryThroughput: (warehousingThroughputTime: number) => Promise<number | null>;
|
|
24
24
|
isActive: () => boolean;
|
|
25
25
|
isAutoReleaseAllowed: () => boolean;
|
|
26
|
-
pickUpLocationById: (locationId: string) => Promise<DeliveryLocation>;
|
|
26
|
+
pickUpLocationById: (locationId: string) => Promise<DeliveryLocation | null>;
|
|
27
27
|
pickUpLocations: () => Promise<DeliveryLocation[]>;
|
|
28
28
|
send: () => Promise<boolean | Work>;
|
|
29
29
|
}
|