Cotton code
728 lines · 17.7 KB · JSONRaw
{  "format_version": 1,  "id": "pull",  "setup": true,  "name": "Pull request",  "plural": "Pull requests",  "picture": null,  "builtin": true,  "engine": "repos",  "core_links": true,  "screen_family": "core",  "columns": [    {      "key": "repo_id",      "name": "Repository",      "type": "link",      "link_to": "repository",      "readonly": true    },    {      "key": "number",      "type": "number",      "readonly": true    },    {      "key": "title",      "type": "text",      "required": true    },    {      "key": "body",      "name": "Description",      "type": "longtext"    },    {      "key": "state",      "type": "choice",      "choices": [        "open",        "closed"      ],      "readonly": true    },    {      "key": "merged",      "type": "bool",      "readonly": true    },    {      "key": "draft",      "type": "bool",      "readonly": true    },    {      "key": "author",      "type": "text",      "readonly": true    },    {      "key": "head_ref",      "name": "From branch",      "type": "text",      "readonly": true    },    {      "key": "base_ref",      "name": "Into branch",      "type": "text",      "readonly": true    },    {      "key": "mergeable",      "type": "bool",      "readonly": true    },    {      "key": "additions",      "type": "number",      "readonly": true    },    {      "key": "deletions",      "type": "number",      "readonly": true    },    {      "key": "changed_files",      "name": "Files changed",      "type": "number",      "readonly": true    },    {      "key": "comments_count",      "name": "Comments",      "type": "number",      "readonly": true    },    {      "key": "checks_state",      "name": "Checks",      "type": "choice",      "choices": [        "pending",        "success",        "failure",        "error",        "warning"      ],      "readonly": true    },    {      "key": "html_url",      "name": "Web address",      "type": "text",      "readonly": true    },    {      "key": "remote_created_at",      "name": "Opened",      "type": "date",      "readonly": true    },    {      "key": "remote_updated_at",      "name": "Updated",      "type": "date",      "readonly": true    },    {      "key": "merged_at",      "name": "Merged",      "type": "date",      "readonly": true    },    {      "key": "closed_at",      "name": "Closed",      "type": "date",      "readonly": true    },    {      "key": "origin",      "name": "Hosted by",      "type": "choice",      "choices": [        "forgejo",        "github",        "cotton"      ],      "readonly": true    },    {      "key": "open_in",      "name": "Open in",      "type": "link",      "link_to": "repository",      "readonly": true    },    {      "key": "stamp",      "name": "Stamp",      "type": "choice",      "choices": [        "open",        "draft",        "merged",        "closed"      ],      "readonly": true    },    {      "key": "title_line",      "name": "Pull request",      "type": "text",      "readonly": true    },    {      "key": "meta_line",      "name": "About",      "type": "text",      "readonly": true    },    {      "key": "checks_summary",      "name": "Checks say",      "type": "text",      "readonly": true    },    {      "key": "readiness_line",      "name": "Why it cannot merge",      "type": "text",      "readonly": true    },    {      "key": "labels",      "name": "Labels",      "type": "text"    },    {      "key": "reviews_line",      "name": "Reviews",      "type": "text",      "readonly": true    },    {      "key": "reviewers",      "name": "Reviewers",      "type": "longtext",      "readonly": true    },    {      "key": "checks",      "name": "Each check",      "type": "longtext",      "readonly": true    },    {      "key": "check_links",      "name": "Check links",      "type": "longtext",      "readonly": true    },    {      "key": "closed_line",      "name": "Over",      "type": "text",      "readonly": true    }  ],  "title": "title",  "date": "remote_updated_at",  "project": null,  "order": null,  "slip": {    "title": "title_line",    "subtitle": "meta_line",    "trailing": "stamp",    "caption": {      "columns": [        "checks_summary",        "readiness_line"      ],      "dates": []    },    "photo": null,    "toggle": null  },  "tile": {    "face": "slip-list"  },  "page": [    {      "heading": null,      "columns": [        "title",        "author",        "number",        "remote_created_at",        "stamp",        "repo_id",        "body"      ]    },    {      "heading": "Checks",      "columns": [        "checks_summary",        "readiness_line",        "checks"      ]    },    {      "heading": "Conversation",      "columns": [],      "list": {        "table": "repo_comment",        "link": "pull_id",        "limit": 10      }    }  ],  "instructions": "A pull request is a proposed change to a repository, numbered within it. It is open or closed, and a closed one may have been merged; checks summarise its CI runs. Pull requests are indexed from the host, so write changes through the host rather than editing the record.",  "add": false,  "group": {    "column": "stamp",    "sections": [      {        "heading": "Open",        "values": [          "open",          "draft"        ]      },      {        "heading": "Merged",        "values": [          "merged"        ],        "closed": true      },      {        "heading": "Closed",        "values": [          "closed"        ],        "closed": true      }    ]  },  "empty": {    "title": "No pull requests.",    "message": "The Mac that serves you reads every open pull request each pass, and walks the closed ones back from the newest."  },  "sort": {    "column": "remote_updated_at",    "descending": true  },  "readonly_when": "closed_line",  "conversation": {    "table": "repo_comment",    "links": [      "pull_id"    ],    "body": "body",    "at": "remote_created_at",    "mine": {      "column": "by",      "values": [        "owner"      ]    },    "blank_body": "verdict_said",    "footer": [      "author",      "verdict",      "place"    ],    "placeholder": "Say something on this pull request"  },  "parts": {    "shape": "desk",    "head": {      "facts": [        "author",        "number",        "remote_created_at"      ],      "state": "stamp"    },    "links": [      "repo_id"    ],    "body": "body",    "lists": [      {        "table": "repo_comment",        "relation": "pull_id",        "heading": "Conversation"      }    ],    "acts": {      "more": []    }  },  "tables": [    {      "name": "cotton_repo_pulls",      "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": "repo_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    repo_id TEXT NOT NULL",          "position": 2        },        {          "name": "number",          "type": "INTEGER",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    number INTEGER NOT NULL",          "position": 3        },        {          "name": "remote_id",          "type": "INTEGER",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    remote_id INTEGER",          "position": 4        },        {          "name": "title",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    title TEXT NOT NULL",          "position": 5        },        {          "name": "body",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    body TEXT",          "position": 6        },        {          "name": "state",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    state TEXT NOT NULL",          "position": 7        },        {          "name": "merged",          "type": "INTEGER",          "default": "0",          "nullable": false,          "primary_key": false,          "declaration": "\n    merged INTEGER NOT NULL DEFAULT 0",          "position": 8        },        {          "name": "draft",          "type": "INTEGER",          "default": "0",          "nullable": false,          "primary_key": false,          "declaration": "\n    draft INTEGER NOT NULL DEFAULT 0",          "position": 9        },        {          "name": "author",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    author TEXT",          "position": 10        },        {          "name": "head_ref",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    head_ref TEXT",          "position": 11        },        {          "name": "head_sha",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    head_sha TEXT",          "position": 12        },        {          "name": "base_ref",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    base_ref TEXT",          "position": 13        },        {          "name": "mergeable",          "type": "INTEGER",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    mergeable INTEGER",          "position": 14        },        {          "name": "additions",          "type": "INTEGER",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    additions INTEGER",          "position": 15        },        {          "name": "deletions",          "type": "INTEGER",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    deletions INTEGER",          "position": 16        },        {          "name": "changed_files",          "type": "INTEGER",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    changed_files INTEGER",          "position": 17        },        {          "name": "comments_count",          "type": "INTEGER",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    comments_count INTEGER",          "position": 18        },        {          "name": "review_comments_count",          "type": "INTEGER",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    review_comments_count INTEGER",          "position": 19        },        {          "name": "labels",          "type": "TEXT",          "default": "'[]'",          "nullable": false,          "primary_key": false,          "declaration": "\n    labels TEXT NOT NULL DEFAULT '[]'",          "position": 20        },        {          "name": "checks_state",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    checks_state TEXT",          "position": 21        },        {          "name": "checks",          "type": "TEXT",          "default": "'[]'",          "nullable": false,          "primary_key": false,          "declaration": "\n    checks TEXT NOT NULL DEFAULT '[]'",          "position": 22        },        {          "name": "html_url",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    html_url TEXT",          "position": 23        },        {          "name": "remote_created_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    remote_created_at TEXT",          "position": 24        },        {          "name": "remote_updated_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    remote_updated_at TEXT",          "position": 25        },        {          "name": "merged_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    merged_at TEXT",          "position": 26        },        {          "name": "closed_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    closed_at TEXT",          "position": 27        },        {          "name": "created_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    created_at TEXT NOT NULL",          "position": 28        },        {          "name": "updated_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    updated_at TEXT NOT NULL",          "position": 29        },        {          "name": "_hlc",          "type": "TEXT",          "default": "''",          "nullable": false,          "primary_key": false,          "declaration": "\n    _hlc TEXT NOT NULL DEFAULT ''",          "position": 30        },        {          "name": "_born",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    _born TEXT",          "position": 31        },        {          "name": "merge_commit_sha",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    merge_commit_sha TEXT",          "position": 32        }      ],      "constraints": [        {          "declaration": "\n    UNIQUE (workspace_id, repo_id, number)",          "position": 33        },        {          "declaration": "\n    CHECK (state IN ('open', 'closed'))",          "position": 34        },        {          "declaration": "\n    CHECK (merged IN (0, 1))",          "position": 35        },        {          "declaration": "\n    CHECK (draft IN (0, 1))",          "position": 36        },        {          "declaration": "\n    CHECK (mergeable IS NULL OR mergeable IN (0, 1))",          "position": 37        },        {          "declaration": "\n    CHECK (checks_state IS NULL OR checks_state IN ('pending', 'success', 'failure', 'error', 'warning'))",          "position": 38        },        {          "declaration": "\n    CHECK (json_type(labels) = 'array')",          "position": 39        },        {          "declaration": "\n    CHECK (json_type(checks) = 'array')",          "position": 40        },        {          "declaration": "\n    FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE",          "position": 41        },        {          "declaration": "\n    FOREIGN KEY (repo_id) REFERENCES cotton_repos(id)\n  ",          "position": 42        }      ],      "prefix": "CREATE TABLE IF NOT EXISTS cotton_repo_pulls (",      "suffix": ")",      "indexes": [        "CREATE INDEX IF NOT EXISTS idx_cotton_repo_pulls_repo ON cotton_repo_pulls (workspace_id, repo_id, state, remote_updated_at DESC)",        "CREATE INDEX IF NOT EXISTS idx_cotton_repo_pulls_author ON cotton_repo_pulls (substr(_hlc, 20), _hlc)"      ],      "full_text": [        "CREATE VIRTUAL TABLE fts_repo_pulls USING fts5(\n       title, body, content = 'cotton_repo_pulls', content_rowid = 'rowid',\n       tokenize = 'unicode61 remove_diacritics 2'\n     )"      ],      "triggers": [        "CREATE TRIGGER fts_repo_pulls_ai AFTER INSERT ON cotton_repo_pulls WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_repo_pulls'), 0) BEGIN\n       INSERT INTO fts_repo_pulls (rowid, title, body) VALUES (new.rowid, new.title, new.body);\n     END",        "CREATE TRIGGER fts_repo_pulls_ad AFTER DELETE ON cotton_repo_pulls WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_repo_pulls'), 0) BEGIN\n       INSERT INTO fts_repo_pulls (fts_repo_pulls, rowid, title, body) VALUES ('delete', old.rowid, old.title, old.body);\n     END",        "CREATE TRIGGER fts_repo_pulls_au AFTER UPDATE OF title, body ON cotton_repo_pulls\n       FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_repo_pulls'), 0) AND (new.title IS NOT old.title OR new.body IS NOT old.body) BEGIN\n       INSERT INTO fts_repo_pulls (fts_repo_pulls, rowid, title, body) VALUES ('delete', old.rowid, old.title, old.body);\n       INSERT INTO fts_repo_pulls (rowid, title, body) VALUES (new.rowid, new.title, new.body);\n     END"      ]    }  ],  "delete": false}