feat: Shipping options API (#6957)
**What** Add support for shipping options management API PARTIALLY FIXES CORE-1918
This commit is contained in:
committed by
GitHub
parent
21990fcd4b
commit
ee73031d0e
@@ -2,7 +2,7 @@ import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import {
|
||||
IFulfillmentModuleService,
|
||||
RemoveFulfillmentShippingOptionRulesWorkflowDTO,
|
||||
ShippingOptionRuleOperatorType,
|
||||
RuleOperatorType,
|
||||
} from "@medusajs/types"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
@@ -41,7 +41,7 @@ export const removeRulesFromFulfillmentShippingOptionStep = createStep(
|
||||
await fulfillmentModule.createShippingOptionRules(
|
||||
shippingOptionRules.map((rule) => ({
|
||||
attribute: rule.attribute,
|
||||
operator: rule.operator as ShippingOptionRuleOperatorType,
|
||||
operator: rule.operator as RuleOperatorType,
|
||||
value: rule.value as unknown as string | string[],
|
||||
shipping_option_id: rule.shipping_option_id,
|
||||
}))
|
||||
|
||||
@@ -25,4 +25,5 @@ export * as WorkflowTypes from "./workflow"
|
||||
export * as ApiKeyTypes from "./api-key"
|
||||
export * as StoreTypes from "./store"
|
||||
export * as CurrencyTypes from "./currency"
|
||||
export * as HttpTypes from "./http"
|
||||
export * as FileTypes from "./file"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "./common"
|
||||
export * from "./rule"
|
||||
export * from "./config-module"
|
||||
export * from "./medusa-container"
|
||||
|
||||
9
packages/types/src/common/rule.ts
Normal file
9
packages/types/src/common/rule.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export type RuleOperatorType =
|
||||
| "in"
|
||||
| "eq"
|
||||
| "ne"
|
||||
| "gt"
|
||||
| "gte"
|
||||
| "lt"
|
||||
| "lte"
|
||||
| "nin"
|
||||
@@ -1,16 +1,8 @@
|
||||
export type ShippingOptionRuleOperatorType =
|
||||
| "in"
|
||||
| "eq"
|
||||
| "ne"
|
||||
| "gt"
|
||||
| "gte"
|
||||
| "lt"
|
||||
| "lte"
|
||||
| "nin"
|
||||
import { RuleOperatorType } from "../../common"
|
||||
|
||||
export interface CreateShippingOptionRuleDTO {
|
||||
attribute: string
|
||||
operator: ShippingOptionRuleOperatorType
|
||||
operator: RuleOperatorType
|
||||
value: string | string[]
|
||||
shipping_option_id: string
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @experimental
|
||||
*/
|
||||
export interface AdminFulfillmentAddressResponse {
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @experimental
|
||||
*/
|
||||
export interface AdminFulfillmentItemResponse {
|
||||
id: string
|
||||
title: string
|
||||
quantity: number
|
||||
sku: string
|
||||
barcode: string
|
||||
line_item_id: string | null
|
||||
inventory_item_id: string | null
|
||||
fulfillment_id: string
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @experimental
|
||||
*/
|
||||
export interface AdminFulfillmentLabelResponse {
|
||||
id: string
|
||||
tracking_number: string
|
||||
tracking_url: string
|
||||
label_url: string
|
||||
fulfillment_id: string
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @experimental
|
||||
*/
|
||||
export interface AdminFulfillmentProviderResponse {
|
||||
id: string
|
||||
name: string
|
||||
metadata: Record<string, unknown> | null
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
15
packages/types/src/http/fulfillment/admin/fulfillment-set.ts
Normal file
15
packages/types/src/http/fulfillment/admin/fulfillment-set.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { AdminServiceZoneResponse } from "./service-zone"
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
*/
|
||||
export interface AdminFulfillmentSetResponse {
|
||||
id: string
|
||||
name: string
|
||||
type: string
|
||||
metadata: Record<string, unknown> | null
|
||||
service_zones: AdminServiceZoneResponse[]
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
27
packages/types/src/http/fulfillment/admin/fulfillment.ts
Normal file
27
packages/types/src/http/fulfillment/admin/fulfillment.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { AdminFulfillmentAddressResponse } from "./fulfillment-address"
|
||||
import { AdminFulfillmentProviderResponse } from "./fulfillment-provider"
|
||||
import { AdminFulfillmentItemResponse } from "./fulfillment-item"
|
||||
import { AdminFulfillmentLabelResponse } from "./fulfillment-label"
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
*/
|
||||
export interface AdminFulfillmentResponse {
|
||||
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
|
||||
provider: AdminFulfillmentProviderResponse
|
||||
delivery_address: AdminFulfillmentAddressResponse
|
||||
items: AdminFulfillmentItemResponse[]
|
||||
labels: AdminFulfillmentLabelResponse[]
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
17
packages/types/src/http/fulfillment/admin/geo-zone.ts
Normal file
17
packages/types/src/http/fulfillment/admin/geo-zone.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { GeoZoneType } from "../../../fulfillment"
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
*/
|
||||
export interface AdminGeoZoneResponse {
|
||||
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
|
||||
}
|
||||
12
packages/types/src/http/fulfillment/admin/index.ts
Normal file
12
packages/types/src/http/fulfillment/admin/index.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
export * from "./fulfillment"
|
||||
export * from "./fulfillment-item"
|
||||
export * from "./fulfillment-set"
|
||||
export * from "./fulfillment-label"
|
||||
export * from "./fulfillment-provider"
|
||||
export * from "./fulfillment-address"
|
||||
export * from "./geo-zone"
|
||||
export * from "./service-zone"
|
||||
export * from "./shipping-option"
|
||||
export * from "./shipping-option-rule"
|
||||
export * from "./shipping-option-type"
|
||||
export * from "./shipping-profile"
|
||||
14
packages/types/src/http/fulfillment/admin/service-zone.ts
Normal file
14
packages/types/src/http/fulfillment/admin/service-zone.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { AdminGeoZoneResponse } from "./geo-zone"
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
*/
|
||||
export interface AdminServiceZoneResponse {
|
||||
id: string
|
||||
name: string
|
||||
metadata: Record<string, unknown> | null
|
||||
geo_zones: AdminGeoZoneResponse[]
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @experimental
|
||||
*/
|
||||
export interface AdminShippingOptionRuleResponse {
|
||||
id: string
|
||||
attribute: string
|
||||
operator: string
|
||||
value: { value: string | string[] } | null
|
||||
shipping_option_id: string
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @experimental
|
||||
*/
|
||||
export interface AdminShippingOptionTypeResponse {
|
||||
id: string
|
||||
label: string
|
||||
description: string
|
||||
code: string
|
||||
shipping_option_id: string
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
31
packages/types/src/http/fulfillment/admin/shipping-option.ts
Normal file
31
packages/types/src/http/fulfillment/admin/shipping-option.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { ShippingOptionPriceType } from "../../../fulfillment"
|
||||
import { AdminServiceZoneResponse } from "./service-zone"
|
||||
import { AdminShippingOptionTypeResponse } from "./shipping-option-type"
|
||||
import { AdminShippingOptionRuleResponse } from "./shipping-option-rule"
|
||||
import { AdminShippingProfileResponse } from "./shipping-profile"
|
||||
import { AdminFulfillmentProviderResponse } from "./fulfillment-provider"
|
||||
import { AdminFulfillmentResponse } from "./fulfillment"
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
*/
|
||||
export interface AdminShippingOptionResponse {
|
||||
id: string
|
||||
name: string
|
||||
price_type: ShippingOptionPriceType
|
||||
service_zone_id: string
|
||||
shipping_profile_id: string
|
||||
provider_id: string
|
||||
shipping_option_type_id: string | null
|
||||
data: Record<string, unknown> | null
|
||||
metadata: Record<string, unknown> | null
|
||||
service_zone: AdminServiceZoneResponse
|
||||
shipping_profile: AdminShippingProfileResponse
|
||||
fulfillment_provider: AdminFulfillmentProviderResponse
|
||||
type: AdminShippingOptionTypeResponse
|
||||
rules: AdminShippingOptionRuleResponse[]
|
||||
fulfillments: AdminFulfillmentResponse[]
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @experimental
|
||||
*/
|
||||
export interface AdminShippingProfileResponse {
|
||||
id: string
|
||||
name: string
|
||||
type: string
|
||||
metadata: Record<string, unknown> | null
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
deleted_at: Date | null
|
||||
}
|
||||
1
packages/types/src/http/fulfillment/index.ts
Normal file
1
packages/types/src/http/fulfillment/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./admin"
|
||||
1
packages/types/src/http/index.ts
Normal file
1
packages/types/src/http/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./fulfillment"
|
||||
@@ -35,4 +35,5 @@ export * from "./transaction-base"
|
||||
export * from "./user"
|
||||
export * from "./workflow"
|
||||
export * from "./currency"
|
||||
export * from "./http"
|
||||
export * from "./file"
|
||||
|
||||
Reference in New Issue
Block a user