Cotton code
81 lines · 3.9 KB · JSONRaw
{  "about": "The default seal a personal table with no seal block takes (crates/cotton-core/src/seal/default.json): `seal` is what the core's cotton_core::seal::rule::default_seal and the Worker's defaultSeal answer, null where the rule leaves the table open. Synthetic tables only.",  "cases": [    {      "name": "the clear columns are the named ones, the links and the marks, in the definition's order",      "table": {        "id": "garden_bed",        "date": "planted_on",        "order": "position",        "archived": "archived",        "project": "project",        "sort": { "column": "planted_on", "tie": "position" },        "group": { "column": "state" },        "columns": [          { "key": "id", "type": "text" },          { "key": "name", "type": "text" },          { "key": "notes", "type": "longtext" },          { "key": "planted_on", "type": "date" },          { "key": "position", "type": "number" },          { "key": "archived", "type": "bool" },          { "key": "project", "type": "link", "link_to": "project" },          { "key": "state", "type": "choice", "choices": ["open", "done"] },          { "key": "neighbour", "type": "link", "link_to": "garden_bed" },          { "key": "trashed_at", "type": "date" },          { "key": "deleted_at", "type": "date" },          { "key": "archived_at", "type": "date" },          { "key": "yield_kg", "type": "number" }        ]      },      "seal": { "clear": ["planted_on", "position", "archived", "project", "state", "neighbour", "trashed_at", "deleted_at", "archived_at"] }    },    {      "name": "a computed column's inputs stay clear, the computed column itself is never stored",      "table": {        "id": "seed_order",        "row_key": "code",        "columns": [          { "key": "code", "type": "text" },          { "key": "label", "type": "text" },          { "key": "price_minor", "type": "amount" },          { "key": "count", "type": "number" },          { "key": "returned", "type": "bool" },          { "key": "supplier", "type": "link", "link_to": "seed_supplier" },          { "key": "total", "type": "amount", "computed": { "formula": { "op": "multiply", "of": ["price_minor", "count"], "flip_when": { "column": "returned", "equals": true } } } },          { "key": "supplier_name", "type": "text", "computed": { "lookup": { "through": "supplier", "column": "name" } } }        ]      },      "seal": { "clear": ["code", "price_minor", "count", "returned", "supplier"] }    },    {      "name": "a table with no column the object needs seals everything",      "table": { "id": "garden_whisper", "columns": [{ "key": "words", "type": "longtext" }, { "key": "loud", "type": "bool" }] },      "seal": { "clear": [] }    },    {      "name": "a table's own seal block wins: the default says nothing",      "table": { "id": "garden_note", "columns": [{ "key": "noted_on", "type": "date" }, { "key": "body", "type": "text" }], "seal": { "clear": ["noted_on"], "blind": ["body"] } },      "seal": null    },    {      "name": "a table open by design (R1) stays open",      "table": { "id": "device", "columns": [{ "key": "name", "type": "text" }] },      "seal": null    },    {      "name": "a table pending the move of the object's work stays open",      "table": { "id": "secret", "columns": [{ "key": "name", "type": "text" }] },      "seal": null    },    {      "name": "the object's own internal table stays open",      "table": { "id": "garden_token", "internal": true, "columns": [{ "key": "hash", "type": "text" }] },      "seal": null    },    {      "name": "a sort of words is sealed and sorted on the device; a sort by a number stays clear",      "table": { "id": "seed_packet", "sort": { "column": "variety", "tie": "weight_g" }, "columns": [{ "key": "id", "type": "text" }, { "key": "variety", "type": "text" }, { "key": "weight_g", "type": "number" }, { "key": "notes", "type": "longtext" }] },      "seal": { "clear": ["weight_g"] }    }  ]}