@unchainedshop/core 4.0.0-rc.9 → 4.0.1
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/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/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 +9 -6
- package/lib/core-index.d.ts.map +1 -1
- package/lib/core-index.js +5 -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 +7 -8
- package/lib/directors/FilterDirector.js.map +1 -1
- package/lib/directors/MessagingDirector.d.ts +2 -2
- package/lib/directors/MessagingDirector.d.ts.map +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 +5 -5
- 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/factory/index.d.ts +3 -0
- package/lib/factory/index.d.ts.map +1 -0
- package/lib/factory/index.js +3 -0
- package/lib/factory/index.js.map +1 -0
- package/lib/factory/registerProductDiscoverabilityFilter.d.ts +5 -0
- package/lib/factory/registerProductDiscoverabilityFilter.d.ts.map +1 -0
- package/lib/factory/registerProductDiscoverabilityFilter.js +27 -0
- package/lib/factory/registerProductDiscoverabilityFilter.js.map +1 -0
- package/lib/modules.d.ts +4 -5
- package/lib/modules.d.ts.map +1 -1
- package/lib/modules.js +3 -3
- 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 +10 -4
- 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.d.ts.map +1 -1
- package/lib/services/initCartProviders.js +6 -2
- 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 +30 -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.d.ts.map +1 -1
- package/lib/services/searchAssortments.js +3 -2
- package/lib/services/searchAssortments.js.map +1 -1
- package/lib/services/searchProducts.d.ts.map +1 -1
- package/lib/services/searchProducts.js +3 -2
- 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 +20 -12
- 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 +10 -7
- 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 +11 -12
- package/src/directors/MessagingDirector.ts +1 -1
- 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 +9 -9
- 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/factory/index.ts +3 -0
- package/src/factory/registerProductDiscoverabilityFilter.ts +36 -0
- package/src/modules.ts +6 -7
- 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 +10 -5
- 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 +8 -10
- 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 +37 -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 +3 -2
- package/src/services/searchProducts.ts +4 -2
- 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 +37 -20
- 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/src/modules.ts
CHANGED
|
@@ -69,17 +69,17 @@ export interface ModuleOptions {
|
|
|
69
69
|
assortments?: AssortmentsSettingsOptions;
|
|
70
70
|
products?: ProductsSettingsOptions;
|
|
71
71
|
delivery?: DeliverySettingsOptions;
|
|
72
|
+
payment?: PaymentSettingsOptions;
|
|
72
73
|
filters?: FiltersSettingsOptions;
|
|
73
74
|
enrollments?: EnrollmentsSettingsOptions;
|
|
74
75
|
orders?: OrdersSettingsOptions;
|
|
75
76
|
quotations?: QuotationsSettingsOptions;
|
|
76
77
|
files?: FilesSettingsOptions;
|
|
77
|
-
payment?: PaymentSettingsOptions;
|
|
78
78
|
worker?: WorkerSettingsOptions;
|
|
79
79
|
users?: UserSettingsOptions;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
export default async function initModules(
|
|
83
83
|
{
|
|
84
84
|
db,
|
|
85
85
|
migrationRepository,
|
|
@@ -87,7 +87,7 @@ const initModules = async (
|
|
|
87
87
|
}: {
|
|
88
88
|
db: mongodb.Db;
|
|
89
89
|
migrationRepository: MigrationRepository<unknown>;
|
|
90
|
-
options
|
|
90
|
+
options: ModuleOptions;
|
|
91
91
|
},
|
|
92
92
|
customModules: Record<
|
|
93
93
|
string,
|
|
@@ -95,7 +95,7 @@ const initModules = async (
|
|
|
95
95
|
configure: (params: ModuleInput<any>) => any;
|
|
96
96
|
}
|
|
97
97
|
>,
|
|
98
|
-
): Promise<Modules>
|
|
98
|
+
): Promise<Modules> {
|
|
99
99
|
const assortments = await configureAssortmentsModule({
|
|
100
100
|
db,
|
|
101
101
|
options: options.assortments,
|
|
@@ -154,6 +154,7 @@ const initModules = async (
|
|
|
154
154
|
const products = await configureProductsModule({
|
|
155
155
|
db,
|
|
156
156
|
migrationRepository,
|
|
157
|
+
options: options.products,
|
|
157
158
|
});
|
|
158
159
|
const quotations = await configureQuotationsModule({
|
|
159
160
|
db,
|
|
@@ -203,6 +204,4 @@ const initModules = async (
|
|
|
203
204
|
}
|
|
204
205
|
|
|
205
206
|
return modules;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export default initModules;
|
|
207
|
+
}
|
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
import { Enrollment, EnrollmentStatus } from '@unchainedshop/core-enrollments';
|
|
2
2
|
import { Modules } from '../modules.js';
|
|
3
3
|
import { processEnrollmentService } from './processEnrollment.js';
|
|
4
|
+
import { addMessageService } from './addMessage.js';
|
|
4
5
|
|
|
5
6
|
export async function activateEnrollmentService(this: Modules, enrollment: Enrollment) {
|
|
6
7
|
if (enrollment.status === EnrollmentStatus.TERMINATED) return enrollment;
|
|
7
8
|
|
|
8
|
-
let updatedEnrollment = await this.enrollments.updateStatus(enrollment._id, {
|
|
9
|
+
let updatedEnrollment = (await this.enrollments.updateStatus(enrollment._id, {
|
|
9
10
|
status: EnrollmentStatus.ACTIVE,
|
|
10
11
|
info: 'activated manually',
|
|
11
|
-
});
|
|
12
|
+
})) as Enrollment;
|
|
12
13
|
|
|
13
|
-
updatedEnrollment = await processEnrollmentService.bind(this)(updatedEnrollment);
|
|
14
|
+
updatedEnrollment = (await processEnrollmentService.bind(this)(updatedEnrollment)) as Enrollment;
|
|
14
15
|
|
|
15
16
|
const user = await this.users.findUserById(enrollment.userId);
|
|
16
17
|
const locale = this.users.userLocale(user);
|
|
17
18
|
|
|
18
|
-
await
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
reason: 'status_change',
|
|
23
|
-
locale: locale.baseName,
|
|
24
|
-
template: 'ENROLLMENT_STATUS',
|
|
25
|
-
enrollmentId: updatedEnrollment._id,
|
|
26
|
-
},
|
|
19
|
+
await addMessageService.bind(this)('ENROLLMENT_STATUS', {
|
|
20
|
+
reason: 'status_change',
|
|
21
|
+
locale: locale.baseName,
|
|
22
|
+
enrollmentId: updatedEnrollment!._id,
|
|
27
23
|
});
|
|
28
24
|
|
|
29
|
-
return updatedEnrollment
|
|
25
|
+
return updatedEnrollment!;
|
|
30
26
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Work } from '@unchainedshop/core-worker';
|
|
2
|
+
import { MessagingDirector } from '../core-index.js';
|
|
3
|
+
import { Modules } from '../modules.js';
|
|
4
|
+
|
|
5
|
+
export async function addMessageService<T = Record<string, any>>(
|
|
6
|
+
this: Modules,
|
|
7
|
+
template: string,
|
|
8
|
+
input: T,
|
|
9
|
+
): Promise<Work | null> {
|
|
10
|
+
const templateResolver = MessagingDirector.getTemplate(template); // Validate template exists
|
|
11
|
+
if (!templateResolver) return null;
|
|
12
|
+
return this.worker.addWork({
|
|
13
|
+
type: 'MESSAGE',
|
|
14
|
+
input: {
|
|
15
|
+
template,
|
|
16
|
+
...input,
|
|
17
|
+
},
|
|
18
|
+
retries: 0,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -20,19 +20,19 @@ export async function calculateDiscountTotalService(
|
|
|
20
20
|
|
|
21
21
|
// Delivery discounts
|
|
22
22
|
const orderDelivery = await this.orders.deliveries.findDelivery({
|
|
23
|
-
orderDeliveryId: order.deliveryId
|
|
23
|
+
orderDeliveryId: order.deliveryId!,
|
|
24
24
|
});
|
|
25
25
|
const orderDeliveryDiscountSum = DeliveryPricingSheet({
|
|
26
|
-
calculation: orderDelivery
|
|
26
|
+
calculation: orderDelivery?.calculation || [],
|
|
27
27
|
currencyCode: order.currencyCode,
|
|
28
28
|
}).total({ category: DeliveryPricingRowCategory.Discount, discountId: orderDiscountId });
|
|
29
29
|
|
|
30
30
|
// Payment discounts
|
|
31
31
|
const orderPayment = await this.orders.payments.findOrderPayment({
|
|
32
|
-
orderPaymentId: order.paymentId
|
|
32
|
+
orderPaymentId: order.paymentId!,
|
|
33
33
|
});
|
|
34
34
|
const orderPaymentDiscountSum = PaymentPricingSheet({
|
|
35
|
-
calculation: orderPayment
|
|
35
|
+
calculation: orderPayment?.calculation || [],
|
|
36
36
|
currencyCode: order.currencyCode,
|
|
37
37
|
}).total({ category: PaymentPricingRowCategory.Discount, discountId: orderDiscountId });
|
|
38
38
|
|
|
@@ -3,6 +3,7 @@ import { Modules } from '../modules.js';
|
|
|
3
3
|
import { nextUserCartService } from './nextUserCart.js';
|
|
4
4
|
import { validateOrderService } from './validateOrder.js';
|
|
5
5
|
import { processOrderService } from './processOrder.js';
|
|
6
|
+
import { User } from '@unchainedshop/core-users';
|
|
6
7
|
|
|
7
8
|
export async function checkoutOrderService(
|
|
8
9
|
this: Modules,
|
|
@@ -15,6 +16,7 @@ export async function checkoutOrderService(
|
|
|
15
16
|
},
|
|
16
17
|
) {
|
|
17
18
|
const order = await this.orders.findOrder({ orderId });
|
|
19
|
+
if (!order) return null;
|
|
18
20
|
if (order.status !== null) return order;
|
|
19
21
|
|
|
20
22
|
await validateOrderService.bind(this)(order);
|
|
@@ -25,15 +27,18 @@ export async function checkoutOrderService(
|
|
|
25
27
|
const processedOrder = await processOrderService.bind(this)(order, transactionContext);
|
|
26
28
|
|
|
27
29
|
// After checkout, store last checkout information on user
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
if (processedOrder.billingAddress) {
|
|
31
|
+
await this.users.updateLastBillingAddress(processedOrder.userId, processedOrder.billingAddress);
|
|
32
|
+
}
|
|
33
|
+
if (processedOrder.contact) {
|
|
34
|
+
await this.users.updateLastContact(processedOrder.userId, processedOrder.contact);
|
|
35
|
+
}
|
|
31
36
|
// Then eventually build next cart
|
|
32
|
-
const user = await this.users.findUserById(processedOrder.userId);
|
|
37
|
+
const user = (await this.users.findUserById(processedOrder.userId)) as User;
|
|
33
38
|
const locale = this.users.userLocale(user);
|
|
34
39
|
await nextUserCartService.bind(this)({
|
|
35
40
|
user,
|
|
36
|
-
countryCode: locale.
|
|
41
|
+
countryCode: locale?.region || processedOrder.countryCode,
|
|
37
42
|
});
|
|
38
43
|
|
|
39
44
|
return processedOrder;
|
|
@@ -11,6 +11,7 @@ export async function createDownloadStreamService(
|
|
|
11
11
|
) {
|
|
12
12
|
const fileAdapter = getFileAdapter();
|
|
13
13
|
const file = await this.files.findFile({ fileId });
|
|
14
|
+
if (!file) return null;
|
|
14
15
|
const stream = fileAdapter.createDownloadStream(file, { modules: this });
|
|
15
16
|
return stream;
|
|
16
17
|
}
|
|
@@ -25,42 +25,44 @@ export async function createEnrollmentFromCheckoutService(
|
|
|
25
25
|
const orderId = order._id;
|
|
26
26
|
|
|
27
27
|
const payment = await this.orders.payments.findOrderPayment({
|
|
28
|
-
orderPaymentId: order.paymentId
|
|
28
|
+
orderPaymentId: order.paymentId!,
|
|
29
29
|
});
|
|
30
30
|
const delivery = await this.orders.deliveries.findDelivery({
|
|
31
|
-
orderDeliveryId: order.deliveryId
|
|
31
|
+
orderDeliveryId: order.deliveryId!,
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
const template = {
|
|
35
|
-
billingAddress: order.billingAddress
|
|
36
|
-
contact: order.contact
|
|
35
|
+
billingAddress: order.billingAddress!,
|
|
36
|
+
contact: order.contact!,
|
|
37
37
|
countryCode: order.countryCode,
|
|
38
38
|
currencyCode: order.currencyCode,
|
|
39
39
|
delivery: {
|
|
40
|
-
deliveryProviderId: delivery
|
|
41
|
-
context: delivery
|
|
40
|
+
deliveryProviderId: delivery!.deliveryProviderId,
|
|
41
|
+
context: delivery!.context,
|
|
42
42
|
},
|
|
43
43
|
orderIdForFirstPeriod: orderId,
|
|
44
44
|
payment: {
|
|
45
|
-
paymentProviderId: payment
|
|
46
|
-
context: payment
|
|
45
|
+
paymentProviderId: payment!.paymentProviderId,
|
|
46
|
+
context: payment!.context,
|
|
47
47
|
},
|
|
48
48
|
userId: order.userId,
|
|
49
49
|
meta: order.context,
|
|
50
50
|
...context,
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
return (
|
|
54
|
+
await Promise.all(
|
|
55
|
+
items.map(async (item) => {
|
|
56
|
+
const enrollmentData = await EnrollmentDirector.transformOrderItemToEnrollment(item, template, {
|
|
57
|
+
modules: this,
|
|
58
|
+
});
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
const enrollment = await this.enrollments.create(enrollmentData);
|
|
61
|
+
return await initializeEnrollmentService.bind(this)(enrollment, {
|
|
62
|
+
orderIdForFirstPeriod: enrollment.orderIdForFirstPeriod,
|
|
63
|
+
reason: 'new_enrollment',
|
|
64
|
+
});
|
|
65
|
+
}),
|
|
66
|
+
)
|
|
67
|
+
).filter(Boolean) as Enrollment[];
|
|
66
68
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Order
|
|
1
|
+
import { Order } from '@unchainedshop/core-orders';
|
|
2
2
|
import { OrderDiscountDirector } from '../directors/OrderDiscountDirector.js';
|
|
3
3
|
import { Modules } from '../modules.js';
|
|
4
4
|
|
|
5
5
|
export async function createManualOrderDiscountService(
|
|
6
6
|
this: Modules,
|
|
7
7
|
{ order, code }: { code: string; order: Order },
|
|
8
|
-
)
|
|
8
|
+
) {
|
|
9
9
|
// Use an already existing discount if available!
|
|
10
10
|
const spareDiscount = await this.orders.discounts.findSpareDiscount({ code });
|
|
11
11
|
if (spareDiscount) {
|
|
@@ -9,6 +9,7 @@ export async function createSignedURLService(
|
|
|
9
9
|
const preparedFileData = await fileUploadAdapter.createSignedURL(directoryName, fileName, {
|
|
10
10
|
modules: this,
|
|
11
11
|
});
|
|
12
|
+
if (!preparedFileData) throw new Error('Could not prepare signed URL');
|
|
12
13
|
const fileData = getFileFromFileData(preparedFileData, meta);
|
|
13
14
|
const fileId = await this.files.create(fileData);
|
|
14
15
|
const file = await this.files.findFile({ fileId });
|
|
@@ -9,9 +9,14 @@ export async function deleteUserService(this: Modules, { userId }: { userId: str
|
|
|
9
9
|
await this.quotations.deleteRequestedUserQuotations(userId);
|
|
10
10
|
await this.enrollments.deleteInactiveUserEnrollments(userId);
|
|
11
11
|
await this.payment.paymentCredentials.deleteUserPaymentCredentials(userId);
|
|
12
|
-
await this.users.webAuthn.deleteUserWebAuthnCredentials(user.username);
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
if (user.username) {
|
|
14
|
+
await this.users.webAuthn.deleteUserWebAuthnCredentials(user.username);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const carts = (await this.orders.findOrders({ userId, includeCarts: true })).filter(
|
|
18
|
+
(c) => c.status === null,
|
|
19
|
+
);
|
|
15
20
|
|
|
16
21
|
await Array.fromAsync(carts, async (userCart) => {
|
|
17
22
|
await this.orders.positions.deleteOrderPositions(userCart?._id);
|
|
@@ -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
|
|
|
@@ -33,10 +33,9 @@ export async function initCartProvidersService(this: Modules, order: Order) {
|
|
|
33
33
|
{ modules: this },
|
|
34
34
|
);
|
|
35
35
|
if (defaultOrderDeliveryProvider) {
|
|
36
|
-
updatedOrder =
|
|
37
|
-
updatedOrder._id,
|
|
38
|
-
|
|
39
|
-
);
|
|
36
|
+
updatedOrder =
|
|
37
|
+
(await this.orders.setDeliveryProvider(updatedOrder._id, defaultOrderDeliveryProvider._id)) ||
|
|
38
|
+
updatedOrder;
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
|
|
@@ -46,7 +45,7 @@ export async function initCartProvidersService(this: Modules, order: Order) {
|
|
|
46
45
|
});
|
|
47
46
|
|
|
48
47
|
const orderPayment = await this.orders.payments.findOrderPayment({
|
|
49
|
-
orderPaymentId: updatedOrder.paymentId
|
|
48
|
+
orderPaymentId: updatedOrder.paymentId!,
|
|
50
49
|
});
|
|
51
50
|
const paymentProviderId = orderPayment?.paymentProviderId;
|
|
52
51
|
|
|
@@ -76,10 +75,9 @@ export async function initCartProvidersService(this: Modules, order: Order) {
|
|
|
76
75
|
);
|
|
77
76
|
|
|
78
77
|
if (defaultOrderPaymentProvider) {
|
|
79
|
-
updatedOrder =
|
|
80
|
-
updatedOrder._id,
|
|
81
|
-
|
|
82
|
-
);
|
|
78
|
+
updatedOrder =
|
|
79
|
+
(await this.orders.setPaymentProvider(updatedOrder._id, defaultOrderPaymentProvider._id)) ||
|
|
80
|
+
updatedOrder;
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
83
|
return updatedOrder;
|
|
@@ -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
|
}
|