{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://redbook.fun/specification/1.0/schemas/domain-policy.schema.json",
  "title": "Standard response policy and finite rule grammar",
  "$ref": "#/$defs/responsePolicy",
  "$defs": {
    "responsePolicy": {
      "type": "object",
      "properties": {
        "eligibility": {
          "enum": [
            "members",
            "open"
          ],
          "default": "members"
        },
        "reviseSubmitted": {
          "type": "boolean",
          "default": false
        }
      },
      "required": [],
      "additionalProperties": {
        "$ref": "https://redbook.fun/specification/1.0/schemas/value.schema.json"
      }
    },
    "participationPolicy": {
      "type": "object",
      "properties": {
        "enrollment": {
          "enum": [
            "invitation",
            "open"
          ],
          "default": "invitation"
        },
        "conceptualEditing": {
          "enum": [
            "contributors",
            "members"
          ],
          "default": "contributors"
        },
        "extensionAuthoring": {
          "$ref": "https://redbook.fun/specification/1.0/schemas/participant-authoring-policy.schema.json"
        }
      },
      "required": [],
      "additionalProperties": {
        "$ref": "https://redbook.fun/specification/1.0/schemas/value.schema.json"
      }
    },
    "condition": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "all": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/condition"
              }
            }
          },
          "required": [
            "all"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "any": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/condition"
              }
            }
          },
          "required": [
            "any"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "not": {
              "$ref": "#/$defs/condition"
            }
          },
          "required": [
            "not"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "path": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "op": {
              "const": "exists"
            }
          },
          "required": [
            "path",
            "op"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "path": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "op": {
              "enum": [
                "eq",
                "ne",
                "in",
                "contains"
              ]
            },
            "value": {
              "$ref": "https://redbook.fun/specification/1.0/schemas/value.schema.json"
            }
          },
          "required": [
            "path",
            "op",
            "value"
          ],
          "additionalProperties": false
        }
      ]
    },
    "effect": {
      "type": "object",
      "properties": {
        "action": {
          "type": "string",
          "minLength": 1
        },
        "input": {
          "$ref": "https://redbook.fun/specification/1.0/schemas/value.schema.json#/$defs/map"
        }
      },
      "required": [
        "action",
        "input"
      ],
      "additionalProperties": false
    },
    "ruleProperties": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean",
          "default": true
        },
        "priority": {
          "type": "integer",
          "minimum": -9007199254740991,
          "maximum": 9007199254740991,
          "default": 0
        },
        "actions": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "uniqueItems": true
        },
        "mode": {
          "enum": [
            "require",
            "deny",
            "effects"
          ],
          "default": "require"
        },
        "conditions": {
          "oneOf": [
            {
              "type": "object",
              "properties": {},
              "required": [],
              "additionalProperties": false
            },
            {
              "$ref": "#/$defs/condition"
            }
          ]
        },
        "effects": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/effect"
          }
        },
        "mailboxId": {
          "type": "object",
          "properties": {
            "$rb": {
              "const": "reference"
            },
            "id": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "$rb",
            "id"
          ],
          "additionalProperties": false
        }
      },
      "required": [],
      "additionalProperties": {
        "$ref": "https://redbook.fun/specification/1.0/schemas/value.schema.json"
      }
    }
  }
}
