feat(core-flows,dashboard,js-sdk,medusa,types): support Fulfillment Options (#10622)

**What**
- add a list point for fetching fulfillment options for a provider
- add FO support on SO create & update on dashboard
- pass `cart` and `stockLocation` to `validateFufillmentData` context

---

CLOSES CMRC-789
CLOSES CMRC-790
This commit is contained in:
Frane Polić
2024-12-18 10:16:26 +01:00
committed by GitHub
parent f3eca7734e
commit bde4b82194
20 changed files with 1850 additions and 487 deletions

View File

@@ -18,25 +18,25 @@ export class FulfillmentProvider {
* This method retrieves a paginated list of fulfillment providers. It sends a request to the
* [List Fulfillment Providers](https://docs.medusajs.com/api/admin#fulfillment-providers_getfulfillmentproviders)
* API route.
*
*
* @param query - Filters and pagination configurations.
* @param headers - Headers to pass in the request.
* @returns The paginated list of providers.
*
*
* @example
* To retrieve the list of fulfillment providers:
*
*
* ```ts
* sdk.admin.fulfillmentProvider.list()
* .then(({ fulfillment_providers, count, limit, offset }) => {
* console.log(fulfillment_providers)
* })
* ```
*
*
* To configure the pagination, pass the `limit` and `offset` query parameters.
*
*
* For example, to retrieve only 10 items and skip 10 items:
*
*
* ```ts
* sdk.admin.fulfillmentProvider.list({
* limit: 10,
@@ -46,10 +46,10 @@ export class FulfillmentProvider {
* console.log(fulfillment_providers)
* })
* ```
*
*
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
* in each fulfillment provider:
*
*
* ```ts
* sdk.admin.fulfillmentProvider.list({
* fields: "id"
@@ -58,7 +58,7 @@ export class FulfillmentProvider {
* console.log(fulfillment_providers)
* })
* ```
*
*
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
*/
async list(
@@ -74,4 +74,23 @@ export class FulfillmentProvider {
}
)
}
/**
* This method retrieves a list of fulfillment options for a given fulfillment provider. It sends a request to the
* [List Fulfillment Options](https://docs.medusajs.com/api/admin#fulfillment-providers_getfulfillmentprovideroptions)
* API route.
*
* @param id - The ID of the fulfillment provider.
* @param headers - Headers to pass in the request.
* @returns The list of fulfillment options.
*/
async listFulfillmentOptions(id: string, headers?: ClientHeaders) {
return await this.client.fetch<HttpTypes.AdminFulfillmentProviderOptionsListResponse>(
`/admin/fulfillment-providers/${id}/options`,
{
method: "GET",
headers,
}
)
}
}