@unchainedshop/core 4.0.0-rc.15 → 4.0.0-rc.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bulk-importer/createBulkImporter.d.ts +84 -0
- package/lib/bulk-importer/createBulkImporter.d.ts.map +1 -0
- package/lib/bulk-importer/createBulkImporter.js +142 -0
- package/lib/bulk-importer/createBulkImporter.js.map +1 -0
- package/lib/bulk-importer/handlers/assortment/create.d.ts +565 -0
- package/lib/bulk-importer/handlers/assortment/create.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/assortment/create.js +89 -0
- package/lib/bulk-importer/handlers/assortment/create.js.map +1 -0
- package/lib/bulk-importer/handlers/assortment/index.d.ts +4 -0
- package/lib/bulk-importer/handlers/assortment/index.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/assortment/index.js +4 -0
- package/lib/bulk-importer/handlers/assortment/index.js.map +1 -0
- package/lib/bulk-importer/handlers/assortment/remove.d.ts +30 -0
- package/lib/bulk-importer/handlers/assortment/remove.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/assortment/remove.js +18 -0
- package/lib/bulk-importer/handlers/assortment/remove.js.map +1 -0
- package/lib/bulk-importer/handlers/assortment/update.d.ts +566 -0
- package/lib/bulk-importer/handlers/assortment/update.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/assortment/update.js +98 -0
- package/lib/bulk-importer/handlers/assortment/update.js.map +1 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts +29 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js +45 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js.map +1 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts +29 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js +41 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js.map +1 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts +29 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js +46 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js.map +1 -0
- package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts +76 -0
- package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js +53 -0
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js.map +1 -0
- package/lib/bulk-importer/handlers/filter/create.d.ts +138 -0
- package/lib/bulk-importer/handlers/filter/create.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/filter/create.js +80 -0
- package/lib/bulk-importer/handlers/filter/create.js.map +1 -0
- package/lib/bulk-importer/handlers/filter/index.d.ts +4 -0
- package/lib/bulk-importer/handlers/filter/index.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/filter/index.js +4 -0
- package/lib/bulk-importer/handlers/filter/index.js.map +1 -0
- package/lib/bulk-importer/handlers/filter/remove.d.ts +20 -0
- package/lib/bulk-importer/handlers/filter/remove.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/filter/remove.js +18 -0
- package/lib/bulk-importer/handlers/filter/remove.js.map +1 -0
- package/lib/bulk-importer/handlers/filter/update.d.ts +138 -0
- package/lib/bulk-importer/handlers/filter/update.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/filter/update.js +70 -0
- package/lib/bulk-importer/handlers/filter/update.js.map +1 -0
- package/lib/bulk-importer/handlers/product/create.d.ts +1330 -0
- package/lib/bulk-importer/handlers/product/create.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/product/create.js +132 -0
- package/lib/bulk-importer/handlers/product/create.js.map +1 -0
- package/lib/bulk-importer/handlers/product/index.d.ts +4 -0
- package/lib/bulk-importer/handlers/product/index.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/product/index.js +4 -0
- package/lib/bulk-importer/handlers/product/index.js.map +1 -0
- package/lib/bulk-importer/handlers/product/remove.d.ts +32 -0
- package/lib/bulk-importer/handlers/product/remove.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/product/remove.js +18 -0
- package/lib/bulk-importer/handlers/product/remove.js.map +1 -0
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts +280 -0
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js +77 -0
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js.map +1 -0
- package/lib/bulk-importer/handlers/product/update.d.ts +1330 -0
- package/lib/bulk-importer/handlers/product/update.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/product/update.js +132 -0
- package/lib/bulk-importer/handlers/product/update.js.map +1 -0
- package/lib/bulk-importer/handlers/product/upsertMedia.d.ts +75 -0
- package/lib/bulk-importer/handlers/product/upsertMedia.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/product/upsertMedia.js +59 -0
- package/lib/bulk-importer/handlers/product/upsertMedia.js.map +1 -0
- package/lib/bulk-importer/handlers/product/upsertVariations.d.ts +79 -0
- package/lib/bulk-importer/handlers/product/upsertVariations.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/product/upsertVariations.js +72 -0
- package/lib/bulk-importer/handlers/product/upsertVariations.js.map +1 -0
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts +3 -0
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js +6 -0
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js.map +1 -0
- 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 +28 -0
- package/lib/bulk-importer/upsertAsset.d.ts.map +1 -0
- package/lib/bulk-importer/upsertAsset.js +41 -0
- package/lib/bulk-importer/upsertAsset.js.map +1 -0
- package/lib/core-index.d.ts +8 -6
- package/lib/core-index.d.ts.map +1 -1
- package/lib/core-index.js +4 -1
- 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 +24 -6
- 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 +3 -2
- 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/modules.js +1 -0
- package/lib/modules.js.map +1 -1
- package/lib/services/activateEnrollment.d.ts.map +1 -1
- package/lib/services/activateEnrollment.js +8 -12
- package/lib/services/activateEnrollment.js.map +1 -1
- package/lib/services/addMessage.d.ts +4 -0
- package/lib/services/addMessage.d.ts.map +1 -0
- package/lib/services/addMessage.js +15 -0
- package/lib/services/addMessage.js.map +1 -0
- 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 +6 -0
- package/lib/services/index.d.ts.map +1 -1
- package/lib/services/index.js +6 -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 +11 -12
- 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.d.ts.map +1 -1
- package/lib/services/processQuotation.js +10 -14
- 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/removeFiles.js +2 -2
- package/lib/services/removeFiles.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/terminateEnrollment.d.ts.map +1 -1
- package/lib/services/terminateEnrollment.js +5 -9
- package/lib/services/terminateEnrollment.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 +21 -20
- package/src/bulk-importer/createBulkImporter.ts +205 -0
- package/src/bulk-importer/handlers/assortment/create.ts +118 -0
- package/src/bulk-importer/handlers/assortment/index.ts +3 -0
- package/src/bulk-importer/handlers/assortment/remove.ts +26 -0
- package/src/bulk-importer/handlers/assortment/update.ts +133 -0
- package/src/bulk-importer/handlers/assortment/upsertAssortmentChildren.ts +77 -0
- package/src/bulk-importer/handlers/assortment/upsertAssortmentFilters.ts +70 -0
- package/src/bulk-importer/handlers/assortment/upsertAssortmentProducts.ts +76 -0
- package/src/bulk-importer/handlers/assortment/upsertMedia.ts +76 -0
- package/src/bulk-importer/handlers/filter/create.ts +104 -0
- package/src/bulk-importer/handlers/filter/index.ts +3 -0
- package/src/bulk-importer/handlers/filter/remove.ts +25 -0
- package/src/bulk-importer/handlers/filter/update.ts +94 -0
- package/src/bulk-importer/handlers/product/create.ts +170 -0
- package/src/bulk-importer/handlers/product/index.ts +3 -0
- package/src/bulk-importer/handlers/product/remove.ts +27 -0
- package/src/bulk-importer/handlers/product/update.ts +175 -0
- package/src/bulk-importer/handlers/product/upsertMedia.ts +81 -0
- package/src/bulk-importer/handlers/product/upsertVariations.ts +110 -0
- package/src/bulk-importer/handlers/utils/convertTagsToLowerCase.ts +4 -0
- package/src/bulk-importer/index.ts +3 -0
- package/src/bulk-importer/upsertAsset.ts +50 -0
- package/src/core-index.ts +9 -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 +34 -10
- 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 +9 -4
- package/src/directors/WorkerDirector.ts +5 -6
- package/src/modules.ts +2 -1
- package/src/services/activateEnrollment.ts +9 -13
- package/src/services/addMessage.ts +20 -0
- 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 +8 -0
- package/src/services/initCartProviders.ts +2 -2
- package/src/services/initializeEnrollment.ts +16 -13
- 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 +10 -14
- package/src/services/proposeQuotation.ts +2 -2
- package/src/services/registerPaymentCredentials.ts +6 -8
- package/src/services/rejectQuotation.ts +2 -2
- package/src/services/removeFiles.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/terminateEnrollment.ts +5 -9
- 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
|
@@ -15,32 +15,32 @@ export async function discountedEntitiesService(
|
|
|
15
15
|
): Promise<OrderPricingDiscount[]> {
|
|
16
16
|
// Delivery discounts
|
|
17
17
|
const orderDelivery = await this.orders.deliveries.findDelivery({
|
|
18
|
-
orderDeliveryId: order.deliveryId
|
|
18
|
+
orderDeliveryId: order.deliveryId!,
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
const deliveryPricingSheet = DeliveryPricingSheet({
|
|
22
|
-
calculation: orderDelivery
|
|
22
|
+
calculation: orderDelivery!.calculation || [],
|
|
23
23
|
currencyCode: order.currencyCode,
|
|
24
24
|
});
|
|
25
25
|
const orderDeliveryDiscounts = deliveryPricingSheet
|
|
26
26
|
.discountPrices(orderDiscount._id)
|
|
27
27
|
.map((discount) => ({
|
|
28
|
-
delivery: orderDelivery
|
|
28
|
+
delivery: orderDelivery!,
|
|
29
29
|
...discount,
|
|
30
30
|
}));
|
|
31
31
|
|
|
32
32
|
// Payment discounts
|
|
33
33
|
const orderPayment = await this.orders.payments.findOrderPayment({
|
|
34
|
-
orderPaymentId: order.paymentId
|
|
34
|
+
orderPaymentId: order.paymentId!,
|
|
35
35
|
});
|
|
36
36
|
const paymentPricingSheet = PaymentPricingSheet({
|
|
37
|
-
calculation: orderPayment
|
|
37
|
+
calculation: orderPayment!.calculation || [],
|
|
38
38
|
currencyCode: order.currencyCode,
|
|
39
39
|
});
|
|
40
40
|
const orderPaymentDiscounts = paymentPricingSheet
|
|
41
41
|
.discountPrices(orderDiscount._id)
|
|
42
42
|
.map((discount) => ({
|
|
43
|
-
payment: orderPayment
|
|
43
|
+
payment: orderPayment!,
|
|
44
44
|
...discount,
|
|
45
45
|
}));
|
|
46
46
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { User } from '@unchainedshop/core-users';
|
|
2
|
-
import { Order } from '@unchainedshop/core-orders';
|
|
3
2
|
import { Modules } from '../modules.js';
|
|
4
3
|
import { nextUserCartService } from './nextUserCart.js';
|
|
5
4
|
|
|
@@ -25,5 +24,5 @@ export async function findOrInitCartService(
|
|
|
25
24
|
user,
|
|
26
25
|
countryCode,
|
|
27
26
|
forceCartCreation: true,
|
|
28
|
-
})
|
|
27
|
+
});
|
|
29
28
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Modules } from '../modules.js';
|
|
2
|
+
import { Enrollment, EnrollmentOrderPositionTemplate } from '@unchainedshop/core-enrollments';
|
|
3
|
+
import { updateCalculationService } from './updateCalculation.js';
|
|
4
|
+
import { checkoutOrderService } from './checkoutOrder.js';
|
|
5
|
+
|
|
6
|
+
export async function generateOrderFromEnrollmentService(
|
|
7
|
+
this: Modules,
|
|
8
|
+
enrollment: Enrollment,
|
|
9
|
+
{
|
|
10
|
+
orderPositionTemplates,
|
|
11
|
+
orderContext,
|
|
12
|
+
}: {
|
|
13
|
+
orderPositionTemplates: EnrollmentOrderPositionTemplate[];
|
|
14
|
+
orderContext?: any;
|
|
15
|
+
},
|
|
16
|
+
) {
|
|
17
|
+
if (!enrollment.payment || !enrollment.delivery) return null;
|
|
18
|
+
|
|
19
|
+
const order = await this.orders.create({
|
|
20
|
+
userId: enrollment.userId,
|
|
21
|
+
currencyCode: enrollment.currencyCode,
|
|
22
|
+
countryCode: enrollment.countryCode,
|
|
23
|
+
contact: enrollment.contact,
|
|
24
|
+
billingAddress: enrollment.billingAddress,
|
|
25
|
+
originEnrollmentId: enrollment._id,
|
|
26
|
+
context: orderContext,
|
|
27
|
+
});
|
|
28
|
+
const orderId = order._id;
|
|
29
|
+
|
|
30
|
+
await Promise.all(
|
|
31
|
+
orderPositionTemplates.map((orderPositionTemplate) =>
|
|
32
|
+
this.orders.positions.addProductItem({
|
|
33
|
+
...orderPositionTemplate,
|
|
34
|
+
orderId: order._id,
|
|
35
|
+
}),
|
|
36
|
+
),
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const { paymentProviderId, context: paymentContext } = enrollment.payment;
|
|
40
|
+
if (paymentProviderId) {
|
|
41
|
+
await this.orders.setPaymentProvider(orderId, paymentProviderId);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const { deliveryProviderId, context: deliveryContext } = enrollment.delivery;
|
|
45
|
+
if (deliveryProviderId) {
|
|
46
|
+
await this.orders.setDeliveryProvider(orderId, deliveryProviderId);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
await updateCalculationService.bind(this)(orderId);
|
|
50
|
+
return checkoutOrderService.bind(this)(order._id, {
|
|
51
|
+
deliveryContext,
|
|
52
|
+
paymentContext,
|
|
53
|
+
});
|
|
54
|
+
}
|
package/src/services/index.ts
CHANGED
|
@@ -44,6 +44,8 @@ import { simulateProductPricingService } from './simulateProductPricing.js';
|
|
|
44
44
|
import { simulateProductDispatchingService } from './simulateProductDispatching.js';
|
|
45
45
|
import { simulateProductInventoryService } from './simulateProductInventory.js';
|
|
46
46
|
import { findOrInitCartService } from './findOrInitCart.js';
|
|
47
|
+
import { addMessageService } from './addMessage.js';
|
|
48
|
+
import { generateOrderFromEnrollmentService } from './generateOrderFromEnrollment.js';
|
|
47
49
|
|
|
48
50
|
// Auto-Inject Unchained API as last parameter
|
|
49
51
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
|
|
@@ -134,6 +136,9 @@ export default function initServices(modules: Modules, customServices: CustomSer
|
|
|
134
136
|
createEnrollmentFromCheckout: createEnrollmentFromCheckoutService as Bound<
|
|
135
137
|
typeof createEnrollmentFromCheckoutService
|
|
136
138
|
>,
|
|
139
|
+
generateOrderFromEnrollment: generateOrderFromEnrollmentService as Bound<
|
|
140
|
+
typeof generateOrderFromEnrollmentService
|
|
141
|
+
>,
|
|
137
142
|
processEnrollment: processOrderService as Bound<typeof processOrderService>,
|
|
138
143
|
initializeEnrollment: initializeEnrollmentService as Bound<typeof initializeEnrollmentService>,
|
|
139
144
|
activateEnrollment: activateEnrollmentService as Bound<typeof activateEnrollmentService>,
|
|
@@ -156,6 +161,9 @@ export default function initServices(modules: Modules, customServices: CustomSer
|
|
|
156
161
|
warehousing: {
|
|
157
162
|
ercMetadata: ercMetadataService as Bound<typeof ercMetadataService>,
|
|
158
163
|
},
|
|
164
|
+
worker: {
|
|
165
|
+
addMessage: addMessageService as Bound<typeof addMessageService>,
|
|
166
|
+
},
|
|
159
167
|
};
|
|
160
168
|
|
|
161
169
|
// This Proxy Binds all services to the Modules Object
|
|
@@ -14,7 +14,7 @@ export async function initCartProvidersService(this: Modules, order: Order) {
|
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
const orderDelivery = await this.orders.deliveries.findDelivery({
|
|
17
|
-
orderDeliveryId: updatedOrder.deliveryId
|
|
17
|
+
orderDeliveryId: updatedOrder.deliveryId!,
|
|
18
18
|
});
|
|
19
19
|
const deliveryProviderId = orderDelivery?.deliveryProviderId;
|
|
20
20
|
|
|
@@ -45,7 +45,7 @@ export async function initCartProvidersService(this: Modules, order: Order) {
|
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
const orderPayment = await this.orders.payments.findOrderPayment({
|
|
48
|
-
orderPaymentId: updatedOrder.paymentId
|
|
48
|
+
orderPaymentId: updatedOrder.paymentId!,
|
|
49
49
|
});
|
|
50
50
|
const paymentProviderId = orderPayment?.paymentProviderId;
|
|
51
51
|
|
|
@@ -2,36 +2,39 @@ import { Enrollment } from '@unchainedshop/core-enrollments';
|
|
|
2
2
|
import { EnrollmentDirector } from '../core-index.js';
|
|
3
3
|
import { processEnrollmentService } from './processEnrollment.js';
|
|
4
4
|
import { Modules } from '../modules.js';
|
|
5
|
+
import { addMessageService } from './addMessage.js';
|
|
5
6
|
|
|
6
7
|
export async function initializeEnrollmentService(
|
|
7
8
|
this: Modules,
|
|
8
9
|
enrollment: Enrollment,
|
|
9
10
|
params: { orderIdForFirstPeriod?: string; reason: string },
|
|
10
11
|
) {
|
|
11
|
-
const
|
|
12
|
+
const product = await this.products.findProduct({
|
|
13
|
+
productId: enrollment.productId,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const director = await EnrollmentDirector.actions(
|
|
17
|
+
{ enrollment, product: product! },
|
|
18
|
+
{ modules: this },
|
|
19
|
+
);
|
|
12
20
|
const period = await director.nextPeriod();
|
|
13
21
|
|
|
14
22
|
let updatedEnrollment = enrollment;
|
|
15
23
|
if (period && (params.orderIdForFirstPeriod || period.isTrial)) {
|
|
16
|
-
updatedEnrollment = await this.enrollments.addEnrollmentPeriod(enrollment._id, {
|
|
24
|
+
updatedEnrollment = (await this.enrollments.addEnrollmentPeriod(enrollment._id, {
|
|
17
25
|
...period,
|
|
18
26
|
orderId: params.orderIdForFirstPeriod,
|
|
19
|
-
});
|
|
27
|
+
})) as Enrollment;
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
const processedEnrollment = await processEnrollmentService.bind(this)(updatedEnrollment);
|
|
23
31
|
const user = await this.users.findUserById(enrollment.userId);
|
|
24
|
-
const locale = this.users.userLocale(user);
|
|
32
|
+
const locale = this.users.userLocale(user!);
|
|
25
33
|
|
|
26
|
-
await
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
reason: params.reason || 'status_change',
|
|
31
|
-
locale: locale.baseName,
|
|
32
|
-
template: 'ENROLLMENT_STATUS',
|
|
33
|
-
enrollmentId: processedEnrollment._id,
|
|
34
|
-
},
|
|
34
|
+
await addMessageService.bind(this)('ENROLLMENT_STATUS', {
|
|
35
|
+
reason: 'status_change',
|
|
36
|
+
locale: locale.baseName,
|
|
37
|
+
enrollmentId: processedEnrollment._id,
|
|
35
38
|
});
|
|
36
39
|
|
|
37
40
|
return processedEnrollment;
|
|
@@ -6,11 +6,13 @@ export async function linkFileService(
|
|
|
6
6
|
{ fileId, size, type }: { fileId: string; size?: number; type?: string },
|
|
7
7
|
) {
|
|
8
8
|
const file = await this.files.findFile({ fileId });
|
|
9
|
+
if (!file) return null;
|
|
10
|
+
|
|
9
11
|
await this.files.update(file._id, {
|
|
10
12
|
size: size || file.size,
|
|
11
13
|
type: type || file.type,
|
|
12
|
-
expires: null,
|
|
13
14
|
});
|
|
15
|
+
await this.files.unexpire(file._id);
|
|
14
16
|
if (file?.expires) {
|
|
15
17
|
const callback = FileDirector.getFileUploadCallback(file.path);
|
|
16
18
|
if (callback) {
|
|
@@ -30,7 +30,7 @@ export async function nextUserCartService(
|
|
|
30
30
|
|
|
31
31
|
const countryObject = await this.countries.findCountry({ isoCode: countryCode });
|
|
32
32
|
const currencies = await this.currencies.findCurrencies({ includeInactive: false });
|
|
33
|
-
const currencyCode = resolveBestCurrency(countryObject
|
|
33
|
+
const currencyCode = resolveBestCurrency(countryObject?.defaultCurrencyCode || null, currencies);
|
|
34
34
|
|
|
35
35
|
const order = await this.orders.create({
|
|
36
36
|
userId: user._id,
|
|
@@ -2,9 +2,18 @@ import { Enrollment, EnrollmentStatus } from '@unchainedshop/core-enrollments';
|
|
|
2
2
|
import { Modules } from '../modules.js';
|
|
3
3
|
import { EnrollmentDirector } from '../core-index.js';
|
|
4
4
|
|
|
5
|
-
const findNextStatus = async (
|
|
5
|
+
const findNextStatus = async (
|
|
6
|
+
enrollment: Enrollment,
|
|
7
|
+
modules: Modules,
|
|
8
|
+
): Promise<EnrollmentStatus | null> => {
|
|
6
9
|
let status = enrollment.status;
|
|
7
|
-
const
|
|
10
|
+
const product = await modules.products.findProduct({
|
|
11
|
+
productId: enrollment.productId,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
if (!product) throw new Error('Product not found for enrollment');
|
|
15
|
+
|
|
16
|
+
const director = await EnrollmentDirector.actions({ enrollment, product }, { modules });
|
|
8
17
|
|
|
9
18
|
if (status === EnrollmentStatus.INITIAL || status === EnrollmentStatus.PAUSED) {
|
|
10
19
|
if (await director.isValidForActivation()) {
|
|
@@ -30,8 +39,11 @@ export async function processEnrollmentService(this: Modules, enrollment: Enroll
|
|
|
30
39
|
// status = await findNextStatus(nextEnrollment, unchainedAPI);
|
|
31
40
|
}
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
if (status) {
|
|
43
|
+
return this.enrollments.updateStatus(enrollment._id, {
|
|
44
|
+
status,
|
|
45
|
+
info: 'enrollment processed',
|
|
46
|
+
}) as Promise<Enrollment>;
|
|
47
|
+
}
|
|
48
|
+
return enrollment;
|
|
37
49
|
}
|
|
@@ -4,11 +4,12 @@ import {
|
|
|
4
4
|
OrderDeliveryStatus,
|
|
5
5
|
OrderPayment,
|
|
6
6
|
OrderPaymentStatus,
|
|
7
|
+
OrderPosition,
|
|
7
8
|
OrderStatus,
|
|
8
9
|
} from '@unchainedshop/core-orders';
|
|
9
10
|
import { Modules } from '../modules.js';
|
|
10
11
|
import { createEnrollmentFromCheckoutService } from './createEnrollmentFromCheckout.js';
|
|
11
|
-
import { ProductTypes } from '@unchainedshop/core-products';
|
|
12
|
+
import { Product, ProductTypes } from '@unchainedshop/core-products';
|
|
12
13
|
import { WarehousingProviderType } from '@unchainedshop/core-warehousing';
|
|
13
14
|
import { WarehousingDirector, DeliveryDirector, PaymentDirector } from '../directors/index.js';
|
|
14
15
|
import { fullfillQuotationService } from './fullfillQuotation.js';
|
|
@@ -24,10 +25,12 @@ const isAutoConfirmationEnabled = async (
|
|
|
24
25
|
modules: Modules,
|
|
25
26
|
) => {
|
|
26
27
|
if (orderPayment.status !== OrderPaymentStatus.PAID) {
|
|
27
|
-
const
|
|
28
|
+
const paymentProvider = await modules.payment.paymentProviders.findProvider({
|
|
28
29
|
paymentProviderId: orderPayment.paymentProviderId,
|
|
29
30
|
});
|
|
30
|
-
|
|
31
|
+
if (!paymentProvider)
|
|
32
|
+
throw new Error('Payment provider not found: ' + orderPayment.paymentProviderId);
|
|
33
|
+
const actions = await PaymentDirector.actions(paymentProvider, {}, { modules });
|
|
31
34
|
if (!actions.isPayLaterAllowed()) return false;
|
|
32
35
|
}
|
|
33
36
|
|
|
@@ -35,6 +38,8 @@ const isAutoConfirmationEnabled = async (
|
|
|
35
38
|
const deliveryProvider = await modules.delivery.findProvider({
|
|
36
39
|
deliveryProviderId: orderDelivery.deliveryProviderId,
|
|
37
40
|
});
|
|
41
|
+
if (!deliveryProvider)
|
|
42
|
+
throw new Error('Delivery provider not found: ' + orderDelivery.deliveryProviderId);
|
|
38
43
|
const director = await DeliveryDirector.actions(deliveryProvider, {}, { modules });
|
|
39
44
|
if (!director.isAutoReleaseAllowed()) return false;
|
|
40
45
|
}
|
|
@@ -56,14 +61,18 @@ const findNextStatus = async (
|
|
|
56
61
|
return status;
|
|
57
62
|
}
|
|
58
63
|
|
|
59
|
-
const orderPayment =
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
const orderPayment =
|
|
65
|
+
order.paymentId &&
|
|
66
|
+
(await modules.orders.payments.findOrderPayment({
|
|
67
|
+
orderPaymentId: order.paymentId,
|
|
68
|
+
}));
|
|
62
69
|
if (!orderPayment) return status;
|
|
63
70
|
|
|
64
|
-
const orderDelivery =
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
const orderDelivery =
|
|
72
|
+
order.deliveryId &&
|
|
73
|
+
(await modules.orders.deliveries.findDelivery({
|
|
74
|
+
orderDeliveryId: order.deliveryId,
|
|
75
|
+
}));
|
|
67
76
|
if (!orderDelivery) return status;
|
|
68
77
|
|
|
69
78
|
// Ok, we have a payment and a delivery and the correct status,
|
|
@@ -108,26 +117,18 @@ export async function processOrderService(
|
|
|
108
117
|
|
|
109
118
|
if (nextStatus === OrderStatus.PENDING) {
|
|
110
119
|
// auto charge during transition to pending
|
|
111
|
-
const orderPayment = await this.orders.payments.findOrderPayment({
|
|
112
|
-
orderPaymentId: order.paymentId,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
120
|
await PaymentDirector.chargeOrderPayment(
|
|
116
|
-
|
|
121
|
+
order,
|
|
117
122
|
{ userId: order.userId, transactionContext: paymentContext },
|
|
118
123
|
{ modules: this },
|
|
119
124
|
);
|
|
120
|
-
|
|
121
125
|
nextStatus = await findNextStatus(nextStatus, order, this);
|
|
122
126
|
}
|
|
123
127
|
|
|
124
128
|
if (nextStatus === OrderStatus.REJECTED) {
|
|
125
129
|
// auto cancel during transition to rejected
|
|
126
|
-
const orderPayment = await this.orders.payments.findOrderPayment({
|
|
127
|
-
orderPaymentId: order.paymentId,
|
|
128
|
-
});
|
|
129
130
|
await PaymentDirector.cancelOrderPayment(
|
|
130
|
-
|
|
131
|
+
order,
|
|
131
132
|
{ userId: order.userId, transactionContext: paymentContext },
|
|
132
133
|
{ modules: this },
|
|
133
134
|
);
|
|
@@ -135,11 +136,8 @@ export async function processOrderService(
|
|
|
135
136
|
|
|
136
137
|
if (nextStatus === OrderStatus.CONFIRMED) {
|
|
137
138
|
// confirm pre-authorized payments
|
|
138
|
-
const orderPayment = await this.orders.payments.findOrderPayment({
|
|
139
|
-
orderPaymentId: order.paymentId,
|
|
140
|
-
});
|
|
141
139
|
await PaymentDirector.confirmOrderPayment(
|
|
142
|
-
|
|
140
|
+
order,
|
|
143
141
|
{ userId: order.userId, transactionContext: paymentContext },
|
|
144
142
|
{ modules: this },
|
|
145
143
|
);
|
|
@@ -147,27 +145,23 @@ export async function processOrderService(
|
|
|
147
145
|
// we have to stop here shortly to complete the confirmation
|
|
148
146
|
// before auto delivery is started, else we have no chance to create
|
|
149
147
|
// numbers that are needed for delivery
|
|
150
|
-
order = await this.orders.updateStatus(orderId, {
|
|
148
|
+
order = (await this.orders.updateStatus(orderId, {
|
|
151
149
|
status: OrderStatus.CONFIRMED,
|
|
152
150
|
info: comment,
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
const orderDelivery = await this.orders.deliveries.findDelivery({
|
|
156
|
-
orderDeliveryId: order.deliveryId,
|
|
157
|
-
});
|
|
151
|
+
})) as Order;
|
|
158
152
|
|
|
159
153
|
// TODO: What happens if this THROWS?
|
|
160
154
|
// Tokenization would be skipped?
|
|
161
155
|
// Enrollments will not be there?
|
|
162
156
|
// Quotations would not fulfil?
|
|
163
|
-
await DeliveryDirector.sendOrderDelivery(
|
|
157
|
+
await DeliveryDirector.sendOrderDelivery(order, deliveryContext, { modules: this });
|
|
164
158
|
|
|
165
159
|
const orderPositions = await this.orders.positions.findOrderPositions({ orderId });
|
|
166
160
|
const mappedProductOrderPositions = await Promise.all(
|
|
167
161
|
orderPositions.map(async (orderPosition) => {
|
|
168
|
-
const product = await this.products.findProduct({
|
|
162
|
+
const product = (await this.products.findProduct({
|
|
169
163
|
productId: orderPosition.productId,
|
|
170
|
-
});
|
|
164
|
+
})) as Product;
|
|
171
165
|
return {
|
|
172
166
|
orderPosition,
|
|
173
167
|
product,
|
|
@@ -176,7 +170,8 @@ export async function processOrderService(
|
|
|
176
170
|
);
|
|
177
171
|
const tokenizedItems = mappedProductOrderPositions.filter(
|
|
178
172
|
(item) => item.product?.type === ProductTypes.TokenizedProduct,
|
|
179
|
-
);
|
|
173
|
+
) as { orderPosition: OrderPosition; product: Product }[];
|
|
174
|
+
|
|
180
175
|
if (tokenizedItems.length > 0) {
|
|
181
176
|
// Give virtual warehouse a chance to instantiate new virtual objects
|
|
182
177
|
const virtualProviders = (await this.warehousing.allProviders()).filter(
|
|
@@ -184,7 +179,7 @@ export async function processOrderService(
|
|
|
184
179
|
);
|
|
185
180
|
|
|
186
181
|
// It's very important to do this in a series and not in Promise.all
|
|
187
|
-
// TODO: Actually, only createTokens should decide on the unique
|
|
182
|
+
// TODO: Actually, only createTokens should decide on the unique tokenSerialNumber
|
|
188
183
|
// and the tokens should be created with a distributed Lock to not assign the same id multiple times!
|
|
189
184
|
for (const { orderPosition, product } of tokenizedItems) {
|
|
190
185
|
for (const virtualProvider of virtualProviders) {
|
|
@@ -225,12 +220,14 @@ export async function processOrderService(
|
|
|
225
220
|
// Quotations: If we came here, the checkout succeeded, so we can fullfill underlying quotations
|
|
226
221
|
const quotationItems = mappedProductOrderPositions.filter(
|
|
227
222
|
(item) => item.orderPosition.quotationId,
|
|
228
|
-
);
|
|
223
|
+
) as { orderPosition: OrderPosition & { quotationId: string }; product: Product }[];
|
|
224
|
+
|
|
229
225
|
await Promise.all(
|
|
230
226
|
quotationItems.map(async ({ orderPosition }) => {
|
|
231
227
|
const quotation = await this.quotations.findQuotation({
|
|
232
228
|
quotationId: orderPosition.quotationId,
|
|
233
229
|
});
|
|
230
|
+
if (!quotation) return; // TODO: What happens then?
|
|
234
231
|
await fullfillQuotationService.bind(this)(quotation, {
|
|
235
232
|
orderId,
|
|
236
233
|
orderPositionId: orderPosition._id,
|
|
@@ -242,5 +239,5 @@ export async function processOrderService(
|
|
|
242
239
|
nextStatus = await findNextStatus(nextStatus, order, this);
|
|
243
240
|
}
|
|
244
241
|
|
|
245
|
-
return this.orders.updateStatus(order._id, { status: nextStatus, info: comment });
|
|
242
|
+
return (await this.orders.updateStatus(order._id, { status: nextStatus, info: comment })) as Order;
|
|
246
243
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Quotation, QuotationStatus } from '@unchainedshop/core-quotations';
|
|
2
2
|
import { Modules } from '../modules.js';
|
|
3
3
|
import { QuotationDirector } from '../core-index.js';
|
|
4
|
+
import { addMessageService } from './addMessage.js';
|
|
4
5
|
|
|
5
6
|
const findNextStatus = async (quotation: Quotation, modules: Modules): Promise<QuotationStatus> => {
|
|
6
7
|
let status = quotation.status as QuotationStatus;
|
|
@@ -33,42 +34,37 @@ export async function processQuotationService(
|
|
|
33
34
|
await director.submitRequest(params.quotationContext);
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
quotation = await this.quotations.findQuotation({ quotationId });
|
|
37
|
+
quotation = (await this.quotations.findQuotation({ quotationId })) as Quotation;
|
|
37
38
|
nextStatus = await findNextStatus(quotation, this);
|
|
38
39
|
if (nextStatus !== QuotationStatus.PROCESSING) {
|
|
39
40
|
await director.verifyRequest(params.quotationContext);
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
quotation = await this.quotations.findQuotation({ quotationId });
|
|
43
|
+
quotation = (await this.quotations.findQuotation({ quotationId })) as Quotation;
|
|
43
44
|
nextStatus = await findNextStatus(quotation, this);
|
|
44
45
|
if (nextStatus === QuotationStatus.REJECTED) {
|
|
45
46
|
await director.rejectRequest(params.quotationContext);
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
quotation = await this.quotations.findQuotation({ quotationId });
|
|
49
|
+
quotation = (await this.quotations.findQuotation({ quotationId })) as Quotation;
|
|
49
50
|
nextStatus = await findNextStatus(quotation, this);
|
|
50
51
|
if (nextStatus === QuotationStatus.PROPOSED) {
|
|
51
52
|
const proposal = await director.quote();
|
|
52
|
-
quotation = await this.quotations.updateProposal(quotation._id, proposal);
|
|
53
|
+
quotation = (await this.quotations.updateProposal(quotation._id, proposal)) as Quotation;
|
|
53
54
|
nextStatus = await findNextStatus(quotation, this);
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
const updatedQuotation = await this.quotations.updateStatus(quotation._id, {
|
|
57
|
+
const updatedQuotation = (await this.quotations.updateStatus(quotation._id, {
|
|
57
58
|
status: nextStatus,
|
|
58
59
|
info: 'quotation processed',
|
|
59
|
-
});
|
|
60
|
+
})) as Quotation;
|
|
60
61
|
|
|
61
62
|
const user = await this.users.findUserById(updatedQuotation.userId);
|
|
62
63
|
const locale = this.users.userLocale(user);
|
|
63
64
|
|
|
64
|
-
await
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
input: {
|
|
68
|
-
locale: locale.baseName,
|
|
69
|
-
template: 'QUOTATION_STATUS',
|
|
70
|
-
quotationId: updatedQuotation._id,
|
|
71
|
-
},
|
|
65
|
+
await addMessageService.bind(this)('QUOTATION_STATUS', {
|
|
66
|
+
locale: locale.baseName,
|
|
67
|
+
quotationId: updatedQuotation._id,
|
|
72
68
|
});
|
|
73
69
|
|
|
74
70
|
return updatedQuotation;
|
|
@@ -9,10 +9,10 @@ export async function proposeQuotationService(
|
|
|
9
9
|
) {
|
|
10
10
|
if (quotation.status !== QuotationStatus.PROCESSING) return quotation;
|
|
11
11
|
|
|
12
|
-
const updatedQuotation = await this.quotations.updateStatus(quotation._id, {
|
|
12
|
+
const updatedQuotation = (await this.quotations.updateStatus(quotation._id, {
|
|
13
13
|
status: QuotationStatus.PROPOSED,
|
|
14
14
|
info: 'proposed manually',
|
|
15
|
-
});
|
|
15
|
+
})) as Quotation;
|
|
16
16
|
|
|
17
17
|
return processQuotationService.bind(this)(updatedQuotation, { quotationContext });
|
|
18
18
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PaymentCredentials } from '@unchainedshop/core-payment';
|
|
2
1
|
import { PaymentContext } from '../directors/PaymentAdapter.js';
|
|
3
2
|
import { PaymentDirector } from '../directors/PaymentDirector.js';
|
|
4
3
|
import { Modules } from '../modules.js';
|
|
@@ -7,24 +6,23 @@ export async function registerPaymentCredentialsService(
|
|
|
7
6
|
this: Modules,
|
|
8
7
|
paymentProviderId: string,
|
|
9
8
|
paymentContext: PaymentContext,
|
|
10
|
-
)
|
|
9
|
+
) {
|
|
11
10
|
const paymentProvider = await this.payment.paymentProviders.findProvider({
|
|
12
11
|
paymentProviderId,
|
|
13
12
|
});
|
|
13
|
+
|
|
14
|
+
if (!paymentProvider) return null;
|
|
15
|
+
|
|
14
16
|
const actions = await PaymentDirector.actions(paymentProvider, paymentContext, { modules: this });
|
|
15
17
|
const registration = await actions.register();
|
|
16
18
|
|
|
17
19
|
if (!registration) return null;
|
|
18
20
|
|
|
19
|
-
const
|
|
21
|
+
const paymentCredentials = await this.payment.paymentCredentials.upsertCredentials({
|
|
20
22
|
userId: paymentContext.userId,
|
|
21
23
|
paymentProviderId,
|
|
22
24
|
...registration,
|
|
23
25
|
});
|
|
24
26
|
|
|
25
|
-
return
|
|
26
|
-
paymentCredentialsId,
|
|
27
|
-
userId: paymentContext.userId,
|
|
28
|
-
paymentProviderId,
|
|
29
|
-
});
|
|
27
|
+
return paymentCredentials;
|
|
30
28
|
}
|
|
@@ -9,10 +9,10 @@ export async function rejectQuotationService(
|
|
|
9
9
|
) {
|
|
10
10
|
if (quotation.status === QuotationStatus.FULLFILLED) return quotation;
|
|
11
11
|
|
|
12
|
-
const updatedQuotation = await this.quotations.updateStatus(quotation._id, {
|
|
12
|
+
const updatedQuotation = (await this.quotations.updateStatus(quotation._id, {
|
|
13
13
|
status: QuotationStatus.REJECTED,
|
|
14
14
|
info: 'rejected manually',
|
|
15
|
-
});
|
|
15
|
+
})) as Quotation;
|
|
16
16
|
|
|
17
17
|
return processQuotationService.bind(this)(updatedQuotation, { quotationContext });
|
|
18
18
|
}
|
|
@@ -13,8 +13,8 @@ export async function removeFilesService(this: Modules, { fileIds }: { fileIds:
|
|
|
13
13
|
|
|
14
14
|
try {
|
|
15
15
|
await fileUploadAdapter.removeFiles(fileObjects, { modules: this });
|
|
16
|
-
} catch
|
|
17
|
-
|
|
16
|
+
} catch {
|
|
17
|
+
/**/
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const fileIdsToDelete = fileObjects.map((f) => f._id).filter(Boolean);
|
|
@@ -8,7 +8,7 @@ export async function removeProductService(
|
|
|
8
8
|
): Promise<boolean> {
|
|
9
9
|
const product = await this.products.findProduct({ productId });
|
|
10
10
|
|
|
11
|
-
switch (product
|
|
11
|
+
switch (product?.status) {
|
|
12
12
|
case ProductStatus.ACTIVE:
|
|
13
13
|
await this.products.unpublish(product);
|
|
14
14
|
// falls through
|
|
@@ -16,7 +16,7 @@ export async function removeProductService(
|
|
|
16
16
|
case ProductStatus.DRAFT:
|
|
17
17
|
{
|
|
18
18
|
await this.bookmarks.deleteByProductId(productId);
|
|
19
|
-
await this.assortments.products.
|
|
19
|
+
await this.assortments.products.deleteMany({ productId });
|
|
20
20
|
await this.products.removeAllAssignmentsAndBundleItems(productId);
|
|
21
21
|
const orderIdsToRecalculate =
|
|
22
22
|
await this.orders.positions.removeProductByIdFromAllOpenPositions(productId);
|
|
@@ -29,7 +29,7 @@ export async function removeProductService(
|
|
|
29
29
|
}
|
|
30
30
|
break;
|
|
31
31
|
default:
|
|
32
|
-
throw new Error(`Invalid status
|
|
32
|
+
throw new Error(`Invalid status: ${product?.status}`);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
return true;
|