{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/youtrack-app/latest.json",
  "title": "JetBrains YouTrack App Manifest Schema",
  "description": "Schema for the JetBrains YouTrack app manifest file",
  "x-lintel": {
    "source": "https://www.schemastore.org/youtrack-app.json",
    "sourceSha256": "7aec8f55cef4378512425bfdcb8024b4388ea96ac1322f5c25d8fcaae5300997"
  },
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string",
      "readOnly": true,
      "description": "The URL for the JSON schema that defines the structure of the manifest file."
    },
    "aiToolPrefix": {
      "type": "string",
      "description": "The prefix for AI tool names in the app. The prefix is intended to separate the custom tools from the YouTrack predefined tools and avoid name collisions with other apps. If not set, the app name will be used as a prefix.",
      "pattern": "^[A-Za-z0-9._-]+$"
    },
    "name": {
      "type": "string",
      "description": "The name of the app. This is used as a unique identifier in YouTrack.",
      "pattern": "^[a-z0-9-_.~]+$"
    },
    "title": {
      "type": "string",
      "description": "The title of the app. This is a user-friendly name that is shown in the JetBrains Marketplace and the YouTrack UI."
    },
    "description": {
      "type": "string",
      "description": "The description of the app. You can see this description in the app details on the Apps administration page."
    },
    "version": {
      "$ref": "#/$defs/semver",
      "type": "string",
      "description": "The version number assigned to the app package in major.minor.bugfix format. The default value is '0.0.0'."
    },
    "vendor": {
      "type": "object",
      "description": "An object that contains the description of the app vendor.",
      "properties": {
        "name": {
          "type": "string"
        },
        "url": {
          "$ref": "#/$defs/url"
        },
        "email": {
          "type": "string",
          "format": "email"
        }
      },
      "required": [
        "name"
      ]
    },
    "icon": {
      "$ref": "#/$defs/icon",
      "description": "The name of the file with the app icon. Store this file at the root level of the app package."
    },
    "iconDark": {
      "$ref": "#/$defs/icon",
      "description": "The name of the file with the app icon for the dark theme. Store this file at the root level of the app package. If you don't include a separate icon for the dark theme, YouTrack will use the icon image for both dark and light themes."
    },
    "minYouTrackVersion": {
      "$ref": "#/$defs/semver",
      "type": "string",
      "description": "The minimum YouTrack version with which the app is compatible. If you attempt to upload or install an app in a YouTrack installation that runs a version lower than the value specified in the manifest, the operation fails."
    },
    "maxYouTrackVersion": {
      "$ref": "#/$defs/semver",
      "type": "string",
      "description": "The maximum YouTrack version with which the app is compatible. If you attempt to upload or install an app in a YouTrack installation that runs a version higher than the value specified in the manifest, the operation fails."
    },
    "changeNotes": {
      "type": "string",
      "description": "A description of changes available in a specific version of the app. This information is only displayed in the JetBrains Marketplace."
    },
    "url": {
      "$ref": "#/$defs/url",
      "description": "The website for the app. For example, a GitHub page or landing page for your company or product."
    },
    "visual": {
      "type": "boolean",
      "readOnly": true,
      "description": ""
    },
    "widgets": {
      "type": "array",
      "minItems": 1,
      "description": "An array of widget objects included in the app. Each widget represents a frontend extension.",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "pattern": "^[a-z0-9-_.~]+$",
            "type": "string",
            "description": "The unique key identifier of the widget. This is a mandatory field that must be unique within the app."
          },
          "name": {
            "type": "string",
            "description": "The name of the widget shown in the app settings in YouTrack."
          },
          "indexPath": {
            "type": "string",
            "description": "The path to the index.html file that defines the content and structure of the widget. The path is relative to the widgets folder inside the app package.",
            "pattern": ".*index\\.html(\\?.*)?$"
          },
          "extensionPoint": {
            "type": "string",
            "description": "The location in the YouTrack UI where the widget will be embedded.",
            "anyOf": [
              {
                "$ref": "#/$defs/extensionPoints"
              }
            ]
          },
          "description": {
            "type": "string",
            "description": "The description of the widget."
          },
          "iconPath": {
            "$ref": "#/$defs/icon",
            "description": "The relative path to the file with the icon for the widget inside the app package."
          },
          "permissions:": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "description": "The set of permissions required to view and use the widget. Depending on the app scope, these permissions can be required at the global or project level.",
            "items": {
              "$ref": "#/$defs/permissions"
            }
          },
          "showHeader": {
            "type": "boolean",
            "description": "Controls the global top bar for full screen widgets. If set to false, the app must implement a visually consistent custom header or breadcrumbs."
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "extensionPoint": {
                  "const": "HELPDESK_CHANNEL"
                }
              },
              "required": [
                "extensionPoint"
              ],
              "type": "object"
            },
            "then": {
              "required": [
                "description",
                "iconPath"
              ]
            }
          },
          {
            "if": {
              "not": {
                "anyOf": [
                  {
                    "properties": {
                      "extensionPoint": {
                        "const": "MARKDOWN"
                      }
                    },
                    "required": [
                      "extensionPoint"
                    ],
                    "type": "object"
                  },
                  {
                    "properties": {
                      "extensionPoint": {
                        "const": "DASHBOARD_WIDGET"
                      }
                    },
                    "required": [
                      "extensionPoint"
                    ],
                    "type": "object"
                  }
                ]
              }
            },
            "then": {
              "properties": {
                "expectedDimensions": {
                  "$ref": "#/$defs/expectedDimensions"
                }
              }
            },
            "else": {
              "properties": {
                "settingsSchemaPath": {
                  "$ref": "#/$defs/settingsSchemaPath"
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "extensionPoint": {
                  "const": "MARKDOWN"
                }
              },
              "required": [
                "extensionPoint"
              ],
              "type": "object"
            },
            "then": {
              "properties": {
                "defaultDimensions": {
                  "$ref": "#/$defs/defaultDimensions",
                  "properties": {
                    "width": {
                      "$ref": "#/$defs/pixelOrPercentValue"
                    },
                    "height": {
                      "$ref": "#/$defs/pixelOrPercentValue"
                    }
                  },
                  "type": "object"
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "extensionPoint": {
                  "const": "DASHBOARD_WIDGET"
                }
              },
              "required": [
                "extensionPoint"
              ],
              "type": "object"
            },
            "then": {
              "properties": {
                "defaultDimensions": {
                  "$ref": "#/$defs/defaultDimensions",
                  "properties": {
                    "width": {
                      "$ref": "#/$defs/fractionValue"
                    },
                    "height": {
                      "$ref": "#/$defs/fractionValue"
                    }
                  },
                  "type": "object"
                }
              }
            }
          },
          {
            "if": {
              "not": {
                "anyOf": [
                  {
                    "properties": {
                      "extensionPoint": {
                        "const": "MAIN_MENU_ITEM"
                      }
                    },
                    "required": [
                      "extensionPoint"
                    ],
                    "type": "object"
                  },
                  {
                    "properties": {
                      "extensionPoint": {
                        "const": "ADMINISTRATION_MENU_ITEM"
                      }
                    },
                    "required": [
                      "extensionPoint"
                    ],
                    "type": "object"
                  }
                ]
              }
            },
            "then": {
              "properties": {
                "showHeader": {
                  "not": {}
                }
              }
            }
          }
        ],
        "required": [
          "key",
          "name",
          "indexPath",
          "extensionPoint"
        ]
      }
    }
  },
  "required": [
    "name"
  ],
  "additionalProperties": true,
  "$defs": {
    "semver": {
      "type": "string",
      "minLength": 5,
      "maxLength": 14,
      "pattern": "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$"
    },
    "url": {
      "type": "string",
      "format": "url",
      "minLength": 1,
      "maxLength": 255
    },
    "expectedDimensions": {
      "type": "object",
      "description": "The expected dimensions of the widget in pixels. YouTrack will try to display the widget according to these dimensions if the monitor settings allow.",
      "properties": {
        "width": {
          "type": "integer"
        },
        "height": {
          "type": "integer"
        }
      }
    },
    "defaultDimensions": {
      "type": "object",
      "description": "The default width and height of the widget."
    },
    "settingsSchemaPath": {
      "type": "string",
      "description": "The path to the JSON file that stores the settings scheme for Markdown and dashboard widgets.",
      "pattern": ".*\\.json$"
    },
    "icon": {
      "type": "string",
      "pattern": ".*\\.(svg|png|jpg|jpeg|ico)$"
    },
    "pixelOrPercentValue": {
      "type": "string",
      "pattern": "^(\\d+px|\\d+%$)"
    },
    "fractionValue": {
      "type": "string",
      "pattern": "^[1-9]\\d*fr$"
    },
    "permissions": {
      "type": "string",
      "enum": [
        "READ_PROJECT_BASIC",
        "CREATE_PROJECT",
        "READ_PROJECT",
        "UPDATE_PROJECT",
        "DELETE_PROJECT",
        "READ_USERGROUP",
        "CREATE_USERGROUP",
        "UPDATE_USERGROUP",
        "DELETE_USERGROUP",
        "READ_ORGANIZATION",
        "UPDATE_ORGANIZATION",
        "CREATE_ORGANIZATION",
        "DELETE_ORGANIZATION",
        "UPDATE_PROFILE",
        "READ_USER_BASIC",
        "READ_USER",
        "UPDATE_USER",
        "CREATE_USER",
        "DELETE_USER",
        "READ_ROLE",
        "MANAGE_ROLE",
        "ADMIN_READ_APP",
        "ADMIN_UPDATE_APP",
        "READ_ISSUE",
        "PRIVATE_READ_ISSUE",
        "UPDATE_ISSUE",
        "CREATE_ISSUE",
        "DELETE_ISSUE",
        "LINK_ISSUE",
        "PRIVATE_UPDATE_ISSUE",
        "APPLY_COMMANDS_SILENTLY",
        "VIEW_WATCHERS",
        "UPDATE_WATCHERS",
        "VIEW_VOTERS",
        "CREATE_ATTACHMENT_ISSUE",
        "UPDATE_ATTACHMENT_ISSUE",
        "DELETE_ATTACHMENT_ISSUE",
        "CREATE_COMMENT",
        "READ_COMMENT",
        "UPDATE_COMMENT",
        "DELETE_COMMENT",
        "UPDATE_NOT_OWN_COMMENT",
        "DELETE_NOT_OWN_COMMENT",
        "READ_HIDDEN_STUFF",
        "CREATE_WATCH_FOLDER",
        "UPDATE_WATCH_FOLDER",
        "DELETE_WATCH_FOLDER",
        "SHARE_WATCH_FOLDER",
        "READ_WORK_ITEM",
        "UPDATE_WORK_ITEM"
      ]
    },
    "extensionPoints": {
      "type": "string",
      "enum": [
        "ADMINISTRATION_MENU_ITEM",
        "ARTICLE_ABOVE_ACTIVITY_STREAM",
        "ARTICLE_BELOW_SUMMARY",
        "ARTICLE_OPTIONS_MENU_ITEM",
        "DASHBOARD_WIDGET",
        "HELPDESK_CHANNEL",
        "ISSUE_ABOVE_ACTIVITY_STREAM",
        "ISSUE_BELOW_SUMMARY",
        "ISSUE_FIELD_PANEL_FIRST",
        "ISSUE_FIELD_PANEL_LAST",
        "ISSUE_OPTIONS_MENU_ITEM",
        "MAIN_MENU_ITEM",
        "MARKDOWN",
        "PROJECT_TAB",
        "PROJECT_SETTINGS",
        "USER_CARD",
        "USER_PROFILE_SETTINGS"
      ]
    }
  }
}
