|
|
@@ -1,5 +1,4 @@
|
|
|
import { ConfigArg } from '@vendure/common/lib/generated-types';
|
|
|
-import { ConfigArgSubset } from '@vendure/common/lib/shared-types';
|
|
|
|
|
|
import {
|
|
|
ConfigArgs,
|
|
|
@@ -13,9 +12,6 @@ import { Order } from '../../entity/order/order.entity';
|
|
|
|
|
|
import { PromotionUtils } from './promotion-condition';
|
|
|
|
|
|
-export type PromotionActionArgType = ConfigArgSubset<'int' | 'ID'>;
|
|
|
-export type PromotionActionArgs = ConfigArgs<PromotionActionArgType>;
|
|
|
-
|
|
|
/**
|
|
|
* @description
|
|
|
* The function which is used by a PromotionItemAction to calculate the
|
|
|
@@ -24,7 +20,7 @@ export type PromotionActionArgs = ConfigArgs<PromotionActionArgType>;
|
|
|
* @docsCategory promotions
|
|
|
* @docsPage promotion-action
|
|
|
*/
|
|
|
-export type ExecutePromotionItemActionFn<T extends PromotionActionArgs> = (
|
|
|
+export type ExecutePromotionItemActionFn<T extends ConfigArgs> = (
|
|
|
orderItem: OrderItem,
|
|
|
orderLine: OrderLine,
|
|
|
args: ConfigArgValues<T>,
|
|
|
@@ -39,14 +35,13 @@ export type ExecutePromotionItemActionFn<T extends PromotionActionArgs> = (
|
|
|
* @docsCategory promotions
|
|
|
* @docsPage promotion-action
|
|
|
*/
|
|
|
-export type ExecutePromotionOrderActionFn<T extends PromotionActionArgs> = (
|
|
|
+export type ExecutePromotionOrderActionFn<T extends ConfigArgs> = (
|
|
|
order: Order,
|
|
|
args: ConfigArgValues<T>,
|
|
|
utils: PromotionUtils,
|
|
|
) => number | Promise<number>;
|
|
|
|
|
|
-export interface PromotionActionConfig<T extends PromotionActionArgs>
|
|
|
- extends ConfigurableOperationDefOptions<T> {
|
|
|
+export interface PromotionActionConfig<T extends ConfigArgs> extends ConfigurableOperationDefOptions<T> {
|
|
|
priorityValue?: number;
|
|
|
}
|
|
|
|
|
|
@@ -56,7 +51,7 @@ export interface PromotionActionConfig<T extends PromotionActionArgs>
|
|
|
* @docsCategory promotions
|
|
|
* @docsPage promotion-action
|
|
|
*/
|
|
|
-export interface PromotionItemActionConfig<T extends PromotionActionArgs> extends PromotionActionConfig<T> {
|
|
|
+export interface PromotionItemActionConfig<T extends ConfigArgs> extends PromotionActionConfig<T> {
|
|
|
/**
|
|
|
* @description
|
|
|
* The function which contains the promotion calculation logic.
|
|
|
@@ -70,7 +65,7 @@ export interface PromotionItemActionConfig<T extends PromotionActionArgs> extend
|
|
|
* @docsCategory promotions
|
|
|
* @docsPage promotion-action
|
|
|
*/
|
|
|
-export interface PromotionOrderActionConfig<T extends PromotionActionArgs> extends PromotionActionConfig<T> {
|
|
|
+export interface PromotionOrderActionConfig<T extends ConfigArgs> extends PromotionActionConfig<T> {
|
|
|
/**
|
|
|
* @description
|
|
|
* The function which contains the promotion calculation logic.
|
|
|
@@ -85,9 +80,7 @@ export interface PromotionOrderActionConfig<T extends PromotionActionArgs> exten
|
|
|
* @docsCategory promotions
|
|
|
* @docsPage promotion-action
|
|
|
*/
|
|
|
-export abstract class PromotionAction<T extends PromotionActionArgs = {}> extends ConfigurableOperationDef<
|
|
|
- T
|
|
|
-> {
|
|
|
+export abstract class PromotionAction<T extends ConfigArgs = {}> extends ConfigurableOperationDef<T> {
|
|
|
readonly priorityValue: number;
|
|
|
|
|
|
protected constructor(config: PromotionActionConfig<T>) {
|
|
|
@@ -116,7 +109,7 @@ export abstract class PromotionAction<T extends PromotionActionArgs = {}> extend
|
|
|
* @docsCategory promotions
|
|
|
* @docsPage promotion-action
|
|
|
*/
|
|
|
-export class PromotionItemAction<T extends PromotionActionArgs = {}> extends PromotionAction<T> {
|
|
|
+export class PromotionItemAction<T extends ConfigArgs = ConfigArgs> extends PromotionAction<T> {
|
|
|
private readonly executeFn: ExecutePromotionItemActionFn<T>;
|
|
|
constructor(config: PromotionItemActionConfig<T>) {
|
|
|
super(config);
|
|
|
@@ -149,7 +142,7 @@ export class PromotionItemAction<T extends PromotionActionArgs = {}> extends Pro
|
|
|
* @docsCategory promotions
|
|
|
* @docsPage promotion-action
|
|
|
*/
|
|
|
-export class PromotionOrderAction<T extends PromotionActionArgs = {}> extends PromotionAction<T> {
|
|
|
+export class PromotionOrderAction<T extends ConfigArgs = ConfigArgs> extends PromotionAction<T> {
|
|
|
private readonly executeFn: ExecutePromotionOrderActionFn<T>;
|
|
|
constructor(config: PromotionOrderActionConfig<T>) {
|
|
|
super(config);
|