@gohcltech/bitbucket-mcp
Version:
Bitbucket integration for Claude via Model Context Protocol
196 lines • 6.17 kB
TypeScript
/**
* @fileoverview Zod validation schemas for Bitbucket workspace operations.
*
* This module provides comprehensive validation schemas for workspace-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 workspace API responses
* - Input parameter validation for workspace tools
* - Type-safe schema definitions that match TypeScript interfaces
* - Comprehensive error reporting for validation failures
*/
import { z } from 'zod';
/**
* Zod schema for validating Bitbucket workspace API responses.
*
* This schema validates the structure of workspace 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<Workspace>` 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/workspaces/gohcl');
* const rawData = await apiResponse.json();
* const workspace = WorkspaceSchema.parse(rawData);
* ```
*/
export declare const WorkspaceSchema: z.ZodObject<{
/**
* Unique UUID identifier for the workspace.
* Must be a non-empty string in UUID format.
*/
uuid: z.ZodString;
/**
* Human-readable workspace name.
* Must be a non-empty string, can contain any valid Unicode characters.
*/
name: z.ZodString;
/**
* URL-safe workspace identifier.
* Must follow Bitbucket's slug naming conventions:
* - Alphanumeric characters, hyphens, and underscores only
* - No consecutive special characters
* - Cannot start or end with special characters
*/
slug: z.ZodString;
/**
* Privacy flag indicating workspace visibility.
* Boolean value determining if workspace is publicly visible.
*/
is_private: z.ZodBoolean;
/**
* ISO 8601 timestamp of workspace creation.
* Must be a valid ISO string format (YYYY-MM-DDTHH:mm:ss.sssZ).
*/
created_on: z.ZodString;
/**
* ISO 8601 timestamp of last workspace modification.
* Must be a valid ISO string format (YYYY-MM-DDTHH:mm:ss.sssZ).
*/
updated_on: z.ZodString;
/**
* Collection of related URLs and resources for the workspace.
* Contains links to web interface and optional avatar image.
*/
links: z.ZodObject<{
/**
* Link to the workspace's main page in Bitbucket web interface.
* Always present and contains the direct URL to the workspace.
*/
html: z.ZodObject<{
/** Full URL to the workspace page, must be a valid HTTP(S) URL */
href: z.ZodString;
}, "strip", z.ZodTypeAny, {
href: string;
}, {
href: string;
}>;
/**
* Optional link to the workspace's avatar image.
* May be undefined if no custom avatar is configured.
*/
avatar: z.ZodOptional<z.ZodObject<{
/** Full URL to the avatar image, must be a valid HTTP(S) URL */
href: z.ZodString;
}, "strip", z.ZodTypeAny, {
href: string;
}, {
href: string;
}>>;
}, "strip", z.ZodTypeAny, {
html: {
href: string;
};
avatar?: {
href: string;
} | undefined;
}, {
html: {
href: string;
};
avatar?: {
href: string;
} | undefined;
}>;
}, "strip", z.ZodTypeAny, {
name: string;
uuid: string;
slug: string;
is_private: boolean;
created_on: string;
updated_on: string;
links: {
html: {
href: string;
};
avatar?: {
href: string;
} | undefined;
};
}, {
name: string;
uuid: string;
slug: string;
is_private: boolean;
created_on: string;
updated_on: string;
links: {
html: {
href: string;
};
avatar?: {
href: string;
} | undefined;
};
}>;
/**
* Base validation schema for workspace-related tool parameters.
*
* This schema validates the fundamental workspace identifier required by
* most workspace-related MCP tools. It reuses the common WorkspaceBaseSchema
* to ensure consistent validation across all workspace operations.
*
* Validates:
* - Workspace slug format (alphanumeric, hyphens, underscores)
* - Required field presence
* - Length constraints
*/
export declare const WorkspaceInputSchema: z.ZodObject<{
workspace: z.ZodString;
}, "strip", z.ZodTypeAny, {
workspace: string;
}, {
workspace: string;
}>;
/**
* Input validation schema for the get_workspace MCP tool.
*
* This schema validates parameters passed to the get_workspace tool,
* ensuring that only the required workspace identifier is provided.
* It uses Zod's `pick` method to extract only the workspace field
* from the base schema, providing focused validation.
*
* @example
* ```typescript
* const input = { workspace: 'gohcl' };
* const validatedInput = GetWorkspaceInputSchema.parse(input);
* ```
*/
export declare const GetWorkspaceInputSchema: z.ZodObject<Pick<{
workspace: z.ZodString;
}, "workspace">, "strip", z.ZodTypeAny, {
workspace: string;
}, {
workspace: string;
}>;
/**
* Type guard functions for workspace-related data validation.
*
* Note: The isWorkspaceInput 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:
* - isWorkspaceInput(input): Validates workspace input parameters
*
* @see {@link ../common.ts} for type guard implementations
*/
//# sourceMappingURL=schemas.d.ts.map