Files
devops-platform-api/src/deploy-runs/create-deploy-run.dto.ts
T
2026-06-11 20:49:59 +08:00

46 lines
1.3 KiB
TypeScript

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { z } from 'zod';
import { DeployEnvironment } from './deploy-run.types';
const optionalTrimmedString = (maxLength: number) =>
z
.string()
.trim()
.max(maxLength)
.optional()
.or(z.literal('').transform(() => undefined));
/**
* 创建发布单的运行时校验规则;真实密钥和第三方参数不允许从前端传入。
*/
export const createDeployRunSchema = z.object({
projectKey: z.string().trim().min(1).max(80),
environment: z.enum(['test', 'production']),
ref: z.string().trim().min(1).max(200),
operator: z.string().trim().min(1).max(120),
remark: optionalTrimmedString(500),
idempotencyKey: optionalTrimmedString(260),
});
export class CreateDeployRunDto {
@ApiProperty({ example: 'access-manage' })
projectKey!: string;
@ApiProperty({ enum: ['test', 'production'], example: 'test' })
environment!: DeployEnvironment;
@ApiProperty({ example: 'develop' })
ref!: string;
@ApiProperty({ example: 'operator@example.com' })
operator!: string;
@ApiPropertyOptional({ example: 'Manual test deploy before release.' })
remark?: string;
@ApiPropertyOptional({
example: 'access-manage:test:develop:2026-06-11T10:00:00Z',
})
idempotencyKey?: string;
}