trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
89 lines • 3.07 kB
TypeScript
/**
* Catalog Generator — Reads brand tokens from the Trellis graph and produces
* a json-render catalog with Zod-constrained component props.
*
* Pure function: no side effects, no caching (caching is handled by CatalogCache).
*
* @module trellis/plugins/brand
*/
import type { EntityRecord } from '../../core/kernel/trellis-kernel.js';
import { type VoiceToneConfig } from './voice-tone.js';
export interface CollectedTokens {
color: Array<{
role: string;
value: unknown;
lightMode?: unknown;
darkMode?: unknown;
}>;
typography: Array<{
role: string;
value: unknown;
}>;
spacing: Array<{
role: string;
value: unknown;
}>;
shadow: Array<{
role: string;
value: unknown;
}>;
motion: Array<{
role: string;
value: unknown;
}>;
radius: Array<{
role: string;
value: unknown;
}>;
}
export interface BrandGuideData {
id: string;
name: string;
status: string;
complianceMode: 'strict' | 'moderate' | 'permissive';
voiceTone: VoiceToneConfig | null;
}
export interface GenerateCatalogResult {
/** The constrained catalog (opaque — call .prompt() or .jsonSchema() on it) */
catalog: unknown;
/** Voice/tone rules derived from the brand guide */
voiceRules: string[];
/** The parsed brand guide data */
guide: BrandGuideData;
/** All collected tokens grouped by type */
tokens: CollectedTokens;
}
/**
* Minimal kernel interface — only the methods the generator needs.
* Avoids importing the full TrellisKernel class.
*/
export interface KernelReader {
getEntity(entityId: string): EntityRecord | null;
listEntities(type?: string, filters?: Record<string, unknown>): EntityRecord[];
}
/**
* Collect all DesignTokens linked to a BrandGuide, grouped by tokenType.
*/
export declare function collectTokens(kernel: KernelReader, guideEntity: EntityRecord): CollectedTokens;
/**
* Parse a BrandGuide entity into structured data.
*/
export declare function parseBrandGuide(entity: EntityRecord): BrandGuideData;
/**
* Generate a brand-constrained json-render catalog.
*
* @param kernel - Trellis kernel (or anything implementing KernelReader)
* @param brandGuideId - Entity ID of the BrandGuide
* @param defineCatalog - The `defineCatalog` function from `@json-render/core`
* @param schema - The schema instance from `@json-render/react/schema` (or other renderer)
* @param baseComponents - Component definitions to constrain (defaults to shadcn if not provided)
* @returns Generated catalog, voice rules, guide data, and collected tokens
*/
export declare function generateBrandCatalog(kernel: KernelReader, brandGuideId: string, defineCatalog: (schema: unknown, input: {
components: Record<string, unknown>;
actions: Record<string, unknown>;
}) => unknown, schema: unknown, baseComponents: Record<string, {
props: unknown;
[key: string]: unknown;
}>): GenerateCatalogResult;
//# sourceMappingURL=catalog-generator.d.ts.map