feat(fulfillment): Init dtos work (#6329)
* feat(fulfillment): Init dtos work * update DTO partially * WIP * more interfaces * continue service definition * cleanup * cleanup * preliminary filters * cleanup * cleanup * Create angry-planets-wave.md
This commit is contained in:
committed by
GitHub
parent
2afcf1c918
commit
1fd0457c15
6
.changeset/angry-planets-wave.md
Normal file
6
.changeset/angry-planets-wave.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@medusajs/types": patch
|
||||
---
|
||||
|
||||
feat(fulfillment): Init dtos work and module service interface
|
||||
|
||||
@@ -28,14 +28,6 @@ const fulfillmentIdIndexStatement = createPsqlIndexStatementHelper({
|
||||
where: "deleted_at IS NULL",
|
||||
})
|
||||
|
||||
const providerIdIndexName = "IDX_fulfillment_label_provider_id"
|
||||
const providerIdIndexStatement = createPsqlIndexStatementHelper({
|
||||
name: providerIdIndexName,
|
||||
tableName: "fulfillment_label",
|
||||
columns: "provider_id",
|
||||
where: "deleted_at IS NULL",
|
||||
})
|
||||
|
||||
const deletedAtIndexName = "IDX_fulfillment_label_deleted_at"
|
||||
const deletedAtIndexStatement = createPsqlIndexStatementHelper({
|
||||
name: deletedAtIndexName,
|
||||
@@ -66,13 +58,6 @@ export default class FulfillmentLabel {
|
||||
name: fulfillmentIdIndexName,
|
||||
expression: fulfillmentIdIndexStatement,
|
||||
})
|
||||
provider_id: string
|
||||
|
||||
@Property({ columnType: "text" })
|
||||
@Index({
|
||||
name: providerIdIndexName,
|
||||
expression: providerIdIndexStatement,
|
||||
})
|
||||
fulfillment_id: string
|
||||
|
||||
@ManyToOne(() => Fulfillment)
|
||||
|
||||
@@ -28,6 +28,14 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
|
||||
where: "deleted_at IS NOT NULL",
|
||||
})
|
||||
|
||||
const shippingOptionIdIndexName = "IDX_shipping_option_type_shipping_option_id"
|
||||
const shippingOptionIdIndexStatement = createPsqlIndexStatementHelper({
|
||||
name: shippingOptionIdIndexName,
|
||||
tableName: "shipping_option_type",
|
||||
columns: "shipping_option_id",
|
||||
where: "deleted_at IS NULL",
|
||||
})
|
||||
|
||||
@Entity()
|
||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||
export default class ShippingOptionType {
|
||||
@@ -42,6 +50,16 @@ export default class ShippingOptionType {
|
||||
@Property({ columnType: "text", nullable: true })
|
||||
description: string | null = null
|
||||
|
||||
@Property({ columnType: "text" })
|
||||
code: string
|
||||
|
||||
@Property({ columnType: "text" })
|
||||
@Index({
|
||||
name: shippingOptionIdIndexName,
|
||||
expression: shippingOptionIdIndexStatement,
|
||||
})
|
||||
shipping_option_id: string
|
||||
|
||||
@OneToOne(() => ShippingOption, (so) => so.shipping_option_type)
|
||||
shipping_option: ShippingOption
|
||||
|
||||
|
||||
@@ -6,11 +6,14 @@ import {
|
||||
InternalModuleDeclaration,
|
||||
ModuleJoinerConfig,
|
||||
ModulesSdkTypes,
|
||||
UpdateFulfillmentSetDTO,
|
||||
} from "@medusajs/types"
|
||||
import { InjectTransactionManager, ModulesSdkUtils } from "@medusajs/utils"
|
||||
|
||||
import { entityNameToLinkableKeysMap, joinerConfig } from "../joiner-config"
|
||||
import { FulfillmentSet } from "@models"
|
||||
import { FulfillmentSet, ServiceZone, ShippingOption } from "@models"
|
||||
|
||||
const generateMethodForModels = [ServiceZone, ShippingOption]
|
||||
|
||||
type InjectedDependencies = {
|
||||
baseRepository: DAL.RepositoryService
|
||||
@@ -22,9 +25,13 @@ export default class FulfillmentModuleService<
|
||||
>
|
||||
extends ModulesSdkUtils.abstractModuleServiceFactory<
|
||||
InjectedDependencies,
|
||||
any, // TODO Create appropriate DTO
|
||||
{}
|
||||
>(FulfillmentSet, [], entityNameToLinkableKeysMap)
|
||||
FulfillmentTypes.FulfillmentSetDTO,
|
||||
{
|
||||
FulfillmentSet: { dto: FulfillmentTypes.FulfillmentSetDTO }
|
||||
ServiceZone: { dto: FulfillmentTypes.ServiceZoneDTO }
|
||||
ShippingOption: { dto: FulfillmentTypes.ShippingOptionDTO }
|
||||
}
|
||||
>(FulfillmentSet, generateMethodForModels, entityNameToLinkableKeysMap)
|
||||
implements IFulfillmentModuleService
|
||||
{
|
||||
protected baseRepository_: DAL.RepositoryService
|
||||
@@ -45,47 +52,126 @@ export default class FulfillmentModuleService<
|
||||
}
|
||||
|
||||
create(
|
||||
data: any[],
|
||||
data: FulfillmentTypes.CreateFulfillmentSetDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentTypes.FulfillmentDTO[]>
|
||||
|
||||
): Promise<FulfillmentTypes.FulfillmentSetDTO[]>
|
||||
create(
|
||||
data: any,
|
||||
data: FulfillmentTypes.CreateFulfillmentSetDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentTypes.FulfillmentDTO>
|
||||
): Promise<FulfillmentTypes.FulfillmentSetDTO>
|
||||
|
||||
// TODO Implement the methods from the interface and change type
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async create(
|
||||
data: any[] | any,
|
||||
data:
|
||||
| FulfillmentTypes.CreateFulfillmentSetDTO
|
||||
| FulfillmentTypes.CreateFulfillmentSetDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<
|
||||
FulfillmentTypes.FulfillmentDTO | FulfillmentTypes.FulfillmentDTO[]
|
||||
FulfillmentTypes.FulfillmentSetDTO | FulfillmentTypes.FulfillmentSetDTO[]
|
||||
> {
|
||||
return await Promise.resolve(
|
||||
[] as FulfillmentTypes.FulfillmentDTO[] | FulfillmentTypes.FulfillmentDTO
|
||||
)
|
||||
return []
|
||||
}
|
||||
|
||||
// TODO Implement the methods from the interface and change type
|
||||
update(
|
||||
data: any[],
|
||||
createServiceZones(
|
||||
data: FulfillmentTypes.CreateServiceZoneDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentTypes.FulfillmentDTO[]>
|
||||
update(
|
||||
data: any,
|
||||
): Promise<FulfillmentTypes.ServiceZoneDTO[]>
|
||||
createServiceZones(
|
||||
data: FulfillmentTypes.CreateServiceZoneDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentTypes.FulfillmentDTO>
|
||||
): Promise<FulfillmentTypes.ServiceZoneDTO>
|
||||
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async createServiceZones(
|
||||
data:
|
||||
| FulfillmentTypes.CreateServiceZoneDTO[]
|
||||
| FulfillmentTypes.CreateServiceZoneDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<
|
||||
FulfillmentTypes.ServiceZoneDTO | FulfillmentTypes.ServiceZoneDTO[]
|
||||
> {
|
||||
return []
|
||||
}
|
||||
|
||||
createShippingOptions(
|
||||
data: FulfillmentTypes.CreateShippingOptionDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentTypes.ShippingOptionDTO[]>
|
||||
createShippingOptions(
|
||||
data: FulfillmentTypes.CreateShippingOptionDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentTypes.ShippingOptionDTO>
|
||||
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async createShippingOptions(
|
||||
data:
|
||||
| FulfillmentTypes.CreateShippingOptionDTO[]
|
||||
| FulfillmentTypes.CreateShippingOptionDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<
|
||||
FulfillmentTypes.ShippingOptionDTO | FulfillmentTypes.ShippingOptionDTO[]
|
||||
> {
|
||||
return []
|
||||
}
|
||||
|
||||
update(
|
||||
data: FulfillmentTypes.UpdateFulfillmentSetDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentTypes.FulfillmentSetDTO[]>
|
||||
update(
|
||||
data: FulfillmentTypes.UpdateFulfillmentSetDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentTypes.FulfillmentSetDTO>
|
||||
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async update(
|
||||
data: any,
|
||||
data: UpdateFulfillmentSetDTO[] | UpdateFulfillmentSetDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<
|
||||
FulfillmentTypes.FulfillmentDTO | FulfillmentTypes.FulfillmentDTO[]
|
||||
FulfillmentTypes.FulfillmentSetDTO[] | FulfillmentTypes.FulfillmentSetDTO
|
||||
> {
|
||||
return await Promise.resolve(
|
||||
[] as FulfillmentTypes.FulfillmentDTO[] | FulfillmentTypes.FulfillmentDTO
|
||||
)
|
||||
return []
|
||||
}
|
||||
|
||||
updateServiceZones(
|
||||
data: FulfillmentTypes.UpdateServiceZoneDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentTypes.ServiceZoneDTO[]>
|
||||
updateServiceZones(
|
||||
data: FulfillmentTypes.UpdateServiceZoneDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentTypes.ServiceZoneDTO>
|
||||
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async updateServiceZones(
|
||||
data:
|
||||
| FulfillmentTypes.UpdateServiceZoneDTO[]
|
||||
| FulfillmentTypes.UpdateServiceZoneDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<
|
||||
FulfillmentTypes.ServiceZoneDTO[] | FulfillmentTypes.ServiceZoneDTO
|
||||
> {
|
||||
return []
|
||||
}
|
||||
|
||||
updateShippingOptions(
|
||||
data: FulfillmentTypes.UpdateShippingOptionDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentTypes.ShippingOptionDTO[]>
|
||||
updateShippingOptions(
|
||||
data: FulfillmentTypes.UpdateShippingOptionDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentTypes.ShippingOptionDTO>
|
||||
|
||||
@InjectTransactionManager("baseRepository_")
|
||||
async updateShippingOptions(
|
||||
data:
|
||||
| FulfillmentTypes.UpdateShippingOptionDTO[]
|
||||
| FulfillmentTypes.UpdateShippingOptionDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<
|
||||
FulfillmentTypes.ShippingOptionDTO[] | FulfillmentTypes.ShippingOptionDTO
|
||||
> {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
export type GeoZoneType = "country" | "province" | "city" | "zip"
|
||||
|
||||
export interface FulfillmentDTO {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
18
packages/types/src/fulfillment/common/address.ts
Normal file
18
packages/types/src/fulfillment/common/address.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export interface FulfillmentAddressDTO {
|
||||
id: string
|
||||
fulfillment_id: string | null
|
||||
company: string | null
|
||||
first_name: string | null
|
||||
last_name: string | null
|
||||
address_1: string | null
|
||||
address_2: string | null
|
||||
city: string | null
|
||||
country_code: string | null
|
||||
province: string | null
|
||||
postal_code: string | null
|
||||
phone: string | null
|
||||
metadata: Record<string, unknown> | null
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
16
packages/types/src/fulfillment/common/fulfillment-item.ts
Normal file
16
packages/types/src/fulfillment/common/fulfillment-item.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { FulfillmentDTO } from "./fulfillment"
|
||||
|
||||
export interface FulfillmentItemDTO {
|
||||
id: string
|
||||
title: string
|
||||
quantity: number
|
||||
sku: string
|
||||
barcode: string
|
||||
line_item_id: string | null
|
||||
inventory_item_id: string | null
|
||||
fulfillment_id: string
|
||||
fulfillment: FulfillmentDTO
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
13
packages/types/src/fulfillment/common/fulfillment-label.ts
Normal file
13
packages/types/src/fulfillment/common/fulfillment-label.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { FulfillmentDTO } from "./fulfillment"
|
||||
|
||||
export interface FulfillmentLabelDTO {
|
||||
id: string
|
||||
tracking_number: string
|
||||
tracking_url: string
|
||||
label_url: string
|
||||
fulfillment_id: string
|
||||
fulfillment: FulfillmentDTO
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
21
packages/types/src/fulfillment/common/fulfillment-set.ts
Normal file
21
packages/types/src/fulfillment/common/fulfillment-set.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { FilterableServiceZoneProps, ServiceZoneDTO } from "./service-zone"
|
||||
import { BaseFilterable } from "../../dal"
|
||||
|
||||
export interface FulfillmentSetDTO {
|
||||
id: string
|
||||
name: string
|
||||
type: string
|
||||
metadata: Record<string, unknown> | null
|
||||
service_zones: ServiceZoneDTO[]
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
|
||||
export interface FilterableFulfillmentSetProps
|
||||
extends BaseFilterable<FilterableFulfillmentSetProps> {
|
||||
id?: string | string[]
|
||||
name?: string | string[]
|
||||
type?: string | string[]
|
||||
service_zones?: FilterableServiceZoneProps
|
||||
}
|
||||
26
packages/types/src/fulfillment/common/fulfillment.ts
Normal file
26
packages/types/src/fulfillment/common/fulfillment.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { ShippingOptionDTO } from "./shipping-option"
|
||||
import { ServiceProviderDTO } from "./service-provider"
|
||||
import { FulfillmentAddressDTO } from "./address"
|
||||
import { FulfillmentItemDTO } from "./fulfillment-item"
|
||||
import { FulfillmentLabelDTO } from "./fulfillment-label"
|
||||
|
||||
export interface FulfillmentDTO {
|
||||
id: string
|
||||
location_id: string
|
||||
packed_at: Date | null
|
||||
shipped_at: Date | null
|
||||
delivered_at: Date | null
|
||||
canceled_at: Date | null
|
||||
data: Record<string, unknown> | null
|
||||
provider_id: string
|
||||
shipping_option_id: string | null
|
||||
metadata: Record<string, unknown> | null
|
||||
shipping_option: ShippingOptionDTO | null
|
||||
provider: ServiceProviderDTO
|
||||
delivery_address: FulfillmentAddressDTO
|
||||
items: FulfillmentItemDTO[]
|
||||
labels: FulfillmentLabelDTO[]
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
26
packages/types/src/fulfillment/common/geo-zone.ts
Normal file
26
packages/types/src/fulfillment/common/geo-zone.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { BaseFilterable } from "../../dal"
|
||||
|
||||
export type GeoZoneType = "country" | "province" | "city" | "zip"
|
||||
|
||||
export interface GeoZoneDTO {
|
||||
id: string
|
||||
type: GeoZoneType
|
||||
country_code: string
|
||||
province_code: string | null
|
||||
city: string | null
|
||||
postal_expression: Record<string, unknown> | null
|
||||
metadata: Record<string, unknown> | null
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
|
||||
export interface FilterableGeoZoneProps
|
||||
extends BaseFilterable<FilterableGeoZoneProps> {
|
||||
id?: string | string[]
|
||||
type?: GeoZoneType | GeoZoneType[]
|
||||
country_code?: string | string[]
|
||||
province_code?: string | string[]
|
||||
city?: string | string[]
|
||||
// postal_expression?: Record<string, unknown> | Record<string, unknown>[] // TODO: Add support for postal_expression filtering
|
||||
}
|
||||
12
packages/types/src/fulfillment/common/index.ts
Normal file
12
packages/types/src/fulfillment/common/index.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
export * from "./address"
|
||||
export * from "./fulfillment-set"
|
||||
export * from "./shipping-profile"
|
||||
export * from "./shipping-option-rule"
|
||||
export * from "./shipping-option"
|
||||
export * from "./shipping-option-type"
|
||||
export * from "./service-zone"
|
||||
export * from "./geo-zone"
|
||||
export * from "./service-provider"
|
||||
export * from "./fulfillment"
|
||||
export * from "./fulfillment-item"
|
||||
export * from "./fulfillment-label"
|
||||
11
packages/types/src/fulfillment/common/service-provider.ts
Normal file
11
packages/types/src/fulfillment/common/service-provider.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { ShippingOptionDTO } from "./shipping-option"
|
||||
|
||||
export interface ServiceProviderDTO {
|
||||
id: string
|
||||
name: string
|
||||
metadata: Record<string, unknown> | null
|
||||
shipping_options: ShippingOptionDTO[]
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
24
packages/types/src/fulfillment/common/service-zone.ts
Normal file
24
packages/types/src/fulfillment/common/service-zone.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { FulfillmentSetDTO } from "./fulfillment-set"
|
||||
import { FilterableGeoZoneProps, GeoZoneDTO } from "./geo-zone"
|
||||
import { ShippingOptionDTO } from "./shipping-option"
|
||||
import { BaseFilterable } from "../../dal"
|
||||
|
||||
export interface ServiceZoneDTO {
|
||||
id: string
|
||||
name: string
|
||||
metadata: Record<string, unknown> | null
|
||||
fulfillment_sets: FulfillmentSetDTO[]
|
||||
geo_zones: GeoZoneDTO[]
|
||||
shipping_options: ShippingOptionDTO[]
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
|
||||
export interface FilterableServiceZoneProps
|
||||
extends BaseFilterable<FilterableServiceZoneProps> {
|
||||
id?: string | string[]
|
||||
name?: string | string[]
|
||||
geo_zones?: FilterableGeoZoneProps
|
||||
shipping_options?: any // TODO
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { ShippingOptionDTO } from "./shipping-option"
|
||||
import { BaseFilterable } from "../../dal"
|
||||
|
||||
export interface ShippingOptionRuleDTO {
|
||||
id: string
|
||||
attribute: string
|
||||
operator: string
|
||||
value: { value: string | string[] } | null
|
||||
shipping_option_id: string
|
||||
shipping_option: ShippingOptionDTO
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
|
||||
export interface FilterableShippingOptionRuleProps
|
||||
extends BaseFilterable<FilterableShippingOptionRuleProps> {
|
||||
id?: string | string[]
|
||||
attribute?: string | string[]
|
||||
operator?: string | string[]
|
||||
value?: string | string[]
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { ShippingOptionDTO } from "./shipping-option"
|
||||
import { BaseFilterable } from "../../dal"
|
||||
|
||||
export interface ShippingOptionTypeDTO {
|
||||
id: string
|
||||
label: string
|
||||
description: string
|
||||
code: string
|
||||
shipping_option_id: string
|
||||
shipping_option: ShippingOptionDTO
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
|
||||
export interface FilterableShippingOptionTypeProps
|
||||
extends BaseFilterable<FilterableShippingOptionTypeProps> {
|
||||
id?: string | string[]
|
||||
label?: string | string[]
|
||||
description?: string | string[]
|
||||
code?: string | string[]
|
||||
}
|
||||
44
packages/types/src/fulfillment/common/shipping-option.ts
Normal file
44
packages/types/src/fulfillment/common/shipping-option.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { FilterableServiceZoneProps, ServiceZoneDTO } from "./service-zone"
|
||||
import { ShippingProfileDTO } from "./shipping-profile"
|
||||
import { ServiceProviderDTO } from "./service-provider"
|
||||
import {
|
||||
FilterableShippingOptionTypeProps,
|
||||
ShippingOptionTypeDTO,
|
||||
} from "./shipping-option-type"
|
||||
import {
|
||||
FilterableShippingOptionRuleProps,
|
||||
ShippingOptionRuleDTO,
|
||||
} from "./shipping-option-rule"
|
||||
import { BaseFilterable } from "../../dal"
|
||||
|
||||
export type ShippingOptionPriceType = "calculated" | "flat"
|
||||
|
||||
export interface ShippingOptionDTO {
|
||||
id: string
|
||||
name: string
|
||||
price_type: ShippingOptionPriceType
|
||||
service_zone_id: string
|
||||
shipping_profile_id: string
|
||||
service_provider_id: string
|
||||
shipping_option_type_id: string | null
|
||||
data: Record<string, unknown> | null
|
||||
metadata: Record<string, unknown> | null
|
||||
service_zone: ServiceZoneDTO
|
||||
shipping_profile: ShippingProfileDTO
|
||||
service_provider: ServiceProviderDTO
|
||||
shipping_option_type: ShippingOptionTypeDTO
|
||||
rules: ShippingOptionRuleDTO[]
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
|
||||
export interface FilterableShippingOptionProps
|
||||
extends BaseFilterable<FilterableShippingOptionProps> {
|
||||
id?: string | string[]
|
||||
name?: string | string[]
|
||||
price_type?: ShippingOptionPriceType | ShippingOptionPriceType[]
|
||||
service_zone?: FilterableServiceZoneProps
|
||||
shipping_option_type?: FilterableShippingOptionTypeProps
|
||||
rules?: FilterableShippingOptionRuleProps
|
||||
}
|
||||
11
packages/types/src/fulfillment/common/shipping-profile.ts
Normal file
11
packages/types/src/fulfillment/common/shipping-profile.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { ShippingOptionDTO } from "./shipping-option"
|
||||
|
||||
export interface ShippingProfileDTO {
|
||||
id: string
|
||||
name: string
|
||||
metadata: Record<string, unknown> | null
|
||||
shipping_options: ShippingOptionDTO[]
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export {}
|
||||
12
packages/types/src/fulfillment/mutations/fulfillment-set.ts
Normal file
12
packages/types/src/fulfillment/mutations/fulfillment-set.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { CreateServiceZoneDTO } from "./service-zone"
|
||||
|
||||
export interface CreateFulfillmentSetDTO {
|
||||
name: string
|
||||
type: string
|
||||
service_zones: Omit<CreateServiceZoneDTO, "fulfillment_set_id">[]
|
||||
}
|
||||
|
||||
export interface UpdateFulfillmentSetDTO
|
||||
extends Partial<CreateFulfillmentSetDTO> {
|
||||
id: string
|
||||
}
|
||||
70
packages/types/src/fulfillment/mutations/geo-zone.ts
Normal file
70
packages/types/src/fulfillment/mutations/geo-zone.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import { GeoZoneType } from "../common"
|
||||
|
||||
interface CreateGeoZoneBaseDTO {
|
||||
type: GeoZoneType
|
||||
service_zone_id: string
|
||||
country_code: string
|
||||
metadata?: Record<string, any> | null
|
||||
}
|
||||
|
||||
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>
|
||||
}
|
||||
|
||||
export type CreateGeoZoneDTO =
|
||||
| CreateCountryGeoZoneDTO
|
||||
| CreateProvinceGeoZoneDTO
|
||||
| CreateCityGeoZoneDTO
|
||||
| CreateZipGeoZoneDTO
|
||||
|
||||
interface UpdateGeoZoneBaseDTO extends Partial<CreateGeoZoneBaseDTO> {
|
||||
id: string
|
||||
}
|
||||
|
||||
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>
|
||||
}
|
||||
|
||||
export type UpdateGeoZoneDTO =
|
||||
| UpdateCountryGeoZoneDTO
|
||||
| UpdateProvinceGeoZoneDTO
|
||||
| UpdateCityGeoZoneDTO
|
||||
| UpdateZipGeoZoneDTO
|
||||
6
packages/types/src/fulfillment/mutations/index.ts
Normal file
6
packages/types/src/fulfillment/mutations/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export * from "./shipping-option-type"
|
||||
export * from "./shipping-option-rule"
|
||||
export * from "./geo-zone"
|
||||
export * from "./service-zone"
|
||||
export * from "./shipping-option"
|
||||
export * from "./fulfillment-set"
|
||||
14
packages/types/src/fulfillment/mutations/service-zone.ts
Normal file
14
packages/types/src/fulfillment/mutations/service-zone.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { CreateGeoZoneDTO, UpdateGeoZoneDTO } from "./geo-zone"
|
||||
|
||||
export interface CreateServiceZoneDTO {
|
||||
fulfillment_set_id: string
|
||||
name: string
|
||||
geo_zones: (
|
||||
| Omit<CreateGeoZoneDTO, "service_zone_id">
|
||||
| Omit<UpdateGeoZoneDTO, "service_zone_id">
|
||||
)[]
|
||||
}
|
||||
|
||||
export interface UpdateServiceZoneDTO extends Partial<CreateServiceZoneDTO> {
|
||||
id: string
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
export interface CreateShippingOptionRuleDTO {
|
||||
attribute: string
|
||||
operator: string
|
||||
value: string | string[]
|
||||
shipping_option_id: string
|
||||
}
|
||||
|
||||
export interface UpdateShippingOptionRuleDTO
|
||||
extends Partial<CreateShippingOptionRuleDTO> {
|
||||
id: string
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
export interface CreateShippingOptionTypeDTO {
|
||||
label: string
|
||||
description: string
|
||||
code: string
|
||||
shipping_option_id: string
|
||||
}
|
||||
|
||||
export interface UpdateShippingOptionTypeDTO
|
||||
extends Partial<CreateShippingOptionTypeDTO> {
|
||||
id: string
|
||||
}
|
||||
37
packages/types/src/fulfillment/mutations/shipping-option.ts
Normal file
37
packages/types/src/fulfillment/mutations/shipping-option.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import {
|
||||
CreateShippingOptionTypeDTO,
|
||||
UpdateShippingOptionTypeDTO,
|
||||
} from "./shipping-option-type"
|
||||
import { ShippingOptionPriceType } from "../common"
|
||||
import {
|
||||
CreateShippingOptionRuleDTO,
|
||||
UpdateShippingOptionRuleDTO,
|
||||
} from "./shipping-option-rule"
|
||||
|
||||
export interface CreateShippingOptionDTO {
|
||||
name: string
|
||||
price_type: ShippingOptionPriceType
|
||||
service_zone_id: string
|
||||
shipping_profile_id: string
|
||||
service_provider_id: string
|
||||
type: Omit<CreateShippingOptionTypeDTO, "shipping_option_id">
|
||||
data?: Record<string, unknown> | null
|
||||
rules?: Omit<CreateShippingOptionRuleDTO, "shipping_option_id">[]
|
||||
}
|
||||
|
||||
export interface UpdateShippingOptionDTO {
|
||||
id: string
|
||||
name?: string
|
||||
price_type?: ShippingOptionPriceType
|
||||
service_zone_id?: string
|
||||
shipping_profile_id?: string
|
||||
service_provider_id?: string
|
||||
type:
|
||||
| Omit<CreateShippingOptionTypeDTO, "shipping_option_id">
|
||||
| Omit<UpdateShippingOptionTypeDTO, "shipping_option_id">
|
||||
data?: Record<string, unknown> | null
|
||||
rules?: (
|
||||
| Omit<CreateShippingOptionRuleDTO, "shipping_option_id">
|
||||
| Omit<UpdateShippingOptionRuleDTO, "shipping_option_id">
|
||||
)[]
|
||||
}
|
||||
@@ -1,55 +1,277 @@
|
||||
import { IModuleService } from "../modules-sdk"
|
||||
import { FulfillmentDTO } from "./common"
|
||||
import {
|
||||
FilterableFulfillmentSetProps,
|
||||
FilterableServiceZoneProps,
|
||||
FilterableShippingOptionProps,
|
||||
FulfillmentSetDTO,
|
||||
ServiceZoneDTO,
|
||||
ShippingOptionDTO,
|
||||
} from "./common"
|
||||
import { FindConfig } from "../common"
|
||||
import { Context } from "../shared-context"
|
||||
import { RestoreReturn, SoftDeleteReturn } from "../dal"
|
||||
import {
|
||||
CreateFulfillmentSetDTO,
|
||||
CreateServiceZoneDTO,
|
||||
CreateShippingOptionDTO,
|
||||
UpdateFulfillmentSetDTO,
|
||||
UpdateServiceZoneDTO,
|
||||
UpdateShippingOptionDTO,
|
||||
} from "./mutations"
|
||||
|
||||
export interface IFulfillmentModuleService extends IModuleService {
|
||||
/**
|
||||
* Create a new fulfillment set
|
||||
* @param data
|
||||
* @param sharedContext
|
||||
*/
|
||||
create(
|
||||
data: any[], // TODO Create appropriate DTO
|
||||
data: CreateFulfillmentSetDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentDTO[]>
|
||||
): Promise<FulfillmentSetDTO[]>
|
||||
create(
|
||||
data: any, // TODO Create appropriate DTO
|
||||
data: CreateFulfillmentSetDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentDTO>
|
||||
): Promise<FulfillmentSetDTO>
|
||||
|
||||
update(
|
||||
data: any[], // TODO Create appropriate DTO
|
||||
/**
|
||||
* Create a new service zone
|
||||
* @param data
|
||||
* @param sharedContext
|
||||
*/
|
||||
createServiceZones(
|
||||
data: CreateServiceZoneDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentDTO[]>
|
||||
update(
|
||||
data: any, // TODO Create appropriate DTO
|
||||
): Promise<ServiceZoneDTO[]>
|
||||
createServiceZones(
|
||||
data: CreateServiceZoneDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentDTO>
|
||||
): Promise<ServiceZoneDTO>
|
||||
|
||||
/**
|
||||
* Create a new shipping option
|
||||
* @param data
|
||||
* @param sharedContext
|
||||
*/
|
||||
createShippingOptions(
|
||||
data: CreateShippingOptionDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<ShippingOptionDTO[]>
|
||||
createShippingOptions(
|
||||
data: CreateShippingOptionDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<ShippingOptionDTO>
|
||||
|
||||
/**
|
||||
* Update a fulfillment set
|
||||
* @param data
|
||||
* @param sharedContext
|
||||
*/
|
||||
update(
|
||||
data: UpdateFulfillmentSetDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentSetDTO[]>
|
||||
update(
|
||||
data: UpdateFulfillmentSetDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentSetDTO>
|
||||
|
||||
/**
|
||||
* Update a service zone
|
||||
* @param data
|
||||
* @param sharedContext
|
||||
*/
|
||||
updateServiceZones(
|
||||
data: UpdateServiceZoneDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<ServiceZoneDTO[]>
|
||||
updateServiceZones(
|
||||
data: UpdateServiceZoneDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<ServiceZoneDTO>
|
||||
|
||||
/**
|
||||
* Update a shipping option
|
||||
* @param data
|
||||
* @param sharedContext
|
||||
*/
|
||||
updateShippingOptions(
|
||||
data: UpdateShippingOptionDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<ShippingOptionDTO[]>
|
||||
updateShippingOptions(
|
||||
data: UpdateShippingOptionDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<ShippingOptionDTO>
|
||||
|
||||
/**
|
||||
* Delete a fulfillment set
|
||||
* @param ids
|
||||
* @param sharedContext
|
||||
*/
|
||||
delete(ids: string[], sharedContext?: Context): Promise<void>
|
||||
delete(id: string, sharedContext?: Context): Promise<void>
|
||||
|
||||
/**
|
||||
* Delete a service zone
|
||||
* @param ids
|
||||
* @param sharedContext
|
||||
*/
|
||||
deleteServiceZones(ids: string[], sharedContext?: Context): Promise<void>
|
||||
deleteServiceZones(id: string, sharedContext?: Context): Promise<void>
|
||||
|
||||
/**
|
||||
* Delete a shippingOption
|
||||
* @param ids
|
||||
* @param sharedContext
|
||||
*/
|
||||
deleteShippingOptions(ids: string[], sharedContext?: Context): Promise<void>
|
||||
deleteShippingOptions(id: string, sharedContext?: Context): Promise<void>
|
||||
|
||||
/**
|
||||
* Retrieve a fulfillment set
|
||||
* @param id
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
retrieve(
|
||||
id: string,
|
||||
config?: FindConfig<FulfillmentDTO>,
|
||||
config?: FindConfig<FulfillmentSetDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentDTO>
|
||||
): Promise<FulfillmentSetDTO>
|
||||
|
||||
/**
|
||||
* Retrieve a service zone
|
||||
* @param id
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
retrieveServiceZone(
|
||||
id: string,
|
||||
config?: FindConfig<ServiceZoneDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<ServiceZoneDTO>
|
||||
|
||||
/**
|
||||
* Retrieve a shipping option
|
||||
* @param id
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
retrieveShippingOption(
|
||||
id: string,
|
||||
config?: FindConfig<ShippingOptionDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<ShippingOptionDTO>
|
||||
|
||||
/**
|
||||
* List fulfillment sets
|
||||
* @param filters
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
list(
|
||||
filters?: any, // TODO Create appropriate filter type
|
||||
config?: FindConfig<FulfillmentDTO>,
|
||||
filters?: FilterableFulfillmentSetProps,
|
||||
config?: FindConfig<FulfillmentSetDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<FulfillmentDTO[]>
|
||||
): Promise<FulfillmentSetDTO[]>
|
||||
|
||||
/**
|
||||
* List service zones
|
||||
* @param filters
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
listServiceZones(
|
||||
filters?: FilterableServiceZoneProps,
|
||||
config?: FindConfig<ServiceZoneDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<ServiceZoneDTO[]>
|
||||
|
||||
/**
|
||||
* List shipping options
|
||||
* @param filters
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
listShippingOptions(
|
||||
filters?: FilterableShippingOptionProps,
|
||||
config?: FindConfig<ShippingOptionDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<ShippingOptionDTO[]>
|
||||
|
||||
/**
|
||||
* List and count fulfillment sets
|
||||
* @param filters
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
listAndCount(
|
||||
filters?: any, // TODO Create appropriate filter type
|
||||
config?: FindConfig<FulfillmentDTO>,
|
||||
filters?: FilterableFulfillmentSetProps,
|
||||
config?: FindConfig<FulfillmentSetDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<[FulfillmentDTO[], number]>
|
||||
): Promise<[FulfillmentSetDTO[], number]>
|
||||
|
||||
/**
|
||||
* List and count service zones
|
||||
* @param filters
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
listAndCountServiceZones(
|
||||
filters?: FilterableServiceZoneProps,
|
||||
config?: FindConfig<ServiceZoneDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<[ServiceZoneDTO[], number]>
|
||||
|
||||
/**
|
||||
* List and count shipping options
|
||||
* @param filters
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
listAndCountShippingOptions(
|
||||
filters?: FilterableShippingOptionProps,
|
||||
config?: FindConfig<ShippingOptionDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<[ShippingOptionDTO[], number]>
|
||||
|
||||
/**
|
||||
* Soft delete fulfillment sets
|
||||
* @param fulfillmentIds
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
softDelete<TReturnableLinkableKeys extends string = string>(
|
||||
fulfillmentIds: string[],
|
||||
config?: SoftDeleteReturn<TReturnableLinkableKeys>,
|
||||
sharedContext?: Context
|
||||
): Promise<Record<string, string[]> | void>
|
||||
|
||||
/**
|
||||
* Soft delete service zones
|
||||
* @param serviceZoneIds
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
softDeleteServiceZones<TReturnableLinkableKeys extends string = string>(
|
||||
serviceZoneIds: string[],
|
||||
config?: SoftDeleteReturn<TReturnableLinkableKeys>,
|
||||
sharedContext?: Context
|
||||
): Promise<Record<string, string[]> | void>
|
||||
|
||||
/**
|
||||
* Soft delete shipping options
|
||||
* @param shippingOptionsIds
|
||||
* @param config
|
||||
* @param sharedContext
|
||||
*/
|
||||
softDeleteShippingOptions<TReturnableLinkableKeys extends string = string>(
|
||||
shippingOptionsIds: string[],
|
||||
config?: SoftDeleteReturn<TReturnableLinkableKeys>,
|
||||
sharedContext?: Context
|
||||
): Promise<Record<string, string[]> | void>
|
||||
|
||||
restore<TReturnableLinkableKeys extends string = string>(
|
||||
fulfillmentIds: string[],
|
||||
config?: RestoreReturn<TReturnableLinkableKeys>,
|
||||
|
||||
Reference in New Issue
Block a user