@unchainedshop/core 4.8.4 → 5.0.0-alpha.1
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-exporter/createBulkExporter.d.ts +2 -2
- package/lib/bulk-exporter/createBulkExporter.js +2 -2
- 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 +9 -9
- package/lib/bulk-exporter/handlers/exportUsersHandler.d.ts +17 -17
- package/lib/bulk-exporter/handlers/exportUsersHandler.js +8 -8
- package/lib/bulk-importer/createBulkImporter.js +6 -6
- package/lib/bulk-importer/handlers/product/create.d.ts +3 -3
- package/lib/bulk-importer/handlers/product/create.js +2 -2
- package/lib/bulk-importer/handlers/product/update.d.ts +3 -3
- package/lib/bulk-importer/handlers/product/update.js +1 -1
- 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/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/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/services/createDownloadStream.js +1 -1
- package/lib/services/createFileDownloadURL.js +2 -1
- package/lib/services/createSignedURL.js +2 -1
- package/lib/services/linkFileService.js +1 -1
- package/lib/services/removeFiles.js +1 -1
- package/lib/services/uploadFileFromStream.js +2 -1
- package/lib/services/uploadFileFromURL.js +2 -1
- package/package.json +20 -20
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { BaseDirector } from '@unchainedshop/utils';
|
|
2
|
+
import { EnrollmentAdapter } from "./EnrollmentAdapter.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 baseDirector = BaseDirector('EnrollmentDirector', {
|
|
5
7
|
adapterSortKey: 'orderIndex',
|
|
6
8
|
});
|
|
7
|
-
const findAppropriateAdapters = (productPlan) =>
|
|
9
|
+
const findAppropriateAdapters = (productPlan) => EnrollmentDirector.getAdapters({
|
|
8
10
|
adapterFilter: (Adapter) => {
|
|
9
11
|
const activated = Adapter.isActivatedFor(productPlan);
|
|
10
12
|
if (!activated) {
|
|
@@ -15,6 +17,14 @@ const findAppropriateAdapters = (productPlan) => baseDirector.getAdapters({
|
|
|
15
17
|
});
|
|
16
18
|
export const EnrollmentDirector = {
|
|
17
19
|
...baseDirector,
|
|
20
|
+
getAdapter: (key) => {
|
|
21
|
+
const adapters = pluginRegistry.getAdapters(EnrollmentAdapter.adapterType);
|
|
22
|
+
return adapters.find((adapter) => adapter.key === key) || null;
|
|
23
|
+
},
|
|
24
|
+
getAdapters: ({ adapterFilter } = {}) => {
|
|
25
|
+
const adapters = pluginRegistry.getAdapters(EnrollmentAdapter.adapterType);
|
|
26
|
+
return adapters.filter(adapterFilter || (() => true));
|
|
27
|
+
},
|
|
18
28
|
transformOrderItemToEnrollment: async ({ orderPosition, product }, doc, unchainedAPI) => {
|
|
19
29
|
const Adapter = findAppropriateAdapters(product.plan)?.[0];
|
|
20
30
|
if (!Adapter) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { mongodb } from '@unchainedshop/mongodb';
|
|
2
2
|
import { BaseDirector } from '@unchainedshop/utils';
|
|
3
3
|
import { filtersSettings, FilterType, } from '@unchainedshop/core-filters';
|
|
4
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
5
|
+
import { FilterAdapter } from "./FilterAdapter.js";
|
|
4
6
|
export const parseQueryArray = (query) => (query || []).reduce((accumulator, { key, value }) => ({
|
|
5
7
|
...accumulator,
|
|
6
8
|
[key]: accumulator[key] ? accumulator[key].concat(value) : [value],
|
|
@@ -10,9 +12,17 @@ const baseDirector = BaseDirector('FilterDirector', {
|
|
|
10
12
|
});
|
|
11
13
|
export const FilterDirector = {
|
|
12
14
|
...baseDirector,
|
|
15
|
+
getAdapter: (key) => {
|
|
16
|
+
const adapters = pluginRegistry.getAdapters(FilterAdapter.adapterType);
|
|
17
|
+
return adapters.find((adapter) => adapter.key === key) || null;
|
|
18
|
+
},
|
|
19
|
+
getAdapters: ({ adapterFilter } = {}) => {
|
|
20
|
+
const adapters = pluginRegistry.getAdapters(FilterAdapter.adapterType);
|
|
21
|
+
return adapters.filter(adapterFilter || (() => true));
|
|
22
|
+
},
|
|
13
23
|
actions: async (filterContext, unchainedAPI) => {
|
|
14
24
|
const context = { ...filterContext, ...unchainedAPI };
|
|
15
|
-
const adapters =
|
|
25
|
+
const adapters = FilterDirector.getAdapters().map((Adapter) => Adapter.actions(context));
|
|
16
26
|
const reduceAdapters = (reducer, initialValue) => {
|
|
17
27
|
if (adapters.length === 0) {
|
|
18
28
|
return initialValue;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { type IDiscountAdapter
|
|
2
|
-
|
|
1
|
+
import { type IDiscountAdapter } from './BaseDiscountAdapter.ts';
|
|
2
|
+
import type { OrderDiscountConfiguration } from './OrderDiscountConfiguration.ts';
|
|
3
|
+
export declare const OrderDiscountAdapter: Omit<IDiscountAdapter<OrderDiscountConfiguration>, 'key' | 'label' | 'version'>;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import { BaseDiscountAdapter
|
|
2
|
-
export const OrderDiscountAdapter =
|
|
1
|
+
import { BaseDiscountAdapter } from "./BaseDiscountAdapter.js";
|
|
2
|
+
export const OrderDiscountAdapter = {
|
|
3
|
+
...BaseDiscountAdapter,
|
|
4
|
+
adapterType: Symbol.for('unchained:adapter:discount:order'),
|
|
5
|
+
};
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
+
import type { IDiscountAdapter } from './BaseDiscountAdapter.ts';
|
|
1
2
|
import type { OrderDiscountConfiguration } from './OrderDiscountConfiguration.ts';
|
|
2
|
-
export declare const OrderDiscountDirector:
|
|
3
|
+
export declare const OrderDiscountDirector: {
|
|
4
|
+
getAdapter: (key: string) => IDiscountAdapter<OrderDiscountConfiguration> | null;
|
|
5
|
+
getAdapters: (options?: {
|
|
6
|
+
adapterFilter?: (adapter: any) => boolean;
|
|
7
|
+
}) => IDiscountAdapter<OrderDiscountConfiguration>[];
|
|
8
|
+
actions: (discountContext: import("./BaseDiscountAdapter.ts").DiscountContext, unchainedAPI: {
|
|
9
|
+
modules: import("../modules.ts").Modules;
|
|
10
|
+
}) => Promise<{
|
|
11
|
+
resolveDiscountAdapterFromStaticCode: (params: {
|
|
12
|
+
code: string;
|
|
13
|
+
}) => Promise<IDiscountAdapter<OrderDiscountConfiguration> | null>;
|
|
14
|
+
findSystemDiscounts: () => Promise<string[]>;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
@@ -1,2 +1,15 @@
|
|
|
1
1
|
import { BaseDiscountDirector } from "./BaseDiscountDirector.js";
|
|
2
|
-
|
|
2
|
+
import { OrderDiscountAdapter } from "./OrderDiscountAdapter.js";
|
|
3
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
4
|
+
const baseDirector = BaseDiscountDirector('OrderDiscountDirector');
|
|
5
|
+
export const OrderDiscountDirector = {
|
|
6
|
+
...baseDirector,
|
|
7
|
+
getAdapter: (key) => {
|
|
8
|
+
const adapters = pluginRegistry.getAdapters(OrderDiscountAdapter.adapterType);
|
|
9
|
+
return adapters.find((adapter) => adapter.key === key) || null;
|
|
10
|
+
},
|
|
11
|
+
getAdapters: (options) => {
|
|
12
|
+
const adapters = pluginRegistry.getAdapters(OrderDiscountAdapter.adapterType);
|
|
13
|
+
return adapters.filter(options?.adapterFilter || (() => true));
|
|
14
|
+
},
|
|
15
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type IOrderPricingSheet, type OrderPricingCalculation
|
|
1
|
+
import { type IOrderPricingSheet, type OrderPricingCalculation } from './OrderPricingSheet.ts';
|
|
2
|
+
import { type IPricingAdapter, type BasePricingAdapterContext } from './BasePricingAdapter.ts';
|
|
2
3
|
import type { Order, OrderDelivery, OrderDiscount, OrderPayment, OrderPosition } from '@unchainedshop/core-orders';
|
|
3
4
|
import type { User } from '@unchainedshop/core-users';
|
|
4
5
|
import type { Modules } from '../modules.ts';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { OrderPricingSheet,
|
|
1
|
+
import { OrderPricingSheet, } from "./OrderPricingSheet.js";
|
|
2
|
+
import { BasePricingAdapter, } from "./BasePricingAdapter.js";
|
|
2
3
|
const basePricingAdapter = BasePricingAdapter();
|
|
3
4
|
export const OrderPricingAdapter = {
|
|
4
5
|
...basePricingAdapter,
|
|
6
|
+
adapterType: Symbol.for('unchained:adapter:pricing:order'),
|
|
5
7
|
isActivatedFor: () => {
|
|
6
8
|
return false;
|
|
7
9
|
},
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { type IOrderPricingSheet, type OrderPricingCalculation
|
|
1
|
+
import { type IOrderPricingSheet, type OrderPricingCalculation } from './OrderPricingSheet.ts';
|
|
2
|
+
import { type IOrderPricingAdapter, type OrderPricingAdapterContext } from './OrderPricingAdapter.ts';
|
|
3
|
+
import { type IPricingDirector } from './BasePricingDirector.ts';
|
|
4
|
+
import type { PricingDiscount } from './BasePricingSheet.ts';
|
|
2
5
|
import type { Order, OrderDelivery, OrderPayment, OrderPosition } from '@unchainedshop/core-orders';
|
|
3
6
|
export interface OrderPricingContext {
|
|
4
7
|
currencyCode: string;
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import { OrderPricingSheet,
|
|
1
|
+
import { OrderPricingSheet, } from "./OrderPricingSheet.js";
|
|
2
|
+
import { OrderPricingAdapter, } from "./OrderPricingAdapter.js";
|
|
3
|
+
import { BasePricingDirector } from "./BasePricingDirector.js";
|
|
4
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
2
5
|
const baseDirector = BasePricingDirector('OrderPricingDirector');
|
|
3
6
|
export const OrderPricingDirector = {
|
|
4
7
|
...baseDirector,
|
|
8
|
+
getAdapter: (key) => {
|
|
9
|
+
const adapters = pluginRegistry.getAdapters(OrderPricingAdapter.adapterType);
|
|
10
|
+
return adapters.find((adapter) => adapter.key === key) || null;
|
|
11
|
+
},
|
|
12
|
+
getAdapters: ({ adapterFilter } = {}) => {
|
|
13
|
+
const adapters = pluginRegistry.getAdapters(OrderPricingAdapter.adapterType);
|
|
14
|
+
return adapters.filter(adapterFilter || (() => true));
|
|
15
|
+
},
|
|
5
16
|
buildPricingContext: async (context, unchainedAPI) => {
|
|
6
17
|
const { modules } = unchainedAPI;
|
|
7
18
|
const { order, currencyCode } = context;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PricingCalculation } from '@unchainedshop/utils';
|
|
2
|
-
import { type IPricingSheet, type PricingSheetParams } from '
|
|
2
|
+
import { type IPricingSheet, type PricingSheetParams } from './BasePricingSheet.ts';
|
|
3
3
|
export interface OrderPricingCalculation extends PricingCalculation {
|
|
4
4
|
discountId?: string;
|
|
5
5
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BaseDirector } from '@unchainedshop/utils';
|
|
2
2
|
import { createLogger } from '@unchainedshop/logger';
|
|
3
|
-
import { PaymentError, } from "./PaymentAdapter.js";
|
|
3
|
+
import { PaymentError, PaymentAdapter, } from "./PaymentAdapter.js";
|
|
4
4
|
import { OrderPaymentStatus } from '@unchainedshop/core-orders';
|
|
5
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
5
6
|
const buildPaymentProviderActionsContext = (orderPayment, { transactionContext, ...rest }) => ({
|
|
6
7
|
...rest,
|
|
7
8
|
orderPayment,
|
|
@@ -14,8 +15,16 @@ const logger = createLogger('unchained:core:payment');
|
|
|
14
15
|
const baseDirector = BaseDirector('PaymentDirector');
|
|
15
16
|
export const PaymentDirector = {
|
|
16
17
|
...baseDirector,
|
|
18
|
+
getAdapter: (key) => {
|
|
19
|
+
const adapters = pluginRegistry.getAdapters(PaymentAdapter.adapterType);
|
|
20
|
+
return adapters.find((adapter) => adapter.key === key) || null;
|
|
21
|
+
},
|
|
22
|
+
getAdapters: ({ adapterFilter } = {}) => {
|
|
23
|
+
const adapters = pluginRegistry.getAdapters(PaymentAdapter.adapterType);
|
|
24
|
+
return adapters.filter(adapterFilter || (() => true));
|
|
25
|
+
},
|
|
17
26
|
actions: async (paymentProvider, paymentContext, unchainedAPI) => {
|
|
18
|
-
const Adapter =
|
|
27
|
+
const Adapter = PaymentDirector.getAdapter(paymentProvider.adapterKey);
|
|
19
28
|
if (!Adapter) {
|
|
20
29
|
throw new Error(`Payment Plugin ${paymentProvider.adapterKey} not available`);
|
|
21
30
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PricingCalculation } from '@unchainedshop/utils';
|
|
2
|
-
import { type BasePricingAdapterContext, type IPricingAdapter
|
|
2
|
+
import { type BasePricingAdapterContext, type IPricingAdapter } from './BasePricingAdapter.ts';
|
|
3
|
+
import type { IPricingSheet } from './BasePricingSheet.ts';
|
|
3
4
|
import type { PaymentProvider } from '@unchainedshop/core-payment';
|
|
4
5
|
import type { OrderDiscount, OrderPayment, Order } from '@unchainedshop/core-orders';
|
|
5
6
|
import type { User } from '@unchainedshop/core-users';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { BasePricingAdapter, } from "
|
|
1
|
+
import { BasePricingAdapter, } from "./BasePricingAdapter.js";
|
|
2
2
|
import { PaymentPricingSheet } from "./PaymentPricingSheet.js";
|
|
3
3
|
const basePricingAdapter = BasePricingAdapter();
|
|
4
4
|
export const PaymentPricingAdapter = {
|
|
5
5
|
...basePricingAdapter,
|
|
6
|
+
adapterType: Symbol.for('unchained:adapter:pricing:payment'),
|
|
6
7
|
isActivatedFor: () => {
|
|
7
8
|
return false;
|
|
8
9
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type IPricingDirector
|
|
1
|
+
import { type IPricingDirector } from './BasePricingDirector.ts';
|
|
2
|
+
import { type IPaymentPricingAdapter, type IPaymentPricingSheet, type PaymentPricingAdapterContext, type PaymentPricingCalculation } from './PaymentPricingAdapter.ts';
|
|
2
3
|
import type { PaymentProvider } from '@unchainedshop/core-payment';
|
|
3
4
|
import type { OrderPayment, Order } from '@unchainedshop/core-orders';
|
|
4
5
|
import type { User } from '@unchainedshop/core-users';
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import { BasePricingDirector
|
|
1
|
+
import { BasePricingDirector } from "./BasePricingDirector.js";
|
|
2
|
+
import { PaymentPricingAdapter, } from "./PaymentPricingAdapter.js";
|
|
2
3
|
import { PaymentPricingSheet } from "./PaymentPricingSheet.js";
|
|
4
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
3
5
|
const baseDirector = BasePricingDirector('PaymentPricingDirector');
|
|
4
6
|
export const PaymentPricingDirector = {
|
|
5
7
|
...baseDirector,
|
|
8
|
+
getAdapter: (key) => {
|
|
9
|
+
const adapters = pluginRegistry.getAdapters(PaymentPricingAdapter.adapterType);
|
|
10
|
+
return adapters.find((adapter) => adapter.key === key) || null;
|
|
11
|
+
},
|
|
12
|
+
getAdapters: ({ adapterFilter } = {}) => {
|
|
13
|
+
const adapters = pluginRegistry.getAdapters(PaymentPricingAdapter.adapterType);
|
|
14
|
+
return adapters.filter(adapterFilter || (() => true));
|
|
15
|
+
},
|
|
6
16
|
async buildPricingContext(context, unchainedAPI) {
|
|
7
17
|
const { modules } = unchainedAPI;
|
|
8
18
|
if ('item' in context) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type PaymentPricingCalculation, type IPaymentPricingSheet
|
|
1
|
+
import { type PaymentPricingCalculation, type IPaymentPricingSheet } from './PaymentPricingAdapter.ts';
|
|
2
|
+
import { type PricingSheetParams } from './BasePricingSheet.ts';
|
|
2
3
|
export declare const PaymentPricingRowCategory: {
|
|
3
4
|
readonly Item: "ITEM";
|
|
4
5
|
readonly Payment: "PAYMENT";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { type IDiscountAdapter
|
|
2
|
-
|
|
1
|
+
import { type IDiscountAdapter } from './BaseDiscountAdapter.ts';
|
|
2
|
+
import type { ProductDiscountConfiguration } from './ProductDiscountConfiguration.ts';
|
|
3
|
+
export declare const ProductDiscountAdapter: Omit<IDiscountAdapter<ProductDiscountConfiguration>, 'key' | 'label' | 'version'>;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import { BaseDiscountAdapter
|
|
2
|
-
export const ProductDiscountAdapter =
|
|
1
|
+
import { BaseDiscountAdapter } from "./BaseDiscountAdapter.js";
|
|
2
|
+
export const ProductDiscountAdapter = {
|
|
3
|
+
...BaseDiscountAdapter,
|
|
4
|
+
adapterType: Symbol.for('unchained:adapter:discount:product'),
|
|
5
|
+
};
|
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { ProductDiscountConfiguration } from './ProductDiscountConfiguration.ts';
|
|
2
|
+
import type { IDiscountAdapter } from './BaseDiscountAdapter.ts';
|
|
3
|
+
export declare const ProductDiscountDirector: {
|
|
4
|
+
getAdapter: (key: string) => IDiscountAdapter<ProductDiscountConfiguration> | null;
|
|
5
|
+
getAdapters: (options?: {
|
|
6
|
+
adapterFilter?: (adapter: any) => boolean;
|
|
7
|
+
}) => IDiscountAdapter<ProductDiscountConfiguration>[];
|
|
8
|
+
actions: (discountContext: import("./BaseDiscountAdapter.ts").DiscountContext, unchainedAPI: {
|
|
9
|
+
modules: import("../modules.ts").Modules;
|
|
10
|
+
}) => Promise<{
|
|
11
|
+
resolveDiscountAdapterFromStaticCode: (params: {
|
|
12
|
+
code: string;
|
|
13
|
+
}) => Promise<IDiscountAdapter<ProductDiscountConfiguration> | null>;
|
|
14
|
+
findSystemDiscounts: () => Promise<string[]>;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
import { BaseDiscountDirector } from "
|
|
2
|
-
|
|
1
|
+
import { BaseDiscountDirector } from "./BaseDiscountDirector.js";
|
|
2
|
+
import { ProductDiscountAdapter } from "./ProductDiscountAdapter.js";
|
|
3
|
+
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
4
|
+
const baseDirector = BaseDiscountDirector('ProductDiscountDirector');
|
|
5
|
+
export const ProductDiscountDirector = {
|
|
6
|
+
...baseDirector,
|
|
7
|
+
getAdapter: (key) => {
|
|
8
|
+
const adapters = pluginRegistry.getAdapters(ProductDiscountAdapter.adapterType);
|
|
9
|
+
return adapters.find((adapter) => adapter.key === key) || null;
|
|
10
|
+
},
|
|
11
|
+
getAdapters: (options) => {
|
|
12
|
+
const adapters = pluginRegistry.getAdapters(ProductDiscountAdapter.adapterType);
|
|
13
|
+
return adapters.filter(options?.adapterFilter || (() => true));
|
|
14
|
+
},
|
|
15
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Product, ProductConfiguration } from '@unchainedshop/core-products';
|
|
2
2
|
import type { Order } from '@unchainedshop/core-orders';
|
|
3
|
-
import { type IProductPricingSheet, type ProductPricingCalculation
|
|
3
|
+
import { type IProductPricingSheet, type ProductPricingCalculation } from './ProductPricingSheet.ts';
|
|
4
|
+
import { type BasePricingAdapterContext, type IPricingAdapter } from './BasePricingAdapter.ts';
|
|
4
5
|
import type { Modules } from '../modules.ts';
|
|
5
6
|
import type { User } from '@unchainedshop/core-users';
|
|
6
7
|
export interface ProductPricingAdapterContext extends BasePricingAdapterContext {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { ProductPricingSheet,
|
|
1
|
+
import { ProductPricingSheet, } from "./ProductPricingSheet.js";
|
|
2
|
+
import { BasePricingAdapter, } from "./BasePricingAdapter.js";
|
|
2
3
|
const basePricingAdapter = BasePricingAdapter();
|
|
3
4
|
export const ProductPricingAdapter = {
|
|
4
5
|
...basePricingAdapter,
|
|
6
|
+
adapterType: Symbol.for('unchained:adapter:pricing:product'),
|
|
5
7
|
isActivatedFor: () => {
|
|
6
8
|
return false;
|
|
7
9
|
},
|
|
@@ -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";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { SearchQuery } from '@unchainedshop/core-filters';
|
|
2
|
+
import { type IPlugin } from '../core-index.ts';
|
|
2
3
|
export default function registerAssortmentSearchFilter({ orderIndex, search, }: {
|
|
3
4
|
orderIndex?: number;
|
|
4
5
|
search: (params: SearchQuery & {
|
|
5
6
|
queryString: string;
|
|
6
7
|
locale: Intl.Locale;
|
|
7
8
|
}) => Promise<string[]>;
|
|
8
|
-
}):
|
|
9
|
+
}): IPlugin;
|