(data: {
perspective_id: string;
image_data?: Buffer;
prompt_used?: string;
author_description?: string;
status?: 'pending' | 'generated' | 'approved';
c2pa_signed_at?: Date;
c2pa_manifest_digest?: string;
})
| 72 | |
| 73 | /** Create a new illustration record */ |
| 74 | export async function createIllustration(data: { |
| 75 | perspective_id: string; |
| 76 | image_data?: Buffer; |
| 77 | prompt_used?: string; |
| 78 | author_description?: string; |
| 79 | status?: 'pending' | 'generated' | 'approved'; |
| 80 | c2pa_signed_at?: Date; |
| 81 | c2pa_manifest_digest?: string; |
| 82 | }): Promise<PerspectiveIllustration> { |
| 83 | const result = await query<PerspectiveIllustration>( |
| 84 | `INSERT INTO perspective_illustrations (perspective_id, image_data, prompt_used, author_description, status, c2pa_signed_at, c2pa_manifest_digest) |
| 85 | VALUES ($1, decode($2, 'base64'), $3, $4, $5, $6, $7) |
| 86 | RETURNING ${METADATA_COLUMNS}`, |
| 87 | [ |
| 88 | data.perspective_id, |
| 89 | data.image_data ? data.image_data.toString('base64') : null, |
| 90 | data.prompt_used || null, |
| 91 | data.author_description || null, |
| 92 | data.status || 'generated', |
| 93 | data.c2pa_signed_at ?? null, |
| 94 | data.c2pa_manifest_digest ?? null, |
| 95 | ] |
| 96 | ); |
| 97 | return result.rows[0]; |
| 98 | } |
| 99 | |
| 100 | /** Approve an illustration and set it as the perspective's active illustration */ |
| 101 | export async function approveIllustration(illustrationId: string, perspectiveId: string): Promise<IllustrationMetadata | null> { |
no outgoing calls
no test coverage detected