All files / src/entities/files schema-readonly.ts

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

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 62 63 64 65 66 67 68 693x 3x 3x         3x                         3x               3x     3x         3x                 3x                   3x                          
import { z } from "zod";
import { flexibleBoolean } from "../utils";
import { ProjectParamsSchema } from "../shared";
 
// READ-ONLY FILE OPERATION SCHEMAS
 
// Repository content response schemas (read-only)
export const GitLabFileContentSchema = z.object({
  file_name: z.string(),
  file_path: z.string(),
  size: z.number(),
  encoding: z.string(),
  content_sha256: z.string().optional(),
  ref: z.string().optional(),
  blob_id: z.string(),
  commit_id: z.string(),
  last_commit_id: z.string(),
  content: z.string().optional(),
});
 
export const GitLabDirectoryContentSchema = z.object({
  id: z.string(),
  name: z.string(),
  type: z.enum(["tree", "blob"]),
  path: z.string(),
  mode: z.string(),
});
 
export const GitLabContentSchema = z.union([GitLabFileContentSchema, GitLabDirectoryContentSchema]);
 
// Response schemas (read-only)
export const GitLabCreateUpdateFileResponseSchema = z.object({
  file_path: z.string(),
  branch: z.string(),
});
 
export const GitLabTreeSchema = z.object({
  id: z.string(),
  name: z.string(),
  type: z.enum(["tree", "blob"]),
  path: z.string(),
  mode: z.string(),
});
 
// Repository operations (read-only)
export const GetRepositoryTreeSchema = z.object({
  project_id: z.coerce.string().describe("Project ID or URL-encoded path"),
  path: z.string().optional().describe("The path inside repository"),
  ref: z.string().optional().describe("The name of a repository branch or tag"),
  recursive: flexibleBoolean.optional().describe("Boolean value used to get a recursive tree"),
  per_page: z.number().int().min(1).max(100).optional().describe("Number of results per page"),
  page: z.number().int().min(1).optional().describe("Page number"),
});
 
// Get file contents (read-only)
export const GetFileContentsSchema = ProjectParamsSchema.extend({
  file_path: z.string().describe("URL-encoded full path to the file"),
  ref: z.string().optional().describe("The name of branch, tag or commit"),
});
 
// Export type definitions
export type GitLabFileContent = z.infer<typeof GitLabFileContentSchema>;
export type GitLabDirectoryContent = z.infer<typeof GitLabDirectoryContentSchema>;
export type GitLabContent = z.infer<typeof GitLabContentSchema>;
export type GitLabCreateUpdateFileResponse = z.infer<typeof GitLabCreateUpdateFileResponseSchema>;
export type GitLabTree = z.infer<typeof GitLabTreeSchema>;
export type GetRepositoryTreeOptions = z.infer<typeof GetRepositoryTreeSchema>;
export type GetFileContentsOptions = z.infer<typeof GetFileContentsSchema>;