Skip to main content
Version: Next

Entity Types

An EntityType defines the schema for a class of entities. It is itself an entity of type entity_type/entity_type, which means it is created, versioned, and queried through the same API as any other entity.

Every entity type you define -- whether recipe, document, or part -- automatically becomes available as a REST API endpoint. See REST API Reference for details.

Properties of an EntityType

FieldTypeRequiredDescription
namestringyesSystem identifier; used as the key. Must match [a-zA-Z0-9_]+. A customer prefix (e.g. xy_document) is recommended for namespacing.
labellocalized mapyesDisplay name per locale
label_plurallocalized mapnoPlural display name per locale
descriptionlocalized mapnoDescription per locale
iconstringnoIcon identifier for UI display (Lucide icon library)
key_scriptLua stringnoComputes the human-readable key for instances. See Lua Scripting.
label_scriptLua stringnoComputes the display label for instances. See Lua Scripting.

Localized Maps

Properties like label, label_plural, and description use locale codes as keys:

{
"label": { "de_de": "Rezept", "en_us": "Recipe" },
"label_plural": { "de_de": "Rezepte", "en_us": "Recipes" }
}

Relationships on an EntityType

An entity type declares its structure through relationships to other meta-model entities:

RelationshipTarget TypeDescription
has_propproperty_typeDeclares properties on this entity type. See Property Types.
has_virtual_propproperty_typeDeclares computed (read-only) properties. See Virtual Properties.
has_relrelationship_typeDeclares which relationship types this entity type participates in. See Relationship Types.
has_listentity_typeDeclares ordered sub-entity lists. See Lists.
has_parententity_typeInheritance -- this type extends another entity type. See Inheritance below.
has_lc_maplc_mapAssigns a lifecycle map. See Lifecycle.
has_actionactionDeclares callable actions. See Actions & Hooks.
has_hookactionDeclares lifecycle hooks. See Actions & Hooks.

Example: Defining an EntityType

{
"key": "recipe",
"properties": {
"name": "recipe",
"label": { "en_us": "Recipe", "de_de": "Rezept" },
"label_plural": { "en_us": "Recipes", "de_de": "Rezepte" },
"description": { "en_us": "A cooking recipe" },
"icon": "book-open",
"key_script": "return self.properties[\"recipe_id\"]"
},
"relationships": {
"has_prop": [
{
"properties": { "name": "recipe_id", "label": { "en_us": "Recipe ID" }, "required": true, "unique": true },
"target": "string_property_type/system_name"
},
{
"properties": { "name": "title", "label": { "en_us": "Title" }, "required": true },
"target": "multi_lang_property_type/generic"
},
{
"properties": { "name": "servings", "label": { "en_us": "Servings" } },
"target": "int_property_type/generic"
}
],
"has_rel": [
{
"properties": { "name": "has_ingredient", "label": { "en_us": "Ingredients" } },
"target": "relationship_type/has_ingredient"
}
],
"has_lc_map": [
{ "target": "lc_map/EP_Default" }
]
}
}

This defines a recipe entity type with three properties, one relationship type, and the default lifecycle.

Inheritance

Entity types support single inheritance via has_parent. A child type inherits all properties, relationships, and lists from its parent.

{
"key": "vegan_recipe",
"properties": {
"name": "vegan_recipe",
"label": { "en_us": "Vegan Recipe" }
},
"relationships": {
"has_parent": [
{ "target": "entity_type/recipe" }
],
"has_prop": [
{
"properties": { "name": "certification", "label": { "en_us": "Certification" } },
"target": "string_property_type/generic"
}
]
}
}

The vegan_recipe type inherits all properties and relationships from recipe and adds its own certification property.

info

The property type hierarchy itself uses this mechanism -- all concrete property types (string_property_type, int_property_type, etc.) inherit from the base property_type.

Automatic API Endpoints

Every entity type is instantly available in the REST API and creates endpoints for its instances:

GET /api/v1/by-type/<type_name> -- List all instances
POST /api/v1/by-type/<type_name> -- Create a new instance
GET /api/v1/by-key/<type_name>/<key> -- Get a specific instance
PUT /api/v1/by-id/<uuid> -- Update an instance
DELETE /api/v1/by-id/<uuid>?purge=true -- Delete an instance

See REST API Reference for the complete endpoint documentation.

info

Entity types can change over time. Multiple versions of an entity type may exist concurrently, following the same immutability model described in The Meta Model.