{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://workspai.dev/schemas/infra-plan.v1.json",
  "title": "Workspai Infrastructure Plan",
  "type": "object",
  "required": [
    "schemaVersion",
    "generatedAt",
    "workspacePath",
    "strategy",
    "composePath",
    "envExamplePath",
    "services",
    "connectionEnv",
    "sources",
    "warnings"
  ],
  "properties": {
    "schemaVersion": {
      "const": "rapidkit.infra-plan.v1"
    },
    "generatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "workspacePath": {
      "type": "string",
      "minLength": 1
    },
    "workspaceName": {
      "type": "string",
      "minLength": 1
    },
    "contractPath": {
      "type": "string",
      "minLength": 1
    },
    "strategy": {
      "const": "sidecar"
    },
    "composePath": {
      "type": "string",
      "minLength": 1
    },
    "envExamplePath": {
      "type": "string",
      "minLength": 1
    },
    "services": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "displayName",
          "category",
          "image",
          "ports",
          "sources"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "displayName": {
            "type": "string",
            "minLength": 1
          },
          "category": {
            "type": "string",
            "minLength": 1
          },
          "image": {
            "type": "string",
            "minLength": 1
          },
          "ports": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "name",
                "host",
                "container"
              ],
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1
                },
                "host": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 65535
                },
                "container": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 65535
                }
              },
              "additionalProperties": false
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "kind",
                "value"
              ],
              "properties": {
                "kind": {
                  "enum": [
                    "module",
                    "env-var",
                    "override",
                    "contract-env"
                  ]
                },
                "value": {
                  "type": "string",
                  "minLength": 1
                },
                "project": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "additionalProperties": false
            }
          }
        },
        "additionalProperties": false
      }
    },
    "connectionEnv": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    },
    "sources": {
      "type": "object",
      "required": [
        "modules",
        "envVars",
        "overrides"
      ],
      "properties": {
        "modules": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "envVars": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "overrides": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "serviceEnvOverrides": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "additionalProperties": {
          "type": "string"
        }
      }
    }
  },
  "additionalProperties": true
}
