import {z} from 'zod' export type DeleteApiProjectsProjectIdEvalRunsRunIdGateWaiversWaiverIdArgs = {'x-mcpjam-eval-vocabulary'?: ('1' | '2') | undefined, projectId: string, runId: string, waiverId: string}; export type DeleteApiProjectsProjectIdEvalRunsRunIdGateWaiversWaiverIdOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const gateWaiver = z.object({id: z.string(), suiteId: z.string(), runId: z.string().nullable(), reason: z.string(), expiresAt: z.number().int(), createdAt: z.number().int(), createdBy: z.string(), createdByEmail: z.string().nullable(), revokedAt: z.number().int().nullable(), revokedBy: z.string().nullable(), active: z.boolean(), policySnapshot: z.object({minimumPassRate: z.number()}).nullable()}); export const gateWaiverWriteResult = z.object({status: z.enum(["created", "conflict", "revoked", "already_revoked"]), republishedChecks: z.number().int(), waiver: gateWaiver}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Revoke a gate waiver * * DELETE /projects/{projectId}/eval-runs/{runId}/gate-waivers/{waiverId} */ export const deleteApiProjectsProjectIdEvalRunsRunIdGateWaiversWaiverId = async (args: DeleteApiProjectsProjectIdEvalRunsRunIdGateWaiversWaiverIdArgs, options?: DeleteApiProjectsProjectIdEvalRunsRunIdGateWaiversWaiverIdOptions) => { const {baseUrl = "https://app.mcpjam.com/api/v1", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['x-mcpjam-eval-vocabulary'] != null) headers.set("x-mcpjam-eval-vocabulary", String(args['x-mcpjam-eval-vocabulary'])) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/projects/${encodeURIComponent(String(args.projectId))}/eval-runs/${encodeURIComponent(String(args.runId))}/gate-waivers/${encodeURIComponent(String(args.waiverId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(gateWaiverWriteResult, await res.json()) };