Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.

9 downloads

dbbasic-object-server/dron/dron-view.schema.json
Install on DigitalOcean Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-object-server.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-object-server.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-object-server.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

Daniel Quellhorst Changelog for this batch. 65ef78d 3 hours, 19 minutes ago History
dron-view.schema.json · 14.6 KB · 199 lines
1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "title": "DRON view blocks",
4 "description": "The `blocks` column of a seeded `views` record (packages/*/seed/views.tsv): a JSON list of block descriptors the universal renderer (site_view_render) draws, top to bottom, in the record's layout. DRON (Data Rules Object Notation) 0.2. A block is data, never code: its kind picks a renderer, the other keys are that renderer's options. The renderer draws an unknown kind or an unknown key as a placeholder or ignores it; this schema refuses both so a typo is caught before it ships. Blocks only choose what a page ASKS for: every block reads through the records API as the viewer, so the permission rules still decide what appears. A view record is not described here beyond its columns (see docs/dron.md and docs/package-authoring.md).",
5 "type": "array",
6 "items": {
7 "oneOf": [
8 {"$ref": "#/$defs/listBlock"},
9 {"$ref": "#/$defs/formBlock"},
10 {"$ref": "#/$defs/detailBlock"},
11 {"$ref": "#/$defs/relatedBlock"},
12 {"$ref": "#/$defs/threadBlock"},
13 {"$ref": "#/$defs/countBlock"},
14 {"$ref": "#/$defs/aggregateBlock"},
15 {"$ref": "#/$defs/markdownBlock"},
16 {"$ref": "#/$defs/readerBlock"},
17 {"$ref": "#/$defs/objectBlock"}
18 ]
19 },
20 "$defs": {
21 "collection": {
22 "title": "Block collection",
23 "description": "The collection the block reads. The viewer must be allowed to read it, or the block draws an empty or denied state. Example: \"notes\".",
24 "$ref": "dron-common.schema.json#/$defs/collectionName"
25 },
26 "recordRef": {
27 "title": "Record reference",
28 "description": "A record id, or the token \"$record_id\", which the renderer resolves to the id captured by this view's own route (one {name} capture, e.g. /notes/{note_id}). A $record_id on a view whose route has no single capture draws a visible error in the block, never a crash.",
29 "type": "string",
30 "minLength": 1
31 },
32 "flag": {
33 "title": "Switch",
34 "description": "true or false.",
35 "type": "boolean"
36 },
37 "literalMap": {
38 "title": "Field to literal value",
39 "description": "{field: value} pairs. Values are literal strings, compared for equality as stored (a boolean field is \"true\" or \"false\"). There is no operator syntax here, only equality.",
40 "type": "object",
41 "additionalProperties": {"type": "string"}
42 },
43 "listBlock": {
44 "title": "list block",
45 "description": "A collection as a working list page: the schema's own list mode (table, board, tree, calendar, or rows), the filter bar from views.filter_fields, realtime updates and the 50-row cap. Table and board honour the schema's views.list_fields; the plain row list shows a title and a created date only, and takes its title and subtitle from title_field and subtitle_field here.",
46 "type": "object",
47 "required": ["kind", "collection"],
48 "additionalProperties": false,
49 "properties": {
50 "kind": {"description": "Always \"list\".", "const": "list"},
51 "collection": {"$ref": "#/$defs/collection"},
52 "title": {"description": "A heading above the list.", "$ref": "dron-common.schema.json#/$defs/nonBlankText"},
53 "search": {"description": "true adds a search box (text search over the collection's schema `search.fields`, through /api/search).", "$ref": "#/$defs/flag"},
54 "sort": {
55 "description": "true adds a Newest/Oldest select. The string \"oldest\" (or \"asc\") lists oldest first. Sorting is by created_at; use sort_by for another field.",
56 "anyOf": [{"type": "boolean"}, {"enum": ["oldest", "asc"]}]
57 },
58 "add": {"description": "true adds a button that opens the collection's generated create form. The viewer still needs create permission for the write to succeed.", "$ref": "#/$defs/flag"},
59 "add_label": {"description": "The add button's text. Default \"+ New <Singular>\".", "$ref": "dron-common.schema.json#/$defs/nonBlankText"},
60 "owner_scoped": {"description": "true asks only for the viewer's own rows (owner_id = the viewer). It is what the page asks for, not access control: the permission rules decide what comes back either way. Leave it off for a shared collection.", "$ref": "#/$defs/flag"},
61 "where": {"description": "A standing narrowing, applied by the server after the permission row filter: one field=value pair per entry. The filter bar's picks layer on top. Equality only, literal values (no $record_id). Example: {\"direction\": \"inbound\"}.", "$ref": "#/$defs/literalMap"},
62 "filters": {"description": "A client-side narrowing, equality only. Setting filters (or limit) swaps the real list generator for a bare list of titles: no table, no filter bar, no list_fields. Prefer where.", "$ref": "#/$defs/literalMap"},
63 "limit": {"description": "Keep only this many rows, after sorting. Like filters, it swaps in the bare list. Prefer row_limit.", "type": "integer", "minimum": 0},
64 "title_field": {"description": "The field the row list uses as each row's title, instead of the first of title, name, label, subject, body, text, content, message, description, email, id. Also the title in tree and calendar modes.", "$ref": "dron-common.schema.json#/$defs/fieldName"},
65 "subtitle_field": {"description": "A field shown under each row's title in the row list.", "$ref": "dron-common.schema.json#/$defs/fieldName"},
66 "subtitle_label": {"description": "Text put before the subtitle value, as \"<label>: <value>\".", "$ref": "dron-common.schema.json#/$defs/nonBlankText"},
67 "href_template": {"description": "Where a row title links, when that is not /<collection>/<id>: a path with {field} placeholders, each replaced by that field's value. Example: \"/journals/{id}\".", "type": "string", "minLength": 1},
68 "href_field": {"description": "A field holding a URL; the row title opens it in a new tab. Ignored when href_template is set.", "$ref": "dron-common.schema.json#/$defs/fieldName"},
69 "row_actions": {"description": "false removes the per-row edit and delete buttons and the detail link: a log, a report, a rollup target.", "type": "boolean"},
70 "link": {"description": "false removes the row's link to a detail page (a collection with none).", "type": "boolean"},
71 "row_limit": {"description": "How many rows to draw before the Show all toggle. Default 50.", "type": "integer", "minimum": 0},
72 "sort_by": {"description": "Sort the rows by this field instead of created_at (numbers compare as numbers). With sort_dir, a bounded top-N report.", "$ref": "dron-common.schema.json#/$defs/fieldName"},
73 "sort_dir": {"description": "asc or desc (default desc), for sort_by.", "enum": ["asc", "desc"]}
74 }
75 },
76 "formBlock": {
77 "title": "form block",
78 "description": "The collection's generated form (the fields in schema forms.default.fields). With record_id it edits that record; without, it creates, and resets after each save so another can be added.",
79 "type": "object",
80 "required": ["kind", "collection"],
81 "additionalProperties": false,
82 "properties": {
83 "kind": {"description": "Always \"form\".", "const": "form"},
84 "collection": {"$ref": "#/$defs/collection"},
85 "record_id": {"description": "Edit this record instead of creating one.", "$ref": "#/$defs/recordRef"},
86 "fixed": {"description": "Fields locked to a value and hidden from the form: {field: value}. Use \"$record_id\" to tie a child to the page's record. Example: {\"order_id\": \"$record_id\"}.", "type": "object", "additionalProperties": {"type": "string"}},
87 "title": {"description": "Accepted and shipped by existing views, but the renderer does not draw it today.", "$ref": "dron-common.schema.json#/$defs/nonBlankText"}
88 }
89 },
90 "detailBlock": {
91 "title": "detail block",
92 "description": "One record, composed read-only from the schema (views.detail_fields when declared, else every field the viewer may read), with the collection's capabilities (comments, attachments, sharing) mounted under it. Edit and Delete show to the record's owner unless switched off.",
93 "type": "object",
94 "required": ["kind", "collection", "record_id"],
95 "additionalProperties": false,
96 "properties": {
97 "kind": {"description": "Always \"detail\".", "const": "detail"},
98 "collection": {"$ref": "#/$defs/collection"},
99 "record_id": {"$ref": "#/$defs/recordRef"},
100 "editable": {"description": "false hides Edit. Default true (the owner sees it).", "type": "boolean"},
101 "deletable": {"description": "false hides Delete. Default true (the owner sees it).", "type": "boolean"},
102 "delete_redirect": {"description": "Where to go after a delete. Default /<collection>.", "type": "string", "minLength": 1},
103 "owner_field": {"description": "The field that names the owner, when it is not owner_id.", "$ref": "dron-common.schema.json#/$defs/fieldName"}
104 }
105 },
106 "relatedBlock": {
107 "title": "related block",
108 "description": "The child rows of the page's record: the target collection filtered server-side by a foreign key, drawn with the list generator. For true children with their own identity and lifecycle (comments, interactions, files), not for lines embedded in a document.",
109 "type": "object",
110 "required": ["kind", "collection", "fk_field", "match"],
111 "additionalProperties": false,
112 "properties": {
113 "kind": {"description": "Always \"related\".", "const": "related"},
114 "collection": {"$ref": "#/$defs/collection"},
115 "fk_field": {"description": "The child field that holds the parent's id.", "$ref": "dron-common.schema.json#/$defs/fieldName"},
116 "match": {"description": "The parent's id: \"$record_id\" for the page's record, or a literal id.", "$ref": "#/$defs/recordRef"},
117 "title": {"description": "A heading above the rows.", "$ref": "dron-common.schema.json#/$defs/nonBlankText"}
118 }
119 },
120 "threadBlock": {
121 "title": "thread block",
122 "description": "The comment thread of one record (the thread_comments widget).",
123 "type": "object",
124 "required": ["kind", "collection", "record_id"],
125 "additionalProperties": false,
126 "properties": {
127 "kind": {"description": "Always \"thread\".", "const": "thread"},
128 "collection": {"description": "The collection of the record the thread hangs on.", "$ref": "#/$defs/collection"},
129 "record_id": {"$ref": "#/$defs/recordRef"}
130 }
131 },
132 "countBlock": {
133 "title": "count block",
134 "description": "A number card: how many rows of the collection the viewer may read (up to the first 500) match the filters.",
135 "type": "object",
136 "required": ["kind", "collection"],
137 "additionalProperties": false,
138 "properties": {
139 "kind": {"description": "Always \"count\".", "const": "count"},
140 "collection": {"$ref": "#/$defs/collection"},
141 "filters": {"description": "Count only rows where every {field: value} holds (equality).", "$ref": "#/$defs/literalMap"},
142 "label": {"description": "The caption under the number. Default: the collection name.", "$ref": "dron-common.schema.json#/$defs/nonBlankText"},
143 "warn_over": {"description": "Draw the card in the warning colour when the count is above this number.", "type": "integer", "minimum": 0}
144 }
145 },
146 "aggregateBlock": {
147 "title": "aggregate block",
148 "description": "Totals of numeric fields over a set of rows (a journal's debits and credits): one card per sum, and optionally a Balanced / Not balanced badge. A field ending in _cents is shown in whole units.",
149 "type": "object",
150 "required": ["kind", "collection", "sums"],
151 "additionalProperties": false,
152 "properties": {
153 "kind": {"description": "Always \"aggregate\".", "const": "aggregate"},
154 "collection": {"$ref": "#/$defs/collection"},
155 "sums": {"description": "The fields to sum.", "type": "array", "minItems": 1, "items": {"$ref": "dron-common.schema.json#/$defs/fieldName"}},
156 "fk_field": {"description": "With match: sum only the rows whose fk_field equals match.", "$ref": "dron-common.schema.json#/$defs/fieldName"},
157 "match": {"description": "The parent's id for fk_field: \"$record_id\" or a literal id.", "$ref": "#/$defs/recordRef"},
158 "filters": {"description": "Sum only rows where every {field: value} holds. Used when fk_field and match are not both set.", "$ref": "#/$defs/literalMap"},
159 "balance": {"description": "Exactly two of the sums that must be equal; a badge shows whether they are. Example: [\"debit_cents\", \"credit_cents\"].", "type": "array", "minItems": 2, "items": {"$ref": "dron-common.schema.json#/$defs/fieldName"}},
160 "title": {"description": "A heading above the cards.", "$ref": "dron-common.schema.json#/$defs/nonBlankText"}
161 }
162 },
163 "markdownBlock": {
164 "title": "markdown block",
165 "description": "Static text in a safe subset of Markdown.",
166 "type": "object",
167 "required": ["kind", "text"],
168 "additionalProperties": false,
169 "properties": {
170 "kind": {"description": "Always \"markdown\".", "const": "markdown"},
171 "text": {"description": "The Markdown source.", "type": "string"}
172 }
173 },
174 "readerBlock": {
175 "title": "reader block",
176 "description": "A fetched web page as title, text and links. Needs DBBASIC_ENABLE_READER and a signed-in viewer; otherwise it draws the refusal.",
177 "type": "object",
178 "required": ["kind", "url"],
179 "additionalProperties": false,
180 "properties": {
181 "kind": {"description": "Always \"reader\".", "const": "reader"},
182 "url": {"description": "The page to read.", "type": "string", "minLength": 1}
183 }
184 },
185 "objectBlock": {
186 "title": "object block",
187 "description": "A hand-written object drawn inline, so a generated page can keep one part that needs code. It runs through the ordinary execution path: permissions and audit apply, and it widens what a page can show, never what a viewer may see.",
188 "type": "object",
189 "required": ["kind", "object_id"],
190 "additionalProperties": false,
191 "properties": {
192 "kind": {"description": "Always \"object\".", "const": "object"},
193 "object_id": {"description": "The installed object to run (GET). Example: \"site_my_panel\".", "$ref": "dron-common.schema.json#/$defs/collectionName"},
194 "title": {"description": "A heading above the object's output.", "$ref": "dron-common.schema.json#/$defs/nonBlankText"},
195 "params": {"description": "Query parameters passed to the object, {name: value}.", "type": "object", "additionalProperties": {"type": "string"}}
196 }
197 }
198 }
199}