feat(oas): declare x-expanded-relations - Admin (#3483)
* feat(oas): declare x-expanded-relations - Admin * fixup! feat(oas): declare x-expanded-relations - Admin * fixup! feat(oas): declare x-expanded-relations - Admin * fixup! feat(oas): declare x-expanded-relations - Admin * fixup! feat(oas): declare x-expanded-relations - Admin * fixup! feat(oas): declare x-expanded-relations - Admin * feat: move defaultAdminOrdersRelations and Fields to types directory * chore(changeset): patch * fix(test): update unit tests --------- Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
1 parent
522e306e2e
commit
13f40d7217
49 files changed
+854
-127
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/client-types": patch
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat(oas): declare x-expanded-relations - Admin
|
||||||
@@ -3,6 +3,7 @@ import { Request, Response } from "express"
|
|||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
|
|
||||||
import ProductCollectionService from "../../../../services/product-collection"
|
import ProductCollectionService from "../../../../services/product-collection"
|
||||||
|
import { defaultAdminCollectionsRelations } from "./index"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [post] /admin/collections/{id}/products/batch
|
* @oas [post] /admin/collections/{id}/products/batch
|
||||||
@@ -67,12 +68,16 @@ export default async (req: Request, res: Response) => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const manager: EntityManager = req.scope.resolve("manager")
|
const manager: EntityManager = req.scope.resolve("manager")
|
||||||
const collection = await manager.transaction(async (transactionManager) => {
|
const updated = await manager.transaction(async (transactionManager) => {
|
||||||
return await productCollectionService
|
return await productCollectionService
|
||||||
.withTransaction(transactionManager)
|
.withTransaction(transactionManager)
|
||||||
.addProducts(id, validatedBody.product_ids)
|
.addProducts(id, validatedBody.product_ids)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const collection = await productCollectionService.retrieve(updated.id, {
|
||||||
|
relations: defaultAdminCollectionsRelations,
|
||||||
|
})
|
||||||
|
|
||||||
res.status(200).json({ collection })
|
res.status(200).json({ collection })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { IsNotEmpty, IsObject, IsOptional, IsString } from "class-validator"
|
|||||||
import ProductCollectionService from "../../../../services/product-collection"
|
import ProductCollectionService from "../../../../services/product-collection"
|
||||||
import { Request, Response } from "express"
|
import { Request, Response } from "express"
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
|
import { defaultAdminCollectionsRelations } from "."
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [post] /admin/collections
|
* @oas [post] /admin/collections
|
||||||
@@ -77,7 +78,9 @@ export default async (req: Request, res: Response) => {
|
|||||||
.create(validatedBody)
|
.create(validatedBody)
|
||||||
})
|
})
|
||||||
|
|
||||||
const collection = await productCollectionService.retrieve(created.id)
|
const collection = await productCollectionService.retrieve(created.id, {
|
||||||
|
relations: defaultAdminCollectionsRelations,
|
||||||
|
})
|
||||||
|
|
||||||
res.status(200).json({ collection })
|
res.status(200).json({ collection })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,6 +149,10 @@ export type AdminDeleteProductsFromCollectionRes = {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminCollectionsRes
|
* @schema AdminCollectionsRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: collection
|
||||||
|
* relations:
|
||||||
|
* - products
|
||||||
* required:
|
* required:
|
||||||
* - collection
|
* - collection
|
||||||
* properties:
|
* properties:
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { IsObject, IsOptional, IsString } from "class-validator"
|
|||||||
import { Request, Response } from "express"
|
import { Request, Response } from "express"
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
import ProductCollectionService from "../../../../services/product-collection"
|
import ProductCollectionService from "../../../../services/product-collection"
|
||||||
|
import { defaultAdminCollectionsRelations } from "."
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [post] /admin/collections/{id}
|
* @oas [post] /admin/collections/{id}
|
||||||
@@ -82,7 +83,9 @@ export default async (req: Request, res: Response) => {
|
|||||||
.update(id, validatedBody)
|
.update(id, validatedBody)
|
||||||
})
|
})
|
||||||
|
|
||||||
const collection = await productCollectionService.retrieve(updated.id)
|
const collection = await productCollectionService.retrieve(updated.id, {
|
||||||
|
relations: defaultAdminCollectionsRelations,
|
||||||
|
})
|
||||||
|
|
||||||
res.status(200).json({ collection })
|
res.status(200).json({ collection })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ export default (app) => {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminCustomersRes
|
* @schema AdminCustomersRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: customer
|
||||||
|
* relations:
|
||||||
|
* - orders
|
||||||
|
* - shipping_addresses
|
||||||
* required:
|
* required:
|
||||||
* - customer
|
* - customer
|
||||||
* properties:
|
* properties:
|
||||||
|
|||||||
@@ -223,6 +223,16 @@ export const defaultAdminDiscountConditionRelations = ["discount_rule"]
|
|||||||
/**
|
/**
|
||||||
* @schema AdminDiscountsRes
|
* @schema AdminDiscountsRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: discount
|
||||||
|
* relations:
|
||||||
|
* - parent_discount
|
||||||
|
* - regions
|
||||||
|
* - rule
|
||||||
|
* - rule.conditions
|
||||||
|
* eager:
|
||||||
|
* - regions.fulfillment_providers
|
||||||
|
* - regions.payment_providers
|
||||||
* required:
|
* required:
|
||||||
* - discount
|
* - discount
|
||||||
* properties:
|
* properties:
|
||||||
@@ -236,6 +246,10 @@ export type AdminDiscountsRes = {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminDiscountConditionsRes
|
* @schema AdminDiscountConditionsRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: discount_condition
|
||||||
|
* relations:
|
||||||
|
* - discount_rule
|
||||||
* required:
|
* required:
|
||||||
* - discount_condition
|
* - discount_condition
|
||||||
* properties:
|
* properties:
|
||||||
@@ -299,6 +313,13 @@ export type AdminDiscountConditionsDeleteRes = DeleteResponse & {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminDiscountsListRes
|
* @schema AdminDiscountsListRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: discounts
|
||||||
|
* relations:
|
||||||
|
* - parent_discount
|
||||||
|
* - regions
|
||||||
|
* - rule
|
||||||
|
* - rule.conditions
|
||||||
* required:
|
* required:
|
||||||
* - discounts
|
* - discounts
|
||||||
* - count
|
* - count
|
||||||
|
|||||||
@@ -103,10 +103,67 @@ export const defaultAdminDraftOrdersFields: (keyof DraftOrder)[] = [
|
|||||||
export type AdminPostDraftOrdersDraftOrderRegisterPaymentRes = {
|
export type AdminPostDraftOrdersDraftOrderRegisterPaymentRes = {
|
||||||
order: Order
|
order: Order
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @schema AdminDraftOrdersRes
|
* @schema AdminDraftOrdersRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: draft_order
|
||||||
|
* relations:
|
||||||
|
* - order
|
||||||
|
* - cart
|
||||||
|
* - cart.items
|
||||||
|
* - cart.items.adjustments
|
||||||
|
* - cart.billing_address
|
||||||
|
* - cart.customer
|
||||||
|
* - cart.discounts
|
||||||
|
* - cart.discounts.rule
|
||||||
|
* - cart.items
|
||||||
|
* - cart.items.adjustments
|
||||||
|
* - cart.payment
|
||||||
|
* - cart.payment_sessions
|
||||||
|
* - cart.region
|
||||||
|
* - cart.region.payment_providers
|
||||||
|
* - cart.shipping_address
|
||||||
|
* - cart.shipping_methods
|
||||||
|
* - cart.shipping_methods.shipping_option
|
||||||
|
* eager:
|
||||||
|
* - cart.region.fulfillment_providers
|
||||||
|
* - cart.region.payment_providers
|
||||||
|
* - cart.shipping_methods.shipping_option
|
||||||
|
* implicit:
|
||||||
|
* - cart.discounts
|
||||||
|
* - cart.discounts.rule
|
||||||
|
* - cart.gift_cards
|
||||||
|
* - cart.items
|
||||||
|
* - cart.items.adjustments
|
||||||
|
* - cart.items.tax_lines
|
||||||
|
* - cart.items.variant
|
||||||
|
* - cart.items.variant.product
|
||||||
|
* - cart.region
|
||||||
|
* - cart.region.tax_rates
|
||||||
|
* - cart.shipping_address
|
||||||
|
* - cart.shipping_methods
|
||||||
|
* - cart.shipping_methods.tax_lines
|
||||||
|
* totals:
|
||||||
|
* - cart.discount_total
|
||||||
|
* - cart.gift_card_tax_total
|
||||||
|
* - cart.gift_card_total
|
||||||
|
* - cart.item_tax_total
|
||||||
|
* - cart.refundable_amount
|
||||||
|
* - cart.refunded_total
|
||||||
|
* - cart.shipping_tax_total
|
||||||
|
* - cart.shipping_total
|
||||||
|
* - cart.subtotal
|
||||||
|
* - cart.tax_total
|
||||||
|
* - cart.total
|
||||||
|
* - cart.items.discount_total
|
||||||
|
* - cart.items.gift_card_total
|
||||||
|
* - cart.items.original_tax_total
|
||||||
|
* - cart.items.original_total
|
||||||
|
* - cart.items.refundable
|
||||||
|
* - cart.items.subtotal
|
||||||
|
* - cart.items.tax_total
|
||||||
|
* - cart.items.total
|
||||||
* required:
|
* required:
|
||||||
* - draft_order
|
* - draft_order
|
||||||
* properties:
|
* properties:
|
||||||
@@ -142,6 +199,13 @@ export type AdminDraftOrdersDeleteRes = DeleteResponse
|
|||||||
/**
|
/**
|
||||||
* @schema AdminDraftOrdersListRes
|
* @schema AdminDraftOrdersListRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: draft_orders
|
||||||
|
* relations:
|
||||||
|
* - order
|
||||||
|
* - cart
|
||||||
|
* - cart.items
|
||||||
|
* - cart.items.adjustments
|
||||||
* required:
|
* required:
|
||||||
* - draft_orders
|
* - draft_orders
|
||||||
* - count
|
* - count
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ import {
|
|||||||
PaymentProviderService,
|
PaymentProviderService,
|
||||||
ProductVariantInventoryService,
|
ProductVariantInventoryService,
|
||||||
} from "../../../../services"
|
} from "../../../../services"
|
||||||
import {
|
|
||||||
defaultAdminOrdersFields as defaultOrderFields,
|
|
||||||
defaultAdminOrdersRelations as defaultOrderRelations,
|
|
||||||
} from "../orders/index"
|
|
||||||
|
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
import { Order } from "../../../../models"
|
import { Order } from "../../../../models"
|
||||||
import { MedusaError } from "medusa-core-utils"
|
import { MedusaError } from "medusa-core-utils"
|
||||||
|
import {
|
||||||
|
defaultAdminOrdersFields as defaultOrderFields,
|
||||||
|
defaultAdminOrdersRelations as defaultOrderRelations,
|
||||||
|
} from "../../../../types/orders"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [post] /admin/draft-orders/{id}/pay
|
* @oas [post] /admin/draft-orders/{id}/pay
|
||||||
|
|||||||
@@ -59,6 +59,14 @@ export const defaultAdminGiftCardRelations = ["region", "order"]
|
|||||||
/**
|
/**
|
||||||
* @schema AdminGiftCardsRes
|
* @schema AdminGiftCardsRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: gift_card
|
||||||
|
* relations:
|
||||||
|
* - order
|
||||||
|
* - region
|
||||||
|
* eager:
|
||||||
|
* - region.fulfillment_providers
|
||||||
|
* - region.payment_providers
|
||||||
* required:
|
* required:
|
||||||
* - gift_card
|
* - gift_card
|
||||||
* properties:
|
* properties:
|
||||||
@@ -94,6 +102,14 @@ export type AdminGiftCardsDeleteRes = DeleteResponse
|
|||||||
/**
|
/**
|
||||||
* @schema AdminGiftCardsListRes
|
* @schema AdminGiftCardsListRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: gift_cards
|
||||||
|
* relations:
|
||||||
|
* - order
|
||||||
|
* - region
|
||||||
|
* eager:
|
||||||
|
* - region.fulfillment_providers
|
||||||
|
* - region.payment_providers
|
||||||
* required:
|
* required:
|
||||||
* - gift_cards
|
* - gift_cards
|
||||||
* - count
|
* - count
|
||||||
|
|||||||
@@ -25,7 +25,10 @@ import { FindParams } from "../../../../types/common"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/AdminPostInventoryItemsItemLocationLevelsReq"
|
* $ref: "#/components/schemas/AdminPostInventoryItemsReq"
|
||||||
|
* x-codegen:
|
||||||
|
* method: create
|
||||||
|
* queryParams: AdminPostInventoryItemsParams
|
||||||
* x-codeSamples:
|
* x-codeSamples:
|
||||||
* - lang: JavaScript
|
* - lang: JavaScript
|
||||||
* label: JS Client
|
* label: JS Client
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ import { FindParams } from "../../../../types/common"
|
|||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/AdminPostInventoryItemsItemLocationLevelsReq"
|
* $ref: "#/components/schemas/AdminPostInventoryItemsItemLocationLevelsReq"
|
||||||
|
* x-codegen:
|
||||||
|
* method: createLocationLevel
|
||||||
|
* queryParams: AdminPostInventoryItemsItemLocationLevelsParams
|
||||||
* x-codeSamples:
|
* x-codeSamples:
|
||||||
* - lang: JavaScript
|
* - lang: JavaScript
|
||||||
* label: JS Client
|
* label: JS Client
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import { ProductVariantInventoryService } from "../../../../services"
|
|||||||
* x-authenticated: true
|
* x-authenticated: true
|
||||||
* parameters:
|
* parameters:
|
||||||
* - (path) id=* {string} The ID of the Inventory Item to delete.
|
* - (path) id=* {string} The ID of the Inventory Item to delete.
|
||||||
|
* x-codegen:
|
||||||
|
* method: delete
|
||||||
* x-codeSamples:
|
* x-codeSamples:
|
||||||
* - lang: JavaScript
|
* - lang: JavaScript
|
||||||
* label: JS Client
|
* label: JS Client
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import { IInventoryService } from "../../../../interfaces"
|
|||||||
* parameters:
|
* parameters:
|
||||||
* - (path) id=* {string} The ID of the Inventory Item.
|
* - (path) id=* {string} The ID of the Inventory Item.
|
||||||
* - (path) location_id=* {string} The ID of the location.
|
* - (path) location_id=* {string} The ID of the location.
|
||||||
* - (query) expand {string} Comma separated list of relations to include in the results.
|
* x-codegen:
|
||||||
* - (query) fields {string} Comma separated list of fields to include in the results.
|
* method: deleteLocationLevel
|
||||||
* x-codeSamples:
|
* x-codeSamples:
|
||||||
* - lang: JavaScript
|
* - lang: JavaScript
|
||||||
* label: JS Client
|
* label: JS Client
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ import middlewares, {
|
|||||||
} from "../../../middlewares"
|
} from "../../../middlewares"
|
||||||
import { AdminGetInventoryItemsParams } from "./list-inventory-items"
|
import { AdminGetInventoryItemsParams } from "./list-inventory-items"
|
||||||
import { AdminGetInventoryItemsItemParams } from "./get-inventory-item"
|
import { AdminGetInventoryItemsItemParams } from "./get-inventory-item"
|
||||||
import { AdminPostInventoryItemsInventoryItemReq } from "./update-inventory-item"
|
import {
|
||||||
|
AdminPostInventoryItemsInventoryItemParams,
|
||||||
|
AdminPostInventoryItemsInventoryItemReq,
|
||||||
|
} from "./update-inventory-item"
|
||||||
import { AdminGetInventoryItemsItemLocationLevelsParams } from "./list-location-levels"
|
import { AdminGetInventoryItemsItemLocationLevelsParams } from "./list-location-levels"
|
||||||
import {
|
import {
|
||||||
AdminPostInventoryItemsItemLocationLevelsParams,
|
AdminPostInventoryItemsItemLocationLevelsParams,
|
||||||
@@ -52,7 +55,7 @@ export default (app) => {
|
|||||||
|
|
||||||
route.post(
|
route.post(
|
||||||
"/:id",
|
"/:id",
|
||||||
transformQuery(AdminGetInventoryItemsItemParams, {
|
transformQuery(AdminPostInventoryItemsInventoryItemParams, {
|
||||||
defaultFields: defaultAdminInventoryItemFields,
|
defaultFields: defaultAdminInventoryItemFields,
|
||||||
defaultRelations: defaultAdminInventoryItemRelations,
|
defaultRelations: defaultAdminInventoryItemRelations,
|
||||||
isList: false,
|
isList: false,
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ import { EntityManager } from "typeorm"
|
|||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/AdminPostInventoryItemsInventoryItemReq"
|
* $ref: "#/components/schemas/AdminPostInventoryItemsInventoryItemReq"
|
||||||
|
* x-codegen:
|
||||||
|
* method: update
|
||||||
|
* queryParams: AdminPostInventoryItemsInventoryItemParams
|
||||||
* x-codeSamples:
|
* x-codeSamples:
|
||||||
* - lang: JavaScript
|
* - lang: JavaScript
|
||||||
* label: JS Client
|
* label: JS Client
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ import { EntityManager } from "typeorm"
|
|||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/AdminPostInventoryItemsItemLocationLevelsLevelReq"
|
* $ref: "#/components/schemas/AdminPostInventoryItemsItemLocationLevelsLevelReq"
|
||||||
|
* x-codegen:
|
||||||
|
* method: updateLocationLevel
|
||||||
|
* queryParams: AdminPostInventoryItemsItemLocationLevelsLevelParams
|
||||||
* x-codeSamples:
|
* x-codeSamples:
|
||||||
* - lang: JavaScript
|
* - lang: JavaScript
|
||||||
* label: JS Client
|
* label: JS Client
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ export const defaultAdminNotificationsFields = [
|
|||||||
/**
|
/**
|
||||||
* @schema AdminNotificationsListRes
|
* @schema AdminNotificationsListRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: notifications
|
||||||
|
* relations:
|
||||||
|
* - resends
|
||||||
* required:
|
* required:
|
||||||
* - notifications
|
* - notifications
|
||||||
* properties:
|
* properties:
|
||||||
@@ -54,6 +58,10 @@ export type AdminNotificationsListRes = {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminNotificationsRes
|
* @schema AdminNotificationsRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: notification
|
||||||
|
* relations:
|
||||||
|
* - resends
|
||||||
* required:
|
* required:
|
||||||
* - notification
|
* - notification
|
||||||
* properties:
|
* properties:
|
||||||
|
|||||||
@@ -70,10 +70,11 @@ export default async (req: Request, res: Response) => {
|
|||||||
.cancel(id, { canceledBy: userId })
|
.cancel(id, { canceledBy: userId })
|
||||||
})
|
})
|
||||||
|
|
||||||
const orderEdit = await orderEditService.retrieve(id, {
|
let orderEdit = await orderEditService.retrieve(id, {
|
||||||
select: defaultOrderEditFields,
|
select: defaultOrderEditFields,
|
||||||
relations: defaultOrderEditRelations,
|
relations: defaultOrderEditRelations,
|
||||||
})
|
})
|
||||||
|
orderEdit = await orderEditService.decorateTotals(orderEdit)
|
||||||
|
|
||||||
return res.json({ order_edit: orderEdit })
|
return res.json({ order_edit: orderEdit })
|
||||||
}
|
}
|
||||||
@@ -101,6 +101,41 @@ export default (app) => {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminOrderEditsRes
|
* @schema AdminOrderEditsRes
|
||||||
* 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:
|
||||||
@@ -114,6 +149,41 @@ export type AdminOrderEditsRes = {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminOrderEditsListRes
|
* @schema AdminOrderEditsListRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: order_edits
|
||||||
|
* 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_edits
|
* - order_edits
|
||||||
* - count
|
* - count
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
import { IdMap } from "medusa-test-utils"
|
import { IdMap } from "medusa-test-utils"
|
||||||
import { request } from "../../../../../helpers/test-request"
|
import { request } from "../../../../../helpers/test-request"
|
||||||
import { OrderServiceMock } from "../../../../../services/__mocks__/order"
|
import { OrderServiceMock } from "../../../../../services/__mocks__/order"
|
||||||
import { defaultAdminOrdersFields, defaultAdminOrdersRelations } from "../index"
|
import {
|
||||||
|
defaultAdminOrdersFields,
|
||||||
|
defaultAdminOrdersRelations,
|
||||||
|
} from "../../../../../types/orders"
|
||||||
|
|
||||||
describe("GET /admin/orders", () => {
|
describe("GET /admin/orders", () => {
|
||||||
describe("successfully gets an order", () => {
|
describe("successfully gets an order", () => {
|
||||||
|
|||||||
@@ -72,6 +72,10 @@ import {
|
|||||||
AdminPostOrdersOrderClaimsClaimShipmentsParams,
|
AdminPostOrdersOrderClaimsClaimShipmentsParams,
|
||||||
AdminPostOrdersOrderClaimsClaimShipmentsReq,
|
AdminPostOrdersOrderClaimsClaimShipmentsReq,
|
||||||
} from "./create-claim-shipment"
|
} from "./create-claim-shipment"
|
||||||
|
import {
|
||||||
|
defaultAdminOrdersFields,
|
||||||
|
defaultAdminOrdersRelations,
|
||||||
|
} from "../../../../types/orders"
|
||||||
|
|
||||||
const route = Router()
|
const route = Router()
|
||||||
|
|
||||||
@@ -480,6 +484,109 @@ export default (app, featureFlagRouter: FlagRouter) => {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminOrdersRes
|
* @schema AdminOrdersRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: order
|
||||||
|
* relations:
|
||||||
|
* - billing_address
|
||||||
|
* - claims
|
||||||
|
* - claims.additional_items
|
||||||
|
* - claims.additional_items.variant
|
||||||
|
* - claims.claim_items
|
||||||
|
* - claims.claim_items.images
|
||||||
|
* - claims.claim_items.item
|
||||||
|
* - claims.fulfillments
|
||||||
|
* - claims.fulfillments.tracking_links
|
||||||
|
* - claims.return_order
|
||||||
|
* - claims.return_order.shipping_method
|
||||||
|
* - claims.return_order.shipping_method.tax_lines
|
||||||
|
* - claims.shipping_address
|
||||||
|
* - claims.shipping_methods
|
||||||
|
* - customer
|
||||||
|
* - discounts
|
||||||
|
* - discounts.rule
|
||||||
|
* - fulfillments
|
||||||
|
* - fulfillments.items
|
||||||
|
* - fulfillments.tracking_links
|
||||||
|
* - gift_card_transactions
|
||||||
|
* - gift_cards
|
||||||
|
* - items
|
||||||
|
* - payments
|
||||||
|
* - refunds
|
||||||
|
* - region
|
||||||
|
* - returns
|
||||||
|
* - returns.items
|
||||||
|
* - returns.items.reason
|
||||||
|
* - returns.shipping_method
|
||||||
|
* - returns.shipping_method.tax_lines
|
||||||
|
* - shipping_address
|
||||||
|
* - shipping_methods
|
||||||
|
* eager:
|
||||||
|
* - fulfillments.items
|
||||||
|
* - region.fulfillment_providers
|
||||||
|
* - region.payment_providers
|
||||||
|
* - returns.items
|
||||||
|
* - 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
|
||||||
* required:
|
* required:
|
||||||
* - order
|
* - order
|
||||||
* properties:
|
* properties:
|
||||||
@@ -493,6 +600,109 @@ export type AdminOrdersRes = {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminOrdersListRes
|
* @schema AdminOrdersListRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: orders
|
||||||
|
* relations:
|
||||||
|
* - billing_address
|
||||||
|
* - claims
|
||||||
|
* - claims.additional_items
|
||||||
|
* - claims.additional_items.variant
|
||||||
|
* - claims.claim_items
|
||||||
|
* - claims.claim_items.images
|
||||||
|
* - claims.claim_items.item
|
||||||
|
* - claims.fulfillments
|
||||||
|
* - claims.fulfillments.tracking_links
|
||||||
|
* - claims.return_order
|
||||||
|
* - claims.return_order.shipping_method
|
||||||
|
* - claims.return_order.shipping_method.tax_lines
|
||||||
|
* - claims.shipping_address
|
||||||
|
* - claims.shipping_methods
|
||||||
|
* - customer
|
||||||
|
* - discounts
|
||||||
|
* - discounts.rule
|
||||||
|
* - fulfillments
|
||||||
|
* - fulfillments.items
|
||||||
|
* - fulfillments.tracking_links
|
||||||
|
* - gift_card_transactions
|
||||||
|
* - gift_cards
|
||||||
|
* - items
|
||||||
|
* - payments
|
||||||
|
* - refunds
|
||||||
|
* - region
|
||||||
|
* - returns
|
||||||
|
* - returns.items
|
||||||
|
* - returns.items.reason
|
||||||
|
* - returns.shipping_method
|
||||||
|
* - returns.shipping_method.tax_lines
|
||||||
|
* - shipping_address
|
||||||
|
* - shipping_methods
|
||||||
|
* eager:
|
||||||
|
* - fulfillments.items
|
||||||
|
* - region.fulfillment_providers
|
||||||
|
* - region.payment_providers
|
||||||
|
* - returns.items
|
||||||
|
* - 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
|
||||||
* required:
|
* required:
|
||||||
* - orders
|
* - orders
|
||||||
* - count
|
* - count
|
||||||
@@ -517,78 +727,6 @@ export type AdminOrdersListRes = PaginatedResponse & {
|
|||||||
orders: Order[]
|
orders: Order[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultAdminOrdersRelations = [
|
|
||||||
"customer",
|
|
||||||
"billing_address",
|
|
||||||
"shipping_address",
|
|
||||||
"discounts",
|
|
||||||
"discounts.rule",
|
|
||||||
"shipping_methods",
|
|
||||||
"payments",
|
|
||||||
"items",
|
|
||||||
"refunds",
|
|
||||||
"region",
|
|
||||||
"fulfillments",
|
|
||||||
"fulfillments.tracking_links",
|
|
||||||
"fulfillments.items",
|
|
||||||
"returns",
|
|
||||||
"returns.shipping_method",
|
|
||||||
"returns.shipping_method.tax_lines",
|
|
||||||
"returns.items",
|
|
||||||
"returns.items.reason",
|
|
||||||
"gift_cards",
|
|
||||||
"gift_card_transactions",
|
|
||||||
"claims",
|
|
||||||
"claims.return_order",
|
|
||||||
"claims.return_order.shipping_method",
|
|
||||||
"claims.return_order.shipping_method.tax_lines",
|
|
||||||
"claims.shipping_methods",
|
|
||||||
"claims.shipping_address",
|
|
||||||
"claims.additional_items",
|
|
||||||
"claims.additional_items.variant",
|
|
||||||
"claims.fulfillments",
|
|
||||||
"claims.fulfillments.tracking_links",
|
|
||||||
"claims.claim_items",
|
|
||||||
"claims.claim_items.item",
|
|
||||||
"claims.claim_items.images",
|
|
||||||
// "claims.claim_items.tags",
|
|
||||||
"swaps",
|
|
||||||
"swaps.return_order",
|
|
||||||
"swaps.return_order.shipping_method",
|
|
||||||
"swaps.return_order.shipping_method.tax_lines",
|
|
||||||
"swaps.payment",
|
|
||||||
"swaps.shipping_methods",
|
|
||||||
"swaps.shipping_methods.tax_lines",
|
|
||||||
"swaps.shipping_address",
|
|
||||||
"swaps.additional_items",
|
|
||||||
"swaps.additional_items.variant",
|
|
||||||
"swaps.fulfillments",
|
|
||||||
"swaps.fulfillments.tracking_links",
|
|
||||||
]
|
|
||||||
|
|
||||||
export const defaultAdminOrdersFields = [
|
|
||||||
"id",
|
|
||||||
"status",
|
|
||||||
"fulfillment_status",
|
|
||||||
"payment_status",
|
|
||||||
"display_id",
|
|
||||||
"cart_id",
|
|
||||||
"draft_order_id",
|
|
||||||
"customer_id",
|
|
||||||
"email",
|
|
||||||
"region_id",
|
|
||||||
"currency_code",
|
|
||||||
"tax_rate",
|
|
||||||
"canceled_at",
|
|
||||||
"created_at",
|
|
||||||
"updated_at",
|
|
||||||
"metadata",
|
|
||||||
"items.refundable",
|
|
||||||
"swaps.additional_items.refundable",
|
|
||||||
"claims.additional_items.refundable",
|
|
||||||
"no_notification",
|
|
||||||
] as (keyof Order)[]
|
|
||||||
|
|
||||||
export const filterableAdminOrdersFields = [
|
export const filterableAdminOrdersFields = [
|
||||||
"id",
|
"id",
|
||||||
"status",
|
"status",
|
||||||
|
|||||||
@@ -65,6 +65,15 @@ export const defaulPaymentCollectionRelations = [
|
|||||||
/**
|
/**
|
||||||
* @schema AdminPaymentCollectionsRes
|
* @schema AdminPaymentCollectionsRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: payment_collection
|
||||||
|
* relations:
|
||||||
|
* - payment_sessions
|
||||||
|
* - payments
|
||||||
|
* - region
|
||||||
|
* eager:
|
||||||
|
* - region.fulfillment_providers
|
||||||
|
* - region.payment_providers
|
||||||
* required:
|
* required:
|
||||||
* - payment_collection
|
* - payment_collection
|
||||||
* properties:
|
* properties:
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ import { EntityManager } from "typeorm"
|
|||||||
import TaxInclusivePricingFeatureFlag from "../../../../loaders/feature-flags/tax-inclusive-pricing"
|
import TaxInclusivePricingFeatureFlag from "../../../../loaders/feature-flags/tax-inclusive-pricing"
|
||||||
import PriceListService from "../../../../services/price-list"
|
import PriceListService from "../../../../services/price-list"
|
||||||
import { FeatureFlagDecorators } from "../../../../utils/feature-flag-decorators"
|
import { FeatureFlagDecorators } from "../../../../utils/feature-flag-decorators"
|
||||||
|
import {
|
||||||
|
defaultAdminPriceListFields,
|
||||||
|
defaultAdminPriceListRelations,
|
||||||
|
} from "./index"
|
||||||
|
import { PriceList } from "../../../../models"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [post] /admin/price-lists
|
* @oas [post] /admin/price-lists
|
||||||
@@ -104,12 +109,17 @@ export default async (req: Request, res) => {
|
|||||||
req.scope.resolve("priceListService")
|
req.scope.resolve("priceListService")
|
||||||
|
|
||||||
const manager: EntityManager = req.scope.resolve("manager")
|
const manager: EntityManager = req.scope.resolve("manager")
|
||||||
const priceList = await manager.transaction(async (transactionManager) => {
|
let priceList = await manager.transaction(async (transactionManager) => {
|
||||||
return await priceListService
|
return await priceListService
|
||||||
.withTransaction(transactionManager)
|
.withTransaction(transactionManager)
|
||||||
.create(req.validatedBody as CreatePriceListInput)
|
.create(req.validatedBody as CreatePriceListInput)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
priceList = await priceListService.retrieve(priceList.id, {
|
||||||
|
select: defaultAdminPriceListFields as (keyof PriceList)[],
|
||||||
|
relations: defaultAdminPriceListRelations,
|
||||||
|
})
|
||||||
|
|
||||||
res.json({ price_list: priceList })
|
res.json({ price_list: priceList })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,11 @@ export const defaultAdminPriceListRelations = ["prices", "customer_groups"]
|
|||||||
/**
|
/**
|
||||||
* @schema AdminPriceListRes
|
* @schema AdminPriceListRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: price_list
|
||||||
|
* relations:
|
||||||
|
* - customer_groups
|
||||||
|
* - prices
|
||||||
* required:
|
* required:
|
||||||
* - price_list
|
* - price_list
|
||||||
* properties:
|
* properties:
|
||||||
@@ -234,6 +239,17 @@ export type AdminPriceListsListRes = PaginatedResponse & {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminPriceListsProductsListRes
|
* @schema AdminPriceListsProductsListRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: products
|
||||||
|
* relations:
|
||||||
|
* - categories
|
||||||
|
* - collection
|
||||||
|
* - images
|
||||||
|
* - options
|
||||||
|
* - tags
|
||||||
|
* - type
|
||||||
|
* - variants
|
||||||
|
* - variants.options
|
||||||
* required:
|
* required:
|
||||||
* - products
|
* - products
|
||||||
* - count
|
* - count
|
||||||
|
|||||||
@@ -153,6 +153,11 @@ export const defaultProductCategoryFields = [
|
|||||||
/**
|
/**
|
||||||
* @schema AdminProductCategoriesCategoryRes
|
* @schema AdminProductCategoriesCategoryRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: product_category
|
||||||
|
* relations:
|
||||||
|
* - category_children
|
||||||
|
* - parent_category
|
||||||
* required:
|
* required:
|
||||||
* - product_category
|
* - product_category
|
||||||
* properties:
|
* properties:
|
||||||
@@ -188,6 +193,11 @@ export type AdminProductCategoriesCategoryDeleteRes = DeleteResponse
|
|||||||
/**
|
/**
|
||||||
* @schema AdminProductCategoriesListRes
|
* @schema AdminProductCategoriesListRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: product_categories
|
||||||
|
* relations:
|
||||||
|
* - category_children
|
||||||
|
* - parent_category
|
||||||
* required:
|
* required:
|
||||||
* - product_categories
|
* - product_categories
|
||||||
* - count
|
* - count
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
} from "class-validator"
|
} from "class-validator"
|
||||||
import { Type } from "class-transformer"
|
import { Type } from "class-transformer"
|
||||||
import {
|
import {
|
||||||
|
PricingService,
|
||||||
ProductService,
|
ProductService,
|
||||||
ProductVariantInventoryService,
|
ProductVariantInventoryService,
|
||||||
ProductVariantService,
|
ProductVariantService,
|
||||||
@@ -146,11 +147,15 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const productService: ProductService = req.scope.resolve("productService")
|
const productService: ProductService = req.scope.resolve("productService")
|
||||||
const product = await productService.retrieve(id, {
|
const pricingService: PricingService = req.scope.resolve("pricingService")
|
||||||
|
|
||||||
|
const rawProduct = await productService.retrieve(id, {
|
||||||
select: defaultAdminProductFields,
|
select: defaultAdminProductFields,
|
||||||
relations: defaultAdminProductRelations,
|
relations: defaultAdminProductRelations,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const [product] = await pricingService.setProductPrices([rawProduct])
|
||||||
|
|
||||||
res.json({ product })
|
res.json({ product })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,6 +139,17 @@ export const defaultAdminGetProductsVariantsFields = ["id", "product_id"]
|
|||||||
/**
|
/**
|
||||||
* @schema AdminProductsDeleteOptionRes
|
* @schema AdminProductsDeleteOptionRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: product
|
||||||
|
* relations:
|
||||||
|
* - collection
|
||||||
|
* - images
|
||||||
|
* - options
|
||||||
|
* - tags
|
||||||
|
* - type
|
||||||
|
* - variants
|
||||||
|
* - variants.options
|
||||||
|
* - variants.prices
|
||||||
* required:
|
* required:
|
||||||
* - option_id
|
* - option_id
|
||||||
* - object
|
* - object
|
||||||
@@ -157,7 +168,7 @@ export const defaultAdminGetProductsVariantsFields = ["id", "product_id"]
|
|||||||
* description: Whether or not the items were deleted.
|
* description: Whether or not the items were deleted.
|
||||||
* default: true
|
* default: true
|
||||||
* product:
|
* product:
|
||||||
* $ref: "#/components/schemas/Product"
|
* $ref: "#/components/schemas/PricedProduct"
|
||||||
*/
|
*/
|
||||||
export type AdminProductsDeleteOptionRes = {
|
export type AdminProductsDeleteOptionRes = {
|
||||||
option_id: string
|
option_id: string
|
||||||
@@ -169,6 +180,17 @@ export type AdminProductsDeleteOptionRes = {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminProductsDeleteVariantRes
|
* @schema AdminProductsDeleteVariantRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: product
|
||||||
|
* relations:
|
||||||
|
* - collection
|
||||||
|
* - images
|
||||||
|
* - options
|
||||||
|
* - tags
|
||||||
|
* - type
|
||||||
|
* - variants
|
||||||
|
* - variants.options
|
||||||
|
* - variants.prices
|
||||||
* required:
|
* required:
|
||||||
* - variant_id
|
* - variant_id
|
||||||
* - object
|
* - object
|
||||||
@@ -187,7 +209,7 @@ export type AdminProductsDeleteOptionRes = {
|
|||||||
* description: Whether or not the items were deleted.
|
* description: Whether or not the items were deleted.
|
||||||
* default: true
|
* default: true
|
||||||
* product:
|
* product:
|
||||||
* $ref: "#/components/schemas/Product"
|
* $ref: "#/components/schemas/PricedProduct"
|
||||||
*/
|
*/
|
||||||
export type AdminProductsDeleteVariantRes = {
|
export type AdminProductsDeleteVariantRes = {
|
||||||
variant_id: string
|
variant_id: string
|
||||||
@@ -225,6 +247,17 @@ export type AdminProductsDeleteRes = {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminProductsListRes
|
* @schema AdminProductsListRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: products
|
||||||
|
* relations:
|
||||||
|
* - collection
|
||||||
|
* - images
|
||||||
|
* - options
|
||||||
|
* - tags
|
||||||
|
* - type
|
||||||
|
* - variants
|
||||||
|
* - variants.options
|
||||||
|
* - variants.prices
|
||||||
* required:
|
* required:
|
||||||
* - products
|
* - products
|
||||||
* - count
|
* - count
|
||||||
@@ -234,9 +267,7 @@ export type AdminProductsDeleteRes = {
|
|||||||
* products:
|
* products:
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* oneOf:
|
* $ref: "#/components/schemas/PricedProduct"
|
||||||
* - $ref: "#/components/schemas/Product"
|
|
||||||
* - $ref: "#/components/schemas/PricedProduct"
|
|
||||||
* count:
|
* count:
|
||||||
* type: integer
|
* type: integer
|
||||||
* description: The total number of items available
|
* description: The total number of items available
|
||||||
@@ -329,11 +360,22 @@ export type AdminProductsListTagsRes = {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminProductsRes
|
* @schema AdminProductsRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: product
|
||||||
|
* relations:
|
||||||
|
* - collection
|
||||||
|
* - images
|
||||||
|
* - options
|
||||||
|
* - tags
|
||||||
|
* - type
|
||||||
|
* - variants
|
||||||
|
* - variants.options
|
||||||
|
* - variants.prices
|
||||||
* required:
|
* required:
|
||||||
* - product
|
* - product
|
||||||
* properties:
|
* properties:
|
||||||
* product:
|
* product:
|
||||||
* $ref: "#/components/schemas/Product"
|
* $ref: "#/components/schemas/PricedProduct"
|
||||||
*/
|
*/
|
||||||
export type AdminProductsRes = {
|
export type AdminProductsRes = {
|
||||||
product: Product
|
product: Product
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { defaultAdminProductFields, defaultAdminProductRelations } from "."
|
|||||||
import { IsString } from "class-validator"
|
import { IsString } from "class-validator"
|
||||||
import { validator } from "../../../../utils/validator"
|
import { validator } from "../../../../utils/validator"
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
|
import { PricingService } from "../../../../services"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [post] /admin/products/{id}/metadata
|
* @oas [post] /admin/products/{id}/metadata
|
||||||
@@ -77,6 +78,8 @@ export default async (req, res) => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const productService = req.scope.resolve("productService")
|
const productService = req.scope.resolve("productService")
|
||||||
|
const pricingService: PricingService = req.scope.resolve("pricingService")
|
||||||
|
|
||||||
const manager: EntityManager = req.scope.resolve("manager")
|
const manager: EntityManager = req.scope.resolve("manager")
|
||||||
await manager.transaction(async (transactionManager) => {
|
await manager.transaction(async (transactionManager) => {
|
||||||
return await productService.withTransaction(transactionManager).update(id, {
|
return await productService.withTransaction(transactionManager).update(id, {
|
||||||
@@ -84,11 +87,13 @@ export default async (req, res) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const product = await productService.retrieve(id, {
|
const rawProduct = await productService.retrieve(id, {
|
||||||
select: defaultAdminProductFields,
|
select: defaultAdminProductFields,
|
||||||
relations: defaultAdminProductRelations,
|
relations: defaultAdminProductRelations,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const [product] = await pricingService.setProductPrices([rawProduct])
|
||||||
|
|
||||||
res.status(200).json({ product })
|
res.status(200).json({ product })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { defaultAdminProductFields, defaultAdminProductRelations } from "."
|
import { defaultAdminProductFields, defaultAdminProductRelations } from "."
|
||||||
|
|
||||||
import { IsString } from "class-validator"
|
import { IsString } from "class-validator"
|
||||||
import { ProductService } from "../../../../services"
|
import { PricingService, ProductService } from "../../../../services"
|
||||||
import { validator } from "../../../../utils/validator"
|
import { validator } from "../../../../utils/validator"
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
|
|
||||||
@@ -77,6 +77,7 @@ export default async (req, res) => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const productService: ProductService = req.scope.resolve("productService")
|
const productService: ProductService = req.scope.resolve("productService")
|
||||||
|
const pricingService: PricingService = req.scope.resolve("pricingService")
|
||||||
|
|
||||||
const manager: EntityManager = req.scope.resolve("manager")
|
const manager: EntityManager = req.scope.resolve("manager")
|
||||||
await manager.transaction(async (transactionManager) => {
|
await manager.transaction(async (transactionManager) => {
|
||||||
@@ -85,11 +86,13 @@ export default async (req, res) => {
|
|||||||
.updateOption(id, option_id, validated)
|
.updateOption(id, option_id, validated)
|
||||||
})
|
})
|
||||||
|
|
||||||
const product = await productService.retrieve(id, {
|
const rawProduct = await productService.retrieve(id, {
|
||||||
select: defaultAdminProductFields,
|
select: defaultAdminProductFields,
|
||||||
relations: defaultAdminProductRelations,
|
relations: defaultAdminProductRelations,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const [product] = await pricingService.setProductPrices([rawProduct])
|
||||||
|
|
||||||
res.json({ product })
|
res.json({ product })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,15 @@ export const defaultAdminRegionRelations = [
|
|||||||
/**
|
/**
|
||||||
* @schema AdminRegionsRes
|
* @schema AdminRegionsRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: region
|
||||||
|
* relations:
|
||||||
|
* - countries
|
||||||
|
* - fulfillment_providers
|
||||||
|
* - payment_providers
|
||||||
|
* eager:
|
||||||
|
* - fulfillment_providers
|
||||||
|
* - payment_providers
|
||||||
* required:
|
* required:
|
||||||
* - region
|
* - region
|
||||||
* properties:
|
* properties:
|
||||||
@@ -101,6 +110,15 @@ export class AdminRegionsRes {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminRegionsListRes
|
* @schema AdminRegionsListRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: regions
|
||||||
|
* relations:
|
||||||
|
* - countries
|
||||||
|
* - fulfillment_providers
|
||||||
|
* - payment_providers
|
||||||
|
* eager:
|
||||||
|
* - fulfillment_providers
|
||||||
|
* - payment_providers
|
||||||
* required:
|
* required:
|
||||||
* - regions
|
* - regions
|
||||||
* - count
|
* - count
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ import { IInventoryService } from "../../../../interfaces"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/AdminPostReservationsReq"
|
* $ref: "#/components/schemas/AdminReservationsRes"
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import { IInventoryService } from "../../../../interfaces"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/AdminPostReservationsReq"
|
* $ref: "#/components/schemas/AdminReservationsRes"
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ import { IInventoryService } from "../../../../interfaces"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* $ref: "#/components/schemas/AdminPostReservationsReq"
|
* $ref: "#/components/schemas/AdminReservationsRes"
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -55,6 +55,11 @@ export const defaultAdminReturnReasonsRelations: (keyof ReturnReason)[] = [
|
|||||||
/**
|
/**
|
||||||
* @schema AdminReturnReasonsRes
|
* @schema AdminReturnReasonsRes
|
||||||
* 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:
|
||||||
@@ -68,6 +73,11 @@ export type AdminReturnReasonsRes = {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminReturnReasonsListRes
|
* @schema AdminReturnReasonsListRes
|
||||||
* 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:
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import { OrderService, ReturnService } from "../../../../services"
|
import { OrderService, ReturnService } from "../../../../services"
|
||||||
import {
|
|
||||||
defaultAdminOrdersFields,
|
|
||||||
defaultAdminOrdersRelations,
|
|
||||||
} from "../orders"
|
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
|
import { defaultReturnCancelFields, defaultReturnCancelRelations } from "."
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [post] /admin/returns/{id}/cancel
|
* @oas [post] /admin/returns/{id}/cancel
|
||||||
@@ -75,8 +72,8 @@ export default async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const order = await orderService.retrieve(result.order_id!, {
|
const order = await orderService.retrieve(result.order_id!, {
|
||||||
select: defaultAdminOrdersFields,
|
select: defaultReturnCancelFields,
|
||||||
relations: defaultAdminOrdersRelations,
|
relations: defaultReturnCancelRelations,
|
||||||
})
|
})
|
||||||
|
|
||||||
res.status(200).json({ order })
|
res.status(200).json({ order })
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ import "reflect-metadata"
|
|||||||
import { Order, Return } from "../../../.."
|
import { Order, Return } from "../../../.."
|
||||||
import { PaginatedResponse } from "../../../../types/common"
|
import { PaginatedResponse } from "../../../../types/common"
|
||||||
import middlewares from "../../../middlewares"
|
import middlewares from "../../../middlewares"
|
||||||
|
import {
|
||||||
|
defaultAdminOrdersFields,
|
||||||
|
defaultAdminOrdersRelations,
|
||||||
|
} from "../../../../types/orders"
|
||||||
|
|
||||||
const route = Router()
|
const route = Router()
|
||||||
|
|
||||||
@@ -27,9 +31,62 @@ export default (app) => {
|
|||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const defaultRelations = ["swap"]
|
||||||
|
export const defaultRelationsList = ["swap", "order"]
|
||||||
|
export const defaultReturnCancelRelations = [...defaultAdminOrdersRelations]
|
||||||
|
export const defaultReturnCancelFields = [...defaultAdminOrdersFields]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @schema AdminReturnsCancelRes
|
* @schema AdminReturnsCancelRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: order
|
||||||
|
* relations:
|
||||||
|
* - billing_address
|
||||||
|
* - claims
|
||||||
|
* - claims.additional_items
|
||||||
|
* - claims.additional_items.variant
|
||||||
|
* - claims.claim_items
|
||||||
|
* - claims.claim_items.images
|
||||||
|
* - claims.claim_items.item
|
||||||
|
* - claims.fulfillments
|
||||||
|
* - claims.fulfillments.tracking_links
|
||||||
|
* - claims.return_order
|
||||||
|
* - claims.return_order.shipping_method
|
||||||
|
* - claims.return_order.shipping_method.tax_lines
|
||||||
|
* - claims.shipping_address
|
||||||
|
* - claims.shipping_methods
|
||||||
|
* - customer
|
||||||
|
* - discounts
|
||||||
|
* - discounts.rule
|
||||||
|
* - fulfillments
|
||||||
|
* - fulfillments.items
|
||||||
|
* - fulfillments.tracking_links
|
||||||
|
* - gift_card_transactions
|
||||||
|
* - gift_cards
|
||||||
|
* - items
|
||||||
|
* - payments
|
||||||
|
* - refunds
|
||||||
|
* - region
|
||||||
|
* - returns
|
||||||
|
* - returns.items
|
||||||
|
* - returns.items.reason
|
||||||
|
* - returns.shipping_method
|
||||||
|
* - returns.shipping_method.tax_lines
|
||||||
|
* - shipping_address
|
||||||
|
* - shipping_methods
|
||||||
|
* - swaps
|
||||||
|
* - swaps.additional_items
|
||||||
|
* - swaps.additional_items.variant
|
||||||
|
* - swaps.fulfillments
|
||||||
|
* - swaps.fulfillments.tracking_links
|
||||||
|
* - swaps.payment
|
||||||
|
* - swaps.return_order
|
||||||
|
* - swaps.return_order.shipping_method
|
||||||
|
* - swaps.return_order.shipping_method.tax_lines
|
||||||
|
* - swaps.shipping_address
|
||||||
|
* - swaps.shipping_methods
|
||||||
|
* - swaps.shipping_methods.tax_lines
|
||||||
* required:
|
* required:
|
||||||
* - order
|
* - order
|
||||||
* properties:
|
* properties:
|
||||||
@@ -43,6 +100,11 @@ export type AdminReturnsCancelRes = {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminReturnsListRes
|
* @schema AdminReturnsListRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relation:
|
||||||
|
* field: returns
|
||||||
|
* relations:
|
||||||
|
* - order
|
||||||
|
* - swap
|
||||||
* required:
|
* required:
|
||||||
* - returns
|
* - returns
|
||||||
* - count
|
* - count
|
||||||
@@ -70,6 +132,10 @@ export type AdminReturnsListRes = PaginatedResponse & {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminReturnsRes
|
* @schema AdminReturnsRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relation:
|
||||||
|
* field: return
|
||||||
|
* relations:
|
||||||
|
* - swap
|
||||||
* required:
|
* required:
|
||||||
* - return
|
* - return
|
||||||
* properties:
|
* properties:
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { Type } from "class-transformer"
|
|||||||
import { validator } from "../../../../utils/validator"
|
import { validator } from "../../../../utils/validator"
|
||||||
import { FindConfig } from "../../../../types/common"
|
import { FindConfig } from "../../../../types/common"
|
||||||
import { Return } from "../../../../models"
|
import { Return } from "../../../../models"
|
||||||
|
import { defaultRelationsList } from "."
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [get] /admin/returns
|
* @oas [get] /admin/returns
|
||||||
@@ -66,7 +67,7 @@ export default async (req, res) => {
|
|||||||
const selector = {}
|
const selector = {}
|
||||||
|
|
||||||
const listConfig = {
|
const listConfig = {
|
||||||
relations: ["swap", "order"],
|
relations: defaultRelationsList,
|
||||||
skip: validated.offset,
|
skip: validated.offset,
|
||||||
take: validated.limit,
|
take: validated.limit,
|
||||||
order: { created_at: "DESC" },
|
order: { created_at: "DESC" },
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { Type } from "class-transformer"
|
|||||||
import { isDefined } from "medusa-core-utils"
|
import { isDefined } from "medusa-core-utils"
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
import { validator } from "../../../../utils/validator"
|
import { validator } from "../../../../utils/validator"
|
||||||
|
import { defaultRelations } from "."
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [post] /admin/returns/{id}/receive
|
* @oas [post] /admin/returns/{id}/receive
|
||||||
@@ -124,7 +125,9 @@ export default async (req, res) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
receivedReturn = await returnService.retrieve(id, { relations: ["swap"] })
|
receivedReturn = await returnService.retrieve(id, {
|
||||||
|
relations: defaultRelations,
|
||||||
|
})
|
||||||
|
|
||||||
res.status(200).json({ return: receivedReturn })
|
res.status(200).json({ return: receivedReturn })
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-1
@@ -2,6 +2,25 @@ import { IdMap } from "medusa-test-utils"
|
|||||||
import { request } from "../../../../../helpers/test-request"
|
import { request } from "../../../../../helpers/test-request"
|
||||||
import { ShippingOptionServiceMock } from "../../../../../services/__mocks__/shipping-option"
|
import { ShippingOptionServiceMock } from "../../../../../services/__mocks__/shipping-option"
|
||||||
|
|
||||||
|
const defaultFields = [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"region_id",
|
||||||
|
"profile_id",
|
||||||
|
"provider_id",
|
||||||
|
"price_type",
|
||||||
|
"amount",
|
||||||
|
"is_return",
|
||||||
|
"admin_only",
|
||||||
|
"data",
|
||||||
|
"created_at",
|
||||||
|
"updated_at",
|
||||||
|
"deleted_at",
|
||||||
|
"metadata",
|
||||||
|
]
|
||||||
|
|
||||||
|
const defaultRelations = ["region", "profile", "requirements"]
|
||||||
|
|
||||||
describe("GET /admin/shipping-options/:optionId", () => {
|
describe("GET /admin/shipping-options/:optionId", () => {
|
||||||
describe("successful retrieval", () => {
|
describe("successful retrieval", () => {
|
||||||
let subject
|
let subject
|
||||||
@@ -27,7 +46,11 @@ describe("GET /admin/shipping-options/:optionId", () => {
|
|||||||
it("calls service retrieve", () => {
|
it("calls service retrieve", () => {
|
||||||
expect(ShippingOptionServiceMock.retrieve).toHaveBeenCalledTimes(1)
|
expect(ShippingOptionServiceMock.retrieve).toHaveBeenCalledTimes(1)
|
||||||
expect(ShippingOptionServiceMock.retrieve).toHaveBeenCalledWith(
|
expect(ShippingOptionServiceMock.retrieve).toHaveBeenCalledWith(
|
||||||
IdMap.getId("validId")
|
IdMap.getId("validId"),
|
||||||
|
{
|
||||||
|
select: defaultFields,
|
||||||
|
relations: defaultRelations,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { defaultFields, defaultRelations } from "."
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [get] /admin/shipping-options/{id}
|
* @oas [get] /admin/shipping-options/{id}
|
||||||
* operationId: "GetShippingOptionsOption"
|
* operationId: "GetShippingOptionsOption"
|
||||||
@@ -52,7 +54,11 @@
|
|||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const { option_id } = req.params
|
const { option_id } = req.params
|
||||||
const optionService = req.scope.resolve("shippingOptionService")
|
const optionService = req.scope.resolve("shippingOptionService")
|
||||||
const data = await optionService.retrieve(option_id)
|
|
||||||
|
const data = await optionService.retrieve(option_id, {
|
||||||
|
select: defaultFields,
|
||||||
|
relations: defaultRelations,
|
||||||
|
})
|
||||||
|
|
||||||
res.status(200).json({ shipping_option: data })
|
res.status(200).json({ shipping_option: data })
|
||||||
}
|
}
|
||||||
@@ -55,6 +55,15 @@ export const defaultRelations = ["region", "profile", "requirements"]
|
|||||||
/**
|
/**
|
||||||
* @schema AdminShippingOptionsListRes
|
* @schema AdminShippingOptionsListRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: shipping_options
|
||||||
|
* relations:
|
||||||
|
* - profile
|
||||||
|
* - region
|
||||||
|
* - requirements
|
||||||
|
* eager:
|
||||||
|
* - region.fulfillment_providers
|
||||||
|
* - region.payment_providers
|
||||||
* required:
|
* required:
|
||||||
* - shipping_options
|
* - shipping_options
|
||||||
* - count
|
* - count
|
||||||
@@ -82,6 +91,15 @@ export type AdminShippingOptionsListRes = PaginatedResponse & {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminShippingOptionsRes
|
* @schema AdminShippingOptionsRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: shipping_option
|
||||||
|
* relations:
|
||||||
|
* - profile
|
||||||
|
* - region
|
||||||
|
* - requirements
|
||||||
|
* eager:
|
||||||
|
* - region.fulfillment_providers
|
||||||
|
* - region.payment_providers
|
||||||
* required:
|
* required:
|
||||||
* - shipping_option
|
* - shipping_option
|
||||||
* properties:
|
* properties:
|
||||||
|
|||||||
@@ -69,6 +69,11 @@ export type AdminDeleteShippingProfileRes = DeleteResponse
|
|||||||
/**
|
/**
|
||||||
* @schema AdminShippingProfilesRes
|
* @schema AdminShippingProfilesRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: shipping_profile
|
||||||
|
* relations:
|
||||||
|
* - products
|
||||||
|
* - shipping_options
|
||||||
* required:
|
* required:
|
||||||
* - shipping_profile
|
* - shipping_profile
|
||||||
* properties:
|
* properties:
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ import { EntityManager } from "typeorm"
|
|||||||
import { ShippingProfileType } from "../../../../models"
|
import { ShippingProfileType } from "../../../../models"
|
||||||
import { ShippingProfileService } from "../../../../services"
|
import { ShippingProfileService } from "../../../../services"
|
||||||
import { validator } from "../../../../utils/validator"
|
import { validator } from "../../../../utils/validator"
|
||||||
|
import {
|
||||||
|
defaultAdminShippingProfilesFields,
|
||||||
|
defaultAdminShippingProfilesRelations,
|
||||||
|
} from "."
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [post] /admin/shipping-profiles/{id}
|
* @oas [post] /admin/shipping-profiles/{id}
|
||||||
@@ -91,7 +95,11 @@ export default async (req, res) => {
|
|||||||
.update(profile_id, validated)
|
.update(profile_id, validated)
|
||||||
})
|
})
|
||||||
|
|
||||||
const data = await profileService.retrieve(profile_id)
|
const data = await profileService.retrieve(profile_id, {
|
||||||
|
select: defaultAdminShippingProfilesFields,
|
||||||
|
relations: defaultAdminShippingProfilesRelations,
|
||||||
|
})
|
||||||
|
|
||||||
res.status(200).json({ shipping_profile: data })
|
res.status(200).json({ shipping_profile: data })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ export const defaultRelationsExtended = ["currencies", "default_currency"]
|
|||||||
/**
|
/**
|
||||||
* @schema AdminExtendedStoresRes
|
* @schema AdminExtendedStoresRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: store
|
||||||
|
* relations:
|
||||||
|
* - currencies
|
||||||
|
* - default_currency
|
||||||
* required:
|
* required:
|
||||||
* - store
|
* - store
|
||||||
* properties:
|
* properties:
|
||||||
|
|||||||
@@ -3,18 +3,18 @@ import { request } from "../../../../../helpers/test-request"
|
|||||||
import { SwapServiceMock } from "../../../../../services/__mocks__/swap"
|
import { SwapServiceMock } from "../../../../../services/__mocks__/swap"
|
||||||
|
|
||||||
const defaultRelations = [
|
const defaultRelations = [
|
||||||
"order",
|
|
||||||
"additional_items",
|
"additional_items",
|
||||||
"additional_items.adjustments",
|
"additional_items.adjustments",
|
||||||
"return_order",
|
|
||||||
"fulfillments",
|
|
||||||
"payment",
|
|
||||||
"shipping_address",
|
|
||||||
"shipping_methods",
|
|
||||||
"cart",
|
"cart",
|
||||||
"cart.items",
|
"cart.items",
|
||||||
"cart.items.variant",
|
|
||||||
"cart.items.adjustments",
|
"cart.items.adjustments",
|
||||||
|
"cart.items.variant",
|
||||||
|
"fulfillments",
|
||||||
|
"order",
|
||||||
|
"payment",
|
||||||
|
"return_order",
|
||||||
|
"shipping_address",
|
||||||
|
"shipping_methods",
|
||||||
]
|
]
|
||||||
|
|
||||||
const defaultFields = [
|
const defaultFields = [
|
||||||
|
|||||||
@@ -22,18 +22,18 @@ export default (app) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const defaultAdminSwapRelations = [
|
export const defaultAdminSwapRelations = [
|
||||||
"order",
|
|
||||||
"additional_items",
|
"additional_items",
|
||||||
"additional_items.adjustments",
|
"additional_items.adjustments",
|
||||||
"return_order",
|
|
||||||
"fulfillments",
|
|
||||||
"payment",
|
|
||||||
"shipping_address",
|
|
||||||
"shipping_methods",
|
|
||||||
"cart",
|
"cart",
|
||||||
"cart.items",
|
"cart.items",
|
||||||
"cart.items.variant",
|
|
||||||
"cart.items.adjustments",
|
"cart.items.adjustments",
|
||||||
|
"cart.items.variant",
|
||||||
|
"fulfillments",
|
||||||
|
"order",
|
||||||
|
"payment",
|
||||||
|
"return_order",
|
||||||
|
"shipping_address",
|
||||||
|
"shipping_methods",
|
||||||
]
|
]
|
||||||
|
|
||||||
export const defaultAdminSwapFields = [
|
export const defaultAdminSwapFields = [
|
||||||
@@ -84,6 +84,24 @@ export type AdminSwapsListRes = PaginatedResponse & {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminSwapsRes
|
* @schema AdminSwapsRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: swap
|
||||||
|
* relations:
|
||||||
|
* - additional_items
|
||||||
|
* - additional_items.adjustments
|
||||||
|
* - cart
|
||||||
|
* - cart.items
|
||||||
|
* - cart.items.adjustments
|
||||||
|
* - cart.items.variant
|
||||||
|
* - fulfillments
|
||||||
|
* - order
|
||||||
|
* - payment
|
||||||
|
* - return_order
|
||||||
|
* - shipping_address
|
||||||
|
* - shipping_methods
|
||||||
|
* eager:
|
||||||
|
* - fulfillments.items
|
||||||
|
* - shipping_methods.shipping_option
|
||||||
* required:
|
* required:
|
||||||
* - swap
|
* - swap
|
||||||
* properties:
|
* properties:
|
||||||
|
|||||||
@@ -75,6 +75,12 @@ export const defaultAdminVariantFields: (keyof ProductVariant)[] = [
|
|||||||
/**
|
/**
|
||||||
* @schema AdminVariantsListRes
|
* @schema AdminVariantsListRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: variants
|
||||||
|
* relations:
|
||||||
|
* - options
|
||||||
|
* - prices
|
||||||
|
* - product
|
||||||
* required:
|
* required:
|
||||||
* - variants
|
* - variants
|
||||||
* - count
|
* - count
|
||||||
@@ -84,7 +90,7 @@ export const defaultAdminVariantFields: (keyof ProductVariant)[] = [
|
|||||||
* variants:
|
* variants:
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/ProductVariant"
|
* $ref: "#/components/schemas/PricedVariant"
|
||||||
* count:
|
* count:
|
||||||
* type: integer
|
* type: integer
|
||||||
* description: The total number of items available
|
* description: The total number of items available
|
||||||
@@ -102,6 +108,12 @@ export type AdminVariantsListRes = PaginatedResponse & {
|
|||||||
/**
|
/**
|
||||||
* @schema AdminVariantsRes
|
* @schema AdminVariantsRes
|
||||||
* type: object
|
* type: object
|
||||||
|
* x-expanded-relations:
|
||||||
|
* field: variant
|
||||||
|
* relations:
|
||||||
|
* - options
|
||||||
|
* - prices
|
||||||
|
* - product
|
||||||
* required:
|
* required:
|
||||||
* - variant
|
* - variant
|
||||||
* properties:
|
* properties:
|
||||||
|
|||||||
@@ -101,6 +101,79 @@ export type UpdateOrderInput = {
|
|||||||
payment_status?: PaymentStatus
|
payment_status?: PaymentStatus
|
||||||
metadata?: Record<string, unknown>
|
metadata?: Record<string, unknown>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const defaultAdminOrdersRelations = [
|
||||||
|
"billing_address",
|
||||||
|
"claims",
|
||||||
|
"claims.additional_items",
|
||||||
|
"claims.additional_items.variant",
|
||||||
|
"claims.claim_items",
|
||||||
|
"claims.claim_items.images",
|
||||||
|
"claims.claim_items.item",
|
||||||
|
"claims.fulfillments",
|
||||||
|
"claims.fulfillments.tracking_links",
|
||||||
|
"claims.return_order",
|
||||||
|
"claims.return_order.shipping_method",
|
||||||
|
"claims.return_order.shipping_method.tax_lines",
|
||||||
|
"claims.shipping_address",
|
||||||
|
"claims.shipping_methods",
|
||||||
|
"customer",
|
||||||
|
"discounts",
|
||||||
|
"discounts.rule",
|
||||||
|
"fulfillments",
|
||||||
|
"fulfillments.items",
|
||||||
|
"fulfillments.tracking_links",
|
||||||
|
"gift_card_transactions",
|
||||||
|
"gift_cards",
|
||||||
|
"items",
|
||||||
|
"payments",
|
||||||
|
"refunds",
|
||||||
|
"region",
|
||||||
|
"returns",
|
||||||
|
"returns.items",
|
||||||
|
"returns.items.reason",
|
||||||
|
"returns.shipping_method",
|
||||||
|
"returns.shipping_method.tax_lines",
|
||||||
|
"shipping_address",
|
||||||
|
"shipping_methods",
|
||||||
|
"swaps",
|
||||||
|
"swaps.additional_items",
|
||||||
|
"swaps.additional_items.variant",
|
||||||
|
"swaps.fulfillments",
|
||||||
|
"swaps.fulfillments.tracking_links",
|
||||||
|
"swaps.payment",
|
||||||
|
"swaps.return_order",
|
||||||
|
"swaps.return_order.shipping_method",
|
||||||
|
"swaps.return_order.shipping_method.tax_lines",
|
||||||
|
"swaps.shipping_address",
|
||||||
|
"swaps.shipping_methods",
|
||||||
|
"swaps.shipping_methods.tax_lines",
|
||||||
|
// "claims.claim_items.tags",
|
||||||
|
]
|
||||||
|
|
||||||
|
export const defaultAdminOrdersFields = [
|
||||||
|
"id",
|
||||||
|
"status",
|
||||||
|
"fulfillment_status",
|
||||||
|
"payment_status",
|
||||||
|
"display_id",
|
||||||
|
"cart_id",
|
||||||
|
"draft_order_id",
|
||||||
|
"customer_id",
|
||||||
|
"email",
|
||||||
|
"region_id",
|
||||||
|
"currency_code",
|
||||||
|
"tax_rate",
|
||||||
|
"canceled_at",
|
||||||
|
"created_at",
|
||||||
|
"updated_at",
|
||||||
|
"metadata",
|
||||||
|
"items.refundable",
|
||||||
|
"swaps.additional_items.refundable",
|
||||||
|
"claims.additional_items.refundable",
|
||||||
|
"no_notification",
|
||||||
|
] as (keyof Order)[]
|
||||||
|
|
||||||
export class AdminListOrdersSelector {
|
export class AdminListOrdersSelector {
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
|
|||||||
Reference in new issue
Block a user