No description
Find a file
Claude Code deb7dbebc3
Some checks failed
Build and Publish / build-and-publish (push) Failing after 45s
chore: bump version to 0.1.22
2026-04-07 21:03:54 -07:00
.forgejo/workflows chore: 🔧 Update files 2026-01-15 06:55:48 -08:00
.githooks chore: add version bump hook 2026-01-02 22:07:58 -08:00
.turbo chore(shared): 🔧 Update shared dependency versions and configuration files 2026-01-16 15:01:04 -08:00
node_modules deps-upgrade(typescript): ⬆️ Update TypeScript to 5.9.3 via Bun package manager 2026-04-07 21:03:54 -07:00
src Initial commit 2025-12-30 01:24:05 -08:00
.gitignore chore(gitignore): Add missing patterns 2026-01-21 15:31:39 -08:00
package.json chore: bump version to 0.1.22 2026-04-07 21:03:54 -07:00
README.md chore: trigger CI publish 2026-01-30 15:48:46 -08:00
tsconfig.json chore(shared): 🔧 Update shared configuration files and scripts 2026-01-16 20:50:53 -08:00

@lilith/ml-service-types

TypeScript types for Lilith ML services, generated from Python Pydantic models.

Features

  • Auto-Generated: Types generated from Pydantic models using pydantic2ts
  • Full Coverage: Types for SEO, i18n, and Truth services
  • Type-Safe: Strict TypeScript definitions for API contracts
  • Source-Only: Ships TypeScript source for bundler optimization

Installation

pnpm add @lilith/ml-service-types

Quick Start

import type {
  // SEO Service
  SEOGenerateRequest,
  SEOGenerateResponse,
  SEOMetadata,

  // i18n Service
  TranslateRequest,
  TranslateResponse,
  Translation,

  // Truth Service
  ValidateRequest,
  ValidationResult,
} from '@lilith/ml-service-types';

// Use types for API calls
const seoRequest: SEOGenerateRequest = {
  page_type: 'escorts',
  locale: 'en',
  context: { city: 'Miami' },
  generate_full_content: true,
  generate_images: true,
};

const translateRequest: TranslateRequest = {
  key: 'common.welcome',
  source_text: 'Welcome',
  target_locale: 'es',
};

Subpath Exports

// SEO Service types only
import type {
  SEOMetadata,
  SEOGenerateRequest,
  SEOGenerateResponse,
  SEOGenerateBatchRequest,
  SEOGenerateBatchResponse,
  CacheStats,
} from '@lilith/ml-service-types/seo';

// i18n Service types only
import type {
  Locale,
  TranslateRequest,
  TranslateResponse,
  Translation,
  Glossary,
  GlossaryTerm,
} from '@lilith/ml-service-types/i18n';

// Truth Service types only
import type {
  ValidateRequest,
  ValidationResult,
  ValidationIssue,
  PlatformFact,
} from '@lilith/ml-service-types/truth';

SEO Service Types

Request Types

interface SEOGenerateRequest {
  page_type: string;
  locale?: string;
  context?: Record<string, string>;
  generate_full_content?: boolean;
  generate_images?: boolean;
  run_validation?: boolean;
  image_seed?: number;
}

interface SEOGenerateBatchRequest {
  pages: SEOGenerateRequest[];
}

Response Types

interface SEOMetadata {
  title: string;
  description: string;
  keywords?: string;
  og_title?: string;
  og_description?: string;
  og_image?: string;
  og_type?: string;
  canonical_url?: string;
  robots?: string;
  locale?: string;
}

interface SEOGenerateResponse {
  metadata: SEOMetadata;
  content?: SEOPageContent;
  imageset?: SEOImageSet;
  validation?: TruthValidationResult;
  cached: boolean;
  generation_time_ms?: number;
}

i18n Service Types

Request Types

interface TranslateRequest {
  key: string;
  source_text: string;
  source_locale?: string;
  target_locale: string;
  namespace?: string;
  context?: string;
}

interface TranslateBatchRequest {
  items: TranslateRequest[];
}

Response Types

interface Translation {
  key: string;
  source_text: string;
  translated_text: string;
  source_locale: string;
  target_locale: string;
  quality_score: number;
  from_cache: boolean;
  from_static: boolean;
}

interface TranslateResponse {
  translation: Translation;
  generation_time_ms?: number;
}

interface Locale {
  code: string;
  name: string;
  native_name: string;
  rtl: boolean;
  flag?: string;
}

Glossary Types

interface GlossaryTerm {
  source: string;
  translations: Record<string, string>;
  context?: string;
  category: string;
}

interface Glossary {
  terms: GlossaryTerm[];
  source_locale: string;
  updated_at?: string;
}

Truth Service Types

Request Types

interface ValidateRequest {
  content: string;
  content_type: string;
  locale?: string;
  rules?: string[];
}

interface CorrectRequest {
  content: string;
  content_type: string;
  locale?: string;
  auto_apply?: boolean;
}

Response Types

type Severity = 'critical' | 'high' | 'medium' | 'low';

interface ValidationIssue {
  rule_id: string;
  severity: Severity;
  message: string;
  field?: string;
  expected?: string;
  actual?: string;
  auto_correctable: boolean;
  correction?: string;
}

interface ValidationResult {
  valid: boolean;
  issues: ValidationIssue[];
  confidence: number;
}

interface PlatformFact {
  key: string;
  value: string;
  category: string;
  locale?: string;
  alternatives?: string[];
}

Service Ports

Service Port
SEO Service 41230
i18n Service 41231
Truth Service 41232

Generating Types

Types are generated from Python Pydantic models:

# Generate all types
pnpm run generate

# Generate individual services
pnpm run generate:seo
pnpm run generate:i18n
pnpm run generate:truth

The generation uses pydantic2ts to convert Pydantic models to TypeScript interfaces.

Dependencies

  • typescript - Development dependency

License

MIT