{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://schema.dpksystem.cloud/Web/bootstrap.schema.json",
  "title": "USP Bootstrap Configuration",
  "description": "Minimalna konfiguracja pobierana przez frontend PRZED loginem. Deployment single-tenant.",
  "type": "object",
  "additionalProperties": false,
  "required": ["environment", "urls", "tenantKey"],

  "properties": {
    "$schema": {
      "type": "string",
      "format": "uri"
    },

    "environment": {
      "type": "string",
      "enum": ["development", "staging", "production"]
    },

    "generatedAt": {
      "type": "string",
      "format": "date-time"
    },

    "urls": {
      "type": "object",
      "additionalProperties": false,
      "required": ["openId", "webApi"],
      "properties": {
        "openId": {
          "type": "string",
          "format": "uri",
          "pattern": "^https?://"
        },
        "webApi": {
          "type": "string",
          "format": "uri",
          "pattern": "^https?://"
        },
        "assetsBase": {
          "type": "string",
          "format": "uri"
        }
      }
    },

    "tenantKey": {
      "type": "string",
      "pattern": "^[A-Z][A-Z0-9_]*$",
      "minLength": 2,
      "maxLength": 32,
      "description": "Statyczny tenant key dla tego deployment (np. 'KML')",
      "examples": ["KML", "MPK_LODZ", "GAIT", "DEFAULT"]
    },

    "features": {
      "type": "object",
      "additionalProperties": { "type": "boolean" },
      "description": "Bootstrap-time feature flags (rzadko używane)"
    },

    "apiTimeouts": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "tenantIdentityMs": {
          "type": "integer",
          "minimum": 500,
          "maximum": 30000,
          "default": 5000
        },
        "tenantConfigMs": {
          "type": "integer",
          "minimum": 500,
          "maximum": 30000,
          "default": 10000
        }
      }
    },

    "cacheStrategy": {
      "type": "string",
      "enum": ["aggressive", "normal", "none"],
      "default": "normal"
    }
  }
}
