@gohcltech/bitbucket-mcp
Version:
Bitbucket integration for Claude via Model Context Protocol
521 lines • 14.8 kB
TypeScript
/**
* @fileoverview Zod validation schemas for Bitbucket pull request operations.
*
* This module provides comprehensive validation schemas for pull request-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 pull request API responses
* - Comment and discussion validation
* - Input parameter validation for pull request management tools
* - State transition and workflow validation
* - Type-safe schema definitions matching TypeScript interfaces
* - Comprehensive error reporting for validation failures
*/
import { z } from 'zod';
/**
* Zod schema for validating Bitbucket pull request API responses.
*
* This schema validates the structure of pull request objects returned by
* Bitbucket's REST API v2.0. It ensures that all required fields are present
* and correctly typed, including source/destination branch information,
* author details, and state tracking.
*
* @example
* ```typescript
* const apiResponse = await fetch('/2.0/repositories/gohcl/bitbucket-mcp/pullrequests/123');
* const rawData = await apiResponse.json();
* const pullRequest = PullRequestSchema.parse(rawData);
* ```
*/
export declare const PullRequestSchema: z.ZodObject<{
/**
* Unique numeric identifier for the pull request.
* Must be a positive integer assigned sequentially by Bitbucket.
*/
id: z.ZodNumber;
/**
* Pull request title summarizing the changes.
* Must be a non-empty string with reasonable length limits.
*/
title: z.ZodString;
/**
* Optional detailed description of the pull request.
* Can contain markdown formatting and comprehensive change details.
*/
description: z.ZodOptional<z.ZodString>;
/**
* Current lifecycle state of the pull request.
* Must be one of the predefined Bitbucket pull request states.
*/
state: z.ZodEnum<["OPEN", "MERGED", "DECLINED", "SUPERSEDED"]>;
/**
* Information about the pull request author.
* Contains identification details for the user who created the PR.
*/
author: z.ZodObject<{
/** Display name of the pull request author */
display_name: z.ZodString;
/** Unique UUID identifier for the author */
uuid: z.ZodString;
}, "strip", z.ZodTypeAny, {
uuid: string;
display_name: string;
}, {
uuid: string;
display_name: string;
}>;
/**
* Source branch and repository information.
* Defines where the changes are coming from.
*/
source: z.ZodObject<{
/**
* Source branch containing the proposed changes.
*/
branch: z.ZodObject<{
/** Name of the source branch */
name: z.ZodString;
}, "strip", z.ZodTypeAny, {
name: string;
}, {
name: string;
}>;
/**
* Repository containing the source branch.
*/
repository: z.ZodObject<{
/** Name of the source repository */
name: z.ZodString;
}, "strip", z.ZodTypeAny, {
name: string;
}, {
name: string;
}>;
}, "strip", z.ZodTypeAny, {
repository: {
name: string;
};
branch: {
name: string;
};
}, {
repository: {
name: string;
};
branch: {
name: string;
};
}>;
/**
* Destination branch and repository information.
* Defines where the changes will be merged.
*/
destination: z.ZodObject<{
/**
* Destination branch that will receive the changes.
*/
branch: z.ZodObject<{
/** Name of the destination branch */
name: z.ZodString;
}, "strip", z.ZodTypeAny, {
name: string;
}, {
name: string;
}>;
/**
* Repository containing the destination branch.
*/
repository: z.ZodObject<{
/** Name of the destination repository */
name: z.ZodString;
}, "strip", z.ZodTypeAny, {
name: string;
}, {
name: string;
}>;
}, "strip", z.ZodTypeAny, {
repository: {
name: string;
};
branch: {
name: string;
};
}, {
repository: {
name: string;
};
branch: {
name: string;
};
}>;
/**
* ISO 8601 timestamp when the pull request was created.
* Must be a valid datetime string with timezone information.
*/
created_on: z.ZodString;
/**
* ISO 8601 timestamp when the pull request was last modified.
* Must be a valid datetime string with timezone information.
*/
updated_on: z.ZodString;
/**
* Collection of related URLs for the pull request.
* Provides navigation links to web interface and related resources.
*/
links: z.ZodObject<{
/**
* Direct link to the pull request's page in Bitbucket web interface.
*/
html: z.ZodObject<{
/** Full URL to the pull request page */
href: z.ZodString;
}, "strip", z.ZodTypeAny, {
href: string;
}, {
href: string;
}>;
}, "strip", z.ZodTypeAny, {
html: {
href: string;
};
}, {
html: {
href: string;
};
}>;
}, "strip", z.ZodTypeAny, {
destination: {
repository: {
name: string;
};
branch: {
name: string;
};
};
created_on: string;
updated_on: string;
links: {
html: {
href: string;
};
};
author: {
uuid: string;
display_name: string;
};
id: number;
title: string;
state: "OPEN" | "MERGED" | "DECLINED" | "SUPERSEDED";
source: {
repository: {
name: string;
};
branch: {
name: string;
};
};
description?: string | undefined;
}, {
destination: {
repository: {
name: string;
};
branch: {
name: string;
};
};
created_on: string;
updated_on: string;
links: {
html: {
href: string;
};
};
author: {
uuid: string;
display_name: string;
};
id: number;
title: string;
state: "OPEN" | "MERGED" | "DECLINED" | "SUPERSEDED";
source: {
repository: {
name: string;
};
branch: {
name: string;
};
};
description?: string | undefined;
}>;
/**
* Zod schema for validating pull request comment API responses.
*
* This schema validates the structure of comment objects returned by
* Bitbucket's pull request comments API. It ensures proper formatting
* of comment content, author information, and timestamps.
*
* @example
* ```typescript
* const apiResponse = await fetch('/2.0/repositories/gohcl/bitbucket-mcp/pullrequests/123/comments');
* const rawData = await apiResponse.json();
* const comments = rawData.values.map(comment => CommentSchema.parse(comment));
* ```
*/
export declare const CommentSchema: z.ZodObject<{
/**
* Unique numeric identifier for the comment.
* Must be a positive integer assigned by Bitbucket.
*/
id: z.ZodNumber;
/**
* Comment content in various formats.
* Contains the actual text and formatting information.
*/
content: z.ZodObject<{
/**
* Raw comment text as entered by the user.
* May contain markdown, mentions, and other formatting.
*/
raw: z.ZodString;
}, "strip", z.ZodTypeAny, {
raw: string;
}, {
raw: string;
}>;
/**
* Information about the comment author.
* Contains user identification for attribution.
*/
user: z.ZodObject<{
/**
* Display name of the comment author.
* Must be a non-empty string for user identification.
*/
display_name: z.ZodString;
}, "strip", z.ZodTypeAny, {
display_name: string;
}, {
display_name: string;
}>;
/**
* ISO 8601 timestamp when the comment was created.
* Must be a valid datetime string with timezone information.
*/
created_on: z.ZodString;
/**
* ISO 8601 timestamp when the comment was last modified.
* Must be a valid datetime string with timezone information.
*/
updated_on: z.ZodString;
}, "strip", z.ZodTypeAny, {
created_on: string;
updated_on: string;
user: {
display_name: string;
};
id: number;
content: {
raw: string;
};
}, {
created_on: string;
updated_on: string;
user: {
display_name: string;
};
id: number;
content: {
raw: string;
};
}>;
/**
* Input validation schema for pull request-related MCP tool parameters.
*
* This schema validates the basic parameters required by pull request tools,
* extending the repository base schema with pull request-specific validation.
* Used by tools that operate on existing pull requests.
*
* @example
* ```typescript
* const input = {
* workspace: 'gohcl',
* repo_slug: 'bitbucket-mcp',
* pull_request_id: 123
* };
* const validatedInput = PullRequestInputSchema.parse(input);
* ```
*/
export declare const PullRequestInputSchema: z.ZodObject<{
workspace: z.ZodString;
} & {
repo_slug: z.ZodString;
} & {
/**
* Numeric identifier for the pull request.
* Must be a positive integer referencing an existing pull request.
*/
pull_request_id: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
workspace: string;
repo_slug: string;
pull_request_id: number;
}, {
workspace: string;
repo_slug: string;
pull_request_id: number;
}>;
/**
* Input validation schema for the create_pull_request MCP tool.
*
* This schema validates parameters for creating new pull requests,
* including title, description, source/destination branches, and
* optional settings like auto-closing the source branch.
*
* @example
* ```typescript
* const input = {
* workspace: 'gohcl',
* repo_slug: 'bitbucket-mcp',
* title: 'Add OAuth 2.0 authentication',
* description: 'Implements secure OAuth flow...',
* source_branch: 'feature/oauth-auth',
* destination_branch: 'develop',
* close_source_branch: true
* };
* const validatedInput = CreatePullRequestInputSchema.parse(input);
* ```
*/
export declare const CreatePullRequestInputSchema: z.ZodObject<{
workspace: z.ZodString;
} & {
repo_slug: z.ZodString;
} & {
/**
* Pull request title summarizing the changes.
* Must be descriptive and within character limits.
*/
title: z.ZodString;
/**
* Optional detailed description of the pull request.
* Can contain markdown formatting and comprehensive change details.
*/
description: z.ZodOptional<z.ZodString>;
/**
* Name of the source branch containing the changes.
* Must be a valid git branch name that exists in the repository.
*/
source_branch: z.ZodString;
/**
* Name of the destination branch that will receive the changes.
* Must be a valid git branch name that exists in the repository.
*/
destination_branch: z.ZodString;
/**
* Whether to automatically close the source branch when PR is merged.
* Defaults to false to preserve branches unless explicitly requested.
*/
close_source_branch: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
}, "strip", z.ZodTypeAny, {
workspace: string;
repo_slug: string;
title: string;
source_branch: string;
destination_branch: string;
close_source_branch: boolean;
description?: string | undefined;
}, {
workspace: string;
repo_slug: string;
title: string;
source_branch: string;
destination_branch: string;
description?: string | undefined;
close_source_branch?: boolean | undefined;
}>;
/**
* Input validation schema for the list_pull_requests MCP tool.
*
* This schema validates parameters for listing pull requests with
* optional state filtering. Allows filtering by pull request state
* to show only PRs in specific lifecycle phases.
*
* @example
* ```typescript
* const input = {
* workspace: 'gohcl',
* repo_slug: 'bitbucket-mcp',
* state: 'OPEN'
* };
* const validatedInput = ListPullRequestsInputSchema.parse(input);
* ```
*/
export declare const ListPullRequestsInputSchema: z.ZodObject<{
workspace: z.ZodString;
} & {
repo_slug: z.ZodString;
} & {
/**
* Optional state filter for pull requests.
* When specified, only returns pull requests in the given state.
* If omitted, returns pull requests in all states.
*/
state: z.ZodOptional<z.ZodEnum<["OPEN", "MERGED", "DECLINED", "SUPERSEDED"]>>;
}, "strip", z.ZodTypeAny, {
workspace: string;
repo_slug: string;
state?: "OPEN" | "MERGED" | "DECLINED" | "SUPERSEDED" | undefined;
}, {
workspace: string;
repo_slug: string;
state?: "OPEN" | "MERGED" | "DECLINED" | "SUPERSEDED" | undefined;
}>;
/**
* Input validation schema for pull request comment operations.
*
* This schema validates parameters for adding comments to pull requests,
* including the target pull request ID and comment content with length
* restrictions to ensure reasonable comment sizes.
*
* @example
* ```typescript
* const input = {
* workspace: 'gohcl',
* repo_slug: 'bitbucket-mcp',
* pull_request_id: 123,
* content: 'This implementation looks great! LGTM.'
* };
* const validatedInput = CommentInputSchema.parse(input);
* ```
*/
export declare const CommentInputSchema: z.ZodObject<{
workspace: z.ZodString;
} & {
repo_slug: z.ZodString;
} & {
/**
* Numeric identifier for the target pull request.
* Must reference an existing pull request in the repository.
*/
pull_request_id: z.ZodNumber;
/**
* Comment content to be added to the pull request.
* Must be non-empty and within reasonable length limits.
* Can contain markdown formatting, mentions, and links.
*/
content: z.ZodString;
}, "strip", z.ZodTypeAny, {
workspace: string;
repo_slug: string;
content: string;
pull_request_id: number;
}, {
workspace: string;
repo_slug: string;
content: string;
pull_request_id: number;
}>;
//# sourceMappingURL=schemas.d.ts.map