All files / src/entities/pipelines schema.ts

100% Statements 8/8
100% Branches 0/0
100% Functions 0/0
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 623x   3x                             3x           3x         3x                             3x         3x     3x                    
import { z } from "zod";
 
export const CreatePipelineSchema = z.object({
  project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
  ref: z.string().describe("The branch or tag to run the pipeline on"),
  variables: z
    .array(
      z.object({
        key: z.string(),
        value: z.string(),
        variable_type: z.enum(["env_var", "file"]).optional(),
      })
    )
    .optional()
    .describe("Variables to pass to the pipeline"),
});
 
export const RetryPipelineSchema = z.object({
  project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
  pipeline_id: z.coerce.string().describe("The ID of the pipeline to retry"),
});
 
// Schema for canceling a pipeline
export const CancelPipelineSchema = RetryPipelineSchema;
 
// Write-only pipeline operation schemas
 
// Schema for running a manual job
export const PlayPipelineJobSchema = z.object({
  project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
  job_id: z.coerce.string().describe("The ID of the job"),
  job_variables_attributes: z
    .array(
      z.object({
        key: z.string(),
        value: z.string(),
        variable_type: z.enum(["env_var", "file"]).optional(),
      })
    )
    .optional()
    .describe("Variables to pass to the job"),
});
 
export const PipelineJobControlSchema = z.object({
  project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
  job_id: z.coerce.string().describe("The ID of the job"),
});
 
export const RetryPipelineJobSchema = PipelineJobControlSchema;
 
// Schema for canceling a job
export const CancelPipelineJobSchema = z.object({
  project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
  job_id: z.coerce.string().describe("The ID of the job"),
  force: z.boolean().optional().describe("Force cancellation of the job"),
});
 
// Export types
export type CreatePipelineOptions = z.infer<typeof CreatePipelineSchema>;
export type RetryPipelineOptions = z.infer<typeof RetryPipelineSchema>;
export type CancelPipelineOptions = z.infer<typeof CancelPipelineSchema>;