Files
medusa-store/packages/medusa/src/api/admin/api-keys/validators.ts
Stevche Radevski e44fe78b96 fix: Several fixes to store product endpoints, moved several test suites to HTTP (#7601)
* chore: Move publishable api key tests to HTTP

* chore: Move store tests to HTTP folder

* fix: Add tests for store products, fix several bugs around publishable keys
2024-06-04 21:00:07 +02:00

45 lines
1.4 KiB
TypeScript

import { z } from "zod"
import {
createFindParams,
createOperatorMap,
createSelectParams,
} from "../../utils/validators"
import { ApiKeyType } from "@medusajs/utils"
export const AdminGetApiKeyParams = createSelectParams()
export type AdminGetApiKeysParamsType = z.infer<typeof AdminGetApiKeysParams>
export const AdminGetApiKeysParams = createFindParams({
offset: 0,
limit: 20,
}).merge(
z.object({
q: z.string().optional(),
id: z.union([z.string(), z.array(z.string())]).optional(),
title: z.union([z.string(), z.array(z.string())]).optional(),
token: z.union([z.string(), z.array(z.string())]).optional(),
type: z.nativeEnum(ApiKeyType).optional(),
created_at: createOperatorMap().optional(),
updated_at: createOperatorMap().optional(),
deleted_at: createOperatorMap().optional(),
$and: z.lazy(() => AdminGetApiKeysParams.array()).optional(),
$or: z.lazy(() => AdminGetApiKeysParams.array()).optional(),
})
)
export type AdminCreateApiKeyType = z.infer<typeof AdminCreateApiKey>
export const AdminCreateApiKey = z.object({
title: z.string(),
type: z.nativeEnum(ApiKeyType),
})
export type AdminUpdateApiKeyType = z.infer<typeof AdminUpdateApiKey>
export const AdminUpdateApiKey = z.object({
title: z.string(),
})
export type AdminRevokeApiKeyType = z.infer<typeof AdminRevokeApiKey>
export const AdminRevokeApiKey = z.object({
revoke_in: z.number().optional(),
})