@unchainedshop/core 4.0.0-rc.2 → 4.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bulk-importer/createBulkImporter.d.ts +84 -0
- package/lib/bulk-importer/createBulkImporter.d.ts.map +1 -0
- package/lib/bulk-importer/createBulkImporter.js +142 -0
- package/lib/bulk-importer/createBulkImporter.js.map +1 -0
- package/lib/bulk-importer/handlers/assortment/create.d.ts +565 -0
- package/lib/bulk-importer/handlers/assortment/create.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/assortment/create.js +89 -0
- package/lib/bulk-importer/handlers/assortment/create.js.map +1 -0
- package/lib/bulk-importer/handlers/assortment/index.d.ts +4 -0
- package/lib/bulk-importer/handlers/assortment/index.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/assortment/index.js +4 -0
- package/lib/bulk-importer/handlers/assortment/index.js.map +1 -0
- package/lib/bulk-importer/handlers/assortment/remove.d.ts +30 -0
- package/lib/bulk-importer/handlers/assortment/remove.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/assortment/remove.js +18 -0
- package/lib/bulk-importer/handlers/assortment/remove.js.map +1 -0
- package/lib/bulk-importer/handlers/assortment/update.d.ts +566 -0
- package/lib/bulk-importer/handlers/assortment/update.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/assortment/update.js +98 -0
- package/lib/bulk-importer/handlers/assortment/update.js.map +1 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts +29 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js +45 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js.map +1 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts +29 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js +41 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js.map +1 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts +29 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js +46 -0
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js.map +1 -0
- package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts +76 -0
- package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js +53 -0
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js.map +1 -0
- package/lib/bulk-importer/handlers/filter/create.d.ts +138 -0
- package/lib/bulk-importer/handlers/filter/create.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/filter/create.js +80 -0
- package/lib/bulk-importer/handlers/filter/create.js.map +1 -0
- package/lib/bulk-importer/handlers/filter/index.d.ts +4 -0
- package/lib/bulk-importer/handlers/filter/index.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/filter/index.js +4 -0
- package/lib/bulk-importer/handlers/filter/index.js.map +1 -0
- package/lib/bulk-importer/handlers/filter/remove.d.ts +20 -0
- package/lib/bulk-importer/handlers/filter/remove.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/filter/remove.js +18 -0
- package/lib/bulk-importer/handlers/filter/remove.js.map +1 -0
- package/lib/bulk-importer/handlers/filter/update.d.ts +138 -0
- package/lib/bulk-importer/handlers/filter/update.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/filter/update.js +70 -0
- package/lib/bulk-importer/handlers/filter/update.js.map +1 -0
- package/lib/bulk-importer/handlers/product/create.d.ts +1330 -0
- package/lib/bulk-importer/handlers/product/create.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/product/create.js +132 -0
- package/lib/bulk-importer/handlers/product/create.js.map +1 -0
- package/lib/bulk-importer/handlers/product/index.d.ts +4 -0
- package/lib/bulk-importer/handlers/product/index.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/product/index.js +4 -0
- package/lib/bulk-importer/handlers/product/index.js.map +1 -0
- package/lib/bulk-importer/handlers/product/remove.d.ts +32 -0
- package/lib/bulk-importer/handlers/product/remove.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/product/remove.js +18 -0
- package/lib/bulk-importer/handlers/product/remove.js.map +1 -0
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts +280 -0
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js +77 -0
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js.map +1 -0
- package/lib/bulk-importer/handlers/product/update.d.ts +1330 -0
- package/lib/bulk-importer/handlers/product/update.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/product/update.js +132 -0
- package/lib/bulk-importer/handlers/product/update.js.map +1 -0
- package/lib/bulk-importer/handlers/product/upsertMedia.d.ts +75 -0
- package/lib/bulk-importer/handlers/product/upsertMedia.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/product/upsertMedia.js +59 -0
- package/lib/bulk-importer/handlers/product/upsertMedia.js.map +1 -0
- package/lib/bulk-importer/handlers/product/upsertVariations.d.ts +79 -0
- package/lib/bulk-importer/handlers/product/upsertVariations.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/product/upsertVariations.js +72 -0
- package/lib/bulk-importer/handlers/product/upsertVariations.js.map +1 -0
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts +3 -0
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js +6 -0
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js.map +1 -0
- package/lib/bulk-importer/handlers/utils/event-schema.d.ts +21 -0
- package/lib/bulk-importer/handlers/utils/event-schema.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/utils/event-schema.js +64 -0
- package/lib/bulk-importer/handlers/utils/event-schema.js.map +1 -0
- package/lib/bulk-importer/index.d.ts +4 -0
- package/lib/bulk-importer/index.d.ts.map +1 -0
- package/lib/bulk-importer/index.js +4 -0
- package/lib/bulk-importer/index.js.map +1 -0
- package/lib/bulk-importer/upsertAsset.d.ts +28 -0
- package/lib/bulk-importer/upsertAsset.d.ts.map +1 -0
- package/lib/bulk-importer/upsertAsset.js +41 -0
- package/lib/bulk-importer/upsertAsset.js.map +1 -0
- package/lib/core-index.d.ts +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.d.ts +3 -3
- package/lib/directors/BaseWorker.d.ts.map +1 -1
- package/lib/directors/BaseWorker.js +12 -12
- package/lib/directors/BaseWorker.js.map +1 -1
- package/lib/directors/DeliveryAdapter.d.ts +4 -5
- package/lib/directors/DeliveryAdapter.d.ts.map +1 -1
- package/lib/directors/DeliveryAdapter.js.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/EventListenerWorker.d.ts.map +1 -1
- package/lib/directors/EventListenerWorker.js +50 -18
- package/lib/directors/EventListenerWorker.js.map +1 -1
- package/lib/directors/FailedRescheduler.d.ts +2 -2
- package/lib/directors/FailedRescheduler.d.ts.map +1 -1
- package/lib/directors/FailedRescheduler.js +1 -1
- package/lib/directors/FailedRescheduler.js.map +1 -1
- package/lib/directors/FilterAdapter.d.ts +4 -4
- 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/IntervalWorker.d.ts.map +1 -1
- package/lib/directors/IntervalWorker.js +27 -9
- package/lib/directors/IntervalWorker.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 +3 -3
- package/lib/directors/ProductPricingDirector.js.map +1 -1
- package/lib/directors/ProductPricingSheet.d.ts +2 -2
- package/lib/directors/ProductPricingSheet.d.ts.map +1 -1
- package/lib/directors/ProductPricingSheet.js +2 -1
- package/lib/directors/ProductPricingSheet.js.map +1 -1
- package/lib/directors/QuotationAdapter.d.ts +2 -2
- package/lib/directors/QuotationAdapter.d.ts.map +1 -1
- package/lib/directors/QuotationDirector.js +2 -2
- package/lib/directors/WarehousingAdapter.d.ts +3 -4
- package/lib/directors/WarehousingAdapter.d.ts.map +1 -1
- package/lib/directors/WarehousingAdapter.js.map +1 -1
- package/lib/directors/WarehousingDirector.d.ts +5 -5
- package/lib/directors/WarehousingDirector.d.ts.map +1 -1
- package/lib/directors/WarehousingDirector.js +10 -13
- package/lib/directors/WarehousingDirector.js.map +1 -1
- package/lib/directors/WorkerAdapter.d.ts +3 -2
- package/lib/directors/WorkerAdapter.d.ts.map +1 -1
- package/lib/directors/WorkerAdapter.js +1 -1
- package/lib/directors/WorkerAdapter.js.map +1 -1
- package/lib/directors/WorkerDirector.d.ts +2 -2
- package/lib/directors/WorkerDirector.d.ts.map +1 -1
- package/lib/directors/WorkerDirector.js +2 -3
- package/lib/directors/WorkerDirector.js.map +1 -1
- package/lib/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.d.ts.map +1 -1
- package/lib/services/removeProduct.js +4 -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.js +3 -3
- 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 +2 -2
- package/lib/services/uploadFileFromStream.d.ts.map +1 -1
- package/lib/services/uploadFileFromStream.js +6 -3
- 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 +23 -22
- 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 +14 -13
- package/src/directors/DeliveryAdapter.ts +3 -5
- 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/EventListenerWorker.ts +59 -19
- package/src/directors/FailedRescheduler.ts +2 -2
- package/src/directors/FilterAdapter.ts +4 -4
- package/src/directors/FilterDirector.ts +11 -12
- package/src/directors/IntervalWorker.ts +30 -9
- 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 +7 -7
- package/src/directors/ProductPricingSheet.ts +4 -3
- package/src/directors/QuotationAdapter.ts +2 -2
- package/src/directors/QuotationDirector.ts +2 -2
- package/src/directors/WarehousingAdapter.ts +3 -4
- package/src/directors/WarehousingDirector.ts +20 -23
- package/src/directors/WorkerAdapter.ts +9 -4
- package/src/directors/WorkerDirector.ts +5 -6
- package/src/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 +5 -3
- package/src/services/searchAssortments.ts +3 -2
- package/src/services/searchProducts.ts +3 -3
- 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 +17 -5
- package/src/services/uploadFileFromURL.ts +2 -2
- package/src/services/validateOrder.ts +34 -38
- package/src/services/verifyQuotation.ts +2 -2
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Modules } from '../../../modules.js';
|
|
3
|
+
import { Services } from '../../../services/index.js';
|
|
4
|
+
import upsertVariations, { ProductVariationSchema } from './upsertVariations.js';
|
|
5
|
+
import upsertMedia, { MediaSchema } from './upsertMedia.js';
|
|
6
|
+
import createProduct, { ProductCreatePayloadSchema } from './create.js';
|
|
7
|
+
import convertTagsToLowerCase from '../utils/convertTagsToLowerCase.js';
|
|
8
|
+
|
|
9
|
+
export const ProductUpdateSpecificationSchema = z.object({
|
|
10
|
+
type: z.string().optional(),
|
|
11
|
+
sequence: z.number().optional(),
|
|
12
|
+
status: z.string().optional().nullable(), // or null!
|
|
13
|
+
published: z.string().datetime().optional().nullable(), // or null!
|
|
14
|
+
tags: z.array(z.string()).optional(),
|
|
15
|
+
commerce: z
|
|
16
|
+
.object({
|
|
17
|
+
pricing: z.array(
|
|
18
|
+
z.object({
|
|
19
|
+
amount: z.number(),
|
|
20
|
+
maxQuantity: z.number().optional(),
|
|
21
|
+
isTaxable: z.boolean().optional(),
|
|
22
|
+
isNetPrice: z.boolean().optional(),
|
|
23
|
+
currencyCode: z.string(),
|
|
24
|
+
countryCode: z.string(),
|
|
25
|
+
}),
|
|
26
|
+
),
|
|
27
|
+
})
|
|
28
|
+
.optional(),
|
|
29
|
+
warehousing: z
|
|
30
|
+
.object({
|
|
31
|
+
sku: z.string().optional(),
|
|
32
|
+
baseUnit: z.string().optional(),
|
|
33
|
+
})
|
|
34
|
+
.optional(),
|
|
35
|
+
supply: z
|
|
36
|
+
.object({
|
|
37
|
+
weightInGram: z.number().optional(),
|
|
38
|
+
heightInMillimeters: z.number().optional(),
|
|
39
|
+
lengthInMillimeters: z.number().optional(),
|
|
40
|
+
widthInMillimeters: z.number().optional(),
|
|
41
|
+
})
|
|
42
|
+
.optional(),
|
|
43
|
+
bundleItems: z
|
|
44
|
+
.array(
|
|
45
|
+
z.object({
|
|
46
|
+
productId: z.string(),
|
|
47
|
+
quantity: z.number(),
|
|
48
|
+
configuration: z.array(
|
|
49
|
+
z.object({
|
|
50
|
+
key: z.string(),
|
|
51
|
+
value: z.string(),
|
|
52
|
+
}),
|
|
53
|
+
),
|
|
54
|
+
}),
|
|
55
|
+
)
|
|
56
|
+
.optional(),
|
|
57
|
+
meta: z.record(z.unknown()).optional(),
|
|
58
|
+
content: z
|
|
59
|
+
.record(
|
|
60
|
+
z.string(), // locale
|
|
61
|
+
z.object({
|
|
62
|
+
title: z.string().optional(),
|
|
63
|
+
subtitle: z.string().optional(),
|
|
64
|
+
slug: z.string().optional(),
|
|
65
|
+
description: z.string().optional(),
|
|
66
|
+
brand: z.string().optional(),
|
|
67
|
+
vendor: z.string().optional(),
|
|
68
|
+
labels: z.array(z.string()).optional(),
|
|
69
|
+
}),
|
|
70
|
+
)
|
|
71
|
+
.optional(),
|
|
72
|
+
variationResolvers: z
|
|
73
|
+
.array(
|
|
74
|
+
z.object({
|
|
75
|
+
vector: z.record(z.string()),
|
|
76
|
+
productId: z.string(),
|
|
77
|
+
}),
|
|
78
|
+
)
|
|
79
|
+
.optional(),
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export const ProductUpdatePayloadSchema = z.object({
|
|
83
|
+
_id: z.string(),
|
|
84
|
+
specification: ProductUpdateSpecificationSchema.optional(),
|
|
85
|
+
media: z.array(MediaSchema).optional(),
|
|
86
|
+
variations: z.array(ProductVariationSchema).optional(),
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const transformSpecification = (specification: z.infer<typeof ProductUpdateSpecificationSchema>) => {
|
|
90
|
+
const {
|
|
91
|
+
variationResolvers: assignments,
|
|
92
|
+
content, // eslint-disable-line
|
|
93
|
+
supply,
|
|
94
|
+
warehousing,
|
|
95
|
+
...productData
|
|
96
|
+
} = specification;
|
|
97
|
+
|
|
98
|
+
const tags = productData?.tags ? convertTagsToLowerCase(productData.tags!)! : [];
|
|
99
|
+
const proxy = assignments ? { assignments } : undefined;
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
...productData,
|
|
103
|
+
published: productData.published ? new Date(productData.published) : undefined,
|
|
104
|
+
tags,
|
|
105
|
+
warehousing,
|
|
106
|
+
supply,
|
|
107
|
+
proxy,
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export default async function updateProduct(
|
|
112
|
+
payload: z.infer<typeof ProductUpdatePayloadSchema>,
|
|
113
|
+
{ logger, updateShouldUpsertIfIDNotExists },
|
|
114
|
+
unchainedAPI: { modules: Modules; services: Services },
|
|
115
|
+
) {
|
|
116
|
+
const { modules } = unchainedAPI;
|
|
117
|
+
const { specification, media, variations, _id } = payload;
|
|
118
|
+
|
|
119
|
+
if (!(await modules.products.productExists({ productId: _id }))) {
|
|
120
|
+
if (updateShouldUpsertIfIDNotExists && payload.specification) {
|
|
121
|
+
return createProduct(
|
|
122
|
+
payload as z.infer<typeof ProductCreatePayloadSchema>,
|
|
123
|
+
{ logger, createShouldUpsertIfIDExists: false },
|
|
124
|
+
unchainedAPI,
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
throw new Error(`Can't update non-existing product ${_id}`);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (specification) {
|
|
131
|
+
const productData = transformSpecification(specification);
|
|
132
|
+
logger.debug('update product object', productData);
|
|
133
|
+
await modules.products.update(_id, {
|
|
134
|
+
...productData,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
if (specification.content) {
|
|
138
|
+
logger.debug('replace localized content for product', specification.content);
|
|
139
|
+
await modules.products.texts.updateTexts(
|
|
140
|
+
_id,
|
|
141
|
+
Object.entries(specification.content).map(([locale, localizedData]: [string, any]) => {
|
|
142
|
+
return {
|
|
143
|
+
locale,
|
|
144
|
+
...localizedData,
|
|
145
|
+
};
|
|
146
|
+
}),
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (variations) {
|
|
152
|
+
logger.debug('replace variations', variations);
|
|
153
|
+
await upsertVariations(
|
|
154
|
+
{
|
|
155
|
+
variations: variations || [],
|
|
156
|
+
productId: _id,
|
|
157
|
+
},
|
|
158
|
+
unchainedAPI,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (media) {
|
|
163
|
+
logger.debug('replace product media', media);
|
|
164
|
+
await upsertMedia({ media, productId: _id }, unchainedAPI);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
entity: 'PRODUCT',
|
|
169
|
+
operation: 'update',
|
|
170
|
+
_id,
|
|
171
|
+
success: true,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
updateProduct.payloadSchema = ProductUpdatePayloadSchema;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ProductMedia } from '@unchainedshop/core-products';
|
|
3
|
+
import { Modules } from '../../../modules.js';
|
|
4
|
+
import { Services } from '../../../services/index.js';
|
|
5
|
+
import convertTagsToLowerCase from '../utils/convertTagsToLowerCase.js';
|
|
6
|
+
import upsertAsset, { AssetSchema } from '../../upsertAsset.js';
|
|
7
|
+
|
|
8
|
+
export const MediaSchema = z.object({
|
|
9
|
+
_id: z.string().optional(),
|
|
10
|
+
asset: AssetSchema,
|
|
11
|
+
content: z
|
|
12
|
+
.record(
|
|
13
|
+
z.string(), // locale
|
|
14
|
+
z.object({
|
|
15
|
+
title: z.string().optional(),
|
|
16
|
+
subtitle: z.string().optional(),
|
|
17
|
+
}),
|
|
18
|
+
)
|
|
19
|
+
.optional(),
|
|
20
|
+
tags: z.array(z.string()).optional(),
|
|
21
|
+
sortKey: z.number().optional(),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const upsertProductMedia = async (productMedia: ProductMedia, { modules }: { modules: Modules }) => {
|
|
25
|
+
try {
|
|
26
|
+
const productMediaObj = await modules.products.media.create(productMedia);
|
|
27
|
+
return productMediaObj;
|
|
28
|
+
} catch {
|
|
29
|
+
const { _id, ...productMediaData } = productMedia;
|
|
30
|
+
const productMediaId = _id;
|
|
31
|
+
return modules.products.media.update(productMediaId, productMediaData);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default async function upsertMedia(
|
|
36
|
+
{ media, productId }: { media: z.infer<typeof MediaSchema>[]; productId: string },
|
|
37
|
+
unchainedAPI: { modules: Modules; services: Services },
|
|
38
|
+
) {
|
|
39
|
+
const { modules } = unchainedAPI;
|
|
40
|
+
|
|
41
|
+
const productMediaObjects = await Promise.all(
|
|
42
|
+
media.map(async ({ asset, content, ...mediaData }) => {
|
|
43
|
+
const tags = mediaData?.tags ? convertTagsToLowerCase(mediaData?.tags)! : [];
|
|
44
|
+
const file = await upsertAsset(
|
|
45
|
+
'product-media',
|
|
46
|
+
{ meta: { ...(asset.meta || {}), productId }, ...asset },
|
|
47
|
+
unchainedAPI,
|
|
48
|
+
);
|
|
49
|
+
if (!file) throw new Error(`Unable to create binary ${asset._id}`);
|
|
50
|
+
const fileId = file._id;
|
|
51
|
+
const productMedia = await upsertProductMedia(
|
|
52
|
+
{
|
|
53
|
+
...mediaData,
|
|
54
|
+
tags,
|
|
55
|
+
productId,
|
|
56
|
+
mediaId: file._id,
|
|
57
|
+
} as ProductMedia,
|
|
58
|
+
unchainedAPI,
|
|
59
|
+
);
|
|
60
|
+
if (!productMedia) throw new Error(`Unable to create product media object for file ${fileId}`);
|
|
61
|
+
|
|
62
|
+
if (content) {
|
|
63
|
+
await modules.products.media.texts.updateMediaTexts(
|
|
64
|
+
productMedia._id,
|
|
65
|
+
Object.entries(content).map(([locale, localizedData]: [string, any]) => {
|
|
66
|
+
return {
|
|
67
|
+
locale,
|
|
68
|
+
...localizedData,
|
|
69
|
+
};
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
return productMedia;
|
|
74
|
+
}),
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
await modules.products.media.deleteMediaFiles({
|
|
78
|
+
productId,
|
|
79
|
+
excludedProductMediaIds: productMediaObjects.map((obj) => obj._id),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ProductVariation } from '@unchainedshop/core-products';
|
|
3
|
+
import { Modules } from '../../../modules.js';
|
|
4
|
+
|
|
5
|
+
const ProductVariationOptionSchema = z.object({
|
|
6
|
+
value: z.string(),
|
|
7
|
+
content: z
|
|
8
|
+
.record(
|
|
9
|
+
z.string(), // locale
|
|
10
|
+
z.object({
|
|
11
|
+
title: z.string().optional(),
|
|
12
|
+
subtitle: z.string().optional(),
|
|
13
|
+
}),
|
|
14
|
+
)
|
|
15
|
+
.optional(),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const ProductVariationSchema = z.object({
|
|
19
|
+
_id: z.string().optional(),
|
|
20
|
+
key: z.string(),
|
|
21
|
+
type: z.string(),
|
|
22
|
+
options: z.array(ProductVariationOptionSchema),
|
|
23
|
+
content: z
|
|
24
|
+
.record(
|
|
25
|
+
z.string(), // locale
|
|
26
|
+
z.object({
|
|
27
|
+
title: z.string().optional(),
|
|
28
|
+
subtitle: z.string().optional(),
|
|
29
|
+
}),
|
|
30
|
+
)
|
|
31
|
+
.optional(),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const upsert = async (
|
|
35
|
+
productVariation: Omit<ProductVariation, '_id' | 'created'> &
|
|
36
|
+
Pick<Partial<ProductVariation>, '_id' | 'created'>,
|
|
37
|
+
unchainedAPI: { modules: Modules },
|
|
38
|
+
) => {
|
|
39
|
+
const { modules } = unchainedAPI;
|
|
40
|
+
try {
|
|
41
|
+
const newVariation = (await modules.products.variations.create(
|
|
42
|
+
productVariation,
|
|
43
|
+
)) as ProductVariation;
|
|
44
|
+
return newVariation;
|
|
45
|
+
} catch {
|
|
46
|
+
return (await modules.products.variations.update(
|
|
47
|
+
productVariation._id!,
|
|
48
|
+
productVariation,
|
|
49
|
+
)) as ProductVariation;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default async function upsertVariations(
|
|
54
|
+
{ variations, productId }: { variations: z.infer<typeof ProductVariationSchema>[]; productId: string },
|
|
55
|
+
unchainedAPI: { modules: Modules },
|
|
56
|
+
) {
|
|
57
|
+
const { modules } = unchainedAPI;
|
|
58
|
+
|
|
59
|
+
const upsertedProductVariationIds = await Promise.all(
|
|
60
|
+
variations.map(async ({ content, options, ...variationsRest }) => {
|
|
61
|
+
const variation = await upsert(
|
|
62
|
+
{
|
|
63
|
+
...variationsRest,
|
|
64
|
+
options: options.map((option) => option.value),
|
|
65
|
+
productId,
|
|
66
|
+
},
|
|
67
|
+
unchainedAPI,
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
await Promise.all(
|
|
71
|
+
options.map(async ({ content: optionContent, value: optionValue }) => {
|
|
72
|
+
if (optionContent) {
|
|
73
|
+
await modules.products.variations.texts.updateVariationTexts(
|
|
74
|
+
variation._id,
|
|
75
|
+
Object.entries(optionContent).map(([locale, localizedData]: [string, any]) => {
|
|
76
|
+
return {
|
|
77
|
+
locale,
|
|
78
|
+
...localizedData,
|
|
79
|
+
};
|
|
80
|
+
}),
|
|
81
|
+
optionValue,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
86
|
+
if (content) {
|
|
87
|
+
await modules.products.variations.texts.updateVariationTexts(
|
|
88
|
+
variation._id,
|
|
89
|
+
Object.entries(content).map(([locale, localizedData]: [string, any]) => {
|
|
90
|
+
return {
|
|
91
|
+
locale,
|
|
92
|
+
...localizedData,
|
|
93
|
+
};
|
|
94
|
+
}),
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
return variation._id;
|
|
98
|
+
}),
|
|
99
|
+
);
|
|
100
|
+
const allVariations = await modules.products.variations.findProductVariations({
|
|
101
|
+
productId,
|
|
102
|
+
});
|
|
103
|
+
await Promise.all(
|
|
104
|
+
allVariations.map(async (variation) => {
|
|
105
|
+
if (!upsertedProductVariationIds.includes(variation._id)) {
|
|
106
|
+
await modules.products.variations.delete(variation._id);
|
|
107
|
+
}
|
|
108
|
+
}),
|
|
109
|
+
);
|
|
110
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Modules } from '../modules.js';
|
|
2
|
+
import { Services } from '../services/index.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
export const AssetSchema = z.object({
|
|
6
|
+
_id: z.string().optional(),
|
|
7
|
+
url: z.string(),
|
|
8
|
+
meta: z.record(z.unknown()).optional(),
|
|
9
|
+
fileName: z.string(),
|
|
10
|
+
headers: z.record(z.string()).optional(),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const upsertAsset = async (
|
|
14
|
+
directoryName: string,
|
|
15
|
+
asset: z.infer<typeof AssetSchema>,
|
|
16
|
+
unchainedAPI: { modules: Modules; services: Services },
|
|
17
|
+
) => {
|
|
18
|
+
const { modules, services } = unchainedAPI;
|
|
19
|
+
const { _id: fileId, fileName, url, meta, headers, ...assetData } = asset;
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
const existingFile = fileId && (await modules.files.findFile({ fileId }));
|
|
23
|
+
if (existingFile) {
|
|
24
|
+
if (JSON.stringify(meta) === JSON.stringify(existingFile.meta)) {
|
|
25
|
+
return existingFile;
|
|
26
|
+
}
|
|
27
|
+
await modules.files.update(fileId, { meta, ...assetData });
|
|
28
|
+
const updatedFile = await modules.files.findFile({ fileId });
|
|
29
|
+
return updatedFile;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const assetObject = await services.files.uploadFileFromURL({
|
|
33
|
+
directoryName,
|
|
34
|
+
fileInput: {
|
|
35
|
+
fileLink: url,
|
|
36
|
+
fileName,
|
|
37
|
+
fileId,
|
|
38
|
+
headers,
|
|
39
|
+
},
|
|
40
|
+
meta,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (!assetObject) throw new Error('Media not created');
|
|
44
|
+
return assetObject;
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default upsertAsset;
|
package/src/core-index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { mongodb, MigrationRepository, ModuleInput } from '@unchainedshop/mongodb';
|
|
2
2
|
import initServices, { CustomServices, Services } from './services/index.js';
|
|
3
3
|
import initModules, { Modules, ModuleOptions } from './modules.js';
|
|
4
|
+
import createBulkImporterFactory, { BulkImporter, BulkImportHandler } from './bulk-importer/index.js';
|
|
4
5
|
|
|
5
6
|
import {
|
|
6
7
|
WorkerDirector,
|
|
@@ -17,18 +18,19 @@ import {
|
|
|
17
18
|
QuotationDirector,
|
|
18
19
|
WarehousingDirector,
|
|
19
20
|
} from './directors/index.js';
|
|
21
|
+
import { IBaseAdapter } from '@unchainedshop/utils';
|
|
20
22
|
|
|
23
|
+
export * from './bulk-importer/index.js';
|
|
21
24
|
export * from './services/index.js';
|
|
22
25
|
export * from './directors/index.js';
|
|
23
|
-
|
|
24
|
-
export interface BulkImporter {
|
|
25
|
-
createBulkImporter: (options: any) => any;
|
|
26
|
-
}
|
|
26
|
+
export * from './factory/index.js';
|
|
27
27
|
|
|
28
28
|
export interface UnchainedCoreOptions {
|
|
29
29
|
db: mongodb.Db;
|
|
30
30
|
migrationRepository: MigrationRepository<UnchainedCore>;
|
|
31
|
-
bulkImporter
|
|
31
|
+
bulkImporter?: {
|
|
32
|
+
handlers?: Record<string, BulkImportHandler<UnchainedCore>>;
|
|
33
|
+
};
|
|
32
34
|
modules?: Record<
|
|
33
35
|
string,
|
|
34
36
|
{
|
|
@@ -49,13 +51,14 @@ export interface UnchainedCore {
|
|
|
49
51
|
export const initCore = async ({
|
|
50
52
|
db,
|
|
51
53
|
migrationRepository,
|
|
52
|
-
bulkImporter,
|
|
54
|
+
bulkImporter: bulkImporterOptions = {},
|
|
53
55
|
modules: customModules = {},
|
|
54
56
|
services: customServices = {},
|
|
55
57
|
options = {},
|
|
56
58
|
}: UnchainedCoreOptions): Promise<UnchainedCore> => {
|
|
57
59
|
// Configure custom modules
|
|
58
60
|
|
|
61
|
+
const bulkImporter = createBulkImporterFactory(db, bulkImporterOptions);
|
|
59
62
|
const modules = await initModules({ db, migrationRepository, options }, customModules);
|
|
60
63
|
const services = initServices(modules, customServices);
|
|
61
64
|
|
|
@@ -82,7 +85,7 @@ export const getAllAdapters = () => {
|
|
|
82
85
|
const quotation = QuotationDirector.getAdapters();
|
|
83
86
|
const warehousing = WarehousingDirector.getAdapters();
|
|
84
87
|
|
|
85
|
-
return [].concat(
|
|
88
|
+
return ([] as IBaseAdapter[]).concat(
|
|
86
89
|
worker,
|
|
87
90
|
delivery,
|
|
88
91
|
deliveryPricing,
|
|
@@ -32,7 +32,7 @@ describe('BaseDiscountAdapter instantiation', () => {
|
|
|
32
32
|
|
|
33
33
|
it('release', async () => {
|
|
34
34
|
const result = await adapter.actions(context);
|
|
35
|
-
assert.equal(await result.release(),
|
|
35
|
+
assert.equal(await result.release(), undefined);
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
it('isValidForCodeTriggering', async () => {
|
|
@@ -6,13 +6,13 @@ import { Modules } from '../modules.js';
|
|
|
6
6
|
export interface DiscountContext {
|
|
7
7
|
code?: string;
|
|
8
8
|
orderDiscount?: OrderDiscount;
|
|
9
|
-
order
|
|
9
|
+
order: Order;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export type IDiscountAdapter<DiscountConfiguration> = IBaseAdapter & {
|
|
13
13
|
orderIndex: number;
|
|
14
14
|
|
|
15
|
-
isManualAdditionAllowed: (code
|
|
15
|
+
isManualAdditionAllowed: (code?: string) => Promise<boolean>;
|
|
16
16
|
isManualRemovalAllowed: () => Promise<boolean>;
|
|
17
17
|
|
|
18
18
|
actions: (params: {
|
|
@@ -27,9 +27,9 @@ export interface DiscountAdapterActions<DiscountConfiguration> {
|
|
|
27
27
|
discountForPricingAdapterKey: (params: {
|
|
28
28
|
pricingAdapterKey: string;
|
|
29
29
|
calculationSheet: IPricingSheet<PricingCalculation>;
|
|
30
|
-
}) => DiscountConfiguration;
|
|
30
|
+
}) => DiscountConfiguration | null;
|
|
31
31
|
|
|
32
|
-
reserve: (params: { code
|
|
32
|
+
reserve: (params: { code?: string }) => Promise<any>;
|
|
33
33
|
release: () => Promise<void>;
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -67,7 +67,7 @@ export const BaseDiscountAdapter: Omit<IDiscountAdapter<unknown>, 'key' | 'label
|
|
|
67
67
|
|
|
68
68
|
// return void, allows you to free up any reservations in backend systems
|
|
69
69
|
release: async () => {
|
|
70
|
-
return
|
|
70
|
+
return;
|
|
71
71
|
},
|
|
72
72
|
|
|
73
73
|
// return true if a discount is valid to be part of the order.
|
|
@@ -11,7 +11,7 @@ export type IDiscountDirector<DiscountConfiguration> = IBaseDirector<
|
|
|
11
11
|
) => Promise<{
|
|
12
12
|
resolveDiscountAdapterFromStaticCode: (params: {
|
|
13
13
|
code: string;
|
|
14
|
-
}) => Promise<IDiscountAdapter<DiscountConfiguration
|
|
14
|
+
}) => Promise<IDiscountAdapter<DiscountConfiguration> | null>;
|
|
15
15
|
findSystemDiscounts: () => Promise<string[]>;
|
|
16
16
|
}>;
|
|
17
17
|
};
|
|
@@ -46,7 +46,7 @@ export const BaseDiscountDirector = <DiscountConfigurationType>(
|
|
|
46
46
|
}),
|
|
47
47
|
);
|
|
48
48
|
|
|
49
|
-
return discounts.find(({ isValid }) => isValid === true)?.Adapter;
|
|
49
|
+
return discounts.find(({ isValid }) => isValid === true)?.Adapter || null;
|
|
50
50
|
},
|
|
51
51
|
|
|
52
52
|
async findSystemDiscounts() {
|
|
@@ -4,7 +4,7 @@ import { Discount } from './BasePricingDirector.js';
|
|
|
4
4
|
import { Order, OrderDiscount } from '@unchainedshop/core-orders';
|
|
5
5
|
|
|
6
6
|
interface IDiscountableItem {
|
|
7
|
-
_id
|
|
7
|
+
_id: string;
|
|
8
8
|
orderId?: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -26,7 +26,7 @@ export interface IPricingAdapterActions<
|
|
|
26
26
|
Calculation extends PricingCalculation,
|
|
27
27
|
Sheet extends IPricingSheet<Calculation>,
|
|
28
28
|
> {
|
|
29
|
-
calculate: () => Promise<Calculation[]>;
|
|
29
|
+
calculate: () => Promise<Calculation[] | null>;
|
|
30
30
|
resultSheet: () => Sheet;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -70,7 +70,7 @@ export const BasePricingDirector = <
|
|
|
70
70
|
async rebuildCalculation(this: typeof director, pricingContext, unchainedAPI) {
|
|
71
71
|
const context = await this.buildPricingContext(pricingContext, unchainedAPI);
|
|
72
72
|
|
|
73
|
-
let calculation: Calculation[] = [];
|
|
73
|
+
let calculation: Calculation[] | null = [];
|
|
74
74
|
|
|
75
75
|
const Adapters = baseDirector.getAdapters({
|
|
76
76
|
adapterFilter: (Adapter) => {
|
|
@@ -78,52 +78,55 @@ export const BasePricingDirector = <
|
|
|
78
78
|
},
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
calculation = await Adapters.reduce(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
81
|
+
calculation = await Adapters.reduce(
|
|
82
|
+
async (previousPromise, Adapter) => {
|
|
83
|
+
const resolvedCalculation = await previousPromise;
|
|
84
|
+
if (!resolvedCalculation) return null;
|
|
85
|
+
|
|
86
|
+
const discounts: (Discount<any> | null)[] = await Promise.all(
|
|
87
|
+
context.discounts.map(async (orderDiscount) => {
|
|
88
|
+
const order = await unchainedAPI.modules.orders.findOrder({
|
|
89
|
+
orderId: orderDiscount.orderId,
|
|
90
|
+
});
|
|
91
|
+
const DiscountAdapter = OrderDiscountDirector.getAdapter(orderDiscount.discountKey);
|
|
92
|
+
if (!DiscountAdapter) return null;
|
|
93
|
+
|
|
94
|
+
const adapter = await DiscountAdapter.actions({
|
|
95
|
+
context: { order, orderDiscount, code: orderDiscount.code, ...unchainedAPI },
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const configuration = adapter.discountForPricingAdapterKey({
|
|
99
|
+
pricingAdapterKey: Adapter.key,
|
|
100
|
+
calculationSheet: this.calculationSheet(pricingContext, resolvedCalculation),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
discountId: orderDiscount._id,
|
|
105
|
+
configuration,
|
|
106
|
+
};
|
|
107
|
+
}),
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
const adapter = Adapter.actions({
|
|
112
|
+
context,
|
|
113
|
+
calculationSheet: this.calculationSheet(pricingContext, resolvedCalculation),
|
|
114
|
+
discounts: discounts.filter((d) => d?.configuration !== null) as Discount<any>[],
|
|
95
115
|
});
|
|
96
116
|
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
117
|
+
const nextCalculationResult = await adapter.calculate();
|
|
118
|
+
if (!nextCalculationResult) return null;
|
|
119
|
+
calculation = resolvedCalculation.concat(nextCalculationResult);
|
|
120
|
+
return calculation;
|
|
121
|
+
} catch (error) {
|
|
122
|
+
logger.error(error);
|
|
123
|
+
}
|
|
124
|
+
return resolvedCalculation;
|
|
125
|
+
},
|
|
126
|
+
Promise.resolve([] as Calculation[]),
|
|
127
|
+
);
|
|
101
128
|
|
|
102
|
-
|
|
103
|
-
discountId: orderDiscount._id,
|
|
104
|
-
configuration,
|
|
105
|
-
};
|
|
106
|
-
}),
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
try {
|
|
110
|
-
const adapter = Adapter.actions({
|
|
111
|
-
context,
|
|
112
|
-
calculationSheet: this.calculationSheet(pricingContext, calculation),
|
|
113
|
-
discounts: discounts.filter((d) => d?.configuration !== null),
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
const nextCalculationResult = await adapter.calculate();
|
|
117
|
-
if (!nextCalculationResult) return null;
|
|
118
|
-
calculation = resolvedCalculation.concat(nextCalculationResult);
|
|
119
|
-
return calculation;
|
|
120
|
-
} catch (error) {
|
|
121
|
-
logger.error(error);
|
|
122
|
-
}
|
|
123
|
-
return resolvedCalculation;
|
|
124
|
-
}, Promise.resolve([]));
|
|
125
|
-
|
|
126
|
-
return calculation;
|
|
129
|
+
return calculation || ([] as Calculation[]);
|
|
127
130
|
},
|
|
128
131
|
};
|
|
129
132
|
|
|
@@ -93,7 +93,7 @@ export const BasePricingSheet = <Calculation extends PricingCalculation>(
|
|
|
93
93
|
(oldCalculation, filterKey) =>
|
|
94
94
|
oldCalculation.filter(
|
|
95
95
|
(row: Calculation) =>
|
|
96
|
-
!!row && (filter[filterKey] === undefined || row[filterKey] === filter[filterKey]),
|
|
96
|
+
!!row && (filter![filterKey] === undefined || row[filterKey] === filter![filterKey]),
|
|
97
97
|
),
|
|
98
98
|
this.calculation,
|
|
99
99
|
);
|