Cotton code
277 lines · 8.4 KB · JSONRaw
{  "format_version": 1,  "id": "outage",  "name": "Outage",  "plural": "Outages",  "picture": {"photo": "photo:8b07b44f348da1250b91e5e51dff431f0c897b55223d0b26a748324adf78c5ba", "object": "tool-outages"},  "builtin": true,  "engine": "outages",  "columns": [    { "key": "title", "name": "What", "type": "text", "required": true, "readonly": true },    {      "key": "kind",      "name": "Kind",      "type": "choice",      "readonly": true,      "choices": ["held_elsewhere", "unreachable", "line_down", "name_absent", "relay_down", "not_serving", "restarts", "disk", "host_quiet", "planned"],      "labels": {        "held_elsewhere": "Name held elsewhere",        "unreachable": "Can't be reached",        "line_down": "Mac's line down",        "name_absent": "Name not known",        "relay_down": "Relay down",        "not_serving": "Mac not serving",        "restarts": "Relay restarting",        "disk": "Relay disk low",        "host_quiet": "Relay host quiet",        "planned": "Planned"      }    },    { "key": "effect", "name": "What it means for you", "type": "text", "readonly": true },    { "key": "doing", "name": "What is being done", "type": "text", "readonly": true },    {  "key": "started_at",  "name": "Began",  "type": "date",  "readonly": true,  "fact": true,  "reading": "Began {value}",  "format": "calendar-datetime"},    {  "key": "ended_at",  "name": "Ended",  "type": "date",  "readonly": true,  "fact": true,  "reading": "Ended {value}",  "format": "calendar-datetime"},    { "key": "machine", "name": "Seen by", "type": "text", "readonly": true }  ],  "title": "title",  "date": "started_at",  "project": null,  "order": null,  "slip": {    "title": "title",    "subtitle": "effect",    "trailing": "kind",    "photo": null,    "toggle": null,    "caption": {  "dates": [],  "fields": [    "started_at",    "ended_at"  ]}  },  "tile": { "face": "slip-list" },  "empty": {    "title": "Nothing has gone wrong",    "message": "When your serving Mac sees Cotton out of reach, the relay in trouble or itself not serving, it writes it here and tells you — once when it starts, once when it ends."  },  "page": [    { "heading": null, "columns": ["title", "effect", "doing"] },    { "heading": "When", "columns": ["started_at", "ended_at", "kind", "machine"] }  ],  "instructions": "The owner's outage record, newest first, written by the serving Mac itself: one row per continuous outage it saw — the household out of reach from outside, the serving Mac's own line to the relay down (usually its internet), the relay down, restarting, low on disk or gone quiet, the relay no longer knowing the household's name or having given it to another household, the serving Mac itself not serving for a while — and planned changes (a relaunch onto a new build). `effect` says what it meant for the owner and `doing` what is being done; both are the server's own sentences, shown exactly as written. A row with no `ended_at` is still going on. The owner is rung when a row opens and when it ends; a planned row is never rung. Nobody adds, edits or deletes a row: the Mac opens and closes them as conditions start and clear.",  "add": false,  "delete": false,  "parts": {    "shape": "sheet",    "head": {      "facts": [        "started_at",        "ended_at"      ]    },    "links": [],    "lists": [],    "acts": {      "more": []    },    "cards": [  {    "column": "effect",    "row": true  },  {    "column": "doing",    "row": true  },  {    "column": "machine"  }]  },  "tool": { "name": "Outages", "key": "outages", "icon": "monitor-smartphone", "card_stock": "grey" ,"purpose":"Failures and when they happened."},  "tables": [    {      "name": "cotton_outages",      "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": "kind",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    kind TEXT NOT NULL CHECK (length(trim(kind)) > 0)",          "position": 2        },        {          "name": "condition",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    condition TEXT NOT NULL CHECK (length(trim(condition)) > 0)",          "position": 3        },        {          "name": "machine",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    machine TEXT",          "position": 4        },        {          "name": "title",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    title TEXT NOT NULL CHECK (length(trim(title)) > 0)",          "position": 5        },        {          "name": "effect",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    effect TEXT NOT NULL CHECK (length(trim(effect)) > 0)",          "position": 6        },        {          "name": "doing",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    doing TEXT NOT NULL CHECK (length(trim(doing)) > 0)",          "position": 7        },        {          "name": "started_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    started_at TEXT NOT NULL",          "position": 8        },        {          "name": "ended_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    ended_at TEXT",          "position": 9        },        {          "name": "told_open_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    told_open_at TEXT",          "position": 10        },        {          "name": "told_close_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    told_close_at TEXT",          "position": 11        },        {          "name": "created_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    created_at TEXT NOT NULL",          "position": 12        },        {          "name": "updated_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    updated_at TEXT NOT NULL",          "position": 13        },        {          "name": "_hlc",          "type": "TEXT",          "default": "''",          "nullable": false,          "primary_key": false,          "declaration": "\n    _hlc TEXT NOT NULL DEFAULT ''",          "position": 14        },        {          "name": "_born",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    _born TEXT",          "position": 15        }      ],      "constraints": [        {          "declaration": "\n    FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n  ",          "position": 16        }      ],      "prefix": "CREATE TABLE IF NOT EXISTS cotton_outages (",      "suffix": ")",      "indexes": [        "CREATE INDEX IF NOT EXISTS idx_cotton_outages_author ON cotton_outages (substr(_hlc, 20), _hlc)",        "CREATE INDEX idx_cotton_outages_open ON cotton_outages (workspace_id, condition) WHERE ended_at IS NULL",        "CREATE INDEX idx_cotton_outages_started ON cotton_outages (workspace_id, started_at DESC)"      ],      "full_text": [],      "triggers": []    }  ]}