@onlyworlds/sdk
Version:
TypeScript SDK for the OnlyWorlds API - build world-building applications with type safety
1,559 lines (1,558 loc) • 86.7 kB
text/typescript
/**
* Modern branded types for type-safe element relationships
* Provides compile-time safety while maintaining zero runtime overhead
*/
declare const __brand: unique symbol;
type Brand<B> = {
[__brand]: B;
};
/**
* Branded type for element IDs - ensures type safety for relationships
* @template T The element type this ID references
*/
type ElementId<T extends ElementType> = string & Brand<T>;
/**
* Branded type for arrays of element IDs
* @template T The element type these IDs reference
*/
type ElementIds<T extends ElementType> = ElementId<T>[];
/**
* Special type for IDs that can reference ANY element type
* Used in cases like Pin.element_type where the target can be any OnlyWorlds element
*/
type AnyElementId = ElementId<ElementType>;
/**
* Base fields shared by all OnlyWorlds elements
*/
interface BaseElement {
id?: string;
name: string;
description?: string;
image_url?: string;
supertype?: string;
subtype?: string;
world?: string;
created_at?: string;
updated_at?: string;
}
/**
* World element type
*/
interface World {
id?: string;
api_key: string;
name: string;
description?: string;
version?: string;
image_url?: string;
time_format_equivalents?: any[];
time_format_names?: any[];
time_basic_unit?: string;
time_range_min?: number;
time_range_max?: number;
time_current?: number;
user?: string;
created_at?: string;
updated_at?: string;
}
/**
* World input type for creation/updates
*/
interface WorldInput {
name: string;
description?: string;
version?: string;
image_url?: string;
time_format_equivalents?: any[];
time_format_names?: any[];
time_basic_unit?: string;
time_range_min?: number;
time_range_max?: number;
time_current?: number;
}
/**
* Ability element type
* Fields organized by sections: Mechanics, World
*/
interface Ability extends BaseElement {
activation?: string;
duration?: number;
potency?: number;
range?: number;
effects?: ElementIds<ElementType.Phenomenon>;
challenges?: string;
talents?: ElementIds<ElementType.Trait>;
requisites?: ElementIds<ElementType.Construct>;
prevalence?: string;
tradition?: ElementId<ElementType.Construct>;
source?: ElementId<ElementType.Phenomenon>;
locus?: ElementId<ElementType.Location>;
instruments?: ElementIds<ElementType.Object>;
systems?: ElementIds<ElementType.Construct>;
}
/**
* Object element type
* Fields organized by sections: Form, Function, World
*/
interface Object$1 extends BaseElement {
aesthetics?: string;
weight?: number;
amount?: number;
parent_object?: ElementId<ElementType.Object>;
materials?: ElementIds<ElementType.Construct>;
technology?: ElementIds<ElementType.Construct>;
utility?: string;
effects?: ElementIds<ElementType.Phenomenon>;
abilities?: ElementIds<ElementType.Ability>;
consumes?: ElementIds<ElementType.Construct>;
origins?: string;
location?: ElementId<ElementType.Location>;
language?: ElementId<ElementType.Language>;
affinities?: ElementIds<ElementType.Trait>;
}
/**
* Character element type
* Fields organized by sections: Constitution, Origins, World, Personality, Social, TTRPG
*/
interface Character extends BaseElement {
physicality?: string;
mentality?: string;
height?: number;
weight?: number;
species?: ElementIds<ElementType.Species>;
traits?: ElementIds<ElementType.Trait>;
abilities?: ElementIds<ElementType.Ability>;
background?: string;
motivations?: string;
birth_date?: number;
birthplace?: ElementId<ElementType.Location>;
languages?: ElementIds<ElementType.Language>;
reputation?: string;
location?: ElementId<ElementType.Location>;
objects?: ElementIds<ElementType.Object>;
institutions?: ElementIds<ElementType.Institution>;
charisma?: number;
coercion?: number;
competence?: number;
compassion?: number;
creativity?: number;
courage?: number;
family?: ElementIds<ElementType.Family>;
friends?: ElementIds<ElementType.Character>;
rivals?: ElementIds<ElementType.Character>;
level?: number;
hit_points?: number;
STR?: number;
DEX?: number;
CON?: number;
INT?: number;
WIS?: number;
CHA?: number;
}
/**
* Collective element type
* Fields organized by sections: Formation, Dynamics, World
*/
interface Collective extends BaseElement {
composition?: string;
count?: number;
formation_date?: number;
operator?: ElementId<ElementType.Institution>;
equipment?: ElementIds<ElementType.Construct>;
activity?: string;
disposition?: string;
state?: string;
abilities?: ElementIds<ElementType.Ability>;
symbolism?: ElementIds<ElementType.Construct>;
species?: ElementIds<ElementType.Species>;
characters?: ElementIds<ElementType.Character>;
creatures?: ElementIds<ElementType.Creature>;
phenomena?: ElementIds<ElementType.Phenomenon>;
}
/**
* Construct element type
* Fields organized by sections: Nature, Involves
*/
interface Construct extends BaseElement {
rationale?: string;
history?: string;
status?: string;
reach?: string;
start_date?: number;
end_date?: number;
founder?: ElementId<ElementType.Character>;
custodian?: ElementId<ElementType.Institution>;
characters?: ElementIds<ElementType.Character>;
objects?: ElementIds<ElementType.Object>;
locations?: ElementIds<ElementType.Location>;
species?: ElementIds<ElementType.Species>;
creatures?: ElementIds<ElementType.Creature>;
institutions?: ElementIds<ElementType.Institution>;
traits?: ElementIds<ElementType.Trait>;
collectives?: ElementIds<ElementType.Collective>;
zones?: ElementIds<ElementType.Zone>;
abilities?: ElementIds<ElementType.Ability>;
phenomena?: ElementIds<ElementType.Phenomenon>;
languages?: ElementIds<ElementType.Language>;
families?: ElementIds<ElementType.Family>;
relations?: ElementIds<ElementType.Relation>;
titles?: ElementIds<ElementType.Title>;
constructs?: ElementIds<ElementType.Construct>;
events?: ElementIds<ElementType.Event>;
narratives?: ElementIds<ElementType.Narrative>;
}
/**
* Creature element type
* Fields organized by sections: Biology, Behaviour, World, TTRPG
*/
interface Creature extends BaseElement {
appearance?: string;
weight?: number;
height?: number;
species?: ElementIds<ElementType.Species>;
habits?: string;
demeanor?: string;
traits?: ElementIds<ElementType.Trait>;
abilities?: ElementIds<ElementType.Ability>;
languages?: ElementIds<ElementType.Language>;
status?: string;
birth_date?: number;
location?: ElementId<ElementType.Location>;
zone?: ElementId<ElementType.Zone>;
challenge_rating?: number;
hit_points?: number;
armor_class?: number;
speed?: number;
actions?: ElementIds<ElementType.Ability>;
}
/**
* Event element type
* Fields organized by sections: Nature, Involves
*/
interface Event extends BaseElement {
history?: string;
challenges?: string;
consequences?: string;
start_date?: number;
end_date?: number;
triggers?: ElementIds<ElementType.Event>;
characters?: ElementIds<ElementType.Character>;
objects?: ElementIds<ElementType.Object>;
locations?: ElementIds<ElementType.Location>;
species?: ElementIds<ElementType.Species>;
creatures?: ElementIds<ElementType.Creature>;
institutions?: ElementIds<ElementType.Institution>;
traits?: ElementIds<ElementType.Trait>;
collectives?: ElementIds<ElementType.Collective>;
zones?: ElementIds<ElementType.Zone>;
abilities?: ElementIds<ElementType.Ability>;
phenomena?: ElementIds<ElementType.Phenomenon>;
languages?: ElementIds<ElementType.Language>;
families?: ElementIds<ElementType.Family>;
relations?: ElementIds<ElementType.Relation>;
titles?: ElementIds<ElementType.Title>;
constructs?: ElementIds<ElementType.Construct>;
}
/**
* Family element type
* Fields organized by sections: Identity, World
*/
interface Family extends BaseElement {
spirit?: string;
history?: string;
traditions?: ElementIds<ElementType.Construct>;
traits?: ElementIds<ElementType.Trait>;
abilities?: ElementIds<ElementType.Ability>;
languages?: ElementIds<ElementType.Language>;
ancestors?: ElementIds<ElementType.Character>;
reputation?: string;
estates?: ElementIds<ElementType.Location>;
governs?: ElementIds<ElementType.Institution>;
heirlooms?: ElementIds<ElementType.Object>;
creatures?: ElementIds<ElementType.Creature>;
}
/**
* Institution element type
* Fields organized by sections: Foundation, Claims, World
*/
interface Institution extends BaseElement {
doctrine?: string;
founding_date?: number;
parent_institution?: ElementId<ElementType.Institution>;
zones?: ElementIds<ElementType.Zone>;
objects?: ElementIds<ElementType.Object>;
creatures?: ElementIds<ElementType.Creature>;
status?: string;
allies?: ElementIds<ElementType.Institution>;
adversaries?: ElementIds<ElementType.Institution>;
constructs?: ElementIds<ElementType.Construct>;
}
/**
* Language element type
* Fields organized by sections: Structure, World
*/
interface Language extends BaseElement {
phonology?: string;
grammar?: string;
lexicon?: string;
writing?: string;
classification?: ElementId<ElementType.Construct>;
status?: string;
spread?: ElementIds<ElementType.Location>;
dialects?: ElementIds<ElementType.Language>;
}
/**
* Law element type
* Fields organized by sections: Code, World
*/
interface Law extends BaseElement {
declaration?: string;
purpose?: string;
date?: number;
parent_law?: ElementId<ElementType.Law>;
penalties?: ElementIds<ElementType.Construct>;
author?: ElementId<ElementType.Institution>;
locations?: ElementIds<ElementType.Location>;
zones?: ElementIds<ElementType.Zone>;
prohibitions?: ElementIds<ElementType.Construct>;
adjudicators?: ElementIds<ElementType.Title>;
enforcers?: ElementIds<ElementType.Title>;
}
/**
* Location element type
* Fields organized by sections: Setting, Politics, World, Production, Commerce, Construction, Defense
*/
interface Location extends BaseElement {
form?: string;
function?: string;
founding_date?: number;
parent_location?: ElementId<ElementType.Location>;
populations?: ElementIds<ElementType.Collective>;
political_climate?: string;
primary_power?: ElementId<ElementType.Institution>;
governing_title?: ElementId<ElementType.Title>;
secondary_powers?: ElementIds<ElementType.Institution>;
zone?: ElementId<ElementType.Zone>;
rival?: ElementId<ElementType.Location>;
partner?: ElementId<ElementType.Location>;
customs?: string;
founders?: ElementIds<ElementType.Character>;
cults?: ElementIds<ElementType.Construct>;
delicacies?: ElementIds<ElementType.Species>;
extraction_methods?: ElementIds<ElementType.Construct>;
extraction_goods?: ElementIds<ElementType.Construct>;
industry_methods?: ElementIds<ElementType.Construct>;
industry_goods?: ElementIds<ElementType.Construct>;
infrastructure?: string;
extraction_markets?: ElementIds<ElementType.Location>;
industry_markets?: ElementIds<ElementType.Location>;
currencies?: ElementIds<ElementType.Construct>;
architecture?: string;
buildings?: ElementIds<ElementType.Object>;
building_methods?: ElementIds<ElementType.Construct>;
defensibility?: string;
elevation?: number;
fighters?: ElementIds<ElementType.Construct>;
defensive_objects?: ElementIds<ElementType.Object>;
}
/**
* Phenomenon element type
* Fields organized by sections: Mechanics, World
*/
interface Phenomenon extends BaseElement {
expression?: string;
effects?: string;
duration?: number;
catalysts?: ElementIds<ElementType.Object>;
empowerments?: ElementIds<ElementType.Ability>;
mythology?: string;
system?: ElementId<ElementType.Phenomenon>;
triggers?: ElementIds<ElementType.Construct>;
wielders?: ElementIds<ElementType.Character>;
environments?: ElementIds<ElementType.Location>;
}
/**
* Relation element type
* Fields organized by sections: Nature, Involves
*/
interface Relation extends BaseElement {
background?: string;
start_date?: number;
end_date?: number;
intensity?: number;
actor?: ElementId<ElementType.Character>;
events?: ElementIds<ElementType.Event>;
characters?: ElementIds<ElementType.Character>;
objects?: ElementIds<ElementType.Object>;
locations?: ElementIds<ElementType.Location>;
species?: ElementIds<ElementType.Species>;
creatures?: ElementIds<ElementType.Creature>;
institutions?: ElementIds<ElementType.Institution>;
traits?: ElementIds<ElementType.Trait>;
collectives?: ElementIds<ElementType.Collective>;
zones?: ElementIds<ElementType.Zone>;
abilities?: ElementIds<ElementType.Ability>;
phenomena?: ElementIds<ElementType.Phenomenon>;
languages?: ElementIds<ElementType.Language>;
families?: ElementIds<ElementType.Family>;
titles?: ElementIds<ElementType.Title>;
constructs?: ElementIds<ElementType.Construct>;
narratives?: ElementIds<ElementType.Narrative>;
}
/**
* Species element type
* Fields organized by sections: Biology, Psychology, World
*/
interface Species extends BaseElement {
appearance?: string;
life_span?: number;
weight?: number;
nourishment?: ElementIds<ElementType.Species>;
reproduction?: ElementIds<ElementType.Construct>;
adaptations?: ElementIds<ElementType.Ability>;
instincts?: string;
sociality?: string;
temperament?: string;
communication?: string;
aggression?: number;
traits?: ElementIds<ElementType.Trait>;
role?: string;
parent_species?: ElementId<ElementType.Species>;
locations?: ElementIds<ElementType.Location>;
zones?: ElementIds<ElementType.Zone>;
affinities?: ElementIds<ElementType.Phenomenon>;
}
/**
* Zone element type
* Fields organized by sections: Scope, World
*/
interface Zone extends BaseElement {
role?: string;
start_date?: number;
end_date?: number;
phenomena?: ElementIds<ElementType.Phenomenon>;
linked_zones?: ElementIds<ElementType.Zone>;
context?: string;
populations?: ElementIds<ElementType.Collective>;
titles?: ElementIds<ElementType.Title>;
principles?: ElementIds<ElementType.Construct>;
}
/**
* Title element type
* Fields organized by sections: Mandate, World
*/
interface Title extends BaseElement {
authority?: string;
eligibility?: string;
grant_date?: number;
revoke_date?: number;
issuer?: ElementId<ElementType.Institution>;
body?: ElementId<ElementType.Institution>;
superior_title?: ElementId<ElementType.Title>;
holders?: ElementIds<ElementType.Character>;
symbols?: ElementIds<ElementType.Object>;
status?: string;
history?: string;
characters?: ElementIds<ElementType.Character>;
institutions?: ElementIds<ElementType.Institution>;
families?: ElementIds<ElementType.Family>;
zones?: ElementIds<ElementType.Zone>;
locations?: ElementIds<ElementType.Location>;
objects?: ElementIds<ElementType.Object>;
constructs?: ElementIds<ElementType.Construct>;
laws?: ElementIds<ElementType.Law>;
collectives?: ElementIds<ElementType.Collective>;
creatures?: ElementIds<ElementType.Creature>;
phenomena?: ElementIds<ElementType.Phenomenon>;
species?: ElementIds<ElementType.Species>;
languages?: ElementIds<ElementType.Language>;
}
/**
* Trait element type
* Fields organized by sections: Qualitative, Quantitative, World
*/
interface Trait extends BaseElement {
social_effects?: string;
physical_effects?: string;
functional_effects?: string;
personality_effects?: string;
behaviour_effects?: string;
charisma?: number;
coercion?: number;
competence?: number;
compassion?: number;
creativity?: number;
courage?: number;
significance?: string;
anti_trait?: ElementId<ElementType.Trait>;
empowered_abilities?: ElementIds<ElementType.Ability>;
}
/**
* Narrative element type
* Fields organized by sections: Context, Involves
*/
interface Narrative extends BaseElement {
story?: string;
consequences?: string;
start_date?: number;
end_date?: number;
order?: number;
parent_narrative?: ElementId<ElementType.Narrative>;
protagonist?: ElementId<ElementType.Character>;
antagonist?: ElementId<ElementType.Character>;
narrator?: ElementId<ElementType.Character>;
conservator?: ElementId<ElementType.Institution>;
events?: ElementIds<ElementType.Event>;
characters?: ElementIds<ElementType.Character>;
objects?: ElementIds<ElementType.Object>;
locations?: ElementIds<ElementType.Location>;
species?: ElementIds<ElementType.Species>;
creatures?: ElementIds<ElementType.Creature>;
institutions?: ElementIds<ElementType.Institution>;
traits?: ElementIds<ElementType.Trait>;
collectives?: ElementIds<ElementType.Collective>;
zones?: ElementIds<ElementType.Zone>;
abilities?: ElementIds<ElementType.Ability>;
phenomena?: ElementIds<ElementType.Phenomenon>;
languages?: ElementIds<ElementType.Language>;
families?: ElementIds<ElementType.Family>;
relations?: ElementIds<ElementType.Relation>;
titles?: ElementIds<ElementType.Title>;
constructs?: ElementIds<ElementType.Construct>;
laws?: ElementIds<ElementType.Law>;
}
/**
* Map element type
* Fields organized by sections: Details
*/
interface Map extends BaseElement {
background_color?: string;
hierarchy?: number;
width?: number;
height?: number;
depth?: number;
parent_map?: ElementId<ElementType.Map>;
location?: ElementId<ElementType.Location>;
}
/**
* Marker element type
* Fields organized by sections: Details
*/
interface Marker extends BaseElement {
map?: ElementId<ElementType.Map>;
zone?: ElementId<ElementType.Zone>;
x?: number;
y?: number;
z?: number;
}
/**
* Pin element type
* Fields organized by sections: Details
*/
interface Pin extends BaseElement {
map?: ElementId<ElementType.Map>;
element_type?: ElementType;
element_id?: AnyElementId;
x?: number;
y?: number;
z?: number;
}
/**
* Input types for API requests (using _id and _ids suffixes)
*/
interface AbilityInput extends Omit<Ability, 'tradition' | 'source' | 'locus' | 'effects' | 'talents' | 'requisites' | 'instruments' | 'systems'> {
tradition_id?: string;
source_id?: string;
locus_id?: string;
effects_ids?: string[];
talents_ids?: string[];
requisites_ids?: string[];
instruments_ids?: string[];
systems_ids?: string[];
}
interface ObjectInput extends Omit<Object$1, 'parent_object' | 'location' | 'language' | 'materials' | 'technology' | 'effects' | 'abilities' | 'consumes' | 'affinities'> {
parent_object_id?: string;
location_id?: string;
language_id?: string;
materials_ids?: string[];
technology_ids?: string[];
effects_ids?: string[];
abilities_ids?: string[];
consumes_ids?: string[];
affinities_ids?: string[];
}
interface CharacterInput extends Omit<Character, 'birthplace' | 'location' | 'species' | 'traits' | 'abilities' | 'languages' | 'objects' | 'institutions' | 'family' | 'friends' | 'rivals'> {
birthplace_id?: string;
location_id?: string;
species_ids?: string[];
traits_ids?: string[];
abilities_ids?: string[];
languages_ids?: string[];
objects_ids?: string[];
institutions_ids?: string[];
family_ids?: string[];
friends_ids?: string[];
rivals_ids?: string[];
}
interface CollectiveInput extends Omit<Collective, 'operator' | 'equipment' | 'abilities' | 'symbolism' | 'species' | 'characters' | 'creatures' | 'phenomena'> {
operator_id?: string;
equipment_ids?: string[];
abilities_ids?: string[];
symbolism_ids?: string[];
species_ids?: string[];
characters_ids?: string[];
creatures_ids?: string[];
phenomena_ids?: string[];
}
interface ConstructInput extends Omit<Construct, 'founder' | 'custodian' | 'characters' | 'objects' | 'locations' | 'species' | 'creatures' | 'institutions' | 'traits' | 'collectives' | 'zones' | 'abilities' | 'phenomena' | 'languages' | 'families' | 'relations' | 'titles' | 'constructs' | 'events' | 'narratives'> {
founder_id?: string;
custodian_id?: string;
characters_ids?: string[];
objects_ids?: string[];
locations_ids?: string[];
species_ids?: string[];
creatures_ids?: string[];
institutions_ids?: string[];
traits_ids?: string[];
collectives_ids?: string[];
zones_ids?: string[];
abilities_ids?: string[];
phenomena_ids?: string[];
languages_ids?: string[];
families_ids?: string[];
relations_ids?: string[];
titles_ids?: string[];
constructs_ids?: string[];
events_ids?: string[];
narratives_ids?: string[];
}
interface CreatureInput extends Omit<Creature, 'location' | 'zone' | 'species' | 'traits' | 'abilities' | 'languages' | 'actions'> {
location_id?: string;
zone_id?: string;
species_ids?: string[];
traits_ids?: string[];
abilities_ids?: string[];
languages_ids?: string[];
actions_ids?: string[];
}
interface EventInput extends Omit<Event, 'triggers' | 'characters' | 'objects' | 'locations' | 'species' | 'creatures' | 'institutions' | 'traits' | 'collectives' | 'zones' | 'abilities' | 'phenomena' | 'languages' | 'families' | 'relations' | 'titles' | 'constructs'> {
triggers_ids?: string[];
characters_ids?: string[];
objects_ids?: string[];
locations_ids?: string[];
species_ids?: string[];
creatures_ids?: string[];
institutions_ids?: string[];
traits_ids?: string[];
collectives_ids?: string[];
zones_ids?: string[];
abilities_ids?: string[];
phenomena_ids?: string[];
languages_ids?: string[];
families_ids?: string[];
relations_ids?: string[];
titles_ids?: string[];
constructs_ids?: string[];
}
interface FamilyInput extends Omit<Family, 'traditions' | 'traits' | 'abilities' | 'languages' | 'ancestors' | 'estates' | 'governs' | 'heirlooms' | 'creatures'> {
traditions_ids?: string[];
traits_ids?: string[];
abilities_ids?: string[];
languages_ids?: string[];
ancestors_ids?: string[];
estates_ids?: string[];
governs_ids?: string[];
heirlooms_ids?: string[];
creatures_ids?: string[];
}
interface InstitutionInput extends Omit<Institution, 'parent_institution' | 'zones' | 'objects' | 'creatures' | 'allies' | 'adversaries' | 'constructs'> {
parent_institution_id?: string;
zones_ids?: string[];
objects_ids?: string[];
creatures_ids?: string[];
allies_ids?: string[];
adversaries_ids?: string[];
constructs_ids?: string[];
}
interface LanguageInput extends Omit<Language, 'classification' | 'spread' | 'dialects'> {
classification_id?: string;
spread_ids?: string[];
dialects_ids?: string[];
}
interface LawInput extends Omit<Law, 'parent_law' | 'author' | 'penalties' | 'locations' | 'zones' | 'prohibitions' | 'adjudicators' | 'enforcers'> {
parent_law_id?: string;
author_id?: string;
penalties_ids?: string[];
locations_ids?: string[];
zones_ids?: string[];
prohibitions_ids?: string[];
adjudicators_ids?: string[];
enforcers_ids?: string[];
}
interface LocationInput extends Omit<Location, 'parent_location' | 'primary_power' | 'governing_title' | 'zone' | 'rival' | 'partner' | 'populations' | 'secondary_powers' | 'founders' | 'cults' | 'delicacies' | 'extraction_methods' | 'extraction_goods' | 'industry_methods' | 'industry_goods' | 'extraction_markets' | 'industry_markets' | 'currencies' | 'buildings' | 'building_methods' | 'fighters' | 'defensive_objects'> {
parent_location_id?: string;
primary_power_id?: string;
governing_title_id?: string;
zone_id?: string;
rival_id?: string;
partner_id?: string;
populations_ids?: string[];
secondary_powers_ids?: string[];
founders_ids?: string[];
cults_ids?: string[];
delicacies_ids?: string[];
extraction_methods_ids?: string[];
extraction_goods_ids?: string[];
industry_methods_ids?: string[];
industry_goods_ids?: string[];
extraction_markets_ids?: string[];
industry_markets_ids?: string[];
currencies_ids?: string[];
buildings_ids?: string[];
building_methods_ids?: string[];
fighters_ids?: string[];
defensive_objects_ids?: string[];
}
interface PhenomenonInput extends Omit<Phenomenon, 'system' | 'catalysts' | 'empowerments' | 'triggers' | 'wielders' | 'environments'> {
system_id?: string;
catalysts_ids?: string[];
empowerments_ids?: string[];
triggers_ids?: string[];
wielders_ids?: string[];
environments_ids?: string[];
}
interface RelationInput extends Omit<Relation, 'actor' | 'characters' | 'objects' | 'locations' | 'species' | 'creatures' | 'institutions' | 'traits' | 'collectives' | 'zones' | 'abilities' | 'phenomena' | 'languages' | 'families' | 'titles' | 'constructs' | 'events' | 'narratives'> {
actor_id?: string;
characters_ids?: string[];
objects_ids?: string[];
locations_ids?: string[];
species_ids?: string[];
creatures_ids?: string[];
institutions_ids?: string[];
traits_ids?: string[];
collectives_ids?: string[];
zones_ids?: string[];
abilities_ids?: string[];
phenomena_ids?: string[];
languages_ids?: string[];
families_ids?: string[];
titles_ids?: string[];
constructs_ids?: string[];
events_ids?: string[];
narratives_ids?: string[];
}
interface SpeciesInput extends Omit<Species, 'parent_species' | 'nourishment' | 'reproduction' | 'adaptations' | 'traits' | 'locations' | 'zones' | 'affinities'> {
parent_species_id?: string;
nourishment_ids?: string[];
reproduction_ids?: string[];
adaptations_ids?: string[];
traits_ids?: string[];
locations_ids?: string[];
zones_ids?: string[];
affinities_ids?: string[];
}
interface ZoneInput extends Omit<Zone, 'phenomena' | 'linked_zones' | 'populations' | 'titles' | 'principles'> {
phenomena_ids?: string[];
linked_zones_ids?: string[];
populations_ids?: string[];
titles_ids?: string[];
principles_ids?: string[];
}
interface TitleInput extends Omit<Title, 'issuer' | 'body' | 'superior_title' | 'holders' | 'symbols' | 'characters' | 'institutions' | 'families' | 'zones' | 'locations' | 'objects' | 'constructs' | 'laws' | 'collectives' | 'creatures' | 'phenomena' | 'species' | 'languages'> {
issuer_id?: string;
body_id?: string;
superior_title_id?: string;
holders_ids?: string[];
symbols_ids?: string[];
characters_ids?: string[];
institutions_ids?: string[];
families_ids?: string[];
zones_ids?: string[];
locations_ids?: string[];
objects_ids?: string[];
constructs_ids?: string[];
laws_ids?: string[];
collectives_ids?: string[];
creatures_ids?: string[];
phenomena_ids?: string[];
species_ids?: string[];
languages_ids?: string[];
}
interface TraitInput extends Omit<Trait, 'anti_trait' | 'empowered_abilities'> {
anti_trait_id?: string;
empowered_abilities_ids?: string[];
}
interface NarrativeInput extends Omit<Narrative, 'parent_narrative' | 'protagonist' | 'antagonist' | 'narrator' | 'conservator' | 'events' | 'characters' | 'objects' | 'locations' | 'species' | 'creatures' | 'institutions' | 'traits' | 'collectives' | 'zones' | 'abilities' | 'phenomena' | 'languages' | 'families' | 'relations' | 'titles' | 'constructs' | 'laws'> {
parent_narrative_id?: string;
protagonist_id?: string;
antagonist_id?: string;
narrator_id?: string;
conservator_id?: string;
events_ids?: string[];
characters_ids?: string[];
objects_ids?: string[];
locations_ids?: string[];
species_ids?: string[];
creatures_ids?: string[];
institutions_ids?: string[];
traits_ids?: string[];
collectives_ids?: string[];
zones_ids?: string[];
abilities_ids?: string[];
phenomena_ids?: string[];
languages_ids?: string[];
families_ids?: string[];
relations_ids?: string[];
titles_ids?: string[];
constructs_ids?: string[];
laws_ids?: string[];
}
interface MapInput extends Omit<Map, 'parent_map' | 'location'> {
parent_map_id?: string;
location_id?: string;
}
interface MarkerInput extends Omit<Marker, 'map' | 'zone'> {
map_id?: string;
zone_id?: string;
}
interface PinInput extends Omit<Pin, 'map' | 'element_id'> {
map_id?: string;
element_id?: string;
}
/**
* All available element types in OnlyWorlds
*/
declare enum ElementType {
Ability = "ability",
Character = "character",
Collective = "collective",
Construct = "construct",
Creature = "creature",
Event = "event",
Family = "family",
Institution = "institution",
Language = "language",
Law = "law",
Location = "location",
Map = "map",
Marker = "marker",
Narrative = "narrative",
Object = "object",
Phenomenon = "phenomenon",
Pin = "pin",
Relation = "relation",
Species = "species",
Title = "title",
Trait = "trait",
Zone = "zone"
}
/**
* UI labels for element types - provides proper plural forms
* Useful for displaying element type names in user interfaces
*/
declare const ELEMENT_LABELS: Record<ElementType, string>;
/**
* Get the plural label for an element type
* @param elementType The element type
* @returns The plural label string
*/
declare function getElementLabel(elementType: ElementType): string;
/**
* Section metadata for OnlyWorlds elements
* Source: sectioned_schema.json
*/
interface SectionInfo {
name: string;
order: number;
fields: string[];
}
/**
* Element section definitions - provides organized field groupings for each element type
* Enables UI components to display fields in logical sections with proper ordering
*/
declare const ELEMENT_SECTIONS: Record<ElementType, SectionInfo[]>;
/**
* Get sections for an element type
* @param elementType The element type
* @returns Array of section information for the element type
*/
declare function getElementSections(elementType: ElementType): SectionInfo[];
/**
* Current OnlyWorlds version
* Synced with https://github.com/OnlyWorlds/OnlyWorlds/blob/main/VERSION
*/
declare const ONLYWORLDS_VERSION: "00.30.00";
/**
* Material Design icons for element types
* These are the uniform, monochrome icons used in the OnlyWorlds frontend
* Compatible with Google Material Icons font
*/
declare const ELEMENT_ICONS: Record<ElementType, string>;
/**
* Simple Unicode icons for element types
* Minimalist symbols used as fallbacks
*/
declare const ELEMENT_UNICODE_ICONS: Record<ElementType, string>;
/**
* Get Material Design icon for an element type
* Returns the uniform monochrome icon used in OnlyWorlds frontend
* @param elementType The element type
* @returns Material icon name
*/
declare function getElementIcon(elementType: ElementType): string;
/**
* Get Unicode icon for an element type
* @param elementType The element type
* @returns Unicode symbol string
*/
declare function getElementUnicodeIcon(elementType: ElementType): string;
/**
* Field type definitions for OnlyWorlds elements
*/
type FieldType = 'text' | 'integer' | 'integer_max' | 'single_link' | 'multi_link';
/**
* Field metadata structure
*/
interface FieldInfo {
type: FieldType;
target?: string;
max?: number;
}
/**
* Comprehensive field schema - provides complete metadata for all fields
* Maps element types to their field definitions including types and cardinality
*/
declare const FIELD_SCHEMA: {
readonly ability: {
readonly name: {
readonly type: "text";
readonly required: true;
};
readonly description: {
readonly type: "text";
readonly required: false;
};
readonly supertype: {
readonly type: "text";
readonly required: false;
};
readonly subtype: {
readonly type: "text";
readonly required: false;
};
readonly image_url: {
readonly type: "text";
readonly required: false;
};
readonly activation: {
readonly type: "text";
};
readonly duration: {
readonly type: "number";
};
readonly potency: {
readonly type: "number";
};
readonly range: {
readonly type: "number";
};
readonly effects: {
readonly type: "multi_link";
readonly target: "phenomenon";
};
readonly challenges: {
readonly type: "text";
};
readonly talents: {
readonly type: "multi_link";
readonly target: "trait";
};
readonly requisites: {
readonly type: "multi_link";
readonly target: "construct";
};
readonly prevalence: {
readonly type: "text";
};
readonly tradition: {
readonly type: "single_link";
readonly target: "construct";
};
readonly source: {
readonly type: "single_link";
readonly target: "phenomenon";
};
readonly locus: {
readonly type: "single_link";
readonly target: "location";
};
readonly instruments: {
readonly type: "multi_link";
readonly target: "object";
};
readonly systems: {
readonly type: "multi_link";
readonly target: "construct";
};
};
readonly character: {
readonly name: {
readonly type: "text";
readonly required: true;
};
readonly description: {
readonly type: "text";
readonly required: false;
};
readonly supertype: {
readonly type: "text";
readonly required: false;
};
readonly subtype: {
readonly type: "text";
readonly required: false;
};
readonly image_url: {
readonly type: "text";
readonly required: false;
};
readonly physicality: {
readonly type: "text";
};
readonly mentality: {
readonly type: "text";
};
readonly height: {
readonly type: "number";
};
readonly weight: {
readonly type: "number";
};
readonly species: {
readonly type: "multi_link";
readonly target: "species";
};
readonly traits: {
readonly type: "multi_link";
readonly target: "trait";
};
readonly abilities: {
readonly type: "multi_link";
readonly target: "ability";
};
readonly background: {
readonly type: "text";
};
readonly motivations: {
readonly type: "text";
};
readonly birth_date: {
readonly type: "number";
};
readonly birthplace: {
readonly type: "single_link";
readonly target: "location";
};
readonly languages: {
readonly type: "multi_link";
readonly target: "language";
};
readonly reputation: {
readonly type: "text";
};
readonly location: {
readonly type: "single_link";
readonly target: "location";
};
readonly objects: {
readonly type: "multi_link";
readonly target: "object";
};
readonly institutions: {
readonly type: "multi_link";
readonly target: "institution";
};
readonly charisma: {
readonly type: "number";
};
readonly coercion: {
readonly type: "number";
};
readonly competence: {
readonly type: "number";
};
readonly compassion: {
readonly type: "number";
};
readonly creativity: {
readonly type: "number";
};
readonly courage: {
readonly type: "number";
};
readonly family: {
readonly type: "multi_link";
readonly target: "family";
};
readonly friends: {
readonly type: "multi_link";
readonly target: "character";
};
readonly rivals: {
readonly type: "multi_link";
readonly target: "character";
};
readonly level: {
readonly type: "number";
};
readonly hit_points: {
readonly type: "number";
};
readonly STR: {
readonly type: "number";
};
readonly DEX: {
readonly type: "number";
};
readonly CON: {
readonly type: "number";
};
readonly INT: {
readonly type: "number";
};
readonly WIS: {
readonly type: "number";
};
readonly CHA: {
readonly type: "number";
};
};
readonly collective: {
readonly name: {
readonly type: "text";
readonly required: true;
};
readonly description: {
readonly type: "text";
readonly required: false;
};
readonly supertype: {
readonly type: "text";
readonly required: false;
};
readonly subtype: {
readonly type: "text";
readonly required: false;
};
readonly image_url: {
readonly type: "text";
readonly required: false;
};
readonly composition: {
readonly type: "text";
};
readonly count: {
readonly type: "number";
};
readonly formation_date: {
readonly type: "number";
};
readonly operator: {
readonly type: "single_link";
readonly target: "institution";
};
readonly equipment: {
readonly type: "multi_link";
readonly target: "construct";
};
readonly activity: {
readonly type: "text";
};
readonly disposition: {
readonly type: "text";
};
readonly state: {
readonly type: "text";
};
readonly abilities: {
readonly type: "multi_link";
readonly target: "ability";
};
readonly symbolism: {
readonly type: "multi_link";
readonly target: "construct";
};
readonly species: {
readonly type: "multi_link";
readonly target: "species";
};
readonly characters: {
readonly type: "multi_link";
readonly target: "character";
};
readonly creatures: {
readonly type: "multi_link";
readonly target: "creature";
};
readonly phenomena: {
readonly type: "multi_link";
readonly target: "phenomenon";
};
};
readonly construct: {
readonly name: {
readonly type: "text";
readonly required: true;
};
readonly description: {
readonly type: "text";
readonly required: false;
};
readonly supertype: {
readonly type: "text";
readonly required: false;
};
readonly subtype: {
readonly type: "text";
readonly required: false;
};
readonly image_url: {
readonly type: "text";
readonly required: false;
};
readonly rationale: {
readonly type: "text";
};
readonly history: {
readonly type: "text";
};
readonly status: {
readonly type: "text";
};
readonly reach: {
readonly type: "text";
};
readonly start_date: {
readonly type: "number";
};
readonly end_date: {
readonly type: "number";
};
readonly founder: {
readonly type: "single_link";
readonly target: "character";
};
readonly custodian: {
readonly type: "single_link";
readonly target: "institution";
};
readonly characters: {
readonly type: "multi_link";
readonly target: "character";
};
readonly objects: {
readonly type: "multi_link";
readonly target: "object";
};
readonly locations: {
readonly type: "multi_link";
readonly target: "location";
};
readonly species: {
readonly type: "multi_link";
readonly target: "species";
};
readonly creatures: {
readonly type: "multi_link";
readonly target: "creature";
};
readonly institutions: {
readonly type: "multi_link";
readonly target: "institution";
};
readonly traits: {
readonly type: "multi_link";
readonly target: "trait";
};
readonly collectives: {
readonly type: "multi_link";
readonly target: "collective";
};
readonly zones: {
readonly type: "multi_link";
readonly target: "zone";
};
readonly abilities: {
readonly type: "multi_link";
readonly target: "ability";
};
readonly phenomena: {
readonly type: "multi_link";
readonly target: "phenomenon";
};
readonly languages: {
readonly type: "multi_link";
readonly target: "language";
};
readonly families: {
readonly type: "multi_link";
readonly target: "family";
};
readonly relations: {
readonly type: "multi_link";
readonly target: "relation";
};
readonly titles: {
readonly type: "multi_link";
readonly target: "title";
};
readonly constructs: {
readonly type: "multi_link";
readonly target: "construct";
};
readonly events: {
readonly type: "multi_link";
readonly target: "event";
};
readonly narratives: {
readonly type: "multi_link";
readonly target: "narrative";
};
};
readonly creature: {
readonly name: {
readonly type: "text";
readonly required: true;
};
readonly description: {
readonly type: "text";
readonly required: false;
};
readonly supertype: {
readonly type: "text";
readonly required: false;
};
readonly subtype: {
readonly type: "text";
readonly required: false;
};
readonly image_url: {
readonly type: "text";
readonly required: false;
};
readonly appearance: {
readonly type: "text";
};
readonly weight: {
readonly type: "number";
};
readonly height: {
readonly type: "number";
};
readonly species: {
readonly type: "multi_link";
readonly target: "species";
};
readonly habits: {
readonly type: "text";
};
readonly demeanor: {
readonly type: "text";
};
readonly traits: {
readonly type: "multi_link";
readonly target: "trait";
};
readonly abilities: {
readonly type: "multi_link";
readonly target: "ability";
};
readonly languages: {
readonly type: "multi_link";
readonly target: "language";
};
readonly status: {
readonly type: "text";
};
readonly birth_date: {
readonly type: "number";
};
readonly location: {
readonly type: "single_link";
readonly target: "location";
};
readonly zone: {
readonly type: "single_link";
readonly target: "zone";
};
readonly challenge_rating: {
readonly type: "number";
};
readonly hit_points: {
readonly type: "number";
};
readonly armor_class: {
readonly type: "number";
};
readonly speed: {
readonly type: "number";
};
readonly actions: {
readonly type: "multi_link";
readonly target: "ability";
};
};
readonly event: {
readonly name: {
readonly type: "text";
readonly required: true;
};
readonly description: {
readonly type: "text";
readonly required: false;
};
readonly supertype: {
readonly type: "text";
readonly required: false;
};
readonly subtype: {
readonly type: "text";
readonly required: false;
};
readonly image_url: {
readonly type: "text";
readonly required: false;
};
readonly history: {
readonly type: "text";
};
readonly challenges: {
readonly type: "text";
};
readonly consequences: {
readonly type: "text";
};
readonly start_date: {
readonly type: "number";
};
readonly end_date: {
readonly type: "number";
};
readonly triggers: {
readonly type: "multi_link";
readonly target: "construct";
};
readonly characters: {
readonly type: "multi_link";
readonly target: "character";
};
readonly objects: {
readonly type: "multi_link";
readonly target: "object";
};
readonly locations: {
readonly type: "multi_link";
readonly target: "location";
};
readonly species: {
readonly type: "multi_link";
readonly target: "species";
};
readonly creatures: {
readonly type: "multi_link";
readonly target: "creature";
};
readonly institutions: {
readonly type: "multi_link";
readonly target: "institution";
};
readonly traits: {
readonly type: "multi_link";
readonly target: "trait";
};
readonly collectives: {
readonly type: "multi_link";
readonly target: "collective";
};
readonly zones: {
readonly type: "multi_link";
readonly target: "zone";
};
readonly abilities: {
readonly type: "multi_link";
readonly target: "ability";
};
readonly phenomena: {
readonly type: "multi_link";
readonly target: "phenomenon";
};
readonly languages: {
readonly type: "multi_link";
readonly target: "language";
};
readonly families: {
readonly type: "multi_link";
readonly target: "family";
};
readonly relations: {
readonly type: "multi_link";
readonly target: "relation";
};
readonly titles: {
readonly type: "multi_link";
readonly target: "title";
};
readonly constructs: {
readonly type: "multi_link";
readonly target: "construct";
};
};
readonly family: {
readonly name: {
readonly type: "text";
readonly required: true;
};
readonly description: {
readonly type: "text";
readonly required: false;
};
readonly supertype: {
readonly type: "text";
readonly required: false;
};
readonly subtype: {
readonly type: "text";
readonly required: false;
};
readonly image_url: {
readonly type: "text";
readonly required: false;
};
readonly spirit: {
readonly type: "text";
};
readonly history: {
readonly type: "text";
};
readonly traditions: {
readonly type: "multi_link";
readonly target: "construct";
};
readonly traits: {
readonly type: "multi_link";
readonly target: "trait";
};
readonly abilities: {
readonly type: "multi_link";
readonly target: "ability";
};
readonly languages: {
readonly type: "multi_link";
readonly target: "language";
};
readonly ancestors: {
readonly type: "multi_link";
readonly target: "character";
};
readonly reputation: {
readonly type: "text";