askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
danq9
signup: the person chooses the password and name on the confirm page
83c7aa6
2 weeks, 5 days ago
History
sent_documents.json · 6.3 KB · 94 lines
| 1 | { |
| 2 | "name": "sent_documents", |
| 3 | "title": "Sent Documents", |
| 4 | "version": 1, |
| 5 | "description": "One row per document that LEFT THE BUILDING, and what it said when it did. A tokened link is usually the better delivery than a PDF -- it is not caught by spam filters and it can show live truth (paid, shipped, collected) -- but that strength is also the trap, and this collection exists to close it. Email a quote at 4,000, change the price to 4,500, and the customer's link must not silently show 4,500: a document that was SENT is evidence of what was sent, and silently restating a document somebody is holding a printout of is the same class of error as restating an approved rate or a rolled-up invoice total (docs/logic-decisions.md #1 and #8, applied to paper). So the row carries the rendered SNAPSHOT -- the whole render model as JSON, exactly as object_documents folded it -- and site_document renders THAT, not the live record. A changed source is shown, never hidden: the page keeps serving the snapshot and adds a banner naming both dates with a link to the current version, so the customer can see that something moved and what it was. content_hash seals the snapshot; source_rev is the platform's own record fingerprint (object_records.compute_record_rev) taken at send time, which is what makes 'has the source changed?' an exact question rather than a timestamp comparison that a same-second edit would lose. The token is the whole credential and is a SEPARATE field rather than the row id, for the reason site_invoice_portal already argues: record ids appear in change logs, in owner-scoped collection paths and in correlation ids, so a leaked link must be revocable without touching the document's identity or its audit trail. opened_at is the question everyone asks the moment they send a quote -- 'did they read it?' -- and it comes free with a tokened link, stamped once on first view and never restamped, because 'they opened it on the 3rd' is the fact worth keeping and a view counter is a different feature. Rows are never deleted: a sent document cannot be made not to have been sent.", |
| 6 | "fields": [ |
| 7 | { |
| 8 | "name": "id" |
| 9 | }, |
| 10 | { |
| 11 | "name": "kind", |
| 12 | "type": "text", |
| 13 | "required": true, |
| 14 | "label": "Kind", |
| 15 | "validation": {"max_length": 60, "pattern": "^[a-z][a-z0-9_]*$"}, |
| 16 | "help": "A document kind object_documents.KINDS declares -- invoice, quote, order, purchase_order, packing_slip. Free text rather than a schema enum on purpose: the kind registry is code (it also decides the money rule and the address role), and a second copy of the list here could only ever disagree with it." |
| 17 | }, |
| 18 | { |
| 19 | "name": "source", |
| 20 | "type": "text", |
| 21 | "required": true, |
| 22 | "label": "Source", |
| 23 | "validation": {"max_length": 200}, |
| 24 | "help": "The record this document was rendered FROM, as 'collection/{id}' -- 'orders/9f3...', 'invoices/inv1'. A pointer, not a copy: the snapshot already holds what was said, and this says what it was said about, so 'which quote did we send them?' has an answer that survives the quote becoming an order." |
| 25 | }, |
| 26 | { |
| 27 | "name": "token", |
| 28 | "type": "text", |
| 29 | "read_only": true, |
| 30 | "label": "Token", |
| 31 | "validation": {"max_length": 120}, |
| 32 | "help": "The capability that opens /d/{token}. Read-only in the schema: never client-submitted, minted only by action_send_document with preserve_read_only=True (the escape hatch object_records reserves for a caller that owns a field's derivation). The client controls WHETHER a document is sent; it never controls what the token is." |
| 33 | }, |
| 34 | { |
| 35 | "name": "sent_to", |
| 36 | "type": "text", |
| 37 | "required": true, |
| 38 | "label": "Sent To", |
| 39 | "validation": {"max_length": 200}, |
| 40 | "help": "The address this copy went to. Part of the idempotency key with `source`: sending the same document to the same person twice is one document and one email, while sending it to their accounts department as well is genuinely a second delivery with its own link and its own opened_at." |
| 41 | }, |
| 42 | { |
| 43 | "name": "sent_at", |
| 44 | "type": "datetime", |
| 45 | "label": "Sent", |
| 46 | "help": "One half of what the changed-document banner has to name. Stamped by the action, not derived at read time." |
| 47 | }, |
| 48 | { |
| 49 | "name": "opened_at", |
| 50 | "type": "datetime", |
| 51 | "label": "Opened", |
| 52 | "help": "First view of the link, stamped once and never restamped -- idempotent by construction, because the fact worth keeping is 'they opened it', not how many times. Blank means never opened, which is a different follow-up from 'read it three times and did not reply'." |
| 53 | }, |
| 54 | { |
| 55 | "name": "content_hash", |
| 56 | "type": "text", |
| 57 | "label": "Content Hash", |
| 58 | "validation": {"max_length": 128}, |
| 59 | "help": "object_documents.content_hash of the snapshot: canonical JSON, SHA-256. The seal on the evidence -- a snapshot that no longer hashes to this has been edited by something that had no business editing it." |
| 60 | }, |
| 61 | { |
| 62 | "name": "source_rev", |
| 63 | "type": "text", |
| 64 | "label": "Source Rev", |
| 65 | "validation": {"max_length": 128}, |
| 66 | "help": "object_records.compute_record_rev of the source record at the moment of sending. Comparing it to the live record's rev is how site_document knows the source has changed -- exact, and immune to the same-second edit a timestamp comparison would miss. Blank on a row whose source could not be read at send time, which reads as 'cannot tell' and shows no banner rather than a false one." |
| 67 | }, |
| 68 | { |
| 69 | "name": "snapshot", |
| 70 | "type": "textarea", |
| 71 | "label": "Snapshot", |
| 72 | "validation": {"max_length": 65536}, |
| 73 | "help": "The rendered model as JSON -- header, identity, parties, lines, totals, terms, footer, exactly as object_documents.build_model produced it. This is the document. A packing slip's snapshot contains no prices at all, because build_model drops money from the model rather than hiding it in the renderer, so the no-prices rule survives being written to disk." |
| 74 | }, |
| 75 | { |
| 76 | "name": "owner_id", |
| 77 | "type": "text", |
| 78 | "label": "Owner" |
| 79 | } |
| 80 | ], |
| 81 | "forms": { |
| 82 | "default": { |
| 83 | "fields": ["kind", "source", "sent_to", "sent_at"] |
| 84 | } |
| 85 | }, |
| 86 | "views": { |
| 87 | "list_mode": "table", |
| 88 | "list_fields": ["kind", "source", "sent_to", "sent_at", "opened_at"], |
| 89 | "filter_fields": ["kind"] |
| 90 | }, |
| 91 | "search": { |
| 92 | "fields": ["sent_to", "source"] |
| 93 | } |
| 94 | } |