{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "kintone plugin manifest.json",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string",
      "format": "uri"
    },
    "manifest_version": {
      "type": "integer",
      "minimum": 1
    },
    "version": {
      "oneOf": [
        {
          "type": "integer",
          "minimum": 0
        },
        {
          "type": "string",
          "pattern": "^(0|[1-9]\\d*)(?:\\.(0|[1-9]\\d*))?(?:\\.(0|[1-9]\\d*))?$"
        }
      ]
    },
    "type": {
      "type": "string",
      "enum": ["APP"]
    },
    "name": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "ja": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "requiredProperties": {
            "items": [
              {
                "homepage_url": {
                  "properties": ["ja"]
                }
              }
            ],
            "warn": true
          }
        },
        "en": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "requiredProperties": {
            "items": [
              {
                "homepage_url": {
                  "properties": ["en"]
                }
              }
            ],
            "warn": true
          }
        },
        "zh": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "requiredProperties": {
            "items": [
              {
                "homepage_url": {
                  "properties": ["zh"]
                }
              }
            ],
            "warn": true
          }
        },
        "zh-TW": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "requiredProperties": {
            "items": [
              {
                "homepage_url": {
                  "properties": ["zh-TW"]
                }
              }
            ],
            "warn": true
          }
        },
        "es": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "requiredProperties": {
            "items": [
              {
                "homepage_url": {
                  "properties": ["es"]
                }
              }
            ],
            "warn": true
          }
        },
        "th": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "requiredProperties": {
            "items": [
              {
                "homepage_url": {
                  "properties": ["th"]
                }
              }
            ],
            "warn": true
          }
        },
        "pt-BR": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "requiredProperties": {
            "items": [
              {
                "homepage_url": {
                  "properties": ["pt-BR"]
                }
              }
            ],
            "warn": true
          }
        },
        "ms": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "requiredProperties": {
            "items": [
              {
                "homepage_url": {
                  "properties": ["ms"]
                }
              }
            ],
            "warn": true
          }
        }
      },
      "required": ["en"]
    },
    "description": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "ja": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "en": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "zh": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "zh-TW": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "es": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "th": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "pt-BR": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "ms": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        }
      },
      "required": ["en"]
    },
    "icon": {
      "type": "string",
      "description": "internal only",
      "minLength": 1,
      "format": "relative-path",
      "maxFileSize": "20MB",
      "fileExists": true
    },
    "homepage_url": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "ja": {
          "type": "string",
          "minLength": 1,
          "format": "http-url",
          "requiredProperties": {
            "items": [
              {
                "name": {
                  "properties": ["ja"]
                }
              }
            ]
          }
        },
        "en": {
          "type": "string",
          "minLength": 1,
          "format": "http-url",
          "requiredProperties": {
            "items": [
              {
                "name": {
                  "properties": ["en"]
                }
              }
            ]
          }
        },
        "zh": {
          "type": "string",
          "minLength": 1,
          "format": "http-url",
          "requiredProperties": {
            "items": [
              {
                "name": {
                  "properties": ["zh"]
                }
              }
            ]
          }
        },
        "zh-TW": {
          "type": "string",
          "minLength": 1,
          "format": "http-url",
          "requiredProperties": {
            "items": [
              {
                "name": {
                  "properties": ["zh-TW"]
                }
              }
            ]
          }
        },
        "es": {
          "type": "string",
          "minLength": 1,
          "format": "http-url",
          "requiredProperties": {
            "items": [
              {
                "name": {
                  "properties": ["es"]
                }
              }
            ]
          }
        },
        "th": {
          "type": "string",
          "minLength": 1,
          "format": "http-url",
          "requiredProperties": {
            "items": [
              {
                "name": {
                  "properties": ["th"]
                }
              }
            ]
          }
        },
        "pt-BR": {
          "type": "string",
          "minLength": 1,
          "format": "http-url",
          "requiredProperties": {
            "items": [
              {
                "name": {
                  "properties": ["pt-BR"]
                }
              }
            ]
          }
        },
        "ms": {
          "type": "string",
          "minLength": 1,
          "format": "http-url",
          "requiredProperties": {
            "items": [
              {
                "name": {
                  "properties": ["ms"]
                }
              }
            ]
          }
        }
      }
    },
    "desktop": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "js": {
          "$ref": "#/definitions/resources"
        },
        "css": {
          "$ref": "#/definitions/resources"
        }
      }
    },
    "mobile": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "js": {
          "$ref": "#/definitions/resources"
        },
        "css": {
          "$ref": "#/definitions/resources"
        }
      }
    },
    "config": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "html": {
          "description": "internal only",
          "type": "string",
          "format": "relative-path",
          "maxFileSize": "65535B",
          "minLength": 1,
          "fileExists": true
        },
        "js": {
          "$ref": "#/definitions/resources"
        },
        "css": {
          "$ref": "#/definitions/resources"
        },
        "required_params": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          }
        }
      }
    },
    "sandbox": {
      "type": "boolean"
    },
    "allowed_hosts": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string",
        "minLength": 1,
        "description": "Either \"*\" or a URI with a scheme. Domain-level rules are enforced by kintone.",
        "anyOf": [{ "const": "*" }, { "format": "uri" }]
      }
    },
    "allowed_domains": {
      "type": "string",
      "description": "Cross-domain access scope inside cybozu products. Defaults to \"SELF\".",
      "enum": ["SELF", "ANY"]
    },
    "permissions": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "js_api": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "rest_api": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    }
  },
  "required": ["manifest_version", "version", "type", "name", "icon"],
  "allOf": [
    {
      "if": {
        "required": ["sandbox"],
        "properties": {
          "sandbox": { "const": true }
        }
      },
      "then": {
        "required": ["allowed_hosts", "permissions"]
      }
    }
  ],
  "definitions": {
    "resources": {
      "$id": "#resources",
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string",
        "anyOf": [
          {
            "format": "https-url"
          },
          {
            "format": "relative-path",
            "maxFileSize": "20MB",
            "fileExists": true
          }
        ]
      },
      "maxItems": 30
    }
  }
}
