{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://echowerks.com/downloads/echowerks-project-file-v1.schema.json",
  "title": "EchoWerks Project File",
  "description": "Versioned interchange envelope shared by EchoWerks website and mobile applications.",
  "type": "object",
  "required": ["format", "formatVersion", "kind", "exportedAt"],
  "properties": {
    "format": { "const": "echowerks.project" },
    "formatVersion": { "const": "1.0.0" },
    "kind": { "enum": ["project", "collection"] },
    "exportedAt": { "type": "string", "format": "date-time" },
    "project": { "$ref": "#/$defs/project" },
    "projects": { "type": "array", "items": { "$ref": "#/$defs/project" } }
  },
  "allOf": [
    { "if": { "properties": { "kind": { "const": "project" } } }, "then": { "required": ["project"] } },
    { "if": { "properties": { "kind": { "const": "collection" } } }, "then": { "required": ["projects"] } }
  ],
  "$defs": {
    "project": {
      "type": "object",
      "required": ["id", "name", "projectType", "createdAt", "updatedAt", "source", "data"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "name": { "type": "string", "minLength": 1 },
        "projectType": { "enum": ["commercial-av", "crestron-home"] },
        "createdAt": { "type": "string", "format": "date-time" },
        "updatedAt": { "type": "string", "format": "date-time" },
        "source": {
          "type": "object",
          "required": ["app", "appVersion"],
          "properties": {
            "app": { "type": "string", "minLength": 1 },
            "appVersion": { "type": "string", "minLength": 1 }
          },
          "additionalProperties": true
        },
        "data": { "type": "object" }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
