Schema for new records.
{
"name": "post",
"icon_name": "rss_feed",
"schema": {...},
"unique_by": {...}
}
TypeRecord
A public Record that defines a schema that new records can conform to.
name
string
snake_case
format.icon_name
string optional
Name of the icon to use for the type.
It should be part of the Material Symbols library.
schema
Schema
Schema for the records to follow.
At the top-level should be an Object schema with a content
property.
unique_by
TypeRecordUniqueBy optional
The schema
applies to the entire record, and not just to its content. This makes it possible to constrain other properties like permissions
(e.g. ensure all records of this type are public).
Material Symbols are used for type icons because they’re open, feature an extensive collection, and are easy to customize to fit different visual styles. This makes it possible to display record types of various origins side by side while retaining some visual consistency.
TypeRecordUniqueBy
Let servers know what properties should form a unicity constraint.
domain
string optional
Scope within which the unicity constraint applies.
128-bit identifier, hex-encoded, all-lowercase, without any spaces.
Defaults to only applying within records of this type.
set_equality
boolean optional
Should properties be compared as a set and not as an array.
Default to false
.
values
JsonPointer[]
This is what the full content of a Type record might look like. Here it’s the schema for a task in a basic “Todo” app. It includes a title, and whether it was marked as completed.
{
"name": "task",
"schema": {
"type": "object",
"properties": {
"content": {
"type": "object",
"properties": {
"title": {
"description": "Title of the task.",
"type": "string",
"max_length": 128
},
"completed": {
"description": "Whether the task was completed.",
"type": "boolean"
}
}
}
}
}
}
Some records might need to always be public, or always private, or to only be shared with a limited number of people. Since the schema
applies to the whole record, it makes it possible to constrain permissions
and in this example we make sure the records are always public.
{
"name": "post",
"schema": {
"type": "object",
"properties": {
"content": {...},
"permissions": {
"type": "object",
"properties": {
"read": {
"type": "tag_link",
"enum": ["public"]
}
}
}
}
}
}
Some apps may need servers to enforce custom unicity constraints based on their own logic. In this example, a Task record is made unique by title
so that two tasks cannot have the same one.
{
"name": "task",
"schema": {
"type": "object",
"properties": {
"content": {
"type": "object",
"properties": {
"title": {
"type": "string",
"max_length": 128
},
"completed": {
"type": "boolean"
}
}
}
}
},
"unique_by": {
"values": ["/content/title"]
}
}