Cotton code
797 lines · 18.2 KB · JSONRaw
{  "format_version": 1,  "id": "todo",  "name": "Todo",  "plural": "Todos",  "visibility": "owner",  "title": "title",  "columns": [    {      "key": "title",      "type": "text",      "required": true,      "name": "Title",      "placeholder": "What needs doing?"    },    {      "key": "notes",      "type": "longtext",      "name": "Details"    },    {      "key": "status",      "type": "choice",      "choices": [        "open",        "done",        "dropped",        "missed"      ],      "default": "open",      "name": "Status",      "labels": {        "open": "Open",        "done": "Done",        "dropped": "Dropped",        "missed": "Missed"      }    },    {      "key": "due_at",      "type": "date",      "name": "Due",      "untimed": "due today"    },    {      "key": "snoozed_until",      "type": "date",      "format": "calendar-datetime",      "name": "Snoozed until",      "fact": true,      "reading": "Snoozed until {value}"    },    {      "key": "priority",      "type": "number",      "default": 0,      "name": "Priority"    },    {      "key": "completed_at",      "type": "date",      "readonly": true,      "name": "Completed"    },    {      "key": "recurrence_id",      "type": "link",      "readonly": true,      "name": "Repeat rule",      "link_to": "todo_recurrence",      "contributes": false    },    {      "key": "occurrence_at",      "name": "Occurrence at",      "type": "text",      "readonly": true    },    {      "key": "trashed_at",      "name": "Trashed at",      "type": "text",      "readonly": true    },    {      "key": "repeats",      "name": "Repeats",      "type": "text",      "readonly": true,      "placeholder": "Once",      "format": "repeat-rule",      "labels": {        "none": "Once",        "daily": "Daily",        "weekdays": "Every weekday",        "weekly": "Weekly",        "biweekly": "Every two weeks",        "monthly": "Monthly",        "yearly": "Yearly",        "custom": "Custom repeat",        "paused_daily": "Daily, paused",        "paused_weekdays": "Every weekday, paused",        "paused_weekly": "Weekly, paused",        "paused_biweekly": "Every two weeks, paused",        "paused_monthly": "Monthly, paused",        "paused_yearly": "Yearly, paused",        "paused_custom": "Custom repeat, paused"      },      "opens": {        "column": "recurrence_id",        "table": "todo_recurrence"      }    },    {      "key": "done_before",      "name": "Done before",      "type": "number",      "readonly": true,      "units": {        "one": "done once before",        "other": "done {n} times before",        "zero": ""      }    },    {      "key": "project",      "name": "Project",      "type": "link",      "link_to": "project"    },    {      "key": "people",      "name": "People",      "type": "link",      "link_to": "person",      "readonly": true,      "multiple": true,      "edges": true    },    {      "key": "source_inbox_id",      "name": "Capture",      "type": "link",      "link_to": "thought",      "readonly": true    }  ],  "instructions": "A todo is one thing to do. Status is open until it is done, or dropped when it will not be done; an earlier occurrence of a repeating todo still open when a later one is done becomes missed, never done. the due date is when it is wanted, and a snoozed todo stays out of sight until its snooze ends. A priority of 1 or more marks it as high priority. Never invent a due date the person did not give.",  "tables": [    {      "name": "cotton_todos",      "columns": [        {          "name": "id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": true,          "declaration": "\n    id TEXT PRIMARY KEY",          "position": 0        },        {          "name": "title",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    title TEXT NOT NULL",          "position": 1        },        {          "name": "notes",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    notes TEXT",          "position": 2        },        {          "name": "label",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    label TEXT",          "position": 3        },        {          "name": "status",          "type": "TEXT",          "default": "'open'",          "nullable": false,          "primary_key": false,          "declaration": "\n    status TEXT NOT NULL DEFAULT 'open'",          "position": 4        },        {          "name": "due_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    due_at TEXT",          "position": 5        },        {          "name": "snoozed_until",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    snoozed_until TEXT",          "position": 6        },        {          "name": "priority",          "type": "INTEGER",          "default": "0",          "nullable": false,          "primary_key": false,          "declaration": "\n    priority INTEGER NOT NULL DEFAULT 0",          "position": 7        },        {          "name": "completed_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    completed_at 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": "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": "recurrence_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    recurrence_id TEXT",          "position": 12        },        {          "name": "occurrence_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    occurrence_at TEXT",          "position": 13        },        {          "name": "workspace_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    workspace_id TEXT NOT NULL",          "position": 14        },        {          "name": "_hlc",          "type": "TEXT",          "default": "''",          "nullable": false,          "primary_key": false,          "declaration": "\n    _hlc TEXT NOT NULL DEFAULT ''",          "position": 15        },        {          "name": "_born",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    _born TEXT",          "position": 16        },        {          "name": "trashed_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " trashed_at TEXT",          "position": 17        }      ],      "constraints": [        {          "declaration": "\n    UNIQUE (recurrence_id, occurrence_at)",          "position": 18        },        {          "declaration": "\n    CHECK (status IN ('open', 'done', 'dropped', 'missed'))",          "position": 19        },        {          "declaration": "\n    FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n  ",          "position": 20        }      ],      "prefix": "CREATE TABLE cotton_todos (",      "suffix": ")",      "indexes": [        "CREATE INDEX idx_cotton_todos_open ON cotton_todos (workspace_id) WHERE status = 'open' AND trashed_at IS NULL",        "CREATE INDEX idx_cotton_todos_recurrence ON cotton_todos (recurrence_id) WHERE recurrence_id IS NOT NULL",        "CREATE INDEX idx_cotton_todos_workspace ON cotton_todos (workspace_id)",        "CREATE INDEX idx_cotton_todos_workspace_due ON cotton_todos (workspace_id, due_at)",        "CREATE INDEX IF NOT EXISTS idx_cotton_todos_author ON cotton_todos (substr(_hlc, 20), _hlc)"      ],      "full_text": [        "CREATE VIRTUAL TABLE fts_todos USING fts5(\n       title, notes, content = 'cotton_todos', content_rowid = 'rowid',\n       tokenize = 'unicode61 remove_diacritics 2'\n     )"      ],      "triggers": [        "CREATE TRIGGER fts_todos_ai AFTER INSERT ON cotton_todos WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_todos'), 0) BEGIN\n       INSERT INTO fts_todos (rowid, title, notes) VALUES (new.rowid, new.title, new.notes);\n     END",        "CREATE TRIGGER fts_todos_ad AFTER DELETE ON cotton_todos WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_todos'), 0) BEGIN\n       INSERT INTO fts_todos (fts_todos, rowid, title, notes) VALUES ('delete', old.rowid, old.title, old.notes);\n     END",        "CREATE TRIGGER fts_todos_au AFTER UPDATE OF title, notes ON cotton_todos\n       FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_todos'), 0) AND (new.title IS NOT old.title OR new.notes IS NOT old.notes) BEGIN\n       INSERT INTO fts_todos (fts_todos, rowid, title, notes) VALUES ('delete', old.rowid, old.title, old.notes);\n       INSERT INTO fts_todos (rowid, title, notes) VALUES (new.rowid, new.title, new.notes);\n     END"      ]    }  ],  "picture": {    "photo": "photo:a86576668bb7f4915eae3b9dd6f2e3b9cbd20b9e55f85fc7c12586b759858b0e",    "object": "tool-todos"  },  "builtin": true,  "engine": "todos",  "date": "due_at",  "project": "project",  "order": null,  "slip": {    "title": "title",    "subtitle": null,    "trailing": "due_at",    "photo": null,    "toggle": "status",    "byline": {      "column": "priority",      "words": {        "1": "high priority",        "2": "high priority",        "3": "high priority"      }    },    "badge": {      "column": "recurrence_id",      "symbol": "repeat",      "spoken": "Repeats"    },    "dye": "pink"  },  "tile": {    "face": "slip-list"  },  "page": [    {      "heading": null,      "columns": [        "title",        "due_at",        "repeats",        "snoozed_until",        "completed_at",        "project",        "people",        "source_inbox_id"      ]    },    {      "heading": "Details",      "columns": [        "notes"      ]    },    {      "heading": null,      "columns": [],      "when": {        "column": "status",        "values": [          "dropped"        ]      },      "note": "Dropped"    }  ],  "record_route": "/todos/todo/[id]",  "record_kind": "todo",  "filing_rank": 1,  "made_by_verb": true,  "role": "todo",  "projects_read": {    "kind": "todo",    "read": "todo",    "families": [      "todos",      "projects"    ]  },  "group": {    "column": "status",    "sections": [      {        "heading": null,        "values": [          "open"        ],        "closed": false      },      {        "heading": "Done",        "values": [          "done"        ],        "closed": false      },      {        "heading": "Dropped",        "values": [          "dropped"        ],        "closed": false      },      {        "heading": "Missed",        "values": [          "missed"        ],        "closed": false      }    ]  },  "upcoming": {    "dates": [      "due_at",      "snoozed_until"    ],    "undated": "No date",    "late": "Late",    "later": "Later",    "series": "recurrence_id"  },  "empty": {    "title": "No todos yet"  },  "create": {    "label": "New todo",    "dated": "due_at"  },  "deletion": {    "bin": true  },  "links": [    {      "label": "Deleted",      "table": "bin",      "where": {        "table": "todo"      }    }  ],  "commands": [    {      "id": "done",      "label": "Mark done",      "kind": "update",      "verb": "update_todo",      "data": {        "status": "done"      },      "bindings": {        "id": "$id"      },      "when": {        "status": "open"      },      "receipt": "Done",      "undo": "reopen",      "does": "completes"    },    {      "id": "reopen",      "label": "Reopen",      "kind": "update",      "verb": "update_todo",      "data": {        "status": "open"      },      "bindings": {        "id": "$id"      },      "when": {        "status": "done"      },      "receipt": "Reopened",      "undo": "done",      "object": "restore"    },    {      "id": "drop",      "label": "Drop",      "kind": "update",      "verb": "update_todo",      "data": {        "status": "dropped"      },      "bindings": {        "id": "$id"      },      "when": {        "status": "open"      },      "receipt": "Dropped",      "undo": "take_up",      "does": "puts-away"    },    {      "id": "take_up",      "label": "Reopen",      "kind": "update",      "verb": "update_todo",      "data": {        "status": "open"      },      "bindings": {        "id": "$id"      },      "when": {        "status": "dropped"      },      "receipt": "Reopened",      "undo": "drop",      "object": "restore"    },    {      "id": "delete",      "label": "Delete",      "kind": "delete",      "verb": "delete_record",      "data": {        "table": "todo"      },      "confirm": "Undo on the receipt brings it back.",      "bindings": {        "id": "$id"      },      "receipt": "Deleted",      "does": "destroys"    },    {      "id": "open-people",      "label": "Open people",      "kind": "open",      "opens": "people"    },    {      "id": "open-repeat-rule",      "label": "Open repeat rule",      "kind": "open",      "opens": "recurrence_id"    }  ],  "groups": {    "stack": "slips"  },  "views": [    {      "face": "today",      "name": "Today"    },    {      "face": "upcoming",      "name": "Upcoming"    }  ],  "card": {    "face": "todo.card",    "fields": [      {        "slot": "check",        "column": "status",        "label": "label.face.todo.check"      },      {        "slot": "title",        "column": "title"      },      {        "slot": "body",        "column": "notes"      },      {        "slot": "date",        "column": "due_at",        "form": "weekday_date"      },      {        "slot": "group"      },      {        "slot": "state",        "column": "status",        "only": [          "dropped",          "missed"        ]      }    ],    "corner": [      {        "column": "due_at",        "form": "late",        "behind": 1      },      {        "column": "due_at",        "form": "late",        "within": 0,        "line": "corner.today"      },      {        "column": "due_at",        "form": "late",        "within": 1,        "line": "corner.tomorrow"      },      {        "column": "due_at",        "form": "late",        "within": 3650      },      {        "column": "completed_at",        "form": "relative",        "within": 0,        "line": "corner.done",        "done": true      }    ],    "art": "pace",    "pace": {      "date": "due_at",      "done": {        "column": "status",        "values": [          "done",          "dropped",          "missed"        ]      },      "repeat": "recurrence_id"    },    "offers": [      "todo.card",      "todo"    ]  },  "tool": {    "views": [      {        "id": "done",        "label": "Done",        "visibility": "owner",        "is_default": false,        "read": {          "table": "todo",          "section": "done"        }      },      {        "id": "late",        "label": "Late",        "visibility": "owner",        "is_default": false,        "read": {          "table": "todo",          "section": "late"        }      },      {        "id": "today",        "label": "Today",        "visibility": "owner",        "is_default": true,        "read": {          "table": "todo",          "section": "today",          "empty": {            "title": "Nothing due today.",            "counts": {              "late": "{count} late."            }          }        }      },      {        "id": "upcoming",        "label": "Upcoming",        "visibility": "owner",        "is_default": false,        "read": {          "table": "todo",          "section": "upcoming"        }      },      {        "id": "all",        "label": "All",        "visibility": "owner",        "lead": "late",        "is_default": false,        "read": {          "table": "todo"        }      }    ],    "name": "Todos",    "purpose": "What you need to do and when it is due.",    "key": "todos",    "icon": "circle-check",    "card_stock": "sage",    "route": "/todos",    "figures": [      {        "read": "openTodos",        "many": "{n} open"      }    ]  },  "parts": {    "shape": "sheet",    "head": {      "facts": [        "snoozed_until"      ],      "state": "status"    },    "links": [      "people",      "project"    ],    "body": "notes",    "lists": [],    "acts": {      "main": "done",      "more": [        "reopen",        "drop",        "take_up",        "open-people",        "open-repeat-rule"      ],      "away": "delete"    },    "cards": [      {        "column": "priority",        "object": "flag"      },      {        "column": "due_at"      },      {        "column": "notes",        "width": "full"      }    ],    "strip": []  }}