@unchainedshop/core 4.8.24 → 4.8.26
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/directors/WorkerDirector.d.ts +6 -0
- package/lib/directors/WorkerDirector.js +26 -14
- package/package.json +1 -1
- package/lib/directors/FileDirector.d.ts +0 -10
- package/lib/directors/FileDirector.js +0 -25
- package/lib/errors/common.d.ts +0 -568
- package/lib/errors/common.js +0 -789
- package/lib/errors/index.d.ts +0 -1
- package/lib/errors/index.js +0 -1
- package/lib/factory/registerDeliveryPricing.d.ts +0 -7
- package/lib/factory/registerDeliveryPricing.js +0 -30
- package/lib/factory/registerDeliveryProvider.d.ts +0 -12
- package/lib/factory/registerDeliveryProvider.js +0 -46
- package/lib/factory/registerEnrollment.d.ts +0 -18
- package/lib/factory/registerEnrollment.js +0 -43
- package/lib/factory/registerFileAdapter.d.ts +0 -17
- package/lib/factory/registerFileAdapter.js +0 -24
- package/lib/factory/registerOrderDiscount.d.ts +0 -13
- package/lib/factory/registerOrderDiscount.js +0 -39
- package/lib/factory/registerOrderPricing.d.ts +0 -7
- package/lib/factory/registerOrderPricing.js +0 -30
- package/lib/factory/registerPaymentPricing.d.ts +0 -7
- package/lib/factory/registerPaymentPricing.js +0 -30
- package/lib/factory/registerPaymentProvider.d.ts +0 -15
- package/lib/factory/registerPaymentProvider.js +0 -53
- package/lib/factory/registerProductDiscount.d.ts +0 -20
- package/lib/factory/registerProductDiscount.js +0 -47
- package/lib/factory/registerProductPricing.d.ts +0 -7
- package/lib/factory/registerProductPricing.js +0 -30
- package/lib/factory/registerQuotation.d.ts +0 -12
- package/lib/factory/registerQuotation.js +0 -52
- package/lib/plugins/PluginRegistry.d.ts +0 -42
- package/lib/plugins/PluginRegistry.js +0 -115
- package/lib/services/addCartDiscount.d.ts +0 -10
- package/lib/services/addCartDiscount.js +0 -27
- package/lib/services/addCartItem.d.ts +0 -15
- package/lib/services/addCartItem.js +0 -41
- package/lib/services/addCartQuotation.d.ts +0 -16
- package/lib/services/addCartQuotation.js +0 -52
- package/lib/services/addEmail.d.ts +0 -7
- package/lib/services/addEmail.js +0 -17
- package/lib/services/addProductAssignment.d.ts +0 -3
- package/lib/services/addProductAssignment.js +0 -63
- package/lib/services/authenticateWithPassword.d.ts +0 -15
- package/lib/services/authenticateWithPassword.js +0 -34
- package/lib/services/changePassword.d.ts +0 -10
- package/lib/services/changePassword.js +0 -19
- package/lib/services/countOrdersWithFilters.d.ts +0 -3
- package/lib/services/countOrdersWithFilters.js +0 -25
- package/lib/services/createAssortment.d.ts +0 -7
- package/lib/services/createAssortment.js +0 -10
- package/lib/services/createBookmark.d.ts +0 -8
- package/lib/services/createBookmark.js +0 -21
- package/lib/services/createDeliveryProvider.d.ts +0 -6
- package/lib/services/createDeliveryProvider.js +0 -19
- package/lib/services/createEnrollment.d.ts +0 -17
- package/lib/services/createEnrollment.js +0 -33
- package/lib/services/createProduct.d.ts +0 -7
- package/lib/services/createProduct.js +0 -8
- package/lib/services/createProductBundleItem.d.ts +0 -5
- package/lib/services/createProductBundleItem.js +0 -25
- package/lib/services/createProductReview.d.ts +0 -8
- package/lib/services/createProductReview.js +0 -12
- package/lib/services/deleteDeadCarts.d.ts +0 -2
- package/lib/services/deleteDeadCarts.js +0 -17
- package/lib/services/deliverOrder.d.ts +0 -5
- package/lib/services/deliverOrder.js +0 -26
- package/lib/services/findActiveWorkTypes.d.ts +0 -2
- package/lib/services/findActiveWorkTypes.js +0 -6
- package/lib/services/findDeliveryInterfaces.d.ts +0 -7
- package/lib/services/findDeliveryInterfaces.js +0 -13
- package/lib/services/findOrdersWithFilters.d.ts +0 -9
- package/lib/services/findOrdersWithFilters.js +0 -25
- package/lib/services/findPaymentInterfaces.d.ts +0 -7
- package/lib/services/findPaymentInterfaces.js +0 -13
- package/lib/services/findWarehousingInterfaces.d.ts +0 -7
- package/lib/services/findWarehousingInterfaces.js +0 -13
- package/lib/services/getDeliveryDiscounts.d.ts +0 -8
- package/lib/services/getDeliveryDiscounts.js +0 -14
- package/lib/services/getPaymentDiscounts.d.ts +0 -8
- package/lib/services/getPaymentDiscounts.js +0 -14
- package/lib/services/getShopInfo.d.ts +0 -25
- package/lib/services/getShopInfo.js +0 -47
- package/lib/services/impersonateUser.d.ts +0 -8
- package/lib/services/impersonateUser.js +0 -20
- package/lib/services/loginAsGuest.d.ts +0 -10
- package/lib/services/loginAsGuest.js +0 -19
- package/lib/services/obfuscateWorkerData.d.ts +0 -4
- package/lib/services/obfuscateWorkerData.js +0 -4
- package/lib/services/orderPricingAccessors.d.ts +0 -18
- package/lib/services/orderPricingAccessors.js +0 -29
- package/lib/services/payOrder.d.ts +0 -5
- package/lib/services/payOrder.js +0 -25
- package/lib/services/registerUser.d.ts +0 -14
- package/lib/services/registerUser.js +0 -44
- package/lib/services/removeBookmark.d.ts +0 -6
- package/lib/services/removeBookmark.js +0 -10
- package/lib/services/removeCartItem.d.ts +0 -6
- package/lib/services/removeCartItem.js +0 -19
- package/lib/services/resetPasswordWithMigration.d.ts +0 -14
- package/lib/services/resetPasswordWithMigration.js +0 -31
- package/lib/services/resolveWorkType.d.ts +0 -1
- package/lib/services/resolveWorkType.js +0 -7
- package/lib/services/searchProductsWithAssortment.d.ts +0 -19
- package/lib/services/searchProductsWithAssortment.js +0 -17
- package/lib/services/toggleBookmark.d.ts +0 -8
- package/lib/services/toggleBookmark.js +0 -33
- package/lib/services/updateCart.d.ts +0 -15
- package/lib/services/updateCart.js +0 -27
- package/lib/services/updateCartItem.d.ts +0 -11
- package/lib/services/updateCartItem.js +0 -37
- package/lib/services/updateEnrollment.d.ts +0 -13
- package/lib/services/updateEnrollment.js +0 -36
- package/lib/services/verifyEmailWithMigration.d.ts +0 -15
- package/lib/services/verifyEmailWithMigration.js +0 -23
- package/lib/utils/getFileAdapter.d.ts +0 -1
- package/lib/utils/getFileAdapter.js +0 -7
package/lib/errors/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './common.ts';
|
package/lib/errors/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./common.js";
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type IPlugin, type IDeliveryPricingSheet, type DeliveryPricingAdapterContext } from '../core-index.ts';
|
|
2
|
-
export default function registerDeliveryPricing({ adapterId, orderIndex, isActivatedFor, calculate, }: {
|
|
3
|
-
adapterId: string;
|
|
4
|
-
orderIndex?: number;
|
|
5
|
-
isActivatedFor?: (context: DeliveryPricingAdapterContext) => boolean;
|
|
6
|
-
calculate: (sheet: IDeliveryPricingSheet, context: DeliveryPricingAdapterContext) => Promise<void>;
|
|
7
|
-
}): IPlugin;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { DeliveryPricingAdapter, } from "../core-index.js";
|
|
2
|
-
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
3
|
-
export default function registerDeliveryPricing({ adapterId, orderIndex, isActivatedFor, calculate, }) {
|
|
4
|
-
const adapter = {
|
|
5
|
-
...DeliveryPricingAdapter,
|
|
6
|
-
key: `shop.unchained.pricing.delivery-${adapterId}`,
|
|
7
|
-
label: 'Delivery Pricing: ' + adapterId,
|
|
8
|
-
version: '1.0.0',
|
|
9
|
-
orderIndex: orderIndex ?? 0,
|
|
10
|
-
isActivatedFor: (context) => (isActivatedFor ? isActivatedFor(context) : true),
|
|
11
|
-
actions: (params) => {
|
|
12
|
-
const pricingAdapter = DeliveryPricingAdapter.actions(params);
|
|
13
|
-
return {
|
|
14
|
-
...pricingAdapter,
|
|
15
|
-
calculate: async () => {
|
|
16
|
-
await calculate(pricingAdapter.resultSheet(), params.context);
|
|
17
|
-
return pricingAdapter.calculate();
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
const plugin = {
|
|
23
|
-
key: adapter.key,
|
|
24
|
-
label: adapter.label,
|
|
25
|
-
version: adapter.version,
|
|
26
|
-
adapters: [adapter],
|
|
27
|
-
};
|
|
28
|
-
pluginRegistry.register(plugin);
|
|
29
|
-
return plugin;
|
|
30
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { DeliveryConfiguration } from '@unchainedshop/core-delivery';
|
|
2
|
-
import { DeliveryProviderType } from '@unchainedshop/core-delivery';
|
|
3
|
-
import { type DeliveryContext, type IPlugin } from '../core-index.ts';
|
|
4
|
-
import type { Work } from '@unchainedshop/core-worker';
|
|
5
|
-
export default function registerDeliveryProvider({ adapterId, type, active, autoReleaseAllowed, estimatedDeliveryThroughput, send, }: {
|
|
6
|
-
adapterId: string;
|
|
7
|
-
type?: DeliveryProviderType;
|
|
8
|
-
active?: boolean;
|
|
9
|
-
autoReleaseAllowed?: boolean;
|
|
10
|
-
estimatedDeliveryThroughput?: (warehousingThroughputTime: number, context: DeliveryContext) => Promise<number | null>;
|
|
11
|
-
send: boolean | ((configuration: DeliveryConfiguration, context: DeliveryContext) => Promise<boolean | Work>);
|
|
12
|
-
}): IPlugin;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { DeliveryProviderType } from '@unchainedshop/core-delivery';
|
|
2
|
-
import { DeliveryAdapter, } from "../core-index.js";
|
|
3
|
-
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
4
|
-
export default function registerDeliveryProvider({ adapterId, type = DeliveryProviderType.SHIPPING, active, autoReleaseAllowed, estimatedDeliveryThroughput, send, }) {
|
|
5
|
-
const adapter = {
|
|
6
|
-
...DeliveryAdapter,
|
|
7
|
-
key: `shop.unchained.delivery.${adapterId}`,
|
|
8
|
-
label: 'Delivery: ' + adapterId,
|
|
9
|
-
version: '1.0.0',
|
|
10
|
-
initialConfiguration: [],
|
|
11
|
-
typeSupported: (deliveryType) => {
|
|
12
|
-
return deliveryType === type;
|
|
13
|
-
},
|
|
14
|
-
actions: (config, context) => {
|
|
15
|
-
return {
|
|
16
|
-
...DeliveryAdapter.actions(config, context),
|
|
17
|
-
isActive: () => {
|
|
18
|
-
return active ?? true;
|
|
19
|
-
},
|
|
20
|
-
isAutoReleaseAllowed: () => {
|
|
21
|
-
return autoReleaseAllowed ?? true;
|
|
22
|
-
},
|
|
23
|
-
configurationError: () => {
|
|
24
|
-
return null;
|
|
25
|
-
},
|
|
26
|
-
estimatedDeliveryThroughput: async (warehousingThroughputTime) => {
|
|
27
|
-
if (estimatedDeliveryThroughput) {
|
|
28
|
-
return estimatedDeliveryThroughput(warehousingThroughputTime, context);
|
|
29
|
-
}
|
|
30
|
-
return 0;
|
|
31
|
-
},
|
|
32
|
-
send: async () => {
|
|
33
|
-
return typeof send === 'function' ? await send(config, context) : send;
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
const plugin = {
|
|
39
|
-
key: adapter.key,
|
|
40
|
-
label: adapter.label,
|
|
41
|
-
version: adapter.version,
|
|
42
|
-
adapters: [adapter],
|
|
43
|
-
};
|
|
44
|
-
pluginRegistry.register(plugin);
|
|
45
|
-
return plugin;
|
|
46
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { EnrollmentOrderPositionTemplate, EnrollmentPeriod, EnrollmentPlan } from '@unchainedshop/core-enrollments';
|
|
2
|
-
import type { ProductPlan } from '@unchainedshop/core-products';
|
|
3
|
-
import type { OrderPosition } from '@unchainedshop/core-orders';
|
|
4
|
-
import { type EnrollmentContext, type IPlugin } from '../core-index.ts';
|
|
5
|
-
export default function registerEnrollment({ adapterId, isActivatedFor, transformOrderItem, configurationForOrder, isOverdue, isValidForActivation, nextPeriod, }: {
|
|
6
|
-
adapterId: string;
|
|
7
|
-
isActivatedFor?: (productPlan?: ProductPlan) => boolean;
|
|
8
|
-
transformOrderItem?: (orderPosition: OrderPosition, unchainedAPI: any) => Promise<EnrollmentPlan>;
|
|
9
|
-
configurationForOrder: (params: {
|
|
10
|
-
period: EnrollmentPeriod;
|
|
11
|
-
}, context: EnrollmentContext) => Promise<{
|
|
12
|
-
orderContext?: Record<string, any>;
|
|
13
|
-
orderPositionTemplates: EnrollmentOrderPositionTemplate[];
|
|
14
|
-
} | null>;
|
|
15
|
-
isOverdue?: (context: EnrollmentContext) => Promise<boolean>;
|
|
16
|
-
isValidForActivation?: (context: EnrollmentContext) => Promise<boolean>;
|
|
17
|
-
nextPeriod?: (context: EnrollmentContext) => Promise<EnrollmentPeriod | null>;
|
|
18
|
-
}): IPlugin;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { EnrollmentAdapter, } from "../core-index.js";
|
|
2
|
-
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
3
|
-
export default function registerEnrollment({ adapterId, isActivatedFor, transformOrderItem, configurationForOrder, isOverdue, isValidForActivation, nextPeriod, }) {
|
|
4
|
-
const adapter = {
|
|
5
|
-
...EnrollmentAdapter,
|
|
6
|
-
key: `shop.unchained.enrollment.${adapterId}`,
|
|
7
|
-
label: 'Enrollment: ' + adapterId,
|
|
8
|
-
version: '1.0.0',
|
|
9
|
-
isActivatedFor: (productPlan) => {
|
|
10
|
-
return isActivatedFor ? isActivatedFor(productPlan) : true;
|
|
11
|
-
},
|
|
12
|
-
transformOrderItemToEnrollmentPlan: async (orderPosition, unchainedAPI) => {
|
|
13
|
-
return transformOrderItem
|
|
14
|
-
? transformOrderItem(orderPosition, unchainedAPI)
|
|
15
|
-
: EnrollmentAdapter.transformOrderItemToEnrollmentPlan(orderPosition, unchainedAPI);
|
|
16
|
-
},
|
|
17
|
-
actions: (context) => {
|
|
18
|
-
return {
|
|
19
|
-
...EnrollmentAdapter.actions(context),
|
|
20
|
-
configurationForOrder: async (params) => {
|
|
21
|
-
return configurationForOrder(params, context);
|
|
22
|
-
},
|
|
23
|
-
isOverdue: async () => {
|
|
24
|
-
return isOverdue ? isOverdue(context) : false;
|
|
25
|
-
},
|
|
26
|
-
isValidForActivation: async () => {
|
|
27
|
-
return isValidForActivation ? isValidForActivation(context) : false;
|
|
28
|
-
},
|
|
29
|
-
nextPeriod: async () => {
|
|
30
|
-
return nextPeriod ? nextPeriod(context) : EnrollmentAdapter.actions(context).nextPeriod();
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
const plugin = {
|
|
36
|
-
key: adapter.key,
|
|
37
|
-
label: adapter.label,
|
|
38
|
-
version: adapter.version,
|
|
39
|
-
adapters: [adapter],
|
|
40
|
-
};
|
|
41
|
-
pluginRegistry.register(plugin);
|
|
42
|
-
return plugin;
|
|
43
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type UploadedFile, type UploadFileData } from '@unchainedshop/core-files';
|
|
2
|
-
import { type IPlugin } from '../core-index.ts';
|
|
3
|
-
export default function registerFileAdapter<Context = unknown>({ adapterId, createSignedURL, uploadFileFromStream, createDownloadURL, removeFiles, uploadFileFromURL, }: {
|
|
4
|
-
adapterId: string;
|
|
5
|
-
createSignedURL: (directoryName: string, fileName: string, unchainedAPI: Context) => Promise<(UploadFileData & {
|
|
6
|
-
putURL: string;
|
|
7
|
-
}) | null>;
|
|
8
|
-
uploadFileFromStream: (directoryName: string, rawFile: any, unchainedAPI: Context, options?: Record<string, any>) => Promise<UploadFileData>;
|
|
9
|
-
createDownloadURL?: (file: UploadedFile, expiry?: number) => Promise<string | null>;
|
|
10
|
-
removeFiles?: (files: UploadedFile[], unchainedContext: Context) => Promise<void>;
|
|
11
|
-
uploadFileFromURL?: (directoryName: string, fileInput: {
|
|
12
|
-
fileLink: string;
|
|
13
|
-
fileName: string;
|
|
14
|
-
fileId?: string;
|
|
15
|
-
headers?: Record<string, unknown>;
|
|
16
|
-
}, unchainedAPI: Context) => Promise<UploadFileData>;
|
|
17
|
-
}): IPlugin;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { FileAdapter, } from '@unchainedshop/core-files';
|
|
2
|
-
import {} from "../core-index.js";
|
|
3
|
-
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
4
|
-
export default function registerFileAdapter({ adapterId, createSignedURL, uploadFileFromStream, createDownloadURL, removeFiles, uploadFileFromURL, }) {
|
|
5
|
-
const adapter = {
|
|
6
|
-
...FileAdapter,
|
|
7
|
-
key: `shop.unchained.file-upload.${adapterId}`,
|
|
8
|
-
label: 'File Adapter: ' + adapterId,
|
|
9
|
-
version: '1.0.0',
|
|
10
|
-
createSignedURL,
|
|
11
|
-
uploadFileFromStream,
|
|
12
|
-
...(createDownloadURL ? { createDownloadURL } : {}),
|
|
13
|
-
...(removeFiles ? { removeFiles } : {}),
|
|
14
|
-
...(uploadFileFromURL ? { uploadFileFromURL } : {}),
|
|
15
|
-
};
|
|
16
|
-
const plugin = {
|
|
17
|
-
key: adapter.key,
|
|
18
|
-
label: adapter.label,
|
|
19
|
-
version: adapter.version,
|
|
20
|
-
adapters: [adapter],
|
|
21
|
-
};
|
|
22
|
-
pluginRegistry.register(plugin);
|
|
23
|
-
return plugin;
|
|
24
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { PricingCalculation } from '@unchainedshop/utils';
|
|
2
|
-
import { type DiscountContext, type IPricingSheet, type OrderDiscountConfiguration, type IPlugin } from '../core-index.ts';
|
|
3
|
-
export default function registerOrderDiscount({ adapterId, isValidForSystemTriggering, isValidForCodeTriggering, discountForPricingAdapterKey, reserve, release, }: {
|
|
4
|
-
adapterId: string;
|
|
5
|
-
isValidForSystemTriggering?: (context: DiscountContext) => Promise<boolean>;
|
|
6
|
-
isValidForCodeTriggering?: (code: string, context: DiscountContext) => Promise<boolean>;
|
|
7
|
-
discountForPricingAdapterKey: (params: {
|
|
8
|
-
pricingAdapterKey: string;
|
|
9
|
-
calculationSheet: IPricingSheet<PricingCalculation>;
|
|
10
|
-
}, context: DiscountContext) => OrderDiscountConfiguration | null;
|
|
11
|
-
reserve?: (code: string | undefined, context: DiscountContext) => Promise<any>;
|
|
12
|
-
release?: (context: DiscountContext) => Promise<void>;
|
|
13
|
-
}): IPlugin;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { OrderDiscountAdapter, } from "../core-index.js";
|
|
2
|
-
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
3
|
-
export default function registerOrderDiscount({ adapterId, isValidForSystemTriggering, isValidForCodeTriggering, discountForPricingAdapterKey, reserve, release, }) {
|
|
4
|
-
const adapter = {
|
|
5
|
-
...OrderDiscountAdapter,
|
|
6
|
-
key: `shop.unchained.discount.order-${adapterId}`,
|
|
7
|
-
label: 'Order Discount: ' + adapterId,
|
|
8
|
-
version: '1.0.0',
|
|
9
|
-
actions: async ({ context }) => {
|
|
10
|
-
return {
|
|
11
|
-
...(await OrderDiscountAdapter.actions({ context })),
|
|
12
|
-
isValidForSystemTriggering: async () => {
|
|
13
|
-
return isValidForSystemTriggering ? isValidForSystemTriggering(context) : false;
|
|
14
|
-
},
|
|
15
|
-
isValidForCodeTriggering: async ({ code }) => {
|
|
16
|
-
return isValidForCodeTriggering ? isValidForCodeTriggering(code, context) : false;
|
|
17
|
-
},
|
|
18
|
-
discountForPricingAdapterKey: (params) => {
|
|
19
|
-
return discountForPricingAdapterKey(params, context);
|
|
20
|
-
},
|
|
21
|
-
reserve: async ({ code }) => {
|
|
22
|
-
return reserve ? reserve(code, context) : {};
|
|
23
|
-
},
|
|
24
|
-
release: async () => {
|
|
25
|
-
if (release)
|
|
26
|
-
await release(context);
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
const plugin = {
|
|
32
|
-
key: adapter.key,
|
|
33
|
-
label: adapter.label,
|
|
34
|
-
version: adapter.version,
|
|
35
|
-
adapters: [adapter],
|
|
36
|
-
};
|
|
37
|
-
pluginRegistry.register(plugin);
|
|
38
|
-
return plugin;
|
|
39
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type IPlugin, type IOrderPricingSheet, type OrderPricingAdapterContext } from '../core-index.ts';
|
|
2
|
-
export default function registerOrderPricing({ adapterId, orderIndex, isActivatedFor, calculate, }: {
|
|
3
|
-
adapterId: string;
|
|
4
|
-
orderIndex?: number;
|
|
5
|
-
isActivatedFor?: (context: OrderPricingAdapterContext) => boolean;
|
|
6
|
-
calculate: (sheet: IOrderPricingSheet, context: OrderPricingAdapterContext) => Promise<void>;
|
|
7
|
-
}): IPlugin;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { OrderPricingAdapter, } from "../core-index.js";
|
|
2
|
-
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
3
|
-
export default function registerOrderPricing({ adapterId, orderIndex, isActivatedFor, calculate, }) {
|
|
4
|
-
const adapter = {
|
|
5
|
-
...OrderPricingAdapter,
|
|
6
|
-
key: `shop.unchained.pricing.order-${adapterId}`,
|
|
7
|
-
label: 'Order Pricing: ' + adapterId,
|
|
8
|
-
version: '1.0.0',
|
|
9
|
-
orderIndex: orderIndex ?? 0,
|
|
10
|
-
isActivatedFor: (context) => (isActivatedFor ? isActivatedFor(context) : true),
|
|
11
|
-
actions: (params) => {
|
|
12
|
-
const pricingAdapter = OrderPricingAdapter.actions(params);
|
|
13
|
-
return {
|
|
14
|
-
...pricingAdapter,
|
|
15
|
-
calculate: async () => {
|
|
16
|
-
await calculate(pricingAdapter.resultSheet(), params.context);
|
|
17
|
-
return pricingAdapter.calculate();
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
const plugin = {
|
|
23
|
-
key: adapter.key,
|
|
24
|
-
label: adapter.label,
|
|
25
|
-
version: adapter.version,
|
|
26
|
-
adapters: [adapter],
|
|
27
|
-
};
|
|
28
|
-
pluginRegistry.register(plugin);
|
|
29
|
-
return plugin;
|
|
30
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type IPlugin, type IPaymentPricingSheet, type PaymentPricingAdapterContext } from '../core-index.ts';
|
|
2
|
-
export default function registerPaymentPricing({ adapterId, orderIndex, isActivatedFor, calculate, }: {
|
|
3
|
-
adapterId: string;
|
|
4
|
-
orderIndex?: number;
|
|
5
|
-
isActivatedFor?: (context: PaymentPricingAdapterContext) => boolean;
|
|
6
|
-
calculate: (sheet: IPaymentPricingSheet, context: PaymentPricingAdapterContext) => Promise<void>;
|
|
7
|
-
}): IPlugin;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { PaymentPricingAdapter, } from "../core-index.js";
|
|
2
|
-
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
3
|
-
export default function registerPaymentPricing({ adapterId, orderIndex, isActivatedFor, calculate, }) {
|
|
4
|
-
const adapter = {
|
|
5
|
-
...PaymentPricingAdapter,
|
|
6
|
-
key: `shop.unchained.pricing.payment-${adapterId}`,
|
|
7
|
-
label: 'Payment Pricing: ' + adapterId,
|
|
8
|
-
version: '1.0.0',
|
|
9
|
-
orderIndex: orderIndex ?? 0,
|
|
10
|
-
isActivatedFor: (context) => (isActivatedFor ? isActivatedFor(context) : true),
|
|
11
|
-
actions: (params) => {
|
|
12
|
-
const pricingAdapter = PaymentPricingAdapter.actions(params);
|
|
13
|
-
return {
|
|
14
|
-
...pricingAdapter,
|
|
15
|
-
calculate: async () => {
|
|
16
|
-
await calculate(pricingAdapter.resultSheet(), params.context);
|
|
17
|
-
return pricingAdapter.calculate();
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
const plugin = {
|
|
23
|
-
key: adapter.key,
|
|
24
|
-
label: adapter.label,
|
|
25
|
-
version: adapter.version,
|
|
26
|
-
adapters: [adapter],
|
|
27
|
-
};
|
|
28
|
-
pluginRegistry.register(plugin);
|
|
29
|
-
return plugin;
|
|
30
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { PaymentConfiguration } from '@unchainedshop/core-payment';
|
|
2
|
-
import { PaymentProviderType } from '@unchainedshop/core-payment';
|
|
3
|
-
import { type PaymentContext, type PaymentChargeActionResult, type PaymentError, type IPlugin } from '../core-index.ts';
|
|
4
|
-
export default function registerPaymentProvider({ adapterId, type, charge, sign, validate, isActive, isPayLaterAllowed, configurationError, cancel, confirm, }: {
|
|
5
|
-
adapterId: string;
|
|
6
|
-
type?: PaymentProviderType;
|
|
7
|
-
charge: false | ((configuration: PaymentConfiguration, context: PaymentContext) => Promise<PaymentChargeActionResult | false>);
|
|
8
|
-
sign?: (configuration: PaymentConfiguration, context: PaymentContext) => Promise<string | null>;
|
|
9
|
-
validate?: (configuration: PaymentConfiguration, context: PaymentContext) => Promise<boolean>;
|
|
10
|
-
isActive?: boolean;
|
|
11
|
-
isPayLaterAllowed?: boolean;
|
|
12
|
-
configurationError?: PaymentError | null;
|
|
13
|
-
cancel?: (configuration: PaymentConfiguration, context: PaymentContext) => Promise<boolean>;
|
|
14
|
-
confirm?: (configuration: PaymentConfiguration, context: PaymentContext) => Promise<boolean>;
|
|
15
|
-
}): IPlugin;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { PaymentProviderType } from '@unchainedshop/core-payment';
|
|
2
|
-
import { PaymentAdapter, } from "../core-index.js";
|
|
3
|
-
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
4
|
-
export default function registerPaymentProvider({ adapterId, type, charge, sign, validate, isActive, isPayLaterAllowed, configurationError, cancel, confirm, }) {
|
|
5
|
-
const providerType = type ?? PaymentProviderType.GENERIC;
|
|
6
|
-
const adapter = {
|
|
7
|
-
...PaymentAdapter,
|
|
8
|
-
key: `shop.unchained.payment.${adapterId}`,
|
|
9
|
-
label: 'Payment: ' + adapterId,
|
|
10
|
-
version: '1.0.0',
|
|
11
|
-
initialConfiguration: [],
|
|
12
|
-
typeSupported: (t) => {
|
|
13
|
-
return t === providerType;
|
|
14
|
-
},
|
|
15
|
-
actions: (config, context) => {
|
|
16
|
-
return {
|
|
17
|
-
...PaymentAdapter.actions(config, context),
|
|
18
|
-
isActive: () => {
|
|
19
|
-
return isActive ?? true;
|
|
20
|
-
},
|
|
21
|
-
isPayLaterAllowed: () => {
|
|
22
|
-
return isPayLaterAllowed ?? false;
|
|
23
|
-
},
|
|
24
|
-
configurationError: () => {
|
|
25
|
-
return configurationError ?? null;
|
|
26
|
-
},
|
|
27
|
-
sign: async () => {
|
|
28
|
-
return sign ? sign(config, context) : null;
|
|
29
|
-
},
|
|
30
|
-
validate: async () => {
|
|
31
|
-
return validate ? validate(config, context) : false;
|
|
32
|
-
},
|
|
33
|
-
cancel: async () => {
|
|
34
|
-
return cancel ? cancel(config, context) : false;
|
|
35
|
-
},
|
|
36
|
-
confirm: async () => {
|
|
37
|
-
return confirm ? confirm(config, context) : false;
|
|
38
|
-
},
|
|
39
|
-
charge: async () => {
|
|
40
|
-
return typeof charge === 'function' ? await charge(config, context) : charge;
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
const plugin = {
|
|
46
|
-
key: adapter.key,
|
|
47
|
-
label: adapter.label,
|
|
48
|
-
version: adapter.version,
|
|
49
|
-
adapters: [adapter],
|
|
50
|
-
};
|
|
51
|
-
pluginRegistry.register(plugin);
|
|
52
|
-
return plugin;
|
|
53
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type IPlugin, type IPricingSheet, type ProductDiscountConfiguration } from '../core-index.ts';
|
|
2
|
-
import type { PricingCalculation } from '@unchainedshop/utils';
|
|
3
|
-
export default function registerProductDiscount({ adapterId, orderIndex, isManualAdditionAllowed, isManualRemovalAllowed, isValidForSystemTriggering, isValidForCodeTriggering, discountForPricingAdapterKey, reserve, release, }: {
|
|
4
|
-
adapterId: string;
|
|
5
|
-
orderIndex?: number;
|
|
6
|
-
isManualAdditionAllowed?: (code?: string) => Promise<boolean>;
|
|
7
|
-
isManualRemovalAllowed?: () => Promise<boolean>;
|
|
8
|
-
isValidForSystemTriggering?: () => Promise<boolean>;
|
|
9
|
-
isValidForCodeTriggering?: (params: {
|
|
10
|
-
code: string;
|
|
11
|
-
}) => Promise<boolean>;
|
|
12
|
-
discountForPricingAdapterKey: (params: {
|
|
13
|
-
pricingAdapterKey: string;
|
|
14
|
-
calculationSheet: IPricingSheet<PricingCalculation>;
|
|
15
|
-
}) => ProductDiscountConfiguration | null;
|
|
16
|
-
reserve?: (params: {
|
|
17
|
-
code?: string;
|
|
18
|
-
}) => Promise<any>;
|
|
19
|
-
release?: () => Promise<void>;
|
|
20
|
-
}): IPlugin;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ProductDiscountAdapter, } from "../core-index.js";
|
|
2
|
-
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
3
|
-
export default function registerProductDiscount({ adapterId, orderIndex, isManualAdditionAllowed, isManualRemovalAllowed, isValidForSystemTriggering, isValidForCodeTriggering, discountForPricingAdapterKey, reserve, release, }) {
|
|
4
|
-
const adapter = {
|
|
5
|
-
...ProductDiscountAdapter,
|
|
6
|
-
key: `shop.unchained.discount.product-${adapterId}`,
|
|
7
|
-
label: 'Product Discount: ' + adapterId,
|
|
8
|
-
version: '1.0.0',
|
|
9
|
-
orderIndex: orderIndex ?? 0,
|
|
10
|
-
isManualAdditionAllowed: async (code) => {
|
|
11
|
-
return isManualAdditionAllowed
|
|
12
|
-
? isManualAdditionAllowed(code)
|
|
13
|
-
: ProductDiscountAdapter.isManualAdditionAllowed(code);
|
|
14
|
-
},
|
|
15
|
-
isManualRemovalAllowed: async () => {
|
|
16
|
-
return isManualRemovalAllowed
|
|
17
|
-
? isManualRemovalAllowed()
|
|
18
|
-
: ProductDiscountAdapter.isManualRemovalAllowed();
|
|
19
|
-
},
|
|
20
|
-
actions: async (params) => {
|
|
21
|
-
return {
|
|
22
|
-
...(await ProductDiscountAdapter.actions(params)),
|
|
23
|
-
isValidForSystemTriggering: async () => {
|
|
24
|
-
return isValidForSystemTriggering ? isValidForSystemTriggering() : false;
|
|
25
|
-
},
|
|
26
|
-
isValidForCodeTriggering: async ({ code }) => {
|
|
27
|
-
return isValidForCodeTriggering ? isValidForCodeTriggering({ code }) : false;
|
|
28
|
-
},
|
|
29
|
-
discountForPricingAdapterKey,
|
|
30
|
-
reserve: async ({ code }) => {
|
|
31
|
-
return reserve ? reserve({ code }) : {};
|
|
32
|
-
},
|
|
33
|
-
release: async () => {
|
|
34
|
-
return release ? release() : undefined;
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
const plugin = {
|
|
40
|
-
key: adapter.key,
|
|
41
|
-
label: adapter.label,
|
|
42
|
-
version: adapter.version,
|
|
43
|
-
adapters: [adapter],
|
|
44
|
-
};
|
|
45
|
-
pluginRegistry.register(plugin);
|
|
46
|
-
return plugin;
|
|
47
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type IPlugin, type IProductPricingSheet, type ProductPricingAdapterContext } from '../core-index.ts';
|
|
2
|
-
export default function registerProductPricing({ adapterId, orderIndex, isActivatedFor, calculate, }: {
|
|
3
|
-
adapterId: string;
|
|
4
|
-
orderIndex?: number;
|
|
5
|
-
isActivatedFor?: (context: ProductPricingAdapterContext) => boolean;
|
|
6
|
-
calculate: (sheet: IProductPricingSheet, context: ProductPricingAdapterContext) => Promise<void>;
|
|
7
|
-
}): IPlugin;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ProductPricingAdapter, } from "../core-index.js";
|
|
2
|
-
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
3
|
-
export default function registerProductPricing({ adapterId, orderIndex, isActivatedFor, calculate, }) {
|
|
4
|
-
const adapter = {
|
|
5
|
-
...ProductPricingAdapter,
|
|
6
|
-
key: `shop.unchained.pricing.product-${adapterId}`,
|
|
7
|
-
label: 'Product Pricing: ' + adapterId,
|
|
8
|
-
version: '1.0.0',
|
|
9
|
-
orderIndex: orderIndex ?? 0,
|
|
10
|
-
isActivatedFor: (context) => (isActivatedFor ? isActivatedFor(context) : true),
|
|
11
|
-
actions: (params) => {
|
|
12
|
-
const pricingAdapter = ProductPricingAdapter.actions(params);
|
|
13
|
-
return {
|
|
14
|
-
...pricingAdapter,
|
|
15
|
-
calculate: async () => {
|
|
16
|
-
await calculate(pricingAdapter.resultSheet(), params.context);
|
|
17
|
-
return pricingAdapter.calculate();
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
const plugin = {
|
|
23
|
-
key: adapter.key,
|
|
24
|
-
label: adapter.label,
|
|
25
|
-
version: adapter.version,
|
|
26
|
-
adapters: [adapter],
|
|
27
|
-
};
|
|
28
|
-
pluginRegistry.register(plugin);
|
|
29
|
-
return plugin;
|
|
30
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { QuotationItemConfiguration, QuotationProposal } from '@unchainedshop/core-quotations';
|
|
2
|
-
import { type QuotationContext, type IPlugin } from '../core-index.ts';
|
|
3
|
-
export default function registerQuotation({ adapterId, isManualRequestVerificationRequired, isManualProposalRequired, quote, submitRequest, verifyRequest, rejectRequest, transformItemConfiguration, }: {
|
|
4
|
-
adapterId: string;
|
|
5
|
-
isManualRequestVerificationRequired?: boolean;
|
|
6
|
-
isManualProposalRequired?: boolean;
|
|
7
|
-
quote?: (context: QuotationContext) => Promise<QuotationProposal>;
|
|
8
|
-
submitRequest?: (context: QuotationContext) => Promise<boolean>;
|
|
9
|
-
verifyRequest?: (context: QuotationContext) => Promise<boolean>;
|
|
10
|
-
rejectRequest?: (context: QuotationContext) => Promise<boolean>;
|
|
11
|
-
transformItemConfiguration?: (params: QuotationItemConfiguration, context: QuotationContext) => Promise<QuotationItemConfiguration | null>;
|
|
12
|
-
}): IPlugin;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { QuotationAdapter, } from "../core-index.js";
|
|
2
|
-
import { pluginRegistry } from "../plugins/PluginRegistry.js";
|
|
3
|
-
export default function registerQuotation({ adapterId, isManualRequestVerificationRequired, isManualProposalRequired, quote, submitRequest, verifyRequest, rejectRequest, transformItemConfiguration, }) {
|
|
4
|
-
const adapter = {
|
|
5
|
-
...QuotationAdapter,
|
|
6
|
-
key: `shop.unchained.quotation.${adapterId}`,
|
|
7
|
-
label: 'Quotation: ' + adapterId,
|
|
8
|
-
version: '1.0.0',
|
|
9
|
-
isActivatedFor: () => {
|
|
10
|
-
return true;
|
|
11
|
-
},
|
|
12
|
-
actions: (context) => {
|
|
13
|
-
return {
|
|
14
|
-
...QuotationAdapter.actions(context),
|
|
15
|
-
configurationError: () => {
|
|
16
|
-
return null;
|
|
17
|
-
},
|
|
18
|
-
isManualRequestVerificationRequired: async () => {
|
|
19
|
-
return isManualRequestVerificationRequired ?? true;
|
|
20
|
-
},
|
|
21
|
-
isManualProposalRequired: async () => {
|
|
22
|
-
return isManualProposalRequired ?? true;
|
|
23
|
-
},
|
|
24
|
-
quote: async () => {
|
|
25
|
-
return quote ? quote(context) : {};
|
|
26
|
-
},
|
|
27
|
-
submitRequest: async () => {
|
|
28
|
-
return submitRequest ? submitRequest(context) : true;
|
|
29
|
-
},
|
|
30
|
-
verifyRequest: async () => {
|
|
31
|
-
return verifyRequest ? verifyRequest(context) : true;
|
|
32
|
-
},
|
|
33
|
-
rejectRequest: async () => {
|
|
34
|
-
return rejectRequest ? rejectRequest(context) : true;
|
|
35
|
-
},
|
|
36
|
-
transformItemConfiguration: async (params) => {
|
|
37
|
-
return transformItemConfiguration
|
|
38
|
-
? transformItemConfiguration(params, context)
|
|
39
|
-
: { quantity: params.quantity, configuration: params.configuration };
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
const plugin = {
|
|
45
|
-
key: adapter.key,
|
|
46
|
-
label: adapter.label,
|
|
47
|
-
version: adapter.version,
|
|
48
|
-
adapters: [adapter],
|
|
49
|
-
};
|
|
50
|
-
pluginRegistry.register(plugin);
|
|
51
|
-
return plugin;
|
|
52
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { UnchainedCore } from '../core-index.ts';
|
|
2
|
-
import type { IBaseAdapter } from '@unchainedshop/utils';
|
|
3
|
-
import type { mongodb } from '@unchainedshop/mongodb';
|
|
4
|
-
export interface PluginHttpRoute {
|
|
5
|
-
path: string;
|
|
6
|
-
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'ALL';
|
|
7
|
-
handler: (request: Request, context: UnchainedCore & {
|
|
8
|
-
params: Record<string, string>;
|
|
9
|
-
userId?: string;
|
|
10
|
-
impersonatorId?: string;
|
|
11
|
-
}) => Response | Promise<Response>;
|
|
12
|
-
}
|
|
13
|
-
export type PluginModuleFactory = (options: {
|
|
14
|
-
db: mongodb.Db;
|
|
15
|
-
}) => Record<string, any>;
|
|
16
|
-
export interface IPlugin {
|
|
17
|
-
key: string;
|
|
18
|
-
label: string;
|
|
19
|
-
version: string;
|
|
20
|
-
adapters?: IBaseAdapter[];
|
|
21
|
-
module?: PluginModuleFactory;
|
|
22
|
-
routes?: PluginHttpRoute[];
|
|
23
|
-
onRegister?: (unchainedAPI: UnchainedCore) => void | boolean | Promise<void | boolean>;
|
|
24
|
-
onShutdown?: (unchainedAPI: UnchainedCore) => void | Promise<void>;
|
|
25
|
-
}
|
|
26
|
-
declare class PluginRegistry {
|
|
27
|
-
private plugins;
|
|
28
|
-
private moduleFactories;
|
|
29
|
-
private skippedPlugins;
|
|
30
|
-
register(plugin: IPlugin): void;
|
|
31
|
-
initialize(unchainedAPI: UnchainedCore): Promise<void>;
|
|
32
|
-
getModuleFactories(): PluginModuleFactory[];
|
|
33
|
-
getRoutes(): PluginHttpRoute[];
|
|
34
|
-
shutdown(unchainedAPI: UnchainedCore): Promise<void>;
|
|
35
|
-
getPlugin(key: string): IPlugin | undefined;
|
|
36
|
-
getAllPlugins(): IPlugin[];
|
|
37
|
-
getAdapters(adapterType: symbol): IBaseAdapter[];
|
|
38
|
-
hasPlugin(key: string): boolean;
|
|
39
|
-
clear(): void;
|
|
40
|
-
}
|
|
41
|
-
export declare const pluginRegistry: PluginRegistry;
|
|
42
|
-
export {};
|