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

This commit is contained in:
Shahed Nasser
2025-10-28 11:02:28 +02:00
committed by GitHub
parent c0cc70b2fb
commit 5b0c6e6a94
4 changed files with 17 additions and 7 deletions

View File

@@ -19,5 +19,8 @@ export interface AdminUpdateApiKey {
}
export interface AdminRevokeApiKey {
/**
* The number of seconds to wait before revoking the API key.
*/
revoke_in?: number
}

View File

@@ -3,12 +3,14 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/framework/http"
import { AdminRevokeApiKeyType } from "../../validators"
import { refetchApiKey } from "../../helpers"
import { HttpTypes } from "@medusajs/framework/types"
export const POST = async (
req: AuthenticatedMedusaRequest<AdminRevokeApiKeyType>,
req: AuthenticatedMedusaRequest<
HttpTypes.AdminRevokeApiKey,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminApiKeyResponse>
) => {
await revokeApiKeysWorkflow(req.scope).run({

View File

@@ -8,12 +8,11 @@ import {
} from "@medusajs/framework/http"
import { refetchApiKey } from "../helpers"
import { AdminUpdateApiKeyType } from "../validators"
import { MedusaError } from "@medusajs/framework/utils"
import { HttpTypes } from "@medusajs/framework/types"
export const GET = async (
req: AuthenticatedMedusaRequest,
req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.AdminApiKeyResponse>
) => {
const apiKey = await refetchApiKey(
@@ -33,7 +32,10 @@ export const GET = async (
}
export const POST = async (
req: AuthenticatedMedusaRequest<AdminUpdateApiKeyType>,
req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateApiKey,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminApiKeyResponse>
) => {
await updateApiKeysWorkflow(req.scope).run({

View File

@@ -1,5 +1,5 @@
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 {
AuthenticatedMedusaRequest,
@@ -8,7 +8,10 @@ import {
import { refetchApiKey } from "../../helpers"
export const POST = async (
req: AuthenticatedMedusaRequest<LinkMethodRequest>,
req: AuthenticatedMedusaRequest<
HttpTypes.AdminBatchLink,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminApiKeyResponse>
) => {
const { add, remove } = req.validatedBody