@ujl-framework/types
v0.0.3
Published
UJL Types
Readme
@ujl-framework/types
Type Definitions and Validation - TypeScript types, Zod schemas, and validation utilities for the UJL Framework.
This package provides runtime validation for both theme and content files using Zod schemas. It also includes all TypeScript type definitions for the UJL Framework, ensuring type safety across the entire ecosystem.
Installation
pnpm add @ujl-framework/typesValidation
Quick Start
# Auto-detect type from JSON structure
pnpm run validate ./path/to/file.json
# Use the CLI tool directly
ujl-validate ./path/to/file.jsonProgrammatic Usage
import {
validateUJLCDocumentSafe,
validateUJLTDocumentSafe,
validateModule,
validateSlot,
} from "@ujl-framework/types";
// Validate documents (safe - returns result object)
const result = validateUJLCDocumentSafe(document);
if (result.success) {
console.log("Valid:", result.data);
} else {
console.error("Invalid:", result.error.issues);
}
// Validate partial structures
const module = validateModule(moduleData);
const slot = validateSlot(slotData);Available Functions:
validateUJLCDocumentSafe(data)/validateUJLCDocument(data)- Content validationvalidateUJLTDocumentSafe(data)/validateUJLTDocument(data)- Theme validationvalidateModule(data)- Single module validationvalidateSlot(data)- Slot validationvalidateTokenSet(data)- Token set validation
Library Types
Image assets use the LibraryAssetImage type:
interface LibraryAssetImage {
kind: "image";
img: {
src: string;
width?: number;
height?: number;
srcset?: ImageSrcSet;
};
meta?: ImageMetadata; // Alt, caption, credits
sources?: PictureSource[]; // Art direction
}Stored in ujlc.library as Record<string, LibraryAssetImage>.
Terminology mapping:
LibraryAssetImage.img= transport-level image payload (src, optionalsrcset, dimensions)- AST image nodes (
UJLAbstractImageNode) useprops.assetto hold the selectedLibraryAssetImage ImageSource/ImageSrcSetTypeare helper types used insideLibraryAssetImage(not a separate asset model)
For full type definitions, see:
library.ts- Asset types and provider interfacesujl-content.ts- Document and module typesujl-theme.ts- Theme and token typesast.ts- AST node types
