Cotton code
412 lines · 10.4 KB · JSONRaw
{  "format_version": 1,  "id": "face",  "name": "Face",  "plural": "People to confirm",  "picture": null,  "builtin": true,  "engine": "photos",  "columns": [    {      "key": "question",      "name": "Question",      "type": "text",      "readonly": true    },    {      "key": "crop",      "name": "Face",      "type": "photo",      "readonly": true    },    {  "key": "likelihood",  "name": "How sure",  "type": "choice",  "choices": [    "likely",    "maybe"  ],  "readonly": true,  "labels": {    "likely": "Likely",    "maybe": "Maybe"  }},    {  "key": "decision",  "name": "Answer",  "type": "choice",  "choices": [    "yes",    "no"  ],  "labels": {    "yes": "Yes",    "no": "No"  }},    {      "key": "photo_id",      "media": true,      "name": "In the photo",      "type": "link",      "link_to": "photo",      "readonly": true    },    {      "key": "suggested_person_id",      "name": "Maybe",      "type": "link",      "link_to": "person",      "readonly": true,      "contributes": false    }  ],  "title": "question",  "date": null,  "project": null,  "order": null,  "slip": {    "title": "question",    "subtitle": null,    "trailing": null,    "photo": "crop",    "toggle": null,    "byline": {      "column": "likelihood",      "words": {        "likely": "Very likely",        "maybe": "Maybe"      }    },    "answers": {      "column": "decision",      "values": {        "yes": "Yes",        "no": "Not them"      }    }  },  "tile": {    "face": "slip-list"  },  "page": [    {      "heading": null,      "columns": [        "crop",        "question",        "likelihood",        "decision",        "photo_id",        "suggested_person_id"      ],      "answers": {        "column": "decision",        "values": {          "yes": "Yes",          "no": "Not them"        }      }    }  ],  "layout": "sheet",  "grid": {    "columns": 4  },  "empty": {    "title": "Nobody to confirm",    "message": "When the Mac thinks it recognises someone in a picture, it asks you here. It never decides on its own."  },  "delete": false,  "instructions": "A face the Mac found in a photo and thinks it recognises: the question names the person it suggests. Answering yes names that person in the face; no stops the question for this face. Nothing is decided without the owner.",  "add": false,  "tables": [    {      "name": "cotton_media_faces",      "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": "record_kind",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    record_kind TEXT NOT NULL",          "position": 2        },        {          "name": "record_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    record_id TEXT NOT NULL",          "position": 3        },        {          "name": "source",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    source TEXT NOT NULL",          "position": 4        },        {          "name": "source_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    source_id TEXT NOT NULL",          "position": 5        },        {          "name": "x",          "type": "REAL",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    x REAL NOT NULL",          "position": 6        },        {          "name": "y",          "type": "REAL",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    y REAL NOT NULL",          "position": 7        },        {          "name": "w",          "type": "REAL",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    w REAL NOT NULL",          "position": 8        },        {          "name": "h",          "type": "REAL",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    h REAL NOT NULL",          "position": 9        },        {          "name": "quality",          "type": "REAL",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    quality REAL",          "position": 10        },        {          "name": "cluster_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    cluster_id TEXT",          "position": 11        },        {          "name": "person_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    person_id TEXT",          "position": 12        },        {          "name": "created_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    created_at TEXT NOT NULL",          "position": 13        },        {          "name": "updated_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    updated_at 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": "suggested_person_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " suggested_person_id TEXT",          "position": 16        },        {          "name": "suggested_distance",          "type": "REAL",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " suggested_distance REAL CHECK (suggested_distance IS NULL OR (suggested_distance >= 0 AND suggested_distance <= 2))",          "position": 17        },        {          "name": "suggestion_dismissed_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " suggestion_dismissed_at TEXT",          "position": 18        },        {          "name": "_born",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    _born TEXT",          "position": 19        },        {          "name": "embedding",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " embedding TEXT CHECK (embedding IS NULL OR length(embedding) > 0)",          "position": 20        },        {          "name": "embedding_model",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " embedding_model TEXT CHECK (embedding_model IS NULL OR length(embedding_model) > 0)",          "position": 21        },        {          "name": "person_by",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " person_by TEXT CHECK (person_by IS NULL OR person_by = 'match')",          "position": 22        }      ],      "constraints": [        {          "declaration": "\n    CHECK (record_kind IN ('photo', 'video'))",          "position": 23        },        {          "declaration": "\n    CHECK (substr(record_id, 1, length(record_kind) + 1) = record_kind || ':')",          "position": 24        },        {          "declaration": "\n    CHECK (source IN ('apple', 'cotton'))",          "position": 25        },        {          "declaration": "\n    CHECK (x >= 0 AND x <= 1 AND y >= 0 AND y <= 1)",          "position": 26        },        {          "declaration": "\n    CHECK (w > 0 AND w <= 1 AND h > 0 AND h <= 1)",          "position": 27        },        {          "declaration": "\n    FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n  ",          "position": 28        }      ],      "prefix": "CREATE TABLE cotton_media_faces (",      "suffix": ")",      "indexes": [        "CREATE UNIQUE INDEX uq_cotton_media_faces_natural ON cotton_media_faces (workspace_id, record_kind, record_id, source, source_id)",        "CREATE INDEX idx_cotton_media_faces_record ON cotton_media_faces (workspace_id, record_id)",        "CREATE INDEX idx_cotton_media_faces_person ON cotton_media_faces (workspace_id, person_id) WHERE person_id IS NOT NULL",        "CREATE INDEX idx_cotton_media_faces_cluster ON cotton_media_faces (workspace_id, cluster_id) WHERE cluster_id IS NOT NULL",        "CREATE INDEX idx_cotton_media_faces_suggested ON cotton_media_faces (workspace_id, suggested_person_id) WHERE suggested_person_id IS NOT NULL",        "CREATE INDEX IF NOT EXISTS idx_cotton_media_faces_author ON cotton_media_faces (substr(_hlc, 20), _hlc)"      ],      "full_text": [],      "triggers": []    }  ],  "commands": [    {      "id": "open-photo",      "label": "Open photo",      "kind": "open",      "opens": "photo_id"    },    {      "id": "open-person",      "label": "Open person",      "kind": "open",      "opens": "suggested_person_id"    }  ],  "parts": {    "shape": "sheet",    "head": {      "facts": [],      "state": "decision"    },    "links": [],    "lists": [],    "acts": {      "more": [        "open-photo",        "open-person"      ]    },    "cards": [      {        "column": "likelihood"      }    ]  }}