UNPKG

@gohcltech/bitbucket-mcp

Version:

Bitbucket integration for Claude via Model Context Protocol

409 lines 13.5 kB
/** * @fileoverview Zod validation schemas for Bitbucket repository operations. * * This module provides comprehensive validation schemas for repository-related * operations using Zod for runtime type checking and validation. These schemas * ensure that data conforms to Bitbucket API v2.0 specifications and provide * type-safe validation for MCP tool inputs and API responses. * * Key features: * - Runtime validation of repository API responses * - Input parameter validation for repository management tools * - Create and update operation schemas with appropriate constraints * - Type-safe schema definitions that match TypeScript interfaces * - Comprehensive error reporting for validation failures */ import { z } from 'zod'; /** * Zod schema for validating Bitbucket repository API responses. * * This schema validates the complete structure of repository objects returned by * Bitbucket's REST API v2.0. It ensures that all required fields are present * and correctly typed, while allowing optional fields to be undefined. * * The schema uses `satisfies z.ZodType<Repository>` to guarantee that the * validation schema matches the TypeScript interface exactly, preventing * drift between runtime validation and compile-time types. * * @example * ```typescript * const apiResponse = await fetch('/2.0/repositories/gohcl/bitbucket-mcp'); * const rawData = await apiResponse.json(); * const repository = RepositorySchema.parse(rawData); * ``` */ export declare const RepositorySchema: z.ZodObject<{ /** * Unique UUID identifier for the repository. * Must be a non-empty string in UUID format. */ uuid: z.ZodString; /** * Repository name within the workspace. * Must be a non-empty string following repository naming conventions. */ name: z.ZodString; /** * Full repository name including workspace prefix. * Format: workspace-slug/repository-name */ full_name: z.ZodString; /** * Optional repository description. * Can contain markdown and should provide context about the repository. */ description: z.ZodOptional<z.ZodString>; /** * Privacy flag indicating repository visibility. * Boolean value determining if repository is publicly accessible. */ is_private: z.ZodBoolean; /** * Repository fork policy controlling how the repository can be forked. * Must be one of the predefined Bitbucket fork policy values. */ fork_policy: z.ZodEnum<["allow_forks", "no_public_forks", "no_forks"]>; /** * ISO 8601 timestamp of repository creation. * Must be a valid ISO string format (YYYY-MM-DDTHH:mm:ss.sssZ). */ created_on: z.ZodString; /** * ISO 8601 timestamp of last repository modification. * Must be a valid ISO string format (YYYY-MM-DDTHH:mm:ss.sssZ). */ updated_on: z.ZodString; /** * Repository size in bytes. * Must be a non-negative integer representing total storage usage. */ size: z.ZodNumber; /** * Primary programming language detected in the repository. * Optional string identifying the predominant language used. */ language: z.ZodOptional<z.ZodString>; /** * Flag indicating whether issue tracking is enabled. * Boolean value controlling availability of issue features. */ has_issues: z.ZodBoolean; /** * Flag indicating whether wiki functionality is enabled. * Boolean value controlling availability of wiki features. */ has_wiki: z.ZodBoolean; /** * Information about the repository's main/default branch. * Optional object containing main branch details, undefined for empty repos. */ mainbranch: z.ZodOptional<z.ZodObject<{ /** Name of the main branch following git branch naming conventions */ name: z.ZodString; }, "strip", z.ZodTypeAny, { name: string; }, { name: string; }>>; /** * Repository owner information. * Contains details about the user or entity that owns the repository. */ owner: z.ZodObject<{ /** Human-readable display name of the owner */ display_name: z.ZodString; /** Unique UUID identifier for the owner */ uuid: z.ZodString; }, "strip", z.ZodTypeAny, { uuid: string; display_name: string; }, { uuid: string; display_name: string; }>; /** * Workspace information containing the repository. * Every repository belongs to exactly one workspace. */ workspace: z.ZodObject<{ /** Human-readable workspace name */ name: z.ZodString; /** URL-safe workspace identifier */ slug: z.ZodString; }, "strip", z.ZodTypeAny, { name: string; slug: string; }, { name: string; slug: string; }>; /** * Collection of related URLs and clone endpoints. * Provides access to web interface and git clone operations. */ links: z.ZodObject<{ /** * Link to the repository's main page in Bitbucket web interface. */ html: z.ZodObject<{ /** Full URL to the repository page, must be a valid HTTP(S) URL */ href: z.ZodString; }, "strip", z.ZodTypeAny, { href: string; }, { href: string; }>; /** * Array of clone URLs for different protocols. * Typically includes HTTPS and SSH clone options. */ clone: z.ZodArray<z.ZodObject<{ /** Protocol name (e.g., "https", "ssh") */ name: z.ZodString; /** Full clone URL for git operations, must be a valid git URL */ href: z.ZodString; }, "strip", z.ZodTypeAny, { name: string; href: string; }, { name: string; href: string; }>, "many">; }, "strip", z.ZodTypeAny, { html: { href: string; }; clone: { name: string; href: string; }[]; }, { html: { href: string; }; clone: { name: string; href: string; }[]; }>; }, "strip", z.ZodTypeAny, { workspace: { name: string; slug: string; }; name: string; uuid: string; is_private: boolean; created_on: string; updated_on: string; links: { html: { href: string; }; clone: { name: string; href: string; }[]; }; full_name: string; fork_policy: "allow_forks" | "no_public_forks" | "no_forks"; size: number; has_issues: boolean; has_wiki: boolean; owner: { uuid: string; display_name: string; }; description?: string | undefined; language?: string | undefined; mainbranch?: { name: string; } | undefined; }, { workspace: { name: string; slug: string; }; name: string; uuid: string; is_private: boolean; created_on: string; updated_on: string; links: { html: { href: string; }; clone: { name: string; href: string; }[]; }; full_name: string; fork_policy: "allow_forks" | "no_public_forks" | "no_forks"; size: number; has_issues: boolean; has_wiki: boolean; owner: { uuid: string; display_name: string; }; description?: string | undefined; language?: string | undefined; mainbranch?: { name: string; } | undefined; }>; /** * Base validation schema for repository-related tool parameters. * * This schema validates the fundamental identifiers required by most * repository-related MCP tools. It reuses the common RepositoryBaseSchema * to ensure consistent validation across all repository operations. * * Validates: * - Workspace slug format (alphanumeric, hyphens, underscores) * - Repository slug format (alphanumeric, hyphens, underscores, dots) * - Required field presence and length constraints */ export declare const RepositoryInputSchema: z.ZodObject<{ workspace: z.ZodString; } & { repo_slug: z.ZodString; }, "strip", z.ZodTypeAny, { workspace: string; repo_slug: string; }, { workspace: string; repo_slug: string; }>; /** * Input validation schema for the create_repository MCP tool. * * This schema validates parameters for creating new repositories, including * required fields like workspace and name, as well as optional settings * like privacy and fork policies. It enforces Bitbucket's naming conventions * and provides sensible defaults for optional fields. * * Default values: * - is_private: true (repositories are private by default) * - fork_policy: 'allow_forks' (forking allowed by default) * * @example * ```typescript * const input = { * workspace: 'gohcl', * name: 'new-project', * description: 'A new project repository', * is_private: true * }; * const validatedInput = CreateRepositoryInputSchema.parse(input); * ``` */ export declare const CreateRepositoryInputSchema: z.ZodObject<{ /** Workspace slug where the repository will be created */ workspace: z.ZodString; /** Repository name (must be unique within workspace) */ name: z.ZodString; /** Optional repository description (supports markdown) */ description: z.ZodOptional<z.ZodString>; /** Whether the repository should be private (default: true) */ is_private: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; /** Fork policy controlling how the repository can be forked (default: allow_forks) */ fork_policy: z.ZodDefault<z.ZodOptional<z.ZodEnum<["allow_forks", "no_public_forks", "no_forks"]>>>; }, "strip", z.ZodTypeAny, { workspace: string; name: string; is_private: boolean; fork_policy: "allow_forks" | "no_public_forks" | "no_forks"; description?: string | undefined; }, { workspace: string; name: string; description?: string | undefined; is_private?: boolean | undefined; fork_policy?: "allow_forks" | "no_public_forks" | "no_forks" | undefined; }>; /** * Input validation schema for the update_repository MCP tool. * * This schema validates parameters for updating existing repositories, * allowing modification of repository settings, metadata, and features. * All fields except workspace and repo_slug are optional, enabling * partial updates of repository configuration. * * Supported updates: * - Repository name and description * - Privacy and fork policy settings * - Website URL (can be set to null to remove) * - Language override * - Feature toggles (issues, wiki) * * @example * ```typescript * const input = { * workspace: 'gohcl', * repo_slug: 'existing-repo', * description: 'Updated description', * has_issues: false * }; * const validatedInput = UpdateRepositoryInputSchema.parse(input); * ``` */ export declare const UpdateRepositoryInputSchema: z.ZodObject<{ /** Workspace slug containing the repository */ workspace: z.ZodString; /** Current repository slug to identify the repository */ repo_slug: z.ZodString; /** New repository name (optional, renames the repository) */ name: z.ZodOptional<z.ZodString>; /** Updated repository description (optional, supports markdown) */ description: z.ZodOptional<z.ZodString>; /** Change repository privacy setting (optional) */ is_private: z.ZodOptional<z.ZodBoolean>; /** Update fork policy (optional) */ fork_policy: z.ZodOptional<z.ZodEnum<["allow_forks", "no_public_forks", "no_forks"]>>; /** Repository website URL (optional, null to remove) */ website: z.ZodNullable<z.ZodOptional<z.ZodString>>; /** Override detected primary language (optional) */ language: z.ZodOptional<z.ZodString>; /** Enable or disable issue tracking (optional) */ has_issues: z.ZodOptional<z.ZodBoolean>; /** Enable or disable wiki functionality (optional) */ has_wiki: z.ZodOptional<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { workspace: string; repo_slug: string; name?: string | undefined; description?: string | undefined; is_private?: boolean | undefined; fork_policy?: "allow_forks" | "no_public_forks" | "no_forks" | undefined; language?: string | undefined; has_issues?: boolean | undefined; has_wiki?: boolean | undefined; website?: string | null | undefined; }, { workspace: string; repo_slug: string; name?: string | undefined; description?: string | undefined; is_private?: boolean | undefined; fork_policy?: "allow_forks" | "no_public_forks" | "no_forks" | undefined; language?: string | undefined; has_issues?: boolean | undefined; has_wiki?: boolean | undefined; website?: string | null | undefined; }>; /** * Type guard functions for repository-related data validation. * * Note: The isRepositoryInput type guard function is exported from * common.ts to avoid circular dependencies and ensure it's available * across all domain modules. This centralized approach prevents * conflicts and maintains consistency in type checking. * * Available type guards: * - isRepositoryInput(input): Validates repository input parameters * * @see {@link ../common.ts} for type guard implementations */ //# sourceMappingURL=schemas.d.ts.map