{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.bseshop.com.tr/schemas/plugin-manifest-v1.json",
  "title": "BSE Shop Plugin Manifest v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "$schema",
    "type",
    "slug",
    "name",
    "publisher",
    "version",
    "namespace",
    "entry",
    "translations",
    "requires",
    "dependencies",
    "capabilities",
    "permissions",
    "routes",
    "providers",
    "integrity"
  ],
  "properties": {
    "$schema": {
      "const": "https://docs.bseshop.com.tr/schemas/plugin-manifest-v1.json"
    },
    "type": {
      "const": "bse-plugin"
    },
    "slug": {
      "$ref": "#/$defs/slug"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "publisher": {
      "$ref": "#/$defs/slug"
    },
    "version": {
      "$ref": "#/$defs/semver"
    },
    "namespace": {
      "type": "string",
      "pattern": "^[A-Z][A-Za-z0-9]*(\\\\[A-Z][A-Za-z0-9]*)*$"
    },
    "entry": {
      "$ref": "#/$defs/class"
    },
    "translations": {
      "$ref": "#/$defs/translations"
    },
    "requires": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "core",
        "php",
        "extensions"
      ],
      "properties": {
        "core": {
          "$ref": "#/$defs/range"
        },
        "php": {
          "$ref": "#/$defs/range"
        },
        "extensions": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "pattern": "^[a-z0-9_]+$"
          }
        }
      }
    },
    "dependencies": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "plugins"
      ],
      "properties": {
        "plugins": {
          "type": "object",
          "propertyNames": {
            "$ref": "#/$defs/slug"
          },
          "additionalProperties": {
            "$ref": "#/$defs/range"
          }
        }
      }
    },
    "capabilities": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "enum": [
          "admin.contributions",
          "admin.navigation",
          "hooks",
          "migrations",
          "queue",
          "routes.api",
          "schedule"
        ]
      }
    },
    "permissions": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string",
        "pattern": "^[a-z0-9]+(-[a-z0-9]+)*(\\.[a-z0-9]+(-[a-z0-9]+)*){2,}$"
      }
    },
    "routes": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "kind",
          "name",
          "path",
          "methods",
          "permission",
          "handler"
        ],
        "properties": {
          "kind": {
            "enum": [
              "admin",
              "api",
              "storefront"
            ]
          },
          "name": {
            "type": "string",
            "minLength": 3,
            "maxLength": 160
          },
          "path": {
            "type": "string",
            "pattern": "^/",
            "maxLength": 240
          },
          "methods": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "enum": [
                "DELETE",
                "GET",
                "PATCH",
                "POST",
                "PUT"
              ]
            }
          },
          "permission": {
            "type": [
              "string",
              "null"
            ]
          },
          "handler": {
            "$ref": "#/$defs/class"
          }
        }
      }
    },
    "providers": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "$ref": "#/$defs/class"
      }
    },
    "integrity": {
      "$ref": "#/$defs/integrity"
    },
    "admin": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "id",
          "label_key",
          "route",
          "permission",
          "context",
          "order"
        ],
        "properties": {
          "type": {
            "enum": [
              "navigation",
              "settings",
              "widget",
              "detail_tab",
              "list_column",
              "filter",
              "bulk_action"
            ]
          },
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9]+(-[a-z0-9]+)*(\\.[a-z0-9_]+)+$",
            "maxLength": 160
          },
          "label_key": {
            "type": "string",
            "pattern": "^[a-z0-9]+(-[a-z0-9]+)*::[a-z0-9_.-]+$",
            "maxLength": 160
          },
          "route": {
            "type": [
              "string",
              "null"
            ]
          },
          "permission": {
            "type": "string"
          },
          "context": {
            "type": [
              "string",
              "null"
            ]
          },
          "order": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000
          }
        }
      }
    },
    "jobs": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "handler"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 160
          },
          "handler": {
            "$ref": "#/$defs/class"
          }
        }
      }
    },
    "schedules": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "job",
          "every_minutes"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 160
          },
          "job": {
            "type": "string",
            "maxLength": 160
          },
          "every_minutes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10080
          }
        }
      }
    }
  },
  "$defs": {
    "slug": {
      "type": "string",
      "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
    },
    "semver": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$"
    },
    "range": {
      "type": "string",
      "pattern": "^((>=|<=|>|<|=)?[0-9]+\\.[0-9]+(\\.[0-9]+)?)( ((>=|<=|>|<|=)?[0-9]+\\.[0-9]+(\\.[0-9]+)?))*$"
    },
    "class": {
      "type": "string",
      "pattern": "^[A-Z][A-Za-z0-9]*(\\\\[A-Z][A-Za-z0-9]*)+$"
    },
    "translations": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "format",
        "default_locale",
        "locales"
      ],
      "properties": {
        "format": {
          "const": "json"
        },
        "default_locale": {
          "type": "string",
          "pattern": "^[a-z]{2}(-[A-Z]{2})?$"
        },
        "locales": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "pattern": "^[a-z]{2}(-[A-Z]{2})?$"
          }
        }
      }
    },
    "integrity": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "algorithm",
        "files",
        "signature",
        "key_id"
      ],
      "properties": {
        "algorithm": {
          "const": "sha256"
        },
        "files": {
          "const": "checksums.json"
        },
        "signature": {
          "const": "signature.ed25519"
        },
        "key_id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{2,127}$"
        }
      }
    }
  }
}
