{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://oto-enterprise-os-dtp/rbac/fixtures.schema.json",
  "title": "Bundle de fixtures ERPNext généré depuis rbac_50_roles.json",
  "description": "Contrat de sortie du générateur rbac_fixtures_gen.py. Validé par le validateur maison Publiciste (zéro pip) dans le job CI rbac-fixtures-tests.",
  "type": "object",
  "additionalProperties": false,
  "required": ["manifest", "role", "custom_docperm"],
  "properties": {
    "manifest": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "generated_from",
        "source_version",
        "cible_rbac_roles",
        "counts",
        "custom_doctypes_a_confirmer"
      ],
      "properties": {
        "generated_from": { "type": "string", "const": "rbac_50_roles.json" },
        "source_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
        "cible_rbac_roles": { "type": "integer", "const": 50 },
        "counts": {
          "type": "object",
          "additionalProperties": false,
          "required": ["role", "custom_docperm", "doctypes_uniques"],
          "properties": {
            "role": { "type": "integer", "minimum": 50, "maximum": 50 },
            "custom_docperm": { "type": "integer", "minimum": 1 },
            "doctypes_uniques": { "type": "integer", "minimum": 1 }
          }
        },
        "custom_doctypes_a_confirmer": {
          "type": "array",
          "uniqueItems": true,
          "items": { "type": "string", "minLength": 1 }
        }
      }
    },
    "role": {
      "type": "array",
      "minItems": 50,
      "maxItems": 50,
      "items": { "$ref": "#/definitions/role" }
    },
    "custom_docperm": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/definitions/custom_docperm" }
    }
  },
  "definitions": {
    "flag": { "type": "integer", "enum": [0, 1] },
    "role": {
      "type": "object",
      "additionalProperties": false,
      "required": ["doctype", "name", "role_name", "desk_access", "disabled"],
      "properties": {
        "doctype": { "type": "string", "const": "Role" },
        "name": { "type": "string", "pattern": "^OTO " },
        "role_name": { "type": "string", "pattern": "^OTO " },
        "desk_access": { "$ref": "#/definitions/flag" },
        "disabled": { "$ref": "#/definitions/flag" },
        "two_factor_auth": { "$ref": "#/definitions/flag" },
        "restrict_to_domain": { "type": ["string", "null"] }
      }
    },
    "custom_docperm": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "doctype",
        "parent",
        "parenttype",
        "parentfield",
        "role",
        "permlevel",
        "if_owner",
        "select",
        "read",
        "write",
        "create",
        "delete",
        "submit",
        "cancel",
        "amend",
        "report",
        "export",
        "import",
        "print",
        "email",
        "share",
        "set_user_permissions"
      ],
      "properties": {
        "doctype": { "type": "string", "const": "Custom DocPerm" },
        "parent": { "type": "string", "minLength": 1 },
        "parenttype": { "type": "string", "const": "DocType" },
        "parentfield": { "type": "string", "const": "permissions" },
        "role": { "type": "string", "pattern": "^OTO " },
        "permlevel": { "type": "integer", "minimum": 0 },
        "if_owner": { "$ref": "#/definitions/flag" },
        "select": { "$ref": "#/definitions/flag" },
        "read": { "$ref": "#/definitions/flag" },
        "write": { "$ref": "#/definitions/flag" },
        "create": { "$ref": "#/definitions/flag" },
        "delete": { "$ref": "#/definitions/flag" },
        "submit": { "$ref": "#/definitions/flag" },
        "cancel": { "$ref": "#/definitions/flag" },
        "amend": { "$ref": "#/definitions/flag" },
        "report": { "$ref": "#/definitions/flag" },
        "export": { "$ref": "#/definitions/flag" },
        "import": { "$ref": "#/definitions/flag" },
        "print": { "$ref": "#/definitions/flag" },
        "email": { "$ref": "#/definitions/flag" },
        "share": { "$ref": "#/definitions/flag" },
        "set_user_permissions": { "$ref": "#/definitions/flag" }
      }
    }
  }
}
