diff --git a/.changeset/stale-games-marry.md b/.changeset/stale-games-marry.md new file mode 100644 index 0000000000..e7e0bcfc90 --- /dev/null +++ b/.changeset/stale-games-marry.md @@ -0,0 +1,6 @@ +--- +"@medusajs/client-types": patch +"@medusajs/medusa": patch +--- + +fix(medusa): fix types for upload endpoints diff --git a/packages/generated/client-types/src/lib/models/AdminDeleteUploadsReq.ts b/packages/generated/client-types/src/lib/models/AdminDeleteUploadsReq.ts index 72bc3bdf47..85c5c188c6 100644 --- a/packages/generated/client-types/src/lib/models/AdminDeleteUploadsReq.ts +++ b/packages/generated/client-types/src/lib/models/AdminDeleteUploadsReq.ts @@ -5,7 +5,7 @@ import { SetRelation, Merge } from "../core/ModelUtils" export interface AdminDeleteUploadsReq { /** - * key of the file to delete + * key of the file to delete. This is obtained when you first uploaded the file, or by the file service if you used it directly. */ file_key: string } diff --git a/packages/generated/client-types/src/lib/models/AdminPostUploadsDownloadUrlReq.ts b/packages/generated/client-types/src/lib/models/AdminPostUploadsDownloadUrlReq.ts index ac15ae80ea..162c62e399 100644 --- a/packages/generated/client-types/src/lib/models/AdminPostUploadsDownloadUrlReq.ts +++ b/packages/generated/client-types/src/lib/models/AdminPostUploadsDownloadUrlReq.ts @@ -5,7 +5,7 @@ import { SetRelation, Merge } from "../core/ModelUtils" export interface AdminPostUploadsDownloadUrlReq { /** - * key of the file to obtain the download link for + * key of the file to obtain the download link for. This is obtained when you first uploaded the file, or by the file service if you used it directly. */ file_key: string } diff --git a/packages/generated/client-types/src/lib/models/AdminUploadsRes.ts b/packages/generated/client-types/src/lib/models/AdminUploadsRes.ts index 02e2392d07..f41b4d85b6 100644 --- a/packages/generated/client-types/src/lib/models/AdminUploadsRes.ts +++ b/packages/generated/client-types/src/lib/models/AdminUploadsRes.ts @@ -12,5 +12,9 @@ export interface AdminUploadsRes { * The URL of the uploaded file. */ url: string + /** + * The key of the file that is identifiable by the file service. It can be used later to retrieve or manipulate the file. + */ + key: string }> } diff --git a/packages/medusa/src/api/routes/admin/uploads/delete-upload.ts b/packages/medusa/src/api/routes/admin/uploads/delete-upload.ts index 2b5fb462d4..358fff5a1a 100644 --- a/packages/medusa/src/api/routes/admin/uploads/delete-upload.ts +++ b/packages/medusa/src/api/routes/admin/uploads/delete-upload.ts @@ -77,7 +77,7 @@ export default async (req, res) => { * - file_key * properties: * file_key: - * description: "key of the file to delete" + * description: "key of the file to delete. This is obtained when you first uploaded the file, or by the file service if you used it directly." * type: string */ export class AdminDeleteUploadsReq { diff --git a/packages/medusa/src/api/routes/admin/uploads/get-download-url.ts b/packages/medusa/src/api/routes/admin/uploads/get-download-url.ts index 1d1c960e40..ebf4037698 100644 --- a/packages/medusa/src/api/routes/admin/uploads/get-download-url.ts +++ b/packages/medusa/src/api/routes/admin/uploads/get-download-url.ts @@ -76,7 +76,7 @@ export default async (req, res) => { * - file_key * properties: * file_key: - * description: "key of the file to obtain the download link for" + * description: "key of the file to obtain the download link for. This is obtained when you first uploaded the file, or by the file service if you used it directly." * type: string */ export class AdminPostUploadsDownloadUrlReq { diff --git a/packages/medusa/src/api/routes/admin/uploads/index.ts b/packages/medusa/src/api/routes/admin/uploads/index.ts index 0f665f25bd..1908e812ec 100644 --- a/packages/medusa/src/api/routes/admin/uploads/index.ts +++ b/packages/medusa/src/api/routes/admin/uploads/index.ts @@ -5,6 +5,7 @@ import { DeleteResponse } from "../../../../types/common" import middlewares, { transformBody } from "../../../middlewares" import { AdminDeleteUploadsReq } from "./delete-upload" import { AdminPostUploadsDownloadUrlReq } from "./get-download-url" +import { FileServiceUploadResult } from "@medusajs/types" const route = Router() const upload = multer({ dest: "uploads/" }) @@ -52,14 +53,18 @@ export default (app) => { * type: object * required: * - url + * - key * properties: * url: * description: The URL of the uploaded file. * type: string * format: uri + * key: + * description: The key of the file that is identifiable by the file service. It can be used later to retrieve or manipulate the file. + * type: string */ export type AdminUploadsRes = { - uploads: { url: string }[] + uploads: FileServiceUploadResult[] } /**