Cotton code
579 lines · 14.1 KB · JSONRaw
{  "format_version": 1,  "id": "feedback",  "name": "Feedback",  "plural": "Feedback",  "builtin": true,  "visibility": "owner",  "date": "created_at",  "title": "body",  "columns": [    {      "key": "image_sha256",      "type": "text",      "readonly": true    },    {      "key": "image_ext",      "type": "text",      "readonly": true    },    {      "key": "x",      "type": "number",      "readonly": true    },    {      "key": "y",      "type": "number",      "readonly": true    },    {      "key": "body",      "type": "longtext",      "required": true    },    {      "key": "author_kind",      "name": "From",      "type": "choice",      "choices": [        "user",        "agent",        "guest"      ],      "labels": {        "user": "You",        "agent": "Assistant",        "guest": "Guest"      },      "readonly": true    },    {      "key": "author_user_id",      "type": "text",      "readonly": true    },    {      "key": "author_label",      "name": "Author",      "type": "text",      "readonly": true,      "fact": true,      "reading": "From {value}"    },    {      "key": "person_id",      "name": "Person",      "type": "link",      "link_to": "person",      "contributes": false    },    {      "key": "same_as",      "name": "Same as",      "type": "link",      "link_to": "feedback",      "contributes": false    },    {      "key": "share_id",      "type": "text",      "readonly": true    },    {      "key": "app",      "type": "text",      "readonly": true    },    {      "key": "context",      "type": "longtext",      "readonly": true    },    {      "key": "status",      "type": "choice",      "choices": [        "open",        "agreed",        "declined",        "shipped",        "resolved",        "dismissed"      ],      "labels": {        "open": "Open",        "agreed": "Agreed",        "declined": "Declined",        "shipped": "Shipped",        "resolved": "Resolved",        "dismissed": "Dismissed"      }    },    {      "key": "resolved_at",      "name": "Resolved",      "type": "date",      "readonly": true    },    {      "key": "resolved_by_kind",      "name": "Resolved by",      "type": "choice",      "choices": [        "user",        "agent"      ],      "labels": {        "user": "You",        "agent": "Assistant"      },      "readonly": true    },    {      "key": "resolved_by_label",      "name": "Resolver",      "type": "text",      "readonly": true    },    {      "key": "resolution_note",      "name": "Resolution",      "type": "longtext"    },    {      "key": "parent_id",      "name": "Reply to",      "type": "link",      "link_to": "feedback",      "readonly": true,      "contributes": false    },    {      "key": "created_at",      "name": "Sent",      "type": "date",      "readonly": true    },    {      "key": "refused_reason",      "name": "Last write refused",      "type": "text",      "readonly": true,      "fact": false,      "reading": "the last sample was refused: {value}"    },    {      "key": "refused_since",      "name": "Refused since",      "type": "date",      "readonly": true,      "fact": false,      "reading": " (since {value})"    }  ],  "instructions": "Feedback is a report about an app, often with a screenshot, from the owner, an assistant or a guest. It stays open until someone agrees, declines, ships or resolves it; weigh it by who said it and how many said the same thing. Mark a repeat as the same as the earlier report instead of filing it twice.",  "tables": [    {      "name": "cotton_feedback",      "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": "image_sha256",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    image_sha256 TEXT",          "position": 2        },        {          "name": "image_ext",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    image_ext TEXT",          "position": 3        },        {          "name": "x",          "type": "REAL",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    x REAL",          "position": 4        },        {          "name": "y",          "type": "REAL",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    y REAL",          "position": 5        },        {          "name": "body",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    body TEXT NOT NULL",          "position": 6        },        {          "name": "author_kind",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    author_kind TEXT NOT NULL",          "position": 7        },        {          "name": "author_user_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    author_user_id TEXT",          "position": 8        },        {          "name": "author_label",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    author_label TEXT",          "position": 9        },        {          "name": "person_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    person_id TEXT",          "position": 10        },        {          "name": "same_as",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    same_as TEXT",          "position": 11        },        {          "name": "share_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    share_id TEXT",          "position": 12        },        {          "name": "app",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    app TEXT",          "position": 13        },        {          "name": "context",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    context TEXT",          "position": 14        },        {          "name": "status",          "type": "TEXT",          "default": "'open'",          "nullable": false,          "primary_key": false,          "declaration": "\n    status TEXT NOT NULL DEFAULT 'open'",          "position": 15        },        {          "name": "resolved_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    resolved_at TEXT",          "position": 16        },        {          "name": "resolved_by_kind",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    resolved_by_kind TEXT",          "position": 17        },        {          "name": "resolved_by_label",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    resolved_by_label TEXT",          "position": 18        },        {          "name": "resolution_note",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    resolution_note TEXT",          "position": 19        },        {          "name": "parent_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    parent_id TEXT",          "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        }      ],      "constraints": [        {          "declaration": "\n    CHECK ((image_sha256 IS NULL) OR (app IS NOT NULL))",          "position": 25        },        {          "declaration": "\n    CHECK ((image_sha256 IS NULL) = (image_ext IS NULL))",          "position": 26        },        {          "declaration": "\n    CHECK ((x IS NULL) = (y IS NULL))",          "position": 27        },        {          "declaration": "\n    CHECK ((x IS NULL) OR (app IS NULL) OR (image_sha256 IS NOT NULL))",          "position": 28        },        {          "declaration": "\n    CHECK (length(trim(body)) > 0)",          "position": 29        },        {          "declaration": "\n    CHECK (author_kind IN ('user', 'agent', 'guest'))",          "position": 30        },        {          "declaration": "\n    CHECK ((author_kind = 'user') = (author_user_id IS NOT NULL))",          "position": 31        },        {          "declaration": "\n    CHECK ((author_kind = 'user') OR (author_label IS NOT NULL))",          "position": 32        },        {          "declaration": "\n    CHECK (same_as IS NULL OR same_as <> id)",          "position": 33        },        {          "declaration": "\n    CHECK ((same_as IS NULL) OR (parent_id IS NULL))",          "position": 34        },        {          "declaration": "\n    CHECK (context IS NULL OR json_type(context) = 'object')",          "position": 35        },        {          "declaration": "\n    CHECK (status IN ('open', 'agreed', 'declined', 'shipped', 'resolved', 'dismissed'))",          "position": 36        },        {          "declaration": "\n    CHECK (resolved_by_kind IN ('user', 'agent'))",          "position": 37        },        {          "declaration": "\n    FOREIGN KEY (parent_id) REFERENCES cotton_feedback(id)",          "position": 38        },        {          "declaration": "\n    FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n  ",          "position": 39        }      ],      "prefix": "CREATE TABLE \"cotton_feedback\" (",      "suffix": ")",      "indexes": [        "CREATE INDEX idx_cotton_feedback_open ON cotton_feedback (workspace_id, created_at DESC) WHERE resolved_at IS NULL",        "CREATE INDEX idx_cotton_feedback_parent ON cotton_feedback (parent_id) WHERE parent_id IS NOT NULL",        "CREATE INDEX idx_cotton_feedback_capture ON cotton_feedback (workspace_id, app, created_at) WHERE app IS NOT NULL",        "CREATE INDEX idx_cotton_feedback_person ON cotton_feedback (person_id, created_at) WHERE person_id IS NOT NULL",        "CREATE INDEX idx_cotton_feedback_same_as ON cotton_feedback (same_as) WHERE same_as IS NOT NULL",        "CREATE INDEX IF NOT EXISTS idx_cotton_feedback_author ON cotton_feedback (substr(_hlc, 20), _hlc)"      ],      "full_text": [],      "triggers": []    }  ],  "picture": {    "photo": "photo:295881b10732ac0ddd3ba3a47d9afa8e9aca56607f1622ea09fc4f9dc546ee7a",    "object": "tool-feedback"  },  "engine": "feedback",  "project": null,  "order": null,  "slip": {    "title": "body",    "subtitle": "status",    "trailing": "created_at",    "photo": null,    "toggle": null  },  "tile": {    "face": "slip-list"  },  "page": [    {      "heading": null,      "columns": [        "body",        "status",        "author_kind",        "author_label",        "person_id",        "created_at"      ]    },    {      "heading": "Resolution",      "columns": [        "resolved_at",        "resolved_by_kind",        "resolved_by_label",        "resolution_note"      ]    },    {      "heading": "Related",      "columns": [        "parent_id",        "same_as",        "app"      ]    }  ],  "add": false,  "delete": false,  "tool": {    "views": [      {        "id": "all",        "label": "All",        "visibility": "owner",        "is_default": true,        "read": {          "table": "feedback"        }      }    ],    "name": "Feedback",    "purpose": "Problems, ideas and reports you have filed.",    "key": "feedback",    "icon": "message-square",    "card_stock": "rose",    "route": "/lists/project_feedback"  },  "parts": {    "shape": "desk",    "head": {      "facts": [        "author_label",        "created_at"      ],      "state": "status"    },    "links": [      "person_id",      "parent_id",      "same_as"    ],    "body": "body",    "lists": [],    "acts": {      "more": []    },    "strip": [      {        "column": "resolution_note"      },      {        "column": "resolved_by_label"      }    ]  }}