chore: fixes to HTTP and request types for API Keys (#13819)

This commit is contained in:
Shahed Nasser authored and GitHub committed 2025-10-28 10:02:28 +01:00
1 parent c0cc70b2fb
commit 5b0c6e6a94
4 files changed
+17 -7

No files matched your search

@@ -19,5 +19,8 @@ export interface AdminUpdateApiKey {
} }
export interface AdminRevokeApiKey { export interface AdminRevokeApiKey {
/**
* The number of seconds to wait before revoking the API key.
*/
revoke_in?: number revoke_in?: number
} }
@@ -3,12 +3,14 @@ import {
AuthenticatedMedusaRequest, AuthenticatedMedusaRequest,
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { AdminRevokeApiKeyType } from "../../validators"
import { refetchApiKey } from "../../helpers" import { refetchApiKey } from "../../helpers"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminRevokeApiKeyType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminRevokeApiKey,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminApiKeyResponse> res: MedusaResponse<HttpTypes.AdminApiKeyResponse>
) => { ) => {
await revokeApiKeysWorkflow(req.scope).run({ await revokeApiKeysWorkflow(req.scope).run({
@@ -8,12 +8,11 @@ import {
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { refetchApiKey } from "../helpers" import { refetchApiKey } from "../helpers"
import { AdminUpdateApiKeyType } from "../validators"
import { MedusaError } from "@medusajs/framework/utils" import { MedusaError } from "@medusajs/framework/utils"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const GET = async ( export const GET = async (
req: AuthenticatedMedusaRequest, req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.AdminApiKeyResponse> res: MedusaResponse<HttpTypes.AdminApiKeyResponse>
) => { ) => {
const apiKey = await refetchApiKey( const apiKey = await refetchApiKey(
@@ -33,7 +32,10 @@ export const GET = async (
} }
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminUpdateApiKeyType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateApiKey,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminApiKeyResponse> res: MedusaResponse<HttpTypes.AdminApiKeyResponse>
) => { ) => {
await updateApiKeysWorkflow(req.scope).run({ await updateApiKeysWorkflow(req.scope).run({
@@ -1,5 +1,5 @@
import { linkSalesChannelsToApiKeyWorkflow } from "@medusajs/core-flows" import { linkSalesChannelsToApiKeyWorkflow } from "@medusajs/core-flows"
import { HttpTypes, LinkMethodRequest } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
import { ApiKeyType, MedusaError } from "@medusajs/framework/utils" import { ApiKeyType, MedusaError } from "@medusajs/framework/utils"
import { import {
AuthenticatedMedusaRequest, AuthenticatedMedusaRequest,
@@ -8,7 +8,10 @@ import {
import { refetchApiKey } from "../../helpers" import { refetchApiKey } from "../../helpers"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<LinkMethodRequest>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminBatchLink,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminApiKeyResponse> res: MedusaResponse<HttpTypes.AdminApiKeyResponse>
) => { ) => {
const { add, remove } = req.validatedBody const { add, remove } = req.validatedBody