fix(medusa, medusa-js): publishable api key bugs (#5926)
* fix: publishable api key bugs * Create old-meals-run.md
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
import { Router } from "express"
|
||||
|
||||
import { PublishableApiKey, SalesChannel } from "../../../../models"
|
||||
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
|
||||
import middlewares, {
|
||||
transformBody,
|
||||
transformQuery,
|
||||
} from "../../../middlewares"
|
||||
import { GetPublishableApiKeysParams } from "./list-publishable-api-keys"
|
||||
import { PublishableApiKey, SalesChannel } from "../../../../models"
|
||||
import { DeleteResponse, PaginatedResponse } from "../../../../types/common"
|
||||
import { AdminPostPublishableApiKeysReq } from "./create-publishable-api-key"
|
||||
import { AdminPostPublishableApiKeysPublishableApiKeyReq } from "./update-publishable-api-key"
|
||||
import { AdminDeletePublishableApiKeySalesChannelsBatchReq } from "./delete-channels-batch"
|
||||
import { AdminPostPublishableApiKeySalesChannelsBatchReq } from "./add-channels-batch"
|
||||
import { GetPublishableApiKeySalesChannelsParams } from "./list-publishable-api-key-sales-channels"
|
||||
import { AdminPostPublishableApiKeysReq } from "./create-publishable-api-key"
|
||||
import { AdminDeletePublishableApiKeySalesChannelsBatchReq } from "./delete-channels-batch"
|
||||
import { GetPublishableApiKeysParams } from "./list-publishable-api-keys"
|
||||
import { AdminPostPublishableApiKeysPublishableApiKeyReq } from "./update-publishable-api-key"
|
||||
|
||||
const route = Router()
|
||||
|
||||
@@ -55,7 +54,6 @@ export default (app) => {
|
||||
|
||||
route.get(
|
||||
"/:id/sales-channels",
|
||||
transformQuery(GetPublishableApiKeySalesChannelsParams, { isList: true }),
|
||||
middlewares.wrap(
|
||||
require("./list-publishable-api-key-sales-channels").default
|
||||
)
|
||||
@@ -158,8 +156,8 @@ export type AdminPublishableApiKeysListSalesChannelsRes = {
|
||||
}
|
||||
|
||||
export * from "./add-channels-batch"
|
||||
export * from "./delete-channels-batch"
|
||||
export * from "./list-publishable-api-keys"
|
||||
export * from "./list-publishable-api-key-sales-channels"
|
||||
export * from "./create-publishable-api-key"
|
||||
export * from "./delete-channels-batch"
|
||||
export * from "./list-publishable-api-key-sales-channels"
|
||||
export * from "./list-publishable-api-keys"
|
||||
export * from "./update-publishable-api-key"
|
||||
|
||||
+8
-5
@@ -1,8 +1,8 @@
|
||||
import { Request, Response } from "express"
|
||||
import { IsOptional, IsString } from "class-validator"
|
||||
import { Request, Response } from "express"
|
||||
|
||||
import PublishableApiKeyService from "../../../../services/publishable-api-key"
|
||||
import { extendedFindParamsMixin } from "../../../../types/common"
|
||||
import { validator } from "../../../../utils/validator"
|
||||
|
||||
/**
|
||||
* @oas [get] /admin/publishable-api-keys/{id}/sales-channels
|
||||
@@ -64,10 +64,13 @@ export default async (req: Request, res: Response) => {
|
||||
"publishableApiKeyService"
|
||||
)
|
||||
|
||||
const filterableFields = req.filterableFields
|
||||
const validated = await validator(
|
||||
GetPublishableApiKeySalesChannelsParams,
|
||||
req.query
|
||||
)
|
||||
|
||||
const salesChannels = await publishableApiKeyService.listSalesChannels(id, {
|
||||
q: filterableFields.q as string | undefined,
|
||||
q: validated.q,
|
||||
})
|
||||
|
||||
return res.json({
|
||||
@@ -78,7 +81,7 @@ export default async (req: Request, res: Response) => {
|
||||
/**
|
||||
* Parameters used to filter the sales channels.
|
||||
*/
|
||||
export class GetPublishableApiKeySalesChannelsParams extends extendedFindParamsMixin() {
|
||||
export class GetPublishableApiKeySalesChannelsParams {
|
||||
/**
|
||||
* Search term to search sales channels' names and descriptions.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user