UCD.js Docs
Schemas & Generation

Schema Gen

AI-powered schema generation

Schema Gen

AI-powered schema generation for Unicode data files.

Installation

npm install @ucdjs/schema-gen

Overview

The @ucdjs/schema-gen package provides tools to automatically generate TypeScript interfaces and field definitions from raw Unicode data files using AI models.

Usage

The primary function is runSchemagen, which processes a list of files and generates TypeScript code.

generate.ts
import { runSchemagen } from "@ucdjs/schema-gen";

const results = await runSchemagen({
  files: [
    {
      filePath: "./data/UnicodeData.txt",
      version: "15.1.0"
    }
  ],
  openaiKey: process.env.OPENAI_API_KEY,
  // Alternatively, provide a custom AI model
  // model: myCustomModel
});

for (const result of results) {
  console.log(`Generated code for ${result.fileName}:`);
  console.log(result.code);
}

You must provide either an openaiKey or a custom model (from the AI SDK) to use the schema generator.

On this page