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-document.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, 18 minutes ago History
dron-document.schema.json · 19.0 KB · 579 lines
1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "title": "DRON exchange document",
4 "description": "DRON (Data Rules Object Notation) is a portable, declarative description of an application's data and the rules over it. This file validates the envelope one box sends another (a purchase order, order confirmation, invoice, credit note, remittance or goods receipt, or a control message such as connection_request). It is the shape object_exchange.validate_envelope checks and no more: what needs computation is the engine's alone (the signature, the canonical bytes, the SHA-256 of the envelope, a remittance adding up, a line id repeating, a calendar date existing, that no number in the document is a float), and whether the sender may send it or the receiver knows the documents it refers to is not judged here either. The signature is detached and sits beside the envelope on the wire, never inside it. See docs/box-to-box-exchange.md. The envelope's own version (dron_document) is that format's and is not DRON 0.2's; this file belongs to DRON 0.2.",
5 "type": "object",
6 "required": [
7 "dron_document",
8 "id",
9 "type",
10 "sender",
11 "recipient",
12 "created_at",
13 "body"
14 ],
15 "additionalProperties": false,
16 "properties": {
17 "dron_document": {
18 "description": "The version of this envelope format, always \"0.1\" for now. A box refuses any other value.",
19 "const": "0.1"
20 },
21 "id": {
22 "description": "The sender's unique id for this document; delivery is idempotent on (sender, id).",
23 "$ref": "#/$defs/id"
24 },
25 "type": {
26 "description": "What the document is. Business documents: purchase_order, order_confirmation, invoice, credit_note, remittance, receipt. Control messages, never stored in the inbox: connection_request, connection_accept, connection_end, document_refusal.",
27 "enum": [
28 "purchase_order",
29 "order_confirmation",
30 "invoice",
31 "credit_note",
32 "remittance",
33 "receipt",
34 "connection_request",
35 "connection_accept",
36 "connection_end",
37 "document_refusal"
38 ]
39 },
40 "sender": {
41 "description": "The domain of the box that made and signed the document.",
42 "$ref": "#/$defs/domain"
43 },
44 "recipient": {
45 "description": "The domain of the box it is addressed to.",
46 "$ref": "#/$defs/domain"
47 },
48 "created_at": {
49 "description": "When the sender made the document, in UTC.",
50 "$ref": "#/$defs/stamp"
51 },
52 "refs": {
53 "description": "Earlier documents this one answers, by id and type. Leave it out or write [] when it answers none.",
54 "type": "array",
55 "items": {
56 "$ref": "#/$defs/ref"
57 }
58 },
59 "body": {
60 "description": "The document's content; its shape depends on type. A connection_request or connection_accept carries any object.",
61 "type": "object"
62 }
63 },
64 "allOf": [
65 {
66 "description": "A purchase order, order confirmation, invoice or credit note carries priced lines and totals.",
67 "if": {
68 "required": [
69 "type"
70 ],
71 "properties": {
72 "type": {
73 "enum": [
74 "purchase_order",
75 "order_confirmation",
76 "invoice",
77 "credit_note"
78 ]
79 }
80 }
81 },
82 "then": {
83 "properties": {
84 "body": {
85 "$ref": "#/$defs/pricedBody"
86 }
87 }
88 }
89 },
90 {
91 "description": "An order confirmation also says whether it accepts, rejects or amends the order.",
92 "if": {
93 "required": [
94 "type"
95 ],
96 "properties": {
97 "type": {
98 "enum": [
99 "order_confirmation"
100 ]
101 }
102 }
103 },
104 "then": {
105 "properties": {
106 "body": {
107 "required": [
108 "response"
109 ],
110 "properties": {
111 "response": {
112 "enum": [
113 "accepted",
114 "rejected",
115 "amended"
116 ]
117 }
118 }
119 }
120 }
121 }
122 },
123 {
124 "description": "A remittance names the payment and the invoices it settles.",
125 "if": {
126 "required": [
127 "type"
128 ],
129 "properties": {
130 "type": {
131 "enum": [
132 "remittance"
133 ]
134 }
135 }
136 },
137 "then": {
138 "properties": {
139 "body": {
140 "$ref": "#/$defs/remittanceBody"
141 }
142 }
143 }
144 },
145 {
146 "description": "A goods receipt names the date and the lines received.",
147 "if": {
148 "required": [
149 "type"
150 ],
151 "properties": {
152 "type": {
153 "enum": [
154 "receipt"
155 ]
156 }
157 }
158 },
159 "then": {
160 "properties": {
161 "body": {
162 "$ref": "#/$defs/receiptBody"
163 }
164 }
165 }
166 },
167 {
168 "description": "connection_end may say why.",
169 "if": {
170 "required": [
171 "type"
172 ],
173 "properties": {
174 "type": {
175 "enum": [
176 "connection_end"
177 ]
178 }
179 }
180 },
181 "then": {
182 "properties": {
183 "body": {
184 "$ref": "#/$defs/connectionEndBody"
185 }
186 }
187 }
188 },
189 {
190 "description": "document_refusal names the refused document and says why.",
191 "if": {
192 "required": [
193 "type"
194 ],
195 "properties": {
196 "type": {
197 "enum": [
198 "document_refusal"
199 ]
200 }
201 }
202 },
203 "then": {
204 "properties": {
205 "body": {
206 "$ref": "#/$defs/documentRefusalBody"
207 }
208 }
209 }
210 }
211 ],
212 "$defs": {
213 "id": {
214 "title": "Document id",
215 "description": "The sender's unique id for a document, 1 to 128 characters: a letter or digit first, then letters, digits and . _ : - . Delivery is idempotent on (sender, id), so a resend of the same document keeps its id. Example: \"doc-6f1c9a\".",
216 "type": "string",
217 "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
218 },
219 "domain": {
220 "title": "Box domain",
221 "description": "A box is its domain: a lower-case DNS name with at least one dot, labels of letters, digits and hyphens (not at either end), at most 253 characters in all. An IP address or a bare host name is refused. Example: \"supplier.example\".",
222 "type": "string",
223 "pattern": "^(?=.{1,253}$)[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)+$",
224 "not": {
225 "pattern": "^[0-9.]+$"
226 }
227 },
228 "stamp": {
229 "title": "UTC time",
230 "description": "One spelling of an instant: YYYY-MM-DDTHH:MM:SSZ, in UTC, with the capital Z and no fraction or offset. Two spellings of one instant do not compare equal, so only this one is read. Example: \"2026-12-03T09:30:00Z\".",
231 "type": "string",
232 "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|6[01])Z$"
233 },
234 "date": {
235 "title": "Calendar date",
236 "description": "A date written YYYY-MM-DD. Example: \"2026-12-03\".",
237 "type": "string",
238 "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
239 },
240 "currency": {
241 "title": "Currency",
242 "description": "An ISO 4217 currency code: three capital letters. Example: \"EUR\".",
243 "type": "string",
244 "pattern": "^[A-Z]{3}$"
245 },
246 "minor": {
247 "title": "Money in minor units",
248 "description": "Money is a whole number of minor units (cents, pence): 1850 is 18.50 in a two-decimal currency. A float anywhere in a document is refused, because floats are where two JSON libraries disagree about the bytes a signature covers. Example: 1850.",
249 "type": "integer"
250 },
251 "decimalString": {
252 "title": "Decimal string",
253 "description": "A quantity is a decimal written as TEXT, never a JSON number (for the same reason money is not a float): digits with an optional sign, decimal point and exponent. Example: \"12\" or \"1.5\".",
254 "type": "string",
255 "pattern": "^\\s*[+-]?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([eE][+-]?[0-9]+)?\\s*$"
256 },
257 "unitCode": {
258 "title": "Unit code",
259 "description": "What a line's quantity counts, as a UN/ECE Recommendation 20 code of one to three capital letters or digits (C62 one, H87 piece, KGM kilogram, XBG bag). Any code of that shape is read, whether or not this box can name it. Example: \"H87\".",
260 "type": "string",
261 "pattern": "^[A-Z0-9]{1,3}$"
262 },
263 "ref": {
264 "title": "Earlier document",
265 "description": "One earlier document this one answers, by id and type. Keys beyond these are allowed and signed but not interpreted. Example: {\"id\": \"doc-91ab\", \"type\": \"purchase_order\"}.",
266 "type": "object",
267 "required": [
268 "id",
269 "type"
270 ],
271 "properties": {
272 "id": {
273 "description": "The id of the earlier document, as its sender wrote it.",
274 "$ref": "#/$defs/id"
275 },
276 "type": {
277 "description": "The earlier document's type. Only business documents can be referred to, not control messages.",
278 "enum": [
279 "purchase_order",
280 "order_confirmation",
281 "invoice",
282 "credit_note",
283 "remittance",
284 "receipt"
285 ]
286 }
287 }
288 },
289 "line": {
290 "title": "Priced line",
291 "description": "One line of a purchase order, order confirmation, invoice or credit note. Keys beyond those listed are allowed (a newer box may add some) and are signed with the rest. Line ids must be different within one document; that is the engine's check, not this file's.",
292 "type": "object",
293 "required": [
294 "line_id",
295 "description",
296 "quantity",
297 "unit_price_minor",
298 "line_extension_minor"
299 ],
300 "properties": {
301 "line_id": {
302 "description": "This line's id within the document, any non-empty text. A confirmation's ref_line_id points at one. Example: \"1\".",
303 "type": "string",
304 "minLength": 1
305 },
306 "description": {
307 "description": "What the line is, in words a person can read. Not blank.",
308 "type": "string",
309 "pattern": "\\S"
310 },
311 "quantity": {
312 "description": "How many, as a decimal string. Example: \"12\".",
313 "$ref": "#/$defs/decimalString"
314 },
315 "unit_code": {
316 "description": "What the quantity counts. Leave it out for \"one\".",
317 "$ref": "#/$defs/unitCode"
318 },
319 "unit_price_minor": {
320 "description": "Net price of one unit, in minor units.",
321 "$ref": "#/$defs/minor"
322 },
323 "line_extension_minor": {
324 "description": "The line's net amount, in minor units.",
325 "$ref": "#/$defs/minor"
326 },
327 "tax_rate_bps": {
328 "description": "Tax rate in basis points: 2000 is 20%. Example: 0.",
329 "type": "integer"
330 },
331 "ref_line_id": {
332 "description": "On a confirmation: the id of the buyer's line this answers. Same shape as a document id.",
333 "$ref": "#/$defs/id"
334 },
335 "line_status": {
336 "description": "On a confirmation: accepted (as asked), changed (quantity, unit or price), rejected (not supplied, sent with quantity 0) or added (a line the buyer did not ask for).",
337 "enum": [
338 "accepted",
339 "changed",
340 "rejected",
341 "added"
342 ]
343 }
344 }
345 },
346 "receivedLine": {
347 "title": "Received line",
348 "description": "One line of a goods receipt. Keys beyond those listed are allowed. Line ids must be different within one document (the engine's check).",
349 "type": "object",
350 "required": [
351 "line_id",
352 "description",
353 "quantity_received"
354 ],
355 "properties": {
356 "line_id": {
357 "description": "This line's id within the document, any non-empty text.",
358 "type": "string",
359 "minLength": 1
360 },
361 "description": {
362 "description": "What was received, in words. Not blank.",
363 "type": "string",
364 "pattern": "\\S"
365 },
366 "quantity_received": {
367 "description": "How many arrived, as a decimal string.",
368 "$ref": "#/$defs/decimalString"
369 },
370 "quantity_rejected": {
371 "description": "How many were turned away, as a decimal string.",
372 "$ref": "#/$defs/decimalString"
373 },
374 "unit_code": {
375 "description": "What the quantity counts.",
376 "$ref": "#/$defs/unitCode"
377 },
378 "ref_line_id": {
379 "description": "The id of the order line this receives.",
380 "$ref": "#/$defs/id"
381 },
382 "line_status": {
383 "description": "How the line was answered: accepted, changed, rejected or added.",
384 "enum": [
385 "accepted",
386 "changed",
387 "rejected",
388 "added"
389 ]
390 }
391 }
392 },
393 "pricedBody": {
394 "title": "Priced document body",
395 "description": "The body of a purchase order, order confirmation, invoice or credit note. Keys beyond those listed are allowed and signed. An order confirmation also needs response.",
396 "type": "object",
397 "required": [
398 "number",
399 "issue_date",
400 "currency",
401 "lines",
402 "totals"
403 ],
404 "properties": {
405 "number": {
406 "description": "The sender's own number for this document, not blank. Example: \"INV-77\".",
407 "type": "string",
408 "pattern": "\\S"
409 },
410 "issue_date": {
411 "description": "The date the document was issued.",
412 "$ref": "#/$defs/date"
413 },
414 "due_date": {
415 "description": "When payment is due, on an invoice.",
416 "$ref": "#/$defs/date"
417 },
418 "currency": {
419 "description": "The currency every amount in the document is in.",
420 "$ref": "#/$defs/currency"
421 },
422 "response": {
423 "description": "On an order confirmation only (required there): accepted, rejected or amended. Ignored on the other types.",
424 "type": "string"
425 },
426 "lines": {
427 "description": "The lines, at least one.",
428 "type": "array",
429 "minItems": 1,
430 "items": {
431 "$ref": "#/$defs/line"
432 }
433 },
434 "totals": {
435 "description": "Document totals in minor units. Keys beyond those listed are allowed.",
436 "type": "object",
437 "required": [
438 "line_extension_minor",
439 "tax_minor",
440 "payable_minor"
441 ],
442 "properties": {
443 "line_extension_minor": {
444 "description": "Sum of the line net amounts.",
445 "$ref": "#/$defs/minor"
446 },
447 "charge_minor": {
448 "description": "Document-level charges such as carriage.",
449 "$ref": "#/$defs/minor"
450 },
451 "tax_minor": {
452 "description": "Total tax.",
453 "$ref": "#/$defs/minor"
454 },
455 "payable_minor": {
456 "description": "The amount due.",
457 "$ref": "#/$defs/minor"
458 }
459 }
460 }
461 }
462 },
463 "remittanceBody": {
464 "title": "Remittance body",
465 "description": "The body of a remittance: a payment and the invoices it settles. The amounts settled must add up to paid_minor; that sum is the engine's check, not this file's. Keys beyond those listed are allowed.",
466 "type": "object",
467 "required": [
468 "currency",
469 "paid_minor",
470 "paid_on",
471 "settles"
472 ],
473 "properties": {
474 "currency": {
475 "description": "The currency paid in.",
476 "$ref": "#/$defs/currency"
477 },
478 "paid_minor": {
479 "description": "The total paid, in minor units; equal to the sum of the settles amounts.",
480 "$ref": "#/$defs/minor"
481 },
482 "paid_on": {
483 "description": "The date the payment was made.",
484 "$ref": "#/$defs/date"
485 },
486 "payment_reference": {
487 "description": "A structured payment reference such as an ISO 11649 RF reference.",
488 "type": "string"
489 },
490 "settles": {
491 "description": "The invoices this payment settles, at least one.",
492 "type": "array",
493 "minItems": 1,
494 "items": {
495 "type": "object",
496 "required": [
497 "document_id",
498 "amount_minor"
499 ],
500 "properties": {
501 "document_id": {
502 "description": "The id of the invoice settled.",
503 "$ref": "#/$defs/id"
504 },
505 "amount_minor": {
506 "description": "How much of the payment went to this invoice, in minor units.",
507 "$ref": "#/$defs/minor"
508 }
509 }
510 }
511 }
512 }
513 },
514 "receiptBody": {
515 "title": "Goods receipt body",
516 "description": "The body of a goods receipt. Keys beyond those listed are allowed.",
517 "type": "object",
518 "required": [
519 "received_on",
520 "lines"
521 ],
522 "properties": {
523 "received_on": {
524 "description": "The date the goods arrived.",
525 "$ref": "#/$defs/date"
526 },
527 "lines": {
528 "description": "The lines received, at least one.",
529 "type": "array",
530 "minItems": 1,
531 "items": {
532 "$ref": "#/$defs/receivedLine"
533 }
534 }
535 }
536 },
537 "connectionEndBody": {
538 "title": "Connection end body",
539 "description": "The body of connection_end: the sender ends the relationship. Keys beyond reason are allowed.",
540 "type": "object",
541 "properties": {
542 "reason": {
543 "description": "Why, in a sentence. Optional.",
544 "type": "string"
545 }
546 }
547 },
548 "documentRefusalBody": {
549 "title": "Document refusal body",
550 "description": "The body of document_refusal: a person at the sender refused a document the receiver delivered, named by its id and the SHA-256 of its envelope. Keys beyond those listed are allowed.",
551 "type": "object",
552 "required": [
553 "document_id",
554 "envelope_sha256",
555 "reason"
556 ],
557 "properties": {
558 "document_id": {
559 "description": "The id of the refused document.",
560 "$ref": "#/$defs/id"
561 },
562 "envelope_sha256": {
563 "description": "The SHA-256 of the refused envelope's canonical bytes, as 64 lower-case hex digits.",
564 "type": "string",
565 "pattern": "^[0-9a-f]{64}$"
566 },
567 "code": {
568 "description": "A short machine-readable reason code. Optional.",
569 "type": "string"
570 },
571 "reason": {
572 "description": "Why it was refused, not blank.",
573 "type": "string",
574 "pattern": "\\S"
575 }
576 }
577 }
578 }
579}