@unchainedshop/core 4.3.6 → 4.4.0
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/README.md +614 -2
- package/lib/bulk-importer/createBulkImporter.d.ts +5 -6
- package/lib/bulk-importer/createBulkImporter.js +6 -5
- package/lib/bulk-importer/handlers/assortment/create.d.ts +2 -3
- package/lib/bulk-importer/handlers/assortment/create.js +6 -8
- package/lib/bulk-importer/handlers/assortment/index.d.ts +3 -4
- package/lib/bulk-importer/handlers/assortment/index.js +3 -4
- package/lib/bulk-importer/handlers/assortment/remove.d.ts +1 -2
- package/lib/bulk-importer/handlers/assortment/remove.js +0 -1
- package/lib/bulk-importer/handlers/assortment/update.d.ts +2 -3
- package/lib/bulk-importer/handlers/assortment/update.js +7 -9
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts +1 -2
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js +1 -2
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts +1 -2
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js +1 -2
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts +1 -2
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js +1 -2
- package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts +2 -3
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js +2 -4
- package/lib/bulk-importer/handlers/filter/create.d.ts +7 -3
- package/lib/bulk-importer/handlers/filter/create.js +3 -4
- package/lib/bulk-importer/handlers/filter/index.d.ts +3 -4
- package/lib/bulk-importer/handlers/filter/index.js +3 -4
- package/lib/bulk-importer/handlers/filter/remove.d.ts +1 -2
- package/lib/bulk-importer/handlers/filter/remove.js +0 -1
- package/lib/bulk-importer/handlers/filter/update.d.ts +1 -2
- package/lib/bulk-importer/handlers/filter/update.js +2 -4
- package/lib/bulk-importer/handlers/product/create.d.ts +23 -6
- package/lib/bulk-importer/handlers/product/create.js +10 -12
- package/lib/bulk-importer/handlers/product/index.d.ts +3 -4
- package/lib/bulk-importer/handlers/product/index.js +3 -4
- package/lib/bulk-importer/handlers/product/remove.d.ts +2 -3
- package/lib/bulk-importer/handlers/product/remove.js +0 -1
- package/lib/bulk-importer/handlers/product/update.d.ts +2 -3
- package/lib/bulk-importer/handlers/product/update.js +8 -11
- package/lib/bulk-importer/handlers/product/upsertMedia.d.ts +2 -3
- package/lib/bulk-importer/handlers/product/upsertMedia.js +3 -5
- package/lib/bulk-importer/handlers/product/upsertVariations.d.ts +1 -2
- package/lib/bulk-importer/handlers/product/upsertVariations.js +2 -5
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts +0 -1
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js +0 -1
- package/lib/bulk-importer/index.d.ts +2 -3
- package/lib/bulk-importer/index.js +2 -3
- package/lib/bulk-importer/upsertAsset.d.ts +3 -4
- package/lib/bulk-importer/upsertAsset.js +1 -3
- package/lib/core-index.d.ts +9 -10
- package/lib/core-index.js +9 -10
- package/lib/directors/BaseDiscountAdapter.d.ts +5 -6
- package/lib/directors/BaseDiscountAdapter.js +0 -17
- package/lib/directors/BaseDiscountDirector.d.ts +3 -4
- package/lib/directors/BaseDiscountDirector.js +0 -1
- package/lib/directors/BasePricingAdapter.d.ts +4 -5
- package/lib/directors/BasePricingAdapter.js +1 -2
- package/lib/directors/BasePricingDirector.d.ts +4 -5
- package/lib/directors/BasePricingDirector.js +1 -6
- package/lib/directors/BasePricingSheet.d.ts +1 -2
- package/lib/directors/BasePricingSheet.js +0 -4
- package/lib/directors/BaseWorker.d.ts +1 -2
- package/lib/directors/BaseWorker.js +2 -5
- package/lib/directors/DeliveryAdapter.d.ts +8 -8
- package/lib/directors/DeliveryAdapter.js +6 -15
- package/lib/directors/DeliveryDirector.d.ts +5 -6
- package/lib/directors/DeliveryDirector.js +1 -2
- package/lib/directors/DeliveryPricingAdapter.d.ts +6 -7
- package/lib/directors/DeliveryPricingAdapter.js +2 -3
- package/lib/directors/DeliveryPricingDirector.d.ts +3 -4
- package/lib/directors/DeliveryPricingDirector.js +2 -2
- package/lib/directors/DeliveryPricingSheet.d.ts +9 -9
- package/lib/directors/DeliveryPricingSheet.js +7 -9
- package/lib/directors/EnrollmentAdapter.d.ts +2 -3
- package/lib/directors/EnrollmentAdapter.js +0 -1
- package/lib/directors/EnrollmentDirector.d.ts +3 -4
- package/lib/directors/EnrollmentDirector.js +0 -1
- package/lib/directors/EventListenerWorker.d.ts +1 -2
- package/lib/directors/EventListenerWorker.js +2 -11
- package/lib/directors/FailedRescheduler.d.ts +1 -2
- package/lib/directors/FailedRescheduler.js +0 -3
- package/lib/directors/FilterAdapter.d.ts +5 -6
- package/lib/directors/FilterAdapter.js +1 -5
- package/lib/directors/FilterDirector.d.ts +4 -5
- package/lib/directors/FilterDirector.js +1 -10
- package/lib/directors/IntervalWorker.d.ts +2 -3
- package/lib/directors/IntervalWorker.js +3 -5
- package/lib/directors/MessagingDirector.d.ts +0 -1
- package/lib/directors/MessagingDirector.js +0 -1
- package/lib/directors/OrderDiscountAdapter.d.ts +1 -2
- package/lib/directors/OrderDiscountAdapter.js +1 -2
- package/lib/directors/OrderDiscountConfiguration.d.ts +0 -1
- package/lib/directors/OrderDiscountConfiguration.js +0 -1
- package/lib/directors/OrderDiscountDirector.d.ts +2 -3
- package/lib/directors/OrderDiscountDirector.js +1 -2
- package/lib/directors/OrderPricingAdapter.d.ts +4 -5
- package/lib/directors/OrderPricingAdapter.js +1 -2
- package/lib/directors/OrderPricingDirector.d.ts +2 -3
- package/lib/directors/OrderPricingDirector.js +1 -2
- package/lib/directors/OrderPricingSheet.d.ts +10 -10
- package/lib/directors/OrderPricingSheet.js +8 -12
- package/lib/directors/PaymentAdapter.d.ts +8 -8
- package/lib/directors/PaymentAdapter.js +6 -12
- package/lib/directors/PaymentDirector.d.ts +4 -5
- package/lib/directors/PaymentDirector.js +1 -2
- package/lib/directors/PaymentPricingAdapter.d.ts +6 -7
- package/lib/directors/PaymentPricingAdapter.js +2 -3
- package/lib/directors/PaymentPricingDirector.d.ts +4 -5
- package/lib/directors/PaymentPricingDirector.js +2 -3
- package/lib/directors/PaymentPricingSheet.d.ts +8 -8
- package/lib/directors/PaymentPricingSheet.js +7 -9
- package/lib/directors/ProductDiscountAdapter.d.ts +1 -2
- package/lib/directors/ProductDiscountAdapter.js +1 -2
- package/lib/directors/ProductDiscountConfiguration.d.ts +1 -2
- package/lib/directors/ProductDiscountConfiguration.js +0 -1
- package/lib/directors/ProductDiscountDirector.d.ts +2 -3
- package/lib/directors/ProductDiscountDirector.js +1 -2
- package/lib/directors/ProductPricingAdapter.d.ts +5 -6
- package/lib/directors/ProductPricingAdapter.js +1 -2
- package/lib/directors/ProductPricingDirector.d.ts +4 -5
- package/lib/directors/ProductPricingDirector.js +1 -2
- package/lib/directors/ProductPricingSheet.d.ts +8 -8
- package/lib/directors/ProductPricingSheet.js +6 -8
- package/lib/directors/QuotationAdapter.d.ts +9 -9
- package/lib/directors/QuotationAdapter.js +6 -8
- package/lib/directors/QuotationDirector.d.ts +2 -3
- package/lib/directors/QuotationDirector.js +1 -2
- package/lib/directors/WarehousingAdapter.d.ts +12 -12
- package/lib/directors/WarehousingAdapter.js +6 -8
- package/lib/directors/WarehousingDirector.d.ts +4 -5
- package/lib/directors/WarehousingDirector.js +1 -4
- package/lib/directors/WorkerAdapter.d.ts +5 -6
- package/lib/directors/WorkerAdapter.js +0 -1
- package/lib/directors/WorkerDirector.d.ts +5 -6
- package/lib/directors/WorkerDirector.js +0 -3
- package/lib/directors/index.d.ts +42 -43
- package/lib/directors/index.js +42 -43
- package/lib/factory/index.d.ts +9 -10
- package/lib/factory/index.js +9 -10
- package/lib/factory/registerAssortmentSearchFilter.d.ts +1 -2
- package/lib/factory/registerAssortmentSearchFilter.js +1 -2
- package/lib/factory/registerInvoicePayment.d.ts +2 -3
- package/lib/factory/registerInvoicePayment.js +1 -2
- package/lib/factory/registerPhysicalWarehousing.d.ts +2 -3
- package/lib/factory/registerPhysicalWarehousing.js +1 -2
- package/lib/factory/registerPickUpDelivery.d.ts +3 -4
- package/lib/factory/registerPickUpDelivery.js +1 -2
- package/lib/factory/registerProductDiscoverabilityFilter.d.ts +0 -1
- package/lib/factory/registerProductDiscoverabilityFilter.js +1 -2
- package/lib/factory/registerProductSearchFilter.d.ts +1 -2
- package/lib/factory/registerProductSearchFilter.js +1 -2
- package/lib/factory/registerShippingDelivery.d.ts +3 -4
- package/lib/factory/registerShippingDelivery.js +1 -2
- package/lib/factory/registerVirtualWarehousing.d.ts +2 -3
- package/lib/factory/registerVirtualWarehousing.js +1 -2
- package/lib/factory/registerWorker.d.ts +0 -1
- package/lib/factory/registerWorker.js +1 -2
- package/lib/modules.d.ts +18 -19
- package/lib/modules.js +5 -5
- package/lib/services/activateEnrollment.d.ts +2 -3
- package/lib/services/activateEnrollment.js +2 -3
- package/lib/services/addMessage.d.ts +2 -3
- package/lib/services/addMessage.js +2 -3
- package/lib/services/calculateDiscountTotal.d.ts +2 -3
- package/lib/services/calculateDiscountTotal.js +1 -6
- package/lib/services/checkoutOrder.d.ts +1 -2
- package/lib/services/checkoutOrder.js +4 -6
- package/lib/services/confirmOrder.d.ts +2 -3
- package/lib/services/confirmOrder.js +1 -2
- package/lib/services/createDownloadStream.d.ts +2 -3
- package/lib/services/createDownloadStream.js +0 -1
- package/lib/services/createEnrollmentFromCheckout.d.ts +4 -5
- package/lib/services/createEnrollmentFromCheckout.js +2 -3
- package/lib/services/createManualOrderDiscount.d.ts +2 -3
- package/lib/services/createManualOrderDiscount.js +1 -3
- package/lib/services/createSignedURL.d.ts +2 -3
- package/lib/services/createSignedURL.js +0 -1
- package/lib/services/deleteUser.d.ts +1 -2
- package/lib/services/deleteUser.js +0 -1
- package/lib/services/discountedEntities.d.ts +3 -4
- package/lib/services/discountedEntities.js +1 -7
- package/lib/services/ercMetadata.d.ts +3 -4
- package/lib/services/ercMetadata.js +1 -2
- package/lib/services/findOrInitCart.d.ts +2 -3
- package/lib/services/findOrInitCart.js +1 -2
- package/lib/services/fullfillQuotation.d.ts +2 -3
- package/lib/services/fullfillQuotation.js +1 -2
- package/lib/services/generateOrderFromEnrollment.d.ts +2 -3
- package/lib/services/generateOrderFromEnrollment.js +2 -3
- package/lib/services/index.d.ts +48 -49
- package/lib/services/index.js +47 -51
- package/lib/services/initCartProviders.d.ts +2 -3
- package/lib/services/initCartProviders.js +2 -5
- package/lib/services/initializeEnrollment.d.ts +2 -3
- package/lib/services/initializeEnrollment.js +3 -4
- package/lib/services/invalidateFilterCache.d.ts +1 -2
- package/lib/services/invalidateFilterCache.js +1 -2
- package/lib/services/linkFileService.d.ts +1 -2
- package/lib/services/linkFileService.js +0 -1
- package/lib/services/loadFilterOptions.d.ts +2 -3
- package/lib/services/loadFilterOptions.js +1 -2
- package/lib/services/loadFilters.d.ts +2 -3
- package/lib/services/loadFilters.js +1 -2
- package/lib/services/migrateBookmarks.d.ts +1 -2
- package/lib/services/migrateBookmarks.js +0 -2
- package/lib/services/migrateOrderCart.d.ts +1 -2
- package/lib/services/migrateOrderCart.js +1 -7
- package/lib/services/migrateUserData.d.ts +0 -1
- package/lib/services/migrateUserData.js +2 -3
- package/lib/services/nextUserCart.d.ts +2 -3
- package/lib/services/nextUserCart.js +1 -2
- package/lib/services/processEnrollment.d.ts +2 -3
- package/lib/services/processEnrollment.js +1 -5
- package/lib/services/processOrder.d.ts +2 -3
- package/lib/services/processOrder.js +7 -27
- package/lib/services/processQuotation.d.ts +2 -3
- package/lib/services/processQuotation.js +2 -3
- package/lib/services/proposeQuotation.d.ts +2 -3
- package/lib/services/proposeQuotation.js +1 -2
- package/lib/services/registerPaymentCredentials.d.ts +2 -3
- package/lib/services/registerPaymentCredentials.js +1 -2
- package/lib/services/rejectOrder.d.ts +2 -3
- package/lib/services/rejectOrder.js +1 -2
- package/lib/services/rejectQuotation.d.ts +2 -3
- package/lib/services/rejectQuotation.js +1 -2
- package/lib/services/removeFiles.d.ts +1 -2
- package/lib/services/removeFiles.js +0 -2
- package/lib/services/removeProduct.d.ts +1 -2
- package/lib/services/removeProduct.js +1 -4
- package/lib/services/searchAssortments.d.ts +3 -4
- package/lib/services/searchAssortments.js +1 -2
- package/lib/services/searchProducts.d.ts +3 -4
- package/lib/services/searchProducts.js +1 -4
- package/lib/services/simulateProductDispatching.d.ts +5 -6
- package/lib/services/simulateProductDispatching.js +2 -3
- package/lib/services/simulateProductInventory.d.ts +4 -5
- package/lib/services/simulateProductInventory.js +2 -3
- package/lib/services/simulateProductPricing.d.ts +5 -6
- package/lib/services/simulateProductPricing.js +1 -2
- package/lib/services/supportedDeliveryProviders.d.ts +3 -4
- package/lib/services/supportedDeliveryProviders.js +1 -2
- package/lib/services/supportedPaymentProviders.d.ts +3 -4
- package/lib/services/supportedPaymentProviders.js +1 -2
- package/lib/services/supportedWarehousingProviders.d.ts +3 -4
- package/lib/services/supportedWarehousingProviders.js +1 -2
- package/lib/services/terminateEnrollment.d.ts +1 -2
- package/lib/services/terminateEnrollment.js +2 -3
- package/lib/services/updateCalculation.d.ts +2 -3
- package/lib/services/updateCalculation.js +3 -20
- package/lib/services/updateScheduling.d.ts +2 -3
- package/lib/services/updateScheduling.js +2 -4
- package/lib/services/updateUserAvatarAfterUpload.d.ts +2 -3
- package/lib/services/updateUserAvatarAfterUpload.js +1 -3
- package/lib/services/uploadFileFromStream.d.ts +2 -3
- package/lib/services/uploadFileFromStream.js +0 -1
- package/lib/services/uploadFileFromURL.d.ts +1 -2
- package/lib/services/uploadFileFromURL.js +0 -1
- package/lib/services/validateOrder.d.ts +2 -3
- package/lib/services/validateOrder.js +0 -1
- package/lib/services/verifyQuotation.d.ts +2 -3
- package/lib/services/verifyQuotation.js +1 -2
- package/package.json +27 -26
- package/lib/bulk-importer/createBulkImporter.d.ts.map +0 -1
- package/lib/bulk-importer/createBulkImporter.js.map +0 -1
- package/lib/bulk-importer/handlers/assortment/create.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/assortment/create.js.map +0 -1
- package/lib/bulk-importer/handlers/assortment/index.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/assortment/index.js.map +0 -1
- package/lib/bulk-importer/handlers/assortment/remove.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/assortment/remove.js.map +0 -1
- package/lib/bulk-importer/handlers/assortment/update.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/assortment/update.js.map +0 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js.map +0 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js.map +0 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js.map +0 -1
- package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js.map +0 -1
- package/lib/bulk-importer/handlers/filter/create.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/filter/create.js.map +0 -1
- package/lib/bulk-importer/handlers/filter/index.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/filter/index.js.map +0 -1
- package/lib/bulk-importer/handlers/filter/remove.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/filter/remove.js.map +0 -1
- package/lib/bulk-importer/handlers/filter/update.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/filter/update.js.map +0 -1
- package/lib/bulk-importer/handlers/product/create.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/product/create.js.map +0 -1
- package/lib/bulk-importer/handlers/product/index.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/product/index.js.map +0 -1
- package/lib/bulk-importer/handlers/product/remove.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/product/remove.js.map +0 -1
- package/lib/bulk-importer/handlers/product/update.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/product/update.js.map +0 -1
- package/lib/bulk-importer/handlers/product/upsertMedia.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/product/upsertMedia.js.map +0 -1
- package/lib/bulk-importer/handlers/product/upsertVariations.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/product/upsertVariations.js.map +0 -1
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts.map +0 -1
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js.map +0 -1
- package/lib/bulk-importer/index.d.ts.map +0 -1
- package/lib/bulk-importer/index.js.map +0 -1
- package/lib/bulk-importer/upsertAsset.d.ts.map +0 -1
- package/lib/bulk-importer/upsertAsset.js.map +0 -1
- package/lib/core-index.d.ts.map +0 -1
- package/lib/core-index.js.map +0 -1
- package/lib/directors/BaseDiscountAdapter.d.ts.map +0 -1
- package/lib/directors/BaseDiscountAdapter.js.map +0 -1
- package/lib/directors/BaseDiscountDirector.d.ts.map +0 -1
- package/lib/directors/BaseDiscountDirector.js.map +0 -1
- package/lib/directors/BasePricingAdapter.d.ts.map +0 -1
- package/lib/directors/BasePricingAdapter.js.map +0 -1
- package/lib/directors/BasePricingDirector.d.ts.map +0 -1
- package/lib/directors/BasePricingDirector.js.map +0 -1
- package/lib/directors/BasePricingSheet.d.ts.map +0 -1
- package/lib/directors/BasePricingSheet.js.map +0 -1
- package/lib/directors/BaseWorker.d.ts.map +0 -1
- package/lib/directors/BaseWorker.js.map +0 -1
- package/lib/directors/DeliveryAdapter.d.ts.map +0 -1
- package/lib/directors/DeliveryAdapter.js.map +0 -1
- package/lib/directors/DeliveryDirector.d.ts.map +0 -1
- package/lib/directors/DeliveryDirector.js.map +0 -1
- package/lib/directors/DeliveryPricingAdapter.d.ts.map +0 -1
- package/lib/directors/DeliveryPricingAdapter.js.map +0 -1
- package/lib/directors/DeliveryPricingDirector.d.ts.map +0 -1
- package/lib/directors/DeliveryPricingDirector.js.map +0 -1
- package/lib/directors/DeliveryPricingSheet.d.ts.map +0 -1
- package/lib/directors/DeliveryPricingSheet.js.map +0 -1
- package/lib/directors/EnrollmentAdapter.d.ts.map +0 -1
- package/lib/directors/EnrollmentAdapter.js.map +0 -1
- package/lib/directors/EnrollmentDirector.d.ts.map +0 -1
- package/lib/directors/EnrollmentDirector.js.map +0 -1
- package/lib/directors/EventListenerWorker.d.ts.map +0 -1
- package/lib/directors/EventListenerWorker.js.map +0 -1
- package/lib/directors/FailedRescheduler.d.ts.map +0 -1
- package/lib/directors/FailedRescheduler.js.map +0 -1
- package/lib/directors/FilterAdapter.d.ts.map +0 -1
- package/lib/directors/FilterAdapter.js.map +0 -1
- package/lib/directors/FilterDirector.d.ts.map +0 -1
- package/lib/directors/FilterDirector.js.map +0 -1
- package/lib/directors/IntervalWorker.d.ts.map +0 -1
- package/lib/directors/IntervalWorker.js.map +0 -1
- package/lib/directors/MessagingDirector.d.ts.map +0 -1
- package/lib/directors/MessagingDirector.js.map +0 -1
- package/lib/directors/OrderDiscountAdapter.d.ts.map +0 -1
- package/lib/directors/OrderDiscountAdapter.js.map +0 -1
- package/lib/directors/OrderDiscountConfiguration.d.ts.map +0 -1
- package/lib/directors/OrderDiscountConfiguration.js.map +0 -1
- package/lib/directors/OrderDiscountDirector.d.ts.map +0 -1
- package/lib/directors/OrderDiscountDirector.js.map +0 -1
- package/lib/directors/OrderPricingAdapter.d.ts.map +0 -1
- package/lib/directors/OrderPricingAdapter.js.map +0 -1
- package/lib/directors/OrderPricingDirector.d.ts.map +0 -1
- package/lib/directors/OrderPricingDirector.js.map +0 -1
- package/lib/directors/OrderPricingSheet.d.ts.map +0 -1
- package/lib/directors/OrderPricingSheet.js.map +0 -1
- package/lib/directors/PaymentAdapter.d.ts.map +0 -1
- package/lib/directors/PaymentAdapter.js.map +0 -1
- package/lib/directors/PaymentDirector.d.ts.map +0 -1
- package/lib/directors/PaymentDirector.js.map +0 -1
- package/lib/directors/PaymentPricingAdapter.d.ts.map +0 -1
- package/lib/directors/PaymentPricingAdapter.js.map +0 -1
- package/lib/directors/PaymentPricingDirector.d.ts.map +0 -1
- package/lib/directors/PaymentPricingDirector.js.map +0 -1
- package/lib/directors/PaymentPricingSheet.d.ts.map +0 -1
- package/lib/directors/PaymentPricingSheet.js.map +0 -1
- package/lib/directors/ProductDiscountAdapter.d.ts.map +0 -1
- package/lib/directors/ProductDiscountAdapter.js.map +0 -1
- package/lib/directors/ProductDiscountConfiguration.d.ts.map +0 -1
- package/lib/directors/ProductDiscountConfiguration.js.map +0 -1
- package/lib/directors/ProductDiscountDirector.d.ts.map +0 -1
- package/lib/directors/ProductDiscountDirector.js.map +0 -1
- package/lib/directors/ProductPricingAdapter.d.ts.map +0 -1
- package/lib/directors/ProductPricingAdapter.js.map +0 -1
- package/lib/directors/ProductPricingDirector.d.ts.map +0 -1
- package/lib/directors/ProductPricingDirector.js.map +0 -1
- package/lib/directors/ProductPricingSheet.d.ts.map +0 -1
- package/lib/directors/ProductPricingSheet.js.map +0 -1
- package/lib/directors/QuotationAdapter.d.ts.map +0 -1
- package/lib/directors/QuotationAdapter.js.map +0 -1
- package/lib/directors/QuotationDirector.d.ts.map +0 -1
- package/lib/directors/QuotationDirector.js.map +0 -1
- package/lib/directors/WarehousingAdapter.d.ts.map +0 -1
- package/lib/directors/WarehousingAdapter.js.map +0 -1
- package/lib/directors/WarehousingDirector.d.ts.map +0 -1
- package/lib/directors/WarehousingDirector.js.map +0 -1
- package/lib/directors/WorkerAdapter.d.ts.map +0 -1
- package/lib/directors/WorkerAdapter.js.map +0 -1
- package/lib/directors/WorkerDirector.d.ts.map +0 -1
- package/lib/directors/WorkerDirector.js.map +0 -1
- package/lib/directors/index.d.ts.map +0 -1
- package/lib/directors/index.js.map +0 -1
- package/lib/factory/index.d.ts.map +0 -1
- package/lib/factory/index.js.map +0 -1
- package/lib/factory/registerAssortmentSearchFilter.d.ts.map +0 -1
- package/lib/factory/registerAssortmentSearchFilter.js.map +0 -1
- package/lib/factory/registerInvoicePayment.d.ts.map +0 -1
- package/lib/factory/registerInvoicePayment.js.map +0 -1
- package/lib/factory/registerPhysicalWarehousing.d.ts.map +0 -1
- package/lib/factory/registerPhysicalWarehousing.js.map +0 -1
- package/lib/factory/registerPickUpDelivery.d.ts.map +0 -1
- package/lib/factory/registerPickUpDelivery.js.map +0 -1
- package/lib/factory/registerProductDiscoverabilityFilter.d.ts.map +0 -1
- package/lib/factory/registerProductDiscoverabilityFilter.js.map +0 -1
- package/lib/factory/registerProductSearchFilter.d.ts.map +0 -1
- package/lib/factory/registerProductSearchFilter.js.map +0 -1
- package/lib/factory/registerShippingDelivery.d.ts.map +0 -1
- package/lib/factory/registerShippingDelivery.js.map +0 -1
- package/lib/factory/registerVirtualWarehousing.d.ts.map +0 -1
- package/lib/factory/registerVirtualWarehousing.js.map +0 -1
- package/lib/factory/registerWorker.d.ts.map +0 -1
- package/lib/factory/registerWorker.js.map +0 -1
- package/lib/modules.d.ts.map +0 -1
- package/lib/modules.js.map +0 -1
- package/lib/services/activateEnrollment.d.ts.map +0 -1
- package/lib/services/activateEnrollment.js.map +0 -1
- package/lib/services/addMessage.d.ts.map +0 -1
- package/lib/services/addMessage.js.map +0 -1
- package/lib/services/calculateDiscountTotal.d.ts.map +0 -1
- package/lib/services/calculateDiscountTotal.js.map +0 -1
- package/lib/services/checkoutOrder.d.ts.map +0 -1
- package/lib/services/checkoutOrder.js.map +0 -1
- package/lib/services/confirmOrder.d.ts.map +0 -1
- package/lib/services/confirmOrder.js.map +0 -1
- package/lib/services/createDownloadStream.d.ts.map +0 -1
- package/lib/services/createDownloadStream.js.map +0 -1
- package/lib/services/createEnrollmentFromCheckout.d.ts.map +0 -1
- package/lib/services/createEnrollmentFromCheckout.js.map +0 -1
- package/lib/services/createManualOrderDiscount.d.ts.map +0 -1
- package/lib/services/createManualOrderDiscount.js.map +0 -1
- package/lib/services/createSignedURL.d.ts.map +0 -1
- package/lib/services/createSignedURL.js.map +0 -1
- package/lib/services/deleteUser.d.ts.map +0 -1
- package/lib/services/deleteUser.js.map +0 -1
- package/lib/services/discountedEntities.d.ts.map +0 -1
- package/lib/services/discountedEntities.js.map +0 -1
- package/lib/services/ercMetadata.d.ts.map +0 -1
- package/lib/services/ercMetadata.js.map +0 -1
- package/lib/services/findOrInitCart.d.ts.map +0 -1
- package/lib/services/findOrInitCart.js.map +0 -1
- package/lib/services/fullfillQuotation.d.ts.map +0 -1
- package/lib/services/fullfillQuotation.js.map +0 -1
- package/lib/services/generateOrderFromEnrollment.d.ts.map +0 -1
- package/lib/services/generateOrderFromEnrollment.js.map +0 -1
- package/lib/services/index.d.ts.map +0 -1
- package/lib/services/index.js.map +0 -1
- package/lib/services/initCartProviders.d.ts.map +0 -1
- package/lib/services/initCartProviders.js.map +0 -1
- package/lib/services/initializeEnrollment.d.ts.map +0 -1
- package/lib/services/initializeEnrollment.js.map +0 -1
- package/lib/services/invalidateFilterCache.d.ts.map +0 -1
- package/lib/services/invalidateFilterCache.js.map +0 -1
- package/lib/services/linkFileService.d.ts.map +0 -1
- package/lib/services/linkFileService.js.map +0 -1
- package/lib/services/loadFilterOptions.d.ts.map +0 -1
- package/lib/services/loadFilterOptions.js.map +0 -1
- package/lib/services/loadFilters.d.ts.map +0 -1
- package/lib/services/loadFilters.js.map +0 -1
- package/lib/services/migrateBookmarks.d.ts.map +0 -1
- package/lib/services/migrateBookmarks.js.map +0 -1
- package/lib/services/migrateOrderCart.d.ts.map +0 -1
- package/lib/services/migrateOrderCart.js.map +0 -1
- package/lib/services/migrateUserData.d.ts.map +0 -1
- package/lib/services/migrateUserData.js.map +0 -1
- package/lib/services/nextUserCart.d.ts.map +0 -1
- package/lib/services/nextUserCart.js.map +0 -1
- package/lib/services/processEnrollment.d.ts.map +0 -1
- package/lib/services/processEnrollment.js.map +0 -1
- package/lib/services/processOrder.d.ts.map +0 -1
- package/lib/services/processOrder.js.map +0 -1
- package/lib/services/processQuotation.d.ts.map +0 -1
- package/lib/services/processQuotation.js.map +0 -1
- package/lib/services/proposeQuotation.d.ts.map +0 -1
- package/lib/services/proposeQuotation.js.map +0 -1
- package/lib/services/registerPaymentCredentials.d.ts.map +0 -1
- package/lib/services/registerPaymentCredentials.js.map +0 -1
- package/lib/services/rejectOrder.d.ts.map +0 -1
- package/lib/services/rejectOrder.js.map +0 -1
- package/lib/services/rejectQuotation.d.ts.map +0 -1
- package/lib/services/rejectQuotation.js.map +0 -1
- package/lib/services/removeFiles.d.ts.map +0 -1
- package/lib/services/removeFiles.js.map +0 -1
- package/lib/services/removeProduct.d.ts.map +0 -1
- package/lib/services/removeProduct.js.map +0 -1
- package/lib/services/searchAssortments.d.ts.map +0 -1
- package/lib/services/searchAssortments.js.map +0 -1
- package/lib/services/searchProducts.d.ts.map +0 -1
- package/lib/services/searchProducts.js.map +0 -1
- package/lib/services/simulateProductDispatching.d.ts.map +0 -1
- package/lib/services/simulateProductDispatching.js.map +0 -1
- package/lib/services/simulateProductInventory.d.ts.map +0 -1
- package/lib/services/simulateProductInventory.js.map +0 -1
- package/lib/services/simulateProductPricing.d.ts.map +0 -1
- package/lib/services/simulateProductPricing.js.map +0 -1
- package/lib/services/supportedDeliveryProviders.d.ts.map +0 -1
- package/lib/services/supportedDeliveryProviders.js.map +0 -1
- package/lib/services/supportedPaymentProviders.d.ts.map +0 -1
- package/lib/services/supportedPaymentProviders.js.map +0 -1
- package/lib/services/supportedWarehousingProviders.d.ts.map +0 -1
- package/lib/services/supportedWarehousingProviders.js.map +0 -1
- package/lib/services/terminateEnrollment.d.ts.map +0 -1
- package/lib/services/terminateEnrollment.js.map +0 -1
- package/lib/services/updateCalculation.d.ts.map +0 -1
- package/lib/services/updateCalculation.js.map +0 -1
- package/lib/services/updateScheduling.d.ts.map +0 -1
- package/lib/services/updateScheduling.js.map +0 -1
- package/lib/services/updateUserAvatarAfterUpload.d.ts.map +0 -1
- package/lib/services/updateUserAvatarAfterUpload.js.map +0 -1
- package/lib/services/uploadFileFromStream.d.ts.map +0 -1
- package/lib/services/uploadFileFromStream.js.map +0 -1
- package/lib/services/uploadFileFromURL.d.ts.map +0 -1
- package/lib/services/uploadFileFromURL.js.map +0 -1
- package/lib/services/validateOrder.d.ts.map +0 -1
- package/lib/services/validateOrder.js.map +0 -1
- package/lib/services/verifyQuotation.d.ts.map +0 -1
- package/lib/services/verifyQuotation.js.map +0 -1
- package/src/bulk-importer/createBulkImporter.ts +0 -205
- package/src/bulk-importer/handlers/assortment/create.ts +0 -118
- package/src/bulk-importer/handlers/assortment/index.ts +0 -3
- package/src/bulk-importer/handlers/assortment/remove.ts +0 -26
- package/src/bulk-importer/handlers/assortment/update.ts +0 -133
- package/src/bulk-importer/handlers/assortment/upsertAssortmentChildren.ts +0 -77
- package/src/bulk-importer/handlers/assortment/upsertAssortmentFilters.ts +0 -70
- package/src/bulk-importer/handlers/assortment/upsertAssortmentProducts.ts +0 -76
- package/src/bulk-importer/handlers/assortment/upsertMedia.ts +0 -76
- package/src/bulk-importer/handlers/filter/create.ts +0 -104
- package/src/bulk-importer/handlers/filter/index.ts +0 -3
- package/src/bulk-importer/handlers/filter/remove.ts +0 -25
- package/src/bulk-importer/handlers/filter/update.ts +0 -94
- package/src/bulk-importer/handlers/product/create.ts +0 -170
- package/src/bulk-importer/handlers/product/index.ts +0 -3
- package/src/bulk-importer/handlers/product/remove.ts +0 -27
- package/src/bulk-importer/handlers/product/update.ts +0 -175
- package/src/bulk-importer/handlers/product/upsertMedia.ts +0 -81
- package/src/bulk-importer/handlers/product/upsertVariations.ts +0 -110
- package/src/bulk-importer/handlers/utils/convertTagsToLowerCase.ts +0 -4
- package/src/bulk-importer/index.ts +0 -3
- package/src/bulk-importer/upsertAsset.ts +0 -53
- package/src/core-index.ts +0 -103
- package/src/directors/BaseDiscountAdapter.test.ts +0 -52
- package/src/directors/BaseDiscountAdapter.ts +0 -86
- package/src/directors/BaseDiscountDirector.ts +0 -73
- package/src/directors/BasePricingAdapter.ts +0 -74
- package/src/directors/BasePricingDirector.ts +0 -136
- package/src/directors/BasePricingSheet.test.ts +0 -45
- package/src/directors/BasePricingSheet.ts +0 -141
- package/src/directors/BaseWorker.ts +0 -117
- package/src/directors/DeliveryAdapter.ts +0 -106
- package/src/directors/DeliveryDirector.ts +0 -143
- package/src/directors/DeliveryPricingAdapter.ts +0 -87
- package/src/directors/DeliveryPricingDirector.ts +0 -91
- package/src/directors/DeliveryPricingSheet.ts +0 -87
- package/src/directors/EnrollmentAdapter.ts +0 -108
- package/src/directors/EnrollmentDirector.ts +0 -71
- package/src/directors/EventListenerWorker.ts +0 -101
- package/src/directors/FailedRescheduler.ts +0 -73
- package/src/directors/FilterAdapter.ts +0 -106
- package/src/directors/FilterDirector.ts +0 -314
- package/src/directors/IntervalWorker.ts +0 -75
- package/src/directors/MessagingDirector.test.ts +0 -8
- package/src/directors/MessagingDirector.ts +0 -52
- package/src/directors/OrderDiscountAdapter.ts +0 -10
- package/src/directors/OrderDiscountConfiguration.ts +0 -5
- package/src/directors/OrderDiscountDirector.ts +0 -5
- package/src/directors/OrderPricingAdapter.ts +0 -63
- package/src/directors/OrderPricingDirector.ts +0 -74
- package/src/directors/OrderPricingSheet.ts +0 -148
- package/src/directors/PaymentAdapter.ts +0 -118
- package/src/directors/PaymentDirector.ts +0 -297
- package/src/directors/PaymentPricingAdapter.ts +0 -86
- package/src/directors/PaymentPricingDirector.ts +0 -92
- package/src/directors/PaymentPricingSheet.ts +0 -92
- package/src/directors/ProductDiscountAdapter.ts +0 -10
- package/src/directors/ProductDiscountConfiguration.ts +0 -18
- package/src/directors/ProductDiscountDirector.ts +0 -4
- package/src/directors/ProductPricingAdapter.ts +0 -58
- package/src/directors/ProductPricingDirector.ts +0 -100
- package/src/directors/ProductPricingSheet.test.ts +0 -140
- package/src/directors/ProductPricingSheet.ts +0 -125
- package/src/directors/QuotationAdapter.ts +0 -82
- package/src/directors/QuotationDirector.ts +0 -105
- package/src/directors/WarehousingAdapter.ts +0 -77
- package/src/directors/WarehousingDirector.ts +0 -233
- package/src/directors/WorkerAdapter.ts +0 -31
- package/src/directors/WorkerDirector.ts +0 -149
- package/src/directors/index.ts +0 -53
- package/src/directors/periodForReferenceDate.test.ts +0 -25
- package/src/factory/index.ts +0 -21
- package/src/factory/registerAssortmentSearchFilter.ts +0 -36
- package/src/factory/registerInvoicePayment.ts +0 -61
- package/src/factory/registerPhysicalWarehousing.ts +0 -92
- package/src/factory/registerPickUpDelivery.ts +0 -81
- package/src/factory/registerProductDiscoverabilityFilter.ts +0 -36
- package/src/factory/registerProductSearchFilter.ts +0 -36
- package/src/factory/registerShippingDelivery.ts +0 -65
- package/src/factory/registerVirtualWarehousing.ts +0 -100
- package/src/factory/registerWorker.ts +0 -46
- package/src/modules.ts +0 -207
- package/src/services/activateEnrollment.ts +0 -26
- package/src/services/addMessage.ts +0 -20
- package/src/services/calculateDiscountTotal.ts +0 -71
- package/src/services/checkoutOrder.ts +0 -48
- package/src/services/confirmOrder.ts +0 -26
- package/src/services/createDownloadStream.ts +0 -17
- package/src/services/createEnrollmentFromCheckout.ts +0 -68
- package/src/services/createManualOrderDiscount.ts +0 -56
- package/src/services/createSignedURL.ts +0 -21
- package/src/services/deleteUser.ts +0 -48
- package/src/services/discountedEntities.ts +0 -81
- package/src/services/ercMetadata.ts +0 -25
- package/src/services/findOrInitCart.ts +0 -28
- package/src/services/fullfillQuotation.ts +0 -14
- package/src/services/generateOrderFromEnrollment.ts +0 -54
- package/src/services/index.ts +0 -173
- package/src/services/initCartProviders.ts +0 -84
- package/src/services/initializeEnrollment.ts +0 -41
- package/src/services/invalidateFilterCache.ts +0 -16
- package/src/services/linkFileService.ts +0 -24
- package/src/services/loadFilterOptions.ts +0 -49
- package/src/services/loadFilters.ts +0 -62
- package/src/services/migrateBookmarks.ts +0 -39
- package/src/services/migrateOrderCart.ts +0 -52
- package/src/services/migrateUserData.ts +0 -22
- package/src/services/nextUserCart.ts +0 -52
- package/src/services/processEnrollment.ts +0 -49
- package/src/services/processOrder.ts +0 -243
- package/src/services/processQuotation.ts +0 -71
- package/src/services/proposeQuotation.ts +0 -18
- package/src/services/registerPaymentCredentials.ts +0 -28
- package/src/services/rejectOrder.ts +0 -26
- package/src/services/rejectQuotation.ts +0 -18
- package/src/services/removeFiles.ts +0 -25
- package/src/services/removeProduct.ts +0 -39
- package/src/services/searchAssortments.ts +0 -57
- package/src/services/searchProducts.ts +0 -71
- package/src/services/simulateProductDispatching.ts +0 -58
- package/src/services/simulateProductInventory.ts +0 -59
- package/src/services/simulateProductPricing.ts +0 -23
- package/src/services/supportedDeliveryProviders.ts +0 -24
- package/src/services/supportedPaymentProviders.ts +0 -25
- package/src/services/supportedWarehousingProviders.ts +0 -18
- package/src/services/terminateEnrollment.ts +0 -25
- package/src/services/updateCalculation.ts +0 -159
- package/src/services/updateScheduling.ts +0 -63
- package/src/services/updateUserAvatarAfterUpload.ts +0 -33
- package/src/services/uploadFileFromStream.ts +0 -27
- package/src/services/uploadFileFromURL.ts +0 -29
- package/src/services/validateOrder.ts +0 -49
- package/src/services/verifyQuotation.ts +0 -18
- package/tsconfig.json +0 -9
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TokenSurrogate,
|
|
3
|
-
WarehousingConfiguration,
|
|
4
|
-
WarehousingProviderType,
|
|
5
|
-
} from '@unchainedshop/core-warehousing';
|
|
6
|
-
import { WarehousingAdapter, WarehousingContext, WarehousingDirector } from '../core-index.js';
|
|
7
|
-
|
|
8
|
-
export default function registerVirtualWarehousing<Metadata = Record<string, any>>({
|
|
9
|
-
adapterId,
|
|
10
|
-
orderIndex = 0,
|
|
11
|
-
stock,
|
|
12
|
-
tokenize,
|
|
13
|
-
tokenMetadata,
|
|
14
|
-
isInvalidateable,
|
|
15
|
-
}: {
|
|
16
|
-
adapterId: string;
|
|
17
|
-
orderIndex?: number;
|
|
18
|
-
stock?:
|
|
19
|
-
| number
|
|
20
|
-
| ((
|
|
21
|
-
referenceDate: Date,
|
|
22
|
-
configuration: WarehousingConfiguration,
|
|
23
|
-
context: WarehousingContext,
|
|
24
|
-
) => Promise<number>);
|
|
25
|
-
|
|
26
|
-
tokenize: (
|
|
27
|
-
configuration: WarehousingConfiguration,
|
|
28
|
-
context: WarehousingContext,
|
|
29
|
-
) => Promise<Omit<TokenSurrogate, 'userId' | 'productId' | 'orderPositionId'>[]>;
|
|
30
|
-
|
|
31
|
-
tokenMetadata?: (
|
|
32
|
-
serialNumber: string,
|
|
33
|
-
referenceDate: Date,
|
|
34
|
-
configuration: WarehousingConfiguration,
|
|
35
|
-
context: WarehousingContext,
|
|
36
|
-
) => Promise<Metadata>;
|
|
37
|
-
|
|
38
|
-
isInvalidateable?: (
|
|
39
|
-
serialNumber: string,
|
|
40
|
-
referenceDate: Date,
|
|
41
|
-
configuration: WarehousingConfiguration,
|
|
42
|
-
context: WarehousingContext,
|
|
43
|
-
) => Promise<boolean>;
|
|
44
|
-
}) {
|
|
45
|
-
WarehousingDirector.registerAdapter({
|
|
46
|
-
...WarehousingAdapter,
|
|
47
|
-
|
|
48
|
-
key: 'shop.unchained.warehousing.virtual.' + adapterId,
|
|
49
|
-
label: 'Virtual Wareshousing: ' + adapterId,
|
|
50
|
-
version: '1.0.0',
|
|
51
|
-
orderIndex,
|
|
52
|
-
|
|
53
|
-
initialConfiguration: [{ key: 'shipping-hub', value: 'Shipping Hub' }],
|
|
54
|
-
|
|
55
|
-
typeSupported: (type) => {
|
|
56
|
-
return type === WarehousingProviderType.VIRTUAL;
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
actions: (configuration, context) => {
|
|
60
|
-
return {
|
|
61
|
-
...WarehousingAdapter.actions(configuration, context),
|
|
62
|
-
|
|
63
|
-
isActive() {
|
|
64
|
-
return true;
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
configurationError() {
|
|
68
|
-
return null;
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
stock: async (referenceDate) => {
|
|
72
|
-
if (typeof stock === 'number') {
|
|
73
|
-
return stock;
|
|
74
|
-
} else if (typeof stock === 'function') {
|
|
75
|
-
return stock(referenceDate, configuration, context);
|
|
76
|
-
}
|
|
77
|
-
return 99999;
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
async tokenize() {
|
|
81
|
-
return tokenize(configuration, context);
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
async tokenMetadata(serialNumber, referenceDate) {
|
|
85
|
-
if (tokenMetadata) {
|
|
86
|
-
return tokenMetadata(serialNumber, referenceDate, configuration, context);
|
|
87
|
-
}
|
|
88
|
-
return null;
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
async isInvalidateable(serialNumber, referenceDate) {
|
|
92
|
-
if (isInvalidateable) {
|
|
93
|
-
return isInvalidateable(serialNumber, referenceDate, configuration, context);
|
|
94
|
-
}
|
|
95
|
-
return false;
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { WorkerAdapter, WorkerDirector } from '../core-index.js';
|
|
2
|
-
|
|
3
|
-
export default function registerWorker<Input = any, Result = any>({
|
|
4
|
-
type,
|
|
5
|
-
external,
|
|
6
|
-
maxParallelAllocations,
|
|
7
|
-
process,
|
|
8
|
-
}: {
|
|
9
|
-
type: string;
|
|
10
|
-
external?: boolean;
|
|
11
|
-
maxParallelAllocations?: number;
|
|
12
|
-
process?: (input: Input, workId: string) => Promise<Result>;
|
|
13
|
-
}) {
|
|
14
|
-
WorkerDirector.registerAdapter({
|
|
15
|
-
...WorkerAdapter,
|
|
16
|
-
|
|
17
|
-
key: 'shop.unchained.worker.' + type.toLowerCase(),
|
|
18
|
-
label: 'Worker: ' + type,
|
|
19
|
-
version: '1.0',
|
|
20
|
-
external: external ?? false,
|
|
21
|
-
maxParallelAllocations,
|
|
22
|
-
type,
|
|
23
|
-
|
|
24
|
-
async doWork(input, _, workId) {
|
|
25
|
-
if (!process) {
|
|
26
|
-
return { success: false };
|
|
27
|
-
}
|
|
28
|
-
try {
|
|
29
|
-
const result = await process(input, workId);
|
|
30
|
-
return {
|
|
31
|
-
success: true,
|
|
32
|
-
result,
|
|
33
|
-
};
|
|
34
|
-
} catch (err) {
|
|
35
|
-
return {
|
|
36
|
-
success: false,
|
|
37
|
-
error: {
|
|
38
|
-
name: err.name,
|
|
39
|
-
message: err.message,
|
|
40
|
-
cause: err.cause,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
}
|
package/src/modules.ts
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AssortmentsModule,
|
|
3
|
-
AssortmentsSettingsOptions,
|
|
4
|
-
configureAssortmentsModule,
|
|
5
|
-
} from '@unchainedshop/core-assortments';
|
|
6
|
-
import { BookmarksModule, configureBookmarksModule } from '@unchainedshop/core-bookmarks';
|
|
7
|
-
import { configureCountriesModule, CountriesModule } from '@unchainedshop/core-countries';
|
|
8
|
-
import { configureCurrenciesModule, CurrenciesModule } from '@unchainedshop/core-currencies';
|
|
9
|
-
import {
|
|
10
|
-
configureDeliveryModule,
|
|
11
|
-
DeliveryModule,
|
|
12
|
-
DeliverySettingsOptions,
|
|
13
|
-
} from '@unchainedshop/core-delivery';
|
|
14
|
-
import {
|
|
15
|
-
configureEnrollmentsModule,
|
|
16
|
-
EnrollmentsModule,
|
|
17
|
-
EnrollmentsSettingsOptions,
|
|
18
|
-
} from '@unchainedshop/core-enrollments';
|
|
19
|
-
import { configureEventsModule, EventsModule } from '@unchainedshop/core-events';
|
|
20
|
-
import { configureFilesModule, FilesModule, FilesSettingsOptions } from '@unchainedshop/core-files';
|
|
21
|
-
import {
|
|
22
|
-
configureFiltersModule,
|
|
23
|
-
FiltersModule,
|
|
24
|
-
FiltersSettingsOptions,
|
|
25
|
-
} from '@unchainedshop/core-filters';
|
|
26
|
-
import { configureLanguagesModule, LanguagesModule } from '@unchainedshop/core-languages';
|
|
27
|
-
import { configureOrdersModule, OrdersModule, OrdersSettingsOptions } from '@unchainedshop/core-orders';
|
|
28
|
-
import {
|
|
29
|
-
configurePaymentModule,
|
|
30
|
-
PaymentModule,
|
|
31
|
-
PaymentSettingsOptions,
|
|
32
|
-
} from '@unchainedshop/core-payment';
|
|
33
|
-
import {
|
|
34
|
-
configureProductsModule,
|
|
35
|
-
ProductsModule,
|
|
36
|
-
ProductsSettingsOptions,
|
|
37
|
-
} from '@unchainedshop/core-products';
|
|
38
|
-
import {
|
|
39
|
-
configureQuotationsModule,
|
|
40
|
-
QuotationsModule,
|
|
41
|
-
QuotationsSettingsOptions,
|
|
42
|
-
} from '@unchainedshop/core-quotations';
|
|
43
|
-
import { configureUsersModule, UserSettingsOptions, UsersModule } from '@unchainedshop/core-users';
|
|
44
|
-
import { configureWarehousingModule, WarehousingModule } from '@unchainedshop/core-warehousing';
|
|
45
|
-
import { configureWorkerModule, WorkerModule, WorkerSettingsOptions } from '@unchainedshop/core-worker';
|
|
46
|
-
import { MigrationRepository, ModuleInput, mongodb } from '@unchainedshop/mongodb';
|
|
47
|
-
|
|
48
|
-
export interface Modules {
|
|
49
|
-
assortments: AssortmentsModule;
|
|
50
|
-
bookmarks: BookmarksModule;
|
|
51
|
-
countries: CountriesModule;
|
|
52
|
-
currencies: CurrenciesModule;
|
|
53
|
-
delivery: DeliveryModule;
|
|
54
|
-
enrollments: EnrollmentsModule;
|
|
55
|
-
events: EventsModule;
|
|
56
|
-
files: FilesModule;
|
|
57
|
-
filters: FiltersModule;
|
|
58
|
-
languages: LanguagesModule;
|
|
59
|
-
orders: OrdersModule;
|
|
60
|
-
payment: PaymentModule;
|
|
61
|
-
products: ProductsModule;
|
|
62
|
-
quotations: QuotationsModule;
|
|
63
|
-
users: UsersModule;
|
|
64
|
-
warehousing: WarehousingModule;
|
|
65
|
-
worker: WorkerModule;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface ModuleOptions {
|
|
69
|
-
assortments?: AssortmentsSettingsOptions;
|
|
70
|
-
products?: ProductsSettingsOptions;
|
|
71
|
-
delivery?: DeliverySettingsOptions;
|
|
72
|
-
payment?: PaymentSettingsOptions;
|
|
73
|
-
filters?: FiltersSettingsOptions;
|
|
74
|
-
enrollments?: EnrollmentsSettingsOptions;
|
|
75
|
-
orders?: OrdersSettingsOptions;
|
|
76
|
-
quotations?: QuotationsSettingsOptions;
|
|
77
|
-
files?: FilesSettingsOptions;
|
|
78
|
-
worker?: WorkerSettingsOptions;
|
|
79
|
-
users?: UserSettingsOptions;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export default async function initModules(
|
|
83
|
-
{
|
|
84
|
-
db,
|
|
85
|
-
migrationRepository,
|
|
86
|
-
options,
|
|
87
|
-
}: {
|
|
88
|
-
db: mongodb.Db;
|
|
89
|
-
migrationRepository: MigrationRepository<unknown>;
|
|
90
|
-
options: ModuleOptions;
|
|
91
|
-
},
|
|
92
|
-
customModules: Record<
|
|
93
|
-
string,
|
|
94
|
-
{
|
|
95
|
-
configure: (params: ModuleInput<any>) => any;
|
|
96
|
-
}
|
|
97
|
-
>,
|
|
98
|
-
): Promise<Modules> {
|
|
99
|
-
const assortments = await configureAssortmentsModule({
|
|
100
|
-
db,
|
|
101
|
-
options: options.assortments,
|
|
102
|
-
migrationRepository,
|
|
103
|
-
});
|
|
104
|
-
const bookmarks = await configureBookmarksModule({
|
|
105
|
-
db,
|
|
106
|
-
migrationRepository,
|
|
107
|
-
});
|
|
108
|
-
const countries = await configureCountriesModule({
|
|
109
|
-
db,
|
|
110
|
-
migrationRepository,
|
|
111
|
-
});
|
|
112
|
-
const currencies = await configureCurrenciesModule({
|
|
113
|
-
db,
|
|
114
|
-
migrationRepository,
|
|
115
|
-
});
|
|
116
|
-
const delivery = await configureDeliveryModule({
|
|
117
|
-
db,
|
|
118
|
-
options: options.delivery,
|
|
119
|
-
migrationRepository,
|
|
120
|
-
});
|
|
121
|
-
const enrollments = await configureEnrollmentsModule({
|
|
122
|
-
db,
|
|
123
|
-
options: options.enrollments,
|
|
124
|
-
migrationRepository,
|
|
125
|
-
});
|
|
126
|
-
const events = await configureEventsModule({
|
|
127
|
-
db,
|
|
128
|
-
migrationRepository,
|
|
129
|
-
});
|
|
130
|
-
const files = await configureFilesModule({
|
|
131
|
-
db,
|
|
132
|
-
options: options.files,
|
|
133
|
-
migrationRepository,
|
|
134
|
-
});
|
|
135
|
-
const filters = await configureFiltersModule({
|
|
136
|
-
db,
|
|
137
|
-
options: options.filters,
|
|
138
|
-
migrationRepository,
|
|
139
|
-
});
|
|
140
|
-
const languages = await configureLanguagesModule({
|
|
141
|
-
db,
|
|
142
|
-
migrationRepository,
|
|
143
|
-
});
|
|
144
|
-
const orders = await configureOrdersModule({
|
|
145
|
-
db,
|
|
146
|
-
options: options.orders,
|
|
147
|
-
migrationRepository,
|
|
148
|
-
});
|
|
149
|
-
const payment = await configurePaymentModule({
|
|
150
|
-
db,
|
|
151
|
-
options: options.payment,
|
|
152
|
-
migrationRepository,
|
|
153
|
-
});
|
|
154
|
-
const products = await configureProductsModule({
|
|
155
|
-
db,
|
|
156
|
-
migrationRepository,
|
|
157
|
-
options: options.products,
|
|
158
|
-
});
|
|
159
|
-
const quotations = await configureQuotationsModule({
|
|
160
|
-
db,
|
|
161
|
-
options: options.quotations,
|
|
162
|
-
migrationRepository,
|
|
163
|
-
});
|
|
164
|
-
const users = await configureUsersModule({
|
|
165
|
-
db,
|
|
166
|
-
options: options.users,
|
|
167
|
-
migrationRepository,
|
|
168
|
-
});
|
|
169
|
-
const warehousing = await configureWarehousingModule({
|
|
170
|
-
db,
|
|
171
|
-
migrationRepository,
|
|
172
|
-
});
|
|
173
|
-
const worker = await configureWorkerModule({
|
|
174
|
-
db,
|
|
175
|
-
options: options.worker,
|
|
176
|
-
migrationRepository,
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
const modules = {
|
|
180
|
-
assortments,
|
|
181
|
-
bookmarks,
|
|
182
|
-
countries,
|
|
183
|
-
currencies,
|
|
184
|
-
delivery,
|
|
185
|
-
enrollments,
|
|
186
|
-
events,
|
|
187
|
-
files,
|
|
188
|
-
filters,
|
|
189
|
-
languages,
|
|
190
|
-
orders,
|
|
191
|
-
payment,
|
|
192
|
-
products,
|
|
193
|
-
quotations,
|
|
194
|
-
users,
|
|
195
|
-
warehousing,
|
|
196
|
-
worker,
|
|
197
|
-
};
|
|
198
|
-
for (const [key, customModule] of Object.entries(customModules)) {
|
|
199
|
-
modules[key] = await customModule.configure({
|
|
200
|
-
db,
|
|
201
|
-
options: options[key],
|
|
202
|
-
migrationRepository,
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return modules;
|
|
207
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Enrollment, EnrollmentStatus } from '@unchainedshop/core-enrollments';
|
|
2
|
-
import { Modules } from '../modules.js';
|
|
3
|
-
import { processEnrollmentService } from './processEnrollment.js';
|
|
4
|
-
import { addMessageService } from './addMessage.js';
|
|
5
|
-
|
|
6
|
-
export async function activateEnrollmentService(this: Modules, enrollment: Enrollment) {
|
|
7
|
-
if (enrollment.status === EnrollmentStatus.TERMINATED) return enrollment;
|
|
8
|
-
|
|
9
|
-
let updatedEnrollment = (await this.enrollments.updateStatus(enrollment._id, {
|
|
10
|
-
status: EnrollmentStatus.ACTIVE,
|
|
11
|
-
info: 'activated manually',
|
|
12
|
-
})) as Enrollment;
|
|
13
|
-
|
|
14
|
-
updatedEnrollment = (await processEnrollmentService.bind(this)(updatedEnrollment)) as Enrollment;
|
|
15
|
-
|
|
16
|
-
const user = await this.users.findUserById(enrollment.userId);
|
|
17
|
-
const locale = this.users.userLocale(user);
|
|
18
|
-
|
|
19
|
-
await addMessageService.bind(this)('ENROLLMENT_STATUS', {
|
|
20
|
-
reason: 'status_change',
|
|
21
|
-
locale: locale.baseName,
|
|
22
|
-
enrollmentId: updatedEnrollment!._id,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
return updatedEnrollment!;
|
|
26
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Order, OrderDiscount } from '@unchainedshop/core-orders';
|
|
2
|
-
import { Modules } from '../modules.js';
|
|
3
|
-
import {
|
|
4
|
-
OrderPricingRowCategory,
|
|
5
|
-
OrderPricingSheet,
|
|
6
|
-
DeliveryPricingRowCategory,
|
|
7
|
-
DeliveryPricingSheet,
|
|
8
|
-
ProductPricingRowCategory,
|
|
9
|
-
ProductPricingSheet,
|
|
10
|
-
PaymentPricingRowCategory,
|
|
11
|
-
PaymentPricingSheet,
|
|
12
|
-
} from '../directors/index.js';
|
|
13
|
-
|
|
14
|
-
export async function calculateDiscountTotalService(
|
|
15
|
-
this: Modules,
|
|
16
|
-
order: Order,
|
|
17
|
-
orderDiscount: OrderDiscount,
|
|
18
|
-
) {
|
|
19
|
-
const orderDiscountId = orderDiscount._id;
|
|
20
|
-
|
|
21
|
-
// Delivery discounts
|
|
22
|
-
const orderDelivery = await this.orders.deliveries.findDelivery({
|
|
23
|
-
orderDeliveryId: order.deliveryId!,
|
|
24
|
-
});
|
|
25
|
-
const orderDeliveryDiscountSum = DeliveryPricingSheet({
|
|
26
|
-
calculation: orderDelivery?.calculation || [],
|
|
27
|
-
currencyCode: order.currencyCode,
|
|
28
|
-
}).total({ category: DeliveryPricingRowCategory.Discount, discountId: orderDiscountId });
|
|
29
|
-
|
|
30
|
-
// Payment discounts
|
|
31
|
-
const orderPayment = await this.orders.payments.findOrderPayment({
|
|
32
|
-
orderPaymentId: order.paymentId!,
|
|
33
|
-
});
|
|
34
|
-
const orderPaymentDiscountSum = PaymentPricingSheet({
|
|
35
|
-
calculation: orderPayment?.calculation || [],
|
|
36
|
-
currencyCode: order.currencyCode,
|
|
37
|
-
}).total({ category: PaymentPricingRowCategory.Discount, discountId: orderDiscountId });
|
|
38
|
-
|
|
39
|
-
// Position discounts
|
|
40
|
-
const orderPositions = await this.orders.positions.findOrderPositions({
|
|
41
|
-
orderId: order._id,
|
|
42
|
-
});
|
|
43
|
-
const orderPositionDiscounts = orderPositions.map((orderPosition) =>
|
|
44
|
-
ProductPricingSheet({
|
|
45
|
-
calculation: orderPosition.calculation || [],
|
|
46
|
-
currencyCode: order.currencyCode,
|
|
47
|
-
quantity: orderPosition.quantity,
|
|
48
|
-
}).total({
|
|
49
|
-
category: ProductPricingRowCategory.Discount,
|
|
50
|
-
discountId: orderDiscountId,
|
|
51
|
-
}),
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
// order discounts
|
|
55
|
-
const orderDiscountSum = OrderPricingSheet({
|
|
56
|
-
calculation: order.calculation,
|
|
57
|
-
currencyCode: order.currencyCode,
|
|
58
|
-
}).total({ category: OrderPricingRowCategory.Discounts, discountId: orderDiscountId });
|
|
59
|
-
|
|
60
|
-
const prices = [
|
|
61
|
-
orderDeliveryDiscountSum.amount,
|
|
62
|
-
orderPaymentDiscountSum.amount,
|
|
63
|
-
...orderPositionDiscounts.map((positionDiscount) => positionDiscount.amount),
|
|
64
|
-
orderDiscountSum.amount,
|
|
65
|
-
];
|
|
66
|
-
const amount = prices.reduce((oldValue, price) => oldValue + (price || 0), 0);
|
|
67
|
-
return {
|
|
68
|
-
amount,
|
|
69
|
-
currencyCode: order.currencyCode,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { OrderStatus } from '@unchainedshop/core-orders';
|
|
2
|
-
import { Modules } from '../modules.js';
|
|
3
|
-
import { nextUserCartService } from './nextUserCart.js';
|
|
4
|
-
import { validateOrderService } from './validateOrder.js';
|
|
5
|
-
import { processOrderService } from './processOrder.js';
|
|
6
|
-
import { User } from '@unchainedshop/core-users';
|
|
7
|
-
|
|
8
|
-
export async function checkoutOrderService(
|
|
9
|
-
this: Modules,
|
|
10
|
-
orderId: string,
|
|
11
|
-
transactionContext: {
|
|
12
|
-
paymentContext?: any;
|
|
13
|
-
deliveryContext?: any;
|
|
14
|
-
comment?: string;
|
|
15
|
-
nextStatus?: OrderStatus;
|
|
16
|
-
},
|
|
17
|
-
) {
|
|
18
|
-
const order = await this.orders.findOrder({ orderId });
|
|
19
|
-
if (!order) return null;
|
|
20
|
-
if (order.status !== null) return order;
|
|
21
|
-
|
|
22
|
-
await validateOrderService.bind(this)(order);
|
|
23
|
-
|
|
24
|
-
const lock = await this.orders.acquireLock(order._id, 'checkout');
|
|
25
|
-
|
|
26
|
-
try {
|
|
27
|
-
const processedOrder = await processOrderService.bind(this)(order, transactionContext);
|
|
28
|
-
|
|
29
|
-
// After checkout, store last checkout information on user
|
|
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
|
-
}
|
|
36
|
-
// Then eventually build next cart
|
|
37
|
-
const user = (await this.users.findUserById(processedOrder.userId)) as User;
|
|
38
|
-
const locale = this.users.userLocale(user);
|
|
39
|
-
await nextUserCartService.bind(this)({
|
|
40
|
-
user,
|
|
41
|
-
countryCode: locale?.region || processedOrder.countryCode,
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return processedOrder;
|
|
45
|
-
} finally {
|
|
46
|
-
await lock.release();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Order, OrderStatus } from '@unchainedshop/core-orders';
|
|
2
|
-
import { Modules } from '../modules.js';
|
|
3
|
-
import { processOrderService } from './processOrder.js';
|
|
4
|
-
|
|
5
|
-
export async function confirmOrderService(
|
|
6
|
-
this: Modules,
|
|
7
|
-
order: Order,
|
|
8
|
-
transactionContext: {
|
|
9
|
-
paymentContext?: any;
|
|
10
|
-
deliveryContext?: any;
|
|
11
|
-
comment?: string;
|
|
12
|
-
nextStatus?: OrderStatus;
|
|
13
|
-
},
|
|
14
|
-
) {
|
|
15
|
-
if (order.status !== OrderStatus.PENDING) return order;
|
|
16
|
-
|
|
17
|
-
const lock = await this.orders.acquireLock(order._id, 'confirm-reject', 1500);
|
|
18
|
-
try {
|
|
19
|
-
return await processOrderService.bind(this)(order, {
|
|
20
|
-
...transactionContext,
|
|
21
|
-
nextStatus: OrderStatus.CONFIRMED,
|
|
22
|
-
});
|
|
23
|
-
} finally {
|
|
24
|
-
await lock.release();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { getFileAdapter } from '@unchainedshop/core-files';
|
|
2
|
-
import { Modules } from '../modules.js';
|
|
3
|
-
|
|
4
|
-
export async function createDownloadStreamService(
|
|
5
|
-
this: Modules,
|
|
6
|
-
{
|
|
7
|
-
fileId,
|
|
8
|
-
}: {
|
|
9
|
-
fileId: string;
|
|
10
|
-
},
|
|
11
|
-
) {
|
|
12
|
-
const fileAdapter = getFileAdapter();
|
|
13
|
-
const file = await this.files.findFile({ fileId });
|
|
14
|
-
if (!file) return null;
|
|
15
|
-
const stream = fileAdapter.createDownloadStream(file, { modules: this });
|
|
16
|
-
return stream;
|
|
17
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Order, OrderPosition } from '@unchainedshop/core-orders';
|
|
2
|
-
import { Product } from '@unchainedshop/core-products';
|
|
3
|
-
import { Enrollment } from '@unchainedshop/core-enrollments';
|
|
4
|
-
import { Modules } from '../modules.js';
|
|
5
|
-
import { EnrollmentDirector } from '../directors/index.js';
|
|
6
|
-
import { initializeEnrollmentService } from './initializeEnrollment.js';
|
|
7
|
-
|
|
8
|
-
export async function createEnrollmentFromCheckoutService(
|
|
9
|
-
this: Modules,
|
|
10
|
-
order: Order,
|
|
11
|
-
{
|
|
12
|
-
items,
|
|
13
|
-
context,
|
|
14
|
-
}: {
|
|
15
|
-
items: {
|
|
16
|
-
orderPosition: OrderPosition;
|
|
17
|
-
product: Product;
|
|
18
|
-
}[];
|
|
19
|
-
context: {
|
|
20
|
-
paymentContext?: any;
|
|
21
|
-
deliveryContext?: any;
|
|
22
|
-
};
|
|
23
|
-
},
|
|
24
|
-
): Promise<Enrollment[]> {
|
|
25
|
-
const orderId = order._id;
|
|
26
|
-
|
|
27
|
-
const payment = await this.orders.payments.findOrderPayment({
|
|
28
|
-
orderPaymentId: order.paymentId!,
|
|
29
|
-
});
|
|
30
|
-
const delivery = await this.orders.deliveries.findDelivery({
|
|
31
|
-
orderDeliveryId: order.deliveryId!,
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const template = {
|
|
35
|
-
billingAddress: order.billingAddress!,
|
|
36
|
-
contact: order.contact!,
|
|
37
|
-
countryCode: order.countryCode,
|
|
38
|
-
currencyCode: order.currencyCode,
|
|
39
|
-
delivery: {
|
|
40
|
-
deliveryProviderId: delivery!.deliveryProviderId,
|
|
41
|
-
context: delivery!.context,
|
|
42
|
-
},
|
|
43
|
-
orderIdForFirstPeriod: orderId,
|
|
44
|
-
payment: {
|
|
45
|
-
paymentProviderId: payment!.paymentProviderId,
|
|
46
|
-
context: payment!.context,
|
|
47
|
-
},
|
|
48
|
-
userId: order.userId,
|
|
49
|
-
meta: order.context,
|
|
50
|
-
...context,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
await Promise.all(
|
|
55
|
-
items.map(async (item) => {
|
|
56
|
-
const enrollmentData = await EnrollmentDirector.transformOrderItemToEnrollment(item, template, {
|
|
57
|
-
modules: this,
|
|
58
|
-
});
|
|
59
|
-
|
|
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[];
|
|
68
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Order } from '@unchainedshop/core-orders';
|
|
2
|
-
import { OrderDiscountDirector } from '../directors/OrderDiscountDirector.js';
|
|
3
|
-
import { Modules } from '../modules.js';
|
|
4
|
-
|
|
5
|
-
export async function createManualOrderDiscountService(
|
|
6
|
-
this: Modules,
|
|
7
|
-
{ order, code }: { code: string; order: Order },
|
|
8
|
-
) {
|
|
9
|
-
// Use an already existing discount if available!
|
|
10
|
-
const spareDiscount = await this.orders.discounts.findSpareDiscount({ code });
|
|
11
|
-
if (spareDiscount) {
|
|
12
|
-
const Adapter = OrderDiscountDirector.getAdapter(spareDiscount.discountKey);
|
|
13
|
-
if (!Adapter) return null;
|
|
14
|
-
|
|
15
|
-
const actions = await Adapter.actions({
|
|
16
|
-
context: { order, orderDiscount: spareDiscount, code, modules: this },
|
|
17
|
-
});
|
|
18
|
-
const reservation = await actions.reserve({
|
|
19
|
-
code,
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
return this.orders.discounts.update(spareDiscount._id, { orderId: order._id, reservation });
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const director = await OrderDiscountDirector.actions({ order, code }, { modules: this });
|
|
26
|
-
const Adapter = await director.resolveDiscountAdapterFromStaticCode({
|
|
27
|
-
code,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
if (!Adapter) return null;
|
|
31
|
-
|
|
32
|
-
const newDiscount = await this.orders.discounts.create({
|
|
33
|
-
orderId: order._id,
|
|
34
|
-
code,
|
|
35
|
-
discountKey: Adapter.key,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const adapter = await Adapter.actions({
|
|
39
|
-
context: { order, orderDiscount: newDiscount, code: newDiscount.code, modules: this },
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
try {
|
|
43
|
-
const reservation = await adapter.reserve({
|
|
44
|
-
code: newDiscount.code,
|
|
45
|
-
});
|
|
46
|
-
const reservedDiscount = this.orders.discounts.update(newDiscount._id, {
|
|
47
|
-
orderId: newDiscount.orderId,
|
|
48
|
-
reservation,
|
|
49
|
-
});
|
|
50
|
-
return reservedDiscount;
|
|
51
|
-
} catch (error) {
|
|
52
|
-
await adapter.release();
|
|
53
|
-
await this.orders.discounts.delete(newDiscount._id);
|
|
54
|
-
throw error;
|
|
55
|
-
}
|
|
56
|
-
}
|