{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "StageTrace CLI plugins response 1.0",
  "type": "object",
  "required": [
    "schemaVersion",
    "command",
    "status",
    "data",
    "errors",
    "warnings",
    "timingMs"
  ],
  "properties": {
    "schemaVersion": {
      "const": "1.0"
    },
    "command": {
      "const": "plugins"
    },
    "status": {
      "type": "string",
      "enum": [
        "ok",
        "error"
      ]
    },
    "data": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "bundledPluginPaths",
            "externalPluginPaths",
            "pluginSearchPath",
            "loadedPlugins",
            "missingPlugins",
            "loadedSchemas",
            "missingSchemaTypes",
            "resolver"
          ],
          "properties": {
            "bundledPluginPaths": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "externalPluginPaths": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "pluginSearchPath": {
              "type": "string"
            },
            "loadedPlugins": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "missingPlugins": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {},
                "additionalProperties": false
              }
            },
            "loadedSchemas": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {},
                "additionalProperties": false
              }
            },
            "missingSchemaTypes": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {},
                "additionalProperties": false
              }
            },
            "resolver": {
              "type": "object",
              "required": [
                "name",
                "contextSummary"
              ],
              "properties": {
                "name": {
                  "type": "string"
                },
                "contextSummary": {
                  "type": "string"
                }
              },
              "additionalProperties": false
            }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {},
          "additionalProperties": false
        }
      ]
    },
    "errors": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["code", "message"],
        "properties": {
          "code": {"type": "string"},
          "message": {"type": "string"}
        },
        "additionalProperties": false
      }
    },
    "timingMs": {
      "type": "number"
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "status": {
            "const": "ok"
          }
        },
        "required": [
          "status"
        ]
      },
      "then": {
        "properties": {
          "data": {
            "type": "object",
            "required": [
              "bundledPluginPaths",
              "externalPluginPaths",
              "pluginSearchPath",
              "loadedPlugins",
              "missingPlugins",
              "loadedSchemas",
              "missingSchemaTypes",
              "resolver"
            ],
            "properties": {
              "bundledPluginPaths": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "externalPluginPaths": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "pluginSearchPath": {
                "type": "string"
              },
              "loadedPlugins": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "missingPlugins": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {},
                  "additionalProperties": false
                }
              },
              "loadedSchemas": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {},
                  "additionalProperties": false
                }
              },
              "missingSchemaTypes": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {},
                  "additionalProperties": false
                }
              },
              "resolver": {
                "type": "object",
                "required": [
                  "name",
                  "contextSummary"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "contextSummary": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              }
            },
            "additionalProperties": false
          },
          "errors": {
            "type": "array",
            "maxItems": 0
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "status": {
            "const": "error"
          }
        },
        "required": [
          "status"
        ]
      },
      "then": {
        "properties": {
          "data": {
            "type": "object",
            "properties": {},
            "additionalProperties": false
          },
          "errors": {
            "type": "array",
            "minItems": 1
          }
        }
      }
    }
  ],
  "additionalProperties": false
}
