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:
Adrien de Peretti
2024-02-12 11:28:31 +01:00
committed by GitHub
parent 2afcf1c918
commit 1fd0457c15
27 changed files with 805 additions and 68 deletions
@@ -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 []
}
}