数据模型 (DTO)
API 的标准请求/响应结构,便于类型约束与 SDK 开发。
这些 DTO 反映了 SyncPostly 当前的标准请求与响应结构。
Media
type MediaDto = {
id: string;
mime_type: 'image/png' | 'image/jpeg' | 'video/mp4' | 'video/quicktime';
type: 'image' | 'video';
post_id: string | null;
status: 'pending' | 'uploaded';
object: {
isDeleted: boolean;
url: string | null;
size_bytes: number;
name: string | null;
};
};
type CreateUploadUrlResponse = {
media_id: string;
upload_url: string; // PUT /api/v1/media/upload/{id}
name: string;
};
type UploadResponse = {
success: true;
media_id: string;
url: string;
};
type DeleteResponse = { success: true };Posts
type PostStatus = 'draft' | 'processing' | 'scheduled' | 'posted' | 'failed';
type PostDto = {
id: string;
caption: string;
social_accounts: string[];
scheduled_at: string | null;
is_draft: boolean;
status: PostStatus;
media: string[]; // 仅包含已上传媒体的 ID
platform_configurations: Record<string, unknown> | null;
account_configurations: Record<string, unknown> | null;
processing_enabled: boolean;
};
type CreatePostPayload = {
caption: string;
social_accounts: string[];
scheduled_at?: string | null;
is_draft?: boolean | null;
media?: string[];
media_urls?: string[];
platform_configurations?: Record<string, unknown> | null;
account_configurations?: Record<string, unknown> | null;
processing_enabled?: boolean | null;
};
// PATCH 接受 Partial<CreatePostPayload>Social accounts
type SocialAccountDto = {
id: string;
platform:
| 'twitter-x'
| 'instagram'
| 'linkedin'
| 'facebook-page'
| 'tiktok'
| 'youtube'
| 'bluesky'
| 'threads'
| 'pinterest';
username: string;
display_name: string | null;
};Post results
type PostResultDto = {
id: string;
post_id: string;
success: boolean;
social_account_id: string | null;
platform_data: {
id: string | null;
url: string | null;
username: string | null;
};
error: {
code: string;
message: string;
context?: Record<string, unknown> | null;
} | null;
};分页包装
interface Paginated<T> {
data: T[];
meta: { offset: number; limit: number; total: number };
}