Cotton code
286 lines · 6.8 KB · JSONRaw
{  "format_version": 1,  "id": "album_item",  "name": "Picture",  "plural": "Pictures",  "picture": null,  "builtin": true,  "engine": "media",  "columns": [    {      "key": "album_id",      "name": "Album",      "type": "link",      "link_to": "album",      "readonly": true    },    {      "key": "record_id",      "name": "Picture",      "type": "text",      "readonly": true    },    {      "key": "kind",      "name": "Kind",      "type": "choice",      "choices": [        "photo",        "video"      ],      "readonly": true    },    {      "key": "key",      "name": "Print",      "type": "photo",      "readonly": true    },    {      "key": "caption",      "name": "Caption",      "type": "text",      "readonly": true    },    {      "key": "taken_at",      "name": "Taken",      "type": "date",      "readonly": true    },    {      "key": "duration_ms",      "name": "Length",      "type": "number",      "readonly": true,      "format": "duration"    }  ],  "title": "caption",  "date": "taken_at",  "project": null,  "order": null,  "slip": {    "title": "caption",    "subtitle": null,    "trailing": "taken_at",    "photo": "key",    "toggle": null,    "badge": {      "column": "kind",      "values": [        "video"      ],      "symbol": "play.fill",      "spoken": "Video"    }  },  "tile": {    "face": "polaroid-grid"  },  "polaroid": {    "caption": "duration_ms"  },  "layout": "sheet",  "grid": {    "columns": 4  },  "opens": {    "column": "record_id",    "table_column": "kind"  },  "delete_when": {    "column": "kind",    "present": true  },  "select": {    "verb": "delete"  },  "deletion": {    "label": "Remove from album",    "asks": false,    "confirm": "Remove from album"  },  "empty": {    "title": "No pictures in this album",    "message": "Add some from your photos with the + circle."  },  "page": [    {      "heading": null,      "columns": [        "key",        "caption",        "taken_at"      ]    }  ],  "instructions": "One picture or film in one album (kind names its table, record_id its id). Removing one takes it out of the album; the picture stays in Photos.",  "tables": [    {      "name": "cotton_media_album_items",      "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": "album_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    album_id TEXT NOT NULL",          "position": 2        },        {          "name": "record_kind",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    record_kind TEXT NOT NULL",          "position": 3        },        {          "name": "record_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    record_id TEXT NOT NULL",          "position": 4        },        {          "name": "added_by",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    added_by TEXT NOT NULL",          "position": 5        },        {          "name": "sort_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    sort_at 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": "updated_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    updated_at TEXT NOT NULL",          "position": 8        },        {          "name": "_hlc",          "type": "TEXT",          "default": "''",          "nullable": false,          "primary_key": false,          "declaration": "\n    _hlc TEXT NOT NULL DEFAULT ''",          "position": 9        },        {          "name": "origin_handle",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " origin_handle TEXT CHECK (origin_handle IS NULL OR length(origin_handle) > 0)",          "position": 10        },        {          "name": "_born",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    _born TEXT",          "position": 11        }      ],      "constraints": [        {          "declaration": "\n    CHECK (record_kind IN ('photo', 'video'))",          "position": 12        },        {          "declaration": "\n    CHECK (substr(record_id, 1, length(record_kind) + 1) = record_kind || ':')",          "position": 13        },        {          "declaration": "\n    CHECK (added_by IN ('derived', 'user'))",          "position": 14        },        {          "declaration": "\n    FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE",          "position": 15        },        {          "declaration": "\n    FOREIGN KEY (album_id) REFERENCES cotton_media_albums(id)\n  ",          "position": 16        }      ],      "prefix": "CREATE TABLE cotton_media_album_items (",      "suffix": ")",      "indexes": [        "CREATE UNIQUE INDEX uq_cotton_media_album_items_member ON cotton_media_album_items (album_id, record_id)",        "CREATE INDEX idx_cotton_media_album_items_record ON cotton_media_album_items (workspace_id, record_id)",        "CREATE INDEX idx_cotton_media_album_items_origin ON cotton_media_album_items (origin_handle) WHERE origin_handle IS NOT NULL",        "CREATE INDEX IF NOT EXISTS idx_cotton_media_album_items_author ON cotton_media_album_items (substr(_hlc, 20), _hlc)"      ],      "full_text": [],      "triggers": []    }  ],  "parts": {    "shape": "sheet",    "head": {      "facts": []    },    "links": [],    "lists": [],    "acts": {      "more": []    },    "cards": [      {        "column": "taken_at"      },      {        "column": "duration_ms"      }    ]  }}