chore(oas): replace response with $ref class JSDoc (Admin D-N) (#3015)
### Scope Admin routes directories D to N. ### What Move inline OAS response schema declaration under their respective class declarations in order to expose them through `#/components/schemas`. Replace inline OAS response schema with a `$ref` reference pointing to the newly declared schema. ### Why Having response declared as its own "named" schema will allow OAS code generators to output typed entities/DTO that can be consumed without having to reference the route/operation. ### How Declare a new @schema JSDoc for each "Res" class used to parse and validate request body. Move the current inline requestBody to the new @schema. ### Test - Ran OAS validator. - Ran docs build script. Expect no visible changes to the documentation.
This commit is contained in:
1 parent
cdcbc064b7
commit
8221e089b8
45 files changed
+294
-267
No files matched your search
@@ -40,10 +40,7 @@ import { EntityManager } from "typeorm"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDiscountsRes"
|
||||||
* properties:
|
|
||||||
* discount:
|
|
||||||
* $ref: "#/components/schemas/Discount"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -58,10 +58,7 @@ import { FindParams } from "../../../../types/common"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDiscountsRes"
|
||||||
* properties:
|
|
||||||
* discount:
|
|
||||||
* $ref: "#/components/schemas/Discount"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -57,10 +57,7 @@ import { FindParams } from "../../../../types/common"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDiscountsRes"
|
||||||
* properties:
|
|
||||||
* discount:
|
|
||||||
* $ref: "#/components/schemas/Discount"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -87,10 +87,7 @@ import { FindParams } from "../../../../types/common"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDiscountsRes"
|
||||||
* properties:
|
|
||||||
* discount:
|
|
||||||
* $ref: "#/components/schemas/Discount"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -56,10 +56,7 @@ import { EntityManager } from "typeorm"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDiscountsRes"
|
||||||
* properties:
|
|
||||||
* discount:
|
|
||||||
* $ref: "#/components/schemas/Discount"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -42,22 +42,7 @@ import { FindParams } from "../../../../types/common"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDiscountConditionsDeleteRes"
|
||||||
* properties:
|
|
||||||
* id:
|
|
||||||
* type: string
|
|
||||||
* description: The ID of the deleted DiscountCondition
|
|
||||||
* object:
|
|
||||||
* type: string
|
|
||||||
* description: The type of the object that was deleted.
|
|
||||||
* default: discount-condition
|
|
||||||
* deleted:
|
|
||||||
* type: boolean
|
|
||||||
* description: Whether the discount condition was deleted successfully or not.
|
|
||||||
* default: true
|
|
||||||
* discount:
|
|
||||||
* description: The Discount to which the condition used to belong
|
|
||||||
* $ref: "#/components/schemas/Discount"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -36,19 +36,7 @@ import { EntityManager } from "typeorm"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDiscountsDeleteRes"
|
||||||
* properties:
|
|
||||||
* id:
|
|
||||||
* type: string
|
|
||||||
* description: The ID of the deleted Discount
|
|
||||||
* object:
|
|
||||||
* type: string
|
|
||||||
* description: The type of the object that was deleted.
|
|
||||||
* default: discount
|
|
||||||
* deleted:
|
|
||||||
* type: boolean
|
|
||||||
* description: Whether the discount was deleted successfully or not.
|
|
||||||
* default: true
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -39,10 +39,7 @@ import { EntityManager } from "typeorm"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDiscountsRes"
|
||||||
* properties:
|
|
||||||
* discount:
|
|
||||||
* $ref: "#/components/schemas/Discount"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
+1
-4
@@ -57,10 +57,7 @@ import { FindParams } from "../../../../types/common"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDiscountsRes"
|
||||||
* properties:
|
|
||||||
* discount:
|
|
||||||
* $ref: "#/components/schemas/Discount"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -40,10 +40,7 @@ import { FindParams } from "../../../../types/common"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDiscountConditionsRes"
|
||||||
* properties:
|
|
||||||
* discount_condition:
|
|
||||||
* $ref: "#/components/schemas/DiscountCondition"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -39,10 +39,7 @@ import { FindParams } from "../../../../types/common"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDiscountsRes"
|
||||||
* properties:
|
|
||||||
* discount:
|
|
||||||
* $ref: "#/components/schemas/Discount"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -39,10 +39,7 @@ import { FindParams } from "../../../../types/common"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDiscountsRes"
|
||||||
* properties:
|
|
||||||
* discount:
|
|
||||||
* $ref: "#/components/schemas/Discount"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -220,16 +220,87 @@ export const defaultAdminDiscountConditionFields: (keyof DiscountCondition)[] =
|
|||||||
|
|
||||||
export const defaultAdminDiscountConditionRelations = ["discount_rule"]
|
export const defaultAdminDiscountConditionRelations = ["discount_rule"]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminDiscountsRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* discount:
|
||||||
|
* $ref: "#/components/schemas/Discount"
|
||||||
|
*/
|
||||||
export type AdminDiscountsRes = {
|
export type AdminDiscountsRes = {
|
||||||
discount: Discount
|
discount: Discount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminDiscountConditionsRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* discount_condition:
|
||||||
|
* $ref: "#/components/schemas/DiscountCondition"
|
||||||
|
*/
|
||||||
export type AdminDiscountConditionsRes = {
|
export type AdminDiscountConditionsRes = {
|
||||||
discount_condition: DiscountCondition
|
discount_condition: DiscountCondition
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminDiscountsDeleteRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* id:
|
||||||
|
* type: string
|
||||||
|
* description: The ID of the deleted Discount
|
||||||
|
* object:
|
||||||
|
* type: string
|
||||||
|
* description: The type of the object that was deleted.
|
||||||
|
* default: discount
|
||||||
|
* deleted:
|
||||||
|
* type: boolean
|
||||||
|
* description: Whether the discount was deleted successfully or not.
|
||||||
|
* default: true
|
||||||
|
*/
|
||||||
export type AdminDiscountsDeleteRes = DeleteResponse
|
export type AdminDiscountsDeleteRes = DeleteResponse
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminDiscountConditionsDeleteRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* id:
|
||||||
|
* type: string
|
||||||
|
* description: The ID of the deleted DiscountCondition
|
||||||
|
* object:
|
||||||
|
* type: string
|
||||||
|
* description: The type of the object that was deleted.
|
||||||
|
* default: discount-condition
|
||||||
|
* deleted:
|
||||||
|
* type: boolean
|
||||||
|
* description: Whether the discount condition was deleted successfully or not.
|
||||||
|
* default: true
|
||||||
|
* discount:
|
||||||
|
* description: The Discount to which the condition used to belong
|
||||||
|
* $ref: "#/components/schemas/Discount"
|
||||||
|
*/
|
||||||
|
export type AdminDiscountConditionsDeleteRes = DeleteResponse & {
|
||||||
|
discount: Discount
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminDiscountsListRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* discounts:
|
||||||
|
* type: array
|
||||||
|
* items:
|
||||||
|
* $ref: "#/components/schemas/Discount"
|
||||||
|
* count:
|
||||||
|
* type: integer
|
||||||
|
* description: The total number of items available
|
||||||
|
* offset:
|
||||||
|
* type: integer
|
||||||
|
* description: The number of items skipped before these items
|
||||||
|
* limit:
|
||||||
|
* type: integer
|
||||||
|
* description: The number of items per page
|
||||||
|
*/
|
||||||
export type AdminDiscountsListRes = PaginatedResponse & {
|
export type AdminDiscountsListRes = PaginatedResponse & {
|
||||||
discounts: Discount[]
|
discounts: Discount[]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,21 +66,7 @@ import { optionalBooleanMapper } from "../../../../utils/validators/is-boolean"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDiscountsListRes"
|
||||||
* properties:
|
|
||||||
* discounts:
|
|
||||||
* type: array
|
|
||||||
* items:
|
|
||||||
* $ref: "#/components/schemas/Discount"
|
|
||||||
* count:
|
|
||||||
* type: integer
|
|
||||||
* description: The total number of items available
|
|
||||||
* offset:
|
|
||||||
* type: integer
|
|
||||||
* description: The number of items skipped before these items
|
|
||||||
* limit:
|
|
||||||
* type: integer
|
|
||||||
* description: The number of items per page
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -39,10 +39,7 @@ import { EntityManager } from "typeorm"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDiscountsRes"
|
||||||
* properties:
|
|
||||||
* discount:
|
|
||||||
* $ref: "#/components/schemas/Discount"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -58,10 +58,7 @@ import { FindParams } from "../../../../types/common"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDiscountsRes"
|
||||||
* properties:
|
|
||||||
* discount:
|
|
||||||
* $ref: "#/components/schemas/Discount"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -70,10 +70,7 @@ import { FindParams } from "../../../../types/common"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDiscountsRes"
|
||||||
* properties:
|
|
||||||
* discount:
|
|
||||||
* $ref: "#/components/schemas/Discount"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -92,10 +92,7 @@ import { IsType } from "../../../../utils/validators/is-type"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDraftOrdersRes"
|
||||||
* properties:
|
|
||||||
* draft_order:
|
|
||||||
* $ref: "#/components/schemas/DraftOrder"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -60,10 +60,7 @@ import { validator } from "../../../../utils/validator"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDraftOrdersRes"
|
||||||
* properties:
|
|
||||||
* draft_order:
|
|
||||||
* $ref: "#/components/schemas/DraftOrder"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { DraftOrderService } from "../../../../services"
|
import { DraftOrderService } from "../../../../services"
|
||||||
import { EntityManager } from "typeorm"
|
import { EntityManager } from "typeorm"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @oas [delete] /draft-orders/{id}
|
* @oas [delete] /draft-orders/{id}
|
||||||
* operationId: DeleteDraftOrdersDraftOrder
|
* operationId: DeleteDraftOrdersDraftOrder
|
||||||
@@ -35,19 +36,7 @@ import { EntityManager } from "typeorm"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDraftOrdersDeleteRes"
|
||||||
* properties:
|
|
||||||
* id:
|
|
||||||
* type: string
|
|
||||||
* description: The ID of the deleted Draft Order.
|
|
||||||
* object:
|
|
||||||
* type: string
|
|
||||||
* description: The type of the object that was deleted.
|
|
||||||
* default: draft-order
|
|
||||||
* deleted:
|
|
||||||
* type: boolean
|
|
||||||
* description: Whether the draft order was deleted successfully or not.
|
|
||||||
* default: true
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -45,10 +45,7 @@ import { MedusaError } from "medusa-core-utils"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDraftOrdersRes"
|
||||||
* properties:
|
|
||||||
* draft_order:
|
|
||||||
* $ref: "#/components/schemas/DraftOrder"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -43,10 +43,7 @@ import { DraftOrder } from "../../../.."
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDraftOrdersRes"
|
||||||
* properties:
|
|
||||||
* draft_order:
|
|
||||||
* $ref: "#/components/schemas/DraftOrder"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -91,16 +91,64 @@ export const defaultAdminDraftOrdersFields: (keyof DraftOrder)[] = [
|
|||||||
"no_notification_order",
|
"no_notification_order",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminPostDraftOrdersDraftOrderRegisterPaymentRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* order:
|
||||||
|
* $ref: "#/components/schemas/Order"
|
||||||
|
*/
|
||||||
export type AdminPostDraftOrdersDraftOrderRegisterPaymentRes = {
|
export type AdminPostDraftOrdersDraftOrderRegisterPaymentRes = {
|
||||||
order: Order
|
order: Order
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminDraftOrdersRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* draft_order:
|
||||||
|
* $ref: "#/components/schemas/DraftOrder"
|
||||||
|
*/
|
||||||
export type AdminDraftOrdersRes = {
|
export type AdminDraftOrdersRes = {
|
||||||
draft_order: DraftOrder
|
draft_order: DraftOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminDraftOrdersDeleteRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* id:
|
||||||
|
* type: string
|
||||||
|
* description: The ID of the deleted Draft Order.
|
||||||
|
* object:
|
||||||
|
* type: string
|
||||||
|
* description: The type of the object that was deleted.
|
||||||
|
* default: draft-order
|
||||||
|
* deleted:
|
||||||
|
* type: boolean
|
||||||
|
* description: Whether the draft order was deleted successfully or not.
|
||||||
|
* default: true
|
||||||
|
*/
|
||||||
export type AdminDraftOrdersDeleteRes = DeleteResponse
|
export type AdminDraftOrdersDeleteRes = DeleteResponse
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminDraftOrdersListRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* draft_orders:
|
||||||
|
* type: array
|
||||||
|
* items:
|
||||||
|
* $ref: "#/components/schemas/DraftOrder"
|
||||||
|
* count:
|
||||||
|
* type: integer
|
||||||
|
* description: The total number of items available
|
||||||
|
* offset:
|
||||||
|
* type: integer
|
||||||
|
* description: The number of items skipped before these items
|
||||||
|
* limit:
|
||||||
|
* type: integer
|
||||||
|
* description: The number of items per page
|
||||||
|
*/
|
||||||
export type AdminDraftOrdersListRes = PaginatedResponse & {
|
export type AdminDraftOrdersListRes = PaginatedResponse & {
|
||||||
draft_orders: DraftOrder[]
|
draft_orders: DraftOrder[]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,21 +48,7 @@ import { validator } from "../../../../utils/validator"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDraftOrdersListRes"
|
||||||
* properties:
|
|
||||||
* draft_orders:
|
|
||||||
* type: array
|
|
||||||
* items:
|
|
||||||
* $ref: "#/components/schemas/DraftOrder"
|
|
||||||
* count:
|
|
||||||
* type: integer
|
|
||||||
* description: The total number of items available
|
|
||||||
* offset:
|
|
||||||
* type: integer
|
|
||||||
* description: The number of items skipped before these items
|
|
||||||
* limit:
|
|
||||||
* type: integer
|
|
||||||
* description: The number of items per page
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -46,10 +46,7 @@ import { EntityManager } from "typeorm"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminPostDraftOrdersDraftOrderRegisterPaymentRes"
|
||||||
* properties:
|
|
||||||
* order:
|
|
||||||
* $ref: "#/components/schemas/DraftOrder"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -66,10 +66,7 @@ import { IsType } from "../../../../utils/validators/is-type"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDraftOrdersRes"
|
||||||
* properties:
|
|
||||||
* draft_order:
|
|
||||||
* $ref: "#/components/schemas/DraftOrder"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -59,10 +59,7 @@ import { validator } from "../../../../utils/validator"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminDraftOrdersRes"
|
||||||
* properties:
|
|
||||||
* draft_order:
|
|
||||||
* $ref: "#/components/schemas/DraftOrder"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -49,10 +49,7 @@ import { EntityManager } from "typeorm"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminGiftCardsRes"
|
||||||
* properties:
|
|
||||||
* gift_card:
|
|
||||||
* $ref: "#/components/schemas/GiftCard"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
@@ -67,13 +64,16 @@ import { EntityManager } from "typeorm"
|
|||||||
* $ref: "#/components/responses/500_error"
|
* $ref: "#/components/responses/500_error"
|
||||||
*/
|
*/
|
||||||
export default async (req, res) => {
|
export default async (req, res) => {
|
||||||
const validatedBody: AdminPostGiftCardsReq & { balance?: number } = req.validatedBody
|
const validatedBody: AdminPostGiftCardsReq & { balance?: number } =
|
||||||
|
req.validatedBody
|
||||||
validatedBody.balance = validatedBody.value
|
validatedBody.balance = validatedBody.value
|
||||||
|
|
||||||
const giftCardService: GiftCardService = req.scope.resolve("giftCardService")
|
const giftCardService: GiftCardService = req.scope.resolve("giftCardService")
|
||||||
const manager: EntityManager = req.scope.resolve("manager")
|
const manager: EntityManager = req.scope.resolve("manager")
|
||||||
const newly = await manager.transaction(async (transactionManager) => {
|
const newly = await manager.transaction(async (transactionManager) => {
|
||||||
return await giftCardService.withTransaction(transactionManager).create(validatedBody)
|
return await giftCardService
|
||||||
|
.withTransaction(transactionManager)
|
||||||
|
.create(validatedBody)
|
||||||
})
|
})
|
||||||
|
|
||||||
const giftCard = await giftCardService.retrieve(newly.id, {
|
const giftCard = await giftCardService.retrieve(newly.id, {
|
||||||
|
|||||||
@@ -35,19 +35,7 @@ import { EntityManager } from "typeorm"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminGiftCardsDeleteRes"
|
||||||
* properties:
|
|
||||||
* id:
|
|
||||||
* type: string
|
|
||||||
* description: The ID of the deleted Gift Card
|
|
||||||
* object:
|
|
||||||
* type: string
|
|
||||||
* description: The type of the object that was deleted.
|
|
||||||
* default: gift-card
|
|
||||||
* deleted:
|
|
||||||
* type: boolean
|
|
||||||
* description: Whether the gift card was deleted successfully or not.
|
|
||||||
* default: true
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -35,10 +35,7 @@ import { defaultAdminGiftCardFields, defaultAdminGiftCardRelations } from "./"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminGiftCardsRes"
|
||||||
* properties:
|
|
||||||
* gift_card:
|
|
||||||
* $ref: "#/components/schemas/GiftCard"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -2,9 +2,12 @@ import { Router } from "express"
|
|||||||
import "reflect-metadata"
|
import "reflect-metadata"
|
||||||
import { GiftCard } from "../../../.."
|
import { GiftCard } from "../../../.."
|
||||||
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
|
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
|
||||||
import middlewares, { transformQuery, transformBody } from "../../../middlewares"
|
import middlewares, {
|
||||||
|
transformBody,
|
||||||
|
transformQuery,
|
||||||
|
} from "../../../middlewares"
|
||||||
import { AdminGetGiftCardsParams } from "./list-gift-cards"
|
import { AdminGetGiftCardsParams } from "./list-gift-cards"
|
||||||
import { AdminPostGiftCardsReq } from './create-gift-card'
|
import { AdminPostGiftCardsReq } from "./create-gift-card"
|
||||||
|
|
||||||
const route = Router()
|
const route = Router()
|
||||||
|
|
||||||
@@ -53,12 +56,53 @@ export const defaultAdminGiftCardFields: (keyof GiftCard)[] = [
|
|||||||
|
|
||||||
export const defaultAdminGiftCardRelations = ["region", "order"]
|
export const defaultAdminGiftCardRelations = ["region", "order"]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminGiftCardsRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* gift_card:
|
||||||
|
* $ref: "#/components/schemas/GiftCard"
|
||||||
|
*/
|
||||||
export type AdminGiftCardsRes = {
|
export type AdminGiftCardsRes = {
|
||||||
gift_card: GiftCard
|
gift_card: GiftCard
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminGiftCardsDeleteRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* id:
|
||||||
|
* type: string
|
||||||
|
* description: The ID of the deleted Gift Card
|
||||||
|
* object:
|
||||||
|
* type: string
|
||||||
|
* description: The type of the object that was deleted.
|
||||||
|
* default: gift-card
|
||||||
|
* deleted:
|
||||||
|
* type: boolean
|
||||||
|
* description: Whether the gift card was deleted successfully or not.
|
||||||
|
* default: true
|
||||||
|
*/
|
||||||
export type AdminGiftCardsDeleteRes = DeleteResponse
|
export type AdminGiftCardsDeleteRes = DeleteResponse
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminGiftCardsListRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* gift_cards:
|
||||||
|
* type: array
|
||||||
|
* items:
|
||||||
|
* $ref: "#/components/schemas/GiftCard"
|
||||||
|
* count:
|
||||||
|
* type: integer
|
||||||
|
* description: The total number of items available
|
||||||
|
* offset:
|
||||||
|
* type: integer
|
||||||
|
* description: The number of items skipped before these items
|
||||||
|
* limit:
|
||||||
|
* type: integer
|
||||||
|
* description: The number of items per page
|
||||||
|
*/
|
||||||
export type AdminGiftCardsListRes = PaginatedResponse & {
|
export type AdminGiftCardsListRes = PaginatedResponse & {
|
||||||
gift_cards: GiftCard[]
|
gift_cards: GiftCard[]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,21 +43,7 @@ import { isDefined } from "medusa-core-utils"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminGiftCardsListRes"
|
||||||
* properties:
|
|
||||||
* gift_cards:
|
|
||||||
* type: array
|
|
||||||
* items:
|
|
||||||
* $ref: "#/components/schemas/GiftCard"
|
|
||||||
* count:
|
|
||||||
* type: integer
|
|
||||||
* description: The total number of items available
|
|
||||||
* offset:
|
|
||||||
* type: integer
|
|
||||||
* description: The number of items skipped before these items
|
|
||||||
* limit:
|
|
||||||
* type: integer
|
|
||||||
* description: The number of items per page
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -52,10 +52,7 @@ import { EntityManager } from "typeorm"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminGiftCardsRes"
|
||||||
* properties:
|
|
||||||
* gift_card:
|
|
||||||
* $ref: "#/components/schemas/GiftCard"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import InviteService from "../../../../services/invite"
|
|||||||
/**
|
/**
|
||||||
* @oas [delete] /invites/{invite_id}
|
* @oas [delete] /invites/{invite_id}
|
||||||
* operationId: "DeleteInvitesInvite"
|
* operationId: "DeleteInvitesInvite"
|
||||||
* summary: "Create an Invite"
|
* summary: "Delete an Invite"
|
||||||
* description: "Creates an Invite and triggers an 'invite' created event"
|
* description: "Deletes an Invite"
|
||||||
* x-authenticated: true
|
* x-authenticated: true
|
||||||
* parameters:
|
* parameters:
|
||||||
* - (path) invite_id=* {string} The ID of the Invite
|
* - (path) invite_id=* {string} The ID of the Invite
|
||||||
@@ -36,19 +36,7 @@ import InviteService from "../../../../services/invite"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminInviteDeleteRes"
|
||||||
* properties:
|
|
||||||
* id:
|
|
||||||
* type: string
|
|
||||||
* description: The ID of the deleted Invite.
|
|
||||||
* object:
|
|
||||||
* type: string
|
|
||||||
* description: The type of the object that was deleted.
|
|
||||||
* format: invite
|
|
||||||
* deleted:
|
|
||||||
* type: boolean
|
|
||||||
* description: Whether or not the Invite was deleted.
|
|
||||||
* default: true
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -32,8 +32,33 @@ export default (app) => {
|
|||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminInviteDeleteRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* id:
|
||||||
|
* type: string
|
||||||
|
* description: The ID of the deleted Invite.
|
||||||
|
* object:
|
||||||
|
* type: string
|
||||||
|
* description: The type of the object that was deleted.
|
||||||
|
* default: invite
|
||||||
|
* deleted:
|
||||||
|
* type: boolean
|
||||||
|
* description: Whether or not the Invite was deleted.
|
||||||
|
* default: true
|
||||||
|
*/
|
||||||
export type AdminInviteDeleteRes = DeleteResponse
|
export type AdminInviteDeleteRes = DeleteResponse
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminListInvitesRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* invites:
|
||||||
|
* type: array
|
||||||
|
* items:
|
||||||
|
* $ref: "#/components/schemas/Invite"
|
||||||
|
*/
|
||||||
export type AdminListInvitesRes = {
|
export type AdminListInvitesRes = {
|
||||||
invites: Invite[]
|
invites: Invite[]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,12 +33,7 @@ import InviteService from "../../../../services/invite"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminListInvitesRes"
|
||||||
* properties:
|
|
||||||
* invites:
|
|
||||||
* type: array
|
|
||||||
* items:
|
|
||||||
* $ref: "#/components/schemas/Invite"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -52,10 +52,7 @@ import { EntityManager } from "typeorm"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminNotesRes"
|
||||||
* properties:
|
|
||||||
* note:
|
|
||||||
* $ref: "#/components/schemas/Note"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -36,19 +36,7 @@ import NoteService from "../../../../services/note"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminNotesDeleteRes"
|
||||||
* properties:
|
|
||||||
* id:
|
|
||||||
* type: string
|
|
||||||
* description: The ID of the deleted Note.
|
|
||||||
* object:
|
|
||||||
* type: string
|
|
||||||
* description: The type of the object that was deleted.
|
|
||||||
* default: note
|
|
||||||
* deleted:
|
|
||||||
* type: boolean
|
|
||||||
* description: Whether or not the Note was deleted.
|
|
||||||
* default: true
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -35,10 +35,7 @@ import NoteService from "../../../../services/note"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminNotesRes"
|
||||||
* properties:
|
|
||||||
* note:
|
|
||||||
* $ref: "#/components/schemas/Note"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -22,12 +22,53 @@ export default (app) => {
|
|||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminNotesRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* note:
|
||||||
|
* $ref: "#/components/schemas/Note"
|
||||||
|
*/
|
||||||
export type AdminNotesRes = {
|
export type AdminNotesRes = {
|
||||||
note: Note
|
note: Note
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminNotesDeleteRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* id:
|
||||||
|
* type: string
|
||||||
|
* description: The ID of the deleted Note.
|
||||||
|
* object:
|
||||||
|
* type: string
|
||||||
|
* description: The type of the object that was deleted.
|
||||||
|
* default: note
|
||||||
|
* deleted:
|
||||||
|
* type: boolean
|
||||||
|
* description: Whether or not the Note was deleted.
|
||||||
|
* default: true
|
||||||
|
*/
|
||||||
export type AdminNotesDeleteRes = DeleteResponse
|
export type AdminNotesDeleteRes = DeleteResponse
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminNotesListRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* notes:
|
||||||
|
* type: array
|
||||||
|
* items:
|
||||||
|
* $ref: "#/components/schemas/Note"
|
||||||
|
* count:
|
||||||
|
* type: integer
|
||||||
|
* description: The total number of items available
|
||||||
|
* offset:
|
||||||
|
* type: integer
|
||||||
|
* description: The number of items skipped before these items
|
||||||
|
* limit:
|
||||||
|
* type: integer
|
||||||
|
* description: The number of items per page
|
||||||
|
*/
|
||||||
export type AdminNotesListRes = PaginatedResponse & {
|
export type AdminNotesListRes = PaginatedResponse & {
|
||||||
notes: Note[]
|
notes: Note[]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,21 +42,7 @@ import { validator } from "../../../../utils/validator"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminNotesListRes"
|
||||||
* properties:
|
|
||||||
* notes:
|
|
||||||
* type: array
|
|
||||||
* items:
|
|
||||||
* $ref: "#/components/schemas/Note"
|
|
||||||
* count:
|
|
||||||
* type: integer
|
|
||||||
* description: The total number of items available
|
|
||||||
* offset:
|
|
||||||
* type: integer
|
|
||||||
* description: The number of items skipped before these items
|
|
||||||
* limit:
|
|
||||||
* type: integer
|
|
||||||
* description: The number of items per page
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -49,10 +49,7 @@ import { EntityManager } from "typeorm"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminNotesRes"
|
||||||
* properties:
|
|
||||||
* note:
|
|
||||||
* $ref: "#/components/schemas/Note"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -36,10 +36,26 @@ export const defaultAdminNotificationsFields = [
|
|||||||
"updated_at",
|
"updated_at",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminNotificationsListRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* notifications:
|
||||||
|
* type: array
|
||||||
|
* items:
|
||||||
|
* $ref: "#/components/schemas/Notification"
|
||||||
|
*/
|
||||||
export type AdminNotificationsListRes = {
|
export type AdminNotificationsListRes = {
|
||||||
notifications: Notification[]
|
notifications: Notification[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @schema AdminNotificationsRes
|
||||||
|
* type: object
|
||||||
|
* properties:
|
||||||
|
* notification:
|
||||||
|
* $ref: "#/components/schemas/Notification"
|
||||||
|
*/
|
||||||
export type AdminNotificationsRes = {
|
export type AdminNotificationsRes = {
|
||||||
notification: Notification
|
notification: Notification
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,12 +54,7 @@ import { validator } from "../../../../utils/validator"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminNotificationsListRes"
|
||||||
* properties:
|
|
||||||
* notifications:
|
|
||||||
* type: array
|
|
||||||
* items:
|
|
||||||
* $ref: "#/components/schemas/Notification"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
@@ -49,10 +49,7 @@ import { validator } from "../../../../utils/validator"
|
|||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
* schema:
|
* schema:
|
||||||
* type: object
|
* $ref: "#/components/schemas/AdminNotificationsRes"
|
||||||
* properties:
|
|
||||||
* notification:
|
|
||||||
* $ref: "#/components/schemas/Notification"
|
|
||||||
* "400":
|
* "400":
|
||||||
* $ref: "#/components/responses/400_error"
|
* $ref: "#/components/responses/400_error"
|
||||||
* "401":
|
* "401":
|
||||||
|
|||||||
Reference in new issue
Block a user