{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://schemas.apps.smartmate.io/processes/processPermissions/processPermissions.schema.json",
  "$$target": "https://schemas.apps.smartmate.io/processes/processPermissions/processPermissions.schema.json",
  "type": "object",
  "title": "permissions",
  "description": "Process permissions to start, pause, reassign or archive cases. See :ref:`Process permissions <process-permissions>` for more information.`",
  "propertyNames": {
    "allOf": [{
      "type": "string",
      "pattern": "^([a-zA-Z][a-zA-Z_0-9.]*)$",
      "minLength": 2,
      "maxLength": 81,
      "description": "The key must correspond to a valid :ref:`app role <app-roles>`.",
      "examples": [
        "recruiter"
      ]
    }]
  },
  "patternProperties": {
    "": {
      "oneOf": [
        {
          "type": "boolean",
          "description": "``true`` grants all permissions. ``false`` deny all."
        },
        {
          "$ref": "#/definitions/validObjectOptions"
        }
      ]
    }
  },
  "definitions": {
    "validObjectOptions": {
        "type": "object",
        "properties": {
          "start": {
            "type": "boolean",
            "description": "Indicates if the user can start a case of this process"
          },
          "pause": {
            "oneOf": [
              {
                "type": "boolean",
                "description": "Indicates if the user can pause cases."
              },
              {
                "type": "object",
                "propertyNames": {
                  "type": "string",
                  "enum": ["own", "assigned", "any"]
                },
                "patternProperties": {
                    "": {
                      "type": "boolean"
                    }
                },
                "additionalProperties": false
              }
            ]
          },
          "archive": {
            "oneOf": [
              {
                "type": "boolean",
                "description": "Indicates if the user can archive cases"
              },
              {
                "type": "object",
                "propertyNames": {
                  "type": "string",
                  "enum": ["own", "assigned", "any"]
                },
                "patternProperties": {
                    "": {
                      "type": "boolean"
                    }
                },
                "additionalProperties": false
              }
            ]
          },
          "reassign": {
            "oneOf": [
              {
                "type": "boolean",
                "description": "Indicates if the user can reassign cases."
              },
              {
                "type": "object",
                "propertyNames": {
                  "type": "string",
                  "enum": ["own", "assigned", "any"]
                },
                "patternProperties": {
                    "": {
                      "type": "boolean"
                    }
                },
                "additionalProperties": false
              }
            ]
          }
        },
        "additionalProperties": false
    }
  },
  "additionalProperties": false
}
