@unchainedshop/core 4.0.0-rc.16 → 4.0.0-rc.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bulk-importer/createBulkImporter.d.ts +29 -6
- package/lib/bulk-importer/createBulkImporter.d.ts.map +1 -1
- package/lib/bulk-importer/createBulkImporter.js +26 -19
- package/lib/bulk-importer/createBulkImporter.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/create.d.ts +552 -2
- package/lib/bulk-importer/handlers/assortment/create.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/create.js +32 -5
- package/lib/bulk-importer/handlers/assortment/create.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/remove.d.ts +20 -2
- package/lib/bulk-importer/handlers/assortment/remove.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/remove.js +7 -2
- package/lib/bulk-importer/handlers/assortment/remove.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/update.d.ts +552 -2
- package/lib/bulk-importer/handlers/assortment/update.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/update.js +43 -7
- package/lib/bulk-importer/handlers/assortment/update.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts +23 -3
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js +14 -6
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts +23 -3
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js +15 -6
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts +23 -3
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js +17 -8
- package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts +67 -2
- package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js +18 -4
- package/lib/bulk-importer/handlers/assortment/upsertMedia.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/create.d.ts +125 -0
- package/lib/bulk-importer/handlers/filter/create.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/filter/create.js +22 -0
- package/lib/bulk-importer/handlers/filter/create.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/remove.d.ts +10 -2
- package/lib/bulk-importer/handlers/filter/remove.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/filter/remove.js +4 -0
- package/lib/bulk-importer/handlers/filter/remove.js.map +1 -1
- package/lib/bulk-importer/handlers/filter/update.d.ts +125 -0
- package/lib/bulk-importer/handlers/filter/update.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/filter/update.js +22 -0
- package/lib/bulk-importer/handlers/filter/update.js.map +1 -1
- package/lib/bulk-importer/handlers/product/create.d.ts +1317 -2
- package/lib/bulk-importer/handlers/product/create.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/create.js +87 -8
- package/lib/bulk-importer/handlers/product/create.js.map +1 -1
- package/lib/bulk-importer/handlers/product/remove.d.ts +20 -2
- package/lib/bulk-importer/handlers/product/remove.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/remove.js +5 -0
- package/lib/bulk-importer/handlers/product/remove.js.map +1 -1
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts +278 -1
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js +64 -3
- package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js.map +1 -1
- package/lib/bulk-importer/handlers/product/update.d.ts +1317 -2
- package/lib/bulk-importer/handlers/product/update.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/update.js +89 -5
- package/lib/bulk-importer/handlers/product/update.js.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertMedia.d.ts +67 -2
- package/lib/bulk-importer/handlers/product/upsertMedia.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertMedia.js +16 -2
- package/lib/bulk-importer/handlers/product/upsertMedia.js.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertVariations.d.ts +73 -2
- package/lib/bulk-importer/handlers/product/upsertVariations.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/product/upsertVariations.js +26 -2
- package/lib/bulk-importer/handlers/product/upsertVariations.js.map +1 -1
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts +1 -1
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts.map +1 -1
- package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js.map +1 -1
- package/lib/bulk-importer/handlers/utils/event-schema.d.ts +21 -0
- package/lib/bulk-importer/handlers/utils/event-schema.d.ts.map +1 -0
- package/lib/bulk-importer/handlers/utils/event-schema.js +64 -0
- package/lib/bulk-importer/handlers/utils/event-schema.js.map +1 -0
- package/lib/bulk-importer/index.d.ts +4 -0
- package/lib/bulk-importer/index.d.ts.map +1 -0
- package/lib/bulk-importer/index.js +4 -0
- package/lib/bulk-importer/index.js.map +1 -0
- package/lib/bulk-importer/upsertAsset.d.ts +21 -5
- package/lib/bulk-importer/upsertAsset.d.ts.map +1 -1
- package/lib/bulk-importer/upsertAsset.js +8 -0
- package/lib/bulk-importer/upsertAsset.js.map +1 -1
- package/lib/core-index.d.ts +4 -3
- package/lib/core-index.d.ts.map +1 -1
- package/lib/core-index.js +2 -2
- package/lib/core-index.js.map +1 -1
- package/lib/directors/BaseDiscountAdapter.d.ts +4 -4
- package/lib/directors/BaseDiscountAdapter.d.ts.map +1 -1
- package/lib/directors/BaseDiscountAdapter.js +1 -1
- package/lib/directors/BaseDiscountAdapter.js.map +1 -1
- package/lib/directors/BaseDiscountDirector.d.ts +1 -1
- package/lib/directors/BaseDiscountDirector.d.ts.map +1 -1
- package/lib/directors/BaseDiscountDirector.js +1 -1
- package/lib/directors/BaseDiscountDirector.js.map +1 -1
- package/lib/directors/BasePricingAdapter.d.ts +2 -2
- package/lib/directors/BasePricingAdapter.d.ts.map +1 -1
- package/lib/directors/BasePricingDirector.d.ts.map +1 -1
- package/lib/directors/BasePricingDirector.js +3 -3
- package/lib/directors/BasePricingDirector.js.map +1 -1
- package/lib/directors/BasePricingSheet.js.map +1 -1
- package/lib/directors/BaseWorker.js +1 -1
- package/lib/directors/BaseWorker.js.map +1 -1
- package/lib/directors/DeliveryAdapter.d.ts +3 -3
- package/lib/directors/DeliveryAdapter.d.ts.map +1 -1
- package/lib/directors/DeliveryDirector.d.ts +3 -3
- package/lib/directors/DeliveryDirector.d.ts.map +1 -1
- package/lib/directors/DeliveryDirector.js +29 -16
- package/lib/directors/DeliveryDirector.js.map +1 -1
- package/lib/directors/DeliveryPricingAdapter.d.ts +1 -1
- package/lib/directors/DeliveryPricingAdapter.d.ts.map +1 -1
- package/lib/directors/DeliveryPricingDirector.d.ts.map +1 -1
- package/lib/directors/DeliveryPricingDirector.js +3 -4
- package/lib/directors/DeliveryPricingDirector.js.map +1 -1
- package/lib/directors/DeliveryPricingSheet.d.ts.map +1 -1
- package/lib/directors/DeliveryPricingSheet.js +2 -1
- package/lib/directors/DeliveryPricingSheet.js.map +1 -1
- package/lib/directors/EnrollmentAdapter.d.ts +7 -4
- package/lib/directors/EnrollmentAdapter.d.ts.map +1 -1
- package/lib/directors/EnrollmentAdapter.js +1 -4
- package/lib/directors/EnrollmentAdapter.js.map +1 -1
- package/lib/directors/EnrollmentDirector.d.ts +1 -1
- package/lib/directors/EnrollmentDirector.d.ts.map +1 -1
- package/lib/directors/EnrollmentDirector.js +1 -5
- package/lib/directors/EnrollmentDirector.js.map +1 -1
- package/lib/directors/FilterAdapter.d.ts +3 -3
- package/lib/directors/FilterAdapter.d.ts.map +1 -1
- package/lib/directors/FilterDirector.d.ts +1 -1
- package/lib/directors/FilterDirector.d.ts.map +1 -1
- package/lib/directors/FilterDirector.js +1 -1
- package/lib/directors/FilterDirector.js.map +1 -1
- package/lib/directors/MessagingDirector.d.ts +1 -1
- package/lib/directors/OrderDiscountAdapter.d.ts +1 -1
- package/lib/directors/OrderDiscountAdapter.d.ts.map +1 -1
- package/lib/directors/OrderDiscountAdapter.js.map +1 -1
- package/lib/directors/OrderPricingAdapter.d.ts +2 -2
- package/lib/directors/OrderPricingAdapter.d.ts.map +1 -1
- package/lib/directors/OrderPricingDirector.d.ts +2 -2
- package/lib/directors/OrderPricingDirector.d.ts.map +1 -1
- package/lib/directors/OrderPricingDirector.js +1 -1
- package/lib/directors/OrderPricingDirector.js.map +1 -1
- package/lib/directors/OrderPricingSheet.d.ts.map +1 -1
- package/lib/directors/OrderPricingSheet.js +2 -1
- package/lib/directors/OrderPricingSheet.js.map +1 -1
- package/lib/directors/PaymentAdapter.d.ts +2 -2
- package/lib/directors/PaymentAdapter.d.ts.map +1 -1
- package/lib/directors/PaymentDirector.d.ts +4 -4
- package/lib/directors/PaymentDirector.d.ts.map +1 -1
- package/lib/directors/PaymentDirector.js +22 -4
- package/lib/directors/PaymentDirector.js.map +1 -1
- package/lib/directors/PaymentPricingAdapter.d.ts +2 -2
- package/lib/directors/PaymentPricingAdapter.d.ts.map +1 -1
- package/lib/directors/PaymentPricingDirector.d.ts +1 -1
- package/lib/directors/PaymentPricingDirector.d.ts.map +1 -1
- package/lib/directors/PaymentPricingDirector.js +3 -5
- package/lib/directors/PaymentPricingDirector.js.map +1 -1
- package/lib/directors/PaymentPricingSheet.d.ts.map +1 -1
- package/lib/directors/PaymentPricingSheet.js +2 -1
- package/lib/directors/PaymentPricingSheet.js.map +1 -1
- package/lib/directors/ProductDiscountAdapter.d.ts +1 -1
- package/lib/directors/ProductDiscountAdapter.d.ts.map +1 -1
- package/lib/directors/ProductDiscountAdapter.js.map +1 -1
- package/lib/directors/ProductDiscountConfiguration.d.ts +1 -1
- package/lib/directors/ProductDiscountConfiguration.d.ts.map +1 -1
- package/lib/directors/ProductPricingAdapter.d.ts +1 -1
- package/lib/directors/ProductPricingAdapter.d.ts.map +1 -1
- package/lib/directors/ProductPricingDirector.d.ts +2 -2
- package/lib/directors/ProductPricingDirector.d.ts.map +1 -1
- package/lib/directors/ProductPricingDirector.js +3 -3
- package/lib/directors/ProductPricingDirector.js.map +1 -1
- package/lib/directors/ProductPricingSheet.d.ts +2 -2
- package/lib/directors/ProductPricingSheet.d.ts.map +1 -1
- package/lib/directors/ProductPricingSheet.js +2 -1
- package/lib/directors/ProductPricingSheet.js.map +1 -1
- package/lib/directors/QuotationAdapter.d.ts +2 -2
- package/lib/directors/QuotationAdapter.d.ts.map +1 -1
- package/lib/directors/QuotationDirector.js +2 -2
- package/lib/directors/WarehousingAdapter.d.ts +3 -4
- package/lib/directors/WarehousingAdapter.d.ts.map +1 -1
- package/lib/directors/WarehousingAdapter.js.map +1 -1
- package/lib/directors/WarehousingDirector.d.ts +5 -5
- package/lib/directors/WarehousingDirector.d.ts.map +1 -1
- package/lib/directors/WarehousingDirector.js +10 -13
- package/lib/directors/WarehousingDirector.js.map +1 -1
- package/lib/directors/WorkerAdapter.d.ts +1 -1
- package/lib/directors/WorkerAdapter.d.ts.map +1 -1
- package/lib/directors/WorkerAdapter.js +1 -1
- package/lib/directors/WorkerAdapter.js.map +1 -1
- package/lib/directors/WorkerDirector.d.ts +2 -2
- package/lib/directors/WorkerDirector.d.ts.map +1 -1
- package/lib/directors/WorkerDirector.js +2 -3
- package/lib/directors/WorkerDirector.js.map +1 -1
- package/lib/modules.d.ts +1 -1
- package/lib/modules.d.ts.map +1 -1
- package/lib/services/activateEnrollment.js +3 -3
- package/lib/services/activateEnrollment.js.map +1 -1
- package/lib/services/calculateDiscountTotal.js +2 -2
- package/lib/services/calculateDiscountTotal.js.map +1 -1
- package/lib/services/checkoutOrder.d.ts +1 -1
- package/lib/services/checkoutOrder.d.ts.map +1 -1
- package/lib/services/checkoutOrder.js +9 -3
- package/lib/services/checkoutOrder.js.map +1 -1
- package/lib/services/confirmOrder.d.ts +1 -1
- package/lib/services/confirmOrder.d.ts.map +1 -1
- package/lib/services/createDownloadStream.d.ts +1 -1
- package/lib/services/createDownloadStream.d.ts.map +1 -1
- package/lib/services/createDownloadStream.js +2 -0
- package/lib/services/createDownloadStream.js.map +1 -1
- package/lib/services/createEnrollmentFromCheckout.d.ts.map +1 -1
- package/lib/services/createEnrollmentFromCheckout.js +2 -2
- package/lib/services/createEnrollmentFromCheckout.js.map +1 -1
- package/lib/services/createManualOrderDiscount.d.ts +2 -2
- package/lib/services/createManualOrderDiscount.d.ts.map +1 -1
- package/lib/services/createSignedURL.d.ts.map +1 -1
- package/lib/services/createSignedURL.js +2 -0
- package/lib/services/createSignedURL.js.map +1 -1
- package/lib/services/deleteUser.d.ts +1 -1
- package/lib/services/deleteUser.d.ts.map +1 -1
- package/lib/services/deleteUser.js +4 -2
- package/lib/services/deleteUser.js.map +1 -1
- package/lib/services/discountedEntities.js.map +1 -1
- package/lib/services/findOrInitCart.d.ts +1 -2
- package/lib/services/findOrInitCart.d.ts.map +1 -1
- package/lib/services/findOrInitCart.js.map +1 -1
- package/lib/services/fullfillQuotation.d.ts +1 -1
- package/lib/services/fullfillQuotation.d.ts.map +1 -1
- package/lib/services/fullfillQuotation.js.map +1 -1
- package/lib/services/generateOrderFromEnrollment.d.ts +7 -0
- package/lib/services/generateOrderFromEnrollment.d.ts.map +1 -0
- package/lib/services/generateOrderFromEnrollment.js +34 -0
- package/lib/services/generateOrderFromEnrollment.js.map +1 -0
- package/lib/services/index.d.ts +2 -0
- package/lib/services/index.d.ts.map +1 -1
- package/lib/services/index.js +2 -0
- package/lib/services/index.js.map +1 -1
- package/lib/services/initCartProviders.js.map +1 -1
- package/lib/services/initializeEnrollment.d.ts +1 -1
- package/lib/services/initializeEnrollment.d.ts.map +1 -1
- package/lib/services/initializeEnrollment.js +6 -3
- package/lib/services/initializeEnrollment.js.map +1 -1
- package/lib/services/linkFileService.d.ts +1 -1
- package/lib/services/linkFileService.d.ts.map +1 -1
- package/lib/services/linkFileService.js +3 -1
- package/lib/services/linkFileService.js.map +1 -1
- package/lib/services/loadFilterOptions.d.ts +2 -2
- package/lib/services/loadFilterOptions.d.ts.map +1 -1
- package/lib/services/migrateOrderCart.d.ts +1 -1
- package/lib/services/migrateOrderCart.d.ts.map +1 -1
- package/lib/services/nextUserCart.d.ts +1 -1
- package/lib/services/nextUserCart.d.ts.map +1 -1
- package/lib/services/nextUserCart.js +1 -1
- package/lib/services/nextUserCart.js.map +1 -1
- package/lib/services/processEnrollment.d.ts.map +1 -1
- package/lib/services/processEnrollment.js +13 -5
- package/lib/services/processEnrollment.js.map +1 -1
- package/lib/services/processOrder.d.ts.map +1 -1
- package/lib/services/processOrder.js +26 -30
- package/lib/services/processOrder.js.map +1 -1
- package/lib/services/processQuotation.js +6 -6
- package/lib/services/processQuotation.js.map +1 -1
- package/lib/services/proposeQuotation.d.ts +1 -1
- package/lib/services/proposeQuotation.d.ts.map +1 -1
- package/lib/services/proposeQuotation.js +2 -2
- package/lib/services/proposeQuotation.js.map +1 -1
- package/lib/services/registerPaymentCredentials.d.ts +1 -2
- package/lib/services/registerPaymentCredentials.d.ts.map +1 -1
- package/lib/services/registerPaymentCredentials.js +4 -6
- package/lib/services/registerPaymentCredentials.js.map +1 -1
- package/lib/services/rejectOrder.d.ts +1 -1
- package/lib/services/rejectOrder.d.ts.map +1 -1
- package/lib/services/rejectQuotation.d.ts +1 -1
- package/lib/services/rejectQuotation.d.ts.map +1 -1
- package/lib/services/rejectQuotation.js +2 -2
- package/lib/services/rejectQuotation.js.map +1 -1
- package/lib/services/removeProduct.js +3 -3
- package/lib/services/removeProduct.js.map +1 -1
- package/lib/services/searchAssortments.js +1 -1
- package/lib/services/searchAssortments.js.map +1 -1
- package/lib/services/searchProducts.js +1 -1
- package/lib/services/searchProducts.js.map +1 -1
- package/lib/services/simulateProductDispatching.d.ts +1 -1
- package/lib/services/simulateProductDispatching.d.ts.map +1 -1
- package/lib/services/simulateProductInventory.d.ts +1 -1
- package/lib/services/simulateProductInventory.d.ts.map +1 -1
- package/lib/services/simulateProductInventory.js.map +1 -1
- package/lib/services/simulateProductPricing.d.ts +7 -4
- package/lib/services/simulateProductPricing.d.ts.map +1 -1
- package/lib/services/simulateProductPricing.js.map +1 -1
- package/lib/services/updateCalculation.d.ts +2 -1
- package/lib/services/updateCalculation.d.ts.map +1 -1
- package/lib/services/updateCalculation.js +16 -10
- package/lib/services/updateCalculation.js.map +1 -1
- package/lib/services/updateScheduling.d.ts +1 -1
- package/lib/services/updateScheduling.d.ts.map +1 -1
- package/lib/services/updateScheduling.js +7 -11
- package/lib/services/updateScheduling.js.map +1 -1
- package/lib/services/updateUserAvatarAfterUpload.d.ts +1 -1
- package/lib/services/updateUserAvatarAfterUpload.d.ts.map +1 -1
- package/lib/services/updateUserAvatarAfterUpload.js.map +1 -1
- package/lib/services/uploadFileFromStream.d.ts.map +1 -1
- package/lib/services/uploadFileFromStream.js +4 -1
- package/lib/services/uploadFileFromStream.js.map +1 -1
- package/lib/services/uploadFileFromURL.d.ts +1 -2
- package/lib/services/uploadFileFromURL.d.ts.map +1 -1
- package/lib/services/uploadFileFromURL.js.map +1 -1
- package/lib/services/validateOrder.d.ts +1 -1
- package/lib/services/validateOrder.d.ts.map +1 -1
- package/lib/services/validateOrder.js +17 -24
- package/lib/services/validateOrder.js.map +1 -1
- package/lib/services/verifyQuotation.d.ts +1 -1
- package/lib/services/verifyQuotation.d.ts.map +1 -1
- package/lib/services/verifyQuotation.js +2 -2
- package/lib/services/verifyQuotation.js.map +1 -1
- package/package.json +20 -20
- package/src/bulk-importer/createBulkImporter.ts +34 -22
- package/src/bulk-importer/handlers/assortment/create.ts +38 -7
- package/src/bulk-importer/handlers/assortment/remove.ts +14 -3
- package/src/bulk-importer/handlers/assortment/update.ts +53 -9
- package/src/bulk-importer/handlers/assortment/upsertAssortmentChildren.ts +44 -19
- package/src/bulk-importer/handlers/assortment/upsertAssortmentFilters.ts +37 -9
- package/src/bulk-importer/handlers/assortment/upsertAssortmentProducts.ts +35 -9
- package/src/bulk-importer/handlers/assortment/upsertMedia.ts +23 -5
- package/src/bulk-importer/handlers/filter/create.ts +28 -0
- package/src/bulk-importer/handlers/filter/remove.ts +6 -1
- package/src/bulk-importer/handlers/filter/update.ts +28 -1
- package/src/bulk-importer/handlers/product/create.ts +109 -9
- package/src/bulk-importer/handlers/product/remove.ts +7 -1
- package/src/bulk-importer/handlers/product/update.ts +117 -8
- package/src/bulk-importer/handlers/product/upsertMedia.ts +20 -3
- package/src/bulk-importer/handlers/product/upsertVariations.ts +43 -4
- package/src/bulk-importer/handlers/utils/convertTagsToLowerCase.ts +1 -1
- package/src/bulk-importer/index.ts +3 -0
- package/src/bulk-importer/upsertAsset.ts +10 -2
- package/src/core-index.ts +4 -6
- package/src/directors/BaseDiscountAdapter.test.ts +1 -1
- package/src/directors/BaseDiscountAdapter.ts +5 -5
- package/src/directors/BaseDiscountDirector.ts +2 -2
- package/src/directors/BasePricingAdapter.ts +2 -2
- package/src/directors/BasePricingDirector.ts +47 -44
- package/src/directors/BasePricingSheet.ts +1 -1
- package/src/directors/BaseWorker.ts +1 -1
- package/src/directors/DeliveryAdapter.ts +3 -3
- package/src/directors/DeliveryDirector.ts +33 -23
- package/src/directors/DeliveryPricingAdapter.ts +1 -1
- package/src/directors/DeliveryPricingDirector.ts +5 -6
- package/src/directors/DeliveryPricingSheet.ts +3 -2
- package/src/directors/EnrollmentAdapter.ts +9 -6
- package/src/directors/EnrollmentDirector.ts +9 -8
- package/src/directors/FilterAdapter.ts +3 -3
- package/src/directors/FilterDirector.ts +5 -5
- package/src/directors/OrderDiscountAdapter.ts +2 -2
- package/src/directors/OrderPricingAdapter.ts +2 -2
- package/src/directors/OrderPricingDirector.ts +3 -3
- package/src/directors/OrderPricingSheet.ts +3 -2
- package/src/directors/PaymentAdapter.ts +2 -2
- package/src/directors/PaymentDirector.ts +32 -8
- package/src/directors/PaymentPricingAdapter.ts +2 -2
- package/src/directors/PaymentPricingDirector.ts +6 -8
- package/src/directors/PaymentPricingSheet.ts +3 -2
- package/src/directors/ProductDiscountAdapter.ts +2 -2
- package/src/directors/ProductDiscountConfiguration.ts +1 -1
- package/src/directors/ProductPricingAdapter.ts +1 -1
- package/src/directors/ProductPricingDirector.ts +7 -7
- package/src/directors/ProductPricingSheet.ts +4 -3
- package/src/directors/QuotationAdapter.ts +2 -2
- package/src/directors/QuotationDirector.ts +2 -2
- package/src/directors/WarehousingAdapter.ts +3 -4
- package/src/directors/WarehousingDirector.ts +20 -23
- package/src/directors/WorkerAdapter.ts +2 -2
- package/src/directors/WorkerDirector.ts +5 -6
- package/src/modules.ts +1 -1
- package/src/services/activateEnrollment.ts +5 -5
- package/src/services/calculateDiscountTotal.ts +4 -4
- package/src/services/checkoutOrder.ts +9 -4
- package/src/services/createDownloadStream.ts +1 -0
- package/src/services/createEnrollmentFromCheckout.ts +22 -20
- package/src/services/createManualOrderDiscount.ts +2 -2
- package/src/services/createSignedURL.ts +1 -0
- package/src/services/deleteUser.ts +7 -2
- package/src/services/discountedEntities.ts +6 -6
- package/src/services/findOrInitCart.ts +1 -2
- package/src/services/fullfillQuotation.ts +1 -1
- package/src/services/generateOrderFromEnrollment.ts +54 -0
- package/src/services/index.ts +4 -0
- package/src/services/initCartProviders.ts +2 -2
- package/src/services/initializeEnrollment.ts +11 -4
- package/src/services/linkFileService.ts +3 -1
- package/src/services/nextUserCart.ts +1 -1
- package/src/services/processEnrollment.ts +18 -6
- package/src/services/processOrder.ts +33 -36
- package/src/services/processQuotation.ts +6 -6
- package/src/services/proposeQuotation.ts +2 -2
- package/src/services/registerPaymentCredentials.ts +6 -8
- package/src/services/rejectQuotation.ts +2 -2
- package/src/services/removeProduct.ts +3 -3
- package/src/services/searchAssortments.ts +1 -1
- package/src/services/searchProducts.ts +1 -1
- package/src/services/simulateProductDispatching.ts +1 -1
- package/src/services/simulateProductInventory.ts +7 -3
- package/src/services/simulateProductPricing.ts +6 -3
- package/src/services/updateCalculation.ts +33 -18
- package/src/services/updateScheduling.ts +19 -20
- package/src/services/updateUserAvatarAfterUpload.ts +4 -1
- package/src/services/uploadFileFromStream.ts +3 -1
- package/src/services/uploadFileFromURL.ts +2 -2
- package/src/services/validateOrder.ts +34 -38
- package/src/services/verifyQuotation.ts +2 -2
- package/lib/factory/registerProductDiscoverabilityFilter copy.d.ts +0 -5
- package/lib/factory/registerProductDiscoverabilityFilter copy.d.ts.map +0 -1
- package/lib/factory/registerProductDiscoverabilityFilter copy.js +0 -28
- package/lib/factory/registerProductDiscoverabilityFilter copy.js.map +0 -1
- package/src/bulk-importer/handlers/product/transformSpecificationToProductStructure.ts +0 -22
|
@@ -1,14 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import upsertAssortmentProducts, { AssortmentProductSchema } from './upsertAssortmentProducts.js';
|
|
3
|
+
import upsertAssortmentChildren, { AssortmentLinkSchema } from './upsertAssortmentChildren.js';
|
|
4
|
+
import upsertAssortmentFilters, { AssortmentFilterSchema } from './upsertAssortmentFilters.js';
|
|
5
|
+
import upsertMedia, { MediaSchema } from './upsertMedia.js';
|
|
5
6
|
import convertTagsToLowerCase from '../utils/convertTagsToLowerCase.js';
|
|
6
|
-
import createAssortment from './create.js';
|
|
7
|
+
import createAssortment, { AssortmentCreatePayloadSchema } from './create.js';
|
|
7
8
|
import { Modules } from '../../../modules.js';
|
|
8
9
|
import { Services } from '../../../services/index.js';
|
|
9
10
|
|
|
11
|
+
export const AssortmentUpdatePayloadSchema = z.object({
|
|
12
|
+
_id: z.string(),
|
|
13
|
+
specification: z
|
|
14
|
+
.object({
|
|
15
|
+
isActive: z.boolean().optional(),
|
|
16
|
+
isBase: z.boolean().optional(),
|
|
17
|
+
isRoot: z.boolean().optional(),
|
|
18
|
+
sequence: z.number().optional(),
|
|
19
|
+
tags: z.array(z.string()).optional(),
|
|
20
|
+
meta: z.record(z.unknown()).optional(),
|
|
21
|
+
content: z
|
|
22
|
+
.record(
|
|
23
|
+
z.string(), // locale
|
|
24
|
+
z.object({
|
|
25
|
+
title: z.string().optional(),
|
|
26
|
+
subtitle: z.string().optional(),
|
|
27
|
+
slug: z.string().optional(),
|
|
28
|
+
}),
|
|
29
|
+
)
|
|
30
|
+
.optional(),
|
|
31
|
+
})
|
|
32
|
+
.optional(),
|
|
33
|
+
media: z.array(MediaSchema).optional(),
|
|
34
|
+
products: z.array(AssortmentProductSchema).optional(),
|
|
35
|
+
children: z.array(AssortmentLinkSchema).optional(),
|
|
36
|
+
filters: z.array(AssortmentFilterSchema).optional(),
|
|
37
|
+
});
|
|
38
|
+
|
|
10
39
|
export default async function updateAssortment(
|
|
11
|
-
payload:
|
|
40
|
+
payload: z.infer<typeof AssortmentUpdatePayloadSchema>,
|
|
12
41
|
{ logger, createShouldUpsertIfIDExists, updateShouldUpsertIfIDNotExists },
|
|
13
42
|
unchainedAPI: { modules: Modules; services: Services },
|
|
14
43
|
) {
|
|
@@ -16,8 +45,19 @@ export default async function updateAssortment(
|
|
|
16
45
|
const { media, specification, products, children, filters, _id } = payload;
|
|
17
46
|
|
|
18
47
|
if (!(await modules.assortments.assortmentExists({ assortmentId: _id }))) {
|
|
19
|
-
if (updateShouldUpsertIfIDNotExists) {
|
|
20
|
-
return createAssortment(
|
|
48
|
+
if (updateShouldUpsertIfIDNotExists && specification) {
|
|
49
|
+
return createAssortment(
|
|
50
|
+
{
|
|
51
|
+
_id,
|
|
52
|
+
specification,
|
|
53
|
+
media,
|
|
54
|
+
products,
|
|
55
|
+
children,
|
|
56
|
+
filters,
|
|
57
|
+
} as z.infer<typeof AssortmentCreatePayloadSchema>,
|
|
58
|
+
{ logger, createShouldUpsertIfIDExists },
|
|
59
|
+
unchainedAPI,
|
|
60
|
+
);
|
|
21
61
|
}
|
|
22
62
|
throw new Error(`Can't update non-existing assortment ${_id}`);
|
|
23
63
|
}
|
|
@@ -25,7 +65,9 @@ export default async function updateAssortment(
|
|
|
25
65
|
if (specification) {
|
|
26
66
|
logger.debug('update assortment object', specification);
|
|
27
67
|
|
|
28
|
-
|
|
68
|
+
if (specification.tags) {
|
|
69
|
+
specification.tags = convertTagsToLowerCase(specification.tags!)!;
|
|
70
|
+
}
|
|
29
71
|
|
|
30
72
|
await unchainedAPI.modules.assortments.update(_id, { ...specification });
|
|
31
73
|
|
|
@@ -87,3 +129,5 @@ export default async function updateAssortment(
|
|
|
87
129
|
success: true,
|
|
88
130
|
};
|
|
89
131
|
}
|
|
132
|
+
|
|
133
|
+
updateAssortment.payloadSchema = AssortmentUpdatePayloadSchema;
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
import convertTagsToLowerCase from '../utils/convertTagsToLowerCase.js';
|
|
3
3
|
import { Modules } from '../../../modules.js';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
export const AssortmentLinkSchema = z.object({
|
|
6
|
+
_id: z.string().optional(),
|
|
7
|
+
assortmentId: z.string(),
|
|
8
|
+
tags: z.array(z.string()).optional(),
|
|
9
|
+
sortKey: z.number().optional(),
|
|
10
|
+
meta: z.record(z.unknown()).optional(),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const upsert = async (
|
|
14
|
+
assortmentLink: {
|
|
15
|
+
_id?: string;
|
|
16
|
+
parentAssortmentId: string;
|
|
17
|
+
childAssortmentId: string;
|
|
18
|
+
tags: string[];
|
|
19
|
+
sortKey?: number;
|
|
20
|
+
},
|
|
21
|
+
{ modules }: { modules: Modules },
|
|
22
|
+
) => {
|
|
6
23
|
if (
|
|
7
24
|
!(await modules.assortments.assortmentExists({
|
|
8
25
|
assortmentId: assortmentLink.childAssortmentId,
|
|
@@ -14,33 +31,41 @@ const upsert = async (assortmentLink: AssortmentLink, { modules }: { modules: Mo
|
|
|
14
31
|
const newAssortmentLink = await modules.assortments.links.create(assortmentLink, {
|
|
15
32
|
skipInvalidation: true,
|
|
16
33
|
});
|
|
17
|
-
return newAssortmentLink
|
|
34
|
+
return newAssortmentLink!;
|
|
18
35
|
} catch {
|
|
19
|
-
return modules.assortments.links.update(assortmentLink._id
|
|
36
|
+
return (await modules.assortments.links.update(assortmentLink._id!, assortmentLink, {
|
|
20
37
|
skipInvalidation: true,
|
|
21
|
-
})
|
|
38
|
+
}))!;
|
|
22
39
|
}
|
|
23
40
|
};
|
|
24
41
|
|
|
25
42
|
export default async (
|
|
26
|
-
{
|
|
43
|
+
{
|
|
44
|
+
children,
|
|
45
|
+
assortmentId: parentAssortmentId,
|
|
46
|
+
}: {
|
|
47
|
+
children: z.infer<typeof AssortmentLinkSchema>[];
|
|
48
|
+
assortmentId: string;
|
|
49
|
+
},
|
|
27
50
|
unchainedAPI: { modules: Modules },
|
|
28
51
|
) => {
|
|
29
52
|
const { modules } = unchainedAPI;
|
|
30
53
|
const assortmentLinkIds = await Promise.all(
|
|
31
|
-
children.map(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
children.map(
|
|
55
|
+
async ({ assortmentId: childAssortmentId, sortKey, tags: tagsMixedCase }, sortKeyForced) => {
|
|
56
|
+
const tags = tagsMixedCase ? convertTagsToLowerCase(tagsMixedCase)! : [];
|
|
57
|
+
const assortmentLink = await upsert(
|
|
58
|
+
{
|
|
59
|
+
sortKey: sortKey ?? sortKeyForced,
|
|
60
|
+
tags,
|
|
61
|
+
parentAssortmentId,
|
|
62
|
+
childAssortmentId,
|
|
63
|
+
},
|
|
64
|
+
unchainedAPI,
|
|
65
|
+
);
|
|
66
|
+
return assortmentLink._id;
|
|
67
|
+
},
|
|
68
|
+
),
|
|
44
69
|
);
|
|
45
70
|
await modules.assortments.links.deleteMany(
|
|
46
71
|
{
|
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
import convertTagsToLowerCase from '../utils/convertTagsToLowerCase.js';
|
|
3
3
|
import { Modules } from '../../../modules.js';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
export const AssortmentFilterSchema = z.object({
|
|
6
|
+
_id: z.string().optional(),
|
|
7
|
+
filterId: z.string(),
|
|
8
|
+
tags: z.array(z.string()).optional(),
|
|
9
|
+
sortKey: z.number().optional(),
|
|
10
|
+
meta: z.record(z.unknown()).optional(),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const upsert = async (
|
|
14
|
+
assortmentFilter: {
|
|
15
|
+
_id?: string;
|
|
16
|
+
filterId: string;
|
|
17
|
+
tags: string[];
|
|
18
|
+
assortmentId: string;
|
|
19
|
+
sortKey: number;
|
|
20
|
+
},
|
|
21
|
+
{ modules }: { modules: Modules },
|
|
22
|
+
) => {
|
|
6
23
|
if (
|
|
7
24
|
!(await modules.filters.filterExists({
|
|
8
25
|
filterId: assortmentFilter.filterId,
|
|
@@ -14,24 +31,35 @@ const upsert = async (assortmentFilter: AssortmentFilter, { modules }: { modules
|
|
|
14
31
|
const newAssortmentFilter = await modules.assortments.filters.create(assortmentFilter);
|
|
15
32
|
return newAssortmentFilter;
|
|
16
33
|
} catch {
|
|
17
|
-
return modules.assortments.filters.update(assortmentFilter._id
|
|
34
|
+
return await modules.assortments.filters.update(assortmentFilter._id!, assortmentFilter);
|
|
18
35
|
}
|
|
19
36
|
};
|
|
20
37
|
|
|
21
|
-
export default async (
|
|
38
|
+
export default async (
|
|
39
|
+
{
|
|
40
|
+
filters,
|
|
41
|
+
assortmentId,
|
|
42
|
+
}: {
|
|
43
|
+
filters: z.infer<typeof AssortmentFilterSchema>[];
|
|
44
|
+
assortmentId: string;
|
|
45
|
+
},
|
|
46
|
+
unchainedAPI: { modules: Modules },
|
|
47
|
+
) => {
|
|
22
48
|
const { modules } = unchainedAPI;
|
|
23
49
|
const assortmentFilterIds = await Promise.all(
|
|
24
|
-
filters.map(async (
|
|
25
|
-
const tags = convertTagsToLowerCase(
|
|
50
|
+
filters.map(async ({ tags: tagsMixedCase, sortKey, ...rest }, forcedSortKey) => {
|
|
51
|
+
const tags = tagsMixedCase ? convertTagsToLowerCase(tagsMixedCase)! : [];
|
|
52
|
+
|
|
26
53
|
const assortmentFilter = await upsert(
|
|
27
54
|
{
|
|
28
|
-
...
|
|
29
|
-
tags,
|
|
55
|
+
...rest,
|
|
30
56
|
assortmentId,
|
|
57
|
+
tags,
|
|
58
|
+
sortKey: sortKey ?? forcedSortKey,
|
|
31
59
|
},
|
|
32
60
|
unchainedAPI,
|
|
33
61
|
);
|
|
34
|
-
return assortmentFilter
|
|
62
|
+
return assortmentFilter!._id;
|
|
35
63
|
}),
|
|
36
64
|
);
|
|
37
65
|
|
|
@@ -1,8 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { AssortmentProduct } from '@unchainedshop/core-assortments';
|
|
2
3
|
import convertTagsToLowerCase from '../utils/convertTagsToLowerCase.js';
|
|
3
4
|
import { Modules } from '../../../modules.js';
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
+
export const AssortmentProductSchema = z.object({
|
|
7
|
+
_id: z.string().optional(),
|
|
8
|
+
productId: z.string(),
|
|
9
|
+
tags: z.array(z.string()).optional(),
|
|
10
|
+
sortKey: z.number().optional(),
|
|
11
|
+
meta: z.record(z.any()).optional(),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const upsert = async (
|
|
15
|
+
assortmentProduct: {
|
|
16
|
+
_id?: string;
|
|
17
|
+
productId: string;
|
|
18
|
+
tags: string[];
|
|
19
|
+
assortmentId: string;
|
|
20
|
+
sortKey: number;
|
|
21
|
+
},
|
|
22
|
+
unchainedAPI: { modules: Modules },
|
|
23
|
+
) => {
|
|
6
24
|
const { modules } = unchainedAPI;
|
|
7
25
|
if (
|
|
8
26
|
!(await modules.products.productExists({
|
|
@@ -12,26 +30,34 @@ const upsert = async (assortmentProduct: AssortmentProduct, unchainedAPI: { modu
|
|
|
12
30
|
throw new Error(`Can't link non-existing product ${assortmentProduct.productId}`);
|
|
13
31
|
}
|
|
14
32
|
try {
|
|
15
|
-
const newAssortmentProduct = await modules.assortments.products.create(assortmentProduct, {
|
|
33
|
+
const newAssortmentProduct = (await modules.assortments.products.create(assortmentProduct, {
|
|
16
34
|
skipInvalidation: true,
|
|
17
|
-
});
|
|
35
|
+
})) as AssortmentProduct;
|
|
18
36
|
return newAssortmentProduct;
|
|
19
37
|
} catch {
|
|
20
|
-
return modules.assortments.products.update(assortmentProduct._id
|
|
38
|
+
return (await modules.assortments.products.update(assortmentProduct._id!, assortmentProduct, {
|
|
21
39
|
skipInvalidation: true,
|
|
22
|
-
});
|
|
40
|
+
})) as AssortmentProduct;
|
|
23
41
|
}
|
|
24
42
|
};
|
|
25
43
|
|
|
26
|
-
export default async (
|
|
44
|
+
export default async (
|
|
45
|
+
{
|
|
46
|
+
products,
|
|
47
|
+
assortmentId,
|
|
48
|
+
}: { products: z.infer<typeof AssortmentProductSchema>[]; assortmentId: string },
|
|
49
|
+
unchainedAPI: { modules: Modules },
|
|
50
|
+
) => {
|
|
27
51
|
const { modules } = unchainedAPI;
|
|
28
52
|
const assortmentProductIds = await Promise.all(
|
|
29
|
-
products.map(async (
|
|
30
|
-
const tags = convertTagsToLowerCase(
|
|
53
|
+
products.map(async ({ tags: tagsMixedCase, sortKey, ...rest }, forcedSortKey) => {
|
|
54
|
+
const tags = tagsMixedCase ? convertTagsToLowerCase(tagsMixedCase)! : [];
|
|
55
|
+
|
|
31
56
|
const assortmentProduct = await upsert(
|
|
32
57
|
{
|
|
33
|
-
...
|
|
58
|
+
...rest,
|
|
34
59
|
tags,
|
|
60
|
+
sortKey: sortKey ?? forcedSortKey,
|
|
35
61
|
assortmentId,
|
|
36
62
|
},
|
|
37
63
|
unchainedAPI,
|
|
@@ -1,20 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { Services } from '../../../services/index.js';
|
|
2
3
|
import { Modules } from '../../../modules.js';
|
|
3
|
-
import upsertAsset from '../../upsertAsset.js';
|
|
4
|
+
import upsertAsset, { AssetSchema } from '../../upsertAsset.js';
|
|
5
|
+
import { AssortmentMediaType } from '@unchainedshop/core-assortments';
|
|
6
|
+
|
|
7
|
+
export const MediaSchema = z.object({
|
|
8
|
+
_id: z.string().optional(),
|
|
9
|
+
asset: AssetSchema,
|
|
10
|
+
content: z
|
|
11
|
+
.record(
|
|
12
|
+
z.string(), // locale
|
|
13
|
+
z.object({
|
|
14
|
+
title: z.string().optional(),
|
|
15
|
+
subtitle: z.string().optional(),
|
|
16
|
+
}),
|
|
17
|
+
)
|
|
18
|
+
.optional(),
|
|
19
|
+
tags: z.array(z.string()).optional(),
|
|
20
|
+
sortKey: z.number().optional(),
|
|
21
|
+
});
|
|
4
22
|
|
|
5
23
|
const upsertMediaObject = async (media, unchainedAPI: { modules: Modules; services: Services }) => {
|
|
6
24
|
const { modules } = unchainedAPI;
|
|
7
25
|
try {
|
|
8
|
-
const assortmentMedia = await modules.assortments.media.create(media);
|
|
26
|
+
const assortmentMedia = (await modules.assortments.media.create(media)) as AssortmentMediaType;
|
|
9
27
|
return assortmentMedia;
|
|
10
28
|
} catch {
|
|
11
29
|
const { _id, ...mediaData } = media;
|
|
12
|
-
return modules.assortments.media.update(_id, mediaData);
|
|
30
|
+
return (await modules.assortments.media.update(_id, mediaData)) as AssortmentMediaType;
|
|
13
31
|
}
|
|
14
32
|
};
|
|
15
33
|
|
|
16
34
|
export default async (
|
|
17
|
-
{ media, assortmentId },
|
|
35
|
+
{ media, assortmentId }: { media: z.infer<typeof MediaSchema>[]; assortmentId: string },
|
|
18
36
|
unchainedAPI: { modules: Modules; services: Services },
|
|
19
37
|
) => {
|
|
20
38
|
const { modules } = unchainedAPI;
|
|
@@ -36,7 +54,7 @@ export default async (
|
|
|
36
54
|
unchainedAPI,
|
|
37
55
|
);
|
|
38
56
|
|
|
39
|
-
if (!mediaObject) throw new Error(`Unable to create media object ${
|
|
57
|
+
if (!mediaObject) throw new Error(`Unable to create media object ${mediaData._id}`);
|
|
40
58
|
|
|
41
59
|
if (content) {
|
|
42
60
|
await modules.assortments.media.texts.updateMediaTexts(
|
|
@@ -1,5 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { Modules } from '../../../modules.js';
|
|
2
3
|
|
|
4
|
+
export const LocalizedContentSchema = z.record(
|
|
5
|
+
z.string(), // locale
|
|
6
|
+
z.object({
|
|
7
|
+
title: z.string().optional(),
|
|
8
|
+
subtitle: z.string().optional(),
|
|
9
|
+
}),
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export const FilterCreatePayloadSchema = z.object({
|
|
13
|
+
_id: z.string(),
|
|
14
|
+
specification: z.object({
|
|
15
|
+
type: z.string(),
|
|
16
|
+
key: z.string(),
|
|
17
|
+
isActive: z.boolean().optional(),
|
|
18
|
+
options: z
|
|
19
|
+
.array(
|
|
20
|
+
z.object({
|
|
21
|
+
value: z.string(),
|
|
22
|
+
content: LocalizedContentSchema.optional(),
|
|
23
|
+
}),
|
|
24
|
+
)
|
|
25
|
+
.optional(),
|
|
26
|
+
meta: z.record(z.unknown()).optional(),
|
|
27
|
+
content: LocalizedContentSchema,
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
|
|
3
31
|
export default async function createFilter(
|
|
4
32
|
payload: any,
|
|
5
33
|
{ logger, createShouldUpsertIfIDExists },
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { Modules } from '../../../modules.js';
|
|
2
3
|
|
|
4
|
+
export const FilterRemovePayloadSchema = z.object({
|
|
5
|
+
_id: z.string(),
|
|
6
|
+
});
|
|
7
|
+
|
|
3
8
|
export default async function removeFilter(
|
|
4
|
-
payload:
|
|
9
|
+
payload: z.infer<typeof FilterRemovePayloadSchema>,
|
|
5
10
|
{ logger },
|
|
6
11
|
unchainedAPI: { modules: Modules },
|
|
7
12
|
) {
|
|
@@ -1,5 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z } from 'zod';
|
|
2
2
|
import createFilter from './create.js';
|
|
3
|
+
import { Modules } from '../../../modules.js';
|
|
4
|
+
|
|
5
|
+
export const LocalizedContentSchema = z.record(
|
|
6
|
+
z.string(), // locale
|
|
7
|
+
z.object({
|
|
8
|
+
title: z.string().optional(),
|
|
9
|
+
subtitle: z.string().optional(),
|
|
10
|
+
}),
|
|
11
|
+
);
|
|
12
|
+
export const FilterUpdatePayloadSchema = z.object({
|
|
13
|
+
_id: z.string(),
|
|
14
|
+
specification: z.object({
|
|
15
|
+
type: z.string(),
|
|
16
|
+
key: z.string(),
|
|
17
|
+
isActive: z.boolean().optional(),
|
|
18
|
+
options: z
|
|
19
|
+
.array(
|
|
20
|
+
z.object({
|
|
21
|
+
value: z.string(),
|
|
22
|
+
content: LocalizedContentSchema.optional(),
|
|
23
|
+
}),
|
|
24
|
+
)
|
|
25
|
+
.optional(),
|
|
26
|
+
meta: z.record(z.unknown()).optional(),
|
|
27
|
+
content: LocalizedContentSchema,
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
3
30
|
|
|
4
31
|
export default async function updateFilter(
|
|
5
32
|
payload: any,
|
|
@@ -1,22 +1,120 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { Modules } from '../../../modules.js';
|
|
2
3
|
import { Services } from '../../../services/index.js';
|
|
3
|
-
import upsertVariations from './upsertVariations.js';
|
|
4
|
+
import upsertVariations, { ProductVariationSchema } from './upsertVariations.js';
|
|
4
5
|
import upsertMedia from './upsertMedia.js';
|
|
5
|
-
import
|
|
6
|
+
import { MediaSchema } from '../assortment/upsertMedia.js';
|
|
7
|
+
import convertTagsToLowerCase from '../utils/convertTagsToLowerCase.js';
|
|
8
|
+
|
|
9
|
+
export const ProductCreateSpecificationSchema = z.object({
|
|
10
|
+
type: z.string(),
|
|
11
|
+
sequence: z.number(),
|
|
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.record(
|
|
59
|
+
z.string(), // locale
|
|
60
|
+
z.object({
|
|
61
|
+
title: z.string().optional(),
|
|
62
|
+
subtitle: z.string().optional(),
|
|
63
|
+
slug: z.string().optional(),
|
|
64
|
+
description: z.string().optional(),
|
|
65
|
+
brand: z.string().optional(),
|
|
66
|
+
vendor: z.string().optional(),
|
|
67
|
+
labels: z.array(z.string()).optional(),
|
|
68
|
+
}),
|
|
69
|
+
),
|
|
70
|
+
variationResolvers: z
|
|
71
|
+
.array(
|
|
72
|
+
z.object({
|
|
73
|
+
vector: z.record(z.string()),
|
|
74
|
+
productId: z.string(),
|
|
75
|
+
}),
|
|
76
|
+
)
|
|
77
|
+
.optional(),
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export const ProductCreatePayloadSchema = z.object({
|
|
81
|
+
_id: z.string(),
|
|
82
|
+
specification: ProductCreateSpecificationSchema,
|
|
83
|
+
media: z.array(MediaSchema).optional(),
|
|
84
|
+
variations: z.array(ProductVariationSchema).optional(),
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const transformSpecification = (specification: z.infer<typeof ProductCreateSpecificationSchema>) => {
|
|
88
|
+
const {
|
|
89
|
+
variationResolvers: assignments,
|
|
90
|
+
content, // eslint-disable-line
|
|
91
|
+
supply,
|
|
92
|
+
warehousing,
|
|
93
|
+
...productData
|
|
94
|
+
} = specification;
|
|
95
|
+
|
|
96
|
+
const tags = productData?.tags ? convertTagsToLowerCase(productData.tags!)! : [];
|
|
97
|
+
const proxy = assignments ? { assignments } : undefined;
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
...productData,
|
|
101
|
+
published: productData.published ? new Date(productData.published) : undefined,
|
|
102
|
+
tags,
|
|
103
|
+
warehousing,
|
|
104
|
+
supply,
|
|
105
|
+
proxy,
|
|
106
|
+
};
|
|
107
|
+
};
|
|
6
108
|
|
|
7
109
|
export default async function createProduct(
|
|
8
|
-
payload:
|
|
110
|
+
payload: z.infer<typeof ProductCreatePayloadSchema>,
|
|
9
111
|
{ logger, createShouldUpsertIfIDExists },
|
|
10
112
|
unchainedAPI: { modules: Modules; services: Services },
|
|
11
113
|
) {
|
|
12
114
|
const { modules } = unchainedAPI;
|
|
13
115
|
const { specification, media, variations, _id } = payload;
|
|
14
116
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (!specification.content) throw new Error(`Content is required when creating new product ${_id}`);
|
|
18
|
-
|
|
19
|
-
const productData = transformSpecificationToProductStructure(specification);
|
|
117
|
+
const productData = transformSpecification(specification);
|
|
20
118
|
logger.debug('create product object', productData);
|
|
21
119
|
try {
|
|
22
120
|
await modules.products.create({
|
|
@@ -33,7 +131,7 @@ export default async function createProduct(
|
|
|
33
131
|
}
|
|
34
132
|
|
|
35
133
|
if (!(await modules.products.productExists({ productId: _id }))) {
|
|
36
|
-
throw new Error(`Can't create product ${_id}
|
|
134
|
+
throw new Error(`Can't create product ${_id}`);
|
|
37
135
|
}
|
|
38
136
|
|
|
39
137
|
if (specification.content) {
|
|
@@ -68,3 +166,5 @@ export default async function createProduct(
|
|
|
68
166
|
success: true,
|
|
69
167
|
};
|
|
70
168
|
}
|
|
169
|
+
|
|
170
|
+
createProduct.payloadSchema = ProductCreatePayloadSchema;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
import { Modules } from '../../../modules.js';
|
|
2
3
|
import { Services } from '../../../services/index.js';
|
|
3
4
|
|
|
5
|
+
export const ProductRemovePayloadSchema = z.object({
|
|
6
|
+
_id: z.string(),
|
|
7
|
+
});
|
|
4
8
|
export default async function removeProduct(
|
|
5
|
-
payload:
|
|
9
|
+
payload: z.infer<typeof ProductRemovePayloadSchema>,
|
|
6
10
|
{ logger },
|
|
7
11
|
unchainedAPI: { modules: Modules; services: Services },
|
|
8
12
|
) {
|
|
@@ -19,3 +23,5 @@ export default async function removeProduct(
|
|
|
19
23
|
success: true,
|
|
20
24
|
};
|
|
21
25
|
}
|
|
26
|
+
|
|
27
|
+
removeProduct.payloadSchema = ProductRemovePayloadSchema;
|