@vfarcic/dot-ai
Version:
AI-powered development productivity platform that enhances software development workflows through intelligent automation and AI-driven assistance
117 lines (116 loc) • 5.03 kB
JavaScript
"use strict";
/**
* Prompts Endpoint Schemas
*
* Schemas for the /api/v1/prompts and /api/v1/prompts/:promptName endpoints.
* PRD #354: REST API Route Registry with Auto-Generated OpenAPI and Test Fixtures
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.PromptsCacheRefreshErrorSchema = exports.PromptsCacheRefreshResponseSchema = exports.PromptsCacheRefreshDataSchema = exports.PromptGetErrorSchema = exports.PromptsListErrorSchema = exports.PromptValidationErrorSchema = exports.PromptNotFoundErrorSchema = exports.PromptGetRequestSchema = exports.PromptGetResponseSchema = exports.PromptGetDataSchema = exports.PromptFileSchema = exports.PromptMessageSchema = exports.PromptsListResponseSchema = exports.PromptsListDataSchema = exports.PromptInfoSchema = exports.PromptArgumentSchema = void 0;
const zod_1 = require("zod");
const common_1 = require("./common");
/**
* Prompt argument definition
*/
exports.PromptArgumentSchema = zod_1.z.object({
name: zod_1.z.string().describe('Argument name'),
description: zod_1.z.string().optional().describe('Argument description'),
required: zod_1.z.boolean().optional().describe('Whether the argument is required'),
});
/**
* Prompt information in list
*/
exports.PromptInfoSchema = zod_1.z.object({
name: zod_1.z.string().describe('Prompt name/identifier'),
description: zod_1.z.string().optional().describe('Prompt description'),
arguments: zod_1.z.array(exports.PromptArgumentSchema).optional().describe('Prompt arguments'),
});
/**
* Prompts list response data
* GET /api/v1/prompts
*/
exports.PromptsListDataSchema = zod_1.z.object({
prompts: zod_1.z.array(exports.PromptInfoSchema).describe('List of available prompts'),
});
exports.PromptsListResponseSchema = (0, common_1.createSuccessResponseSchema)(exports.PromptsListDataSchema);
/**
* Prompt message content
*/
exports.PromptMessageSchema = zod_1.z.object({
role: zod_1.z.enum(['user', 'assistant', 'system']).describe('Message role'),
content: zod_1.z.object({
type: zod_1.z.literal('text'),
text: zod_1.z.string().describe('Message text content'),
}).describe('Message content'),
});
/**
* Supporting file for folder-based skills (base64-encoded)
*/
exports.PromptFileSchema = zod_1.z.object({
path: zod_1.z.string().describe('Relative path within skill folder'),
content: zod_1.z.string().describe('Base64-encoded file content'),
});
/**
* Prompt get response data
* POST /api/v1/prompts/:promptName
*/
exports.PromptGetDataSchema = zod_1.z.object({
description: zod_1.z.string().optional().describe('Prompt description'),
messages: zod_1.z.array(exports.PromptMessageSchema).describe('Prompt messages'),
files: zod_1.z.array(exports.PromptFileSchema).optional().describe('Supporting files for folder-based skills (base64-encoded)'),
});
exports.PromptGetResponseSchema = (0, common_1.createSuccessResponseSchema)(exports.PromptGetDataSchema);
/**
* Prompt get request body
*/
exports.PromptGetRequestSchema = zod_1.z.object({
arguments: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional().describe('Arguments to pass to the prompt'),
});
/**
* Prompts endpoint error schemas
*/
exports.PromptNotFoundErrorSchema = common_1.NotFoundErrorSchema.extend({
error: zod_1.z.object({
code: zod_1.z.literal('NOT_FOUND'),
message: zod_1.z.string().regex(/Prompt not found/),
details: zod_1.z.any().optional(),
}),
});
exports.PromptValidationErrorSchema = common_1.BadRequestErrorSchema.extend({
error: zod_1.z.object({
code: zod_1.z.literal('VALIDATION_ERROR'),
message: zod_1.z.string(),
details: zod_1.z.any().optional(),
}),
});
exports.PromptsListErrorSchema = common_1.InternalServerErrorSchema.extend({
error: zod_1.z.object({
code: zod_1.z.literal('PROMPTS_LIST_ERROR'),
message: zod_1.z.string(),
details: zod_1.z.any().optional(),
}),
});
exports.PromptGetErrorSchema = common_1.InternalServerErrorSchema.extend({
error: zod_1.z.object({
code: zod_1.z.literal('PROMPT_GET_ERROR'),
message: zod_1.z.string(),
details: zod_1.z.any().optional(),
}),
});
/**
* Prompts cache refresh response data
* POST /api/v1/prompts/refresh
*/
exports.PromptsCacheRefreshDataSchema = zod_1.z.object({
refreshed: zod_1.z.boolean().describe('Whether the cache was refreshed'),
promptsLoaded: zod_1.z.number().describe('Total number of prompts loaded after refresh'),
source: zod_1.z.string().describe('Source of prompts (e.g., "built-in", "built-in+repository")'),
});
exports.PromptsCacheRefreshResponseSchema = (0, common_1.createSuccessResponseSchema)(exports.PromptsCacheRefreshDataSchema);
exports.PromptsCacheRefreshErrorSchema = common_1.InternalServerErrorSchema.extend({
error: zod_1.z.object({
code: zod_1.z.literal('PROMPTS_CACHE_REFRESH_ERROR'),
message: zod_1.z.string(),
details: zod_1.z.any().optional(),
}),
});