Cotton code
427 lines · 10.7 KB · JSONRaw
{  "format_version": 1,  "id": "location",  "name": "Location",  "plural": "Locations",  "record_route": "/locations/location/[id]",  "picture": {    "photo": "photo:574a9c3f55f867a59782a834f2692ed932a99a254dfd36f534e94898941cef56",    "object": "tool-locations"  },  "builtin": true,  "delete": false,  "engine": "locations",  "projects_read": {    "kind": "location",    "read": "location",    "families": [      "locations",      "projects"    ]  },  "voice_words": [    "name"  ],  "columns": [    {      "key": "name",      "type": "text",      "required": true    },    {      "key": "place",      "name": "Place",      "type": "place",      "place": {        "id": "place_id",        "country": "country",        "zone": "timezone"      }    },    {      "key": "place_id",      "name": "Place id",      "type": "text",      "readonly": true    },    {      "key": "country",      "name": "Country",      "type": "text",      "readonly": true    },    {      "key": "timezone",      "name": "Time zone",      "type": "text",      "readonly": true    },    {      "key": "near",      "name": "Nearest place",      "type": "text",      "readonly": true    },    {      "key": "address",      "type": "text"    },    {      "key": "lat",      "name": "Latitude",      "type": "number",      "pair": "lng"    },    {      "key": "lng",      "name": "Longitude",      "type": "number"    },    {      "key": "note",      "name": "Notes",      "type": "longtext"    },    {      "key": "created_at",      "name": "Added",      "type": "date",      "readonly": true    },    {      "key": "archived_at",      "name": "Archived",      "type": "date"    },    {      "key": "updated_at",      "name": "Changed",      "type": "date",      "readonly": true    }  ],  "title": "name",  "date": null,  "project": null,  "order": null,  "layout": "cards",  "slip": {    "title": "name",    "subtitle": "address",    "trailing": null,    "photo": null,    "toggle": null,    "trailing_picture": "lat",    "subtitle_fallback": "note"  },  "tile": {    "face": "slip-list"  },  "page": [    {      "heading": null,      "columns": [        "name",        "place",        "address"      ]    },    {      "heading": null,      "columns": [        "lat",        "lng",        "created_at"      ],      "picture": "lat"    },    {      "heading": "Notes",      "columns": [        "note"      ]    }  ],  "archived": "archived_at",  "instructions": "A location is a place the owner cares about: a name, an address and, when known, a map pin. Only set latitude and longitude from a real lookup or what the person gave; never estimate them. Notes hold anything worth remembering about the place.",  "create": {    "label": "Add a place"  },  "empty": {    "title": "No places yet.",    "message": "Capture one from Home and it files itself here, or add one now."  },  "recent": {    "column": "updated_at",    "count": 2,    "over": 3  },  "groups": {    "stack": "slips"  },  "parts": {    "shape": "desk",    "head": {      "facts": []    },    "links": [],    "lists": [],    "acts": {      "main": "book_ride",      "more": []    },    "strip": [],    "cards": [      {        "column": "address",        "row": true      },      {        "column": "note",        "row": true      }    ]  },  "tool": {    "name": "Locations",    "key": "locations",    "icon": "map-pin",    "card_stock": "tan",    "route": "/locations",    "figures": [      {        "read": "locations",        "one": "1 place",        "many": "{n} places"      }    ]  ,"purpose":"Places you have saved and how to get there."},  "commands": [    {      "id": "book_ride",      "label": "Book a ride",      "kind": "create",      "verb": "book_ride",      "bindings": {        "from_location": "$id"      },      "pick": {        "kind": "record",        "table": "location",        "argument": "to_location"      },      "receipt": "Ride request prepared",      "spoken": {        "verbs": [          "book an uber",          "book a ride",          "book a cab",          "get an uber",          "get a ride",          "get me a ride",          "get me an uber"        ],        "record": "from",        "pick": "to"      }    }  ],  "tables": [    {      "name": "cotton_locations",      "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": "name",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    name TEXT NOT NULL",          "position": 2        },        {          "name": "address",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    address TEXT",          "position": 3        },        {          "name": "lat",          "type": "REAL",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    lat REAL",          "position": 4        },        {          "name": "lng",          "type": "REAL",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    lng REAL",          "position": 5        },        {          "name": "note",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    note TEXT",          "position": 6        },        {          "name": "source_inbox_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    source_inbox_id TEXT",          "position": 7        },        {          "name": "created_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    created_at TEXT NOT NULL",          "position": 8        },        {          "name": "updated_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    updated_at TEXT NOT NULL",          "position": 9        },        {          "name": "archived_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    archived_at TEXT",          "position": 10        },        {          "name": "_hlc",          "type": "TEXT",          "default": "''",          "nullable": false,          "primary_key": false,          "declaration": "\n    _hlc TEXT NOT NULL DEFAULT ''",          "position": 11        },        {          "name": "_born",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    _born TEXT",          "position": 12        },        {          "name": "trashed_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " trashed_at TEXT",          "position": 13        },        {          "name": "place",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " place TEXT",          "position": 14        },        {          "name": "place_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " place_id TEXT",          "position": 15        },        {          "name": "country",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " country TEXT",          "position": 16        },        {          "name": "timezone",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " timezone TEXT",          "position": 17        },        {          "name": "near",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " near TEXT",          "position": 18        }      ],      "constraints": [        {          "declaration": "\n    FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n  ",          "position": 19        }      ],      "prefix": "CREATE TABLE cotton_locations (",      "suffix": ")",      "indexes": [        "CREATE INDEX idx_cotton_locations_workspace ON cotton_locations (workspace_id)",        "CREATE INDEX IF NOT EXISTS idx_cotton_locations_author ON cotton_locations (substr(_hlc, 20), _hlc)"      ],      "full_text": [        "CREATE VIRTUAL TABLE fts_locations USING fts5(\n       name, address, note, content = 'cotton_locations', content_rowid = 'rowid',\n       tokenize = 'unicode61 remove_diacritics 2'\n     )"      ],      "triggers": [        "CREATE TRIGGER fts_locations_ai AFTER INSERT ON cotton_locations WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_locations'), 0) BEGIN\n       INSERT INTO fts_locations (rowid, name, address, note) VALUES (new.rowid, new.name, new.address, new.note);\n     END",        "CREATE TRIGGER fts_locations_ad AFTER DELETE ON cotton_locations WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_locations'), 0) BEGIN\n       INSERT INTO fts_locations (fts_locations, rowid, name, address, note) VALUES ('delete', old.rowid, old.name, old.address, old.note);\n     END",        "CREATE TRIGGER fts_locations_au AFTER UPDATE OF name, address, note ON cotton_locations\n       FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_locations'), 0) AND (new.name IS NOT old.name OR new.address IS NOT old.address OR new.note IS NOT old.note) BEGIN\n       INSERT INTO fts_locations (fts_locations, rowid, name, address, note) VALUES ('delete', old.rowid, old.name, old.address, old.note);\n       INSERT INTO fts_locations (rowid, name, address, note) VALUES (new.rowid, new.name, new.address, new.note);\n     END"      ]    }  ]}