template-studio/src/types.ts

81 lines
1.6 KiB
TypeScript

export type TemplateType = 'email' | 'report'
export type BlockType = 'heading' | 'text' | 'kpi' | 'button' | 'image' | 'divider' | 'table' | 'spacer'
export type Block = {
id: string
type: BlockType
props: Record<string, unknown>
style?: Record<string, unknown>
}
export type TemplateDocument = {
theme?: Record<string, unknown>
email?: {
subject?: string
preheader?: string
}
blocks: Block[]
}
export type EmailCompatibilityWarning = {
code: string
severity: 'info' | 'warning' | 'error'
message: string
block_id?: string | null
}
export type EmailRenderResult = {
subject: string
preheader: string
html: string
text: string
warnings: EmailCompatibilityWarning[]
metadata: Record<string, unknown>
}
export type TemplateRecord = {
id: string
template_key: string
name: string
type: TemplateType
status: string
draft_document: TemplateDocument
sample_data: Record<string, unknown>
published_version?: number | null
folder_id?: string | null
updated_at: string
}
export type TemplateSummary = Pick<
TemplateRecord,
'id' | 'template_key' | 'name' | 'type' | 'status' | 'published_version' | 'folder_id' | 'updated_at'
>
export type ApiKeySummary = {
id: string
name: string
key_prefix: string
created_at: string
last_used_at?: string | null
}
export type ThemeSummary = {
id: string
name: string
applies_to: 'all' | TemplateType
theme: Record<string, unknown>
created_at: string
updated_at: string
}
export type FolderSummary = {
id: string
name: string
parent_id?: string | null
template_count: number
created_at: string
updated_at: string
}