857389e68b
Co-Authored-By: Claude Code <noreply@anthropic.com>
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
export const UNIVERSAL_ROW_VERSION = 1
|
|
|
|
export interface UniversalRow {
|
|
sourceType: string
|
|
sourceId: string
|
|
status: string
|
|
locale: string
|
|
sourceUrl?: string
|
|
slug?: string
|
|
title?: string
|
|
excerpt?: string
|
|
bodyHtml?: string
|
|
publishedAt?: string
|
|
modifiedAt?: string
|
|
taxonomyRefs: Array<{ taxonomy: string; sourceTermId: string }>
|
|
attachmentRefs: Array<{ role: string; sourceId?: string; sourceUrl?: string }>
|
|
seo: Record<string, unknown>
|
|
knownFields: Record<string, unknown>
|
|
extras: Record<string, unknown>
|
|
rawLocation: string
|
|
}
|
|
|
|
const REQUIRED: (keyof UniversalRow)[] = [
|
|
'sourceType', 'sourceId', 'status', 'locale',
|
|
'taxonomyRefs', 'attachmentRefs', 'seo', 'knownFields', 'extras', 'rawLocation',
|
|
]
|
|
|
|
export function isUniversalRow(v: unknown): v is UniversalRow {
|
|
if (typeof v !== 'object' || v === null) return false
|
|
const row = v as Record<string, unknown>
|
|
return REQUIRED.every((k) => k in row)
|
|
&& Array.isArray(row.taxonomyRefs) && Array.isArray(row.attachmentRefs)
|
|
&& row.seo !== null && typeof row.seo === 'object'
|
|
&& row.knownFields !== null && typeof row.knownFields === 'object'
|
|
&& row.extras !== null && typeof row.extras === 'object'
|
|
}
|