diff --git a/.changeset/good-rabbits-pay.md b/.changeset/good-rabbits-pay.md new file mode 100644 index 0000000000..97cb7353f7 --- /dev/null +++ b/.changeset/good-rabbits-pay.md @@ -0,0 +1,5 @@ +--- +"@medusajs/medusa": patch +--- + +feat(oas): declare x-codegen on Admin routes - A to D diff --git a/packages/medusa/src/api/routes/admin/apps/authorize-app.ts b/packages/medusa/src/api/routes/admin/apps/authorize-app.ts index e516043b3d..dd7ad3a669 100644 --- a/packages/medusa/src/api/routes/admin/apps/authorize-app.ts +++ b/packages/medusa/src/api/routes/admin/apps/authorize-app.ts @@ -14,6 +14,8 @@ import { validator } from "../../../../utils/validator" * application/json: * schema: * $ref: "#/components/schemas/AdminPostAppsReq" + * x-codegen: + * method: authorize * x-codeSamples: * - lang: Shell * label: cURL diff --git a/packages/medusa/src/api/routes/admin/apps/list.ts b/packages/medusa/src/api/routes/admin/apps/list.ts index 2ba191832d..46c6776c27 100644 --- a/packages/medusa/src/api/routes/admin/apps/list.ts +++ b/packages/medusa/src/api/routes/admin/apps/list.ts @@ -6,6 +6,8 @@ import { OauthService } from "../../../../services" * summary: "List Applications" * description: "Retrieve a list of applications." * x-authenticated: true + * x-codegen: + * method: list * x-codeSamples: * - lang: Shell * label: cURL diff --git a/packages/medusa/src/api/routes/admin/auth/create-session.ts b/packages/medusa/src/api/routes/admin/auth/create-session.ts index 948ea3a5bb..a49ee369e4 100644 --- a/packages/medusa/src/api/routes/admin/auth/create-session.ts +++ b/packages/medusa/src/api/routes/admin/auth/create-session.ts @@ -21,6 +21,8 @@ import { validator } from "../../../../utils/validator" * application/json: * schema: * $ref: "#/components/schemas/AdminPostAuthReq" + * x-codegen: + * method: createSession * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/auth/delete-session.ts b/packages/medusa/src/api/routes/admin/auth/delete-session.ts index b7319bb94e..53aa6c9d0d 100644 --- a/packages/medusa/src/api/routes/admin/auth/delete-session.ts +++ b/packages/medusa/src/api/routes/admin/auth/delete-session.ts @@ -4,6 +4,8 @@ * summary: "User Logout" * x-authenticated: true * description: "Deletes the current session for the logged in user." + * x-codegen: + * method: deleteSession * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/auth/get-session.ts b/packages/medusa/src/api/routes/admin/auth/get-session.ts index 417996af2d..098ab665c3 100644 --- a/packages/medusa/src/api/routes/admin/auth/get-session.ts +++ b/packages/medusa/src/api/routes/admin/auth/get-session.ts @@ -7,6 +7,8 @@ import _ from "lodash" * summary: "Get Current User" * x-authenticated: true * description: "Gets the currently logged in User." + * x-codegen: + * method: getSession * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/batch/cancel-batch-job.ts b/packages/medusa/src/api/routes/admin/batch/cancel-batch-job.ts index 71eb2e447f..8473c06f0c 100644 --- a/packages/medusa/src/api/routes/admin/batch/cancel-batch-job.ts +++ b/packages/medusa/src/api/routes/admin/batch/cancel-batch-job.ts @@ -9,6 +9,8 @@ import { EntityManager } from "typeorm" * x-authenticated: true * parameters: * - (path) id=* {string} The ID of the batch job. + * x-codegen: + * method: cancel * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/batch/confirm-batch-job.ts b/packages/medusa/src/api/routes/admin/batch/confirm-batch-job.ts index 98b8c6d811..6bc4bb2bf7 100644 --- a/packages/medusa/src/api/routes/admin/batch/confirm-batch-job.ts +++ b/packages/medusa/src/api/routes/admin/batch/confirm-batch-job.ts @@ -9,6 +9,8 @@ import { EntityManager } from "typeorm" * x-authenticated: true * parameters: * - (path) id=* {string} The ID of the batch job. + * x-codegen: + * method: confirm * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/batch/create-batch-job.ts b/packages/medusa/src/api/routes/admin/batch/create-batch-job.ts index b289606821..ee0704a5a6 100644 --- a/packages/medusa/src/api/routes/admin/batch/create-batch-job.ts +++ b/packages/medusa/src/api/routes/admin/batch/create-batch-job.ts @@ -16,6 +16,8 @@ import { validator } from "../../../../utils/validator" * application/json: * schema: * $ref: "#/components/schemas/AdminPostBatchesReq" + * x-codegen: + * method: create * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/batch/get-batch-job.ts b/packages/medusa/src/api/routes/admin/batch/get-batch-job.ts index b3fe0c2d3a..356540108f 100644 --- a/packages/medusa/src/api/routes/admin/batch/get-batch-job.ts +++ b/packages/medusa/src/api/routes/admin/batch/get-batch-job.ts @@ -6,6 +6,8 @@ * x-authenticated: true * parameters: * - (path) id=* {string} The ID of the Batch Job + * x-codegen: + * method: retrieve * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/batch/list-batch-jobs.ts b/packages/medusa/src/api/routes/admin/batch/list-batch-jobs.ts index f36ed50ddc..26b4dc4498 100644 --- a/packages/medusa/src/api/routes/admin/batch/list-batch-jobs.ts +++ b/packages/medusa/src/api/routes/admin/batch/list-batch-jobs.ts @@ -210,6 +210,9 @@ import { isDefined } from "medusa-core-utils" * type: string * description: filter by dates greater than or equal to this date * format: date + * x-codegen: + * method: list + * queryParams: AdminGetBatchParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/collections/add-products.ts b/packages/medusa/src/api/routes/admin/collections/add-products.ts index 2da41a60f2..2028d797e7 100644 --- a/packages/medusa/src/api/routes/admin/collections/add-products.ts +++ b/packages/medusa/src/api/routes/admin/collections/add-products.ts @@ -17,6 +17,8 @@ import ProductCollectionService from "../../../../services/product-collection" * application/json: * schema: * $ref: "#/components/schemas/AdminPostProductsToCollectionReq" + * x-codegen: + * method: addProducts * x-codeSamples: * - lang: Shell * label: cURL diff --git a/packages/medusa/src/api/routes/admin/collections/create-collection.ts b/packages/medusa/src/api/routes/admin/collections/create-collection.ts index 498f1525a2..0b046b274b 100644 --- a/packages/medusa/src/api/routes/admin/collections/create-collection.ts +++ b/packages/medusa/src/api/routes/admin/collections/create-collection.ts @@ -14,6 +14,8 @@ import { EntityManager } from "typeorm" * application/json: * schema: * $ref: "#/components/schemas/AdminPostCollectionsReq" + * x-codegen: + * method: create * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/collections/delete-collection.ts b/packages/medusa/src/api/routes/admin/collections/delete-collection.ts index cd47a31ca9..c6dbc3a1af 100644 --- a/packages/medusa/src/api/routes/admin/collections/delete-collection.ts +++ b/packages/medusa/src/api/routes/admin/collections/delete-collection.ts @@ -11,6 +11,8 @@ import ProductCollectionService from "../../../../services/product-collection" * x-authenticated: true * parameters: * - (path) id=* {string} The ID of the Collection. + * x-codegen: + * method: delete * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/collections/get-collection.ts b/packages/medusa/src/api/routes/admin/collections/get-collection.ts index aed4dd1b77..97c4a5ce83 100644 --- a/packages/medusa/src/api/routes/admin/collections/get-collection.ts +++ b/packages/medusa/src/api/routes/admin/collections/get-collection.ts @@ -11,6 +11,8 @@ import { defaultAdminCollectionsRelations } from "." * x-authenticated: true * parameters: * - (path) id=* {string} The ID of the Product Collection + * x-codegen: + * method: retrieve * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/collections/list-collections.ts b/packages/medusa/src/api/routes/admin/collections/list-collections.ts index ea0ed5fb10..154cea4e52 100644 --- a/packages/medusa/src/api/routes/admin/collections/list-collections.ts +++ b/packages/medusa/src/api/routes/admin/collections/list-collections.ts @@ -84,6 +84,9 @@ import { Type } from "class-transformer" * type: string * description: filter by dates greater than or equal to this date * format: date + * x-codegen: + * method: list + * queryParams: AdminGetCollectionsParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/collections/remove-products.ts b/packages/medusa/src/api/routes/admin/collections/remove-products.ts index 8e9c75a409..e42915a738 100644 --- a/packages/medusa/src/api/routes/admin/collections/remove-products.ts +++ b/packages/medusa/src/api/routes/admin/collections/remove-products.ts @@ -17,6 +17,8 @@ import ProductCollectionService from "../../../../services/product-collection" * application/json: * schema: * $ref: "#/components/schemas/AdminDeleteProductsFromCollectionReq" + * x-codegen: + * method: removeProducts * x-codeSamples: * - lang: Shell * label: cURL diff --git a/packages/medusa/src/api/routes/admin/collections/update-collection.ts b/packages/medusa/src/api/routes/admin/collections/update-collection.ts index f6b572fb75..7fcff59c6a 100644 --- a/packages/medusa/src/api/routes/admin/collections/update-collection.ts +++ b/packages/medusa/src/api/routes/admin/collections/update-collection.ts @@ -16,6 +16,8 @@ import ProductCollectionService from "../../../../services/product-collection" * application/json: * schema: * $ref: "#/components/schemas/AdminPostCollectionsCollectionReq" + * x-codegen: + * method: update * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/currencies/list-currencies.ts b/packages/medusa/src/api/routes/admin/currencies/list-currencies.ts index aad9d4ea49..8e768fa4bd 100644 --- a/packages/medusa/src/api/routes/admin/currencies/list-currencies.ts +++ b/packages/medusa/src/api/routes/admin/currencies/list-currencies.ts @@ -18,6 +18,9 @@ import { FeatureFlagDecorators } from "../../../../utils/feature-flag-decorators * - (query) order {string} order to retrieve products in. * - (query) offset=0 {number} How many products to skip in the result. * - (query) limit=20 {number} Limit the number of products returned. + * x-codegen: + * method: list + * queryParams: AdminGetCurrenciesParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/currencies/update-currency.ts b/packages/medusa/src/api/routes/admin/currencies/update-currency.ts index 4d16a78573..090d6fb2cc 100644 --- a/packages/medusa/src/api/routes/admin/currencies/update-currency.ts +++ b/packages/medusa/src/api/routes/admin/currencies/update-currency.ts @@ -18,6 +18,8 @@ import TaxInclusivePricingFeatureFlag from "../../../../loaders/feature-flags/ta * application/json: * schema: * $ref: "#/components/schemas/AdminPostCurrenciesCurrencyReq" + * x-codegen: + * method: update * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/customer-groups/add-customers-batch.ts b/packages/medusa/src/api/routes/admin/customer-groups/add-customers-batch.ts index 4b5152a214..6dd9ba0ec7 100644 --- a/packages/medusa/src/api/routes/admin/customer-groups/add-customers-batch.ts +++ b/packages/medusa/src/api/routes/admin/customer-groups/add-customers-batch.ts @@ -20,6 +20,8 @@ import { validator } from "../../../../utils/validator" * application/json: * schema: * $ref: "#/components/schemas/AdminPostCustomerGroupsGroupCustomersBatchReq" + * x-codegen: + * method: addCustomers * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/customer-groups/create-customer-group.ts b/packages/medusa/src/api/routes/admin/customer-groups/create-customer-group.ts index 4653f50b94..8382f3a8e0 100644 --- a/packages/medusa/src/api/routes/admin/customer-groups/create-customer-group.ts +++ b/packages/medusa/src/api/routes/admin/customer-groups/create-customer-group.ts @@ -11,9 +11,13 @@ import { validator } from "../../../../utils/validator" * summary: "Create a Customer Group" * description: "Creates a CustomerGroup." * x-authenticated: true - * parameters: - * - (body) name=* {string} Name of the customer group - * - (body) metadata {object} Metadata for the customer. + * requestBody: + * content: + * application/json: + * schema: + * $ref: "#/components/schemas/AdminPostCustomerGroupsReq" + * x-codegen: + * method: create * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -81,6 +85,19 @@ export default async (req: Request, res: Response) => { res.status(200).json({ customer_group: customerGroup }) } +/** + * @schema AdminPostCustomerGroupsReq + * type: object + * required: + * - name + * properties: + * name: + * type: string + * description: Name of the customer group + * metadata: + * type: object + * description: Metadata for the customer. + */ export class AdminPostCustomerGroupsReq { @IsString() name: string diff --git a/packages/medusa/src/api/routes/admin/customer-groups/delete-customer-group.ts b/packages/medusa/src/api/routes/admin/customer-groups/delete-customer-group.ts index 8c166b8e3e..47cdb6e963 100644 --- a/packages/medusa/src/api/routes/admin/customer-groups/delete-customer-group.ts +++ b/packages/medusa/src/api/routes/admin/customer-groups/delete-customer-group.ts @@ -11,6 +11,8 @@ import { EntityManager } from "typeorm" * x-authenticated: true * parameters: * - (path) id=* {string} The ID of the Customer Group + * x-codegen: + * method: delete * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/customer-groups/delete-customers-batch.ts b/packages/medusa/src/api/routes/admin/customer-groups/delete-customers-batch.ts index 8d32efec43..da89bc6a58 100644 --- a/packages/medusa/src/api/routes/admin/customer-groups/delete-customers-batch.ts +++ b/packages/medusa/src/api/routes/admin/customer-groups/delete-customers-batch.ts @@ -20,6 +20,8 @@ import { validator } from "../../../../utils/validator" * application/json: * schema: * $ref: "#/components/schemas/AdminDeleteCustomerGroupsGroupCustomerBatchReq" + * x-codegen: + * method: removeCustomers * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/customer-groups/get-customer-group-customers.ts b/packages/medusa/src/api/routes/admin/customer-groups/get-customer-group-customers.ts index d76530e0e3..2f5a7e2334 100644 --- a/packages/medusa/src/api/routes/admin/customer-groups/get-customer-group-customers.ts +++ b/packages/medusa/src/api/routes/admin/customer-groups/get-customer-group-customers.ts @@ -1,6 +1,8 @@ import { Request, Response } from "express" import CustomerController from "../../../../controllers/customers" +import { IsNumber, IsOptional, IsString } from "class-validator" +import { Type } from "class-transformer" /** * @oas [get] /customer-groups/{id}/customers @@ -10,6 +12,13 @@ import CustomerController from "../../../../controllers/customers" * x-authenticated: true * parameters: * - (path) id=* {string} The ID of the customer group. + * - (query) limit=50 {integer} The number of items to return. + * - (query) offset=0 {integer} The items to skip before result. + * - (query) expand {string} (Comma separated) Which fields should be expanded in each customer. + * - (query) q {string} a search term to search email, first_name, and last_name. + * x-codegen: + * method: listCustomers + * queryParams: AdminGetGroupsGroupCustomersParams * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -64,3 +73,25 @@ export default async (req: Request, res: Response) => { res.json(result) } + +// eslint-disable-next-line max-len +export class AdminGetGroupsGroupCustomersParams { + @IsString() + @IsOptional() + q?: string + + @IsNumber() + @IsOptional() + @Type(() => Number) + limit = 50 + + @IsOptional() + @IsNumber() + @IsOptional() + @Type(() => Number) + offset = 0 + + @IsString() + @IsOptional() + expand?: string +} diff --git a/packages/medusa/src/api/routes/admin/customer-groups/get-customer-group.ts b/packages/medusa/src/api/routes/admin/customer-groups/get-customer-group.ts index d82777cca4..78da680d7a 100644 --- a/packages/medusa/src/api/routes/admin/customer-groups/get-customer-group.ts +++ b/packages/medusa/src/api/routes/admin/customer-groups/get-customer-group.ts @@ -13,6 +13,9 @@ import { FindParams } from "../../../../types/common" * - (path) id=* {string} The ID of the Customer Group. * - (query) expand {string} (Comma separated) Which fields should be expanded in the customer group. * - (query) fields {string} (Comma separated) Which fields should be included in the customer group. + * x-codegen: + * method: retrieve + * queryParams: AdminGetCustomerGroupsGroupParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/customer-groups/list-customer-groups.ts b/packages/medusa/src/api/routes/admin/customer-groups/list-customer-groups.ts index a40c41f3e7..00158f07ef 100644 --- a/packages/medusa/src/api/routes/admin/customer-groups/list-customer-groups.ts +++ b/packages/medusa/src/api/routes/admin/customer-groups/list-customer-groups.ts @@ -100,6 +100,9 @@ import { Type } from "class-transformer" * format: date * - (query) limit=10 {integer} Limit the number of customer groups returned. * - (query) expand {string} (Comma separated) Which fields should be expanded in each customer groups of the result. + * x-codegen: + * method: list + * queryParams: AdminGetCustomerGroupsParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/customer-groups/update-customer-group.ts b/packages/medusa/src/api/routes/admin/customer-groups/update-customer-group.ts index 474f78acfb..4f2f86bde7 100644 --- a/packages/medusa/src/api/routes/admin/customer-groups/update-customer-group.ts +++ b/packages/medusa/src/api/routes/admin/customer-groups/update-customer-group.ts @@ -20,6 +20,8 @@ import { validator } from "../../../../utils/validator" * application/json: * schema: * $ref: "#/components/schemas/AdminPostCustomerGroupsGroupReq" + * x-codegen: + * method: update * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/customers/create-customer.ts b/packages/medusa/src/api/routes/admin/customers/create-customer.ts index d12155f385..17ac6c50af 100644 --- a/packages/medusa/src/api/routes/admin/customers/create-customer.ts +++ b/packages/medusa/src/api/routes/admin/customers/create-customer.ts @@ -15,8 +15,8 @@ import { EntityManager } from "typeorm" * application/json: * schema: * $ref: "#/components/schemas/AdminPostCustomersReq" - * tags: - * - Customer + * x-codegen: + * method: create * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -48,6 +48,8 @@ import { EntityManager } from "typeorm" * security: * - api_token: [] * - cookie_auth: [] + * tags: + * - Customer * responses: * 201: * description: OK diff --git a/packages/medusa/src/api/routes/admin/customers/get-customer.ts b/packages/medusa/src/api/routes/admin/customers/get-customer.ts index 80adc494b2..0063cecb9e 100644 --- a/packages/medusa/src/api/routes/admin/customers/get-customer.ts +++ b/packages/medusa/src/api/routes/admin/customers/get-customer.ts @@ -13,6 +13,8 @@ import { validator } from "../../../../utils/validator" * - (path) id=* {string} The ID of the Customer. * - (query) expand {string} (Comma separated) Which fields should be expanded in the customer. * - (query) fields {string} (Comma separated) Which fields should be included in the customer. + * x-codegen: + * method: retrieve * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/customers/list-customers.ts b/packages/medusa/src/api/routes/admin/customers/list-customers.ts index 775b76189e..c3947cda0a 100644 --- a/packages/medusa/src/api/routes/admin/customers/list-customers.ts +++ b/packages/medusa/src/api/routes/admin/customers/list-customers.ts @@ -16,6 +16,9 @@ import customerController from "../../../../controllers/customers" * - (query) expand {string} (Comma separated) Which fields should be expanded in each customer. * - (query) q {string} a search term to search email, first_name, and last_name. * - (query) groups[] {string} group IDs to search customers by. + * x-codegen: + * method: list + * queryParams: AdminGetCustomersParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/customers/update-customer.ts b/packages/medusa/src/api/routes/admin/customers/update-customer.ts index f57a56bbc4..e66e1b340e 100644 --- a/packages/medusa/src/api/routes/admin/customers/update-customer.ts +++ b/packages/medusa/src/api/routes/admin/customers/update-customer.ts @@ -30,6 +30,8 @@ import { validator } from "../../../../utils/validator" * application/json: * schema: * $ref: "#/components/schemas/AdminPostCustomersCustomerReq" + * x-codegen: + * method: update * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/discounts/add-region.ts b/packages/medusa/src/api/routes/admin/discounts/add-region.ts index 75e00408db..3f0b89d7a3 100644 --- a/packages/medusa/src/api/routes/admin/discounts/add-region.ts +++ b/packages/medusa/src/api/routes/admin/discounts/add-region.ts @@ -13,6 +13,8 @@ import { EntityManager } from "typeorm" * parameters: * - (path) id=* {string} The ID of the Discount. * - (path) region_id=* {string} The ID of the Region. + * x-codegen: + * method: addRegion * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/discounts/add-resources-to-condition-batch.ts b/packages/medusa/src/api/routes/admin/discounts/add-resources-to-condition-batch.ts index 8c6775bd2b..768e4f3959 100644 --- a/packages/medusa/src/api/routes/admin/discounts/add-resources-to-condition-batch.ts +++ b/packages/medusa/src/api/routes/admin/discounts/add-resources-to-condition-batch.ts @@ -25,6 +25,9 @@ import { FindParams } from "../../../../types/common" * application/json: * schema: * $ref: "#/components/schemas/AdminPostDiscountsDiscountConditionsConditionBatchReq" + * x-codegen: + * method: addConditionResourceBatch + * queryParams: AdminPostDiscountsDiscountConditionsConditionBatchParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/discounts/create-condition.ts b/packages/medusa/src/api/routes/admin/discounts/create-condition.ts index b42785d859..3c4ab2a91f 100644 --- a/packages/medusa/src/api/routes/admin/discounts/create-condition.ts +++ b/packages/medusa/src/api/routes/admin/discounts/create-condition.ts @@ -23,6 +23,9 @@ import { FindParams } from "../../../../types/common" * application/json: * schema: * $ref: "#/components/schemas/AdminPostDiscountsDiscountConditions" + * x-codegen: + * method: createCondition + * queryParams: AdminPostDiscountsDiscountConditionsParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/discounts/create-discount.ts b/packages/medusa/src/api/routes/admin/discounts/create-discount.ts index 7e8a13fbb6..adcb84abf9 100644 --- a/packages/medusa/src/api/routes/admin/discounts/create-discount.ts +++ b/packages/medusa/src/api/routes/admin/discounts/create-discount.ts @@ -32,13 +32,16 @@ import { FindParams } from "../../../../types/common" * x-authenticated: true * description: "Creates a Discount with a given set of rules that define how the Discount behaves." * parameters: - * - (query) expand {string} (Comma separated) Which fields should be expanded in each customer. - * - (query) fields {string} (Comma separated) Which fields should be retrieved in each customer. + * - (query) expand {string} (Comma separated) Which fields should be expanded in the results. + * - (query) fields {string} (Comma separated) Which fields should be retrieved in the results. * requestBody: * content: * application/json: * schema: * $ref: "#/components/schemas/AdminPostDiscountsReq" + * x-codegen: + * method: create + * queryParams: AdminPostDiscountsParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/discounts/create-dynamic-code.ts b/packages/medusa/src/api/routes/admin/discounts/create-dynamic-code.ts index b152e4867a..bad529debd 100644 --- a/packages/medusa/src/api/routes/admin/discounts/create-dynamic-code.ts +++ b/packages/medusa/src/api/routes/admin/discounts/create-dynamic-code.ts @@ -19,9 +19,13 @@ import { EntityManager } from "typeorm" * x-authenticated: true * parameters: * - (path) id=* {string} The ID of the Discount to create the dynamic code from." - * - (body) code=* {string} The unique code that will be used to redeem the Discount. - * - (body) usage_limit=1 {number} amount of times the discount can be applied. - * - (body) metadata {object} An optional set of key-value paris to hold additional information. + * requestBody: + * content: + * application/json: + * schema: + * $ref: "#/components/schemas/AdminPostDiscountsDiscountDynamicCodesReq" + * x-codegen: + * method: createDynamicCode * x-codeSamples: * - lang: JavaScript * label: JS Client @@ -92,6 +96,23 @@ export default async (req: Request, res: Response) => { res.status(200).json({ discount }) } +/** + * @schema AdminPostDiscountsDiscountDynamicCodesReq + * type: object + * required: + * - code + * properties: + * code: + * type: string + * description: A unique code that will be used to redeem the Discount + * usage_limit: + * type: number + * description: Maximum times the discount can be used + * default: 1 + * metadata: + * type: object + * description: An optional set of key-value pairs to hold additional information. + */ export class AdminPostDiscountsDiscountDynamicCodesReq { @IsString() @IsNotEmpty() diff --git a/packages/medusa/src/api/routes/admin/discounts/delete-condition.ts b/packages/medusa/src/api/routes/admin/discounts/delete-condition.ts index a61af2418d..ed0c27a1ac 100644 --- a/packages/medusa/src/api/routes/admin/discounts/delete-condition.ts +++ b/packages/medusa/src/api/routes/admin/discounts/delete-condition.ts @@ -15,6 +15,9 @@ import { FindParams } from "../../../../types/common" * - (path) condition_id=* {string} The ID of the DiscountCondition * - (query) expand {string} Comma separated list of relations to include in the results. * - (query) fields {string} Comma separated list of fields to include in the results. + * x-codegen: + * method: deleteCondition + * queryParams: AdminDeleteDiscountsDiscountConditionsConditionParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/discounts/delete-discount.ts b/packages/medusa/src/api/routes/admin/discounts/delete-discount.ts index d67e37157a..34070cc755 100644 --- a/packages/medusa/src/api/routes/admin/discounts/delete-discount.ts +++ b/packages/medusa/src/api/routes/admin/discounts/delete-discount.ts @@ -9,6 +9,8 @@ import { EntityManager } from "typeorm" * x-authenticated: true * parameters: * - (path) id=* {string} The ID of the Discount + * x-codegen: + * method: delete * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/discounts/delete-dynamic-code.ts b/packages/medusa/src/api/routes/admin/discounts/delete-dynamic-code.ts index 972e72d963..b8296f4261 100644 --- a/packages/medusa/src/api/routes/admin/discounts/delete-dynamic-code.ts +++ b/packages/medusa/src/api/routes/admin/discounts/delete-dynamic-code.ts @@ -12,6 +12,8 @@ import { EntityManager } from "typeorm" * parameters: * - (path) id=* {string} The ID of the Discount * - (path) code=* {string} The ID of the Discount + * x-codegen: + * method: deleteDynamicCode * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/discounts/delete-resources-from-condition-batch.ts b/packages/medusa/src/api/routes/admin/discounts/delete-resources-from-condition-batch.ts index 21c5d4826f..df6192ad31 100644 --- a/packages/medusa/src/api/routes/admin/discounts/delete-resources-from-condition-batch.ts +++ b/packages/medusa/src/api/routes/admin/discounts/delete-resources-from-condition-batch.ts @@ -24,6 +24,8 @@ import { FindParams } from "../../../../types/common" * application/json: * schema: * $ref: "#/components/schemas/AdminDeleteDiscountsDiscountConditionsConditionBatchReq" + * x-codegen: + * method: deleteConditionResourceBatch * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/discounts/get-condition.ts b/packages/medusa/src/api/routes/admin/discounts/get-condition.ts index 76ea22dfad..3952718cc2 100644 --- a/packages/medusa/src/api/routes/admin/discounts/get-condition.ts +++ b/packages/medusa/src/api/routes/admin/discounts/get-condition.ts @@ -13,6 +13,9 @@ import { FindParams } from "../../../../types/common" * - (path) condition_id=* {string} The ID of the DiscountCondition. * - (query) expand {string} Comma separated list of relations to include in the results. * - (query) fields {string} Comma separated list of fields to include in the results. + * x-codegen: + * method: getCondition + * queryParams: AdminGetDiscountsDiscountConditionsConditionParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/discounts/get-discount-by-code.ts b/packages/medusa/src/api/routes/admin/discounts/get-discount-by-code.ts index 83f1dae940..bbfa30ade9 100644 --- a/packages/medusa/src/api/routes/admin/discounts/get-discount-by-code.ts +++ b/packages/medusa/src/api/routes/admin/discounts/get-discount-by-code.ts @@ -12,6 +12,9 @@ import { FindParams } from "../../../../types/common" * - (path) code=* {string} The code of the Discount * - (query) expand {string} Comma separated list of relations to include in the results. * - (query) fields {string} Comma separated list of fields to include in the results. + * x-codegen: + * method: retrieveByCode + * queryParams: AdminGetDiscountsDiscountCodeParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/discounts/get-discount.ts b/packages/medusa/src/api/routes/admin/discounts/get-discount.ts index 24b413d55a..192f2716aa 100644 --- a/packages/medusa/src/api/routes/admin/discounts/get-discount.ts +++ b/packages/medusa/src/api/routes/admin/discounts/get-discount.ts @@ -12,6 +12,9 @@ import { FindParams } from "../../../../types/common" * - (path) id=* {string} The ID of the Discount * - (query) expand {string} Comma separated list of relations to include in the results. * - (query) fields {string} Comma separated list of fields to include in the results. + * x-codegen: + * method: retrieve + * queryParams: AdminGetDiscountParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/discounts/list-discounts.ts b/packages/medusa/src/api/routes/admin/discounts/list-discounts.ts index 39cdddcbc0..7f793979c3 100644 --- a/packages/medusa/src/api/routes/admin/discounts/list-discounts.ts +++ b/packages/medusa/src/api/routes/admin/discounts/list-discounts.ts @@ -39,6 +39,9 @@ import { optionalBooleanMapper } from "../../../../utils/validators/is-boolean" * - (query) limit=20 {number} The number of items in the response * - (query) offset=0 {number} The offset of items in response * - (query) expand {string} Comma separated list of relations to include in the results. + * x-codegen: + * method: list + * queryParams: AdminGetDiscountsParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/discounts/remove-region.ts b/packages/medusa/src/api/routes/admin/discounts/remove-region.ts index 402fbb3d1e..ca9556653d 100644 --- a/packages/medusa/src/api/routes/admin/discounts/remove-region.ts +++ b/packages/medusa/src/api/routes/admin/discounts/remove-region.ts @@ -12,6 +12,8 @@ import { EntityManager } from "typeorm" * parameters: * - (path) id=* {string} The ID of the Discount. * - (path) region_id=* {string} The ID of the Region. + * x-codegen: + * method: removeRegion * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/discounts/update-condition.ts b/packages/medusa/src/api/routes/admin/discounts/update-condition.ts index b772a4805d..2cc541f473 100644 --- a/packages/medusa/src/api/routes/admin/discounts/update-condition.ts +++ b/packages/medusa/src/api/routes/admin/discounts/update-condition.ts @@ -21,6 +21,9 @@ import { FindParams } from "../../../../types/common" * application/json: * schema: * $ref: "#/components/schemas/AdminPostDiscountsDiscountConditionsCondition" + * x-codegen: + * method: updateCondition + * queryParams: AdminPostDiscountsDiscountConditionsConditionParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/discounts/update-discount.ts b/packages/medusa/src/api/routes/admin/discounts/update-discount.ts index c1a8896759..8b761e1bd4 100644 --- a/packages/medusa/src/api/routes/admin/discounts/update-discount.ts +++ b/packages/medusa/src/api/routes/admin/discounts/update-discount.ts @@ -37,6 +37,9 @@ import { FindParams } from "../../../../types/common" * application/json: * schema: * $ref: "#/components/schemas/AdminPostDiscountsDiscountReq" + * x-codegen: + * method: update + * queryParams: AdminPostDiscountsDiscountParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.ts b/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.ts index 353c002130..8e65df24e3 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/create-draft-order.ts @@ -37,6 +37,8 @@ import { IsType } from "../../../../utils/validators/is-type" * application/json: * schema: * $ref: "#/components/schemas/AdminPostDraftOrdersReq" + * x-codegen: + * method: create * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/draft-orders/create-line-item.ts b/packages/medusa/src/api/routes/admin/draft-orders/create-line-item.ts index b5603fef6e..18497b0911 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/create-line-item.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/create-line-item.ts @@ -27,6 +27,8 @@ import { validator } from "../../../../utils/validator" * application/json: * schema: * $ref: "#/components/schemas/AdminPostDraftOrdersDraftOrderLineItemsReq" + * x-codegen: + * method: addLineItem * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/draft-orders/delete-draft-order.ts b/packages/medusa/src/api/routes/admin/draft-orders/delete-draft-order.ts index 665ed0abca..060277005a 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/delete-draft-order.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/delete-draft-order.ts @@ -9,6 +9,8 @@ import { EntityManager } from "typeorm" * x-authenticated: true * parameters: * - (path) id=* {string} The ID of the Draft Order. + * x-codegen: + * method: delete * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/draft-orders/delete-line-item.ts b/packages/medusa/src/api/routes/admin/draft-orders/delete-line-item.ts index 52c1e0d7c6..4395817cbc 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/delete-line-item.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/delete-line-item.ts @@ -18,6 +18,8 @@ import { MedusaError } from "medusa-core-utils" * parameters: * - (path) id=* {string} The ID of the Draft Order. * - (path) line_id=* {string} The ID of the Draft Order. + * x-codegen: + * method: removeLineItem * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/draft-orders/get-draft-order.ts b/packages/medusa/src/api/routes/admin/draft-orders/get-draft-order.ts index e07c96e246..c3c87382ba 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/get-draft-order.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/get-draft-order.ts @@ -16,6 +16,8 @@ import { DraftOrder } from "../../../.." * x-authenticated: true * parameters: * - (path) id=* {string} The ID of the Draft Order. + * x-codegen: + * method: retrieve * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/draft-orders/list-draft-orders.ts b/packages/medusa/src/api/routes/admin/draft-orders/list-draft-orders.ts index 8f0874e24d..85a6b96f8f 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/list-draft-orders.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/list-draft-orders.ts @@ -21,6 +21,9 @@ import { validator } from "../../../../utils/validator" * - (query) offset=0 {number} The number of items to skip before the results. * - (query) limit=50 {number} Limit the number of items returned. * - (query) q {string} a search term to search emails in carts associated with draft orders and display IDs of draft orders + * x-codegen: + * method: list + * queryParams: AdminGetDraftOrdersParams * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/draft-orders/register-payment.ts b/packages/medusa/src/api/routes/admin/draft-orders/register-payment.ts index 96144e0c77..c3632fdb59 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/register-payment.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/register-payment.ts @@ -22,6 +22,8 @@ import { MedusaError } from "medusa-core-utils" * x-authenticated: true * parameters: * - (path) id=* {String} The Draft Order id. + * x-codegen: + * method: markPaid * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.ts b/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.ts index abe861d379..78abe0ab09 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/update-draft-order.ts @@ -33,6 +33,8 @@ import { IsType } from "../../../../utils/validators/is-type" * application/json: * schema: * $ref: "#/components/schemas/AdminPostDraftOrdersDraftOrderReq" + * x-codegen: + * method: update * x-codeSamples: * - lang: JavaScript * label: JS Client diff --git a/packages/medusa/src/api/routes/admin/draft-orders/update-line-item.ts b/packages/medusa/src/api/routes/admin/draft-orders/update-line-item.ts index db4d83ab7f..c38ba03aec 100644 --- a/packages/medusa/src/api/routes/admin/draft-orders/update-line-item.ts +++ b/packages/medusa/src/api/routes/admin/draft-orders/update-line-item.ts @@ -26,6 +26,8 @@ import { validator } from "../../../../utils/validator" * application/json: * schema: * $ref: "#/components/schemas/AdminPostDraftOrdersDraftOrderLineItemsItemReq" + * x-codegen: + * method: updateLineItem * x-codeSamples: * - lang: JavaScript * label: JS Client