1044 lines · 22.9 KB · JSONRaw
{ "format_version": 1, "id": "email_thread", "name": "Email", "plural": "Email", "builtin": true, "visibility": "owner", "date": "last_at", "title": "subject", "columns": [ { "key": "external_key", "type": "text", "readonly": true }, { "key": "subject", "type": "text", "readonly": true, "placeholder": "No subject" }, { "key": "first_at", "name": "First email", "type": "date", "readonly": true }, { "key": "last_at", "name": "Latest email", "type": "date", "format": "calendar-datetime", "readonly": true, "fact": false, "reading": "{value}" }, { "key": "email_count", "name": "Emails", "type": "number", "readonly": true, "units": { "one": "email", "other": "emails", "zero": "0 emails" } }, { "key": "summary", "type": "longtext", "readonly": false }, { "key": "summary_updated_at", "type": "date", "format": "calendar-datetime", "readonly": true }, { "key": "summary_by", "name": "Summary by", "type": "text", "readonly": true }, { "key": "trashed_at", "name": "Binned", "type": "date", "readonly": true }, { "key": "sender_address", "type": "text", "readonly": true }, { "key": "sender_kind", "name": "Sender is", "type": "choice", "choices": [ "person", "service", "junk" ], "readonly": true }, { "key": "record_kind", "name": "Record", "type": "choice", "choices": [ "receipt", "statement", "ticket", "booking", "code", "delivery", "notice" ], "labels": { "receipt": "Receipt", "statement": "Statement", "ticket": "Ticket", "booking": "Booking", "code": "Sign-in code", "delivery": "Delivery", "notice": "Notice" }, "readonly": true }, { "key": "amount_minor", "name": "Amount", "type": "amount", "readonly": true, "currency": "currency" }, { "key": "currency", "type": "text", "readonly": true }, { "key": "merchant", "name": "Merchant", "type": "text", "readonly": true }, { "key": "record_on", "name": "On", "type": "date", "readonly": true }, { "key": "reference", "name": "Reference", "type": "text", "readonly": true }, { "key": "record_reason", "type": "text", "readonly": true }, { "key": "sender", "type": "text", "readonly": true, "fact": true, "reading": "{value}" }, { "key": "preview", "type": "text", "readonly": true }, { "key": "read_state", "name": "Read state", "type": "choice", "choices": [ "read", "unread" ], "readonly": true, "red_when": [ "unread" ], "labels": { "read": "Read", "unread": "Unread" } }, { "key": "starred", "type": "bool", "readonly": true }, { "key": "in_inbox", "name": "In inbox", "type": "bool", "readonly": true }, { "key": "binned", "name": "In bin", "type": "bool", "readonly": true }, { "key": "marks", "name": "Marked", "type": "text", "readonly": true }, { "key": "people", "name": "People", "type": "link", "link_to": "person", "readonly": true, "multiple": true }, { "key": "transaction_id", "name": "Recorded in Money", "type": "link", "link_to": "transaction", "readonly": true }, { "key": "event_id", "name": "In the calendar", "type": "link", "link_to": "event", "readonly": true } ], "seal": { "clear": [ "first_at", "last_at", "trashed_at", "sender_kind", "people", "transaction_id", "event_id" ], "blind": [ "subject" ], "blind_exact": [ "external_key", "sender_address" ] }, "instructions": "Imported email archive. Ingest and Gmail sync run in Rust. Cotton has no send or reply verb. Never create imported mail as a substitute for delivery.", "tables": [ { "name": "cotton_email_threads", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "external_key", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n external_key TEXT NOT NULL", "position": 2 }, { "name": "subject", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n subject TEXT", "position": 3 }, { "name": "first_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n first_at TEXT", "position": 4 }, { "name": "last_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n last_at TEXT", "position": 5 }, { "name": "email_count", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n email_count INTEGER NOT NULL DEFAULT 0", "position": 6 }, { "name": "summary", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary TEXT", "position": 7 }, { "name": "summary_updated_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary_updated_at TEXT", "position": 8 }, { "name": "summary_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n summary_by TEXT", "position": 9 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 10 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 11 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 12 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " trashed_at TEXT", "position": 13 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 14 }, { "name": "sender_address", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n sender_address TEXT", "position": 15 }, { "name": "sender_kind", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n sender_kind TEXT", "position": 16 }, { "name": "record_kind", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n record_kind TEXT", "position": 17 }, { "name": "amount_minor", "type": "INTEGER", "default": null, "nullable": true, "primary_key": false, "declaration": "\n amount_minor INTEGER", "position": 18 }, { "name": "currency", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n currency TEXT", "position": 19 }, { "name": "merchant", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n merchant TEXT", "position": 20 }, { "name": "record_on", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n record_on TEXT", "position": 21 }, { "name": "reference", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n reference TEXT", "position": 22 }, { "name": "record_reason", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n record_reason TEXT", "position": 23 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, external_key)", "position": 24 }, { "declaration": "\n CHECK ((record_kind IS NULL) OR (record_kind IN ('receipt', 'statement', 'ticket', 'booking', 'code', 'delivery', 'notice')))", "position": 25 }, { "declaration": "\n CHECK ((currency IS NULL) OR (length(currency) = 3 AND currency = upper(currency)))", "position": 26 }, { "declaration": "\n CHECK ((record_on IS NULL) OR (record_on GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'))", "position": 27 }, { "declaration": "\n CHECK ((sender_address IS NULL) OR (sender_address = lower(sender_address) AND length(sender_address) > 0))", "position": 28 }, { "declaration": "\n CHECK ((sender_kind IS NULL) OR (sender_kind IN ('person', 'service', 'junk')))", "position": 29 }, { "declaration": "\n CHECK (length(external_key) > 0)", "position": 30 }, { "declaration": "\n CHECK (email_count >= 0)", "position": 31 }, { "declaration": "\n CHECK ((summary IS NULL) OR (length(summary) <= 4000))", "position": 32 }, { "declaration": "\n CHECK ((summary_by IS NULL) OR (length(trim(summary_by)) > 0))", "position": 33 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 34 } ], "prefix": "CREATE TABLE cotton_email_threads (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_email_threads_workspace_recent ON cotton_email_threads (workspace_id, last_at DESC)", "CREATE INDEX idx_cotton_email_threads_sender_kind ON cotton_email_threads (workspace_id, sender_kind, last_at DESC)", "CREATE INDEX idx_cotton_email_threads_sender ON cotton_email_threads (workspace_id, sender_address) WHERE sender_address IS NOT NULL", "CREATE INDEX idx_cotton_email_threads_record_kind ON cotton_email_threads (workspace_id, record_kind, last_at DESC) WHERE record_kind IS NOT NULL", "CREATE INDEX idx_cotton_email_threads_merchant ON cotton_email_threads (workspace_id, id, merchant, trashed_at) WHERE merchant IS NOT NULL AND trashed_at IS NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_email_threads_author ON cotton_email_threads (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ], "card": { "face": "email", "fields": [ { "slot": "title", "column": "subject" }, { "slot": "subtitle", "column": "sender" }, { "slot": "body", "column": "preview" }, { "slot": "date", "column": "last_at", "form": "weekday_date" }, { "slot": "count", "column": "email_count" }, { "slot": "unread", "column": "read_state", "only": [ "unread" ] }, { "slot": "amount", "column": "amount_minor" }, { "slot": "people", "column": "people", "max": 3 } ] }, "picture": { "photo": "photo:b5cf213d649bc342c2915d314e56b4f4fbc12dabd589527e171f51fa674aa2ea", "object": "tool-email" }, "engine": "email", "voice_words": [ "merchant" ], "project": null, "order": null, "slip": { "title": "sender", "subtitle": "subject", "trailing": null, "photo": null, "toggle": null, "caption": { "columns": [ "last_at", "preview" ] }, "badge": { "column": "starred", "symbol": "star.fill", "spoken": "Starred" }, "unread": "read_state", "dye": "straw" }, "tile": { "face": "slip-list", "current": { "column": "last_at", "days": 2 } }, "page": [ { "heading": null, "columns": [ "subject", "sender", "marks", "email_count", "first_at", "last_at", "transaction_id", "event_id" ] }, { "heading": "Summary", "columns": [ "summary", "summary_by" ] }, { "heading": null, "columns": [ "trashed_at" ] } ], "page_parts": [ "title", "facts", "messages", "grid" ], "add": false, "record_route": "/email/[id]", "sort": { "column": "last_at", "descending": true }, "by_day": "last_at", "empty": { "title": "No email in this view", "message": "Email from connected accounts appears here when it matches this view." }, "conversation": { "table": "email", "links": [ "thread_id" ], "body": "body", "at": "sent_at", "mine": { "column": "direction", "values": [ "out" ] }, "media": "media", "can_send": false, "folds": true, "header_columns": [ "from_name", "from_email", "to_line", "cc_line", "subject" ] }, "delete": false, "links": [ { "label": "Senders", "table": "email_sender" }, { "label": "Junk senders", "table": "email_sender", "where": { "blocked": true } } ], "link_tiles": { "after": 4 }, "commands": [ { "id": "record_as_transaction", "label": "Record transaction", "kind": "create", "method": "records.recordAsTransaction", "bindings": { "threadId": "$id" }, "when": { "record_kind": [ "receipt", "statement" ], "transaction_id": null }, "receipt": "Recorded in Money", "does": "moves", "object": "folder" }, { "id": "add_to_calendar", "label": "Add event", "kind": "create", "method": "records.addToCalendar", "bindings": { "threadId": "$id" }, "when": { "record_kind": [ "ticket", "booking" ], "event_id": null }, "receipt": "Added to the calendar", "does": "moves", "object": "folder" }, { "id": "star", "label": "Star", "kind": "update", "verb": "update_email", "data": { "starred": true }, "bindings": { "threadId": "$id" }, "when": { "starred": false, "binned": false }, "receipt": "Starred", "undo": "unstar", "does": "completes", "object": "star" }, { "id": "unstar", "label": "Unstar", "kind": "update", "verb": "update_email", "data": { "starred": false }, "bindings": { "threadId": "$id" }, "when": { "starred": true, "binned": false }, "receipt": "Unstarred", "undo": "star", "object": "star" }, { "id": "archive", "label": "Archive", "kind": "update", "verb": "update_email", "data": { "inbox": false }, "bindings": { "threadId": "$id" }, "when": { "in_inbox": true, "binned": false }, "receipt": "Archived", "undo": "inbox", "object": "folder", "does": "puts-away" }, { "id": "inbox", "label": "Move to inbox", "kind": "update", "verb": "update_email", "data": { "inbox": true }, "bindings": { "threadId": "$id" }, "when": { "in_inbox": false, "binned": false }, "receipt": "Moved {name} to the inbox", "undo": "archive", "does": "moves", "object": "folder" }, { "id": "junk", "label": "Junk", "object": "cross", "kind": "update", "verb": "block_sender", "destructive": true, "confirm": "Mail from this sender goes to Junk from now on. Not junk brings it back.", "bindings": { "address": "sender_address" }, "when": { "sender_kind": { "not": "junk" }, "binned": false }, "receipt": "Moved {name} to Junk", "does": "destroys" }, { "id": "not_junk", "label": "Unblock", "kind": "update", "verb": "unblock_sender", "bindings": { "address": "sender_address" }, "when": { "sender_kind": "junk", "binned": false }, "receipt": "Moved {name} out of Junk", "does": "completes", "object": "stamp" }, { "id": "transaction", "label": "Open transaction", "object": "open", "kind": "open", "opens": "transaction_id" }, { "id": "event", "label": "Open event", "object": "open", "kind": "open", "opens": "event_id" } ], "slip_by": { "column": "record_kind", "slips": { "receipt": { "title": "merchant", "subtitle": "subject", "caption": { "columns": [ "last_at", "preview" ] } }, "statement": { "title": "merchant", "subtitle": "subject", "caption": { "columns": [ "last_at", "preview" ] } }, "ticket": { "title": "merchant", "subtitle": "subject", "caption": { "columns": [ "last_at", "preview" ] } }, "booking": { "title": "merchant", "subtitle": "subject", "caption": { "columns": [ "last_at", "preview" ] } }, "delivery": { "title": "merchant", "subtitle": "subject", "caption": { "columns": [ "last_at", "preview" ] } }, "code": { "title": "merchant", "subtitle": "subject", "caption": { "columns": [ "last_at", "preview" ] } } } }, "groups": { "stack": "slips" }, "tool": { "views": [ { "id": "today", "label": "Today", "visibility": "owner", "is_default": true, "read": { "table": "email_thread", "section": "today", "empty": { "line": "empty_views.email.today", "table": true } } }, { "id": "records", "label": "Records", "visibility": "owner", "is_default": false, "read": { "table": "email_thread", "where": { "sender_kind": "service" }, "empty": { "line": "empty_views.email.records", "table": true } } }, { "id": "people", "label": "People", "visibility": "owner", "is_default": false, "read": { "table": "email_thread", "where": { "sender_kind": "person" }, "empty": { "line": "empty_views.email.people", "table": true } } }, { "id": "junk", "label": "Junk", "visibility": "owner", "is_default": false, "read": { "table": "email_thread", "where": { "sender_kind": "junk" }, "empty": { "line": "empty_views.email.junk", "table": true } } }, { "id": "all", "label": "All", "visibility": "owner", "is_default": false, "read": { "table": "email_thread" } } ], "name": "Email", "purpose": "Your email conversations and attachments.", "key": "email", "icon": "mail", "card_stock": "rose", "route": "/email" }, "parts": { "shape": "desk", "head": { "facts": [ "sender" ] }, "links": [], "lists": [], "acts": { "more": [ "star", "unstar", "inbox", "not_junk", "record_as_transaction", "add_to_calendar", "transaction", "event" ], "away": "junk" }, "strip": [ { "column": "marks" }, { "column": "record_on" }, { "column": "amount_minor" }, { "column": "merchant" }, { "column": "reference" } ] }}