Feat(fulfillment): service provider registration + fulfillment management (#6524)

**What**
- Create the fulfillment manual package with a first iteration API 
- Create a new `AbstractFulfillmentProviderService` and `IFulfillmentProvider`
- Modify the module service interface to add new methods to manipulate the fulfillment and the communication with the external provider
  - create (no bulk)
  - cancel (no bulk)
  - update (no bulk)
  - list
  - listAndCount
  - retrieve
- Add new methods to the service provider service to include communication with the third party provider
  - get options
  - create
  - cancel
  - validate data
  - validate option
- Update/create interfaces and DTO's
- fix repository serializer to allow non entity to be passed without throwing
- split module tests into multiple files to simplify navigation
- Add integration tests to validate fulfillments manipulation and external provider loading + communication

FIXES CORE-1729
FIXES CORE-1785
FIXES CORE-1784
FIXES CORE-1766
This commit is contained in:
Adrien de Peretti authored and GitHub committed 2024-03-05 11:11:14 +00:00
1 parent f9ef37a2f2
commit 62a7bcc30c
55 files changed
+4066 -2749

No files matched your search

@@ -0,0 +1,44 @@
import { AbstractFulfillmentProviderService } from "@medusajs/utils"
// TODO rework type and DTO's
export class ManualFulfillmentService extends AbstractFulfillmentProviderService {
static identifier = "manual"
constructor() {
super()
}
async getFulfillmentOptions(): Promise<Record<string, unknown>[]> {
return [
{
id: "manual-fulfillment",
},
{
id: "manual-fulfillment-return",
is_return: true,
},
]
}
async validateFulfillmentData(
optionData: Record<string, unknown>,
data: Record<string, unknown>,
context: Record<string, unknown>
): Promise<any> {
return data
}
async validateOption(data: Record<string, unknown>): Promise<boolean> {
return true
}
async createFulfillment(): Promise<Record<string, unknown>> {
// No data is being sent anywhere
return {}
}
async cancelFulfillment(fulfillment: Record<string, unknown>): Promise<any> {
return {}
}
}