feat(fulfillment): Shipping options, rules CRUD + rules based context filtering (#6455)
**What**
- Update shipping options with its rules and type
- create/update rules independently
- context based validation fundation
- 🔴 list shipping options with context rules fitlering will come in a separate pr to keep this one smaller
FIXES CORE-1743
FIXES CORE-1764
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
export interface CreateShippingOptionRuleDTO {
|
||||
attribute: string
|
||||
operator: string
|
||||
operator: "in" | "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "nin"
|
||||
value: string | string[]
|
||||
shipping_option_id: string
|
||||
}
|
||||
|
||||
@@ -4,11 +4,15 @@ import {
|
||||
FilterableGeoZoneProps,
|
||||
FilterableServiceZoneProps,
|
||||
FilterableShippingOptionProps,
|
||||
FilterableShippingOptionRuleProps,
|
||||
FilterableShippingOptionTypeProps,
|
||||
FilterableShippingProfileProps,
|
||||
FulfillmentSetDTO,
|
||||
GeoZoneDTO,
|
||||
ServiceZoneDTO,
|
||||
ShippingOptionDTO,
|
||||
ShippingOptionRuleDTO,
|
||||
ShippingOptionTypeDTO,
|
||||
ShippingProfileDTO,
|
||||
} from "./common"
|
||||
import { FindConfig } from "../common"
|
||||
@@ -19,10 +23,12 @@ import {
|
||||
CreateGeoZoneDTO,
|
||||
CreateServiceZoneDTO,
|
||||
CreateShippingOptionDTO,
|
||||
CreateShippingOptionRuleDTO,
|
||||
UpdateFulfillmentSetDTO,
|
||||
UpdateGeoZoneDTO,
|
||||
UpdateServiceZoneDTO,
|
||||
UpdateShippingOptionDTO,
|
||||
UpdateShippingOptionRuleDTO,
|
||||
} from "./mutations"
|
||||
import { CreateShippingProfileDTO } from "./mutations/shipping-profile"
|
||||
|
||||
@@ -98,6 +104,20 @@ export interface IFulfillmentModuleService extends IModuleService {
|
||||
sharedContext?: Context
|
||||
): Promise<GeoZoneDTO>
|
||||
|
||||
/**
|
||||
* Create a new shipping option rules
|
||||
* @param data
|
||||
* @param sharedContext
|
||||
*/
|
||||
createShippingOptionRules(
|
||||
data: CreateShippingOptionRuleDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<ShippingOptionRuleDTO[]>
|
||||
createShippingOptionRules(
|
||||
data: CreateShippingOptionRuleDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<ShippingOptionRuleDTO>
|
||||
|
||||
/**
|
||||
* Update a fulfillment set
|
||||
* @param data
|
||||
@@ -168,6 +188,20 @@ export interface IFulfillmentModuleService extends IModuleService {
|
||||
sharedContext?: Context
|
||||
): Promise<GeoZoneDTO>
|
||||
|
||||
/**
|
||||
* Update a shipping option rule
|
||||
* @param data
|
||||
* @param sharedContext
|
||||
*/
|
||||
updateShippingOptionRules(
|
||||
data: UpdateShippingOptionRuleDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<ShippingOptionRuleDTO[]>
|
||||
updateShippingOptionRules(
|
||||
data: UpdateShippingOptionRuleDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<ShippingOptionRuleDTO>
|
||||
|
||||
/**
|
||||
* Delete a fulfillment set
|
||||
* @param ids
|
||||
@@ -208,6 +242,17 @@ export interface IFulfillmentModuleService extends IModuleService {
|
||||
deleteGeoZones(ids: string[], sharedContext?: Context): Promise<void>
|
||||
deleteGeoZones(id: string, sharedContext?: Context): Promise<void>
|
||||
|
||||
/**
|
||||
* Delete a shipping option rule
|
||||
* @param ids
|
||||
* @param sharedContext
|
||||
*/
|
||||
deleteShippingOptionRules(
|
||||
ids: string[],
|
||||
sharedContext?: Context
|
||||
): Promise<void>
|
||||
deleteShippingOptionRules(id: string, sharedContext?: Context): Promise<void>
|
||||
|
||||
/**
|
||||
* Retrieve a fulfillment set
|
||||
* @param id
|
||||
@@ -268,6 +313,30 @@ export interface IFulfillmentModuleService extends IModuleService {
|
||||
sharedContext?: Context
|
||||
): Promise<GeoZoneDTO>
|
||||
|
||||
/**
|
||||
* Retrieve a shipping option rule
|
||||
* @param id
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
retrieveShippingOptionRule(
|
||||
id: string,
|
||||
config?: FindConfig<ShippingOptionRuleDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<ShippingOptionRuleDTO>
|
||||
|
||||
/**
|
||||
* Retrieve a shipping option type
|
||||
* @param id
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
retrieveShippingOptionType(
|
||||
id: string,
|
||||
config?: FindConfig<ShippingOptionTypeDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<ShippingOptionTypeDTO>
|
||||
|
||||
/**
|
||||
* List fulfillment sets
|
||||
* @param filters
|
||||
@@ -328,6 +397,30 @@ export interface IFulfillmentModuleService extends IModuleService {
|
||||
sharedContext?: Context
|
||||
): Promise<GeoZoneDTO[]>
|
||||
|
||||
/**
|
||||
* List shipping option rules
|
||||
* @param filters
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
listShippingOptionRules(
|
||||
filters?: FilterableShippingOptionRuleProps,
|
||||
config?: FindConfig<ShippingOptionRuleDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<ShippingOptionRuleDTO[]>
|
||||
|
||||
/**
|
||||
* List shipping option types
|
||||
* @param filters
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
listShippingOptionTypes(
|
||||
filters?: FilterableShippingOptionTypeProps,
|
||||
config?: FindConfig<ShippingOptionTypeDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<ShippingOptionTypeDTO[]>
|
||||
|
||||
/**
|
||||
* List and count fulfillment sets
|
||||
* @param filters
|
||||
@@ -388,6 +481,30 @@ export interface IFulfillmentModuleService extends IModuleService {
|
||||
sharedContext?: Context
|
||||
): Promise<[GeoZoneDTO[], number]>
|
||||
|
||||
/**
|
||||
* List and count shipping option rules
|
||||
* @param filters
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
listAndCountShippingOptionRules(
|
||||
filters?: FilterableShippingOptionRuleProps,
|
||||
config?: FindConfig<ShippingOptionRuleDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<[ShippingOptionRuleDTO[], number]>
|
||||
|
||||
/**
|
||||
* List and count shipping options types
|
||||
* @param filters
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
listAndCountShippingOptionTypes(
|
||||
filters?: FilterableShippingOptionTypeProps,
|
||||
config?: FindConfig<ShippingOptionTypeDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<[ShippingOptionTypeDTO[], number]>
|
||||
|
||||
/**
|
||||
* Soft delete fulfillment sets
|
||||
* @param fulfillmentIds
|
||||
@@ -454,5 +571,5 @@ export interface IFulfillmentModuleService extends IModuleService {
|
||||
sharedContext?: Context
|
||||
): Promise<Record<string, string[]> | void>
|
||||
|
||||
// TODO defined the other restore methods
|
||||
// TODO define needed soft delete/delete/restore methods
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user