|
| 1 | +import { z } from 'zod' |
| 2 | +import { |
| 3 | + athenaConnectionSchema, |
| 4 | + athenaPreparedStatementSchema, |
| 5 | + athenaStatementNameSchema, |
| 6 | + athenaWorkGroupSchema, |
| 7 | +} from '@/lib/api/contracts/tools/aws/athena-shared' |
| 8 | +import type { |
| 9 | + ContractBody, |
| 10 | + ContractBodyInput, |
| 11 | + ContractJsonResponse, |
| 12 | +} from '@/lib/api/contracts/types' |
| 13 | +import { defineRouteContract } from '@/lib/api/contracts/types' |
| 14 | + |
| 15 | +const BatchGetPreparedStatementSchema = athenaConnectionSchema.extend({ |
| 16 | + preparedStatementNames: z |
| 17 | + .array(athenaStatementNameSchema) |
| 18 | + .min(1, 'At least one prepared statement name is required') |
| 19 | + .max(256, 'A maximum of 256 prepared statement names can be requested at once'), |
| 20 | + workGroup: athenaWorkGroupSchema, |
| 21 | +}) |
| 22 | + |
| 23 | +const BatchGetPreparedStatementResponseSchema = z.object({ |
| 24 | + success: z.literal(true), |
| 25 | + output: z.object({ |
| 26 | + preparedStatements: z.array(athenaPreparedStatementSchema), |
| 27 | + unprocessedPreparedStatementNames: z.array( |
| 28 | + z.object({ |
| 29 | + statementName: z.string().nullable(), |
| 30 | + errorCode: z.string().nullable(), |
| 31 | + errorMessage: z.string().nullable(), |
| 32 | + }) |
| 33 | + ), |
| 34 | + }), |
| 35 | +}) |
| 36 | + |
| 37 | +export const awsAthenaBatchGetPreparedStatementContract = defineRouteContract({ |
| 38 | + method: 'POST', |
| 39 | + path: '/api/tools/athena/batch-get-prepared-statement', |
| 40 | + body: BatchGetPreparedStatementSchema, |
| 41 | + response: { mode: 'json', schema: BatchGetPreparedStatementResponseSchema }, |
| 42 | +}) |
| 43 | +export type AwsAthenaBatchGetPreparedStatementRequest = ContractBodyInput< |
| 44 | + typeof awsAthenaBatchGetPreparedStatementContract |
| 45 | +> |
| 46 | +export type AwsAthenaBatchGetPreparedStatementBody = ContractBody< |
| 47 | + typeof awsAthenaBatchGetPreparedStatementContract |
| 48 | +> |
| 49 | +export type AwsAthenaBatchGetPreparedStatementResponse = ContractJsonResponse< |
| 50 | + typeof awsAthenaBatchGetPreparedStatementContract |
| 51 | +> |
0 commit comments