{
  "$schema": "https://flow.jig.md/schemas/schema-1.json",
  "title": "Jig project authoring value/1",
  "oneOf": [
    {
      "$ref": "#/$defs/project"
    },
    {
      "$ref": "#/$defs/bindingDefinition"
    }
  ],
  "$defs": {
    "localName": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64
    },
    "projectPath": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1024
    },
    "targetSelector": {
      "type": "string",
      "description": "An exact flow:<project-relative-path> or binding:<LocalName> selector. Jig additionally validates the prefix and canonical target identity.",
      "minLength": 6,
      "maxLength": 1029
    },
    "discoverSource": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "discover"
        },
        "roots": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/projectPath"
          },
          "minItems": 1,
          "maxItems": 65536
        }
      },
      "required": ["kind", "roots"],
      "additionalProperties": false
    },
    "membersSource": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "members"
        },
        "paths": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/projectPath"
          },
          "maxItems": 65536
        }
      },
      "required": ["kind", "paths"],
      "additionalProperties": false
    },
    "source": {
      "oneOf": [
        {
          "$ref": "#/$defs/discoverSource"
        },
        {
          "$ref": "#/$defs/membersSource"
        }
      ]
    },
    "project": {
      "type": "object",
      "properties": {
        "flows": {
          "$ref": "#/$defs/source"
        },
        "bindings": {
          "$ref": "#/$defs/source"
        }
      },
      "additionalProperties": false
    },
    "packageBinding": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "package"
        },
        "package": {
          "$ref": "#/$defs/projectPath"
        },
        "settings": {
          "type": "object",
          "maxProperties": 65536
        },
        "slots": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/targetSelector"
          },
          "maxProperties": 256
        },
        "commands": {
          "$ref": "#/$defs/commands"
        }
      },
      "required": ["kind", "package", "settings", "slots"],
      "additionalProperties": false
    },
    "bindingDefinition": {
      "$ref": "#/$defs/packageBinding"
    },
    "commands": {
      "type": "object",
      "maxProperties": 8,
      "additionalProperties": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "run": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              }
            },
            "required": ["run"],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "test": {
                "type": "array",
                "minItems": 1,
                "maxItems": 16,
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                }
              }
            },
            "required": ["test"],
            "additionalProperties": false
          }
        ]
      }
    }
  }
}
