@unchainedshop/core 4.8.29 → 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.d.ts +2 -2
- package/lib/bulk-exporter/createBulkExporter.js +1 -1
- package/lib/bulk-exporter/handlers/exportAssortmentsHandler.d.ts +19 -19
- package/lib/bulk-exporter/handlers/exportAssortmentsHandler.js +9 -9
- package/lib/bulk-exporter/handlers/exportFiltersHandler.d.ts +11 -11
- package/lib/bulk-exporter/handlers/exportFiltersHandler.js +5 -5
- package/lib/bulk-exporter/handlers/exportProductsHandler.d.ts +19 -19
- package/lib/bulk-exporter/handlers/exportProductsHandler.js +11 -11
- package/lib/bulk-exporter/handlers/exportUsersHandler.d.ts +17 -17
- package/lib/bulk-exporter/handlers/exportUsersHandler.js +8 -8
- package/lib/bulk-importer/createBulkImporter.d.ts +1 -1
- package/lib/bulk-importer/createBulkImporter.js +6 -6
- package/lib/bulk-importer/handlers/product/create.d.ts +135 -32
- package/lib/bulk-importer/handlers/product/create.js +33 -16
- package/lib/bulk-importer/handlers/product/update.d.ts +63 -33
- package/lib/bulk-importer/handlers/product/update.js +5 -48
- package/lib/core-index.d.ts +4 -2
- package/lib/core-index.js +5 -17
- package/lib/directors/BaseDiscountAdapter.d.ts +3 -0
- package/lib/directors/BaseDiscountDirector.d.ts +2 -2
- package/lib/directors/BaseDiscountDirector.js +12 -14
- package/lib/directors/BasePricingDirector.d.ts +2 -2
- package/lib/directors/BasePricingDirector.js +4 -7
- package/lib/directors/BaseWorker.js +3 -2
- package/lib/directors/DeliveryAdapter.js +1 -0
- package/lib/directors/DeliveryDirector.d.ts +1 -1
- package/lib/directors/DeliveryDirector.js +4 -5
- package/lib/directors/DeliveryPricingAdapter.d.ts +2 -1
- package/lib/directors/DeliveryPricingAdapter.js +2 -1
- package/lib/directors/DeliveryPricingDirector.d.ts +1 -1
- package/lib/directors/DeliveryPricingDirector.js +4 -3
- package/lib/directors/DeliveryPricingSheet.d.ts +1 -1
- package/lib/directors/DeliveryPricingSheet.js +1 -1
- package/lib/directors/EnrollmentAdapter.js +1 -1
- package/lib/directors/EnrollmentDirector.d.ts +1 -1
- package/lib/directors/EnrollmentDirector.js +5 -7
- package/lib/directors/FileDirector.d.ts +4 -4
- package/lib/directors/FileDirector.js +2 -13
- package/lib/directors/FilterAdapter.js +1 -0
- package/lib/directors/FilterDirector.d.ts +1 -1
- package/lib/directors/FilterDirector.js +6 -8
- package/lib/directors/OrderDiscountAdapter.d.ts +3 -2
- package/lib/directors/OrderDiscountAdapter.js +5 -2
- package/lib/directors/OrderDiscountDirector.js +2 -1
- package/lib/directors/OrderPricingAdapter.d.ts +2 -1
- package/lib/directors/OrderPricingAdapter.js +3 -1
- package/lib/directors/OrderPricingDirector.d.ts +4 -1
- package/lib/directors/OrderPricingDirector.js +4 -2
- package/lib/directors/OrderPricingSheet.d.ts +2 -1
- package/lib/directors/OrderPricingSheet.js +18 -18
- package/lib/directors/PaymentAdapter.js +1 -0
- package/lib/directors/PaymentDirector.d.ts +1 -1
- package/lib/directors/PaymentDirector.js +4 -5
- package/lib/directors/PaymentPricingAdapter.d.ts +2 -1
- package/lib/directors/PaymentPricingAdapter.js +2 -1
- package/lib/directors/PaymentPricingDirector.d.ts +2 -1
- package/lib/directors/PaymentPricingDirector.js +3 -2
- package/lib/directors/PaymentPricingSheet.d.ts +2 -1
- package/lib/directors/PaymentPricingSheet.js +2 -1
- package/lib/directors/ProductDiscountAdapter.d.ts +3 -2
- package/lib/directors/ProductDiscountAdapter.js +5 -2
- package/lib/directors/ProductDiscountDirector.d.ts +1 -1
- package/lib/directors/ProductDiscountDirector.js +3 -2
- package/lib/directors/ProductPricingAdapter.d.ts +2 -1
- package/lib/directors/ProductPricingAdapter.js +3 -1
- package/lib/directors/ProductPricingDirector.d.ts +3 -1
- package/lib/directors/ProductPricingDirector.js +4 -2
- package/lib/directors/ProductPricingSheet.d.ts +1 -1
- package/lib/directors/ProductPricingSheet.js +1 -1
- package/lib/directors/QuotationAdapter.js +1 -0
- package/lib/directors/QuotationDirector.d.ts +1 -1
- package/lib/directors/QuotationDirector.js +4 -7
- package/lib/directors/WarehousingAdapter.js +1 -0
- package/lib/directors/WarehousingDirector.d.ts +1 -1
- package/lib/directors/WarehousingDirector.js +19 -27
- package/lib/directors/WorkerAdapter.js +1 -0
- package/lib/directors/WorkerDirector.d.ts +2 -2
- package/lib/directors/WorkerDirector.js +3 -22
- package/lib/directors/index.d.ts +2 -0
- package/lib/directors/index.js +2 -0
- package/lib/directors/registryDirector.d.ts +2 -0
- package/lib/directors/registryDirector.js +6 -0
- package/lib/factory/index.d.ts +12 -1
- package/lib/factory/index.js +12 -1
- package/lib/factory/registerAssortmentSearchFilter.d.ts +4 -2
- package/lib/factory/registerAssortmentSearchFilter.js +18 -6
- package/lib/factory/registerInvoicePayment.d.ts +2 -2
- package/lib/factory/registerInvoicePayment.js +12 -3
- package/lib/factory/registerPhysicalWarehousing.d.ts +2 -2
- package/lib/factory/registerPhysicalWarehousing.js +12 -3
- package/lib/factory/registerPickUpDelivery.d.ts +2 -2
- package/lib/factory/registerPickUpDelivery.js +12 -3
- package/lib/factory/registerProductDiscoverabilityFilter.d.ts +4 -2
- package/lib/factory/registerProductDiscoverabilityFilter.js +18 -6
- package/lib/factory/registerProductSearchFilter.d.ts +4 -2
- package/lib/factory/registerProductSearchFilter.js +16 -6
- package/lib/factory/registerShippingDelivery.d.ts +2 -2
- package/lib/factory/registerShippingDelivery.js +12 -3
- package/lib/factory/registerVirtualWarehousing.d.ts +2 -2
- package/lib/factory/registerVirtualWarehousing.js +13 -4
- package/lib/factory/registerWorker.d.ts +2 -1
- package/lib/factory/registerWorker.js +13 -4
- package/lib/plugins/PluginRegistry.d.ts +1 -0
- package/lib/plugins/PluginRegistry.js +8 -1
- package/lib/services/checkoutOrder.js +4 -0
- package/lib/services/createDownloadStream.js +1 -1
- package/lib/services/createFileDownloadURL.js +2 -1
- package/lib/services/createSignedURL.js +2 -1
- package/lib/services/index.d.ts +14 -1
- package/lib/services/index.js +14 -1
- package/lib/services/initCartProviders.js +1 -0
- package/lib/services/linkFileService.js +1 -1
- package/lib/services/removeFiles.js +1 -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/uploadFileFromStream.js +2 -1
- package/lib/services/uploadFileFromURL.js +2 -1
- package/package.json +26 -24
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getFileAdapter } from
|
|
1
|
+
import { getFileAdapter } from "../utils/getFileAdapter.js";
|
|
2
2
|
export async function createDownloadStreamService({ fileId, }) {
|
|
3
3
|
const fileAdapter = getFileAdapter();
|
|
4
4
|
const file = await this.files.findFile({ fileId });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {} from '@unchainedshop/core-files';
|
|
2
|
+
import { getFileAdapter } from "../utils/getFileAdapter.js";
|
|
2
3
|
export async function createFileDownloadURLService({ file, expires, params = {}, }) {
|
|
3
4
|
if (!file)
|
|
4
5
|
return null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getFileFromFileData
|
|
1
|
+
import { getFileFromFileData } from '@unchainedshop/core-files';
|
|
2
|
+
import { getFileAdapter } from "../utils/getFileAdapter.js";
|
|
2
3
|
import { createServiceError } from "../errors.js";
|
|
3
4
|
export async function createSignedURLService({ directoryName, fileName, meta }) {
|
|
4
5
|
const fileUploadAdapter = getFileAdapter();
|
package/lib/services/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { searchProductsService } from './searchProducts.ts';
|
|
|
24
24
|
import { calculateDiscountTotalService } from './calculateDiscountTotal.ts';
|
|
25
25
|
import { registerPaymentCredentialsService } from './registerPaymentCredentials.ts';
|
|
26
26
|
import { processOrderService } from './processOrder.ts';
|
|
27
|
+
import { processEnrollmentService } from './processEnrollment.ts';
|
|
27
28
|
import { checkoutOrderService } from './checkoutOrder.ts';
|
|
28
29
|
import { confirmOrderService } from './confirmOrder.ts';
|
|
29
30
|
import { rejectOrderService } from './rejectOrder.ts';
|
|
@@ -62,6 +63,11 @@ import { simulateConfigurablePriceRangeService } from './simulateConfigurablePri
|
|
|
62
63
|
import { createFileDownloadURLService } from './createFileDownloadURL.ts';
|
|
63
64
|
import { resolveTokenStatusService } from './resolveTokenStatus.ts';
|
|
64
65
|
import { isTokenInvalidateableService } from './isTokenInvalidateable.ts';
|
|
66
|
+
import { bulkRemoveProductsService } from './bulkRemoveProducts.ts';
|
|
67
|
+
import { bulkRemoveFiltersService } from './bulkRemoveFilters.ts';
|
|
68
|
+
import { bulkDeleteUsersService } from './bulkDeleteUsers.ts';
|
|
69
|
+
import { bulkSetFilterActiveService } from './bulkSetFilterActive.ts';
|
|
70
|
+
import { bulkAssignProductsToAssortmentService } from './bulkAssignProductsToAssortment.ts';
|
|
65
71
|
export type ServiceInterface = (this: Modules, ...args: any[]) => Promise<any> | any;
|
|
66
72
|
export type Bound<T extends ServiceInterface> = OmitThisParameter<T>;
|
|
67
73
|
export type CustomServices = Record<string, ServiceInterface | Record<string, ServiceInterface>>;
|
|
@@ -105,18 +111,23 @@ export default function initServices(modules: Modules, customServices?: CustomSe
|
|
|
105
111
|
simulateProductDispatching: Bound<typeof simulateProductDispatchingService>;
|
|
106
112
|
simulateProductInventory: Bound<typeof simulateProductInventoryService>;
|
|
107
113
|
removeProduct: Bound<typeof removeProductService>;
|
|
114
|
+
bulkRemoveProducts: Bound<typeof bulkRemoveProductsService>;
|
|
108
115
|
findProductSiblings: Bound<typeof findProductSiblingsService>;
|
|
109
116
|
simulateConfigurablePriceRange: Bound<typeof simulateConfigurablePriceRangeService>;
|
|
110
117
|
};
|
|
118
|
+
assortments: {
|
|
119
|
+
bulkAssignProductsToAssortment: Bound<typeof bulkAssignProductsToAssortmentService>;
|
|
120
|
+
};
|
|
111
121
|
users: {
|
|
112
122
|
migrateUserData: Bound<typeof migrateUserDataService>;
|
|
113
123
|
updateUserAvatarAfterUpload: Bound<typeof updateUserAvatarAfterUploadService>;
|
|
114
124
|
deleteUser: Bound<typeof deleteUserService>;
|
|
125
|
+
bulkDeleteUsers: Bound<typeof bulkDeleteUsersService>;
|
|
115
126
|
};
|
|
116
127
|
enrollments: {
|
|
117
128
|
createEnrollmentFromCheckout: Bound<typeof createEnrollmentFromCheckoutService>;
|
|
118
129
|
generateOrderFromEnrollment: Bound<typeof generateOrderFromEnrollmentService>;
|
|
119
|
-
processEnrollment: Bound<typeof
|
|
130
|
+
processEnrollment: Bound<typeof processEnrollmentService>;
|
|
120
131
|
initializeEnrollment: Bound<typeof initializeEnrollmentService>;
|
|
121
132
|
activateEnrollment: Bound<typeof activateEnrollmentService>;
|
|
122
133
|
terminateEnrollment: Bound<typeof terminateEnrollmentService>;
|
|
@@ -139,6 +150,8 @@ export default function initServices(modules: Modules, customServices?: CustomSe
|
|
|
139
150
|
updateFilter: Bound<typeof updateFilterService>;
|
|
140
151
|
createFilterOption: Bound<typeof createFilterOptionService>;
|
|
141
152
|
removeFilterOption: Bound<typeof removeFilterOptionService>;
|
|
153
|
+
bulkRemoveFilters: Bound<typeof bulkRemoveFiltersService>;
|
|
154
|
+
bulkSetFilterActive: Bound<typeof bulkSetFilterActiveService>;
|
|
142
155
|
};
|
|
143
156
|
warehousing: {
|
|
144
157
|
ercMetadata: Bound<typeof ercMetadataService>;
|
package/lib/services/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import { searchProductsService } from "./searchProducts.js";
|
|
|
23
23
|
import { calculateDiscountTotalService } from "./calculateDiscountTotal.js";
|
|
24
24
|
import { registerPaymentCredentialsService } from "./registerPaymentCredentials.js";
|
|
25
25
|
import { processOrderService } from "./processOrder.js";
|
|
26
|
+
import { processEnrollmentService } from "./processEnrollment.js";
|
|
26
27
|
import { checkoutOrderService } from "./checkoutOrder.js";
|
|
27
28
|
import { confirmOrderService } from "./confirmOrder.js";
|
|
28
29
|
import { rejectOrderService } from "./rejectOrder.js";
|
|
@@ -61,6 +62,11 @@ import { simulateConfigurablePriceRangeService } from "./simulateConfigurablePri
|
|
|
61
62
|
import { createFileDownloadURLService } from "./createFileDownloadURL.js";
|
|
62
63
|
import { resolveTokenStatusService } from "./resolveTokenStatus.js";
|
|
63
64
|
import { isTokenInvalidateableService } from "./isTokenInvalidateable.js";
|
|
65
|
+
import { bulkRemoveProductsService } from "./bulkRemoveProducts.js";
|
|
66
|
+
import { bulkRemoveFiltersService } from "./bulkRemoveFilters.js";
|
|
67
|
+
import { bulkDeleteUsersService } from "./bulkDeleteUsers.js";
|
|
68
|
+
import { bulkSetFilterActiveService } from "./bulkSetFilterActive.js";
|
|
69
|
+
import { bulkAssignProductsToAssortmentService } from "./bulkAssignProductsToAssortment.js";
|
|
64
70
|
function bindMethodsToModules(modules) {
|
|
65
71
|
return {
|
|
66
72
|
get(target, prop, receiver) {
|
|
@@ -116,18 +122,23 @@ export default function initServices(modules, customServices = {}) {
|
|
|
116
122
|
simulateProductDispatching: simulateProductDispatchingService,
|
|
117
123
|
simulateProductInventory: simulateProductInventoryService,
|
|
118
124
|
removeProduct: removeProductService,
|
|
125
|
+
bulkRemoveProducts: bulkRemoveProductsService,
|
|
119
126
|
findProductSiblings: findProductSiblingsService,
|
|
120
127
|
simulateConfigurablePriceRange: simulateConfigurablePriceRangeService,
|
|
121
128
|
},
|
|
129
|
+
assortments: {
|
|
130
|
+
bulkAssignProductsToAssortment: bulkAssignProductsToAssortmentService,
|
|
131
|
+
},
|
|
122
132
|
users: {
|
|
123
133
|
migrateUserData: migrateUserDataService,
|
|
124
134
|
updateUserAvatarAfterUpload: updateUserAvatarAfterUploadService,
|
|
125
135
|
deleteUser: deleteUserService,
|
|
136
|
+
bulkDeleteUsers: bulkDeleteUsersService,
|
|
126
137
|
},
|
|
127
138
|
enrollments: {
|
|
128
139
|
createEnrollmentFromCheckout: createEnrollmentFromCheckoutService,
|
|
129
140
|
generateOrderFromEnrollment: generateOrderFromEnrollmentService,
|
|
130
|
-
processEnrollment:
|
|
141
|
+
processEnrollment: processEnrollmentService,
|
|
131
142
|
initializeEnrollment: initializeEnrollmentService,
|
|
132
143
|
activateEnrollment: activateEnrollmentService,
|
|
133
144
|
terminateEnrollment: terminateEnrollmentService,
|
|
@@ -150,6 +161,8 @@ export default function initServices(modules, customServices = {}) {
|
|
|
150
161
|
updateFilter: updateFilterService,
|
|
151
162
|
createFilterOption: createFilterOptionService,
|
|
152
163
|
removeFilterOption: removeFilterOptionService,
|
|
164
|
+
bulkRemoveFilters: bulkRemoveFiltersService,
|
|
165
|
+
bulkSetFilterActive: bulkSetFilterActiveService,
|
|
153
166
|
},
|
|
154
167
|
warehousing: {
|
|
155
168
|
ercMetadata: ercMetadataService,
|
|
@@ -39,6 +39,7 @@ export async function initCartProvidersService(order) {
|
|
|
39
39
|
const paymentCredentials = await this.payment.paymentCredentials.findPaymentCredentials({ userId: updatedOrder.userId, isPreferred: true }, {
|
|
40
40
|
sort: {
|
|
41
41
|
created: -1,
|
|
42
|
+
_id: -1,
|
|
42
43
|
},
|
|
43
44
|
});
|
|
44
45
|
const defaultOrderPaymentProvider = await paymentSettings.determineDefaultProvider({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getFileAdapter } from
|
|
1
|
+
import { getFileAdapter } from "../utils/getFileAdapter.js";
|
|
2
2
|
export async function removeFilesService({ fileIds }) {
|
|
3
3
|
if (fileIds && typeof fileIds !== 'string' && !Array.isArray(fileIds))
|
|
4
4
|
throw Error('Media id/s to be removed not provided as a string or array');
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
2
|
+
import { OrderDiscountDirector } from "../directors/OrderDiscountDirector.js";
|
|
3
|
+
const logger = createLogger('unchained:core:checkoutOrder');
|
|
4
|
+
export async function reserveOrderDiscountsForCheckout(order) {
|
|
5
|
+
const reservations = [];
|
|
6
|
+
const release = async () => {
|
|
7
|
+
const results = await Promise.allSettled(reservations.map((reservation) => reservation.release()));
|
|
8
|
+
for (const result of results) {
|
|
9
|
+
if (result.status === 'rejected') {
|
|
10
|
+
logger.error(`Could not release a discount reservation of order ${order._id}`, {
|
|
11
|
+
error: result.reason,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
try {
|
|
17
|
+
const discounts = await this.orders.discounts.findOrderDiscounts({ orderId: order._id });
|
|
18
|
+
for (const orderDiscount of discounts) {
|
|
19
|
+
const Adapter = OrderDiscountDirector.getAdapter(orderDiscount.discountKey);
|
|
20
|
+
if (!Adapter)
|
|
21
|
+
continue;
|
|
22
|
+
const adapter = await Adapter.actions({
|
|
23
|
+
context: { order, orderDiscount, code: orderDiscount.code, modules: this },
|
|
24
|
+
});
|
|
25
|
+
if (adapter.reserveForCheckout)
|
|
26
|
+
reservations.push(await adapter.reserveForCheckout());
|
|
27
|
+
}
|
|
28
|
+
return { release };
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
await release();
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -3,10 +3,12 @@ import type { Product } from '@unchainedshop/core-products';
|
|
|
3
3
|
import { type EstimatedDispatch } from '../directors/WarehousingDirector.ts';
|
|
4
4
|
import type { WarehousingContext } from '../directors/WarehousingAdapter.ts';
|
|
5
5
|
import type { WarehousingProvider } from '@unchainedshop/core-warehousing';
|
|
6
|
-
|
|
6
|
+
import type { DeliveryProviderType } from '@unchainedshop/core-delivery';
|
|
7
|
+
export declare function simulateProductDispatchingService(this: Modules, { product, quantity, referenceDate, deliveryProviderType, }: {
|
|
7
8
|
product: Product;
|
|
8
9
|
quantity: number;
|
|
9
10
|
referenceDate?: Date;
|
|
11
|
+
deliveryProviderType?: DeliveryProviderType | null;
|
|
10
12
|
}): Promise<(WarehousingContext & EstimatedDispatch & {
|
|
11
13
|
warehousingProvider: WarehousingProvider;
|
|
12
14
|
})[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { supportedWarehousingProvidersService } from "./supportedWarehousingProviders.js";
|
|
2
2
|
import { WarehousingDirector } from "../directors/WarehousingDirector.js";
|
|
3
|
-
export async function simulateProductDispatchingService({ product, quantity, referenceDate, }) {
|
|
4
|
-
const deliveryProviders = await this.delivery.allProviders();
|
|
3
|
+
export async function simulateProductDispatchingService({ product, quantity, referenceDate, deliveryProviderType, }) {
|
|
4
|
+
const deliveryProviders = (await this.delivery.allProviders()).filter(({ type }) => !deliveryProviderType || type === deliveryProviderType);
|
|
5
5
|
return deliveryProviders.reduce(async (oldResult, deliveryProvider) => {
|
|
6
6
|
const result = await oldResult;
|
|
7
7
|
const warehousingProviders = await supportedWarehousingProvidersService.bind(this)({
|
|
@@ -25,6 +25,6 @@ export async function simulateProductDispatchingService({ product, quantity, ref
|
|
|
25
25
|
...dispatch,
|
|
26
26
|
};
|
|
27
27
|
}));
|
|
28
|
-
return result.concat(
|
|
28
|
+
return result.concat(mappedWarehousingProviders);
|
|
29
29
|
}, Promise.resolve([]));
|
|
30
30
|
}
|
|
@@ -2,9 +2,11 @@ import type { Modules } from '../modules.ts';
|
|
|
2
2
|
import type { Product } from '@unchainedshop/core-products';
|
|
3
3
|
import type { WarehousingContext } from '../directors/WarehousingAdapter.ts';
|
|
4
4
|
import type { WarehousingProvider } from '@unchainedshop/core-warehousing';
|
|
5
|
-
|
|
5
|
+
import type { DeliveryProviderType } from '@unchainedshop/core-delivery';
|
|
6
|
+
export declare function simulateProductInventoryService(this: Modules, { product, referenceDate, deliveryProviderType, }: {
|
|
6
7
|
product: Product;
|
|
7
8
|
referenceDate?: Date;
|
|
9
|
+
deliveryProviderType?: DeliveryProviderType | null;
|
|
8
10
|
}): Promise<(WarehousingContext & {
|
|
9
11
|
quantity?: number;
|
|
10
12
|
} & {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { supportedWarehousingProvidersService } from "./supportedWarehousingProviders.js";
|
|
2
2
|
import { WarehousingDirector } from "../directors/WarehousingDirector.js";
|
|
3
|
-
export async function simulateProductInventoryService({ product, referenceDate, }) {
|
|
4
|
-
const deliveryProviders = await this.delivery.allProviders();
|
|
3
|
+
export async function simulateProductInventoryService({ product, referenceDate, deliveryProviderType, }) {
|
|
4
|
+
const deliveryProviders = (await this.delivery.allProviders()).filter(({ type }) => !deliveryProviderType || type === deliveryProviderType);
|
|
5
5
|
return deliveryProviders.reduce(async (oldResult, deliveryProvider) => {
|
|
6
6
|
const result = await oldResult;
|
|
7
7
|
const warehousingProviders = await supportedWarehousingProvidersService.bind(this)({
|
|
@@ -24,6 +24,6 @@ export async function simulateProductInventoryService({ product, referenceDate,
|
|
|
24
24
|
...stock,
|
|
25
25
|
};
|
|
26
26
|
}));
|
|
27
|
-
return result.concat(
|
|
27
|
+
return result.concat(mappedWarehousingProviders);
|
|
28
28
|
}, Promise.resolve([]));
|
|
29
29
|
}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { deliverySettings } from '@unchainedshop/core-delivery';
|
|
2
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
2
3
|
import { DeliveryDirector } from "../directors/index.js";
|
|
4
|
+
const logger = createLogger('unchained:core');
|
|
3
5
|
export async function supportedDeliveryProvidersService(params) {
|
|
4
6
|
const allProviders = await this.delivery.allProviders();
|
|
5
7
|
const providers = (await Promise.all(allProviders.map(async (provider) => {
|
|
8
|
+
if (!DeliveryDirector.getAdapter(provider.adapterKey)) {
|
|
9
|
+
logger.warn('Delivery provider skipped, its adapter is not registered', {
|
|
10
|
+
deliveryProviderId: provider._id,
|
|
11
|
+
adapterKey: provider.adapterKey,
|
|
12
|
+
});
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
6
15
|
const adapter = await DeliveryDirector.actions(provider, params, { modules: this });
|
|
7
16
|
return adapter.isActive() ? [provider] : [];
|
|
8
17
|
}))).flat();
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { paymentSettings } from '@unchainedshop/core-payment';
|
|
2
|
+
import { createLogger } from '@unchainedshop/logger';
|
|
2
3
|
import { PaymentDirector } from "../directors/PaymentDirector.js";
|
|
4
|
+
const logger = createLogger('unchained:core');
|
|
3
5
|
export async function supportedPaymentProvidersService(params) {
|
|
4
6
|
const allProviders = await this.payment.paymentProviders.allProviders();
|
|
5
7
|
const providers = (await Promise.all(allProviders.map(async (provider) => {
|
|
8
|
+
if (!PaymentDirector.getAdapter(provider.adapterKey)) {
|
|
9
|
+
logger.warn('Payment provider skipped, its adapter is not registered', {
|
|
10
|
+
paymentProviderId: provider._id,
|
|
11
|
+
adapterKey: provider.adapterKey,
|
|
12
|
+
});
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
6
15
|
const adapter = await PaymentDirector.actions(provider, params, { modules: this });
|
|
7
16
|
return adapter.isActive() ? [provider] : [];
|
|
8
17
|
}))).flat();
|
|
@@ -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,4 +1,5 @@
|
|
|
1
|
-
import { getFileFromFileData
|
|
1
|
+
import { getFileFromFileData } from '@unchainedshop/core-files';
|
|
2
|
+
import { getFileAdapter } from "../utils/getFileAdapter.js";
|
|
2
3
|
import { createServiceError } from "../errors.js";
|
|
3
4
|
export async function uploadFileFromStreamService({ directoryName, rawFile, meta, ...options }) {
|
|
4
5
|
const fileUploadAdapter = getFileAdapter();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getFileFromFileData
|
|
1
|
+
import { getFileFromFileData } from '@unchainedshop/core-files';
|
|
2
|
+
import { getFileAdapter } from "../utils/getFileAdapter.js";
|
|
2
3
|
export async function uploadFileFromURLService({ directoryName, fileInput, meta, }) {
|
|
3
4
|
const fileUploadAdapter = getFileAdapter();
|
|
4
5
|
const uploadFileData = await fileUploadAdapter.uploadFileFromURL(directoryName, fileInput, {
|
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": "
|
|
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,33 +38,32 @@
|
|
|
35
38
|
},
|
|
36
39
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
37
40
|
"dependencies": {
|
|
38
|
-
"@unchainedshop/core-assortments": "^
|
|
39
|
-
"@unchainedshop/core-bookmarks": "^
|
|
40
|
-
"@unchainedshop/core-countries": "^
|
|
41
|
-
"@unchainedshop/core-currencies": "^
|
|
42
|
-
"@unchainedshop/core-delivery": "^
|
|
43
|
-
"@unchainedshop/core-enrollments": "^
|
|
44
|
-
"@unchainedshop/core-events": "^
|
|
45
|
-
"@unchainedshop/core-files": "^
|
|
46
|
-
"@unchainedshop/core-filters": "^
|
|
47
|
-
"@unchainedshop/core-languages": "^
|
|
48
|
-
"@unchainedshop/core-orders": "^
|
|
49
|
-
"@unchainedshop/core-payment": "^
|
|
50
|
-
"@unchainedshop/core-products": "^
|
|
51
|
-
"@unchainedshop/core-quotations": "^
|
|
52
|
-
"@unchainedshop/core-users": "^
|
|
53
|
-
"@unchainedshop/core-warehousing": "^
|
|
54
|
-
"@unchainedshop/core-worker": "^
|
|
55
|
-
"@unchainedshop/events": "^
|
|
56
|
-
"@unchainedshop/
|
|
57
|
-
"@unchainedshop/
|
|
58
|
-
"@unchainedshop/
|
|
59
|
-
"@unchainedshop/utils": "^4.8.27",
|
|
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",
|
|
60
62
|
"minipass-json-stream": "^1.0.2",
|
|
61
63
|
"zod": "^4.2.0"
|
|
62
64
|
},
|
|
63
65
|
"devDependencies": {
|
|
64
66
|
"@types/node": "^26.2.0",
|
|
65
|
-
"typescript": "^
|
|
67
|
+
"typescript": "^6.0.3"
|
|
66
68
|
}
|
|
67
69
|
}
|