@presentations-ai/shared
v0.2.2
Published
TypeScript types, Zod schemas, and error handling for the Presentations.AI API
Maintainers
Readme
@presentations-ai/shared
TypeScript types, Zod schemas, and error handling for the Presentations.AI API. Validate tool inputs, type-check API responses, and handle errors consistently.
Do you need this package?
Most developers don't install this directly. It's a low-level building block used internally by:
@presentations-ai/api-client— REST client (already depends on this)@presentations-ai/cloudy-runtime— AI runtime (already depends on this)
Install @presentations-ai/shared directly only if you're:
- Building your own client/runtime that talks to the Presentations.AI API
- Validating tool inputs server-side (e.g., in a custom MCP wrapper)
- Re-exporting the types in your own SDK
If you just want to create presentations from your app, install one of the two packages above instead.
Installation
npm install @presentations-ai/sharedWhat's included
| Export | Description |
|--------|-------------|
| Zod schemas | Input validation for all 9 MCP tools |
| TypeScript types | Request/response interfaces for the REST API |
| StructuredError | Error class: { code, message, remediation } |
| ErrorCode | Enum of all error codes |
| Token budget | Token estimation and truncation utilities |
Usage
Validate inputs
import { CreateFromTopicInputSchema } from '@presentations-ai/shared';
const result = CreateFromTopicInputSchema.safeParse({
topic: 'Series B Pitch: AI-Powered Design Platform',
exportType: 'pptx',
slideCount: 12,
});
if (result.success) {
console.log(result.data); // validated input ready to send to the API
} else {
console.error(result.error.issues);
}TypeScript types
import type { CreateFromTopicRequest } from '@presentations-ai/shared';
const req: CreateFromTopicRequest = {
topic: 'Q4 Growth Strategy for Enterprise Sales',
exportType: 'pdf',
slideCount: 15,
targetAudience: 'leadership team',
tone: 'professional',
};Structured errors
import { StructuredError } from '@presentations-ai/shared';
try {
await client.createFromTopic({ topic: '', exportType: 'pptx' });
} catch (err) {
if (err instanceof StructuredError) {
console.error(err.code); // "API_VALIDATION_FAILED"
console.error(err.message); // "topic must be a non-empty string"
console.error(err.remediation); // "Provide a presentation topic (1-500 characters)."
}
}Schemas
| Schema | Purpose |
|--------|---------|
| CreateFromTopicInputSchema | Generate from a topic string |
| CreateFromFileInputSchema | Convert a file (PDF, DOCX, etc.) |
| CreateSingleSlideInputSchema | Generate one slide |
| CreateFromContentInputSchema | Create from structured slide data |
| CreateFromRawContentInputSchema | Transform raw text |
| UpdateSlidesInputSchema | Update specific slides |
| RefreshPresentationInputSchema | Regenerate an existing presentation |
| CheckJobStatusInputSchema | Poll an async job |
| ExportPresentationInputSchema | Export to a format |
Requirements
- Node.js >= 20.0.0
License
MIT