The schema document is the one YAML file that holds all the collections of an app. This page is generated from collections-document.schema.json, the JSON Schema the platform checks a document against, so it describes the format as it is checked. App Data explains what the keys do; the routes that save, preview and publish a document are under App collections.
Document
| Key | Type | Required | Description |
|---|---|---|---|
format |
1 |
yes |
The document format version. Always 1. |
collections |
record<string, object> | null |
yes |
The collections of the app by key, at most 50. Nothing under collections: (null) means none. |
Collection
One entry of collections, under its key. A key matches ^[a-z][a-z0-9_]{0,62}$.
| Key | Type | Required | Description |
|---|---|---|---|
label |
string |
no |
A name for people to read. It may change at any time; the key is what code uses. |
description |
string |
no |
Free text that explains the collection to people. |
binding |
"global" | "per_robot" | "one_per_robot" |
yes |
global: records belong to the app and no robot. per_robot: every record belongs to one robot (system field robot_id, fixed when the record is created). one_per_robot: every robot of the app has exactly one record, which Fleetless creates itself. |
display |
string |
no |
A template that names a record in lists, references and titles, for example {{name}} ({{location.name}}). A placeholder is a field of this collection, a system field (id, created_at, created_by, updated_at, updated_by, revision, and robot_id on robot-bound collections), robot.name on robot-bound collections, or <reference field>.<field of the target>. |
access |
object |
no |
Which roles may read, create, update and delete the records of this collection. A missing key grants that action to nobody; developers and server keys can always do everything. |
fields |
record<string, object> |
yes |
The fields of a record, at most 100. Their order is the order of the record form. |
Access
The access of a collection says which roles may do what with its records. A value is a role key or a list of role keys; update and delete also take all and own. A missing key, or a collection without access, grants that action to nobody.
| Key | Type | Required | Description |
|---|---|---|---|
read |
string | string[] |
no |
Roles that may read records. |
create |
string | string[] |
no |
Roles that may create records. Has no effect on one_per_robot collections, whose records Fleetless creates. |
update |
string | string[] | object |
no |
Roles that may change records: a role key, a list, or { all, own } to tell every record from the ones a role created itself. |
update.all |
string | string[] |
no |
Roles that may do this to every record. |
update.own |
string | string[] |
no |
Roles that may do this only to records they created themselves. |
delete |
string | string[] | object |
no |
Roles that may delete records: a role key, a list, or { all, own }. Has no effect on one_per_robot collections, whose records are never deleted through the API. |
delete.all |
string | string[] |
no |
Roles that may do this to every record. |
delete.own |
string | string[] |
no |
Roles that may do this only to records they created themselves. |
Field types
A field is an object under fields whose type decides which options it accepts. An option a type does not list is refused: the format knows no other keys.
Options of every type
| Key | Type | Required | Description |
|---|---|---|---|
label |
string |
no |
A short name for people to read. It may change at any time; the key is what code uses. |
description |
string |
no |
Free text that explains the field to the people who fill it in. |
required |
boolean |
no |
A new record must set this field, and an update may not clear it. |
unique |
boolean | "collection" |
no |
true: no two records hold the same value, within the collection (global) or within one robot (per_robot, one_per_robot). collection: on a robot-bound collection, across all robots. Empty values never collide. Not allowed on boolean and json fields. |
default |
unknown |
no |
The value a record gets when it does not set this field. It must itself be a valid value of the field. |
text
One line of text.
| Key | Type | Required | Description |
|---|---|---|---|
max_length |
integer |
no |
Longest value in characters. Default 255, at most 1000. |
pattern |
string |
no |
A regular expression in the RE2 subset, checked in unicode mode: lookahead, lookbehind and backreferences are not supported. At most 1,000 characters, and the cloud may also refuse a pattern as too complex (its compiled size is bounded; counted repeats such as {n} multiply it), which a document reports as an invalid pattern. The value must match somewhere in it; anchor it with ^ and $ to match the whole value. |
searchable |
boolean |
no |
Include this field in the search of record lists. |
long_text
Text with line breaks.
| Key | Type | Required | Description |
|---|---|---|---|
max_length |
integer |
no |
Longest value in characters. Default 10000, at most 100000. |
searchable |
boolean |
no |
Include this field in the search of record lists. |
number
A JSON number.
| Key | Type | Required | Description |
|---|---|---|---|
integer |
boolean |
no |
Accept whole numbers only. |
min |
number |
no |
Smallest accepted value. |
max |
number |
no |
Largest accepted value. |
unit |
string |
no |
A unit to show next to the value, such as m or rad/s. Display only; nothing converts values. |
boolean
true or false.
No options of its own.
select
One option value, or a list of them when multiple is set.
| Key | Type | Required | Description |
|---|---|---|---|
options |
object[] |
yes |
The accepted values, 1 to 500. Two options may not share a value. |
options[].value |
string |
yes |
What is stored in records and used in filters. |
options[].label |
string |
no |
What people see instead of the value. |
multiple |
boolean |
no |
Hold a list of distinct options instead of one. |
searchable |
boolean |
no |
Include the values and labels of the chosen options in the search of record lists. |
date
A date as YYYY-MM-DD.
No options of its own.
datetime
A moment in ISO 8601, in UTC, to the millisecond.
No options of its own.
json
Any JSON value, checked against a template or an inline JSON Schema when schema is set.
| Key | Type | Required | Description |
|---|---|---|---|
schema |
string | record<string, unknown> |
no |
What the value must look like: the name of a built-in template (pose2d, point2d, polygon2d, range1d) or an inline JSON Schema (draft 2020-12). Without it any JSON value is accepted. |
reference
The id of a record in another collection.
| Key | Type | Required | Description |
|---|---|---|---|
to |
string |
yes |
The key of the collection whose records this field points at. It must be a collection of the same document. |
on_delete |
"prevent" | "clear" |
no |
prevent (the default): a record that other records point at cannot be deleted. clear: deleting it clears the reference in the records that pointed at it. |
JSON templates
A json field names one of these in schema. The units are metres and radians, and frame_id is the name of a coordinate frame. Each template is a closed object with every property required.
pose2d
A position and a heading in a plane.
| Key | Type | Required | Description |
|---|---|---|---|
x |
number |
yes |
Position along the x axis, in metres. |
y |
number |
yes |
Position along the y axis, in metres. |
yaw |
number |
yes |
Heading around the vertical axis, in radians. |
frame_id |
string |
yes |
The name of the coordinate frame the numbers are given in. |
Example:
{
"x": 12.5,
"y": -3.2,
"yaw": 1.5708,
"frame_id": "map"
}
point2d
A position in a plane.
| Key | Type | Required | Description |
|---|---|---|---|
x |
number |
yes |
Position along the x axis, in metres. |
y |
number |
yes |
Position along the y axis, in metres. |
frame_id |
string |
yes |
The name of the coordinate frame the numbers are given in. |
Example:
{
"x": 4,
"y": 0.5,
"frame_id": "map"
}
polygon2d
A closed outline in a plane, given by its corners in order.
| Key | Type | Required | Description |
|---|---|---|---|
points |
object[] |
yes |
The corners, at least three. |
points[].x |
number |
yes |
Position along the x axis, in metres. |
points[].y |
number |
yes |
Position along the y axis, in metres. |
frame_id |
string |
yes |
The name of the coordinate frame the numbers are given in. |
Example:
{
"points": [
{
"x": 0,
"y": 0
},
{
"x": 4,
"y": 0
},
{
"x": 4,
"y": 3
}
],
"frame_id": "map"
}
range1d
An interval along one axis.
| Key | Type | Required | Description |
|---|---|---|---|
from |
number |
yes |
Start of the interval, in metres. |
to |
number |
yes |
End of the interval, in metres. |
Example:
{
"from": 2.5,
"to": 8
}
Keys and limits
- A collection key and a field key match
^[a-z][a-z0-9_]{0,62}$. - These field keys are reserved:
id,robot,robot_id,created_at,created_by,updated_at,updated_byandrevision. - A document has at most 50 collections, and a collection at most 100 fields.
- A
selecthas 1 to 500 options. - The document as text is at most 1,000,000 bytes of UTF-8.
Validity
A document is refused with 400 validation_error when it is not YAML or JSON, when it does not match this schema, or when it has an error below. A key the format does not know counts: it is nearly always a typo. Each finding is { path, code, message, severity }, where path points into the document, as in collections.chargers.fields.location.to.
Only an error makes a document invalid; a warning or information leaves it valid. Nothing about the stored data does, see Publishing a schema. The findings reach a caller in the issues of a preview.
| Code | Severity | Rule |
|---|---|---|
too_many_collections |
error |
The document has more than 50 collections. |
too_many_fields |
error |
A collection has more than 100 fields. |
reserved_key |
error |
A field key is one of the reserved keys. |
unknown_reference_target |
error |
The to of a reference field is not a collection of the document. |
robot_reference_from_global |
error |
A global collection points at a collection that belongs to robots. |
unknown_template |
error |
The schema of a json field names a template that does not exist. |
invalid_json_schema |
error |
An inline schema is not a usable JSON Schema. |
invalid_pattern |
error |
A pattern is not a valid regular expression, or uses lookahead, lookbehind or a backreference. |
display_template_invalid |
error |
A display cannot be read as a template. |
display_placeholder_unresolved |
error |
A display placeholder names no field, system field or reference hop of its collection. |
duplicate_option |
error |
Two options of a select share a value. |
invalid_default |
error |
A default is not a valid value of its field. |
required_without_default |
error |
A required field has no default in a one_per_robot collection, whose records Fleetless creates itself. |
unique_not_allowed |
error |
unique is set on a boolean or json field. |
access_ignored |
warning |
create or delete is set in the access of a one_per_robot collection, where it grants nothing. |
unknown_role |
warning |
A role key in access is not a role of the app. It grants nothing. |
no_role_has_access |
info |
No role can read a collection. Only developers and server keys reach its records. |