fix(types, medusa): http types fixes (#9334)
* fix(types, medusa): http types fixes * fix build error * remove return fields * more fixes * fix cart payload types
This commit is contained in:
@@ -6,6 +6,10 @@ import {
|
||||
BaseCartAddress,
|
||||
BaseCartLineItem,
|
||||
BaseCartShippingMethod,
|
||||
BaseLineItemAdjustment,
|
||||
BaseLineItemTaxLine,
|
||||
BaseShippingMethodAdjustment,
|
||||
BaseShippingMethodTaxLine,
|
||||
} from "../common"
|
||||
|
||||
export interface StoreCart extends Omit<BaseCart, "items"> {
|
||||
@@ -20,6 +24,19 @@ export interface StoreCartLineItem extends Omit<BaseCartLineItem, "product" | "v
|
||||
product?: StoreProduct
|
||||
variant?: StoreProductVariant
|
||||
cart: StoreCart
|
||||
tax_lines?: (BaseLineItemTaxLine & {
|
||||
item: StoreCartLineItem
|
||||
})[]
|
||||
adjustments?: (BaseLineItemAdjustment & {
|
||||
item: StoreCartLineItem
|
||||
})[]
|
||||
}
|
||||
export interface StoreCartAddress extends BaseCartAddress {}
|
||||
export interface StoreCartShippingMethod extends BaseCartShippingMethod {}
|
||||
export interface StoreCartShippingMethod extends BaseCartShippingMethod {
|
||||
tax_lines?: (BaseShippingMethodTaxLine & {
|
||||
shipping_method: StoreCartShippingMethod
|
||||
})[]
|
||||
adjustments?: (BaseShippingMethodAdjustment & {
|
||||
shipping_method: StoreCartShippingMethod
|
||||
})[]
|
||||
}
|
||||
@@ -1,20 +1,18 @@
|
||||
import { StoreCartAddress, StoreCartLineItem } from "./entities"
|
||||
|
||||
export interface StoreCreateCart {
|
||||
region_id?: string
|
||||
shipping_address?: StoreCartAddress
|
||||
billing_address?: StoreCartAddress
|
||||
shipping_address?: StoreAddAddress
|
||||
billing_address?: StoreAddAddress
|
||||
email?: string
|
||||
currency_code?: string
|
||||
items?: StoreCartLineItem[]
|
||||
items?: StoreAddCartLineItem[]
|
||||
sales_channel_id?: string
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface StoreUpdateCart {
|
||||
region_id?: string
|
||||
shipping_address?: StoreCartAddress
|
||||
billing_address?: StoreCartAddress
|
||||
shipping_address?: StoreAddAddress | string
|
||||
billing_address?: StoreAddAddress | string
|
||||
email?: string
|
||||
sales_channel_id?: string
|
||||
metadata?: Record<string, unknown>
|
||||
@@ -40,3 +38,60 @@ export interface StoreAddCartShippingMethods {
|
||||
export interface StoreCompleteCart {
|
||||
idempotency_key?: string
|
||||
}
|
||||
|
||||
export interface StoreAddAddress {
|
||||
/**
|
||||
* The first name of the address.
|
||||
*/
|
||||
first_name?: string
|
||||
|
||||
/**
|
||||
* The last name of the address.
|
||||
*/
|
||||
last_name?: string
|
||||
|
||||
/**
|
||||
* The phone number of the address.
|
||||
*/
|
||||
phone?: string
|
||||
|
||||
/**
|
||||
* The company of the address.
|
||||
*/
|
||||
company?: string
|
||||
|
||||
/**
|
||||
* The first address line of the address.
|
||||
*/
|
||||
address_1?: string
|
||||
|
||||
/**
|
||||
* The second address line of the address.
|
||||
*/
|
||||
address_2?: string
|
||||
|
||||
/**
|
||||
* The city of the address.
|
||||
*/
|
||||
city?: string
|
||||
|
||||
/**
|
||||
* The country code of the address.
|
||||
*/
|
||||
country_code?: string
|
||||
|
||||
/**
|
||||
* The province/state of the address.
|
||||
*/
|
||||
province?: string
|
||||
|
||||
/**
|
||||
* The postal code of the address.
|
||||
*/
|
||||
postal_code?: string
|
||||
|
||||
/**
|
||||
* Holds custom data in key-value pairs.
|
||||
*/
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
import { StoreProduct } from "../../product"
|
||||
import { BaseCollection } from "../common"
|
||||
|
||||
export interface StoreCollection extends BaseCollection {}
|
||||
export interface StoreCollection extends Omit<BaseCollection, "products"> {
|
||||
products?: StoreProduct[]
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { AdminCustomer } from "../../customer/admin"
|
||||
import { BaseCustomerGroup } from "../common"
|
||||
|
||||
export interface AdminCustomerGroup extends BaseCustomerGroup {}
|
||||
export interface AdminCustomerGroup extends BaseCustomerGroup {
|
||||
customers: AdminCustomer[]
|
||||
}
|
||||
|
||||
@@ -4,5 +4,6 @@ import { BaseCustomer, BaseCustomerAddress } from "../common"
|
||||
export interface AdminCustomer extends BaseCustomer {
|
||||
has_account: boolean
|
||||
groups?: AdminCustomerGroup[]
|
||||
addresses: AdminCustomerAddress[]
|
||||
}
|
||||
export interface AdminCustomerAddress extends BaseCustomerAddress {}
|
||||
|
||||
@@ -3,5 +3,7 @@ import {
|
||||
BaseCustomerAddress,
|
||||
} from "../common"
|
||||
|
||||
export interface StoreCustomer extends BaseCustomer {}
|
||||
export interface StoreCustomer extends Omit<BaseCustomer, "created_by"> {
|
||||
addresses: StoreCustomerAddress[]
|
||||
}
|
||||
export interface StoreCustomerAddress extends BaseCustomerAddress {}
|
||||
@@ -22,5 +22,5 @@ export interface AdminDraftOrderResponse {
|
||||
}
|
||||
|
||||
export type AdminDraftOrderListResponse = PaginatedResponse<{
|
||||
draft_orders: AdminOrder
|
||||
draft_orders: AdminOrder[]
|
||||
}>
|
||||
|
||||
@@ -6,11 +6,17 @@ import {
|
||||
BaseOrder,
|
||||
BaseOrderAddress,
|
||||
BaseOrderFulfillment,
|
||||
BaseOrderItemDetail,
|
||||
BaseOrderLineItem,
|
||||
BaseOrderLineItemAdjustment,
|
||||
BaseOrderLineItemTaxLine,
|
||||
BaseOrderShippingDetail,
|
||||
BaseOrderShippingMethod,
|
||||
BaseOrderShippingMethodAdjustment,
|
||||
BaseOrderShippingMethodTaxLine,
|
||||
} from "../common"
|
||||
|
||||
export interface StoreOrder extends Omit<BaseOrder, "items"> {
|
||||
export interface StoreOrder extends Omit<BaseOrder, "items" | "version" | "transations"> {
|
||||
shipping_address?: StoreOrderAddress | null
|
||||
billing_address?: StoreOrderAddress | null
|
||||
items: StoreOrderLineItem[] | null
|
||||
@@ -22,9 +28,28 @@ export interface StoreOrder extends Omit<BaseOrder, "items"> {
|
||||
export interface StoreOrderLineItem extends Omit<BaseOrderLineItem, "product" | "variant"> {
|
||||
variant?: StoreProductVariant
|
||||
product?: StoreProduct
|
||||
tax_lines?: (BaseOrderLineItemTaxLine & {
|
||||
item: StoreOrderLineItem
|
||||
})[]
|
||||
adjustments?: (BaseOrderLineItemAdjustment & {
|
||||
item: StoreOrderLineItem
|
||||
})[]
|
||||
detail: BaseOrderItemDetail & {
|
||||
item: StoreOrderLineItem
|
||||
}
|
||||
}
|
||||
export interface StoreOrderAddress extends BaseOrderAddress {
|
||||
country?: StoreRegionCountry
|
||||
}
|
||||
export interface StoreOrderShippingMethod extends BaseOrderShippingMethod {}
|
||||
export interface StoreOrderShippingMethod extends BaseOrderShippingMethod {
|
||||
tax_lines?: (BaseOrderShippingMethodTaxLine & {
|
||||
shipping_method: StoreOrderShippingMethod
|
||||
})[]
|
||||
adjustments?: (BaseOrderShippingMethodAdjustment & {
|
||||
shipping_method: StoreOrderShippingMethod
|
||||
})[]
|
||||
detail?: BaseOrderShippingDetail & {
|
||||
shipping_method: StoreOrderShippingMethod
|
||||
}
|
||||
}
|
||||
export interface StoreOrderFulfillment extends BaseOrderFulfillment {}
|
||||
@@ -136,7 +136,11 @@ export interface BaseProductVariantParams
|
||||
BaseFilterable<BaseProductVariantParams> {
|
||||
q?: string
|
||||
id?: string | string[]
|
||||
sku?: string | string[]
|
||||
product_id?: string | string[]
|
||||
options?: Record<string, string>
|
||||
options?: {
|
||||
value: string
|
||||
option_id: string
|
||||
}
|
||||
created_at?: OperatorMap<string>
|
||||
updated_at?: OperatorMap<string>
|
||||
deleted_at?: OperatorMap<string>
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
ProductStatus,
|
||||
} from "../common"
|
||||
|
||||
export interface StoreProduct extends Omit<BaseProduct, "categories" | "sales_channels" | "variants" | "options"> {
|
||||
export interface StoreProduct extends Omit<BaseProduct, "categories" | "sales_channels" | "variants" | "options" | "collection"> {
|
||||
collection?: StoreCollection | null
|
||||
categories?: StoreProductCategory[] | null
|
||||
variants: StoreProductVariant[] | null
|
||||
|
||||
@@ -11,6 +11,6 @@ export interface StoreProductParams extends Omit<BaseProductListParams, "tags" |
|
||||
// The region ID and currency_code are not params, but are used for the pricing context. Maybe move to separate type definition.
|
||||
region_id?: string
|
||||
currency_code?: string
|
||||
variants?: StoreProductVariantParams
|
||||
variants?: Pick<StoreProductVariantParams, "options">
|
||||
province?: string
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BaseReturn, BaseReturnItem } from "../common";
|
||||
|
||||
export interface StoreReturn extends BaseReturn {
|
||||
export interface StoreReturn extends Omit<BaseReturn, "no_notification" | "order_version"> {
|
||||
items: StoreReturnItem[]
|
||||
}
|
||||
export interface StoreReturnItem extends BaseReturnItem {}
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface AdminCreateShippingOption {
|
||||
|
||||
export interface AdminUpdateShippingOptionRule
|
||||
extends AdminCreateShippingOptionRule {
|
||||
id?: string
|
||||
id: string
|
||||
}
|
||||
|
||||
export interface AdminUpdateShippingOptionPriceWithCurrency {
|
||||
|
||||
@@ -5,10 +5,9 @@ import {
|
||||
MedusaResponse,
|
||||
} from "../../../../../../../types/routing"
|
||||
import { refetchEntity } from "../../../../../../utils/refetch-entity"
|
||||
import { AdminMarkOrderFulfillmentDeliveredType } from "../../../../validators"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminMarkOrderFulfillmentDeliveredType>,
|
||||
req: AuthenticatedMedusaRequest,
|
||||
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||
) => {
|
||||
const { id: orderId, fulfillment_id: fulfillmentId } = req.params
|
||||
|
||||
@@ -7,7 +7,7 @@ import { remapKeysForProduct } from "../helpers"
|
||||
import { exportProductsWorkflow } from "@medusajs/core-flows"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<HttpTypes.AdminExportProductRequest>,
|
||||
req: AuthenticatedMedusaRequest,
|
||||
res: MedusaResponse<HttpTypes.AdminExportProductResponse>
|
||||
) => {
|
||||
const selectFields = remapKeysForProduct(req.remoteQueryConfig.fields ?? [])
|
||||
|
||||
@@ -4,18 +4,14 @@ import {
|
||||
MedusaResponse,
|
||||
} from "../../../../../../types/routing"
|
||||
import { BatchMethodRequest, HttpTypes } from "@medusajs/framework/types"
|
||||
import {
|
||||
AdminCreatePromotionRuleType,
|
||||
AdminUpdatePromotionRuleType,
|
||||
} from "../../../validators"
|
||||
import { RuleType } from "@medusajs/framework/utils"
|
||||
import { refetchBatchRules } from "../../../helpers"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<
|
||||
BatchMethodRequest<
|
||||
AdminCreatePromotionRuleType,
|
||||
AdminUpdatePromotionRuleType
|
||||
HttpTypes.AdminCreatePromotionRule,
|
||||
HttpTypes.AdminUpdatePromotionRule
|
||||
>
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminPromotionRuleBatchResponse>
|
||||
|
||||
@@ -4,18 +4,14 @@ import {
|
||||
MedusaResponse,
|
||||
} from "../../../../../../types/routing"
|
||||
import { BatchMethodRequest, HttpTypes } from "@medusajs/framework/types"
|
||||
import {
|
||||
AdminCreatePromotionRuleType,
|
||||
AdminUpdatePromotionRuleType,
|
||||
} from "../../../validators"
|
||||
import { RuleType } from "@medusajs/framework/utils"
|
||||
import { refetchBatchRules } from "../../../helpers"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<
|
||||
BatchMethodRequest<
|
||||
AdminCreatePromotionRuleType,
|
||||
AdminUpdatePromotionRuleType
|
||||
HttpTypes.AdminCreatePromotionRule,
|
||||
HttpTypes.AdminUpdatePromotionRule
|
||||
>
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminPromotionRuleBatchResponse>
|
||||
|
||||
@@ -4,18 +4,14 @@ import {
|
||||
MedusaResponse,
|
||||
} from "../../../../../../types/routing"
|
||||
import { BatchMethodRequest, HttpTypes } from "@medusajs/framework/types"
|
||||
import {
|
||||
AdminCreatePromotionRuleType,
|
||||
AdminUpdatePromotionRuleType,
|
||||
} from "../../../validators"
|
||||
import { RuleType } from "@medusajs/framework/utils"
|
||||
import { refetchBatchRules } from "../../../helpers"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<
|
||||
BatchMethodRequest<
|
||||
AdminCreatePromotionRuleType,
|
||||
AdminUpdatePromotionRuleType
|
||||
HttpTypes.AdminCreatePromotionRule,
|
||||
HttpTypes.AdminUpdatePromotionRule
|
||||
>
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminPromotionRuleBatchResponse>
|
||||
|
||||
@@ -3,18 +3,14 @@ import {
|
||||
MedusaResponse,
|
||||
} from "../../../../../../types/routing"
|
||||
import { BatchMethodRequest, HttpTypes } from "@medusajs/framework/types"
|
||||
import {
|
||||
AdminCreateShippingOptionRuleType,
|
||||
AdminUpdateShippingOptionRuleType,
|
||||
} from "../../../validators"
|
||||
import { refetchBatchRules } from "../../../helpers"
|
||||
import { batchShippingOptionRulesWorkflow } from "@medusajs/core-flows"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<
|
||||
BatchMethodRequest<
|
||||
AdminCreateShippingOptionRuleType,
|
||||
AdminUpdateShippingOptionRuleType
|
||||
HttpTypes.AdminCreateShippingOptionRule,
|
||||
HttpTypes.AdminUpdateShippingOptionRule
|
||||
>
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminUpdateShippingOptionRulesResponse>
|
||||
|
||||
@@ -7,7 +7,6 @@ const defaultStoreCustomersFields = [
|
||||
"phone",
|
||||
"metadata",
|
||||
"has_account",
|
||||
"created_by",
|
||||
"deleted_at",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
export const defaultStoreOrderFields = [
|
||||
"id",
|
||||
"status",
|
||||
"version",
|
||||
"summary",
|
||||
"display_id",
|
||||
"total",
|
||||
@@ -16,7 +15,6 @@ export const defaultStoreOrderFields = [
|
||||
export const defaultStoreRetrieveOrderFields = [
|
||||
"id",
|
||||
"status",
|
||||
"version",
|
||||
"summary",
|
||||
"currency_code",
|
||||
"display_id",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { z } from "zod"
|
||||
import {
|
||||
GetProductsParams,
|
||||
ProductStatusEnum,
|
||||
transformProductParams,
|
||||
} from "../../utils/common-validators"
|
||||
import {
|
||||
@@ -32,7 +31,6 @@ export const StoreGetProductVariantsParams = createFindParams({
|
||||
z.object({
|
||||
q: z.string().optional(),
|
||||
id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
status: ProductStatusEnum.array().optional(),
|
||||
options: z.object({ value: z.string(), option_id: z.string() }).optional(),
|
||||
created_at: createOperatorMap().optional(),
|
||||
updated_at: createOperatorMap().optional(),
|
||||
@@ -58,7 +56,6 @@ export const StoreGetProductsParams = createFindParams({
|
||||
|
||||
variants: z
|
||||
.object({
|
||||
status: ProductStatusEnum.array().optional(),
|
||||
options: z
|
||||
.object({ value: z.string(), option_id: z.string() })
|
||||
.optional(),
|
||||
|
||||
Reference in New Issue
Block a user