@unchainedshop/core 4.6.1 → 4.7.2
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/core-index.d.ts +3 -0
- package/lib/core-index.js +6 -2
- package/lib/directors/BaseDiscountDirector.js +6 -6
- package/lib/directors/BasePricingDirector.js +1 -1
- package/lib/directors/DeliveryAdapter.js +1 -0
- package/lib/directors/DeliveryDirector.js +11 -2
- 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 +12 -2
- package/lib/directors/DeliveryPricingSheet.d.ts +1 -1
- package/lib/directors/DeliveryPricingSheet.js +1 -1
- package/lib/directors/EnrollmentAdapter.js +1 -0
- package/lib/directors/EnrollmentDirector.js +11 -1
- package/lib/directors/FileDirector.d.ts +10 -0
- package/lib/directors/FileDirector.js +25 -0
- package/lib/directors/FilterAdapter.js +1 -0
- package/lib/directors/FilterDirector.js +11 -1
- package/lib/directors/OrderDiscountAdapter.d.ts +3 -2
- package/lib/directors/OrderDiscountAdapter.js +5 -2
- package/lib/directors/OrderDiscountDirector.d.ts +15 -1
- package/lib/directors/OrderDiscountDirector.js +14 -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 +12 -1
- package/lib/directors/OrderPricingSheet.d.ts +1 -1
- package/lib/directors/OrderPricingSheet.js +1 -1
- package/lib/directors/PaymentAdapter.js +1 -0
- package/lib/directors/PaymentDirector.js +11 -2
- 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 +11 -1
- 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 +16 -2
- package/lib/directors/ProductDiscountDirector.js +15 -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 +12 -1
- 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.js +11 -2
- package/lib/directors/WarehousingAdapter.js +1 -0
- package/lib/directors/WarehousingDirector.d.ts +1 -1
- package/lib/directors/WarehousingDirector.js +12 -2
- package/lib/directors/WorkerAdapter.js +1 -0
- package/lib/directors/WorkerDirector.d.ts +1 -1
- package/lib/directors/WorkerDirector.js +10 -17
- package/lib/directors/index.d.ts +2 -0
- package/lib/directors/index.js +2 -0
- package/lib/errors/common.d.ts +568 -0
- package/lib/errors/common.js +789 -0
- package/lib/errors/index.d.ts +1 -0
- package/lib/errors/index.js +1 -0
- package/lib/factory/registerAssortmentSearchFilter.d.ts +2 -1
- package/lib/factory/registerAssortmentSearchFilter.js +12 -3
- 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 +2 -1
- package/lib/factory/registerProductDiscoverabilityFilter.js +12 -3
- package/lib/factory/registerProductSearchFilter.d.ts +2 -1
- package/lib/factory/registerProductSearchFilter.js +12 -3
- 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 +12 -3
- package/lib/factory/registerWorker.d.ts +2 -1
- package/lib/factory/registerWorker.js +12 -3
- package/lib/plugins/PluginRegistry.d.ts +42 -0
- package/lib/plugins/PluginRegistry.js +113 -0
- package/lib/services/addCartDiscount.d.ts +10 -0
- package/lib/services/addCartDiscount.js +27 -0
- package/lib/services/addCartItem.d.ts +15 -0
- package/lib/services/addCartItem.js +41 -0
- package/lib/services/addCartQuotation.d.ts +16 -0
- package/lib/services/addCartQuotation.js +52 -0
- package/lib/services/addEmail.d.ts +7 -0
- package/lib/services/addEmail.js +17 -0
- package/lib/services/addProductAssignment.d.ts +3 -0
- package/lib/services/addProductAssignment.js +63 -0
- package/lib/services/authenticateWithPassword.d.ts +15 -0
- package/lib/services/authenticateWithPassword.js +34 -0
- package/lib/services/changePassword.d.ts +10 -0
- package/lib/services/changePassword.js +19 -0
- package/lib/services/countOrdersWithFilters.d.ts +3 -0
- package/lib/services/countOrdersWithFilters.js +25 -0
- package/lib/services/createAssortment.d.ts +7 -0
- package/lib/services/createAssortment.js +10 -0
- package/lib/services/createBookmark.d.ts +8 -0
- package/lib/services/createBookmark.js +21 -0
- package/lib/services/createDeliveryProvider.d.ts +6 -0
- package/lib/services/createDeliveryProvider.js +19 -0
- package/lib/services/createDownloadStream.js +1 -1
- package/lib/services/createEnrollment.d.ts +17 -0
- package/lib/services/createEnrollment.js +33 -0
- package/lib/services/createFileDownloadURL.js +2 -1
- package/lib/services/createProduct.d.ts +7 -0
- package/lib/services/createProduct.js +8 -0
- package/lib/services/createProductBundleItem.d.ts +5 -0
- package/lib/services/createProductBundleItem.js +25 -0
- package/lib/services/createProductReview.d.ts +8 -0
- package/lib/services/createProductReview.js +12 -0
- package/lib/services/createSignedURL.js +2 -1
- package/lib/services/deliverOrder.d.ts +5 -0
- package/lib/services/deliverOrder.js +26 -0
- package/lib/services/findActiveWorkTypes.d.ts +2 -0
- package/lib/services/findActiveWorkTypes.js +6 -0
- package/lib/services/findDeliveryInterfaces.d.ts +7 -0
- package/lib/services/findDeliveryInterfaces.js +13 -0
- package/lib/services/findOrdersWithFilters.d.ts +9 -0
- package/lib/services/findOrdersWithFilters.js +25 -0
- package/lib/services/findPaymentInterfaces.d.ts +7 -0
- package/lib/services/findPaymentInterfaces.js +13 -0
- package/lib/services/findWarehousingInterfaces.d.ts +7 -0
- package/lib/services/findWarehousingInterfaces.js +13 -0
- package/lib/services/getDeliveryDiscounts.d.ts +8 -0
- package/lib/services/getDeliveryDiscounts.js +14 -0
- package/lib/services/getPaymentDiscounts.d.ts +8 -0
- package/lib/services/getPaymentDiscounts.js +14 -0
- package/lib/services/getShopInfo.d.ts +25 -0
- package/lib/services/getShopInfo.js +47 -0
- package/lib/services/impersonateUser.d.ts +8 -0
- package/lib/services/impersonateUser.js +20 -0
- package/lib/services/linkFileService.js +1 -1
- package/lib/services/loginAsGuest.d.ts +10 -0
- package/lib/services/loginAsGuest.js +19 -0
- package/lib/services/obfuscateWorkerData.d.ts +4 -0
- package/lib/services/obfuscateWorkerData.js +4 -0
- package/lib/services/orderPricingAccessors.d.ts +18 -0
- package/lib/services/orderPricingAccessors.js +29 -0
- package/lib/services/payOrder.d.ts +5 -0
- package/lib/services/payOrder.js +25 -0
- package/lib/services/registerUser.d.ts +14 -0
- package/lib/services/registerUser.js +44 -0
- package/lib/services/removeBookmark.d.ts +6 -0
- package/lib/services/removeBookmark.js +10 -0
- package/lib/services/removeCartItem.d.ts +6 -0
- package/lib/services/removeCartItem.js +19 -0
- package/lib/services/removeFiles.js +1 -1
- package/lib/services/resetPasswordWithMigration.d.ts +14 -0
- package/lib/services/resetPasswordWithMigration.js +31 -0
- package/lib/services/resolveWorkType.d.ts +1 -0
- package/lib/services/resolveWorkType.js +7 -0
- package/lib/services/searchProductsWithAssortment.d.ts +19 -0
- package/lib/services/searchProductsWithAssortment.js +17 -0
- package/lib/services/toggleBookmark.d.ts +8 -0
- package/lib/services/toggleBookmark.js +33 -0
- package/lib/services/updateCart.d.ts +15 -0
- package/lib/services/updateCart.js +27 -0
- package/lib/services/updateCartItem.d.ts +11 -0
- package/lib/services/updateCartItem.js +37 -0
- package/lib/services/updateEnrollment.d.ts +13 -0
- package/lib/services/updateEnrollment.js +36 -0
- package/lib/services/uploadFileFromStream.js +2 -1
- package/lib/services/uploadFileFromURL.js +2 -1
- package/lib/services/verifyEmailWithMigration.d.ts +15 -0
- package/lib/services/verifyEmailWithMigration.js +23 -0
- package/lib/utils/getFileAdapter.d.ts +1 -0
- package/lib/utils/getFileAdapter.js +7 -0
- package/lib/utils/schedule.js +164 -28
- package/package.json +1 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Product, ProductConfiguration } from '@unchainedshop/core-products';
|
|
2
2
|
import type { User } from '@unchainedshop/core-users';
|
|
3
3
|
import type { Order, OrderDiscount, OrderPosition } from '@unchainedshop/core-orders';
|
|
4
|
-
import { type IProductPricingSheet, type ProductPricingCalculation
|
|
4
|
+
import { type IProductPricingSheet, type ProductPricingCalculation } from './ProductPricingSheet.ts';
|
|
5
|
+
import { type IProductPricingAdapter, type ProductPricingAdapterContext } from './ProductPricingAdapter.ts';
|
|
6
|
+
import { type IPricingDirector } from './BasePricingDirector.ts';
|
|
5
7
|
export type ProductPricingContext = {
|
|
6
8
|
currencyCode: string;
|
|
7
9
|
countryCode: string;
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import { ProductPricingSheet,
|
|
1
|
+
import { ProductPricingSheet, } from "./ProductPricingSheet.js";
|
|
2
|
+
import { ProductPricingAdapter, } from "./ProductPricingAdapter.js";
|
|
3
|
+
import { BasePricingDirector } from "./BasePricingDirector.js";
|
|
4
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
2
5
|
const baseDirector = BasePricingDirector('ProductPricingDirector');
|
|
3
6
|
export const ProductPricingDirector = {
|
|
4
7
|
...baseDirector,
|
|
8
|
+
getAdapter: (key) => {
|
|
9
|
+
const adapters = pluginRegistry.getAdapters(ProductPricingAdapter.adapterType);
|
|
10
|
+
return adapters.find((adapter) => adapter.key === key) || null;
|
|
11
|
+
},
|
|
12
|
+
getAdapters: ({ adapterFilter } = {}) => {
|
|
13
|
+
const adapters = pluginRegistry.getAdapters(ProductPricingAdapter.adapterType);
|
|
14
|
+
return adapters.filter(adapterFilter || (() => true));
|
|
15
|
+
},
|
|
5
16
|
async buildPricingContext(context, unchainedAPI) {
|
|
6
17
|
const { modules } = unchainedAPI;
|
|
7
18
|
const { quantity = 1, currencyCode } = context;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Price, PricingCalculation } from '@unchainedshop/utils';
|
|
2
|
-
import { type IPricingSheet, type PricingSheetParams } from '
|
|
2
|
+
import { type IPricingSheet, type PricingSheetParams } from './BasePricingSheet.ts';
|
|
3
3
|
export interface ProductPricingCalculation extends PricingCalculation {
|
|
4
4
|
discountId?: string;
|
|
5
5
|
isTaxable: boolean;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { BaseDirector } from '@unchainedshop/utils';
|
|
2
|
-
import { QuotationError, } from "./QuotationAdapter.js";
|
|
2
|
+
import { QuotationError, QuotationAdapter, } from "./QuotationAdapter.js";
|
|
3
3
|
import { createLogger } from '@unchainedshop/logger';
|
|
4
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
4
5
|
const logger = createLogger('unchained:core');
|
|
5
6
|
const baseDirector = BaseDirector('QuotationDirector', {
|
|
6
7
|
adapterSortKey: 'orderIndex',
|
|
7
8
|
});
|
|
8
|
-
const findAppropriateAdapters = (quotationContext, unchainedAPI) =>
|
|
9
|
+
const findAppropriateAdapters = (quotationContext, unchainedAPI) => QuotationDirector.getAdapters({
|
|
9
10
|
adapterFilter: (Adapter) => {
|
|
10
11
|
const activated = Adapter.isActivatedFor(quotationContext, unchainedAPI);
|
|
11
12
|
if (!activated) {
|
|
@@ -16,6 +17,14 @@ const findAppropriateAdapters = (quotationContext, unchainedAPI) => baseDirector
|
|
|
16
17
|
});
|
|
17
18
|
export const QuotationDirector = {
|
|
18
19
|
...baseDirector,
|
|
20
|
+
getAdapter: (key) => {
|
|
21
|
+
const adapters = pluginRegistry.getAdapters(QuotationAdapter.adapterType);
|
|
22
|
+
return adapters.find((adapter) => adapter.key === key) || null;
|
|
23
|
+
},
|
|
24
|
+
getAdapters: ({ adapterFilter } = {}) => {
|
|
25
|
+
const adapters = pluginRegistry.getAdapters(QuotationAdapter.adapterType);
|
|
26
|
+
return adapters.filter(adapterFilter || (() => true));
|
|
27
|
+
},
|
|
19
28
|
actions: async (quotationContext, unchainedAPI) => {
|
|
20
29
|
const context = { ...quotationContext, ...unchainedAPI };
|
|
21
30
|
const Adapter = findAppropriateAdapters(quotationContext, unchainedAPI)?.shift();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IBaseDirector } from '@unchainedshop/utils';
|
|
2
2
|
import type { WarehousingProvider, TokenSurrogate } from '@unchainedshop/core-warehousing';
|
|
3
|
-
import { type IWarehousingAdapter, type WarehousingContext, WarehousingError } from '
|
|
3
|
+
import { type IWarehousingAdapter, type WarehousingContext, WarehousingError } from './WarehousingAdapter.ts';
|
|
4
4
|
import type { Modules } from '../modules.ts';
|
|
5
5
|
export interface EstimatedDispatch {
|
|
6
6
|
shipping?: Date;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { BaseDirector } from '@unchainedshop/utils';
|
|
2
2
|
import { createLogger } from '@unchainedshop/logger';
|
|
3
3
|
const logger = createLogger('unchained:core');
|
|
4
|
-
import { DeliveryDirector
|
|
4
|
+
import { DeliveryDirector } from "./DeliveryDirector.js";
|
|
5
|
+
import { WarehousingError, WarehousingAdapter, } from "./WarehousingAdapter.js";
|
|
6
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
5
7
|
const getReferenceDate = (context) => {
|
|
6
8
|
return context && context.referenceDate ? context.referenceDate : new Date();
|
|
7
9
|
};
|
|
@@ -10,8 +12,16 @@ const baseDirector = BaseDirector('WarehousingDirector', {
|
|
|
10
12
|
});
|
|
11
13
|
export const WarehousingDirector = {
|
|
12
14
|
...baseDirector,
|
|
15
|
+
getAdapter: (key) => {
|
|
16
|
+
const adapters = pluginRegistry.getAdapters(WarehousingAdapter.adapterType);
|
|
17
|
+
return adapters.find((adapter) => adapter.key === key) || null;
|
|
18
|
+
},
|
|
19
|
+
getAdapters: ({ adapterFilter } = {}) => {
|
|
20
|
+
const adapters = pluginRegistry.getAdapters(WarehousingAdapter.adapterType);
|
|
21
|
+
return adapters.filter(adapterFilter || (() => true));
|
|
22
|
+
},
|
|
13
23
|
actions: async (warehousingProvider, warehousingContext, unchainedAPI) => {
|
|
14
|
-
const Adapter =
|
|
24
|
+
const Adapter = WarehousingDirector.getAdapter(warehousingProvider.adapterKey);
|
|
15
25
|
if (!Adapter) {
|
|
16
26
|
throw new Error(`Warehousing Plugin ${warehousingProvider.adapterKey} not available`);
|
|
17
27
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Work, WorkData, WorkResult } from '@unchainedshop/core-worker';
|
|
2
2
|
import { type IBaseDirector } from '@unchainedshop/utils';
|
|
3
3
|
import type { ScheduleData } from '../utils/schedule.ts';
|
|
4
|
-
import type
|
|
4
|
+
import { type IWorkerAdapter } from './WorkerAdapter.ts';
|
|
5
5
|
import type { Modules } from '../modules.ts';
|
|
6
6
|
export type WorkScheduleConfiguration = Pick<WorkData, 'timeout' | 'retries' | 'priority' | 'worker' | 'scheduleId'> & {
|
|
7
7
|
type: string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { BaseDirector } from '@unchainedshop/utils';
|
|
2
|
+
import { WorkerAdapter } from "./WorkerAdapter.js";
|
|
2
3
|
import { createLogger } from '@unchainedshop/logger';
|
|
4
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
3
5
|
const logger = createLogger('unchained:core');
|
|
4
6
|
const AutoScheduleMap = new Map();
|
|
5
7
|
const baseDirector = BaseDirector('WorkerDirector', {
|
|
@@ -7,6 +9,14 @@ const baseDirector = BaseDirector('WorkerDirector', {
|
|
|
7
9
|
});
|
|
8
10
|
export const WorkerDirector = {
|
|
9
11
|
...baseDirector,
|
|
12
|
+
getAdapter: (key) => {
|
|
13
|
+
const adapters = pluginRegistry.getAdapters(WorkerAdapter.adapterType);
|
|
14
|
+
return adapters.find((adapter) => adapter.key === key) || null;
|
|
15
|
+
},
|
|
16
|
+
getAdapters: ({ adapterFilter } = {}) => {
|
|
17
|
+
const adapters = pluginRegistry.getAdapters(WorkerAdapter.adapterType);
|
|
18
|
+
return adapters.filter(adapterFilter || (() => true));
|
|
19
|
+
},
|
|
10
20
|
getActivePluginTypes: ({ external } = {}) => {
|
|
11
21
|
return WorkerDirector.getAdapters()
|
|
12
22
|
.filter((adapter) => {
|
|
@@ -16,26 +26,9 @@ export const WorkerDirector = {
|
|
|
16
26
|
})
|
|
17
27
|
.map((adapter) => adapter.type);
|
|
18
28
|
},
|
|
19
|
-
registerAdapter: (Adapter) => {
|
|
20
|
-
if (WorkerDirector.getAdapterByType(Adapter.type))
|
|
21
|
-
throw new Error(`WorkerDirector: There is already a adapter registered with type: ${Adapter.type}`);
|
|
22
|
-
baseDirector.registerAdapter(Adapter);
|
|
23
|
-
},
|
|
24
29
|
disableAutoscheduling: (type) => {
|
|
25
30
|
AutoScheduleMap.delete(type);
|
|
26
31
|
},
|
|
27
|
-
unregisterAdapter: (key) => {
|
|
28
|
-
const adapter = WorkerDirector.getAdapter(key);
|
|
29
|
-
const result = baseDirector.unregisterAdapter(key);
|
|
30
|
-
if (adapter) {
|
|
31
|
-
AutoScheduleMap.forEach((workItemConfiguration, scheduleId) => {
|
|
32
|
-
if (workItemConfiguration.type === adapter.type) {
|
|
33
|
-
AutoScheduleMap.delete(scheduleId);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return result;
|
|
38
|
-
},
|
|
39
32
|
configureAutoscheduling: (workItemConfiguration) => {
|
|
40
33
|
AutoScheduleMap.set(workItemConfiguration.scheduleId || workItemConfiguration.type, workItemConfiguration);
|
|
41
34
|
},
|
package/lib/directors/index.d.ts
CHANGED
|
@@ -39,4 +39,6 @@ export * from './FailedRescheduler.ts';
|
|
|
39
39
|
export * from './BaseWorker.ts';
|
|
40
40
|
export * from './QuotationAdapter.ts';
|
|
41
41
|
export * from './QuotationDirector.ts';
|
|
42
|
+
export * from './FileDirector.ts';
|
|
43
|
+
export { type IFileAdapter, FileAdapter } from '@unchainedshop/core-files';
|
|
42
44
|
export * from './MessagingDirector.ts';
|
package/lib/directors/index.js
CHANGED
|
@@ -39,4 +39,6 @@ export * from "./FailedRescheduler.js";
|
|
|
39
39
|
export * from "./BaseWorker.js";
|
|
40
40
|
export * from "./QuotationAdapter.js";
|
|
41
41
|
export * from "./QuotationDirector.js";
|
|
42
|
+
export * from "./FileDirector.js";
|
|
43
|
+
export { FileAdapter } from '@unchainedshop/core-files';
|
|
42
44
|
export * from "./MessagingDirector.js";
|