ragatanga-mcp-sdk
Version:
SDK for integrating with the Ragatanga Management Control Plane (MCP) with Next.js 15, React 19, WebSocket and Arrow IPC support
367 lines (363 loc) • 10.3 kB
text/typescript
import { z } from 'zod';
import { ValidationError } from '../errors/index.mjs';
/**
* Base schema for timestamps
*/
declare const timestampSchema: z.ZodString;
/**
* Base schema for UUIDs
*/
declare const uuidSchema: z.ZodString;
/**
* Schema for OntologySummary
*/
declare const ontologySummarySchema: z.ZodObject<{
id: z.ZodString;
name: z.ZodString;
createdAt: z.ZodString;
format: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
id: string;
name: string;
createdAt: string;
format?: string | undefined;
}, {
id: string;
name: string;
createdAt: string;
format?: string | undefined;
}>;
type OntologySummarySchema = z.infer<typeof ontologySummarySchema>;
/**
* Schema for OntologyMetadata
*/
declare const ontologyMetadataSchema: z.ZodObject<z.objectUtil.extendShape<{
id: z.ZodString;
name: z.ZodString;
createdAt: z.ZodString;
format: z.ZodOptional<z.ZodString>;
}, {
size: z.ZodOptional<z.ZodNumber>;
updatedAt: z.ZodOptional<z.ZodString>;
entityCount: z.ZodOptional<z.ZodNumber>;
owner: z.ZodOptional<z.ZodString>;
}>, "strip", z.ZodTypeAny, {
id: string;
name: string;
createdAt: string;
format?: string | undefined;
size?: number | undefined;
updatedAt?: string | undefined;
entityCount?: number | undefined;
owner?: string | undefined;
}, {
id: string;
name: string;
createdAt: string;
format?: string | undefined;
size?: number | undefined;
updatedAt?: string | undefined;
entityCount?: number | undefined;
owner?: string | undefined;
}>;
type OntologyMetadataSchema = z.infer<typeof ontologyMetadataSchema>;
/**
* Schema for authentication information
*/
declare const authSchema: z.ZodObject<{
token: z.ZodString;
refreshToken: z.ZodOptional<z.ZodString>;
expiresAt: z.ZodOptional<z.ZodString>;
userId: z.ZodOptional<z.ZodString>;
permissions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
token: string;
refreshToken?: string | undefined;
expiresAt?: string | undefined;
userId?: string | undefined;
permissions?: string[] | undefined;
}, {
token: string;
refreshToken?: string | undefined;
expiresAt?: string | undefined;
userId?: string | undefined;
permissions?: string[] | undefined;
}>;
type AuthSchema = z.infer<typeof authSchema>;
/**
* Schema for MCPContextSpec
*/
declare const contextSpecSchema: z.ZodObject<{
id: z.ZodString;
parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
}, "strip", z.ZodTypeAny, {
id: string;
parameters: Record<string, unknown>;
}, {
id: string;
parameters: Record<string, unknown>;
}>;
type ContextSpecSchema = z.infer<typeof contextSpecSchema>;
/**
* Schema for MCPContextRequest
*/
declare const contextRequestSchema: z.ZodObject<{
request_id: z.ZodString;
current_query: z.ZodString;
context_specs: z.ZodArray<z.ZodObject<{
id: z.ZodString;
parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
}, "strip", z.ZodTypeAny, {
id: string;
parameters: Record<string, unknown>;
}, {
id: string;
parameters: Record<string, unknown>;
}>, "many">;
}, "strip", z.ZodTypeAny, {
request_id: string;
current_query: string;
context_specs: {
id: string;
parameters: Record<string, unknown>;
}[];
}, {
request_id: string;
current_query: string;
context_specs: {
id: string;
parameters: Record<string, unknown>;
}[];
}>;
type ContextRequestSchema = z.infer<typeof contextRequestSchema>;
/**
* Schema for MCPContextResponse
*/
declare const contextResponseSchema: z.ZodObject<{
responses: z.ZodArray<z.ZodObject<{
id: z.ZodString;
content: z.ZodObject<{
type: z.ZodString;
value: z.ZodString;
}, "strip", z.ZodTypeAny, {
value: string;
type: string;
}, {
value: string;
type: string;
}>;
metadata: z.ZodObject<{
confidence: z.ZodNumber;
source: z.ZodString;
timestamp: z.ZodString;
}, "strip", z.ZodUnknown, z.objectOutputType<{
confidence: z.ZodNumber;
source: z.ZodString;
timestamp: z.ZodString;
}, z.ZodUnknown, "strip">, z.objectInputType<{
confidence: z.ZodNumber;
source: z.ZodString;
timestamp: z.ZodString;
}, z.ZodUnknown, "strip">>;
}, "strip", z.ZodTypeAny, {
id: string;
content: {
value: string;
type: string;
};
metadata: {
confidence: number;
source: string;
timestamp: string;
} & {
[k: string]: unknown;
};
}, {
id: string;
content: {
value: string;
type: string;
};
metadata: {
confidence: number;
source: string;
timestamp: string;
} & {
[k: string]: unknown;
};
}>, "many">;
}, "strip", z.ZodTypeAny, {
responses: {
id: string;
content: {
value: string;
type: string;
};
metadata: {
confidence: number;
source: string;
timestamp: string;
} & {
[k: string]: unknown;
};
}[];
}, {
responses: {
id: string;
content: {
value: string;
type: string;
};
metadata: {
confidence: number;
source: string;
timestamp: string;
} & {
[k: string]: unknown;
};
}[];
}>;
type ContextResponseSchema = z.infer<typeof contextResponseSchema>;
/**
* Schema for error responses
*/
declare const errorResponseSchema: z.ZodObject<{
error: z.ZodString;
message: z.ZodString;
statusCode: z.ZodOptional<z.ZodNumber>;
code: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
message: string;
error: string;
code?: string | undefined;
statusCode?: number | undefined;
}, {
message: string;
error: string;
code?: string | undefined;
statusCode?: number | undefined;
}>;
type ErrorResponseSchema = z.infer<typeof errorResponseSchema>;
/**
* Schema for pagination metadata
*/
declare const paginationSchema: z.ZodObject<{
total: z.ZodNumber;
page: z.ZodNumber;
pageSize: z.ZodNumber;
totalPages: z.ZodNumber;
hasMore: z.ZodBoolean;
}, "strip", z.ZodTypeAny, {
total: number;
page: number;
pageSize: number;
totalPages: number;
hasMore: boolean;
}, {
total: number;
page: number;
pageSize: number;
totalPages: number;
hasMore: boolean;
}>;
type PaginationSchema = z.infer<typeof paginationSchema>;
/**
* Generic paginated response schema
*/
declare function createPaginatedSchema<T extends z.ZodTypeAny>(itemSchema: T): z.ZodObject<{
data: z.ZodArray<T, "many">;
pagination: z.ZodObject<{
total: z.ZodNumber;
page: z.ZodNumber;
pageSize: z.ZodNumber;
totalPages: z.ZodNumber;
hasMore: z.ZodBoolean;
}, "strip", z.ZodTypeAny, {
total: number;
page: number;
pageSize: number;
totalPages: number;
hasMore: boolean;
}, {
total: number;
page: number;
pageSize: number;
totalPages: number;
hasMore: boolean;
}>;
}, "strip", z.ZodTypeAny, {
data: T["_output"][];
pagination: {
total: number;
page: number;
pageSize: number;
totalPages: number;
hasMore: boolean;
};
}, {
data: T["_input"][];
pagination: {
total: number;
page: number;
pageSize: number;
totalPages: number;
hasMore: boolean;
};
}>;
/**
* Schema for API limits/usage
*/
declare const apiLimitsSchema: z.ZodObject<{
limit: z.ZodNumber;
remaining: z.ZodNumber;
reset: z.ZodString;
}, "strip", z.ZodTypeAny, {
limit: number;
remaining: number;
reset: string;
}, {
limit: number;
remaining: number;
reset: string;
}>;
type ApiLimitsSchema = z.infer<typeof apiLimitsSchema>;
/**
* Validates data against a Zod schema and returns the validated data
* @param schema - Zod schema to validate against
* @param data - Data to validate
* @returns Validated and typed data
* @throws ValidationError if validation fails
*/
declare function validate<T>(schema: z.ZodType<T>, data: unknown): T;
/**
* Similar to validate, but returns a Result object with success/error state
* instead of throwing an exception.
*/
declare function validateSafe<T>(schema: z.ZodType<T>, data: unknown): {
success: boolean;
data?: T;
error?: ValidationError;
};
/**
* Returns a function that will validate data against the given schema
* @param schema - Zod schema to validate against
* @returns Function that validates data against the schema
*/
declare function createValidator<T>(schema: z.ZodType<T>): (data: unknown) => T;
/**
* Creates a safe validator that doesn't throw exceptions
*/
declare function createSafeValidator<T>(schema: z.ZodType<T>): (data: unknown) => {
success: boolean;
data?: T;
error?: ValidationError;
};
/**
* Validates an array of items against a schema
*/
declare function validateArray<T>(schema: z.ZodType<T>, data: unknown): T[];
/**
* Validates that the response is a non-null object before further validation
*/
declare function validateResponse<T>(schema: z.ZodType<T>, data: unknown): T;
export { type ApiLimitsSchema, type AuthSchema, type ContextRequestSchema, type ContextResponseSchema, type ContextSpecSchema, type ErrorResponseSchema, type OntologyMetadataSchema, type OntologySummarySchema, type PaginationSchema, apiLimitsSchema, authSchema, contextRequestSchema, contextResponseSchema, contextSpecSchema, createPaginatedSchema, createSafeValidator, createValidator, errorResponseSchema, ontologyMetadataSchema, ontologySummarySchema, paginationSchema, timestampSchema, uuidSchema, validate, validateArray, validateResponse, validateSafe };