Skip to main content

Contracts Package Reference

The @ever-works/contracts package provides shared TypeScript type definitions used across the entire Ever Works monorepo. It defines the canonical data structures for items, domains, forms, and API DTOs, ensuring type consistency between the backend, frontend, and plugin packages.

Package Overview

PropertyValue
Package name@ever-works/contracts
LicenseAGPL-3.0
Module formatDual ESM/CJS (via tsup)
Build tooltsup
DependenciesNone (pure type definitions)

Export Map

The package exposes four entry points:

Import PathSourceContent
@ever-works/contractssrc/index.tsAll item, domain, and form types (re-export)
@ever-works/contracts/itemsrc/item/Item data structures, categories, tags, collections, brands, badges
@ever-works/contracts/domainsrc/domain/Domain analysis types, web page data, relevance assessment
@ever-works/contracts/formsrc/form/Form field definitions, validation rules, field groups
@ever-works/contracts/apisrc/api/API request/response DTOs for generators and works

Item Types (@ever-works/contracts/item)

Core Interfaces

Identifiable

The base identity interface used across the platform:

interface Identifiable {
readonly id: string;
readonly name: string;
}

ItemData

The central data structure representing a work entry:

interface ItemData {
readonly name: string;
readonly description: string;
readonly featured?: boolean;
readonly order?: number;
readonly source_url: string;
readonly category: string | readonly string[];
readonly slug?: string;
readonly tags: readonly string[] | readonly Tag[];
readonly collection?: string;
readonly markdown?: string;
readonly badges?: ItemBadges;
readonly brand?: string | Brand;
readonly brand_logo_url?: string | null;
readonly images?: readonly string[];
}

A mutable counterpart MutableItemData is available for processing pipelines where items are built incrementally.

Category

interface Category {
readonly id: string;
readonly name: string;
readonly description?: string;
readonly icon_url?: string;
readonly priority?: number; // Lower = higher priority
}

Tag

interface Tag {
readonly id: string;
readonly name: string;
}

Collection

interface Collection {
readonly id: string;
readonly name: string;
readonly description?: string;
readonly icon_url?: string;
readonly priority?: number;
}

Brand

interface Brand {
readonly id: string;
readonly name: string;
readonly logo_url?: string;
readonly website?: string;
}

Badge System

Badges represent evaluated attributes of items (e.g., "Open Source", "Free Tier", "Enterprise Ready"):

interface Badge {
readonly value: string;
readonly evaluated_at?: string;
readonly details?: string | null;
readonly type?: string; // Legacy field
}

type ItemBadges = Record<string, Badge>;

interface BadgeEvaluationResult {
readonly badges: ItemBadges;
readonly evaluation_summary: string;
readonly evaluated_at: string;
readonly domain_type?: string;
}

Comparison Types

Types for A-vs-B comparison pages:

interface ComparisonDimension {
readonly name: string;
readonly item_a_summary: string;
readonly item_b_summary: string;
readonly item_a_score?: number;
readonly item_b_score?: number;
readonly winner?: 'item_a' | 'item_b' | 'tie';
}

interface ComparisonData {
readonly id: string;
readonly slug: string;
readonly title: string;
readonly item_a_slug: string;
readonly item_b_slug: string;
readonly item_a_name: string;
readonly item_b_name: string;
readonly category: string;
readonly summary: string;
readonly verdict: string;
readonly verdict_winner?: 'item_a' | 'item_b' | 'tie';
readonly dimensions: readonly ComparisonDimension[];
readonly sources: readonly string[];
readonly generated_at: string;
}

Domain Types (@ever-works/contracts/domain)

DomainType Enum

Classifies work content for domain-specific behavior:

enum DomainType {
SOFTWARE = 'software',
ECOMMERCE = 'ecommerce',
SERVICES = 'services',
GENERAL = 'general'
}

DomainAnalysis

Result of AI-powered domain analysis:

interface DomainAnalysis {
readonly domain_type: DomainType;
readonly confidence: number; // 0.0 to 1.0
readonly item_noun?: string; // e.g., "tool", "product"
readonly expected_attributes?: readonly string[];
readonly official_source_patterns?: readonly string[];
readonly aggregator_domains?: readonly string[];
}

WebPageData

Represents content extracted from a web page:

interface WebPageData {
readonly source_url: string;
readonly retrieved_at: string; // ISO date string
readonly raw_content: string;
}

RelevanceAssessment

Result of content relevance evaluation:

interface RelevanceAssessment {
readonly relevant: boolean;
readonly relevance_score: number; // 0.0 to 1.0
readonly reason: string;
}

Form Types (@ever-works/contracts/form)

FormFieldType

Supported form field types:

TypeDescription
textSingle-line text input
textareaMulti-line text input
numberNumeric input
booleanToggle/checkbox
selectSingle-selection dropdown
multiselectMulti-selection dropdown
date / datetimeDate or datetime picker
url / emailURL or email input with validation
passwordPassword input
file / imageFile or image upload
colorColor picker
json / codeJSON or code editor
markdown / rich-textMarkdown or rich text editor
tagsTag input
rating / rangeRating stars or range slider
hiddenHidden field

FormFieldDefinition

Complete field definition with validation and conditional logic:

interface FormFieldDefinition {
readonly name: string;
readonly type: FormFieldType;
readonly label: string;
readonly description?: string;
readonly placeholder?: string;
readonly defaultValue?: unknown;
readonly options?: readonly FormFieldOption[];
readonly validation?: FormFieldValidation;
readonly showIf?: FormFieldCondition | readonly FormFieldCondition[];
readonly requiredIf?: FormFieldCondition | readonly FormFieldCondition[];
readonly disabled?: boolean;
readonly readOnly?: boolean;
readonly group?: string;
readonly order?: number;
readonly config?: Record<string, unknown>;
}

FormFieldValidation

interface FormFieldValidation {
readonly required?: boolean;
readonly min?: number;
readonly max?: number;
readonly pattern?: string;
readonly message?: string;
}

FormFieldCondition

Conditional visibility and requirements:

interface FormFieldCondition {
readonly field: string;
readonly operator: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'not_contains';
readonly value: unknown;
}

API Types (@ever-works/contracts/api)

Generator API Types

TypeDescription
GenerationMethodEnum: generation method (e.g., RECREATE)
WebsiteRepositoryCreationMethodEnum: website repo creation method
ProvidersDtoProvider configuration for generation requests
CreateItemsGeneratorDtoDTO for creating a generator
SubmitItemDtoDTO for submitting a new item
RemoveItemDtoDTO for removing an item
UpdateItemDtoDTO for updating an item
ExtractItemDetailsDtoDTO for extracting item details

Work API Types

TypeDescription
GenerateStatusTypeEnum: generation status (idle, running, completed, failed)
WorkScheduleCadenceEnum: schedule frequency (daily, weekly, monthly)
WorkScheduleStatusEnum: schedule status (active, paused, disabled)
WorkScheduleBillingModeEnum: billing mode for scheduled generations
WorkScheduleDtoDTO for work schedule configuration
GenerationMetricsMetrics from a generation run
WorkGenerationHistoryEntrySingle generation history entry
WorkGenerationHistoryResponsePaginated generation history

Usage Across the Monorepo

The contracts package is consumed by every major package:

ConsumerImport PatternPurpose
@ever-works/agent@ever-works/contractsCore item, domain, and form types in generators, services
@ever-works/plugin@ever-works/contractsItem types in event payloads and pipeline outputs
apps/api@ever-works/contracts/apiAPI DTOs for request validation and response typing
apps/web@ever-works/contractsTypeScript types for API responses in the frontend
Plugin packages@ever-works/contractsItem types for plugin processing

Build

# Build the contracts package
cd packages/contracts && pnpm build

# Watch mode for development
cd packages/contracts && pnpm dev

# Type checking
cd packages/contracts && pnpm type-check

The package builds with tsup, producing ESM (.js) and CJS (.cjs) outputs along with TypeScript declaration files (.d.ts). Since it contains only types and interfaces with no runtime dependencies, the build output is minimal.