No description
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| .githooks | ||
| .turbo | ||
| node_modules | ||
| src | ||
| .gitignore | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
@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