UNPKG

@onlyworlds/sdk

Version:

TypeScript SDK for the OnlyWorlds API - build world-building applications with type safety

954 lines (952 loc) 41.7 kB
// src/client.ts var Resource = class { constructor(client, elementType) { this.client = client; this.elementType = elementType; } async list(options) { return this.client.request("GET", `/${this.elementType}/`, { params: options }); } async get(id) { return this.client.request("GET", `/${this.elementType}/${id}/`); } async create(data) { return this.client.request("POST", `/${this.elementType}/`, { body: data }); } async update(id, data) { return this.client.request("PATCH", `/${this.elementType}/${id}/`, { body: data }); } async delete(id) { return this.client.request("DELETE", `/${this.elementType}/${id}/`); } }; var OnlyWorldsClient = class { constructor(config) { this.baseUrl = config.baseUrl || "https://www.onlyworlds.com/api/worldapi"; this.headers = { "Content-Type": "application/json", "API-Key": config.apiKey, "API-Pin": config.apiPin }; this.worlds = new Resource(this, "world"); this.abilities = new Resource(this, "ability"); this.characters = new Resource(this, "character"); this.collectives = new Resource(this, "collective"); this.constructs = new Resource(this, "construct"); this.creatures = new Resource(this, "creature"); this.events = new Resource(this, "event"); this.families = new Resource(this, "family"); this.institutions = new Resource(this, "institution"); this.languages = new Resource(this, "language"); this.laws = new Resource(this, "law"); this.locations = new Resource(this, "location"); this.maps = new Resource(this, "map"); this.markers = new Resource(this, "marker"); this.narratives = new Resource(this, "narrative"); this.objects = new Resource(this, "object"); this.phenomena = new Resource(this, "phenomenon"); this.pins = new Resource(this, "pin"); this.relations = new Resource(this, "relation"); this.species = new Resource(this, "species"); this.titles = new Resource(this, "title"); this.traits = new Resource(this, "trait"); this.zones = new Resource(this, "zone"); } /** * Make a request to the OnlyWorlds API */ async request(method, path, options) { const url = new URL(`${this.baseUrl}${path}`); if (options?.params) { Object.entries(options.params).forEach(([key, value]) => { if (value !== void 0 && value !== null) { url.searchParams.append(key, String(value)); } }); } const fetchOptions = { method, headers: this.headers }; if (options?.body && ["POST", "PATCH", "PUT"].includes(method)) { fetchOptions.body = JSON.stringify(options.body); } const response = await fetch(url.toString(), fetchOptions); if (!response.ok) { let errorMessage = `API Error ${response.status}`; try { const errorText = await response.text(); if (errorText) { try { const errorJson = JSON.parse(errorText); errorMessage += `: ${errorJson.detail || errorJson.error || errorText}`; } catch { errorMessage += `: ${errorText}`; } } } catch { } throw new Error(errorMessage); } if (response.status === 204) { return void 0; } return response.json(); } /** * Get all worlds accessible with current credentials * @deprecated Use client.worlds.list() instead for consistent API */ async getWorlds() { return this.request("GET", "/world/"); } /** * Helper to convert nested objects to _id/_ids format */ static prepareInput(data) { const result = { ...data }; for (const [key, value] of Object.entries(result)) { if (value && typeof value === "object" && "id" in value) { delete result[key]; result[`${key}_id`] = value.id; } else if (Array.isArray(value) && value.length > 0 && typeof value[0] === "object" && "id" in value[0]) { delete result[key]; result[`${key}_ids`] = value.map((item) => item.id); } } return result; } }; // src/types.ts var ElementType = /* @__PURE__ */ ((ElementType2) => { ElementType2["Ability"] = "ability"; ElementType2["Character"] = "character"; ElementType2["Collective"] = "collective"; ElementType2["Construct"] = "construct"; ElementType2["Creature"] = "creature"; ElementType2["Event"] = "event"; ElementType2["Family"] = "family"; ElementType2["Institution"] = "institution"; ElementType2["Language"] = "language"; ElementType2["Law"] = "law"; ElementType2["Location"] = "location"; ElementType2["Map"] = "map"; ElementType2["Marker"] = "marker"; ElementType2["Narrative"] = "narrative"; ElementType2["Object"] = "object"; ElementType2["Phenomenon"] = "phenomenon"; ElementType2["Pin"] = "pin"; ElementType2["Relation"] = "relation"; ElementType2["Species"] = "species"; ElementType2["Title"] = "title"; ElementType2["Trait"] = "trait"; ElementType2["Zone"] = "zone"; return ElementType2; })(ElementType || {}); var ELEMENT_LABELS = { ["ability" /* Ability */]: "Abilities", ["character" /* Character */]: "Characters", ["collective" /* Collective */]: "Collectives", ["construct" /* Construct */]: "Constructs", ["creature" /* Creature */]: "Creatures", ["event" /* Event */]: "Events", ["family" /* Family */]: "Families", ["institution" /* Institution */]: "Institutions", ["language" /* Language */]: "Languages", ["law" /* Law */]: "Laws", ["location" /* Location */]: "Locations", ["map" /* Map */]: "Maps", ["marker" /* Marker */]: "Markers", ["narrative" /* Narrative */]: "Narratives", ["object" /* Object */]: "Objects", ["phenomenon" /* Phenomenon */]: "Phenomena", ["pin" /* Pin */]: "Pins", ["relation" /* Relation */]: "Relations", ["species" /* Species */]: "Species", ["title" /* Title */]: "Titles", ["trait" /* Trait */]: "Traits", ["zone" /* Zone */]: "Zones" }; function getElementLabel(elementType) { return ELEMENT_LABELS[elementType]; } var ELEMENT_SECTIONS = { ["ability" /* Ability */]: [ { name: "Mechanics", order: 1, fields: ["activation", "duration", "potency", "range", "effects", "challenges", "talents", "requisites"] }, { name: "World", order: 2, fields: ["prevalence", "tradition", "source", "locus", "instruments", "systems"] } ], ["character" /* Character */]: [ { name: "Constitution", order: 1, fields: ["physicality", "mentality", "height", "weight", "species", "traits", "abilities"] }, { name: "Origins", order: 2, fields: ["background", "motivations", "birth_date", "birthplace", "languages"] }, { name: "World", order: 3, fields: ["reputation", "location", "objects", "institutions"] }, { name: "Personality", order: 4, fields: ["charisma", "coercion", "competence", "compassion", "creativity", "courage"] }, { name: "Social", order: 5, fields: ["family", "friends", "rivals"] }, { name: "TTRPG", order: 6, fields: ["level", "hit_points", "STR", "DEX", "CON", "INT", "WIS", "CHA"] } ], ["collective" /* Collective */]: [ { name: "Formation", order: 1, fields: ["composition", "count", "formation_date", "operator", "equipment"] }, { name: "Dynamics", order: 2, fields: ["activity", "disposition", "state", "abilities", "symbolism"] }, { name: "World", order: 3, fields: ["species", "characters", "creatures", "phenomena"] } ], ["construct" /* Construct */]: [ { name: "Nature", order: 1, fields: ["rationale", "history", "status", "reach", "start_date", "end_date", "founder", "custodian"] }, { name: "Involves", order: 2, fields: ["characters", "objects", "locations", "species", "creatures", "institutions", "traits", "collectives", "zones", "abilities", "phenomena", "languages", "families", "relations", "titles", "constructs", "events", "narratives"] } ], ["creature" /* Creature */]: [ { name: "Biology", order: 1, fields: ["appearance", "weight", "height", "species"] }, { name: "Behaviour", order: 2, fields: ["habits", "demeanor", "traits", "abilities", "languages"] }, { name: "World", order: 3, fields: ["status", "birth_date", "location", "zone"] }, { name: "TTRPG", order: 4, fields: ["challenge_rating", "hit_points", "armor_class", "speed", "actions"] } ], ["event" /* Event */]: [ { name: "Nature", order: 1, fields: ["history", "challenges", "consequences", "start_date", "end_date", "triggers"] }, { name: "Involves", order: 2, fields: ["characters", "objects", "locations", "species", "creatures", "institutions", "traits", "collectives", "zones", "abilities", "phenomena", "languages", "families", "relations", "titles", "constructs"] } ], ["family" /* Family */]: [ { name: "Identity", order: 1, fields: ["spirit", "history", "traditions", "traits", "abilities", "languages", "ancestors"] }, { name: "World", order: 2, fields: ["reputation", "estates", "governs", "heirlooms", "creatures"] } ], ["institution" /* Institution */]: [ { name: "Foundation", order: 1, fields: ["doctrine", "founding_date", "parent_institution"] }, { name: "Claims", order: 2, fields: ["zones", "objects", "creatures"] }, { name: "World", order: 3, fields: ["status", "allies", "adversaries", "constructs"] } ], ["language" /* Language */]: [ { name: "Structure", order: 1, fields: ["phonology", "grammar", "lexicon", "writing", "classification"] }, { name: "World", order: 2, fields: ["status", "spread", "dialects"] } ], ["law" /* Law */]: [ { name: "Code", order: 1, fields: ["declaration", "purpose", "date", "parent_law", "penalties"] }, { name: "World", order: 2, fields: ["author", "locations", "zones", "prohibitions", "adjudicators", "enforcers"] } ], ["location" /* Location */]: [ { name: "Setting", order: 1, fields: ["form", "function", "founding_date", "parent_location", "populations"] }, { name: "Politics", order: 2, fields: ["political_climate", "primary_power", "governing_title", "secondary_powers", "zone", "rival", "partner"] }, { name: "World", order: 3, fields: ["customs", "founders", "cults", "delicacies"] }, { name: "Production", order: 4, fields: ["extraction_methods", "extraction_goods", "industry_methods", "industry_goods"] }, { name: "Commerce", order: 5, fields: ["infrastructure", "extraction_markets", "industry_markets", "currencies"] }, { name: "Construction", order: 6, fields: ["architecture", "buildings", "building_methods"] }, { name: "Defense", order: 7, fields: ["defensibility", "elevation", "fighters", "defensive_objects"] } ], ["map" /* Map */]: [ { name: "Details", order: 1, fields: ["background_color", "hierarchy", "width", "height", "depth", "parent_map", "location"] } ], ["marker" /* Marker */]: [ { name: "Details", order: 1, fields: ["map", "zone", "x", "y", "z"] } ], ["narrative" /* Narrative */]: [ { name: "Context", order: 1, fields: ["story", "consequences", "start_date", "end_date", "order", "parent_narrative", "protagonist", "antagonist", "narrator", "conservator"] }, { name: "Involves", order: 2, fields: ["events", "characters", "objects", "locations", "species", "creatures", "institutions", "traits", "collectives", "zones", "abilities", "phenomena", "languages", "families", "relations", "titles", "constructs", "laws"] } ], ["object" /* Object */]: [ { name: "Form", order: 1, fields: ["aesthetics", "weight", "amount", "parent_object", "materials", "technology"] }, { name: "Function", order: 2, fields: ["utility", "effects", "abilities", "consumes"] }, { name: "World", order: 3, fields: ["origins", "location", "language", "affinities"] } ], ["phenomenon" /* Phenomenon */]: [ { name: "Mechanics", order: 1, fields: ["expression", "effects", "duration", "catalysts", "empowerments"] }, { name: "World", order: 2, fields: ["mythology", "system", "triggers", "wielders", "environments"] } ], ["pin" /* Pin */]: [ { name: "Details", order: 1, fields: ["map", "element_type", "element_id", "element", "x", "y", "z"] } ], ["relation" /* Relation */]: [ { name: "Nature", order: 1, fields: ["background", "start_date", "end_date", "intensity", "actor", "events"] }, { name: "Involves", order: 2, fields: ["characters", "objects", "locations", "species", "creatures", "institutions", "traits", "collectives", "zones", "abilities", "phenomena", "languages", "families", "relations", "titles", "constructs", "events", "narratives"] } ], ["species" /* Species */]: [ { name: "Biology", order: 1, fields: ["appearance", "life_span", "weight", "nourishment", "reproduction", "adaptations"] }, { name: "Psychology", order: 2, fields: ["instincts", "sociality", "temperament", "communication", "aggression", "traits"] }, { name: "World", order: 3, fields: ["role", "parent_species", "locations", "zones", "affinities"] } ], ["title" /* Title */]: [ { name: "Mandate", order: 1, fields: ["authority", "eligibility", "grant_date", "revoke_date", "issuer", "body", "superior_title", "holders", "symbols"] }, { name: "World", order: 2, fields: ["status", "history", "characters", "institutions", "families", "zones", "locations", "objects", "constructs", "laws", "collectives", "creatures", "phenomena", "species", "languages"] } ], ["trait" /* Trait */]: [ { name: "Qualitative", order: 1, fields: ["social_effects", "physical_effects", "functional_effects", "personality_effects", "behaviour_effects"] }, { name: "Quantitative", order: 2, fields: ["charisma", "coercion", "competence", "compassion", "creativity", "courage"] }, { name: "World", order: 3, fields: ["significance", "anti_trait", "empowered_abilities"] } ], ["zone" /* Zone */]: [ { name: "Scope", order: 1, fields: ["role", "start_date", "end_date", "phenomena", "linked_zones"] }, { name: "World", order: 2, fields: ["context", "populations", "titles", "principles"] } ] }; function getElementSections(elementType) { return ELEMENT_SECTIONS[elementType] || []; } var ONLYWORLDS_VERSION = "00.30.00"; var ELEMENT_ICONS = { ["ability" /* Ability */]: "auto_fix_normal", ["character" /* Character */]: "person", ["collective" /* Collective */]: "groups_3", ["construct" /* Construct */]: "api", ["creature" /* Creature */]: "bug_report", ["event" /* Event */]: "saved_search", ["family" /* Family */]: "supervisor_account", ["institution" /* Institution */]: "business", ["language" /* Language */]: "edit_road", ["law" /* Law */]: "gpp_bad", ["location" /* Location */]: "castle", ["map" /* Map */]: "map", ["marker" /* Marker */]: "place", ["narrative" /* Narrative */]: "menu_book", ["object" /* Object */]: "webhook", ["phenomenon" /* Phenomenon */]: "thunderstorm", ["pin" /* Pin */]: "push_pin", ["relation" /* Relation */]: "link", ["species" /* Species */]: "crib", ["title" /* Title */]: "military_tech", ["trait" /* Trait */]: "flaky", ["zone" /* Zone */]: "architecture" }; var ELEMENT_UNICODE_ICONS = { ["ability" /* Ability */]: "\u2728", ["character" /* Character */]: "\u{1F464}", ["collective" /* Collective */]: "\u{1F465}", ["construct" /* Construct */]: "\u2699\uFE0F", ["creature" /* Creature */]: "\u{1F43E}", ["event" /* Event */]: "\u{1F4C5}", ["family" /* Family */]: "\u{1F468}\u200D\u{1F469}\u200D\u{1F467}\u200D\u{1F466}", ["institution" /* Institution */]: "\u{1F3DB}\uFE0F", ["language" /* Language */]: "\u{1F4AC}", ["law" /* Law */]: "\u2696\uFE0F", ["location" /* Location */]: "\u{1F3F0}", ["map" /* Map */]: "\u{1F5FA}\uFE0F", ["marker" /* Marker */]: "\u{1F4CD}", ["narrative" /* Narrative */]: "\u{1F4D6}", ["object" /* Object */]: "\u{1F4E6}", ["phenomenon" /* Phenomenon */]: "\u26A1", ["pin" /* Pin */]: "\u{1F4CC}", ["relation" /* Relation */]: "\u{1F517}", ["species" /* Species */]: "\u{1F9EC}", ["title" /* Title */]: "\u{1F451}", ["trait" /* Trait */]: "\u2744\uFE0F", ["zone" /* Zone */]: "\u{1F5FA}\uFE0F" }; function getElementIcon(elementType) { return ELEMENT_ICONS[elementType]; } function getElementUnicodeIcon(elementType) { return ELEMENT_UNICODE_ICONS[elementType]; } var FIELD_SCHEMA = { ability: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Mechanics activation: { type: "text" }, duration: { type: "number" }, potency: { type: "number" }, range: { type: "number" }, effects: { type: "multi_link", target: "phenomenon" }, challenges: { type: "text" }, talents: { type: "multi_link", target: "trait" }, requisites: { type: "multi_link", target: "construct" }, // World prevalence: { type: "text" }, tradition: { type: "single_link", target: "construct" }, source: { type: "single_link", target: "phenomenon" }, locus: { type: "single_link", target: "location" }, instruments: { type: "multi_link", target: "object" }, systems: { type: "multi_link", target: "construct" } }, character: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Constitution physicality: { type: "text" }, mentality: { type: "text" }, height: { type: "number" }, weight: { type: "number" }, species: { type: "multi_link", target: "species" }, traits: { type: "multi_link", target: "trait" }, abilities: { type: "multi_link", target: "ability" }, // Origins background: { type: "text" }, motivations: { type: "text" }, birth_date: { type: "number" }, birthplace: { type: "single_link", target: "location" }, languages: { type: "multi_link", target: "language" }, // World reputation: { type: "text" }, location: { type: "single_link", target: "location" }, objects: { type: "multi_link", target: "object" }, institutions: { type: "multi_link", target: "institution" }, // Personality charisma: { type: "number" }, coercion: { type: "number" }, competence: { type: "number" }, compassion: { type: "number" }, creativity: { type: "number" }, courage: { type: "number" }, // Social family: { type: "multi_link", target: "family" }, friends: { type: "multi_link", target: "character" }, rivals: { type: "multi_link", target: "character" }, // TTRPG level: { type: "number" }, hit_points: { type: "number" }, STR: { type: "number" }, DEX: { type: "number" }, CON: { type: "number" }, INT: { type: "number" }, WIS: { type: "number" }, CHA: { type: "number" } }, collective: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Formation composition: { type: "text" }, count: { type: "number" }, formation_date: { type: "number" }, operator: { type: "single_link", target: "institution" }, equipment: { type: "multi_link", target: "construct" }, // Dynamics activity: { type: "text" }, disposition: { type: "text" }, state: { type: "text" }, abilities: { type: "multi_link", target: "ability" }, symbolism: { type: "multi_link", target: "construct" }, // World species: { type: "multi_link", target: "species" }, characters: { type: "multi_link", target: "character" }, creatures: { type: "multi_link", target: "creature" }, phenomena: { type: "multi_link", target: "phenomenon" } }, construct: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Nature rationale: { type: "text" }, history: { type: "text" }, status: { type: "text" }, reach: { type: "text" }, start_date: { type: "number" }, end_date: { type: "number" }, founder: { type: "single_link", target: "character" }, custodian: { type: "single_link", target: "institution" }, // Involves characters: { type: "multi_link", target: "character" }, objects: { type: "multi_link", target: "object" }, locations: { type: "multi_link", target: "location" }, species: { type: "multi_link", target: "species" }, creatures: { type: "multi_link", target: "creature" }, institutions: { type: "multi_link", target: "institution" }, traits: { type: "multi_link", target: "trait" }, collectives: { type: "multi_link", target: "collective" }, zones: { type: "multi_link", target: "zone" }, abilities: { type: "multi_link", target: "ability" }, phenomena: { type: "multi_link", target: "phenomenon" }, languages: { type: "multi_link", target: "language" }, families: { type: "multi_link", target: "family" }, relations: { type: "multi_link", target: "relation" }, titles: { type: "multi_link", target: "title" }, constructs: { type: "multi_link", target: "construct" }, events: { type: "multi_link", target: "event" }, narratives: { type: "multi_link", target: "narrative" } }, creature: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Biology appearance: { type: "text" }, weight: { type: "number" }, height: { type: "number" }, species: { type: "multi_link", target: "species" }, // Behaviour habits: { type: "text" }, demeanor: { type: "text" }, traits: { type: "multi_link", target: "trait" }, abilities: { type: "multi_link", target: "ability" }, languages: { type: "multi_link", target: "language" }, // World status: { type: "text" }, birth_date: { type: "number" }, location: { type: "single_link", target: "location" }, zone: { type: "single_link", target: "zone" }, // TTRPG challenge_rating: { type: "number" }, hit_points: { type: "number" }, armor_class: { type: "number" }, speed: { type: "number" }, actions: { type: "multi_link", target: "ability" } }, event: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Nature history: { type: "text" }, challenges: { type: "text" }, consequences: { type: "text" }, start_date: { type: "number" }, end_date: { type: "number" }, triggers: { type: "multi_link", target: "construct" }, // Involves characters: { type: "multi_link", target: "character" }, objects: { type: "multi_link", target: "object" }, locations: { type: "multi_link", target: "location" }, species: { type: "multi_link", target: "species" }, creatures: { type: "multi_link", target: "creature" }, institutions: { type: "multi_link", target: "institution" }, traits: { type: "multi_link", target: "trait" }, collectives: { type: "multi_link", target: "collective" }, zones: { type: "multi_link", target: "zone" }, abilities: { type: "multi_link", target: "ability" }, phenomena: { type: "multi_link", target: "phenomenon" }, languages: { type: "multi_link", target: "language" }, families: { type: "multi_link", target: "family" }, relations: { type: "multi_link", target: "relation" }, titles: { type: "multi_link", target: "title" }, constructs: { type: "multi_link", target: "construct" } }, family: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Identity spirit: { type: "text" }, history: { type: "text" }, traditions: { type: "multi_link", target: "construct" }, traits: { type: "multi_link", target: "trait" }, abilities: { type: "multi_link", target: "ability" }, languages: { type: "multi_link", target: "language" }, ancestors: { type: "multi_link", target: "character" }, // World reputation: { type: "text" }, estates: { type: "multi_link", target: "location" }, governs: { type: "multi_link", target: "institution" }, heirlooms: { type: "multi_link", target: "object" }, creatures: { type: "multi_link", target: "creature" } }, institution: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Foundation doctrine: { type: "text" }, founding_date: { type: "number" }, parent_institution: { type: "single_link", target: "institution" }, // Claims zones: { type: "multi_link", target: "zone" }, objects: { type: "multi_link", target: "object" }, creatures: { type: "multi_link", target: "creature" }, // World status: { type: "text" }, allies: { type: "multi_link", target: "institution" }, adversaries: { type: "multi_link", target: "institution" }, constructs: { type: "multi_link", target: "construct" } }, language: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Structure phonology: { type: "text" }, grammar: { type: "text" }, lexicon: { type: "text" }, writing: { type: "text" }, classification: { type: "single_link", target: "construct" }, // World status: { type: "text" }, spread: { type: "multi_link", target: "location" }, dialects: { type: "multi_link", target: "language" } }, law: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Code declaration: { type: "text" }, purpose: { type: "text" }, date: { type: "number" }, parent_law: { type: "single_link", target: "law" }, penalties: { type: "multi_link", target: "construct" }, // World author: { type: "single_link", target: "institution" }, locations: { type: "multi_link", target: "location" }, zones: { type: "multi_link", target: "zone" }, prohibitions: { type: "multi_link", target: "construct" }, adjudicators: { type: "multi_link", target: "title" }, enforcers: { type: "multi_link", target: "title" } }, location: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Setting form: { type: "text" }, function: { type: "text" }, founding_date: { type: "number" }, parent_location: { type: "single_link", target: "location" }, populations: { type: "multi_link", target: "collective" }, // Politics political_climate: { type: "text" }, primary_power: { type: "single_link", target: "institution" }, governing_title: { type: "single_link", target: "title" }, secondary_powers: { type: "multi_link", target: "institution" }, zone: { type: "single_link", target: "zone" }, rival: { type: "single_link", target: "location" }, partner: { type: "single_link", target: "location" }, // World customs: { type: "text" }, founders: { type: "multi_link", target: "character" }, cults: { type: "multi_link", target: "construct" }, delicacies: { type: "multi_link", target: "species" }, // Production extraction_methods: { type: "multi_link", target: "construct" }, extraction_goods: { type: "multi_link", target: "construct" }, industry_methods: { type: "multi_link", target: "construct" }, industry_goods: { type: "multi_link", target: "construct" }, // Commerce infrastructure: { type: "text" }, extraction_markets: { type: "multi_link", target: "location" }, industry_markets: { type: "multi_link", target: "location" }, currencies: { type: "multi_link", target: "construct" }, // Construction architecture: { type: "text" }, buildings: { type: "multi_link", target: "object" }, building_methods: { type: "multi_link", target: "construct" }, // Defense defensibility: { type: "text" }, elevation: { type: "number" }, fighters: { type: "multi_link", target: "construct" }, defensive_objects: { type: "multi_link", target: "object" } }, map: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Details background_color: { type: "text" }, hierarchy: { type: "number" }, width: { type: "number" }, height: { type: "number" }, depth: { type: "number" }, parent_map: { type: "single_link", target: "map" }, location: { type: "single_link", target: "location" } }, marker: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Details map: { type: "single_link", target: "map" }, zone: { type: "single_link", target: "zone" }, x: { type: "number" }, y: { type: "number" }, z: { type: "number" } }, narrative: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Context story: { type: "text" }, consequences: { type: "text" }, start_date: { type: "number" }, end_date: { type: "number" }, order: { type: "number" }, parent_narrative: { type: "single_link", target: "narrative" }, protagonist: { type: "single_link", target: "character" }, antagonist: { type: "single_link", target: "character" }, narrator: { type: "single_link", target: "character" }, conservator: { type: "single_link", target: "institution" }, // Involves events: { type: "multi_link", target: "event" }, characters: { type: "multi_link", target: "character" }, objects: { type: "multi_link", target: "object" }, locations: { type: "multi_link", target: "location" }, species: { type: "multi_link", target: "species" }, creatures: { type: "multi_link", target: "creature" }, institutions: { type: "multi_link", target: "institution" }, traits: { type: "multi_link", target: "trait" }, collectives: { type: "multi_link", target: "collective" }, zones: { type: "multi_link", target: "zone" }, abilities: { type: "multi_link", target: "ability" }, phenomena: { type: "multi_link", target: "phenomenon" }, languages: { type: "multi_link", target: "language" }, families: { type: "multi_link", target: "family" }, relations: { type: "multi_link", target: "relation" }, titles: { type: "multi_link", target: "title" }, constructs: { type: "multi_link", target: "construct" }, laws: { type: "multi_link", target: "law" } }, object: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Form aesthetics: { type: "text" }, weight: { type: "number" }, amount: { type: "number" }, parent_object: { type: "single_link", target: "object" }, materials: { type: "multi_link", target: "construct" }, technology: { type: "multi_link", target: "construct" }, // Function utility: { type: "text" }, effects: { type: "multi_link", target: "phenomenon" }, abilities: { type: "multi_link", target: "ability" }, consumes: { type: "multi_link", target: "construct" }, // World origins: { type: "text" }, location: { type: "single_link", target: "location" }, language: { type: "single_link", target: "language" }, affinities: { type: "multi_link", target: "trait" } }, phenomenon: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Mechanics expression: { type: "text" }, effects: { type: "text" }, duration: { type: "number" }, catalysts: { type: "multi_link", target: "object" }, empowerments: { type: "multi_link", target: "ability" }, // World mythology: { type: "text" }, system: { type: "single_link", target: "phenomenon" }, triggers: { type: "multi_link", target: "construct" }, wielders: { type: "multi_link", target: "character" }, environments: { type: "multi_link", target: "location" } }, pin: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Details map: { type: "single_link", target: "map" }, element_type: { type: "text" }, // ElementType enum value element_id: { type: "single_link", target: "any" }, // Can reference any element x: { type: "number" }, y: { type: "number" }, z: { type: "number" } }, relation: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Nature background: { type: "text" }, start_date: { type: "number" }, end_date: { type: "number" }, intensity: { type: "number" }, actor: { type: "single_link", target: "character" }, events: { type: "multi_link", target: "event" }, // Involves characters: { type: "multi_link", target: "character" }, objects: { type: "multi_link", target: "object" }, locations: { type: "multi_link", target: "location" }, species: { type: "multi_link", target: "species" }, creatures: { type: "multi_link", target: "creature" }, institutions: { type: "multi_link", target: "institution" }, traits: { type: "multi_link", target: "trait" }, collectives: { type: "multi_link", target: "collective" }, zones: { type: "multi_link", target: "zone" }, abilities: { type: "multi_link", target: "ability" }, phenomena: { type: "multi_link", target: "phenomenon" }, languages: { type: "multi_link", target: "language" }, families: { type: "multi_link", target: "family" }, relations: { type: "multi_link", target: "relation" }, titles: { type: "multi_link", target: "title" }, constructs: { type: "multi_link", target: "construct" }, narratives: { type: "multi_link", target: "narrative" } }, species: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Biology appearance: { type: "text" }, life_span: { type: "number" }, weight: { type: "number" }, nourishment: { type: "multi_link", target: "species" }, reproduction: { type: "multi_link", target: "construct" }, adaptations: { type: "multi_link", target: "ability" }, // Psychology instincts: { type: "text" }, sociality: { type: "text" }, temperament: { type: "text" }, communication: { type: "text" }, aggression: { type: "number" }, traits: { type: "multi_link", target: "trait" }, // World role: { type: "text" }, parent_species: { type: "single_link", target: "species" }, locations: { type: "multi_link", target: "location" }, zones: { type: "multi_link", target: "zone" }, affinities: { type: "multi_link", target: "phenomenon" } }, title: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Mandate authority: { type: "text" }, eligibility: { type: "text" }, grant_date: { type: "number" }, revoke_date: { type: "number" }, issuer: { type: "single_link", target: "institution" }, body: { type: "single_link", target: "institution" }, superior_title: { type: "single_link", target: "title" }, holders: { type: "multi_link", target: "character" }, symbols: { type: "multi_link", target: "object" }, // World status: { type: "text" }, history: { type: "text" }, characters: { type: "multi_link", target: "character" }, institutions: { type: "multi_link", target: "institution" }, families: { type: "multi_link", target: "family" }, zones: { type: "multi_link", target: "zone" }, locations: { type: "multi_link", target: "location" }, objects: { type: "multi_link", target: "object" }, constructs: { type: "multi_link", target: "construct" }, laws: { type: "multi_link", target: "law" }, collectives: { type: "multi_link", target: "collective" }, creatures: { type: "multi_link", target: "creature" }, phenomena: { type: "multi_link", target: "phenomenon" }, species: { type: "multi_link", target: "species" }, languages: { type: "multi_link", target: "language" } }, trait: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Qualitative social_effects: { type: "text" }, physical_effects: { type: "text" }, functional_effects: { type: "text" }, personality_effects: { type: "text" }, behaviour_effects: { type: "text" }, // Quantitative charisma: { type: "number" }, coercion: { type: "number" }, competence: { type: "number" }, compassion: { type: "number" }, creativity: { type: "number" }, courage: { type: "number" }, // World significance: { type: "text" }, anti_trait: { type: "single_link", target: "trait" }, empowered_abilities: { type: "multi_link", target: "ability" } }, zone: { // Base fields (shared by all elements) name: { type: "text", required: true }, description: { type: "text", required: false }, supertype: { type: "text", required: false }, subtype: { type: "text", required: false }, image_url: { type: "text", required: false }, // Scope role: { type: "text" }, start_date: { type: "number" }, end_date: { type: "number" }, phenomena: { type: "multi_link", target: "phenomenon" }, linked_zones: { type: "multi_link", target: "zone" }, // World context: { type: "text" }, populations: { type: "multi_link", target: "collective" }, titles: { type: "multi_link", target: "title" }, principles: { type: "multi_link", target: "construct" } } }; function createElementId(id) { return id; } function createElementIds(ids) { return ids; } function createAnyElementId(id) { return id; } export { ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_UNICODE_ICONS, ElementType, FIELD_SCHEMA, ONLYWORLDS_VERSION, OnlyWorldsClient, createAnyElementId, createElementId, createElementIds, getElementIcon, getElementLabel, getElementSections, getElementUnicodeIcon };