@unchainedshop/core 5.0.0-alpha.1 → 5.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -546
- package/lib/bulk-exporter/createBulkExporter.js +1 -1
- package/lib/bulk-exporter/handlers/exportProductsHandler.js +2 -2
- package/lib/bulk-importer/handlers/assortment/create.js +1 -3
- package/lib/bulk-importer/handlers/assortment/update.js +1 -1
- package/lib/bulk-importer/handlers/product/create.d.ts +150 -35
- package/lib/bulk-importer/handlers/product/create.js +35 -16
- package/lib/bulk-importer/handlers/product/update.d.ts +78 -36
- package/lib/bulk-importer/handlers/product/update.js +8 -48
- package/lib/core-index.d.ts +1 -2
- package/lib/core-index.js +2 -18
- package/lib/directors/BaseDiscountAdapter.d.ts +3 -0
- package/lib/directors/BaseDiscountDirector.d.ts +2 -2
- package/lib/directors/BaseDiscountDirector.js +7 -9
- package/lib/directors/BasePricingDirector.d.ts +2 -2
- package/lib/directors/BasePricingDirector.js +3 -6
- package/lib/directors/BaseWorker.js +3 -2
- package/lib/directors/DeliveryDirector.d.ts +1 -1
- package/lib/directors/DeliveryDirector.js +2 -12
- package/lib/directors/DeliveryPricingDirector.js +1 -10
- package/lib/directors/EnrollmentAdapter.js +0 -1
- package/lib/directors/EnrollmentDirector.d.ts +1 -1
- package/lib/directors/EnrollmentDirector.js +3 -15
- package/lib/directors/FileDirector.d.ts +4 -4
- package/lib/directors/FileDirector.js +2 -13
- package/lib/directors/FilterDirector.d.ts +1 -1
- package/lib/directors/FilterDirector.js +25 -32
- package/lib/directors/OrderDiscountDirector.d.ts +1 -15
- package/lib/directors/OrderDiscountDirector.js +1 -13
- package/lib/directors/OrderPricingDirector.js +1 -10
- package/lib/directors/OrderPricingSheet.d.ts +1 -0
- package/lib/directors/OrderPricingSheet.js +17 -17
- package/lib/directors/PaymentDirector.d.ts +1 -1
- package/lib/directors/PaymentDirector.js +2 -12
- package/lib/directors/PaymentPricingDirector.js +1 -10
- package/lib/directors/ProductDiscountDirector.d.ts +1 -15
- package/lib/directors/ProductDiscountDirector.js +1 -13
- package/lib/directors/ProductPricingDirector.js +1 -10
- package/lib/directors/QuotationDirector.d.ts +1 -1
- package/lib/directors/QuotationDirector.js +2 -14
- package/lib/directors/WarehousingDirector.js +16 -34
- package/lib/directors/WorkerDirector.d.ts +7 -1
- package/lib/directors/WorkerDirector.js +29 -29
- package/lib/directors/registryDirector.d.ts +2 -0
- package/lib/directors/registryDirector.js +6 -0
- package/lib/errors.d.ts +1 -0
- package/lib/errors.js +5 -0
- package/lib/factory/index.d.ts +12 -1
- package/lib/factory/index.js +12 -1
- package/lib/factory/registerAssortmentSearchFilter.d.ts +2 -1
- package/lib/factory/registerAssortmentSearchFilter.js +6 -3
- package/lib/factory/registerDeliveryPricing.d.ts +7 -0
- package/lib/factory/registerDeliveryPricing.js +30 -0
- package/lib/factory/registerDeliveryProvider.d.ts +12 -0
- package/lib/factory/registerDeliveryProvider.js +46 -0
- package/lib/factory/registerEnrollment.d.ts +18 -0
- package/lib/factory/registerEnrollment.js +43 -0
- package/lib/factory/registerFileAdapter.d.ts +17 -0
- package/lib/factory/registerFileAdapter.js +24 -0
- package/lib/factory/registerOrderDiscount.d.ts +13 -0
- package/lib/factory/registerOrderDiscount.js +39 -0
- package/lib/factory/registerOrderPricing.d.ts +7 -0
- package/lib/factory/registerOrderPricing.js +30 -0
- package/lib/factory/registerPaymentPricing.d.ts +7 -0
- package/lib/factory/registerPaymentPricing.js +30 -0
- package/lib/factory/registerPaymentProvider.d.ts +15 -0
- package/lib/factory/registerPaymentProvider.js +53 -0
- package/lib/factory/registerProductDiscount.d.ts +20 -0
- package/lib/factory/registerProductDiscount.js +47 -0
- package/lib/factory/registerProductDiscoverabilityFilter.d.ts +2 -1
- package/lib/factory/registerProductDiscoverabilityFilter.js +6 -3
- package/lib/factory/registerProductPricing.d.ts +7 -0
- package/lib/factory/registerProductPricing.js +30 -0
- package/lib/factory/registerProductSearchFilter.d.ts +2 -1
- package/lib/factory/registerProductSearchFilter.js +4 -3
- package/lib/factory/registerQuotation.d.ts +12 -0
- package/lib/factory/registerQuotation.js +52 -0
- package/lib/factory/registerVirtualWarehousing.js +1 -1
- package/lib/factory/registerWorker.js +1 -1
- package/lib/plugins/PluginRegistry.d.ts +1 -0
- package/lib/plugins/PluginRegistry.js +11 -2
- package/lib/services/addMultipleCartProducts.js +3 -2
- package/lib/services/bulkAssignProductsToAssortment.d.ts +8 -0
- package/lib/services/bulkAssignProductsToAssortment.js +11 -0
- package/lib/services/bulkDeleteUsers.d.ts +7 -0
- package/lib/services/bulkDeleteUsers.js +11 -0
- package/lib/services/bulkRemoveFilters.d.ts +7 -0
- package/lib/services/bulkRemoveFilters.js +10 -0
- package/lib/services/bulkRemoveProducts.d.ts +7 -0
- package/lib/services/bulkRemoveProducts.js +23 -0
- package/lib/services/bulkSetFilterActive.d.ts +8 -0
- package/lib/services/bulkSetFilterActive.js +12 -0
- package/lib/services/checkoutOrder.js +4 -0
- package/lib/services/createFilter.d.ts +3 -0
- package/lib/services/createFilter.js +6 -0
- package/lib/services/createFilterOption.d.ts +5 -0
- package/lib/services/createFilterOption.js +8 -0
- package/lib/services/createSignedURL.js +2 -1
- package/lib/services/deleteCart.d.ts +2 -0
- package/lib/services/deleteCart.js +7 -0
- package/lib/services/deleteDeadCarts.d.ts +2 -0
- package/lib/services/deleteDeadCarts.js +17 -0
- package/lib/services/deleteUser.js +2 -5
- package/lib/services/index.d.ts +24 -1
- package/lib/services/index.js +24 -1
- package/lib/services/initCartProviders.js +1 -0
- package/lib/services/isTokenInvalidateable.d.ts +3 -1
- package/lib/services/isTokenInvalidateable.js +2 -2
- package/lib/services/loadFilterOptions.js +3 -3
- package/lib/services/processEnrollment.js +2 -1
- package/lib/services/processOrder.js +3 -2
- package/lib/services/processQuotation.js +11 -13
- package/lib/services/proposeQuotation.js +3 -0
- package/lib/services/removeFilterOption.d.ts +6 -0
- package/lib/services/removeFilterOption.js +8 -0
- package/lib/services/removeProduct.js +2 -1
- package/lib/services/reserveOrderDiscountsForCheckout.d.ts +5 -0
- package/lib/services/reserveOrderDiscountsForCheckout.js +34 -0
- package/lib/services/simulateProductDispatching.d.ts +3 -1
- package/lib/services/simulateProductDispatching.js +3 -3
- package/lib/services/simulateProductInventory.d.ts +3 -1
- package/lib/services/simulateProductInventory.js +3 -3
- package/lib/services/supportedDeliveryProviders.js +9 -0
- package/lib/services/supportedPaymentProviders.js +9 -0
- package/lib/services/supportedWarehousingProviders.js +9 -0
- package/lib/services/updateCalculation.js +2 -1
- package/lib/services/updateFilter.d.ts +3 -0
- package/lib/services/updateFilter.js +8 -0
- package/lib/services/uploadFileFromStream.js +2 -1
- package/lib/services/validateOrder.js +7 -8
- package/package.json +29 -23
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
1
2
|
import { WarehousingDirector } from "../directors/index.js";
|
|
3
|
+
const logger = createLogger('unchained:core');
|
|
2
4
|
export async function supportedWarehousingProvidersService(params) {
|
|
3
5
|
const allProviders = await this.warehousing.allProviders();
|
|
4
6
|
const providers = (await Promise.all(allProviders.map(async (provider) => {
|
|
7
|
+
if (!WarehousingDirector.getAdapter(provider.adapterKey)) {
|
|
8
|
+
logger.warn('Warehousing provider skipped, its adapter is not registered', {
|
|
9
|
+
warehousingProviderId: provider._id,
|
|
10
|
+
adapterKey: provider.adapterKey,
|
|
11
|
+
});
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
5
14
|
const adapter = await WarehousingDirector.actions(provider, params, { modules: this });
|
|
6
15
|
return adapter.isActive() ? [provider] : [];
|
|
7
16
|
}))).flat();
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { OrderDiscountTrigger, } from '@unchainedshop/core-orders';
|
|
2
2
|
import { initCartProvidersService } from "./initCartProviders.js";
|
|
3
3
|
import { updateSchedulingService } from "./updateScheduling.js";
|
|
4
|
+
import { createServiceError } from "../errors.js";
|
|
4
5
|
import { OrderDiscountDirector, OrderPricingDirector, DeliveryPricingDirector, ProductPricingDirector, PaymentPricingDirector, } from "../directors/index.js";
|
|
5
6
|
export async function updateCalculationService(orderId) {
|
|
6
7
|
let order = await this.orders.findOrder({ orderId });
|
|
7
8
|
if (!order)
|
|
8
|
-
throw
|
|
9
|
+
throw createServiceError('OrderNotFoundError', 'Order not found');
|
|
9
10
|
if (order.status !== null)
|
|
10
11
|
return order;
|
|
11
12
|
const discounts = await this.orders.discounts.findOrderDiscounts({
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FilterDirector } from "../core-index.js";
|
|
2
|
+
export async function updateFilterService(filterId, doc) {
|
|
3
|
+
const updatedFilter = await this.filters.update(filterId, doc);
|
|
4
|
+
if (updatedFilter) {
|
|
5
|
+
await FilterDirector.invalidateProductIdCache(updatedFilter, { modules: this });
|
|
6
|
+
}
|
|
7
|
+
return updatedFilter;
|
|
8
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getFileFromFileData } from '@unchainedshop/core-files';
|
|
2
2
|
import { getFileAdapter } from "../utils/getFileAdapter.js";
|
|
3
|
+
import { createServiceError } from "../errors.js";
|
|
3
4
|
export async function uploadFileFromStreamService({ directoryName, rawFile, meta, ...options }) {
|
|
4
5
|
const fileUploadAdapter = getFileAdapter();
|
|
5
6
|
const uploadFileData = await fileUploadAdapter.uploadFileFromStream(directoryName, rawFile, {
|
|
@@ -9,6 +10,6 @@ export async function uploadFileFromStreamService({ directoryName, rawFile, meta
|
|
|
9
10
|
const fileId = await this.files.create(fileData);
|
|
10
11
|
const file = await this.files.findFile({ fileId });
|
|
11
12
|
if (!file)
|
|
12
|
-
throw
|
|
13
|
+
throw createServiceError('FileNotFoundError', 'File not found after upload');
|
|
13
14
|
return file;
|
|
14
15
|
}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { ordersSettings } from '@unchainedshop/core-orders';
|
|
2
|
+
import { createServiceError } from "../errors.js";
|
|
2
3
|
export async function validateOrderService(order) {
|
|
3
4
|
if (!order.contact)
|
|
4
|
-
throw
|
|
5
|
+
throw createServiceError('ContactMissingError', 'Contact data not provided');
|
|
5
6
|
if (!order.billingAddress)
|
|
6
|
-
throw
|
|
7
|
+
throw createServiceError('BillingAddressMissingError', 'Billing address not provided');
|
|
7
8
|
if (!order.deliveryId ||
|
|
8
9
|
!(await this.orders.deliveries.findDelivery({ orderDeliveryId: order.deliveryId })))
|
|
9
|
-
throw
|
|
10
|
+
throw createServiceError('NoDeliveryProviderError', 'No delivery provider selected');
|
|
10
11
|
if (!order.paymentId ||
|
|
11
12
|
!(await this.orders.payments.findOrderPayment({ orderPaymentId: order.paymentId })))
|
|
12
|
-
throw
|
|
13
|
+
throw createServiceError('NoPaymentProviderError', 'No payment provider selected');
|
|
13
14
|
const orderPositions = await this.orders.positions.findOrderPositions({ orderId: order._id });
|
|
14
15
|
if (orderPositions.length === 0) {
|
|
15
|
-
|
|
16
|
-
NoItemsError.name = 'NoItemsError';
|
|
17
|
-
throw NoItemsError;
|
|
16
|
+
throw createServiceError('NoItemsError', 'No items to checkout');
|
|
18
17
|
}
|
|
19
18
|
for (const orderPosition of orderPositions) {
|
|
20
19
|
const product = await this.products.findProduct({
|
|
@@ -31,7 +30,7 @@ export async function validateOrderService(order) {
|
|
|
31
30
|
quotationId: orderPosition.quotationId,
|
|
32
31
|
}));
|
|
33
32
|
if (quotation && !this.quotations.isProposalValid(quotation)) {
|
|
34
|
-
throw
|
|
33
|
+
throw createServiceError('QuotationInvalidError', 'Quotation expired or fulfilled, please request a new offer');
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
36
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core",
|
|
3
3
|
"description": "Core orchestration package for the Unchained Engine with business services and directors",
|
|
4
|
-
"version": "5.0.0-alpha.
|
|
4
|
+
"version": "5.0.0-alpha.10",
|
|
5
|
+
"files": [
|
|
6
|
+
"lib"
|
|
7
|
+
],
|
|
5
8
|
"main": "lib/core-index.js",
|
|
6
9
|
"types": "lib/core-index.d.ts",
|
|
7
10
|
"type": "module",
|
|
@@ -35,29 +38,32 @@
|
|
|
35
38
|
},
|
|
36
39
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
37
40
|
"dependencies": {
|
|
38
|
-
"@unchainedshop/core-assortments": "^5.0.0-alpha.
|
|
39
|
-
"@unchainedshop/core-bookmarks": "^5.0.0-alpha.
|
|
40
|
-
"@unchainedshop/core-countries": "^5.0.0-alpha.
|
|
41
|
-
"@unchainedshop/core-currencies": "^5.0.0-alpha.
|
|
42
|
-
"@unchainedshop/core-delivery": "^5.0.0-alpha.
|
|
43
|
-
"@unchainedshop/core-enrollments": "^5.0.0-alpha.
|
|
44
|
-
"@unchainedshop/core-events": "^5.0.0-alpha.
|
|
45
|
-
"@unchainedshop/core-files": "^5.0.0-alpha.
|
|
46
|
-
"@unchainedshop/core-filters": "^5.0.0-alpha.
|
|
47
|
-
"@unchainedshop/core-languages": "^5.0.0-alpha.
|
|
48
|
-
"@unchainedshop/core-orders": "^5.0.0-alpha.
|
|
49
|
-
"@unchainedshop/core-payment": "^5.0.0-alpha.
|
|
50
|
-
"@unchainedshop/core-products": "^5.0.0-alpha.
|
|
51
|
-
"@unchainedshop/core-quotations": "^5.0.0-alpha.
|
|
52
|
-
"@unchainedshop/core-users": "^5.0.0-alpha.
|
|
53
|
-
"@unchainedshop/core-warehousing": "^5.0.0-alpha.
|
|
54
|
-
"@unchainedshop/core-worker": "^5.0.0-alpha.
|
|
55
|
-
"@unchainedshop/
|
|
56
|
-
"@unchainedshop/
|
|
57
|
-
"
|
|
41
|
+
"@unchainedshop/core-assortments": "^5.0.0-alpha.10",
|
|
42
|
+
"@unchainedshop/core-bookmarks": "^5.0.0-alpha.10",
|
|
43
|
+
"@unchainedshop/core-countries": "^5.0.0-alpha.10",
|
|
44
|
+
"@unchainedshop/core-currencies": "^5.0.0-alpha.10",
|
|
45
|
+
"@unchainedshop/core-delivery": "^5.0.0-alpha.10",
|
|
46
|
+
"@unchainedshop/core-enrollments": "^5.0.0-alpha.10",
|
|
47
|
+
"@unchainedshop/core-events": "^5.0.0-alpha.10",
|
|
48
|
+
"@unchainedshop/core-files": "^5.0.0-alpha.10",
|
|
49
|
+
"@unchainedshop/core-filters": "^5.0.0-alpha.10",
|
|
50
|
+
"@unchainedshop/core-languages": "^5.0.0-alpha.10",
|
|
51
|
+
"@unchainedshop/core-orders": "^5.0.0-alpha.10",
|
|
52
|
+
"@unchainedshop/core-payment": "^5.0.0-alpha.10",
|
|
53
|
+
"@unchainedshop/core-products": "^5.0.0-alpha.10",
|
|
54
|
+
"@unchainedshop/core-quotations": "^5.0.0-alpha.10",
|
|
55
|
+
"@unchainedshop/core-users": "^5.0.0-alpha.10",
|
|
56
|
+
"@unchainedshop/core-warehousing": "^5.0.0-alpha.10",
|
|
57
|
+
"@unchainedshop/core-worker": "^5.0.0-alpha.10",
|
|
58
|
+
"@unchainedshop/events": "^5.0.0-alpha.10",
|
|
59
|
+
"@unchainedshop/logger": "^5.0.0-alpha.10",
|
|
60
|
+
"@unchainedshop/mongodb": "^5.0.0-alpha.10",
|
|
61
|
+
"@unchainedshop/utils": "^5.0.0-alpha.10",
|
|
62
|
+
"minipass-json-stream": "^1.0.2",
|
|
63
|
+
"zod": "^4.2.0"
|
|
58
64
|
},
|
|
59
65
|
"devDependencies": {
|
|
60
|
-
"@types/node": "^
|
|
61
|
-
"typescript": "^
|
|
66
|
+
"@types/node": "^26.2.0",
|
|
67
|
+
"typescript": "^6.0.3"
|
|
62
68
|
}
|
|
63
69
|
}
|