Cotton code
942 lines · 23.2 KB · JSONRaw
{  "format_version": 1,  "id": "meeting",  "name": "Meeting",  "plural": "Meetings",  "record_route": "/meetings/meeting/[id]",  "picture": {    "photo": "photo:2edc49d8f3a823b4359f5d619b12e0af2f23d1c30236c98dba621bafc51cbb97",    "object": "tool-meetings"  },  "builtin": true,  "engine": "meetings",  "columns": [    {      "key": "title",      "type": "text"    },    {      "key": "status",      "type": "choice",      "choices": [        "recording",        "uploading",        "queued",        "transcribing",        "summarizing",        "ready",        "failed"      ],      "readonly": true,      "labels": {        "recording": "Recording",        "uploading": "Waiting for the recording",        "queued": "Turning it into text…",        "transcribing": "Turning it into text…",        "summarizing": "Turning it into text…",        "ready": "Ready",        "failed": "Did not work"      },      "name": "State",      "shown_when": {        "column": "status",        "values": [          "recording",          "uploading",          "queued",          "transcribing",          "summarizing",          "failed"        ]      }    },    {      "key": "source",      "type": "choice",      "choices": [        "recorded",        "imported"      ],      "readonly": true,      "labels": {        "recorded": "Recorded here",        "imported": "Imported audio"      },      "name": "From"    },    {      "key": "started_at",      "name": "Started",      "type": "date",      "readonly": true,      "fact": true,      "reading": "{datetime}"    },    {      "key": "ended_at",      "name": "Ended",      "type": "date",      "readonly": true    },    {      "key": "duration_seconds",      "name": "Length",      "type": "number",      "readonly": true,      "format": "duration"    },    {      "key": "language",      "type": "text",      "readonly": true    },    {      "key": "event_id",      "name": "Event",      "type": "link",      "link_to": "event",      "readonly": true    },    {      "key": "summary_md",      "name": "What was said",      "type": "longtext",      "readonly": true,      "markdown": true    },    {      "key": "audio_deleted_at",      "name": "Audio deleted",      "type": "date",      "readonly": true,      "fact": true,      "reading": "Audio deleted {date}"    },    {      "key": "failed_stage",      "name": "Stopped while",      "type": "choice",      "choices": [        "submit",        "transcribe",        "summarize"      ],      "readonly": true,      "labels": {        "submit": "Sending the recording",        "transcribe": "Turning it into text",        "summarize": "Writing the summary"      }    },    {      "key": "error_code",      "name": "Problem",      "type": "text",      "readonly": true    },    {      "key": "segments",      "name": "Recording",      "type": "file",      "readonly": true    },    {      "key": "summary_by",      "name": "Summary by",      "type": "text",      "readonly": true    },    {      "key": "transcript",      "name": "Transcript",      "type": "longtext",      "readonly": true,      "placeholder": "No transcript",      "shown_when": {        "column": "status",        "values": [          "ready"        ]      },      "presentation": "turns",      "markdown": true    },    {      "key": "decisions",      "name": "Decisions",      "type": "longtext",      "readonly": true    },    {      "key": "questions",      "name": "Questions and answers",      "type": "longtext",      "readonly": true    },    {      "key": "speakers",      "name": "Speakers",      "type": "longtext",      "readonly": true    },    {      "key": "status_changed_at",      "name": "State since",      "type": "date",      "readonly": true    },    {      "key": "waiting_to_upload",      "name": "Waiting to upload",      "type": "bool",      "readonly": true    },    {      "key": "waiting_for",      "name": "Waiting for",      "type": "text",      "readonly": true    },    {      "key": "failure_message",      "name": "Problem",      "type": "longtext",      "readonly": true    },    {      "key": "lost_segments",      "name": "Missing audio",      "type": "longtext",      "readonly": true    },    {      "key": "projects",      "name": "Projects",      "type": "link",      "link_to": "project",      "readonly": true    },    {      "key": "people",      "name": "People",      "type": "link",      "link_to": "person",      "multiple": true,      "readonly": true    }  ],  "title": "title",  "date": "started_at",  "project": "projects",  "order": null,  "slip": {    "title": "title",    "subtitle": "duration_seconds",    "trailing": "started_at",    "photo": null,    "toggle": null,    "player": "segments",    "caption": {      "dates": [],      "fields": [        "started_at",        "status",        "lost_segments"      ]    }  },  "tile": {    "face": "slip-list"  },  "page": [    {      "heading": null,      "columns": [        "title"      ]    },    {      "heading": null,      "when": {        "column": "status",        "values": [          "failed"        ]      },      "note": "This recording did not work",      "ink": "red",      "commands": [        "retry",        "retry_summary"      ]    },    {      "heading": null,      "when": {        "column": "status",        "values": [          "uploading"        ]      },      "hand": [        "waiting_for"      ]    },    {      "heading": null,      "when": {        "column": "status",        "values": [          "queued",          "transcribing",          "summarizing"        ]      },      "note": "Turning it into text…"    },    {      "heading": null,      "when": {        "column": "status",        "values": [          "recording"        ]      },      "note": "Recording"    },    {      "heading": null,      "columns": [        "started_at",        "duration_seconds"      ],      "role": "facts"    },    {      "heading": "Recording",      "columns": [        "segments",        "audio_deleted_at",        "lost_segments"      ]    },    {      "heading": "Summary",      "columns": [        "summary_md"      ]    },    {      "heading": "Decisions",      "columns": [        "decisions"      ]    },    {      "heading": "Questions and answers",      "columns": [        "questions"      ]    },    {      "heading": "Transcript",      "columns": [        "transcript"      ],      "role": "main"    },    {      "heading": "Who spoke",      "columns": [        "people",        "speakers"      ]    },    {      "heading": "Details",      "columns": [        "source",        "event_id",        "ended_at",        "status_changed_at",        "waiting_to_upload",        "failure_message",        "failed_stage",        "summary_by"      ],      "role": "side"    },    {      "heading": "Filed under",      "columns": [        "projects"      ]    }  ],  "sort": {    "column": "started_at",    "descending": true  },  "day_grouping": "started_at",  "instructions": "A meeting is a recorded or imported conversation that is transcribed and summarised. Status moves from recording through transcribing and summarizing to ready, or failed at a named stage. The summary and decisions come from the transcript; quote what was said and never add decisions nobody made. The recording column is the meeting's audio, answered as its media key; it is empty once the audio was deleted (audio_deleted_at), and nothing plays it then.",  "empty": {    "title": "No meetings yet",    "message": "Record a conversation or import audio to keep its transcript and summary."  },  "create": {    "label": "Record a meeting",    "path": "/meetings/record"  },  "links": [    {      "label": "Import audio",      "table": "meeting",      "path": "/meetings?import=1"    },    {      "label": "Deleted",      "table": "bin",      "where": {        "table": "meeting"      }    }  ],  "deletion": {    "bin": true  },  "commands": [    {      "id": "retry",      "label": "Try again",      "object": "retry",      "kind": "update",      "verb": "update_meeting",      "data": {        "retry": "transcribe"      },      "bindings": {        "id": "$id"      },      "when": {        "status": "failed",        "failed_stage": [          "submit",          "transcribe"        ]      },      "receipt": "Trying again"    },    {      "id": "retry_summary",      "label": "Try again",      "object": "retry",      "kind": "update",      "verb": "update_meeting",      "data": {        "retry": "summarize"      },      "bindings": {        "id": "$id"      },      "when": {        "status": "failed",        "failed_stage": "summarize"      },      "receipt": "Trying again"    },    {      "id": "delete",      "label": "Delete",      "kind": "delete",      "verb": "delete_record",      "data": {        "table": "meeting"      },      "bindings": {        "id": "$id"      },      "confirm": "Undo on the receipt brings it back.",      "receipt": "Deleted",      "does": "destroys"    }  ],  "add": false,  "parts": {    "shape": "desk",    "head": {      "facts": [        "started_at",        "audio_deleted_at"      ]    },    "links": [      "event_id",      "projects",      "people"    ],    "body": "summary_md",    "lists": [],    "acts": {      "more": [        "retry",        "retry_summary"      ],      "away": "delete"    },    "strip": [      {        "column": "transcript"      },      {        "column": "duration_seconds"      },      {        "column": "source"      },      {        "column": "failure_message"      },      {        "column": "lost_segments"      }    ]  },  "tool": {    "name": "Meetings",    "key": "meetings",    "icon": "audio-lines",    "card_stock": "sage",    "route": "/meetings"  ,"purpose":"Meeting recordings, transcripts and notes."},  "tables": [    {      "name": "cotton_meetings",      "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": "title",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    title TEXT",          "position": 2        },        {          "name": "status",          "type": "TEXT",          "default": "'uploading'",          "nullable": false,          "primary_key": false,          "declaration": "\n    status TEXT NOT NULL DEFAULT 'uploading'",          "position": 3        },        {          "name": "source",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    source TEXT NOT NULL",          "position": 4        },        {          "name": "started_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    started_at TEXT NOT NULL",          "position": 5        },        {          "name": "ended_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    ended_at TEXT",          "position": 6        },        {          "name": "duration_seconds",          "type": "INTEGER",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    duration_seconds INTEGER",          "position": 7        },        {          "name": "language",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    language TEXT",          "position": 8        },        {          "name": "event_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    event_id TEXT",          "position": 9        },        {          "name": "speakers",          "type": "TEXT",          "default": "'[]'",          "nullable": false,          "primary_key": false,          "declaration": "\n    speakers TEXT NOT NULL DEFAULT '[]'",          "position": 10        },        {          "name": "summary_md",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    summary_md TEXT",          "position": 11        },        {          "name": "decisions",          "type": "TEXT",          "default": "'[]'",          "nullable": false,          "primary_key": false,          "declaration": "\n    decisions TEXT NOT NULL DEFAULT '[]'",          "position": 12        },        {          "name": "vendor",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    vendor TEXT",          "position": 13        },        {          "name": "vendor_job_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    vendor_job_id TEXT",          "position": 14        },        {          "name": "poll_attempts",          "type": "INTEGER",          "default": "0",          "nullable": false,          "primary_key": false,          "declaration": "\n    poll_attempts INTEGER NOT NULL DEFAULT 0",          "position": 15        },        {          "name": "status_changed_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    status_changed_at TEXT NOT NULL",          "position": 16        },        {          "name": "audio_deleted_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    audio_deleted_at TEXT",          "position": 17        },        {          "name": "failed_stage",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    failed_stage TEXT",          "position": 18        },        {          "name": "error_code",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    error_code TEXT",          "position": 19        },        {          "name": "segments",          "type": "TEXT",          "default": "'[]'",          "nullable": false,          "primary_key": false,          "declaration": "\n    segments TEXT NOT NULL DEFAULT '[]'",          "position": 20        },        {          "name": "created_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    created_at TEXT NOT NULL",          "position": 21        },        {          "name": "updated_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    updated_at TEXT NOT NULL",          "position": 22        },        {          "name": "_hlc",          "type": "TEXT",          "default": "''",          "nullable": false,          "primary_key": false,          "declaration": "\n    _hlc TEXT NOT NULL DEFAULT ''",          "position": 23        },        {          "name": "_born",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    _born TEXT",          "position": 24        },        {          "name": "trashed_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    trashed_at TEXT",          "position": 25        },        {          "name": "event_database",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    event_database TEXT CHECK (event_database IS NULL OR length(event_database) > 0)",          "position": 26        }      ],      "constraints": [        {          "declaration": "\n    CHECK ((duration_seconds IS NULL) OR (duration_seconds >= 0))",          "position": 27        },        {          "declaration": "\n    CHECK ((status = 'failed') = (failed_stage IS NOT NULL))",          "position": 28        },        {          "declaration": "\n    CHECK (failed_stage IS NULL OR failed_stage IN ('submit', 'transcribe', 'summarize'))",          "position": 29        },        {          "declaration": "\n    CHECK (poll_attempts >= 0)",          "position": 30        },        {          "declaration": "\n    CHECK (source IN ('recorded', 'imported'))",          "position": 31        },        {          "declaration": "\n    CHECK (status IN ('recording', 'uploading', 'queued', 'transcribing', 'summarizing', 'ready', 'failed'))",          "position": 32        },        {          "declaration": "\n    FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n  ",          "position": 33        }      ],      "prefix": "CREATE TABLE cotton_meetings (",      "suffix": ")",      "indexes": [        "CREATE INDEX idx_cotton_meetings_event ON cotton_meetings (event_id) WHERE event_id IS NOT NULL",        "CREATE INDEX idx_cotton_meetings_pipeline ON cotton_meetings (status, status_changed_at) WHERE status IN ('transcribing', 'summarizing')",        "CREATE INDEX idx_cotton_meetings_workspace_started ON cotton_meetings (workspace_id, started_at DESC)",        "CREATE INDEX IF NOT EXISTS idx_cotton_meetings_author ON cotton_meetings (substr(_hlc, 20), _hlc)"      ],      "full_text": [        "CREATE VIRTUAL TABLE fts_meetings USING fts5(\n       title, summary_md, content = 'cotton_meetings', content_rowid = 'rowid',\n       tokenize = 'unicode61 remove_diacritics 2'\n     )"      ],      "triggers": [        "CREATE TRIGGER fts_meetings_ai AFTER INSERT ON cotton_meetings WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_meetings'), 0) BEGIN\n       INSERT INTO fts_meetings (rowid, title, summary_md) VALUES (new.rowid, new.title, new.summary_md);\n     END",        "CREATE TRIGGER fts_meetings_ad AFTER DELETE ON cotton_meetings WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_meetings'), 0) BEGIN\n       INSERT INTO fts_meetings (fts_meetings, rowid, title, summary_md) VALUES ('delete', old.rowid, old.title, old.summary_md);\n     END",        "CREATE TRIGGER fts_meetings_au AFTER UPDATE OF title, summary_md ON cotton_meetings\n       FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_meetings'), 0) AND (new.title IS NOT old.title OR new.summary_md IS NOT old.summary_md) BEGIN\n       INSERT INTO fts_meetings (fts_meetings, rowid, title, summary_md) VALUES ('delete', old.rowid, old.title, old.summary_md);\n       INSERT INTO fts_meetings (rowid, title, summary_md) VALUES (new.rowid, new.title, new.summary_md);\n     END"      ]    },    {      "name": "cotton_meeting_utterances",      "columns": [        {          "name": "id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": true,          "declaration": "\n    id TEXT PRIMARY KEY",          "position": 0        },        {          "name": "meeting_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    meeting_id TEXT NOT NULL",          "position": 1        },        {          "name": "seq",          "type": "INTEGER",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    seq INTEGER NOT NULL",          "position": 2        },        {          "name": "speaker_label",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    speaker_label TEXT NOT NULL",          "position": 3        },        {          "name": "t0_ms",          "type": "INTEGER",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    t0_ms INTEGER NOT NULL",          "position": 4        },        {          "name": "t1_ms",          "type": "INTEGER",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    t1_ms INTEGER NOT NULL",          "position": 5        },        {          "name": "text",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    text TEXT NOT NULL",          "position": 6        },        {          "name": "created_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    created_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    UNIQUE (meeting_id, seq)",          "position": 10        },        {          "declaration": "\n    CHECK (seq >= 0)",          "position": 11        },        {          "declaration": "\n    CHECK (t1_ms >= t0_ms)",          "position": 12        },        {          "declaration": "\n    CHECK (t0_ms >= 0)",          "position": 13        },        {          "declaration": "\n    CHECK (t1_ms >= 0)",          "position": 14        },        {          "declaration": "\n    FOREIGN KEY (meeting_id) REFERENCES cotton_meetings(id)\n  ",          "position": 15        }      ],      "prefix": "CREATE TABLE cotton_meeting_utterances (",      "suffix": ")",      "indexes": [        "CREATE INDEX idx_cotton_meeting_utterances_meeting ON cotton_meeting_utterances (meeting_id, seq)",        "CREATE INDEX IF NOT EXISTS idx_cotton_meeting_utterances_author ON cotton_meeting_utterances (substr(_hlc, 20), _hlc)"      ],      "full_text": [],      "triggers": []    }  ],  "page_parts": [    "title",    "facts",    "content",    "grid"  ]}