feat(oas): declare x-expanded-relations - Store (#3482)

* feat(oas): declare x-expanded-relations - Store

* fixup! feat(oas): declare x-expanded-relations - Store

* fixup! feat(oas): declare x-expanded-relations - Store

* fixup! feat(oas): declare x-expanded-relations - Store

* fixup! feat(oas): declare x-expanded-relations - Store

* chore(changeset): patch

* fix(tests): update store auth integration test

* fix: pr feedback

* fix(test): match response code
This commit is contained in:
Patrick authored and GitHub committed 2023-03-16 09:08:20 +01:00
1 parent da0787bd11
commit 522e306e2e
31 files changed
+448 -52

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
---
"@medusajs/client-types": patch
"@medusajs/medusa": patch
---
feat(oas): declare x-expanded-relations - Store
@@ -1,18 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`/store/auth creates store session correctly 1`] = `
Object {
"billing_address_id": null,
"created_at": Any<String>,
"deleted_at": null,
"email": "test@testesen.dk",
"first_name": "test",
"has_account": true,
"id": Any<String>,
"last_name": "testesen",
"metadata": null,
"orders": Array [],
"phone": null,
"updated_at": Any<String>,
}
`;
+12 -9
View File
@@ -49,15 +49,18 @@ describe("/store/auth", () => {
expect(response.status).toEqual(200) expect(response.status).toEqual(200)
expect(response.data.customer.password_hash).toEqual(undefined) expect(response.data.customer.password_hash).toEqual(undefined)
expect(response.data.customer).toMatchSnapshot({ expect(response.data.customer).toEqual(
id: expect.any(String), expect.objectContaining({
created_at: expect.any(String), id: expect.any(String),
updated_at: expect.any(String), created_at: expect.any(String),
first_name: "test", updated_at: expect.any(String),
last_name: "testesen", first_name: "test",
phone: null, last_name: "testesen",
email: "test@testesen.dk", phone: null,
}) email: "test@testesen.dk",
shipping_addresses: expect.arrayContaining([]),
})
)
}) })
describe("Store session management", () => { describe("Store session management", () => {
@@ -440,7 +440,7 @@ describe("/store/payment-collections", () => {
}) })
) )
expect(response.status).toEqual(207) expect(response.status).toEqual(200)
}) })
}) })
}) })
@@ -4,6 +4,7 @@ import { EntityManager } from "typeorm"
import AuthService from "../../../../services/auth" import AuthService from "../../../../services/auth"
import CustomerService from "../../../../services/customer" import CustomerService from "../../../../services/customer"
import { validator } from "../../../../utils/validator" import { validator } from "../../../../utils/validator"
import { defaultRelations } from "."
/** /**
* @oas [post] /store/auth * @oas [post] /store/auth
@@ -91,7 +92,7 @@ export default async (req, res) => {
const customerService: CustomerService = req.scope.resolve("customerService") const customerService: CustomerService = req.scope.resolve("customerService")
const customer = await customerService.retrieve(result.customer?.id || "", { const customer = await customerService.retrieve(result.customer?.id || "", {
relations: ["orders", "orders.items"], relations: defaultRelations,
}) })
res.json({ customer }) res.json({ customer })
@@ -1,4 +1,5 @@
import CustomerService from "../../../../services/customer" import CustomerService from "../../../../services/customer"
import { defaultRelations } from "."
/** /**
* @oas [get] /store/auth * @oas [get] /store/auth
@@ -52,7 +53,7 @@ export default async (req, res) => {
const customerService: CustomerService = req.scope.resolve("customerService") const customerService: CustomerService = req.scope.resolve("customerService")
const customer = await customerService.retrieve(req.user.customer_id, { const customer = await customerService.retrieve(req.user.customer_id, {
relations: ["shipping_addresses", "orders", "orders.items"], relations: defaultRelations,
}) })
res.json({ customer }) res.json({ customer })
@@ -19,9 +19,17 @@ export default (app) => {
return app return app
} }
export const defaultRelations = ["orders", "orders.items", "shipping_addresses"]
/** /**
* @schema StoreAuthRes * @schema StoreAuthRes
* type: object * type: object
* x-expanded-relations:
* field: customer
* relations:
* - orders
* - orders.items
* - shipping_addresses
* required: * required:
* - customer * - customer
* properties: * properties:
@@ -171,15 +171,24 @@ export const defaultStoreCartRelations = [
* - region.payment_providers * - region.payment_providers
* - shipping_address * - shipping_address
* - shipping_methods * - shipping_methods
* - shipping_methods.shipping_option * eager:
* implicit:
* - items.tax_lines
* - items.variant.product
* - region.fulfillment_providers * - region.fulfillment_providers
* - region.payment_providers * - region.payment_providers
* - region.tax_rates
* - shipping_methods.shipping_option * - shipping_methods.shipping_option
* - shipping_methods.tax_lines * implicit:
* - items
* - items.variant
* - items.variant.product
* - items.tax_lines
* - items.adjustments
* - gift_cards
* - discounts
* - discounts.rule
* - shipping_methods
* - shipping_methods.tax_lines
* - shipping_address
* - region
* - region.tax_rates
* totals: * totals:
* - discount_total * - discount_total
* - gift_card_tax_total * - gift_card_tax_total
@@ -22,11 +22,12 @@ export default (app) => {
return app return app
} }
export const defaultStoreCollectionRelations = ["products"] export const defaultStoreCollectionRelations = []
export const allowedFields = [ export const allowedFields = [
"id", "id",
"title", "title",
"handle", "handle",
"products",
"metadata", "metadata",
"created_at", "created_at",
"updated_at", "updated_at",
@@ -13,6 +13,15 @@ import { Type } from "class-transformer"
* - (query) offset=0 {integer} The number of collections to skip before starting to collect the collections set * - (query) offset=0 {integer} The number of collections to skip before starting to collect the collections set
* - (query) limit=10 {integer} The number of collections to return * - (query) limit=10 {integer} The number of collections to return
* - in: query * - in: query
* name: handle
* style: form
* explode: false
* description: Filter by the collection handle
* schema:
* type: array
* items:
* type: string
* - in: query
* name: created_at * name: created_at
* description: Date comparison for when resulting collections were created. * description: Date comparison for when resulting collections were created.
* schema: * schema:
@@ -114,6 +114,11 @@ export const allowedStoreCustomersFields = [
/** /**
* @schema StoreCustomersRes * @schema StoreCustomersRes
* type: object * type: object
* x-expanded-relations:
* field: customer
* relations:
* - billing_address
* - shipping_addresses
* required: * required:
* - customer * - customer
* properties: * properties:
@@ -124,9 +129,103 @@ export type StoreCustomersRes = {
customer: Omit<Customer, "password_hash"> customer: Omit<Customer, "password_hash">
} }
/**
* @schema StoreCustomersResetPasswordRes
* type: object
* required:
* - customer
* properties:
* customer:
* $ref: "#/components/schemas/Customer"
*/
export type StoreCustomersResetPasswordRes = {
customer: Omit<Customer, "password_hash">
}
/** /**
* @schema StoreCustomersListOrdersRes * @schema StoreCustomersListOrdersRes
* type: object * type: object
* x-expanded-relations:
* field: orders
* relations:
* - customer
* - discounts
* - discounts.rule
* - fulfillments
* - fulfillments.tracking_links
* - items
* - items.variant
* - payments
* - region
* - shipping_address
* - shipping_methods
* eager:
* - region.fulfillment_providers
* - region.payment_providers
* - shipping_methods.shipping_option
* implicit:
* - claims
* - claims.additional_items
* - claims.additional_items.adjustments
* - claims.additional_items.refundable
* - claims.additional_items.tax_lines
* - customer
* - discounts
* - discounts.rule
* - gift_card_transactions
* - gift_card_transactions.gift_card
* - gift_cards
* - items
* - items.adjustments
* - items.refundable
* - items.tax_lines
* - items.variant
* - items.variant.product
* - refunds
* - region
* - shipping_address
* - shipping_methods
* - shipping_methods.tax_lines
* - swaps
* - swaps.additional_items
* - swaps.additional_items.adjustments
* - swaps.additional_items.refundable
* - swaps.additional_items.tax_lines
* totals:
* - discount_total
* - gift_card_tax_total
* - gift_card_total
* - paid_total
* - refundable_amount
* - refunded_total
* - shipping_total
* - subtotal
* - tax_total
* - total
* - claims.additional_items.discount_total
* - claims.additional_items.gift_card_total
* - claims.additional_items.original_tax_total
* - claims.additional_items.original_total
* - claims.additional_items.refundable
* - claims.additional_items.subtotal
* - claims.additional_items.tax_total
* - claims.additional_items.total
* - items.discount_total
* - items.gift_card_total
* - items.original_tax_total
* - items.original_total
* - items.refundable
* - items.subtotal
* - items.tax_total
* - items.total
* - swaps.additional_items.discount_total
* - swaps.additional_items.gift_card_total
* - swaps.additional_items.original_tax_total
* - swaps.additional_items.original_total
* - swaps.additional_items.refundable
* - swaps.additional_items.subtotal
* - swaps.additional_items.tax_total
* - swaps.additional_items.total
* required: * required:
* - orders * - orders
* - count * - count
@@ -49,7 +49,7 @@ import { EntityManager } from "typeorm"
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: "#/components/schemas/StoreCustomersRes" * $ref: "#/components/schemas/StoreCustomersResetPasswordRes"
* "400": * "400":
* $ref: "#/components/responses/400_error" * $ref: "#/components/responses/400_error"
* "401": * "401":
@@ -44,6 +44,41 @@ export default (app) => {
/** /**
* @schema StoreOrderEditsRes * @schema StoreOrderEditsRes
* type: object * type: object
* x-expanded-relations:
* field: order_edit
* relations:
* - changes
* - changes.line_item
* - changes.line_item.variant
* - changes.original_line_item
* - changes.original_line_item.variant
* - items
* - items.adjustments
* - items.tax_lines
* - items.variant
* - payment_collection
* implicit:
* - items
* - items.tax_lines
* - items.adjustments
* - items.variant
* totals:
* - difference_due
* - discount_total
* - gift_card_tax_total
* - gift_card_total
* - shipping_total
* - subtotal
* - tax_total
* - total
* - items.discount_total
* - items.gift_card_total
* - items.original_tax_total
* - items.original_total
* - items.refundable
* - items.subtotal
* - items.tax_total
* - items.total
* required: * required:
* - order_edit * - order_edit
* properties: * properties:
@@ -131,6 +131,86 @@ export const allowedStoreOrdersFields = [
* type: object * type: object
* required: * required:
* - order * - order
* x-expanded-relations:
* field: order
* relations:
* - customer
* - discounts
* - discounts.rule
* - fulfillments
* - fulfillments.tracking_links
* - items
* - items.variant
* - payments
* - region
* - shipping_address
* - shipping_methods
* eager:
* - fulfillments.items
* - region.fulfillment_providers
* - region.payment_providers
* - shipping_methods.shipping_option
* implicit:
* - claims
* - claims.additional_items
* - claims.additional_items.adjustments
* - claims.additional_items.refundable
* - claims.additional_items.tax_lines
* - discounts
* - discounts.rule
* - gift_card_transactions
* - gift_card_transactions.gift_card
* - gift_cards
* - items
* - items.adjustments
* - items.refundable
* - items.tax_lines
* - items.variant
* - items.variant.product
* - refunds
* - region
* - shipping_methods
* - shipping_methods.tax_lines
* - swaps
* - swaps.additional_items
* - swaps.additional_items.adjustments
* - swaps.additional_items.refundable
* - swaps.additional_items.tax_lines
* totals:
* - discount_total
* - gift_card_tax_total
* - gift_card_total
* - paid_total
* - refundable_amount
* - refunded_total
* - shipping_total
* - subtotal
* - tax_total
* - total
* - claims.additional_items.discount_total
* - claims.additional_items.gift_card_total
* - claims.additional_items.original_tax_total
* - claims.additional_items.original_total
* - claims.additional_items.refundable
* - claims.additional_items.subtotal
* - claims.additional_items.tax_total
* - claims.additional_items.total
* - items.discount_total
* - items.gift_card_total
* - items.original_tax_total
* - items.original_total
* - items.refundable
* - items.subtotal
* - items.tax_total
* - items.total
* - swaps.additional_items.discount_total
* - swaps.additional_items.gift_card_total
* - swaps.additional_items.original_tax_total
* - swaps.additional_items.original_total
* - swaps.additional_items.refundable
* - swaps.additional_items.subtotal
* - swaps.additional_items.tax_total
* - swaps.additional_items.total
* properties: * properties:
* order: * order:
* $ref: "#/components/schemas/Order" * $ref: "#/components/schemas/Order"
@@ -72,7 +72,7 @@ export default async (req, res) => {
req.request_context req.request_context
) )
res.status(207).json({ payment_collection }) res.status(200).json({ payment_collection })
} }
/** /**
@@ -74,6 +74,14 @@ export const defaultPaymentCollectionRelations = ["region", "payment_sessions"]
/** /**
* @schema StorePaymentCollectionsRes * @schema StorePaymentCollectionsRes
* type: object * type: object
* x-expanded-relations:
* field: payment_collection
* relations:
* - payment_sessions
* - region
* eager:
* - region.fulfillment_providers
* - region.payment_providers
* required: * required:
* - payment_collection * - payment_collection
* properties: * properties:
@@ -74,6 +74,11 @@ export const allowedStoreProductCategoryFields = [
/** /**
* @schema StoreGetProductCategoriesCategoryRes * @schema StoreGetProductCategoriesCategoryRes
* type: object * type: object
* x-expanded-relations:
* field: product_category
* relations:
* - category_children
* - parent_category
* required: * required:
* - product_category * - product_category
* properties: * properties:
@@ -87,6 +92,11 @@ export type StoreGetProductCategoriesCategoryRes = {
/** /**
* @schema StoreGetProductCategoriesRes * @schema StoreGetProductCategoriesRes
* type: object * type: object
* x-expanded-relations:
* field: product_categories
* relations:
* - category_children
* - parent_category
* required: * required:
* - product_categories * - product_categories
* - count * - count
@@ -110,6 +110,18 @@ export * from "./search"
/** /**
* @schema StoreProductsRes * @schema StoreProductsRes
* type: object * type: object
* x-expanded-relations:
* field: product
* relations:
* - collection
* - images
* - options
* - options.values
* - tags
* - type
* - variants
* - variants.options
* - variants.prices
* required: * required:
* - product * - product
* properties: * properties:
@@ -139,6 +151,18 @@ export type StorePostSearchRes = {
/** /**
* @schema StoreProductsListRes * @schema StoreProductsListRes
* type: object * type: object
* x-expanded-relations:
* field: products
* relations:
* - collection
* - images
* - options
* - options.values
* - tags
* - type
* - variants
* - variants.options
* - variants.prices
* required: * required:
* - products * - products
* - count * - count
@@ -1,4 +1,5 @@
import RegionService from "../../../../services/region" import RegionService from "../../../../services/region"
import { defaultRelations } from "."
/** /**
* @oas [get] /store/regions/{id} * @oas [get] /store/regions/{id}
@@ -49,7 +50,7 @@ export default async (req, res) => {
const regionService: RegionService = req.scope.resolve("regionService") const regionService: RegionService = req.scope.resolve("regionService")
const region = await regionService.retrieve(region_id, { const region = await regionService.retrieve(region_id, {
relations: ["countries", "payment_providers", "fulfillment_providers"], relations: defaultRelations,
}) })
res.json({ region }) res.json({ region })
@@ -13,6 +13,12 @@ export default (app) => {
return app return app
} }
export const defaultRelations = [
"countries",
"payment_providers",
"fulfillment_providers",
]
/** /**
* @schema StoreRegionsListRes * @schema StoreRegionsListRes
* type: object * type: object
@@ -22,6 +28,9 @@ export default (app) => {
* - countries * - countries
* - payment_providers * - payment_providers
* - fulfillment_providers * - fulfillment_providers
* eager:
* - payment_providers
* - fulfillment_providers
* required: * required:
* - regions * - regions
* properties: * properties:
@@ -43,6 +52,9 @@ export type StoreRegionsListRes = {
* - countries * - countries
* - payment_providers * - payment_providers
* - fulfillment_providers * - fulfillment_providers
* eager:
* - payment_providers
* - fulfillment_providers
* required: * required:
* - region * - region
* properties: * properties:
@@ -5,6 +5,7 @@ import RegionService from "../../../../services/region"
import { Type } from "class-transformer" import { Type } from "class-transformer"
import { omit } from "lodash" import { omit } from "lodash"
import { validator } from "../../../../utils/validator" import { validator } from "../../../../utils/validator"
import { defaultRelations } from "."
/** /**
* @oas [get] /store/regions * @oas [get] /store/regions
@@ -104,7 +105,7 @@ export default async (req, res) => {
const filterableFields = omit(validated, ["limit", "offset"]) const filterableFields = omit(validated, ["limit", "offset"])
const listConfig = { const listConfig = {
relations: ["countries", "payment_providers", "fulfillment_providers"], relations: defaultRelations,
skip: offset, skip: offset,
take: limit, take: limit,
} }
@@ -39,6 +39,11 @@ export const defaultStoreReturnReasonRelations: (keyof ReturnReason)[] = [
/** /**
* @schema StoreReturnReasonsListRes * @schema StoreReturnReasonsListRes
* type: object * type: object
* x-expanded-relations:
* field: return_reasons
* relations:
* - parent_return_reason
* - return_reason_children
* required: * required:
* - return_reasons * - return_reasons
* properties: * properties:
@@ -54,6 +59,11 @@ export type StoreReturnReasonsListRes = {
/** /**
* @schema StoreReturnReasonsRes * @schema StoreReturnReasonsRes
* type: object * type: object
* x-expanded-relations:
* field: return_reason
* relations:
* - parent_return_reason
* - return_reason_children
* required: * required:
* - return_reason * - return_reason
* properties: * properties:
@@ -15,6 +15,7 @@ import EventBusService from "../../../../services/event-bus"
import IdempotencyKeyService from "../../../../services/idempotency-key" import IdempotencyKeyService from "../../../../services/idempotency-key"
import ReturnService from "../../../../services/return" import ReturnService from "../../../../services/return"
import { validator } from "../../../../utils/validator" import { validator } from "../../../../utils/validator"
import { defaultRelations } from "."
/** /**
* @oas [post] /store/returns * @oas [post] /store/returns
@@ -172,7 +173,7 @@ export default async (req, res) => {
idempotency_key: idempotencyKey.idempotency_key, idempotency_key: idempotencyKey.idempotency_key,
}, },
{ {
relations: ["items", "items.reason"], relations: defaultRelations,
} }
) )
if (!returnOrders.length) { if (!returnOrders.length) {
@@ -12,9 +12,18 @@ export default (app) => {
return app return app
} }
export const defaultRelations = ["items", "items.reason"]
/** /**
* @schema StoreReturnsRes * @schema StoreReturnsRes
* type: object * type: object
* x-expanded-relations:
* field: return
* relations:
* - items
* - items.reason
* eager:
* - items
* required: * required:
* - return * - return
* properties: * properties:
@@ -1,6 +1,6 @@
import { ShippingOption } from "./../../../../"
import { Router } from "express" import { Router } from "express"
import middlewares from "../../../middlewares" import middlewares from "../../../middlewares"
import { PricedShippingOption } from "../../../../types/pricing"
const route = Router() const route = Router()
@@ -16,19 +16,45 @@ export default (app) => {
return app return app
} }
export const defaultRelations = ["requirements"]
/** /**
* @schema StoreShippingOptionsListRes * @schema StoreShippingOptionsListRes
* type: object * type: object
* x-expanded-relations:
* field: shipping_options
* relations:
* - requirements
* required: * required:
* - shipping_options * - shipping_options
* properties: * properties:
* shipping_options: * shipping_options:
* type: array * type: array
* items: * items:
* $ref: "#/components/schemas/ShippingOption" * $ref: "#/components/schemas/PricedShippingOption"
*/ */
export type StoreShippingOptionsListRes = { export type StoreShippingOptionsListRes = {
shipping_options: ShippingOption[] shipping_options: PricedShippingOption[]
}
/**
* @schema StoreCartShippingOptionsListRes
* type: object
* x-expanded-relations:
* field: shipping_options
* implicit:
* - profile
* - requirements
* required:
* - shipping_options
* properties:
* shipping_options:
* type: array
* items:
* $ref: "#/components/schemas/PricedShippingOption"
*/
export type StoreCartShippingOptionsListRes = {
shipping_options: PricedShippingOption[]
} }
export * from "./list-options" export * from "./list-options"
@@ -2,6 +2,7 @@ import { IsBooleanString, IsOptional, IsString } from "class-validator"
import { PricingService, ProductService } from "../../../../services" import { PricingService, ProductService } from "../../../../services"
import ShippingOptionService from "../../../../services/shipping-option" import ShippingOptionService from "../../../../services/shipping-option"
import { validator } from "../../../../utils/validator" import { validator } from "../../../../utils/validator"
import { defaultRelations } from "."
/** /**
* @oas [get] /store/shipping-options * @oas [get] /store/shipping-options
@@ -80,7 +81,7 @@ export default async (req, res) => {
} }
const options = await shippingOptionService.list(query, { const options = await shippingOptionService.list(query, {
relations: ["requirements"], relations: defaultRelations,
}) })
const data = await pricingService.setShippingOptionPrices(options) const data = await pricingService.setShippingOptionPrices(options)
@@ -32,7 +32,7 @@ import ShippingProfileService from "../../../../services/shipping-profile"
* content: * content:
* application/json: * application/json:
* schema: * schema:
* $ref: "#/components/schemas/StoreShippingOptionsListRes" * $ref: "#/components/schemas/StoreCartShippingOptionsListRes"
* "400": * "400":
* $ref: "#/components/responses/400_error" * $ref: "#/components/responses/400_error"
* "404": * "404":
@@ -1,4 +1,5 @@
import SwapService from "../../../../services/swap" import SwapService from "../../../../services/swap"
import { defaultStoreSwapRelations } from "."
/** /**
* @oas [get] /store/swaps/{cart_id} * @oas [get] /store/swaps/{cart_id}
@@ -48,7 +49,10 @@ export default async (req, res) => {
const swapService: SwapService = req.scope.resolve("swapService") const swapService: SwapService = req.scope.resolve("swapService")
const swap = await swapService.retrieveByCartId(cart_id) const swap = await swapService.retrieveByCartId(
cart_id,
defaultStoreSwapRelations
)
res.json({ swap }) res.json({ swap })
} }
@@ -49,6 +49,21 @@ export const defaultStoreSwapFields: FindConfig<Swap>["select"] = [
/** /**
* @schema StoreSwapsRes * @schema StoreSwapsRes
* type: object * type: object
* x-expanded-relations:
* field: swap
* relations:
* - additional_items
* - additional_items.variant
* - cart
* - fulfillments
* - order
* - payment
* - return_order
* - return_order.shipping_method
* - shipping_address
* - shipping_methods
* eager:
* - fulfillments.items
* required: * required:
* - swap * - swap
* properties: * properties:
@@ -1,6 +1,5 @@
import { Router } from "express" import { Router } from "express"
import { PricedVariant } from "../../../../types/pricing"
import { ProductVariant } from "../../../../"
import middlewares from "../../../middlewares" import middlewares from "../../../middlewares"
import { extendRequestParams } from "../../../middlewares/publishable-api-key/extend-request-params" import { extendRequestParams } from "../../../middlewares/publishable-api-key/extend-request-params"
import { validateSalesChannelParam } from "../../../middlewares/publishable-api-key/validate-sales-channel-param" import { validateSalesChannelParam } from "../../../middlewares/publishable-api-key/validate-sales-channel-param"
@@ -24,6 +23,12 @@ export const defaultStoreVariantRelations = ["prices", "options", "product"]
/** /**
* @schema StoreVariantsRes * @schema StoreVariantsRes
* type: object * type: object
* x-expanded-relations:
* field: variant
* relations:
* - prices
* - options
* - product
* required: * required:
* - variant * - variant
* properties: * properties:
@@ -31,12 +36,18 @@ export const defaultStoreVariantRelations = ["prices", "options", "product"]
* $ref: "#/components/schemas/PricedVariant" * $ref: "#/components/schemas/PricedVariant"
*/ */
export type StoreVariantsRes = { export type StoreVariantsRes = {
variant: ProductVariant variant: PricedVariant
} }
/** /**
* @schema StoreVariantsListRes * @schema StoreVariantsListRes
* type: object * type: object
* x-expanded-relations:
* field: variants
* relations:
* - prices
* - options
* - product
* required: * required:
* - variants * - variants
* properties: * properties:
@@ -46,7 +57,7 @@ export type StoreVariantsRes = {
* $ref: "#/components/schemas/PricedVariant" * $ref: "#/components/schemas/PricedVariant"
*/ */
export type StoreVariantsListRes = { export type StoreVariantsListRes = {
variants: ProductVariant[] variants: PricedVariant[]
} }
export * from "./list-variants" export * from "./list-variants"
+29
View File
@@ -31,6 +31,35 @@ export type ShippingOptionPricing = {
tax_amount: number tax_amount: number
} }
/** @schema PricedShippingOption
* title: "Priced Shipping Option"
* type: object
* allOf:
* - $ref: "#/components/schemas/ShippingOption"
* - type: object
* properties:
* price_incl_tax:
* type: number
* description: Price including taxes
* tax_rates:
* type: array
* description: An array of applied tax rates
* items:
* type: object
* properties:
* rate:
* type: number
* description: The tax rate value
* name:
* type: string
* description: The name of the tax rate
* code:
* type: string
* description: The code of the tax rate
* tax_amount:
* type: number
* description: The taxes applied.
*/
export type PricedShippingOption = Partial<ShippingOption> & export type PricedShippingOption = Partial<ShippingOption> &
ShippingOptionPricing ShippingOptionPricing