/**
* Common Zod schemas for IT Glue MCP Server
*/
import { z } from 'zod';
import { ResponseFormat } from '../types.js';
import { DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE } from '../constants.js';
/**
* Pagination schema used across all list endpoints
*/
export const PaginationSchema = z.object({
page: z.number()
.int()
.min(1)
.default(1)
.describe('Page number (1-indexed)'),
page_size: z.number()
.int()
.min(1)
.max(MAX_PAGE_SIZE)
.default(DEFAULT_PAGE_SIZE)
.describe(`Number of items per page (max ${MAX_PAGE_SIZE})`)
});
/**
* Response format schema
*/
export const ResponseFormatSchema = z.nativeEnum(ResponseFormat)
.default(ResponseFormat.MARKDOWN)
.describe("Output format: 'markdown' for human-readable or 'json' for structured data");
/**
* Sort direction schema
*/
export const SortDirectionSchema = z.enum(['asc', 'desc'])
.default('asc')
.describe('Sort direction: asc (ascending) or desc (descending)');
/**
* Common ID parameter
*/
export const IdSchema = z.union([z.string(), z.number()])
.transform(val => String(val))
.describe('The unique ID of the resource');
/**
* Organization ID filter (used by many endpoints)
*/
export const OrganizationIdFilterSchema = z.number()
.int()
.positive()
.optional()
.describe('Filter by organization ID');
/**
* Search/filter string with minimum length
*/
export const SearchQuerySchema = z.string()
.min(1)
.max(500)
.describe('Search query string');
/**
* Boolean filter that accepts various formats
*/
export const BooleanFilterSchema = z.union([
z.boolean(),
z.enum(['true', 'false', '1', '0'])
]).transform(val => {
if (typeof val === 'boolean') return val;
return val === 'true' || val === '1';
}).optional();
/**
* Name filter (partial match)
*/
export const NameFilterSchema = z.string()
.min(1)
.max(255)
.optional()
.describe('Filter by name (partial match supported)');
/**
* Include related resources parameter
*/
export const IncludeSchema = z.array(z.string())
.optional()
.describe('Related resources to include in response');