export type Localised = string | { [locale: string]: T }; export function resolveLocalised(val: Localised | undefined, locale = 'en', defaultVal = ''): string { if (!val) return defaultVal; if (typeof val === 'string') return val; if (typeof val === 'object' && val !== null) { if (val[locale]) return String(val[locale]); if (val['en']) return String(val['en']); const keys = Object.keys(val); if (keys.length > 0) return String(val[keys[0]]); } return defaultVal; } export interface SiteConfig { schemaVersion: string; brand: { name: string; logo: string; tagline: Localised; }; locales: { default: string; supported: string[]; }; theme: { colors: { primary: string; accent: string; background: string; text: string; dark?: { background: string; text: string; }; }; font: { heading: string; body: string; }; radius: string; maxWidth: string; motion: boolean; }; nav: { header: Array<{ label: Localised; href: string; children?: string; }>; cta: { label: Localised; href: string; }; }; footer: { copyright: string; links: Array<{ label: Localised; href: string; }>; }; features: { tryIt: boolean; appPicker: boolean; darkMode: boolean; webAccounts: boolean; webWallet: boolean; }; seo: { titleTemplate: string; defaultOgImage: string; siteUrl: string; }; analytics?: { provider: string; id: string; consent: string; }; } export interface SectionConfig { id: string; type: string; variant?: string; disabled?: boolean; enabled?: boolean; props: Record; visibleWhen?: { device?: 'mobile' | 'desktop'; locale?: string; flag?: string; }; } export interface PageConfig { id: string; route: string; status: 'draft' | 'published' | 'archived'; seo: { title: Localised; description: Localised; indexable?: boolean; ogImage?: string; }; sections: SectionConfig[]; } export interface ParamSpec { name: string; alias?: string; description?: string; required: boolean; kind: 'file' | 'string' | 'integer' | 'number' | 'boolean' | 'json' | 'unknown'; rawType: string; default?: string; location: 'multipart' | 'form' | 'json' | 'query' | 'header' | 'path'; isSecret: boolean; source: 'user.file' | 'secret' | { option: string } | { constant: string }; } export interface VariantSpec { id: string; method: string; path: string; url: string; description?: string; label?: Localised; } export interface EndpointSpec { id: string; groupKey?: string; groupTitle?: string; title: string; summary?: string; description?: string; method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'MULTI'; url: string; baseUrl: string; path: string; responseType: string; params: ParamSpec[]; variants: VariantSpec[]; enabled: boolean; publicTry: boolean; limits: { timeoutMs: number; retries: number; maxUploadMB: number; allowedMime: string[]; rateLimit: string; }; response: { kind: 'binary-image' | 'json' | 'job'; delivery: 'stream' | 'signed-url'; }; hash: string; } export interface ToolItem { id: string; slug: string; status: 'draft' | 'published' | 'archived'; category: string; name: Localised; summary: Localised; homeApp: string; alsoIn?: string[]; featured?: boolean; tryIt: { enabled: boolean; endpointRef: { id: string; defaultVariant?: string; }; variantControl?: { type: 'radio' | 'tabs' | 'select'; label: Localised; }; limits?: { perDay: number; maxMB: number; maxPixels: number; formats: string[]; }; result?: { quality: string; showAppCta: boolean; }; }; content?: { steps?: Array<{ title: Localised; desc: Localised; }>; examples?: Array<{ before: string; after: string; alt?: Localised; caption?: string; }>; faqs?: Array<{ q: string; a: string; }>; }; related?: string[]; seo?: { title: string; description: string; }; } export interface AppItem { id: string; slug: string; status: 'draft' | 'published' | 'archived'; name: Localised; tagline: Localised; description: Localised; stores: { android?: { packageId: string; url: string; }; ios?: { appId: string; url: string; }; }; deepLink?: { base: string; toolParam?: string; sourceParam?: string; bonusParam?: string; }; tools: string[]; rating: { value: number; count: number; source: string; }; welcomeBonus?: { code: string; title: string; description: string; }; features?: string[]; creditsNote?: Localised; } export interface CategoryItem { id: string; slug: string; name: Localised; description: Localised; icon?: string; } export type TryItResult = | { state: 'succeeded'; delivery: 'stream' | 'signed-url'; resultUrl?: string; info?: { width?: number; height?: number; type: string }; durationMs?: number; } | { state: 'failed'; error: { code: string; messageKey: string; message?: string; retryable: boolean }; } | { state: 'limit'; messageKey: string; remainingToday?: number; } | { state: 'unavailable'; messageKey: string; }; export interface DiffReport { timestamp: string; addedEndpointIds: string[]; removedEndpointIds: string[]; changedEndpointIds: string[]; affectedTools: Array<{ toolId: string; toolSlug: string; issue: string }>; misconfiguredEndpoints: string[]; totalEndpoints: number; }