{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://extension.js.org/contract/envelope-1.json",
  "title": "Extension.js CLI result envelope, schema 1",
  "type": "object",
  "required": [
    "schema",
    "ok",
    "command",
    "status",
    "value",
    "error",
    "warnings"
  ],
  "properties": {
    "schema": { "const": 1 },
    "ok": { "type": "boolean" },
    "command": { "type": "string", "minLength": 1 },
    "status": { "type": "string", "minLength": 1 },
    "value": {},
    "error": {
      "oneOf": [
        { "type": "null" },
        {
          "type": "object",
          "required": ["code", "message"],
          "properties": {
            "code": { "type": "string", "pattern": "^E_[A-Z0-9_]+$" },
            "message": { "type": "string" },
            "name": { "type": "string" },
            "engine": { "type": "string" },
            "hint": { "type": "string" },
            "refs": {
              "type": "object",
              "properties": {
                "flag": { "type": "string" },
                "command": { "type": "string" },
                "path": { "type": "string" },
                "version": { "type": "string" }
              }
            },
            "details": {
              "type": "array",
              "items": {
                "type": "object",
                "required": ["message", "severity"],
                "if": { "properties": { "severity": { "const": "error" } } },
                "then": { "properties": { "code": { "pattern": "^E_" } } },
                "else": { "properties": { "code": { "pattern": "^W_" } } },
                "properties": {
                  "code": { "type": "string", "pattern": "^[EW]_[A-Z0-9_]+$" },
                  "message": { "type": "string" },
                  "file": { "type": "string" },
                  "line": { "type": "integer" },
                  "column": { "type": "integer" },
                  "severity": { "enum": ["error", "warning"] },
                  "name": { "type": "string" }
                }
              }
            }
          }
        }
      ]
    },
    "truncated": { "type": "boolean" },
    "hint": { "type": "string" },
    "browser": { "type": "string", "minLength": 1 },
    "warnings": { "type": "array", "items": { "type": "string" } }
  },
  "additionalProperties": true
}
