@ph-cms/api-contract
v0.1.4
Published
Shared Zod schemas and types for PH-CMS
Readme
@ph-cms/api-contract
Shared Zod schemas and TypeScript types for PH-CMS.
This package is intended to be published to npm and consumed by servers, clients, and tooling that need a single source of truth for request and response contracts.
Installation
npm install @ph-cms/api-contract zodUsage
import { CreateContentSchema, type CreateContentRequest } from '@ph-cms/api-contract';
import { UpdateUserProfileSchema, type UpdateUserProfileRequest } from '@ph-cms/api-contract';
// Create Content
const contentPayload: CreateContentRequest = {
title: 'Hello',
channelUid: 'news',
type: 'ARTICLE',
status: 'DRAFT',
};
const parsedContent = CreateContentSchema.parse(contentPayload);
// Update User Profile
const userPayload: UpdateUserProfileRequest = {
display_name: 'Updated Name',
avatar_url: 'https://example.com/avatar.jpg',
profile_data: { bio: 'New bio' }
};
const parsedUser = UpdateUserProfileSchema.parse(userPayload);Exports
- Auth, content, channel, user, hierarchy, policy, terms, geo, and common schemas
- Inferred TypeScript types derived from the shared Zod schemas
License
MIT
