{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://cbsshekhawat18-lab.github.io/karni/assets/karni-spec.schema.json",
  "title": "karni.yaml",
  "description": "Experimental. A whole ``karni.yaml``.",
  "$defs": {
    "Access": {
      "additionalProperties": false,
      "description": "Experimental. ``access:`` of an entity: the viewset's ``Access(...)``.\n\nEach slot takes ``public``, ``authenticated``, ``granted``,\n``role:<slug>``, ``owned:<field>``, ``where:<field>[=<value>]``, or a\nlist of them (any of them admits). ``read`` and ``write`` default to\n``granted``, ``create`` and ``delete`` to ``write``; ``assign`` (who may\nset the owner to another user) to nobody.",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "read": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            }
          ],
          "description": "Who sees which rows (list, detail)."
        },
        "write": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            }
          ],
          "description": "Who changes and deletes which rows."
        },
        "create": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "description": "Who creates rows (default: write)."
        },
        "delete": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "description": "Experimental. Who deletes which rows (default: write)."
        },
        "assign": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "description": "Experimental. Who may set the owner field (owned:<field> in write or create) to another user. Default: nobody, the owner is the signed-in user."
        }
      },
      "type": "object"
    },
    "ActionRule": {
      "additionalProperties": false,
      "description": "Experimental. One ``actions:`` entry: a row action (the viewset's row_actions).",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "from": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            }
          ],
          "description": "The states the action runs from (default: any)."
        },
        "to": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The state it moves the row to. Without it the viewset's own method of the action's name does the work."
        },
        "by": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "description": "Who may run it, in access words (default: write)."
        },
        "field": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The state field (default: the entity's only state field)."
        }
      },
      "type": "object"
    },
    "Aggregate": {
      "additionalProperties": false,
      "description": "Experimental. ``aggregate:`` of an entity: ``class Karni: aggregate``.\n\nWhat ``GET <resource>/aggregate/`` may group by and sum (docs/aggregations.md).\nExpressions (``TextNumber`` and your own) stay in the project's code.",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "group_by": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            }
          ],
          "description": "Fields or relation paths (category__parent) a request may group by. A date or datetime field takes :year, :quarter or :month, or allows every bucket without one."
        },
        "values": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            }
          ],
          "description": "Fields a metric other than a plain count reads."
        },
        "metrics": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "description": "The metrics a request may name, of count, sum, avg, min, max, distinct_count (default: all of them)."
        }
      },
      "required": [
        "group_by"
      ],
      "type": "object"
    },
    "ApiCache": {
      "additionalProperties": false,
      "description": "Experimental. ``features.api_cache`` as a mapping: on, with its lifetime.",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "ttl": {
          "description": "KARNI_API_CACHE_TTL: the seconds a cached response lives (default 300).",
          "type": "integer"
        }
      },
      "required": [
        "ttl"
      ],
      "type": "object"
    },
    "App": {
      "additionalProperties": false,
      "description": "Experimental. One Django app of ``apps:`` and its entities.",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "route": {
          "anyOf": [
            {
              "pattern": "^/[a-z0-9][a-z0-9-]*(/[a-z0-9][a-z0-9-]*)*$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Experimental. The base path its entity pages are mounted under (/bookings: the resources list is /bookings/resources). Default: none, each page at /<route>. karni recipes add sets /<label> for a recipe's app."
        },
        "entities": {
          "additionalProperties": {
            "$ref": "#/$defs/Entity"
          },
          "description": "Entity name (PascalCase) -> entity.",
          "propertyNames": {
            "pattern": "^(?:x-.*|[A-Z][A-Za-z0-9]*)$"
          },
          "type": "object"
        }
      },
      "type": "object"
    },
    "AppInfo": {
      "additionalProperties": false,
      "description": "Experimental. ``app:``: what the project is.",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "name": {
          "description": "The project's name, as given to karni new.",
          "type": "string"
        },
        "kind": {
          "default": "app",
          "description": "The project's kind, as karni new --kind: site, app or site+app.",
          "enum": [
            "site",
            "app",
            "site+app"
          ],
          "type": "string"
        },
        "recipe": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Deprecated: write recipes: [<name>]. Read as a list of one until Karni 1.0, with a deprecation warning."
        },
        "recipes": {
          "description": "Experimental. The recipes this project holds, in the order they were added. karni recipes add and remove keep it, and karni build writes a new one's files.",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "currency": {
          "anyOf": [
            {
              "pattern": "^[A-Z]{3}$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Experimental. The project's currency, an ISO 4217 code (EUR). A money field without a currency of its own is in it, and the payments module's currency follows it."
        },
        "api_version": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "KARNI_API_VERSION: the API's current version, e.g. v1. The API is then mounted at /api/v1/ (karni.api.versions). Leave it out for an unversioned API.",
          "pattern": "^[a-z0-9][a-z0-9-]{0,15}$"
        }
      },
      "required": [
        "name"
      ],
      "type": "object"
    },
    "Bound": {
      "additionalProperties": false,
      "description": "Experimental. One field's ``bounds``: its lowest and highest value.",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "min": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The lowest value: a number, a date, $now or $today."
        },
        "max": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The highest value: a number, a date, $now or $today."
        }
      },
      "type": "object"
    },
    "DashboardTile": {
      "additionalProperties": false,
      "description": "Experimental. One ``dashboard:`` tile: a box on the home page of the roles it names.\n\nA tile with ``entity`` counts (``stat``) or lists (``list``) that entity's\nrows matching ``filters``, through its list endpoint. A tile whose\n``key`` names a tile an app declares in code (``<app>/dashboard.py``:\n``commerce.revenue``) places it: its title, order, size and who sees it,\nor ``hidden: true``.",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "key": {
          "description": "A unique name, prefixed by its part: shop.to_send.",
          "pattern": "^[a-z][a-z0-9_]*\\.[a-z][a-z0-9_]*$",
          "type": "string"
        },
        "title": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "What the tile says at the top."
        },
        "kind": {
          "anyOf": [
            {
              "enum": [
                "stat",
                "list",
                "chart",
                "custom"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "stat (a number), list (the first rows), chart or custom."
        },
        "entity": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The entity whose rows it counts or lists."
        },
        "filters": {
          "anyOf": [
            {
              "additionalProperties": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "integer"
                  },
                  {
                    "type": "boolean"
                  },
                  {
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  }
                ]
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "description": "API filters of the entity's list: {status: processing}, {stock__lte: 3}. A date may be today, today-7 or today+1."
        },
        "columns": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "description": "A list tile's columns (fields)."
        },
        "limit": {
          "anyOf": [
            {
              "maximum": 25,
              "minimum": 1,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "description": "How many rows a list tile shows."
        },
        "link": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Where a click on the tile goes (an app path)."
        },
        "requires": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "authenticated, * or a permission pattern (app.entity:action). Default: the entity's view permission, else authenticated."
        },
        "roles": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "description": "Only these roles see it."
        },
        "order": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "description": "Its place among the tiles, smallest first."
        },
        "size": {
          "anyOf": [
            {
              "enum": [
                "third",
                "half",
                "full"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "Its width."
        },
        "description": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "A line under the title."
        },
        "hidden": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "description": "true takes a code tile off the home."
        }
      },
      "required": [
        "key"
      ],
      "type": "object"
    },
    "DeleteRule": {
      "additionalProperties": false,
      "description": "Experimental. ``delete:`` of an entity: when a row may be deleted (class Karni: delete).",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "when": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "description": "A row filter the row must match to be deleted (its state)."
        },
        "blocked_by": {
          "description": "Entities whose live rows pointing here keep the row (Deal, Deal.company), or a mapping of them to a row filter of the rows that count.",
          "oneOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "additionalProperties": {
                "anyOf": [
                  {
                    "additionalProperties": true,
                    "type": "object"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "type": "object"
            }
          ]
        }
      },
      "type": "object"
    },
    "DetailOptions": {
      "additionalProperties": false,
      "description": "Experimental. What a detail page shows besides the record: ``{related: [Deal, Person]}``.",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "related": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            }
          ],
          "description": "A tab per reverse relation, each a table of the related rows filtered to the record: an entity with a fk to this one (Deal), or Entity.field when it has two (Deal.partner)."
        }
      },
      "type": "object"
    },
    "DetailPage": {
      "additionalProperties": false,
      "description": "Experimental. An entity's detail page with options: ``{detail: {related: [Deal]}}``.",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "detail": {
          "$ref": "#/$defs/DetailOptions",
          "description": "The detail page's options."
        }
      },
      "required": [
        "detail"
      ],
      "type": "object"
    },
    "Entity": {
      "additionalProperties": false,
      "description": "Experimental. One entity: a model on BaseModel or BigIntBaseModel, its viewset and options.",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "fields": {
          "additionalProperties": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "$ref": "#/$defs/FieldEntry"
              }
            ]
          },
          "description": "Field name -> type, in karni make model's syntax (types: str text int float decimal bool date datetime url file image uuid choice state daterange datetimerange capacity fk m2m o2o money percent quantity email slug phone markdown country currency json array), a trailing ? for optional. Or {type, was} to rename a field and keep its rows.",
          "propertyNames": {
            "pattern": "^(?:x-.*|[a-z][a-z0-9_]*)$"
          },
          "type": "object"
        },
        "was": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The entity's old name in the same app: a rename that keeps the table's rows."
        },
        "pk": {
          "anyOf": [
            {
              "enum": [
                "uuid",
                "bigint"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The key type: uuid (BaseModel) or bigint (BigIntBaseModel). Default: the project's KARNI_PK."
        },
        "external": {
          "default": false,
          "description": "A table or view another system owns: Meta.managed = False and class Karni: external = True. No migration changes it, and it is read-only unless writable.",
          "type": "boolean"
        },
        "table": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "With external: the table or view, as [schema.]table (Meta.db_table)."
        },
        "writable": {
          "default": false,
          "description": "With external: the API and the admin may write it (Karni.writable).",
          "type": "boolean"
        },
        "database": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The DATABASES alias its reads, writes and migrations go to (Karni.database). Default: default."
        },
        "tree": {
          "default": false,
          "description": "Experimental. A hierarchy: true inherits TreeModel (a parent field and the tree endpoints), ordered inherits OrderedTreeModel (also a position among siblings).",
          "oneOf": [
            {
              "type": "boolean"
            },
            {
              "const": "ordered",
              "type": "string"
            }
          ]
        },
        "taxonomies": {
          "additionalProperties": {
            "type": "string"
          },
          "description": "Experimental. Tag the entity to tree entities: key -> tree entity (Name or app.Name). Each key is a many-to-many of that name, with the list filters ?<key>= and ?<key>_descendants=, the facets/ counts and the tree:<key> scope (class Karni: taxonomies).",
          "propertyNames": {
            "pattern": "^(?:x-.*|[a-z][a-z0-9_]*)$"
          },
          "type": "object"
        },
        "key": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The natural key imports match rows on (Karni.import_key)."
        },
        "help": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "One line that says what the entity is for, shown at the top of its admin list and form (class Karni: help). Without it the admin shows no line."
        },
        "search": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            }
          ],
          "description": "The viewset's search_fields."
        },
        "global_search": {
          "default": false,
          "description": "Cross-model search (class Karni: search, GET /api/search/): true, or a mapping {fields, title, subtitle, weight}. The fields default to search.",
          "oneOf": [
            {
              "type": "boolean"
            },
            {
              "$ref": "#/$defs/GlobalSearch"
            }
          ]
        },
        "owner": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The owner field the own scope uses (Karni.owner_field)."
        },
        "audit": {
          "default": false,
          "description": "Change history (Karni.audit): true, or a list of fields.",
          "oneOf": [
            {
              "type": "boolean"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            }
          ]
        },
        "groups": {
          "additionalProperties": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "description": "Field groups: title -> fields (Karni.field_groups): sections of the React form and detail page and fieldsets of the admin. The fields in no group come last, in Other.",
          "type": "object"
        },
        "column_sets": {
          "additionalProperties": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "description": "Column presets of the React table: name -> fields (Karni.column_sets). The set named default shows first, else the first set.",
          "propertyNames": {
            "pattern": "^[a-z][a-z0-9_]*$"
          },
          "type": "object"
        },
        "order": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            }
          ],
          "description": "Default ordering (Meta.ordering), - for descending."
        },
        "scope_paths": {
          "additionalProperties": {
            "type": "string"
          },
          "description": "Keys the related:<key> scope uses -> lookup path (Karni.scope_paths).",
          "type": "object"
        },
        "access": {
          "description": "Who reads and writes: a mapping {read, write, create}, or code.",
          "oneOf": [
            {
              "const": "code",
              "type": "string"
            },
            {
              "$ref": "#/$defs/Access"
            }
          ]
        },
        "aggregate": {
          "anyOf": [
            {
              "$ref": "#/$defs/Aggregate"
            },
            {
              "type": "null"
            }
          ],
          "description": "What GET <resource>/aggregate/ may group by and sum (Karni.aggregate): group_by, values, metrics."
        },
        "cache": {
          "anyOf": [
            {
              "oneOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "integer"
                }
              ]
            },
            {
              "type": "null"
            }
          ],
          "description": "The viewset's response caching: a lifetime in seconds (Cache(ttl=...)), or false (Uncached(reason=\"spec\")). Default: KARNI_API_CACHE and KARNI_API_CACHE_TTL."
        },
        "bounds": {
          "additionalProperties": {
            "$ref": "#/$defs/Bound"
          },
          "description": "Experimental. Field -> {min, max}: the lowest and highest value of a number, date or datetime ($now and $today for dates). class Karni: bounds.",
          "type": "object"
        },
        "unique": {
          "description": "Experimental. Fields unique together among the live rows: a list of fields, or {fields, where} with a row filter. A partial unique index (class Karni: unique).",
          "items": {
            "oneOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "$ref": "#/$defs/UniqueEntry"
              }
            ]
          },
          "type": "array"
        },
        "targets": {
          "additionalProperties": {
            "additionalProperties": true,
            "type": "object"
          },
          "description": "Experimental. Foreign key -> a row filter the row it points at must match ($me, $now, $today, $<field>). class Karni: targets.",
          "type": "object"
        },
        "frozen": {
          "additionalProperties": {
            "oneOf": [
              {
                "type": "boolean"
              },
              {
                "additionalProperties": true,
                "type": "object"
              }
            ]
          },
          "description": "Experimental. Field -> true (never changes after create) or a row filter (cannot change while the row matches it). class Karni: frozen.",
          "type": "object"
        },
        "delete": {
          "anyOf": [
            {
              "$ref": "#/$defs/DeleteRule"
            },
            {
              "type": "null"
            }
          ],
          "description": "Experimental. When a row may be deleted: {when, blocked_by} (class Karni: delete). Who may delete is access.delete."
        },
        "moves": {
          "additionalProperties": {
            "$ref": "#/$defs/MoveRule"
          },
          "description": "Experimental. State (or boolean field becoming true) -> {requires, needs, stamps} (class Karni: moves).",
          "type": "object"
        },
        "actions": {
          "additionalProperties": {
            "$ref": "#/$defs/ActionRule"
          },
          "description": "Experimental. Row actions: name -> {from, to, by, field}, POST <resource>/<id>/<name>/ (the viewset's row_actions, x-karni-actions).",
          "propertyNames": {
            "pattern": "^(?:x-.*|[a-z][a-z0-9_]*)$"
          },
          "type": "object"
        }
      },
      "type": "object"
    },
    "Features": {
      "additionalProperties": false,
      "description": "Experimental. ``features:``: built-in options, each switched by a setting.",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "two_factor": {
          "default": false,
          "description": "KARNI_2FA. Needs karni[2fa].",
          "type": "boolean"
        },
        "email_code_login": {
          "default": false,
          "description": "KARNI_EMAIL_OTP: sign-in with a code.",
          "type": "boolean"
        },
        "social_login": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            }
          ],
          "description": "KARNI_SOCIAL_TOKEN_PROVIDERS: the providers, of google, microsoft, apple. Their client ids stay in settings or .env. Needs karni[social-token]."
        },
        "terms": {
          "anyOf": [
            {
              "$ref": "#/$defs/Terms"
            },
            {
              "type": "null"
            }
          ],
          "description": "KARNI_TERMS: the terms acceptance gate."
        },
        "people": {
          "default": false,
          "description": "Experimental. KARNI_PEOPLE: the people contract (karni.people). A relation to people.Person switches it on too.",
          "type": "boolean"
        },
        "events": {
          "default": false,
          "description": "Experimental. Family events: karni.outbox in INSTALLED_APPS.",
          "type": "boolean"
        },
        "preferences": {
          "default": false,
          "description": "Experimental. The preferences contract: karni.preferences in INSTALLED_APPS, the business's details, one settings section per part, connections and email switches behind the Settings page.",
          "type": "boolean"
        },
        "timeline": {
          "default": false,
          "description": "Experimental. The timeline contract: karni.timeline in INSTALLED_APPS. It needs people and events, which it switches on too.",
          "type": "boolean"
        },
        "notify": {
          "default": false,
          "description": "Experimental. The notifications contract: karni.notify in INSTALLED_APPS, the emails a business edits in the app, the inbox, each person's switches and unsubscribing from marketing emails.",
          "type": "boolean"
        },
        "user_grants": {
          "default": false,
          "description": "KARNI_USER_GRANTS: per-user grants next to the role grants.",
          "type": "boolean"
        },
        "api_cache": {
          "default": false,
          "description": "KARNI_API_CACHE: cached list and detail responses, invalidated on every write. true, or {ttl: <seconds>} to set KARNI_API_CACHE_TTL too.",
          "oneOf": [
            {
              "type": "boolean"
            },
            {
              "$ref": "#/$defs/ApiCache"
            }
          ]
        }
      },
      "type": "object"
    },
    "FieldEntry": {
      "additionalProperties": false,
      "description": "Experimental. A field written as a mapping, to say what it was called before.\n\n``title: {type: \"str:200\", was: name}`` is the field ``title`` of type\n``str:200``, which ``karni plan`` and ``karni build`` treat as the field\n``name`` renamed: the column keeps its rows.",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "type": {
          "description": "The field's type, as in the short form (str:200, fk:Studio).",
          "type": "string"
        },
        "was": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The field's old name: a rename that keeps the column and its rows."
        }
      },
      "required": [
        "type"
      ],
      "type": "object"
    },
    "GlobalSearch": {
      "additionalProperties": false,
      "description": "Experimental. ``global_search:`` of an entity as a mapping: ``class Karni: search``.\n\nEvery key is optional. ``fields`` defaults to the entity's ``search``\nlist, ``title`` to the first field, ``weight`` to 1.",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "fields": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "description": "The text fields the query is matched with (default: search)."
        },
        "title": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The field a hit shows as its title (default: the first field)."
        },
        "subtitle": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "A field shown under the title, or a path through a relation."
        },
        "weight": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            }
          ],
          "default": 1,
          "description": "Multiplies the entity's scores across entities (default 1).",
          "gt": 0
        }
      },
      "type": "object"
    },
    "MoveRule": {
      "additionalProperties": false,
      "description": "Experimental. One ``moves:`` entry: what a move into a state needs (class Karni: moves).",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "requires": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            }
          ],
          "description": "Fields that must hold a value after the move."
        },
        "needs": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            }
          ],
          "description": "Entities that must have a live row pointing here (Lesson, Lesson.course)."
        },
        "stamps": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            }
          ],
          "description": "Date or datetime fields set to now by the move."
        },
        "notify": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "A path to the user an email about the move goes to (member), from the templates <app>/email/<entity>_<state>_subject.txt and _body.txt."
        }
      },
      "type": "object"
    },
    "NavigationEntry": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "additionalProperties": {
            "oneOf": [
              {
                "items": {
                  "$ref": "#/$defs/NavigationEntry"
                },
                "type": "array"
              },
              {
                "$ref": "#/$defs/NavigationOptions"
              }
            ]
          },
          "type": "object",
          "minProperties": 1,
          "maxProperties": 1
        }
      ]
    },
    "NavigationOptions": {
      "additionalProperties": false,
      "description": "Experimental. A ``navigation:`` entry written as a mapping's value: a page's or a group's options.\n\nA page takes ``label``, ``icon`` and ``requires``. A group takes\n``items`` (its entries), ``icon`` and ``requires``.",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "label": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "A page's label in the menu (default: its title)."
        },
        "icon": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "An icon name the frontend knows, e.g. home."
        },
        "requires": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "public, authenticated or a permission pattern (app.entity:action). Default: from the page's access, and for a group public when one of its entries is."
        },
        "items": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/NavigationEntry"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "description": "A group's entries."
        }
      },
      "type": "object"
    },
    "Role": {
      "additionalProperties": false,
      "description": "Experimental. One role of ``roles:``: an entry of ``KARNI_ROLES``.",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "The role's name (default: from the slug)."
        },
        "description": {
          "default": "",
          "description": "What the role is for.",
          "type": "string"
        },
        "system": {
          "default": false,
          "description": "A system role cannot be deleted in the admin.",
          "type": "boolean"
        },
        "default": {
          "type": "boolean",
          "default": false,
          "description": "Every self-registered user gets it (KARNI_ACCOUNTS_DEFAULT_ROLES)."
        },
        "grants": {
          "additionalProperties": {
            "type": "string"
          },
          "description": "Permission pattern -> scope. Patterns: \"*\", app.entity, app.entity:action, with * for a part. Scopes: all, own, own:<owner field>, related:<scope path key>, custom:<registered name>, tree:<path to a tree entity> (experimental).",
          "type": "object"
        }
      },
      "type": "object"
    },
    "Terms": {
      "additionalProperties": false,
      "description": "Experimental. ``features.terms``: ``KARNI_TERMS``.",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "version": {
          "description": "The current terms version, e.g. 2026-11.",
          "type": "string"
        },
        "url": {
          "description": "Where the terms are, e.g. /terms/.",
          "type": "string"
        },
        "required": {
          "default": true,
          "description": "False keeps the routes and gates nothing.",
          "type": "boolean"
        },
        "paths": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "description": "URL prefixes the gate covers (default [\"/api/\"])."
        },
        "exempt": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "description": "URL prefixes the gate leaves open."
        }
      },
      "required": [
        "version",
        "url"
      ],
      "type": "object"
    },
    "UniqueEntry": {
      "additionalProperties": false,
      "description": "Experimental. One ``unique`` entry written as a mapping: its fields and a row filter.",
      "patternProperties": {
        "^x-": {}
      },
      "properties": {
        "fields": {
          "description": "The fields whose values are unique together.",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "where": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "description": "Only the live rows matching this filter count (fixed values only)."
        }
      },
      "required": [
        "fields"
      ],
      "type": "object"
    }
  },
  "additionalProperties": false,
  "patternProperties": {
    "^x-": {}
  },
  "properties": {
    "version": {
      "const": 1,
      "description": "The format version: 1.",
      "type": "integer"
    },
    "app": {
      "$ref": "#/$defs/AppInfo",
      "description": "What the project is."
    },
    "modules": {
      "additionalProperties": {
        "anyOf": [
          {
            "type": "object"
          },
          {
            "type": "null"
          }
        ]
      },
      "description": "karni add <name>, with the module's options (its KARNI_<MODULE>_* settings).",
      "propertyNames": {
        "anyOf": [
          {
            "enum": [
              "ai",
              "approvals",
              "charts",
              "commerce",
              "game",
              "impersonation",
              "payments",
              "reports",
              "site",
              "storage"
            ]
          },
          {
            "pattern": "^x-"
          }
        ]
      },
      "type": "object"
    },
    "features": {
      "$ref": "#/$defs/Features",
      "description": "Built-in options."
    },
    "roles": {
      "additionalProperties": {
        "$ref": "#/$defs/Role"
      },
      "description": "KARNI_ROLES: slug -> role.",
      "propertyNames": {
        "pattern": "^(?:x-.*|[A-Za-z0-9][A-Za-z0-9_.-]*)$"
      },
      "type": "object"
    },
    "apps": {
      "additionalProperties": {
        "$ref": "#/$defs/App"
      },
      "description": "App label -> app.",
      "propertyNames": {
        "pattern": "^(?:x-.*|[a-z][a-z0-9_]*)$"
      },
      "type": "object"
    },
    "pages": {
      "description": "karni make page, in navigation order. Each item is one key: an entity with its pages (list, detail, form, or {detail: {related: [Deal]}} for related tabs), or a page name with its kind (blank, login, dashboard: the scaffold's home page for home and a page of charts for any other name, or code: a page of the project's own at /<name>, which karni build leaves alone).",
      "items": {
        "additionalProperties": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "$ref": "#/$defs/DetailPage"
                  }
                ]
              },
              "type": "array"
            }
          ]
        },
        "type": "object",
        "minProperties": 1,
        "maxProperties": 1
      },
      "type": "array"
    },
    "navigation": {
      "default": false,
      "description": "Experimental. The menu karni build writes to KARNI_NAVIGATION: true for every page of pages in their order, or a list of pages (by their key) and groups ({label: [entries]}), each page with optional {label, icon, requires}, or named menus ({app: [...], public: [...], account: [...]}), each such a list.",
      "oneOf": [
        {
          "type": "boolean"
        },
        {
          "items": {
            "$ref": "#/$defs/NavigationEntry"
          },
          "type": "array"
        },
        {
          "patternProperties": {
            "^[a-z][a-z0-9_-]{0,39}$": {
              "items": {
                "$ref": "#/$defs/NavigationEntry"
              },
              "type": "array"
            }
          },
          "type": "object"
        }
      ]
    },
    "dashboard": {
      "description": "Experimental. The home tiles karni build writes to KARNI_DASHBOARD_TILES: each counts or lists an entity's rows for the roles it names, or places a tile an app declares in code.",
      "items": {
        "$ref": "#/$defs/DashboardTile"
      },
      "type": "array"
    },
    "seed": {
      "additionalProperties": {
        "type": "integer"
      },
      "description": "Entity -> demo rows per karni seed run (a Seeder's Meta.count).",
      "propertyNames": {
        "pattern": "^(?:x-.*|[A-Z][A-Za-z0-9]*)$"
      },
      "type": "object"
    }
  },
  "required": [
    "version",
    "app"
  ],
  "type": "object"
}
