feat(fulfillment): Module service implementation first iteration (#6381)

This commit is contained in:
Adrien de Peretti
2024-02-14 18:43:42 +01:00
committed by GitHub
parent 02c53ec93f
commit fafde4f54d
18 changed files with 3986 additions and 74 deletions
@@ -3,10 +3,12 @@ import { CreateServiceZoneDTO } from "./service-zone"
export interface CreateFulfillmentSetDTO {
name: string
type: string
service_zones: Omit<CreateServiceZoneDTO, "fulfillment_set_id">[]
service_zones?: Omit<CreateServiceZoneDTO, 'fulfillment_set_id'>[]
}
export interface UpdateFulfillmentSetDTO
extends Partial<CreateFulfillmentSetDTO> {
export interface UpdateFulfillmentSetDTO {
id: string
name?: string
type?: string
service_zones?: (Omit<CreateServiceZoneDTO, 'fulfillment_set_id'> | { id: string })[]
}
@@ -9,24 +9,20 @@ interface CreateGeoZoneBaseDTO {
interface CreateCountryGeoZoneDTO extends CreateGeoZoneBaseDTO {
type: "country"
country_code: string
}
interface CreateProvinceGeoZoneDTO extends CreateGeoZoneBaseDTO {
type: "province"
country_code: string
province_code: string
}
interface CreateCityGeoZoneDTO extends CreateGeoZoneBaseDTO {
type: "city"
country_code: string
city: string
}
interface CreateZipGeoZoneDTO extends CreateGeoZoneBaseDTO {
type: "zip"
country_code: string
postal_expression: Record<string, any>
}
@@ -42,24 +38,20 @@ interface UpdateGeoZoneBaseDTO extends Partial<CreateGeoZoneBaseDTO> {
interface UpdateCountryGeoZoneDTO extends UpdateGeoZoneBaseDTO {
type: "country"
country_code: string
}
interface UpdateProvinceGeoZoneDTO extends UpdateGeoZoneBaseDTO {
type: "province"
country_code: string
province_code: string
}
interface UpdateCityGeoZoneDTO extends UpdateGeoZoneBaseDTO {
type: "city"
country_code: string
city: string
}
interface UpdateZipGeoZoneDTO extends UpdateGeoZoneBaseDTO {
type: "zip"
country_code: string
postal_expression: Record<string, any>
}
@@ -1,14 +1,13 @@
import { CreateGeoZoneDTO, UpdateGeoZoneDTO } from "./geo-zone"
import { CreateGeoZoneDTO } from "./geo-zone"
export interface CreateServiceZoneDTO {
fulfillment_set_id: string
name: string
geo_zones: (
| Omit<CreateGeoZoneDTO, "service_zone_id">
| Omit<UpdateGeoZoneDTO, "service_zone_id">
)[]
fulfillment_set_id: string
geo_zones?: Omit<CreateGeoZoneDTO, "service_zone_id">[]
}
export interface UpdateServiceZoneDTO extends Partial<CreateServiceZoneDTO> {
export interface UpdateServiceZoneDTO {
id: string
name?: string
geo_zones?: (Omit<CreateGeoZoneDTO, "service_zone_id"> | { id: string })[]
}
+88
View File
@@ -1,9 +1,11 @@
import { IModuleService } from "../modules-sdk"
import {
FilterableFulfillmentSetProps,
FilterableGeoZoneProps,
FilterableServiceZoneProps,
FilterableShippingOptionProps,
FulfillmentSetDTO,
GeoZoneDTO,
ServiceZoneDTO,
ShippingOptionDTO,
} from "./common"
@@ -12,9 +14,11 @@ import { Context } from "../shared-context"
import { RestoreReturn, SoftDeleteReturn } from "../dal"
import {
CreateFulfillmentSetDTO,
CreateGeoZoneDTO,
CreateServiceZoneDTO,
CreateShippingOptionDTO,
UpdateFulfillmentSetDTO,
UpdateGeoZoneDTO,
UpdateServiceZoneDTO,
UpdateShippingOptionDTO,
} from "./mutations"
@@ -62,6 +66,20 @@ export interface IFulfillmentModuleService extends IModuleService {
sharedContext?: Context
): Promise<ShippingOptionDTO>
/**
* Create a new geo zone
* @param data
* @param sharedContext
*/
createGeoZones(
data: CreateGeoZoneDTO[],
sharedContext?: Context
): Promise<GeoZoneDTO[]>
createGeoZones(
data: CreateGeoZoneDTO,
sharedContext?: Context
): Promise<GeoZoneDTO>
/**
* Update a fulfillment set
* @param data
@@ -104,6 +122,20 @@ export interface IFulfillmentModuleService extends IModuleService {
sharedContext?: Context
): Promise<ShippingOptionDTO>
/**
* Update a geo zone
* @param data
* @param sharedContext
*/
updateGeoZones(
data: UpdateGeoZoneDTO[],
sharedContext?: Context
): Promise<GeoZoneDTO[]>
updateGeoZones(
data: UpdateGeoZoneDTO,
sharedContext?: Context
): Promise<GeoZoneDTO>
/**
* Delete a fulfillment set
* @param ids
@@ -128,6 +160,14 @@ export interface IFulfillmentModuleService extends IModuleService {
deleteShippingOptions(ids: string[], sharedContext?: Context): Promise<void>
deleteShippingOptions(id: string, sharedContext?: Context): Promise<void>
/**
* Delete a geo zone
* @param ids
* @param sharedContext
*/
deleteGeoZones(ids: string[], sharedContext?: Context): Promise<void>
deleteGeoZones(id: string, sharedContext?: Context): Promise<void>
/**
* Retrieve a fulfillment set
* @param id
@@ -164,6 +204,18 @@ export interface IFulfillmentModuleService extends IModuleService {
sharedContext?: Context
): Promise<ShippingOptionDTO>
/**
* Retrieve a geo zone
* @param id
* @param config
* @param sharedContext
*/
retrieveGeoZone(
id: string,
config?: FindConfig<GeoZoneDTO>,
sharedContext?: Context
): Promise<GeoZoneDTO>
/**
* List fulfillment sets
* @param filters
@@ -200,6 +252,18 @@ export interface IFulfillmentModuleService extends IModuleService {
sharedContext?: Context
): Promise<ShippingOptionDTO[]>
/**
* List geo zones
* @param filters
* @param config
* @param sharedContext
*/
listGeoZones(
filters?: FilterableGeoZoneProps,
config?: FindConfig<GeoZoneDTO>,
sharedContext?: Context
): Promise<GeoZoneDTO[]>
/**
* List and count fulfillment sets
* @param filters
@@ -236,6 +300,18 @@ export interface IFulfillmentModuleService extends IModuleService {
sharedContext?: Context
): Promise<[ShippingOptionDTO[], number]>
/**
* List and count geo zones
* @param filters
* @param config
* @param sharedContext
*/
listAndCountGeoZones(
filters?: FilterableGeoZoneProps,
config?: FindConfig<GeoZoneDTO>,
sharedContext?: Context
): Promise<[GeoZoneDTO[], number]>
/**
* Soft delete fulfillment sets
* @param fulfillmentIds
@@ -272,6 +348,18 @@ export interface IFulfillmentModuleService extends IModuleService {
sharedContext?: Context
): Promise<Record<string, string[]> | void>
/**
* Soft delete geo zones
* @param geoZoneIds
* @param config
* @param sharedContext
*/
softDeleteGeoZones<TReturnableLinkableKeys extends string = string>(
geoZoneIds: string[],
config?: SoftDeleteReturn<TReturnableLinkableKeys>,
sharedContext?: Context
): Promise<Record<string, string[]> | void>
restore<TReturnableLinkableKeys extends string = string>(
fulfillmentIds: string[],
config?: RestoreReturn<TReturnableLinkableKeys>,