Cotton code
832 lines · 21.1 KB · JSONRaw
{  "format_version": 1,  "id": "event",  "name": "Event",  "plural": "Calendar",  "record_route": "/calendar/event/[id]",  "linked_when": { "scheduled": "starts {when}" },  "picture": {"photo": "photo:a4c0a1a6ab854cbc99f2481f788b16b76214b2133e43df2502d694498861624f", "object": "tool-calendar"},  "builtin": true,  "links": [    {      "label": "Deleted",      "table": "bin",      "where": {        "table": "event"      }    }  ],  "deletion": {    "bin": true,    "confirm": "Delete",    "asks": true  },  "engine": "calendar",  "role": "event",  "filing_rank": 3,  "record_kind": "event",  "views": [{"face": "nextUp", "name": "Next up", "sizes": ["small", "medium", "large"]}, {"face": "month", "name": "Month", "sizes": ["small", "medium", "large"], "opens": "/calendar/month"}],  "columns": [    {      "key": "title",      "type": "text",      "required": true,      "name": "Title"    },    {      "key": "starts_at",      "name": "Starts",      "type": "date",      "required": true    },    {      "key": "ends_at",      "name": "Ends",      "type": "date"    },    {      "key": "all_day",      "name": "All day",      "type": "bool"    },    {      "key": "on_google",      "name": "On Google",      "type": "bool"    },    {      "key": "location",      "type": "place",      "name": "Where",      "place": {"id": "event_place", "country": "country", "zone": "timezone"}    },    {      "key": "event_place",      "name": "Place",      "type": "text",      "readonly": true    },    {      "key": "country",      "name": "Country",      "type": "text",      "readonly": true    },    {      "key": "timezone",      "name": "Time zone",      "type": "text",      "readonly": true    },    {      "key": "notes",      "type": "longtext",      "name": "Notes"    },    {      "key": "project",      "name": "Project",      "type": "link",      "link_to": "project"    },    {      "key": "people",      "edges": true,      "name": "Who",      "type": "link",      "link_to": "person",      "multiple": true,      "readonly": true    },    {      "key": "guest_responses",      "name": "Replies",      "type": "longtext",      "readonly": true    },    {      "key": "my_response",      "name": "Your reply",      "type": "choice",      "choices": [        "needs_action",        "accepted",        "tentative",        "declined"      ],      "format": "words",      "shown_when": {        "column": "invited",        "values": [          "invited"        ]      }    },    {      "key": "rrule",      "name": "Repeats",      "type": "text",      "format": "repeat-rule"    },    {      "key": "calendar_name",      "name": "Calendar",      "type": "text",      "readonly": true    },    {      "key": "source",      "name": "Source",      "type": "text",      "readonly": true,      "format": "words"    },    {      "key": "sync_state",      "name": "Sync",      "type": "text",      "readonly": true,      "format": "words"    },    {      "key": "created_at",      "name": "Added",      "type": "date",      "readonly": true    },    {      "key": "trashed_at",      "name": "Removed",      "type": "date"    },    {      "key": "day",      "name": "Day",      "type": "date",      "readonly": true    },    {      "key": "start_time",      "name": "Starts",      "type": "time",      "readonly": true    },    {      "key": "collection_id",      "name": "Calendar",      "type": "text",      "readonly": true    },    {      "key": "invited",      "name": "Invited",      "type": "choice",      "readonly": true,      "choices": [        "invited"      ],      "labels": {        "invited": "Invited"      }    },    {      "key": "email_thread_id",      "name": "From mail",      "type": "link",      "link_to": "email_thread",      "readonly": true    }  ],  "title": "title",  "archived": "trashed_at",  "date": "starts_at",  "project": "project",  "order": null,  "slip": {    "title": "title",    "subtitle": "location",    "trailing": "starts_at",    "photo": null,    "toggle": null,    "caption": {      "dates": [],      "columns": [        "starts_at",        "rrule"      ],      "status": "my_response"    }  },  "tile": {    "face": "slip-list",    "current": {      "column": "starts_at",      "days": 0    }  },  "page": [    {      "heading": null,      "columns": [        "title"      ]    },    {      "heading": null,      "columns": [        "starts_at",        "ends_at",        "all_day",        "rrule",        "my_response",            "on_google"          ]    },    {      "heading": null,      "columns": [        "location"      ]    },    {      "heading": "Who",      "columns": [        "people",        "guest_responses"      ]    },    {      "heading": "Notes",      "columns": [        "notes"      ]    },    {      "heading": "Details",      "columns": [        "calendar_name",        "source",        "project",        "email_thread_id"      ]    },    {"heading": "Meetings", "list": {"table": "meeting", "link": "event_id", "limit": 3}},    {"heading": "Mail", "list": {"table": "email_thread", "link": "event_id", "limit": 3}}  ],  "sort": {    "column": "starts_at"  },  "day_grouping": "starts_at",  "instructions": "An event is something on the calendar with a start and usually an end; an all-day event ignores the clock time. A repeating event carries an iCal repeat rule, and your reply only applies to invitations someone else sent. Always give times with an explicit time zone, and never guess a location or end time that was not stated.",  "create": {    "label": "New event",    "dated": "starts_at",    "path": "/calendar/event/edit"  },  "empty": {    "title": "Nothing on the calendar yet.",    "message": "Events from your synced calendars land here, and New event adds one."  },  "kept_by": { "when": "sync_state", "says": "Kept in step with Google Calendar" },  "parts": {  "shape": "desk",  "head": {    "facts": []  },  "links": [],  "lists": [    {      "table": "meeting",      "relation": "event_id",      "heading": "Meetings"    },    {      "table": "email_thread",      "relation": "event_id",      "heading": "Mail"    }  ],  "acts": {    "more": [      "open-email-thread-id",      "open-people",      "open-project"    ],    "away": "delete"  },  "cards": [    {      "column": "start_time",      "label": "time"    },    {      "column": "starts_at",      "label": "when",      "until": "ends_at"    },    {      "column": "location",      "label": "where"    },    {      "column": "my_response"    },    {      "column": "guest_responses"    },    {      "column": "rrule",      "object": "ring",      "label": "repeats"    },    {      "column": "calendar_name",      "label": "calendar"    }  ],  "strip": [],  "body": "notes"},  "commands": [  {    "id": "delete",    "label": "Delete",    "kind": "delete",    "verb": "delete_record",    "data": {      "table": "event"    },    "bindings": {      "id": "$id"    },    "when": {      "rrule": [        null,        ""      ]    },    "confirm": "Undo on the receipt brings it back.",    "receipt": "Deleted",    "does": "destroys"  },  {    "id": "open-email-thread-id",    "label": "Open from mail",    "kind": "open",    "opens": "email_thread_id"  },  {    "id": "open-people",    "label": "Open who",    "kind": "open",    "opens": "people"  },  {    "id": "open-project",    "label": "Open project",    "kind": "open",    "opens": "project"  }],  "tool": {    "name": "Calendar",    "key": "calendar",    "icon": "calendar-days",    "card_stock": "sage",    "route": "/calendar",    "figures": [      {        "read": "eventsLeftToday",        "many": "{n} left today"      }    ]  ,"purpose":"Events, appointments and time you have planned."},  "tables": [    {      "name": "cotton_events",      "columns": [        {          "name": "id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": true,          "declaration": "\n    id TEXT PRIMARY KEY",          "position": 0        },        {          "name": "collection_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    collection_id TEXT NOT NULL",          "position": 1        },        {          "name": "title",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    title TEXT NOT NULL",          "position": 2        },        {          "name": "notes",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    notes TEXT",          "position": 3        },        {          "name": "starts_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    starts_at TEXT NOT NULL",          "position": 4        },        {          "name": "ends_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    ends_at TEXT",          "position": 5        },        {          "name": "all_day",          "type": "INTEGER",          "default": "0",          "nullable": false,          "primary_key": false,          "declaration": "\n    all_day INTEGER NOT NULL DEFAULT 0",          "position": 6        },        {          "name": "rrule",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    rrule TEXT",          "position": 7        },        {          "name": "location",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    location TEXT",          "position": 8        },        {          "name": "source_inbox_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    source_inbox_id TEXT",          "position": 9        },        {          "name": "gcal_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    gcal_id TEXT",          "position": 10        },        {          "name": "gcal_etag",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    gcal_etag TEXT",          "position": 11        },        {          "name": "sync_state",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    sync_state TEXT",          "position": 12        },        {          "name": "organizer_is_self",          "type": "INTEGER",          "default": "1",          "nullable": false,          "primary_key": false,          "declaration": "\n    organizer_is_self INTEGER NOT NULL DEFAULT 1",          "position": 13        },        {          "name": "my_response",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    my_response TEXT",          "position": 14        },        {          "name": "created_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    created_at TEXT NOT NULL",          "position": 15        },        {          "name": "updated_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    updated_at TEXT NOT NULL",          "position": 16        },        {          "name": "_hlc",          "type": "TEXT",          "default": "''",          "nullable": false,          "primary_key": false,          "declaration": "\n    _hlc TEXT NOT NULL DEFAULT ''",          "position": 17        },        {          "name": "series_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " series_id TEXT",          "position": 18        },        {          "name": "original_starts_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " original_starts_at TEXT",          "position": 19        },        {          "name": "exdates",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " exdates TEXT CHECK (exdates IS NULL OR json_type(exdates) = 'array')",          "position": 20        },        {          "name": "trashed_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " trashed_at TEXT",          "position": 21        },        {          "name": "erase_requested_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    erase_requested_at TEXT",          "position": 22        },        {          "name": "_born",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    _born TEXT",          "position": 23        },        {          "name": "ical_uid",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    ical_uid TEXT",          "position": 24        },        {          "name": "account",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    account TEXT",          "position": 25        },        {          "name": "on_google",          "type": "INTEGER",          "default": "0",          "nullable": false,          "primary_key": false,          "declaration": "\n    on_google INTEGER NOT NULL DEFAULT 0",          "position": 26        },        {          "name": "event_place",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " event_place TEXT",          "position": 27        },        {          "name": "country",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " country TEXT",          "position": 28        },        {          "name": "timezone",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " timezone TEXT",          "position": 29        }      ],      "constraints": [        {          "declaration": "\n    CHECK (on_google IN (0, 1))",          "position": 30        },        {          "declaration": "\n    CHECK (my_response IN ('needs_action', 'accepted', 'declined', 'tentative'))",          "position": 31        },        {          "declaration": "\n    CHECK (sync_state IN ('synced', 'pending', 'conflict'))",          "position": 32        },        {          "declaration": "\n    FOREIGN KEY (collection_id) REFERENCES cotton_collections(id)\n  ",          "position": 33        }      ],      "prefix": "CREATE TABLE cotton_events (",      "suffix": ")",      "indexes": [        "CREATE INDEX idx_cotton_events_collection ON cotton_events (collection_id)",        "CREATE INDEX idx_cotton_events_range ON cotton_events (collection_id, starts_at)",        "CREATE UNIQUE INDEX uq_cotton_events_gcal_id ON cotton_events (account, gcal_id) WHERE gcal_id IS NOT NULL",        "CREATE INDEX idx_cotton_events_series ON cotton_events (series_id) WHERE series_id IS NOT NULL",        "CREATE INDEX idx_cotton_events_trashed ON cotton_events (trashed_at) WHERE trashed_at IS NOT NULL",        "CREATE INDEX idx_cotton_events_ical_uid ON cotton_events (ical_uid, original_starts_at) WHERE ical_uid IS NOT NULL",        "CREATE INDEX IF NOT EXISTS idx_cotton_events_author ON cotton_events (substr(_hlc, 20), _hlc)"      ],      "full_text": [        "CREATE VIRTUAL TABLE fts_events USING fts5(\n       title, notes, location, content = 'cotton_events', content_rowid = 'rowid',\n       tokenize = 'unicode61 remove_diacritics 2'\n     )"      ],      "triggers": [        "CREATE TRIGGER fts_events_ai AFTER INSERT ON cotton_events WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_events'), 0) BEGIN\n       INSERT INTO fts_events (rowid, title, notes, location) VALUES (new.rowid, new.title, new.notes, new.location);\n     END",        "CREATE TRIGGER fts_events_ad AFTER DELETE ON cotton_events WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_events'), 0) BEGIN\n       INSERT INTO fts_events (fts_events, rowid, title, notes, location) VALUES ('delete', old.rowid, old.title, old.notes, old.location);\n     END",        "CREATE TRIGGER fts_events_au AFTER UPDATE OF title, notes, location ON cotton_events\n       FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_events'), 0) AND (new.title IS NOT old.title OR new.notes IS NOT old.notes OR new.location IS NOT old.location) BEGIN\n       INSERT INTO fts_events (fts_events, rowid, title, notes, location) VALUES ('delete', old.rowid, old.title, old.notes, old.location);\n       INSERT INTO fts_events (rowid, title, notes, location) VALUES (new.rowid, new.title, new.notes, new.location);\n     END"      ]    },    {      "name": "cotton_event_attendees",      "columns": [        {          "name": "id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": true,          "declaration": "\n    id TEXT PRIMARY KEY",          "position": 0        },        {          "name": "event_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    event_id TEXT NOT NULL",          "position": 1        },        {          "name": "email",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    email TEXT",          "position": 2        },        {          "name": "phone",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    phone TEXT",          "position": 3        },        {          "name": "display_name",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    display_name TEXT",          "position": 4        },        {          "name": "response",          "type": "TEXT",          "default": "'needs_action'",          "nullable": false,          "primary_key": false,          "declaration": "\n    response TEXT NOT NULL DEFAULT 'needs_action'",          "position": 5        },        {          "name": "created_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    created_at TEXT NOT NULL",          "position": 6        },        {          "name": "updated_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    updated_at TEXT NOT NULL",          "position": 7        },        {          "name": "_hlc",          "type": "TEXT",          "default": "''",          "nullable": false,          "primary_key": false,          "declaration": "\n    _hlc TEXT NOT NULL DEFAULT ''",          "position": 8        },        {          "name": "_born",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    _born TEXT",          "position": 9        }      ],      "constraints": [        {          "declaration": "\n    CHECK (response IN ('needs_action', 'accepted', 'declined', 'tentative'))",          "position": 10        },        {          "declaration": "\n    FOREIGN KEY (event_id) REFERENCES cotton_events(id)\n  ",          "position": 11        }      ],      "prefix": "CREATE TABLE cotton_event_attendees (",      "suffix": ")",      "indexes": [        "CREATE INDEX idx_cotton_event_attendees_event ON cotton_event_attendees (event_id)",        "CREATE INDEX IF NOT EXISTS idx_cotton_event_attendees_author ON cotton_event_attendees (substr(_hlc, 20), _hlc)"      ],      "full_text": [],      "triggers": []    }  ]}